From c11907cad2aebf74b07a921e3d5f5473ec11e0cc Mon Sep 17 00:00:00 2001 From: Heikki Hokkanen Date: Sat, 10 Jan 2009 14:32:53 +0200 Subject: [PATCH] Moved plugin-related global stuff to VGPlugin class. --- inc/plugins.php | 34 +++++++++++++++++++--------------- templates/footer.php | 2 +- templates/header.php | 6 +++--- 3 files changed, 23 insertions(+), 19 deletions(-) diff --git a/inc/plugins.php b/inc/plugins.php index fd734b1..87049c9 100644 --- a/inc/plugins.php +++ b/inc/plugins.php @@ -1,17 +1,5 @@ plugin object -$plugin_hooks = array(); - -function call_hooks($type) { - global $plugin_hooks; - if (in_array($type, $plugin_hooks)) { - foreach ($plugin_hooks[$type] as $class) { - $class->hook($type); - } - } -} - /** * Base class plugins should extend. This defines the public, hopefully * somewhat static API plugins should be able to rely on. @@ -67,13 +55,29 @@ class VGPlugin * Registers the given action for this plugin. */ function register_action($action) { - global $plugin_actions; - $plugin_actions[$action] = $this; + self::$plugin_actions[$action] = $this; } function register_hook($type) { + self::$plugin_hooks[$type][] = $this; + } + + // Static members + methods + + public static $plugin_actions = array(); + public static $plugin_hooks = array(); + + /** + * Call plugin hooks of given type. + * @see VGPlugin::register_hook() + */ + static function call_hooks($type) { global $plugin_hooks; - $plugin_hooks[$type][] = $this; + if (in_array($type, self::$plugin_hooks)) { + foreach (self::$plugin_hooks[$type] as $class) { + $class->hook($type); + } + } } } diff --git a/templates/footer.php b/templates/footer.php index ae82f9f..7109661 100644 --- a/templates/footer.php +++ b/templates/footer.php @@ -2,7 +2,7 @@ if ($conf['ad']) { echo "
ViewGit
"; } -call_hooks('footer'); +VGPlugin::call_hooks('footer'); ?> diff --git a/templates/header.php b/templates/header.php index 7d57cd0..3171046 100644 --- a/templates/header.php +++ b/templates/header.php @@ -13,12 +13,12 @@ if (isset($page['project'])) { } ?> - + '; foreach ($page['notices'] as $n) { @@ -86,7 +86,7 @@ foreach ($links as $link => $params) { if ($page['action'] === $link) { echo ''; } $first = false; } -call_hooks('pagenav'); +VGPlugin::call_hooks('pagenav'); ?> |