{combine_css path=$URLUPLOADER_PATH|@cat:"template/style.css"} {combine_script id="URI" load="footer" path=$URLUPLOADER_PATH|@cat:"template/URI.min.js"} {combine_script id="createTextareaWithLines" load="footer" path=$URLUPLOADER_PATH|@cat:"template/createTextareaWithLines.js"} {if $upload_mode == 'multiple'} {combine_script id='jquery.ajaxmanager' load='footer' path='themes/default/js/plugins/jquery.ajaxmanager.js'} {combine_script id='jquery.jgrowl' load='footer' require='jquery' path='themes/default/js/plugins/jquery.jgrowl_minimized.js' } {combine_script id='jquery.ui.progressbar' load='footer'} {combine_css path="admin/themes/default/uploadify.jGrowl.css"} {/if} {include file='include/colorbox.inc.tpl'} {include file='include/add_album.inc.tpl'} {footer_script} var allowed_extensions = new Array('jpeg','jpg','png','gif'); var errorHead = '{'ERROR'|@translate|@escape:'javascript'}'; var errorMsg = '{'an error happened'|@translate|@escape:'javascript'}'; var lang = new Array(); lang['Invalid file URL'] = '{'Invalid file URL'|@translate|@escape:'javascript'}'; lang['Invalid file type'] = '{'Invalid file type'|@translate|@escape:'javascript'}'; lang['File URL is empty'] = '{'File URL is empty'|@translate|@escape:'javascript'}'; lang['Unable to download file'] = '{'Unable to download file'|@translate|@escape:'javascript'}'; lang['Pending'] = '{'Pending'|@translate|@escape:'javascript'}'; lang['Delete this item'] = '{'Delete this item'|@translate|@escape:'javascript'}'; {literal} jQuery("#hideErrors").click(function() { jQuery("#formErrors").hide(); return false; }); jQuery("#uploadWarningsSummary a.showInfo").click(function() { jQuery("#uploadWarningsSummary").hide(); jQuery("#uploadWarnings").show(); return false; }); jQuery("#showPermissions").click(function() { jQuery(this).parent(".showFieldset").hide(); jQuery("#permissions").show(); return false; }); {/literal} {* *} {if $upload_mode == 'multiple'} {literal} function checkUploadStart() { var nbErrors = 0; jQuery("#formErrors").hide(); jQuery("#formErrors li").hide(); if (jQuery("#albumSelect option:selected").length == 0) { jQuery("#formErrors #noAlbum").show(); nbErrors++; } var nbFiles = jQuery("table#links tr.pending").length; if (nbFiles == 0) { jQuery("#formErrors #noPhoto").show(); nbErrors++; } if (nbErrors != 0) { jQuery("#formErrors").show(); return false; } else { return true; } } function trim (myString) { return myString.replace(/^\s+/g,'').replace(/\s+$/g,'') } jQuery("input[name='add_links']").click(function() { $input = jQuery("textarea#urls"); if ($input.val() != "") { jQuery("table#links").show(); lines = $input.val().split('\n'); $input.val(""); for (i in lines) { line = lines[i].split('|'); item = new Array; // no name given if (line.length == 1) { uri = new URI(trim(line[0])); item['name'] = ""; } // name given else { uri = new URI(trim(line[1])); item['name']= trim(line[0]); } uri.fragment(""); item['url'] = uri.href(); item['short_url'] = item['url']; // shortened url for display if (item['url'].length > 40) { item['short_url'] = item['url'].substring(0, 17) + ' ... ' + item['url'].substring(item['url'].length-17); } // check if consistent url if (uri.is("relative")) { item['status'] = 'error'; item['info'] = lang['Invalid file URL']; } else { // check if good extension if (allowed_extensions.indexOf(uri.suffix().toLowerCase()) == -1) { item['status'] = 'error'; item['info'] = lang['Invalid file type']; } else { item['status'] = 'pending'; item['info'] = lang['Pending']; } } // add link to table jQuery("table#links tbody").append(''+ ''+ item['name'] +''+ ''+ item['short_url'] +''+ ''+ item['info'] +''+ ' '+ ''); } } $input.focus(); return false; }); jQuery("table#links").on("click", "a.delete", function() { $(this).parents("tr").remove(); jQuery("textarea#urls").focus(); }); /* */ var import_done = 0; var import_selected = 0; var queuedManager = jQuery.manageAjax.create('queued', { queue: true, maxRequests: 1 }); function performImport(file_url, category, name, level, $target) { queuedManager.add({ type: 'GET', dataType: 'json', url: 'ws.php', data: { method: 'pwg.images.addRemote', file_url: file_url, category: category, name: name, level: level, format: 'json' }, success: function(data) { if (data['stat'] == 'ok') { $target.remove(); jQuery("#uploadedPhotos").parent("fieldset").show(); jQuery("#uploadedPhotos").prepend(' '); jQuery("#uploadForm").append(''); } else { jQuery.jGrowl(name +' : '+ lang[data['message']], { theme: 'error', header: errorHead, sticky: true }); $target.children("td:nth-child(3)").html(lang[data['message']]); jQuery("#uploadForm").append(''); } import_done++; jQuery("#progressbar").progressbar({value: import_done}); jQuery("#progressCurrent").text(import_done); if (import_done == import_selected) { $("#uploadForm").submit(); } }, error: function(data) { jQuery.jGrowl(name +' : '+ errorMsg, { theme: 'error', header: errorHead, sticky: true }); $target.children("td:nth-child(3)").html(errorMsg); } }); } jQuery("input[name='submit_upload']").click(function() { if (!checkUploadStart()) { return false; } import_selected = jQuery("table#links tr.pending").length; jQuery("table#links a.delete").hide(); jQuery("#progressbar").progressbar({max: import_selected, value:0}); jQuery("#progressMax").text(import_selected); jQuery("#progressCurrent").text(0); jQuery("#uploadProgress").show(); jQuery("table#links tr.pending").each(function() { performImport( $(this).data('url'), $("select[name=category] option:selected").val(), $(this).data('name'), $("select[name=level] option:selected").val(), $(this) ); }); return false; }); createTextAreaWithLines('urls'); {/literal} {* *} {else} {literal} function checkUploadStart() { var nbErrors = 0; jQuery("#formErrors").hide(); jQuery("#formErrors li").hide(); if (jQuery("#albumSelect option:selected").length == 0) { jQuery("#formErrors #noAlbum").show(); nbErrors++; } if (jQuery("input[name='file_url']").val() == "") { jQuery("#formErrors #urlEmpty").show(); nbErrors++; } else { uri = new URI(jQuery("input[name='file_url']").val()); if (uri.is('relative')) { jQuery("#formErrors #urlError").show(); nbErrors++; } else if (allowed_extensions.indexOf(uri.suffix().toLowerCase()) == -1) { jQuery("#formErrors #typeError").show(); nbErrors++; } } if (nbErrors != 0) { jQuery("#formErrors").show(); return false; } else { return true; } } jQuery("input[name='submit_upload']").click(function() { return checkUploadStart(); }); {/literal} {/if} {/footer_script} {html_head}{literal} {/literal}{/html_head}

{'Upload Photos'|@translate} {$TABSHEET_TITLE}

{if count($setup_errors) > 0}
{else} {if count($setup_warnings) > 0}
{/if} {if !empty($thumbnails)}
{'Uploaded Photos'|@translate}
{foreach from=$thumbnails item=thumbnail} {$thumbnail.file} {/foreach}

{'Add another set of photos'|@translate}

{else}
{'Drop into album'|@translate} {'create a new album'|@translate}
{'Select files'|@translate}

{'Allowed file types: %s.'|@translate|@sprintf:$upload_file_types} {if isset($max_upload_resolution)} {$max_upload_resolution}Mpx i {/if}

{'Allowed file types: %s.'|@translate|@sprintf:$upload_file_types} {if isset($max_upload_resolution)} {'Approximate maximum resolution: %dM pixels (that\'s %dx%d pixels).'|@translate|@sprintf:$max_upload_resolution:$max_upload_width:$max_upload_height} {/if}

{* *} {if $upload_mode == 'single'}

{'Want to upload many files? Try the multiple uploader instead.'|@translate|@sprintf:$switch_url}

{* *} {else}

{'One link by line, separate photo name and url with a « | ». Photo name is optional.'|@translate}

{'Multiple uploader doesn\'t work? Try the single uploader instead.'|@translate|@sprintf:$switch_url}

{/if}

{'Manage Permissions'|@translate}

{'Uploaded Photos'|@translate}
{/if} {* empty($thumbnails) *} {/if} {* $setup_errors *}