X-Git-Url: https://jfr.im/git/irc/unrealircd/unrealircd-webpanel.git/blobdiff_plain/55fd88eb5bc3006a975800bca93c05e51a1c8e9c..440ff671f07bf112f2371cbe7e1afb23f2f614b6:/Classes/class-hook.php diff --git a/Classes/class-hook.php b/Classes/class-hook.php index 97d06a1..2e9eb86 100644 --- a/Classes/class-hook.php +++ b/Classes/class-hook.php @@ -1,6 +1,66 @@ ""]; + * + * So when you call this hook, you must refer to the + * parameter by reference. For example: + * Hook::func(HOOKTYPE_NAVBAR, 'add_navbar_item'); + * + * function add_navbar_item(&$pages) // remember the & to use by reference + * { insert_hacks_here(); } + */ +define('HOOKTYPE_NAVBAR', 100); + +/** HOOKTYPE_PRE_HEADER + * + * This doesn't receive anything, however you must still specify an + * parameter for your hook function, because it's referring to memory. Sorry =] + * + * Currently this is only used by the "sql_auth" plugin by Valware in order to + * redirect users immediately to the login page. + * + * Putting HTML in this hook is not a good idea. + */ +define('HOOKTYPE_PRE_HEADER', 101); + +/** HOOKTYPE_PRE_OVERVIEW_CARD + * + * @param object $stats + * + * This is called before the initial cards have loaded in the overview. + * This lets you add your own HTML or whatever you like on the overview, + * new cards, whatever. + * + * The parameter is an object containing stats used in the overview. + * See "index.php" to see how it's used. + * + */ + +define('HOOKTYPE_PRE_OVERVIEW_CARD', 102); +/** HOOKTYPE_OVERVIEW_CARD + * + * @param object $stats + * + * This is called after the initial cards have loaded in the overview. + * This lets you add your own HTML or whatever you like on the overview, + * new cards, whatever. + * + * The parameter is an object containing stats used in the overview. + * See "index.php" to see how it's used. + * + */ + + +define('HOOKTYPE_OVERVIEW_CARD', 102); /** * Class for "Hook" @@ -39,10 +99,10 @@ class Hook { */ public static function run($Hook, &$args = array()) { - if (!empty(self::$actions[$Hook])) - foreach (self::$actions[$Hook] as &$f) - $f($args); - + if (!empty(self::$actions[$Hook])) + foreach (self::$actions[$Hook] as &$f) + $f($args); + } /** Calls a Hook @@ -51,7 +111,7 @@ class Hook { * @return void Does not return anything. */ public static function func($Hook, $function) - { + { self::$actions[$Hook][] = $function; } @@ -62,9 +122,9 @@ class Hook { */ public static function del($Hook, $function) - { + { for ($i = 0; isset(self::$actions[$Hook][$i]); $i++) - if (self::$actions[$Hook][$i] == $function) - array_splice(self::$actions[$Hook],$i); + if (self::$actions[$Hook][$i] == $function) + array_splice(self::$actions[$Hook],$i); } }