Changeset 13652
- Timestamp:
- Mar 20, 2012, 11:32:30 PM (12 years ago)
- Location:
- extensions/GThumb
- Files:
-
- 1 deleted
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/GThumb/admin.php
r12758 r13652 3 3 if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); 4 4 5 function delete_gthumb_cache($height) 6 { 7 $pattern = '#.*-cu_s9999x'.$height.'\.[a-zA-Z0-9]{3,4}$#'; 8 if ($contents = @opendir(PHPWG_ROOT_PATH.PWG_DERIVATIVE_DIR)) 9 { 10 while (($node = readdir($contents)) !== false) 11 { 12 if ($node != '.' 13 and $node != '..' 14 and is_dir(PHPWG_ROOT_PATH.PWG_DERIVATIVE_DIR.$node)) 15 { 16 clear_derivative_cache_rec(PHPWG_ROOT_PATH.PWG_DERIVATIVE_DIR.$node, $pattern); 17 } 18 } 19 closedir($contents); 20 } 21 } 22 23 if (isset($_GET['getMissingDerivative'])) 24 { 25 list($max_id, $image_count) = pwg_db_fetch_row( pwg_query('SELECT MAX(id)+1, COUNT(*) FROM '.IMAGES_TABLE) ); 26 $start_id = intval($_POST['prev_page']); 27 $max_urls = intval($_POST['max_urls']); 28 if ($start_id<=0) 29 { 30 $start_id = $max_id; 31 } 32 33 $uid = '&b='.time(); 34 global $conf; 35 $conf['question_mark_in_urls'] = $conf['php_extension_in_urls'] = true; 36 $conf['derivative_url_style']=2; //script 37 38 $qlimit = min(5000, ceil(max($image_count/500, $max_urls))); 39 40 $query_model = 'SELECT id, path, representative_ext, width, height 41 FROM '.IMAGES_TABLE.' 42 WHERE id < start_id 43 ORDER BY id DESC 44 LIMIT '.$qlimit; 45 46 $urls=array(); 47 do 48 { 49 $result = pwg_query( str_replace('start_id', $start_id, $query_model)); 50 $is_last = pwg_db_num_rows($result) < $qlimit; 51 while ($row=pwg_db_fetch_assoc($result)) 52 { 53 $start_id = $row['id']; 54 $src_image = new SrcImage($row); 55 if ($src_image->is_mimetype()) 56 continue; 57 $derivative = new DerivativeImage(ImageStdParams::get_custom(9999, $conf['GThumb']['height']), $src_image); 58 if (@filemtime($derivative->get_path())===false) 59 { 60 $urls[] = $derivative->get_url().$uid; 61 } 62 if (count($urls)>=$max_urls && !$is_last) 63 break; 64 } 65 if ($is_last) 66 { 67 $start_id = 0; 68 } 69 }while (count($urls)<$max_urls && $start_id); 70 71 $ret = array(); 72 if ($start_id) 73 { 74 $ret['next_page']=$start_id; 75 } 76 $ret['urls']=$urls; 77 echo json_encode($ret); 78 exit(); 79 } 80 5 81 global $template, $conf, $page; 6 82 7 83 load_language('plugin.lang', GTHUMB_PATH); 8 include_once(GTHUMB_PATH.'functions.inc.php');9 84 include(dirname(__FILE__).'/config_default.inc.php'); 10 85 $params = $conf['GThumb']; 11 86 12 87 // Delete cache 13 if (isset($_ GET['deletecache']))88 if (isset($_POST['cachedelete'])) 14 89 { 15 check_pwg_token(); 16 gtdeltree(GTHUMB_CACHE_DIR); 90 check_pwg_token(); 91 delete_gthumb_cache($conf['GThumb']['height']); 92 delete_gthumb_cache($conf['GThumb']['height'] * 2 + $conf['GThumb']['margin']); 17 93 redirect('admin.php?page=plugin-GThumb'); 18 }19 20 // Generate cache21 if (isset($_GET['generatecache']))22 {23 if ($_GET['generatecache'] == 'complete')24 {25 array_push($page['infos'], l10n('Cache have been generated'));26 }27 else28 {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 }45 94 } 46 95 … … 72 121 if ($params['height'] != $conf['GThumb']['height']) 73 122 { 74 gtdeltree(GTHUMB_CACHE_DIR);123 delete_gthumb_cache($conf['GThumb']['height']); 75 124 } 76 125 elseif ($params['margin'] != $conf['GThumb']['margin']) 77 126 { 78 gtdeltree(GTHUMB_CACHE_DIR.'/'.($conf['GThumb']['height'] * 2 + $conf['GThumb']['margin']));127 delete_gthumb_cache($conf['GThumb']['height'] * 2 + $conf['GThumb']['margin']); 79 128 } 80 129 … … 101 150 'CACHE_BIG_THUMB' => $params['cache_big_thumb'], 102 151 'METHOD' => $params['method'], 103 ) 104 ); 105 106 // Informations 107 $data = gtdirsize(GTHUMB_CACHE_DIR); 108 109 $template->assign( 110 array( 111 'NB_FILES' => $data['nb_files'], 112 'CACHE_SIZE' => $data['size'], 113 'PWG_TOKEN' => get_pwg_token(), 152 'PWG_TOKEN' => get_pwg_token(), 114 153 ) 115 154 ); -
extensions/GThumb/js/gthumb.js
r12857 r13652 1 1 var GThumb = { 2 2 3 root: './',4 3 max_height: 200, 5 4 margin: 10, … … 10 9 t: new Array, 11 10 12 queue: jQuery.manageAjax.create('queued', {13 queue: true,14 cacheResponse: false,15 maxRequests: 3,16 preventDoubleRequests: false17 }),18 19 11 build: function () { 20 12 21 13 GThumb.t = new Array; 22 jQuery('#thumbnails img.thumbnail').each(function() { 23 id = parseInt(this.id.substring(2)); 14 jQuery('#thumbnails img.thumbnail').each(function(index) { 24 15 width = parseInt(jQuery(this).attr('width')); 25 16 height = parseInt(jQuery(this).attr('height')); 26 th = {i d:id,width:width,height:height,real_width:width,real_height:height};17 th = {index:index,width:width,height:height,real_width:width,real_height:height}; 27 18 if (height < GThumb.max_height) { 28 19 th.width = Math.round(GThumb.max_height * width / height); … … 30 21 } 31 22 GThumb.t.push(th); 23 }); 32 24 33 if (jQuery(this).attr('src') == '') { 34 GThumb.addToQueue(id, 1); 35 } 36 }); 25 first = GThumb.t[0]; 26 GThumb.small_thumb = {index:first.index,width:first.real_width,height:first.real_height,src:jQuery('#thumbnails img:first').attr('src')} 37 27 38 28 jQuery.resize.throttleWindow = false; 39 29 jQuery.resize.delay = 50; 40 30 GThumb.process(); 41 },42 43 addToQueue: function (id, loop) {44 45 GThumb.queue.add({46 type: 'GET',47 url: GThumb.root+'ws.php',48 data: {49 method: 'pwg.images.getGThumbPlusThumbnail',50 image_id: id,51 format: 'json'52 },53 dataType: 'json',54 success: function(data) {55 if (data.stat == 'ok') {56 jQuery('#gt'+data.result.id).prop('src', GThumb.root+data.result.src).show();57 } else if (loop < 4) {58 GThumb.addToQueue(id, ++loop);59 }60 },61 error: function() {62 if (loop < 4) GThumb.addToQueue(id, ++loop);63 }64 });65 31 }, 66 32 … … 98 64 if (line > 2) { 99 65 if (height >= best_size.height && width/height >= min_ratio && height<=GThumb.big_thumb.height) { 100 best_size = {width:width,height:height} 66 best_size = {width:width,height:height}; 101 67 } 102 68 break; … … 153 119 if (width_count > available_width) { 154 120 155 last_thumb = GThumb.t[i].i d;121 last_thumb = GThumb.t[i].index; 156 122 ratio = width_count / available_width; 157 123 new_height = Math.round(max_height / ratio); … … 161 127 for (j=0;j<thumb_process.length;j++) { 162 128 163 if (thumb_process[j].i d== last_thumb) {129 if (thumb_process[j].index == last_thumb) { 164 130 new_width = available_width - width_count - GThumb.margin; 165 131 } else { … … 168 134 new_width = Math.round(new_width); 169 135 } 170 GThumb.resize(jQuery('# gt'+thumb_process[j].id), thumb_process[j].real_width, thumb_process[j].real_height, new_width, new_height, false);136 GThumb.resize(jQuery('#thumbnails img.thumbnail').eq(thumb_process[j].index), thumb_process[j].real_width, thumb_process[j].real_height, new_width, new_height, false); 171 137 172 138 width_count += new_width + GThumb.margin; … … 181 147 // Last line does not need to be cropped 182 148 for (j=0;j<thumb_process.length;j++) { 183 GThumb.resize(jQuery('# gt'+thumb_process[j].id), thumb_process[j].real_width, thumb_process[j].real_height, thumb_process[j].width, max_height, false);149 GThumb.resize(jQuery('#thumbnails img.thumbnail').eq(thumb_process[j].index), thumb_process[j].real_width, thumb_process[j].real_height, thumb_process[j].width, max_height, false); 184 150 } 185 151 -
extensions/GThumb/main.inc.php
r12924 r13652 14 14 15 15 define('GTHUMB_PATH' , PHPWG_PLUGINS_PATH . basename(dirname(__FILE__)) . '/'); 16 define('GTHUMB_CACHE_DIR', PHPWG_ROOT_PATH.PWG_LOCAL_DIR.'GThumb');17 16 18 17 $conf['GThumb'] = unserialize($conf['GThumb']); … … 26 25 27 26 add_event_handler('loc_begin_index', 'GThumb_init', 60); 28 add_event_handler('ws_add_methods', 'add_gthumb_thumbnails_method');29 27 add_event_handler('get_admin_plugin_menu_links', 'GThumb_admin_menu'); 30 28 … … 48 46 $template->assign('GThumb', $conf['GThumb']); 49 47 50 include_once(PHPWG_ROOT_PATH.'admin/include/image.class.php');48 $template->assign('GThumb_derivative_params', ImageStdParams::get_custom(9999, $conf['GThumb']['height'])); 51 49 52 foreach ($tpl_vars as $key => &$tpl_var)50 if ($conf['GThumb']['big_thumb'] and !empty($tpl_vars[0])) 53 51 { 54 $data = get_gthumb_data($pictures[$key]); 55 56 $tpl_var['TN_SRC'] = $data['src']; 57 $tpl_var['TN_WIDTH'] = $data['width']; 58 $tpl_var['TN_HEIGHT'] = $data['height']; 52 $derivative_params = ImageStdParams::get_custom(9999, 2 * $conf['GThumb']['height'] + $conf['GThumb']['margin']); 53 $template->assign('GThumb_big', new DerivativeImage($derivative_params, $tpl_vars[0]['src_image'])); 59 54 } 60 55 61 if ($conf['GThumb']['big_thumb'])62 {63 $ft = &$tpl_vars[0];64 65 // Small thumb data66 $small_thumb = array(67 'id' => $ft['ID'],68 'src' => $ft['TN_SRC'],69 'width' => $ft['TN_WIDTH'],70 'height' => $ft['TN_HEIGHT'],71 );72 73 if (empty($small_thumb['src']))74 {75 include_once(GTHUMB_PATH.'functions.inc.php');76 $data = get_gthumb_data($pictures[0]);77 $result = make_gthumb_image($pictures[0], $data);78 $small_thumb['src'] = $result['destination'];79 }80 81 // Big thumb data82 $data = get_gthumb_data($pictures[0], 'big');83 84 $big_thumb = array(85 'id' => $ft['ID'],86 'src' => $data['src'],87 'width' => $data['width'],88 'height' => $data['height'],89 );90 if (empty($big_thumb['src']))91 {92 if ($conf['GThumb']['cache_big_thumb'])93 {94 include_once(GTHUMB_PATH.'functions.inc.php');95 $result = make_gthumb_image($pictures[0], $data);96 $big_thumb['src'] = embellish_url(get_root_url().$result['destination']);97 }98 else99 {100 $big_thumb['src'] = get_root_url().'ws.php?method=pwg.images.getGThumbPlusThumbnail&image_id='.$ft['ID'].'&size=big&return=true';101 }102 }103 104 $template->assign(105 array(106 'small_thumb' => $small_thumb,107 'big_thumb' => $big_thumb,108 )109 );110 $ft['TN_SRC'] = $big_thumb['src'];111 $ft['TN_WIDTH'] = $big_thumb['width'];112 $ft['TN_HEIGHT'] = $big_thumb['height'];113 }114 115 56 return $tpl_vars; 116 }117 118 function add_gthumb_thumbnails_method($arr)119 {120 include_once(GTHUMB_PATH.'functions.inc.php');121 122 $service = &$arr[0];123 $service->addMethod(124 'pwg.images.getGThumbPlusThumbnail',125 'ws_images_getGThumbPlusThumbnail',126 array(127 'image_id' => array(),128 'size' => array('default'=>'small'),129 'return' => array('default'=>false),130 ),131 'Get thumbnail for GThumb+ plugin. Size parameter can be "small" or "big".'132 );133 }134 135 function get_gthumb_data($picture, $size='small')136 {137 global $conf;138 139 $picture_ext = array('jpg', 'jpeg', 'png', 'gif');140 141 if (!in_array(strtolower(get_extension($picture['path'])), $picture_ext))142 {143 list($width, $height) = getimagesize(get_thumbnail_path($picture));144 145 return array(146 'src' => get_thumbnail_url($picture),147 'width' => $width,148 'height' => $height,149 );150 }151 152 $new_height = $size == 'small' ? $conf['GThumb']['height'] : $conf['GThumb']['height'] * 2 + $conf['GThumb']['margin'];153 $file = GTHUMB_CACHE_DIR.'/'.$new_height.'/'.md5($picture['path'].(!empty($picture['md5sum']) ? $picture['md5sum'] : '')).'.'.$picture['tn_ext'];154 155 if (file_exists($file))156 {157 list($width, $height) = getimagesize($file);158 159 return array(160 'src' => embellish_url(get_root_url().$file),161 'width' => $width,162 'height' => $height,163 );164 }165 166 if ( !empty($picture['tn_ext']) )167 {168 $file = substr_replace(get_filename_wo_extension($picture['path']), '/thumbnail/GT-',strrpos($picture['path'],'/'),1).'.'.$picture['tn_ext'];169 if (file_exists($file))170 {171 list($width, $height) = getimagesize($file);172 173 return array(174 'src' => embellish_url(get_root_url().$file),175 'width' => $width,176 'height' => $height,177 );178 }179 }180 181 $width = $picture['width'];182 $height = $picture['height'];183 $use_high = false;184 185 if ($height < $new_height and $picture['has_high'] == 'true')186 {187 $width = $picture['high_width'];188 $height = $picture['high_height'];189 $use_high = true;190 }191 192 if ($size == 'big')193 {194 $width = min($width, round(max($height, $new_height) * 1.15));195 }196 197 $result = pwg_image::get_resize_dimensions($width, $height, 5000, $new_height);198 $result['src'] = '';199 200 // Test thumbnail size201 list($width, $height) = getimagesize(get_thumbnail_path($picture));202 if ($result['width'] == $width and $result['height'] == $height)203 {204 $result['src'] = get_thumbnail_url($picture);205 }206 207 $result['use_high'] = $use_high;208 $result['cache_path'] = GTHUMB_CACHE_DIR.'/'.$new_height.'/';209 $result['size'] = $size;210 211 return $result;212 57 } 213 58 -
extensions/GThumb/maintain.inc.php
r12758 r13652 15 15 function plugin_uninstall() 16 16 { 17 include_once(dirname(__FILE__).'/functions.inc.php'); 18 gtdeltree(PHPWG_ROOT_PATH.PWG_LOCAL_DIR.'GThumb'); 17 if (is_dir(PHPWG_ROOT_PATH.PWG_LOCAL_DIR.'GThumb')) 18 { 19 gtdeltree(PHPWG_ROOT_PATH.PWG_LOCAL_DIR.'GThumb'); 20 } 19 21 20 22 $query = 'DELETE FROM ' . CONFIG_TABLE . ' WHERE param="GThumb" LIMIT 1;'; … … 24 26 function plugin_activate($plugin_id, $version) 25 27 { 26 if (i n_array($version, array('2.3.a', '2.3.b')))28 if (is_dir(PHPWG_ROOT_PATH.PWG_LOCAL_DIR.'GThumb')) 27 29 { 28 include_once(PHPWG_PLUGINS_PATH.basename(dirname(__FILE__)).'/functions.inc.php');29 30 gtdeltree(PHPWG_ROOT_PATH.PWG_LOCAL_DIR.'GThumb'); 30 31 } 31 32 } 32 33 34 function gtdeltree($path) 35 { 36 if (is_dir($path)) 37 { 38 $fh = opendir($path); 39 while ($file = readdir($fh)) 40 { 41 if ($file != '.' and $file != '..') 42 { 43 $pathfile = $path . '/' . $file; 44 if (is_dir($pathfile)) 45 { 46 gtdeltree($pathfile); 47 } 48 else 49 { 50 @unlink($pathfile); 51 } 52 } 53 } 54 closedir($fh); 55 return @rmdir($path); 56 } 57 } 58 33 59 ?> -
extensions/GThumb/template/admin.tpl
r12857 r13652 47 47 </fieldset> 48 48 49 <p><input type="submit" name="submit" value="{'Submit'|@translate}"></p> 49 <p> 50 <input type="hidden" name="pwg_token" value="{$PWG_TOKEN}"> 51 <input type="submit" name="submit" value="{'Submit'|@translate}"> 52 <input type="submit" name="cachedelete" value="{'Purge thumbnails cache'|@translate}" title="{'Delete images in GThumb+ cache.'|@translate}" onclick="return confirm('{'Are you sure?'|@translate}');"> 53 <input type="button" name="cachebuild" value="{'Pre-cache thumbnails'|@translate}" title="{'Finds images that have not been cached and creates the cached version.'|@translate}" onclick="start()"> 54 </p> 50 55 </form> 51 56 52 <fieldset id="cacheinfo"> 53 <legend>{'Cache Informations'|@translate}</legend> 54 <p id="cache_data"> </p> 55 <p id="GThumbAction"> 56 <button onclick="GThumb.deletecache();" title="{'Delete images in GThumb+ cache.'|@translate}">{'Purge thumbnails cache'|@translate}</button> 57 <button onclick="GThumb.generatecache();" title="{'Finds images that have not been cached and creates the cached version.'|@translate}">{'Pre-cache thumbnails'|@translate}</button> 57 <fieldset id="generate_cache"> 58 <legend>{'Pre-cache thumbnails'|@translate}</legend> 59 <p> 60 <table> 61 <tr> 62 <td>Errors</td> 63 <td id="errors">0</td> 64 </tr> 65 <tr> 66 <td>Loaded</td> 67 <td id="loaded">0</td> 68 </tr> 69 <tr> 70 <td>Remaining</td> 71 <td id="remaining">0</td> 72 </tr> 73 </table> 58 74 </p> 59 <div id="GThumbProgressbar" style="display:none;"> 60 {'Generating cache, please wait...'|@translate}<br> 61 <div id="progressbar"></div> 62 <p><button onclick="GThumb.abort();">{'Cancel'|@translate}</button></p> 75 <p> 76 <input id="startLink" value="{'Start'|@translate}" onclick="start()" type="button"> 77 <input id="pauseLink" value="{'Pause'|@translate}" onclick="pause()" type="button" disabled="disbled"> 78 <input id="stopLink" value="{'Stop'|@translate}" onclick="stop()" type="button" disabled="disbled"> 79 </p> 80 <div id="feedbackWrap" style="height:320px; min-height:320px;"> 81 <img id="feedbackImg"> 82 </div> 83 84 <div id="errorList"> 63 85 </div> 64 86 </fieldset> … … 69 91 #cacheinfo p, #GThumbProgressbar { text-align:left; line-height:20px; margin:20px } 70 92 .ui-progressbar-value { background-image: url(plugins/GThumb/template/pbar-ani.gif); } 93 #generate_cache { display: none; } 71 94 </style> 72 95 {/literal}{/html_head} 73 96 74 {combine_script id='jquery.ui.progressbar' load='footer'} 75 {combine_script id='jquery.ajaxmanager' load='footer' path='themes/default/js/plugins/jquery.ajaxmanager.js'} 76 77 {footer_script} 78 var pwg_token = '{$PWG_TOKEN}'; 79 var confirm_message = '{'Are you sure?'|@translate}'; 80 var nb_files_str = '{'%d file'|@translate}'; 81 var nb_files_str_plur = '{'%d files'|@translate}'; 82 var lang_info_zero_plural = {if $lang_info.zero_plural}true{else}false{/if}; 83 var cache_size = {$CACHE_SIZE}; 84 var nb_files = {$NB_FILES}; 85 86 {literal} 87 var GThumb = { 88 89 total: 0, 90 done: 0, 91 92 queue: jQuery.manageAjax.create('queued', { 93 queue: true, 94 cacheResponse: false, 95 maxRequests: 3 96 }), 97 98 deletecache: function() { 99 if (confirm(confirm_message)) { 100 window.location = 'admin.php?page=plugin-GThumb&deletecache=true&pwg_token='+pwg_token; 101 } 102 }, 103 104 generatecache: function() { 105 GThumb.total = nb_files; 106 GThumb.done = nb_files; 107 jQuery("#progressbar").progressbar({value: 1}); 108 jQuery.ajax({ 109 url: 'admin.php?page=plugin-GThumb&generatecache=request', 110 dataType: 'json', 111 success: function(data) { 112 if (data.length > 0) { 113 jQuery("#GThumbProgressbar, #GThumbAction").toggle(); 114 GThumb.total = data.length + GThumb.done; 115 jQuery("#progressbar").progressbar({value: Math.ceil(GThumb.done * 100 / GThumb.total)}); 116 for (i=0;i<data.length;i++) { 117 GThumb.queue.add({ 118 type: 'GET', 119 url: 'ws.php', 120 data: { 121 method: 'pwg.images.getGThumbPlusThumbnail', 122 image_id: data[i], 123 format: 'json' 124 }, 125 dataType: 'json', 126 success: function(data) { 127 nb_files++; 128 cache_size += data.result.filesize; 129 updateCacheSizeAndFiles(); 130 GThumb.progressbar(); 131 }, 132 error: GThumb.progressbar 133 }); 134 } 135 } else { 136 window.location = 'admin.php?page=plugin-GThumb&generatecache=complete'; 137 } 138 }, 139 error: function() { 140 alert('An error occured'); 141 } 142 }); 143 return false; 144 }, 145 146 progressbar: function() { 147 jQuery( "#progressbar" ).progressbar({ 148 value: Math.ceil(++GThumb.done * 100 / GThumb.total) 149 }); 150 if (GThumb.done == GThumb.total) { 151 window.location = 'admin.php?page=plugin-GThumb&generatecache=complete'; 152 } 153 }, 154 155 abort: function() { 156 GThumb.queue.clear(); 157 GThumb.queue.abort(); 158 jQuery("#GThumbProgressbar, #GThumbAction").toggle(); 97 {combine_script id='iloader' load='footer' path='themes/default/js/image.loader.js'} 98 99 {footer_script require='jquery.effects.slide'}{literal} 100 jQuery('input[name^="cache"]').tipTip({'delay' : 0, 'fadeIn' : 200, 'fadeOut' : 200}); 101 102 var loader = new ImageLoader( {onChanged: loaderChanged, maxRequests:1 } ) 103 , pending_next_page = null 104 , last_image_show_time = 0 105 , allDoneDfd, urlDfd; 106 107 function start() { 108 allDoneDfd = jQuery.Deferred(); 109 urlDfd = jQuery.Deferred(); 110 111 allDoneDfd.always( function() { 112 jQuery("#startLink").attr('disabled', false).css("opacity", 1); 113 jQuery("#pauseLink,#stopLink").attr('disabled', true).css("opacity", 0.5); 114 } ); 115 116 urlDfd.always( function() { 117 if (loader.remaining()==0) 118 allDoneDfd.resolve(); 119 } ); 120 121 jQuery('#generate_cache').show(); 122 jQuery("#startLink").attr('disabled', true).css("opacity", 0.5); 123 jQuery("#pauseLink,#stopLink").attr('disabled', false).css("opacity", 1); 124 125 loader.pause(false); 126 updateStats(); 127 getUrls('0'); 128 } 129 130 function pause() { 131 loader.pause( !loader.pause() ); 132 } 133 134 function stop() { 135 loader.clear(); 136 urlDfd.resolve(); 137 } 138 139 function getUrls(page_token) { 140 data = {prev_page: page_token, max_urls: 195, types: []}; 141 jQuery.post( '{/literal}{$ROOT_URL}{literal}admin.php?page=plugin-GThumb&getMissingDerivative=', 142 data, wsData, "json").fail( wsError ); 143 } 144 145 function wsData(data) { 146 if (data.urls.length == 0) { 147 jQuery('#generate_cache, input[name="cachebuild"]').hide(); 159 148 } 160 }; 161 162 function updateCacheSizeAndFiles() { 163 164 if ( nb_files > 1 || (nb_files == 0 && lang_info_zero_plural)) { 165 nbstr = nb_files_str_plur; 166 } else { 167 nbstr = nb_files_str; 168 } 169 170 ret = nbstr.replace('%d', nb_files) + ', '; 171 172 if (cache_size > 1024 * 1024) 173 ret += Math.round((cache_size / (1024 * 1024))*100)/100 + ' MB'; 174 else 175 ret += Math.round((cache_size / 1024)*100)/100 + ' KB'; 176 177 jQuery("#cache_data").html(ret); 178 } 179 180 updateCacheSizeAndFiles(); 181 182 jQuery('#GThumbAction button').tipTip({'delay' : 0, 'fadeIn' : 200, 'fadeOut' : 200}); 149 loader.add( data.urls ); 150 if (data.next_page) { 151 if (loader.pause() || loader.remaining() > 100) { 152 pending_next_page = data.next_page; 153 } 154 else { 155 getUrls(data.next_page); 156 } 157 } 158 } 159 160 function wsError() { 161 urlDfd.reject(); 162 } 163 164 function updateStats() { 165 jQuery("#loaded").text( loader.loaded ); 166 jQuery("#errors").text( loader.errors ); 167 jQuery("#remaining").text( loader.remaining() ); 168 } 169 170 function loaderChanged(type, img) { 171 updateStats(); 172 if (img) { 173 if (type==="load") { 174 var now = jQuery.now(); 175 if (now - last_image_show_time > 3000) { 176 last_image_show_time = now; 177 var h=img.height, url=img.src; 178 jQuery("#feedbackWrap").hide("slide", {direction:'down'}, function() { 179 last_image_show_time = jQuery.now(); 180 if (h > 300 ) 181 jQuery("#feedbackImg").attr("height", 300); 182 else 183 jQuery("#feedbackImg").removeAttr("height"); 184 jQuery("#feedbackImg").attr("src", url); 185 jQuery("#feedbackWrap").show("slide", {direction:'up'} ); 186 } ); 187 } 188 } 189 else { 190 jQuery("#errorList").prepend( '<a href="'+img.src+'">'+img.src+'</a>' + "<br>"); 191 } 192 } 193 if (pending_next_page && 100 > loader.remaining() ) { 194 getUrls(pending_next_page); 195 pending_next_page = null; 196 } 197 else if (loader.remaining() == 0 && (urlDfd.isResolved() || urlDfd.isRejected())) { 198 allDoneDfd.resolve(); 199 } 200 } 183 201 {/literal}{/footer_script} -
extensions/GThumb/template/gthumb.tpl
r13579 r13652 1 1 {if !empty($thumbnails)} 2 {strip}{foreach from=$thumbnails item=thumbnail} 2 {foreach from=$thumbnails item=thumbnail} 3 {assign var=derivative value=$pwg->derivative($GThumb_derivative_params, $thumbnail.src_image)} 3 4 <li class="gthumb"> 4 5 <a href="{$thumbnail.URL}"> 5 <img id="gt{$thumbnail.ID}" class="thumbnail" src="{$thumbnail.TN_SRC}" alt="{$thumbnail.TN_ALT}" title="{$thumbnail.TN_TITLE}" 6 width="{$thumbnail.TN_WIDTH}" height="{$thumbnail.TN_HEIGHT}" {if empty($thumbnail.TN_SRC)}style="display:none;"{/if}> 6 <img class="thumbnail" {if !$derivative->is_cached()}data-{/if}src="{$derivative->get_url()}" alt="{$thumbnail.TN_ALT}" title="{$thumbnail.TN_TITLE}" {$derivative->get_size_htm()}> 7 7 </a> 8 8 </li> 9 {/foreach} {/strip}9 {/foreach} 10 10 11 11 {combine_css path="plugins/GThumb/template/gthumb.css"} 12 {combine_script id='jquery.ajaxmanager' path='themes/default/js/plugins/jquery.ajaxmanager.js' load="footer"} 12 {combine_script id='jquery.ajaxmanager' path='themes/default/js/plugins/jquery.ajaxmanager.js' load='footer'} 13 {combine_script id='thumbnails.loader' path='themes/default/js/thumbnails.loader.js' require='jquery.ajaxmanager' load='footer'} 13 14 {combine_script id='jquery.ba-resize' path='plugins/GThumb/js/jquery.ba-resize.min.js' load="footer"} 14 {combine_script id='gthumb' require='jquery,jquery. ajaxmanager,jquery.ba-resize' path='plugins/GThumb/js/gthumb.js' load="footer"}15 {combine_script id='gthumb' require='jquery,jquery.ba-resize' path='plugins/GThumb/js/gthumb.js' load="footer"} 15 16 16 17 {footer_script require="gthumb"} 17 GThumb.root = '{$ROOT_URL}';18 18 GThumb.max_height = {$GThumb.height}; 19 19 GThumb.margin = {$GThumb.margin}; 20 20 GThumb.method = '{$GThumb.method}'; 21 21 22 {if isset($ big_thumb)}23 GThumb.small_thumb = {ldelim}id:{$small_thumb.id},src:'{$small_thumb.src}',width:{$small_thumb.width},height:{$small_thumb.height}{rdelim}; 24 GThumb.big_thumb = {ldelim}id:{$ big_thumb.id},src:'{$big_thumb.src}',width:{$big_thumb.width},height:{$big_thumb.height}{rdelim};22 {if isset($GThumb_big)} 23 {assign var=gt_size value=$GThumb_big->get_size()} 24 GThumb.big_thumb = {ldelim}id:{$GThumb_big->src_image->id},src:'{$GThumb_big->get_url()}',width:{$gt_size[0]},height:{$gt_size[1]}{rdelim}; 25 25 {/if} 26 26
Note: See TracChangeset
for help on using the changeset viewer.