]>
git.wh0rd.org - tt-rss.git/blob - classes/pluginhost.php
4 private $hooks = array();
5 private $plugins = array();
7 const HOOK_ARTICLE_BUTTON
= 1;
8 const HOOK_ARTICLE_FILTER
= 2;
10 function __construct($link) {
14 private function register_plugin($name, $plugin) {
15 //array_push($this->plugins, $plugin);
16 $this->plugins
[$name] = $plugin;
23 function get_plugins() {
24 return $this->plugins
;
27 function get_plugin($name) {
28 return $this->plugins
[$name];
31 function add_hook($type, $sender) {
32 if (!is_array($this->hooks
[$type])) {
33 $this->hooks
[$type] = array();
36 array_push($this->hooks
[$type], $sender);
39 function del_hook($type, $sender) {
40 if (is_array($this->hooks
[$type])) {
41 $key = array_Search($this->hooks
[$type], $sender);
43 unset($this->hooks
[$type][$key]);
48 function get_hooks($type) {
49 return $this->hooks
[$type];
52 function load($classlist) {
53 $plugins = explode(",", $classlist);
55 foreach ($plugins as $class) {
56 $class = trim($class);
57 $class_file = str_replace("_", "/", strtolower(basename($class)));
58 $file = dirname(__FILE__
)."/../plugins/$class_file/$class_file.php";
60 if (file_exists($file)) require_once $file;
62 if (class_exists($class)) {
63 $plugin = new $class($this);
65 $this->register_plugin($class, $plugin);