source: trunk/admin/themes/default/template/batch_manager_global.tpl @ 8422

Revision 8422, 20.6 KB checked in by plg, 9 years ago (diff)

feature 2092 added: Batch Manager can filter all photos with no tag

feature 1866 added: Batch Manager can synchronize metadata

Line 
1{include file='include/tag_selection.inc.tpl'}
2{include file='include/datepicker.inc.tpl'}
3
4{footer_script}{literal}
5  pwg_initialization_datepicker("#date_creation_day", "#date_creation_month", "#date_creation_year", "#date_creation_linked_date", "#date_creation_action_set");
6{/literal}{/footer_script}
7
8{combine_script id='jquery.fcbkcomplete' load='footer' require='jquery' path='themes/default/js/plugins/jquery.fcbkcomplete.js'}
9
10{footer_script require='jquery.fcbkcomplete'}{literal}
11jQuery(document).ready(function() {
12  jQuery("#tags").fcbkcomplete({
13    json_url: "admin.php?fckb_tags=1",
14    cache: false,
15    filter_case: false,
16    filter_hide: true,
17    firstselected: true,
18    filter_selected: true,
19    maxitems: 100,
20    newel: true
21  });
22});
23{/literal}{/footer_script}
24
25{footer_script}
26var nb_thumbs_page = {$nb_thumbs_page};
27var nb_thumbs_set = {$nb_thumbs_set};
28var applyOnDetails_pattern = "{'on the %d selected photos'|@translate}";
29
30var selectedMessage_pattern = "{'%d of %d photos selected'|@translate}";
31var selectedMessage_none = "{'No photo selected, %d photos in current set'|@translate}";
32var selectedMessage_all = "{'All %d photos are selected'|@translate}";
33{literal}
34function str_repeat(i, m) {
35        for (var o = []; m > 0; o[--m] = i);
36        return o.join('');
37}
38
39function sprintf() {
40        var i = 0, a, f = arguments[i++], o = [], m, p, c, x, s = '';
41        while (f) {
42                if (m = /^[^\x25]+/.exec(f)) {
43                        o.push(m[0]);
44                }
45                else if (m = /^\x25{2}/.exec(f)) {
46                        o.push('%');
47                }
48                else if (m = /^\x25(?:(\d+)\$)?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-fosuxX])/.exec(f)) {
49                        if (((a = arguments[m[1] || i++]) == null) || (a == undefined)) {
50                                throw('Too few arguments.');
51                        }
52                        if (/[^s]/.test(m[7]) && (typeof(a) != 'number')) {
53                                throw('Expecting number but found ' + typeof(a));
54                        }
55                        switch (m[7]) {
56                                case 'b': a = a.toString(2); break;
57                                case 'c': a = String.fromCharCode(a); break;
58                                case 'd': a = parseInt(a); break;
59                                case 'e': a = m[6] ? a.toExponential(m[6]) : a.toExponential(); break;
60                                case 'f': a = m[6] ? parseFloat(a).toFixed(m[6]) : parseFloat(a); break;
61                                case 'o': a = a.toString(8); break;
62                                case 's': a = ((a = String(a)) && m[6] ? a.substring(0, m[6]) : a); break;
63                                case 'u': a = Math.abs(a); break;
64                                case 'x': a = a.toString(16); break;
65                                case 'X': a = a.toString(16).toUpperCase(); break;
66                        }
67                        a = (/[def]/.test(m[7]) && m[2] && a >= 0 ? '+'+ a : a);
68                        c = m[3] ? m[3] == '0' ? '0' : m[3].charAt(1) : ' ';
69                        x = m[5] - String(a).length - s.length;
70                        p = m[5] ? str_repeat(c, x) : '';
71                        o.push(s + (m[4] ? a + p : p + a));
72                }
73                else {
74                        throw('Huh ?!');
75                }
76                f = f.substring(m[0].length);
77        }
78        return o.join('');
79}
80
81$(document).ready(function() {
82  function checkPermitAction() {
83    var nbSelected = 0;
84    if ($("input[name=setSelected]").is(':checked')) {
85      nbSelected = nb_thumbs_set;
86    }
87    else {
88      $(".thumbnails input[type=checkbox]").each(function() {
89         if ($(this).is(':checked')) {
90           nbSelected++;
91         }
92      });
93    }
94
95    if (nbSelected == 0) {
96      $("#permitAction").hide();
97      $("#forbidAction").show();
98    }
99    else {
100      $("#permitAction").show();
101      $("#forbidAction").hide();
102    }
103
104    $("#applyOnDetails").text(
105      sprintf(
106        applyOnDetails_pattern,
107        nbSelected
108      )
109    );
110
111    // display the number of currently selected photos in the "Selection" fieldset
112    if (nbSelected == 0) {
113      $("#selectedMessage").text(
114        sprintf(
115          selectedMessage_none,
116          nb_thumbs_set
117        )
118      );
119    }
120    else if (nbSelected == nb_thumbs_set) {
121      $("#selectedMessage").text(
122        sprintf(
123          selectedMessage_all,
124          nb_thumbs_set
125        )
126      );
127    }
128    else {
129      $("#selectedMessage").text(
130        sprintf(
131          selectedMessage_pattern,
132          nbSelected,
133          nb_thumbs_set
134        )
135      );
136    }
137  }
138
139  $('img.thumbnail').tipTip({
140    'delay' : 0,
141    'fadeIn' : 200,
142    'fadeOut' : 200,
143  });
144
145  $("[id^=action_]").hide();
146
147  $("select[name=selectAction]").click(function () {
148    $("[id^=action_]").hide();
149    $("#action_"+$(this).attr("value")).show();
150  });
151
152  $(".wrap1 label").click(function () {
153    $("input[name=setSelected]").attr('checked', false);
154
155    var wrap2 = $(this).children(".wrap2");
156    var checkbox = $(this).children("input[type=checkbox]");
157
158    if ($(checkbox).is(':checked')) {
159      $(wrap2).addClass("thumbSelected");
160    }
161    else {
162      $(wrap2).removeClass('thumbSelected');
163    }
164
165    checkPermitAction();
166  });
167
168  $("#selectAll").click(function () {
169    $(".thumbnails label").each(function() {
170      var wrap2 = $(this).children(".wrap2");
171      var checkbox = $(this).children("input[type=checkbox]");
172
173      $(checkbox).attr('checked', true);
174      $(wrap2).addClass("thumbSelected");
175    });
176
177    checkPermitAction();
178
179    return false;
180  });
181
182  $("#selectNone").click(function () {
183    $("input[name=setSelected]").attr('checked', false);
184
185    $(".thumbnails label").each(function() {
186      var wrap2 = $(this).children(".wrap2");
187      var checkbox = $(this).children("input[type=checkbox]");
188
189      $(checkbox).attr('checked', false);
190      $(wrap2).removeClass("thumbSelected");
191    });
192    checkPermitAction();
193    return false;
194  });
195
196  $("#selectInvert").click(function () {
197    $("input[name=setSelected]").attr('checked', false);
198
199    $(".thumbnails label").each(function() {
200      var wrap2 = $(this).children(".wrap2");
201      var checkbox = $(this).children("input[type=checkbox]");
202
203      $(checkbox).attr('checked', !$(checkbox).is(':checked'));
204
205      if ($(checkbox).is(':checked')) {
206        $(wrap2).addClass("thumbSelected");
207      }
208      else {
209        $(wrap2).removeClass('thumbSelected');
210      }
211    });
212    checkPermitAction();
213    return false;
214  });
215
216  $("#selectSet").click(function () {
217    $("input[name=setSelected]").attr('checked', true);
218    checkPermitAction();
219    return false;
220  });
221
222  $("input[name=remove_author]").click(function () {
223    if ($(this).is(':checked')) {
224      $("input[name=author]").hide();
225    }
226    else {
227      $("input[name=author]").show();
228    }
229  });
230
231  $("input[name=remove_title]").click(function () {
232    if ($(this).is(':checked')) {
233      $("input[name=title]").hide();
234    }
235    else {
236      $("input[name=title]").show();
237    }
238  });
239
240  $("input[name=remove_date_creation]").click(function () {
241    if ($(this).is(':checked')) {
242      $("#set_date_creation").hide();
243    }
244    else {
245      $("#set_date_creation").show();
246    }
247  });
248
249  $("select[name=selectAction]").change(function() {
250    if ($(this).val() != -1) {
251      $("#applyActionBlock").show();
252    }
253    else {
254      $("#applyActionBlock").hide();
255    }
256  });
257
258  $(".removeFilter").click(function () {
259    var filter = $(this).parent('li').attr("id");
260    filter_disable(filter);
261
262    return false;
263  });
264
265  function filter_enable(filter) {
266    /* show the filter*/
267    $("#"+filter).show();
268
269    /* check the checkbox to declare we use this filter */
270    $("input[type=checkbox][name="+filter+"_use]").attr("checked", true);
271
272    /* forbid to select this filter in the addFilter list */
273    $("#addFilter").children("option[value="+filter+"]").attr("disabled", "disabled");
274  }
275
276  $("#addFilter").change(function () {
277    var filter = $(this).attr("value");
278    filter_enable(filter);
279    $(this).attr("value", -1);
280  });
281
282  function filter_disable(filter) {
283    /* hide the filter line */
284    $("#"+filter).hide();
285
286    /* uncheck the checkbox to declare we do not use this filter */
287    $("input[name="+filter+"_use]").removeAttr("checked");
288
289    /* give the possibility to show it again */
290    $("#addFilter").children("option[value="+filter+"]").removeAttr("disabled");
291  }
292
293  $("#removeFilters").click(function() {
294    $("#filterList li").each(function() {
295      var filter = $(this).attr("id");
296      filter_disable(filter);
297    });
298    return false;
299  });
300
301  checkPermitAction()
302});
303{/literal}{/footer_script}
304
305{literal}
306<style>
307#action p {text-align:left;}
308.bulkAction {text-align:left;margin:15px 0;padding:0;}
309#action_del_tags ul.tagSelection {margin:0 !important; width:620px;}
310#selectAction {}
311#checkActions {text-align:left; margin:0 0 20px 0;}
312.content ul.thumbnails span.wrap1 {margin:5px}
313.content ul.thumbnails span.wrap2 {border:0;background-color:#ddd;}
314.content ul.thumbnails span.wrap2:hover {background-color:#7CBA0F;}
315.thumbSelected {background-color:#C2F5C2 !important}
316
317#selectedMessage {background-color:#C2F5C2; padding:5px; -moz-border-radius:5px;}
318#selectSet a {border-bottom:1px dotted}
319#applyOnDetails {font-style:italic;}
320
321.actionButtons {text-align:left;}
322#filterList {padding-left:5px;}
323#filterList li {margin-bottom:5px; list-style-type:none;}
324a.removeFilter {background: url(admin/themes/default/icon/remove_filter.png) no-repeat top left;width:7px;height:7px;display:inline-block}
325a.removeFilter:hover {background: url(admin/themes/default/icon/remove_filter_hover.png); border:none;}
326.removeFilter span {display:none}
327#applyFilterBlock {margin-top:20px;}
328.useFilterCheckbox {display:none}
329</style>
330{/literal}
331
332<h2>{'Batch Manager'|@translate}</h2>
333
334  <form action="{$F_ACTION}" method="post">
335
336  <fieldset>
337    <legend>{'Filter'|@translate}</legend>
338
339    <ul id="filterList">
340      <li id="filter_prefilter" {if !isset($filter.prefilter)}style="display:none"{/if}>
341        <a href="#" class="removeFilter" title="{'remove this filter'|@translate}"><span>[x]</span></a>
342        <input type="checkbox" name="filter_prefilter_use" class="useFilterCheckbox" {if isset($filter.prefilter)}checked="checked"{/if}>
343        {'predefined filter'|@translate}
344        <select name="filter_prefilter">
345          <option value="caddie" {if $filter.prefilter eq 'caddie'}selected="selected"{/if}>{'caddie'|@translate}</option>
346          <option value="last import" {if $filter.prefilter eq 'last import'}selected="selected"{/if}>{'last import'|@translate}</option>
347          <option value="with no album" {if $filter.prefilter eq 'with no album'}selected="selected"{/if}>{'with no album'|@translate}</option> -->
348{if $ENABLE_SYNCHRONIZATION}
349          <option value="with no virtual album" {if $filter.prefilter eq 'with no virtual album'}selected="selected"{/if}>{'with no virtual album'|@translate}</option>
350{/if}
351          <option value="with no tag" {if $filter.prefilter eq 'with no tag'}selected="selected"{/if}>{'with no tag'|@translate}</option>
352          <option value="duplicates" {if $filter.prefilter eq 'duplicates'}selected="selected"{/if}>{'duplicates'|@translate}</option>
353        </select>
354      </li>
355      <li id="filter_category" {if !isset($filter.category)}style="display:none"{/if}>
356        <a href="#" class="removeFilter" title="remove this filter"><span>[x]</span></a>
357        <input type="checkbox" name="filter_category_use" class="useFilterCheckbox" {if isset($filter.category)}checked="checked"{/if}>
358        {'album'|@translate}
359        <select style="width:400px" name="filter_category" size="1">
360          {html_options options=$filter_category_options selected=$filter_category_options_selected}
361        </select>
362        <label><input type="checkbox" name="filter_category_recursive" {if isset($filter.category_recursive)}checked="checked"{/if}> {'include child albums'|@translate}</label>
363      </li>
364      <li id="filter_level" {if !isset($filter.level)}style="display:none"{/if}>
365        <a href="#" class="removeFilter" title="remove this filter"><span>[x]</span></a>
366        <input type="checkbox" name="filter_level_use" class="useFilterCheckbox" {if isset($filter.level)}checked="checked"{/if}>
367        {'Who can see these photos?'|@translate}
368        <select name="filter_level" size="1">
369          {html_options options=$filter_level_options selected=$filter_level_options_selected}
370        </select>
371      </li>
372    </ul>
373
374    <p class="actionButtons" style="">
375      <select id="addFilter">
376        <option value="-1">{'Add a filter'|@translate}</option>
377        <option disabled="disabled">------------------</option>
378        <option value="filter_prefilter">{'predefined filter'|@translate}</option>
379        <option value="filter_category">{'album'|@translate}</option>
380        <option value="filter_level">{'Who can see these photos?'|@translate}</option>
381      </select>
382<!--      <input id="removeFilters" class="submit" type="submit" value="Remove all filters" name="removeFilters"> -->
383      <a id="removeFilters" href="">{'Remove all filters'|@translate}</a>
384    </p>
385
386    <p class="actionButtons" id="applyFilterBlock">
387      <input id="applyFilter" class="submit" type="submit" value="{'Refresh photo set'|@translate}" name="submitFilter">
388    </p>
389
390  </fieldset>
391
392  <fieldset>
393
394    <legend>{'Selection'|@translate}</legend>
395
396  {if !empty($thumbnails)}
397  <p id="checkActions">
398    {'Select:'|@translate}
399{if $nb_thumbs_set > $nb_thumbs_page}
400    <a href="#" id="selectAll">{'The whole page'|@translate}</a>,
401    <a href="#" id="selectSet">{'The whole set'|@translate}</a>,
402{else}
403    <a href="#" id="selectAll">{'All'|@translate}</a>,
404{/if}
405    <a href="#" id="selectNone">{'None'|@translate}</a>,
406    <a href="#" id="selectInvert">{'Invert'|@translate}</a>
407
408    <span id="selectedMessage"></span>
409
410    <input type="checkbox" name="setSelected" style="display:none" {if count($selection) == $nb_thumbs_set}checked="checked"{/if}>
411  </p>
412
413    <ul class="thumbnails">
414      {foreach from=$thumbnails item=thumbnail}
415        {if in_array($thumbnail.ID, $selection)}
416          {assign var='isSelected' value=true}
417        {else}
418          {assign var='isSelected' value=false}
419        {/if}
420
421      <li><span class="wrap1">
422          <label>
423            <span class="wrap2{if $isSelected} thumbSelected{/if}">
424        {if $thumbnail.LEVEL > 0}
425        <em class="levelIndicatorB">{$pwg->l10n($pwg->sprintf('Level %d',$thumbnail.LEVEL))}</em>
426        <em class="levelIndicatorF" title="{'Who can see these photos?'|@translate} : ">{$pwg->l10n($pwg->sprintf('Level %d',$thumbnail.LEVEL))}</em>
427        {/if}
428            <span>
429              <img src="{$thumbnail.TN_SRC}"
430                 alt="{$thumbnail.FILE}"
431                 title="{$thumbnail.TITLE|@escape:'html'}"
432                 class="thumbnail">
433            </span></span>
434            <input type="checkbox" name="selection[]" value="{$thumbnail.ID}" {if $isSelected}checked="checked"{/if}>
435          </label>
436          </span>
437      </li>
438      {/foreach}
439    </ul>
440
441  {if !empty($navbar) }
442  <div style="clear:both;">
443
444    <div style="float:left">
445    {include file='navigation_bar.tpl'|@get_extent:'navbar'}
446    </div>
447
448    <div style="float:right;margin-top:10px;">{'display'|@translate}
449      <a href="{$U_DISPLAY}&amp;display=20">20</a>
450      &middot; <a href="{$U_DISPLAY}&amp;display=50">50</a>
451      &middot; <a href="{$U_DISPLAY}&amp;display=100">100</a>
452      &middot; <a href="{$U_DISPLAY}&amp;display=all">{'all'|@translate}</a>
453      {'thumbnails per page'|@translate}
454    </div>
455  </div>
456  {/if}
457
458  {else}
459  <div>{'No photo in the current set.'|@translate}</div>
460  {/if}
461  </fieldset>
462
463  <fieldset id="action">
464
465    <legend>{'Action'|@translate}</legend>
466      <div id="forbidAction"{if count($selection) != 0}style="display:none"{/if}>{'No photo selected, no action possible.'|@translate}</div>
467      <div id="permitAction"{if count($selection) == 0}style="display:none"{/if}>
468
469    <select name="selectAction">
470      <option value="-1">{'Choose an action'|@translate}</option>
471      <option disabled="disabled">------------------</option>
472  {if isset($show_delete_form) }
473      <option value="delete">{'Delete selected photos'|@translate}</option>
474  {/if}
475      <option value="associate">{'Associate to album'|@translate}</option>
476  {if !empty($dissociate_options)}
477      <option value="dissociate">{'Dissociate from album'|@translate}</option>
478  {/if}
479      <option value="add_tags">{'add tags'|@translate}</option>
480  {if !empty($DEL_TAG_SELECTION)}
481      <option value="del_tags">{'remove tags'|@translate}</option>
482  {/if}
483      <option value="author">{'Set author'|@translate}</option>
484      <option value="title">{'Set title'|@translate}</option>
485      <option value="date_creation">{'Set creation date'|@translate}</option>
486      <option value="level">{'Who can see these photos?'|@translate}</option>
487      <option value="metadata">{'synchronize metadata'|@translate}</option>
488  {if ($IN_CADDIE)}
489      <option value="remove_from_caddie">{'Remove from caddie'|@translate}</option>
490  {else}
491      <option value="add_to_caddie">{'add to caddie'|@translate}</option>
492  {/if}
493    </select>
494
495    <!-- delete -->
496    <div id="action_delete" class="bulkAction">
497    <p><label><input type="checkbox" name="confirm_deletion" value="1"> {'Are you sure?'|@translate}</label></p>
498    </div>
499
500    <!-- associate -->
501    <div id="action_associate" class="bulkAction">
502          <select style="width:400px" name="associate" size="1">
503            {html_options options=$associate_options }
504         </select>
505    </div>
506
507    <!-- dissociate -->
508    <div id="action_dissociate" class="bulkAction">
509          <select style="width:400px" name="dissociate" size="1">
510            {if !empty($dissociate_options)}{html_options options=$dissociate_options }{/if}
511          </select>
512    </div>
513
514
515    <!-- add_tags -->
516    <div id="action_add_tags" class="bulkAction">
517<select id="tags" name="add_tags">
518</select>
519    </div>
520
521    <!-- del_tags -->
522    <div id="action_del_tags" class="bulkAction">
523{$DEL_TAG_SELECTION}
524    </div>
525
526    <!-- author -->
527    <div id="action_author" class="bulkAction">
528    <label><input type="checkbox" name="remove_author"> {'remove author'|@translate}</label><br>
529    {assign var='authorDefaultValue' value='Type here the author name'|@translate}
530<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;">
531    </div>   
532
533    <!-- title -->
534    <div id="action_title" class="bulkAction">
535    <label><input type="checkbox" name="remove_title"> {'remove title'|@translate}</label><br>
536    {assign var='titleDefaultValue' value='Type here the title'|@translate}
537<input type="text" class="large" name="title" value="{$titleDefaultValue}" onfocus="this.value=(this.value=='{$titleDefaultValue}') ? '' : this.value;" onblur="this.value=(this.value=='') ? '{$titleDefaultValue}' : this.value;">
538    </div>
539
540    <!-- date_creation -->
541    <div id="action_date_creation" class="bulkAction">
542      <label><input type="checkbox" name="remove_date_creation"> {'remove creation date'|@translate}</label><br>
543      <div id="set_date_creation">
544          <select id="date_creation_day" name="date_creation_day">
545             <option value="0">--</option>
546            {section name=day start=1 loop=32}
547              <option value="{$smarty.section.day.index}" {if $smarty.section.day.index==$DATE_CREATION_DAY}selected="selected"{/if}>{$smarty.section.day.index}</option>
548            {/section}
549          </select>
550          <select id="date_creation_month" name="date_creation_month">
551            {html_options options=$month_list selected=$DATE_CREATION_MONTH}
552          </select>
553          <input id="date_creation_year"
554                 name="date_creation_year"
555                 type="text"
556                 size="4"
557                 maxlength="4"
558                 value="{$DATE_CREATION_YEAR}">
559          <input id="date_creation_linked_date" name="date_creation_linked_date" type="hidden" size="10" disabled="disabled">
560      </div>
561    </div>
562
563    <!-- level -->
564    <div id="action_level" class="bulkAction">
565        <select name="level" size="1">
566          {html_options options=$level_options selected=$level_options_selected}
567        </select>
568    </div>
569
570    <!-- metadata -->
571    <div id="action_metadata" class="bulkAction">
572    </div>
573
574    <p id="applyActionBlock" style="display:none" class="actionButtons">
575      <input id="applyAction" class="submit" type="submit" value="{'Apply action'|@translate}" name="submit"> <span id="applyOnDetails"></span></p>
576
577    </div> <!-- #permitAction -->
578  </fieldset>
579
580  </form>
Note: See TracBrowser for help on using the repository browser.