-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');\r
-/**\r
- * CodeIgniter\r
- *\r
- * An open source application development framework for PHP 4.3.2 or newer\r
- *\r
- * @package CodeIgniter\r
- * @author ExpressionEngine Dev Team\r
- * @copyright Copyright (c) 2008, EllisLab, Inc.\r
- * @license http://codeigniter.com/user_guide/license.html\r
- * @link http://codeigniter.com\r
- * @since Version 1.0\r
- * @filesource\r
- */\r
-\r
-// ------------------------------------------------------------------------\r
-\r
-/**\r
- * CodeIgniter Hooks Class\r
- *\r
- * Provides a mechanism to extend the base system without hacking. Most of\r
- * this class is borrowed from Paul's Extension class in ExpressionEngine.\r
- *\r
- * @package CodeIgniter\r
- * @subpackage Libraries\r
- * @category Libraries\r
- * @author ExpressionEngine Dev Team\r
- * @link http://codeigniter.com/user_guide/libraries/encryption.html\r
- */\r
-class CI_Hooks {\r
- \r
- var $enabled = FALSE;\r
- var $hooks = array();\r
- var $in_progress = FALSE;\r
- \r
- /**\r
- * Constructor\r
- *\r
- */\r
- function CI_Hooks()\r
- {\r
- $this->_initialize(); \r
- log_message('debug', "Hooks Class Initialized");\r
- }\r
- \r
- // --------------------------------------------------------------------\r
-\r
- /**\r
- * Initialize the Hooks Preferences\r
- *\r
- * @access private\r
- * @return void\r
- */ \r
- function _initialize()\r
- {\r
- $CFG =& load_class('Config');\r
- \r
- // If hooks are not enabled in the config file\r
- // there is nothing else to do\r
- \r
- if ($CFG->item('enable_hooks') == FALSE)\r
- {\r
- return;\r
- }\r
- \r
- // Grab the "hooks" definition file.\r
- // If there are no hooks, we're done.\r
- \r
- @include(APPPATH.'config/hooks'.EXT);\r
- \r
- if ( ! isset($hook) OR ! is_array($hook))\r
- {\r
- return;\r
- }\r
-\r
- $this->hooks =& $hook;\r
- $this->enabled = TRUE;\r
- }\r
- \r
- // --------------------------------------------------------------------\r
-\r
- /**\r
- * Call Hook\r
- *\r
- * Calls a particular hook\r
- *\r
- * @access private\r
- * @param string the hook name\r
- * @return mixed\r
- */\r
- function _call_hook($which = '')\r
- {\r
- if ( ! $this->enabled OR ! isset($this->hooks[$which]))\r
- {\r
- return FALSE;\r
- }\r
- \r
- if (isset($this->hooks[$which][0]) AND is_array($this->hooks[$which][0]))\r
- {\r
- foreach ($this->hooks[$which] as $val)\r
- {\r
- $this->_run_hook($val);\r
- }\r
- }\r
- else\r
- {\r
- $this->_run_hook($this->hooks[$which]);\r
- }\r
- \r
- return TRUE;\r
- }\r
-\r
- // --------------------------------------------------------------------\r
-\r
- /**\r
- * Run Hook\r
- *\r
- * Runs a particular hook\r
- *\r
- * @access private\r
- * @param array the hook details\r
- * @return bool\r
- */\r
- function _run_hook($data)\r
- {\r
- if ( ! is_array($data))\r
- {\r
- return FALSE;\r
- }\r
- \r
- // -----------------------------------\r
- // Safety - Prevents run-away loops\r
- // -----------------------------------\r
- \r
- // If the script being called happens to have the same\r
- // hook call within it a loop can happen\r
- \r
- if ($this->in_progress == TRUE)\r
- {\r
- return;\r
- }\r
-\r
- // -----------------------------------\r
- // Set file path\r
- // -----------------------------------\r
- \r
- if ( ! isset($data['filepath']) OR ! isset($data['filename']))\r
- {\r
- return FALSE;\r
- }\r
- \r
- $filepath = APPPATH.$data['filepath'].'/'.$data['filename'];\r
- \r
- if ( ! file_exists($filepath))\r
- {\r
- return FALSE;\r
- }\r
- \r
- // -----------------------------------\r
- // Set class/function name\r
- // -----------------------------------\r
- \r
- $class = FALSE;\r
- $function = FALSE;\r
- $params = '';\r
- \r
- if (isset($data['class']) AND $data['class'] != '')\r
- {\r
- $class = $data['class'];\r
- }\r
-\r
- if (isset($data['function']))\r
- {\r
- $function = $data['function'];\r
- }\r
-\r
- if (isset($data['params']))\r
- {\r
- $params = $data['params'];\r
- }\r
- \r
- if ($class === FALSE AND $function === FALSE)\r
- {\r
- return FALSE;\r
- }\r
- \r
- // -----------------------------------\r
- // Set the in_progress flag\r
- // -----------------------------------\r
-\r
- $this->in_progress = TRUE;\r
- \r
- // -----------------------------------\r
- // Call the requested class and/or function\r
- // -----------------------------------\r
- \r
- if ($class !== FALSE)\r
- {\r
- if ( ! class_exists($class))\r
- {\r
- require($filepath);\r
- }\r
- \r
- $HOOK = new $class;\r
- $HOOK->$function($params);\r
- }\r
- else\r
- {\r
- if ( ! function_exists($function))\r
- {\r
- require($filepath);\r
- }\r
- \r
- $function($params);\r
- }\r
- \r
- $this->in_progress = FALSE;\r
- return TRUE;\r
- }\r
-\r
-}\r
-\r
-// END CI_Hooks class\r
-\r
-/* End of file Hooks.php */\r
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 4.3.2 or newer
+ *
+ * @package CodeIgniter
+ * @author ExpressionEngine Dev Team
+ * @copyright Copyright (c) 2008, EllisLab, Inc.
+ * @license http://codeigniter.com/user_guide/license.html
+ * @link http://codeigniter.com
+ * @since Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * CodeIgniter Hooks Class
+ *
+ * Provides a mechanism to extend the base system without hacking. Most of
+ * this class is borrowed from Paul's Extension class in ExpressionEngine.
+ *
+ * @package CodeIgniter
+ * @subpackage Libraries
+ * @category Libraries
+ * @author ExpressionEngine Dev Team
+ * @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();
+ log_message('debug', "Hooks Class Initialized");
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Initialize the Hooks Preferences
+ *
+ * @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;
+ }
+
+ $this->hooks =& $hook;
+ $this->enabled = TRUE;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Call Hook
+ *
+ * Calls a particular hook
+ *
+ * @access private
+ * @param string the hook name
+ * @return mixed
+ */
+ function _call_hook($which = '')
+ {
+ if ( ! $this->enabled OR ! isset($this->hooks[$which]))
+ {
+ return FALSE;
+ }
+
+ if (isset($this->hooks[$which][0]) AND is_array($this->hooks[$which][0]))
+ {
+ foreach ($this->hooks[$which] as $val)
+ {
+ $this->_run_hook($val);
+ }
+ }
+ else
+ {
+ $this->_run_hook($this->hooks[$which]);
+ }
+
+ return TRUE;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Run Hook
+ *
+ * Runs a particular hook
+ *
+ * @access private
+ * @param array the hook details
+ * @return bool
+ */
+ function _run_hook($data)
+ {
+ if ( ! is_array($data))
+ {
+ 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;
+ }
+
+ // -----------------------------------
+ // 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'];
+ }
+
+ if (isset($data['function']))
+ {
+ $function = $data['function'];
+ }
+
+ if (isset($data['params']))
+ {
+ $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);
+ }
+ else
+ {
+ if ( ! function_exists($function))
+ {
+ require($filepath);
+ }
+
+ $function($params);
+ }
+
+ $this->in_progress = FALSE;
+ return TRUE;
+ }
+
+}
+
+// END CI_Hooks class
+
+/* End of file Hooks.php */
/* Location: ./system/libraries/Hooks.php */
\ No newline at end of file