- Timestamp:
- Jan 17, 2012, 7:09:32 AM (13 years ago)
- Location:
- trunk
- Files:
-
- 18 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/i.php
r12865 r12908 29 29 defined('PWG_DERIVATIVE_DIR') or define('PWG_DERIVATIVE_DIR', $conf['data_location'].'i/'); 30 30 31 function get_moment() 32 { 33 $t1 = explode( ' ', microtime() ); 34 $t2 = explode( '.', $t1[0] ); 35 $t2 = $t1[1].'.'.$t2[1]; 36 return $t2; 37 } 31 38 function trigger_action() {} 32 39 function get_extension( $filename ) … … 64 71 // end fast bootstrap 65 72 73 function ilog() 74 { 75 global $conf, $ilogfh; 76 if (!$conf['enable_i_log']) return; 77 if(!$ilogfh) 78 { 79 $dir=PHPWG_ROOT_PATH.$conf['data_location'].'tmp/'; 80 if (!mkgetdir($dir) or ! ($ilogfh=fopen($dir.'i.log', 'a')) ) 81 return; 82 } 83 fwrite($ilogfh, date("c") ); 84 foreach( func_get_args() as $arg) 85 { 86 fwrite($ilogfh, ' ' ); 87 if (is_array($arg)) 88 { 89 fwrite($ilogfh, implode(' ', $arg) ); 90 } 91 else 92 { 93 fwrite($ilogfh, $arg); 94 } 95 } 96 fwrite($ilogfh, "\n"); 97 } 66 98 67 99 function ierror($msg, $code) … … 93 125 } 94 126 127 function time_step( &$step ) 128 { 129 $tmp = $step; 130 $step = get_moment(); 131 return intval(1000*($step - $tmp)); 132 } 95 133 96 134 function parse_request() … … 160 198 } 161 199 array_shift($deriv); 162 163 200 $page['coi'] = ''; 164 201 if (count($deriv) && $deriv[0][0]=='c' && $deriv[0][1]=='i') 165 202 { 166 203 $page['coi'] = substr(array_shift($deriv), 2); 167 preg_match('#^[a-z ]{4}$#', $page['coi']) or ierror('Invalid center of interest', 400);204 preg_match('#^[a-zA-Z]{4}$#', $page['coi']) or ierror('Invalid center of interest', 400); 168 205 } 169 206 … … 188 225 } 189 226 190 if ($req[0]!='g' && $req[0]!='u') 227 if (!is_file(PHPWG_ROOT_PATH.$req.$ext) and 228 is_file(PHPWG_ROOT_PATH.'../'.$req.$ext) ) 191 229 $req = '../'.$req; 192 230 … … 226 264 227 265 $page=array(); 266 $begin = $step = get_moment(); 267 $timing=array(); 268 foreach( explode(',','load,rotate,crop,scale,sharpen,watermark,save,send') as $k ) 269 { 270 $timing[$k] = ''; 271 } 228 272 229 273 include_once( PHPWG_ROOT_PATH .'/include/derivative_params.inc.php'); … … 288 332 289 333 $image = new pwg_image($page['src_path']); 334 $timing['load'] = time_step($step); 290 335 291 336 $changes = 0; … … 300 345 $changes++; 301 346 $image->crop( $crop_rect->width(), $crop_rect->height(), $crop_rect->l, $crop_rect->t); 347 $timing['crop'] = time_step($step); 302 348 } 303 349 … … 307 353 $image->resize( $scaled_size[0], $scaled_size[1] ); 308 354 $d_size = $scaled_size; 355 $timing['scale'] = time_step($step); 309 356 } 310 357 … … 312 359 { 313 360 $changes += $image->sharpen( $params->sharpen ); 361 $timing['sharpen'] = time_step($step); 314 362 } 315 363 … … 346 394 } 347 395 $wm_image->destroy(); 396 $timing['watermark'] = time_step($step); 348 397 } 349 398 … … 358 407 $image->write( $page['derivative_path'] ); 359 408 $image->destroy(); 409 $timing['save'] = time_step($step); 360 410 361 411 send_derivative($expires); 412 $timing['send'] = time_step($step); 413 414 ilog('perf', 415 basename($page['src_path']), $o_size, $o_size[0]*$o_size[1], 416 basename($page['derivative_path']), $d_size, $d_size[0]*$d_size[1], 417 time_step($begin), 418 $timing); 362 419 ?> -
trunk/include/category_default.inc.php
r12887 r12908 3 3 // | Piwigo - a PHP based photo gallery | 4 4 // +-----------------------------------------------------------------------+ 5 // | Copyright(C) 2008-201 1Piwigo Team http://piwigo.org |5 // | Copyright(C) 2008-2012 Piwigo Team http://piwigo.org | 6 6 // | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net | 7 7 // | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick | … … 105 105 ); 106 106 107 if (isset($nb_comments_of) 107 if (isset($nb_comments_of)) 108 108 { 109 $row[' nb_comments'] = (int)@$nb_comments_of[$row['id']];109 $row['NB_COMMENTS'] = $row['nb_comments'] = (int)@$nb_comments_of[$row['id']]; 110 110 } 111 111 112 112 $name = get_picture_title($row); 113 113 114 $tpl_var = array( 115 'ID' => $row['id'], 114 $tpl_var = array_merge( $row, array( 116 115 'TN_SRC' => DerivativeImage::thumb_url($row), 117 116 'TN_ALT' => htmlspecialchars(strip_tags($name)), 118 117 'TN_TITLE' => get_thumbnail_title($row), 119 118 'URL' => $url, 119 'src_image' => new SrcImage($row), 120 ) ); 120 121 121 // Extra fields for usage in extra themes122 'FILE_PATH' => $row['path'],123 'FILE_POSTED' => $row['date_available'],124 'FILE_CREATED' => $row['date_creation'],125 'FILE_DESC' => $row['comment'],126 'FILE_AUTHOR' => $row['author'],127 'FILE_HIT' => $row['hit'],128 'FILE_SIZE' => $row['filesize'],129 'FILE_WIDTH' => $row['width'],130 'FILE_HEIGHT' => $row['height'],131 'FILE_METADATE' => $row['date_metadata_update'],132 'FILE_HAS_HD' => $row['has_high'],133 'FILE_HD_WIDTH' => $row['high_width'],134 'FILE_HD_HEIGHT' => $row['high_height'],135 'FILE_HD_FILESIZE' => $row['high_filesize'],136 'FILE_RATING_SCORE' => $row['rating_score'],137 );138 139 122 if ($conf['index_new_icon']) 140 123 { … … 146 129 $tpl_var['NB_HITS'] = $row['hit']; 147 130 } 148 131 149 132 switch ($page['section']) 150 133 { … … 163 146 } 164 147 } 165 148 166 149 $tpl_var['NAME'] = $name; 167 168 if (isset($row['nb_comments']))169 {170 $tpl_var['NB_COMMENTS'] = $row['nb_comments'];171 }172 173 150 $tpl_thumbnails_var[] = $tpl_var; 174 151 } 175 152 176 $template->assign('SHOW_THUMBNAIL_CAPTION', $conf['show_thumbnail_caption']); 153 $derivative_params = ImageStdParams::get_by_type( pwg_get_session_var('index_deriv', IMG_THUMB) ); 154 155 $template->assign( array( 156 'derivative_params' =>$derivative_params, 157 'SHOW_THUMBNAIL_CAPTION' =>$conf['show_thumbnail_caption'], 158 ) ); 177 159 $tpl_thumbnails_var = trigger_event('loc_end_index_thumbnails', $tpl_thumbnails_var, $pictures); 178 160 $template->assign('thumbnails', $tpl_thumbnails_var); 179 161 180 162 $template->assign_var_from_handle('THUMBNAILS', 'index_thumbnails'); 181 163 unset($pictures, $selection, $tpl_thumbnails_var); 164 $template->clear_assign( array('thumbnails') ); 182 165 pwg_debug('end include/category_default.inc.php'); 183 166 ?> -
trunk/include/config_default.inc.php
r12802 r12908 3 3 // | Piwigo - a PHP based photo gallery | 4 4 // +-----------------------------------------------------------------------+ 5 // | Copyright(C) 2008-201 1Piwigo Team http://piwigo.org |5 // | Copyright(C) 2008-2012 Piwigo Team http://piwigo.org | 6 6 // | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net | 7 7 // | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick | … … 467 467 // gives an empty value '' to deactivate 468 468 $conf['show_php_errors'] = E_ALL; 469 470 // enable log for i derivative script 471 $conf['enable_i_log'] = false; 469 472 470 473 // +-----------------------------------------------------------------------+ -
trunk/include/derivative.inc.php
r12865 r12908 101 101 public $src_image; 102 102 103 private $requested_type;104 105 103 private $flags = 0; 106 104 private $params; … … 112 110 if (is_string($type)) 113 111 { 114 $this->requested_type = $type;115 112 $this->params = ImageStdParams::get_by_type($type); 116 113 } 117 114 else 118 115 { 119 $this->requested_type = IMG_CUSTOM;120 116 $this->params = $type; 121 117 } … … 126 122 static function thumb_url($infos) 127 123 { 128 $src_image = new SrcImage($infos); 129 self::build($src_image, ImageStdParams::get_by_type(IMG_THUMB), $rel_path, $rel_url); 130 return get_root_url().$rel_url; 124 return self::url(IMG_THUMB, $infos); 131 125 } 132 126 133 127 static function url($type, $infos) 134 128 { 135 $src_image = new SrcImage($infos);129 $src_image = is_object($infos) ? $infos : new SrcImage($infos); 136 130 $params = is_string($type) ? ImageStdParams::get_by_type($type) : $type; 137 131 self::build($src_image, $params, $rel_path, $rel_url); … … 258 252 if ($size) 259 253 { 260 return 'width= "'.$size[0].'" height="'.$size[1].'"';254 return 'width='.$size[0].' height='.$size[1]; 261 255 } 262 256 } -
trunk/include/derivative_params.inc.php
r12881 r12908 316 316 } 317 317 318 function max_width() 319 { 320 return $this->sizing->ideal_size[0]; 321 } 322 323 function max_height() 324 { 325 return $this->sizing->ideal_size[1]; 326 } 327 318 328 function is_identity($in_size) 319 329 { -
trunk/include/template.class.php
r12874 r12908 3 3 // | Piwigo - a PHP based photo gallery | 4 4 // +-----------------------------------------------------------------------+ 5 // | Copyright(C) 2008-201 1Piwigo Team http://piwigo.org |5 // | Copyright(C) 2008-2012 Piwigo Team http://piwigo.org | 6 6 // | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net | 7 7 // | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick | … … 843 843 return call_user_func_array('sprintf', $args ); 844 844 } 845 846 function derivative_url($type, $img) 847 { 848 return DerivativeImage::url($type, $img); 849 } 845 850 } 846 851 -
trunk/index.php
r12553 r12908 3 3 // | Piwigo - a PHP based photo gallery | 4 4 // +-----------------------------------------------------------------------+ 5 // | Copyright(C) 2008-201 1Piwigo Team http://piwigo.org |5 // | Copyright(C) 2008-2012 Piwigo Team http://piwigo.org | 6 6 // | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net | 7 7 // | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick | … … 61 61 ); 62 62 } 63 if (isset($_GET['display'])) 64 { 65 $page['meta_robots']['noindex']=1; 66 if (array_key_exists($_GET['display'], ImageStdParams::get_defined_type_map())) 67 { 68 pwg_set_session_var('index_deriv', $_GET['display']); 69 } 70 } 63 71 //-------------------------------------------------------------- initialization 64 72 … … 253 261 } 254 262 263 if ( count($page['items']) > 0 ) 264 { 265 $url = add_url_params( 266 duplicate_index_url(), 267 array('display' => '') 268 ); 269 $selected_type = pwg_get_session_var('index_deriv', IMG_THUMB); 270 $type_map = ImageStdParams::get_defined_type_map(); 271 unset($type_map[IMG_XXLARGE], $type_map[IMG_XLARGE]); 272 foreach($type_map as $params) 273 { 274 $template->append( 275 'image_derivatives', 276 array( 277 'DISPLAY' => l10n($params->type), 278 'URL' => $url.$params->type, 279 'SELECTED' => ($params->type == $selected_type ? true:false), 280 ) 281 ); 282 } 283 } 284 255 285 // category comment 256 286 if ($page['start']==0 and !isset($page['chronology_field']) and !empty($page['comment']) ) -
trunk/themes/default/iconset.css
r12873 r12908 38 38 .pwg-icon-category-edit {background-position: -26px -52px} 39 39 .pwg-icon-sort {background-position: -52px -52px} 40 .pwg-icon-sizes {background-position: -78px -52px} 40 41 .pwg-icon-category-view-normal {background-position: -156px -52px} 41 42 .pwg-icon-category-view-flat {background-position: -182px -52px} -
trunk/themes/default/template/index.tpl
r12878 r12908 36 36 {/strip}</li> 37 37 {/if} 38 39 {if !empty($image_derivatives)} 40 <li>{strip}<a href="javascript:toggleImageDerivativesBox()" id="derivativeChooseLink" title="{'Photo Sizes'|@translate}" class="pwg-state-default pwg-button" rel="nofollow"> 41 <span class="pwg-icon pwg-icon-sizes"> </span><span class="pwg-button-text">{'Photo Sizes'|@translate}</span> 42 </a> 43 <div id="derivativeSwitchBox" style="display:none; text-align:left" onclick="toggleImageDerivativesBox()"> 44 {foreach from=$image_derivatives item=image_derivative name=deriv_loop}{if !$smarty.foreach.deriv_loop.first}<br>{/if} 45 {if $image_derivative.SELECTED} 46 <span>{$image_derivative.DISPLAY}</span> 47 {else} 48 <a href="{$image_derivative.URL}" rel="nofollow">{$image_derivative.DISPLAY}</a> 49 {/if} 50 {/foreach} 51 </div> 52 {footer_script}{literal} 53 function toggleImageDerivativesBox() 54 { 55 var elt = document.getElementById("derivativeSwitchBox"), 56 ePos = document.getElementById("derivativeChooseLink"); 57 if (elt.style.display==="none") 58 { 59 elt.style.position = "absolute"; 60 elt.style.left = (ePos.offsetLeft) + "px"; 61 elt.style.top = (ePos.offsetTop + ePos.offsetHeight) + "px"; 62 elt.style.display=""; 63 } 64 else 65 elt.style.display="none"; 66 } 67 {/literal}{/footer_script} 68 {/strip}</li> 69 {/if} 70 38 71 {if isset($favorite)} 39 72 <li><a href="{$favorite.U_FAVORITE}" title="{'delete all photos from your favorites'|@translate}" class="pwg-state-default pwg-button" rel="nofollow"> -
trunk/themes/default/template/thumbnails.tpl
r11990 r12908 1 {if !empty($thumbnails)} 2 {strip}{foreach from=$thumbnails item=thumbnail} 1 {if !empty($thumbnails)}{strip} 2 {html_head} 3 <style type="text/css"> 4 {*Set some sizes according to maximum thumbnail width and height*} 5 .thumbnails SPAN, 6 .thumbnails .wrap2 A, 7 .thumbnails LABEL{ldelim} 8 width: {$derivative_params->max_width()}px; 9 } 10 11 .thumbnails .wrap2{ldelim} 12 height: {$derivative_params->max_height()+2}px; 13 } 14 15 </style> 16 {/html_head} 17 {foreach from=$thumbnails item=thumbnail} 3 18 <li> 4 19 <span class="wrap1"> 5 20 <span class="wrap2"> 6 21 <a href="{$thumbnail.URL}"> 7 <img class="thumbnail" src="{$ thumbnail.TN_SRC}" alt="{$thumbnail.TN_ALT}" title="{$thumbnail.TN_TITLE}">22 <img class="thumbnail" src="{$pwg->derivative_url($derivative_params, $thumbnail.src_image)}" alt="{$thumbnail.TN_ALT}" title="{$thumbnail.TN_TITLE}"> 8 23 </a> 9 24 </span> -
trunk/themes/default/theme.css
r12881 r12908 686 686 687 687 /* Set some sizes according to your maximum thumbnail width and height */ 688 .thumbnails SPAN,689 .thumbnails .wrap2 A,690 .thumbnails LABEL,691 688 .thumbnailCategory DIV.illustration { 692 689 width: 140px; /* max thumbnail width + 2px */ 693 690 } 694 .thumbnails .wrap2, 691 695 692 .content .thumbnailCategory .description { 696 693 height: 140px; /* max thumbnail height + 2px */
Note: See TracChangeset
for help on using the changeset viewer.