equal
deleted
inserted
replaced
25 * The list of hooks registered. |
25 * The list of hooks registered. |
26 * @var array |
26 * @var array |
27 * @access private |
27 * @access private |
28 */ |
28 */ |
29 |
29 |
30 var $hook_list; |
30 var $hook_list = array(); |
|
31 |
|
32 /** |
|
33 * List of hooks which are lambda (anonymous) functions |
|
34 * @var array |
|
35 * @access private |
|
36 */ |
|
37 |
|
38 var $hook_list_lambda = array(); |
|
39 |
|
40 /** |
|
41 * Temporary array which holds closures currently being called |
|
42 * @var array |
|
43 * @access private Technically public access, but seriously just don't touch it |
|
44 */ |
|
45 |
|
46 var $__current_hook = array(); |
31 |
47 |
32 /** |
48 /** |
33 * The list of plugins that should be loaded. Used only by common.php. |
49 * The list of plugins that should be loaded. Used only by common.php. |
34 * @var array |
50 * @var array |
35 * @access private |
51 * @access private |
102 * @param array Deprecated. |
118 * @param array Deprecated. |
103 */ |
119 */ |
104 |
120 |
105 function setHook($name, $dont_split = false) |
121 function setHook($name, $dont_split = false) |
106 { |
122 { |
|
123 if ( !empty($this->hook_list_lambda[$name]) ) |
|
124 { |
|
125 $this->__current_hook =& $this->hook_list_lambda[$name]; |
|
126 // This is kind of terrible right now, I'm not sure how to handle inheritance and such. |
|
127 $this->attachHook($name, 'foreach ( $plugins->__current_hook as $func ) { call_user_func($func); }; unset($plugins->__current_hook);'); |
|
128 } |
107 if ( !empty($this->hook_list[$name]) && is_array($this->hook_list[$name]) ) |
129 if ( !empty($this->hook_list[$name]) && is_array($this->hook_list[$name]) ) |
108 { |
130 { |
109 if ( $dont_split ) |
131 if ( $dont_split ) |
110 return $this->hook_list[$name]; |
132 return $this->hook_list[$name]; |
111 |
133 |
134 </code> |
156 </code> |
135 */ |
157 */ |
136 |
158 |
137 function attachHook($name, $code) |
159 function attachHook($name, $code) |
138 { |
160 { |
139 if ( !isset($this->hook_list[$name]) ) |
161 if ( is_callable($code) ) |
140 { |
162 { |
141 $this->hook_list[$name] = Array(); |
163 if ( !isset($this->hook_list_lambda[$name]) ) |
142 } |
164 { |
143 $this->hook_list[$name][] = $code; |
165 $this->hook_list_lambda[$name] = Array(); |
|
166 } |
|
167 $this->hook_list_lambda[$name][] = $code; |
|
168 } |
|
169 else |
|
170 { |
|
171 if ( !isset($this->hook_list[$name]) ) |
|
172 { |
|
173 $this->hook_list[$name] = Array(); |
|
174 } |
|
175 $this->hook_list[$name][] = $code; |
|
176 } |
144 } |
177 } |
145 |
178 |
146 /** |
179 /** |
147 * Tell whether a plugin is loaded or not. |
180 * Tell whether a plugin is loaded or not. |
148 * @param string The filename of the plugin |
181 * @param string The filename of the plugin |