1 | {if $upload_mode eq 'multiple'} |
---|
2 | {combine_script id='jquery.jgrowl' load='footer' require='jquery' path='themes/default/js/plugins/jquery.jgrowl_minimized.js' } |
---|
3 | {combine_script id='jquery.uploadify' load='footer' require='jquery' path='admin/include/uploadify/jquery.uploadify.v3.0.0.min.js' } |
---|
4 | {combine_script id='jquery.ui.progressbar' load='footer'} |
---|
5 | {combine_css path="themes/default/js/plugins/jquery.jgrowl.css"} |
---|
6 | {combine_css path="admin/include/uploadify/uploadify.css"} |
---|
7 | {/if} |
---|
8 | |
---|
9 | {include file='include/colorbox.inc.tpl'} |
---|
10 | {include file='include/add_album.inc.tpl'} |
---|
11 | |
---|
12 | {footer_script}{literal} |
---|
13 | jQuery(document).ready(function(){ |
---|
14 | function checkUploadStart() { |
---|
15 | var nbErrors = 0; |
---|
16 | jQuery("#formErrors").hide(); |
---|
17 | jQuery("#formErrors li").hide(); |
---|
18 | |
---|
19 | if (jQuery("#albumSelect option:selected").length == 0) { |
---|
20 | jQuery("#formErrors #noAlbum").show(); |
---|
21 | nbErrors++; |
---|
22 | } |
---|
23 | |
---|
24 | var nbFiles = 0; |
---|
25 | if (jQuery("#uploadBoxes").size() == 1) { |
---|
26 | jQuery("input[name^=image_upload]").each(function() { |
---|
27 | if (jQuery(this).val() != "") { |
---|
28 | nbFiles++; |
---|
29 | } |
---|
30 | }); |
---|
31 | } |
---|
32 | else { |
---|
33 | nbFiles = jQuery(".uploadifyQueueItem").size(); |
---|
34 | } |
---|
35 | |
---|
36 | if (nbFiles == 0) { |
---|
37 | jQuery("#formErrors #noPhoto").show(); |
---|
38 | nbErrors++; |
---|
39 | } |
---|
40 | |
---|
41 | if (nbErrors != 0) { |
---|
42 | jQuery("#formErrors").show(); |
---|
43 | return false; |
---|
44 | } |
---|
45 | else { |
---|
46 | return true; |
---|
47 | } |
---|
48 | |
---|
49 | } |
---|
50 | |
---|
51 | function humanReadableFileSize(bytes) { |
---|
52 | var byteSize = Math.round(bytes / 1024 * 100) * .01; |
---|
53 | var suffix = 'KB'; |
---|
54 | |
---|
55 | if (byteSize > 1000) { |
---|
56 | byteSize = Math.round(byteSize *.001 * 100) * .01; |
---|
57 | suffix = 'MB'; |
---|
58 | } |
---|
59 | |
---|
60 | var sizeParts = byteSize.toString().split('.'); |
---|
61 | if (sizeParts.length > 1) { |
---|
62 | byteSize = sizeParts[0] + '.' + sizeParts[1].substr(0,2); |
---|
63 | } |
---|
64 | else { |
---|
65 | byteSize = sizeParts[0]; |
---|
66 | } |
---|
67 | |
---|
68 | return byteSize+suffix; |
---|
69 | } |
---|
70 | |
---|
71 | jQuery("#hideErrors").click(function() { |
---|
72 | jQuery("#formErrors").hide(); |
---|
73 | return false; |
---|
74 | }); |
---|
75 | |
---|
76 | jQuery("#uploadWarningsSummary a.showInfo").click(function() { |
---|
77 | jQuery("#uploadWarningsSummary").hide(); |
---|
78 | jQuery("#uploadWarnings").show(); |
---|
79 | return false; |
---|
80 | }); |
---|
81 | |
---|
82 | jQuery("#showPermissions").click(function() { |
---|
83 | jQuery(this).parent(".showFieldset").hide(); |
---|
84 | jQuery("#permissions").show(); |
---|
85 | return false; |
---|
86 | }); |
---|
87 | |
---|
88 | {/literal} |
---|
89 | {if $upload_mode eq 'html'} |
---|
90 | {literal} |
---|
91 | function addUploadBox() { |
---|
92 | var uploadBox = '<p class="file"><input type="file" size="60" name="image_upload[]"></p>'; |
---|
93 | jQuery(uploadBox).appendTo("#uploadBoxes"); |
---|
94 | } |
---|
95 | |
---|
96 | addUploadBox(); |
---|
97 | |
---|
98 | jQuery("#addUploadBox A").click(function () { |
---|
99 | addUploadBox(); |
---|
100 | }); |
---|
101 | |
---|
102 | jQuery("#uploadForm").submit(function() { |
---|
103 | return checkUploadStart(); |
---|
104 | }); |
---|
105 | {/literal} |
---|
106 | {elseif $upload_mode eq 'multiple'} |
---|
107 | |
---|
108 | var uploadify_path = '{$uploadify_path}'; |
---|
109 | var upload_id = '{$upload_id}'; |
---|
110 | var session_id = '{$session_id}'; |
---|
111 | var pwg_token = '{$pwg_token}'; |
---|
112 | var buttonText = "{'Select files'|@translate}"; |
---|
113 | var sizeLimit = Math.round({$upload_max_filesize} / 1024); /* in KBytes */ |
---|
114 | |
---|
115 | {literal} |
---|
116 | jQuery("#uploadify").uploadify({ |
---|
117 | 'uploader' : uploadify_path + '/uploadify.php', |
---|
118 | 'langFile' : uploadify_path + '/uploadifyLang_en.js', |
---|
119 | 'swf' : uploadify_path + '/uploadify.swf', |
---|
120 | 'checkExisting' : false, |
---|
121 | |
---|
122 | buttonCursor : 'pointer', |
---|
123 | 'buttonText' : buttonText, |
---|
124 | 'width' : 300, |
---|
125 | 'cancelImage' : uploadify_path + '/cancel.png', |
---|
126 | 'queueID' : 'fileQueue', |
---|
127 | 'auto' : false, |
---|
128 | 'multi' : true, |
---|
129 | 'fileTypeDesc' : 'Photo files', |
---|
130 | 'fileTypeExts' : '*.jpg;*.JPG;*.jpeg;*.JPEG;*.png;*.PNG;*.gif;*.GIF;{/literal}{if $tif_enabled}*.tif;*.TIF;*.tiff;*.TIFF{/if}{literal}', |
---|
131 | 'fileSizeLimit' : sizeLimit, |
---|
132 | 'progressData' : 'percentage', |
---|
133 | requeueErrors : false, |
---|
134 | 'onSelect' : function(event,ID,fileObj) { |
---|
135 | jQuery("#fileQueue").show(); |
---|
136 | }, |
---|
137 | 'onQueueComplete' : function(stats) { |
---|
138 | jQuery("input[name=submit_upload]").click(); |
---|
139 | }, |
---|
140 | onUploadError: function (file,errorCode,errorMsg,errorString,swfuploadifyQueue) { |
---|
141 | /* uploadify calls the onUploadError trigger when the user cancels a file! */ |
---|
142 | /* There no error so we skip it to avoid panic. */ |
---|
143 | if ("Cancelled" == errorString) { |
---|
144 | return false; |
---|
145 | } |
---|
146 | |
---|
147 | var msg = file.name+', '+errorString; |
---|
148 | |
---|
149 | /* Let's put the error message in the form to display once the form is */ |
---|
150 | /* performed, it makes support easier when user can copy/paste the error */ |
---|
151 | /* thrown. */ |
---|
152 | jQuery("#uploadForm").append('<input type="hidden" name="onUploadError[]" value="'+msg+'">'); |
---|
153 | |
---|
154 | jQuery.jGrowl( |
---|
155 | '<p></p>onUploadError '+msg, |
---|
156 | { |
---|
157 | theme: 'error', |
---|
158 | header: 'ERROR', |
---|
159 | life: 4000, |
---|
160 | sticky: false |
---|
161 | } |
---|
162 | ); |
---|
163 | |
---|
164 | return false; |
---|
165 | }, |
---|
166 | onUploadSuccess: function (file,data,response) { |
---|
167 | var data = jQuery.parseJSON(data); |
---|
168 | jQuery("#uploadedPhotos").parent("fieldset").show(); |
---|
169 | |
---|
170 | /* Let's display the thumbnail of the uploaded photo, no need to wait the */ |
---|
171 | /* end of the queue */ |
---|
172 | jQuery("#uploadedPhotos").prepend('<img src="'+data.thumbnail_url+'" class="thumbnail"> '); |
---|
173 | }, |
---|
174 | onUploadComplete: function(file,swfuploadifyQueue) { |
---|
175 | var max = parseInt(jQuery("#progressMax").text()); |
---|
176 | var next = parseInt(jQuery("#progressCurrent").text())+1; |
---|
177 | var addToProgressBar = 2; |
---|
178 | if (next <= max) { |
---|
179 | jQuery("#progressCurrent").text(next); |
---|
180 | } |
---|
181 | else { |
---|
182 | addToProgressBar = 1; |
---|
183 | } |
---|
184 | |
---|
185 | jQuery("#progressbar").progressbar({ |
---|
186 | value: jQuery("#progressbar").progressbar("option", "value") + addToProgressBar |
---|
187 | }); |
---|
188 | } |
---|
189 | }); |
---|
190 | |
---|
191 | jQuery("input[type=button]").click(function() { |
---|
192 | if (!checkUploadStart()) { |
---|
193 | return false; |
---|
194 | } |
---|
195 | |
---|
196 | jQuery("#uploadify").uploadifySettings( |
---|
197 | 'postData', |
---|
198 | { |
---|
199 | 'category_id' : jQuery("select[name=category] option:selected").val(), |
---|
200 | 'level' : jQuery("select[name=level] option:selected").val(), |
---|
201 | 'upload_id' : upload_id, |
---|
202 | 'session_id' : session_id, |
---|
203 | 'pwg_token' : pwg_token |
---|
204 | } |
---|
205 | ); |
---|
206 | |
---|
207 | nb_files = jQuery(".uploadifyQueueItem").size(); |
---|
208 | jQuery("#progressMax").text(nb_files); |
---|
209 | jQuery("#progressbar").progressbar({max: nb_files*2, value:1}); |
---|
210 | jQuery("#progressCurrent").text(1); |
---|
211 | |
---|
212 | jQuery("#uploadProgress").show(); |
---|
213 | |
---|
214 | jQuery("#uploadify").uploadifyUpload(); |
---|
215 | }); |
---|
216 | |
---|
217 | {/literal} |
---|
218 | {/if} |
---|
219 | }); |
---|
220 | {/footer_script} |
---|
221 | |
---|
222 | <div class="titrePage"> |
---|
223 | <h2>{'Upload Photos'|@translate} {$TABSHEET_TITLE}</h2> |
---|
224 | </div> |
---|
225 | |
---|
226 | <div id="photosAddContent"> |
---|
227 | |
---|
228 | {if count($setup_errors) > 0} |
---|
229 | <div class="errors"> |
---|
230 | <ul> |
---|
231 | {foreach from=$setup_errors item=error} |
---|
232 | <li>{$error}</li> |
---|
233 | {/foreach} |
---|
234 | </ul> |
---|
235 | </div> |
---|
236 | {else} |
---|
237 | |
---|
238 | {if count($setup_warnings) > 0} |
---|
239 | <div class="warnings"> |
---|
240 | <ul> |
---|
241 | {foreach from=$setup_warnings item=warning} |
---|
242 | <li>{$warning}</li> |
---|
243 | {/foreach} |
---|
244 | </ul> |
---|
245 | <div class="hideButton" style="text-align:center"><a href="{$hide_warnings_link}">{'Hide'|@translate}</a></div> |
---|
246 | </div> |
---|
247 | {/if} |
---|
248 | |
---|
249 | |
---|
250 | {if !empty($thumbnails)} |
---|
251 | <fieldset> |
---|
252 | <legend>{'Uploaded Photos'|@translate}</legend> |
---|
253 | <div> |
---|
254 | {foreach from=$thumbnails item=thumbnail} |
---|
255 | <a href="{$thumbnail.link}" class="externalLink"> |
---|
256 | <img src="{$thumbnail.src}" alt="{$thumbnail.file}" title="{$thumbnail.title}" class="thumbnail"> |
---|
257 | </a> |
---|
258 | {/foreach} |
---|
259 | </div> |
---|
260 | <p id="batchLink"><a href="{$batch_link}">{$batch_label}</a></p> |
---|
261 | </fieldset> |
---|
262 | <p style="margin:10px"><a href="{$another_upload_link}">{'Add another set of photos'|@translate}</a></p> |
---|
263 | {else} |
---|
264 | |
---|
265 | <div id="formErrors" class="errors" style="display:none"> |
---|
266 | <ul> |
---|
267 | <li id="noAlbum">{'Select an album'|@translate}</li> |
---|
268 | <li id="noPhoto">{'Select at least one photo'|@translate}</li> |
---|
269 | </ul> |
---|
270 | <div class="hideButton" style="text-align:center"><a href="#" id="hideErrors">{'Hide'|@translate}</a></div> |
---|
271 | </div> |
---|
272 | |
---|
273 | |
---|
274 | <form id="uploadForm" enctype="multipart/form-data" method="post" action="{$form_action}" class="properties"> |
---|
275 | {if $upload_mode eq 'multiple'} |
---|
276 | <input name="upload_id" value="{$upload_id}" type="hidden"> |
---|
277 | {/if} |
---|
278 | |
---|
279 | <fieldset> |
---|
280 | <legend>{'Drop into album'|@translate}</legend> |
---|
281 | |
---|
282 | <span id="albumSelection"{if count($category_options) == 0} style="display:none"{/if}> |
---|
283 | <select id="albumSelect" name="category"> |
---|
284 | {html_options options=$category_options selected=$category_options_selected} |
---|
285 | </select> |
---|
286 | <br>{'... or '|@translate}</span><a href="#" class="addAlbumOpen" title="{'create a new album'|@translate}">{'create a new album'|@translate}</a> |
---|
287 | |
---|
288 | </fieldset> |
---|
289 | |
---|
290 | <fieldset> |
---|
291 | <legend>{'Select files'|@translate}</legend> |
---|
292 | |
---|
293 | {if isset($original_resize_maxheight)}<p class="uploadInfo">{'The picture dimensions will be reduced to %dx%d pixels.'|@translate:$original_resize_maxwidth:$original_resize_maxheight}</p>{/if} |
---|
294 | |
---|
295 | <p id="uploadWarningsSummary">{$upload_max_filesize_shorthand}B. {$upload_file_types}. {if isset($max_upload_resolution)}{$max_upload_resolution}Mpx{/if} <a class="icon-info-circled-1 showInfo" title="{'Learn more'|@translate}"></a></p> |
---|
296 | |
---|
297 | <p id="uploadWarnings"> |
---|
298 | {'Maximum file size: %sB.'|@translate:$upload_max_filesize_shorthand} |
---|
299 | {'Allowed file types: %s.'|@translate:$upload_file_types} |
---|
300 | {if isset($max_upload_resolution)} |
---|
301 | {'Approximate maximum resolution: %dM pixels (that\'s %dx%d pixels).'|@translate:$max_upload_resolution:$max_upload_width:$max_upload_height} |
---|
302 | {/if} |
---|
303 | </p> |
---|
304 | |
---|
305 | |
---|
306 | |
---|
307 | {if $upload_mode eq 'html'} |
---|
308 | <div id="uploadBoxes"></div> |
---|
309 | <div id="addUploadBox"> |
---|
310 | <a href="javascript:">{'+ Add an upload box'|@translate}</a> |
---|
311 | </div> |
---|
312 | |
---|
313 | <p id="uploadModeInfos">{'You are using the Browser uploader. Try the <a href="%s">Flash uploader</a> instead.'|@translate:$switch_url}</p> |
---|
314 | |
---|
315 | {elseif $upload_mode eq 'multiple'} |
---|
316 | <div id="uploadify">You've got a problem with your JavaScript</div> |
---|
317 | |
---|
318 | <div id="fileQueue" style="display:none"></div> |
---|
319 | |
---|
320 | <p id="uploadModeInfos">{'You are using the Flash uploader. Problems? Try the <a href="%s">Browser uploader</a> instead.'|@translate:$switch_url}</p> |
---|
321 | |
---|
322 | {/if} |
---|
323 | </fieldset> |
---|
324 | |
---|
325 | <p class="showFieldset"><a id="showPermissions" href="#">{'Manage Permissions'|@translate}</a></p> |
---|
326 | |
---|
327 | <fieldset id="permissions" style="display:none"> |
---|
328 | <legend>{'Who can see these photos?'|@translate}</legend> |
---|
329 | |
---|
330 | <select name="level" size="1"> |
---|
331 | {html_options options=$level_options selected=$level_options_selected} |
---|
332 | </select> |
---|
333 | </fieldset> |
---|
334 | |
---|
335 | {if $upload_mode eq 'html'} |
---|
336 | <p> |
---|
337 | <input class="submit" type="submit" name="submit_upload" value="{'Start Upload'|@translate}"> |
---|
338 | </p> |
---|
339 | {elseif $upload_mode eq 'multiple'} |
---|
340 | <p style="margin-bottom:1em"> |
---|
341 | <input class="submit" type="button" value="{'Start Upload'|@translate}"> |
---|
342 | <input type="submit" name="submit_upload" style="display:none"> |
---|
343 | </p> |
---|
344 | {/if} |
---|
345 | </form> |
---|
346 | |
---|
347 | <div id="uploadProgress" style="display:none"> |
---|
348 | {'Photo %s of %s'|@translate:'<span id="progressCurrent">1</span>':'<span id="progressMax">10</span>'} |
---|
349 | <br> |
---|
350 | <div id="progressbar"></div> |
---|
351 | </div> |
---|
352 | |
---|
353 | <fieldset style="display:none"> |
---|
354 | <legend>{'Uploaded Photos'|@translate}</legend> |
---|
355 | <div id="uploadedPhotos"></div> |
---|
356 | </fieldset> |
---|
357 | |
---|
358 | {/if} {* empty($thumbnails) *} |
---|
359 | {/if} {* $setup_errors *} |
---|
360 | |
---|
361 | </div> <!-- photosAddContent --> |
---|