Changeset 16392


Ignore:
Timestamp:
07/06/12 13:03:39 (7 years ago)
Author:
mistic100
Message:
  • stylish download page
  • if there is only one archive, the file is downloaded directly
  • improve configuration page + add sliders (needs Piwigo 2.4.2)
Location:
extensions/BatchDownloader
Files:
3 added
9 edited

Legend:

Unmodified
Added
Removed
  • extensions/BatchDownloader/admin.php

    r16379 r16392  
    1919// template 
    2020$template->assign(array( 
    21   'BATCH_DOWNLOAD_PATH'=> BATCH_DOWNLOAD_PATH, 
     21  'BATCH_DOWNLOAD_PATH' => BATCH_DOWNLOAD_PATH, 
    2222  'BATCH_DOWNLOAD_ADMIN' => BATCH_DOWNLOAD_ADMIN, 
    2323  )); 
  • extensions/BatchDownloader/admin/config.php

    r16379 r16392  
    4141$sizes_options['original'] = l10n('Original'); 
    4242 
     43// max values 
     44$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 
    4347$template->assign(array( 
    4448  'group_options' => $group_options, 
  • extensions/BatchDownloader/admin/template/config.tpl

    r16379 r16392  
    11{combine_css path=$BATCH_DOWNLOAD_PATH|@cat:"admin/template/style.css"} 
    22 
     3{combine_script id='jquery.ui.slider' require='jquery.ui' load='footer' path='themes/default/js/ui/jquery.ui.slider.js'} 
     4{combine_css path="themes/default/js/ui/theme/jquery.ui.slider.css"} 
    35{combine_script id='jquery.chosen' load='footer' path='themes/default/js/plugins/chosen.jquery.min.js'} 
    46{combine_css path="themes/default/js/plugins/chosen.css"} 
    57 
    6 {footer_script}{literal} 
    7 jQuery(document).ready(function() { 
    8   jQuery(".chzn-select").chosen(); 
     8{footer_script} 
     9jQuery(".chzn-select").chosen(); 
     10 
     11$("#max_size").slider({ldelim} 
     12  range: "min", 
     13  value: {$batch_download.max_size}, 
     14  min: 10, 
     15  max: {$batch_download.max_size_value}, 
     16  slide: function(event, ui) {ldelim} 
     17    $("input[name='max_size']").val(ui.value); 
     18  } 
    919}); 
    10 {/literal}{/footer_script} 
     20$("input[name='max_size']").change(function() {ldelim} 
     21  $("#max_size").slider("value", $(this).val()); 
     22}); 
     23 
     24$("#max_elements").slider({ldelim} 
     25  range: "min", 
     26  value: {$batch_download.max_elements}, 
     27  min: 10, 
     28  max: {$batch_download.max_elements_value}, 
     29  slide: function(event, ui) {ldelim} 
     30    $("input[name='max_elements']").val(ui.value); 
     31  } 
     32}); 
     33$("input[name='max_elements']").change(function() {ldelim} 
     34  $("#max_elements").slider("value", $(this).val()); 
     35}); 
     36{/footer_script} 
    1137 
    1238<div class="titrePage"> 
    13         <h2>Advanced Downloader</h2> 
     39        <h2>Batch Downloader</h2> 
    1440</div> 
    1541 
    1642<form method="post" action="" class="properties"> 
    1743<fieldset> 
    18   <legend>{'Download access'|@translate}</legend> 
     44  <legend>{'Download permissions'|@translate}</legend> 
    1945   
    2046  <ul> 
    2147    <li> 
    2248      <label> 
     49      {if $group_options} 
    2350        <span class="property">{'User groups'|@translate}</span> 
    2451        <select name="groups[]" data-placeholder="{'Everybody'|@translate}" class="chzn-select" multiple="multiple" style="width:370px;"> 
    2552          {html_options options=$group_options selected=$batch_download.groups} 
    2653        </select> 
     54      {else} 
     55        {'There is no group in this gallery.'|@translate} <a href="admin.php?page=group_list">{'Groups management'|@translate}</a> 
     56      {/if} 
    2757      </label> 
    2858    </li> 
     
    3969 
    4070<fieldset> 
    41   <legend>{'Archives configuration'|@translate}</legend> 
     71  <legend>{'Archives'|@translate}</legend> 
    4272   
    4373  <ul> 
     
    5383    <li> 
    5484      <label> 
     85        <span class="property">{'Delete unterminated downloads after'|@translate}</span> 
     86        <input type="text" name="archive_timeout" value="{$batch_download.archive_timeout}" size="3"> {'hours'|@translate} 
     87      </label> 
     88    </li> 
     89    <li> 
     90      <label> 
     91        <span class="property">{'Maximum number of photos per download set'|@translate}</span> 
     92        <div id="max_elements""></div> 
     93        <input type="text" name="max_elements" value="{$batch_download.max_elements}" size="5"> 
     94      </label> 
     95    </li> 
     96    <li> 
     97      <label> 
     98        <span class="property">{'Maximum size of each archive (in Megabytes)'|@translate}</span> 
     99        <div id="max_size"></div> 
     100        <input type="text" name="max_size" value="{$batch_download.max_size}" size="5"> 
     101      </label> 
     102    </li> 
     103    <li> 
     104      <label> 
    55105        <span class="property">{'Archive prefix'|@translate}</span> 
    56106        <input type="text" name="archive_prefix" value="{$batch_download.archive_prefix}"> 
     
    59109    <li> 
    60110      <label> 
    61         <span class="property">{'Archive comment'|@translate}</span> 
    62         <input type="text" name="archive_comment" value="{$batch_download.archive_comment}" size="80"> 
    63       </label> 
    64     </li> 
    65     <li> 
    66       <label> 
    67         <span class="property">{'Delete unterminated downloads after'|@translate}</span> 
    68         <input type="text" name="archive_timeout" value="{$batch_download.archive_timeout}" size="3">{'hours'|@translate} 
    69       </label> 
    70     </li> 
    71     <li> 
    72       <label> 
    73         <span class="property">{'Maximum number if photos in each set'|@translate}</span> 
    74         <input type="text" name="max_elements" value="{$batch_download.max_elements}" size="3"> 
    75       </label> 
    76     </li> 
    77     <li> 
    78       <label> 
    79         <span class="property">{'Maximum size of each archive'|@translate}</span> 
    80         <input type="text" name="max_size" value="{$batch_download.max_size}" size="4">MB 
     111        <span class="property">{'Archive comment'|@translate} :</span><br> 
     112        <textarea name="archive_comment" rows="5" style="width:450px;">{$batch_download.archive_comment}</textarea> 
    81113      </label> 
    82114    </li> 
     
    84116</fieldset> 
    85117 
    86 <p><input type="submit" name="save_config" value="{'Save Settings'|@translate}"></p>   
     118<p class="formButtons"><input type="submit" name="save_config" value="{'Save Settings'|@translate}"></p>   
    87119</form> 
  • extensions/BatchDownloader/admin/template/sets.tpl

    r16379 r16392  
    22 
    33<div class="titrePage"> 
    4         <h2>Advanced Downloader</h2> 
     4        <h2>Batch Downloader</h2> 
    55</div> 
    66 
  • extensions/BatchDownloader/admin/template/style.css

    r16379 r16392  
    22  clear:none !important; 
    33} 
     4 
     5.property { 
     6  width:auto !important; 
     7} 
     8 
     9input[name='max_size'], input[name='max_elements'] { 
     10  border:none; 
     11  background:none; 
     12  font-weight:bold; 
     13  margin-left:5px; 
     14} 
     15 
     16#max_size, #max_elements { 
     17  display:inline-block; 
     18  width:300px; 
     19} 
  • extensions/BatchDownloader/include/BatchDownloader.class.php

    r16379 r16392  
    260260   * createNextArchive 
    261261   */ 
    262   function createNextArchive() 
     262  function createNextArchive($force_one_archive=false) 
    263263  { 
    264264    // set already downloaded 
     
    329329         
    330330        $total_size+= $row['filesize']; 
    331         if ($total_size >= $this->conf['max_size']*1024) break; 
     331        if ($total_size >= $this->conf['max_size']*1024 and !$force_one_archive) break; 
    332332      } 
    333333       
     
    358358      { 
    359359        $this->updateParam('status', 'done'); 
     360        $this->clear(false); 
    360361      } 
    361362       
     
    417418    $nb_archives = $this->getEstimatedArchiveNumber(); 
    418419     
    419     $out = '<ul id="download_list">'; 
    420     if ($this->data['status'] == 'done') 
     420    $out = ''; 
     421    /*if ($this->data['status'] == 'done') 
    421422    { 
    422423      $out.= '<li id="zip-1">Already downloaded</li>'; 
    423     } 
    424     else 
     424    }*/ 
     425    if (true) 
    425426    { 
    426427      for ($i=1; $i<=$this->data['nb_zip']; $i++) 
     
    430431        if ($i < $this->data['last_zip']+1) 
    431432        { 
    432           $out.= 'Archive #'.$i.' (already downloaded)'; 
     433          $out.= '<img src="'.BATCH_DOWNLOAD_PATH.'template/drive.png"> Archive #'.$i.' (already downloaded)'; 
    433434        } 
    434435        else if ($i == $this->data['last_zip']+1) 
    435436        { 
    436             $out.= '<a href="'.add_url_params($url, array('set_id'=>$this->data['set_id'],'zip'=>$i)).'" rel="nofollow"'  
     437            $out.= '<a href="'.add_url_params($url, array('set_id'=>$this->data['set_id'],'zip'=>$i)).'" rel="nofollow" style="font-weight:bold;"'  
    437438              .($i!=1 ? 'onClick="return confirm(\'Starting download Archive #'.$i.' will destroy Archive #'.($i-1).', be sure you finish the download. Continue ?\');"' : null). 
    438               '>Archive #'.$i.' (ready)</a>'; 
     439              '><img src="'.BATCH_DOWNLOAD_PATH.'template/drive_go.png"> Archive #'.$i.' (ready)</a>'; 
    439440        } 
    440441        else 
    441442        { 
    442           $out.= 'Archive #'.$i.' (pending)'; 
     443          $out.= '<img src="'.BATCH_DOWNLOAD_PATH.'template/drive.png"> Archive #'.$i.' (pending)'; 
    443444        } 
    444445         
     
    446447      } 
    447448    } 
    448     $out.= '</ul>'; 
    449449     
    450450    return $out; 
     
    472472          $this->data['type'] .'-'. $this->data['type_id'] .'_'. 
    473473          $this->data['user_id'] . $this->data['set_id'] .'_'. 
    474           'part'. $i .'.zip'; 
     474          ($this->data['nb_zip']!=1 ? 'part'. $i : null). 
     475          '.zip'; 
    475476  } 
    476477   
     
    505506      { 
    506507        $category = get_cat_info($this->data['type_id']); 
    507         $set['NAME'] = get_cat_display_name($category['upper_names']); 
    508         $set['sNAME'] = $category['name']; 
    509         $set['COMMENT'] = trigger_action('render_category_description', $category['comment']); 
     508        $set['NAME'] = l10n('Album').': '.get_cat_display_name($category['upper_names']); 
     509        $set['sNAME'] = l10n('Album').': '.trigger_event('render_category_name', $category['name']); 
     510        $set['COMMENT'] = trigger_event('render_category_description', $category['comment']); 
    510511        break; 
    511512      } 
     
    532533            .'</a>'; 
    533534        } 
     535         
     536        $set['sNAME'] = l10n('Tags').': '.strip_tags($set['COMMENT']); 
    534537        break; 
    535538      } 
  • extensions/BatchDownloader/include/download.inc.php

    r16379 r16392  
    1515    $BatchDownloader = new BatchDownloader($_GET['set_id']); 
    1616     
    17     if ($BatchDownloader->getParam('status') != 'done') 
     17    if ( isset($_GET['cancel']) ) 
    1818    { 
    19       if (isset($_GET['zip'])) 
    20       { 
    21         $BatchDownloader->deleteLastArchive(); 
    22         $next_file = $BatchDownloader->createNextArchive(); 
    23       } 
    24       else 
    25       { 
    26         $BatchDownloader->getEstimatedArchiveNumber(); 
    27       } 
     19      $BatchDownloader->deleteLastArchive(); 
     20      $BatchDownloader->clear(); 
     21      pwg_query('DELETE FROM '.BATCH_DOWNLOAD_TSETS.' WHERE id = '.$_GET['set_id'].';'); 
     22      $_SESSION['page_infos'][] = l10n('Download set deleted'); 
     23      redirect('index.php'); 
     24    } 
     25     
     26    if ( isset($_GET['zip']) and $BatchDownloader->getParam('status') != 'done' and $_GET['zip'] > $BatchDownloader->getParam('last_zip') ) 
     27    { 
     28      $BatchDownloader->deleteLastArchive(); 
     29      $next_file = $BatchDownloader->createNextArchive(); 
    2830    } 
    2931 
     
    3335    { 
    3436      $set['U_DOWNLOAD'] = BATCH_DOWNLOAD_PATH . 'download.php?set_id='.$_GET['set_id'].'&amp;zip='.$_GET['zip']; 
    35       array_push($page['infos'], sprintf(l10n('Archive #%d is downloading, if the download doesn\'t start automatically please <a href="%s">click here</a>'), $_GET['zip'], $set['U_DOWNLOAD'])); 
     37      array_push($page['infos'], sprintf(l10n('The archive is downloading, if the download doesn\'t start automatically please <a href="%s">click here</a>'), $set['U_DOWNLOAD'])); 
    3638    } 
    3739     
    3840    if ($BatchDownloader->getParam('nb_images') > $conf['batch_download']['max_elements']) 
    3941    { 
    40       array_push($page['errors'], sprintf( 
     42      $template->assign('elements_error', sprintf( 
    4143        l10n('You choose to download %d pictures, but the system is limited to %d. You can edit the set, or the last %d pictures will not be downloaded.'), 
    4244        $BatchDownloader->getParam('nb_images'), 
     
    4446        $BatchDownloader->getParam('nb_images') - $conf['batch_download']['max_elements'] 
    4547        )); 
     48    } 
     49     
     50    if ($BatchDownloader->getParam('status') == 'new') 
     51    { 
     52      $set['U_CANCEL'] = BATCH_DOWNLOAD_PUBLIC . 'init_zip&amp;set_id='.$_GET['set_id'].'&amp;cancel'; 
    4653    } 
    4754     
     
    102109} 
    103110 
     111$template->assign('BATCH_DOWNLOAD_PATH', BATCH_DOWNLOAD_PATH); 
     112 
    104113 
    105114function batch_download_thumbnails_list_prefilter($content, &$smarty) 
  • extensions/BatchDownloader/include/events.inc.php

    r16379 r16392  
    2424     
    2525    $page['section'] = 'download'; 
    26     $page['title'] = l10n('Advanced Downloader').$conf['level_separator'].' '; 
     26    $page['title'] = l10n('Batch Downloader').$conf['level_separator'].' '; 
    2727     
    2828    switch (@$tokens[1]) 
     
    5757function batch_download_index_button() 
    5858{ 
    59   global $page, $template, $user; 
     59  global $page, $template, $user, $conf; 
    6060   
    6161  if ( !count($page['items']) or !isset($page['section']) ) return; 
     
    7171    { 
    7272      $BatchDownloader = new BatchDownloader('new', $page['items'], $set['type'], $set['id']); 
    73       redirect(BATCH_DOWNLOAD_PUBLIC . 'init_zip&amp;set_id='.$BatchDownloader->getParam('set_id')); 
     73      $BatchDownloader->getEstimatedArchiveNumber(); 
     74       
     75      if ( 
     76        $BatchDownloader->getParam('nb_images') <= $conf['batch_download']['max_elements'] 
     77        and $BatchDownloader->getParam('nb_zip') == 1 
     78      ) 
     79      { 
     80        $BatchDownloader->createNextArchive(true); 
     81         
     82        $u_download = BATCH_DOWNLOAD_PATH . 'download.php?set_id='.$BatchDownloader->getParam('set_id').'&amp;zip=1'; 
     83         
     84        $null = null; 
     85        $template->block_footer_script(null, 'setTimeout("document.location.href = \''.$u_download.'\';", 1000);', $null, $null); 
     86         
     87        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)); 
     88      } 
     89      else 
     90      { 
     91        redirect(BATCH_DOWNLOAD_PUBLIC . 'init_zip&amp;set_id='.$BatchDownloader->getParam('set_id')); 
     92      } 
    7493    } 
    7594  } 
  • extensions/BatchDownloader/template/init_zip.tpl

    r16379 r16392  
     1{combine_css path=$BATCH_DOWNLOAD_PATH|@cat:"template/style.css"} 
     2 
    13{$MENUBAR} 
    24 
     
    1820 
    1921 
    20 <p> 
    21   <h3>{$set.NAME}</h3> 
    22   {if $set.COMMENT}<blockquote>{$set.COMMENT}</blockquote>{/if} 
    23   <span>{'%d images'|@translate|@sprintf:$set.NB_IMAGES}{if $set.U_EDIT_SET}, <a href="{$set.U_EDIT_SET}" rel="nofollow">{'Edit the set'|@translate}</a>{/if}</span> 
    24 </p> 
     22<fieldset> 
     23  <legend>{'Download info'|@translate}</legend> 
     24  <h2>{$set.NAME}</h2> 
     25  {if $set.COMMENT}<blockquote class="comment">{$set.COMMENT}</blockquote>{/if} 
     26   
     27  <ul class="set-infos"> 
     28    <li class="error">{$elements_error}</li> 
     29    <li><b>{'%d images'|@translate|@sprintf:$set.NB_IMAGES}</b>{if $set.U_EDIT_SET}, <a href="{$set.U_EDIT_SET}" rel="nofollow">{'Edit the set'|@translate}</a>{/if}</li> 
     30    <li><b>{'Estimated size'|@translate}:</b> {$set.TOTAL_SIZE} MB</li> 
     31    <li><b>{'Estimated number of archives'|@translate}:</b> {$set.NB_ARCHIVES} <i>({'real number of archives can differ'|@translate})</i></li> 
     32  </ul> 
     33   
     34   
     35</fieldset> 
    2536 
    26 <p> 
    27   <b>{'Estimated size'|@translate}:</b> {$set.TOTAL_SIZE} MB<br> 
    28   <b>{'Estimated number of archives'|@translate}:</b> {$set.NB_ARCHIVES}<br> 
    29   <i>{'These datas are an estimation, real specs can differ'|@translate}</i> 
    30 </p> 
    3137 
    32 <p> 
    33 <b>Download links:</b> 
    34 {$set.LINKS} 
    35 </p> 
    36  
    37 <p class="infos"> 
    38 {'<b>Warning:</b> all files will be deleted within %d hours'|@translate|@sprintf:$archive_timeout} 
    39 </p> 
     38<fieldset> 
     39  <legend>{'Download links'|@translate}</legend> 
     40   
     41  <ul class="download-links"> 
     42    {$set.LINKS} 
     43    <li class="warning">{'<b>Warning:</b> all files will be deleted within %d hours'|@translate|@sprintf:$archive_timeout}</li> 
     44  </ul> 
     45   
     46  {if $set.U_CANCEL}<a href="{$set.U_CANCEL}" class="cancel-down" onClick="return confirm('{'Are you sure?'|@translate}');">{'Cancel this download'|@translate}</a>{/if} 
     47</fieldset> 
    4048 
    4149</div>{* <!-- content --> *} 
Note: See TracChangeset for help on using the changeset viewer.