summaryrefslogtreecommitdiff
path: root/classes
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2012-12-24 09:52:15 +0400
committerAndrew Dolgov <[email protected]>2012-12-24 09:52:15 +0400
commit73f28fe979c48a88eb7b4037d7f0f708f8177f4c (patch)
treec531dbb1e141219b4943e3ee8991d764172cb140 /classes
parent6cbe53c9f5e9c369977b737f897a621f00fba90b (diff)
add support for registering update.php commands; move rest of the self-updating stuff into updater plugin
Diffstat (limited to 'classes')
-rw-r--r--classes/pluginhost.php40
1 files changed, 40 insertions, 0 deletions
diff --git a/classes/pluginhost.php b/classes/pluginhost.php
index 46415bd21..027d07539 100644
--- a/classes/pluginhost.php
+++ b/classes/pluginhost.php
@@ -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;
@@ -109,5 +110,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);
+ }
+ }
+ }
+
}
?>