Changeset 12920
- Timestamp:
- 01/17/12 22:58:18 (17 months ago)
- Location:
- trunk
- Files:
-
- 14 modified
-
i.php (modified) (4 diffs)
-
include/category_cats.inc.php (modified) (5 diffs)
-
include/category_default.inc.php (modified) (3 diffs)
-
include/common.inc.php (modified) (2 diffs)
-
include/functions.inc.php (modified) (6 diffs)
-
include/functions_html.inc.php (modified) (4 diffs)
-
include/functions_picture.inc.php (modified) (2 diffs)
-
include/template.class.php (modified) (7 diffs)
-
install.php (modified) (1 diff)
-
picture.php (modified) (10 diffs)
-
themes/default/template/mainpage_categories.tpl (modified) (2 diffs)
-
themes/default/template/thumbnails.tpl (modified) (2 diffs)
-
themes/default/theme.css (modified) (1 diff)
-
upgrade.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/i.php
r12908 r12920 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 }38 31 function trigger_action() {} 39 32 function get_extension( $filename ) … … 128 121 { 129 122 $tmp = $step; 130 $step = get_moment();123 $step = microtime(true); 131 124 return intval(1000*($step - $tmp)); 132 125 } … … 264 257 265 258 $page=array(); 266 $begin = $step = get_moment();259 $begin = $step = microtime(true); 267 260 $timing=array(); 268 261 foreach( explode(',','load,rotate,crop,scale,sharpen,watermark,save,send') as $k ) … … 415 408 basename($page['src_path']), $o_size, $o_size[0]*$o_size[1], 416 409 basename($page['derivative_path']), $d_size, $d_size[0]*$d_size[1], 410 function_exists('memory_get_peak_usage') ? round( memory_get_peak_usage()/(1024*1024), 1) : '', 417 411 time_step($begin), 418 $timing);412 '|', $timing); 419 413 ?> -
trunk/include/category_cats.inc.php
r12796 r12920 190 190 if ($row['level'] <= $user['level']) 191 191 { 192 $row['tn_src'] = DerivativeImage::thumb_url($row);193 192 $infos_of_image[$row['id']] = $row; 194 193 } … … 237 236 while ($row = pwg_db_fetch_assoc($result)) 238 237 { 239 $row['tn_src'] = DerivativeImage::thumb_url($row);240 238 $infos_of_image[$row['id']] = $row; 241 239 } 242 240 } 241 242 foreach ($infos_of_image as &$info) 243 { 244 $info['src_image'] = new SrcImage($info); 245 } 246 unset($info); 243 247 } 244 248 … … 312 316 array( 313 317 'ID' => $category['id'], 314 ' TN_SRC' => $representative_infos['tn_src'],318 'representative' => $representative_infos, 315 319 'TN_ALT' => strip_tags($category['name']), 316 320 … … 334 338 'subcatify_category_description')), 335 339 'NAME' => $name, 336 337 // Extra fields for usage in extra themes338 'FILE_PATH' => $representative_infos['path'],339 'FILE_POSTED' => $representative_infos['date_available'],340 'FILE_CREATED' => $representative_infos['date_creation'],341 'FILE_DESC' => $representative_infos['comment'],342 'FILE_AUTHOR' => $representative_infos['author'],343 'FILE_HIT' => $representative_infos['hit'],344 'FILE_SIZE' => $representative_infos['filesize'],345 'FILE_WIDTH' => $representative_infos['width'],346 'FILE_HEIGHT' => $representative_infos['height'],347 'FILE_METADATE' => $representative_infos['date_metadata_update'],348 'FILE_HAS_HD' => $representative_infos['has_high'],349 'FILE_HD_WIDTH' => $representative_infos['high_width'],350 'FILE_HD_HEIGHT' => $representative_infos['high_height'],351 'FILE_HD_FILESIZE' => $representative_infos['high_filesize'],352 'FILE_RATING_SCORE' => $representative_infos['rating_score'],353 340 ); 354 341 if ($conf['index_new_icon']) … … 388 375 } 389 376 377 $derivative_params = trigger_event('get_index_album_derivative_params', ImageStdParams::get_by_type(IMG_SMALL) ); 390 378 $tpl_thumbnails_var = trigger_event('loc_end_index_category_thumbnails', $tpl_thumbnails_var, $categories); 391 $template->assign( 'category_thumbnails', $tpl_thumbnails_var); 379 $template->assign( array( 380 'category_thumbnails' => $tpl_thumbnails_var, 381 'derivative_params' => $derivative_params, 382 ) ); 392 383 393 384 $template->assign_var_from_handle('CATEGORIES', 'index_category_thumbnails'); -
trunk/include/category_default.inc.php
r12908 r12920 110 110 } 111 111 112 $name = get_picture_title($row); 112 $name = render_element_name($row); 113 $desc = render_element_description($row); 113 114 114 115 $tpl_var = array_merge( $row, array( 115 116 'TN_SRC' => DerivativeImage::thumb_url($row), 116 117 'TN_ALT' => htmlspecialchars(strip_tags($name)), 117 'TN_TITLE' => get_thumbnail_title($row ),118 'TN_TITLE' => get_thumbnail_title($row, $name, $desc), 118 119 'URL' => $url, 120 'DESCRIPTION' => $desc, 119 121 'src_image' => new SrcImage($row), 120 122 ) ); … … 146 148 } 147 149 } 148 149 150 $tpl_var['NAME'] = $name; 150 151 $tpl_thumbnails_var[] = $tpl_var; 151 152 } 152 153 153 $derivative_params = ImageStdParams::get_by_type( pwg_get_session_var('index_deriv', IMG_THUMB) );154 $derivative_params = trigger_event('get_index_derivative_params', ImageStdParams::get_by_type( pwg_get_session_var('index_deriv', IMG_THUMB) ) ); 154 155 155 156 $template->assign( array( … … 162 163 $template->assign_var_from_handle('THUMBNAILS', 'index_thumbnails'); 163 164 unset($pictures, $selection, $tpl_thumbnails_var); 164 $template->clear_assign( array('thumbnails' ) );165 $template->clear_assign( array('thumbnails', 'derivative_params') ); 165 166 pwg_debug('end include/category_default.inc.php'); 166 167 ?> -
trunk/include/common.inc.php
r12802 r12920 25 25 26 26 // determine the initial instant to indicate the generation time of this page 27 $t1 = explode( ' ', microtime() ); 28 $t2 = explode( '.', $t1[0] ); 29 $t2 = $t1[1].'.'.$t2[1]; 27 $t2 = microtime(true); 30 28 31 29 @set_magic_quotes_runtime(0); // Disable magic_quotes_runtime … … 110 108 include(PHPWG_ROOT_PATH . 'include/constants.php'); 111 109 include(PHPWG_ROOT_PATH . 'include/functions.inc.php'); 112 include(PHPWG_ROOT_PATH .'include/template.class.php'); 110 113 111 114 112 // Database connection -
trunk/include/functions.inc.php
r12878 r12920 34 34 include_once( PHPWG_ROOT_PATH .'include/derivative_std_params.inc.php'); 35 35 include_once( PHPWG_ROOT_PATH .'include/derivative.inc.php'); 36 require_once( PHPWG_ROOT_PATH .'include/smarty/libs/Smarty.class.php'); 37 include_once( PHPWG_ROOT_PATH .'include/template.class.php'); 36 38 37 39 //----------------------------------------------------------- generic functions … … 53 55 function get_moment() 54 56 { 55 $t1 = explode( ' ', microtime() ); 56 $t2 = explode( '.', $t1[0] ); 57 $t2 = $t1[1].'.'.$t2[1]; 58 return $t2; 57 return microtime(true); 59 58 } 60 59 … … 664 663 return ''; 665 664 } 666 665 667 666 $query_string = ''; 668 667 … … 817 816 818 817 /** 819 * returns the title of the thumbnail based on photo properties820 */821 function get_thumbnail_title($info)822 {823 global $conf, $user;824 825 $title = get_picture_title($info);826 827 $details = array();828 829 if (!empty($info['hit']))830 {831 $details[] = $info['hit'].' '.strtolower(l10n('Visits'));832 }833 834 if ($conf['rate'] and !empty($info['rating_score']))835 {836 $details[] = strtolower(l10n('Rating score')).' '.$info['rating_score'];837 }838 839 if (isset($info['nb_comments']) and $info['nb_comments'] != 0)840 {841 $details[] = l10n_dec('%d comment', '%d comments', $info['nb_comments']);842 }843 844 if (count($details) > 0)845 {846 $title.= ' ('.implode(', ', $details).')';847 }848 849 if (!empty($info['comment']))850 {851 $info['comment'] = trigger_event('render_element_description', $info['comment']);852 $title.= ' '.substr($info['comment'], 0, 100).(strlen($info['comment']) > 100 ? '...' : '');853 }854 855 $title = htmlspecialchars(strip_tags($title));856 857 $title = trigger_event('get_thumbnail_title', $title, $info);858 859 return $title;860 }861 862 /**863 818 * fill the current user caddie with given elements, if not already in 864 819 * caddie … … 902 857 { 903 858 return str_replace('_',' ',get_filename_wo_extension($filename)); 904 }905 906 /**907 */908 function get_picture_title($info)909 {910 if (isset($info['name']) and !empty($info['name']))911 {912 return trigger_event('render_element_description', $info['name']);913 }914 915 return get_name_from_file($info['file']);916 859 } 917 860 … … 1436 1379 return $time.':'.$valid_after_seconds.':' 1437 1380 .hash_hmac( 1438 'md5', 1439 $time.substr($_SERVER['REMOTE_ADDR'],0,5).$valid_after_seconds.$aditionnal_data_to_hash, 1381 'md5', 1382 $time.substr($_SERVER['REMOTE_ADDR'],0,5).$valid_after_seconds.$aditionnal_data_to_hash, 1440 1383 $conf['secret_key']); 1441 1384 } -
trunk/include/functions_html.inc.php
r12761 r12920 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 | … … 179 179 } 180 180 } 181 181 182 182 if ($single_link and isset($single_url)) 183 183 { … … 296 296 { 297 297 global $page; 298 298 299 299 foreach (array($a, $b) as $tag) 300 300 { … … 534 534 } 535 535 536 /** 537 */ 538 function render_element_name($info) 539 { 540 $name = $info['name']; 541 if (!empty($name)) 542 { 543 $name = trigger_event('render_element_description', $name); 544 return $name; 545 } 546 547 return get_name_from_file($info['file']); 548 } 549 550 function render_element_description($info) 551 { 552 $comment = $info['comment']; 553 if (!empty($comment)) 554 { 555 $comment = trigger_event('render_element_description', $comment); 556 return $comment; 557 } 558 return ''; 559 } 560 561 /** 562 * returns the title of the thumbnail based on photo properties 563 */ 564 function get_thumbnail_title($info, $title, $comment) 565 { 566 global $conf, $user; 567 568 $details = array(); 569 570 if (!empty($info['hit'])) 571 { 572 $details[] = $info['hit'].' '.strtolower(l10n('Visits')); 573 } 574 575 if ($conf['rate'] and !empty($info['rating_score'])) 576 { 577 $details[] = strtolower(l10n('Rating score')).' '.$info['rating_score']; 578 } 579 580 if (isset($info['nb_comments']) and $info['nb_comments'] != 0) 581 { 582 $details[] = l10n_dec('%d comment', '%d comments', $info['nb_comments']); 583 } 584 585 if (count($details) > 0) 586 { 587 $title.= ' ('.implode(', ', $details).')'; 588 } 589 590 if (!empty($comment)) 591 { 592 $title.= ' '.substr($info['comment'], 0, 100).(strlen($info['comment']) > 100 ? '...' : ''); 593 } 594 595 $title = htmlspecialchars(strip_tags($title)); 596 $title = trigger_event('get_thumbnail_title', $title, $info); 597 return $title; 598 } 599 536 600 ?> -
trunk/include/functions_picture.inc.php
r12855 r12920 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 | … … 23 23 24 24 25 26 /*27 * Returns the name of a photo according to its name and its filename.28 * @param name string29 * @param filename string30 * @return string31 */32 function get_image_name($name, $filename)33 {34 if (!empty($name))35 {36 return $name;37 }38 else39 {40 return get_name_from_file($filename);41 }42 }43 44 25 /* 45 26 * @param element_info array containing element information from db; -
trunk/include/template.class.php
r12908 r12920 23 23 24 24 25 require_once(PHPWG_ROOT_PATH.'include/smarty/libs/Smarty.class.php');26 27 28 25 class Template { 29 26 … … 43 40 // used by html_head smarty block to add content before </head> 44 41 var $html_head_elements = array(); 42 private $html_style = ''; 45 43 46 44 const COMBINED_SCRIPTS_TAG = '<!-- COMBINED_SCRIPTS -->'; … … 113 111 $this->smarty->register_modifier( 'get_extent', array(&$this, 'get_extent') ); 114 112 $this->smarty->register_block('html_head', array(&$this, 'block_html_head') ); 113 $this->smarty->register_block('html_style', array(&$this, 'block_html_style') ); 115 114 $this->smarty->register_function('combine_script', array(&$this, 'func_combine_script') ); 116 115 $this->smarty->register_function('get_combined_scripts', array(&$this, 'func_get_combined_scripts') ); … … 467 466 } 468 467 469 if ( count($this->html_head_elements) )468 if ( count($this->html_head_elements) || strlen($this->html_style) ) 470 469 { 471 470 $search = "\n</head>"; … … 473 472 if ($pos !== false) 474 473 { 475 $this->output = substr_replace( $this->output, "\n".implode( "\n", $this->html_head_elements ), $pos, 0 ); 474 $rep = "\n".implode( "\n", $this->html_head_elements ); 475 if (strlen($this->html_style)) 476 { 477 $rep='<style type="text/css">'.$this->html_style.'</style>'; 478 } 479 $this->output = substr_replace( $this->output, $rep, $pos, 0 ); 476 480 } //else maybe error or warning ? 477 481 $this->html_head_elements = array(); 482 $this->html_style = ''; 478 483 } 479 484 … … 530 535 { // second call 531 536 $this->html_head_elements[] = $content; 537 } 538 } 539 540 function block_html_style($params, $content, &$smarty, &$repeat) 541 { 542 $content = trim($content); 543 if ( !empty($content) ) 544 { // second call 545 $this->html_style .= $content; 532 546 } 533 547 } … … 843 857 return call_user_func_array('sprintf', $args ); 844 858 } 845 859 846 860 function derivative_url($type, $img) 847 861 { -
trunk/install.php
r12886 r12920 225 225 226 226 //----------------------------------------------------- template initialization 227 include( PHPWG_ROOT_PATH .'include/template.class.php');228 227 $template = new Template(PHPWG_ROOT_PATH.'admin/themes', 'clear'); 229 228 $template->set_filenames( array('install' => 'install.tpl') ); -
trunk/picture.php
r12887 r12920 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 | … … 177 177 178 178 global $page, $template; 179 179 180 180 if ($show_original) 181 181 { … … 313 313 break; 314 314 } 315 case 'toggle_metadata' :316 {317 break;318 }319 315 case 'add_to_caddie' : 320 316 { … … 335 331 check_input_parameter('comment_to_edit', $_GET, false, PATTERN_ID); 336 332 $author_id = get_comment_author_id($_GET['comment_to_edit']); 337 333 338 334 if (can_manage_comment('edit', $author_id)) 339 335 { … … 365 361 trigger_error('Invalid comment action '.$comment_action, E_USER_WARNING); 366 362 } 367 363 368 364 if ($perform_redirect) 369 365 { … … 501 497 $row['src_image'] = new SrcImage($row); 502 498 $row['derivatives'] = DerivativeImage::get_all($row['src_image']); 503 499 504 500 if ($i=='current') 505 501 { … … 531 527 532 528 $picture[$i] = $row; 533 534 if ( !empty( $row['name'] ) ) 535 { 536 $picture[$i]['name'] = $row['name']; 537 } 538 else 539 { 540 $file_wo_ext = get_filename_wo_extension($row['file']); 541 $picture[$i]['name'] = str_replace('_', ' ', $file_wo_ext); 542 } 543 544 $picture[$i]['name'] = trigger_event('render_element_description', $picture[$i]['name']); 529 $picture[$i]['TITLE'] = render_element_name($row); 545 530 546 531 if ('previous'==$i and $page['previous_item']==$page['first_item']) … … 605 590 } 606 591 607 $title = $picture['current'][' name'];592 $title = $picture['current']['TITLE']; 608 593 $title_nb = ($page['current_rank'] + 1).'/'.count($page['items']); 609 594 … … 644 629 $picture[$which_image], 645 630 array( 646 'TITLE' => $picture[$which_image]['name'],647 631 'THUMB_SRC' => $picture[$which_image]['derivatives'][IMG_THUMB]->get_url(), 648 632 // Params slideshow was transmit to navigation buttons … … 653 637 ) 654 638 ); 655 if ($conf['picture_download_icon'] and !empty($picture['current']['download_url']))656 { 657 $template->append($which_image, array('U_DOWNLOAD' => $picture['current']['download_url']), true); 658 } 659 }639 } 640 } 641 if ($conf['picture_download_icon'] and !empty($picture['current']['download_url'])) 642 { 643 $template->append('current', array('U_DOWNLOAD' => $picture['current']['download_url']), true); 660 644 } 661 645 -
trunk/themes/default/template/mainpage_categories.tpl
r12123 r12920 1 {strip}{html_style} 2 .thumbnailCategory DIV.illustration{ldelim} 3 width: {$derivative_params->max_width()+5}px; 4 } 1 5 6 .content .thumbnailCategory .description{ldelim} 7 height: {$derivative_params->max_height()+5}px; 8 } 9 {/html_style}{/strip} 2 10 <ul class="thumbnailCategories"> 3 11 {foreach from=$category_thumbnails item=cat} … … 6 14 <div class="illustration"> 7 15 <a href="{$cat.URL}"> 8 <img src="{$ cat.TN_SRC}" alt="{$cat.TN_ALT}" title="{$cat.NAME|@replace:'"':' '|@strip_tags:false} - {'display this album'|@translate}">16 <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}"> 9 17 </a> 10 18 </div> -
trunk/themes/default/template/thumbnails.tpl
r12908 r12920 1 1 {if !empty($thumbnails)}{strip} 2 {html_head} 3 <style type="text/css"> 2 {html_style} 4 3 {*Set some sizes according to maximum thumbnail width and height*} 5 4 .thumbnails SPAN, … … 12 11 height: {$derivative_params->max_height()+2}px; 13 12 } 14 15 </style> 16 {/html_head} 13 {if $derivative_params->max_width() > 600} 14 .thumbLegend {ldelim}font-size: 130%} 15 {else} 16 {if $derivative_params->max_width() > 400} 17 .thumbLegend {ldelim}font-size: 110%} 18 {else} 19 .thumbLegend {ldelim}font-size: 90%} 20 {/if} 21 {/if} 22 {/html_style} 17 23 {foreach from=$thumbnails item=thumbnail} 18 24 <li> -
trunk/themes/default/theme.css
r12908 r12920 264 264 /* Thumbnails */ 265 265 .thumbnails SPAN.thumbLegend { 266 font-size: 90%;267 266 overflow: hidden;/* oversized legend is clipped */ 268 267 } -
trunk/upgrade.php
r12768 r12920 217 217 // +-----------------------------------------------------------------------+ 218 218 219 include( PHPWG_ROOT_PATH .'include/template.class.php');220 219 $template = new Template(PHPWG_ROOT_PATH.'admin/themes', 'clear'); 221 220 $template->set_filenames(array('upgrade'=>'upgrade.tpl'));
![(please configure the [header_logo] section in trac.ini)](http://piwigo.org/screenshots/piwigo_logo_on_white.png)