source: extensions/bulk_manager/element_set_global.tpl @ 6756

Last change on this file since 6756 was 6756, checked in by plg, 14 years ago

initial release for Piwigo 2.2 bulk manager

File size: 15.9 KB
Line 
1{include file='include/tag_selection.inc.tpl'}
2{include file='include/datepicker.inc.tpl'}
3
4{literal}
5<script type="text/javascript">
6  pwg_initialization_datepicker("#date_creation_day", "#date_creation_month", "#date_creation_year", "#date_creation_linked_date", "#date_creation_action_set");
7</script>
8{/literal}
9
10{known_script id="jquery.fcbkcomplete" src=$ROOT_URL|@cat:"themes/default/js/plugins/jquery.fcbkcomplete.js"}
11<script type="text/javascript">
12var nb_thumbs_page = {$nb_thumbs_page};
13var nb_thumbs_set = {$nb_thumbs_set};
14var applyOnDetails_pattern = "{'on the %d selected photos'|@translate}";
15{literal}
16function str_repeat(i, m) {
17        for (var o = []; m > 0; o[--m] = i);
18        return o.join('');
19}
20
21function sprintf() {
22        var i = 0, a, f = arguments[i++], o = [], m, p, c, x, s = '';
23        while (f) {
24                if (m = /^[^\x25]+/.exec(f)) {
25                        o.push(m[0]);
26                }
27                else if (m = /^\x25{2}/.exec(f)) {
28                        o.push('%');
29                }
30                else if (m = /^\x25(?:(\d+)\$)?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-fosuxX])/.exec(f)) {
31                        if (((a = arguments[m[1] || i++]) == null) || (a == undefined)) {
32                                throw('Too few arguments.');
33                        }
34                        if (/[^s]/.test(m[7]) && (typeof(a) != 'number')) {
35                                throw('Expecting number but found ' + typeof(a));
36                        }
37                        switch (m[7]) {
38                                case 'b': a = a.toString(2); break;
39                                case 'c': a = String.fromCharCode(a); break;
40                                case 'd': a = parseInt(a); break;
41                                case 'e': a = m[6] ? a.toExponential(m[6]) : a.toExponential(); break;
42                                case 'f': a = m[6] ? parseFloat(a).toFixed(m[6]) : parseFloat(a); break;
43                                case 'o': a = a.toString(8); break;
44                                case 's': a = ((a = String(a)) && m[6] ? a.substring(0, m[6]) : a); break;
45                                case 'u': a = Math.abs(a); break;
46                                case 'x': a = a.toString(16); break;
47                                case 'X': a = a.toString(16).toUpperCase(); break;
48                        }
49                        a = (/[def]/.test(m[7]) && m[2] && a >= 0 ? '+'+ a : a);
50                        c = m[3] ? m[3] == '0' ? '0' : m[3].charAt(1) : ' ';
51                        x = m[5] - String(a).length - s.length;
52                        p = m[5] ? str_repeat(c, x) : '';
53                        o.push(s + (m[4] ? a + p : p + a));
54                }
55                else {
56                        throw('Huh ?!');
57                }
58                f = f.substring(m[0].length);
59        }
60        return o.join('');
61}
62
63$(document).ready(function() {
64  function checkPermitAction() {
65    var nbSelected = 0;
66    if ($("input[name=setSelected]").is(':checked')) {
67      nbSelected = nb_thumbs_set;
68    }
69    else {
70      $(".thumbnails input[type=checkbox]").each(function() {
71         if ($(this).is(':checked')) {
72           nbSelected++;
73         }
74      });
75    }
76
77    if (nbSelected == 0) {
78      $("#permitAction").hide();
79      $("#forbidAction").show();
80    }
81    else {
82      $("#permitAction").show();
83      $("#forbidAction").hide();
84    }
85
86    $("#applyOnDetails").text(
87      sprintf(
88        applyOnDetails_pattern,
89        nbSelected
90      )
91    );
92  }
93
94  $('img.thumbnail').tipTip({
95    'delay' : 0,
96    'fadeIn' : 200,
97    'fadeOut' : 200,
98  });
99
100
101  $("#tags").fcbkcomplete({
102    json_url: "admin.php?fckb_tags=1",
103    cache: false,
104    filter_case: false,
105    filter_hide: true,
106    firstselected: true,
107    filter_selected: true,
108    maxitems: 100,
109    newel: true
110  });
111
112  $("[id^=action_]").hide();
113
114  $("select[name=selectAction]").click(function () {
115    $("[id^=action_]").hide();
116    $("#action_"+$(this).attr("value")).show();
117  });
118
119  $(".wrap1 label").click(function () {
120    $("#selectSetMessage").hide();
121    $("#setSelected").hide();
122    $("input[name=setSelected]").attr('checked', false);
123
124    var wrap2 = $(this).children(".wrap2");
125    var checkbox = $(this).children("input[type=checkbox]");
126
127    if ($(checkbox).is(':checked')) {
128      $(wrap2).addClass("thumbSelected");
129    }
130    else {
131      $(wrap2).removeClass('thumbSelected');
132    }
133
134    checkPermitAction();
135  });
136
137  $("#selectAll").click(function () {
138    $(".thumbnails label").each(function() {
139      var wrap2 = $(this).children(".wrap2");
140      var checkbox = $(this).children("input[type=checkbox]");
141
142      $(checkbox).attr('checked', true);
143      $(wrap2).addClass("thumbSelected");
144    });
145
146    if (nb_thumbs_page < nb_thumbs_set) {
147      $("#selectSetMessage").show();
148    }
149
150    checkPermitAction();
151
152    return false;
153  });
154
155  $("#selectNone").click(function () {
156    $("#selectSetMessage").hide();
157    $("#setSelected").hide();
158    $("input[name=setSelected]").attr('checked', false);
159
160    $(".thumbnails label").each(function() {
161      var wrap2 = $(this).children(".wrap2");
162      var checkbox = $(this).children("input[type=checkbox]");
163
164      $(checkbox).attr('checked', false);
165      $(wrap2).removeClass("thumbSelected");
166    });
167    checkPermitAction();
168    return false;
169  });
170
171  $("#selectInvert").click(function () {
172    $("#selectSetMessage").hide();
173    $("#setSelected").hide();
174    $("input[name=setSelected]").attr('checked', false);
175
176    $(".thumbnails label").each(function() {
177      var wrap2 = $(this).children(".wrap2");
178      var checkbox = $(this).children("input[type=checkbox]");
179
180      $(checkbox).attr('checked', !$(checkbox).is(':checked'));
181
182      if ($(checkbox).is(':checked')) {
183        $(wrap2).addClass("thumbSelected");
184      }
185      else {
186        $(wrap2).removeClass('thumbSelected');
187      }
188    });
189    checkPermitAction();
190    return false;
191  });
192
193  $("#selectSet").click(function () {
194    $("#selectSetMessage").hide();
195    $("#setSelected").show();
196    $("input[name=setSelected]").attr('checked', true);
197    checkPermitAction();
198    return false;
199  });
200
201  $("input[name=remove_author]").click(function () {
202    if ($(this).is(':checked')) {
203      $("input[name=author]").hide();
204    }
205    else {
206      $("input[name=author]").show();
207    }
208  });
209
210  $("input[name=remove_name]").click(function () {
211    if ($(this).is(':checked')) {
212      $("input[name=name]").hide();
213    }
214    else {
215      $("input[name=name]").show();
216    }
217  });
218
219  $("input[name=remove_date_creation]").click(function () {
220    if ($(this).is(':checked')) {
221      $("#set_date_creation").hide();
222    }
223    else {
224      $("#set_date_creation").show();
225    }
226  });
227
228  $("select[name=selectAction]").change(function() {
229    if ($(this).val() != -1) {
230      $("#applyActionBlock").show();
231    }
232    else {
233      $("#applyActionBlock").hide();
234    }
235  });
236
237  checkPermitAction()
238});
239</script>
240
241<style>
242#action p {text-align:left;}
243.bulkAction {text-align:left;margin:15px 0;padding:0;}
244#action_del_tags ul.tagSelection {margin:0 !important; width:620px;}
245#selectAction {}
246#checkActions {text-align:left; margin:0 0 20px 0;}
247.content ul.thumbnails span.wrap1 {margin:5px}
248.content ul.thumbnails span.wrap2 {border:0;background-color:#ddd;}
249.content ul.thumbnails span.wrap2:hover {background-color:#7CBA0F;}
250.thumbSelected {background-color:#C2F5C2 !important}
251
252#selectSetMessage, #setSelected {background-color:#C2F5C2; padding:5px; -moz-border-radius:5px; display:none;}
253#selectSet a {border-bottom:1px dotted}
254#applyOnDetails {font-style:italic;}
255</style>
256{/literal}
257
258<h2>{'Batch management'|@translate}</h2>
259
260<h3>{$CATEGORIES_NAV}</h3>
261
262{if !empty($thumbnails)}
263  <p style="text-align:center;">
264    {'global mode'|@translate}
265    | <a href="{$U_UNIT_MODE}">{'unit mode'|@translate}</a>
266  </p>
267
268  <fieldset style="display:none;">
269
270    <legend>{'Display options'|@translate}</legend>
271
272    <p>{'elements per page'|@translate}:
273        <a href="{$U_DISPLAY}&amp;display=20">20</a>
274      | <a href="{$U_DISPLAY}&amp;display=50">50</a>
275      | <a href="{$U_DISPLAY}&amp;display=100">100</a>
276      | <a href="{$U_DISPLAY}&amp;display=all">{'all'|@translate}</a>
277    </p>
278
279  </fieldset>
280
281<!--  <fieldset> -->
282<!--    <legend>{'Filter'|@translate}</legend> -->
283<!--  </fieldset> -->
284
285  <form action="{$F_ACTION}" method="post">
286
287  <fieldset>
288
289    <legend>{'Selection'|@translate}</legend>
290
291  <p id="checkActions">
292    {'Select:'|@translate}
293    <a href="#" id="selectAll">{'All'|@translate}</a>,
294    <a href="#" id="selectNone">{'None'|@translate}</a>,
295    <a href="#" id="selectInvert">{'Invert'|@translate}</a>
296    <span id="selectSetMessage" {if count($selection) == $nb_thumbs_page}style="display:inline"{/if}>
297      {'All %u photos of this page are selected.'|@translate|@sprintf:$nb_thumbs_page}
298      <a href="#" id="selectSet">{'Select all %d photos of the current set.'|@translate|@sprintf:$nb_thumbs_set}</a>
299    </span>
300    <span id="setSelected" {if count($selection) == $nb_thumbs_set}style="display:inline"{/if}>
301      {'All %u photos of the current are selected.'|@translate|@sprintf:$nb_thumbs_set}
302      <input type="checkbox" name="setSelected" style="display:none" {if count($selection) == $nb_thumbs_set}checked="checked"{/if}>
303    </span>
304  </p>
305
306  {if !empty($thumbnails)}
307    <ul class="thumbnails">
308      {foreach from=$thumbnails item=thumbnail}
309        {if in_array($thumbnail.ID, $selection)}
310          {assign var='isSelected' value=true}
311        {else}
312          {assign var='isSelected' value=false}
313        {/if}
314
315      <li><span class="wrap1">
316          <label>
317            <span class="wrap2{if $isSelected} thumbSelected{/if}">
318        {if $thumbnail.LEVEL > 0}
319        <em class="levelIndicatorB">{$pwg->l10n($pwg->sprintf('Level %d',$thumbnail.LEVEL))}</em>
320        <em class="levelIndicatorF" title="{'Who can see these photos?'|@translate} : ">{$pwg->l10n($pwg->sprintf('Level %d',$thumbnail.LEVEL))}</em>
321        {/if}
322            <span>
323              <img src="{$thumbnail.TN_SRC}"
324                 alt="{$thumbnail.FILE}"
325                 title="{$thumbnail.TITLE|@escape:'html'}"
326                 class="thumbnail">
327            </span></span>
328            <input type="checkbox" name="selection[]" value="{$thumbnail.ID}" {if $isSelected}checked="checked"{/if}>
329          </label>
330          </span>
331      </li>
332      {/foreach}
333    </ul>
334  {/if}
335
336  {if !empty($navbar) }
337  <div style="clear:both;">
338
339    <div style="float:left">
340    {include file='navigation_bar.tpl'|@get_extent:'navbar'}
341    </div>
342
343    <div style="float:right;margin-top:10px;">{'display'|@translate}
344      <a href="{$U_DISPLAY}&amp;display=20">20</a>
345      &middot; <a href="{$U_DISPLAY}&amp;display=50">50</a>
346      &middot; <a href="{$U_DISPLAY}&amp;display=100">100</a>
347      &middot; <a href="{$U_DISPLAY}&amp;display=all">{'all'|@translate}</a>
348      thumbnails per page
349    </div>
350  </div>
351  {/if}
352
353  </fieldset>
354
355  <fieldset id="action">
356
357    <legend>{'Action'|@translate}</legend>
358      <div id="forbidAction"{if count($selection) != 0}style="display:none"{/if}>No photo selected, no action possible.</div>
359      <div id="permitAction"{if count($selection) == 0}style="display:none"{/if}>
360
361    <select name="selectAction">
362      <option value="-1">Choose an action</option>
363      <option disabled="disabled">------------------</option>
364  {if isset($show_delete_form) }
365      <option value="delete">{'Delete selected photos'|@translate}</option>
366  {/if}
367      <option value="associate">{'associate to category'|@translate}</option>
368  {if !empty($dissociate_options)}
369      <option value="dissociate">{'dissociate from category'|@translate}</option>
370  {/if}
371      <option value="add_tags">{'add tags'|@translate}</option>
372  {if !empty($DEL_TAG_SELECTION)}
373      <option value="del_tags">{'remove tags'|@translate}</option>
374  {/if}
375      <option value="author">{'Set author'|@translate}</option>
376      <option value="name">{'Set title'|@translate}</option>
377      <option value="date_creation">{'Set creation date'|@translate}</option>
378      <option value="level">{'Who can see these photos?'|@translate}</option>
379  {if ($IN_CADDIE)}
380      <option value="remove_from_caddie">{'Remove from caddie'|@translate}</option>
381  {else}
382      <option value="add_to_caddie">{'Add to caddie'|@translate}</option>
383  {/if}
384    </select>
385
386    <!-- delete -->
387    <div id="action_delete" class="bulkAction">
388{if $ENABLE_SYNCHRONIZATION}
389    <p style="font-style:italic;width:500px;">{'Note: photo deletion does not apply to photos added by synchronization. For photos added by synchronization, remove them from the filesystem and then perform another synchronization.'|@translate}</p>
390{/if}
391    <p><label><input type="checkbox" name="confirm_deletion" value="1"> {'Are you sure?'|@translate}</label></p>
392    </div>
393
394    <!-- associate -->
395    <div id="action_associate" class="bulkAction">
396          <select style="width:400px" name="associate" size="1">
397            {html_options options=$associate_options }
398         </select>
399    </div>
400
401    <!-- dissociate -->
402    <div id="action_dissociate" class="bulkAction">
403          <select style="width:400px" name="dissociate" size="1">
404            {if !empty($dissociate_options)}{html_options options=$dissociate_options }{/if}
405          </select>
406    </div>
407
408
409    <!-- add_tags -->
410    <div id="action_add_tags" class="bulkAction">
411<select id="tags" name="add_tags">
412</select>
413    </div>
414
415    <!-- del_tags -->
416    <div id="action_del_tags" class="bulkAction">
417{$DEL_TAG_SELECTION}
418    </div>
419
420    <!-- author -->
421    <div id="action_author" class="bulkAction">
422    <label><input type="checkbox" name="remove_author"> remove author</label><br>
423    {assign var='authorDefaultValue' value='Type here the author name'}
424<input type="text" class="large" name="author" value="{$authorDefaultValue}" onfocus="this.value=(this.value=='{$authorDefaultValue}') ? '' : this.value;" onblur="this.value=(this.value=='') ? '{$authorDefaultValue}' : this.value;">
425    </div>   
426
427    <!-- name -->
428    <div id="action_name" class="bulkAction">
429    <label><input type="checkbox" name="remove_name"> remove name</label><br>
430    {assign var='nameDefaultValue' value='Type here the name name'}
431<input type="text" class="large" name="name" value="{$nameDefaultValue}" onfocus="this.value=(this.value=='{$nameDefaultValue}') ? '' : this.value;" onblur="this.value=(this.value=='') ? '{$nameDefaultValue}' : this.value;">
432    </div>
433
434    <!-- date_creation -->
435    <div id="action_date_creation" class="bulkAction">
436      <label><input type="checkbox" name="remove_date_creation"> remove creation date</label><br>
437      <div id="set_date_creation">
438          <select id="date_creation_day" name="date_creation_day">
439             <option value="0">--</option>
440            {section name=day start=1 loop=32}
441              <option value="{$smarty.section.day.index}" {if $smarty.section.day.index==$DATE_CREATION_DAY}selected="selected"{/if}>{$smarty.section.day.index}</option>
442            {/section}
443          </select>
444          <select id="date_creation_month" name="date_creation_month">
445            {html_options options=$month_list selected=$DATE_CREATION_MONTH}
446          </select>
447          <input id="date_creation_year"
448                 name="date_creation_year"
449                 type="text"
450                 size="4"
451                 maxlength="4"
452                 value="{$DATE_CREATION_YEAR}">
453          <input id="date_creation_linked_date" name="date_creation_linked_date" type="hidden" size="10" disabled="disabled">
454      </div>
455    </div>
456
457    <!-- level -->
458    <div id="action_level" class="bulkAction">
459        <select name="level" size="1">
460          {html_options options=$level_options selected=$level_options_selected}
461        </select>
462    </div>
463
464    <p id="applyActionBlock" style="display:none">
465      <input id="applyAction" class="submit" type="submit" value="{'Apply action'|@translate}" name="submit" {$TAG_INPUT_ENABLED}> <span id="applyOnDetails"></span></p>
466
467    </div> <!-- #permitAction -->
468  </fieldset>
469
470  </form>
471
472{else}
473  <div class="infos"><p>{'Caddie is currently empty'|@translate}</p></div>
474{/if}
Note: See TracBrowser for help on using the repository browser.