source: extensions/bulk_manager/element_set_global.tpl @ 6772

Revision 6772, 19.9 KB checked in by plg, 10 years ago (diff)

feature 1802 added: filtering system. Only 3 filters available, more to come
later. Ability to add/remove filters on the fly.

When an administrator displays the "caddie" content, it means bulk manager
with a single filter "prefilter=caddie". Same principle for the photos of a
given album.

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  $(".removeFilter").click(function () {
238    var filter = $(this).parent('li').attr("id");
239    filter_disable(filter);
240
241    return false;
242  });
243
244  function filter_enable(filter) {
245    /* show the filter*/
246    $("#"+filter).show();
247
248    /* check the checkbox to declare we use this filter */
249    $("input[type=checkbox][name="+filter+"_use]").attr("checked", true);
250
251    /* forbid to select this filter in the addFilter list */
252    $("#addFilter").children("option[value="+filter+"]").attr("disabled", "disabled");
253  }
254
255  $("#addFilter").change(function () {
256    var filter = $(this).attr("value");
257    filter_enable(filter);
258    $(this).attr("value", -1);
259  });
260
261  function filter_disable(filter) {
262    /* hide the filter line */
263    $("#"+filter).hide();
264
265    /* uncheck the checkbox to declare we do not use this filter */
266    $("input[name="+filter+"_use]").removeAttr("checked");
267
268    /* give the possibility to show it again */
269    $("#addFilter").children("option[value="+filter+"]").removeAttr("disabled");
270  }
271
272  $("#removeFilters").click(function() {
273    $("#filterList li").each(function() {
274      var filter = $(this).attr("id");
275      filter_disable(filter);
276    });
277    return false;
278  });
279
280  checkPermitAction()
281});
282</script>
283
284<style>
285#action p {text-align:left;}
286.bulkAction {text-align:left;margin:15px 0;padding:0;}
287#action_del_tags ul.tagSelection {margin:0 !important; width:620px;}
288#selectAction {}
289#checkActions {text-align:left; margin:0 0 20px 0;}
290.content ul.thumbnails span.wrap1 {margin:5px}
291.content ul.thumbnails span.wrap2 {border:0;background-color:#ddd;}
292.content ul.thumbnails span.wrap2:hover {background-color:#7CBA0F;}
293.thumbSelected {background-color:#C2F5C2 !important}
294
295#selectSetMessage, #setSelected {background-color:#C2F5C2; padding:5px; -moz-border-radius:5px; display:none;}
296#selectSet a {border-bottom:1px dotted}
297#applyOnDetails {font-style:italic;}
298
299.actionButtons {text-align:left;}
300#filterList {padding-left:5px;}
301#filterList li {margin-bottom:5px; list-style-type:none;}
302a.removeFilter {background: url(plugins/bulk_manager/remove_filter.png) no-repeat top left;width:7px;height:7px;display:inline-block}
303a.removeFilter:hover {background: url(plugins/bulk_manager/remove_filter_hover.png); border:none;}
304.removeFilter span {display:none}
305#applyFilterBlock {margin-top:20px;}
306.useFilterCheckbox {display:none}
307</style>
308{/literal}
309
310  <p style="float:left; font-size:90%;margin:5px 0 0 0;padding:0;">
311    <a href="{$U_UNIT_MODE}">Switch to unit mode</a>
312  </p>
313
314<h2>{'Batch management'|@translate}</h2>
315
316  <form action="{$F_ACTION}" method="post">
317
318  <fieldset>
319    <legend>{'Filter'|@translate}</legend>
320
321    <ul id="filterList">
322      <li id="filter_prefilter" {if !isset($filter.prefilter)}style="display:none"{/if}>
323        <a href="#" class="removeFilter" title="remove this filter"><span>[x]</span></a>
324        <input type="checkbox" name="filter_prefilter_use" class="useFilterCheckbox" {if isset($filter.prefilter)}checked="checked"{/if}>
325        predefined filter
326        <select name="filter_prefilter">
327          <option value="caddie" {if $filter.prefilter eq 'caddie'}selected="selected"{/if}>caddie</option>
328          <option value="last import" {if $filter.prefilter eq 'last import'}selected="selected"{/if}>last import</option>
329<!--          <option value="with no album">with no album</option> -->
330<!--          <option value="with no virtual album">with no virtual album</option> -->
331<!--          <option value="with no tag">with no tag</option> -->
332        </select>
333      </li>
334      <li id="filter_category" {if !isset($filter.category)}style="display:none"{/if}>
335        <a href="#" class="removeFilter" title="remove this filter"><span>[x]</span></a>
336        <input type="checkbox" name="filter_category_use" class="useFilterCheckbox" {if isset($filter.category)}checked="checked"{/if}>
337        album
338        <select style="width:400px" name="filter_category" size="1">
339          {html_options options=$filter_category_options selected=$filter_category_options_selected}
340        </select>
341        <label><input type="checkbox" name="filter_category_recursive" {if isset($filter.category_recursive)}checked="checked"{/if}> {'include child albums'|@translate}</label>
342      </li>
343      <li id="filter_level" {if !isset($filter.level)}style="display:none"{/if}>
344        <a href="#" class="removeFilter" title="remove this filter"><span>[x]</span></a>
345        <input type="checkbox" name="filter_level_use" class="useFilterCheckbox" {if isset($filter.level)}checked="checked"{/if}>
346        {'Who can see these photos?'|@translate}
347        <select name="filter_level" size="1">
348          {html_options options=$filter_level_options selected=$filter_level_options_selected}
349        </select>
350      </li>
351    </ul>
352
353    <p class="actionButtons" style="">
354      <select id="addFilter">
355        <option value="-1">Add a filter</option>
356        <option disabled="disabled">------------------</option>
357        <option value="filter_prefilter">predefined filter</option>
358        <option value="filter_category">album</option>
359        <option value="filter_level">{'Who can see these photos?'|@translate}</option>
360      </select>
361<!--      <input id="removeFilters" class="submit" type="submit" value="Remove all filters" name="removeFilters"> -->
362      <a id="removeFilters" href="">Remove all filters</a>
363    </p>
364
365    <p class="actionButtons" id="applyFilterBlock">
366      <input id="applyFilter" class="submit" type="submit" value="Refresh photo set" name="submitFilter">
367    </p>
368
369  </fieldset>
370
371  <fieldset>
372
373    <legend>{'Selection'|@translate}</legend>
374
375  {if !empty($thumbnails)}
376  <p id="checkActions">
377    {'Select:'|@translate}
378    <a href="#" id="selectAll">{'All'|@translate}</a>,
379    <a href="#" id="selectNone">{'None'|@translate}</a>,
380    <a href="#" id="selectInvert">{'Invert'|@translate}</a>
381    <span id="selectSetMessage" {if count($selection) == $nb_thumbs_page}style="display:inline"{/if}>
382      {'All %u photos of this page are selected.'|@translate|@sprintf:$nb_thumbs_page}
383      <a href="#" id="selectSet">{'Select all %d photos of the current set.'|@translate|@sprintf:$nb_thumbs_set}</a>
384    </span>
385    <span id="setSelected" {if count($selection) == $nb_thumbs_set}style="display:inline"{/if}>
386      {'All %u photos of the current are selected.'|@translate|@sprintf:$nb_thumbs_set}
387      <input type="checkbox" name="setSelected" style="display:none" {if count($selection) == $nb_thumbs_set}checked="checked"{/if}>
388    </span>
389  </p>
390
391    <ul class="thumbnails">
392      {foreach from=$thumbnails item=thumbnail}
393        {if in_array($thumbnail.ID, $selection)}
394          {assign var='isSelected' value=true}
395        {else}
396          {assign var='isSelected' value=false}
397        {/if}
398
399      <li><span class="wrap1">
400          <label>
401            <span class="wrap2{if $isSelected} thumbSelected{/if}">
402        {if $thumbnail.LEVEL > 0}
403        <em class="levelIndicatorB">{$pwg->l10n($pwg->sprintf('Level %d',$thumbnail.LEVEL))}</em>
404        <em class="levelIndicatorF" title="{'Who can see these photos?'|@translate} : ">{$pwg->l10n($pwg->sprintf('Level %d',$thumbnail.LEVEL))}</em>
405        {/if}
406            <span>
407              <img src="{$thumbnail.TN_SRC}"
408                 alt="{$thumbnail.FILE}"
409                 title="{$thumbnail.TITLE|@escape:'html'}"
410                 class="thumbnail">
411            </span></span>
412            <input type="checkbox" name="selection[]" value="{$thumbnail.ID}" {if $isSelected}checked="checked"{/if}>
413          </label>
414          </span>
415      </li>
416      {/foreach}
417    </ul>
418
419  {if !empty($navbar) }
420  <div style="clear:both;">
421
422    <div style="float:left">
423    {include file='navigation_bar.tpl'|@get_extent:'navbar'}
424    </div>
425
426    <div style="float:right;margin-top:10px;">{'display'|@translate}
427      <a href="{$U_DISPLAY}&amp;display=20">20</a>
428      &middot; <a href="{$U_DISPLAY}&amp;display=50">50</a>
429      &middot; <a href="{$U_DISPLAY}&amp;display=100">100</a>
430      &middot; <a href="{$U_DISPLAY}&amp;display=all">{'all'|@translate}</a>
431      thumbnails per page
432    </div>
433  </div>
434  {/if}
435
436  {else}
437  <div>No photo in the current set.</div>
438  {/if}
439  </fieldset>
440
441  <fieldset id="action">
442
443    <legend>{'Action'|@translate}</legend>
444      <div id="forbidAction"{if count($selection) != 0}style="display:none"{/if}>No photo selected, no action possible.</div>
445      <div id="permitAction"{if count($selection) == 0}style="display:none"{/if}>
446
447    <select name="selectAction">
448      <option value="-1">Choose an action</option>
449      <option disabled="disabled">------------------</option>
450  {if isset($show_delete_form) }
451      <option value="delete">{'Delete selected photos'|@translate}</option>
452  {/if}
453      <option value="associate">{'associate to category'|@translate}</option>
454  {if !empty($dissociate_options)}
455      <option value="dissociate">{'dissociate from category'|@translate}</option>
456  {/if}
457      <option value="add_tags">{'add tags'|@translate}</option>
458  {if !empty($DEL_TAG_SELECTION)}
459      <option value="del_tags">{'remove tags'|@translate}</option>
460  {/if}
461      <option value="author">{'Set author'|@translate}</option>
462      <option value="name">{'Set title'|@translate}</option>
463      <option value="date_creation">{'Set creation date'|@translate}</option>
464      <option value="level">{'Who can see these photos?'|@translate}</option>
465  {if ($IN_CADDIE)}
466      <option value="remove_from_caddie">{'Remove from caddie'|@translate}</option>
467  {else}
468      <option value="add_to_caddie">{'Add to caddie'|@translate}</option>
469  {/if}
470    </select>
471
472    <!-- delete -->
473    <div id="action_delete" class="bulkAction">
474{if $ENABLE_SYNCHRONIZATION}
475    <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>
476{/if}
477    <p><label><input type="checkbox" name="confirm_deletion" value="1"> {'Are you sure?'|@translate}</label></p>
478    </div>
479
480    <!-- associate -->
481    <div id="action_associate" class="bulkAction">
482          <select style="width:400px" name="associate" size="1">
483            {html_options options=$associate_options }
484         </select>
485    </div>
486
487    <!-- dissociate -->
488    <div id="action_dissociate" class="bulkAction">
489          <select style="width:400px" name="dissociate" size="1">
490            {if !empty($dissociate_options)}{html_options options=$dissociate_options }{/if}
491          </select>
492    </div>
493
494
495    <!-- add_tags -->
496    <div id="action_add_tags" class="bulkAction">
497<select id="tags" name="add_tags">
498</select>
499    </div>
500
501    <!-- del_tags -->
502    <div id="action_del_tags" class="bulkAction">
503{$DEL_TAG_SELECTION}
504    </div>
505
506    <!-- author -->
507    <div id="action_author" class="bulkAction">
508    <label><input type="checkbox" name="remove_author"> remove author</label><br>
509    {assign var='authorDefaultValue' value='Type here the author name'}
510<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;">
511    </div>   
512
513    <!-- name -->
514    <div id="action_name" class="bulkAction">
515    <label><input type="checkbox" name="remove_name"> remove name</label><br>
516    {assign var='nameDefaultValue' value='Type here the name name'}
517<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;">
518    </div>
519
520    <!-- date_creation -->
521    <div id="action_date_creation" class="bulkAction">
522      <label><input type="checkbox" name="remove_date_creation"> remove creation date</label><br>
523      <div id="set_date_creation">
524          <select id="date_creation_day" name="date_creation_day">
525             <option value="0">--</option>
526            {section name=day start=1 loop=32}
527              <option value="{$smarty.section.day.index}" {if $smarty.section.day.index==$DATE_CREATION_DAY}selected="selected"{/if}>{$smarty.section.day.index}</option>
528            {/section}
529          </select>
530          <select id="date_creation_month" name="date_creation_month">
531            {html_options options=$month_list selected=$DATE_CREATION_MONTH}
532          </select>
533          <input id="date_creation_year"
534                 name="date_creation_year"
535                 type="text"
536                 size="4"
537                 maxlength="4"
538                 value="{$DATE_CREATION_YEAR}">
539          <input id="date_creation_linked_date" name="date_creation_linked_date" type="hidden" size="10" disabled="disabled">
540      </div>
541    </div>
542
543    <!-- level -->
544    <div id="action_level" class="bulkAction">
545        <select name="level" size="1">
546          {html_options options=$level_options selected=$level_options_selected}
547        </select>
548    </div>
549
550    <p id="applyActionBlock" style="display:none" class="actionButtons">
551      <input id="applyAction" class="submit" type="submit" value="{'Apply action'|@translate}" name="submit" {$TAG_INPUT_ENABLED}> <span id="applyOnDetails"></span></p>
552
553    </div> <!-- #permitAction -->
554  </fieldset>
555
556  </form>
Note: See TracBrowser for help on using the repository browser.