Changeset 23318
- Timestamp:
- Jun 18, 2013, 3:38:03 AM (11 years ago)
- Location:
- extensions/BatchDownloader
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/BatchDownloader/admin/sets.php
r23317 r23318 64 64 } 65 65 66 $order_by = $_POST['order_by'].' '.$_POST['direction']; 66 if ($_POST['size'] != -1) 67 { 68 array_push($where_clauses, 'size = "'.$_POST['size'].'"'); 69 } 70 71 if ($_POST['order_by'] == 'size') 72 { 73 $order_by = 'FIND_IN_SET(size, "square,thumb,2small,xsmall,small,medium,large,xlarge,xxlarge,original") '.$_POST['direction']; 74 } 75 else 76 { 77 $order_by = $_POST['order_by'].' '.$_POST['direction']; 78 } 67 79 } 68 80 … … 122 134 ); 123 135 136 $page['size_items'] = array( 137 -1 => '------------', 138 ); 139 foreach (ImageStdParams::get_defined_type_map() as $params) 140 { 141 $page['size_items'][ $params->type ] = l10n($params->type); 142 } 143 $page['size_items']['original'] = l10n('Original'); 144 124 145 $page['order_by_items'] = array( 125 146 'date_creation' => l10n('Creation date'), … … 127 148 'nb_images' => l10n('Number of images'), 128 149 'nb_archives' => l10n('Number of archives'), 150 'size' => l10n('Photo sizes'), 129 151 ); 130 152 … … 139 161 'type_options' => $page['type_items'], 140 162 'type_selected' => isset($_POST['type']) ? $_POST['type'] : '', 163 'size_options' => $page['size_items'], 164 'size_selected' => isset($_POST['size']) ? $_POST['size'] : '', 141 165 'order_options' => $page['order_by_items'], 142 166 'order_selected' => isset($_POST['order_by']) ? $_POST['order_by'] : '', -
extensions/BatchDownloader/admin/template/sets.tpl
r23291 r23318 17 17 {'Set type'|@translate} 18 18 {html_options name=type options=$type_options selected=$type_selected} 19 </label> 20 21 <label> 22 {'Photo sizes'|@translate} 23 {html_options name=size options=$size_options selected=$size_selected} 19 24 </label> 20 25 … … 49 54 <td class="type">{'Set type'|@translate}</td> 50 55 <td class="date">{'Creation date'|@translate}</td> 51 <td class=" size">{'Total size'|@translate}</td>56 <td class="img_size">{'Photo sizes'|@translate}</td> 52 57 <td class="images">{'Number of images'|@translate}</td> 53 58 <td class="archives">{'Number of archives'|@translate}</td> 59 <td class="size">{'Total size'|@translate}</td> 54 60 <td class="status">{'Status'|@translate}</td> 55 61 <td class="action">{'Actions'|@translate}</td> … … 62 68 <td>{$set.NAME}</td> 63 69 <td style="text-align:center;">{$set.DATE_CREATION}</td> 64 <td>{ $set.TOTAL_SIZE}</td>70 <td>{if $set.SIZE=='original'}{'Original'|@translate}{else}{$set.SIZE|@translate}{/if}</td> 65 71 <td>{$set.NB_IMAGES}</td> 66 72 <td>{$set.NB_ARCHIVES}</td> 73 <td>{$set.TOTAL_SIZE}</td> 67 74 <td> 68 75 {$set.STATUS|@translate} -
extensions/BatchDownloader/admin/template/style.css
r23288 r23318 38 38 width:100px; 39 39 } 40 .table2 .img_size { 41 width:120px; 42 } 40 43 .table2 .images { 41 44 width:100px; -
extensions/BatchDownloader/include/BatchDownloader.class.php
r23317 r23318 12 12 * @param: mixed set id (##|'new') 13 13 * @param: array images 14 * @param: string set type ( 'album'|'tag'|'selection')15 * @param: int set type id (for retrieving album infos for instance)14 * @param: string set type (calendar,category,flat,tags,search,favorites,most_visited,best_rated,list,recent_pics,collection) 15 * @param: mixed set type id (for calendar,category,tags,search,collection) 16 16 * @param: string size to download 17 17 */ … … 32 32 'nb_images' => 0, 33 33 'total_size' => 0, 34 'estimated_total_size' => 0,35 34 'status' => 'new', 35 'estimated_total_size' => 0, // not in db 36 36 ); 37 37 $this->images = array(); … … 43 43 SELECT * 44 44 FROM '.BATCH_DOWNLOAD_TSETS.' 45 WHERE 46 id = '.$set_id.' 45 WHERE id = '.$set_id.' 47 46 '.(!is_admin() ? 'AND user_id = '.$this->data['user_id'] : null).' 48 47 ;'; … … 56 55 ); 57 56 58 // make sur all pictures of the set exist57 // make sure all pictures of the set exist 59 58 $query = ' 60 59 DELETE FROM '.BATCH_DOWNLOAD_TIMAGES.' … … 66 65 67 66 $query = ' 68 SELECT 69 image_id, 70 zip 67 SELECT * 71 68 FROM '.BATCH_DOWNLOAD_TIMAGES.' 72 69 WHERE set_id = '.$this->data['id'].' … … 89 86 if ($size != 'original') 90 87 { 91 $type _map= array_keys(ImageStdParams::get_defined_type_map());92 if (!in_array($size, $type _map))88 $types = array_keys(ImageStdParams::get_defined_type_map()); 89 if (!in_array($size, $types)) 93 90 { 94 91 throw new Exception(sprintf(l10n('Invalid size %s'), $size)); … … 166 163 /** 167 164 * getImages 168 * @return: array 165 * @return: array(image_id => zip_idx) 169 166 */ 170 167 function getImages() … … 213 210 function addImages($image_ids) 214 211 { 215 global $conf;216 217 212 if (empty($image_ids) or !is_array($image_ids)) return; 218 213 … … 229 224 { 230 225 if ($this->isInSet($image_id)) continue; 231 if (!in_array(get_extension($file), $ conf['batch_download']['allowed_ext'])) continue;226 if (!in_array(get_extension($file), $this->conf['allowed_ext'])) continue; 232 227 233 228 $this->images[ $image_id ] = 0; 234 array_push($inserts, array('set_id'=>$this->data['id'], 'image_id'=>$image_id, 'zip'=>0)); 235 } 236 237 mass_inserts( 238 BATCH_DOWNLOAD_TIMAGES, 239 array('set_id', 'image_id', 'zip'), 240 $inserts 241 ); 229 $inserts[] = array( 230 'set_id' => $this->data['id'], 231 'image_id' => $image_id, 232 'zip' => 0, 233 ); 234 } 235 236 if (count($inserts)) 237 { 238 mass_inserts( 239 BATCH_DOWNLOAD_TIMAGES, 240 array('set_id','image_id','zip'), 241 $inserts 242 ); 243 } 242 244 243 245 $this->updateParam('nb_images', count($this->images)); … … 259 261 260 262 /** 261 * get missing derivatives files 263 * getMissingDerivatives 264 * @param: bool update, if true, update IMAGE_SIZES with FS datas 262 265 * @return: array of i.php urls 263 266 */ … … 268 271 return array(); 269 272 } 270 271 global $conf;272 273 273 274 $root_url = get_root_url(); … … 280 281 $to_update = $urls = $inserts = array(); 281 282 283 global $conf; 284 $conf['old_question_mark_in_urls'] = $conf['question_mark_in_urls']; 285 $conf['old_php_extension_in_urls'] = $conf['php_extension_in_urls']; 286 $conf['old_derivative_url_style'] = $conf['derivative_url_style']; 282 287 $conf['question_mark_in_urls'] = $conf['php_extension_in_urls'] = true; 283 $conf['derivative_url_style'] = 2; //script288 $conf['derivative_url_style'] = 2; 284 289 285 290 // images which we need to update stats … … 287 292 { 288 293 $query = ' 289 SELECT image_id, filemtime FROM '.IMAGE_SIZES_TABLE.' 294 SELECT image_id, filemtime 295 FROM '.IMAGE_SIZES_TABLE.' 290 296 WHERE image_id IN('.implode(',', $image_ids).') 291 297 AND type = "'.$this->data['size'].'" … … 328 334 { 329 335 $derivative = new DerivativeImage($this->data['size'], $src_image); 330 // if ($this->data['size'] != $derivative->get_type()) continue;331 336 332 337 $filemtime = @filemtime($derivative->get_path()); … … 369 374 } 370 375 376 $conf['question_mark_in_urls'] = $conf['old_question_mark_in_urls']; 377 $conf['php_extension_in_urls'] = $conf['old_php_extension_in_urls']; 378 $conf['derivative_url_style'] = $conf['old_derivative_url_style']; 379 371 380 return $urls; 372 381 } … … 412 421 } 413 422 414 $this->getEstimatedArchiveNumber( );423 $this->getEstimatedArchiveNumber(true); 415 424 416 425 $this->updateParam('date_creation', date('Y-m-d H:i:s')); … … 572 581 } 573 582 574 list($total) = pwg_db_fetch_row(pwg_query($query)); 575 $this->data['estimated_total_size'] = $total; 576 return $total; 583 list($this->data['estimated_total_size']) = pwg_db_fetch_row(pwg_query($query)); 584 return $this->data['estimated_total_size']; 577 585 } 578 586 … … 581 589 * @return: int 582 590 */ 583 function getEstimatedArchiveNumber( )591 function getEstimatedArchiveNumber($force=false) 584 592 { 585 593 if ($this->data['status'] == 'done') return $this->data['nb_zip']; 586 587 return ceil( $this->getEstimatedTotalSize() / ($this->conf['max_size']*1024) ); 594 if ( !empty($this->data['nb_zip']) and !$force ) return $this->data['nb_zip']; 595 596 $this->updateParam('nb_zip', ceil( $this->getEstimatedTotalSize($force) / ($this->conf['max_size']*1024) )); 597 return $this->data['nb_zip']; 588 598 } 589 599 … … 649 659 $path.= $set['BASENAME'] . '_'; 650 660 $path.= $this->data['user_id'] . $this->data['id']; 651 $path.= '_part' . $i; 652 $path.= '.zip'; 661 $path.= '_part' . $i . '.zip'; 653 662 654 663 return $path; … … 657 666 /** 658 667 * getNames 659 * @return: array 668 * @return: array 669 * NAME, set name with HTML 670 * sNAME, set name without HTML 671 * BASENAME, set filename 672 * COMMENT, set comment 660 673 */ 661 674 function getNames() … … 848 861 'NB_IMAGES' => $this->data['nb_images'], 849 862 'NB_ARCHIVES' => $this->data['status']=='new' ? l10n('Unknown') : $this->getEstimatedArchiveNumber(), 850 'STATUS' => $this->data['status'] ,863 'STATUS' => $this->data['status']=='ready' ? 'new' : $this->data['status'], 851 864 'LAST_ZIP' => $this->data['last_zip'], 852 865 'TOTAL_SIZE' => $this->data['status']=='new' ? l10n('Unknown') : sprintf(l10n('%d MB'), ceil($this->getEstimatedTotalSize()/1024)), 853 866 'DATE_CREATION' => format_date($this->data['date_creation'], true), 854 'SIZE_ID' => $this->data['size'], 855 'SIZE' => $this->data['size']=='original' ? l10n('Original') : l10n($this->data['size']), 867 'SIZE' => $this->data['size'], 856 868 ); 857 869 -
extensions/BatchDownloader/include/events.inc.php
r23290 r23318 141 141 'BATCH_DWN_URL' => $url, 142 142 )); 143 144 $type_map = ImageStdParams::get_defined_type_map(); 145 foreach ($type_map as $params) 143 144 foreach (ImageStdParams::get_defined_type_map() as $params) 146 145 { 147 146 $template->append( -
extensions/BatchDownloader/include/functions.inc.php
r23291 r23318 34 34 { 35 35 $batch_type = 'flat'; 36 $batch_id = 0;36 $batch_id = null; 37 37 } 38 38 break; … … 58 58 case 'recent_pics': 59 59 $batch_type = $page['section']; 60 $batch_id = 0;60 $batch_id = null; 61 61 break; 62 62 default: -
extensions/BatchDownloader/template/init_zip.tpl
r23291 r23318 93 93 <li class="error">{$elements_error}</li> 94 94 <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> 95 <li><b>{' Size'|@translate}:</b> {$set.SIZE} {if $set.SIZE_INFO}<span class="downloadSizeDetails">({$set.SIZE_INFO})</span>{/if}</li>95 <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> 96 96 <li><b>{'Estimated size'|@translate}:</b> {$set.TOTAL_SIZE}</li> 97 97 <li><b>{'Estimated number of archives'|@translate}:</b> {$set.NB_ARCHIVES} <i>({'real number of archives can differ'|@translate})</i></li>
Note: See TracChangeset
for help on using the changeset viewer.