- Timestamp:
- Jun 18, 2013, 3:38:03 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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
Note: See TracChangeset
for help on using the changeset viewer.