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

Last change on this file since 10354 was 10354, checked in by patdenice, 13 years ago

feature:2264
new trigger to add prefilter on batch manager

File size: 20.8 KB
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: true,
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]").change(function () {
148    $("[id^=action_]").hide();
149    $("#action_"+$(this).attr("value")).show();
150
151    if ($(this).val() != -1) {
152      $("#applyActionBlock").show();
153    }
154    else {
155      $("#applyActionBlock").hide();
156    }
157  });
158
159  $(".wrap1 label").click(function () {
160    $("input[name=setSelected]").attr('checked', false);
161
162    var wrap2 = $(this).children(".wrap2");
163    var checkbox = $(this).children("input[type=checkbox]");
164
165    if ($(checkbox).is(':checked')) {
166      $(wrap2).addClass("thumbSelected");
167    }
168    else {
169      $(wrap2).removeClass('thumbSelected');
170    }
171
172    checkPermitAction();
173  });
174
175  $("#selectAll").click(function () {
176    $("input[name=setSelected]").attr('checked', false);
177    selectPageThumbnails();
178    checkPermitAction();
179    return false;
180  });
181
182  function selectPageThumbnails() {
183    $(".thumbnails label").each(function() {
184      var wrap2 = $(this).children(".wrap2");
185      var checkbox = $(this).children("input[type=checkbox]");
186
187      $(checkbox).attr('checked', true);
188      $(wrap2).addClass("thumbSelected");
189    });
190  }
191
192  $("#selectNone").click(function () {
193    $("input[name=setSelected]").attr('checked', false);
194
195    $(".thumbnails label").each(function() {
196      var wrap2 = $(this).children(".wrap2");
197      var checkbox = $(this).children("input[type=checkbox]");
198
199      $(checkbox).attr('checked', false);
200      $(wrap2).removeClass("thumbSelected");
201    });
202    checkPermitAction();
203    return false;
204  });
205
206  $("#selectInvert").click(function () {
207    $("input[name=setSelected]").attr('checked', false);
208
209    $(".thumbnails label").each(function() {
210      var wrap2 = $(this).children(".wrap2");
211      var checkbox = $(this).children("input[type=checkbox]");
212
213      $(checkbox).attr('checked', !$(checkbox).is(':checked'));
214
215      if ($(checkbox).is(':checked')) {
216        $(wrap2).addClass("thumbSelected");
217      }
218      else {
219        $(wrap2).removeClass('thumbSelected');
220      }
221    });
222    checkPermitAction();
223    return false;
224  });
225
226  $("#selectSet").click(function () {
227    selectPageThumbnails();
228    $("input[name=setSelected]").attr('checked', true);
229    checkPermitAction();
230    return false;
231  });
232
233  $("input[name=remove_author]").click(function () {
234    if ($(this).is(':checked')) {
235      $("input[name=author]").hide();
236    }
237    else {
238      $("input[name=author]").show();
239    }
240  });
241
242  $("input[name=remove_title]").click(function () {
243    if ($(this).is(':checked')) {
244      $("input[name=title]").hide();
245    }
246    else {
247      $("input[name=title]").show();
248    }
249  });
250
251  $("input[name=remove_date_creation]").click(function () {
252    if ($(this).is(':checked')) {
253      $("#set_date_creation").hide();
254    }
255    else {
256      $("#set_date_creation").show();
257    }
258  });
259
260  $(".removeFilter").click(function () {
261    var filter = $(this).parent('li').attr("id");
262    filter_disable(filter);
263
264    return false;
265  });
266
267  function filter_enable(filter) {
268    /* show the filter*/
269    $("#"+filter).show();
270
271    /* check the checkbox to declare we use this filter */
272    $("input[type=checkbox][name="+filter+"_use]").attr("checked", true);
273
274    /* forbid to select this filter in the addFilter list */
275    $("#addFilter").children("option[value="+filter+"]").attr("disabled", "disabled");
276  }
277
278  $("#addFilter").change(function () {
279    var filter = $(this).attr("value");
280    filter_enable(filter);
281    $(this).attr("value", -1);
282  });
283
284  function filter_disable(filter) {
285    /* hide the filter line */
286    $("#"+filter).hide();
287
288    /* uncheck the checkbox to declare we do not use this filter */
289    $("input[name="+filter+"_use]").removeAttr("checked");
290
291    /* give the possibility to show it again */
292    $("#addFilter").children("option[value="+filter+"]").removeAttr("disabled");
293  }
294
295  $("#removeFilters").click(function() {
296    $("#filterList li").each(function() {
297      var filter = $(this).attr("id");
298      filter_disable(filter);
299    });
300    return false;
301  });
302
303  checkPermitAction()
304});
305
306jQuery(window).load(function() {
307  var max_dim = 20;
308  $(".thumbnails img").each(function () {
309    if ($(this).height() > (max_dim-20))
310      max_dim = $(this).height() + 20;
311    if ($(this).width() > (max_dim-20))
312      max_dim = $(this).width() + 20;
313    $("ul.thumbnails span, ul.thumbnails label").css('width', max_dim+'px').css('height', max_dim+'px');
314  });
315});
316{/literal}{/footer_script}
317
318<div id="batchManagerGlobal">
319
320<h2>{'Batch Manager'|@translate}</h2>
321
322  <form action="{$F_ACTION}" method="post">
323
324  <fieldset>
325    <legend>{'Filter'|@translate}</legend>
326
327    <ul id="filterList">
328      <li id="filter_prefilter" {if !isset($filter.prefilter)}style="display:none"{/if}>
329        <a href="#" class="removeFilter" title="{'remove this filter'|@translate}"><span>[x]</span></a>
330        <input type="checkbox" name="filter_prefilter_use" class="useFilterCheckbox" {if isset($filter.prefilter)}checked="checked"{/if}>
331        {'predefined filter'|@translate}
332        <select name="filter_prefilter">
333          <option value="caddie" {if $filter.prefilter eq 'caddie'}selected="selected"{/if}>{'caddie'|@translate}</option>
334          <option value="last import" {if $filter.prefilter eq 'last import'}selected="selected"{/if}>{'last import'|@translate}</option>
335          <option value="with no album" {if $filter.prefilter eq 'with no album'}selected="selected"{/if}>{'with no album'|@translate}</option>
336{if $ENABLE_SYNCHRONIZATION}
337          <option value="with no virtual album" {if $filter.prefilter eq 'with no virtual album'}selected="selected"{/if}>{'with no virtual album'|@translate}</option>
338{/if}
339          <option value="with no tag" {if $filter.prefilter eq 'with no tag'}selected="selected"{/if}>{'with no tag'|@translate}</option>
340          <option value="duplicates" {if $filter.prefilter eq 'duplicates'}selected="selected"{/if}>{'duplicates'|@translate}</option>
341          <option value="all photos" {if $filter.prefilter eq 'all photos'}selected="selected"{/if}>{'All'|@translate}</option>
342          {foreach from=$bulk_manager_plugins_prefilters item=plugin_prefilter}
343          <option value="{$plugin_prefilter.ID}" {if $filter.prefilter eq $plugin_prefilter.ID}selected="selected"{/if}>{$plugin_prefilter.NAME}</option>
344          {/foreach}
345        </select>
346      </li>
347      <li id="filter_category" {if !isset($filter.category)}style="display:none"{/if}>
348        <a href="#" class="removeFilter" title="remove this filter"><span>[x]</span></a>
349        <input type="checkbox" name="filter_category_use" class="useFilterCheckbox" {if isset($filter.category)}checked="checked"{/if}>
350        {'album'|@translate}
351        <select style="width:400px" name="filter_category" size="1">
352          {html_options options=$filter_category_options selected=$filter_category_options_selected}
353        </select>
354        <label><input type="checkbox" name="filter_category_recursive" {if isset($filter.category_recursive)}checked="checked"{/if}> {'include child albums'|@translate}</label>
355      </li>
356      <li id="filter_level" {if !isset($filter.level)}style="display:none"{/if}>
357        <a href="#" class="removeFilter" title="remove this filter"><span>[x]</span></a>
358        <input type="checkbox" name="filter_level_use" class="useFilterCheckbox" {if isset($filter.level)}checked="checked"{/if}>
359        {'Who can see these photos?'|@translate}
360        <select name="filter_level" size="1">
361          {html_options options=$filter_level_options selected=$filter_level_options_selected}
362        </select>
363      </li>
364    </ul>
365
366    <p class="actionButtons" style="">
367      <select id="addFilter">
368        <option value="-1">{'Add a filter'|@translate}</option>
369        <option disabled="disabled">------------------</option>
370        <option value="filter_prefilter">{'predefined filter'|@translate}</option>
371        <option value="filter_category">{'album'|@translate}</option>
372        <option value="filter_level">{'Who can see these photos?'|@translate}</option>
373      </select>
374<!--      <input id="removeFilters" class="submit" type="submit" value="Remove all filters" name="removeFilters"> -->
375      <a id="removeFilters" href="">{'Remove all filters'|@translate}</a>
376    </p>
377
378    <p class="actionButtons" id="applyFilterBlock">
379      <input id="applyFilter" class="submit" type="submit" value="{'Refresh photo set'|@translate}" name="submitFilter">
380    </p>
381
382  </fieldset>
383
384  <fieldset>
385
386    <legend>{'Selection'|@translate}</legend>
387
388  {if !empty($thumbnails)}
389  <p id="checkActions">
390    {'Select:'|@translate}
391{if $nb_thumbs_set > $nb_thumbs_page}
392    <a href="#" id="selectAll">{'The whole page'|@translate}</a>,
393    <a href="#" id="selectSet">{'The whole set'|@translate}</a>,
394{else}
395    <a href="#" id="selectAll">{'All'|@translate}</a>,
396{/if}
397    <a href="#" id="selectNone">{'None'|@translate}</a>,
398    <a href="#" id="selectInvert">{'Invert'|@translate}</a>
399
400    <span id="selectedMessage"></span>
401
402    <input type="checkbox" name="setSelected" style="display:none" {if count($selection) == $nb_thumbs_set}checked="checked"{/if}>
403  </p>
404
405    <ul class="thumbnails">
406      {foreach from=$thumbnails item=thumbnail}
407        {if in_array($thumbnail.ID, $selection)}
408          {assign var='isSelected' value=true}
409        {else}
410          {assign var='isSelected' value=false}
411        {/if}
412
413      <li><span class="wrap1">
414          <label>
415            <span class="wrap2{if $isSelected} thumbSelected{/if}">
416        {if $thumbnail.LEVEL > 0}
417        <em class="levelIndicatorB">{$pwg->l10n($pwg->sprintf('Level %d',$thumbnail.LEVEL))}</em>
418        <em class="levelIndicatorF" title="{'Who can see these photos?'|@translate} : ">{$pwg->l10n($pwg->sprintf('Level %d',$thumbnail.LEVEL))}</em>
419        {/if}
420            <span>
421              <img src="{$thumbnail.TN_SRC}"
422                 alt="{$thumbnail.FILE}"
423                 title="{$thumbnail.TITLE|@escape:'html'}"
424                 class="thumbnail">
425            </span></span>
426            <input type="checkbox" name="selection[]" value="{$thumbnail.ID}" {if $isSelected}checked="checked"{/if}>
427          </label>
428          </span>
429      </li>
430      {/foreach}
431    </ul>
432
433  {if !empty($navbar) }
434  <div style="clear:both;">
435
436    <div style="float:left">
437    {include file='navigation_bar.tpl'|@get_extent:'navbar'}
438    </div>
439
440    <div style="float:right;margin-top:10px;">{'display'|@translate}
441      <a href="{$U_DISPLAY}&amp;display=20">20</a>
442      &middot; <a href="{$U_DISPLAY}&amp;display=50">50</a>
443      &middot; <a href="{$U_DISPLAY}&amp;display=100">100</a>
444      &middot; <a href="{$U_DISPLAY}&amp;display=all">{'all'|@translate}</a>
445      {'photos per page'|@translate}
446    </div>
447  </div>
448  {/if}
449
450  {else}
451  <div>{'No photo in the current set.'|@translate}</div>
452  {/if}
453  </fieldset>
454
455  <fieldset id="action">
456
457    <legend>{'Action'|@translate}</legend>
458      <div id="forbidAction"{if count($selection) != 0}style="display:none"{/if}>{'No photo selected, no action possible.'|@translate}</div>
459      <div id="permitAction"{if count($selection) == 0}style="display:none"{/if}>
460
461    <select name="selectAction">
462      <option value="-1">{'Choose an action'|@translate}</option>
463      <option disabled="disabled">------------------</option>
464  {if isset($show_delete_form) }
465      <option value="delete">{'Delete selected photos'|@translate}</option>
466  {/if}
467      <option value="associate">{'Associate to album'|@translate}</option>
468  {if !empty($dissociate_options)}
469      <option value="dissociate">{'Dissociate from album'|@translate}</option>
470  {/if}
471      <option value="add_tags">{'add tags'|@translate}</option>
472  {if !empty($DEL_TAG_SELECTION)}
473      <option value="del_tags">{'remove tags'|@translate}</option>
474  {/if}
475      <option value="author">{'Set author'|@translate}</option>
476      <option value="title">{'Set title'|@translate}</option>
477      <option value="date_creation">{'Set creation date'|@translate}</option>
478      <option value="level">{'Who can see these photos?'|@translate}</option>
479      <option value="metadata">{'synchronize metadata'|@translate}</option>
480  {if ($IN_CADDIE)}
481      <option value="remove_from_caddie">{'Remove from caddie'|@translate}</option>
482  {else}
483      <option value="add_to_caddie">{'add to caddie'|@translate}</option>
484  {/if}
485  {if !empty($element_set_global_plugins_actions)}
486    {foreach from=$element_set_global_plugins_actions item=action}
487      <option value="{$action.ID}">{$action.NAME}</option>
488    {/foreach}
489  {/if}
490    </select>
491
492    <!-- delete -->
493    <div id="action_delete" class="bulkAction">
494    <p><label><input type="checkbox" name="confirm_deletion" value="1"> {'Are you sure?'|@translate}</label></p>
495    </div>
496
497    <!-- associate -->
498    <div id="action_associate" class="bulkAction">
499          <select style="width:400px" name="associate" size="1">
500            {html_options options=$associate_options }
501         </select>
502    </div>
503
504    <!-- dissociate -->
505    <div id="action_dissociate" class="bulkAction">
506          <select style="width:400px" name="dissociate" size="1">
507            {if !empty($dissociate_options)}{html_options options=$dissociate_options }{/if}
508          </select>
509    </div>
510
511
512    <!-- add_tags -->
513    <div id="action_add_tags" class="bulkAction">
514<select id="tags" name="add_tags">
515</select>
516    </div>
517
518    <!-- del_tags -->
519    <div id="action_del_tags" class="bulkAction">
520{$DEL_TAG_SELECTION}
521    </div>
522
523    <!-- author -->
524    <div id="action_author" class="bulkAction">
525    <label><input type="checkbox" name="remove_author"> {'remove author'|@translate}</label><br>
526    {assign var='authorDefaultValue' value='Type here the author name'|@translate}
527<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;">
528    </div>   
529
530    <!-- title -->
531    <div id="action_title" class="bulkAction">
532    <label><input type="checkbox" name="remove_title"> {'remove title'|@translate}</label><br>
533    {assign var='titleDefaultValue' value='Type here the title'|@translate}
534<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;">
535    </div>
536
537    <!-- date_creation -->
538    <div id="action_date_creation" class="bulkAction">
539      <label><input type="checkbox" name="remove_date_creation"> {'remove creation date'|@translate}</label><br>
540      <div id="set_date_creation">
541          <select id="date_creation_day" name="date_creation_day">
542             <option value="0">--</option>
543            {section name=day start=1 loop=32}
544              <option value="{$smarty.section.day.index}" {if $smarty.section.day.index==$DATE_CREATION_DAY}selected="selected"{/if}>{$smarty.section.day.index}</option>
545            {/section}
546          </select>
547          <select id="date_creation_month" name="date_creation_month">
548            {html_options options=$month_list selected=$DATE_CREATION_MONTH}
549          </select>
550          <input id="date_creation_year"
551                 name="date_creation_year"
552                 type="text"
553                 size="4"
554                 maxlength="4"
555                 value="{$DATE_CREATION_YEAR}">
556          <input id="date_creation_linked_date" name="date_creation_linked_date" type="hidden" size="10" disabled="disabled">
557      </div>
558    </div>
559
560    <!-- level -->
561    <div id="action_level" class="bulkAction">
562        <select name="level" size="1">
563          {html_options options=$level_options selected=$level_options_selected}
564        </select>
565    </div>
566
567    <!-- metadata -->
568    <div id="action_metadata" class="bulkAction">
569    </div>
570
571    <!-- plugins -->
572{if !empty($element_set_global_plugins_actions)}
573  {foreach from=$element_set_global_plugins_actions item=action}
574    <div id="action_{$action.ID}" class="bulkAction">
575    {if !empty($action.CONTENT)}{$action.CONTENT}{/if}
576    </div>
577  {/foreach}
578{/if}
579
580    <p id="applyActionBlock" style="display:none" class="actionButtons">
581      <input id="applyAction" class="submit" type="submit" value="{'Apply action'|@translate}" name="submit"> <span id="applyOnDetails"></span></p>
582
583    </div> <!-- #permitAction -->
584  </fieldset>
585
586  </form>
587
588</div> <!-- #batchManagerGlobal -->
Note: See TracBrowser for help on using the repository browser.