Changeset 12733 for extensions/GThumb
- Timestamp:
- Dec 14, 2011, 5:54:42 PM (13 years ago)
- Location:
- extensions/GThumb
- Files:
-
- 1 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/GThumb/admin.php
r12696 r12733 3 3 if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); 4 4 5 global $template, $conf ;5 global $template, $conf, $page; 6 6 7 7 load_language('plugin.lang', GTHUMB_PATH); … … 16 16 gtdeltree(GTHUMB_CACHE_DIR); 17 17 redirect('admin.php?page=plugin-GThumb'); 18 } 19 20 // Generate cache 21 if (isset($_GET['generatecache'])) 22 { 23 if ($_GET['generatecache'] == 'complete') 24 { 25 array_push($page['infos'], l10n('Cache have been generated')); 26 } 27 else 28 { 29 $query = 'SELECT id, path, md5sum, tn_ext FROM '.IMAGES_TABLE.';'; 30 $result = pwg_query($query); 31 $cache_dir = GTHUMB_CACHE_DIR.'/'.$conf['GThumb']['height'].'/'; 32 $missing = array(); 33 34 while ($row = pwg_db_fetch_assoc($result)) 35 { 36 if (!is_file($cache_dir.md5($row['path'].(!empty($row['md5sum']) ? $row['md5sum'] : '')).'.'.$row['tn_ext']) 37 and in_array(get_extension($row['path']), $conf['picture_ext'])) 38 { 39 array_push($missing, $row['id']); 40 } 41 } 42 echo json_encode($missing); 43 exit(); 44 } 18 45 } 19 46 … … 70 97 // Informations 71 98 $data = gtdirsize(GTHUMB_CACHE_DIR); 72 if ($data['size'] > 1024 * 1024)73 $data['size'] = round($data['size'] / (1024 * 1024), 2).' MB';74 else75 $data['size'] = round($data['size'] / 1024, 2).' KB';76 99 77 100 $template->assign( 78 101 array( 79 'NB_ ELEMENTS' => l10n_dec('%d file', '%d files', $data['nb_files']),80 ' ELEMENTS_SIZE' => $data['size'],102 'NB_FILES' => $data['nb_files'], 103 'CACHE_SIZE' => $data['size'], 81 104 'PWG_TOKEN' => get_pwg_token(), 82 105 ) -
extensions/GThumb/functions.inc.php
r12732 r12733 80 80 'width' => $result['width'], 81 81 'height' => $result['height'], 82 'filesize' => filesize($file), 82 83 ); 83 84 } -
extensions/GThumb/language/en_UK/plugin.lang.php
r12696 r12733 7 7 $lang['Scale thumbnails'] = 'Scale thumbnails'; 8 8 $lang['Cache Informations'] = 'Cache Informations'; 9 $lang[' Clear the cache'] = 'Clear thecache';9 $lang['Purge thumbnails cache'] = 'Purge thumbnails cache'; 10 10 $lang['%d file'] = '%d file'; 11 11 $lang['%d files'] = '%d files'; 12 $lang['Cache have been generated'] = 'Cache have been generated'; 13 $lang['Pre-cache thumbnails'] = 'Pre-cache thumbnails'; 12 14 13 15 ?> -
extensions/GThumb/language/fr_FR/plugin.lang.php
r12696 r12733 7 7 $lang['Scale thumbnails'] = 'Redimensionner les miniatures'; 8 8 $lang['Cache Informations'] = 'Informations du cache'; 9 $lang[' Clear the cache'] = 'Effacer le cache';9 $lang['Purge thumbnails cache'] = 'Vider le cache'; 10 10 $lang['%d file'] = '%d fichier'; 11 11 $lang['%d files'] = '%d fichiers'; 12 $lang['Cache have been generated'] = 'Le cache a été généré'; 13 $lang['Pre-cache thumbnails'] = 'Mettre en cache les miniatures'; 12 14 13 15 ?> -
extensions/GThumb/main.inc.php
r12732 r12733 144 144 global $conf; 145 145 146 if (!in_array(get_extension($picture[' file']), $conf['picture_ext']))146 if (!in_array(get_extension($picture['path']), $conf['picture_ext'])) 147 147 { 148 148 $file = get_thumbnail_url($picture); -
extensions/GThumb/template/admin.tpl
r12691 r12733 52 52 <fieldset id="cacheinfo"> 53 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> 54 <p id="cache_data"> </p> 55 <p id="GThumbAction"> 56 <button onclick="GThumb.deletecache();">{'Purge thumbnails cache'|@translate}</button> 57 <button onclick="GThumb.generatecache();">{'Pre-cache thumbnails'|@translate}</button> 57 58 </p> 59 <div id="GThumbProgressbar" style="display:none;"> 60 {'Generating cache, please wait...'|@translate}<br> 61 <div id="progressbar"></div> 62 </div> 58 63 </fieldset> 59 64 … … 61 66 <style type="text/css"> 62 67 #GThumb td { padding-bottom: 12px; } 63 #cacheinfo p { text-align:left; line-height:20px; margin:20px } 68 #cacheinfo p, #GThumbProgressbar { text-align:left; line-height:20px; margin:20px } 69 .ui-progressbar-value { background-image: url(plugins/GThumb/template/pbar-ani.gif); } 64 70 </style> 65 71 {/literal}{/html_head} 72 73 {combine_script id='jquery.ui.progressbar' load='footer'} 74 {combine_script id='jquery.ajaxmanager' load='footer' path='themes/default/js/plugins/jquery.ajaxmanager.js'} 75 76 {footer_script} 77 var pwg_token = '{$PWG_TOKEN}'; 78 var confirm_message = '{'Are you sure?'|@translate}'; 79 var nb_files_str = '{'%d file'|@translate}'; 80 var nb_files_str_plur = '{'%d files'|@translate}'; 81 var lang_info_zero_plural = {if $lang_info.zero_plural}true{else}false{/if}; 82 var cache_size = {$CACHE_SIZE}; 83 var nb_files = {$NB_FILES}; 84 85 {literal} 86 var GThumb = { 87 88 total: 0, 89 done: 0, 90 91 queue: jQuery.manageAjax.create('queued', { 92 queue: true, 93 cacheResponse: false, 94 maxRequests: 3 95 }), 96 97 deletecache: function() { 98 if (confirm(confirm_message)) { 99 window.location = 'admin.php?page=plugin-GThumb&deletecache=true&pwg_token='+pwg_token; 100 } 101 }, 102 103 generatecache: function() { 104 jQuery("#progressbar").progressbar({value: 0}); 105 jQuery.ajax({ 106 url: 'admin.php?page=plugin-GThumb&generatecache=request', 107 dataType: 'json', 108 success: function(data) { 109 if (data.length > 0) { 110 jQuery("#GThumbProgressbar, #GThumbAction").toggle(); 111 GThumb.total = data.length; 112 for (i=0;i<data.length;i++) { 113 GThumb.queue.add({ 114 type: 'GET', 115 url: 'ws.php', 116 data: { 117 method: 'pwg.images.getGThumbPlusThumbnail', 118 image_id: data[i], 119 format: 'json' 120 }, 121 dataType: 'json', 122 success: function(data) { 123 nb_files++; 124 cache_size += data.result.filesize; 125 updateCacheSizeAndFiles(); 126 GThumb.progressbar(); 127 }, 128 error: GThumb.progressbar 129 }); 130 } 131 } else { 132 window.location = 'admin.php?page=plugin-GThumb&generatecache=complete'; 133 } 134 }, 135 error: function() { 136 alert('An error occured'); 137 } 138 }); 139 return false; 140 }, 141 142 progressbar: function() { 143 jQuery( "#progressbar" ).progressbar({ 144 value: Math.round(++GThumb.done * 100 / GThumb.total) 145 }); 146 if (GThumb.done == GThumb.total) { 147 window.location = 'admin.php?page=plugin-GThumb&generatecache=complete'; 148 } 149 } 150 }; 151 152 function updateCacheSizeAndFiles() { 153 154 if ( nb_files > 1 || (nb_files == 0 && lang_info_zero_plural)) { 155 nbstr = nb_files_str_plur; 156 } else { 157 nbstr = nb_files_str; 158 } 159 160 ret = nbstr.replace('%d', nb_files) + ', '; 161 162 if (cache_size > 1024 * 1024) 163 ret += Math.round((cache_size / (1024 * 1024))*100)/100 + ' MB'; 164 else 165 ret += Math.round((cache_size / 1024)*100)/100 + ' KB'; 166 167 jQuery("#cache_data").html(ret); 168 } 169 170 updateCacheSizeAndFiles(); 171 {/literal}{/footer_script}
Note: See TracChangeset
for help on using the changeset viewer.