Changeset 25932 for extensions/BatchDownloader
- Timestamp:
- Dec 12, 2013, 2:41:53 PM (10 years ago)
- Location:
- extensions/BatchDownloader
- Files:
-
- 2 deleted
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/BatchDownloader/admin.php
r17880 r25932 8 8 include_once(PHPWG_ROOT_PATH.'admin/include/tabsheet.class.php'); 9 9 $page['tab'] = (isset($_GET['tab'])) ? $_GET['tab'] : 'sets'; 10 10 11 11 $tabsheet = new tabsheet(); 12 12 $tabsheet->add('sets', l10n('Download history'), BATCH_DOWNLOAD_ADMIN . '-sets'); … … 17 17 if (!class_exists('ZipArchive')) 18 18 { 19 array_push($page['warnings'], l10n('Unable to find ZipArchive PHP extension, Batch Downloader will use PclZip instead, but with degraded performance.'));19 $page['warnings'][] = l10n('Unable to find ZipArchive PHP extension, Batch Downloader will use PclZip instead, but with degraded performance.'); 20 20 } 21 21 … … 28 28 'BATCH_DOWNLOAD_ADMIN' => BATCH_DOWNLOAD_ADMIN, 29 29 )); 30 30 31 31 $template->assign_var_from_handle('ADMIN_CONTENT', 'batch_download'); 32 33 ?> -
extensions/BatchDownloader/admin/config.php
r25931 r25932 1 1 <?php 2 if (!defined('BATCH_DOWNLOAD_PATH'))die('Hacking attempt!');2 defined('BATCH_DOWNLOAD_PATH') or die('Hacking attempt!'); 3 3 4 4 if (isset($_POST['save_config'])) 5 5 { 6 6 if (!defined('USER_COLLEC_ID')) $_POST['what']['collections'] = 'on'; 7 7 8 8 $conf['batch_download'] = array( 9 9 'groups' => isset($_POST['groups']) ? $_POST['groups'] : array(), … … 22 22 ); 23 23 $conf['batch_download_comment'] = trim($_POST['archive_comment']); 24 24 25 25 conf_update_param('batch_download', serialize($conf['batch_download'])); 26 26 conf_update_param('batch_download_comment', $conf['batch_download_comment']); 27 28 array_push($page['infos'], l10n('Information data registered in database'));27 28 $page['infos'][] = l10n('Information data registered in database'); 29 29 } 30 30 … … 67 67 68 68 69 $template->set_filename('batch_download', dirname(__FILE__) . '/template/config.tpl'); 70 71 ?> 69 $template->set_filename('batch_download', realpath(BATCH_DOWNLOAD_PATH . 'admin/template/config.tpl')); -
extensions/BatchDownloader/admin/sets.php
r23383 r25932 1 1 <?php 2 if (!defined('BATCH_DOWNLOAD_PATH'))die('Hacking attempt!');2 defined('BATCH_DOWNLOAD_PATH') or die('Hacking attempt!'); 3 3 4 4 // actions … … 11 11 if (isset($_GET['cancel'])) 12 12 { 13 $set = new BatchDownloader($_GET['cancel']); 13 $set = new BatchDownloader($_GET['cancel']); 14 14 $set->updateParam('total_size', $set->getEstimatedTotalSize()); 15 15 $set->updateParam('nb_zip', $set->getEstimatedArchiveNumber()); … … 28 28 date_creation < DATE_SUB(NOW(), INTERVAL 1 HOUR) 29 29 ;'; 30 30 31 31 $sets = array_from_query($query, 'id'); 32 32 33 33 foreach ($sets as $set_id) 34 34 { … … 48 48 if (!empty($_POST['username'])) 49 49 { 50 array_push($where_clauses, 'username LIKE "%'.$_POST['username'].'%"');50 $where_clauses[] = 'username LIKE "%'.$_POST['username'].'%"'; 51 51 } 52 52 53 53 if ($_POST['type'] != -1) 54 54 { 55 array_push($where_clauses, 'type = "'.$_POST['type'].'"');55 $where_clauses[] = 'type = "'.$_POST['type'].'"'; 56 56 } 57 57 58 58 if ($_POST['status'] != -1) 59 59 { 60 60 if ($_POST['status'] == 'new') 61 array_push($where_clauses, '(status = "new" OR status = "ready")');61 $where_clauses[] = '(status = "new" OR status = "ready")'; 62 62 else 63 array_push($where_clauses, 'status = "'.$_POST['status'].'"');63 $where_clauses[] = 'status = "'.$_POST['status'].'"'; 64 64 } 65 65 66 66 if ($_POST['size'] != -1) 67 67 { 68 array_push($where_clauses, 'size = "'.$_POST['size'].'"');68 $where_clauses[] = 'size = "'.$_POST['size'].'"'; 69 69 } 70 70 71 71 if ($_POST['order_by'] == 'size') 72 72 { … … 82 82 // get sets 83 83 $query = ' 84 SELECT 84 SELECT 85 85 s.id, 86 86 u.'.$conf['user_fields']['username'].' AS username … … 97 97 { 98 98 $set = new BatchDownloader($set_id); 99 99 100 100 $template->append('sets', array_merge( 101 101 $set->getSetInfo(), … … 106 106 ) 107 107 )); 108 108 109 109 unset($set); 110 110 } … … 173 173 174 174 175 $template->set_filename('batch_download', dirname(__FILE__) . '/template/sets.tpl'); 176 177 ?> 175 $template->set_filename('batch_download', realpath(BATCH_DOWNLOAD_PATH . 'admin/template/sets.tpl')); -
extensions/BatchDownloader/admin/template/config.tpl
r25931 r25932 1 {combine_css path=$BATCH_DOWNLOAD_PATH| @cat:"admin/template/style.css"}1 {combine_css path=$BATCH_DOWNLOAD_PATH|cat:"admin/template/style.css"} 2 2 3 3 {combine_script id='jquery.ui.slider' require='jquery.ui' load='footer' path='themes/default/js/ui/jquery.ui.slider.js'} … … 51 51 $('input[name="multisize"]').on('change', function() { 52 52 if ($(this).val() == 'true') { 53 $('#multisize_title').text('{'Maximum photo size'| @translate|escape:javascript}');53 $('#multisize_title').text('{'Maximum photo size'|translate|escape:javascript}'); 54 54 } 55 55 else { 56 $('#multisize_title').text('{'Photo size'| @translate|escape:javascript}');56 $('#multisize_title').text('{'Photo size'|translate|escape:javascript}'); 57 57 } 58 58 }) … … 67 67 <form method="post" action="" class="properties"> 68 68 <fieldset> 69 <legend>{'Download permissions'| @translate}</legend>70 69 <legend>{'Download permissions'|translate}</legend> 70 71 71 <ul> 72 72 <li> 73 <i>{'Warning: Only registered users can use Batch Downloader.'| @translate}</i>73 <i>{'Warning: Only registered users can use Batch Downloader.'|translate}</i> 74 74 </li> 75 75 <li> 76 76 <label> 77 77 {if $group_options} 78 <b>{'User groups'| @translate}</b>79 <select name="groups[]" data-placeholder="{'Everybody'| @translate}" class="chzn-select" multiple="multiple" style="width:370px;">78 <b>{'User groups'|translate}</b> 79 <select name="groups[]" data-placeholder="{'Everybody'|translate}" class="chzn-select" multiple="multiple" style="width:370px;"> 80 80 {html_options options=$group_options selected=$batch_download.groups} 81 81 </select> 82 82 {else} 83 {'There is no group in this gallery.'| @translate} <a href="admin.php?page=group_list">{'Group management'|@translate}</a>83 {'There is no group in this gallery.'|translate} <a href="admin.php?page=group_list">{'Group management'|translate}</a> 84 84 {/if} 85 85 </label> … … 87 87 <li> 88 88 <label> 89 <b>{'Privacy level'| @translate}</b>89 <b>{'Privacy level'|translate}</b> 90 90 <select name="level"> 91 91 {html_options options=$level_options selected=$batch_download.level} … … 94 94 </li> 95 95 <li> 96 <b>{'What can be downloaded?'| @translate}</b>97 <label><input type="checkbox" name="what[categories]" {if in_array('categories',$batch_download.what)}checked="checked"{/if}/> {'Albums'| @translate}</label>98 {if $USER_COLLEC_LOADED}<label><input type="checkbox" name="what[collections]" {if in_array('collections',$batch_download.what)}checked="checked"{/if}/> {'Collections'| @translate}</label>{/if}99 <label><input type="checkbox" name="what[specials]" {if in_array('specials',$batch_download.what)}checked="checked"{/if}/> {'Specials'| @translate}</label>100 <a class="icon-info-circled-1 showInfo" title="{'Most visited'| @translate}, {'Random photos'|@translate}, {'Best rated'|@translate}..."></a>96 <b>{'What can be downloaded?'|translate}</b> 97 <label><input type="checkbox" name="what[categories]" {if in_array('categories',$batch_download.what)}checked="checked"{/if}/> {'Albums'|translate}</label> 98 {if $USER_COLLEC_LOADED}<label><input type="checkbox" name="what[collections]" {if in_array('collections',$batch_download.what)}checked="checked"{/if}/> {'Collections'|translate}</label>{/if} 99 <label><input type="checkbox" name="what[specials]" {if in_array('specials',$batch_download.what)}checked="checked"{/if}/> {'Specials'|translate}</label> 100 <a class="icon-info-circled-1 showInfo" title="{'Most visited'|translate}, {'Random photos'|translate}, {'Best rated'|translate}..."></a> 101 101 </li> 102 102 <li> … … 106 106 107 107 <label> 108 <b id="multisize_title">{'Maximum photo size'| @translate}</b>108 <b id="multisize_title">{'Maximum photo size'|translate}</b> 109 109 <select name="photo_size"> 110 110 {html_options options=$sizes_options selected=$batch_download.photo_size} … … 116 116 117 117 <fieldset> 118 <legend>{'Archives'| @translate}</legend>119 118 <legend>{'Archives'|translate}</legend> 119 120 120 <ul> 121 121 <li> 122 122 <label> 123 <b>{'Delete downloads after'| @translate}</b>124 <input type="text" name="archive_timeout" value="{$batch_download.archive_timeout}" size="3"> {'hours'| @translate}125 </label> 126 </li> 127 <li> 128 <label> 129 <b>{'Maximum number of photos per download set'| @translate}</b>123 <b>{'Delete downloads after'|translate}</b> 124 <input type="text" name="archive_timeout" value="{$batch_download.archive_timeout}" size="3"> {'hours'|translate} 125 </label> 126 </li> 127 <li> 128 <label> 129 <b>{'Maximum number of photos per download set'|translate}</b> 130 130 <div id="max_elements"></div> 131 131 <input type="text" name="max_elements" value="{$batch_download.max_elements}" size="5"> … … 134 134 <li> 135 135 <label> 136 <b>{'Maximum size of each archive (in Megabytes)'| @translate}</b>136 <b>{'Maximum size of each archive (in Megabytes)'|translate}</b> 137 137 <div id="max_size"></div> 138 138 <input type="text" name="max_size" value="{$batch_download.max_size}" size="5"> … … 141 141 <li> 142 142 <label> 143 <b>{'Archive prefix'| @translate}</b>143 <b>{'Archive prefix'|translate}</b> 144 144 <input type="text" name="archive_prefix" value="{$batch_download.archive_prefix}"> 145 145 </label> … … 148 148 <label> 149 149 <input type="checkbox" name="one_archive" {if $batch_download.one_archive}checked{/if}> 150 <b>{'Delete previous archive when starting to download another one'| @translate}</b>151 </label> 152 <a class="icon-info-circled-1 showInfo" title="{'It saves space on the server but doesn\'t allow to restart failed downloads.'| @translate}"></a>150 <b>{'Delete previous archive when starting to download another one'|translate}</b> 151 </label> 152 <a class="icon-info-circled-1 showInfo" title="{'It saves space on the server but doesn\'t allow to restart failed downloads.'|translate}"></a> 153 153 </li> 154 154 <li> 155 155 <label> 156 156 <input type="checkbox" name="force_pclzip" {if $batch_download.force_pclzip}checked{/if}> 157 <b>{'Force the usage of PclZip instead of ZipArchive as ZIP library'| @translate}</b>158 </label> 159 <a class="icon-info-circled-1 showInfo" title="{'Only check if you are experiencing corrupted archives with ZipArchive.'| @translate}"></a>157 <b>{'Force the usage of PclZip instead of ZipArchive as ZIP library'|translate}</b> 158 </label> 159 <a class="icon-info-circled-1 showInfo" title="{'Only check if you are experiencing corrupted archives with ZipArchive.'|translate}"></a> 160 160 </li> 161 161 <li> 162 162 <label> 163 163 <input type="checkbox" name="direct" {if $batch_download.direct}checked{/if}> 164 <b>{'Don\'t download archives through PHP'| @translate}</b>165 </label> 166 <a class="icon-info-circled-1 showInfo" title="{'Only check if your host complains about high PHP usage.'| @translate}"></a>164 <b>{'Don\'t download archives through PHP'|translate}</b> 165 </label> 166 <a class="icon-info-circled-1 showInfo" title="{'Only check if your host complains about high PHP usage.'|translate}"></a> 167 167 </li> 168 168 {if $use_ziparchive} 169 169 <li> 170 170 <label> 171 <b>{'Archive comment'| @translate} :</b><br>171 <b>{'Archive comment'|translate} :</b><br> 172 172 <textarea name="archive_comment" rows="5" style="width:450px;">{$batch_download_comment}</textarea> 173 173 </label> 174 174 <br> 175 <i>{'Warning: ZipArchive doesn\'t accept special characters like accentuated ones, angle quotes (») and non-latin alphabets.'| @translate}</i>175 <i>{'Warning: ZipArchive doesn\'t accept special characters like accentuated ones, angle quotes (») and non-latin alphabets.'|translate}</i> 176 176 </li> 177 177 {else} … … 181 181 </fieldset> 182 182 183 <p class="formButtons"><input type="submit" name="save_config" value="{'Save Settings'| @translate}"></p>184 185 <fieldset> 186 <legend>{'Environment'| @translate}</legend>187 183 <p class="formButtons"><input type="submit" name="save_config" value="{'Save Settings'|translate}"></p> 184 185 <fieldset> 186 <legend>{'Environment'|translate}</legend> 187 188 188 <b>PHP</b> {$PHP_VERSION}<br> 189 189 {if $use_ziparchive} … … 195 195 196 196 <fieldset> 197 <legend>{'Advanced features'| @translate}</legend>198 197 <legend>{'Advanced features'|translate}</legend> 198 199 199 <dl class="advanced" style="display:none;"> 200 200 {$ADVANCED_CONF} 201 201 </dl> 202 203 <span class="show_advanced buttonLike">{'Display'| @translate}</span>202 203 <span class="show_advanced buttonLike">{'Display'|translate}</span> 204 204 </fieldset> 205 205 -
extensions/BatchDownloader/admin/template/sets.tpl
r23589 r25932 1 {combine_css path=$BATCH_DOWNLOAD_PATH| @cat:"admin/template/style.css"}1 {combine_css path=$BATCH_DOWNLOAD_PATH|cat:"admin/template/style.css"} 2 2 3 3 <div class="titrePage"> … … 7 7 <form class="filter" method="post" name="filter" action="{$F_FILTER_ACTION}"> 8 8 <fieldset> 9 <legend>{'Filter'| @translate}</legend>9 <legend>{'Filter'|translate}</legend> 10 10 11 11 <label> 12 {'Username'| @translate}12 {'Username'|translate} 13 13 <input type="text" name="username" value="{$F_USERNAME}"> 14 14 </label> 15 15 16 16 <label> 17 {'Set type'| @translate}17 {'Set type'|translate} 18 18 {html_options name=type options=$type_options selected=$type_selected} 19 19 </label> 20 20 21 21 <label> 22 {'Photo sizes'| @translate}22 {'Photo sizes'|translate} 23 23 {html_options name=size options=$size_options selected=$size_selected} 24 24 </label> 25 25 26 26 <label> 27 {'Status'| @translate}27 {'Status'|translate} 28 28 {html_options name=status options=$status_options selected=$status_selected} 29 29 </label> 30 30 31 31 <label> 32 {'Sort by'| @translate}32 {'Sort by'|translate} 33 33 {html_options name=order_by options=$order_options selected=$order_selected} 34 34 </label> 35 35 36 36 <label> 37 {'Sort order'| @translate}37 {'Sort order'|translate} 38 38 {html_options name=direction options=$direction_options selected=$direction_selected} 39 39 </label> … … 41 41 <label> 42 42 43 <span><input class="submit" type="submit" name="filter" value="{'Submit'| @translate}"> <a href="{$F_FILTER_ACTION}">{'Reset'|@translate}</a></span>43 <span><input class="submit" type="submit" name="filter" value="{'Submit'|translate}"> <a href="{$F_FILTER_ACTION}">{'Reset'|translate}</a></span> 44 44 </label> 45 45 … … 51 51 <thead> 52 52 <tr class="throw"> 53 <td class="user">{'Username'| @translate}</td>54 <td class="type">{'Set type'| @translate}</td>55 <td class="date">{'Creation date'| @translate}</td>56 <td class="img_size">{'Photo sizes'| @translate}</td>57 <td class="images">{'Number of images'| @translate}</td>58 <td class="archives">{'Number of archives'| @translate}</td>59 <td class="size">{'Total size'| @translate}</td>60 <td class="status">{'Status'| @translate}</td>61 <td class="action">{'Actions'| @translate}</td>53 <td class="user">{'Username'|translate}</td> 54 <td class="type">{'Set type'|translate}</td> 55 <td class="date">{'Creation date'|translate}</td> 56 <td class="img_size">{'Photo sizes'|translate}</td> 57 <td class="images">{'Number of images'|translate}</td> 58 <td class="archives">{'Number of archives'|translate}</td> 59 <td class="size">{'Total size'|translate}</td> 60 <td class="status">{'Status'|translate}</td> 61 <td class="action">{'Actions'|translate}</td> 62 62 </tr> 63 63 </thead> … … 68 68 <td>{$set.NAME}</td> 69 69 <td style="text-align:center;">{$set.DATE_CREATION}</td> 70 <td>{if $set.SIZE=='original'}{'Original'| @translate}{else}{$set.SIZE|@translate}{/if}</td>70 <td>{if $set.SIZE=='original'}{'Original'|translate}{else}{$set.SIZE|translate}{/if}</td> 71 71 <td>{$set.NB_IMAGES}</td> 72 72 <td>{$set.NB_ARCHIVES}</td> 73 73 <td>{$set.TOTAL_SIZE}</td> 74 74 <td> 75 {$set.STATUS| @translate}75 {$set.STATUS|translate} 76 76 {if $set.STATUS == 'download'}<i style="font-size:0.8em;">({$set.LAST_ZIP}/{$set.NB_ARCHIVES})</i>{/if} 77 77 </td> 78 78 <td style="padding-left:25px;"> 79 <a href="{$set.U_DELETE}" title="{'Delete this set'| @translate}" onClick="return confirm('{'Are you sure?'|@translate}');"><img src="{$themeconf.admin_icon_dir}/delete.png"></a>80 {if $set.STATUS != 'done'}<a href="{$set.U_CANCEL}" title="{'Cancel this set'| @translate}" onClick="return confirm('{'Are you sure?'|@translate}');"><img src="{$themeconf.admin_icon_dir}/permissions.png"></a>{/if}79 <a href="{$set.U_DELETE}" title="{'Delete this set'|translate}" onClick="return confirm('{'Are you sure?'|translate}');"><img src="{$themeconf.admin_icon_dir}/delete.png"></a> 80 {if $set.STATUS != 'done'}<a href="{$set.U_CANCEL}" title="{'Cancel this set'|translate}" onClick="return confirm('{'Are you sure?'|translate}');"><img src="{$themeconf.admin_icon_dir}/permissions.png"></a>{/if} 81 81 </td> 82 82 </tr> 83 83 {/foreach} 84 84 85 85 {if not $sets} 86 86 <tr class="row2"> 87 <td colspan="8" style="text-align:center;font-style:italic;">{'No result'| @translate}</td>87 <td colspan="8" style="text-align:center;font-style:italic;">{'No result'|translate}</td> 88 88 </tr> 89 89 {/if} … … 91 91 92 92 <form action="{$F_FILTER_ACTION}" method="post"> 93 <p><label><input type="checkbox" name="delete_done" value="1"> {'Remove all finished downloads'|@translate}</label>94 <input type="submit" value="{'Submit'|@translate}"></p>93 <p><label><input type="checkbox" name="delete_done" value="1"> {'Remove all finished downloads'|translate}</label> 94 <input type="submit" value="{'Submit'|translate}"></p> 95 95 </form> -
extensions/BatchDownloader/download.php
r23383 r25932 7 7 try { 8 8 $BatchDownloader = new BatchDownloader($_GET['set_id']); 9 9 10 10 if ($conf['batch_download']['one_archive'] and $_GET['zip'] == $BatchDownloader->getParam('last_zip')) 11 11 { … … 16 16 $file = $BatchDownloader->getArchivePath($_GET['zip']); 17 17 } 18 18 19 19 if (empty($file) || !file_exists($file)) 20 20 { 21 21 throw new Exception('Unable to locate file.'); 22 22 } 23 23 24 24 if ($conf['batch_download']['direct']) 25 25 { … … 47 47 48 48 exit(0); 49 50 ?> -
extensions/BatchDownloader/include/BatchDownloader.class.php
r23804 r25932 7 7 private $data; 8 8 private $images; 9 9 10 10 /** 11 11 * __construct … … 19 19 { 20 20 global $user, $conf; 21 21 22 22 $this->conf = $conf['batch_download']; 23 23 $this->data = array( … … 36 36 ); 37 37 $this->images = array(); 38 38 39 39 // load specific set 40 40 if (preg_match('#^[0-9]+$#', $set_id)) … … 47 47 ;'; 48 48 $result = pwg_query($query); 49 49 50 50 if (pwg_db_num_rows($result)) 51 51 { … … 54 54 pwg_db_fetch_assoc($result) 55 55 ); 56 56 57 57 // make sure all pictures of the set exist 58 58 $query = ' … … 63 63 ;'; 64 64 pwg_query($query); 65 65 66 66 $query = ' 67 67 SELECT * … … 70 70 ;'; 71 71 $this->images = simple_hash_from_query($query, 'image_id', 'zip'); 72 72 73 73 if ( $this->data['status'] != 'done' and count($this->images) != $this->data['nb_images'] ) 74 74 { … … 78 78 else 79 79 { 80 throw new Exception(l10n('Invalid dow load set'));80 throw new Exception(l10n('Invalid download set')); 81 81 } 82 82 } … … 89 89 if (!in_array($size, $types)) 90 90 { 91 throw new Exception( sprintf(l10n('Invalid size %s'), $size));92 } 93 } 94 91 throw new Exception(l10n('Invalid size %s', $size)); 92 } 93 } 94 95 95 $this->data['type'] = $type; 96 96 $this->data['type_id'] = $type_id; 97 97 $this->data['size'] = $size; 98 98 99 99 $query = ' 100 100 INSERT INTO '.BATCH_DOWNLOAD_TSETS.'( … … 109 109 total_size, 110 110 status 111 ) 111 ) 112 112 VALUES( 113 113 '.$this->data['user_id'].', … … 125 125 pwg_query($query); 126 126 $this->data['id'] = pwg_db_insert_id(); 127 127 128 128 $date = pwg_query('SELECT FROM_UNIXTIME(NOW());'); 129 129 list($this->data['date_creation']) = pwg_db_fetch_row($date); 130 130 131 131 if (!empty($images)) 132 132 { … … 139 139 } 140 140 } 141 141 142 142 /** 143 143 * updateParam … … 150 150 pwg_query('UPDATE '.BATCH_DOWNLOAD_TSETS.' SET '.$name.' = "'.$value.'" WHERE id = '.$this->data['id'].';'); 151 151 } 152 152 153 153 /** 154 154 * getParam … … 160 160 return $this->data[$name]; 161 161 } 162 162 163 163 /** 164 164 * getImages … … 169 169 return $this->images; 170 170 } 171 171 172 172 /** 173 173 * isInSet … … 179 179 return array_key_exists($image_id, $this->images); 180 180 } 181 181 182 182 /** 183 183 * removeImages … … 187 187 { 188 188 if (empty($image_ids) or !is_array($image_ids)) return; 189 189 190 190 foreach ($image_ids as $image_id) 191 191 { 192 192 unset($this->images[ $image_id ]); 193 193 } 194 194 195 195 $query = ' 196 196 DELETE FROM '.BATCH_DOWNLOAD_TIMAGES.' 197 WHERE 197 WHERE 198 198 set_id = '.$this->data['id'].' 199 199 AND image_id IN('.implode(',', $image_ids).') 200 200 ;'; 201 201 pwg_query($query); 202 202 203 203 $this->updateParam('nb_images', count($this->images)); 204 204 } 205 205 206 206 /** 207 207 * addImages … … 211 211 { 212 212 if (empty($image_ids) or !is_array($image_ids)) return; 213 213 214 214 $query = ' 215 215 SELECT id, file … … 218 218 ;'; 219 219 $images = simple_hash_from_query($query, 'id', 'file'); 220 220 221 221 $inserts = array(); 222 222 223 223 foreach ($images as $image_id => $file) 224 224 { 225 225 if ($this->isInSet($image_id)) continue; 226 226 if (!in_array(get_extension($file), $this->conf['allowed_ext'])) continue; 227 227 228 228 $this->images[ $image_id ] = 0; 229 229 $inserts[] = array( … … 233 233 ); 234 234 } 235 235 236 236 if (count($inserts)) 237 237 { … … 242 242 ); 243 243 } 244 244 245 245 $this->updateParam('nb_images', count($this->images)); 246 246 } 247 247 248 248 /** 249 249 * clearImages … … 252 252 { 253 253 $this->images = array(); 254 254 255 255 $query = ' 256 256 DELETE FROM '.BATCH_DOWNLOAD_TIMAGES.' … … 259 259 pwg_query($query); 260 260 } 261 261 262 262 /** 263 263 * getMissingDerivatives … … 271 271 return array(); 272 272 } 273 273 274 274 $uid = '&b='.time(); 275 275 276 276 $params = ImageStdParams::get_by_type($this->data['size']); 277 277 $last_mod_time = $params->last_mod_time; 278 278 279 279 $image_ids = array_keys($this->images); 280 280 $to_update = $urls = $inserts = array(); 281 281 282 282 global $conf; 283 283 $conf['old_question_mark_in_urls'] = $conf['question_mark_in_urls']; … … 286 286 $conf['question_mark_in_urls'] = $conf['php_extension_in_urls'] = true; 287 287 $conf['derivative_url_style'] = 2; 288 288 289 289 // images which we need to update stats 290 290 if ($update) … … 297 297 ;'; 298 298 $registered = array_from_query($query, 'image_id', 'filemtime'); 299 299 300 300 $to_update = array_filter($registered, create_function('$t', 'return $t<'.$last_mod_time.';')); 301 301 $to_update = array_merge($to_update, array_diff($image_ids, $registered)); 302 302 } 303 303 304 304 $query = ' 305 305 SELECT id, path, width, height, rotation … … 313 313 { 314 314 $src_image = new SrcImage($row); // don't give representive_ext 315 315 316 316 // no-image files 317 317 if ($src_image->is_mimetype()) 318 318 { 319 319 if ($update && in_array($row['id'], $to_update)) 320 { 320 { 321 321 $inserts[ $row['id'] ] = array( 322 322 'image_id' => $row['id'], … … 333 333 { 334 334 $derivative = new DerivativeImage($this->data['size'], $src_image); 335 335 336 336 $filemtime = @filemtime($derivative->get_path()); 337 337 $src_mtime = @filemtime(PHPWG_ROOT_PATH.$row['path']); 338 338 if ($src_mtime===false) continue; 339 339 340 340 if ($filemtime===false || $filemtime<$last_mod_time || $filemtime<$src_mtime) 341 341 { … … 345 345 { 346 346 $imagesize = getimagesize($derivative->get_path()); 347 347 348 348 $inserts[ $row['id'] ] = array( 349 349 'image_id' => $row['id'], … … 357 357 } 358 358 } 359 359 360 360 if (!empty($inserts)) 361 361 { … … 365 365 ;'; 366 366 pwg_query($query); 367 367 368 368 mass_inserts( 369 369 IMAGE_SIZES_TABLE, … … 372 372 ); 373 373 } 374 374 375 375 $conf['question_mark_in_urls'] = $conf['old_question_mark_in_urls']; 376 376 $conf['php_extension_in_urls'] = $conf['old_php_extension_in_urls']; 377 377 $conf['derivative_url_style'] = $conf['old_derivative_url_style']; 378 378 379 379 return $urls; 380 380 } 381 381 382 382 /** 383 383 * deleteArchives … … 386 386 { 387 387 $zip_path = glob($this->getArchivePath('*')); 388 388 389 389 if (is_array($zip_path)) 390 390 { … … 395 395 } 396 396 } 397 397 398 398 /** 399 399 * getFilename … … 402 402 { 403 403 $row['filename'] = stripslashes(get_filename_wo_extension($row['file'])); 404 404 405 405 // datas 406 406 $search = array('%id%', '%filename%', '%author%', '%dimensions%'); 407 407 $replace = array($row['id'], $row['filename']); 408 408 409 409 $replace[2] = empty($row['author']) ? null : $row['author']; 410 410 $replace[3] = empty($filesize) ? null : $filesize['width'].'x'.$filesize['height']; 411 411 412 412 $filename = str_replace($search, $replace, $this->conf['file_pattern']); 413 413 414 414 // functions 415 415 $filename = preg_replace_callback('#\$escape\((.*?)\)#', create_function('$m', 'return str2url($m[1]);'), $filename); … … 417 417 $filename = preg_replace_callback('#\$lower\((.*?)\)#', create_function('$m', 'return str2lower($m[1]);'), $filename); 418 418 $filename = preg_replace_callback('#\$strpad\((.*?),(.*?),(.*?)\)#', create_function('$m', 'return str_pad($m[1],$m[2],$m[3],STR_PAD_LEFT);'), $filename); 419 419 420 420 // cleanup 421 421 $filename = preg_replace( … … 424 424 $filename 425 425 ); 426 426 427 427 if (empty($filename) || $filename == $this->conf['file_pattern']) 428 428 { 429 429 $filename = $row['id'].'_'.$row['filename']; 430 430 } 431 431 432 432 $filename.= '.'.get_extension($row['path']); 433 433 434 434 return $filename; 435 435 } 436 436 437 437 /** 438 438 * createNextArchive … … 447 447 trigger_error('BatchDownloader::createNextArchive, the set is empty', E_USER_ERROR); 448 448 } 449 449 450 450 global $conf; 451 451 452 452 // first zip 453 453 if ($this->data['last_zip'] == 0) 454 454 { 455 455 $this->updateParam('status', 'download'); 456 456 457 457 // limit number of elements 458 458 if ($this->data['nb_images'] > $this->conf['max_elements']) … … 462 462 $this->addImages($images_ids); 463 463 } 464 464 465 465 $this->getEstimatedArchiveNumber(true); 466 466 467 467 $this->updateParam('date_creation', date('Y-m-d H:i:s')); 468 468 469 469 trigger_action('batchdownload_init_zip', $this->data, array_keys($this->images)); // triggered once for all 470 470 } 471 471 472 472 // get next images of the set 473 473 $images_to_add = array(); … … 475 475 { 476 476 if ($zip_id != 0) continue; // here are already added images 477 array_push($images_to_add, $image_id);478 } 479 477 $images_to_add[] = $image_id; 478 } 479 480 480 if (count($images_to_add)) 481 481 { … … 489 489 ;'; 490 490 $images_to_add = hash_from_query($query, 'id'); 491 491 492 492 if ($this->data['size'] != 'original') 493 493 { … … 500 500 $filesizes = hash_from_query($query, 'image_id'); 501 501 } 502 502 503 503 // open zip 504 504 $this->updateParam('last_zip', $this->data['last_zip']+1); 505 505 $zip_path = $this->getArchivePath(); 506 506 $zip = new myZip($zip_path, $this->conf['force_pclzip']); 507 507 508 508 // add images until size limit is reach, or all images are added 509 509 $images_added = array(); … … 516 516 continue; 517 517 } 518 518 519 519 if ($this->data['size'] == 'original') 520 520 { … … 525 525 { 526 526 $src_image = new SrcImage($row); // don't give representive_ext 527 527 528 528 // no-image files 529 529 if ($src_image->is_mimetype()) … … 536 536 { 537 537 $derivative = new DerivativeImage($this->data['size'], $src_image); 538 538 539 539 $zip->addFile($derivative->get_path(), $this->getFilename($row, $filesizes[ $row['id'] ])); 540 540 $total_size+= $filesizes[ $row['id'] ]['filesize']; 541 541 } 542 542 } 543 544 array_push($images_added, $row['id']);543 544 $images_added[] = $row['id']; 545 545 $this->images[ $row['id'] ] = $this->data['last_zip']; 546 546 547 547 if ($total_size >= $this->conf['max_size']*1024 and !$force_one_archive) break; 548 548 } 549 549 550 550 $this->updateParam('total_size', $this->data['total_size'] + $total_size); 551 551 552 552 // archive comment 553 553 $comment = 'Generated on '.date('r').' with PHP '.PHP_VERSION.' by Piwigo Batch Downloader.'; … … 558 558 } 559 559 $zip->setArchiveComment($comment); 560 560 561 561 $zip->close(); 562 562 563 563 // update database 564 564 $query = ' … … 570 570 ;'; 571 571 pwg_query($query); 572 572 573 573 trigger_action('batchdownload_end_zip', $this->data, $images_added); // triggered for each zip 574 574 575 575 // all images added ? 576 576 if (count($images_to_add) == count($images_added)) … … 578 578 if ($this->conf['one_archive']) $this->updateParam('status', 'done'); 579 579 $done = true; 580 580 581 581 // over estimed 582 582 $this->updateParam('nb_zip', $this->data['last_zip']); 583 583 } 584 584 585 585 // under estimed 586 586 if (!isset($done) && $this->data['status'] != 'done' && $this->data['last_zip'] == $this->data['nb_zip']) … … 588 588 $this->updateParam('nb_zip', $this->data['last_zip']+1); 589 589 } 590 590 591 591 return $zip_path; 592 592 } … … 596 596 } 597 597 } 598 598 599 599 /** 600 600 * getEstimatedTotalSize … … 606 606 if ($this->data['nb_images'] == 0) return 0; 607 607 if ( !empty($this->data['estimated_total_size']) and !$force ) return $this->data['estimated_total_size']; 608 608 609 609 $image_ids = array_slice(array_keys($this->images), 0, $this->conf['max_elements']); 610 610 611 611 if ($this->data['size'] == 'original') 612 612 { … … 625 625 ;'; 626 626 } 627 627 628 628 list($this->data['estimated_total_size']) = pwg_db_fetch_row(pwg_query($query)); 629 629 return $this->data['estimated_total_size']; 630 630 } 631 631 632 632 /** 633 633 * getEstimatedArchiveNumber … … 638 638 if ($this->data['status'] == 'done') return $this->data['nb_zip']; 639 639 if ( !empty($this->data['nb_zip']) and !$force ) return $this->data['nb_zip']; 640 640 641 641 $this->updateParam('nb_zip', ceil( $this->getEstimatedTotalSize($force) / ($this->conf['max_size']*1024) )); 642 642 return $this->data['nb_zip']; 643 643 } 644 644 645 645 /** 646 646 * getDownloadList … … 653 653 return '<b>'.l10n('No archive').'</b>'; 654 654 } 655 655 656 656 $root_url = get_root_url(); 657 657 658 658 $out = ''; 659 659 for ($i=1; $i<=$this->getEstimatedArchiveNumber(); $i++) 660 660 { 661 661 $out.= '<li id="zip-'.$i.'">'; 662 662 663 663 if ($this->data['status']=='done' or ($this->conf['one_archive'] and $i<$this->data['last_zip']+1)) 664 664 { 665 $out.= '<img src="'.$root_url.BATCH_DOWNLOAD_PATH.'template/images/drive_error.png"> '. sprintf(l10n('Archive #%d (already downloaded)'), $i);665 $out.= '<img src="'.$root_url.BATCH_DOWNLOAD_PATH.'template/images/drive_error.png"> '.l10n('Archive #%d (already downloaded)', $i); 666 666 } 667 667 else if ($i==$this->data['last_zip']+1 or (!$this->conf['one_archive'] and $i<$this->data['last_zip']+1)) 668 668 { 669 $out.= '<a href="'.add_url_params($url, array('set_id'=>$this->data['id'],'zip'=>$i)).'" rel="nofollow" style="font-weight:bold;"' 670 .(($i!=1 and $this->conf['one_archive']) ? ' onClick="return confirm(\''.addslashes( sprintf(l10n('Starting download Archive #%d will destroy Archive #%d, be sure you finish the download. Continue ?'), $i, $i-1)).'\');"' : null).671 '><img src="'.$root_url.BATCH_DOWNLOAD_PATH.'template/images/drive_go.png"> '. sprintf(l10n('Archive #%d (ready)'), $i).'</a>';669 $out.= '<a href="'.add_url_params($url, array('set_id'=>$this->data['id'],'zip'=>$i)).'" rel="nofollow" style="font-weight:bold;"' 670 .(($i!=1 and $this->conf['one_archive']) ? ' onClick="return confirm(\''.addslashes(l10n('Starting download Archive #%d will destroy Archive #%d, be sure you finish the download. Continue ?', $i, $i-1)).'\');"' : null). 671 '><img src="'.$root_url.BATCH_DOWNLOAD_PATH.'template/images/drive_go.png"> '.l10n('Archive #%d (ready)', $i).'</a>'; 672 672 } 673 673 else 674 674 { 675 $out.= '<img src="'.$root_url.BATCH_DOWNLOAD_PATH.'template/images/drive.png"> '. sprintf(l10n('Archive #%d (pending)'), $i);676 } 677 675 $out.= '<img src="'.$root_url.BATCH_DOWNLOAD_PATH.'template/images/drive.png"> '.l10n('Archive #%d (pending)', $i); 676 } 677 678 678 $out.= '</li>'; 679 679 } 680 680 681 681 return $out; 682 682 } 683 683 684 684 /** 685 685 * getArchivePath … … 693 693 mkgetdir(BATCH_DOWNLOAD_LOCAL . 'u-' .$this->data['user_id']. '/'); 694 694 } 695 695 696 696 if ($i === null) $i = $this->data['last_zip']; 697 697 $set = $this->getNames(); 698 698 699 699 $path = BATCH_DOWNLOAD_LOCAL . 'u-'. $this->data['user_id'] . '/'; 700 700 $path.= !empty($this->conf['archive_prefix']) ? $this->conf['archive_prefix'] . '_' : null; … … 702 702 $path.= $this->data['user_id'] . $this->data['id']; 703 703 $path.= '_part' . $i . '.zip'; 704 704 705 705 return $path; 706 706 } 707 707 708 708 /** 709 709 * getNames 710 * @return: array 710 * @return: array 711 711 * NAME, set name with HTML 712 712 * sNAME, set name without HTML … … 715 715 */ 716 716 function getNames() 717 { 717 { 718 718 switch ($this->data['type']) 719 719 { … … 723 723 global $conf, $page; 724 724 $old_page = $page; 725 725 726 726 $fields = array( 727 727 'created' => l10n('Creation date'), 728 728 'posted' => l10n('Post date'), 729 729 ); 730 730 731 731 $chronology = explode('-', $this->data['type_id']); 732 732 $page['chronology_field'] = $chronology[0]; … … 734 734 $page['chronology_view'] = $chronology[2]; 735 735 $page['chronology_date'] = array_splice($chronology, 3); 736 736 737 737 if (!class_exists('Calendar')) 738 738 { … … 742 742 $calendar->initialize(''); 743 743 $display_name = strip_tags($calendar->get_display_name()); 744 744 745 745 $set['NAME'] = l10n('Calendar').': '.$fields[$page['chronology_field']].$display_name; 746 746 $set['sNAME'] = l10n('Calendar').': '.ltrim($display_name, $conf['level_separator']); 747 747 $set['BASENAME'] = 'calendar-'.$page['chronology_field'].'-'.implode('-',$page['chronology_date']); 748 748 749 749 $page = $old_page; 750 750 break; 751 751 } 752 752 753 753 // category 754 754 case 'category': … … 765 765 $set['sNAME'] = l10n('Album').': '.trigger_event('render_category_name', $category['name']); 766 766 $set['COMMENT'] = trigger_event('render_category_description', $category['comment']); 767 767 768 768 if (!empty($category['permalink'])) 769 769 { … … 781 781 break; 782 782 } 783 783 784 784 // flat 785 785 case 'flat': … … 789 789 break; 790 790 } 791 791 792 792 // tags 793 793 case 'tags': … … 796 796 $set['NAME'] = l10n('Tags').': '; 797 797 $set['BASENAME'] = 'tags'; 798 798 799 799 $first = true; 800 800 foreach ($tags as $tag) … … 810 810 break; 811 811 } 812 812 813 813 // search 814 814 case 'search': … … 818 818 break; 819 819 } 820 820 821 821 // favorites 822 822 case 'favorites': … … 826 826 break; 827 827 } 828 828 829 829 // most_visited 830 830 case 'most_visited': … … 834 834 break; 835 835 } 836 836 837 837 // best_rated 838 838 case 'best_rated': … … 842 842 break; 843 843 } 844 844 845 845 // list 846 846 case 'list': … … 850 850 break; 851 851 } 852 852 853 853 // recent_pics 854 854 case 'recent_pics': … … 858 858 break; 859 859 } 860 860 861 861 // collection 862 862 case 'collection': … … 868 868 $infos = $UserCollection->getCollectionInfo(); 869 869 $set['NAME'] = l10n('Collection').': <a href="'.$infos['U_PUBLIC'].'">'.$UserCollection->getParam('name').'</a>'; 870 870 871 871 if ( ($name = str2url($UserCollection->getParam('name'))) != null) 872 872 { … … 886 886 } 887 887 } 888 888 889 889 if (!isset($set['sNAME'])) $set['sNAME'] = strip_tags($set['NAME']); 890 890 if (!isset($set['COMMENT'])) $set['COMMENT'] = null; 891 891 if (!isset($set['BASENAME'])) $set['BASENAME'] = $this->data['type'] . $this->data['type_id']; 892 892 893 893 return $set; 894 894 } 895 895 896 896 /** 897 897 * getSetInfo … … 899 899 */ 900 900 function getSetInfo() 901 { 901 { 902 902 $set = array( 903 903 'NB_IMAGES' => $this->data['nb_images'], … … 905 905 'STATUS' => $this->data['status']=='ready' ? 'new' : $this->data['status'], 906 906 'LAST_ZIP' => $this->data['last_zip'], 907 'TOTAL_SIZE' => $this->data['status']=='new' ? l10n('Unknown') : sprintf(l10n('%d MB'), ceil($this->getEstimatedTotalSize()/1024)),907 'TOTAL_SIZE' => $this->data['status']=='new' ? l10n('Unknown') : l10n('%d MB', ceil($this->getEstimatedTotalSize()/1024)), 908 908 'DATE_CREATION' => format_date($this->data['date_creation'], true), 909 909 'SIZE' => $this->data['size'], 910 910 ); 911 911 912 912 if ($this->data['size'] != 'original') 913 913 { … … 915 915 $set['SIZE_INFO'] = $params->sizing->ideal_size[0].' x '.$params->sizing->ideal_size[1]; 916 916 } 917 917 918 918 return array_merge($set, $this->getNames()); 919 919 } 920 920 921 921 /** 922 922 * delete … … 939 939 private $lib; 940 940 private $zip; 941 941 942 942 function __construct($zip_path, $pclzip=false) 943 943 { … … 945 945 { 946 946 $this->lib = 'zipa'; 947 947 948 948 $this->zip = new ZipArchive; 949 949 if ($this->zip->open($zip_path, ZipArchive::CREATE) !== true) … … 955 955 { 956 956 $this->lib = 'pcl'; 957 957 958 958 require_once(PHPWG_ROOT_PATH.'admin/include/pclzip.lib.php'); 959 959 $this->zip = new PclZip($zip_path); 960 960 961 961 // create a temporary file for archive creation 962 962 touch(BATCH_DOWNLOAD_LOCAL.'temp.txt'); 963 963 964 964 if ($this->zip->create(BATCH_DOWNLOAD_LOCAL.'temp.txt', PCLZIP_OPT_REMOVE_ALL_PATH) == 0) 965 965 { 966 966 trigger_error('BatchDownloader::createNextArchive, unable to open ZIP archive (PclZip)', E_USER_ERROR); 967 967 } 968 968 969 969 unlink(BATCH_DOWNLOAD_LOCAL.'temp.txt'); 970 970 $this->zip->delete(PCLZIP_OPT_BY_NAME, 'temp.txt'); 971 971 } 972 972 } 973 973 974 974 function addFile($path, $filename) 975 975 { … … 983 983 } 984 984 } 985 985 986 986 function setArchiveComment($comment) 987 987 { … … 991 991 } 992 992 } 993 993 994 994 function close() 995 995 { … … 1000 1000 } 1001 1001 } 1002 1003 ?> -
extensions/BatchDownloader/include/download.inc.php
r23383 r25932 1 1 <?php 2 2 defined('BATCH_DOWNLOAD_PATH') or die('Hacking attempt!'); 3 4 # this file is called on public page #5 3 6 4 global $page, $template, $conf, $user; … … 11 9 case 'init_zip': 12 10 { 13 $template->set_filename(' index', realpath(BATCH_DOWNLOAD_PATH . 'template/init_zip.tpl'));14 11 $template->set_filename('batchdwn', realpath(BATCH_DOWNLOAD_PATH . 'template/init_zip.tpl')); 12 15 13 try 16 14 { 17 15 $BatchDownloader = new BatchDownloader($_GET['set_id']); 18 16 19 17 // delete set 20 18 if ( isset($_GET['cancel']) ) … … 26 24 redirect(get_absolute_root_url()); 27 25 } 28 26 29 27 // prepare next zip 30 28 if ( isset($_GET['zip']) and $BatchDownloader->getParam('status') != 'new' and $BatchDownloader->getParam('status') != 'done' ) … … 35 33 $BatchDownloader->createNextArchive(); 36 34 } 37 35 38 36 if ($conf['batch_download']['one_archive']) 39 37 { … … 45 43 } 46 44 } 47 45 48 46 // alert limit overflow 49 47 if ($BatchDownloader->getParam('nb_images') > $conf['batch_download']['max_elements']) 50 48 { 51 $template->assign('elements_error', sprintf(52 l10n('You choose to download %d pictures, but the system is limited to %d. You can edit the set, or the last %d pictures will not be downloaded.'),49 $template->assign('elements_error', l10n( 50 'You choose to download %d pictures, but the system is limited to %d. You can edit the set, or the last %d pictures will not be downloaded.', 53 51 $BatchDownloader->getParam('nb_images'), 54 52 $conf['batch_download']['max_elements'], … … 61 59 { 62 60 $missing_derivatives = $BatchDownloader->getMissingDerivatives(true); 63 61 64 62 // generate missing files 65 63 if (count($missing_derivatives)) … … 73 71 } 74 72 } 75 73 76 74 // display download links 77 75 if ($BatchDownloader->getParam('status') != 'new') … … 80 78 } 81 79 } 82 80 83 81 $set = $BatchDownloader->getSetInfo(); 84 82 85 83 // link to the zip 86 84 if (isset($next_file)) 87 85 { 88 86 $set['U_DOWNLOAD'] = get_root_url().BATCH_DOWNLOAD_PATH . 'download.php?set_id='.$_GET['set_id'].'&zip='.$_GET['zip']; 89 $page['infos'][] = sprintf(l10n('The archive is downloading, if the download doesn\'t start automatically please <a href="%s">click here</a>'), $set['U_DOWNLOAD']);87 $page['infos'][] = l10n('The archive is downloading, if the download doesn\'t start automatically please <a href="%s">click here</a>', $set['U_DOWNLOAD']); 90 88 } 91 89 92 90 // link to edit page 93 91 if ($BatchDownloader->getParam('status') != 'download' and $BatchDownloader->getParam('status') != 'done' and $BatchDownloader->getParam('nb_images') > 0) … … 95 93 $set['U_EDIT_SET'] = add_url_params(BATCH_DOWNLOAD_PUBLIC . 'view', array('set_id'=>$_GET['set_id'])); 96 94 } 97 95 98 96 // cancel link 99 if ($BatchDownloader->getParam('last_zip') != $BatchDownloader->getParam('nb_zip')) 97 if ($BatchDownloader->getParam('last_zip') != $BatchDownloader->getParam('nb_zip') 98 or (isset($missing_derivatives) and count($missing_derivatives)) 99 ) 100 100 { 101 101 $set['U_CANCEL'] = add_url_params(BATCH_DOWNLOAD_PUBLIC . 'init_zip', array('set_id'=>$_GET['set_id'], 'cancel'=>'true')); 102 102 } 103 103 104 104 $template->assign(array( 105 105 'set' => $set, … … 109 109 catch (Exception $e) 110 110 { 111 array_push($page['errors'], $e->getMessage());111 $page['errors'][] = $e->getMessage(); 112 112 } 113 113 114 114 break; 115 115 } 116 116 117 117 /* edition page */ 118 118 case 'view': 119 119 { 120 120 $self_url = add_url_params(BATCH_DOWNLOAD_PUBLIC . 'view', array('set_id'=>$_GET['set_id'])); 121 122 $template->set_filename(' index', realpath(BATCH_DOWNLOAD_PATH . 'template/view.tpl'));121 122 $template->set_filename('batchdwn', realpath(BATCH_DOWNLOAD_PATH . 'template/view.tpl')); 123 123 $template->assign(array( 124 124 'BATCH_DOWNLOAD_PATH' => BATCH_DOWNLOAD_PATH, … … 127 127 'SET_ID' => $_GET['set_id'], 128 128 )); 129 129 130 130 try 131 131 { 132 132 $BatchDownloader = new BatchDownloader($_GET['set_id']); 133 133 134 134 if ($BatchDownloader->getParam('status') != 'new' && $BatchDownloader->getParam('status') != 'ready') 135 135 { 136 array_push($page['errors'], l10n('You can not edit this set'));136 $page['errors'][] = l10n('You can not edit this set'); 137 137 break; 138 138 } 139 139 140 140 if ( isset($_GET['remove']) and preg_match('#^[0-9]+$#', $_GET['remove']) ) 141 141 { 142 142 $BatchDownloader->removeImages(array($_GET['remove'])); 143 143 } 144 144 145 145 $template->assign('set', $BatchDownloader->getSetInfo()); 146 146 147 147 $template->set_prefilter('index_thumbnails', 'batch_download_thumbnails_list_prefilter'); 148 148 149 149 $page['start'] = isset($_GET['start']) ? $_GET['start'] : 0; 150 150 $page['items'] = array_keys($BatchDownloader->getImages()); 151 151 152 152 if (count($page['items']) > $page['nb_image_page']) 153 153 { … … 161 161 $template->assign('navbar', $page['navigation_bar']); 162 162 } 163 163 164 164 include(PHPWG_ROOT_PATH . 'include/category_default.inc.php'); 165 165 } 166 166 catch (Exception $e) 167 167 { 168 array_push($page['errors'], $e->getMessage());168 $page['errors'][] = $e->getMessage(); 169 169 } 170 170 171 171 break; 172 172 } … … 178 178 )); 179 179 180 $template->assign_var_from_handle('CONTENT', 'batchdwn'); 181 180 182 181 183 function batch_download_thumbnails_list_prefilter($content, &$smarty) … … 185 187 $replace = '$1 186 188 {strip}<a class="removeSet" href="{$U_VIEW}&remove={$thumbnail.id}" data-id="{$thumbnail.id}" rel="nofollow"> 187 {\'Remove from download set\'| @translate} <img src="{$ROOT_URL}{$BATCH_DOWNLOAD_PATH}template/images/image_delete.png" title="{\'Remove from download set\'|@translate}">189 {\'Remove from download set\'|translate} <img src="{$ROOT_URL}{$BATCH_DOWNLOAD_PATH}template/images/image_delete.png" title="{\'Remove from download set\'|translate}"> 188 190 </a>{/strip}'; 189 191 … … 193 195 return preg_replace($search, $replace, $content); 194 196 } 195 196 ?> -
extensions/BatchDownloader/include/events.inc.php
r25931 r25932 2 2 defined('BATCH_DOWNLOAD_PATH') or die('Hacking attempt!'); 3 3 4 # this file contains all functions directly called by the triggers #5 6 4 /* define page section from url */ 7 5 function batch_download_section_init() 8 6 { 9 7 global $tokens, $page, $conf; 10 8 11 9 if ($tokens[0] == 'download') 12 10 { 13 11 if (check_download_access() === false) access_denied(); 14 15 add_event_handler('loc_begin_page_header', 'batch_download_page_header'); 16 12 13 $page['body_id'] = 'theBatchDownloader'; 14 $page['is_external'] = true; 15 $page['is_homepage'] = false; 17 16 $page['section'] = 'download'; 17 18 18 $page['section_title'] = '<a href="'.get_absolute_root_url().'">'.l10n('Home').'</a>'.$conf['level_separator'].l10n('Batch Downloader').$conf['level_separator']; 19 19 $page['title'] = l10n('Batch Downloader'); 20 20 21 21 switch (@$tokens[1]) 22 22 { … … 39 39 } 40 40 41 function batch_download_page_header()42 {43 global $page;44 $page['body_id'] = 'theBatchDownloader';45 }46 47 41 /* download section */ 48 function batch_download_page() 42 function batch_download_page() 49 43 { 50 44 global $page; … … 61 55 { 62 56 global $page, $template, $user, $conf; 63 57 64 58 // check accesses 65 59 if ( !count($page['items']) or !isset($page['section']) ) return; 66 60 67 61 if (check_download_access() === false) return; 68 62 69 63 switch ($page['section']) 70 64 { 71 65 case 'categories': 72 66 if (!isset($page['category']) && !isset($page['chronology_field'])) return; // don't download the full gallery in flat mode ! 73 67 74 68 if (!in_array('categories', $conf['batch_download']['what'])) return; 75 69 break; 76 70 77 71 case 'collections': 78 72 if (!in_array('collections', $conf['batch_download']['what'])) return; 79 73 break; 80 74 81 75 default: 82 76 if (!in_array('specials', $conf['batch_download']['what'])) return; 83 77 } 84 85 78 79 86 80 // download the set 87 81 if ( isset($_GET['action']) and $_GET['action']=='advdown_set' ) 88 82 { 89 83 $set = get_set_info_from_page(); 90 84 91 85 if ($set !== false && count($set['items'])) 92 86 { 93 87 $BatchDownloader = new BatchDownloader('new', $set['items'], $set['type'], $set['id'], $set['size']); 94 88 95 89 if ($BatchDownloader->getParam('nb_images') != 0) 96 90 { … … 103 97 { 104 98 $BatchDownloader->createNextArchive(true); // make sure we have only one zip, even if 'max_size' is exceeded 105 99 106 100 $u_download = get_root_url().BATCH_DOWNLOAD_PATH . 'download.php?set_id='.$BatchDownloader->getParam('id').'&zip=1'; 107 101 108 102 $null = null; 109 103 $template->block_footer_script(null, 'setTimeout("document.location.href = \''.$u_download.'\';", 1000);', $null, $null); 110 111 $page['infos'][] = sprintf(l10n('The archive is downloading, if the download doesn\'t start automatically please <a href="%s">click here</a>'), $u_download);104 105 $page['infos'][] = l10n('The archive is downloading, if the download doesn\'t start automatically please <a href="%s">click here</a>', $u_download); 112 106 } 113 107 // otherwise we go to summary page … … 121 115 $BatchDownloader->delete(); 122 116 unset($BatchDownloader); 123 124 $page['errors'][] = sprintf(l10n('Sorry, there is nothing to download. Some files may have been excluded because of <i title="Authorized types are : %s">filetype restrictions</i>.'), implode(', ', $conf['batch_download']['allowed_ext']));117 118 $page['errors'][] = l10n('Sorry, there is nothing to download. Some files may have been excluded because of <i title="Authorized types are : %s">filetype restrictions</i>.', implode(', ', $conf['batch_download']['allowed_ext'])); 125 119 } 126 120 } 127 121 } 128 122 129 123 if ($page['section'] == 'collections') 130 124 { … … 135 129 $url = duplicate_index_url(array(), array('action')); 136 130 } 137 131 138 132 $url = add_url_params($url, array('action'=>'advdown_set', 'down_size'=>'')); 139 133 140 134 // toolbar button 141 135 $template->assign(array( … … 144 138 'BATCH_DWN_URL' => $url, 145 139 )); 146 140 147 141 if ($conf['batch_download']['multisize']) 148 142 { … … 175 169 $template->assign('BATCH_DWN_SIZE', $conf['batch_download']['photo_size']); 176 170 } 177 171 178 172 $template->set_filename('batchdwn_button', realpath(BATCH_DOWNLOAD_PATH.'template/download_button.tpl')); 179 173 $button = $template->parse('batchdwn_button', true); … … 187 181 { 188 182 global $user; 189 183 190 184 $menu = &$menu_ref_arr[0]; 191 185 if ($menu->get_id() != 'menubar') return; 192 186 193 187 if (check_download_access() === false) return; 194 188 195 189 $query = ' 196 190 SELECT id … … 203 197 $result = pwg_query($query); 204 198 if (!pwg_db_num_rows($result)) return; 205 199 206 200 $menu->register_block(new RegisteredBlock('mbBatchDownloader', l10n('Batch Downloader'), 'BatchDownloader')); 207 201 } … … 210 204 { 211 205 global $template, $conf, $user; 212 206 213 207 $menu = &$menu_ref_arr[0]; 214 208 $block = $menu->get_block('mbBatchDownloader'); 215 209 216 210 if ($block != null) 217 211 { 218 212 $query = ' 219 SELECT id 213 SELECT id 220 214 FROM '.BATCH_DOWNLOAD_TSETS.' 221 215 WHERE … … 224 218 ;'; 225 219 $sets = array_from_query($query, 'id'); 226 220 227 221 $data = array(); 228 222 foreach ($sets as $set_id) … … 230 224 $BatchDownloader = new BatchDownloader($set_id); 231 225 $set = $BatchDownloader->getSetInfo(); 232 233 array_push($data,array(226 227 $data[] = array( 234 228 'URL' => add_url_params(BATCH_DOWNLOAD_PUBLIC . 'init_zip', array('set_id'=>$BatchDownloader->getParam('id'))), 235 229 'TITLE' => str_replace('"', "'", strip_tags($set['COMMENT'])), 236 230 'NAME' => $set['sNAME'], 237 231 'COUNT' => $set['NB_IMAGES'], 238 ) );239 } 240 232 ); 233 } 234 241 235 $template->set_template_dir(BATCH_DOWNLOAD_PATH . 'template/'); 242 236 $block->set_title(l10n('Downloads')); … … 251 245 { 252 246 global $conf; 253 247 254 248 $time = time(); 255 249 256 250 // we only search for old downloads every hour, nevermind which user is connected 257 251 if ($conf['batch_download']['last_clean'] > $time - 3600) return; 258 252 259 253 $conf['batch_download']['last_clean'] = $time; 260 254 conf_update_param('batch_download', serialize($conf['batch_download'])); 261 255 262 256 // set old sets as done and clean images table 263 257 $query = ' … … 271 265 ;'; 272 266 pwg_query($query); 273 267 274 268 $query = ' 275 269 UPDATE '.BATCH_DOWNLOAD_TSETS.' 276 270 SET status = "done" 277 WHERE 271 WHERE 278 272 status != "done" AND 279 273 date_creation < DATE_SUB(NOW(), INTERVAL '.$conf['batch_download']['archive_timeout'].' HOUR) 280 274 ;'; 281 275 pwg_query($query); 282 276 283 277 // remove old archives 284 278 $zips = glob(BATCH_DOWNLOAD_LOCAL . 'u-*/*.zip'); 285 279 286 280 if (is_array($zips)) 287 281 { … … 300 294 { 301 295 if (!isset($_POST['action']) || $_POST['action']!='bd_remove_image') return; 302 296 303 297 check_status(ACCESS_CLASSIC); 304 298 … … 320 314 echo 'error'; 321 315 } 322 316 323 317 exit(0); 324 318 } 325 326 ?> -
extensions/BatchDownloader/include/functions.inc.php
r25931 r25932 9 9 { 10 10 global $page, $conf; 11 11 12 12 switch ($page['section']) 13 13 { … … 16 16 { 17 17 $batch_type = 'calendar'; 18 $batch_id = add_well_known_params_in_url('', 19 array_intersect_key($page, 18 $batch_id = add_well_known_params_in_url('', 19 array_intersect_key($page, 20 20 array( 21 21 'chronology_field'=>0, … … 62 62 return false; 63 63 } 64 64 65 65 $set = array( 66 66 'type' => $batch_type, … … 69 69 'items' => $page['items'], 70 70 ); 71 71 72 72 // check size 73 73 if (!$conf['batch_download']['multisize']) … … 87 87 $avail_sizes[] = 'original'; 88 88 } 89 89 90 90 if (!in_array($set['size'], $avail_sizes)) 91 91 { … … 104 104 { 105 105 global $user, $conf; 106 106 107 107 if (is_a_guest()) return false; 108 108 if (is_admin()) return true; 109 109 110 110 if ($user['level'] < $conf['batch_download']['level']) return false; 111 111 112 112 if (!empty($conf['batch_download']['groups'])) 113 113 { … … 119 119 ;'; 120 120 $result = pwg_query($query); 121 121 122 122 if (!pwg_db_num_rows($result)) return false; 123 123 } 124 124 125 125 return true; 126 126 } … … 167 167 } 168 168 } 169 170 ?> -
extensions/BatchDownloader/main.inc.php
r23589 r25932 1 <?php 1 <?php 2 2 /* 3 3 Plugin Name: Batch Downloader … … 33 33 { 34 34 add_event_handler('init', 'batch_downloader_remove_image'); 35 35 36 36 add_event_handler('loc_end_section_init', 'batch_download_section_init'); 37 37 add_event_handler('loc_end_index', 'batch_download_page'); … … 40 40 41 41 add_event_handler('loc_end_index', 'batch_download_index_button', EVENT_HANDLER_PRIORITY_NEUTRAL+10); 42 } 42 43 43 add_event_handler('blockmanager_register_blocks', 'batch_download_add_menublock'); 44 add_event_handler('blockmanager_apply', 'batch_download_applymenu'); 45 } 44 add_event_handler('blockmanager_register_blocks', 'batch_download_add_menublock'); 45 add_event_handler('blockmanager_apply', 'batch_download_applymenu'); 46 46 47 47 … … 57 57 function batch_download_init() 58 58 { 59 global $conf, $pwg_loaded_plugins; 60 61 if ( 62 BATCH_DOWNLOAD_VERSION == 'auto' or 63 $pwg_loaded_plugins[BATCH_DOWNLOAD_ID]['version'] == 'auto' or 64 version_compare($pwg_loaded_plugins[BATCH_DOWNLOAD_ID]['version'], BATCH_DOWNLOAD_VERSION, '<') 65 ) 66 { 67 include_once(BATCH_DOWNLOAD_PATH . 'include/install.inc.php'); 68 batch_download_install(); 69 70 if ( $pwg_loaded_plugins[BATCH_DOWNLOAD_ID]['version'] != 'auto' and BATCH_DOWNLOAD_VERSION != 'auto' ) 71 { 72 $query = ' 73 UPDATE '. PLUGINS_TABLE .' 74 SET version = "'. BATCH_DOWNLOAD_VERSION .'" 75 WHERE id = "'. BATCH_DOWNLOAD_ID .'"'; 76 pwg_query($query); 77 78 $pwg_loaded_plugins[BATCH_DOWNLOAD_ID]['version'] = BATCH_DOWNLOAD_VERSION; 79 80 if (defined('IN_ADMIN')) 81 { 82 $_SESSION['page_infos'][] = 'BatchDownloader updated to version '. BATCH_DOWNLOAD_VERSION; 83 } 84 } 85 } 86 59 global $conf; 60 61 include_once(BATCH_DOWNLOAD_PATH . 'maintain.inc.php'); 62 $maintain = new BatchDownloader_maintain(BATCH_DOWNLOAD_ID); 63 $maintain->autoUpdate(BATCH_DOWNLOAD_VERSION, 'install'); 64 87 65 $conf['batch_download'] = unserialize($conf['batch_download']); 88 66 $conf['batch_download']['file_pattern'] = isset($conf['batch_download_file_pattern']) ? $conf['batch_download_file_pattern'] : '%id%_%filename%_%dimensions%'; … … 92 70 $conf['batch_download']['allowed_ext'] = array_merge($conf['batch_download']['allowed_ext'], $conf['batch_download_additional_ext']); 93 71 } 94 72 95 73 load_language('plugin.lang', BATCH_DOWNLOAD_PATH); 96 74 } … … 99 77 * admin plugins menu 100 78 */ 101 function batch_download_admin_menu($menu) 79 function batch_download_admin_menu($menu) 102 80 { 103 array_push($menu,array(81 $menu[] = array( 104 82 'NAME' => 'Batch Downloader', 105 83 'URL' => BATCH_DOWNLOAD_ADMIN, 106 ) );84 ); 107 85 return $menu; 108 86 } 109 110 ?> -
extensions/BatchDownloader/maintain.inc.php
r19837 r25932 2 2 if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); 3 3 4 defined('BATCH_DOWNLOAD_ID') or define('BATCH_DOWNLOAD_ID', basename(dirname(__FILE__))); 5 include_once(PHPWG_PLUGINS_PATH . BATCH_DOWNLOAD_ID . '/include/install.inc.php'); 4 class BatchDownloader_maintain extends PluginMaintain 5 { 6 private $installed = false; 6 7 7 function plugin_install() 8 { 9 batch_download_install(); 10 11 define('batch_download_installed', true); 12 } 8 function install($plugin_version, &$errors=array()) 9 { 10 global $conf, $prefixeTable; 13 11 14 function plugin_activate() 15 { 16 if (!defined('batch_download_installed')) 12 // configuration 13 if (empty($conf['batch_download'])) 14 { 15 $batch_download_default_config = array( 16 'groups' => array(), 17 'level' => 0, 18 'what' => array('categories','specials','collections'), 19 'photo_size' => 'original', 20 'multisize' => true, 21 'archive_prefix' => 'piwigo', 22 'archive_timeout' => 48, /* hours */ 23 'max_elements' => 500, 24 'max_size' => 100, /* MB */ 25 'last_clean' => time(), 26 'one_archive' => false, 27 'force_pclzip' => false, 28 'direct' => false, 29 ); 30 31 $conf['batch_download'] = serialize($batch_download_default_config); 32 $conf['batch_download_comment'] = null; 33 34 conf_update_param('batch_download', $conf['batch_download']); 35 conf_update_param('batch_download_comment', $conf['batch_download_comment']); 36 } 37 else 38 { 39 $new_conf = is_string($conf['batch_download']) ? unserialize($conf['batch_download']) : $conf['batch_download']; 40 41 if (!isset($new_conf['what'])) 42 { 43 $new_conf['what'] = array('categories','specials','collections'); 44 } 45 if (!isset($new_conf['one_archive'])) 46 { 47 $new_conf['one_archive'] = false; 48 $new_conf['force_pclzip'] = isset($conf['batch_download_force_pclzip']) && $conf['batch_download_force_pclzip']; 49 $new_conf['direct'] = isset($conf['batch_download_direct']) && $conf['batch_download_direct']; 50 } 51 if (!isset($new_conf['multisize'])) 52 { 53 $new_conf['multisize'] = true; 54 } 55 56 $conf['batch_download'] = serialize($new_conf); 57 conf_update_param('batch_download', $conf['batch_download']); 58 } 59 60 // archives directory 61 if (!file_exists(PHPWG_ROOT_PATH . $conf['data_location'] . 'download_archives/')) 62 { 63 mkgetdir(PHPWG_ROOT_PATH . $conf['data_location'] . 'download_archives/', MKGETDIR_DEFAULT&~MKGETDIR_DIE_ON_ERROR); 64 } 65 66 // create tables 67 $query = ' 68 CREATE TABLE IF NOT EXISTS `' . $prefixeTable . 'download_sets` ( 69 `id` mediumint(8) NOT NULL AUTO_INCREMENT, 70 `user_id` smallint(5) NOT NULL, 71 `date_creation` datetime NOT NULL, 72 `type` varchar(16) NOT NULL, 73 `type_id` varchar(64) NOT NULL, 74 `size` varchar(16) NOT NULL DEFAULT "original", 75 `nb_zip` smallint(3) NOT NULL DEFAULT 0, 76 `last_zip` smallint(3) NOT NULL DEFAULT 0, 77 `nb_images` mediumint(8) NOT NULL DEFAULT 0, 78 `total_size` int(10) NOT NULL DEFAULT 0, 79 `status` enum("new","ready","download","done") NOT NULL DEFAULT "new", 80 PRIMARY KEY (`id`) 81 ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 82 ;'; 83 pwg_query($query); 84 85 $query = ' 86 CREATE TABLE IF NOT EXISTS `' . $prefixeTable . 'download_sets_images` ( 87 `set_id` mediumint(8) NOT NULL, 88 `image_id` mediumint(8) NOT NULL, 89 `zip` smallint(5) NOT NULL DEFAULT 0, 90 UNIQUE KEY `UNIQUE` (`set_id`,`image_id`) 91 ) ENGINE=MyISAM DEFAULT CHARSET=utf8 92 ;'; 93 pwg_query($query); 94 95 $query = ' 96 CREATE TABLE IF NOT EXISTS `' . $prefixeTable . 'image_sizes` ( 97 `image_id` mediumint(8) NOT NULL, 98 `type` varchar(16) NOT NULL, 99 `width` smallint(9) NOT NULL, 100 `height` smallint(9) NOT NULL, 101 `filesize` mediumint(9) NOT NULL, 102 `filemtime` int(16) NOT NULL, 103 PRIMARY KEY (`image_id`) 104 ) ENGINE=MyISAM DEFAULT CHARSET=utf8 105 ;'; 106 pwg_query($query); 107 108 // add a "size" column to download_sets 109 $result = pwg_query('SHOW COLUMNS FROM `' . $prefixeTable . 'download_sets` LIKE "size";'); 110 if (!pwg_db_num_rows($result)) 111 { 112 pwg_query('ALTER TABLE `' . $prefixeTable . 'download_sets` ADD `size` varchar(16) NOT NULL DEFAULT "original";'); 113 } 114 115 // add "ready" status 116 pwg_query('ALTER TABLE `' . $prefixeTable . 'download_sets` CHANGE `status` `status` enum("new","ready","download","done") NOT NULL DEFAULT "new";'); 117 } 118 119 function activate($plugin_version, &$errors=array()) 17 120 { 18 batch_download_install(); 121 if (!$this->installed) 122 { 123 $this->install($plugin_version, $errors); 124 } 19 125 } 20 }21 126 22 function plugin_uninstall() 23 { 24 global $prefixeTable, $conf; 25 26 pwg_query('DELETE FROM `' . CONFIG_TABLE . '` WHERE param = "batch_download" LIMIT 1;'); 27 pwg_query('DROP TABLE IF EXISTS `' . $prefixeTable . 'download_sets`;'); 28 pwg_query('DROP TABLE IF EXISTS `' . $prefixeTable . 'download_sets_images`;'); 29 30 rrmdir(PHPWG_ROOT_PATH . $conf['data_location'] . 'download_archives/'); 31 } 127 function deactivate() 128 { 129 } 32 130 131 function uninstall() 132 { 133 global $prefixeTable, $conf; 33 134 34 if (!function_exists('rrmdir')) 35 { 36 function rrmdir($dir) 135 conf_delete_param('batch_download'); 136 137 pwg_query('DROP TABLE IF EXISTS `' . $prefixeTable . 'download_sets`;'); 138 pwg_query('DROP TABLE IF EXISTS `' . $prefixeTable . 'download_sets_images`;'); 139 140 self::rrmdir(PHPWG_ROOT_PATH . $conf['data_location'] . 'download_archives/'); 141 } 142 143 static function rrmdir($dir) 37 144 { 38 145 if (!is_dir($dir)) … … 43 150 $objects = scandir($dir); 44 151 $return = true; 45 152 46 153 foreach ($objects as $object) 47 154 { … … 49 156 { 50 157 $path = $dir.'/'.$object; 51 if (filetype($path) == 'dir') 158 if (filetype($path) == 'dir') 52 159 { 53 $return = $return && rrmdir($path);160 $return = $return && self::rrmdir($path); 54 161 } 55 else 162 else 56 163 { 57 164 $return = $return && @unlink($path); … … 59 166 } 60 167 } 61 168 62 169 return $return && @rmdir($dir); 63 170 } 64 171 } 65 66 ?> -
extensions/BatchDownloader/template/download_button.tpl
r25931 r25932 1 <a href="{$BATCH_DWN_URL}{$BATCH_DWN_SIZE}" id="batchDownloadLink" title="{'Download all pictures of this selection'| @translate}" class="pwg-state-default pwg-button" rel="nofollow">2 <span class="pwg-icon batch-downloader-icon" style="background:url('{$ROOT_URL}{$BATCH_DOWNLOAD_PATH}template/images/zip.png') center center no-repeat;"> </span><span class="pwg-button-text">{'Download'| @translate}</span>1 <a href="{$BATCH_DWN_URL}{$BATCH_DWN_SIZE}" id="batchDownloadLink" title="{'Download all pictures of this selection'|translate}" class="pwg-state-default pwg-button" rel="nofollow"> 2 <span class="pwg-icon batch-downloader-icon" style="background:url('{$ROOT_URL}{$BATCH_DOWNLOAD_PATH}template/images/zip.png') center center no-repeat;"> </span><span class="pwg-button-text">{'Download'|translate}</span> 3 3 </a> 4 4 … … 7 7 8 8 <div id="batchDownloadBox" class="switchBox" style="display:none"> 9 <div class="switchBoxTitle">{'Download'| @translate} - {'Photo sizes'|@translate}</div>9 <div class="switchBoxTitle">{'Download'|translate} - {'Photo sizes'|translate}</div> 10 10 {foreach from=$BATCH_DWN_SIZES item=size name=loop}{if !$smarty.foreach.loop.first}<br>{/if} 11 11 <a href="{$BATCH_DWN_URL}{$size.TYPE}" rel="nofollow"> … … 18 18 {footer_script require='jquery'} 19 19 var batchdown_count = {$BATCH_DWN_COUNT}; 20 var batchdown_string = "{'Confirm the download of %d pictures?'| @translate}";20 var batchdown_string = "{'Confirm the download of %d pictures?'|translate}"; 21 21 22 22 {if isset($BATCH_DWN_SIZES)} 23 23 (SwitchBox=window.SwitchBox||[]).push("#batchDownloadLink", "#batchDownloadBox"); 24 24 25 25 jQuery("#batchDownloadBox a").click(function() { 26 26 return confirm(batchdown_string.replace('%d', batchdown_count)); -
extensions/BatchDownloader/template/init_zip.tpl
r23360 r25932 1 {combine_css path=$BATCH_DOWNLOAD_PATH| @cat:"template/style.css"}1 {combine_css path=$BATCH_DOWNLOAD_PATH|cat:"template/style.css"} 2 2 3 3 {if $set.U_DOWNLOAD} 4 4 {footer_script} 5 setTimeout("document.location.href = '{$set.U_DOWNLOAD}';", 1000); 5 setTimeout(function() { 6 document.location.href = '{$set.U_DOWNLOAD}'; 7 }, 1000); 6 8 {/footer_script} 7 9 {/if} … … 12 14 13 15 {footer_script} 14 var derivatives = { ldelim}16 var derivatives = { 15 17 elements: ["{'","'|@implode:$missing_derivatives}"], 16 18 done: 0, 17 19 total: {$missing_derivatives|@count}, 18 19 finished: function() { ldelim}20 21 finished: function() { 20 22 return derivatives.done == derivatives.total; 21 23 } 22 24 }; 23 25 24 function progress() { ldelim}25 jQuery('#progressBar').progressBar(derivatives.done/derivatives.total*100, { ldelim}26 function progress() { 27 jQuery('#progressBar').progressBar(derivatives.done/derivatives.total*100, { 26 28 width: 300, 27 29 height: 24, … … 31 33 } 32 34 33 {literal} 34 var queuedManager = jQuery.manageAjax.create('queued', { 35 queue: true, 35 var queuedManager = jQuery.manageAjax.create('queued', { 36 queue: true, 36 37 cacheResponse: false, 37 38 maxRequests: 1 … … 40 41 function next_derivative() { 41 42 if (derivatives.finished()) { 42 setTimeout("location.reload(true)", 1000); 43 setTimeout(function() { 44 location.reload(true); 45 }, 1000); 43 46 return; 44 47 } 45 48 46 49 queuedManager.add({ 47 type: 'GET', 48 url: derivatives.elements[ derivatives.done ], 50 type: 'GET', 51 url: derivatives.elements[ derivatives.done ], 49 52 dataType: 'json', 50 data: { ajaxload: 'true' }, 53 data: { 54 ajaxload: 'true' 55 }, 51 56 success: function() { 52 57 derivatives.done++; … … 63 68 64 69 progress(); 65 setTimeout( "next_derivative()", 1000);66 {/ literal}{/footer_script}70 setTimeout(next_derivative, 1000); 71 {/footer_script} 67 72 68 {/if}69 70 71 {* <!-- Menubar & titrePage --> *}72 {if $themeconf.name == "stripped" or $themeconf.parent == "stripped"}73 {include file=$BATCH_DOWNLOAD_ABS_PATH|@cat:'template/themes/stripped.tpl'}74 {assign var="clear" value="true"}75 {elseif $themeconf.name == "simple-grey" or $themeconf.parent == "simple"}76 {include file=$BATCH_DOWNLOAD_ABS_PATH|@cat:'template/themes/simple.tpl'}77 {assign var="clear" value="true"}78 {else}79 {include file=$BATCH_DOWNLOAD_ABS_PATH|@cat:'template/themes/default.tpl'}80 {/if}81 82 {if isset($errors) or not empty($infos)}83 {include file='infos_errors.tpl'}84 73 {/if} 85 74 … … 87 76 {if $set} 88 77 <fieldset> 89 <legend>{'Download info'| @translate}</legend>78 <legend>{'Download info'|translate}</legend> 90 79 <h2>{$set.NAME}</h2> 91 80 {if $set.COMMENT}<blockquote class="comment">{$set.COMMENT}</blockquote>{/if} 92 81 93 82 <ul class="set-infos"> 94 83 <li class="error">{$elements_error}</li> 95 <li><b>{'%d photos'| @translate|@sprintf:$set.NB_IMAGES}</b>{if $set.U_EDIT_SET}, <a href="{$set.U_EDIT_SET}" rel="nofollow">{'Edit the set'|@translate}</a>{/if}</li>96 <li><b>{'Photo sizes'| @translate}:</b> {if $set.SIZE=='original'}{'Original'|@translate}{else}{$set.SIZE|@translate}{/if} {if $set.SIZE_INFO}<span class="downloadSizeDetails">({$set.SIZE_INFO})</span>{/if}</li>97 <li><b>{'Estimated size'| @translate}:</b> {$set.TOTAL_SIZE}</li>98 <li><b>{'Estimated number of archives'| @translate}:</b> {$set.NB_ARCHIVES} <i>({'real number of archives can differ'|@translate})</i></li>99 <li><b>{'Created on'| @translate}:</b> {$set.DATE_CREATION}</li>84 <li><b>{'%d photos'|translate:$set.NB_IMAGES}</b>{if $set.U_EDIT_SET}, <a href="{$set.U_EDIT_SET}" rel="nofollow">{'Edit the set'|translate}</a>{/if}</li> 85 <li><b>{'Photo sizes'|translate}:</b> {if $set.SIZE=='original'}{'Original'|translate}{else}{$set.SIZE|translate}{/if} {if $set.SIZE_INFO}<span class="downloadSizeDetails">({$set.SIZE_INFO})</span>{/if}</li> 86 <li><b>{'Estimated size'|translate}:</b> {$set.TOTAL_SIZE}</li> 87 <li><b>{'Estimated number of archives'|translate}:</b> {$set.NB_ARCHIVES} <i>({'real number of archives can differ'|translate})</i></li> 88 <li><b>{'Created on'|translate}:</b> {$set.DATE_CREATION}</li> 100 89 </ul> 101 90 </fieldset> … … 103 92 {if $missing_derivatives} 104 93 <fieldset> 105 <legend>{'Preparation'| @translate}</legend>106 107 <p>{'Please wait, your download is being prepared. This page will automatically refresh when it is ready.'| @translate}</p>108 94 <legend>{'Preparation'|translate}</legend> 95 96 <p>{'Please wait, your download is being prepared. This page will automatically refresh when it is ready.'|translate}</p> 97 109 98 <div id="progressBar"></div> 110 111 <a href="{$set.U_CANCEL}" class="cancel-down" onClick="return confirm('{'Are you sure?'| @translate}');">{'Cancel this download'|@translate}</a>99 100 <a href="{$set.U_CANCEL}" class="cancel-down" onClick="return confirm('{'Are you sure?'|translate}');">{'Cancel this download'|translate}</a> 112 101 </fieldset> 113 102 114 103 {elseif $zip_links} 115 104 <fieldset> 116 <legend>{'Download links'| @translate}</legend>117 105 <legend>{'Download links'|translate}</legend> 106 118 107 <ul class="download-links"> 119 108 {$zip_links} 120 <li class="warning">{'<b>Warning:</b> all files will be deleted within %d hours'| @translate|@sprintf:$archive_timeout}</li>109 <li class="warning">{'<b>Warning:</b> all files will be deleted within %d hours'|translate:$archive_timeout}</li> 121 110 </ul> 122 123 {if $set.U_CANCEL}<a href="{$set.U_CANCEL}" class="cancel-down" onClick="return confirm('{'Are you sure?'| @translate}');">{'Cancel this download'|@translate}</a>{/if}111 112 {if $set.U_CANCEL}<a href="{$set.U_CANCEL}" class="cancel-down" onClick="return confirm('{'Are you sure?'|translate}');">{'Cancel this download'|translate}</a>{/if} 124 113 </fieldset> 125 114 {/if} 126 115 {/if} 127 128 {if $clear}<div style="clear: both;"></div>129 </div>{/if}130 </div>{* <!-- content --> *} -
extensions/BatchDownloader/template/style.css
r23291 r25932 38 38 border-color:#f00; 39 39 } 40 40 41 41 .downloadSizeDetails { 42 42 font-style:italic; -
extensions/BatchDownloader/template/thumbnails_css_js.tpl
r23359 r25932 1 {html_style} 2 #thumbnails li { ldelim}position:relative !important;display:inline-block; }3 li .removeSet { ldelim}width:100%;height:16px;display:none;position:absolute;top:0;background:rgba(0,0,0,0.8);padding:2px;border-radius:2px;font-size:10px;z-index:100 !important;color:#eee;white-space:nowrap; }4 li:hover .removeSet { ldelim}display:block !important; }5 {/ html_style}1 {html_style}{literal} 2 #thumbnails li { position:relative !important;display:inline-block; } 3 li .removeSet { width:100%;height:16px;display:none;position:absolute;top:0;background:rgba(0,0,0,0.8);padding:2px;border-radius:2px;font-size:10px;z-index:100 !important;color:#eee;white-space:nowrap; } 4 li:hover .removeSet { display:block !important; } 5 {/literal}{/html_style} 6 6 7 7 {footer_script require='jquery'} 8 jQuery(".removeSet").click(function() { ldelim}8 jQuery(".removeSet").click(function() { 9 9 var toggle_id = jQuery(this).data("id"); 10 10 var $trigger = jQuery(this); 11 12 jQuery.ajax({ ldelim}11 12 jQuery.ajax({ 13 13 type: "POST", 14 14 url: "{$ROOT_URL}index.php", 15 data: { ldelim}15 data: { 16 16 action: "bd_remove_image", 17 17 set_id: "{$SET_ID}", 18 18 toggle_id: toggle_id 19 19 }, 20 success: function(msg) { ldelim}21 if (msg == "ok") { ldelim}22 $trigger.parent("li").hide("fast", function() { ldelim}20 success: function(msg) { 21 if (msg == "ok") { 22 $trigger.parent("li").hide("fast", function() { 23 23 jQuery(this).remove(); 24 24 if (typeof GThumb != "undefined") GThumb.build(); 25 25 }); 26 26 27 27 jQuery(".nbImagesSet").html(parseInt(jQuery(".nbImagesSet").html()) -1); 28 } else {ldelim} 29 $trigger.html('{'Un unknown error occured'|@translate}'); 28 } 29 else { 30 $trigger.html('{'Un unknown error occured'|translate}'); 30 31 } 31 32 }, 32 error: function() { ldelim}33 $trigger.html('{'Un unknown error occured'| @translate}');33 error: function() { 34 $trigger.html('{'Un unknown error occured'|translate}'); 34 35 } 35 36 }); 36 37 37 38 return false; 38 39 }); -
extensions/BatchDownloader/template/view.tpl
r17517 r25932 1 {* <!-- Menubar & titrePage --> *}2 {if $themeconf.name == "stripped" or $themeconf.parent == "stripped"}3 {include file=$BATCH_DOWNLOAD_ABS_PATH|@cat:'template/themes/stripped.tpl'}4 {assign var="clear" value="true"}5 {elseif $themeconf.name == "simple-grey" or $themeconf.parent == "simple"}6 {include file=$BATCH_DOWNLOAD_ABS_PATH|@cat:'template/themes/simple.tpl'}7 {assign var="clear" value="true"}8 {else}9 {include file=$BATCH_DOWNLOAD_ABS_PATH|@cat:'template/themes/default.tpl'}10 {/if}11 12 {if isset($errors) or not empty($infos)}13 {include file='infos_errors.tpl'}14 {/if}15 16 1 {if $set} 17 2 <fieldset> … … 19 4 {if $set.COMMENT}<blockquote>{$set.COMMENT}</blockquote>{/if} 20 5 {assign var="nb_images" value='<span class="nbImagesSet">'|@cat:$set.NB_IMAGES|@cat:'</span>'} 21 {'%d photos'| @translate|replace:'%d':'%s'|sprintf:$nb_images}6 {'%d photos'|translate|replace:'%d':'%s'|sprintf:$nb_images} 22 7 <br> 23 <b><a href="{$U_INIT_ZIP}" rel="nofollow">{'Return to download page'| @translate} →</a></b>8 <b><a href="{$U_INIT_ZIP}" rel="nofollow">{'Return to download page'|translate} →</a></b> 24 9 </fieldset> 25 10 … … 30 15 </ul> 31 16 {else} 32 {'This download set is empty'| @translate}17 {'This download set is empty'|translate} 33 18 {/if} 34 19 35 20 {if !empty($navbar)}{include file='navigation_bar.tpl'|@get_extent:'navbar'}{/if} 36 21 {/if} 37 38 {if $clear}<div style="clear: both;"></div>39 </div>{/if}40 </div>{* <!-- content --> *}
Note: See TracChangeset
for help on using the changeset viewer.