aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--i.php63
-rw-r--r--include/category_default.inc.php49
-rw-r--r--include/config_default.inc.php5
-rw-r--r--include/derivative.inc.php12
-rw-r--r--include/derivative_params.inc.php10
-rw-r--r--include/template.class.php7
-rw-r--r--index.php32
-rw-r--r--themes/default/iconset.css1
-rw-r--r--themes/default/s26/outline_005e89.pngbin1952 -> 2042 bytes
-rw-r--r--themes/default/s26/outline_808060.pngbin1952 -> 2042 bytes
-rw-r--r--themes/default/s26/outline_808080.pngbin2477 -> 2556 bytes
-rw-r--r--themes/default/s26/outline_ff3363.pngbin1952 -> 2042 bytes
-rw-r--r--themes/default/s26/outline_ff7700.pngbin1952 -> 2042 bytes
-rw-r--r--themes/default/s26/outline_ffff80.pngbin1952 -> 2042 bytes
-rw-r--r--themes/default/s26/outline_ffffff.pngbin2169 -> 2247 bytes
-rw-r--r--themes/default/template/index.tpl33
-rw-r--r--themes/default/template/thumbnails.tpl21
-rw-r--r--themes/default/theme.css5
18 files changed, 183 insertions, 55 deletions
diff --git a/i.php b/i.php
index fb2dbc93a..1911d77ab 100644
--- a/i.php
+++ b/i.php
@@ -28,6 +28,13 @@ include(PHPWG_ROOT_PATH . 'include/config_default.inc.php');
defined('PWG_LOCAL_DIR') or define('PWG_LOCAL_DIR', 'local/');
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 get_extension( $filename )
{
@@ -63,6 +70,31 @@ function mkgetdir($dir)
// end fast bootstrap
+function ilog()
+{
+ global $conf, $ilogfh;
+ if (!$conf['enable_i_log']) return;
+ if(!$ilogfh)
+ {
+ $dir=PHPWG_ROOT_PATH.$conf['data_location'].'tmp/';
+ if (!mkgetdir($dir) or ! ($ilogfh=fopen($dir.'i.log', 'a')) )
+ return;
+ }
+ fwrite($ilogfh, date("c") );
+ foreach( func_get_args() as $arg)
+ {
+ fwrite($ilogfh, ' ' );
+ if (is_array($arg))
+ {
+ fwrite($ilogfh, implode(' ', $arg) );
+ }
+ else
+ {
+ fwrite($ilogfh, $arg);
+ }
+ }
+ fwrite($ilogfh, "\n");
+}
function ierror($msg, $code)
{
@@ -92,6 +124,12 @@ function ierror($msg, $code)
exit;
}
+function time_step( &$step )
+{
+ $tmp = $step;
+ $step = get_moment();
+ return intval(1000*($step - $tmp));
+}
function parse_request()
{
@@ -159,12 +197,11 @@ function parse_request()
}
}
array_shift($deriv);
-
$page['coi'] = '';
if (count($deriv) && $deriv[0][0]=='c' && $deriv[0][1]=='i')
{
$page['coi'] = substr(array_shift($deriv), 2);
- preg_match('#^[a-z]{4}$#', $page['coi']) or ierror('Invalid center of interest', 400);
+ preg_match('#^[a-zA-Z]{4}$#', $page['coi']) or ierror('Invalid center of interest', 400);
}
if ($page['derivative_type'] == IMG_CUSTOM)
@@ -187,7 +224,8 @@ function parse_request()
}
}
- if ($req[0]!='g' && $req[0]!='u')
+ if (!is_file(PHPWG_ROOT_PATH.$req.$ext) and
+ is_file(PHPWG_ROOT_PATH.'../'.$req.$ext) )
$req = '../'.$req;
$page['src_location'] = $req.$ext;
@@ -225,6 +263,12 @@ function send_derivative($expires)
$page=array();
+$begin = $step = get_moment();
+$timing=array();
+foreach( explode(',','load,rotate,crop,scale,sharpen,watermark,save,send') as $k )
+{
+ $timing[$k] = '';
+}
include_once( PHPWG_ROOT_PATH .'/include/derivative_params.inc.php');
include_once( PHPWG_ROOT_PATH .'/include/derivative_std_params.inc.php');
@@ -287,6 +331,7 @@ ignore_user_abort(true);
set_time_limit(0);
$image = new pwg_image($page['src_path']);
+$timing['load'] = time_step($step);
$changes = 0;
@@ -299,6 +344,7 @@ if ($crop_rect)
{
$changes++;
$image->crop( $crop_rect->width(), $crop_rect->height(), $crop_rect->l, $crop_rect->t);
+ $timing['crop'] = time_step($step);
}
if ($scaled_size)
@@ -306,11 +352,13 @@ if ($scaled_size)
$changes++;
$image->resize( $scaled_size[0], $scaled_size[1] );
$d_size = $scaled_size;
+ $timing['scale'] = time_step($step);
}
if ($params->sharpen)
{
$changes += $image->sharpen( $params->sharpen );
+ $timing['sharpen'] = time_step($step);
}
if ($params->use_watermark)
@@ -345,6 +393,7 @@ if ($params->use_watermark)
}
}
$wm_image->destroy();
+ $timing['watermark'] = time_step($step);
}
// no change required - redirect to source
@@ -357,6 +406,14 @@ if (!$changes)
$image->set_compression_quality( $params->quality );
$image->write( $page['derivative_path'] );
$image->destroy();
+$timing['save'] = time_step($step);
send_derivative($expires);
+$timing['send'] = time_step($step);
+
+ilog('perf',
+ basename($page['src_path']), $o_size, $o_size[0]*$o_size[1],
+ basename($page['derivative_path']), $d_size, $d_size[0]*$d_size[1],
+ time_step($begin),
+ $timing);
?> \ No newline at end of file
diff --git a/include/category_default.inc.php b/include/category_default.inc.php
index 8d2cd050b..18a4cb4bf 100644
--- a/include/category_default.inc.php
+++ b/include/category_default.inc.php
@@ -2,7 +2,7 @@
// +-----------------------------------------------------------------------+
// | 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) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick |
// +-----------------------------------------------------------------------+
@@ -104,38 +104,21 @@ foreach ($pictures as $row)
array('start')
);
- if (isset($nb_comments_of) )
+ if (isset($nb_comments_of))
{
- $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);
- $tpl_var = array(
- 'ID' => $row['id'],
+ $tpl_var = array_merge( $row, array(
'TN_SRC' => DerivativeImage::thumb_url($row),
'TN_ALT' => htmlspecialchars(strip_tags($name)),
'TN_TITLE' => get_thumbnail_title($row),
'URL' => $url,
+ 'src_image' => new SrcImage($row),
+ ) );
- // Extra fields for usage in extra themes
- 'FILE_PATH' => $row['path'],
- 'FILE_POSTED' => $row['date_available'],
- 'FILE_CREATED' => $row['date_creation'],
- 'FILE_DESC' => $row['comment'],
- 'FILE_AUTHOR' => $row['author'],
- 'FILE_HIT' => $row['hit'],
- 'FILE_SIZE' => $row['filesize'],
- 'FILE_WIDTH' => $row['width'],
- 'FILE_HEIGHT' => $row['height'],
- 'FILE_METADATE' => $row['date_metadata_update'],
- 'FILE_HAS_HD' => $row['has_high'],
- 'FILE_HD_WIDTH' => $row['high_width'],
- 'FILE_HD_HEIGHT' => $row['high_height'],
- 'FILE_HD_FILESIZE' => $row['high_filesize'],
- 'FILE_RATING_SCORE' => $row['rating_score'],
- );
-
if ($conf['index_new_icon'])
{
$tpl_var['icon_ts'] = get_icon($row['date_available']);
@@ -145,7 +128,7 @@ foreach ($pictures as $row)
{
$tpl_var['NB_HITS'] = $row['hit'];
}
-
+
switch ($page['section'])
{
case 'best_rated' :
@@ -162,22 +145,22 @@ foreach ($pictures as $row)
break;
}
}
-
- $tpl_var['NAME'] = $name;
-
- if (isset($row['nb_comments']))
- {
- $tpl_var['NB_COMMENTS'] = $row['nb_comments'];
- }
+ $tpl_var['NAME'] = $name;
$tpl_thumbnails_var[] = $tpl_var;
}
-$template->assign('SHOW_THUMBNAIL_CAPTION', $conf['show_thumbnail_caption']);
+$derivative_params = ImageStdParams::get_by_type( pwg_get_session_var('index_deriv', IMG_THUMB) );
+
+$template->assign( array(
+ 'derivative_params' =>$derivative_params,
+ 'SHOW_THUMBNAIL_CAPTION' =>$conf['show_thumbnail_caption'],
+ ) );
$tpl_thumbnails_var = trigger_event('loc_end_index_thumbnails', $tpl_thumbnails_var, $pictures);
$template->assign('thumbnails', $tpl_thumbnails_var);
$template->assign_var_from_handle('THUMBNAILS', 'index_thumbnails');
-
+unset($pictures, $selection, $tpl_thumbnails_var);
+$template->clear_assign( array('thumbnails') );
pwg_debug('end include/category_default.inc.php');
?> \ No newline at end of file
diff --git a/include/config_default.inc.php b/include/config_default.inc.php
index c1329b96f..dad6e9b20 100644
--- a/include/config_default.inc.php
+++ b/include/config_default.inc.php
@@ -2,7 +2,7 @@
// +-----------------------------------------------------------------------+
// | 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) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick |
// +-----------------------------------------------------------------------+
@@ -467,6 +467,9 @@ $conf['template_combine_files'] = true;
// gives an empty value '' to deactivate
$conf['show_php_errors'] = E_ALL;
+// enable log for i derivative script
+$conf['enable_i_log'] = false;
+
// +-----------------------------------------------------------------------+
// | authentication |
// +-----------------------------------------------------------------------+
diff --git a/include/derivative.inc.php b/include/derivative.inc.php
index d15e7eff3..1f5152dd3 100644
--- a/include/derivative.inc.php
+++ b/include/derivative.inc.php
@@ -100,8 +100,6 @@ final class DerivativeImage
public $src_image;
- private $requested_type;
-
private $flags = 0;
private $params;
private $rel_path, $rel_url;
@@ -111,12 +109,10 @@ final class DerivativeImage
$this->src_image = $src_image;
if (is_string($type))
{
- $this->requested_type = $type;
$this->params = ImageStdParams::get_by_type($type);
}
else
{
- $this->requested_type = IMG_CUSTOM;
$this->params = $type;
}
@@ -125,14 +121,12 @@ final class DerivativeImage
static function thumb_url($infos)
{
- $src_image = new SrcImage($infos);
- self::build($src_image, ImageStdParams::get_by_type(IMG_THUMB), $rel_path, $rel_url);
- return get_root_url().$rel_url;
+ return self::url(IMG_THUMB, $infos);
}
static function url($type, $infos)
{
- $src_image = new SrcImage($infos);
+ $src_image = is_object($infos) ? $infos : new SrcImage($infos);
$params = is_string($type) ? ImageStdParams::get_by_type($type) : $type;
self::build($src_image, $params, $rel_path, $rel_url);
return get_root_url().$rel_url;
@@ -257,7 +251,7 @@ final class DerivativeImage
$size = $this->get_size();
if ($size)
{
- return 'width="'.$size[0].'" height="'.$size[1].'"';
+ return 'width='.$size[0].' height='.$size[1];
}
}
diff --git a/include/derivative_params.inc.php b/include/derivative_params.inc.php
index 569c4ace1..30497639f 100644
--- a/include/derivative_params.inc.php
+++ b/include/derivative_params.inc.php
@@ -315,6 +315,16 @@ final class DerivativeParams
return $scale_size != null ? $scale_size : $in_size;
}
+ function max_width()
+ {
+ return $this->sizing->ideal_size[0];
+ }
+
+ function max_height()
+ {
+ return $this->sizing->ideal_size[1];
+ }
+
function is_identity($in_size)
{
if ($in_size[0] > $this->sizing->ideal_size[0] or
diff --git a/include/template.class.php b/include/template.class.php
index b6d1aa4ba..7bcab1150 100644
--- a/include/template.class.php
+++ b/include/template.class.php
@@ -2,7 +2,7 @@
// +-----------------------------------------------------------------------+
// | 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) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick |
// +-----------------------------------------------------------------------+
@@ -842,6 +842,11 @@ class PwgTemplateAdapter
$args = func_get_args();
return call_user_func_array('sprintf', $args );
}
+
+ function derivative_url($type, $img)
+ {
+ return DerivativeImage::url($type, $img);
+ }
}
diff --git a/index.php b/index.php
index ffabff88b..0af394c66 100644
--- a/index.php
+++ b/index.php
@@ -2,7 +2,7 @@
// +-----------------------------------------------------------------------+
// | 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) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick |
// +-----------------------------------------------------------------------+
@@ -60,6 +60,14 @@ if (isset($_GET['image_order']))
)
);
}
+if (isset($_GET['display']))
+{
+ $page['meta_robots']['noindex']=1;
+ if (array_key_exists($_GET['display'], ImageStdParams::get_defined_type_map()))
+ {
+ pwg_set_session_var('index_deriv', $_GET['display']);
+ }
+}
//-------------------------------------------------------------- initialization
$page['navigation_bar'] = array();
@@ -252,6 +260,28 @@ if ( $conf['index_sort_order_input']
}
}
+if ( count($page['items']) > 0 )
+{
+ $url = add_url_params(
+ duplicate_index_url(),
+ array('display' => '')
+ );
+ $selected_type = pwg_get_session_var('index_deriv', IMG_THUMB);
+ $type_map = ImageStdParams::get_defined_type_map();
+ unset($type_map[IMG_XXLARGE], $type_map[IMG_XLARGE]);
+ foreach($type_map as $params)
+ {
+ $template->append(
+ 'image_derivatives',
+ array(
+ 'DISPLAY' => l10n($params->type),
+ 'URL' => $url.$params->type,
+ 'SELECTED' => ($params->type == $selected_type ? true:false),
+ )
+ );
+ }
+}
+
// category comment
if ($page['start']==0 and !isset($page['chronology_field']) and !empty($page['comment']) )
{
diff --git a/themes/default/iconset.css b/themes/default/iconset.css
index 976f2ce0f..9a7bd464a 100644
--- a/themes/default/iconset.css
+++ b/themes/default/iconset.css
@@ -37,6 +37,7 @@
.pwg-icon-close {background-position: 0 -52px}
.pwg-icon-category-edit {background-position: -26px -52px}
.pwg-icon-sort {background-position: -52px -52px}
+.pwg-icon-sizes {background-position: -78px -52px}
.pwg-icon-category-view-normal {background-position: -156px -52px}
.pwg-icon-category-view-flat {background-position: -182px -52px}
diff --git a/themes/default/s26/outline_005e89.png b/themes/default/s26/outline_005e89.png
index 0e411a152..ee114abe9 100644
--- a/themes/default/s26/outline_005e89.png
+++ b/themes/default/s26/outline_005e89.png
Binary files differ
diff --git a/themes/default/s26/outline_808060.png b/themes/default/s26/outline_808060.png
index 01d1f18df..351cf4149 100644
--- a/themes/default/s26/outline_808060.png
+++ b/themes/default/s26/outline_808060.png
Binary files differ
diff --git a/themes/default/s26/outline_808080.png b/themes/default/s26/outline_808080.png
index d51b3b44c..c7a89c270 100644
--- a/themes/default/s26/outline_808080.png
+++ b/themes/default/s26/outline_808080.png
Binary files differ
diff --git a/themes/default/s26/outline_ff3363.png b/themes/default/s26/outline_ff3363.png
index 9a5aef891..bb2224f39 100644
--- a/themes/default/s26/outline_ff3363.png
+++ b/themes/default/s26/outline_ff3363.png
Binary files differ
diff --git a/themes/default/s26/outline_ff7700.png b/themes/default/s26/outline_ff7700.png
index 45caa0dc3..6cbec3fdf 100644
--- a/themes/default/s26/outline_ff7700.png
+++ b/themes/default/s26/outline_ff7700.png
Binary files differ
diff --git a/themes/default/s26/outline_ffff80.png b/themes/default/s26/outline_ffff80.png
index 0f54e2e46..66734159b 100644
--- a/themes/default/s26/outline_ffff80.png
+++ b/themes/default/s26/outline_ffff80.png
Binary files differ
diff --git a/themes/default/s26/outline_ffffff.png b/themes/default/s26/outline_ffffff.png
index 338aa82b5..d9ac061cd 100644
--- a/themes/default/s26/outline_ffffff.png
+++ b/themes/default/s26/outline_ffffff.png
Binary files differ
diff --git a/themes/default/template/index.tpl b/themes/default/template/index.tpl
index bac0125e5..5f0853071 100644
--- a/themes/default/template/index.tpl
+++ b/themes/default/template/index.tpl
@@ -35,6 +35,39 @@ function toggleSortOrderBox()
{/literal}{/footer_script}
{/strip}</li>
{/if}
+
+{if !empty($image_derivatives)}
+ <li>{strip}<a href="javascript:toggleImageDerivativesBox()" id="derivativeChooseLink" title="{'Photo Sizes'|@translate}" class="pwg-state-default pwg-button" rel="nofollow">
+ <span class="pwg-icon pwg-icon-sizes">&nbsp;</span><span class="pwg-button-text">{'Photo Sizes'|@translate}</span>
+ </a>
+ <div id="derivativeSwitchBox" style="display:none; text-align:left" onclick="toggleImageDerivativesBox()">
+ {foreach from=$image_derivatives item=image_derivative name=deriv_loop}{if !$smarty.foreach.deriv_loop.first}<br>{/if}
+ {if $image_derivative.SELECTED}
+ <span>{$image_derivative.DISPLAY}</span>
+ {else}
+ <a href="{$image_derivative.URL}" rel="nofollow">{$image_derivative.DISPLAY}</a>
+ {/if}
+ {/foreach}
+ </div>
+ {footer_script}{literal}
+function toggleImageDerivativesBox()
+{
+ var elt = document.getElementById("derivativeSwitchBox"),
+ ePos = document.getElementById("derivativeChooseLink");
+ if (elt.style.display==="none")
+ {
+ elt.style.position = "absolute";
+ elt.style.left = (ePos.offsetLeft) + "px";
+ elt.style.top = (ePos.offsetTop + ePos.offsetHeight) + "px";
+ elt.style.display="";
+ }
+ else
+ elt.style.display="none";
+}
+ {/literal}{/footer_script}
+ {/strip}</li>
+{/if}
+
{if isset($favorite)}
<li><a href="{$favorite.U_FAVORITE}" title="{'delete all photos from your favorites'|@translate}" class="pwg-state-default pwg-button" rel="nofollow">
<span class="pwg-icon pwg-icon-favorite-del">&nbsp;</span><span class="pwg-button-text">{'delete all photos from your favorites'|@translate}</span>
diff --git a/themes/default/template/thumbnails.tpl b/themes/default/template/thumbnails.tpl
index 75033a436..fec76214e 100644
--- a/themes/default/template/thumbnails.tpl
+++ b/themes/default/template/thumbnails.tpl
@@ -1,10 +1,25 @@
-{if !empty($thumbnails)}
-{strip}{foreach from=$thumbnails item=thumbnail}
+{if !empty($thumbnails)}{strip}
+{html_head}
+<style type="text/css">
+{*Set some sizes according to maximum thumbnail width and height*}
+.thumbnails SPAN,
+.thumbnails .wrap2 A,
+.thumbnails LABEL{ldelim}
+ width: {$derivative_params->max_width()}px;
+}
+
+.thumbnails .wrap2{ldelim}
+ height: {$derivative_params->max_height()+2}px;
+}
+
+</style>
+{/html_head}
+{foreach from=$thumbnails item=thumbnail}
<li>
<span class="wrap1">
<span class="wrap2">
<a href="{$thumbnail.URL}">
- <img class="thumbnail" src="{$thumbnail.TN_SRC}" alt="{$thumbnail.TN_ALT}" title="{$thumbnail.TN_TITLE}">
+ <img class="thumbnail" src="{$pwg->derivative_url($derivative_params, $thumbnail.src_image)}" alt="{$thumbnail.TN_ALT}" title="{$thumbnail.TN_TITLE}">
</a>
</span>
{if $SHOW_THUMBNAIL_CAPTION }
diff --git a/themes/default/theme.css b/themes/default/theme.css
index 2b43be418..b8f919c43 100644
--- a/themes/default/theme.css
+++ b/themes/default/theme.css
@@ -685,13 +685,10 @@ IMG.ui-datepicker-trigger {
}
/* Set some sizes according to your maximum thumbnail width and height */
-.thumbnails SPAN,
-.thumbnails .wrap2 A,
-.thumbnails LABEL,
.thumbnailCategory DIV.illustration {
width: 140px; /* max thumbnail width + 2px */
}
-.thumbnails .wrap2,
+
.content .thumbnailCategory .description {
height: 140px; /* max thumbnail height + 2px */
}