mirror of
https://github.com/Piwigo/Piwigo.git
synced 2025-04-26 11:19:55 +03:00
feature 2548 multisize - code cleanup + better usage in category_cats + i.php logs memory usage peak
git-svn-id: http://piwigo.org/svn/trunk@12920 68402e56-0260-453c-a942-63ccdbb3a9ee
This commit is contained in:
parent
e1bd64fdfc
commit
cc01941ed9
14 changed files with 150 additions and 169 deletions
14
i.php
14
i.php
|
@ -28,13 +28,6 @@ include(PHPWG_ROOT_PATH . 'include/config_default.inc.php');
|
||||||
defined('PWG_LOCAL_DIR') or define('PWG_LOCAL_DIR', 'local/');
|
defined('PWG_LOCAL_DIR') or define('PWG_LOCAL_DIR', 'local/');
|
||||||
defined('PWG_DERIVATIVE_DIR') or define('PWG_DERIVATIVE_DIR', $conf['data_location'].'i/');
|
defined('PWG_DERIVATIVE_DIR') or define('PWG_DERIVATIVE_DIR', $conf['data_location'].'i/');
|
||||||
|
|
||||||
function get_moment()
|
|
||||||
{
|
|
||||||
$t1 = explode( ' ', microtime() );
|
|
||||||
$t2 = explode( '.', $t1[0] );
|
|
||||||
$t2 = $t1[1].'.'.$t2[1];
|
|
||||||
return $t2;
|
|
||||||
}
|
|
||||||
function trigger_action() {}
|
function trigger_action() {}
|
||||||
function get_extension( $filename )
|
function get_extension( $filename )
|
||||||
{
|
{
|
||||||
|
@ -127,7 +120,7 @@ function ierror($msg, $code)
|
||||||
function time_step( &$step )
|
function time_step( &$step )
|
||||||
{
|
{
|
||||||
$tmp = $step;
|
$tmp = $step;
|
||||||
$step = get_moment();
|
$step = microtime(true);
|
||||||
return intval(1000*($step - $tmp));
|
return intval(1000*($step - $tmp));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -263,7 +256,7 @@ function send_derivative($expires)
|
||||||
|
|
||||||
|
|
||||||
$page=array();
|
$page=array();
|
||||||
$begin = $step = get_moment();
|
$begin = $step = microtime(true);
|
||||||
$timing=array();
|
$timing=array();
|
||||||
foreach( explode(',','load,rotate,crop,scale,sharpen,watermark,save,send') as $k )
|
foreach( explode(',','load,rotate,crop,scale,sharpen,watermark,save,send') as $k )
|
||||||
{
|
{
|
||||||
|
@ -414,6 +407,7 @@ $timing['send'] = time_step($step);
|
||||||
ilog('perf',
|
ilog('perf',
|
||||||
basename($page['src_path']), $o_size, $o_size[0]*$o_size[1],
|
basename($page['src_path']), $o_size, $o_size[0]*$o_size[1],
|
||||||
basename($page['derivative_path']), $d_size, $d_size[0]*$d_size[1],
|
basename($page['derivative_path']), $d_size, $d_size[0]*$d_size[1],
|
||||||
|
function_exists('memory_get_peak_usage') ? round( memory_get_peak_usage()/(1024*1024), 1) : '',
|
||||||
time_step($begin),
|
time_step($begin),
|
||||||
$timing);
|
'|', $timing);
|
||||||
?>
|
?>
|
|
@ -189,7 +189,6 @@ SELECT *
|
||||||
{
|
{
|
||||||
if ($row['level'] <= $user['level'])
|
if ($row['level'] <= $user['level'])
|
||||||
{
|
{
|
||||||
$row['tn_src'] = DerivativeImage::thumb_url($row);
|
|
||||||
$infos_of_image[$row['id']] = $row;
|
$infos_of_image[$row['id']] = $row;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -236,10 +235,15 @@ SELECT *
|
||||||
$result = pwg_query($query);
|
$result = pwg_query($query);
|
||||||
while ($row = pwg_db_fetch_assoc($result))
|
while ($row = pwg_db_fetch_assoc($result))
|
||||||
{
|
{
|
||||||
$row['tn_src'] = DerivativeImage::thumb_url($row);
|
|
||||||
$infos_of_image[$row['id']] = $row;
|
$infos_of_image[$row['id']] = $row;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
foreach ($infos_of_image as &$info)
|
||||||
|
{
|
||||||
|
$info['src_image'] = new SrcImage($info);
|
||||||
|
}
|
||||||
|
unset($info);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count($user_representative_updates_for))
|
if (count($user_representative_updates_for))
|
||||||
|
@ -311,7 +315,7 @@ if (count($categories) > 0)
|
||||||
$tpl_var =
|
$tpl_var =
|
||||||
array(
|
array(
|
||||||
'ID' => $category['id'],
|
'ID' => $category['id'],
|
||||||
'TN_SRC' => $representative_infos['tn_src'],
|
'representative' => $representative_infos,
|
||||||
'TN_ALT' => strip_tags($category['name']),
|
'TN_ALT' => strip_tags($category['name']),
|
||||||
|
|
||||||
'URL' => make_index_url(
|
'URL' => make_index_url(
|
||||||
|
@ -333,23 +337,6 @@ if (count($categories) > 0)
|
||||||
@$category['comment'],
|
@$category['comment'],
|
||||||
'subcatify_category_description')),
|
'subcatify_category_description')),
|
||||||
'NAME' => $name,
|
'NAME' => $name,
|
||||||
|
|
||||||
// Extra fields for usage in extra themes
|
|
||||||
'FILE_PATH' => $representative_infos['path'],
|
|
||||||
'FILE_POSTED' => $representative_infos['date_available'],
|
|
||||||
'FILE_CREATED' => $representative_infos['date_creation'],
|
|
||||||
'FILE_DESC' => $representative_infos['comment'],
|
|
||||||
'FILE_AUTHOR' => $representative_infos['author'],
|
|
||||||
'FILE_HIT' => $representative_infos['hit'],
|
|
||||||
'FILE_SIZE' => $representative_infos['filesize'],
|
|
||||||
'FILE_WIDTH' => $representative_infos['width'],
|
|
||||||
'FILE_HEIGHT' => $representative_infos['height'],
|
|
||||||
'FILE_METADATE' => $representative_infos['date_metadata_update'],
|
|
||||||
'FILE_HAS_HD' => $representative_infos['has_high'],
|
|
||||||
'FILE_HD_WIDTH' => $representative_infos['high_width'],
|
|
||||||
'FILE_HD_HEIGHT' => $representative_infos['high_height'],
|
|
||||||
'FILE_HD_FILESIZE' => $representative_infos['high_filesize'],
|
|
||||||
'FILE_RATING_SCORE' => $representative_infos['rating_score'],
|
|
||||||
);
|
);
|
||||||
if ($conf['index_new_icon'])
|
if ($conf['index_new_icon'])
|
||||||
{
|
{
|
||||||
|
@ -387,8 +374,12 @@ if (count($categories) > 0)
|
||||||
$tpl_thumbnails_var[] = $tpl_var;
|
$tpl_thumbnails_var[] = $tpl_var;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$derivative_params = trigger_event('get_index_album_derivative_params', ImageStdParams::get_by_type(IMG_SMALL) );
|
||||||
$tpl_thumbnails_var = trigger_event('loc_end_index_category_thumbnails', $tpl_thumbnails_var, $categories);
|
$tpl_thumbnails_var = trigger_event('loc_end_index_category_thumbnails', $tpl_thumbnails_var, $categories);
|
||||||
$template->assign( 'category_thumbnails', $tpl_thumbnails_var);
|
$template->assign( array(
|
||||||
|
'category_thumbnails' => $tpl_thumbnails_var,
|
||||||
|
'derivative_params' => $derivative_params,
|
||||||
|
) );
|
||||||
|
|
||||||
$template->assign_var_from_handle('CATEGORIES', 'index_category_thumbnails');
|
$template->assign_var_from_handle('CATEGORIES', 'index_category_thumbnails');
|
||||||
}
|
}
|
||||||
|
|
|
@ -109,13 +109,15 @@ foreach ($pictures as $row)
|
||||||
$row['NB_COMMENTS'] = $row['nb_comments'] = (int)@$nb_comments_of[$row['id']];
|
$row['NB_COMMENTS'] = $row['nb_comments'] = (int)@$nb_comments_of[$row['id']];
|
||||||
}
|
}
|
||||||
|
|
||||||
$name = get_picture_title($row);
|
$name = render_element_name($row);
|
||||||
|
$desc = render_element_description($row);
|
||||||
|
|
||||||
$tpl_var = array_merge( $row, array(
|
$tpl_var = array_merge( $row, array(
|
||||||
'TN_SRC' => DerivativeImage::thumb_url($row),
|
'TN_SRC' => DerivativeImage::thumb_url($row),
|
||||||
'TN_ALT' => htmlspecialchars(strip_tags($name)),
|
'TN_ALT' => htmlspecialchars(strip_tags($name)),
|
||||||
'TN_TITLE' => get_thumbnail_title($row),
|
'TN_TITLE' => get_thumbnail_title($row, $name, $desc),
|
||||||
'URL' => $url,
|
'URL' => $url,
|
||||||
|
'DESCRIPTION' => $desc,
|
||||||
'src_image' => new SrcImage($row),
|
'src_image' => new SrcImage($row),
|
||||||
) );
|
) );
|
||||||
|
|
||||||
|
@ -145,12 +147,11 @@ foreach ($pictures as $row)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$tpl_var['NAME'] = $name;
|
$tpl_var['NAME'] = $name;
|
||||||
$tpl_thumbnails_var[] = $tpl_var;
|
$tpl_thumbnails_var[] = $tpl_var;
|
||||||
}
|
}
|
||||||
|
|
||||||
$derivative_params = ImageStdParams::get_by_type( pwg_get_session_var('index_deriv', IMG_THUMB) );
|
$derivative_params = trigger_event('get_index_derivative_params', ImageStdParams::get_by_type( pwg_get_session_var('index_deriv', IMG_THUMB) ) );
|
||||||
|
|
||||||
$template->assign( array(
|
$template->assign( array(
|
||||||
'derivative_params' =>$derivative_params,
|
'derivative_params' =>$derivative_params,
|
||||||
|
@ -161,6 +162,6 @@ $template->assign('thumbnails', $tpl_thumbnails_var);
|
||||||
|
|
||||||
$template->assign_var_from_handle('THUMBNAILS', 'index_thumbnails');
|
$template->assign_var_from_handle('THUMBNAILS', 'index_thumbnails');
|
||||||
unset($pictures, $selection, $tpl_thumbnails_var);
|
unset($pictures, $selection, $tpl_thumbnails_var);
|
||||||
$template->clear_assign( array('thumbnails') );
|
$template->clear_assign( array('thumbnails', 'derivative_params') );
|
||||||
pwg_debug('end include/category_default.inc.php');
|
pwg_debug('end include/category_default.inc.php');
|
||||||
?>
|
?>
|
|
@ -24,9 +24,7 @@
|
||||||
defined('PHPWG_ROOT_PATH') or trigger_error('Hacking attempt!', E_USER_ERROR);
|
defined('PHPWG_ROOT_PATH') or trigger_error('Hacking attempt!', E_USER_ERROR);
|
||||||
|
|
||||||
// determine the initial instant to indicate the generation time of this page
|
// determine the initial instant to indicate the generation time of this page
|
||||||
$t1 = explode( ' ', microtime() );
|
$t2 = microtime(true);
|
||||||
$t2 = explode( '.', $t1[0] );
|
|
||||||
$t2 = $t1[1].'.'.$t2[1];
|
|
||||||
|
|
||||||
@set_magic_quotes_runtime(0); // Disable magic_quotes_runtime
|
@set_magic_quotes_runtime(0); // Disable magic_quotes_runtime
|
||||||
|
|
||||||
|
@ -109,7 +107,7 @@ if(isset($conf['show_php_errors']) && !empty($conf['show_php_errors']))
|
||||||
|
|
||||||
include(PHPWG_ROOT_PATH . 'include/constants.php');
|
include(PHPWG_ROOT_PATH . 'include/constants.php');
|
||||||
include(PHPWG_ROOT_PATH . 'include/functions.inc.php');
|
include(PHPWG_ROOT_PATH . 'include/functions.inc.php');
|
||||||
include(PHPWG_ROOT_PATH .'include/template.class.php');
|
|
||||||
|
|
||||||
// Database connection
|
// Database connection
|
||||||
try
|
try
|
||||||
|
|
|
@ -33,6 +33,8 @@ include_once( PHPWG_ROOT_PATH .'include/functions_plugins.inc.php' );
|
||||||
include_once( PHPWG_ROOT_PATH .'include/derivative_params.inc.php');
|
include_once( PHPWG_ROOT_PATH .'include/derivative_params.inc.php');
|
||||||
include_once( PHPWG_ROOT_PATH .'include/derivative_std_params.inc.php');
|
include_once( PHPWG_ROOT_PATH .'include/derivative_std_params.inc.php');
|
||||||
include_once( PHPWG_ROOT_PATH .'include/derivative.inc.php');
|
include_once( PHPWG_ROOT_PATH .'include/derivative.inc.php');
|
||||||
|
require_once( PHPWG_ROOT_PATH .'include/smarty/libs/Smarty.class.php');
|
||||||
|
include_once( PHPWG_ROOT_PATH .'include/template.class.php');
|
||||||
|
|
||||||
//----------------------------------------------------------- generic functions
|
//----------------------------------------------------------- generic functions
|
||||||
|
|
||||||
|
@ -52,10 +54,7 @@ function micro_seconds()
|
||||||
// are precised : e.g. 1052343429.89276600
|
// are precised : e.g. 1052343429.89276600
|
||||||
function get_moment()
|
function get_moment()
|
||||||
{
|
{
|
||||||
$t1 = explode( ' ', microtime() );
|
return microtime(true);
|
||||||
$t2 = explode( '.', $t1[0] );
|
|
||||||
$t2 = $t1[1].'.'.$t2[1];
|
|
||||||
return $t2;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// The function get_elapsed_time returns the number of seconds (with 3
|
// The function get_elapsed_time returns the number of seconds (with 3
|
||||||
|
@ -663,7 +662,7 @@ function get_query_string_diff($rejects=array(), $escape=true)
|
||||||
{
|
{
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
$query_string = '';
|
$query_string = '';
|
||||||
|
|
||||||
$str = $_SERVER['QUERY_STRING'];
|
$str = $_SERVER['QUERY_STRING'];
|
||||||
|
@ -815,50 +814,6 @@ function get_thumbnail_location($element_info)
|
||||||
return $path;
|
return $path;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* returns the title of the thumbnail based on photo properties
|
|
||||||
*/
|
|
||||||
function get_thumbnail_title($info)
|
|
||||||
{
|
|
||||||
global $conf, $user;
|
|
||||||
|
|
||||||
$title = get_picture_title($info);
|
|
||||||
|
|
||||||
$details = array();
|
|
||||||
|
|
||||||
if (!empty($info['hit']))
|
|
||||||
{
|
|
||||||
$details[] = $info['hit'].' '.strtolower(l10n('Visits'));
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($conf['rate'] and !empty($info['rating_score']))
|
|
||||||
{
|
|
||||||
$details[] = strtolower(l10n('Rating score')).' '.$info['rating_score'];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isset($info['nb_comments']) and $info['nb_comments'] != 0)
|
|
||||||
{
|
|
||||||
$details[] = l10n_dec('%d comment', '%d comments', $info['nb_comments']);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (count($details) > 0)
|
|
||||||
{
|
|
||||||
$title.= ' ('.implode(', ', $details).')';
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!empty($info['comment']))
|
|
||||||
{
|
|
||||||
$info['comment'] = trigger_event('render_element_description', $info['comment']);
|
|
||||||
$title.= ' '.substr($info['comment'], 0, 100).(strlen($info['comment']) > 100 ? '...' : '');
|
|
||||||
}
|
|
||||||
|
|
||||||
$title = htmlspecialchars(strip_tags($title));
|
|
||||||
|
|
||||||
$title = trigger_event('get_thumbnail_title', $title, $info);
|
|
||||||
|
|
||||||
return $title;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* fill the current user caddie with given elements, if not already in
|
* fill the current user caddie with given elements, if not already in
|
||||||
* caddie
|
* caddie
|
||||||
|
@ -903,18 +858,6 @@ function get_name_from_file($filename)
|
||||||
return str_replace('_',' ',get_filename_wo_extension($filename));
|
return str_replace('_',' ',get_filename_wo_extension($filename));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
function get_picture_title($info)
|
|
||||||
{
|
|
||||||
if (isset($info['name']) and !empty($info['name']))
|
|
||||||
{
|
|
||||||
return trigger_event('render_element_description', $info['name']);
|
|
||||||
}
|
|
||||||
|
|
||||||
return get_name_from_file($info['file']);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* returns the corresponding value from $lang if existing. Else, the key is
|
* returns the corresponding value from $lang if existing. Else, the key is
|
||||||
* returned
|
* returned
|
||||||
|
@ -1435,8 +1378,8 @@ function get_ephemeral_key($valid_after_seconds, $aditionnal_data_to_hash = '')
|
||||||
$time = round(microtime(true), 1);
|
$time = round(microtime(true), 1);
|
||||||
return $time.':'.$valid_after_seconds.':'
|
return $time.':'.$valid_after_seconds.':'
|
||||||
.hash_hmac(
|
.hash_hmac(
|
||||||
'md5',
|
'md5',
|
||||||
$time.substr($_SERVER['REMOTE_ADDR'],0,5).$valid_after_seconds.$aditionnal_data_to_hash,
|
$time.substr($_SERVER['REMOTE_ADDR'],0,5).$valid_after_seconds.$aditionnal_data_to_hash,
|
||||||
$conf['secret_key']);
|
$conf['secret_key']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
// +-----------------------------------------------------------------------+
|
// +-----------------------------------------------------------------------+
|
||||||
// | Piwigo - a PHP based photo gallery |
|
// | Piwigo - a PHP based photo gallery |
|
||||||
// +-----------------------------------------------------------------------+
|
// +-----------------------------------------------------------------------+
|
||||||
// | Copyright(C) 2008-2011 Piwigo Team http://piwigo.org |
|
// | Copyright(C) 2008-2012 Piwigo Team http://piwigo.org |
|
||||||
// | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net |
|
// | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net |
|
||||||
// | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick |
|
// | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick |
|
||||||
// +-----------------------------------------------------------------------+
|
// +-----------------------------------------------------------------------+
|
||||||
|
@ -178,7 +178,7 @@ SELECT id, name, permalink
|
||||||
<a href="'.PHPWG_ROOT_PATH.$url.$category_id.'">'.$cat['name'].'</a>';
|
<a href="'.PHPWG_ROOT_PATH.$url.$category_id.'">'.$cat['name'].'</a>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($single_link and isset($single_url))
|
if ($single_link and isset($single_url))
|
||||||
{
|
{
|
||||||
$output.= '</a>';
|
$output.= '</a>';
|
||||||
|
@ -295,7 +295,7 @@ function name_compare($a, $b)
|
||||||
function tag_alpha_compare($a, $b)
|
function tag_alpha_compare($a, $b)
|
||||||
{
|
{
|
||||||
global $page;
|
global $page;
|
||||||
|
|
||||||
foreach (array($a, $b) as $tag)
|
foreach (array($a, $b) as $tag)
|
||||||
{
|
{
|
||||||
if (!isset($page[__FUNCTION__.'_cache'][ $tag['name'] ]))
|
if (!isset($page[__FUNCTION__.'_cache'][ $tag['name'] ]))
|
||||||
|
@ -533,4 +533,68 @@ function register_default_menubar_blocks( $menu_ref_arr )
|
||||||
$menu->register_block( new RegisteredBlock( 'mbIdentification', 'Identification', 'piwigo') );
|
$menu->register_block( new RegisteredBlock( 'mbIdentification', 'Identification', 'piwigo') );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
function render_element_name($info)
|
||||||
|
{
|
||||||
|
$name = $info['name'];
|
||||||
|
if (!empty($name))
|
||||||
|
{
|
||||||
|
$name = trigger_event('render_element_description', $name);
|
||||||
|
return $name;
|
||||||
|
}
|
||||||
|
|
||||||
|
return get_name_from_file($info['file']);
|
||||||
|
}
|
||||||
|
|
||||||
|
function render_element_description($info)
|
||||||
|
{
|
||||||
|
$comment = $info['comment'];
|
||||||
|
if (!empty($comment))
|
||||||
|
{
|
||||||
|
$comment = trigger_event('render_element_description', $comment);
|
||||||
|
return $comment;
|
||||||
|
}
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* returns the title of the thumbnail based on photo properties
|
||||||
|
*/
|
||||||
|
function get_thumbnail_title($info, $title, $comment)
|
||||||
|
{
|
||||||
|
global $conf, $user;
|
||||||
|
|
||||||
|
$details = array();
|
||||||
|
|
||||||
|
if (!empty($info['hit']))
|
||||||
|
{
|
||||||
|
$details[] = $info['hit'].' '.strtolower(l10n('Visits'));
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($conf['rate'] and !empty($info['rating_score']))
|
||||||
|
{
|
||||||
|
$details[] = strtolower(l10n('Rating score')).' '.$info['rating_score'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($info['nb_comments']) and $info['nb_comments'] != 0)
|
||||||
|
{
|
||||||
|
$details[] = l10n_dec('%d comment', '%d comments', $info['nb_comments']);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count($details) > 0)
|
||||||
|
{
|
||||||
|
$title.= ' ('.implode(', ', $details).')';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($comment))
|
||||||
|
{
|
||||||
|
$title.= ' '.substr($info['comment'], 0, 100).(strlen($info['comment']) > 100 ? '...' : '');
|
||||||
|
}
|
||||||
|
|
||||||
|
$title = htmlspecialchars(strip_tags($title));
|
||||||
|
$title = trigger_event('get_thumbnail_title', $title, $info);
|
||||||
|
return $title;
|
||||||
|
}
|
||||||
|
|
||||||
?>
|
?>
|
|
@ -2,7 +2,7 @@
|
||||||
// +-----------------------------------------------------------------------+
|
// +-----------------------------------------------------------------------+
|
||||||
// | Piwigo - a PHP based photo gallery |
|
// | Piwigo - a PHP based photo gallery |
|
||||||
// +-----------------------------------------------------------------------+
|
// +-----------------------------------------------------------------------+
|
||||||
// | Copyright(C) 2008-2011 Piwigo Team http://piwigo.org |
|
// | Copyright(C) 2008-2012 Piwigo Team http://piwigo.org |
|
||||||
// | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net |
|
// | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net |
|
||||||
// | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick |
|
// | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick |
|
||||||
// +-----------------------------------------------------------------------+
|
// +-----------------------------------------------------------------------+
|
||||||
|
@ -22,25 +22,6 @@
|
||||||
// +-----------------------------------------------------------------------+
|
// +-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Returns the name of a photo according to its name and its filename.
|
|
||||||
* @param name string
|
|
||||||
* @param filename string
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
function get_image_name($name, $filename)
|
|
||||||
{
|
|
||||||
if (!empty($name))
|
|
||||||
{
|
|
||||||
return $name;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return get_name_from_file($filename);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @param element_info array containing element information from db;
|
* @param element_info array containing element information from db;
|
||||||
* at least 'id', 'path', 'has_high' should be present
|
* at least 'id', 'path', 'has_high' should be present
|
||||||
|
@ -249,4 +230,4 @@ function get_picture_size( $original_width, $original_height,
|
||||||
return $picture_size;
|
return $picture_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
|
@ -22,9 +22,6 @@
|
||||||
// +-----------------------------------------------------------------------+
|
// +-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
|
||||||
require_once(PHPWG_ROOT_PATH.'include/smarty/libs/Smarty.class.php');
|
|
||||||
|
|
||||||
|
|
||||||
class Template {
|
class Template {
|
||||||
|
|
||||||
var $smarty;
|
var $smarty;
|
||||||
|
@ -42,6 +39,7 @@ class Template {
|
||||||
|
|
||||||
// used by html_head smarty block to add content before </head>
|
// used by html_head smarty block to add content before </head>
|
||||||
var $html_head_elements = array();
|
var $html_head_elements = array();
|
||||||
|
private $html_style = '';
|
||||||
|
|
||||||
const COMBINED_SCRIPTS_TAG = '<!-- COMBINED_SCRIPTS -->';
|
const COMBINED_SCRIPTS_TAG = '<!-- COMBINED_SCRIPTS -->';
|
||||||
var $scriptLoader;
|
var $scriptLoader;
|
||||||
|
@ -112,6 +110,7 @@ class Template {
|
||||||
$this->smarty->register_modifier( 'explode', array('Template', 'mod_explode') );
|
$this->smarty->register_modifier( 'explode', array('Template', 'mod_explode') );
|
||||||
$this->smarty->register_modifier( 'get_extent', array(&$this, 'get_extent') );
|
$this->smarty->register_modifier( 'get_extent', array(&$this, 'get_extent') );
|
||||||
$this->smarty->register_block('html_head', array(&$this, 'block_html_head') );
|
$this->smarty->register_block('html_head', array(&$this, 'block_html_head') );
|
||||||
|
$this->smarty->register_block('html_style', array(&$this, 'block_html_style') );
|
||||||
$this->smarty->register_function('combine_script', array(&$this, 'func_combine_script') );
|
$this->smarty->register_function('combine_script', array(&$this, 'func_combine_script') );
|
||||||
$this->smarty->register_function('get_combined_scripts', array(&$this, 'func_get_combined_scripts') );
|
$this->smarty->register_function('get_combined_scripts', array(&$this, 'func_get_combined_scripts') );
|
||||||
$this->smarty->register_function('combine_css', array(&$this, 'func_combine_css') );
|
$this->smarty->register_function('combine_css', array(&$this, 'func_combine_css') );
|
||||||
|
@ -466,15 +465,21 @@ class Template {
|
||||||
$this->css_by_priority = array();
|
$this->css_by_priority = array();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( count($this->html_head_elements) )
|
if ( count($this->html_head_elements) || strlen($this->html_style) )
|
||||||
{
|
{
|
||||||
$search = "\n</head>";
|
$search = "\n</head>";
|
||||||
$pos = strpos( $this->output, $search );
|
$pos = strpos( $this->output, $search );
|
||||||
if ($pos !== false)
|
if ($pos !== false)
|
||||||
{
|
{
|
||||||
$this->output = substr_replace( $this->output, "\n".implode( "\n", $this->html_head_elements ), $pos, 0 );
|
$rep = "\n".implode( "\n", $this->html_head_elements );
|
||||||
|
if (strlen($this->html_style))
|
||||||
|
{
|
||||||
|
$rep='<style type="text/css">'.$this->html_style.'</style>';
|
||||||
|
}
|
||||||
|
$this->output = substr_replace( $this->output, $rep, $pos, 0 );
|
||||||
} //else maybe error or warning ?
|
} //else maybe error or warning ?
|
||||||
$this->html_head_elements = array();
|
$this->html_head_elements = array();
|
||||||
|
$this->html_style = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
echo $this->output;
|
echo $this->output;
|
||||||
|
@ -532,6 +537,15 @@ class Template {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function block_html_style($params, $content, &$smarty, &$repeat)
|
||||||
|
{
|
||||||
|
$content = trim($content);
|
||||||
|
if ( !empty($content) )
|
||||||
|
{ // second call
|
||||||
|
$this->html_style .= $content;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* combine_script smarty function allows inclusion of a javascript file in the current page.
|
* combine_script smarty function allows inclusion of a javascript file in the current page.
|
||||||
* The engine will combine several js files into a single one in order to reduce the number of
|
* The engine will combine several js files into a single one in order to reduce the number of
|
||||||
|
@ -842,7 +856,7 @@ class PwgTemplateAdapter
|
||||||
$args = func_get_args();
|
$args = func_get_args();
|
||||||
return call_user_func_array('sprintf', $args );
|
return call_user_func_array('sprintf', $args );
|
||||||
}
|
}
|
||||||
|
|
||||||
function derivative_url($type, $img)
|
function derivative_url($type, $img)
|
||||||
{
|
{
|
||||||
return DerivativeImage::url($type, $img);
|
return DerivativeImage::url($type, $img);
|
||||||
|
|
|
@ -224,7 +224,6 @@ if (version_compare(PHP_VERSION, REQUIRED_PHP_VERSION, '<'))
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------- template initialization
|
//----------------------------------------------------- template initialization
|
||||||
include( PHPWG_ROOT_PATH .'include/template.class.php');
|
|
||||||
$template = new Template(PHPWG_ROOT_PATH.'admin/themes', 'clear');
|
$template = new Template(PHPWG_ROOT_PATH.'admin/themes', 'clear');
|
||||||
$template->set_filenames( array('install' => 'install.tpl') );
|
$template->set_filenames( array('install' => 'install.tpl') );
|
||||||
if (!isset($step))
|
if (!isset($step))
|
||||||
|
|
38
picture.php
38
picture.php
|
@ -2,7 +2,7 @@
|
||||||
// +-----------------------------------------------------------------------+
|
// +-----------------------------------------------------------------------+
|
||||||
// | Piwigo - a PHP based photo gallery |
|
// | Piwigo - a PHP based photo gallery |
|
||||||
// +-----------------------------------------------------------------------+
|
// +-----------------------------------------------------------------------+
|
||||||
// | Copyright(C) 2008-2011 Piwigo Team http://piwigo.org |
|
// | Copyright(C) 2008-2012 Piwigo Team http://piwigo.org |
|
||||||
// | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net |
|
// | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net |
|
||||||
// | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick |
|
// | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick |
|
||||||
// +-----------------------------------------------------------------------+
|
// +-----------------------------------------------------------------------+
|
||||||
|
@ -176,7 +176,7 @@ function default_picture_content($content, $element_info)
|
||||||
}
|
}
|
||||||
|
|
||||||
global $page, $template;
|
global $page, $template;
|
||||||
|
|
||||||
if ($show_original)
|
if ($show_original)
|
||||||
{
|
{
|
||||||
$template->assign( 'U_ORIGINAL', $element_info['element_url'] );
|
$template->assign( 'U_ORIGINAL', $element_info['element_url'] );
|
||||||
|
@ -312,10 +312,6 @@ UPDATE '.USER_CACHE_CATEGORIES_TABLE.'
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'toggle_metadata' :
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 'add_to_caddie' :
|
case 'add_to_caddie' :
|
||||||
{
|
{
|
||||||
fill_caddie(array($page['image_id']));
|
fill_caddie(array($page['image_id']));
|
||||||
|
@ -334,7 +330,7 @@ UPDATE '.USER_CACHE_CATEGORIES_TABLE.'
|
||||||
include_once(PHPWG_ROOT_PATH.'include/functions_comment.inc.php');
|
include_once(PHPWG_ROOT_PATH.'include/functions_comment.inc.php');
|
||||||
check_input_parameter('comment_to_edit', $_GET, false, PATTERN_ID);
|
check_input_parameter('comment_to_edit', $_GET, false, PATTERN_ID);
|
||||||
$author_id = get_comment_author_id($_GET['comment_to_edit']);
|
$author_id = get_comment_author_id($_GET['comment_to_edit']);
|
||||||
|
|
||||||
if (can_manage_comment('edit', $author_id))
|
if (can_manage_comment('edit', $author_id))
|
||||||
{
|
{
|
||||||
if (!empty($_POST['content']))
|
if (!empty($_POST['content']))
|
||||||
|
@ -364,7 +360,7 @@ UPDATE '.USER_CACHE_CATEGORIES_TABLE.'
|
||||||
default:
|
default:
|
||||||
trigger_error('Invalid comment action '.$comment_action, E_USER_WARNING);
|
trigger_error('Invalid comment action '.$comment_action, E_USER_WARNING);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($perform_redirect)
|
if ($perform_redirect)
|
||||||
{
|
{
|
||||||
redirect($url_self);
|
redirect($url_self);
|
||||||
|
@ -500,7 +496,7 @@ while ($row = pwg_db_fetch_assoc($result))
|
||||||
|
|
||||||
$row['src_image'] = new SrcImage($row);
|
$row['src_image'] = new SrcImage($row);
|
||||||
$row['derivatives'] = DerivativeImage::get_all($row['src_image']);
|
$row['derivatives'] = DerivativeImage::get_all($row['src_image']);
|
||||||
|
|
||||||
if ($i=='current')
|
if ($i=='current')
|
||||||
{
|
{
|
||||||
$row['element_path'] = get_element_path($row);
|
$row['element_path'] = get_element_path($row);
|
||||||
|
@ -530,18 +526,7 @@ while ($row = pwg_db_fetch_assoc($result))
|
||||||
);
|
);
|
||||||
|
|
||||||
$picture[$i] = $row;
|
$picture[$i] = $row;
|
||||||
|
$picture[$i]['TITLE'] = render_element_name($row);
|
||||||
if ( !empty( $row['name'] ) )
|
|
||||||
{
|
|
||||||
$picture[$i]['name'] = $row['name'];
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$file_wo_ext = get_filename_wo_extension($row['file']);
|
|
||||||
$picture[$i]['name'] = str_replace('_', ' ', $file_wo_ext);
|
|
||||||
}
|
|
||||||
|
|
||||||
$picture[$i]['name'] = trigger_event('render_element_description', $picture[$i]['name']);
|
|
||||||
|
|
||||||
if ('previous'==$i and $page['previous_item']==$page['first_item'])
|
if ('previous'==$i and $page['previous_item']==$page['first_item'])
|
||||||
{
|
{
|
||||||
|
@ -604,7 +589,7 @@ else
|
||||||
$template->set_filenames( array('picture' => 'picture.tpl'));
|
$template->set_filenames( array('picture' => 'picture.tpl'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$title = $picture['current']['name'];
|
$title = $picture['current']['TITLE'];
|
||||||
$title_nb = ($page['current_rank'] + 1).'/'.count($page['items']);
|
$title_nb = ($page['current_rank'] + 1).'/'.count($page['items']);
|
||||||
|
|
||||||
// metadata
|
// metadata
|
||||||
|
@ -643,7 +628,6 @@ foreach (array('first','previous','next','last', 'current') as $which_image)
|
||||||
array_merge(
|
array_merge(
|
||||||
$picture[$which_image],
|
$picture[$which_image],
|
||||||
array(
|
array(
|
||||||
'TITLE' => $picture[$which_image]['name'],
|
|
||||||
'THUMB_SRC' => $picture[$which_image]['derivatives'][IMG_THUMB]->get_url(),
|
'THUMB_SRC' => $picture[$which_image]['derivatives'][IMG_THUMB]->get_url(),
|
||||||
// Params slideshow was transmit to navigation buttons
|
// Params slideshow was transmit to navigation buttons
|
||||||
'U_IMG' =>
|
'U_IMG' =>
|
||||||
|
@ -652,12 +636,12 @@ foreach (array('first','previous','next','last', 'current') as $which_image)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
if ($conf['picture_download_icon'] and !empty($picture['current']['download_url']))
|
|
||||||
{
|
|
||||||
$template->append($which_image, array('U_DOWNLOAD' => $picture['current']['download_url']), true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if ($conf['picture_download_icon'] and !empty($picture['current']['download_url']))
|
||||||
|
{
|
||||||
|
$template->append('current', array('U_DOWNLOAD' => $picture['current']['download_url']), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if ($page['slideshow'])
|
if ($page['slideshow'])
|
||||||
|
|
|
@ -1,11 +1,19 @@
|
||||||
|
{strip}{html_style}
|
||||||
|
.thumbnailCategory DIV.illustration{ldelim}
|
||||||
|
width: {$derivative_params->max_width()+5}px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.content .thumbnailCategory .description{ldelim}
|
||||||
|
height: {$derivative_params->max_height()+5}px;
|
||||||
|
}
|
||||||
|
{/html_style}{/strip}
|
||||||
<ul class="thumbnailCategories">
|
<ul class="thumbnailCategories">
|
||||||
{foreach from=$category_thumbnails item=cat}
|
{foreach from=$category_thumbnails item=cat}
|
||||||
<li>
|
<li>
|
||||||
<div class="thumbnailCategory">
|
<div class="thumbnailCategory">
|
||||||
<div class="illustration">
|
<div class="illustration">
|
||||||
<a href="{$cat.URL}">
|
<a href="{$cat.URL}">
|
||||||
<img src="{$cat.TN_SRC}" alt="{$cat.TN_ALT}" title="{$cat.NAME|@replace:'"':' '|@strip_tags:false} - {'display this album'|@translate}">
|
<img src="{$pwg->derivative_url($derivative_params, $cat.representative.src_image)}" alt="{$cat.TN_ALT}" title="{$cat.NAME|@replace:'"':' '|@strip_tags:false} - {'display this album'|@translate}">
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<div class="description">
|
<div class="description">
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
{if !empty($thumbnails)}{strip}
|
{if !empty($thumbnails)}{strip}
|
||||||
{html_head}
|
{html_style}
|
||||||
<style type="text/css">
|
|
||||||
{*Set some sizes according to maximum thumbnail width and height*}
|
{*Set some sizes according to maximum thumbnail width and height*}
|
||||||
.thumbnails SPAN,
|
.thumbnails SPAN,
|
||||||
.thumbnails .wrap2 A,
|
.thumbnails .wrap2 A,
|
||||||
|
@ -11,9 +10,16 @@
|
||||||
.thumbnails .wrap2{ldelim}
|
.thumbnails .wrap2{ldelim}
|
||||||
height: {$derivative_params->max_height()+2}px;
|
height: {$derivative_params->max_height()+2}px;
|
||||||
}
|
}
|
||||||
|
{if $derivative_params->max_width() > 600}
|
||||||
</style>
|
.thumbLegend {ldelim}font-size: 130%}
|
||||||
{/html_head}
|
{else}
|
||||||
|
{if $derivative_params->max_width() > 400}
|
||||||
|
.thumbLegend {ldelim}font-size: 110%}
|
||||||
|
{else}
|
||||||
|
.thumbLegend {ldelim}font-size: 90%}
|
||||||
|
{/if}
|
||||||
|
{/if}
|
||||||
|
{/html_style}
|
||||||
{foreach from=$thumbnails item=thumbnail}
|
{foreach from=$thumbnails item=thumbnail}
|
||||||
<li>
|
<li>
|
||||||
<span class="wrap1">
|
<span class="wrap1">
|
||||||
|
|
|
@ -263,7 +263,6 @@ TD.calDayHead {
|
||||||
|
|
||||||
/* Thumbnails */
|
/* Thumbnails */
|
||||||
.thumbnails SPAN.thumbLegend {
|
.thumbnails SPAN.thumbLegend {
|
||||||
font-size: 90%;
|
|
||||||
overflow: hidden;/* oversized legend is clipped */
|
overflow: hidden;/* oversized legend is clipped */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -216,7 +216,6 @@ define('CURRENT_DATE', $dbnow);
|
||||||
// | template initialization |
|
// | template initialization |
|
||||||
// +-----------------------------------------------------------------------+
|
// +-----------------------------------------------------------------------+
|
||||||
|
|
||||||
include( PHPWG_ROOT_PATH .'include/template.class.php');
|
|
||||||
$template = new Template(PHPWG_ROOT_PATH.'admin/themes', 'clear');
|
$template = new Template(PHPWG_ROOT_PATH.'admin/themes', 'clear');
|
||||||
$template->set_filenames(array('upgrade'=>'upgrade.tpl'));
|
$template->set_filenames(array('upgrade'=>'upgrade.tpl'));
|
||||||
$template->assign(array(
|
$template->assign(array(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue