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 $("#conditional_field,#from_field").change(function(){
16 updateWarnings(); // For 3.14.x branches only, if bug 11319 is not pushed into
24 function updateWarnings(){
25 if ( $("#conditional_field").is(":visible") ) {
26 if ( $("#conditional_field").val() == $("#from_field").val() && $("#from_field").val().length > 0 ) {
27 $("#warning_multivalued").show();
29 $("#warning_multivalued").hide();
34 function onActionChange(selectObj) {
35 // get the index of the selected option
36 var idx = selectObj.selectedIndex;
38 // get the value of the selected option
39 var action = selectObj.options[idx].value;
43 show('field_number_block');
44 hide('with_value_block');
45 hide('to_field_block');
49 hide('field_number_block');
50 show('with_value_block');
51 hide('to_field_block');
55 show('field_number_block');
56 hide('with_value_block');
57 show('to_field_block');
61 show('field_number_block');
62 hide('with_value_block');
63 show('to_field_block');
69 function onConditionalChange(selectObj) {
70 // get the index of the selected option
71 var idx = selectObj.selectedIndex;
73 // get the value of the selected option
74 var action = selectObj.options[idx].value;
78 hide('conditional_block');
83 show('conditional_block');
88 function onConditionalComparisonChange(selectObj) {
89 // get the index of the selected option
90 var idx = selectObj.selectedIndex;
92 // get the value of the selected option
93 var action = selectObj.options[idx].value;
98 show('conditional_comparison_block');
102 hide('conditional_comparison_block');
107 function onToFieldRegexChange( checkboxObj ) {
108 if ( checkboxObj.checked ) {
109 show('to_field_regex_value_block');
111 hide('to_field_regex_value_block');
115 function onConditionalRegexChange( checkboxObj ) {
116 if ( checkboxObj.checked ) {
117 $("span.match_regex_prefix" ).show();
118 $("span.match_regex_suffix" ).show();
120 $("span.match_regex_prefix" ).hide();
121 $("span.match_regex_suffix" ).hide();
125 function show(eltId) {
126 elt = document.getElementById( eltId );
127 elt.style.display='inline';
130 function hide(eltId) {
131 clearFormElements( eltId );
132 elt = document.getElementById( eltId );
133 elt.style.display='none';
136 function clearFormElements(divId) {
137 myBlock = document.getElementById( divId );
139 var inputElements = myBlock.getElementsByTagName( "input" );
140 for (var i = 0; i < inputElements.length; i++) {
141 switch( inputElements[i].type ) {
143 inputElements[i].value = '';
146 inputElements[i].checked = false;
151 var selectElements = myBlock.getElementsByTagName( "select" );
152 for (var i = 0; i < selectElements.length; i++) {
153 selectElements[i].selectedIndex = 0;
158 function confirmDelete() {
159 var agree = confirm(_("Are you sure you wish to delete this template?"));
163 var modaction_legend_innerhtml;
164 var action_submit_value;
166 function editAction( mmta_id, ordering, action, field_number, from_field, from_subfield, field_value, to_field,
167 to_subfield, to_regex_search, to_regex_replace, to_regex_modifiers, conditional, conditional_field, conditional_subfield,
168 conditional_comparison, conditional_value, conditional_regex, description
170 document.getElementById('mmta_id').value = mmta_id;
172 setSelectByValue( 'action', action );
173 document.getElementById('action').onchange();
175 setSelectByValue( 'field_number', field_number );
177 document.getElementById('from_field').value = from_field;
178 document.getElementById('from_subfield').value = from_subfield;
179 document.getElementById('field_value').value = field_value;
180 document.getElementById('to_field').value = to_field;
181 document.getElementById('to_subfield').value = to_subfield;
182 $("#to_regex_search").val(to_regex_search);
183 $("#to_regex_replace").val(to_regex_replace);
184 $("#to_regex_modifiers").val(to_regex_modifiers);
186 document.getElementById('to_field_regex').checked = conditional_regex.length;
187 document.getElementById('to_field_regex').onchange();
189 setSelectByValue( 'conditional', conditional );
190 document.getElementById('conditional').onchange();
192 document.getElementById('conditional_field').value = conditional_field;
193 document.getElementById('conditional_subfield').value = conditional_subfield;
195 setSelectByValue( 'conditional_comparison', conditional_comparison );
196 document.getElementById('conditional_comparison').onchange();
198 document.getElementById('conditional_value').value = conditional_value;
200 document.getElementById('conditional_regex').checked = parseInt( conditional_regex );
202 document.getElementById('description').value = description;
204 window.modaction_legend_innerhtml = document.getElementById('modaction_legend').innerHTML;
205 document.getElementById('modaction_legend').innerHTML = _("Edit action %s").format(ordering);
207 window.action_submit_value = document.getElementById('action_submit').value;
208 document.getElementById('action_submit').value = _("Update action");
213 function cancelEditAction() {
214 document.getElementById('mmta_id').value = '';
216 setSelectByValue( 'action', 'delete_field' );
217 document.getElementById('action').onchange();
219 document.getElementById('from_field').value = '';
220 document.getElementById('from_subfield').value = '';
221 document.getElementById('field_value').value = '';
222 document.getElementById('to_field').value = '';
223 document.getElementById('to_subfield').value = '';
224 $("#to_regex_search").val("");
225 $("#to_regex_replace").val("");
226 $("#to_regex_modifiers").val("");
228 document.getElementById('to_field_regex').checked = false;
229 document.getElementById('to_field_regex').onchange();
231 setSelectByValue( 'conditional', '' );
232 document.getElementById('conditional').onchange();
234 document.getElementById('conditional_field').value = '';
235 document.getElementById('conditional_subfield').value = '';
237 setSelectByValue( 'conditional_comparison', '' );
238 document.getElementById('conditional_comparison').onchange();
240 document.getElementById('conditional_value').value = '';
242 document.getElementById('conditional_regex').checked = false;
244 document.getElementById('modaction_legend').innerHTML = window.modaction_legend_innerhtml;
245 document.getElementById('action_submit').value = window.action_submit_value;
250 function setSelectByValue( selectId, value ) {
251 s = document.getElementById( selectId );
253 for ( i = 0; i < s.options.length; i++ ) {
254 if ( s.options[i].value == value ) {
265 [% INCLUDE 'header.inc' %]
266 [% INCLUDE 'cat-search.inc' %]
268 <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>
270 <div id="doc3" class="yui-t2">
274 <h2>MARC modification templates</h2>
277 [% IF error == 'no_from_field' %]
278 <div class="dialog message">Error: no field value specified.</div>
282 [% IF ( TemplatesLoop ) %]
284 <form method="get" action="/cgi-bin/koha/tools/marc_modification_templates.pl" id="select_template">
285 <label for="select_template">Template: </label>
286 <select name="template_id" id="select_template" style="width:20em;">
287 [% FOREACH TemplatesLoo IN TemplatesLoop %]
288 [% IF ( TemplatesLoo.selected ) %]
289 <option value="[% TemplatesLoo.template_id %]" selected="selected"> [% TemplatesLoo.name %]</option>
291 <option value="[% TemplatesLoo.template_id %]"> [% TemplatesLoo.name %]</option>
295 <input type="hidden" name="op" value="select_template">
296 <input type="submit" value="Go" />
299 <form method="get" action="/cgi-bin/koha/tools/marc_modification_templates.pl" id="delete_template">
300 <input type="hidden" name="template_id" value="[% template_id %]" />
301 <input type="hidden" name="op" value="delete_template">
302 <input type="submit" value="Delete template" onClick="return confirmDelete()" />
306 [% IF ( ActionsLoop ) %]
308 <caption>Actions for this template</caption>
311 <th>Change order</th>
319 [% FOREACH ActionsLoo IN ActionsLoop %]
321 <td style="white-space:nowrap;">
322 <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 %]">
323 <img src="[% interface %]/[% theme %]/img/go-up.png" border="0" alt="Go up" />
326 <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 %]">
327 <img src="[% interface %]/[% theme %]/img/go-top.png" border="0" alt="Go top" />
330 <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 %]">
331 <img src="[% interface %]/[% theme %]/img/go-bottom.png" border="0" alt="Go bottom" />
334 <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 %]">
335 <img src="[% interface %]/[% theme %]/img/go-down.png" border="0" alt="Go down" />
339 <td>[% ActionsLoo.ordering %]</td>
341 [% IF ( ActionsLoo.action_delete_field ) %] Delete [% END %]
342 [% IF ( ActionsLoo.action_update_field ) %] Update [% END %]
343 [% IF ( ActionsLoo.action_move_field ) %] Move [% END %]
344 [% IF ( ActionsLoo.action_copy_field ) %] Copy [% END %]
346 [% UNLESS ( ActionsLoo.action_update_field ) %]
347 [% IF ( ActionsLoo.field_number ) %]
354 [% ActionsLoo.from_field %][% IF ( ActionsLoo.from_subfield ) %]$[% ActionsLoo.from_subfield %][% END %]
356 [% IF ( ActionsLoo.field_value ) %]
357 with value <i>[% ActionsLoo.field_value %]</i>
360 [% IF ( ActionsLoo.to_field ) %]
361 to [% ActionsLoo.to_field %][% IF ( ActionsLoo.to_subfield ) %]$[% ActionsLoo.to_subfield %][% END %]
363 [% IF ( ActionsLoo.to_regex_search ) %]
364 using RegEx s<strong>/[% ActionsLoo.to_regex_search %]/[% ActionsLoo.to_regex_replace %]/[% ActionsLoo.to_regex_modifiers %]</strong>
368 [% IF ( ActionsLoo.conditional ) %]
369 [% IF ( ActionsLoo.conditional_if ) %] if [% END %]
370 [% IF ( ActionsLoo.conditional_unless ) %] unless [% END %]
372 [% ActionsLoo.conditional_field %][% IF ( ActionsLoo.conditional_subfield ) %]$[% ActionsLoo.conditional_subfield %][% END %]
374 [% IF ( ActionsLoo.conditional_comparison_exists ) %] exists [% END %]
375 [% IF ( ActionsLoo.conditional_comparison_not_exists ) %] does not exist [% END %]
376 [% IF ( ActionsLoo.conditional_comparison_equals ) %] matches [% END %]
377 [% IF ( ActionsLoo.conditional_comparison_not_equals ) %] does not match [% END %]
379 [% IF ( ActionsLoo.conditional_regex ) %] RegEx m/[% END %]
380 <strong>[% ActionsLoo.conditional_value %]</strong>
381 [% IF ( ActionsLoo.conditional_regex ) %]/[% END %]
384 <td>[% ActionsLoo.description %]</td>
385 <td><a href="#modaction" onclick='editAction(
386 "[% ActionsLoo.mmta_id |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
387 "[% ActionsLoo.ordering |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
388 "[% ActionsLoo.action |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
389 "[% ActionsLoo.field_number |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
390 "[% ActionsLoo.from_field |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
391 "[% ActionsLoo.from_subfield |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
392 "[% ActionsLoo.field_value |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
393 "[% ActionsLoo.to_field |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
394 "[% ActionsLoo.to_subfield |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
395 "[% ActionsLoo.to_regex_search |replace('\\\\', '\\\\') |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
396 "[% ActionsLoo.to_regex_replace |replace('\\\\', '\\\\') |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
397 "[% ActionsLoo.to_regex_modifiers |replace('\\\\', '\\\\') |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
398 "[% ActionsLoo.conditional |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
399 "[% ActionsLoo.conditional_field |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
400 "[% ActionsLoo.conditional_subfield |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
401 "[% ActionsLoo.conditional_comparison |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
402 "[% ActionsLoo.conditional_value |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
403 "[% ActionsLoo.conditional_regex |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
404 "[% ActionsLoo.description |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]"
406 <td><a href="marc_modification_templates.pl?template_id=[% ActionsLoo.template_id %]&op=delete_action&mmta_id=[% ActionsLoo.mmta_id %]">Delete</a></td>
411 <div class="dialog message"><p>There are no defined actions for this template.</p></div>
414 <form method="post" action="/cgi-bin/koha/tools/marc_modification_templates.pl" id="add_action" >
415 <a name="modaction"></a>
417 <legend id="modaction_legend">Add a new action</legend>
418 <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>
420 <select name="action" id="action" onchange="onActionChange(this);">
421 <option value="delete_field">Delete</option>
422 <option value="update_field">Add/Update</option>
423 <option value="move_field">Move</option>
424 <option value="copy_field">Copy</option>
427 <span id="field_number_block">
428 <select name="field_number" id="field_number">
429 <option value="0">All</option>
430 <option value="1">1st</option>
434 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" />
436 <span name="with_value_block" id="with_value_block" style="display:none;">
437 with value <input type="text" name="field_value" id="field_value" />
440 <span name="to_field_block" id="to_field_block" style="display:none;">
441 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" />
443 <span name="to_field_regex_block" id="to_field_regex_block">
445 <label for="to_field_regex">RegEx</label>
446 <input type="checkbox" name="to_field_regex" id="to_field_regex" onchange="onToFieldRegexChange(this);" />
448 <span name="to_field_regex_value_block" id="to_field_regex_value_block" style="display:none;">
449 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" />
457 <select name="conditional" id="conditional" onchange="onConditionalChange(this);">
458 <option value="" selected="selected" />
459 <option value="if">if</option>
460 <option value="unless">unless</option>
463 <span name="conditional_block" id="conditional_block" style="display:none;">
464 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" />
466 <select name="conditional_comparison" id="conditional_comparison" onchange="onConditionalComparisonChange(this);">
468 <option value="exists">exists</option>
469 <option value="not_exists">doesn't exist</option>
470 <option value="equals">matches</option>
471 <option value="not_equals">doesn't match</option>
474 <span name="conditional_comparison_block" id="conditional_comparison_block" style="display:none;">
476 <span class="match_regex_prefix">m/</span><input type="text" id="conditional_value" name="conditional_value" /><span class="match_regex_suffix">/</span>
479 <label for="conditional_regex">RegEx</label>
480 <input type="checkbox" name="conditional_regex" id="conditional_regex" onchange="onConditionalRegexChange(this);" />
486 <input type="hidden" name="template_id" value="[% template_id %]" />
487 <input type="hidden" name="mmta_id" id="mmta_id" />
488 <input type="hidden" name="op" value="add_action" />
491 <label for="description">Description:</label>
492 <input type="text" name="description" id="description" size="60" />
495 <input id="action_submit" type="submit" value="Add action" /> <a href="#modaction" id="cancel_edit" onclick="cancelEditAction();" style="display:none;">Cancel</a>
501 <div class="dialog message"><p>There are no defined templates. Please create a template first.</p></div>
504 <form method="post" action="/cgi-bin/koha/tools/marc_modification_templates.pl" id="add_template" >
506 <legend>Create a new template</legend>
508 <label for="template_name" class="required">Name: </label>
509 <input name="template_name" id="template_name" type="text" size="30" required="required" />
511 <input type="hidden" name="op" value="create_template" />
512 <input type="submit" value="Create template" />
514 [% IF ( template_id ) %]
515 <input type="hidden" name="template_id" value="[% template_id %]" />
516 <input type="checkbox" name="duplicate_current_template" id="duplicate_current_template" />
517 <label for="duplicate_current_template">Duplicate current template</label>
525 [% INCLUDE 'tools-menu.inc' %]
529 [% INCLUDE 'intranet-bottom.inc' %]