Changeset 17915 for extensions/BatchDownloader/include
- Timestamp:
- Sep 14, 2012, 5:59:05 PM (12 years ago)
- Location:
- extensions/BatchDownloader/include
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/BatchDownloader/include/BatchDownloader.class.php
r17880 r17915 30 30 'nb_images' => 0, 31 31 'total_size' => 0, 32 'estimated_total_size' => 0, 32 33 'status' => 'new', 33 34 ); … … 314 315 $this->updateParam('last_zip', $this->data['last_zip']+1); 315 316 $zip_path = $this->getArchivePath(); 316 317 317 $zip = new myZip($zip_path, isset($conf['batch_download_force_pclzip'])); 318 318 … … 383 383 * @return: int 384 384 */ 385 function getEstimatedTotalSize( )385 function getEstimatedTotalSize($force=false) 386 386 { 387 387 if ($this->data['status'] == 'done') return $this->data['total_size']; 388 388 if ($this->data['nb_images'] == 0) return 0; 389 if ( !empty($this->data['estimated_total_size']) and !$force ) return $this->data['estimated_total_size']; 389 390 390 391 $image_ids = array_slice(array_keys($this->images), 0, $this->conf['max_elements']); … … 396 397 ;'; 397 398 list($total) = pwg_db_fetch_row(pwg_query($query)); 399 $this->data['estimated_total_size'] = $total; 398 400 return $total; 399 401 } … … 462 464 463 465 if ($i === null) $i = $this->data['last_zip']; 466 $set = $this->getNames(); 464 467 465 468 include_once(PHPWG_ROOT_PATH . 'admin/include/functions.php'); 466 469 467 return BATCH_DOWNLOAD_LOCAL .'u-'. $this->data['user_id'] .'/'. 468 (!empty($this->conf['archive_prefix']) ? $this->conf['archive_prefix'] .'_' : null). 469 get_username($this->data['user_id']) .'_'. 470 $this->data['type'] .'-'. $this->data['type_id'] .'_'. 471 $this->data['user_id'] . $this->data['id'] . 472 ($this->data['nb_zip']!=1 ? '_part'. $i : null). 473 '.zip'; 474 } 475 476 /** 477 * getSetInfo 470 $path = BATCH_DOWNLOAD_LOCAL . 'u-'. $this->data['user_id'] . '/'; 471 $path.= !empty($this->conf['archive_prefix']) ? $this->conf['archive_prefix'] . '_' : null; 472 $path.= get_username($this->data['user_id']) . '_'; 473 $path.= $set['BASENAME'] . '_'; 474 $path.= $this->data['user_id'] . $this->data['id']; 475 $path.= $this->data['nb_zip']!=1 ? '_part' . $i : null; 476 $path.= '.zip'; 477 478 return $path; 479 } 480 481 /** 482 * getNames 478 483 * @return: array 479 484 */ 480 function getSetInfo() 481 { 482 $set = array( 483 'NB_IMAGES' => $this->data['nb_images'], 484 'NB_ARCHIVES' => $this->data['nb_zip'], 485 'TOTAL_SIZE' => ceil($this->getEstimatedTotalSize()/1024), 486 'LINKS' => $this->getDownloadList(BATCH_DOWNLOAD_PUBLIC . 'init_zip'), 487 'DATE_CREATION' => format_date($this->data['date_creation'], true), 488 ); 489 485 function getNames() 486 { 490 487 switch ($this->data['type']) 491 488 { … … 517 514 $set['NAME'] = l10n('Calendar').': '.$fields[$page['chronology_field']].$display_name; 518 515 $set['sNAME'] = l10n('Calendar').': '.ltrim($display_name, $conf['level_separator']); 516 $set['BASENAME'] = 'calendar-'.$page['chronology_field'].'-'.implode('-',$page['chronology_date']); 519 517 520 518 $page = $old_page; … … 529 527 { 530 528 $set['NAME'] = l10n('Album').': #'.$this->data['type_id'].' (deleted)'; 529 $set['BASENAME'] = 'album'.$this->data['type_id']; 531 530 } 532 531 else … … 535 534 $set['sNAME'] = l10n('Album').': '.trigger_event('render_category_name', $category['name']); 536 535 $set['COMMENT'] = trigger_event('render_category_description', $category['comment']); 536 537 if (!empty($category['permalink'])) 538 { 539 $set['BASENAME'] = 'album-'.$category['permalink']; 540 } 541 else if ( ($name = str2url($category['name'])) != null ) 542 { 543 $set['BASENAME'] = 'album-'.$name; 544 } 545 else 546 { 547 $set['BASENAME'] = 'album'.$this->data['type_id']; 548 } 537 549 } 538 550 break; … … 543 555 { 544 556 $set['NAME'] = l10n('Whole gallery'); 557 $set['BASENAME'] = 'all-gallery'; 545 558 break; 546 559 } … … 551 564 $tags = find_tags(explode(',', $this->data['type_id'])); 552 565 $set['NAME'] = l10n('Tags').': '; 566 $set['BASENAME'] = 'tags'; 553 567 554 568 $first = true; … … 561 575 .trigger_event('render_tag_name', $tag['name']) 562 576 .'</a>'; 577 $set['BASENAME'].= '-'.$tag['url_name']; 563 578 } 564 579 break; … … 569 584 { 570 585 $set['NAME'] = '<a href="'.make_index_url(array('section'=>'search', 'search'=>$this->data['type_id'])).'">'.l10n('Search').'</a>'; 586 $set['BASENAME'] = 'search'.$this->data['type_id']; 571 587 break; 572 588 } … … 576 592 { 577 593 $set['NAME'] = '<a href="'.make_index_url(array('section'=>'favorites')).'">'.l10n('Your favorites').'</a>'; 594 $set['BASENAME'] = 'favorites'; 578 595 break; 579 596 } … … 583 600 { 584 601 $set['NAME'] = '<a href="'.make_index_url(array('section'=>'most_visited')).'">'.l10n('Most visited').'</a>'; 602 $set['BASENAME'] = 'most-visited'; 585 603 break; 586 604 } … … 590 608 { 591 609 $set['NAME'] = '<a href="'.make_index_url(array('section'=>'best_rated')).'">'.l10n('Best rated').'</a>'; 610 $set['BASENAME'] = 'best-rated'; 592 611 break; 593 612 } … … 597 616 { 598 617 $set['NAME'] = l10n('Random'); 618 $set['BASENAME'] = 'random'; 599 619 break; 600 620 } … … 604 624 { 605 625 $set['NAME'] = '<a href="'.make_index_url(array('section'=>'recent_pics')).'">'.l10n('Recent photos').'</a>'; 626 $set['BASENAME'] = 'recent-pics'; 606 627 break; 607 628 } … … 616 637 $infos = $UserCollection->getCollectionInfo(); 617 638 $set['NAME'] = l10n('Collection').': <a href="'.$infos['U_PUBLIC'].'">'.$UserCollection->getParam('name').'</a>'; 639 640 if ( ($name = str2url($UserCollection->getParam('name'))) != null) 641 { 642 $set['BASENAME'] = 'collection-'.$name; 643 } 644 else 645 { 646 $set['BASENAME'] = 'collection'.$this->data['type_id']; 647 } 618 648 } 619 649 catch (Exception $e) 620 650 { 621 651 $set['NAME'] = l10n('Collection').': #'.$this->data['type_id'].' (deleted)'; 652 $set['BASENAME'] = 'collection'.$this->data['type_id']; 622 653 } 623 654 break; … … 625 656 } 626 657 627 if (!isset($set['sNAME'])) $set['sNAME'] = strip_tags($set['NAME']); 628 if (!isset($set['COMMENT'])) $set['COMMENT'] = null; 658 if (!isset($set['sNAME'])) $set['sNAME'] = strip_tags($set['NAME']); 659 if (!isset($set['COMMENT'])) $set['COMMENT'] = null; 660 if (!isset($set['BASENAME'])) $set['BASENAME'] = $this->data['type'] . $this->data['type_id']; 629 661 630 662 return $set; 663 } 664 665 /** 666 * getSetInfo 667 * @return: array 668 */ 669 function getSetInfo() 670 { 671 $set = array( 672 'NB_IMAGES' => $this->data['nb_images'], 673 'NB_ARCHIVES' => $this->data['nb_zip'], 674 'STATUS' => $this->data['status'], 675 'LAST_ZIP' => $this->data['last_zip'], 676 'TOTAL_SIZE' => ceil($this->getEstimatedTotalSize()/1024), 677 'LINKS' => $this->getDownloadList(BATCH_DOWNLOAD_PUBLIC . 'init_zip'), 678 'DATE_CREATION' => format_date($this->data['date_creation'], true), 679 ); 680 681 return array_merge($set, $this->getNames()); 631 682 } 632 683 } -
extensions/BatchDownloader/include/download.inc.php
r17492 r17915 23 23 pwg_query('DELETE FROM '.BATCH_DOWNLOAD_TSETS.' WHERE id = '.$_GET['set_id'].';'); 24 24 $_SESSION['page_infos'][] = l10n('Download set deleted'); 25 redirect(get_ root_url());25 redirect(get_absolute_root_url()); 26 26 } 27 27
Note: See TracChangeset
for help on using the changeset viewer.