Changeset 12691
- Timestamp:
- Dec 3, 2011, 6:11:54 PM (12 years ago)
- Location:
- extensions/GThumb
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/GThumb/admin.php
r12678 r12691 9 9 include(dirname(__FILE__).'/config_default.inc.php'); 10 10 $params = $conf['GThumb']; 11 12 // Delete cache 13 if (isset($_GET['deletecache'])) 14 { 15 check_pwg_token(); 16 gtdeltree(GTHUMB_CACHE_DIR); 17 redirect('admin.php?page=plugin-GThumb'); 18 } 11 19 12 20 // Save configuration … … 60 68 ); 61 69 70 // Informations 71 $data = gtdirsize(GTHUMB_CACHE_DIR); 72 if ($data['size'] > 1024 * 1024) 73 $data['size'] = round($data['size'] / (1024 * 1024), 2).' MB'; 74 else 75 $data['size'] = round($data['size'] / 1024, 2).' KB'; 76 77 $template->assign( 78 array( 79 'NB_ELEMENTS' => l10n_dec('%d photo', '%d photos', $data['nb_files']), 80 'ELEMENTS_SIZE' => $data['size'], 81 'PWG_TOKEN' => get_pwg_token(), 82 ) 83 ); 84 62 85 $template->set_filenames(array('plugin_admin_content' => dirname(__FILE__) . '/template/admin.tpl')); 63 86 $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content'); -
extensions/GThumb/functions.inc.php
r12678 r12691 131 131 } 132 132 133 function gtdirsize($path, &$size=0, &$nb_files=0) 134 { 135 if (is_dir($path)) 136 { 137 $fh = opendir($path); 138 while ($file = readdir($fh)) 139 { 140 if ($file != '.' and $file != '..' and $file != 'index.htm') 141 { 142 $pathfile = $path . '/' . $file; 143 if (is_dir($pathfile)) 144 { 145 $data = gtdirsize($pathfile, $size, $nb_files); 146 } 147 else 148 { 149 $size += filesize($pathfile); 150 $nb_files++; 151 } 152 } 153 } 154 closedir($fh); 155 } 156 return array( 157 'size' => $size, 158 'nb_files' => $nb_files, 159 ); 160 } 161 133 162 ?> -
extensions/GThumb/js/gthumb.js
r12680 r12691 73 73 74 74 // Compute best size for landscape picture (we choose bigger height) 75 min_ratio = Math.min(1 , this.big_thumb.width/this.big_thumb.height);75 min_ratio = Math.min(1.05, this.big_thumb.width/this.big_thumb.height); 76 76 77 77 for(width = this.big_thumb.width; width/best_size.height>=min_ratio; width--) { … … 118 118 } 119 119 this.t[0].crop = best_size.width; 120 this.resize(first_thumb, this.big_thumb.width, this.big_thumb.height, best_size.width, best_size.height, 'crop');120 this.resize(first_thumb, this.big_thumb.width, this.big_thumb.height, best_size.width, best_size.height, true); 121 121 122 122 } … … 164 164 new_width = Math.round(new_width); 165 165 } 166 this.resize(jQuery('#gt'+thumb_process[j].id), thumb_process[j].width, thumb_process[j].height, new_width, new_height, this.method);166 this.resize(jQuery('#gt'+thumb_process[j].id), thumb_process[j].width, thumb_process[j].height, new_width, new_height, false); 167 167 168 168 width_count += new_width + this.margin; … … 177 177 // Last line does not need to be cropped 178 178 for (j=0;j<thumb_process.length;j++) { 179 this.resize(jQuery('#gt'+thumb_process[j].id), thumb_process[j].width, thumb_process[j].height, thumb_process[j].width, max_height, this.method);179 this.resize(jQuery('#gt'+thumb_process[j].id), thumb_process[j].width, thumb_process[j].height, thumb_process[j].width, max_height, false); 180 180 } 181 181 … … 185 185 }, 186 186 187 resize: function(thumb, width, height, new_width, new_height, method) { 188 189 if (method == 'resize') { 187 resize: function(thumb, width, height, new_width, new_height, is_big) { 188 189 if (this.method == 'resize') { 190 real_width = Math.min(new_width, width); 191 real_height = Math.min(new_height, height); 192 width_crop = 0; 193 height_crop = 0; 194 195 if (is_big) { 196 if (width - new_width > height - new_height) { 197 real_width = Math.round(new_height * width / height); 198 width_crop = Math.round((real_width - new_width)/2); 199 } else { 200 real_height = Math.round(new_width * height / width); 201 height_crop = Math.round((real_height - new_height)/2); 202 } 203 } 190 204 thumb.css({ 191 height: new_height+'px',192 width: new_width+'px'205 height: real_height+'px', 206 width: real_width+'px' 193 207 }); 194 height_crop = 0;195 width_crop = 0;196 208 } else { 197 209 thumb.css({height: '', width: ''}); -
extensions/GThumb/language/en_UK/plugin.lang.php
r12678 r12691 6 6 $lang['Cache the big thumbnails (recommended)'] = 'Cache the big thumbnails (recommended)'; 7 7 $lang['Scale thumbnails'] = 'Scale thumbnails'; 8 $lang['Cache Informations'] = 'Cache Informations'; 9 $lang['Clear the cache'] = 'Clear the cache'; 8 10 9 11 ?> -
extensions/GThumb/language/fr_FR/plugin.lang.php
r12678 r12691 6 6 $lang['Cache the big thumbnails (recommended)'] = 'Mettre en cache les grosse miniatures (recommandé)'; 7 7 $lang['Scale thumbnails'] = 'Redimensionner les miniatures'; 8 $lang['Cache Informations'] = 'Informations du cache'; 9 $lang['Clear the cache'] = 'Effacer le cache'; 8 10 9 11 ?> -
extensions/GThumb/template/admin.tpl
r12678 r12691 50 50 </form> 51 51 52 <fieldset id="cacheinfo"> 53 <legend>{'Cache Informations'|@translate}</legend> 54 <p> 55 {$NB_ELEMENTS}, {$ELEMENTS_SIZE}<br> 56 <a href="admin.php?page=plugin-GThumb&pwg_token={$PWG_TOKEN}&deletecache=true" onclick="return confirm('{'Are you sure?'|@translate}');">{'Clear the cache'|@translate}</a> 57 </p> 58 </fieldset> 59 52 60 {html_head}{literal} 53 <style type="text/css">#GThumb td { padding-bottom: 12px; }</style> 61 <style type="text/css"> 62 #GThumb td { padding-bottom: 12px; } 63 #cacheinfo p { text-align:left; line-height:20px; margin:20px } 64 </style> 54 65 {/literal}{/html_head} -
extensions/GThumb/template/gthumb.css
r12678 r12691 16 16 position: absolute; 17 17 } 18 19 .thumbnail, .thumbnail:hover { 20 border: 0 none; 21 } -
extensions/GThumb/template/gthumb.tpl
r12678 r12691 18 18 GThumb.margin = {$GThumb.margin}; 19 19 GThumb.method = '{$GThumb.method}'; 20 20 GThumb.small_thumb = {ldelim}id:{$small_thumb.id},src:'{$small_thumb.src}',width:{$small_thumb.width},height:{$small_thumb.height}{rdelim}; 21 21 {if isset($big_thumb)} 22 22 GThumb.big_thumb = {ldelim}id:{$big_thumb.id},src:'{$big_thumb.src}',width:{$big_thumb.width},height:{$big_thumb.height}{rdelim}; 23 GThumb.small_thumb = {ldelim}id:{$small_thumb.id},src:'{$small_thumb.src}',width:{$small_thumb.width},height:{$small_thumb.height}{rdelim};24 23 {/if} 25 24
Note: See TracChangeset
for help on using the changeset viewer.