]>
git.wh0rd.org - tt-rss.git/blob - classes/pluginhost.php
d7926fa4e0bf62f5b3cd1224016fedaeed91bc18
4 private $hooks = array();
5 private $plugins = array();
7 const HOOK_ARTICLE_BUTTON
= 1;
8 const HOOK_ARTICLE_FILTER
= 2;
9 const HOOK_PREFS_TAB
= 3;
10 const HOOK_PREFS_SECTION
= 4;
12 function __construct($link) {
16 private function register_plugin($name, $plugin) {
17 //array_push($this->plugins, $plugin);
18 $this->plugins
[$name] = $plugin;
25 function get_plugins() {
26 return $this->plugins
;
29 function get_plugin($name) {
30 return $this->plugins
[$name];
33 function run_hooks($type, $method, $args) {
34 foreach ($this->get_hooks($type) as $hook) {
35 $hook->$method($args);
39 function add_hook($type, $sender) {
40 if (!is_array($this->hooks
[$type])) {
41 $this->hooks
[$type] = array();
44 array_push($this->hooks
[$type], $sender);
47 function del_hook($type, $sender) {
48 if (is_array($this->hooks
[$type])) {
49 $key = array_Search($this->hooks
[$type], $sender);
51 unset($this->hooks
[$type][$key]);
56 function get_hooks($type) {
57 return $this->hooks
[$type];
60 function load($classlist) {
61 $plugins = explode(",", $classlist);
63 foreach ($plugins as $class) {
64 $class = trim($class);
65 $class_file = str_replace("_", "/", strtolower(basename($class)));
66 $file = dirname(__FILE__
)."/../plugins/$class_file/$class_file.php";
68 if (file_exists($file)) require_once $file;
70 if (class_exists($class) && is_subclass_of($class, "Plugin")) {
71 $plugin = new $class($this);
73 $this->register_plugin($class, $plugin);