aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/event_tracer/main.inc.php
diff options
context:
space:
mode:
authorrvelices <rv-github@modusoptimus.com>2008-10-18 00:50:19 +0000
committerrvelices <rv-github@modusoptimus.com>2008-10-18 00:50:19 +0000
commit7a28366cba9fc1cb121df1f71f1bfe7b2dc835f0 (patch)
tree396cb7cb2960eea082e0b99ac41de3c46d55472a /plugins/event_tracer/main.inc.php
parent79d51b19c17138aef43f2c01a8e2f5230970bff1 (diff)
- event tracer improvement: option to show all registered event handlers for every page ...
git-svn-id: http://piwigo.org/svn/branches/2.0@2771 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to 'plugins/event_tracer/main.inc.php')
-rw-r--r--plugins/event_tracer/main.inc.php42
1 files changed, 39 insertions, 3 deletions
diff --git a/plugins/event_tracer/main.inc.php b/plugins/event_tracer/main.inc.php
index e80d29238..742bfd0ae 100644
--- a/plugins/event_tracer/main.inc.php
+++ b/plugins/event_tracer/main.inc.php
@@ -34,12 +34,11 @@ if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
class EventTracer
{
- var $me_working;
var $my_config;
+ var $trigger_counts = array();
function EventTracer()
{
- $this->me_working=0;
}
function get_config_file_dir()
@@ -67,6 +66,7 @@ class EventTracer
{
$this->my_config['filters'] = array( '.*' );
$this->my_config['show_args'] = false;
+ $this->my_config['show_registered'] = true;
$this->save_config();
}
}
@@ -82,6 +82,7 @@ class EventTracer
function on_pre_trigger_event($event_info)
{
+ @$this->trigger_counts[$event_info['event']]++;
$this->dump('pre_trigger_event', $event_info);
}
function on_post_trigger_event($event_info)
@@ -91,9 +92,43 @@ class EventTracer
function on_trigger_action($event_info)
{
+ @$this->trigger_counts[$event_info['event']]++;
$this->dump('trigger_action', $event_info);
}
+ function on_page_tail()
+ {
+ if (1 || @$this->my_config['show_registered'])
+ {
+ global $debug, $pwg_event_handlers;
+ $out = '';
+ foreach ($pwg_event_handlers as $event => $prio_array)
+ {
+ $out .= $event.' '.intval(@$this->trigger_counts[$event])." calls\n";
+ foreach ($prio_array as $prio => $handlers)
+ {
+ foreach ($handlers as $handler)
+ {
+ $out .= "\t$prio ";
+ if ( is_array($handler['function']) )
+ {
+ if ( is_string($handler['function'][0]) )
+ $out .= $handler['function'][0].'::';
+ else
+ $out .= @get_class($handler['function'][0]).'->';
+ $out .= $handler['function'][1];
+ }
+ else
+ $out .= $handler['function'];
+ $out .= "\n";
+ }
+ }
+ $out .= "\n";
+ }
+ $debug .= '<pre>'.$out.'</pre>';
+ }
+ }
+
function dump($event, $event_info)
{
foreach( $this->my_config['filters'] as $filter)
@@ -108,7 +143,7 @@ class EventTracer
}
else
$s = '';
- pwg_debug($event.' "'.$event_info['event'].'" '.($s) );
+ pwg_debug($event.' "'.$event_info['event'].'" '.($this->trigger_counts[$event_info['event']]).' calls '.($s) );
break;
}
}
@@ -132,6 +167,7 @@ $obj->load_config();
add_event_handler('get_admin_plugin_menu_links', array(&$obj, 'plugin_admin_menu') );
add_event_handler('pre_trigger_event', array(&$obj, 'on_pre_trigger_event') );
add_event_handler('post_trigger_event', array(&$obj, 'on_post_trigger_event') );
+add_event_handler('loc_begin_page_tail', array(&$obj, 'on_page_tail') );
add_event_handler('trigger_action', array(&$obj, 'on_trigger_action') );
set_plugin_data($plugin['id'], $obj);
?>