Changeset 16609
- Timestamp:
- Jul 11, 2012, 12:58:19 PM (12 years ago)
- Location:
- extensions/BatchDownloader
- Files:
-
- 1 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/BatchDownloader/download.php
r16379 r16609 3 3 include(PHPWG_ROOT_PATH.'include/common.inc.php'); 4 4 5 //check_status(ACCESS_CLASSIC);5 check_status(ACCESS_CLASSIC); 6 6 7 $BatchDownloader = new BatchDownloader($_GET['set_id']); 8 $file = $BatchDownloader->getArchivePath(); 7 try { 8 $BatchDownloader = new BatchDownloader($_GET['set_id']); 9 $file = $BatchDownloader->getArchivePath(); 9 10 10 header('Content-Type: application/force-download; name="'.basename($file).'"');11 header('Content-Disposition: attachment; filename="'.basename($file).'"');12 header('Content-Description: File Transfer');13 header('Content-Transfer-Encoding: binary');14 header('Content-Length: '.filesize($file).'');11 header('Content-Type: application/force-download; name="'.basename($file).'"'); 12 header('Content-Disposition: attachment; filename="'.basename($file).'"'); 13 header('Content-Description: File Transfer'); 14 header('Content-Transfer-Encoding: binary'); 15 header('Content-Length: '.filesize($file).''); 15 16 16 header('Cache-Control: no-cache, must-revalidate');17 header('Pragma: no-cache');18 header('Expires: 0');17 header('Cache-Control: no-cache, must-revalidate'); 18 header('Pragma: no-cache'); 19 header('Expires: 0'); 19 20 20 readfile($file); 21 readfile($file); 22 } 23 catch (Exception $e) 24 { 25 echo $e->getMessage(); 26 } 27 21 28 exit(0); 22 29 -
extensions/BatchDownloader/include/BatchDownloader.class.php
r16598 r16609 95 95 else 96 96 { 97 t rigger_error('BatchDownloader::__construct, invalid set id', E_USER_ERROR);97 throw new Exception(l10n('Invalid dowload set')); 98 98 } 99 99 } … … 270 270 function createNextArchive($force_one_archive=false) 271 271 { 272 // set already downloaded 272 // set already downloaded (we should never be there !) 273 273 if ( $this->data['status'] == 'done' or $this->data['nb_images'] == 0 ) 274 274 { -
extensions/BatchDownloader/include/download.inc.php
r16592 r16609 13 13 $template->set_filename('index', dirname(__FILE__) . '/../template/init_zip.tpl'); 14 14 15 $BatchDownloader = new BatchDownloader($_GET['set_id']); 16 17 if ( isset($_GET['cancel']) ) 15 try 18 16 { 19 $BatchDownloader->deleteLastArchive(); 20 $BatchDownloader->clearImages(); 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(); 30 } 17 $BatchDownloader = new BatchDownloader($_GET['set_id']); 18 19 if ( isset($_GET['cancel']) ) 20 { 21 $BatchDownloader->deleteLastArchive(); 22 $BatchDownloader->clearImages(); 23 pwg_query('DELETE FROM '.BATCH_DOWNLOAD_TSETS.' WHERE id = '.$_GET['set_id'].';'); 24 $_SESSION['page_infos'][] = l10n('Download set deleted'); 25 redirect('index.php'); 26 } 27 28 if ( isset($_GET['zip']) and $BatchDownloader->getParam('status') != 'done' and $_GET['zip'] > $BatchDownloader->getParam('last_zip') ) 29 { 30 $BatchDownloader->deleteLastArchive(); 31 $next_file = $BatchDownloader->createNextArchive(); 32 } 31 33 32 $set = $BatchDownloader->getSetInfo(); 33 34 if (isset($next_file)) 35 { 36 $set['U_DOWNLOAD'] = BATCH_DOWNLOAD_PATH . 'download.php?set_id='.$_GET['set_id'].'&zip='.$_GET['zip']; 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'])); 38 } 39 40 if ($BatchDownloader->getParam('nb_images') > $conf['batch_download']['max_elements']) 41 { 42 $template->assign('elements_error', sprintf( 43 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.'), 44 $BatchDownloader->getParam('nb_images'), 45 $conf['batch_download']['max_elements'], 46 $BatchDownloader->getParam('nb_images') - $conf['batch_download']['max_elements'] 34 $set = $BatchDownloader->getSetInfo(); 35 36 if (isset($next_file)) 37 { 38 $set['U_DOWNLOAD'] = BATCH_DOWNLOAD_PATH . 'download.php?set_id='.$_GET['set_id'].'&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('nb_images') > $conf['batch_download']['max_elements']) 43 { 44 $template->assign('elements_error', sprintf( 45 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.'), 46 $BatchDownloader->getParam('nb_images'), 47 $conf['batch_download']['max_elements'], 48 $BatchDownloader->getParam('nb_images') - $conf['batch_download']['max_elements'] 49 )); 50 } 51 52 $set['U_CANCEL'] = BATCH_DOWNLOAD_PUBLIC . 'init_zip&set_id='.$_GET['set_id'].'&cancel'; 53 54 $template->assign(array( 55 'set' => $set, 56 'archive_timeout' => $conf['batch_download']['archive_timeout'], 47 57 )); 48 58 } 49 50 if ($BatchDownloader->getParam('status') == 'new') 59 catch (Exception $e) 51 60 { 52 $set['U_CANCEL'] = BATCH_DOWNLOAD_PUBLIC . 'init_zip&set_id='.$_GET['set_id'].'&cancel';61 array_push($page['errors'], $e->getMessage()); 53 62 } 54 55 $template->assign(array(56 'set' => $set,57 'archive_timeout' => $conf['batch_download']['archive_timeout'],58 ));59 63 60 64 break; … … 71 75 'U_VIEW' => $self_url, 72 76 'U_INIT_ZIP' => BATCH_DOWNLOAD_PUBLIC . 'init_zip&set_id='.$_GET['set_id'], 77 'SET_ID' => $_GET['set_id'], 73 78 )); 74 79 75 $BatchDownloader = new BatchDownloader($_GET['set_id']); 76 77 if ($BatchDownloader->getParam('status') != 'new') 80 try 78 81 { 79 array_push($page['errors'], l10n('You can not edit this set')); 80 break; 82 $BatchDownloader = new BatchDownloader($_GET['set_id']); 83 84 if ($BatchDownloader->getParam('status') != 'new') 85 { 86 array_push($page['errors'], l10n('You can not edit this set')); 87 break; 88 } 89 90 if ( isset($_GET['remove']) and preg_match('#^[0-9]+$#', $_GET['remove']) ) 91 { 92 $BatchDownloader->removeImages(array($_GET['remove'])); 93 } 94 95 $template->assign('set', $BatchDownloader->getSetInfo()); 96 97 $template->set_prefilter('index_thumbnails', 'batch_download_thumbnails_list_prefilter'); 98 99 $page['start'] = isset($_GET['start']) ? $_GET['start'] : 0; 100 $page['items'] = array_keys($BatchDownloader->getImages()); 101 102 if (count($page['items']) > $page['nb_image_page']) 103 { 104 $page['navigation_bar'] = create_navigation_bar( 105 $self_url, 106 count($page['items']), 107 $page['start'], 108 $page['nb_image_page'], 109 false 110 ); 111 $template->assign('navbar', $page['navigation_bar']); 112 } 113 114 include(PHPWG_ROOT_PATH . 'include/category_default.inc.php'); 81 115 } 82 83 if ( isset($_GET['remove']) and preg_match('#^[0-9]+$#', $_GET['remove']) ) 116 catch (Exception $e) 84 117 { 85 $BatchDownloader->removeImages(array($_GET['remove']));118 array_push($page['errors'], $e->getMessage()); 86 119 } 87 88 $template->assign('set', $BatchDownloader->getSetInfo());89 90 $template->set_prefilter('index_thumbnails', 'batch_download_thumbnails_list_prefilter');91 92 $page['start'] = isset($_GET['start']) ? $_GET['start'] : 0;93 $page['items'] = array_keys($BatchDownloader->getImages());94 95 if (count($page['items']) > $page['nb_image_page'])96 {97 $page['navigation_bar'] = create_navigation_bar(98 $self_url,99 count($page['items']),100 $page['start'],101 $page['nb_image_page'],102 false103 );104 $template->assign('navbar', $page['navigation_bar']);105 }106 107 include(PHPWG_ROOT_PATH . 'include/category_default.inc.php');108 120 109 121 break; … … 116 128 function batch_download_thumbnails_list_prefilter($content, &$smarty) 117 129 { 118 $search = '<span class="thumbName">'; 130 // custom style 131 $search[0] = '{/html_style}'; 132 $replace[0] = '.thumbnails .wrap1 {ldelim} position:relative; } 133 .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; } 134 .wrap1:hover .removeSet {ldelim} display:block; }' 135 .$search[0]; 136 137 // links 138 $search[1] = '<span class="wrap1">'; 139 $replace[1] = $search[1].' 140 {strip}<a class="removeSet" href="{$U_VIEW}&remove={$thumbnail.id}" data-id="{$thumbnail.id}" rel="nofollow"> 141 {\'Remove from download set\'|@translate} <img src="{$BATCH_DOWNLOAD_PATH}template/image_delete.png" title="{\'Remove from download set\'|@translate}"> 142 </a>{/strip}'; 143 144 // AJAX request 145 $search[2] = '{/html_style}'; 146 $replace[2] = $search[2].' 147 {footer_script require=\'jquery\'} 148 jQuery(".removeSet").click(function() {ldelim} 149 var toggle_id = jQuery(this).data("id"); 150 var $trigger = jQuery(this); 119 151 120 $add = '<a href="{$U_VIEW}&remove={$thumbnail.id}" rel="nofollow"> 121 <img src="{$BATCH_DOWNLOAD_PATH}template/image_delete.png" title="{\'Remove from download set\'|@translate}"> 122 </a> '; 152 jQuery.ajax({ldelim} 153 type: "POST", 154 url: "{$BATCH_DOWNLOAD_PATH}remove_image.php", 155 data: {ldelim} "set_id": "{$SET_ID}", "toggle_id": toggle_id } 156 }).done(function(msg) {ldelim} 157 if (msg == "false") {ldelim} 158 $trigger.parent(".wrap1").hide("fast", function() {ldelim} $trigger.remove() }); 159 jQuery(".nbImages").html(jQuery(".nbImages").html() -1); 160 } else {ldelim} 161 $trigger.html(\'{\'Un unknown error occured\'|@translate}\'); 162 } 163 }); 164 165 return false; 166 }); 167 {/footer_script}'; 123 168 124 return str_replace($search, $ search.$add, $content);169 return str_replace($search, $replace, $content); 125 170 } 126 171 -
extensions/BatchDownloader/include/events.inc.php
r16598 r16609 24 24 25 25 $page['section'] = 'download'; 26 $page['title'] = l10n('Batch Downloader').$conf['level_separator'].' ';26 $page['title'] = '<a href="'.get_absolute_root_url().'">'.l10n('Home').'</a>'.$conf['level_separator'].l10n('Batch Downloader').$conf['level_separator']; 27 27 28 28 switch (@$tokens[1]) … … 164 164 array_push($data, array( 165 165 'URL' => BATCH_DOWNLOAD_PUBLIC . 'init_zip&set_id='.$BatchDownloader->getParam('set_id'), 166 'TITLE' => str ip_tags($set['COMMENT']),166 'TITLE' => str_replace('"', "'", strip_tags($set['COMMENT'])), 167 167 'NAME' => $set['sNAME'], 168 168 'COUNT' => $set['NB_IMAGES'], -
extensions/BatchDownloader/language/en_UK/plugin.lang.php
r16598 r16609 6 6 $lang['Random'] = 'Random'; 7 7 $lang['User collection'] = 'User collection'; 8 $lang['Nb images'] = 'Nb images';8 $lang['Nb images'] = 'Nb photos'; 9 9 $lang['Nb archives'] = 'Nb archives'; 10 10 $lang['Total size'] = 'Total size'; … … 32 32 $lang['Cancel this set'] = 'Cancel this set'; 33 33 $lang['Download info'] = 'Download info'; 34 $lang['Estimated size'] = 'Estimated size'; 34 35 $lang['Estimated number of archives'] = 'Estimated number of archives'; 35 36 $lang['real number of archives can differ'] = 'real number of archives can differ'; -
extensions/BatchDownloader/language/fr_FR/plugin.lang.php
r16598 r16609 32 32 $lang['Cancel this set'] = 'Annuler ce lot'; 33 33 $lang['Download info'] = 'Informations sur le téléchargement'; 34 $lang['Estimated size'] = 'Taille estimée'; 34 35 $lang['Estimated number of archives'] = 'Nombre estimé d\'archives'; 35 36 $lang['real number of archives can differ'] = 'le nombre réel d\'archives peut différer'; -
extensions/BatchDownloader/template/init_zip.tpl
r16400 r16609 20 20 21 21 22 {if $set} 22 23 <fieldset> 23 24 <legend>{'Download info'|@translate}</legend> … … 27 28 <ul class="set-infos"> 28 29 <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>{'%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> 30 31 <li><b>{'Estimated size'|@translate}:</b> {$set.TOTAL_SIZE} MB</li> 31 32 <li><b>{'Estimated number of archives'|@translate}:</b> {$set.NB_ARCHIVES} <i>({'real number of archives can differ'|@translate})</i></li> 32 33 <li><b>{'Created on'|@translate}:</b> {$set.DATE_CREATION}</li> 33 34 </ul> 34 35 36 35 </fieldset> 37 38 36 39 37 <fieldset> … … 45 43 </ul> 46 44 47 {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}45 <a href="{$set.U_CANCEL}" class="cancel-down" onClick="return confirm('{'Are you sure?'|@translate}');">{'Cancel this download'|@translate}</a> 48 46 </fieldset> 47 {/if} 49 48 50 49 </div>{* <!-- content --> *} -
extensions/BatchDownloader/template/view.tpl
r16379 r16609 14 14 <h3>{$set.NAME}</h3> 15 15 {if $set.COMMENT}<blockquote>{$set.COMMENT}</blockquote>{/if} 16 <span>{'%d images'|@translate|@sprintf:$set.NB_IMAGES}</span>16 {'Nb images'|@translate}: <span class="nbImages">{$set.NB_IMAGES}</span> 17 17 </p> 18 18
Note: See TracChangeset
for help on using the changeset viewer.