aboutsummaryrefslogtreecommitdiffstats
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
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 '')
-rw-r--r--plugins/event_tracer/main.inc.php42
-rw-r--r--plugins/event_tracer/tracer_admin.php2
-rw-r--r--plugins/event_tracer/tracer_admin.tpl10
3 files changed, 50 insertions, 4 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);
?>
diff --git a/plugins/event_tracer/tracer_admin.php b/plugins/event_tracer/tracer_admin.php
index b17f2a301..6e5b864e0 100644
--- a/plugins/event_tracer/tracer_admin.php
+++ b/plugins/event_tracer/tracer_admin.php
@@ -17,6 +17,7 @@ if ( isset($_POST['eventTracer_filters']) )
else
$me->my_config['filters'] = array();
$me->my_config['show_args'] = isset($_POST['eventTracer_show_args']);
+ $me->my_config['show_registered'] = isset($_POST['eventTracer_show_registered']);
$me->save_config();
global $page;
array_push($page['infos'], 'event tracer options saved');
@@ -24,6 +25,7 @@ if ( isset($_POST['eventTracer_filters']) )
$template->assign('EVENT_TRACER_FILTERS', implode("\n", $me->my_config['filters'] ) );
$template->assign('EVENT_TRACER_SHOW_ARGS', $me->my_config['show_args'] ? 'checked="checked"' : '' );
$template->assign('U_LIST_EVENTS', get_admin_plugin_menu_link(dirname(__FILE__).'/event_list.php'));
+$template->assign('EVENT_TRACER_SHOW_REGISTERED', $me->my_config['show_registered'] ? 'checked="checked"' : '' );
//$template->assign_var('EVENT_TRACER_F_ACTION', $my_url);
diff --git a/plugins/event_tracer/tracer_admin.tpl b/plugins/event_tracer/tracer_admin.tpl
index 17d7e2b01..560459915 100644
--- a/plugins/event_tracer/tracer_admin.tpl
+++ b/plugins/event_tracer/tracer_admin.tpl
@@ -12,15 +12,23 @@ You can use this plugin to see what events is Piwigo calling.
<fieldset>
<legend>Event Tracer</legend>
-<label>Show event argument
+<label>Show event arguments
<input type="checkbox" name="eventTracer_show_args" {$EVENT_TRACER_SHOW_ARGS} />
</label>
+
<br/>
+
<label>Fill below a list of regular expressions (one per line).
An event will be logged if its name matches at least one expression in the list.
<textarea name="eventTracer_filters" id="eventTracer_filters"rows="10" cols="80">{$EVENT_TRACER_FILTERS}</textarea>
</label>
+<br/>
+
+<label>Show all registered handlers
+ <input type="checkbox" name="eventTracer_show_registered" {$EVENT_TRACER_SHOW_REGISTERED} />
+</label>
+
</fieldset>
<p><input class="submit" type="submit" value="Submit" /></p>