Changeset 12797
- Timestamp:
- Dec 27, 2011, 9:26:49 PM (12 years ago)
- Location:
- trunk
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/admin/include/functions.php
r12763 r12797 2247 2247 return array_from_query($query, 'user_id'); 2248 2248 } 2249 2250 function clear_derivative_cache($type='all') 2251 { 2252 $pattern='#.*-'; 2253 if ($type == 'all') 2254 { 2255 $type_urls = array(); 2256 foreach(ImageStdParams::get_all_types() as $dtype) 2257 { 2258 $type_urls[] = derivative_to_url($dtype); 2259 } 2260 $type_urls[] = derivative_to_url(IMG_CUSTOM); 2261 $pattern .= '(' . implode('|',$type_urls) . ')'; 2262 } 2263 else 2264 { 2265 $pattern .= derivative_to_url($type); 2266 } 2267 $pattern.='(_[a-zA-Z0-9]+)*\.[a-zA-Z0-9]{3,4}$#'; 2268 if ($contents = opendir(PHPWG_ROOT_PATH.PWG_DERIVATIVE_DIR)) 2269 { 2270 while (($node = readdir($contents)) !== false) 2271 { 2272 if ($node != '.' 2273 and $node != '..' 2274 and is_dir(PHPWG_ROOT_PATH.PWG_DERIVATIVE_DIR.$node)) 2275 { 2276 clear_derivative_cache_rec(PHPWG_ROOT_PATH.PWG_DERIVATIVE_DIR.$node, $pattern); 2277 } 2278 } 2279 closedir($contents); 2280 } 2281 } 2282 2283 function clear_derivative_cache_rec($path, $pattern) 2284 { 2285 $rmdir = true; 2286 $rm_index = false; 2287 2288 if ($contents = opendir($path)) 2289 { 2290 while (($node = readdir($contents)) !== false) 2291 { 2292 if ($node == '.' or $node == '..') 2293 continue; 2294 if (is_dir($path.'/'.$node)) 2295 { 2296 $rmdir &= clear_derivative_cache_rec($path.'/'.$node, $pattern); 2297 } 2298 else 2299 { 2300 if (preg_match($pattern, $node)) 2301 { 2302 unlink($path.'/'.$node); 2303 } 2304 elseif ($node=='index.htm') 2305 { 2306 $rm_index = true; 2307 } 2308 else 2309 { 2310 $rmdir = false; 2311 } 2312 } 2313 } 2314 closedir($contents); 2315 2316 if ($rmdir) 2317 { 2318 if ($rm_index) 2319 { 2320 unlink($path.'/index.htm'); 2321 } 2322 clearstatcache(); 2323 rmdir($path); 2324 } 2325 return $rmdir; 2326 } 2327 } 2249 2328 ?> -
trunk/admin/maintenance.php
r11827 r12797 122 122 break; 123 123 } 124 case 'compiled-templates' 124 case 'compiled-templates': 125 125 { 126 126 $template->delete_compiled_templates(); 127 127 FileCombiner::clear_combined_files(); 128 break; 129 } 130 case 'derivatives': 131 { 132 clear_derivative_cache(); 128 133 break; 129 134 } … … 155 160 'U_MAINT_SEARCH' => sprintf($url_format, 'search'), 156 161 'U_MAINT_COMPILED_TEMPLATES' => sprintf($url_format, 'compiled-templates'), 162 'U_MAINT_DERIVATIVES' => sprintf($url_format, 'derivatives'), 157 163 'U_HELP' => get_root_url().'admin/popuphelp.php?page=maintenance', 158 164 ) -
trunk/admin/rating.php
r12796 r12797 173 173 i.path, 174 174 i.file, 175 i. tn_ext,175 i.representative_ext, 176 176 i.rating_score AS score, 177 177 MAX(r.date) AS recently_rated, -
trunk/admin/themes/default/template/maintenance.tpl
r10133 r12797 30 30 <li><a href="{$U_MAINT_SEARCH}"onclick="return confirm('{'Purge search history'|@translate|@escape:'javascript'}');">{'Purge search history'|@translate}</a></li> 31 31 <li><a href="{$U_MAINT_COMPILED_TEMPLATES}">{'Purge compiled templates'|@translate}</a></li> 32 <li><a href="{$U_MAINT_DERIVATIVES}">{'Purge derivative image cache'|@translate}</a></li> 32 33 </ul> -
trunk/i.php
r12796 r12797 136 136 foreach (ImageStdParams::get_defined_type_map() as $type => $params) 137 137 { 138 if ( substr($type,0,2) == $deriv[0])138 if ( derivative_to_url($type) == $deriv[0]) 139 139 { 140 140 $page['derivative_type'] = $type; … … 146 146 if (!isset($page['derivative_type'])) 147 147 { 148 if ( substr(IMG_CUSTOM,0,2) == $deriv[0])148 if (derivative_to_url(IMG_CUSTOM) == $deriv[0]) 149 149 { 150 150 $page['derivative_type'] = IMG_CUSTOM; … … 289 289 290 290 fpassthru($fp); 291 exit;291 fclose($fp); 292 292 ?> -
trunk/include/derivative.inc.php
r12796 r12797 22 22 final class SrcImage 23 23 { 24 const IS_ORIGINAL = 0x01; 25 const IS_MIMETYPE = 0x02; 26 24 27 public $rel_path; 25 28 26 29 public $coi=null; 27 30 private $size=null; 31 private $flags=0; 28 32 29 33 function __construct($infos) … … 35 39 { 36 40 $this->rel_path = $infos['path']; 41 $this->flags |= self::IS_ORIGINAL; 37 42 } 38 43 elseif (!empty($infos['representative_ext'])) … … 45 50 else 46 51 { 47 $this->rel_path = get_themeconf('mime_icon_dir').strtolower($ext).'.png'; 52 $ext = strtolower($ext); 53 $this->rel_path = trigger_event('get_mimetype_location', get_themeconf('mime_icon_dir').$ext.'.png', $ext ); 54 $this->flags |= self::IS_MIMETYPE; 55 $this->size = @getimagesize(PHPWG_ROOT_PATH.$this->rel_path); 48 56 } 49 57 50 58 $this->coi = @$infos['coi']; 51 if ( isset($infos['width']) && isset($infos['height']))59 if (!$this->size && isset($infos['width']) && isset($infos['height'])) 52 60 { 53 61 $this->size = array($infos['width'], $infos['height']); 54 62 } 63 } 64 65 function is_original() 66 { 67 return $this->flags & self::IS_ORIGINAL; 68 } 69 70 function is_mimetype() 71 { 72 return $this->flags & self::IS_MIMETYPE; 73 } 74 75 function get_path() 76 { 77 return PHPWG_ROOT_PATH.$this->rel_path; 78 } 79 80 function get_url() 81 { 82 return get_root_url().$this->rel_path; 55 83 } 56 84 … … 127 155 $ret[$type] = $ret[$type2]; 128 156 } 129 157 130 158 return $ret; 131 159 } … … 145 173 $tokens[] = substr($params->type,0,2); 146 174 147 if ( !empty($src->coi))175 if ($params->sizing->max_crop != 0 and !empty($src->coi)) 148 176 { 149 177 $tokens[] = 'ci'.$src->coi; … … 207 235 208 236 237 function get_type() 238 { 239 if ($this->flags & self::SAME_AS_SRC) 240 return 'original'; 241 return $this->params->type; 242 } 243 209 244 /* returns the size of the derivative image*/ 210 245 function get_size() -
trunk/include/derivative_params.inc.php
r12796 r12797 20 20 // +-----------------------------------------------------------------------+ 21 21 22 function derivative_to_url($t) 23 { 24 return substr($t, 0, 2); 25 } 26 22 27 function size_to_url($s) 23 28 { -
trunk/include/picture_metadata.inc.php
r12796 r12797 37 37 } 38 38 39 $exif = get_exif_data($picture['current'][' image_path'], $exif_mapping);39 $exif = get_exif_data($picture['current']['src_image']->get_path(), $exif_mapping); 40 40 41 41 if (count($exif) > 0) … … 80 80 if ($conf['show_iptc']) 81 81 { 82 $iptc = get_iptc_data($picture['current'][' image_path'], $conf['show_iptc_mapping']);82 $iptc = get_iptc_data($picture['current']['src_image']->get_path(), $conf['show_iptc_mapping']); 83 83 84 84 if (count($iptc) > 0) -
trunk/picture.php
r12796 r12797 475 475 $i = 'previous'; 476 476 } 477 else 477 elseif (isset($page['next_item']) and $row['id'] == $page['next_item']) 478 478 { 479 479 $i = 'next'; 480 480 } 481 else 481 elseif (isset($page['first_item']) and $row['id'] == $page['first_item']) 482 482 { 483 483 $i = 'first'; 484 484 } 485 else 485 elseif (isset($page['last_item']) and $row['id'] == $page['last_item']) 486 486 { 487 487 $i = 'last'; … … 492 492 } 493 493 494 $picture[$i] = $row; 495 496 $picture[$i]['is_picture'] = false; 497 if (in_array(get_extension($row['file']), $conf['picture_ext'])) 498 { 499 $picture[$i]['is_picture'] = true; 500 } 501 502 $picture[$i]['derivatives'] = DerivativeImage::get_all($row); 503 $picture[$i]['src_image'] = $picture[$i]['derivatives'][IMG_THUMB]->src_image; 504 $picture[$i]['thumbnail'] = $picture[$i]['derivatives'][IMG_THUMB]->get_url(); 494 495 496 $row['derivatives'] = DerivativeImage::get_all($row); 497 $row['src_image'] = $row['derivatives'][IMG_THUMB]->src_image; 505 498 506 499 // ------ build element_path and element_url 507 $picture[$i]['element_path'] = get_element_path($picture[$i]); 508 $picture[$i]['element_url'] = get_element_url($picture[$i]); 509 510 // ------ build image_path and image_url 511 if ($i=='current' or $i=='next') 512 { 513 $picture[$i]['image_path'] = get_image_path( $picture[$i] ); 514 $picture[$i]['image_url'] = get_image_url( $picture[$i] ); 515 } 500 $row['element_path'] = get_element_path($row); 501 $row['element_url'] = get_element_url($row); 516 502 517 503 if ($i=='current') 518 504 { 519 if ( $ picture[$i]['is_picture'])505 if ( $row['src_image']->is_original() ) 520 506 { 521 507 if ( $user['enabled_high']=='true' ) 522 508 { 523 $ picture[$i]['download_url'] = get_download_url('e',$picture[$i]);509 $row['download_url'] = get_download_url('e',$row); 524 510 } 525 511 } 526 512 else 527 513 { // not a pic - need download link 528 $picture[$i]['download_url'] = get_download_url('e',$picture[$i]); 529 } 530 } 531 532 533 if ( !empty( $row['name'] ) ) 534 { 535 $picture[$i]['name'] = $row['name']; 536 } 537 else 538 { 539 $file_wo_ext = get_filename_wo_extension($row['file']); 540 $picture[$i]['name'] = str_replace('_', ' ', $file_wo_ext); 541 } 542 543 $picture[$i]['name'] = trigger_event('render_element_description', $picture[$i]['name']); 544 545 $picture[$i]['url'] = duplicate_picture_url( 514 $row['download_url'] = $row['element_url']; 515 } 516 } 517 518 $row['url'] = duplicate_picture_url( 546 519 array( 547 520 'image_id' => $row['id'], … … 553 526 ); 554 527 528 $picture[$i] = $row; 529 530 if ( !empty( $row['name'] ) ) 531 { 532 $picture[$i]['name'] = $row['name']; 533 } 534 else 535 { 536 $file_wo_ext = get_filename_wo_extension($row['file']); 537 $picture[$i]['name'] = str_replace('_', ' ', $file_wo_ext); 538 } 539 540 $picture[$i]['name'] = trigger_event('render_element_description', $picture[$i]['name']); 541 555 542 if ('previous'==$i and $page['previous_item']==$page['first_item']) 556 543 { … … 560 547 { 561 548 $picture['last'] = $picture[$i]; 562 }563 }564 565 // calculation of width and height for the current picture566 if (empty($picture['current']['width']))567 {568 $taille_image = @getimagesize($picture['current']['image_path']);569 if ($taille_image!==false)570 {571 $picture['current']['width'] = $taille_image[0];572 $picture['current']['height']= $taille_image[1];573 549 } 574 550 } … … 638 614 ( 639 615 ($conf['show_exif'] or $conf['show_iptc']) 640 and isset($picture['current']['image_path'])616 and !$picture['current']['src_image']->is_mimetype() 641 617 ), 642 $picture['current'] ['path']618 $picture['current'] 643 619 ); 644 620 … … 653 629 // allow plugins to change what we computed before passing data to template 654 630 $picture = trigger_event('picture_pictures_data', $picture); 655 656 657 if (isset($picture['next']['image_url'])658 and $picture['next']['is_picture']659 and strpos($_SERVER['HTTP_USER_AGENT'], 'Chrome/') === false)660 {661 $template->assign('U_PREFETCH', $picture['next']['image_url'] );662 }663 631 664 632 //------------------------------------------------------- navigation management … … 673 641 array( 674 642 'TITLE' => $picture[$which_image]['name'], 675 'THUMB_SRC' => $picture[$which_image][' thumbnail'],643 'THUMB_SRC' => $picture[$which_image]['derivatives'][IMG_THUMB]->get_url(), 676 644 // Params slideshow was transmit to navigation buttons 677 645 'U_IMG' => … … 889 857 890 858 // size in pixels 891 if ($picture['current'][' is_picture']and isset($picture['current']['width']) )859 if ($picture['current']['src_image']->is_original() and isset($picture['current']['width']) ) 892 860 { 893 861 $infos['INFO_DIMENSIONS'] = … … 981 949 $template->assign( 'ELEMENT_CONTENT', $element_content ); 982 950 951 if (isset($picture['next']) 952 and $picture['next']['src_image']->is_original() 953 and strpos($_SERVER['HTTP_USER_AGENT'], 'Chrome/') === false) 954 { 955 $template->assign('U_PREFETCH', $picture['next']['derivatives'][pwg_get_session_var('picture_deriv', IMG_LARGE)]->get_url() ); 956 } 957 958 983 959 // +-----------------------------------------------------------------------+ 984 960 // | sub pages | -
trunk/themes/clear/theme.css
r8306 r12797 15 15 } 16 16 17 #menubar DL, .content, #imageToolBar, .header_notes {17 #menubar DL, .content, #imageToolBar, #derivativeSwitchLink, #derivativeSwitchBox, .header_notes { 18 18 background-color: #eeeeee; 19 19 } 20 20 21 21 /* borders */ 22 #menubar DL, .content, #imageToolBar {22 #menubar DL, .content, #imageToolBar, #derivativeSwitchLink, #derivativeSwitchBox { 23 23 border: 1px solid #d3d3d3; 24 24 } -
trunk/themes/dark/theme.css
r11992 r12797 17 17 } 18 18 19 #menubar DL, .content, #imageToolBar, #imageHeaderBar, .header_notes {19 #menubar DL, .content, #imageToolBar, #imageHeaderBar, #derivativeSwitchLink, #derivativeSwitchBox, .header_notes { 20 20 background-color: #505050; 21 21 } … … 35 35 36 36 /* borders */ 37 #menubar DL, .content {37 #menubar DL, .content, #derivativeSwitchLink, #derivativeSwitchBox{ 38 38 border: 1px solid #000; 39 39 } -
trunk/themes/default/template/picture_content.tpl
r12796 r12797 5 5 {if count($current.available_derivative_types)>1} 6 6 {footer_script}{literal} 7 function changeImgSrc(url,type )7 function changeImgSrc(url,type,display) 8 8 { 9 9 var theImg = document.getElementById("theMainImage"); … … 12 12 theImg.removeAttribute("width");theImg.removeAttribute("height"); 13 13 theImg.src = url; 14 var elt = document.getElementById("derivativeSwitchLink"); 15 if (elt) elt.innerHTML = display; 14 16 } 15 17 document.cookie = 'picture_deriv=' + type; 16 18 } 19 20 function toggleDerivativeSwitchBox() 21 { 22 var elt = document.getElementById("derivativeSwitchBox"), 23 ePos = document.getElementById("derivativeSwitchLink"); 24 if (elt.style.display==="none") 25 { 26 elt.style.position = "absolute"; 27 elt.style.left = (ePos.offsetLeft + 10) + "px"; 28 elt.style.top = (ePos.offsetTop + ePos.offsetHeight) + "px"; 29 elt.style.display=""; 30 } 31 else 32 elt.style.display="none"; 33 } 17 34 {/literal}{/footer_script} 18 <p> 35 <a id="derivativeSwitchLink" onclick="toggleDerivativeSwitchBox()" style="cursor:pointer">{$current.selected_derivative->get_type()|@translate}</a> 36 <div id="derivativeSwitchBox" onclick="toggleDerivativeSwitchBox()" style="display:none"> 19 37 {foreach from=$current.available_derivative_types item=derivative_type} 20 <a onclick="changeImgSrc('{$current.derivatives[$derivative_type]->get_url()|@escape:javascript}', '{$derivative_type}' )" title="{$current.derivatives[$derivative_type]->get_size_hr()}">{$derivative_type}</a>38 <a onclick="changeImgSrc('{$current.derivatives[$derivative_type]->get_url()|@escape:javascript}', '{$derivative_type}', '{$derivative_type|@translate|@escape:javascript}')" style="cursor:pointer">{$derivative_type|@translate} ({$current.derivatives[$derivative_type]->get_size_hr()})</a><br> 21 39 {/foreach} 22 </ p>40 </div> 23 41 {/if} -
trunk/themes/default/theme.css
r12764 r12797 338 338 #imageToolBar .pwg-button {width:42px;} 339 339 340 341 #derivativeSwitchLink { 342 padding: 0.2em; 343 position: absolute; 344 left: 5px; 345 top: 100px; 346 } 347 348 #derivativeSwitchBox { 349 padding: 0.5em; 350 border-radius: 4px; 351 z-index: 100; 352 } 340 353 341 354 #theImage {
Note: See TracChangeset
for help on using the changeset viewer.