Changeset 12855
- Timestamp:
- Jan 5, 2012, 11:06:21 PM (12 years ago)
- Location:
- trunk
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/action.php
r8728 r12855 61 61 or !is_numeric($_GET['id']) 62 62 or !isset($_GET['part']) 63 or !in_array($_GET['part'], array(' t','e','i','h') ) )63 or !in_array($_GET['part'], array('e','r') ) ) 64 64 { 65 65 do_error(400, 'Invalid request - id/part'); … … 103 103 switch ($_GET['part']) 104 104 { 105 case 't':106 $file = get_thumbnail_path($element_info);107 break;108 105 case 'e': 109 $file = get_element_path($element_info);110 break;111 case 'i':112 $file = get_image_path($element_info);113 break;114 case 'h':115 106 if ( $user['enabled_high']!='true' ) 116 107 { 117 108 do_error(401, 'Access denied h'); 118 109 } 119 $file = get_high_path($element_info); 110 $file = get_element_path($element_info); 111 break; 112 case 'r': 113 $file = original_to_representative( get_element_path($element_info), $element_info['representative_ext'] ); 120 114 break; 121 115 } … … 176 170 $http_headers[] = 'Content-Type: '.$ctype; 177 171 178 if ( !isset($_GET['view']))172 if (isset($_GET['download'])) 179 173 { 180 174 $http_headers[] = 'Content-Disposition: attachment; filename="'.$element_info['file'].'";'; -
trunk/admin/include/functions.php
r12820 r12855 201 201 $files[] = get_element_path($row); 202 202 203 if (!empty($row['tn_ext'])) 204 { 205 $files[] = get_thumbnail_path($row); 206 } 207 208 if (!empty($row['has_high']) and get_boolean($row['has_high'])) 209 { 210 $files[] = get_high_path($row); 211 } 212 203 213 204 if (!empty($row['representative_ext'])) 214 205 { 215 206 $pi = pathinfo($row['path']); 216 207 $file_wo_ext = get_filename_wo_extension($pi['basename']); 217 $files[] = PHPWG_ROOT_PATH.$pi['dirname'].'/pwg_representative/'.$file_wo_ext.'.'.$row['representative_ext'];208 $files[] = original_to_representative( $files[0], $row['representative_ext']); 218 209 } 219 210 -
trunk/admin/picture_modify.php
r12831 r12855 304 304 ); 305 305 306 if ($row['has_high'] == 'true')307 {308 $template->assign(array(309 'HIGH_FILESIZE' => isset($row['high_filesize']) ? $row['high_filesize'].' KB' : l10n('unknown'),310 'HIGH_DIMENSIONS' => isset($row['high_width']) ? $row['high_width'].' * '.$row['high_height'] : l10n('unknown'),311 ));312 }313 314 306 // image level options 315 307 $selected_level = isset($_POST['level']) ? $_POST['level'] : $row['level']; -
trunk/admin/themes/default/template/picture_modify.tpl
r12693 r12855 67 67 </tr> 68 68 69 {if isset($HIGH_FILESIZE) }70 <tr>71 <td><strong>{'High dimensions'|@translate}</strong></td>72 <td>{$HIGH_DIMENSIONS}</td>73 </tr>74 75 <tr>76 <td><strong>{'High filesize'|@translate}</strong></td>77 <td>{$HIGH_FILESIZE}</td>78 </tr>79 {/if}80 81 69 <tr> 82 70 <td><strong>{'Storage album'|@translate}</strong></td> -
trunk/include/derivative.inc.php
r12831 r12855 139 139 } 140 140 141 static function get_all($infos) 142 { 143 $src_image = new SrcImage($infos); 141 static function get_all($src_image) 142 { 144 143 $ret = array(); 145 144 foreach (ImageStdParams::get_defined_type_map() as $type => $params) -
trunk/include/functions.inc.php
r12831 r12855 741 741 } 742 742 743 /** 744 * @param element_info array containing element information from db; 745 * at least 'id', 'path' should be present 746 */ 747 function get_element_path($element_info) 748 { 749 $path = $element_info['path']; 750 if ( !url_is_remote($path) ) 751 { 752 $path = PHPWG_ROOT_PATH.$path; 753 } 754 return $path; 755 } 756 743 757 744 758 /* Returns the PATH to the thumbnail to be displayed. If the element does not -
trunk/include/functions_picture.inc.php
r9366 r12855 22 22 // +-----------------------------------------------------------------------+ 23 23 24 /**25 * @param element_info array containing element information from db;26 * at least 'id', 'path' should be present27 */28 function get_element_path($element_info)29 {30 $path = get_element_location($element_info);31 if ( !url_is_remote($path) )32 {33 $path = PHPWG_ROOT_PATH.$path;34 }35 return $path;36 }37 38 /*39 * @param element_info array containing element information from db;40 * at least 'id', 'path' should be present41 */42 function get_element_url($element_info)43 {44 $url = get_element_location($element_info);45 if ( !url_is_remote($url) )46 {47 $url = embellish_url(get_root_url().$url);48 }49 // plugins want another url ?50 return trigger_event('get_element_url', $url, $element_info);51 }52 53 /**54 * Returns the relative path of the element with regards to to the root55 * of PWG (not the current page). This function is not intended to be56 * called directly from code.57 * @param element_info array containing element information from db;58 * at least 'id', 'path' should be present59 */60 function get_element_location($element_info)61 {62 // maybe a cached watermark ?63 return trigger_event('get_element_location',64 $element_info['path'], $element_info);65 }66 24 67 25 … … 84 42 } 85 43 86 87 /**88 * Returns the PATH to the image to be displayed in the picture page. If the89 * element is not a picture, then the representative image or the default90 * mime image. The path can be used in the php script, but not sent to the91 * browser.92 * @param element_info array containing element information from db;93 * at least 'id', 'path', 'representative_ext' should be present94 */95 function get_image_path($element_info)96 {97 global $conf;98 $ext = get_extension($element_info['path']);99 if (in_array($ext, $conf['picture_ext']))100 {101 if (isset($element_info['element_path']) )102 {103 return $element_info['element_path'];104 }105 return get_element_path($element_info);106 }107 108 $path = get_image_location($element_info);109 if ( !url_is_remote($path) )110 {111 $path = PHPWG_ROOT_PATH.$path;112 }113 return $path;114 }115 116 /**117 * Returns the URL of the image to be displayed in the picture page. If the118 * element is not a picture, then the representative image or the default119 * mime image. The URL can't be used in the php script, but can be sent to the120 * browser.121 * @param element_info array containing element information from db;122 * at least 'id', 'path', 'representative_ext' should be present123 */124 function get_image_url($element_info)125 {126 global $conf;127 $ext = get_extension($element_info['path']);128 if (in_array($ext, $conf['picture_ext']))129 {130 if (isset($element_info['element_url']) )131 {132 return $element_info['element_url'];133 }134 return get_element_url($element_info);135 }136 137 $url = get_image_location($element_info);138 if ( !url_is_remote($url) )139 {140 $url = embellish_url(get_root_url().$url);141 }142 return $url;143 }144 145 /**146 * Returns the relative path of the image (element/representative/mimetype)147 * with regards to the root of PWG (not the current page). This function148 * is not intended to be called directly from code.149 * @param element_info array containing element information from db;150 * at least 'id', 'path', 'representative_ext' should be present151 */152 function get_image_location($element_info)153 {154 if (isset($element_info['representative_ext'])155 and $element_info['representative_ext'] != '')156 {157 $pi = pathinfo($element_info['path']);158 $file_wo_ext = get_filename_wo_extension($pi['basename']);159 $path =160 $pi['dirname'].'/pwg_representative/'161 .$file_wo_ext.'.'.$element_info['representative_ext'];162 }163 else164 {165 $ext = get_extension($element_info['path']);166 $path = get_themeconf('mime_icon_dir');167 $path.= strtolower($ext).'.png';168 if ( !file_exists(PHPWG_ROOT_PATH.$path)169 and !empty($element_info['tn_ext']) )170 {171 $path = get_thumbnail_location($element_info);172 }173 }174 175 // plugins want another location ?176 return trigger_event( 'get_image_location', $path, $element_info);177 }178 179 180 44 /* 181 45 * @param element_info array containing element information from db; … … 223 87 224 88 225 /**226 * @param what_part string one of 't' (thumbnail), 'e' (element), 'i' (image),227 * 'h' (high resolution image)228 * @param element_info array containing element information from db;229 * at least 'id', 'path' should be present230 */231 function get_download_url($what_part, $element_info)232 {233 $url = get_root_url().'action.php';234 $url = add_url_params($url,235 array(236 'id' => $element_info['id'],237 'part' => $what_part,238 )239 );240 return trigger_event( 'get_download_url', $url, $element_info);241 }242 89 243 90 /* -
trunk/include/functions_url.inc.php
r11831 r12855 661 661 } 662 662 663 664 /** 665 * @param id image id 666 * @param what_part string one of 'e' (element), 'r' (representative) 667 */ 668 function get_action_url($id, $what_part, $download) 669 { 670 $params = array( 671 'id' => $id, 672 'part' => $what_part, 673 ); 674 if ($download) 675 { 676 $params['download'] = null; 677 } 678 679 return add_url_params(get_root_url().'action.php', $params); 680 } 681 682 /* 683 * @param element_info array containing element information from db; 684 * at least 'id', 'path' should be present 685 */ 686 function get_element_url($element_info) 687 { 688 $url = $element_info['path']; 689 if ( !url_is_remote($url) ) 690 { 691 $url = embellish_url(get_root_url().$url); 692 } 693 return $url; 694 } 695 696 663 697 /** 664 698 * Indicate to build url with full path -
trunk/include/ws_functions.inc.php
r12831 r12855 148 148 { 149 149 $ret = array(); 150 151 $src_image = new SrcImage($image_row); 152 150 153 global $user; 151 154 if ($user['enabled_high']) … … 154 157 } 155 158 156 $derivatives = DerivativeImage::get_all($ image_row);159 $derivatives = DerivativeImage::get_all($src_image); 157 160 $derivatives_arr = array(); 158 161 foreach($derivatives as $type=>$derivative) -
trunk/picture.php
r12798 r12855 163 163 $selected_derivative = $element_info['derivatives'][$deriv_type]; 164 164 165 $available_derivatives = array(); 165 $unique_derivatives = array(); 166 $show_original = isset($element_info['element_url']); 166 167 $added = array(); 167 168 foreach($element_info['derivatives'] as $type => $derivative) … … 171 172 continue; 172 173 $added[$url] = 1; 173 $available_derivatives[] = $type; 174 } 175 176 global $user, $page, $template; 174 $show_original &= !($derivative->same_as_source()); 175 $unique_derivatives[$type]= $derivative; 176 } 177 178 global $page, $template; 177 179 180 if ($show_original) 181 { 182 $template->assign( 'U_ORIGINAL', $element_info['element_url'] ); 183 } 184 178 185 $template->append('current', array( 179 186 'selected_derivative' => $selected_derivative, 180 ' available_derivative_types' => $available_derivatives,187 'unique_derivatives' => $unique_derivatives, 181 188 ), true); 182 189 … … 492 499 } 493 500 494 495 496 $row['derivatives'] = DerivativeImage::get_all($row); 497 $row['src_image'] = $row['derivatives'][IMG_THUMB]->src_image; 501 $row['src_image'] = new SrcImage($row); 502 $row['derivatives'] = DerivativeImage::get_all($row['src_image']); 498 503 499 // ------ build element_path and element_url500 $row['element_path'] = get_element_path($row);501 $row['element_url'] = get_element_url($row);502 503 504 if ($i=='current') 504 505 { 506 $row['element_path'] = get_element_path($row); 507 505 508 if ( $row['src_image']->is_original() ) 506 { 509 {// we have a photo 507 510 if ( $user['enabled_high']=='true' ) 508 511 { 509 $row['download_url'] = get_download_url('e',$row); 512 $row['element_url'] = $row['src_image']->get_url(); 513 $row['download_url'] = get_action_url($row['id'], 'e', true); 510 514 } 511 515 } 512 516 else 513 517 { // not a pic - need download link 514 $row['download_url'] = $row['element_url'] ;518 $row['download_url'] = $row['element_url'] = get_element_url($row);; 515 519 } 516 520 } -
trunk/themes/default/template/picture_content.tpl
r12797 r12855 3 3 title="{$COMMENT_IMG|@strip_tags:false|@replace:'"':' '}" {else} title="{$current.TITLE|@replace:'"':' '} - {$ALT_IMG}" 4 4 {/if}> 5 {if count($current. available_derivative_types)>1}5 {if count($current.unique_derivatives)>1} 6 6 {footer_script}{literal} 7 7 function changeImgSrc(url,type,display) … … 35 35 <a id="derivativeSwitchLink" onclick="toggleDerivativeSwitchBox()" style="cursor:pointer">{$current.selected_derivative->get_type()|@translate}</a> 36 36 <div id="derivativeSwitchBox" onclick="toggleDerivativeSwitchBox()" style="display:none"> 37 {foreach from=$current. available_derivative_types item=derivative_type}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>37 {foreach from=$current.unique_derivatives item=derivative key=derivative_type} 38 <a href="javascript:changeImgSrc('{$derivative->get_url()|@escape:javascript}', '{$derivative_type}', '{$derivative->get_type()|@translate|@escape:javascript}')" style="cursor:pointer">{$derivative->get_type()|@translate} ({$derivative->get_size_hr()})</a><br> 39 39 {/foreach} 40 {if isset($U_ORIGINAL)} 41 <a href="javascript:phpWGOpenWindow('{$U_ORIGINAL}','xxx','scrollbars=yes,toolbar=no,status=no,resizable=yes')" title="{'Click on the photo to see it in high definition'|@translate}">{'original'|@translate}</a> 42 {/if} 40 43 </div> 41 44 {/if} -
trunk/tools/triggers_list.php
r12608 r12855 160 160 'vars' => array('string' => 'url', 'array' => 'element_info'), 161 161 'files' => array('include\functions_picture.inc.php (get_download_url'), 162 ),163 array(164 'name' => 'get_element_location',165 'type' => 'trigger_event',166 'vars' => array('string' => 'path', 'array' => 'element_info'),167 'files' => array('include\functions_picture.inc.php (get_element_location)'),168 162 ), 169 163 array(
Note: See TracChangeset
for help on using the changeset viewer.