Public Member Functions | |
| CI_Hooks () | |
| Constructor. | |
| _initialize () | |
| Initialize the Hooks Preferences. | |
| _call_hook ($which= '') | |
| Call Hook. | |
| _run_hook ($data) | |
| Run Hook. | |
Public Attributes | |
| $enabled = FALSE | |
| $hooks = array() | |
| $in_progress = FALSE | |
Definition at line 30 of file Hooks.php.
| CI_Hooks::_call_hook | ( | $ | which = '' |
) |
Call Hook.
Calls a particular hook
private
| string | the hook name |
Definition at line 91 of file Hooks.php.
References _run_hook().
00092 { 00093 if ( ! $this->enabled OR ! isset($this->hooks[$which])) 00094 { 00095 return FALSE; 00096 } 00097 00098 if (isset($this->hooks[$which][0]) AND is_array($this->hooks[$which][0])) 00099 { 00100 foreach ($this->hooks[$which] as $val) 00101 { 00102 $this->_run_hook($val); 00103 } 00104 } 00105 else 00106 { 00107 $this->_run_hook($this->hooks[$which]); 00108 } 00109 00110 return TRUE; 00111 }

| CI_Hooks::_initialize | ( | ) |
Initialize the Hooks Preferences.
private
Definition at line 54 of file Hooks.php.
References $CFG, and load_class().
Referenced by CI_Hooks().
00055 { 00056 $CFG =& load_class('Config'); 00057 00058 // If hooks are not enabled in the config file 00059 // there is nothing else to do 00060 00061 if ($CFG->item('enable_hooks') == FALSE) 00062 { 00063 return; 00064 } 00065 00066 // Grab the "hooks" definition file. 00067 // If there are no hooks, we're done. 00068 00069 @include(APPPATH.'config/hooks'.EXT); 00070 00071 if ( ! isset($hook) OR ! is_array($hook)) 00072 { 00073 return; 00074 } 00075 00076 $this->hooks =& $hook; 00077 $this->enabled = TRUE; 00078 }


| CI_Hooks::_run_hook | ( | $ | data | ) |
Run Hook.
Runs a particular hook
private
| array | the hook details |
Definition at line 124 of file Hooks.php.
References $class.
Referenced by _call_hook().
00125 { 00126 if ( ! is_array($data)) 00127 { 00128 return FALSE; 00129 } 00130 00131 // ----------------------------------- 00132 // Safety - Prevents run-away loops 00133 // ----------------------------------- 00134 00135 // If the script being called happens to have the same 00136 // hook call within it a loop can happen 00137 00138 if ($this->in_progress == TRUE) 00139 { 00140 return; 00141 } 00142 00143 // ----------------------------------- 00144 // Set file path 00145 // ----------------------------------- 00146 00147 if ( ! isset($data['filepath']) OR ! isset($data['filename'])) 00148 { 00149 return FALSE; 00150 } 00151 00152 $filepath = APPPATH.$data['filepath'].'/'.$data['filename']; 00153 00154 if ( ! file_exists($filepath)) 00155 { 00156 return FALSE; 00157 } 00158 00159 // ----------------------------------- 00160 // Set class/function name 00161 // ----------------------------------- 00162 00163 $class = FALSE; 00164 $function = FALSE; 00165 $params = ''; 00166 00167 if (isset($data['class']) AND $data['class'] != '') 00168 { 00169 $class = $data['class']; 00170 } 00171 00172 if (isset($data['function'])) 00173 { 00174 $function = $data['function']; 00175 } 00176 00177 if (isset($data['params'])) 00178 { 00179 $params = $data['params']; 00180 } 00181 00182 if ($class === FALSE AND $function === FALSE) 00183 { 00184 return FALSE; 00185 } 00186 00187 // ----------------------------------- 00188 // Set the in_progress flag 00189 // ----------------------------------- 00190 00191 $this->in_progress = TRUE; 00192 00193 // ----------------------------------- 00194 // Call the requested class and/or function 00195 // ----------------------------------- 00196 00197 if ($class !== FALSE) 00198 { 00199 if ( ! class_exists($class)) 00200 { 00201 require($filepath); 00202 } 00203 00204 $HOOK = new $class; 00205 $HOOK->$function($params); 00206 } 00207 else 00208 { 00209 if ( ! function_exists($function)) 00210 { 00211 require($filepath); 00212 } 00213 00214 $function($params); 00215 } 00216 00217 $this->in_progress = FALSE; 00218 return TRUE; 00219 }

| CI_Hooks::CI_Hooks | ( | ) |
Constructor.
Definition at line 40 of file Hooks.php.
References _initialize(), and log_message().
00041 { 00042 $this->_initialize(); 00043 log_message('debug', "Hooks Class Initialized"); 00044 }
