aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrvelices <rv-github@modusoptimus.com>2006-11-01 05:54:35 +0000
committerrvelices <rv-github@modusoptimus.com>2006-11-01 05:54:35 +0000
commitbce8b9f680af4eb5481441e52e1d82b11da722be (patch)
tree45b30f55abb3257bbc3a8592f8ab872468e41636
parent525c9bc40ab6a99c44292388ce4385574057da86 (diff)
plugins last modifications + events are triggered now from picture.php
git-svn-id: http://piwigo.org/svn/trunk@1590 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to '')
-rw-r--r--admin/include/functions_plugins.inc.php26
-rw-r--r--admin/plugin.php2
-rw-r--r--admin/plugins.php2
-rw-r--r--include/functions_plugins.inc.php123
-rw-r--r--include/page_header.php9
-rw-r--r--include/picture_metadata.inc.php4
-rw-r--r--picture.php257
-rw-r--r--plugins/event_tracer/main.inc.php (renamed from plugins/event_tracer/index.php)52
-rw-r--r--plugins/event_tracer/tracer_admin.tpl2
-rw-r--r--plugins/hello_world/index.php18
-rw-r--r--plugins/hello_world/main.inc.php30
-rw-r--r--template/yoga/header.tpl6
-rw-r--r--template/yoga/picture.tpl47
-rw-r--r--template/yoga/picture_content.tpl8
14 files changed, 369 insertions, 217 deletions
diff --git a/admin/include/functions_plugins.inc.php b/admin/include/functions_plugins.inc.php
index d938f7b23..652aa7e19 100644
--- a/admin/include/functions_plugins.inc.php
+++ b/admin/include/functions_plugins.inc.php
@@ -38,11 +38,11 @@ function get_fs_plugins()
$path = PHPWG_PLUGINS_PATH.$file;
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) )
{
@@ -72,8 +72,26 @@ function get_fs_plugins()
function add_plugin_admin_menu($title, $func)
{
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(
'title' => $title,
diff --git a/admin/plugin.php b/admin/plugin.php
index 08afccc61..e3d5e4e4e 100644
--- a/admin/plugin.php
+++ b/admin/plugin.php
@@ -36,7 +36,7 @@ check_status(ACCESS_ADMINISTRATOR);
$template->set_filenames(array('plugin' => 'admin/plugin.tpl'));
-trigger_event('plugin_admin_menu');
+trigger_action('plugin_admin_menu');
if ( isset($page['plugin_admin_menu']) )
diff --git a/admin/plugins.php b/admin/plugins.php
index 27bc5600d..6b5bf4505 100644
--- a/admin/plugins.php
+++ b/admin/plugins.php
@@ -162,7 +162,7 @@ foreach ($db_plugins as $db_plugin)
$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',
array(
diff --git a/include/functions_plugins.inc.php b/include/functions_plugins.inc.php
index f381b0a89..e83f76df7 100644
--- a/include/functions_plugins.inc.php
+++ b/include/functions_plugins.inc.php
@@ -35,17 +35,22 @@ string.
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
+ * @param int $priority optional priority (greater priority will
+ * be executed at last)
*/
-function add_event_handler($event, $func, $priority=50, $accepted_args=1)
+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"]) )
+ if ( isset($pwg_event_handlers[$event][$priority]) )
{
- foreach($pwg_event_handlers[$event]["$priority"] as $handler)
+ foreach($pwg_event_handlers[$event][$priority] as $handler)
{
if ( $handler['function'] == $func )
{
@@ -54,18 +59,50 @@ function add_event_handler($event, $func, $priority=50, $accepted_args=1)
}
}
- 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
* @param string $event name of the event
@@ -74,19 +111,15 @@ function add_event_handler($event, $func, $priority=50, $accepted_args=1)
function trigger_event($event, $data=null)
{
global $pwg_event_handlers;
- if ($event!='pre_trigger_event' and $event!='post_trigger_event')
- {// special case
- trigger_event('pre_trigger_event',
+
+ // just for debugging
+ trigger_action('pre_trigger_event',
array('event'=>$event, 'data'=>$data) );
- if ( !isset($pwg_event_handlers[$event]) )
- {
- trigger_event('post_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;
}
$args = array_slice(func_get_args(), 2);
@@ -114,17 +147,53 @@ function trigger_event($event, $data=null)
}
}
}
+ trigger_action('post_trigger_event',
+ array('event'=>$event, 'data'=>$data) );
+ return $data;
+}
- if ($event!='pre_trigger_event' and $event!='post_trigger_event')
- {
- trigger_event('post_trigger_event',
+
+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) );
}
- return $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);
+ }
+ }
+ }
+}
/* Returns an array of plugins defined in the database
@@ -173,8 +242,12 @@ function load_plugins()
$plugins = get_db_plugins('active');
foreach( $plugins as $plugin)
{
- @include_once( PHPWG_PLUGINS_PATH.$plugin['id'].'/index.php' );
+ $file_name = PHPWG_PLUGINS_PATH.$plugin['id'].'/main.inc.php';
+ if ( file_exists($file_name) )
+ {
+ include_once( $file_name );
+ }
}
- trigger_event('plugins_loaded');
+ trigger_action('plugins_loaded');
}
?> \ No newline at end of file
diff --git a/include/page_header.php b/include/page_header.php
index af571ab19..1535eb896 100644
--- a/include/page_header.php
+++ b/include/page_header.php
@@ -30,6 +30,8 @@
//
$template->set_filenames(array('header'=>'header.tpl'));
+trigger_action('loc_begin_page_header');
+
$template->assign_vars(
array(
'GALLERY_TITLE' =>
@@ -37,9 +39,8 @@ $template->assign_vars(
$page['gallery_title'] : $conf['gallery_title'],
'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' =>
isset($page['body_id']) ?
@@ -67,6 +68,8 @@ if ( isset( $refresh ) and intval($refresh) >= 0
$template->assign_block_vars('refresh', array());
}
+trigger_action('loc_end_page_header');
+
header('Content-Type: text/html; charset='.$lang_info['charset']);
$template->parse('header');
?>
diff --git a/include/picture_metadata.inc.php b/include/picture_metadata.inc.php
index 777cbd822..038737eb7 100644
--- a/include/picture_metadata.inc.php
+++ b/include/picture_metadata.inc.php
@@ -39,7 +39,7 @@ if ($conf['show_exif'])
die('Exif extension not available, admin should disable exif display');
}
- if ($exif = @read_exif_data($picture['current']['src_file_system']))
+ if ($exif = @read_exif_data($picture['current']['image_path']))
{
$template->assign_block_vars(
'metadata.headline',
@@ -92,7 +92,7 @@ if ($conf['show_exif'])
}
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']);
if (count($iptc) > 0)
diff --git a/picture.php b/picture.php
index 6ebce15dd..69b28a7cc 100644
--- a/picture.php
+++ b/picture.php
@@ -46,6 +46,50 @@ if (!in_array($page['image_id'], $page['items']))
duplicate_index_url() );
}
+// 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 |
// +-----------------------------------------------------------------------+
@@ -99,7 +143,7 @@ $url_self = duplicate_picture_url();
* Actions finish by a redirection
*/
-if (isset($_GET['action']) and !is_adviser())
+if (isset($_GET['action']))
{
switch ($_GET['action'])
{
@@ -139,7 +183,7 @@ DELETE FROM '.FAVORITES_TABLE.'
}
case 'set_as_representative' :
{
- if (is_admin() and isset($page['category']))
+ if (is_admin() and !is_adviser() and isset($page['category']))
{
$query = '
UPDATE '.CATEGORIES_TABLE.'
@@ -174,7 +218,7 @@ UPDATE '.CATEGORIES_TABLE.'
{
if (isset($_GET['comment_to_delete'])
and is_numeric($_GET['comment_to_delete'])
- and is_admin())
+ and is_admin() and !is_adviser() )
{
$query = '
DELETE FROM '.COMMENTS_TABLE.'
@@ -275,22 +319,17 @@ while ($row = mysql_fetch_array($result))
$cat_directory = dirname($row['path']);
$file_wo_ext = get_filename_wo_extension($row['file']);
- if (isset($row['representative_ext']) and $row['representative_ext'] != '')
+ // ------ build element_path and element_url
+ $picture[$i]['element_url'] = $row['path'];
+ if ( ! url_is_remote($row['path']) )
{
- $picture[$i]['src'] =
- $cat_directory.'/pwg_representative/'
- .$file_wo_ext.'.'.$row['representative_ext'];
+ $picture[$i]['element_url'] = get_root_url().$row['path'];
}
- else
- {
- $icon = get_themeconf('mime_icon_dir');
- $icon.= strtolower(get_extension($row['file'])).'.png';
- $picture[$i]['src'] = $icon;
- }
- // special case for picture files
+
+ // ------ 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
if ($i == 'current')
@@ -298,25 +337,47 @@ while ($row = mysql_fetch_array($result))
if (($row['has_high'] == 'true') and ($user['enabled_high'] == 'true'))
{
$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']) )
+ 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]['src'] = get_root_url(). $picture[$i]['src'];
+ $picture[$i]['image_url'] = get_root_url().$picture[$i]['image_path'];
}
- // if picture is not a file, we need the download link
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'];
+ }
}
$picture[$i]['thumbnail'] = get_thumbnail_src($row['path'], @$row['tn_ext']);
@@ -350,6 +411,32 @@ while ($row = mysql_fetch_array($result))
}
}
+// 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'
.'&amp;cat_id='.(isset($page['category']) ? $page['category'] : '')
@@ -377,42 +464,43 @@ if ( isset( $_GET['slideshow'] ) and isset($page['next_item']) )
$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'])
+
+// 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)
{
- $metadata_showable = true;
if ( !isset($_GET['metadata']) )
{
$url_metadata = add_url_params( $url_metadata, array('metadata'=>null) );
}
}
-else
+
+$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']) )
{
- $metadata_showable = false;
+ $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'));
-$page['body_id'] = 'thePicturePage';
//------------------------------------------------------- navigation management
foreach ( array('first','previous','next','last') as $which_image )
{
@@ -424,48 +512,21 @@ foreach ( array('first','previous','next','last') as $which_image )
'TITLE_IMG' => $picture[$which_image]['name'],
'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(
array(
'SECTION_TITLE' => $page['title'],
'PICTURE_TITLE' => $picture['current']['name'],
'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(),
'U_UP' => $url_up,
'U_METADATA' => $url_metadata,
@@ -482,35 +543,13 @@ if ($conf['show_picture_name_on_title'])
//------------------------------------------------------- upper menu management
-// download link if file is not a picture
-if (!$picture['current']['is_picture'])
-{
- $template->assign_block_vars(
- 'download',
- array(
- 'U_DOWNLOAD' => $picture['current']['download']
- )
- );
-}
-
-// display a high quality link if present
-if (isset($picture['current']['high']))
+// download link
+if ( isset($picture['current']['download_url']) )
{
- $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']
)
);
}
@@ -655,19 +694,19 @@ $url = make_index_url(
$infos['INFO_POSTED_DATE'] = '<a href="'.$url.'" rel="nofollow">'.$val.'</a>';
// size in pixels
-if ($picture['current']['is_picture'])
+if ($picture['current']['is_picture'] and isset($picture['current']['width']) )
{
- if ($original_width != $picture_size[0]
- or $original_height != $picture_size[1])
+ 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'];
}
}
else
diff --git a/plugins/event_tracer/index.php b/plugins/event_tracer/main.inc.php
index cc9130b67..fef23296a 100644
--- a/plugins/event_tracer/index.php
+++ b/plugins/event_tracer/main.inc.php
@@ -19,7 +19,7 @@ class EventTracer
function load_config()
{
- $x = @file_get_contents( dirname(__FILE__).'/tracer.dat' );
+ $x = @file_get_contents( dirname(__FILE__).'/data.dat' );
if ($x!==false)
{
$c = unserialize($x);
@@ -37,39 +37,45 @@ class EventTracer
function save_config()
{
- $file = fopen( dirname(__FILE__).'/tracer.dat', 'w' );
+ $file = fopen( dirname(__FILE__).'/data.dat', 'w' );
fwrite($file, serialize($this->my_config) );
fclose( $file );
}
- function pre_trigger_event($event_info)
+ function on_pre_trigger_event($event_info)
{
- if (!$this->me_working)
+ $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)
{
- foreach( $this->my_config['filters'] as $filter)
+ if ( preg_match( '/'.$filter.'/', $event_info['event'] ) )
{
- if ( preg_match( '/'.$filter.'/', $event_info['event'] ) )
+ if ($this->my_config['show_args'])
{
- 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;
+ $s = '<pre>';
+ $s .= htmlspecialchars( var_export( $event_info['data'], true ) );
+ $s .= '</pre>';
}
+ else
+ $s = '';
+ pwg_debug($event.' "'.$event_info['event'].'" '.($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') );
@@ -86,5 +92,7 @@ $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') );
+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') );
?> \ No newline at end of file
diff --git a/plugins/event_tracer/tracer_admin.tpl b/plugins/event_tracer/tracer_admin.tpl
index 38fbd2796..95ee65907 100644
--- a/plugins/event_tracer/tracer_admin.tpl
+++ b/plugins/event_tracer/tracer_admin.tpl
@@ -8,7 +8,7 @@ You can use this plugin to see what events is PhpWebGallery calling.
<legend>Event Tracer</legend>
<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/>
<label>Fill below a list of regular expressions (one per line).
diff --git a/plugins/hello_world/index.php b/plugins/hello_world/index.php
deleted file mode 100644
index d2a8bcddb..000000000
--- a/plugins/hello_world/index.php
+++ /dev/null
@@ -1,18 +0,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;
-}
-?>
diff --git a/plugins/hello_world/main.inc.php b/plugins/hello_world/main.inc.php
new file mode 100644
index 000000000..eb5f98b82
--- /dev/null
+++ b/plugins/hello_world/main.inc.php
@@ -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>');
+}
+
+?> \ No newline at end of file
diff --git a/template/yoga/header.tpl b/template/yoga/header.tpl
index 6238c5d06..04f2c248a 100644
--- a/template/yoga/header.tpl
+++ b/template/yoga/header.tpl
@@ -15,9 +15,9 @@ the "text/nonsense" prevents gecko based browsers to load it -->
<link rel="stylesheet" type="text/css" href="{pwg_root}template/{themeconf:template}/default-colors.css">
<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}">
<!-- END refresh -->
diff --git a/template/yoga/picture.tpl b/template/yoga/picture.tpl
index cdeeaf4a8..8b82bdb1e 100644
--- a/template/yoga/picture.tpl
+++ b/template/yoga/picture.tpl
@@ -4,7 +4,7 @@
<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}
</div>
@@ -17,8 +17,8 @@
<div id="imageToolBar">
<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>
<!-- END representative -->
@@ -26,10 +26,10 @@
<a href="{favorite.U_FAVORITE}" title="{favorite.FAVORITE_HINT}"><img src="{favorite.FAVORITE_IMG}" class="button" alt="{favorite.FAVORITE_ALT}"></a>
<!-- 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 -->
<a href="{caddie.URL}" title="{lang:add to caddie}"><img src="{pwg_root}{themeconf:icon_dir}/caddie_add.png" class="button" alt="{lang:caddie}"/></a>
@@ -41,11 +41,11 @@
<a class="navButton prev" href="{last.U_IMG}" title="{lang:last_page} : {last.TITLE_IMG}" rel="last"><img src="{pwg_root}{themeconf:icon_dir}/last.png" class="button" alt="{lang:last_page}"></a>
<!-- 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 -->
<a class="navButton prev" href="{first.U_IMG}" title="{lang:first_page} : {first.TITLE_IMG}" rel="first"><img src="{pwg_root}{themeconf:icon_dir}/first.png" class="button" alt="{lang:first_page}"></a>
@@ -55,31 +55,24 @@
</div> <!-- imageToolBar -->
<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>
<!-- END legend -->
<!-- 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 -->
</div>
<!-- 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>
<!-- END next -->
@@ -171,7 +164,7 @@
<!-- 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>
@@ -179,8 +172,8 @@
<div class="comment">
<!-- 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>
<!-- END delete -->
@@ -192,20 +185,18 @@
<!-- BEGIN add_comment -->
<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>
<!-- END add_comment -->
</div>
<!-- END comments -->
-
-
diff --git a/template/yoga/picture_content.tpl b/template/yoga/picture_content.tpl
new file mode 100644
index 000000000..901d397ed
--- /dev/null
+++ b/template/yoga/picture_content.tpl
@@ -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 -->