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='swfobject' load='footer' path='admin/include/uploadify/swfobject.js'} |
---|
4 | {combine_script id='jquery.uploadify' load='footer' require='jquery' path='admin/include/uploadify/jquery.uploadify.v2.1.0.min.js' } |
---|
5 | {combine_css path="admin/themes/default/uploadify.jGrowl.css"} |
---|
6 | {combine_css path="admin/include/uploadify/uploadify.css"} |
---|
7 | {/if} |
---|
8 | |
---|
9 | {footer_script}{literal} |
---|
10 | jQuery(document).ready(function(){ |
---|
11 | function checkUploadStart() { |
---|
12 | var nbErrors = 0; |
---|
13 | jQuery("#formErrors").hide(); |
---|
14 | jQuery("#formErrors li").hide(); |
---|
15 | |
---|
16 | if (jQuery("input[name=category_type]:checked").val() == "new" && jQuery("input[name=category_name]").val() == "") { |
---|
17 | jQuery("#formErrors #emptyCategoryName").show(); |
---|
18 | nbErrors++; |
---|
19 | } |
---|
20 | |
---|
21 | var nbFiles = 0; |
---|
22 | if (jQuery("#uploadBoxes").size() == 1) { |
---|
23 | jQuery("input[name^=image_upload]").each(function() { |
---|
24 | if (jQuery(this).val() != "") { |
---|
25 | nbFiles++; |
---|
26 | } |
---|
27 | }); |
---|
28 | } |
---|
29 | else { |
---|
30 | nbFiles = jQuery(".uploadifyQueueItem").size(); |
---|
31 | } |
---|
32 | |
---|
33 | if (nbFiles == 0) { |
---|
34 | jQuery("#formErrors #noPhoto").show(); |
---|
35 | nbErrors++; |
---|
36 | } |
---|
37 | |
---|
38 | if (nbErrors != 0) { |
---|
39 | jQuery("#formErrors").show(); |
---|
40 | return false; |
---|
41 | } |
---|
42 | else { |
---|
43 | return true; |
---|
44 | } |
---|
45 | |
---|
46 | } |
---|
47 | |
---|
48 | function humanReadableFileSize(bytes) { |
---|
49 | var byteSize = Math.round(bytes / 1024 * 100) * .01; |
---|
50 | var suffix = 'KB'; |
---|
51 | |
---|
52 | if (byteSize > 1000) { |
---|
53 | byteSize = Math.round(byteSize *.001 * 100) * .01; |
---|
54 | suffix = 'MB'; |
---|
55 | } |
---|
56 | |
---|
57 | var sizeParts = byteSize.toString().split('.'); |
---|
58 | if (sizeParts.length > 1) { |
---|
59 | byteSize = sizeParts[0] + '.' + sizeParts[1].substr(0,2); |
---|
60 | } |
---|
61 | else { |
---|
62 | byteSize = sizeParts[0]; |
---|
63 | } |
---|
64 | |
---|
65 | return byteSize+suffix; |
---|
66 | } |
---|
67 | |
---|
68 | if (jQuery("select[name=category] option").length == 0) { |
---|
69 | jQuery('input[name=category_type][value=existing]').attr('disabled', true); |
---|
70 | jQuery('input[name=category_type]').attr('checked', false); |
---|
71 | jQuery('input[name=category_type][value=new]').attr('checked', true); |
---|
72 | } |
---|
73 | |
---|
74 | jQuery("input[name=category_type]").click(function () { |
---|
75 | jQuery("[id^=category_type_]").hide(); |
---|
76 | jQuery("#category_type_"+jQuery(this).attr("value")).show(); |
---|
77 | }); |
---|
78 | |
---|
79 | jQuery("#hideErrors").click(function() { |
---|
80 | jQuery("#formErrors").hide(); |
---|
81 | return false; |
---|
82 | }); |
---|
83 | |
---|
84 | {/literal} |
---|
85 | {if $upload_mode eq 'html'} |
---|
86 | {literal} |
---|
87 | function addUploadBox() { |
---|
88 | var uploadBox = '<p class="file"><input type="file" size="60" name="image_upload[]"></p>'; |
---|
89 | jQuery(uploadBox).appendTo("#uploadBoxes"); |
---|
90 | } |
---|
91 | |
---|
92 | addUploadBox(); |
---|
93 | |
---|
94 | jQuery("#addUploadBox A").click(function () { |
---|
95 | addUploadBox(); |
---|
96 | }); |
---|
97 | |
---|
98 | jQuery("#uploadForm").submit(function() { |
---|
99 | return checkUploadStart(); |
---|
100 | }); |
---|
101 | {/literal} |
---|
102 | {elseif $upload_mode eq 'multiple'} |
---|
103 | |
---|
104 | var uploadify_path = '{$uploadify_path}'; |
---|
105 | var upload_id = '{$upload_id}'; |
---|
106 | var session_id = '{$session_id}'; |
---|
107 | var pwg_token = '{$pwg_token}'; |
---|
108 | var buttonText = 'Browse'; |
---|
109 | var sizeLimit = {$upload_max_filesize}; |
---|
110 | |
---|
111 | {literal} |
---|
112 | jQuery("#uploadify").uploadify({ |
---|
113 | 'uploader' : uploadify_path + '/uploadify.swf', |
---|
114 | 'script' : uploadify_path + '/uploadify.php', |
---|
115 | 'scriptData' : { |
---|
116 | 'upload_id' : upload_id, |
---|
117 | 'session_id' : session_id, |
---|
118 | 'pwg_token' : pwg_token, |
---|
119 | }, |
---|
120 | 'cancelImg' : uploadify_path + '/cancel.png', |
---|
121 | 'queueID' : 'fileQueue', |
---|
122 | 'auto' : false, |
---|
123 | 'displayData' : 'speed', |
---|
124 | 'buttonText' : buttonText, |
---|
125 | 'multi' : true, |
---|
126 | 'fileDesc' : 'Photo files (*.jpg,*.jpeg,*.png)', |
---|
127 | 'fileExt' : '*.jpg;*.JPG;*.jpeg;*.JPEG;*.png;*.PNG', |
---|
128 | 'sizeLimit' : sizeLimit, |
---|
129 | 'onAllComplete' : function(event, data) { |
---|
130 | if (data.errors) { |
---|
131 | return false; |
---|
132 | } |
---|
133 | else { |
---|
134 | jQuery("input[name=submit_upload]").click(); |
---|
135 | } |
---|
136 | }, |
---|
137 | onError: function (event, queueID ,fileObj, errorObj) { |
---|
138 | var msg; |
---|
139 | |
---|
140 | if (errorObj.type === "HTTP") { |
---|
141 | if (errorObj.info === 404) { |
---|
142 | alert('Could not find upload script.'); |
---|
143 | msg = 'Could not find upload script.'; |
---|
144 | } |
---|
145 | else { |
---|
146 | msg = errorObj.type+": "+errorObj.info; |
---|
147 | } |
---|
148 | } |
---|
149 | else if (errorObj.type ==="File Size") { |
---|
150 | msg = "File too big"; |
---|
151 | msg = msg + '<br>'+fileObj.name+': '+humanReadableFileSize(fileObj.size); |
---|
152 | msg = msg + '<br>Limit: '+humanReadableFileSize(sizeLimit); |
---|
153 | } |
---|
154 | else { |
---|
155 | msg = errorObj.type+": "+errorObj.info; |
---|
156 | } |
---|
157 | |
---|
158 | jQuery.jGrowl( |
---|
159 | '<p></p>'+msg, |
---|
160 | { |
---|
161 | theme: 'error', |
---|
162 | header: 'ERROR', |
---|
163 | sticky: true |
---|
164 | } |
---|
165 | ); |
---|
166 | |
---|
167 | jQuery("#fileUploadgrowl" + queueID).fadeOut( |
---|
168 | 250, |
---|
169 | function() { |
---|
170 | jQuery("#fileUploadgrowl" + queueID).remove() |
---|
171 | } |
---|
172 | ); |
---|
173 | return false; |
---|
174 | }, |
---|
175 | onCancel: function (a, b, c, d) { |
---|
176 | var msg = "Cancelled uploading: "+c.name; |
---|
177 | jQuery.jGrowl( |
---|
178 | '<p></p>'+msg, |
---|
179 | { |
---|
180 | theme: 'warning', |
---|
181 | header: 'Cancelled Upload', |
---|
182 | life: 4000, |
---|
183 | sticky: false |
---|
184 | } |
---|
185 | ); |
---|
186 | }, |
---|
187 | onClearQueue: function (a, b) { |
---|
188 | var msg = "Cleared "+b.fileCount+" files from queue"; |
---|
189 | jQuery.jGrowl( |
---|
190 | '<p></p>'+msg, |
---|
191 | { |
---|
192 | theme: 'warning', |
---|
193 | header: 'Cleared Queue', |
---|
194 | life: 4000, |
---|
195 | sticky: false |
---|
196 | } |
---|
197 | ); |
---|
198 | }, |
---|
199 | onComplete: function (a, b ,c, d, e) { |
---|
200 | var size = Math.round(c.size/1024); |
---|
201 | jQuery.jGrowl( |
---|
202 | '<p></p>'+c.name+' - '+size+'KB', |
---|
203 | { |
---|
204 | theme: 'success', |
---|
205 | header: 'Upload Complete', |
---|
206 | life: 4000, |
---|
207 | sticky: false |
---|
208 | } |
---|
209 | ); |
---|
210 | } |
---|
211 | }); |
---|
212 | |
---|
213 | jQuery("input[type=button]").click(function() { |
---|
214 | if (!checkUploadStart()) { |
---|
215 | return false; |
---|
216 | } |
---|
217 | |
---|
218 | jQuery("#uploadify").uploadifyUpload(); |
---|
219 | }); |
---|
220 | |
---|
221 | {/literal} |
---|
222 | {/if} |
---|
223 | }); |
---|
224 | {/footer_script} |
---|
225 | |
---|
226 | <div class="titrePage"> |
---|
227 | <h2>{'Upload Photos'|@translate}</h2> |
---|
228 | </div> |
---|
229 | |
---|
230 | <div id="photosAddContent"> |
---|
231 | |
---|
232 | {if count($setup_errors) > 0} |
---|
233 | <div class="errors"> |
---|
234 | <ul> |
---|
235 | {foreach from=$setup_errors item=error} |
---|
236 | <li>{$error}</li> |
---|
237 | {/foreach} |
---|
238 | </ul> |
---|
239 | </div> |
---|
240 | {else} |
---|
241 | |
---|
242 | {if count($setup_warnings) > 0} |
---|
243 | <div class="warnings"> |
---|
244 | <ul> |
---|
245 | {foreach from=$setup_warnings item=warning} |
---|
246 | <li>{$warning}</li> |
---|
247 | {/foreach} |
---|
248 | </ul> |
---|
249 | <div class="hideButton" style="text-align:center"><a href="{$hide_warnings_link}">{'Hide'|@translate}</a></div> |
---|
250 | </div> |
---|
251 | {/if} |
---|
252 | |
---|
253 | |
---|
254 | {if !empty($thumbnails)} |
---|
255 | <fieldset> |
---|
256 | <legend>{'Uploaded Photos'|@translate}</legend> |
---|
257 | <div> |
---|
258 | {foreach from=$thumbnails item=thumbnail} |
---|
259 | <a href="{$thumbnail.link}" class="externalLink"> |
---|
260 | <img src="{$thumbnail.src}" alt="{$thumbnail.file}" title="{$thumbnail.title}" class="thumbnail"> |
---|
261 | </a> |
---|
262 | {/foreach} |
---|
263 | </div> |
---|
264 | <p id="batchLink"><a href="{$batch_link}">{$batch_label}</a></p> |
---|
265 | </fieldset> |
---|
266 | <p><a href="{$another_upload_link}">{'Add another set of photos'|@translate}</a></p> |
---|
267 | {else} |
---|
268 | |
---|
269 | <div id="formErrors" class="errors" style="display:none"> |
---|
270 | <ul> |
---|
271 | <li id="emptyCategoryName">{'The name of an album must not be empty'|@translate}</li> |
---|
272 | <li id="noPhoto">{'Select at least one photo'|@translate}</li> |
---|
273 | </ul> |
---|
274 | <div class="hideButton" style="text-align:center"><a href="#" id="hideErrors">{'Hide'|@translate}</a></div> |
---|
275 | </div> |
---|
276 | |
---|
277 | <form id="uploadForm" enctype="multipart/form-data" method="post" action="{$form_action}" class="properties"> |
---|
278 | <fieldset> |
---|
279 | <legend>{'Drop into album'|@translate}</legend> |
---|
280 | {if $upload_mode eq 'multiple'} |
---|
281 | <input name="upload_id" value="{$upload_id}" type="hidden"> |
---|
282 | {/if} |
---|
283 | |
---|
284 | <label><input type="radio" name="category_type" value="existing"> {'existing album'|@translate}</label> |
---|
285 | <label><input type="radio" name="category_type" value="new" checked="checked"> {'create a new album'|@translate}</label> |
---|
286 | |
---|
287 | <div id="category_type_existing" style="display:none" class="category_selection"> |
---|
288 | <select class="categoryDropDown" name="category"> |
---|
289 | {html_options options=$category_options selected=$category_options_selected} |
---|
290 | </select> |
---|
291 | </div> |
---|
292 | |
---|
293 | <div id="category_type_new" class="category_selection"> |
---|
294 | <table> |
---|
295 | <tr> |
---|
296 | <td>{'Parent album'|@translate}</td> |
---|
297 | <td> |
---|
298 | <select class="categoryDropDown" name="category_parent"> |
---|
299 | <option value="0">------------</option> |
---|
300 | {html_options options=$category_parent_options selected=$category_parent_options_selected} |
---|
301 | </select> |
---|
302 | </td> |
---|
303 | </tr> |
---|
304 | <tr> |
---|
305 | <td>{'Album name'|@translate}</td> |
---|
306 | <td> |
---|
307 | <input type="text" name="category_name" value="{$F_CATEGORY_NAME}" style="width:400px"> |
---|
308 | </td> |
---|
309 | </tr> |
---|
310 | </table> |
---|
311 | </div> |
---|
312 | </fieldset> |
---|
313 | |
---|
314 | <fieldset> |
---|
315 | <legend>{'Who can see these photos?'|@translate}</legend> |
---|
316 | |
---|
317 | <select name="level" size="1"> |
---|
318 | {html_options options=$level_options selected=$level_options_selected} |
---|
319 | </select> |
---|
320 | </fieldset> |
---|
321 | |
---|
322 | <fieldset> |
---|
323 | <legend>{'Select files'|@translate}</legend> |
---|
324 | |
---|
325 | {if $upload_mode eq 'html'} |
---|
326 | <p><a href="{$switch_url}">{'... or switch to the multiple files form'|@translate}</a></p> |
---|
327 | |
---|
328 | <p>{'JPEG files or ZIP archives with JPEG files inside please.'|@translate}</p> |
---|
329 | |
---|
330 | <div id="uploadBoxes"></div> |
---|
331 | <div id="addUploadBox"> |
---|
332 | <a href="javascript:">{'+ Add an upload box'|@translate}</a> |
---|
333 | </div> |
---|
334 | |
---|
335 | </fieldset> |
---|
336 | |
---|
337 | <p> |
---|
338 | <input class="submit" type="submit" name="submit_upload" value="{'Upload'|@translate}"> |
---|
339 | </p> |
---|
340 | {elseif $upload_mode eq 'multiple'} |
---|
341 | <p> |
---|
342 | <input type="file" name="uploadify" id="uploadify"> |
---|
343 | </p> |
---|
344 | |
---|
345 | <p><a href="{$switch_url}">{'... or switch to the old style form'|@translate}</a></p> |
---|
346 | |
---|
347 | <div id="fileQueue"></div> |
---|
348 | |
---|
349 | </fieldset> |
---|
350 | <p> |
---|
351 | <input class="submit" type="button" value="{'Upload'|@translate}"> |
---|
352 | <input type="submit" name="submit_upload" style="display:none"> |
---|
353 | </p> |
---|
354 | {/if} |
---|
355 | </form> |
---|
356 | {/if} {* empty($thumbnails) *} |
---|
357 | {/if} {* $setup_errors *} |
---|
358 | |
---|
359 | </div> <!-- photosAddContent --> |
---|