diff options
author | rvelices <rv-github@modusoptimus.com> | 2007-02-09 01:41:49 +0000 |
---|---|---|
committer | rvelices <rv-github@modusoptimus.com> | 2007-02-09 01:41:49 +0000 |
commit | 0333119b79f2a1cae08d4d66dda04a91944ae62b (patch) | |
tree | c1bf64aa8f006c0b2ac02c668c0d655a340add3d | |
parent | 5b038de71715c8ec006abffe9d23c4172b71d0ba (diff) |
- added plugin action loc_end_picture
- enhanced the event tracer plugin to show a list of all events and actions trigered by pwg
- small reorganization in picture.php
git-svn-id: http://piwigo.org/svn/trunk@1793 68402e56-0260-453c-a942-63ccdbb3a9ee
-rw-r--r-- | picture.php | 60 | ||||
-rw-r--r-- | plugins/event_tracer/event_list.php | 89 | ||||
-rw-r--r-- | plugins/event_tracer/event_list.tpl | 16 | ||||
-rw-r--r-- | plugins/event_tracer/tracer_admin.php | 4 | ||||
-rw-r--r-- | plugins/event_tracer/tracer_admin.tpl | 2 |
5 files changed, 136 insertions, 35 deletions
diff --git a/picture.php b/picture.php index 1200e4c33..e033fca7c 100644 --- a/picture.php +++ b/picture.php @@ -69,9 +69,9 @@ function default_picture_content($content, $element_info) { // nothing to do return $content; } - - global $user; - + + global $user, $page; + $my_template = new Template( PHPWG_ROOT_PATH.'template/'.$user['template'], $user['theme'] @@ -80,7 +80,7 @@ function default_picture_content($content, $element_info) array('default_content'=>'picture_content.tpl') ); - if (isset($element_info['high_url'])) + if ( !isset($page['slideshow']) and isset($element_info['high_url']) ) { $uuid = uniqid(rand()); $my_template->assign_block_vars( @@ -429,21 +429,30 @@ $url_slide = add_url_params( array( 'slideshow'=>$conf['slideshow_period'] ) ); -$title = $picture['current']['name']; -$refresh = 0; -if ( isset( $_GET['slideshow'] ) and isset($page['next_item']) ) -{ - // $redirect_msg, $refresh, $url_link and $title are required for creating - // an automated refresh page in header.tpl - $refresh= $_GET['slideshow']; - $url_link = add_url_params( - $picture['next']['url'], - array('slideshow'=>$refresh) - ); - $redirect_msg = nl2br(l10n('redirect_msg')); + +$template->set_filename('picture', 'picture.tpl'); +if ( isset( $_GET['slideshow'] ) ) +{ $page['meta_robots']=array('noindex'=>1, 'nofollow'=>1); + $page['slideshow'] = true; + if ( $conf['light_slideshow'] ) + { + $template->set_filename('picture', 'slideshow.tpl'); + } + if ( isset($page['next_item']) ) + { + // $redirect_msg, $refresh, $url_link and $title are required for creating + // an automated refresh page in header.tpl + $refresh= $_GET['slideshow']; + $url_link = add_url_params( + $picture['next']['url'], + array('slideshow'=>$refresh) + ); + $redirect_msg = nl2br(l10n('redirect_msg')); + } } +$title = $picture['current']['name']; $title_nb = ($page['current_rank'] + 1).'/'.$page['cat_nb_images']; // metadata @@ -473,22 +482,6 @@ if ($metadata_showable) $page['body_id'] = 'thePicturePage'; -//------------------------------------------------------------ light slideshow -// Warning !!! Warning !!! Warning !!! -// Notice for plugins writers check if you have to act on the active template -// like this if ( $page['slideshow'] ) { return false; } -// -if ( isset($_GET['slideshow']) and $conf['light_slideshow'] ) -{ - $page['display_tpl'] = 'slideshow.tpl'; - $page['slideshow'] = true; - unset($picture['current']['high_url']); -} -else { - $page['display_tpl'] = 'picture.tpl'; - $page['slideshow'] = false; -} - // maybe someone wants a special display (call it before page_header so that // they can add stylesheets) $element_content = trigger_event( @@ -508,8 +501,6 @@ if (isset($picture['next']['image_url']) ); } -$template->set_filenames(array( 'picture' => $page['display_tpl'] )); - //------------------------------------------------------- navigation management foreach (array('first','previous','next','last') as $which_image) { @@ -837,6 +828,7 @@ if ($metadata_showable and isset($_GET['metadata'])) pwg_log($picture['current']['id']); include(PHPWG_ROOT_PATH.'include/page_header.php'); +trigger_action('loc_end_picture'); $template->parse('picture'); include(PHPWG_ROOT_PATH.'include/page_tail.php'); ?> diff --git a/plugins/event_tracer/event_list.php b/plugins/event_tracer/event_list.php new file mode 100644 index 000000000..1f1969629 --- /dev/null +++ b/plugins/event_tracer/event_list.php @@ -0,0 +1,89 @@ +<?php +if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); + +function get_php_files($path, $to_ignore=array(), $recursive=true ) +{ + $files = array(); + if (is_dir($path)) + { + if ($contents = opendir($path)) + { + while (($node = readdir($contents)) !== false) + { + if ($node != '.' and $node != '..' and $node != '.svn' + and !in_array($node, $to_ignore) ) + { + if ( $recursive and is_dir($path.'/'.$node) ) + { + $files = array_merge($files, get_php_files($path.'/'.$node, $to_ignore)); + + } + if ( is_file($path.'/'.$node) ) + { + $files[] = $path.'/'.$node; + } + } + } + closedir($contents); + } + } + return $files; +} + +$files = array(); +$files = array_merge( $files, get_php_files('.', array(), false) ); +$files = array_merge( $files, get_php_files('./include') ); +$files = array_merge( $files, get_php_files('./admin') ); +$files = array_unique($files); + +$events = array(); +foreach ($files as $file) +{ + $code = file_get_contents($file); + $code = preg_replace( '#\?'.'>.*<\?php#m', '', $code); + $code = preg_replace( '#\/\*.*\*\/#m', '', $code); + $code = preg_replace( '#\/\/.*#', '', $code); + + $count = preg_match_all( + '#[^a-zA-Z_$-]trigger_(action|event)\s*\(\s*([^,)]+)#m', + $code, $matches + ); + + for ($i=0; $i<$count; $i++) + { + $type = $matches[1][$i]; + $name = preg_replace( '#^[\'"]?([^\'"]*)[\'"]?$#', '$1', $matches[2][$i]); + array_push($events, array($type,$name,$file) ); + } +} + +$sort= isset($_GET['sort']) ? $_GET['sort'] : 1; +usort( + $events, + create_function( '$a,$b', 'return $a['.$sort.']>$b['.$sort.'];' ) + ); + +global $template; + +$url = get_admin_plugin_menu_link(__FILE__); + +$template->assign_vars( array( + 'NB_EVENTS' => count($events), + 'U_SORT0' => add_url_params($url, array('sort'=>0) ), + 'U_SORT1' => add_url_params($url, array('sort'=>1) ), + 'U_SORT2' => add_url_params($url, array('sort'=>2) ), + ) ); + +foreach ($events as $e) +{ + $template->assign_block_vars( 'event', array( + 'TYPE' => $e[0], + 'NAME' => $e[1], + 'FILE' => $e[2], + ) + ); +} + +$template->set_filenames( array('event_list' => dirname(__FILE__).'/event_list.tpl' ) ); +$template->assign_var_from_handle( 'ADMIN_CONTENT', 'event_list'); +?> diff --git a/plugins/event_tracer/event_list.tpl b/plugins/event_tracer/event_list.tpl new file mode 100644 index 000000000..8ec507395 --- /dev/null +++ b/plugins/event_tracer/event_list.tpl @@ -0,0 +1,16 @@ +There are {NB_EVENTS} calls to triger_event or triger_action. + +<table width="99%" class="table2"> +<tr class="throw"> + <th><a href="{U_SORT0}">Type</a></th> + <th><a href="{U_SORT1}">Name</a></th> + <th><a href="{U_SORT2}">File</a></th> +</tr> +<!-- BEGIN event --> +<tr> + <td>{event.TYPE}</td> + <td>{event.NAME}</td> + <td>{event.FILE}</td> +</tr> +<!-- END event --> +</table> diff --git a/plugins/event_tracer/tracer_admin.php b/plugins/event_tracer/tracer_admin.php index 2495c0dc0..5b405ba5a 100644 --- a/plugins/event_tracer/tracer_admin.php +++ b/plugins/event_tracer/tracer_admin.php @@ -23,7 +23,9 @@ if ( isset($_POST['eventTracer_filters']) ) } $template->assign_var('EVENT_TRACER_FILTERS', implode("\n", $me->my_config['filters'] ) ); $template->assign_var('EVENT_TRACER_SHOW_ARGS', $me->my_config['show_args'] ? 'checked="checked"' : '' ); +$template->assign_var('U_LIST_EVENTS', get_admin_plugin_menu_link(dirname(__FILE__).'/event_list.php')); + //$template->assign_var('EVENT_TRACER_F_ACTION', $my_url); $template->assign_var_from_handle( 'ADMIN_CONTENT', 'plugin_admin_content'); -?>
\ No newline at end of file +?> diff --git a/plugins/event_tracer/tracer_admin.tpl b/plugins/event_tracer/tracer_admin.tpl index 93deee3b0..980799992 100644 --- a/plugins/event_tracer/tracer_admin.tpl +++ b/plugins/event_tracer/tracer_admin.tpl @@ -23,4 +23,6 @@ An event will be logged if its name matches at least one expression in the list. </fieldset> <p><input type="submit" value="Submit" /></p> + +<p><a href="{U_LIST_EVENTS}">Click here to see a complete list of actions and events trigered by this PWG version</a>.</p> </form> |