]> git.wh0rd.org - tt-rss.git/blobdiff - classes/pluginhost.php
remove magpie, fix article filter plugins
[tt-rss.git] / classes / pluginhost.php
index 46415bd214874b18de66ebf37e9c153f9070d85d..25569302b672fc07377d98c555de249fdc1da598 100644 (file)
@@ -4,6 +4,7 @@ class PluginHost {
        private $hooks = array();
        private $plugins = array();
        private $handlers = array();
+       private $commands = array();
 
        const HOOK_ARTICLE_BUTTON = 1;
        const HOOK_ARTICLE_FILTER = 2;
@@ -56,7 +57,11 @@ class PluginHost {
        }
 
        function get_hooks($type) {
-               return $this->hooks[$type];
+               if (isset($this->hooks[$type])) {
+                       return $this->hooks[$type];
+               } else {
+                       return array();
+               }
        }
 
        function load($classlist) {
@@ -109,5 +114,44 @@ class PluginHost {
 
                return false;
        }
+
+       function add_command($command, $description, $sender) {
+               $command = "-" . str_replace("-", "_", strtolower($command));
+
+               $this->commands[$command] = array("description" => $description,
+                       "class" => $sender);
+       }
+
+       function del_command($command) {
+               $command = "-" . strtolower($command);
+
+               unset($this->commands[$command]);
+       }
+
+       function lookup_command($command) {
+               $command = "-" . strtolower($command);
+
+               if (is_array($this->commands[$command])) {
+                       return $this->commands[$command]["class"];
+               } else {
+                       return false;
+               }
+
+               return false;
+       }
+
+       function get_commands() {
+               return $this->commands;
+       }
+
+       function run_commands($args) {
+               foreach ($this->get_commands() as $command => $data) {
+                       if (in_array($command, $args)) {
+                               $command = str_replace("-", "", $command);
+                               $data["class"]->$command($args);
+                       }
+               }
+       }
+
 }
 ?>