source: trunk/admin/themes/default/template/photos_add_direct.tpl @ 28991

Last change on this file since 28991 was 28917, checked in by plg, 10 years ago

i18n for the new HTML5 upload (use i18n files from plupload)

optional specific $lang_info[jquery_code] and $lang_info[plupload_code] to load the right i18n file

File size: 8.9 KB
Line 
1{combine_script id='common' load='footer' path='admin/themes/default/js/common.js'}
2{combine_script id='jquery.jgrowl' load='footer' require='jquery' path='themes/default/js/plugins/jquery.jgrowl_minimized.js'}
3{combine_script id='jquery.plupload' load='footer' require='jquery' path='themes/default/js/plugins/plupload/plupload.full.min.js'}
4{combine_script id='jquery.plupload.queue' load='footer' require='jquery' path='themes/default/js/plugins/plupload/jquery.plupload.queue/jquery.plupload.queue.min.js'}
5{combine_script id='jquery.ui.progressbar' load='footer'}
6
7{combine_css path="themes/default/js/plugins/jquery.jgrowl.css"}
8{combine_css path="themes/default/js/plugins/plupload/jquery.plupload.queue/css/jquery.plupload.queue.css"}
9
10{assign var="plupload_i18n" value="themes/default/js/plugins/plupload/i18n/`$lang_info.plupload_code`.js"}
11{if "PHPWG_ROOT_PATH"|@constant|@cat:$plupload_i18n|@file_exists}
12  {combine_script id="plupload_i18n-`$lang_info.plupload_code`" load="footer" path=$plupload_i18n require="jquery.plupload.queue"}
13{/if}
14
15{include file='include/colorbox.inc.tpl'}
16{include file='include/add_album.inc.tpl'}
17
18{combine_script id='LocalStorageCache' load='footer' path='admin/themes/default/js/LocalStorageCache.js'}
19
20{assign var="selectizeTheme" value=($themeconf.name=='roma')|ternary:'dark':'default'}
21{combine_script id='jquery.selectize' load='footer' path='themes/default/js/plugins/selectize.min.js'}
22{combine_css id='jquery.selectize' path="themes/default/js/plugins/selectize.`$selectizeTheme`.css"}
23
24{footer_script}
25{* <!-- CATEGORIES --> *}
26var categoriesCache = new CategoriesCache({
27  serverKey: '{$CACHE_KEYS.categories}',
28  serverId: '{$CACHE_KEYS._hash}',
29  rootUrl: '{$ROOT_URL}'
30});
31
32categoriesCache.selectize(jQuery('[data-selectize=categories]'), {
33  filter: function(categories, options) {
34    if (categories.length > 0) {
35      jQuery("#albumSelection, .selectFiles, .showFieldset").show();
36    }
37   
38    return categories;
39  }
40});
41
42jQuery('[data-add-album]').pwgAddAlbum({ cache: categoriesCache });
43
44var pwg_token = '{$pwg_token}';
45var photosUploaded_label = "{'%d photos uploaded'|translate}";
46var batch_Label = "{'Manage this set of %d photos'|translate}";
47var albumSummary_label = "{'Album "%s" now contains %d photos'|translate|escape}";
48var uploadedPhotos = [];
49var uploadCategory = null;
50
51{literal}
52jQuery(document).ready(function(){
53  jQuery("#uploadWarningsSummary a.showInfo").click(function() {
54    jQuery("#uploadWarningsSummary").hide();
55    jQuery("#uploadWarnings").show();
56    return false;
57  });
58
59  jQuery("#showPermissions").click(function() {
60    jQuery(this).parent(".showFieldset").hide();
61    jQuery("#permissions").show();
62    return false;
63  });
64
65        jQuery("#uploader").pluploadQueue({
66                // General settings
67                // runtimes : 'html5,flash,silverlight,html4',
68                runtimes : 'html5',
69
70                // url : '../upload.php',
71                url : 'ws.php?method=pwg.images.upload&format=json',
72
73                // User can upload no more then 20 files in one go (sets multiple_queues to false)
74                max_file_count: 100,
75               
76                chunk_size: '500kb',
77               
78                filters : {
79                        // Maximum file size
80                        max_file_size : '1000mb',
81                        // Specify what files to browse for
82                        mime_types: [
83                                {title : "Image files", extensions : "jpeg,jpg,gif,png"},
84                                {title : "Zip files", extensions : "zip"}
85                        ]
86                },
87
88                // Rename files by clicking on their titles
89                // rename: true,
90               
91                // Sort files
92                sortable: true,
93
94                // Enable ability to drag'n'drop files onto the widget (currently only HTML5 supports that)
95                dragdrop: true,
96
97    init : {
98      BeforeUpload: function(up, file) {
99        console.log('[BeforeUpload]', file);
100
101        // no more change on category/level
102        jQuery("select[name=level]").attr("disabled", "disabled");
103
104        // You can override settings before the file is uploaded
105        // up.setOption('url', 'upload.php?id=' + file.id);
106        up.setOption(
107          'multipart_params',
108          {
109            category : jQuery("select[name=category] option:selected").val(),
110            level : jQuery("select[name=level] option:selected").val(),
111            pwg_token : pwg_token
112            // name : file.name
113          }
114        );
115      },
116
117      FileUploaded: function(up, file, info) {
118        // Called when file has finished uploading
119        console.log('[FileUploaded] File:', file, "Info:", info);
120     
121        var data = jQuery.parseJSON(info.response);
122     
123        jQuery("#uploadedPhotos").parent("fieldset").show();
124     
125        html = '<a href="admin.php?page=photo-'+data.result.image_id+'" target="_blank">';
126        html += '<img src="'+data.result.src+'" class="thumbnail" title="'+data.result.name+'">';
127        html += '</a> ';
128     
129        jQuery("#uploadedPhotos").prepend(html);
130
131        // do not remove file, or it will reset the progress bar :-/
132        // up.removeFile(file);
133        uploadedPhotos.push(parseInt(data.result.image_id));
134        uploadCategory = data.result.category;
135      },
136
137      UploadComplete: function(up, files) {
138        // Called when all files are either uploaded or failed
139        console.log('[UploadComplete]');
140
141        jQuery(".selectAlbum, .selectFiles, #permissions, .showFieldset").hide();
142
143        jQuery(".infos").append('<ul><li>'+sprintf(photosUploaded_label, uploadedPhotos.length)+'</li></ul>');
144
145        html = sprintf(
146          albumSummary_label,
147          '<a href="admin.php?page=album-'+uploadCategory.id+'">'+uploadCategory.label+'</a>',
148          parseInt(uploadCategory.nb_photos)
149        );
150
151        jQuery(".infos ul").append('<li>'+html+'</li>');
152
153        jQuery(".infos").show();
154
155        // TODO: use a new method pwg.caddie.empty +
156        // pwg.caddie.add(uploadedPhotos) instead of relying on huge GET parameter
157        // (and remove useless code from admin/photos_add_direct.php)
158
159        jQuery(".batchLink").attr("href", "admin.php?page=photos_add&section=direct&batch="+uploadedPhotos.join(","));
160        jQuery(".batchLink").html(sprintf(batch_Label, uploadedPhotos.length));
161
162        jQuery(".afterUploadActions").show();
163      }
164    }
165        });
166
167{/literal}
168});
169{/footer_script}
170
171<div class="titrePage">
172  <h2>{'Upload Photos'|@translate} {$TABSHEET_TITLE}</h2>
173</div>
174
175<div id="photosAddContent">
176
177<div class="infos" style="display:none"></div>
178
179<p class="afterUploadActions" style="margin:10px; display:none;"><a class="batchLink"></a> | <a href="">{'Add another set of photos'|@translate}</a></p>
180
181{if count($setup_errors) > 0}
182<div class="errors">
183  <ul>
184  {foreach from=$setup_errors item=error}
185    <li>{$error}</li>
186  {/foreach}
187  </ul>
188</div>
189{else}
190
191  {if count($setup_warnings) > 0}
192<div class="warnings">
193  <ul>
194    {foreach from=$setup_warnings item=warning}
195    <li>{$warning}</li>
196    {/foreach}
197  </ul>
198  <div class="hideButton" style="text-align:center"><a href="{$hide_warnings_link}">{'Hide'|@translate}</a></div>
199</div>
200  {/if}
201
202
203<form id="uploadForm" enctype="multipart/form-data" method="post" action="{$form_action}">
204    <fieldset class="selectAlbum">
205      <legend>{'Drop into album'|@translate}</legend>
206
207      <span id="albumSelection" style="display:none">
208      <select data-selectize="categories" data-value="{$selected_category|@json_encode|escape:html}"
209        data-default="first" name="category" style="width:400px"></select>
210      <br>{'... or '|@translate}</span>
211      <a href="#" data-add-album="category" title="{'create a new album'|@translate}">{'create a new album'|@translate}</a>
212    </fieldset>
213
214    <p class="showFieldset" style="display:none"><a id="showPermissions" href="#">{'Manage Permissions'|@translate}</a></p>
215
216    <fieldset id="permissions" style="display:none">
217      <legend>{'Who can see these photos?'|@translate}</legend>
218
219      <select name="level" size="1">
220        {html_options options=$level_options selected=$level_options_selected}
221      </select>
222    </fieldset>
223
224    <fieldset class="selectFiles" style="display:none">
225      <legend>{'Select files'|@translate}</legend>
226 
227    {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}
228
229    <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>
230
231    <p id="uploadWarnings">
232{'Maximum file size: %sB.'|@translate:$upload_max_filesize_shorthand}
233{'Allowed file types: %s.'|@translate:$upload_file_types}
234  {if isset($max_upload_resolution)}
235{'Approximate maximum resolution: %dM pixels (that\'s %dx%d pixels).'|@translate:$max_upload_resolution:$max_upload_width:$max_upload_height}
236  {/if}
237    </p>
238
239
240        <div id="uploader">
241                <p>Your browser doesn't have HTML5 support.</p>
242        </div>
243
244    </fieldset>
245
246</form>
247
248<fieldset style="display:none">
249  <legend>{'Uploaded Photos'|@translate}</legend>
250  <div id="uploadedPhotos"></div>
251</fieldset>
252
253{/if} {* $setup_errors *}
254
255</div> <!-- photosAddContent -->
Note: See TracBrowser for help on using the repository browser.