X-Git-Url: http://git.onelab.eu/?p=www-register-wizard.git;a=blobdiff_plain;f=libraries%2FHooks.php;h=0b5d468099ea0ef6b154627c33889fcce342e970;hp=76584a7f923267b45a8248126a0f3943950ce76e;hb=47598daa8c32dbbd72db83dc33f2ce91b3f6f7b0;hpb=4afb2fe256f094a1caf6bff14f51c6a88938cc9f diff --git a/libraries/Hooks.php b/libraries/Hooks.php index 76584a7..0b5d468 100644 --- a/libraries/Hooks.php +++ b/libraries/Hooks.php @@ -6,7 +6,7 @@ * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2009, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 @@ -28,21 +28,21 @@ * @link http://codeigniter.com/user_guide/libraries/encryption.html */ class CI_Hooks { - + var $enabled = FALSE; var $hooks = array(); var $in_progress = FALSE; - + /** * Constructor * */ function CI_Hooks() { - $this->_initialize(); + $this->_initialize(); log_message('debug', "Hooks Class Initialized"); } - + // -------------------------------------------------------------------- /** @@ -50,24 +50,24 @@ class CI_Hooks { * * @access private * @return void - */ + */ function _initialize() { $CFG =& load_class('Config'); - + // If hooks are not enabled in the config file // there is nothing else to do - + if ($CFG->item('enable_hooks') == FALSE) { return; } - + // Grab the "hooks" definition file. // If there are no hooks, we're done. - + @include(APPPATH.'config/hooks'.EXT); - + if ( ! isset($hook) OR ! is_array($hook)) { return; @@ -76,7 +76,7 @@ class CI_Hooks { $this->hooks =& $hook; $this->enabled = TRUE; } - + // -------------------------------------------------------------------- /** @@ -94,7 +94,7 @@ class CI_Hooks { { return FALSE; } - + if (isset($this->hooks[$which][0]) AND is_array($this->hooks[$which][0])) { foreach ($this->hooks[$which] as $val) @@ -106,7 +106,7 @@ class CI_Hooks { { $this->_run_hook($this->hooks[$which]); } - + return TRUE; } @@ -127,14 +127,14 @@ class CI_Hooks { { return FALSE; } - + // ----------------------------------- // Safety - Prevents run-away loops // ----------------------------------- - + // If the script being called happens to have the same // hook call within it a loop can happen - + if ($this->in_progress == TRUE) { return; @@ -143,27 +143,27 @@ class CI_Hooks { // ----------------------------------- // Set file path // ----------------------------------- - + if ( ! isset($data['filepath']) OR ! isset($data['filename'])) { return FALSE; } - + $filepath = APPPATH.$data['filepath'].'/'.$data['filename']; - + if ( ! file_exists($filepath)) { return FALSE; } - + // ----------------------------------- // Set class/function name // ----------------------------------- - + $class = FALSE; $function = FALSE; $params = ''; - + if (isset($data['class']) AND $data['class'] != '') { $class = $data['class']; @@ -178,29 +178,29 @@ class CI_Hooks { { $params = $data['params']; } - + if ($class === FALSE AND $function === FALSE) { return FALSE; } - + // ----------------------------------- // Set the in_progress flag // ----------------------------------- $this->in_progress = TRUE; - + // ----------------------------------- // Call the requested class and/or function // ----------------------------------- - + if ($class !== FALSE) { if ( ! class_exists($class)) { require($filepath); } - + $HOOK = new $class; $HOOK->$function($params); } @@ -210,10 +210,10 @@ class CI_Hooks { { require($filepath); } - + $function($params); } - + $this->in_progress = FALSE; return TRUE; }