[26387] | 1 | {combine_css path=$URLUPLOADER_PATH|cat:'template/style.css'} |
---|
| 2 | {combine_script id='URI' load='footer' path=$URLUPLOADER_PATH|cat:'template/URI.min.js'} |
---|
| 3 | {combine_css path=$URLUPLOADER_PATH|cat:'template/jquery.textarea-lines-numbers.css'} |
---|
| 4 | {combine_script id='createTextareaWithLines' load='footer' require='jquery.ui.resizable' path=$URLUPLOADER_PATH|cat:'template/jquery.textarea-lines-numbers.js'} |
---|
[19804] | 5 | |
---|
| 6 | {if $upload_mode == 'multiple'} |
---|
| 7 | {combine_script id='jquery.ajaxmanager' load='footer' path='themes/default/js/plugins/jquery.ajaxmanager.js'} |
---|
| 8 | {combine_script id='jquery.jgrowl' load='footer' require='jquery' path='themes/default/js/plugins/jquery.jgrowl_minimized.js' } |
---|
| 9 | {combine_script id='jquery.ui.progressbar' load='footer'} |
---|
[26387] | 10 | {combine_css path='themes/default/js/plugins/jquery.jgrowl.css'} |
---|
[19804] | 11 | {/if} |
---|
| 12 | |
---|
| 13 | {include file='include/colorbox.inc.tpl'} |
---|
| 14 | {include file='include/add_album.inc.tpl'} |
---|
| 15 | |
---|
| 16 | |
---|
| 17 | {footer_script} |
---|
[26387] | 18 | (function($){ |
---|
| 19 | var allowed_extensions = new Array('jpeg','jpg','png','gif'); |
---|
[19804] | 20 | |
---|
[26387] | 21 | $('#hideErrors').click(function() { |
---|
| 22 | $('#formErrors').hide(); |
---|
[19804] | 23 | return false; |
---|
| 24 | }); |
---|
| 25 | |
---|
[26387] | 26 | $('#uploadWarningsSummary a.showInfo').click(function() { |
---|
| 27 | $('#uploadWarningsSummary').hide(); |
---|
| 28 | $('#uploadWarnings').show(); |
---|
[19804] | 29 | return false; |
---|
| 30 | }); |
---|
| 31 | |
---|
[26387] | 32 | $('#showPermissions').click(function() { |
---|
| 33 | $(this).parent('.showFieldset').hide(); |
---|
| 34 | $('#permissions').show(); |
---|
[19804] | 35 | return false; |
---|
| 36 | }); |
---|
| 37 | |
---|
[26387] | 38 | {* <!-- MULTIPLE UPLOAD --> *} |
---|
| 39 | {if $upload_mode == 'multiple'} |
---|
| 40 | function checkUploadStart() { |
---|
| 41 | var nbErrors = 0; |
---|
| 42 | |
---|
| 43 | $('#formErrors').hide(); |
---|
| 44 | $('#formErrors li').hide(); |
---|
[19804] | 45 | |
---|
[26387] | 46 | if ($('#albumSelect option:selected').length == 0) { |
---|
| 47 | $('#formErrors #noAlbum').show(); |
---|
| 48 | nbErrors++; |
---|
| 49 | } |
---|
| 50 | |
---|
| 51 | var nbFiles = $('table#links tr.pending').length; |
---|
| 52 | |
---|
| 53 | if (nbFiles == 0) { |
---|
| 54 | $('#formErrors #noPhoto').show(); |
---|
| 55 | nbErrors++; |
---|
| 56 | } |
---|
[19804] | 57 | |
---|
[26387] | 58 | if (nbErrors != 0) { |
---|
| 59 | $('#formErrors').show(); |
---|
| 60 | return false; |
---|
| 61 | } |
---|
| 62 | else { |
---|
| 63 | return true; |
---|
| 64 | } |
---|
[19804] | 65 | } |
---|
| 66 | |
---|
[26387] | 67 | function trim (str) { |
---|
| 68 | return str.replace(/^\s+/g,'').replace(/\s+$/g,'') |
---|
[19804] | 69 | } |
---|
| 70 | |
---|
[26387] | 71 | $('input[name=add_links]').click(function() { |
---|
| 72 | $input = $('textarea#urls'); |
---|
[19804] | 73 | |
---|
[26387] | 74 | if ($input.val() != '') { |
---|
| 75 | $('table#links').show(); |
---|
[19804] | 76 | |
---|
[26387] | 77 | var lines = $input.val().split('\n'); |
---|
| 78 | var html = ''; |
---|
| 79 | $input.val(''); |
---|
[19804] | 80 | |
---|
[26387] | 81 | for (i in lines) { |
---|
| 82 | line = lines[i].split('|'); |
---|
| 83 | item = {}; |
---|
| 84 | |
---|
| 85 | // no name given |
---|
| 86 | if (line.length == 1) { |
---|
| 87 | uri = new URI(trim(line[0])); |
---|
| 88 | item.name = ''; |
---|
[19804] | 89 | } |
---|
[26387] | 90 | // name given |
---|
[19804] | 91 | else { |
---|
[26387] | 92 | uri = new URI(trim(line[1])); |
---|
| 93 | item.name = trim(line[0]); |
---|
[19804] | 94 | } |
---|
[26387] | 95 | |
---|
| 96 | uri.fragment(''); |
---|
| 97 | item.url = uri.href(); |
---|
| 98 | item.short_url = item.url; |
---|
| 99 | |
---|
| 100 | // shortened url for display |
---|
| 101 | if (item.url.length > 40) { |
---|
| 102 | item.short_url = item.url.substring(0, 15) + ' ... ' + item.url.substring(item.url.length-15); |
---|
| 103 | } |
---|
| 104 | |
---|
| 105 | // check if consistent url |
---|
| 106 | if (uri.is('relative')) { |
---|
| 107 | item.status = 'error'; |
---|
| 108 | item.info = '{'Invalid file URL'|translate|escape:javascript}'; |
---|
| 109 | } |
---|
| 110 | else { |
---|
| 111 | // check if good extension |
---|
| 112 | if (allowed_extensions.indexOf(uri.suffix().toLowerCase()) == -1) { |
---|
| 113 | item.status = 'error'; |
---|
| 114 | item.info = '{'Invalid file type'|translate|escape:javascript}'; |
---|
| 115 | } |
---|
| 116 | else { |
---|
| 117 | item.status = 'pending'; |
---|
| 118 | item.info = '{'Pending'|translate|escape:javascript}'; |
---|
| 119 | } |
---|
| 120 | } |
---|
| 121 | |
---|
| 122 | // add link to table |
---|
| 123 | html+= '<tr class="'+ item.status + '" data-name="'+ item.name +'" data-url="'+ item.url +'">'+ |
---|
| 124 | '<td>'+ item.name +'</td>'+ |
---|
| 125 | '<td><a href="'+ item.url +'">'+ item.short_url +'</a></td>'+ |
---|
| 126 | '<td>'+ item.info +'</td>'+ |
---|
| 127 | '<td><a class="delete" title="{'Delete this item'|translate|escape:javascript}"> </a></td>'+ |
---|
| 128 | '</tr>'; |
---|
[19804] | 129 | } |
---|
| 130 | |
---|
[26387] | 131 | $('table#links tbody').append(html); |
---|
[19804] | 132 | } |
---|
[26387] | 133 | |
---|
| 134 | $input.focus(); |
---|
| 135 | return false; |
---|
| 136 | }); |
---|
[19804] | 137 | |
---|
[26387] | 138 | $('table#links').on('click', 'a.delete', function() { |
---|
| 139 | $(this).parents('tr').remove(); |
---|
| 140 | $('textarea#urls').focus(); |
---|
| 141 | }); |
---|
[19804] | 142 | |
---|
[26387] | 143 | // AJAX MANAGER |
---|
| 144 | var import_done = 0; |
---|
| 145 | var import_selected = 0; |
---|
| 146 | var queuedManager = $.manageAjax.create('queued', { |
---|
| 147 | queue: true, |
---|
| 148 | maxRequests: 1 |
---|
| 149 | }); |
---|
[19804] | 150 | |
---|
[26387] | 151 | function performImport(file_url, category, name, level, url_in_comment, $target) { |
---|
| 152 | queuedManager.add({ |
---|
| 153 | type: 'GET', |
---|
| 154 | dataType: 'json', |
---|
| 155 | url: 'ws.php', |
---|
| 156 | data: { |
---|
| 157 | method: 'pwg.images.addRemote', |
---|
| 158 | file_url: file_url, |
---|
| 159 | category: category, |
---|
| 160 | name: name, |
---|
| 161 | level: level, |
---|
| 162 | url_in_comment: url_in_comment, |
---|
| 163 | format: 'json' |
---|
| 164 | }, |
---|
| 165 | success: function(data) { |
---|
| 166 | if (data['stat'] == 'ok') { |
---|
| 167 | $target.remove(); |
---|
| 168 | $('#uploadedPhotos').parent('fieldset').show(); |
---|
| 169 | $('#uploadedPhotos').prepend('<img src="'+ data['result']['thumbnail_url'] +'" class="thumbnail"> '); |
---|
| 170 | $('#uploadForm').append('<input type="hidden" name="imageIds[]" value="'+ data['result']['image_id'] +'">'); |
---|
| 171 | } |
---|
| 172 | else { |
---|
| 173 | $.jGrowl(name +' : '+ data['message'], { |
---|
| 174 | theme: 'error', sticky: true, |
---|
| 175 | header: '{'ERROR'|translate}' |
---|
[19804] | 176 | }); |
---|
[26387] | 177 | |
---|
| 178 | $target.children('td:nth-child(3)').html(lang[data['message']]); |
---|
| 179 | $('#uploadForm').append('<input type="hidden" name="onUploadError[]" value="'+ file_url +' : '+ data['message'] +'">'); |
---|
| 180 | } |
---|
| 181 | |
---|
| 182 | import_done++; |
---|
| 183 | $('#progressbar').progressbar({ value: import_done }); |
---|
| 184 | $('#progressCurrent').text(import_done); |
---|
| 185 | |
---|
| 186 | if (import_done == import_selected) { |
---|
| 187 | $('#uploadForm').submit(); |
---|
| 188 | } |
---|
| 189 | }, |
---|
| 190 | error: function(data) { |
---|
| 191 | $.jGrowl(name +' : '+ '{'an error happened'|translate|escape:javascript}', { |
---|
| 192 | theme: 'error', sticky: true, |
---|
| 193 | header: '{'ERROR'|translate}' |
---|
| 194 | }); |
---|
| 195 | |
---|
| 196 | $target.children('td:nth-child(3)').html('{'an error happened'|translate|escape:javascript}'); |
---|
[19804] | 197 | } |
---|
[26387] | 198 | }); |
---|
| 199 | } |
---|
| 200 | |
---|
| 201 | $('input[name=submit_upload]').click(function() { |
---|
| 202 | if (!checkUploadStart()) { |
---|
| 203 | return false; |
---|
| 204 | } |
---|
| 205 | |
---|
| 206 | import_selected = $('table#links tr.pending').length; |
---|
| 207 | |
---|
| 208 | $('table#links a.delete').hide(); |
---|
| 209 | |
---|
| 210 | $('#progressbar').progressbar({ max: import_selected, value:0 }); |
---|
| 211 | $('#progressMax').text(import_selected); |
---|
| 212 | $('#progressCurrent').text(0); |
---|
| 213 | $('#uploadProgress').show(); |
---|
| 214 | |
---|
| 215 | $('table#links tr.pending').each(function() { |
---|
| 216 | performImport( |
---|
| 217 | $(this).data('url'), |
---|
| 218 | $('select[name=category] option:selected').val(), |
---|
| 219 | $(this).data('name'), |
---|
| 220 | $('select[name=level] option:selected').val(), |
---|
| 221 | $('input[name=url_in_comment]').is(':checked'), |
---|
| 222 | $(this) |
---|
| 223 | ); |
---|
| 224 | }); |
---|
[19804] | 225 | |
---|
[26387] | 226 | return false; |
---|
[19804] | 227 | }); |
---|
| 228 | |
---|
[26387] | 229 | $('textarea#urls').textareaLinesNumbers({ |
---|
| 230 | lines:999, |
---|
| 231 | trailing:'.' |
---|
[19804] | 232 | }); |
---|
| 233 | |
---|
| 234 | |
---|
| 235 | {* <!-- SINGLE UPLOAD --> *} |
---|
| 236 | {else} |
---|
[26387] | 237 | function checkUploadStart() { |
---|
| 238 | var nbErrors = 0; |
---|
| 239 | |
---|
| 240 | $('#formErrors').hide(); |
---|
| 241 | $('#formErrors li').hide(); |
---|
[19804] | 242 | |
---|
[26387] | 243 | if ($('#albumSelect option:selected').length == 0) { |
---|
| 244 | $('#formErrors #noAlbum').show(); |
---|
[19804] | 245 | nbErrors++; |
---|
| 246 | } |
---|
[26387] | 247 | |
---|
| 248 | if ($('input[name=file_url]').val() == '') { |
---|
| 249 | $('#formErrors #urlEmpty').show(); |
---|
[19804] | 250 | nbErrors++; |
---|
| 251 | } |
---|
[26387] | 252 | else { |
---|
| 253 | uri = new URI($('input[name=file_url]').val()); |
---|
| 254 | if (uri.is('relative')) { |
---|
| 255 | $('#formErrors #urlError').show(); |
---|
| 256 | nbErrors++; |
---|
| 257 | } |
---|
| 258 | else if (allowed_extensions.indexOf(uri.suffix().toLowerCase()) == -1) { |
---|
| 259 | $('#formErrors #typeError').show(); |
---|
| 260 | nbErrors++; |
---|
| 261 | } |
---|
| 262 | } |
---|
[19804] | 263 | |
---|
[26387] | 264 | if (nbErrors != 0) { |
---|
| 265 | $('#formErrors').show(); |
---|
| 266 | return false; |
---|
| 267 | } |
---|
| 268 | else { |
---|
| 269 | return true; |
---|
| 270 | } |
---|
[19804] | 271 | } |
---|
| 272 | |
---|
[26387] | 273 | $('input[name=submit_upload]').click(function() { |
---|
| 274 | return checkUploadStart(); |
---|
| 275 | }); |
---|
[19804] | 276 | {/if} |
---|
| 277 | |
---|
[26387] | 278 | }(jQuery)); |
---|
[19804] | 279 | {/footer_script} |
---|
| 280 | |
---|
| 281 | |
---|
[26387] | 282 | {html_style} |
---|
[19804] | 283 | a.delete { |
---|
| 284 | background:url('admin/include/uploadify/cancel.png'); |
---|
| 285 | } |
---|
[26387] | 286 | {/html_style} |
---|
[19804] | 287 | |
---|
| 288 | |
---|
| 289 | <div class="titrePage"> |
---|
[26387] | 290 | <h2>{'Upload Photos'|translate} {$TABSHEET_TITLE}</h2> |
---|
[19804] | 291 | </div> |
---|
| 292 | |
---|
| 293 | <div id="photosAddContent"> |
---|
| 294 | |
---|
| 295 | {if count($setup_errors) > 0} |
---|
[26387] | 296 | <div class="errors"> |
---|
| 297 | <ul> |
---|
| 298 | {foreach from=$setup_errors item=error} |
---|
| 299 | <li>{$error}</li> |
---|
| 300 | {/foreach} |
---|
| 301 | </ul> |
---|
| 302 | </div> |
---|
[19804] | 303 | {else} |
---|
| 304 | |
---|
[26387] | 305 | {if count($setup_warnings) > 0} |
---|
| 306 | <div class="warnings"> |
---|
| 307 | <ul> |
---|
| 308 | {foreach from=$setup_warnings item=warning} |
---|
| 309 | <li>{$warning}</li> |
---|
| 310 | {/foreach} |
---|
| 311 | </ul> |
---|
| 312 | <div class="hideButton" style="text-align:center"><a href="{$hide_warnings_link}">{'Hide'|translate}</a></div> |
---|
| 313 | </div> |
---|
| 314 | {/if} |
---|
| 315 | |
---|
| 316 | {if !empty($thumbnails)} |
---|
| 317 | <fieldset> |
---|
| 318 | <legend>{'Uploaded Photos'|translate}</legend> |
---|
| 319 | <div> |
---|
| 320 | {foreach from=$thumbnails item=thumbnail} |
---|
| 321 | <a href="{$thumbnail.link}" class="externalLink"> |
---|
| 322 | <img src="{$thumbnail.src}" alt="{$thumbnail.file}" title="{$thumbnail.title}" class="thumbnail"> |
---|
| 323 | </a> |
---|
[19804] | 324 | {/foreach} |
---|
[26387] | 325 | </div> |
---|
| 326 | |
---|
| 327 | <p id="batchLink"><a href="{$batch_link}">{$batch_label}</a></p> |
---|
| 328 | </fieldset> |
---|
[19804] | 329 | |
---|
[26387] | 330 | <p style="margin:10px"><a href="{$another_upload_link}">{'Add another set of photos'|translate}</a></p> |
---|
| 331 | |
---|
| 332 | {else} |
---|
| 333 | <div id="formErrors" class="errors" style="display:none"> |
---|
| 334 | <ul> |
---|
| 335 | <li id="noAlbum">{'Select an album'|translate}</li> |
---|
| 336 | <li id="noPhoto">{'Select at least one photo'|translate}</li> |
---|
| 337 | <li id="urlEmpty">{'File URL is empty'|translate}</li> |
---|
| 338 | <li id="urlError">{'Invalid file URL'|translate}</li> |
---|
| 339 | <li id="typeError">{'Invalid file type'|translate}</li> |
---|
| 340 | </ul> |
---|
| 341 | <div class="hideButton" style="text-align:center"><a href="#" id="hideErrors">{'Hide'|translate}</a></div> |
---|
[19804] | 342 | </div> |
---|
| 343 | |
---|
[26387] | 344 | <form id="uploadForm" enctype="multipart/form-data" method="post" action="{$form_action}" class="properties"> |
---|
[19804] | 345 | <fieldset> |
---|
[26387] | 346 | <legend>{'Drop into album'|translate}</legend> |
---|
[19804] | 347 | |
---|
| 348 | <span id="albumSelection"{if count($category_options) == 0} style="display:none"{/if}> |
---|
| 349 | <select id="albumSelect" name="category"> |
---|
| 350 | {html_options options=$category_options selected=$category_options_selected} |
---|
| 351 | </select> |
---|
[26387] | 352 | <br>{'... or '|translate}</span><a href="#" class="addAlbumOpen" title="{'create a new album'|translate}">{'create a new album'|translate}</a> |
---|
[19804] | 353 | |
---|
| 354 | </fieldset> |
---|
| 355 | |
---|
| 356 | <fieldset> |
---|
[26387] | 357 | <legend>{'Select files'|translate}</legend> |
---|
[19804] | 358 | |
---|
| 359 | <p id="uploadWarningsSummary"> |
---|
[26387] | 360 | {'Allowed file types: %s.'|translate:$upload_file_types} |
---|
[19804] | 361 | {if isset($max_upload_resolution)} |
---|
| 362 | {$max_upload_resolution}Mpx |
---|
[26387] | 363 | <a class="showInfo" title="{'Learn more'|translate}">i</a> |
---|
[19804] | 364 | {/if} |
---|
| 365 | </p> |
---|
| 366 | |
---|
| 367 | <p id="uploadWarnings"> |
---|
[26387] | 368 | {'Allowed file types: %s.'|translate:$upload_file_types} |
---|
[19804] | 369 | {if isset($max_upload_resolution)} |
---|
[26387] | 370 | {'Approximate maximum resolution: %dM pixels (that\'s %dx%d pixels).'|translate:$max_upload_resolution:$max_upload_width:$max_upload_height} |
---|
[19804] | 371 | {/if} |
---|
| 372 | </p> |
---|
| 373 | |
---|
| 374 | {* <!-- SINGLE UPLOAD --> *} |
---|
[26387] | 375 | {if $upload_mode == 'single'} |
---|
[19804] | 376 | <ul> |
---|
| 377 | <li> |
---|
| 378 | <label> |
---|
[26387] | 379 | <span class="property">{'File URL'|translate}</span> |
---|
[19804] | 380 | <input type="text" name="file_url" size="70"> |
---|
| 381 | </label> |
---|
| 382 | </li> |
---|
| 383 | <li> |
---|
| 384 | <label> |
---|
[26387] | 385 | <span class="property">{'Photo name'|translate}</span> |
---|
[19804] | 386 | <input type="text" name="photo_name" size="40"> |
---|
| 387 | </label> |
---|
| 388 | </li> |
---|
[20407] | 389 | <li> |
---|
| 390 | <label> |
---|
| 391 | <span class="property"><input type="checkbox" name="url_in_comment" checked="checked"></span> |
---|
[26387] | 392 | {'Add website URL in photo description'|translate} |
---|
[20407] | 393 | </label> |
---|
| 394 | </li> |
---|
[19804] | 395 | </ul> |
---|
| 396 | |
---|
[26387] | 397 | <p id="uploadModeInfos">{'Want to upload many files? Try the <a href="%s">multiple uploader</a> instead.'|translate:$switch_url}</p> |
---|
[19804] | 398 | |
---|
| 399 | {* <!-- MULTIPLE UPLOAD --> *} |
---|
[26387] | 400 | {else} |
---|
[19804] | 401 | <table id="links" class="table2" style="display:none;"> |
---|
| 402 | <thead> |
---|
| 403 | <tr class="throw"> |
---|
[26387] | 404 | <th style="width:150px;">{'Photo name'|translate}</th> |
---|
| 405 | <th>{'File URL'|translate}</th> |
---|
| 406 | <th style="width:150px;">{'Status'|translate}</th> |
---|
[19804] | 407 | <th style="width:20px;"></th> |
---|
| 408 | </tr> |
---|
| 409 | </thead> |
---|
| 410 | <tbody> |
---|
| 411 | </tbody> |
---|
| 412 | </table> |
---|
| 413 | |
---|
| 414 | <p> |
---|
[26387] | 415 | {'One link by line, separate photo name and url with a « | ». Photo name is optional.'|translate} |
---|
[19804] | 416 | <br> |
---|
| 417 | <textarea id="urls"></textarea> |
---|
| 418 | </p> |
---|
| 419 | |
---|
[26387] | 420 | <p> |
---|
| 421 | <label> |
---|
| 422 | <input type="checkbox" name="url_in_comment" checked="checked"> |
---|
| 423 | {'Add website URL in photo description'|translate} |
---|
| 424 | </label> |
---|
| 425 | </p> |
---|
| 426 | |
---|
| 427 | <input type="submit" name="add_links" value="{'Add links'|translate}"> |
---|
| 428 | |
---|
| 429 | <p id="uploadModeInfos">{'Multiple uploader doesn\'t work? Try the <a href="%s">single uploader</a> instead.'|translate:$switch_url}</p> |
---|
| 430 | {/if} |
---|
[19804] | 431 | </fieldset> |
---|
| 432 | |
---|
[26387] | 433 | <p class="showFieldset"><a id="showPermissions" href="#">{'Manage Permissions'|translate}</a></p> |
---|
[19804] | 434 | |
---|
| 435 | <fieldset id="permissions" style="display:none"> |
---|
[26387] | 436 | <legend>{'Who can see these photos?'|translate}</legend> |
---|
[19804] | 437 | |
---|
| 438 | <select name="level" size="1"> |
---|
| 439 | {html_options options=$level_options selected=$level_options_selected} |
---|
| 440 | </select> |
---|
| 441 | </fieldset> |
---|
| 442 | |
---|
| 443 | <p> |
---|
[26387] | 444 | <input class="submit" type="submit" name="submit_upload" value="{'Start Upload'|translate}"> |
---|
[19804] | 445 | </p> |
---|
[26387] | 446 | </form> |
---|
[19804] | 447 | |
---|
[26387] | 448 | <div id="uploadProgress" style="display:none"> |
---|
| 449 | {'Photo %s of %s'|translate:'<span id="progressCurrent">1</span>':'<span id="progressMax">10</span>'} |
---|
| 450 | <br> |
---|
| 451 | <div id="progressbar"></div> |
---|
| 452 | </div> |
---|
[19804] | 453 | |
---|
[26387] | 454 | <fieldset style="display:none"> |
---|
| 455 | <legend>{'Uploaded Photos'|translate}</legend> |
---|
| 456 | <div id="uploadedPhotos"></div> |
---|
| 457 | </fieldset> |
---|
[19804] | 458 | |
---|
| 459 | {/if} {* empty($thumbnails) *} |
---|
| 460 | {/if} {* $setup_errors *} |
---|
| 461 | |
---|
| 462 | <br> |
---|
| 463 | </div> <!-- photosAddContent --> |
---|