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();
19 function onActionChange(selectObj) {
20 // get the index of the selected option
21 var idx = selectObj.selectedIndex;
23 // get the value of the selected option
24 var action = selectObj.options[idx].value;
28 show('field_number_block');
29 hide('with_value_block');
30 hide('to_field_block');
34 hide('field_number_block');
35 show('with_value_block');
36 hide('to_field_block');
40 show('field_number_block');
41 hide('with_value_block');
42 show('to_field_block');
46 show('field_number_block');
47 hide('with_value_block');
48 show('to_field_block');
54 function onConditionalChange(selectObj) {
55 // get the index of the selected option
56 var idx = selectObj.selectedIndex;
58 // get the value of the selected option
59 var action = selectObj.options[idx].value;
63 hide('conditional_block');
68 show('conditional_block');
73 function onConditionalComparisonChange(selectObj) {
74 // get the index of the selected option
75 var idx = selectObj.selectedIndex;
77 // get the value of the selected option
78 var action = selectObj.options[idx].value;
83 show('conditional_comparison_block');
87 hide('conditional_comparison_block');
92 function onToFieldRegexChange( checkboxObj ) {
93 if ( checkboxObj.checked ) {
94 show('to_field_regex_value_block');
96 hide('to_field_regex_value_block');
100 function onConditionalRegexChange( checkboxObj ) {
101 if ( checkboxObj.checked ) {
102 $("span.match_regex_prefix" ).show();
103 $("span.match_regex_suffix" ).show();
105 $("span.match_regex_prefix" ).hide();
106 $("span.match_regex_suffix" ).hide();
110 function show(eltId) {
111 elt = document.getElementById( eltId );
112 elt.style.display='inline';
115 function hide(eltId) {
116 clearFormElements( eltId );
117 elt = document.getElementById( eltId );
118 elt.style.display='none';
121 function clearFormElements(divId) {
122 myBlock = document.getElementById( divId );
124 var inputElements = myBlock.getElementsByTagName( "input" );
125 for (var i = 0; i < inputElements.length; i++) {
126 switch( inputElements[i].type ) {
128 inputElements[i].value = '';
131 inputElements[i].checked = false;
136 var selectElements = myBlock.getElementsByTagName( "select" );
137 for (var i = 0; i < selectElements.length; i++) {
138 selectElements[i].selectedIndex = 0;
143 function confirmDelete() {
144 var agree = confirm(_("Are you sure you wish to delete this template?"));
148 var modaction_legend_innerhtml;
149 var action_submit_value;
151 function editAction( mmta_id, ordering, action, field_number, from_field, from_subfield, field_value, to_field,
152 to_subfield, to_regex_search, to_regex_replace, to_regex_modifiers, conditional, conditional_field, conditional_subfield,
153 conditional_comparison, conditional_value, conditional_regex, description
155 document.getElementById('mmta_id').value = mmta_id;
157 setSelectByValue( 'action', action );
158 document.getElementById('action').onchange();
160 setSelectByValue( 'field_number', field_number );
162 document.getElementById('from_field').value = from_field;
163 document.getElementById('from_subfield').value = from_subfield;
164 document.getElementById('field_value').value = field_value;
165 document.getElementById('to_field').value = to_field;
166 document.getElementById('to_subfield').value = to_subfield;
167 $("#to_regex_search").val(to_regex_search);
168 $("#to_regex_replace").val(to_regex_replace);
169 $("#to_regex_modifiers").val(to_regex_modifiers);
171 document.getElementById('to_field_regex').checked = conditional_regex.length;
172 document.getElementById('to_field_regex').onchange();
174 setSelectByValue( 'conditional', conditional );
175 document.getElementById('conditional').onchange();
177 document.getElementById('conditional_field').value = conditional_field;
178 document.getElementById('conditional_subfield').value = conditional_subfield;
180 setSelectByValue( 'conditional_comparison', conditional_comparison );
181 document.getElementById('conditional_comparison').onchange();
183 document.getElementById('conditional_value').value = conditional_value;
185 document.getElementById('conditional_regex').checked = parseInt( conditional_regex );
187 document.getElementById('description').value = description;
189 window.modaction_legend_innerhtml = document.getElementById('modaction_legend').innerhtml;
190 document.getElementById('modaction_legend').innerhtml = _("Edit action") + ordering;
192 window.action_submit_value = document.getElementById('action_submit').value;
193 document.getElementById('action_submit').value = _("Update action");
198 function cancelEditAction() {
199 document.getElementById('mmta_id').value = '';
201 setSelectByValue( 'action', 'delete_field' );
202 document.getElementById('action').onchange();
204 document.getElementById('from_field').value = '';
205 document.getElementById('from_subfield').value = '';
206 document.getElementById('field_value').value = '';
207 document.getElementById('to_field').value = '';
208 document.getElementById('to_subfield').value = '';
209 $("#to_regex_search").val("");
210 $("#to_regex_replace").val("");
211 $("#to_regex_modifiers").val("");
213 document.getElementById('to_field_regex').checked = false;
214 document.getElementById('to_field_regex').onchange();
216 setSelectByValue( 'conditional', '' );
217 document.getElementById('conditional').onchange();
219 document.getElementById('conditional_field').value = '';
220 document.getElementById('conditional_subfield').value = '';
222 setSelectByValue( 'conditional_comparison', '' );
223 document.getElementById('conditional_comparison').onchange();
225 document.getElementById('conditional_value').value = '';
227 document.getElementById('conditional_regex').checked = false;
229 document.getElementById('modaction_legend').innerhtml = window.modaction_legend_innerhtml;
230 document.getElementById('action_submit').value = window.action_submit_value;
235 function setSelectByValue( selectId, value ) {
236 s = document.getElementById( selectId );
238 for ( i = 0; i < s.options.length; i++ ) {
239 if ( s.options[i].value == value ) {
250 [% INCLUDE 'header.inc' %]
251 [% INCLUDE 'cat-search.inc' %]
253 <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>
255 <div id="doc3" class="yui-t2">
259 <h2>MARC modification templates</h2>
261 [% IF ( TemplatesLoop ) %]
263 <form method="get" action="/cgi-bin/koha/tools/marc_modification_templates.pl" id="select_template">
264 <label for="select_template">Template: </label>
265 <select name="template_id" id="select_template" style="width:20em;">
266 [% FOREACH TemplatesLoo IN TemplatesLoop %]
267 [% IF ( TemplatesLoo.selected ) %]
268 <option value="[% TemplatesLoo.template_id %]" selected="selected"> [% TemplatesLoo.name %]</option>
270 <option value="[% TemplatesLoo.template_id %]"> [% TemplatesLoo.name %]</option>
274 <input type="hidden" name="op" value="select_template">
275 <input type="submit" value="Go" />
278 <form method="get" action="/cgi-bin/koha/tools/marc_modification_templates.pl" id="delete_template">
279 <input type="hidden" name="template_id" value="[% template_id %]" />
280 <input type="hidden" name="op" value="delete_template">
281 <input type="submit" value="Delete template" onClick="return confirmDelete()" />
285 [% IF ( ActionsLoop ) %]
287 <caption>Actions for this template</caption>
290 <th>Change order</th>
298 [% FOREACH ActionsLoo IN ActionsLoop %]
300 <td style="white-space:nowrap;">
301 <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 %]">
302 <img src="[% interface %]/[% theme %]/img/go-up.png" border="0" alt="Go up" />
305 <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 %]">
306 <img src="[% interface %]/[% theme %]/img/go-top.png" border="0" alt="Go top" />
309 <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 %]">
310 <img src="[% interface %]/[% theme %]/img/go-bottom.png" border="0" alt="Go bottom" />
313 <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 %]">
314 <img src="[% interface %]/[% theme %]/img/go-down.png" border="0" alt="Go down" />
318 <td>[% ActionsLoo.ordering %]</td>
320 [% IF ( ActionsLoo.action_delete_field ) %] Delete [% END %]
321 [% IF ( ActionsLoo.action_update_field ) %] Update [% END %]
322 [% IF ( ActionsLoo.action_move_field ) %] Move [% END %]
323 [% IF ( ActionsLoo.action_copy_field ) %] Copy [% END %]
325 [% UNLESS ( ActionsLoo.action_update_field ) %]
326 [% IF ( ActionsLoo.field_number ) %]
333 [% ActionsLoo.from_field %][% IF ( ActionsLoo.from_subfield ) %]$[% ActionsLoo.from_subfield %][% END %]
335 [% IF ( ActionsLoo.field_value ) %]
336 with value <i>[% ActionsLoo.field_value %]</i>
339 [% IF ( ActionsLoo.to_field ) %]
340 to [% ActionsLoo.to_field %][% IF ( ActionsLoo.to_subfield ) %]$[% ActionsLoo.to_subfield %][% END %]
342 [% IF ( ActionsLoo.to_regex_search ) %]
343 using RegEx s<strong>/[% ActionsLoo.to_regex_search %]/[% ActionsLoo.to_regex_replace %]/[% ActionsLoo.to_regex_modifiers %]</strong>
347 [% IF ( ActionsLoo.conditional ) %]
348 [% IF ( ActionsLoo.conditional_if ) %] if [% END %]
349 [% IF ( ActionsLoo.conditional_unless ) %] unless [% END %]
351 [% ActionsLoo.conditional_field %][% IF ( ActionsLoo.conditional_subfield ) %]$[% ActionsLoo.conditional_subfield %][% END %]
353 [% IF ( ActionsLoo.conditional_comparison_exists ) %] exists [% END %]
354 [% IF ( ActionsLoo.conditional_comparison_not_exists ) %] does not exist [% END %]
355 [% IF ( ActionsLoo.conditional_comparison_equals ) %] matches [% END %]
356 [% IF ( ActionsLoo.conditional_comparison_not_equals ) %] does not match [% END %]
358 [% IF ( ActionsLoo.conditional_regex ) %] RegEx m/[% END %]<strong>[% ActionsLoo.conditional_value %]/</strong>
361 <td>[% ActionsLoo.description %]</td>
362 <td><a href="#modaction" onclick='editAction(
363 "[% ActionsLoo.mmta_id |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
364 "[% ActionsLoo.ordering |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
365 "[% ActionsLoo.action |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
366 "[% ActionsLoo.field_number |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
367 "[% ActionsLoo.from_field |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
368 "[% ActionsLoo.from_subfield |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
369 "[% ActionsLoo.field_value |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
370 "[% ActionsLoo.to_field |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
371 "[% ActionsLoo.to_subfield |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
372 "[% ActionsLoo.to_regex_search |replace('\\\\', '\\\\') |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
373 "[% ActionsLoo.to_regex_replace |replace('\\\\', '\\\\') |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
374 "[% ActionsLoo.to_regex_modifiers |replace('\\\\', '\\\\') |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
375 "[% ActionsLoo.conditional |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
376 "[% ActionsLoo.conditional_field |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
377 "[% ActionsLoo.conditional_subfield |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
378 "[% ActionsLoo.conditional_comparison |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
379 "[% ActionsLoo.conditional_value |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
380 "[% ActionsLoo.conditional_regex |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
381 "[% ActionsLoo.description |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]"
383 <td><a href="marc_modification_templates.pl?template_id=[% ActionsLoo.template_id %]&op=delete_action&mmta_id=[% ActionsLoo.mmta_id %]">Delete</a></td>
388 <div class="dialog message"><p>There are no defined actions for this template.</p></div>
391 <form method="post" action="/cgi-bin/koha/tools/marc_modification_templates.pl" id="add_action" >
392 <a name="modaction"></a>
394 <legend id="modaction_legend">Add a new action</legend>
396 <select name="action" id="action" onchange="onActionChange(this);">
397 <option value="delete_field">Delete</option>
398 <option value="update_field">Add/Update</option>
399 <option value="move_field">Move</option>
400 <option value="copy_field">Copy</option>
403 <span id="field_number_block">
404 <select name="field_number" id="field_number">
405 <option value="0">All</option>
406 <option value="1">1st</option>
410 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" />
412 <span name="with_value_block" id="with_value_block" style="display:none;">
413 with value <input type="text" name="field_value" id="field_value" />
416 <span name="to_field_block" id="to_field_block" style="display:none;">
417 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" />
419 <span name="to_field_regex_block" id="to_field_regex_block">
421 <label for="to_field_regex">RegEx</label>
422 <input type="checkbox" name="to_field_regex" id="to_field_regex" onchange="onToFieldRegexChange(this);" />
424 <span name="to_field_regex_value_block" id="to_field_regex_value_block" style="display:none;">
425 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" />
433 <select name="conditional" id="conditional" onchange="onConditionalChange(this);">
434 <option value="" selected />
435 <option value="if">if</option>
436 <option value="unless">unless</option>
439 <span name="conditional_block" id="conditional_block" style="display:none;">
440 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" />
442 <select name="conditional_comparison" id="conditional_comparison" onchange="onConditionalComparisonChange(this);">
444 <option value="exists">exists</option>
445 <option value="not_exists">doesn't exist</option>
446 <option value="equals">matches</option>
447 <option value="not_equals">doesn't match</option>
450 <span name="conditional_comparison_block" id="conditional_comparison_block" style="display:none;">
452 <span class="match_regex_prefix">m/</span><input type="text" id="conditional_value" name="conditional_value" /><span class="match_regex_suffix">/</span>
455 <label for="conditional_regex">RegEx</label>
456 <input type="checkbox" name="conditional_regex" id="conditional_regex" onchange="onConditionalRegexChange(this);" />
462 <input type="hidden" name="template_id" value="[% template_id %]" />
463 <input type="hidden" name="mmta_id" id="mmta_id" />
464 <input type="hidden" name="op" value="add_action" />
467 <label for="description">Description:</label>
468 <input type="text" name="description" id="description" size="60" />
471 <input id="action_submit" type="submit" value="Add action" /> <a href="#modaction" id="cancel_edit" onclick="cancelEditAction();" style="display:none;">Cancel</a>
477 <div class="dialog message"><p>There are no defined templates. Please create a template first.</p></div>
480 <form method="post" action="/cgi-bin/koha/tools/marc_modification_templates.pl" id="add_template" >
482 <legend>Create a new template</legend>
484 <label for="template_name" class="required">Name: </label>
485 <input name="template_name" id="template_name" type="text" size="30" required="required" />
487 <input type="hidden" name="op" value="create_template" />
488 <input type="submit" value="Create template" />
490 [% IF ( template_id ) %]
491 <input type="hidden" name="template_id" value="[% template_id %]" />
492 <input type="checkbox" name="duplicate_current_template" id="duplicate_current_template" />
493 <label for="duplicate_current_template">Duplicate current template</label>
501 [% INCLUDE 'tools-menu.inc' %]
505 [% INCLUDE 'intranet-bottom.inc' %]