Ignore:
Timestamp:
Jun 17, 2013, 2:46:12 AM (11 years ago)
Author:
mistic100
Message:

new advanced param $confbatch_download_additional_ext, default is $confpicture_ext

Location:
extensions/BatchDownloader
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • extensions/BatchDownloader/admin/sets.php

    r21607 r23280  
    66{
    77  $BatchDownloader = new BatchDownloader($_GET['delete']);
    8   $BatchDownloader->deleteLastArchive();
    9   $BatchDownloader->clearImages();
    10   pwg_query('DELETE FROM '.BATCH_DOWNLOAD_TSETS.' WHERE id = '.$_GET['delete'].';');
     8  $BatchDownloader->delete();
     9  unset($BatchDownloader);
    1110}
    1211if (isset($_GET['cancel']))
     
    1716  $BatchDownloader->deleteLastArchive();
    1817  $BatchDownloader->clearImages();
     18  unset($BatchDownloader);
    1919}
    2020if (isset($_POST['delete_done']))
     
    8484    )
    8585    ));
     86 
     87  unset($set);
    8688}
    8789
  • extensions/BatchDownloader/include/BatchDownloader.class.php

    r18973 r23280  
    209209  function addImages($image_ids)
    210210  {
     211    global $conf;
     212   
    211213    if (empty($image_ids) or !is_array($image_ids)) return;
    212214   
    213     $image_ids = array_unique($image_ids);
     215    $query = '
     216SELECT id, file
     217  FROM '.IMAGES_TABLE.'
     218  WHERE id IN('.implode(',', array_unique($image_ids)).')
     219;';
     220    $images = simple_hash_from_query($query, 'id', 'file');
     221   
    214222    $inserts = array();
    215223   
    216     foreach ($image_ids as $image_id)
     224    foreach ($images as $image_id => $file)
    217225    {
    218226      if ($this->isInSet($image_id)) continue;
     227      if (!in_array(get_extension($file), $conf['batch_download']['allowed_ext'])) continue;
    219228     
    220229      $this->images[ $image_id ] = 0;
     
    681690    return array_merge($set, $this->getNames());
    682691  }
     692 
     693  /**
     694   * delete
     695   */
     696  function delete()
     697  {
     698    $this->deleteLastArchive();
     699    $this->clearImages();
     700    pwg_query('DELETE FROM '.BATCH_DOWNLOAD_TSETS.' WHERE id = '.$this->data['id'].';');
     701  }
    683702}
    684703
  • extensions/BatchDownloader/include/events.inc.php

    r21422 r23280  
    8888    {
    8989      $BatchDownloader = new BatchDownloader('new', $page['items'], $set['type'], $set['id']);
    90       $BatchDownloader->getEstimatedArchiveNumber();
    9190     
    92       // if we plan only one zip with less elements than 'max_elements', the download starts immediately
    93       if (
    94         $BatchDownloader->getParam('nb_images') <= $conf['batch_download']['max_elements']
    95         and $BatchDownloader->getParam('nb_zip') == 1
    96       )
     91      if ($BatchDownloader->getParam('nb_images') != 0)
    9792      {
    98         $BatchDownloader->createNextArchive(true); // make sure we have only one zip, even if 'max_size' is exceeded
     93        $BatchDownloader->getEstimatedArchiveNumber();
    9994       
    100         $u_download = get_root_url().BATCH_DOWNLOAD_PATH . 'download.php?set_id='.$BatchDownloader->getParam('id').'&amp;zip=1';
    101        
    102         $null = null;
    103         $template->block_footer_script(null, 'setTimeout("document.location.href = \''.$u_download.'\';", 1000);', $null, $null);
    104        
    105         array_push($page['infos'], sprintf(l10n('The archive is downloading, if the download doesn\'t start automatically please <a href="%s">click here</a>'), $u_download));
     95        // if we plan only one zip with less elements than 'max_elements', the download starts immediately
     96        if (
     97          $BatchDownloader->getParam('nb_images') <= $conf['batch_download']['max_elements']
     98          and $BatchDownloader->getParam('nb_zip') == 1
     99        )
     100        {
     101          $BatchDownloader->createNextArchive(true); // make sure we have only one zip, even if 'max_size' is exceeded
     102         
     103          $u_download = get_root_url().BATCH_DOWNLOAD_PATH . 'download.php?set_id='.$BatchDownloader->getParam('id').'&amp;zip=1';
     104         
     105          $null = null;
     106          $template->block_footer_script(null, 'setTimeout("document.location.href = \''.$u_download.'\';", 1000);', $null, $null);
     107         
     108          $page['infos'][] = sprintf(l10n('The archive is downloading, if the download doesn\'t start automatically please <a href="%s">click here</a>'), $u_download);
     109        }
     110        // otherwise we go to summary page
     111        else
     112        {
     113          redirect(add_url_params(BATCH_DOWNLOAD_PUBLIC . 'init_zip', array('set_id'=>$BatchDownloader->getParam('id'))));
     114        }
    106115      }
    107       // oterwise we go to summary page
    108116      else
    109117      {
    110         redirect(add_url_params(BATCH_DOWNLOAD_PUBLIC . 'init_zip', array('set_id'=>$BatchDownloader->getParam('id'))));
     118        $BatchDownloader->delete();
     119        unset($BatchDownloader);
     120       
     121        $page['errors'][] = sprintf(l10n('Sorry, there is nothing to download. Some files may have been excluded because of <i title="Authorized types are : %s">filetype restrictions</i>.'), implode(', ', $conf['batch_download']['allowed_ext']));
    111122      }
    112123    }
  • extensions/BatchDownloader/language/en_UK/plugin.lang.php

    r21607 r23280  
    4949$lang['What can be downloaded?'] = 'What can be downloaded?';
    5050$lang['No result'] = 'No result';
     51$lang['Sorry, there is nothing to download. Some files may have been excluded because of <i title="Authorized types are : %s">filetype restrictions</i>.'] = 'Sorry, there is nothing to download. Some files may have been excluded because of <i title="Authorized types are : %s">filetype restrictions</i>.';
    5152
    5253?>
  • extensions/BatchDownloader/language/fr_FR/plugin.lang.php

    r21607 r23280  
    4949$lang['What can be downloaded?'] = 'Qu\'est-ce qui peut être téléchargé ?';
    5050$lang['No result'] = 'Aucun résultat';
     51$lang['Sorry, there is nothing to download. Some files may have been excluded because of <i title="Authorized types are : %s">filetype restrictions</i>.'] = 'Désolé, il n\'y a rien à télécharger. Certains fichiers ont peut-être été exclu à cause de <i title="Les types autorisés sont : %s">leur type</i>.';
    5152
    5253?>
  • extensions/BatchDownloader/main.inc.php

    r23167 r23280  
    44Version: auto
    55Description: Allows users to download pictures sets in ZIP. Compatible with User Collections.
    6 Plugin URI: http://piwigo.org/ext/extension_view.php?eid=616
     6Plugin URI: auto
    77Author: Mistic
    88Author URI: http://www.strangeplanet.fr
     
    1111/*
    1212 * advanced config:
    13  * $conf['batch_download_max_elements']  max value of the elements slider (default 1000)
    14  * $conf['batch_download_max_size']      max value of the size slider (default 500)
    15  * $conf['batch_download_force_pclzip']  if true, force the usage of PclZip instead of ZipArchive
    16  * $conf['batch_download_direct']        if true, the download script will redirect to the zip instead of deliver it through PHP
     13 * $conf['batch_download_max_elements']   max value of the elements slider (default 1000)
     14 * $conf['batch_download_max_size']       max value of the size slider (default 500)
     15 * $conf['batch_download_force_pclzip']   if true, force the usage of PclZip instead of ZipArchive
     16 * $conf['batch_download_direct']         if true, the download script will redirect to the zip instead of deliver it through PHP
     17 * $conf['batch_download_additional_ext'] array containing downloadable filetypes (case sensitive), default is $conf['picture_ext']
    1718 */
    1819
     
    9192 
    9293  $conf['batch_download'] = unserialize($conf['batch_download']);
     94  $conf['batch_download']['allowed_ext'] = $conf['picture_ext'];
     95  if (!empty($conf['batch_download_additional_ext']))
     96  {
     97    $conf['batch_download']['allowed_ext'] = array_merge($conf['batch_download']['allowed_ext'], $conf['batch_download_additional_ext']);
     98  }
     99 
    93100  load_language('plugin.lang', BATCH_DOWNLOAD_PATH);
    94101}
Note: See TracChangeset for help on using the changeset viewer.