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>
262 [% IF error == 'no_from_field' %]
263 <div class="dialog message">Error: no field value specified.</div>
267 [% IF ( TemplatesLoop ) %]
269 <form method="get" action="/cgi-bin/koha/tools/marc_modification_templates.pl" id="select_template">
270 <label for="select_template">Template: </label>
271 <select name="template_id" id="select_template" style="width:20em;">
272 [% FOREACH TemplatesLoo IN TemplatesLoop %]
273 [% IF ( TemplatesLoo.selected ) %]
274 <option value="[% TemplatesLoo.template_id %]" selected="selected"> [% TemplatesLoo.name %]</option>
276 <option value="[% TemplatesLoo.template_id %]"> [% TemplatesLoo.name %]</option>
280 <input type="hidden" name="op" value="select_template">
281 <input type="submit" value="Go" />
284 <form method="get" action="/cgi-bin/koha/tools/marc_modification_templates.pl" id="delete_template">
285 <input type="hidden" name="template_id" value="[% template_id %]" />
286 <input type="hidden" name="op" value="delete_template">
287 <input type="submit" value="Delete template" onClick="return confirmDelete()" />
291 [% IF ( ActionsLoop ) %]
293 <caption>Actions for this template</caption>
296 <th>Change order</th>
304 [% FOREACH ActionsLoo IN ActionsLoop %]
306 <td style="white-space:nowrap;">
307 <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 %]">
308 <img src="[% interface %]/[% theme %]/img/go-up.png" border="0" alt="Go up" />
311 <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 %]">
312 <img src="[% interface %]/[% theme %]/img/go-top.png" border="0" alt="Go top" />
315 <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 %]">
316 <img src="[% interface %]/[% theme %]/img/go-bottom.png" border="0" alt="Go bottom" />
319 <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 %]">
320 <img src="[% interface %]/[% theme %]/img/go-down.png" border="0" alt="Go down" />
324 <td>[% ActionsLoo.ordering %]</td>
326 [% IF ( ActionsLoo.action_delete_field ) %] Delete [% END %]
327 [% IF ( ActionsLoo.action_update_field ) %] Update [% END %]
328 [% IF ( ActionsLoo.action_move_field ) %] Move [% END %]
329 [% IF ( ActionsLoo.action_copy_field ) %] Copy [% END %]
331 [% UNLESS ( ActionsLoo.action_update_field ) %]
332 [% IF ( ActionsLoo.field_number ) %]
339 [% ActionsLoo.from_field %][% IF ( ActionsLoo.from_subfield ) %]$[% ActionsLoo.from_subfield %][% END %]
341 [% IF ( ActionsLoo.field_value ) %]
342 with value <i>[% ActionsLoo.field_value %]</i>
345 [% IF ( ActionsLoo.to_field ) %]
346 to [% ActionsLoo.to_field %][% IF ( ActionsLoo.to_subfield ) %]$[% ActionsLoo.to_subfield %][% END %]
348 [% IF ( ActionsLoo.to_regex_search ) %]
349 using RegEx s<strong>/[% ActionsLoo.to_regex_search %]/[% ActionsLoo.to_regex_replace %]/[% ActionsLoo.to_regex_modifiers %]</strong>
353 [% IF ( ActionsLoo.conditional ) %]
354 [% IF ( ActionsLoo.conditional_if ) %] if [% END %]
355 [% IF ( ActionsLoo.conditional_unless ) %] unless [% END %]
357 [% ActionsLoo.conditional_field %][% IF ( ActionsLoo.conditional_subfield ) %]$[% ActionsLoo.conditional_subfield %][% END %]
359 [% IF ( ActionsLoo.conditional_comparison_exists ) %] exists [% END %]
360 [% IF ( ActionsLoo.conditional_comparison_not_exists ) %] does not exist [% END %]
361 [% IF ( ActionsLoo.conditional_comparison_equals ) %] matches [% END %]
362 [% IF ( ActionsLoo.conditional_comparison_not_equals ) %] does not match [% END %]
364 [% IF ( ActionsLoo.conditional_regex ) %] RegEx m/[% END %]
365 <strong>[% ActionsLoo.conditional_value %]</strong>
366 [% IF ( ActionsLoo.conditional_regex ) %]/[% END %]
369 <td>[% ActionsLoo.description %]</td>
370 <td><a href="#modaction" onclick='editAction(
371 "[% ActionsLoo.mmta_id |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
372 "[% ActionsLoo.ordering |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
373 "[% ActionsLoo.action |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
374 "[% ActionsLoo.field_number |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
375 "[% ActionsLoo.from_field |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
376 "[% ActionsLoo.from_subfield |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
377 "[% ActionsLoo.field_value |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
378 "[% ActionsLoo.to_field |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
379 "[% ActionsLoo.to_subfield |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
380 "[% ActionsLoo.to_regex_search |replace('\\\\', '\\\\') |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
381 "[% ActionsLoo.to_regex_replace |replace('\\\\', '\\\\') |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
382 "[% ActionsLoo.to_regex_modifiers |replace('\\\\', '\\\\') |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
383 "[% ActionsLoo.conditional |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
384 "[% ActionsLoo.conditional_field |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
385 "[% ActionsLoo.conditional_subfield |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
386 "[% ActionsLoo.conditional_comparison |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
387 "[% ActionsLoo.conditional_value |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
388 "[% ActionsLoo.conditional_regex |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
389 "[% ActionsLoo.description |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]"
391 <td><a href="marc_modification_templates.pl?template_id=[% ActionsLoo.template_id %]&op=delete_action&mmta_id=[% ActionsLoo.mmta_id %]">Delete</a></td>
396 <div class="dialog message"><p>There are no defined actions for this template.</p></div>
399 <form method="post" action="/cgi-bin/koha/tools/marc_modification_templates.pl" id="add_action" >
400 <a name="modaction"></a>
402 <legend id="modaction_legend">Add a new action</legend>
404 <select name="action" id="action" onchange="onActionChange(this);">
405 <option value="delete_field">Delete</option>
406 <option value="update_field">Add/Update</option>
407 <option value="move_field">Move</option>
408 <option value="copy_field">Copy</option>
411 <span id="field_number_block">
412 <select name="field_number" id="field_number">
413 <option value="0">All</option>
414 <option value="1">1st</option>
418 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" />
420 <span name="with_value_block" id="with_value_block" style="display:none;">
421 with value <input type="text" name="field_value" id="field_value" />
424 <span name="to_field_block" id="to_field_block" style="display:none;">
425 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" />
427 <span name="to_field_regex_block" id="to_field_regex_block">
429 <label for="to_field_regex">RegEx</label>
430 <input type="checkbox" name="to_field_regex" id="to_field_regex" onchange="onToFieldRegexChange(this);" />
432 <span name="to_field_regex_value_block" id="to_field_regex_value_block" style="display:none;">
433 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" />
441 <select name="conditional" id="conditional" onchange="onConditionalChange(this);">
442 <option value="" selected />
443 <option value="if">if</option>
444 <option value="unless">unless</option>
447 <span name="conditional_block" id="conditional_block" style="display:none;">
448 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" />
450 <select name="conditional_comparison" id="conditional_comparison" onchange="onConditionalComparisonChange(this);">
452 <option value="exists">exists</option>
453 <option value="not_exists">doesn't exist</option>
454 <option value="equals">matches</option>
455 <option value="not_equals">doesn't match</option>
458 <span name="conditional_comparison_block" id="conditional_comparison_block" style="display:none;">
460 <span class="match_regex_prefix">m/</span><input type="text" id="conditional_value" name="conditional_value" /><span class="match_regex_suffix">/</span>
463 <label for="conditional_regex">RegEx</label>
464 <input type="checkbox" name="conditional_regex" id="conditional_regex" onchange="onConditionalRegexChange(this);" />
470 <input type="hidden" name="template_id" value="[% template_id %]" />
471 <input type="hidden" name="mmta_id" id="mmta_id" />
472 <input type="hidden" name="op" value="add_action" />
475 <label for="description">Description:</label>
476 <input type="text" name="description" id="description" size="60" />
479 <input id="action_submit" type="submit" value="Add action" /> <a href="#modaction" id="cancel_edit" onclick="cancelEditAction();" style="display:none;">Cancel</a>
485 <div class="dialog message"><p>There are no defined templates. Please create a template first.</p></div>
488 <form method="post" action="/cgi-bin/koha/tools/marc_modification_templates.pl" id="add_template" >
490 <legend>Create a new template</legend>
492 <label for="template_name" class="required">Name: </label>
493 <input name="template_name" id="template_name" type="text" size="30" required="required" />
495 <input type="hidden" name="op" value="create_template" />
496 <input type="submit" value="Create template" />
498 [% IF ( template_id ) %]
499 <input type="hidden" name="template_id" value="[% template_id %]" />
500 <input type="checkbox" name="duplicate_current_template" id="duplicate_current_template" />
501 <label for="duplicate_current_template">Duplicate current template</label>
509 [% INCLUDE 'tools-menu.inc' %]
513 [% INCLUDE 'intranet-bottom.inc' %]