Changeset 3136 for trunk/include/functions_plugins.inc.php
- Timestamp:
- Feb 13, 2009, 2:01:03 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/functions_plugins.inc.php
r3049 r3136 110 110 global $pwg_event_handlers; 111 111 112 // just for debugging 113 trigger_action('pre_trigger_event', 114 array('event'=>$event, 'data'=>$data) ); 112 if ( isset($pwg_event_handlers['trigger']) ) 113 {// just for debugging 114 trigger_action('trigger', 115 array('type'=>'event', 'event'=>$event, 'data'=>$data) ); 116 } 115 117 116 118 if ( !isset($pwg_event_handlers[$event]) ) 117 119 { 118 trigger_action('post_trigger_event',119 array('event'=>$event, 'data'=>$data) );120 120 return $data; 121 121 } … … 124 124 foreach ($pwg_event_handlers[$event] as $priority => $handlers) 125 125 { 126 if ( !is_null($handlers) ) 127 { 128 foreach($handlers as $handler) 129 { 130 $all_args = array_merge( array($data), $args); 131 $function_name = $handler['function']; 132 $accepted_args = $handler['accepted_args']; 133 134 if ( $accepted_args == 1 ) 135 $the_args = array($data); 136 elseif ( $accepted_args > 1 ) 137 $the_args = array_slice($all_args, 0, $accepted_args); 138 elseif ( $accepted_args == 0 ) 139 $the_args = NULL; 140 else 141 $the_args = $all_args; 142 143 $data = call_user_func_array($function_name, $the_args); 144 } 145 } 146 } 147 trigger_action('post_trigger_event', 148 array('event'=>$event, 'data'=>$data) ); 126 foreach($handlers as $handler) 127 { 128 $all_args = array_merge( array($data), $args); 129 $function_name = $handler['function']; 130 $accepted_args = $handler['accepted_args']; 131 132 if ( $accepted_args == 1 ) 133 $the_args = array($data); 134 elseif ( $accepted_args > 1 ) 135 $the_args = array_slice($all_args, 0, $accepted_args); 136 elseif ( $accepted_args == 0 ) 137 $the_args = NULL; 138 else 139 $the_args = $all_args; 140 141 $data = call_user_func_array($function_name, $the_args); 142 } 143 } 144 trigger_action('trigger', 145 array('type'=>'post_event', 'event'=>$event, 'data'=>$data) ); 149 146 return $data; 150 147 } … … 153 150 { 154 151 global $pwg_event_handlers; 155 if ($event!='pre_trigger_event' 156 and $event!='post_trigger_event' 157 and $event!='trigger_action') 152 if ( isset($pwg_event_handlers['trigger']) and $event!='trigger' ) 158 153 {// special case for debugging - avoid recursive calls 159 trigger_action('trigger _action',160 array(' event'=>$event, 'data'=>$data) );154 trigger_action('trigger', 155 array('type'=>'action', 'event'=>$event, 'data'=>$data) ); 161 156 } 162 157 … … 169 164 foreach ($pwg_event_handlers[$event] as $priority => $handlers) 170 165 { 171 if ( !is_null($handlers) ) 172 { 173 foreach($handlers as $handler) 174 { 175 $all_args = array_merge( array($data), $args); 176 $function_name = $handler['function']; 177 $accepted_args = $handler['accepted_args']; 178 179 if ( $accepted_args == 1 ) 180 $the_args = array($data); 181 elseif ( $accepted_args > 1 ) 182 $the_args = array_slice($all_args, 0, $accepted_args); 183 elseif ( $accepted_args == 0 ) 184 $the_args = NULL; 185 else 186 $the_args = $all_args; 187 188 call_user_func_array($function_name, $the_args); 189 } 166 foreach($handlers as $handler) 167 { 168 $all_args = array_merge( array($data), $args); 169 $function_name = $handler['function']; 170 $accepted_args = $handler['accepted_args']; 171 172 if ( $accepted_args == 1 ) 173 $the_args = array($data); 174 elseif ( $accepted_args > 1 ) 175 $the_args = array_slice($all_args, 0, $accepted_args); 176 elseif ( $accepted_args == 0 ) 177 $the_args = NULL; 178 else 179 $the_args = $all_args; 180 181 call_user_func_array($function_name, $the_args); 190 182 } 191 183 } … … 230 222 $query = ' 231 223 SELECT * FROM '.PLUGINS_TABLE; 232 if (!empty($state) or !empty($id) ) 233 { 234 $query .= ' 235 WHERE 1=1'; 236 if (!empty($state)) 237 { 224 $clauses = array(); 225 if (!empty($state)) 226 { 227 $clauses[] = 'state="'.$state.'"'; 228 } 229 if (!empty($id)) 230 { 231 $clauses[] = 'id="'.$id.'"'; 232 } 233 if (count($clauses)) 234 { 238 235 $query .= ' 239 AND state="'.$state.'"'; 240 } 241 if (!empty($id)) 242 { 243 $query .= ' 244 AND id="'.$id.'"'; 245 } 236 WHERE '. implode(' AND ', $clauses); 246 237 } 247 238
Note: See TracChangeset
for help on using the changeset viewer.