aboutsummaryrefslogtreecommitdiffstats
path: root/include/functions_plugins.inc.php
diff options
context:
space:
mode:
authorrvelices <rv-github@modusoptimus.com>2009-02-13 13:01:03 +0000
committerrvelices <rv-github@modusoptimus.com>2009-02-13 13:01:03 +0000
commit601134c57e736e4639d0c105c7948279d9563813 (patch)
tree7bfc44db1c9e336596c5b7324d9a491c8afa5c87 /include/functions_plugins.inc.php
parentd4914a344708d4020f7cee561e41503896da5260 (diff)
- 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/trunk@3136 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);