summaryrefslogtreecommitdiffstats
path: root/system/libraries/Hooks.php
diff options
context:
space:
mode:
authorDerek Allard <derek.allard@ellislab.com>2007-04-15 19:41:17 +0200
committerDerek Allard <derek.allard@ellislab.com>2007-04-15 19:41:17 +0200
commitd2df9bc7cc9d4b3e53818470c5d0977c9a36677c (patch)
tree23c0794fefaa6860ec997813fefb9c64fcee1983 /system/libraries/Hooks.php
parent9613e2c136c96fbb1d055b36a0a5055811f03451 (diff)
update pMachine to EllisLab
update copyright year update Code Igniter to CodeIgniter
Diffstat (limited to 'system/libraries/Hooks.php')
-rw-r--r--system/libraries/Hooks.php446
1 files changed, 223 insertions, 223 deletions
diff --git a/system/libraries/Hooks.php b/system/libraries/Hooks.php
index 99d2e3e30..bb06fceeb 100644
--- a/system/libraries/Hooks.php
+++ b/system/libraries/Hooks.php
@@ -1,224 +1,224 @@
-<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
-/**
- * Code Igniter
- *
- * An open source application development framework for PHP 4.3.2 or newer
- *
- * @package CodeIgniter
- * @author Rick Ellis
- * @copyright Copyright (c) 2006, pMachine, Inc.
- * @license http://www.codeignitor.com/user_guide/license.html
- * @link http://www.codeigniter.com
- * @since Version 1.0
- * @filesource
- */
-
-// ------------------------------------------------------------------------
-
-/**
- * Code Igniter 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 Rick Ellis
- * @link http://www.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
+<?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 Rick Ellis
+ * @copyright Copyright (c) 2006, EllisLab, Inc.
+ * @license http://www.codeignitor.com/user_guide/license.html
+ * @link http://www.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 Rick Ellis
+ * @link http://www.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
?> \ No newline at end of file