1 [% INCLUDE 'doc-head-open.inc' %]
2 <title>Koha › Tools › MARC modification templates</title>
3 [% INCLUDE 'doc-head-close.inc' %]
5 <script type="text/javascript">
7 $(document).ready(function() {
8 $('#select_template').find("input:submit").hide();
9 $('#select_template').change(function() {
10 $('#select_template').submit();
12 $("span.match_regex_prefix" ).hide();
13 $("span.match_regex_suffix" ).hide();
15 $("#add_action").submit(function(){
16 var action = $("#action").val();
17 if ( action == 'move_field' || action == 'copy_field' ) {
18 if ( $("#from_subfield").val().length != $("#to_subfield").val().length ) {
19 alert(_("Both subfield values should be filled or empty."));
22 if ( $("#to_field").val().length <= 0 ) {
23 alert(_("The destination should be filled."));
27 if ( action == 'update_field' ) {
28 if ( $("#from_subfield").val().length <= 0 ) {
29 alert(_("The source subfield should be filled for update."));
33 if ( $("#from_field").val().length <= 0 ) {
34 alert(_("The source field should be filled."));
39 $("#conditional_field,#from_field").change(function(){
47 function updateAllEvery(){
48 if ( $("#conditional_field").is(":visible") ) {
49 if ( $("#conditional_field").val() == $("#from_field").val() && $("#from_field").val().length > 0 ) {
50 $("#field_number option[value='0']").html(_("Every"));
52 $("#field_number option[value='0']").html(_("All"));
57 function onActionChange(selectObj) {
58 // get the index of the selected option
59 var idx = selectObj.selectedIndex;
61 // get the value of the selected option
62 var action = selectObj.options[idx].value;
66 show('field_number_block');
67 hide('with_value_block');
68 hide('to_field_block');
72 hide('field_number_block');
73 show('with_value_block');
74 hide('to_field_block');
78 show('field_number_block');
79 hide('with_value_block');
80 show('to_field_block');
84 show('field_number_block');
85 hide('with_value_block');
86 show('to_field_block');
92 function onConditionalChange(selectObj) {
93 // get the index of the selected option
94 var idx = selectObj.selectedIndex;
96 // get the value of the selected option
97 var action = selectObj.options[idx].value;
101 hide('conditional_block');
106 show('conditional_block');
111 function onConditionalComparisonChange(selectObj) {
112 // get the index of the selected option
113 var idx = selectObj.selectedIndex;
115 // get the value of the selected option
116 var action = selectObj.options[idx].value;
121 show('conditional_comparison_block');
125 hide('conditional_comparison_block');
130 function onToFieldRegexChange( checkboxObj ) {
131 if ( checkboxObj.checked ) {
132 show('to_field_regex_value_block');
134 hide('to_field_regex_value_block');
138 function onConditionalRegexChange( checkboxObj ) {
139 if ( checkboxObj.checked ) {
140 $("span.match_regex_prefix" ).show();
141 $("span.match_regex_suffix" ).show();
143 $("span.match_regex_prefix" ).hide();
144 $("span.match_regex_suffix" ).hide();
148 function show(eltId) {
149 elt = document.getElementById( eltId );
150 elt.style.display='inline';
153 function hide(eltId) {
154 clearFormElements( eltId );
155 elt = document.getElementById( eltId );
156 elt.style.display='none';
159 function clearFormElements(divId) {
160 myBlock = document.getElementById( divId );
162 var inputElements = myBlock.getElementsByTagName( "input" );
163 for (var i = 0; i < inputElements.length; i++) {
164 switch( inputElements[i].type ) {
166 inputElements[i].value = '';
169 inputElements[i].checked = false;
174 var selectElements = myBlock.getElementsByTagName( "select" );
175 for (var i = 0; i < selectElements.length; i++) {
176 selectElements[i].selectedIndex = 0;
181 function confirmDelete() {
182 var agree = confirm(_("Are you sure you wish to delete this template?"));
186 var modaction_legend_innerhtml;
187 var action_submit_value;
189 function editAction( mmta_id, ordering, action, field_number, from_field, from_subfield, field_value, to_field,
190 to_subfield, to_regex_search, to_regex_replace, to_regex_modifiers, conditional, conditional_field, conditional_subfield,
191 conditional_comparison, conditional_value, conditional_regex, description
193 document.getElementById('mmta_id').value = mmta_id;
195 setSelectByValue( 'action', action );
196 document.getElementById('action').onchange();
198 setSelectByValue( 'field_number', field_number );
200 document.getElementById('from_field').value = from_field;
201 document.getElementById('from_subfield').value = from_subfield;
202 document.getElementById('field_value').value = field_value;
203 document.getElementById('to_field').value = to_field;
204 document.getElementById('to_subfield').value = to_subfield;
205 $("#to_regex_search").val(to_regex_search);
206 $("#to_regex_replace").val(to_regex_replace);
207 $("#to_regex_modifiers").val(to_regex_modifiers);
209 document.getElementById('to_field_regex').checked = conditional_regex.length;
210 document.getElementById('to_field_regex').onchange();
212 setSelectByValue( 'conditional', conditional );
213 document.getElementById('conditional').onchange();
215 document.getElementById('conditional_field').value = conditional_field;
216 document.getElementById('conditional_subfield').value = conditional_subfield;
218 setSelectByValue( 'conditional_comparison', conditional_comparison );
219 document.getElementById('conditional_comparison').onchange();
221 document.getElementById('conditional_value').value = conditional_value;
223 document.getElementById('conditional_regex').checked = parseInt( conditional_regex );
225 document.getElementById('description').value = description;
227 window.modaction_legend_innerhtml = document.getElementById('modaction_legend').innerHTML;
228 document.getElementById('modaction_legend').innerHTML = _("Edit action %s").format(ordering);
230 window.action_submit_value = document.getElementById('action_submit').value;
231 document.getElementById('action_submit').value = _("Update action");
236 function cancelEditAction() {
237 document.getElementById('mmta_id').value = '';
239 setSelectByValue( 'action', 'delete_field' );
240 document.getElementById('action').onchange();
242 document.getElementById('from_field').value = '';
243 document.getElementById('from_subfield').value = '';
244 document.getElementById('field_value').value = '';
245 document.getElementById('to_field').value = '';
246 document.getElementById('to_subfield').value = '';
247 $("#to_regex_search").val("");
248 $("#to_regex_replace").val("");
249 $("#to_regex_modifiers").val("");
251 document.getElementById('to_field_regex').checked = false;
252 document.getElementById('to_field_regex').onchange();
254 setSelectByValue( 'conditional', '' );
255 document.getElementById('conditional').onchange();
257 document.getElementById('conditional_field').value = '';
258 document.getElementById('conditional_subfield').value = '';
260 setSelectByValue( 'conditional_comparison', '' );
261 document.getElementById('conditional_comparison').onchange();
263 document.getElementById('conditional_value').value = '';
265 document.getElementById('conditional_regex').checked = false;
267 document.getElementById('modaction_legend').innerHTML = window.modaction_legend_innerhtml;
268 document.getElementById('action_submit').value = window.action_submit_value;
273 function setSelectByValue( selectId, value ) {
274 s = document.getElementById( selectId );
276 for ( i = 0; i < s.options.length; i++ ) {
277 if ( s.options[i].value == value ) {
288 [% INCLUDE 'header.inc' %]
289 [% INCLUDE 'cat-search.inc' %]
291 <div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> › <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a> › MARC modification templates</div>
293 <div id="doc3" class="yui-t2">
297 <h2>MARC modification templates</h2>
300 [% IF error == 'no_from_field' %]
301 <div class="dialog message">Error: no field value specified.</div>
305 [% IF ( TemplatesLoop ) %]
307 <form method="get" action="/cgi-bin/koha/tools/marc_modification_templates.pl" id="select_template">
308 <label for="select_template">Template: </label>
309 <select name="template_id" id="select_template" style="width:20em;">
310 [% FOREACH TemplatesLoo IN TemplatesLoop %]
311 [% IF ( TemplatesLoo.selected ) %]
312 <option value="[% TemplatesLoo.template_id %]" selected="selected"> [% TemplatesLoo.name %]</option>
314 <option value="[% TemplatesLoo.template_id %]"> [% TemplatesLoo.name %]</option>
318 <input type="hidden" name="op" value="select_template">
319 <input type="submit" value="Go" />
322 <form method="get" action="/cgi-bin/koha/tools/marc_modification_templates.pl" id="delete_template">
323 <input type="hidden" name="template_id" value="[% template_id %]" />
324 <input type="hidden" name="op" value="delete_template">
325 <input type="submit" value="Delete template" onClick="return confirmDelete()" />
329 [% IF ( ActionsLoop ) %]
331 <caption>Actions for this template</caption>
334 <th>Change order</th>
342 [% FOREACH ActionsLoo IN ActionsLoop %]
344 <td style="white-space:nowrap;">
345 <a title="Move action up" href="marc_modification_templates.pl?op=move_action&where=up&template_id=[% ActionsLoo.template_id %]&mmta_id=[% ActionsLoo.mmta_id %]">
346 <img src="[% interface %]/[% theme %]/img/go-up.png" border="0" alt="Go up" />
349 <a title="Move action to top" href="marc_modification_templates.pl?op=move_action&where=top&template_id=[% ActionsLoo.template_id %]&mmta_id=[% ActionsLoo.mmta_id %]">
350 <img src="[% interface %]/[% theme %]/img/go-top.png" border="0" alt="Go top" />
353 <a title="Move action to bottom" href="marc_modification_templates.pl?op=move_action&where=bottom&template_id=[% ActionsLoo.template_id %]&mmta_id=[% ActionsLoo.mmta_id %]">
354 <img src="[% interface %]/[% theme %]/img/go-bottom.png" border="0" alt="Go bottom" />
357 <a title="Move action down" href="marc_modification_templates.pl?op=move_action&where=down&template_id=[% ActionsLoo.template_id %]&mmta_id=[% ActionsLoo.mmta_id %]">
358 <img src="[% interface %]/[% theme %]/img/go-down.png" border="0" alt="Go down" />
362 <td>[% ActionsLoo.ordering %]</td>
364 [% IF ( ActionsLoo.action_delete_field ) %] Delete [% END %]
365 [% IF ( ActionsLoo.action_update_field ) %] Update [% END %]
366 [% IF ( ActionsLoo.action_move_field ) %] Move [% END %]
367 [% IF ( ActionsLoo.action_copy_field ) %] Copy [% END %]
369 [% UNLESS ( ActionsLoo.action_update_field ) %]
370 [% IF ( ActionsLoo.field_number ) %]
377 [% ActionsLoo.from_field %][% IF ( ActionsLoo.from_subfield ) %]$[% ActionsLoo.from_subfield %][% END %]
379 [% IF ( ActionsLoo.field_value ) %]
380 with value <i>[% ActionsLoo.field_value %]</i>
383 [% IF ( ActionsLoo.to_field ) %]
384 to [% ActionsLoo.to_field %][% IF ( ActionsLoo.to_subfield ) %]$[% ActionsLoo.to_subfield %][% END %]
386 [% IF ( ActionsLoo.to_regex_search ) %]
387 using RegEx s<strong>/[% ActionsLoo.to_regex_search %]/[% ActionsLoo.to_regex_replace %]/[% ActionsLoo.to_regex_modifiers %]</strong>
391 [% IF ( ActionsLoo.conditional ) %]
392 [% IF ( ActionsLoo.conditional_if ) %] if [% END %]
393 [% IF ( ActionsLoo.conditional_unless ) %] unless [% END %]
395 [% ActionsLoo.conditional_field %][% IF ( ActionsLoo.conditional_subfield ) %]$[% ActionsLoo.conditional_subfield %][% END %]
397 [% IF ( ActionsLoo.conditional_comparison_exists ) %] exists [% END %]
398 [% IF ( ActionsLoo.conditional_comparison_not_exists ) %] does not exist [% END %]
399 [% IF ( ActionsLoo.conditional_comparison_equals ) %] matches [% END %]
400 [% IF ( ActionsLoo.conditional_comparison_not_equals ) %] does not match [% END %]
402 [% IF ( ActionsLoo.conditional_regex ) %] RegEx m/[% END %]
403 <strong>[% ActionsLoo.conditional_value %]</strong>
404 [% IF ( ActionsLoo.conditional_regex ) %]/[% END %]
407 <td>[% ActionsLoo.description %]</td>
408 <td><a href="#modaction" onclick='editAction(
409 "[% ActionsLoo.mmta_id |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
410 "[% ActionsLoo.ordering |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
411 "[% ActionsLoo.action |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
412 "[% ActionsLoo.field_number |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
413 "[% ActionsLoo.from_field |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
414 "[% ActionsLoo.from_subfield |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
415 "[% ActionsLoo.field_value |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
416 "[% ActionsLoo.to_field |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
417 "[% ActionsLoo.to_subfield |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
418 "[% ActionsLoo.to_regex_search |replace('\\\\', '\\\\') |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
419 "[% ActionsLoo.to_regex_replace |replace('\\\\', '\\\\') |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
420 "[% ActionsLoo.to_regex_modifiers |replace('\\\\', '\\\\') |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
421 "[% ActionsLoo.conditional |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
422 "[% ActionsLoo.conditional_field |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
423 "[% ActionsLoo.conditional_subfield |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
424 "[% ActionsLoo.conditional_comparison |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
425 "[% ActionsLoo.conditional_value |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
426 "[% ActionsLoo.conditional_regex |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
427 "[% ActionsLoo.description |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]"
429 <td><a href="marc_modification_templates.pl?template_id=[% ActionsLoo.template_id %]&op=delete_action&mmta_id=[% ActionsLoo.mmta_id %]">Delete</a></td>
434 <div class="dialog message"><p>There are no defined actions for this template.</p></div>
437 <form method="post" action="/cgi-bin/koha/tools/marc_modification_templates.pl" id="add_action" >
438 <a name="modaction"></a>
440 <legend id="modaction_legend">Add a new action</legend>
441 <div id="warning_multivalued" style="color:red; display:none;">You have chosen a condition on the same field as the original field. If your records contain multivalued fields it is highly recommended not to do that.</div>
443 <select name="action" id="action" onchange="onActionChange(this);">
444 <option value="delete_field">Delete</option>
445 <option value="update_field">Add/Update</option>
446 <option value="move_field">Move</option>
447 <option value="copy_field">Copy</option>
450 <span id="field_number_block">
451 <select name="field_number" id="field_number">
452 <option value="0">All</option>
453 <option value="1">1st</option>
457 field(s) <input type="text" name="from_field" id="from_field" size="3" maxlength="3" /> <input type="text" name="from_subfield" id="from_subfield" size="1" maxlength="1" title="let blank for the entire field" />
459 <span name="with_value_block" id="with_value_block" style="display:none;">
460 with value <input type="text" name="field_value" id="field_value" />
463 <span name="to_field_block" id="to_field_block" style="display:none;">
464 to field <input type="text" name="to_field" id="to_field" size="3" maxlength="3" /> <input type="text" name="to_subfield" id="to_subfield" size="1" maxlength="1" title="let blank for the entire field" />
466 <span name="to_field_regex_block" id="to_field_regex_block">
468 <label for="to_field_regex">RegEx</label>
469 <input type="checkbox" name="to_field_regex" id="to_field_regex" onchange="onToFieldRegexChange(this);" />
471 <span name="to_field_regex_value_block" id="to_field_regex_value_block" style="display:none;">
472 s/<input type="text" name="to_regex_search" id="to_regex_search" placeholder="regex pattern" />/<input type="text" name="to_regex_replace" id="to_regex_replace" placeholder="regex replacement" />/<input type="text" name="to_regex_modifiers" id="to_regex_modifiers" placeholder="ig" size="3" />
480 <select name="conditional" id="conditional" onchange="onConditionalChange(this);">
481 <option value="" selected="selected" />
482 <option value="if">if</option>
483 <option value="unless">unless</option>
486 <span name="conditional_block" id="conditional_block" style="display:none;">
487 field <input type="text" name="conditional_field" id="conditional_field" size="3" maxlength="3" /> <input type="text" name="conditional_subfield" id="conditional_subfield" size="1" maxlength="1" />
489 <select name="conditional_comparison" id="conditional_comparison" onchange="onConditionalComparisonChange(this);">
491 <option value="exists">exists</option>
492 <option value="not_exists">doesn't exist</option>
493 <option value="equals">matches</option>
494 <option value="not_equals">doesn't match</option>
497 <span name="conditional_comparison_block" id="conditional_comparison_block" style="display:none;">
499 <span class="match_regex_prefix">m/</span><input type="text" id="conditional_value" name="conditional_value" /><span class="match_regex_suffix">/</span>
502 <label for="conditional_regex">RegEx</label>
503 <input type="checkbox" name="conditional_regex" id="conditional_regex" onchange="onConditionalRegexChange(this);" />
509 <input type="hidden" name="template_id" value="[% template_id %]" />
510 <input type="hidden" name="mmta_id" id="mmta_id" />
511 <input type="hidden" name="op" value="add_action" />
514 <label for="description">Description:</label>
515 <input type="text" name="description" id="description" size="60" />
518 <input id="action_submit" type="submit" value="Add action" /> <a href="#modaction" id="cancel_edit" onclick="cancelEditAction();" style="display:none;">Cancel</a>
524 <div class="dialog message"><p>There are no defined templates. Please create a template first.</p></div>
527 <form method="post" action="/cgi-bin/koha/tools/marc_modification_templates.pl" id="add_template" class="validated">
529 <legend>Create a new template</legend>
531 <label for="template_name" class="required">Name: </label>
532 <input name="template_name" id="template_name" type="text" size="30" required="required" class="required" />
533 <span class="required">Required</span>
535 <input type="hidden" name="op" value="create_template" />
536 <input type="submit" value="Create template" />
538 [% IF ( template_id ) %]
539 <input type="hidden" name="template_id" value="[% template_id %]" />
540 <input type="checkbox" name="duplicate_current_template" id="duplicate_current_template" />
541 <label for="duplicate_current_template">Duplicate current template</label>
549 [% INCLUDE 'tools-menu.inc' %]
553 [% INCLUDE 'intranet-bottom.inc' %]