Changeset 17880
- Timestamp:
- Sep 13, 2012, 3:56:14 AM (12 years ago)
- Location:
- extensions/BatchDownloader
- Files:
-
- 1 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/BatchDownloader/admin.php
r17517 r17880 17 17 if (!class_exists('ZipArchive')) 18 18 { 19 array_push($page[' errors'], l10n('Unable to find ZipArchive PHP extension, Batch Downloader can\'t work without this extension.'));19 array_push($page['warnings'], l10n('Unable to find ZipArchive PHP extension, Batch Downloader will use PclZip instead, but with degraded performance.')); 20 20 } 21 21 -
extensions/BatchDownloader/admin/config.php
r16689 r17880 52 52 'batch_download' => $conf['batch_download'], 53 53 'batch_download_comment' => stripslashes($conf['batch_download_comment']), 54 'use_ziparchive' => class_exists('ZipArchive') && !isset($conf['batch_downloader_force_pclzip']), 55 'PHP_VERSION' => PHP_VERSION, 54 56 )); 55 57 -
extensions/BatchDownloader/admin/template/config.tpl
r16697 r17880 107 107 </label> 108 108 </li> 109 {if $use_ziparchive} 109 110 <li> 110 111 <label> … … 115 116 <i>{'Warning: ZipArchive doesn\'t accept special characters like accentuated ones, angle quotes (») and non-latin alphabets.'|@translate}</i> 116 117 </li> 118 {else} 119 <input type="hidden" name="archive_comment" value=""> 120 {/if} 117 121 </ul> 118 122 </fieldset> 119 123 120 124 <p class="formButtons"><input type="submit" name="save_config" value="{'Save Settings'|@translate}"></p> 125 126 <fieldset> 127 <legend>{'Environment'|@translate}</legend> 128 129 <b>PHP</b> {$PHP_VERSION}<br> 130 {if $use_ziparchive} 131 <b>ZipArchive</b> {$PHP_VERSION} 132 {else} 133 <b>PclZip</b> 2.8.2 134 {/if} 135 </fieldset> 136 121 137 </form> -
extensions/BatchDownloader/include/BatchDownloader.class.php
r17656 r17880 20 20 21 21 $this->conf = $conf['batch_download']; 22 $this->conf['archive_acomment'] = $conf['batch_download_comment'];23 22 $this->data = array( 24 23 'id' => 0, … … 270 269 } 271 270 271 global $conf; 272 272 273 // first zip 273 274 if ($this->data['last_zip'] == 0) … … 314 315 $zip_path = $this->getArchivePath(); 315 316 316 $zip = new ZipArchive; 317 if ($zip->open($zip_path, ZipArchive::CREATE) !== true) 318 { 319 trigger_error('BatchDownloader::createNextArchive, unable to open ZIP archive', E_USER_ERROR); 320 } 317 $zip = new myZip($zip_path, isset($conf['batch_download_force_pclzip'])); 321 318 322 319 // add images until size limit is reach, or all images are added … … 337 334 338 335 // archive comment 339 global $conf; 340 $comment = 'Generated on '.date('r').' with PHP ZipArchive '.PHP_VERSION.' by Piwigo Batch Downloader.'; 336 $comment = 'Generated on '.date('r').' with PHP '.PHP_VERSION.' by Piwigo Batch Downloader.'; 341 337 $comment.= "\n".$conf['gallery_title'].' - '.get_absolute_root_url(); 342 if (!empty($ this->conf['archive_comment']))343 { 344 $comment.= "\n\n".wordwrap(remove_accents($ this->conf['archive_comment']), 60);338 if (!empty($conf['batch_download_comment'])) 339 { 340 $comment.= "\n\n".wordwrap(remove_accents($conf['batch_download_comment']), 60); 345 341 } 346 342 $zip->setArchiveComment($comment); … … 629 625 } 630 626 631 if (!isset($set['sNAME'])) $set['sNAME'] = strip_tags($set['NAME']);627 if (!isset($set['sNAME'])) $set['sNAME'] = strip_tags($set['NAME']); 632 628 if (!isset($set['COMMENT'])) $set['COMMENT'] = null; 633 629 634 630 return $set; 631 } 632 } 633 634 635 /** 636 * small class implementing basic ZIP creation 637 * with ZipArchive or PclZip 638 */ 639 class myZip 640 { 641 private $lib; 642 private $zip; 643 644 function __construct($zip_path, $pclzip=false) 645 { 646 if ( class_exists('ZipArchive') and !$pclzip ) 647 { 648 $this->lib = 'zipa'; 649 650 $this->zip = new ZipArchive; 651 if ($this->zip->open($zip_path, ZipArchive::CREATE) !== true) 652 { 653 trigger_error('BatchDownloader::createNextArchive, unable to open ZIP archive (ZipArchive)', E_USER_ERROR); 654 } 655 } 656 else 657 { 658 $this->lib = 'pcl'; 659 660 require_once(BATCH_DOWNLOAD_PATH.'include/pclzip.lib.php'); 661 $this->zip = new PclZip($zip_path); 662 663 // create a temporary file for archive creation 664 touch(BATCH_DOWNLOAD_LOCAL.'temp.txt'); 665 666 if ($this->zip->create(BATCH_DOWNLOAD_LOCAL.'temp.txt', PCLZIP_OPT_REMOVE_ALL_PATH) == 0) 667 { 668 trigger_error('BatchDownloader::createNextArchive, unable to open ZIP archive (PclZip)', E_USER_ERROR); 669 } 670 671 unlink(BATCH_DOWNLOAD_LOCAL.'temp.txt'); 672 $this->zip->delete(PCLZIP_OPT_BY_NAME, 'temp.txt'); 673 } 674 } 675 676 function addFile($path, $filename) 677 { 678 if ($this->lib == 'zipa') 679 { 680 $this->zip->addFile($path, $filename); 681 } 682 else 683 { 684 $this->zip->add($path, PCLZIP_OPT_REMOVE_ALL_PATH); 685 } 686 } 687 688 function setArchiveComment($comment) 689 { 690 if ($this->lib == 'zipa') 691 { 692 $this->zip->setArchiveComment($comment); 693 } 694 } 695 696 function close() 697 { 698 if ($this->lib == 'zipa') 699 { 700 $this->zip->close(); 701 } 635 702 } 636 703 } -
extensions/BatchDownloader/language/en_UK/plugin.lang.php
r16697 r17880 40 40 $lang['Return to download page'] = 'Return to download page'; 41 41 $lang['Warning: ZipArchive doesn\'t accept special characters like accentuated ones, angle quotes (») and non-latin alphabets.'] = 'Warning: ZipArchive doesn\'t accept special characters like accentuated ones, angle quotes (») and non-latin alphabets.'; 42 $lang['Unable to find ZipArchive PHP extension, Batch Downloader can\'t work without this extension.'] = 'Unable to find ZipArchive PHP extension, Batch Downloader can\'t work without this extension.';42 $lang['Unable to find ZipArchive PHP extension, Batch Downloader will use PclZip instead, but with degraded performance.'] = 'Unable to find ZipArchive PHP extension, Batch Downloader will use PclZip instead, but with degraded performance.'; 43 43 $lang['Remove from download set'] = 'Remove from download set'; 44 44 $lang['Confirm the download of %d pictures?'] = 'Confirm the download of %d pictures?'; -
extensions/BatchDownloader/language/fr_FR/plugin.lang.php
r16697 r17880 40 40 $lang['Return to download page'] = 'Retourner à la page de téléchargement'; 41 41 $lang['Warning: ZipArchive doesn\'t accept special characters like accentuated ones, angle quotes (») and non-latin alphabets.'] = 'Attention: ZipArchive n\'accepte pas les caractères spéciaux comme les caractères accentués, les guillemets (») et les alphabets non-latin.'; 42 $lang['Unable to find ZipArchive PHP extension, Batch Downloader can\'t work without this extension.'] = 'Impossible de trouver l\'extension PHP ZipArchive, Batch Downloader ne peut fonctionner sans cette extension';42 $lang['Unable to find ZipArchive PHP extension, Batch Downloader will use PclZip instead, but with degraded performance.'] = 'Impossible de trouver l\'extension PHP ZipArchive, Batch Downloader va utiliser PclZip à la place, mais avec des performances dégradées.'; 43 43 $lang['Remove from download set'] = 'Supprimer du lot'; 44 44 $lang['Confirm the download of %d pictures?'] = 'Confirmer le téléchargementde %d photos ?'; -
extensions/BatchDownloader/main.inc.php
r17656 r17880 19 19 define('BATCH_DOWNLOAD_ADMIN', get_root_url() . 'admin.php?page=plugin-BatchDownloader'); 20 20 define('BATCH_DOWNLOAD_PUBLIC', get_absolute_root_url() . make_index_url(array('section' => 'download')) . '/'); 21 define('BATCH_DOWNLOAD_VERSION', '1.0. 3');21 define('BATCH_DOWNLOAD_VERSION', '1.0.4'); 22 22 23 23 24 24 add_event_handler('init', 'batch_download_init'); 25 25 26 if (class_exists('ZipArchive')) 27 { 28 add_event_handler('loc_end_section_init', 'batch_download_section_init'); 29 add_event_handler('loc_end_index', 'batch_download_page'); 30 31 add_event_handler('loc_end_index', 'batch_download_clean'); 26 add_event_handler('loc_end_section_init', 'batch_download_section_init'); 27 add_event_handler('loc_end_index', 'batch_download_page'); 32 28 33 add_event_handler('loc_end_index', 'batch_download_index_button', EVENT_HANDLER_PRIORITY_NEUTRAL+10);29 add_event_handler('loc_end_index', 'batch_download_clean'); 34 30 35 add_event_handler('blockmanager_register_blocks', 'batch_download_add_menublock'); 36 add_event_handler('blockmanager_apply', 'batch_download_applymenu'); 37 38 include_once(BATCH_DOWNLOAD_PATH . 'include/BatchDownloader.class.php'); 39 include_once(BATCH_DOWNLOAD_PATH . 'include/functions.inc.php'); 40 include_once(BATCH_DOWNLOAD_PATH . 'include/events.inc.php'); 41 } 31 add_event_handler('loc_end_index', 'batch_download_index_button', EVENT_HANDLER_PRIORITY_NEUTRAL+10); 32 33 add_event_handler('blockmanager_register_blocks', 'batch_download_add_menublock'); 34 add_event_handler('blockmanager_apply', 'batch_download_applymenu'); 35 36 include_once(BATCH_DOWNLOAD_PATH . 'include/BatchDownloader.class.php'); 37 include_once(BATCH_DOWNLOAD_PATH . 'include/functions.inc.php'); 38 include_once(BATCH_DOWNLOAD_PATH . 'include/events.inc.php'); 42 39 43 40 if (defined('IN_ADMIN')) … … 49 46 50 47 /** 51 * u nserialize conf andload language48 * update plugin & unserialize conf & load language 52 49 */ 53 50 function batch_download_init()
Note: See TracChangeset
for help on using the changeset viewer.