aboutsummaryrefslogtreecommitdiffstats
path: root/include/functions_plugins.inc.php
diff options
context:
space:
mode:
authorrvelices <rv-github@modusoptimus.com>2009-02-13 13:02:20 +0000
committerrvelices <rv-github@modusoptimus.com>2009-02-13 13:02:20 +0000
commitb77b4f0aba107444ad5003d4c6e9b72cb348a6ca (patch)
tree02ffed73dbc2c052da0df1e8f9f69efa119a7f44 /include/functions_plugins.inc.php
parentbd8b4f51bb68178ea48db2cd55b1ea3a15c63c45 (diff)
merge r3136 from trunk
- moved check upgrade feed code to admin/include/functions_upgrade.php - refactored some code (shorter and somehow faster - but nothing revolutionary) - decrease lost space in permalinks.tpl and hard coded column width (was illisible) git-svn-id: http://piwigo.org/svn/branches/2.0@3137 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to '')
-rw-r--r--include/functions_plugins.inc.php103
1 files changed, 47 insertions, 56 deletions
diff --git a/include/functions_plugins.inc.php b/include/functions_plugins.inc.php
index 14bb66271..5a5ea79e3 100644
--- a/include/functions_plugins.inc.php
+++ b/include/functions_plugins.inc.php
@@ -109,55 +109,50 @@ function trigger_event($event, $data=null)
{
global $pwg_event_handlers;
- // just for debugging
- trigger_action('pre_trigger_event',
- array('event'=>$event, 'data'=>$data) );
+ if ( isset($pwg_event_handlers['trigger']) )
+ {// just for debugging
+ trigger_action('trigger',
+ array('type'=>'event', 'event'=>$event, 'data'=>$data) );
+ }
if ( !isset($pwg_event_handlers[$event]) )
{
- trigger_action('post_trigger_event',
- array('event'=>$event, 'data'=>$data) );
return $data;
}
$args = array_slice(func_get_args(), 2);
foreach ($pwg_event_handlers[$event] as $priority => $handlers)
{
- if ( !is_null($handlers) )
+ foreach($handlers as $handler)
{
- foreach($handlers as $handler)
- {
- $all_args = array_merge( array($data), $args);
- $function_name = $handler['function'];
- $accepted_args = $handler['accepted_args'];
+ $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;
+ 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);
- }
+ $data = call_user_func_array($function_name, $the_args);
}
}
- trigger_action('post_trigger_event',
- array('event'=>$event, 'data'=>$data) );
+ trigger_action('trigger',
+ array('type'=>'post_event', 'event'=>$event, 'data'=>$data) );
return $data;
}
function trigger_action($event, $data=null)
{
global $pwg_event_handlers;
- if ($event!='pre_trigger_event'
- and $event!='post_trigger_event'
- and $event!='trigger_action')
+ if ( isset($pwg_event_handlers['trigger']) and $event!='trigger' )
{// special case for debugging - avoid recursive calls
- trigger_action('trigger_action',
- array('event'=>$event, 'data'=>$data) );
+ trigger_action('trigger',
+ array('type'=>'action', 'event'=>$event, 'data'=>$data) );
}
if ( !isset($pwg_event_handlers[$event]) )
@@ -168,25 +163,22 @@ function trigger_action($event, $data=null)
foreach ($pwg_event_handlers[$event] as $priority => $handlers)
{
- if ( !is_null($handlers) )
+ foreach($handlers as $handler)
{
- foreach($handlers as $handler)
- {
- $all_args = array_merge( array($data), $args);
- $function_name = $handler['function'];
- $accepted_args = $handler['accepted_args'];
+ $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;
+ 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, $the_args);
}
}
}
@@ -229,20 +221,19 @@ function get_db_plugins($state='', $id='')
{
$query = '
SELECT * FROM '.PLUGINS_TABLE;
- if (!empty($state) or !empty($id) )
+ $clauses = array();
+ if (!empty($state))
+ {
+ $clauses[] = 'state="'.$state.'"';
+ }
+ if (!empty($id))
+ {
+ $clauses[] = 'id="'.$id.'"';
+ }
+ if (count($clauses))
{
- $query .= '
-WHERE 1=1';
- if (!empty($state))
- {
- $query .= '
- AND state="'.$state.'"';
- }
- if (!empty($id))
- {
$query .= '
- AND id="'.$id.'"';
- }
+ WHERE '. implode(' AND ', $clauses);
}
$result = pwg_query($query);