- Timestamp:
- Jun 17, 2013, 8:03:39 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/BatchDownloader/include/BatchDownloader.class.php
r23290 r23291 298 298 299 299 $query = ' 300 SELECT id, path, representative_ext,width, height, rotation300 SELECT id, path, width, height, rotation 301 301 FROM '.IMAGES_TABLE.' 302 302 WHERE id IN('.implode(',', $image_ids).') … … 307 307 while ($row = pwg_db_fetch_assoc($result)) 308 308 { 309 $src_image = new SrcImage($row); 310 if ($src_image->is_mimetype()) continue; 311 312 $derivative = new DerivativeImage($this->data['size'], $src_image); 313 // if ($this->data['size'] != $derivative->get_type()) continue; 314 315 $filemtime = @filemtime($derivative->get_path()); 316 317 if ($filemtime===false || $filemtime<$last_mod_time) 318 { 319 $urls[] = $root_url.$derivative->get_url().$uid; 320 } 321 else if ($update && in_array($row['id'], $to_update)) 322 { 323 $imagesize = getimagesize($derivative->get_path()); 324 325 $inserts[ $row['id'] ] = array( 326 'image_id' => $row['id'], 327 'type' => $this->data['size'], 328 'width' => $imagesize[0], 329 'height' => $imagesize[1], 330 'filesize' => filesize($derivative->get_path())/1024, 331 'filemtime' => $filemtime, 332 ); 309 $src_image = new SrcImage($row); // don't give representive_ext 310 311 // no-image files 312 if ($src_image->is_mimetype()) 313 { 314 if ($update && in_array($row['id'], $to_update)) 315 { 316 $inserts[ $row['id'] ] = array( 317 'image_id' => $row['id'], 318 'type' => $this->data['size'], 319 'width' => 0, 320 'height' => 0, 321 'filesize' => filesize(PHPWG_ROOT_PATH.$row['path'])/1024, 322 'filemtime' => filemtime(PHPWG_ROOT_PATH.$row['path']), 323 ); 324 } 325 } 326 // images files 327 else 328 { 329 $derivative = new DerivativeImage($this->data['size'], $src_image); 330 // if ($this->data['size'] != $derivative->get_type()) continue; 331 332 $filemtime = @filemtime($derivative->get_path()); 333 $src_mtime = @filemtime(PHPWG_ROOT_PATH.$row['path']); 334 if ($src_mtime===false) continue; 335 336 if ($filemtime===false || $filemtime<$last_mod_time || $filemtime<$src_mtime) 337 { 338 $urls[] = $root_url.$derivative->get_url().$uid; 339 } 340 else if ($update && in_array($row['id'], $to_update)) 341 { 342 $imagesize = getimagesize($derivative->get_path()); 343 344 $inserts[ $row['id'] ] = array( 345 'image_id' => $row['id'], 346 'type' => $this->data['size'], 347 'width' => $imagesize[0], 348 'height' => $imagesize[1], 349 'filesize' => filesize($derivative->get_path())/1024, 350 'filemtime' => $filemtime, 351 ); 352 } 333 353 } 334 354 } … … 344 364 mass_inserts( 345 365 IMAGE_SIZES_TABLE, 346 array('image_id','type','width','height','filesize' ),366 array('image_id','type','width','height','filesize','filemtime'), 347 367 $inserts 348 368 ); … … 410 430 SELECT 411 431 id, name, file, path, 412 representative_ext, rotation, 413 filesize, width, height 432 rotation, filesize, width, height 414 433 FROM '.IMAGES_TABLE.' 415 434 WHERE id IN ('.implode(',', $images_to_add).') … … 438 457 foreach ($images_to_add as $row) 439 458 { 459 if (!file_exists(PHPWG_ROOT_PATH.$row['path'])) 460 { 461 $this->removeImages(array($row['id'])); 462 continue; 463 } 464 440 465 if ($this->data['size'] == 'original') 441 466 { 442 $zip->addFile(PHPWG_ROOT_PATH .$row['path'], $row['id'].'_'.stripslashes(get_filename_wo_extension($row['file'])).'.'.get_extension($row['path']));467 $zip->addFile(PHPWG_ROOT_PATH.$row['path'], $row['id'].'_'.stripslashes(get_filename_wo_extension($row['file'])).'.'.get_extension($row['path'])); 443 468 $total_size+= $row['filesize']; 444 469 } 445 470 else 446 471 { 447 $src_image = new SrcImage($row); 448 $derivative = new DerivativeImage($this->data['size'], $src_image); 449 $path = $derivative->get_path(); 450 451 $zip->addFile($path, $row['id'].'_'.stripslashes(get_filename_wo_extension(basename($path))).'.'.get_extension($path)); 452 $total_size+= $filesizes[ $row['id'] ]; 472 $src_image = new SrcImage($row); // don't give representive_ext 473 474 // no-image files 475 if ($src_image->is_mimetype()) 476 { 477 $zip->addFile(PHPWG_ROOT_PATH.$row['path'], $row['id'].'_'.stripslashes(get_filename_wo_extension($row['file'])).'.'.get_extension($row['path'])); 478 $total_size+= $row['filesize']; 479 } 480 // images files 481 else 482 { 483 $derivative = new DerivativeImage($this->data['size'], $src_image); 484 $path = $derivative->get_path(); 485 486 $zip->addFile($path, $row['id'].'_'.stripslashes(get_filename_wo_extension(basename($path))).'.'.get_extension($path)); 487 $total_size+= $filesizes[ $row['id'] ]; 488 } 453 489 } 454 490 … … 572 608 if ($this->data['status'] == 'done' or $i < $this->data['last_zip']+1) 573 609 { 574 $out.= '<img src="'.$root_url.BATCH_DOWNLOAD_PATH.'template/ drive.png"> Archive #'.$i.' (already downloaded)';610 $out.= '<img src="'.$root_url.BATCH_DOWNLOAD_PATH.'template/images/drive_error.png"> Archive #'.$i.' (already downloaded)'; 575 611 } 576 612 else if ($i == $this->data['last_zip']+1) … … 578 614 $out.= '<a href="'.add_url_params($url, array('set_id'=>$this->data['id'],'zip'=>$i)).'" rel="nofollow" style="font-weight:bold;"' 579 615 .($i!=1 ? ' 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). 580 '><img src="'.$root_url.BATCH_DOWNLOAD_PATH.'template/ drive_go.png"> Archive #'.$i.' (ready)</a>';616 '><img src="'.$root_url.BATCH_DOWNLOAD_PATH.'template/images/drive_go.png"> Archive #'.$i.' (ready)</a>'; 581 617 } 582 618 else 583 619 { 584 $out.= '<img src="'.$root_url.BATCH_DOWNLOAD_PATH.'template/ drive.png"> Archive #'.$i.' (pending)';620 $out.= '<img src="'.$root_url.BATCH_DOWNLOAD_PATH.'template/images/drive.png"> Archive #'.$i.' (pending)'; 585 621 } 586 622 … … 613 649 $path.= $set['BASENAME'] . '_'; 614 650 $path.= $this->data['user_id'] . $this->data['id']; 615 $path.= $this->getEstimatedArchiveNumber()!=1 ? '_part' . $i : null;651 $path.= '_part' . $i; 616 652 $path.= '.zip'; 617 653 … … 811 847 $set = array( 812 848 'NB_IMAGES' => $this->data['nb_images'], 813 'NB_ARCHIVES' => $this->data['status']=='new' ? l10n(' unknown') : $this->getEstimatedArchiveNumber(),849 'NB_ARCHIVES' => $this->data['status']=='new' ? l10n('Unknown') : $this->getEstimatedArchiveNumber(), 814 850 'STATUS' => $this->data['status'], 815 851 'LAST_ZIP' => $this->data['last_zip'], 816 'TOTAL_SIZE' => $this->data['status']=='new' ? l10n('unknown') : ceil($this->getEstimatedTotalSize()/1024), 817 // 'LINKS' => $this->getDownloadList(BATCH_DOWNLOAD_PUBLIC . 'init_zip'), 852 'TOTAL_SIZE' => $this->data['status']=='new' ? l10n('Unknown') : sprintf(l10n('%d MB'), ceil($this->getEstimatedTotalSize()/1024)), 818 853 'DATE_CREATION' => format_date($this->data['date_creation'], true), 819 854 'SIZE_ID' => $this->data['size'], 820 'SIZE' => l10n($this->data['size']),855 'SIZE' => $this->data['size']=='original' ? l10n('Original') : l10n($this->data['size']), 821 856 ); 822 857
Note: See TracChangeset
for help on using the changeset viewer.