Changeset 23290


Ignore:
Timestamp:
Jun 17, 2013, 5:42:09 PM (7 years ago)
Author:
mistic100
Message:

WORK IN PROGRESS: allow to download derivatives
TODO: only working with images files, finish download page

Location:
extensions/BatchDownloader
Files:
1 added
8 edited

Legend:

Unmodified
Added
Removed
  • extensions/BatchDownloader/include/BatchDownloader.class.php

    r23280 r23290  
    1414   * @param: string set type ('album'|'tag'|'selection')
    1515   * @param: int set type id (for retrieving album infos for instance)
    16    */
    17   function __construct($set_id, $images=array(), $type=null, $type_id=null)
     16   * @param: string size to download
     17   */
     18  function __construct($set_id, $images=array(), $type=null, $type_id=null, $size='original')
    1819  {
    1920    global $user, $conf;
     
    2627      'type' => null,
    2728      'type_id' => null,
     29      'size' => 'original',
    2830      'nb_zip' => 0,
    2931      'last_zip' => 0,
     
    3941    {
    4042      $query = '
    41 SELECT
    42     id,
    43     user_id,
    44     date_creation,
    45     type,
    46     type_id,
    47     nb_zip,
    48     last_zip,
    49     nb_images,
    50     total_size,
    51     status
     43SELECT *
    5244  FROM '.BATCH_DOWNLOAD_TSETS.'
    5345  WHERE
     
    9587    else if ($set_id == 'new')
    9688    {
     89      if ($size != 'original')
     90      {
     91        $type_map = array_keys(ImageStdParams::get_defined_type_map());
     92        if (!in_array($size, $type_map))
     93        {
     94          throw new Exception(sprintf(l10n('Invalid size %s'), $size));
     95        }
     96      }
     97 
    9798      $this->data['type'] = $type;
    9899      $this->data['type_id'] = $type_id;
     100      $this->data['size'] = $size;
    99101     
    100102      $query = '
     
    104106    type,
    105107    type_id,
     108    size,
    106109    nb_zip,
    107110    last_zip,
     
    115118    "'.$this->data['type'].'",
    116119    "'.$this->data['type_id'].'",
     120    "'.$this->data['size'].'",
    117121    0,
    118122    0,
     
    255259 
    256260  /**
     261   * get missing derivatives files
     262   * @return: array of i.php urls
     263   */
     264  function getMissingDerivatives($update=false)
     265  {
     266    if ($this->data['size'] == 'original')
     267    {
     268      return array();
     269    }
     270   
     271    global $conf;
     272   
     273    $root_url = get_root_url();
     274    $uid = '&b='.time();
     275   
     276    $params = ImageStdParams::get_by_type($this->data['size']);
     277    $last_mod_time = $params->last_mod_time;
     278   
     279    $image_ids = array_keys($this->images);
     280    $to_update = $urls = $inserts = array();
     281   
     282    $conf['question_mark_in_urls'] = $conf['php_extension_in_urls'] = true;
     283    $conf['derivative_url_style'] = 2; //script
     284   
     285    // images which we need to update stats
     286    if ($update)
     287    {
     288      $query = '
     289SELECT image_id, filemtime FROM '.IMAGE_SIZES_TABLE.'
     290  WHERE image_id IN('.implode(',', $image_ids).')
     291    AND type = "'.$this->data['size'].'"
     292;';
     293      $registered = array_from_query($query, 'image_id', 'filemtime');
     294     
     295      $to_update = array_filter($registered, create_function('$t', 'return $t<'.$last_mod_time.';'));
     296      $to_update = array_merge($to_update, array_diff($image_ids, $registered));
     297    }
     298   
     299    $query = '
     300SELECT id, path, representative_ext, width, height, rotation
     301  FROM '.IMAGES_TABLE.'
     302  WHERE id IN('.implode(',', $image_ids).')
     303  ORDER BY id DESC
     304;';
     305
     306    $result = pwg_query($query);
     307    while ($row = pwg_db_fetch_assoc($result))
     308    {
     309      $src_image = new SrcImage($row);
     310      if ($src_image->is_mimetype()) continue;
     311     
     312      $derivative = new DerivativeImage($this->data['size'], $src_image);
     313      // if ($this->data['size'] != $derivative->get_type()) continue;
     314     
     315      $filemtime = @filemtime($derivative->get_path());
     316     
     317      if ($filemtime===false || $filemtime<$last_mod_time)
     318      {
     319        $urls[] = $root_url.$derivative->get_url().$uid;
     320      }
     321      else if ($update && in_array($row['id'], $to_update))
     322      {
     323        $imagesize = getimagesize($derivative->get_path());
     324       
     325        $inserts[ $row['id'] ] = array(
     326          'image_id' => $row['id'],
     327          'type' => $this->data['size'],
     328          'width' => $imagesize[0],
     329          'height' => $imagesize[1],
     330          'filesize' => filesize($derivative->get_path())/1024,
     331          'filemtime' => $filemtime,
     332          );
     333      }
     334    }
     335   
     336    if (!empty($inserts))
     337    {
     338      $query = '
     339DELETE FROM '.IMAGE_SIZES_TABLE.'
     340  WHERE image_id IN('.implode(',', array_keys($inserts)).')
     341;';
     342      pwg_query($query);
     343     
     344      mass_inserts(
     345        IMAGE_SIZES_TABLE,
     346        array('image_id','type','width','height','filesize'),
     347        $inserts
     348        );
     349    }
     350   
     351    return $urls;
     352  }
     353 
     354  /**
    257355   * deleteLastArchive
    258356   */
     
    311409      $query = '
    312410SELECT
    313     id,
    314     name,
    315     file,
    316     path,
    317     filesize
     411    id, name, file, path,
     412    representative_ext, rotation,
     413    filesize, width, height
    318414  FROM '.IMAGES_TABLE.'
    319415  WHERE id IN ('.implode(',', $images_to_add).')
    320416;';
    321417      $images_to_add = hash_from_query($query, 'id');
     418     
     419      if ($this->data['size'] != 'original')
     420      {
     421        $query = '
     422SELECT image_id, filesize
     423  FROM '.IMAGE_SIZES_TABLE.'
     424  WHERE image_id IN ('.implode(',', array_keys($images_to_add)).')
     425    AND type = "'.$this->data['size'].'"
     426;';
     427        $filesizes = simple_hash_from_query($query, 'image_id', 'filesize');
     428      }
    322429     
    323430      // open zip
     
    330437      $total_size = 0;
    331438      foreach ($images_to_add as $row)
    332       {       
    333         $zip->addFile(PHPWG_ROOT_PATH . $row['path'], $row['id'].'_'.stripslashes(get_filename_wo_extension($row['file'])).'.'.get_extension($row['path']));
     439      {
     440        if ($this->data['size'] == 'original')
     441        {
     442          $zip->addFile(PHPWG_ROOT_PATH . $row['path'], $row['id'].'_'.stripslashes(get_filename_wo_extension($row['file'])).'.'.get_extension($row['path']));
     443          $total_size+= $row['filesize'];
     444        }
     445        else
     446        {
     447          $src_image = new SrcImage($row);
     448          $derivative = new DerivativeImage($this->data['size'], $src_image);
     449          $path = $derivative->get_path();
     450     
     451          $zip->addFile($path, $row['id'].'_'.stripslashes(get_filename_wo_extension(basename($path))).'.'.get_extension($path));
     452          $total_size+= $filesizes[ $row['id'] ];
     453        }
    334454       
    335455        array_push($images_added, $row['id']);
    336456        $this->images[ $row['id'] ] = $this->data['last_zip'];
    337457       
    338         $total_size+= $row['filesize'];
    339458        if ($total_size >= $this->conf['max_size']*1024 and !$force_one_archive) break;
    340459      }
     
    370489     
    371490      // over estimed
    372       if ( $this->data['status'] == 'done' and $this->data['last_zip'] < $this->data['nb_zip'] )
     491      if ($this->data['status'] == 'done')
    373492      {
    374493        $this->updateParam('nb_zip', $this->data['last_zip']);
    375494      }
    376495      // under estimed
    377       else if ( $this->data['last_zip'] == $this->data['nb_zip'] and $this->data['status'] != 'done' )
     496      else if ($this->data['last_zip'] == $this->data['nb_zip'])
    378497      {
    379498        $this->updateParam('nb_zip', $this->data['last_zip']+1);
     
    400519    $image_ids = array_slice(array_keys($this->images), 0, $this->conf['max_elements']);
    401520   
    402     $query = '
     521    if ($this->data['size'] == 'original')
     522    {
     523      $query = '
    403524SELECT SUM(filesize) AS total
    404525  FROM '.IMAGES_TABLE.'
    405526  WHERE id IN ('.implode(',', $image_ids).')
    406527;';
     528    }
     529    else
     530    {
     531      $query = '
     532SELECT SUM(filesize) AS total
     533  FROM '.IMAGE_SIZES_TABLE.'
     534  WHERE image_id IN ('.implode(',', $image_ids).')
     535;';
     536    }
     537   
    407538    list($total) = pwg_db_fetch_row(pwg_query($query));
    408539    $this->data['estimated_total_size'] = $total;
     
    416547  function getEstimatedArchiveNumber()
    417548  {
    418     $nb_zip = ceil( $this->getEstimatedTotalSize() / ($this->conf['max_size']*1024) );
    419     $this->updateParam('nb_zip', $nb_zip);
    420     return $nb_zip;
     549    if ($this->data['status'] == 'done') return $this->data['nb_zip'];
     550   
     551    return ceil( $this->getEstimatedTotalSize() / ($this->conf['max_size']*1024) );
    421552  }
    422553 
     
    435566   
    436567    $out = '';
    437     for ($i=1; $i<=$this->data['nb_zip']; $i++)
     568    for ($i=1; $i<=$this->getEstimatedArchiveNumber(); $i++)
    438569    {
    439570      $out.= '<li id="zip-'.$i.'">';
     
    482613    $path.= $set['BASENAME'] . '_';
    483614    $path.= $this->data['user_id'] . $this->data['id'];
    484     $path.= $this->data['nb_zip']!=1 ? '_part' . $i : null;
     615    $path.= $this->getEstimatedArchiveNumber()!=1 ? '_part' . $i : null;
    485616    $path.= '.zip';
    486617   
     
    680811    $set = array(
    681812      'NB_IMAGES' =>     $this->data['nb_images'],
    682       'NB_ARCHIVES' =>   $this->data['nb_zip'],
     813      'NB_ARCHIVES' =>   $this->data['status']=='new' ? l10n('unknown') : $this->getEstimatedArchiveNumber(),
    683814      'STATUS' =>        $this->data['status'],
    684815      'LAST_ZIP' =>      $this->data['last_zip'],
    685       'TOTAL_SIZE' =>    ceil($this->getEstimatedTotalSize()/1024),
    686       'LINKS' =>         $this->getDownloadList(BATCH_DOWNLOAD_PUBLIC . 'init_zip'),
     816      'TOTAL_SIZE' =>    $this->data['status']=='new' ? l10n('unknown') : ceil($this->getEstimatedTotalSize()/1024),
     817      // 'LINKS' =>         $this->getDownloadList(BATCH_DOWNLOAD_PUBLIC . 'init_zip'),
    687818      'DATE_CREATION' => format_date($this->data['date_creation'], true),
     819      'SIZE_ID' =>       $this->data['size'],
     820      'SIZE' =>          l10n($this->data['size']),
    688821      );
     822     
     823    if ($this->data['size'] != 'original')
     824    {
     825      $params = ImageStdParams::get_by_type($this->data['size']);
     826      $set['SIZE_INFO'] = $params->sizing->ideal_size[0].' x '.$params->sizing->ideal_size[1];
     827    }
    689828   
    690829    return array_merge($set, $this->getNames());
  • extensions/BatchDownloader/include/download.inc.php

    r21206 r23290  
    1717      $BatchDownloader = new BatchDownloader($_GET['set_id']);
    1818     
     19      // delete set
    1920      if ( isset($_GET['cancel']) )
    2021      {
     
    2627      }
    2728     
    28       if ( isset($_GET['zip']) and $BatchDownloader->getParam('status') != 'done' and $_GET['zip'] > $BatchDownloader->getParam('last_zip') )
     29      // prepare next zip
     30      if ( isset($_GET['zip']) and $BatchDownloader->getParam('status') != 'new' and $BatchDownloader->getParam('status') != 'done' and $_GET['zip'] > $BatchDownloader->getParam('last_zip') )
    2931      {
    3032        $BatchDownloader->deleteLastArchive();
     
    3234      }
    3335     
    34       $set = $BatchDownloader->getSetInfo();
    35      
    36       if (isset($next_file))
    37       {
    38         $set['U_DOWNLOAD'] = get_root_url().BATCH_DOWNLOAD_PATH . 'download.php?set_id='.$_GET['set_id'].'&amp;zip='.$_GET['zip'];
    39         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']));
    40       }
    41      
    42       if ($BatchDownloader->getParam('status') == 'new' and $BatchDownloader->getParam('nb_images') > 0)
    43       {
    44         $set['U_EDIT_SET'] = add_url_params(BATCH_DOWNLOAD_PUBLIC . 'view', array('set_id'=>$_GET['set_id']));
    45       }
    46      
     36      // alert limit overflow
    4737      if ($BatchDownloader->getParam('nb_images') > $conf['batch_download']['max_elements'])
    4838      {
     
    5444          ));
    5545      }
     46      else
     47      {
     48        if ($BatchDownloader->getParam('status') == 'new')
     49        {
     50          $missing_derivatives = $BatchDownloader->getMissingDerivatives(true);
     51       
     52          // generate missing files
     53          if (count($missing_derivatives))
     54          {
     55            $template->assign('missing_derivatives', $missing_derivatives);
     56          }
     57          // set ready
     58          else
     59          {
     60            $BatchDownloader->updateParam('status', 'ready');
     61          }
     62        }
     63       
     64        // display download links
     65        if ($BatchDownloader->getParam('status') != 'new')
     66        {
     67          $template->assign('zip_links', $BatchDownloader->getDownloadList(BATCH_DOWNLOAD_PUBLIC . 'init_zip'));
     68        }
     69      }
    5670     
    57       $set['U_CANCEL'] = add_url_params(BATCH_DOWNLOAD_PUBLIC . 'init_zip', array('set_id'=>$_GET['set_id'], 'cancel'=>'true'));
     71      $set = $BatchDownloader->getSetInfo();
     72     
     73      // link to the zip
     74      if (isset($next_file))
     75      {
     76        $set['U_DOWNLOAD'] = get_root_url().BATCH_DOWNLOAD_PATH . 'download.php?set_id='.$_GET['set_id'].'&amp;zip='.$_GET['zip'];
     77        $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']);
     78      }
     79     
     80      // link to edit page
     81      if ($BatchDownloader->getParam('status') != 'download' and $BatchDownloader->getParam('status') != 'done' and $BatchDownloader->getParam('nb_images') > 0)
     82      {
     83        $set['U_EDIT_SET'] = add_url_params(BATCH_DOWNLOAD_PUBLIC . 'view', array('set_id'=>$_GET['set_id']));
     84      }
     85     
     86      // cancel link
     87      if ($BatchDownloader->getParam('status') != 'done')
     88      {
     89        $set['U_CANCEL'] = add_url_params(BATCH_DOWNLOAD_PUBLIC . 'init_zip', array('set_id'=>$_GET['set_id'], 'cancel'=>'true'));
     90      }
    5891     
    5992      $template->assign(array(
  • extensions/BatchDownloader/include/events.inc.php

    r23280 r23290  
    8787    if ($set !== false)
    8888    {
    89       $BatchDownloader = new BatchDownloader('new', $page['items'], $set['type'], $set['id']);
     89      $BatchDownloader = new BatchDownloader('new', $page['items'], $set['type'], $set['id'], $set['size']);
    9090     
    9191      if ($BatchDownloader->getParam('nb_images') != 0)
    9292      {
    93         $BatchDownloader->getEstimatedArchiveNumber();
    94        
    9593        // if we plan only one zip with less elements than 'max_elements', the download starts immediately
    9694        if (
    9795          $BatchDownloader->getParam('nb_images') <= $conf['batch_download']['max_elements']
    98           and $BatchDownloader->getParam('nb_zip') == 1
     96          and $BatchDownloader->getParam('size') == 'original'
     97          and $BatchDownloader->getEstimatedArchiveNumber() == 1
    9998        )
    10099        {
     
    133132  }
    134133 
    135   $url = add_url_params($url, array('action'=>'advdown_set'));
     134  $url = add_url_params($url, array('action'=>'advdown_set', 'down_size'=>''));
    136135 
    137136  // toolbar button
    138   $button = '<script type="text/javascript">var batchdown_count = '.count($page['items']).'; var batchdown_string = "'.l10n('Confirm the download of %d pictures?').'";</script>
    139     <li><a href="'. $url .'" title="'.l10n('Download all pictures of this selection').'" class="pwg-state-default pwg-button" rel="nofollow"
    140     onClick="return confirm(batchdown_string.replace(\'%d\', batchdown_count));">
    141                         <span class="pwg-icon batch-downloader-icon" style="background:url(\'' . get_root_url().BATCH_DOWNLOAD_PATH . 'template/zip.png\') center center no-repeat;">&nbsp;</span><span class="pwg-button-text">'.l10n('Download').'</span>
    142                 </a></li>';
    143   $template->concat('PLUGIN_INDEX_ACTIONS', $button);
     137  $template->set_filename('batchdwn_button', realpath(BATCH_DOWNLOAD_PATH.'template/download_button.tpl'));
     138  $template->assign(array(
     139    'BATCH_DOWNLOAD_PATH' => BATCH_DOWNLOAD_PATH,
     140    'BATCH_DWN_COUNT' => count($page['items']),
     141    'BATCH_DWN_URL' => $url,
     142    ));
     143   
     144  $type_map = ImageStdParams::get_defined_type_map();
     145  foreach ($type_map as $params)
     146  {
     147    $template->append(
     148      'BATCH_DOWNLOAD_SIZES',
     149      array(
     150        'TYPE' => $params->type,
     151        'DISPLAY' => l10n($params->type),
     152        'SIZE' => $params->sizing->ideal_size[0].' x '.$params->sizing->ideal_size[1],
     153        )
     154      );
     155  }
     156  $template->append(
     157    'BATCH_DOWNLOAD_SIZES',
     158    array(
     159      'TYPE' => 'original',
     160      'DISPLAY' => l10n('Original'),
     161      'SIZE' => null,
     162      )
     163    );
     164   
     165  $button = $template->parse('batchdwn_button', true);
     166  $template->add_index_button($button, 50);
    144167  $template->concat('COLLECTION_ACTIONS', $button);
    145168}
  • extensions/BatchDownloader/include/functions.inc.php

    r23167 r23290  
    6060      $batch_id = 0;
    6161      break;
     62    default:
     63      return false;
    6264  }
    6365 
    64   if ( isset($batch_type) and isset($batch_id) )
    65   {
    66     return array('type'=>$batch_type, 'id'=>$batch_id);
    67   }
    68   else
    69   {
    70     return false;
    71   }
     66  return array(
     67    'type' => $batch_type,
     68    'id' => $batch_id,
     69    'size' => isset($_GET['down_size']) ? $_GET['down_size'] : 'original',
     70    );
    7271}
    7372
  • extensions/BatchDownloader/include/install.inc.php

    r21422 r23290  
    1313      'level'           => 0,
    1414      'what'            => array('categories','specials','collections'),
    15       'photo_size'      => 'original',
     15      'photo_size'      => 'original', // not used
    1616      'archive_prefix'  => 'piwigo',
    1717      'archive_timeout' => 48, /* hours */
     
    5252  `user_id` smallint(5) NOT NULL,
    5353  `date_creation` datetime NOT NULL,
    54   `type` varchar(16) CHARACTER SET utf8 NOT NULL,
    55   `type_id` varchar(64) CHARACTER SET utf8 NOT NULL,
     54  `type` varchar(16) NOT NULL,
     55  `type_id` varchar(64) NOT NULL,
     56  `size` varchar(16) NOT NULL DEFAULT "original",
    5657  `nb_zip` smallint(3) NOT NULL DEFAULT 0,
    5758  `last_zip` smallint(3) NOT NULL DEFAULT 0,
    5859  `nb_images` mediumint(8) NOT NULL DEFAULT 0,
    5960  `total_size` int(10) NOT NULL DEFAULT 0,
    60   `status` enum("new","download","done") CHARACTER SET utf8 NOT NULL DEFAULT "new",
     61  `status` enum("new","ready","download","done") NOT NULL DEFAULT "new",
    6162  PRIMARY KEY (`id`)
    62 ) DEFAULT CHARSET=utf8 AUTO_INCREMENT=1
     63) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1
    6364;';
    6465  pwg_query($query);
     
    7071  `zip` smallint(5) NOT NULL DEFAULT 0,
    7172  UNIQUE KEY `UNIQUE` (`set_id`,`image_id`)
    72 ) DEFAULT CHARSET=utf8
     73) ENGINE=MyISAM DEFAULT CHARSET=utf8
    7374;';
    7475  pwg_query($query);
     76 
     77  $query = '
     78CREATE TABLE IF NOT EXISTS `' . $prefixeTable . 'image_sizes` (
     79  `image_id` mediumint(8) NOT NULL,
     80  `type` varchar(16) NOT NULL,
     81  `width` smallint(9) NOT NULL,
     82  `height` smallint(9) NOT NULL,
     83  `filesize` mediumint(9) NOT NULL,
     84  `filemtime` int(16) NOT NULL,
     85  PRIMARY KEY (`image_id`)
     86) ENGINE=MyISAM DEFAULT CHARSET=utf8
     87;';
     88  pwg_query($query);
     89 
     90  // add a "size" column to download_sets
     91  $result = pwg_query('SHOW COLUMNS FROM `' . $prefixeTable . 'download_sets` LIKE "size";');
     92  if (!pwg_db_num_rows($result))
     93  {     
     94    pwg_query('ALTER TABLE `' . $prefixeTable . 'download_sets` ADD `size` varchar(16) NOT NULL DEFAULT "original";');
     95  }
     96 
     97  // add "ready" status
     98  pwg_query('ALTER TABLE `' . $prefixeTable . 'download_sets` CHANGE `status` `status` enum("new","ready","download","done") NOT NULL DEFAULT "new";');
    7599}
    76100
  • extensions/BatchDownloader/main.inc.php

    r23288 r23290  
    1717define('BATCH_DOWNLOAD_TSETS',   $prefixeTable . 'download_sets');
    1818define('BATCH_DOWNLOAD_TIMAGES', $prefixeTable . 'download_sets_images');
     19define('IMAGE_SIZES_TABLE',      $prefixeTable . 'image_sizes');
    1920define('BATCH_DOWNLOAD_LOCAL',   PHPWG_ROOT_PATH . $conf['data_location'] . 'download_archives/');
    2021define('BATCH_DOWNLOAD_ADMIN',   get_root_url() . 'admin.php?page=plugin-' . BATCH_DOWNLOAD_ID);
  • extensions/BatchDownloader/template/init_zip.tpl

    r17517 r23290  
    66{/footer_script}
    77{/if}
     8
     9{if $missing_derivatives}
     10{combine_script id='jquery.progressBar' load='footer' path='themes/default/js/plugins/jquery.progressbar.min.js'}
     11{combine_script id='jquery.ajaxmanager' load='footer' path='themes/default/js/plugins/jquery.ajaxmanager.js'}
     12
     13{footer_script}
     14var derivatives = {ldelim}
     15        elements: ["{'","'|@implode:$missing_derivatives}"],
     16        done: 0,
     17        total: {$missing_derivatives|@count},
     18       
     19        finished: function() {ldelim}
     20                return derivatives.done == derivatives.total;
     21        }
     22};
     23
     24function progress(success) {ldelim}
     25  jQuery('#progressBar').progressBar(derivatives.done, {ldelim}
     26    max: derivatives.total,
     27    textFormat: 'fraction',
     28    boxImage: '{$ROOT_PATH}themes/default/images/progressbar.gif',
     29    barImage: '{$ROOT_PATH}themes/default/images/progressbg_red.gif'
     30  });
     31  if (success !== undefined) {ldelim}
     32                var type = success ? '.regenerateSuccess': '.regenerateError',
     33                        s = parseInt(jQuery(type).html());
     34                jQuery(type).html(++s);
     35        }
     36}
     37
     38{literal}
     39var queuedManager = jQuery.manageAjax.create('queued', {
     40  queue: true, 
     41  cacheResponse: false,
     42  maxRequests: 1
     43});
     44
     45function next_derivative() {
     46  if (derivatives.finished()) {
     47                alert("finish");
     48    return;
     49        }
     50 
     51  $("#damn").append(derivatives.elements[ derivatives.done ]+"<br>");
     52 
     53  jQuery.manageAjax.add("queued", {
     54    type: 'GET',
     55    url: derivatives.elements[ derivatives.done ]+'&ajaxload=true',
     56    dataType: 'json',
     57    success: function(data) {
     58      derivatives.done++;
     59      progress(true);
     60      next_derivative();
     61    },
     62    error: function(data) {
     63      derivatives.done++;
     64      progress(false);
     65      next_derivative();
     66    }
     67  });
     68}
     69
     70$("#begin").click(function() {
     71  progress();
     72  next_derivative();
     73});
     74{/literal}{/footer_script}
     75
     76{/if}
     77
    878
    979{* <!-- Menubar & titrePage --> *}
     
    32102    <li class="error">{$elements_error}</li>
    33103    <li><b>{'%d photos'|@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>
     104    <li><b>{'Size'|@translate}:</b> {$set.SIZE} {if $set.SIZE_INFO}<span class="downloadSizeDetails">({$set.SIZE_INFO})</span>{/if}</li>
    34105    <li><b>{'Estimated size'|@translate}:</b> {$set.TOTAL_SIZE} MB</li>
    35106    <li><b>{'Estimated number of archives'|@translate}:</b> {$set.NB_ARCHIVES} <i>({'real number of archives can differ'|@translate})</i></li>
     
    38109</fieldset>
    39110
     111{if $missing_derivatives}
     112<fieldset>
     113  <legend>Stuff happening</legend>
     114 
     115  <a id="begin">GO</a>
     116 
     117  <div id="regenerationMsg" class="bulkAction">
     118    <span class="progressBar" id="progressBar"></span>
     119  </div>
     120 
     121  <span class="regenerateSuccess">0</span> -
     122  <span class="regenerateError">0</span>
     123 
     124  <div id="damn">
     125  </div>
     126</fieldset>
     127{/if}
     128
     129{if $zip_links}
    40130<fieldset>
    41131  <legend>{'Download links'|@translate}</legend>
    42132 
    43133  <ul class="download-links">
    44     {$set.LINKS}
     134    {$zip_links}
    45135    <li class="warning">{'<b>Warning:</b> all files will be deleted within %d hours'|@translate|@sprintf:$archive_timeout}</li>
    46136  </ul>
    47137 
    48   <a href="{$set.U_CANCEL}" class="cancel-down" onClick="return confirm('{'Are you sure?'|@translate}');">{'Cancel this download'|@translate}</a>
     138  {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}
    49139</fieldset>
     140{/if}
    50141{/if}
    51142
  • extensions/BatchDownloader/template/style.css

    r16392 r23290  
    3838    border-color:#f00;
    3939  }
     40 
     41.downloadSizeDetails {font-style:italic; font-size:80%;}
Note: See TracChangeset for help on using the changeset viewer.