mirror of
https://github.com/Piwigo/Piwigo.git
synced 2025-04-27 19:59:56 +03:00
- faster trigger_event/trigger_action (it was overly complicated)
- added a new param to get_thumbnail_url event - get_thumbnail_location is called only if the thumbnail does not exist git-svn-id: http://piwigo.org/svn/trunk@8263 68402e56-0260-453c-a942-63ccdbb3a9ee
This commit is contained in:
parent
70b02e28f1
commit
7d75444761
2 changed files with 12 additions and 34 deletions
|
@ -119,26 +119,16 @@ function trigger_event($event, $data=null)
|
|||
{
|
||||
return $data;
|
||||
}
|
||||
$args = array_slice(func_get_args(), 2);
|
||||
$args = func_get_args();
|
||||
|
||||
foreach ($pwg_event_handlers[$event] as $priority => $handlers)
|
||||
{
|
||||
foreach($handlers as $handler)
|
||||
{
|
||||
$all_args = array_merge( array($data), $args);
|
||||
$function_name = $handler['function'];
|
||||
$accepted_args = $handler['accepted_args'];
|
||||
|
||||
if ( $accepted_args == 1 )
|
||||
$the_args = array($data);
|
||||
elseif ( $accepted_args > 1 )
|
||||
$the_args = array_slice($all_args, 0, $accepted_args);
|
||||
elseif ( $accepted_args == 0 )
|
||||
$the_args = NULL;
|
||||
else
|
||||
$the_args = $all_args;
|
||||
|
||||
$data = call_user_func_array($function_name, $the_args);
|
||||
$args[1] = $data;
|
||||
$data = call_user_func_array($function_name, array_slice($args,1,$accepted_args) );
|
||||
}
|
||||
}
|
||||
trigger_action('trigger',
|
||||
|
@ -159,26 +149,16 @@ function trigger_action($event, $data=null)
|
|||
{
|
||||
return;
|
||||
}
|
||||
$args = array_slice(func_get_args(), 2);
|
||||
$args = func_get_args();
|
||||
|
||||
foreach ($pwg_event_handlers[$event] as $priority => $handlers)
|
||||
{
|
||||
foreach($handlers as $handler)
|
||||
{
|
||||
$all_args = array_merge( array($data), $args);
|
||||
$function_name = $handler['function'];
|
||||
$accepted_args = $handler['accepted_args'];
|
||||
|
||||
if ( $accepted_args == 1 )
|
||||
$the_args = array($data);
|
||||
elseif ( $accepted_args > 1 )
|
||||
$the_args = array_slice($all_args, 0, $accepted_args);
|
||||
elseif ( $accepted_args == 0 )
|
||||
$the_args = NULL;
|
||||
else
|
||||
$the_args = $all_args;
|
||||
|
||||
call_user_func_array($function_name, $the_args);
|
||||
call_user_func_array($function_name, array_slice($args,1,$accepted_args) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue