Changeset 16689


Ignore:
Timestamp:
Jul 13, 2012, 12:12:21 PM (12 years ago)
Author:
mistic100
Message:

-separate "archive_comment" in a new config parameter
-confirmation message before start download

Location:
extensions/BatchDownloader
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • extensions/BatchDownloader/admin.php

    r16392 r16689  
    1414$tabsheet->assign();
    1515
     16if (!class_exists('ZipArchive'))
     17{
     18  array_push($page['errors'], l10n('Unable to find ZipArchive PHP extension, Batch Downloader can\'t work without this extension.'));
     19}
     20
    1621// include page
    1722include(BATCH_DOWNLOAD_PATH . 'admin/' . $page['tab'] . '.php');
  • extensions/BatchDownloader/admin/config.php

    r16392 r16689  
    99    'photo_size'      => $_POST['photo_size'],
    1010    'archive_prefix'  => trim($_POST['archive_prefix']),
    11     'archive_comment' => trim($_POST['archive_comment']),
    1211    'archive_timeout' => intval($_POST['archive_timeout']),
    1312    'max_elements'    => intval($_POST['max_elements']),
     
    1514    'last_clean'      => $conf['batch_download']['last_clean'],
    1615    );
     16  $conf['batch_download_comment'] = trim($_POST['archive_comment']);
    1717 
    1818  conf_update_param('batch_download', serialize($conf['batch_download']));
     19  conf_update_param('batch_download_comment', $conf['batch_download_comment']);
    1920}
    2021
     
    4344// max values
    4445$conf['batch_download']['max_elements_value'] = isset($conf['batch_download_max_elements']) ? $conf['batch_download_max_elements'] : 1000;
    45 $conf['batch_download']['max_size_value'] = isset($conf['batch_download_max_size']) ? $conf['batch_download_max_size'] : 1000;
     46$conf['batch_download']['max_size_value'] = isset($conf['batch_download_max_size']) ? $conf['batch_download_max_size'] : 500;
    4647
    4748$template->assign(array(
     
    5051  'sizes_options' => $sizes_options,
    5152  'batch_download' => $conf['batch_download'],
     53  'batch_download_comment' => stripslashes($conf['batch_download_comment']),
    5254  ));
    5355
  • extensions/BatchDownloader/admin/sets.php

    r16598 r16689  
    6868      'STATUS' => $set->getParam('status'),
    6969      'LAST_ZIP' => $set->getParam('last_zip'),
    70       'U_DELETE' => BATCH_DOWNLOAD_ADMIN . '-sets&delete='.$set->getParam('set_id'),
    71       'U_CANCEL' => BATCH_DOWNLOAD_ADMIN . '-sets&cancel='.$set->getParam('set_id'),
     70      'U_DELETE' => BATCH_DOWNLOAD_ADMIN . '-sets&delete='.$set->getParam('id'),
     71      'U_CANCEL' => BATCH_DOWNLOAD_ADMIN . '-sets&cancel='.$set->getParam('id'),
    7272    )
    7373    ));
  • extensions/BatchDownloader/admin/template/config.tpl

    r16622 r16689  
    110110      <label>
    111111        <span class="property">{'Archive comment'|@translate} :</span><br>
    112         <textarea name="archive_comment" rows="5" style="width:450px;">{$batch_download.archive_comment}</textarea>
     112        <textarea name="archive_comment" rows="5" style="width:450px;">{$batch_download_comment}</textarea>
    113113      </label>
     114      <br>
     115      <i>{'Warning: ZipArchive doesn\'t accept special characters like accentuated ones, angle quotes (») and non-latin alphabets.'|@translate}</i>
    114116    </li>
    115117  </ul>
  • extensions/BatchDownloader/include/BatchDownloader.class.php

    r16626 r16689  
    2020   
    2121    $this->conf = $conf['batch_download'];
     22    $this->conf['archive_acomment'] = $conf['batch_download_comment'];
    2223    $this->data = array(
    23       'set_id' => 0,
     24      'id' => 0,
    2425      'user_id' => $user['id'],
    2526      'date_creation' => '0000-00-00 00:00:00',
     
    3940      $query = '
    4041SELECT
     42    id,
    4143    user_id,
    4244    date_creation,
     
    5759      if (pwg_db_num_rows($result))
    5860      {
    59         $this->data['set_id'] = $set_id;
    60         list(
    61           $this->data['user_id'],
    62           $this->data['date_creation'],
    63           $this->data['type'],
    64           $this->data['type_id'],
    65           $this->data['nb_zip'],
    66           $this->data['last_zip'],
    67           $this->data['nb_images'],
    68           $this->data['total_size'],
    69           $this->data['status']
    70           ) = pwg_db_fetch_row($result);
     61        $this->data = array_merge(
     62          $this->data,
     63          pwg_db_fetch_assoc($result)
     64          );
    7165       
    7266        // make sur all pictures of the set exist
     
    8478    zip
    8579  FROM '.BATCH_DOWNLOAD_TIMAGES.'
    86   WHERE set_id = '.$this->data['set_id'].'
     80  WHERE set_id = '.$this->data['id'].'
    8781;';
    8882        $this->images = simple_hash_from_query($query, 'image_id', 'zip');
     
    129123;';
    130124      pwg_query($query);
    131       $this->data['set_id'] = pwg_db_insert_id();
     125      $this->data['id'] = pwg_db_insert_id();
    132126     
    133127      $date = pwg_query('SELECT FROM_UNIXTIME(NOW());');
     
    153147  {
    154148    $this->data[$name] = $value;
    155     pwg_query('UPDATE '.BATCH_DOWNLOAD_TSETS.' SET '.$name.' = "'.$value.'" WHERE id = '.$this->data['set_id'].';');
     149    pwg_query('UPDATE '.BATCH_DOWNLOAD_TSETS.' SET '.$name.' = "'.$value.'" WHERE id = '.$this->data['id'].';');
    156150  }
    157151 
     
    201195DELETE FROM '.BATCH_DOWNLOAD_TIMAGES.'
    202196  WHERE
    203     set_id = '.$this->data['set_id'].'
     197    set_id = '.$this->data['id'].'
    204198    AND image_id IN('.implode(',', $image_ids).')
    205199;';
     
    225219     
    226220      $this->images[ $image_id ] = 0;
    227       array_push($inserts, array('set_id'=>$this->data['set_id'], 'image_id'=>$image_id, 'zip'=>0));
     221      array_push($inserts, array('set_id'=>$this->data['id'], 'image_id'=>$image_id, 'zip'=>0));
    228222    }
    229223   
     
    246240    $query = '
    247241DELETE FROM '.BATCH_DOWNLOAD_TIMAGES.'
    248   WHERE set_id = '.$this->data['set_id'].'
     242  WHERE set_id = '.$this->data['id'].'
    249243;';
    250244    pwg_query($query);
     
    348342      if (!empty($this->conf['archive_comment']))
    349343      {
    350         $comment.= "\n\n".$this->conf['archive_comment'];
     344        $comment.= "\n\n".wordwrap(remove_accents($this->conf['archive_comment']), 60);
    351345      }
    352346      $zip->setArchiveComment($comment);
     
    359353  SET zip = '.$this->data['last_zip'].'
    360354  WHERE
    361     set_id = '.$this->data['set_id'].'
     355    set_id = '.$this->data['id'].'
    362356    AND image_id IN('.implode(',', $images_added).')
    363357;';
     
    442436      else if ($i == $this->data['last_zip']+1)
    443437      {
    444           $out.= '<a href="'.add_url_params($url, array('set_id'=>$this->data['set_id'],'zip'=>$i)).'" rel="nofollow" style="font-weight:bold;"'
     438          $out.= '<a href="'.add_url_params($url, array('set_id'=>$this->data['id'],'zip'=>$i)).'" rel="nofollow" style="font-weight:bold;"'
    445439            .($i!=1 ? 'onClick="return confirm(\'Starting download Archive #'.$i.' will destroy Archive #'.($i-1).', be sure you finish the download. Continue ?\');"' : null).
    446440            '><img src="'.BATCH_DOWNLOAD_PATH.'template/drive_go.png"> Archive #'.$i.' (ready)</a>';
     
    477471          get_username($this->data['user_id']) .'_'.
    478472          $this->data['type'] .'-'. $this->data['type_id'] .'_'.
    479           $this->data['user_id'] . $this->data['set_id'] .
     473          $this->data['user_id'] . $this->data['id'] .
    480474          ($this->data['nb_zip']!=1 ? '_part'. $i : null).
    481475          '.zip';
  • extensions/BatchDownloader/include/events.inc.php

    r16609 r16689  
    8181        $BatchDownloader->createNextArchive(true); // make sure we have only one zip, even if 'max_size' is exceeded
    8282       
    83         $u_download = BATCH_DOWNLOAD_PATH . 'download.php?set_id='.$BatchDownloader->getParam('set_id').'&amp;zip=1';
     83        $u_download = BATCH_DOWNLOAD_PATH . 'download.php?set_id='.$BatchDownloader->getParam('id').'&amp;zip=1';
    8484       
    8585        $null = null;
     
    9191      else
    9292      {
    93         redirect(BATCH_DOWNLOAD_PUBLIC . 'init_zip&amp;set_id='.$BatchDownloader->getParam('set_id'));
     93        redirect(BATCH_DOWNLOAD_PUBLIC . 'init_zip&amp;set_id='.$BatchDownloader->getParam('id'));
    9494      }
    9595    }
     
    106106 
    107107  // toolbar button
    108   $button = '<li><a href="'. $url .'&amp;action=advdown_set" title="'.l10n('Download all pictures of this selection').'" class="pwg-state-default pwg-button" rel="nofollow">
    109                         <span class="pwg-icon" style="background:url(\'' . BATCH_DOWNLOAD_PATH . 'template/zip.png\') center center no-repeat;">&nbsp;</span><span class="pwg-button-text">'.l10n('Batch Downloader').'</span>
     108  $button = '<li><a href="'. $url .'&amp;action=advdown_set" title="'.l10n('Download all pictures of this selection').'" class="pwg-state-default pwg-button" rel="nofollow"
     109    onClick="return confirm(\''.sprintf(l10n('Confirm the download of %d pictures?'), count($page['items'])).'\');">
     110                        <span class="pwg-icon batch-downloader-icon" style="background:url(\'' . BATCH_DOWNLOAD_PATH . 'template/zip.png\') center center no-repeat;">&nbsp;</span><span class="pwg-button-text">'.l10n('Batch Downloader').'</span>
    110111                </a></li>';
    111112  $template->concat('PLUGIN_INDEX_ACTIONS', $button);
     
    163164     
    164165      array_push($data, array(
    165         'URL' => BATCH_DOWNLOAD_PUBLIC . 'init_zip&amp;set_id='.$BatchDownloader->getParam('set_id'),
     166        'URL' => BATCH_DOWNLOAD_PUBLIC . 'init_zip&amp;set_id='.$BatchDownloader->getParam('id'),
    166167        'TITLE' => str_replace('"', "'", strip_tags($set['COMMENT'])),
    167168        'NAME' => $set['sNAME'],
  • extensions/BatchDownloader/language/en_UK/plugin.lang.php

    r16609 r16689  
    3939$lang['Cancel this download'] = 'Cancel this download';
    4040$lang['Return to download page'] = 'Return to download page';
     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.';
     43$lang['Remove from download set'] = 'Remove from download set';
     44$lang['Confirm the download of %d pictures?'] = 'Confirm the download of %d pictures?';
    4145
    4246?>
  • extensions/BatchDownloader/language/fr_FR/plugin.lang.php

    r16622 r16689  
    3939$lang['Cancel this download'] = 'Annuler ce téléchargement';
    4040$lang['Return to download page'] = 'Retourner à la page de téléchargement';
     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';
     43$lang['Remove from download set'] = 'Supprimer du lot';
     44$lang['Confirm the download of %d pictures?'] = 'Confirmer le téléchargementde %d photos ?';
    4145
    4246?>
  • extensions/BatchDownloader/maintain.inc.php

    r16400 r16689  
    99    'photo_size'      => 'original',
    1010    'archive_prefix'  => 'piwigo',
    11     'archive_comment' => null,
    1211    'archive_timeout' => 48, /* hours */
    1312    'max_elements'    => 500,
     
    4948
    5049  conf_update_param('batch_download', batch_download_default_config);
     50  conf_update_param('batch_download_comment', null);
    5151 
    5252  mkdir($conf['data_location'] . 'download_archives/', 0755);
     
    5757  global $conf;
    5858
    59   if (empty($conf['batch_download']))
     59  if (empty($conf['batch_download_comment']))
    6060  {
    61     conf_update_param('batch_download', batch_download_default_config);
     61    $new_conf = unserialize($conf['batch_download']);
     62    unset($new_conf['archive_comment']);
     63    conf_update_param('batch_download', serialize($new_conf));
     64    conf_update_param('batch_download_comment', null);
    6265  }
    6366 
  • extensions/BatchDownloader/template/thumbnails_css_js.tpl

    r16626 r16689  
    11{html_style}
    22.thumbnails  .wrap1 {ldelim} position:relative; }
    3 .removeSet {ldelim} width:100%;height:16px;display:none;position:absolute;top:0;background:rgba(0,0,0,0.8);padding:2px;border-radius:2px;font-size:0.8em;z-index:100;color:#eee;white-space:nowrap; }
     3.wrap1 .removeSet {ldelim} width:100%;height:16px;display:none;position:absolute;top:0;background:rgba(0,0,0,0.8);padding:2px;border-radius:2px;font-size:10px;z-index:100;color:#eee;white-space:nowrap; }
    44.wrap1:hover .removeSet {ldelim} display:block;
    55{/html_style}
  • extensions/BatchDownloader/template/view.tpl

    r16626 r16689  
    2222  {assign var="nb_images" value='<span class="nbImagesSet">'|@cat:$set.NB_IMAGES|@cat:'</span>'}
    2323  {'%d photos'|@translate|replace:'%d':'%s'|sprintf:$nb_images}
     24  <br>
     25  <b><a href="{$U_INIT_ZIP}" rel="nofollow">{'Return to download page'|@translate} →</a></b>
    2426</fieldset>
    2527
     
    3436
    3537{if !empty($navbar)}{include file='navigation_bar.tpl'|@get_extent:'navbar'}{/if}
    36 
    37 <p style="text-align:center;font-weight:bold;margin:20px;"><a href="{$U_INIT_ZIP}" rel="nofollow">{'Return to download page'|@translate}</a></p>
    3838{/if}
    3939
Note: See TracChangeset for help on using the changeset viewer.