Changeset 12920 for trunk/include
- Timestamp:
- Jan 17, 2012, 10:58:18 PM (12 years ago)
- Location:
- trunk/include
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
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 {
Note: See TracChangeset
for help on using the changeset viewer.