Index: trunk/admin/include/functions_plugins.inc.php
===================================================================
--- trunk/admin/include/functions_plugins.inc.php	(revision 1589)
+++ trunk/admin/include/functions_plugins.inc.php	(revision 1590)
@@ -39,9 +39,9 @@
       if (is_dir($path) and !is_link($path)
           and preg_match('/^[a-zA-Z0-9-_]+$/', $file )
-          and file_exists($path.'/index.php')
+          and file_exists($path.'/main.inc.php')
           )
       {
         $plugin = array('name'=>'?', 'version'=>'0', 'uri'=>'', 'description'=>'');
-        $plg_data = implode( '', file($path.'/index.php') );
+        $plg_data = implode( '', file($path.'/main.inc.php') );
 
         if ( preg_match("|Plugin Name: (.*)|i", $plg_data, $val) )
@@ -73,6 +73,24 @@
 {
   global $page;
-
-  $uid = md5( var_export($func, true) );
+  if ( is_array( $func) )
+  {
+    $s = '';
+    foreach( $func as $e)
+    {
+      if (is_object($e))
+      {
+        $s.=get_class($e)."\n";
+      }
+      else
+      {
+        $s.=$e;
+      }
+    }
+    $uid = md5( $s );
+  }
+  else
+  {
+    $uid = md5( $func );
+  }
   $page['plugin_admin_menu'][] =
     array(
Index: trunk/admin/plugin.php
===================================================================
--- trunk/admin/plugin.php	(revision 1589)
+++ trunk/admin/plugin.php	(revision 1590)
@@ -37,5 +37,5 @@
 $template->set_filenames(array('plugin' => 'admin/plugin.tpl'));
 
-trigger_event('plugin_admin_menu');
+trigger_action('plugin_admin_menu');
 
 
Index: trunk/admin/plugins.php
===================================================================
--- trunk/admin/plugins.php	(revision 1589)
+++ trunk/admin/plugins.php	(revision 1590)
@@ -163,5 +163,5 @@
 $template->set_filenames(array('plugins' => 'admin/plugins.tpl'));
 
-trigger_event('plugin_admin_menu');
+trigger_action('plugin_admin_menu');
 
 $template->assign_block_vars('plugin_menu.menu_item',
Index: trunk/include/functions_plugins.inc.php
===================================================================
--- trunk/include/functions_plugins.inc.php	(revision 1589)
+++ trunk/include/functions_plugins.inc.php	(revision 1590)
@@ -36,15 +36,20 @@
 define('PHPWG_PLUGINS_PATH',PHPWG_ROOT_PATH.'plugins/');
 
+define('EVENT_HANDLER_PRIORITY_NEUTRAL', 50);
+
 /* Register a event handler.
  * @param string $event the name of the event to listen to
  * @param mixed $func the function that will handle the event
-*/
-function add_event_handler($event, $func, $priority=50, $accepted_args=1)
-{
-  global $pwg_event_handlers;
-
-  if ( isset($pwg_event_handlers[$event]["$priority"]) )
-  {
-    foreach($pwg_event_handlers[$event]["$priority"] as $handler)
+ * @param int $priority optional priority (greater priority will
+ * be executed at last)
+*/
+function add_event_handler($event, $func,
+    $priority=EVENT_HANDLER_PRIORITY_NEUTRAL, $accepted_args=1)
+{
+  global $pwg_event_handlers;
+
+  if ( isset($pwg_event_handlers[$event][$priority]) )
+  {
+    foreach($pwg_event_handlers[$event][$priority] as $handler)
     {
       if ( $handler['function'] == $func )
@@ -55,16 +60,48 @@
   }
 
-  trigger_event('add_event_handler',
-      array('event'=>$event, 'function'=>$func)
-    );
-
-  $pwg_event_handlers[$event]["$priority"][] =
+  $pwg_event_handlers[$event][$priority][] =
     array(
       'function'=>$func,
       'accepted_args'=>$accepted_args);
-
+  ksort( $pwg_event_handlers[$event] );
   return true;
 }
 
+/* Register a event handler.
+ * @param string $event the name of the event to listen to
+ * @param mixed $func the function that needs removal
+ * @param int $priority optional priority (greater priority will
+ * be executed at last)
+*/
+function remove_event_handler($event, $func,
+   $priority=EVENT_HANDLER_PRIORITY_NEUTRAL)
+{
+  global $pwg_event_handlers;
+
+  if (!isset( $pwg_event_handlers[$event][$priority] ) )
+  {
+    return false;
+  }
+  for ($i=0; $i<count($pwg_event_handlers[$event][$priority]); $i++)
+  {
+    if ($pwg_event_handlers[$event][$priority][$i]['function']==$func)
+    {
+      unset($pwg_event_handlers[$event][$priority][$i]);
+      $pwg_event_handlers[$event][$priority] =
+        array_values($pwg_event_handlers[$event][$priority]);
+
+      if ( empty($pwg_event_handlers[$event][$priority]) )
+      {
+        unset( $pwg_event_handlers[$event][$priority] );
+        if (empty( $pwg_event_handlers[$event] ) )
+        {
+          unset( $pwg_event_handlers[$event] );
+        }
+      }
+      return true;
+    }
+  }
+  return false;
+}
 
 /* Triggers an event and calls all registered event handlers
@@ -75,17 +112,13 @@
 {
   global $pwg_event_handlers;
-  if ($event!='pre_trigger_event' and $event!='post_trigger_event')
-  {// special case
-    trigger_event('pre_trigger_event',
-        array('event'=>$event, 'data'=>$data) );
-    if ( !isset($pwg_event_handlers[$event]) )
-    {
-      trigger_event('post_trigger_event',
-          array('event'=>$event, 'data'=>$data) );
-    }
-  }
+
+  // just for debugging
+  trigger_action('pre_trigger_event',
+        array('event'=>$event, 'data'=>$data) );
 
   if ( !isset($pwg_event_handlers[$event]) )
   {
+    trigger_action('post_trigger_event',
+        array('event'=>$event, 'data'=>$data) );
     return $data;
   }
@@ -115,15 +148,51 @@
     }
   }
-
-  if ($event!='pre_trigger_event' and $event!='post_trigger_event')
-  {
-    trigger_event('post_trigger_event',
-        array('event'=>$event, 'data'=>$data) );
-  }
-
+  trigger_action('post_trigger_event',
+        array('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')
+  {// special case for debugging - avoid recursive calls
+    trigger_action('trigger_action',
+        array('event'=>$event, 'data'=>$data) );
+  }
+
+  if ( !isset($pwg_event_handlers[$event]) )
+  {
+    return;
+  }
+  $args = array_slice(func_get_args(), 2);
+
+  foreach ($pwg_event_handlers[$event] as $priority => $handlers)
+  {
+    if ( !is_null($handlers) )
+    {
+      foreach($handlers as $handler)
+      {
+        $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;
+
+        call_user_func_array($function_name, $the_args);
+      }
+    }
+  }
+}
 
 
@@ -174,7 +243,11 @@
   foreach( $plugins as $plugin)
   {
-    @include_once( PHPWG_PLUGINS_PATH.$plugin['id'].'/index.php' );
-  }
-  trigger_event('plugins_loaded');
+    $file_name = PHPWG_PLUGINS_PATH.$plugin['id'].'/main.inc.php';
+    if ( file_exists($file_name) )
+    {
+      include_once( $file_name );
+    }
+  }
+  trigger_action('plugins_loaded');
 }
 ?>
Index: trunk/include/page_header.php
===================================================================
--- trunk/include/page_header.php	(revision 1589)
+++ trunk/include/page_header.php	(revision 1590)
@@ -31,4 +31,6 @@
 $template->set_filenames(array('header'=>'header.tpl'));
 
+trigger_action('loc_begin_page_header');
+
 $template->assign_vars(
   array(
@@ -38,7 +40,6 @@
 
     'PAGE_BANNER' =>
-      trigger_event('page_banner',
-          isset($page['page_banner']) ?
-          $page['page_banner'] : $conf['page_banner'] ),
+      isset($page['page_banner']) ?
+        $page['page_banner'] : $conf['page_banner'],
 
     'BODY_ID' =>
@@ -68,4 +69,6 @@
 }
 
+trigger_action('loc_end_page_header');
+
 header('Content-Type: text/html; charset='.$lang_info['charset']);
 $template->parse('header');
Index: trunk/include/picture_metadata.inc.php
===================================================================
--- trunk/include/picture_metadata.inc.php	(revision 1589)
+++ trunk/include/picture_metadata.inc.php	(revision 1590)
@@ -40,5 +40,5 @@
   }
 
-  if ($exif = @read_exif_data($picture['current']['src_file_system']))
+  if ($exif = @read_exif_data($picture['current']['image_path']))
   {
     $template->assign_block_vars(
@@ -93,5 +93,5 @@
 if ($conf['show_iptc'])
 {
-  $iptc = get_iptc_data($picture['current']['src_file_system'],
+  $iptc = get_iptc_data($picture['current']['image_path'],
                         $conf['show_iptc_mapping']);
 
Index: trunk/picture.php
===================================================================
--- trunk/picture.php	(revision 1589)
+++ trunk/picture.php	(revision 1590)
@@ -47,4 +47,48 @@
 }
 
+// add default event handler for rendering element content
+add_event_handler('render_element_content', 'default_picture_content',
+  EVENT_HANDLER_PRIORITY_NEUTRAL, 2);
+trigger_action('loc_begin_picture');
+
+// this is the default handler that generates the display for the element
+function default_picture_content($content, $element_info)
+{
+  if ( !empty($content) )
+  {// someone hooked us - so we skip;
+    return $content;
+  }
+  if (!isset($element_info['image_url']))
+  { // nothing to do
+    return $content;
+  }
+  global $user;
+  $my_template = new Template(PHPWG_ROOT_PATH.'template/'.$user['template'],
+    $user['theme'] );
+  $my_template->set_filenames( array('default_content'=>'picture_content.tpl') );
+
+  if (isset($element_info['high_url']))
+  {
+    $uuid = uniqid(rand());
+    $my_template->assign_block_vars(
+      'high',
+      array(
+        'U_HIGH' => $element_info['high_url'],
+        'UUID'   => $uuid,
+        )
+      );
+  }
+  $my_template->assign_vars( array(
+      'SRC_IMG' => $element_info['image_url'],
+      'ALT_IMG' => $element_info['file'],
+      'WIDTH_IMG' => $element_info['scaled_width'],
+      'HEIGHT_IMG' => $element_info['scaled_height'],
+      )
+    );
+  return $my_template->parse( 'default_content', true);
+}
+
+
+
 // +-----------------------------------------------------------------------+
 // |                            initialization                             |
@@ -100,5 +144,5 @@
  */
 
-if (isset($_GET['action']) and !is_adviser())
+if (isset($_GET['action']))
 {
   switch ($_GET['action'])
@@ -140,5 +184,5 @@
     case 'set_as_representative' :
     {
-      if (is_admin() and isset($page['category']))
+      if (is_admin() and !is_adviser() and isset($page['category']))
       {
         $query = '
@@ -175,5 +219,5 @@
       if (isset($_GET['comment_to_delete'])
           and is_numeric($_GET['comment_to_delete'])
-          and is_admin())
+          and is_admin() and !is_adviser() )
       {
         $query = '
@@ -276,20 +320,15 @@
   $file_wo_ext = get_filename_wo_extension($row['file']);
 
-  if (isset($row['representative_ext']) and $row['representative_ext'] != '')
-  {
-    $picture[$i]['src'] =
-      $cat_directory.'/pwg_representative/'
-      .$file_wo_ext.'.'.$row['representative_ext'];
-  }
-  else
-  {
-    $icon = get_themeconf('mime_icon_dir');
-    $icon.= strtolower(get_extension($row['file'])).'.png';
-    $picture[$i]['src'] = $icon;
-  }
-  // special case for picture files
+  // ------ build element_path and element_url
+  $picture[$i]['element_url'] = $row['path'];
+  if ( ! url_is_remote($row['path']) )
+  {
+    $picture[$i]['element_url'] = get_root_url().$row['path'];
+  }
+
+  // ------ build image_path and image_url
   if ($picture[$i]['is_picture'])
   {
-    $picture[$i]['src'] = $row['path'];
+    $picture[$i]['image_path'] = $row['path'];
     // if we are working on the "current" element, we search if there is a
     // high quality picture
@@ -299,23 +338,45 @@
       {
         $url_high=$cat_directory.'/pwg_high/'.$row['file'];
-        $picture[$i]['high_file_system'] = $picture[$i]['high'] = $url_high;
-        if ( ! url_is_remote($picture[$i]['high']) )
+         $picture[$i]['high_url'] = $picture[$i]['high_path'] = $url_high;
+        if ( ! url_is_remote($picture[$i]['high_path']) )
         {
-          $picture[$i]['high'] = get_root_url().$picture[$i]['high'];
+          $picture[$i]['high_url'] = get_root_url().$picture[$i]['high_path'];
         }
       }
     }
   }
-  $picture[$i]['src_file_system'] = $picture[$i]['src'];
-  if ( ! url_is_remote($picture[$i]['src']) )
-  {
-    $picture[$i]['src'] = get_root_url(). $picture[$i]['src'];
-  }
-
-  // if picture is not a file, we need the download link
+  else
+  {// not a picture
+    if (isset($row['representative_ext']) and $row['representative_ext']!='')
+    {
+      $picture[$i]['image_path'] =
+        $cat_directory.'/pwg_representative/'
+        .$file_wo_ext.'.'.$row['representative_ext'];
+    }
+    else
+    {
+      $picture[$i]['image_path'] =
+        get_themeconf('mime_icon_dir')
+        .strtolower(get_extension($row['file'])).'.png';
+    }
+  }
+
+  $picture[$i]['image_url'] = $picture[$i]['image_path'];
+  if ( ! url_is_remote($picture[$i]['image_path']) )
+  {
+    $picture[$i]['image_url'] = get_root_url().$picture[$i]['image_path'];
+  }
+
   if (!$picture[$i]['is_picture'])
-  {
-    $picture[$i]['download'] = url_is_remote($row['path']) ? '' : get_root_url();
-    $picture[$i]['download'].= $row['path'];
+  {// if picture is not a file, we need the download link
+    $picture[$i]['download_url'] = $picture[$i]['element_url'];
+  }
+  else
+  {// if picture is a file with high, we put the download link
+    if ( isset($picture[$i]['high_path']) )
+    {
+      $picture[$i]['download_url'] = get_root_url().'action.php?dwn='
+        .$picture[$i]['high_path'];
+    }
   }
 
@@ -351,4 +412,30 @@
 }
 
+// calculation of width and height for the current picture
+if (empty($picture['current']['width']))
+{
+  $taille_image = @getimagesize($picture['current']['image_path']);
+  if ($taille_image!==false)
+  {
+    $picture['current']['width'] = $taille_image[0];
+    $picture['current']['height']= $taille_image[1];
+  }
+}
+
+if (!empty($picture['current']['width']))
+{
+  list($picture['current']['scaled_width'],$picture['current']['scaled_height']) =
+    get_picture_size(
+      $picture['current']['width'],
+      $picture['current']['height'],
+      @$user['maxwidth'],
+      @$user['maxheight']
+    );
+}
+
+// now give an opportunity to the filters to alter element_url,
+// image_url, high_url and download_url
+$picture = trigger_event('picture_navigation', $picture);
+
 $url_admin =
   get_root_url().'admin.php?page=picture_modify'
@@ -378,29 +465,16 @@
 $title_nb = ($page['current_rank'] + 1).'/'.$page['cat_nb_images'];
 
-// calculation of width and height
-if (empty($picture['current']['width']))
-{
-  $taille_image = @getimagesize($picture['current']['src_file_system']);
-  $original_width = $taille_image[0];
-  $original_height = $taille_image[1];
-}
-else
-{
-  $original_width = $picture['current']['width'];
-  $original_height = $picture['current']['height'];
-}
-
-$picture_size = get_picture_size(
-  $original_width,
-  $original_height,
-  @$user['maxwidth'],
-  @$user['maxheight']
-  );
-
 // metadata
 $url_metadata = duplicate_picture_url();
-if ($conf['show_exif'] or $conf['show_iptc'])
-{
-  $metadata_showable = true;
+
+// do we have a plugin that can show metadata for something else than images?
+$metadata_showable = trigger_event('get_element_metadata_available',
+    (
+      ($conf['show_exif'] or $conf['show_iptc'])
+      and isset($picture['current']['image_path'])
+    ),
+    $picture['current']['path'] );
+if ($metadata_showable)
+{
   if ( !isset($_GET['metadata']) )
   {
@@ -408,10 +482,24 @@
   }
 }
-else
-{
-  $metadata_showable = false;
-}
 
 $page['body_id'] = 'thePicturePage';
+
+// maybe someone wants a special display (call it before page_header so that they
+// can add stylesheets)
+$element_content = trigger_event('render_element_content',
+                      '', $picture['current'] );
+
+if ( isset($picture['next']['image_url'])
+      and isset($picture['next']['is_picture']) )
+{
+  $template->assign_block_vars( 'prefetch',
+    array (
+      'URL' => $picture['next']['image_url']
+    )
+  );
+}
+include(PHPWG_ROOT_PATH.'include/page_header.php');
+$template->set_filenames(array('picture'=>'picture.tpl'));
+
 //------------------------------------------------------- navigation management
 foreach ( array('first','previous','next','last') as $which_image )
@@ -425,12 +513,8 @@
         'IMG' => $picture[$which_image]['thumbnail'],
         'U_IMG' => $picture[$which_image]['url'],
-        'U_IMG_SRC' => $picture[$which_image]['src']
         )
       );
   }
 }
-
-include(PHPWG_ROOT_PATH.'include/page_header.php');
-$template->set_filenames(array('picture'=>'picture.tpl'));
 
 $template->assign_vars(
@@ -440,30 +524,7 @@
     'PHOTO' => $title_nb,
     'TITLE' => $picture['current']['name'],
-    'SRC_IMG' => $picture['current']['src'],
-    'ALT_IMG' => $picture['current']['file'],
-    'WIDTH_IMG' => $picture_size[0],
-    'HEIGHT_IMG' => $picture_size[1],
+    'ELEMENT_CONTENT' => $element_content,
 
     'LEVEL_SEPARATOR' => $conf['level_separator'],
-
-    'L_HOME' => $lang['home'],
-    'L_SLIDESHOW' => $lang['slideshow'],
-    'L_STOP_SLIDESHOW' => $lang['slideshow_stop'],
-    'L_PREV_IMG' =>$lang['previous_page'].' : ',
-    'L_NEXT_IMG' =>$lang['next_page'].' : ',
-    'L_ADMIN' =>$lang['link_info_image'],
-    'L_COMMENT_TITLE' =>$lang['comments_title'],
-    'L_ADD_COMMENT' =>$lang['comments_add'],
-    'L_DELETE_COMMENT' =>$lang['comments_del'],
-    'L_DELETE' =>$lang['delete'],
-    'L_SUBMIT' =>$lang['submit'],
-    'L_AUTHOR' =>  $lang['upload_author'],
-    'L_COMMENT' =>$lang['comment'],
-    'L_DOWNLOAD' => $lang['download'],
-    'L_DOWNLOAD_HINT' => $lang['download_hint'],
-    'L_PICTURE_METADATA' => $lang['picture_show_metadata'],
-    'L_PICTURE_HIGH' => $lang['picture_high'],
-    'L_UP_HINT' => $lang['home_hint'],
-    'L_UP_ALT' => $lang['home'],
 
     'U_HOME' => make_index_url(),
@@ -483,33 +544,11 @@
 //------------------------------------------------------- upper menu management
 
-// download link if file is not a picture
-if (!$picture['current']['is_picture'])
+// download link
+if ( isset($picture['current']['download_url']) )
 {
   $template->assign_block_vars(
     'download',
     array(
-      'U_DOWNLOAD' => $picture['current']['download']
-      )
-    );
-}
-
-// display a high quality link if present
-if (isset($picture['current']['high']))
-{
-  $uuid = uniqid(rand());
-
-  $template->assign_block_vars(
-    'high',
-    array(
-      'U_HIGH' => $picture['current']['high'],
-      'UUID'   => $uuid,
-      )
-    );
-
-  $template->assign_block_vars(
-    'download',
-    array(
-      'U_DOWNLOAD' => get_root_url().'action.php?dwn='
-      .$picture['current']['high_file_system']
+      'U_DOWNLOAD' => $picture['current']['download_url']
       )
     );
@@ -656,17 +695,17 @@
 
 // size in pixels
-if ($picture['current']['is_picture'])
-{
-  if ($original_width != $picture_size[0]
-      or $original_height != $picture_size[1])
+if ($picture['current']['is_picture'] and isset($picture['current']['width']) )
+{
+  if ($picture['current']['scaled_width'] !== $picture['current']['width'] )
   {
     $infos['INFO_DIMENSIONS'] =
-      '<a href="'.$picture['current']['src'].'" title="'.
+      '<a href="'.$picture['current']['image_url'].'" title="'.
       l10n('Original dimensions').'">'.
-      $original_width.'*'.$original_height.'</a>';
+      $picture['current']['width'].'*'.$picture['current']['height'].'</a>';
   }
   else
   {
-    $infos['INFO_DIMENSIONS'] = $original_width.'*'.$original_height;
+    $infos['INFO_DIMENSIONS'] =
+      $picture['current']['width'].'*'.$picture['current']['height'];
   }
 }
Index: trunk/plugins/event_tracer/index.php
===================================================================
--- trunk/plugins/event_tracer/index.php	(revision 1589)
+++ 	(revision )
@@ -1,90 +1,0 @@
-<?php
-/*
-Plugin Name: Event tracer
-Version: 1.0
-Description: For developers. Shows all calls to trigger_event.
-Plugin URI: http://www.phpwebgallery.net
-*/
-if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
-
-class EventTracer
-{
-  var $me_working;
-  var $my_config;
-
-  function EventTracer()
-  {
-    $this->me_working=0;
-  }
-
-  function load_config()
-  {
-    $x = @file_get_contents( dirname(__FILE__).'/tracer.dat' );
-    if ($x!==false)
-    {
-      $c = unserialize($x);
-      // do some more tests here
-      $this->my_config = $c;
-    }
-    if ( !isset($this->my_config)
-        or empty($this->my_config['filters']) )
-    {
-      $this->my_config['filters'] = array( '.*' );
-      $this->my_config['show_args'] = false;
-      $this->save_config();
-    }
-  }
-
-  function save_config()
-  {
-    $file = fopen( dirname(__FILE__).'/tracer.dat', 'w' );
-    fwrite($file, serialize($this->my_config) );
-    fclose( $file );
-  }
-
-  function pre_trigger_event($event_info)
-  {
-    if (!$this->me_working)
-    {
-      foreach( $this->my_config['filters'] as $filter)
-      {
-        if ( preg_match( '/'.$filter.'/', $event_info['event'] ) )
-        {
-          if ($this->my_config['show_args'])
-            $s = var_export( $event_info['data'], true );
-          else
-            $s = '';
-          pwg_debug('begin trigger_event "'.$event_info['event'].'" '.htmlspecialchars($s) );
-          break;
-        }
-      }
-    }
-  }
-
-  /*function post_trigger_event($filter_info)
-  {
-    if (!$this->me_working)
-    {
-      $s = var_export( $filter_info['data'], true );
-      pwg_debug('end trigger_event '.$filter_info['event'].' '.$s );
-    }
-  }*/
-
-  function plugin_admin_menu()
-  {
-    add_plugin_admin_menu( "Event Tracer", array(&$this, 'do_admin') );
-  }
-
-  function do_admin($my_url)
-  {
-    include( dirname(__FILE__).'/tracer_admin.php' );
-  }
-
-}
-
-$eventTracer = new EventTracer();
-$eventTracer->load_config();
-
-add_event_handler('plugin_admin_menu', array(&$eventTracer, 'plugin_admin_menu') );
-add_event_handler('pre_trigger_event', array(&$eventTracer, 'pre_trigger_event') );
-?>
Index: trunk/plugins/event_tracer/main.inc.php
===================================================================
--- trunk/plugins/event_tracer/main.inc.php	(revision 1590)
+++ trunk/plugins/event_tracer/main.inc.php	(revision 1590)
@@ -0,0 +1,98 @@
+<?php
+/*
+Plugin Name: Event tracer
+Version: 1.0
+Description: For developers. Shows all calls to trigger_event.
+Plugin URI: http://www.phpwebgallery.net
+*/
+if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
+
+class EventTracer
+{
+  var $me_working;
+  var $my_config;
+
+  function EventTracer()
+  {
+    $this->me_working=0;
+  }
+
+  function load_config()
+  {
+    $x = @file_get_contents( dirname(__FILE__).'/data.dat' );
+    if ($x!==false)
+    {
+      $c = unserialize($x);
+      // do some more tests here
+      $this->my_config = $c;
+    }
+    if ( !isset($this->my_config)
+        or empty($this->my_config['filters']) )
+    {
+      $this->my_config['filters'] = array( '.*' );
+      $this->my_config['show_args'] = false;
+      $this->save_config();
+    }
+  }
+
+  function save_config()
+  {
+    $file = fopen( dirname(__FILE__).'/data.dat', 'w' );
+    fwrite($file, serialize($this->my_config) );
+    fclose( $file );
+  }
+
+  function on_pre_trigger_event($event_info)
+  {
+    $this->dump('pre_trigger_event', $event_info);
+  }
+  function on_post_trigger_event($event_info)
+  {
+    $this->dump('post_trigger_event', $event_info);
+  }
+
+  function on_trigger_action($event_info)
+  {
+    $this->dump('trigger_action', $event_info);
+  }
+
+  function dump($event, $event_info)
+  {
+    foreach( $this->my_config['filters'] as $filter)
+    {
+      if ( preg_match( '/'.$filter.'/', $event_info['event'] ) )
+      {
+        if ($this->my_config['show_args'])
+        {
+          $s = '<pre>';
+          $s .= htmlspecialchars( var_export( $event_info['data'], true ) );
+          $s .= '</pre>';
+        }
+        else
+          $s = '';
+        pwg_debug($event.' "'.$event_info['event'].'" '.($s) );
+        break;
+      }
+    }
+  }
+
+  function plugin_admin_menu()
+  {
+    add_plugin_admin_menu( "Event Tracer", array(&$this, 'do_admin') );
+  }
+
+  function do_admin($my_url)
+  {
+    include( dirname(__FILE__).'/tracer_admin.php' );
+  }
+
+}
+
+$eventTracer = new EventTracer();
+$eventTracer->load_config();
+
+add_event_handler('plugin_admin_menu', array(&$eventTracer, 'plugin_admin_menu') );
+add_event_handler('pre_trigger_event', array(&$eventTracer, 'on_pre_trigger_event') );
+add_event_handler('post_trigger_event', array(&$eventTracer, 'on_post_trigger_event') );
+add_event_handler('trigger_action', array(&$eventTracer, 'on_trigger_action') );
+?>
Index: trunk/plugins/event_tracer/tracer_admin.tpl
===================================================================
--- trunk/plugins/event_tracer/tracer_admin.tpl	(revision 1589)
+++ trunk/plugins/event_tracer/tracer_admin.tpl	(revision 1590)
@@ -9,5 +9,5 @@
 
 <label>Show event argument
-	<input type="checkbox" name="eventTracer_show_args" value="{EVENT_TRACER_SHOW_ARGS}" />
+	<input type="checkbox" name="eventTracer_show_args" {EVENT_TRACER_SHOW_ARGS} />
 </label>
 <br/>
Index: trunk/plugins/hello_world/index.php
===================================================================
--- trunk/plugins/hello_world/index.php	(revision 1589)
+++ 	(revision )
@@ -1,18 +1,0 @@
-<?php /*
-Plugin Name: Hello World !
-Author: PhpWebGallery team
-Description: This example plugin changes the page banner for the administration page
-*/
-
-add_event_handler('page_banner', 'hello_world_banner' );
-
-function hello_world_banner($banner)
-{
-  global $page;
-  if ( isset($page['body_id']) and $page['body_id']=='theAdminPage')
-  {
-    return '<h1>Hello world from PhpWebGallery plugin!</h1>';
-  }
-  return $banner;
-}
-?>
Index: trunk/plugins/hello_world/main.inc.php
===================================================================
--- trunk/plugins/hello_world/main.inc.php	(revision 1590)
+++ trunk/plugins/hello_world/main.inc.php	(revision 1590)
@@ -0,0 +1,30 @@
+<?php /*
+Plugin Name: Hello World !
+Author: PhpWebGallery team
+Description: This example plugin changes the page banner for the administration page.
+*/
+
+add_event_handler('loc_begin_page_header', 'hello_world_begin_header' );
+
+function hello_world_begin_header()
+{
+  global $page;
+  if ( isset($page['body_id']) and $page['body_id']=='theAdminPage')
+  {
+    $hellos = array( 'Aloha', 'Ahoy', 'Guten tag', 'Hello', 'Hoi', 'Hola', 'Salut', 'Yo' );
+    shuffle($hellos);
+    $page['page_banner'] = $hellos[0];
+    // just as an example we modify it a little bit later
+    add_event_handler('loc_end_page_header', 'hello_world_end_header');
+  }
+}
+
+
+function hello_world_end_header()
+{
+  global $template, $page;
+  $template->assign_var( 'PAGE_BANNER',
+    '<h1>"'.$page['page_banner'].'" from PhpWebGallery plugin!</h1>');
+}
+
+?>
Index: trunk/template/yoga/header.tpl
===================================================================
--- trunk/template/yoga/header.tpl	(revision 1589)
+++ trunk/template/yoga/header.tpl	(revision 1590)
@@ -16,7 +16,7 @@
 <link rel="stylesheet" type="text/css" href="{pwg_root}template/{themeconf:template}/theme/{themeconf:theme}/theme.css">
 {themeconf:local_head}
-<!-- BEGIN next -->
-<link rel="prefetch" href="{next.U_IMG_SRC}">
-<!-- END next -->
+<!-- BEGIN prefetch -->
+<link rel="prefetch" href="{prefetch.URL}">
+<!-- END prefetch -->
 <!-- BEGIN refresh -->
 <meta http-equiv="refresh" content="{REFRESH_TIME};url={U_REFRESH}">
Index: trunk/template/yoga/picture.tpl
===================================================================
--- trunk/template/yoga/picture.tpl	(revision 1589)
+++ trunk/template/yoga/picture.tpl	(revision 1590)
@@ -5,5 +5,5 @@
 <div id="imageHeaderBar">
   <div class="browsePath">
-    <a href="{U_HOME}" rel="home">{L_HOME}</a>
+    <a href="{U_HOME}" rel="home">{lang:home}</a>
     {LEVEL_SEPARATOR}{SECTION_TITLE}
     {LEVEL_SEPARATOR}{PICTURE_TITLE}
@@ -18,6 +18,6 @@
 
 <div class="randomButtons">
-  <a href="{U_SLIDESHOW}" title="{L_SLIDESHOW}" rel="nofollow"><img src="{pwg_root}{themeconf:icon_dir}/slideshow.png" class="button" alt="{L_SLIDESHOW}"></a>
-  <a href="{U_METADATA}" title="{L_PICTURE_METADATA}"><img src="{pwg_root}{themeconf:icon_dir}/metadata.png" class="button" alt="{L_PICTURE_METADATA}"></a>
+  <a href="{U_SLIDESHOW}" title="{lang:slideshow}" rel="nofollow"><img src="{pwg_root}{themeconf:icon_dir}/slideshow.png" class="button" alt="{lang:slideshow}"></a>
+  <a href="{U_METADATA}" title="{lang:picture_show_metadata}"><img src="{pwg_root}{themeconf:icon_dir}/metadata.png" class="button" alt="{lang:picture_show_metadata}"></a>
 <!-- BEGIN representative -->
   <a href="{representative.URL}" title="{lang:set as category representative}"><img src="{pwg_root}{themeconf:icon_dir}/representative.png" class="button" alt="{lang:representative}"/></a>
@@ -27,8 +27,8 @@
 <!-- END favorite -->
 <!-- BEGIN download -->
-  <a href="{download.U_DOWNLOAD}" title="{L_DOWNLOAD}"><img src="{pwg_root}{themeconf:icon_dir}/save.png" class="button" alt="{L_DOWNLOAD}"></a>
+  <a href="{download.U_DOWNLOAD}" title="{lang:download_hint}"><img src="{pwg_root}{themeconf:icon_dir}/save.png" class="button" alt="{lang:download}"></a>
 <!-- END download -->
 <!-- BEGIN admin -->
-  <a href="{U_ADMIN}" title="{L_ADMIN}"><img src="{pwg_root}{themeconf:icon_dir}/preferences.png" class="button" alt="{L_ADMIN}"></a>
+  <a href="{U_ADMIN}" title="{lang:link_info_image}"><img src="{pwg_root}{themeconf:icon_dir}/preferences.png" class="button" alt="{lang:link_info_image}"></a>
 <!-- END admin -->
 <!-- BEGIN caddie -->
@@ -42,9 +42,9 @@
 <!-- END last -->
 <!-- BEGIN next -->
-  <a class="navButton next" href="{next.U_IMG}" title="{L_NEXT_IMG}{next.TITLE_IMG}" rel="next"><img src="{pwg_root}{themeconf:icon_dir}/right.png" class="button" alt="{lang:next_page}"></a>
+  <a class="navButton next" href="{next.U_IMG}" title="{lang:next_page} : {next.TITLE_IMG}" rel="next"><img src="{pwg_root}{themeconf:icon_dir}/right.png" class="button" alt="{lang:next_page}"></a>
 <!-- END next -->
-  <a class="navButton up" href="{U_UP}" title="{lang:thumbnails}" rel="up"><img src="{pwg_root}{themeconf:icon_dir}/up.png" class="button" alt="{L_UP_ALT}"></a>
+  <a class="navButton up" href="{U_UP}" title="{lang:thumbnails}" rel="up"><img src="{pwg_root}{themeconf:icon_dir}/up.png" class="button" alt="{lang:home}"></a>
 <!-- BEGIN previous -->
-  <a class="navButton prev" href="{previous.U_IMG}" title="{L_PREV_IMG}{previous.TITLE_IMG}" rel="prev"><img src="{pwg_root}{themeconf:icon_dir}/left.png" class="button" alt="{lang:previous_page}"></a>
+  <a class="navButton prev" href="{previous.U_IMG}" title="{lang:previous_page} : {previous.TITLE_IMG}" rel="prev"><img src="{pwg_root}{themeconf:icon_dir}/left.png" class="button" alt="{lang:previous_page}"></a>
 <!-- END previous -->
 <!-- BEGIN first -->
@@ -56,12 +56,5 @@
 
 <div id="theImage">
-<!-- BEGIN high -->
-<a href="javascript:phpWGOpenWindow('{high.U_HIGH}','{high.UUID}','scrollbars=yes,toolbar=no,status=no,resizable=yes')">
-<!-- END high -->
-  <img src="{SRC_IMG}" style="width:{WIDTH_IMG}px;height:{HEIGHT_IMG}px;" alt="{ALT_IMG}">
-<!-- BEGIN high -->
-</a>
-  <p>{L_PICTURE_HIGH}</p>
-<!-- END high -->
+{ELEMENT_CONTENT}
 <!-- BEGIN legend -->
 <p>{legend.COMMENT_IMG}</p>
@@ -69,5 +62,5 @@
 <!-- BEGIN stop_slideshow -->
 <p>
-  [ <a href="{stop_slideshow.U_SLIDESHOW}">{L_STOP_SLIDESHOW}</a> ]
+  [ <a href="{stop_slideshow.U_SLIDESHOW}">{lang:slideshow_stop}</a> ]
 </p>
 <!-- END stop_slideshow -->
@@ -75,10 +68,10 @@
 
 <!-- BEGIN previous -->
-<a class="navThumb" id="thumbPrev" href="{previous.U_IMG}" title="{L_PREV_IMG}{previous.TITLE_IMG}" rel="prev">
+<a class="navThumb" id="thumbPrev" href="{previous.U_IMG}" title="{lang:previous_page} : {previous.TITLE_IMG}" rel="prev">
   <img src="{previous.IMG}" class="thumbLink" id="linkPrev" alt="{previous.TITLE_IMG}">
 </a>
 <!-- END previous -->
 <!-- BEGIN next -->
-<a class="navThumb" id="thumbNext" href="{next.U_IMG}" title="{L_NEXT_IMG}{next.TITLE_IMG}" rel="next">
+<a class="navThumb" id="thumbNext" href="{next.U_IMG}" title="{lang:next_page} : {next.TITLE_IMG}" rel="next">
   <img src="{next.IMG}" class="thumbLink" id="linkNext" alt="{next.TITLE_IMG}">
 </a>
@@ -172,5 +165,5 @@
 <!-- BEGIN comments -->
 <div id="comments">
-  <h2>[{comments.NB_COMMENT}] {L_COMMENT_TITLE}</h2>
+  <h2>[{comments.NB_COMMENT}] {lang:comments_title}</h2>
 
   <div class="navigationBar">{comments.NAV_BAR}</div>
@@ -180,6 +173,6 @@
     <!-- BEGIN delete -->
     <p class="userCommentDelete">
-    <a href="{comments.comment.delete.U_COMMENT_DELETE}" title="{L_DELETE_COMMENT}">
-      <img src="{pwg_root}{themeconf:icon_dir}/delete.png" class="button" style="border:none;vertical-align:middle; margin-left:5px;" alt="[{L_DELETE}]"/>
+    <a href="{comments.comment.delete.U_COMMENT_DELETE}" title="{lang:comments_del}">
+      <img src="{pwg_root}{themeconf:icon_dir}/delete.png" class="button" style="border:none;vertical-align:middle; margin-left:5px;" alt="[{lang:delete}]"/>
     </a>
     </p>
@@ -193,13 +186,13 @@
   <form  method="post" action="{U_ADD_COMMENT}" class="filter" id="addComment">
     <fieldset>
-      <legend>{L_ADD_COMMENT}</legend>
+      <legend>{lang:comments_add}</legend>
       <!-- BEGIN author_field -->
-      <label>{L_AUTHOR}<input type="text" name="author"></label>
+      <label>{lang:upload_author}<input type="text" name="author"></label>
       <!-- END author_field -->
       <!-- BEGIN author_known -->
       <input type="hidden" name="author"  value="{comments.add_comment.author_known.KNOWN_AUTHOR}">
       <!-- END author_known -->
-      <label>{L_COMMENT}<textarea name="content" rows="10" cols="80"></textarea></label>
-      <input type="submit" value="{L_SUBMIT}" {TAG_INPUT_ENABLED}>
+      <label>{lang:comment}<textarea name="content" rows="10" cols="80"></textarea></label>
+      <input type="submit" value="{lang:submit}">
     </fieldset>
   </form>
@@ -208,4 +201,2 @@
 </div>
 <!-- END comments -->
-
-
Index: trunk/template/yoga/picture_content.tpl
===================================================================
--- trunk/template/yoga/picture_content.tpl	(revision 1590)
+++ trunk/template/yoga/picture_content.tpl	(revision 1590)
@@ -0,0 +1,8 @@
+<!-- BEGIN high -->
+<a href="javascript:phpWGOpenWindow('{high.U_HIGH}','{high.UUID}','scrollbars=yes,toolbar=no,status=no,resizable=yes')">
+<!-- END high -->
+  <img src="{SRC_IMG}" style="width:{WIDTH_IMG}px;height:{HEIGHT_IMG}px;" alt="{ALT_IMG}" />
+<!-- BEGIN high -->
+</a>
+  <p>{lang:picture_high}</p>
+<!-- END high -->
