Bug 8015: (follow-up) fix various issues (squashed patch)

Bug 8015: Fix template capitalization amd other template issues

Signed-off-by: Leila <koha.aixmarseille@gmail.com>

Bug 8015: Fix error where field object is returned instead of field value for fields without subfields

Signed-off-by: Leila <koha.aixmarseille@gmail.com>

Bug 8015: Fix bad ordering on function parameters

Signed-off-by: Leila <koha.aixmarseille@gmail.com>

Bug 8015: Escape escape characters for strings

Signed-off-by: Leila <koha.aixmarseille@gmail.com>

Bug 8015: Fix bad parameter list for direct external call to update_field

Signed-off-by: Leila <koha.aixmarseille@gmail.com>

Bug 8015: Fix problem with moving existing subfield value to nonexistent field/subfield

Signed-off-by: Leila <koha.aixmarseille@gmail.com>

Bug 8015: FIX QA issues

This patch fixes some stuffs failing qa tests: POD, indentation (tabs),
perlcritic

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
This commit is contained in:
Kyle M Hall 2013-03-19 03:27:46 -07:00 committed by Galen Charlton
parent 0a176d4648
commit 7362776897
6 changed files with 391 additions and 389 deletions

View File

@ -1486,9 +1486,7 @@ sub _isbn_cleanup {
return;
}
=head2
Log( $message );
=head2 Log( $message );
Writes data to /tmp/koha.log.
@ -1499,9 +1497,10 @@ sub _isbn_cleanup {
sub Log {
my ($data) = @_;
open (MYFILE, '>>/tmp/koha.log');
print MYFILE "$data\n";
close (MYFILE);
warn $data;
open my $fh, '>>/tmp/koha.log';
print $fh "$data\n";
close $fh;
}
1;

View File

@ -35,24 +35,24 @@ use vars qw($VERSION @ISA @EXPORT);
use constant DEBUG => 0;
BEGIN {
$VERSION = 1.00; # set the version for version checking
@ISA = qw(Exporter);
@EXPORT = qw(
&GetModificationTemplates
&AddModificationTemplate
&DelModificationTemplate
$VERSION = 1.00; # set the version for version checking
@ISA = qw(Exporter);
@EXPORT = qw(
&GetModificationTemplates
&AddModificationTemplate
&DelModificationTemplate
&GetModificationTemplateAction
&GetModificationTemplateActions
&GetModificationTemplateAction
&GetModificationTemplateActions
&AddModificationTemplateAction
&ModModificationTemplateAction
&DelModificationTemplateAction
&MoveModificationTemplateAction
&AddModificationTemplateAction
&ModModificationTemplateAction
&DelModificationTemplateAction
&MoveModificationTemplateAction
&ModifyRecordsWithTemplate
&ModifyRecordWithTemplate
);
&ModifyRecordsWithTemplate
&ModifyRecordWithTemplate
);
}
@ -529,6 +529,7 @@ sub ModifyRecordWithTemplate {
$field_value =~ s/__CURRENTDATE__/$current_date/g;
$field_value =~ s/__BRANCHCODE__/$branchcode/g;
$eval .= " undef, " if ( $action eq 'update_field' );
$eval .= " '$field_value' ";
C4::Koha::Log( "Field value after replacements: $field_value" ) if ( DEBUG >= 3 );
@ -563,7 +564,7 @@ sub ModifyRecordWithTemplate {
C4::Koha::Log("eval $eval") if DEBUG >= 2;
warn("eval $eval") if DEBUG >= 2;
eval $eval;
eval {$eval};
C4::Koha::Log( $record->as_formatted() ) if DEBUG >= 10;
warn( $record->as_formatted() ) if DEBUG >= 10;

View File

@ -60,7 +60,7 @@ at your option, any later version of Perl 5 you may have available.
=head1 FUNCTIONS
=head2
=head2 copy_field
copy_field( $record, $fromFieldName, $fromSubfieldName, $toFieldName, $toSubfieldName[, $regex[, $n ] ] );
@ -90,13 +90,13 @@ sub copy_field {
}
}
update_field( $record, $toFieldName, $toSubfieldName, @values, $dont_erase );
update_field( $record, $toFieldName, $toSubfieldName, $dont_erase, @values );
}
=head2
=head2 update_field
update_field( $record, $fieldName, $subfieldName, $value[, $value,[ $value ... ] ] );
update_field( $record, $fieldName, $subfieldName, $dont_erase, $value[, $value,[ $value ... ] ] );
Updates a field with the given value, creating it if neccessary.
@ -109,8 +109,8 @@ sub copy_field {
=cut
sub update_field {
my ( $record, $fieldName, $subfieldName, @values, $dont_erase ) = @_;
C4::Koha::Log( "C4::SimpleMARC::update_field( $record, $fieldName, $subfieldName, @values )" ) if $debug;
my ( $record, $fieldName, $subfieldName, $dont_erase, @values ) = @_;
C4::Koha::Log( "C4::SimpleMARC::update_field( $record, $fieldName, $subfieldName, $dont_erase, @values )" ) if $debug;
if ( ! ( $record && $fieldName ) ) { return; }
@ -157,7 +157,7 @@ sub update_field {
}
}
=head2
=head2 read_field
my @values = read_field( $record, $fieldName[, $subfieldName, [, $n ] ] );
@ -174,7 +174,7 @@ sub read_field {
my @fields = $record->field( $fieldName );
return @fields unless $subfieldName;
return map { $_->data() } @fields unless $subfieldName;
my @subfields;
foreach my $field ( @fields ) {
@ -189,7 +189,7 @@ sub read_field {
}
}
=head2
=head2 field_exists
$bool = field_exists( $record, $fieldName[, $subfieldName ]);
@ -214,7 +214,7 @@ sub field_exists {
return $return;
}
=head2
=head2 field_equals
$bool = field_equals( $record, $value, $fieldName[, $subfieldName[, $regex [, $n ] ] ]);
@ -246,7 +246,7 @@ sub field_equals {
}
}
=head2
=head2 move_field
move_field( $record, $fromFieldName, $fromSubfieldName, $toFieldName, $toSubfieldName[, $regex [, $n ] ] );
@ -262,11 +262,11 @@ sub field_equals {
sub move_field {
my ( $record, $fromFieldName, $fromSubfieldName, $toFieldName, $toSubfieldName, $regex, $n ) = @_;
C4::Koha::Log( "C4::SimpleMARC::move_field( '$record', '$fromFieldName', '$fromSubfieldName', '$toFieldName', '$toSubfieldName', '$regex', '$n' )" ) if $debug;
copy_field( $record, $fromFieldName, $fromSubfieldName, $toFieldName, $toSubfieldName, $regex, $n , "don't_erase");
copy_field( $record, $fromFieldName, $fromSubfieldName, $toFieldName, $toSubfieldName, $regex, $n , 1);
delete_field( $record, $fromFieldName, $fromSubfieldName, $n );
}
=head2
=head2 delete_field
delete_field( $record, $fieldName[, $subfieldName [, $n ] ] );
@ -296,7 +296,7 @@ sub delete_field {
}
}
=head2
=head2 _update_repeatable_field_with_single_value
_update_repeatable_field_with_single_value( $record, $fieldName, $subfieldName, $value );
@ -316,11 +316,11 @@ sub _update_repeatable_field_with_single_value {
if ( $subfieldName ) {
if ( my @fields = $record->field( $fieldName ) ) {
foreach my $field ( @fields ) {
$field->update( "$subfieldName" => $value );
$field->update( $subfieldName => $value );
}
} else {
## Field does not exist, create it.
$field = MARC::Field->new( $fieldName, '', '', "$subfieldName" => $value );
$field = MARC::Field->new( $fieldName, undef, undef, $subfieldName => $value );
$record->append_fields( $field );
}
} else { ## No subfield

View File

@ -72,7 +72,7 @@
[% END %]
-->
[% IF ( CAN_user_tools_marc_modification_templates ) %]
<li><a href="/cgi-bin/koha/tools/marc_modification_templates.pl">Manage MARC modification templates</a></li>
<li><a href="/cgi-bin/koha/tools/marc_modification_templates.pl">Manage MARC modification templates</a></li>
[% END %]
[% IF ( CAN_user_tools_stage_marc_import ) %]
<li><a href="/cgi-bin/koha/tools/stage-marc-import.pl">Stage MARC for import</a></li>

View File

@ -1,237 +1,237 @@
[% INCLUDE 'doc-head-open.inc' %]
<title>Koha &rsaquo; Tools &rsaquo; MARC Modification Templates</title>
<title>Koha &rsaquo; Tools &rsaquo; MARC modification templates</title>
[% INCLUDE 'doc-head-close.inc' %]
<script type="text/javascript">
//<![CDATA[
$(document).ready(function() {
$('#select_template').find("input:submit").hide();
$('#select_template').change(function() {
$('#select_template').submit();
});
$('#select_template').find("input:submit").hide();
$('#select_template').change(function() {
$('#select_template').submit();
});
});
//]]>
</script>
<script>
function onActionChange(selectObj) {
// get the index of the selected option
var idx = selectObj.selectedIndex;
// get the index of the selected option
var idx = selectObj.selectedIndex;
// get the value of the selected option
var action = selectObj.options[idx].value;
// get the value of the selected option
var action = selectObj.options[idx].value;
switch( action ) {
case 'delete_field':
show('field_number_block');
hide('with_value_block');
hide('to_field_block');
break;
switch( action ) {
case 'delete_field':
show('field_number_block');
hide('with_value_block');
hide('to_field_block');
break;
case 'update_field':
hide('field_number_block');
show('with_value_block');
hide('to_field_block');
break;
case 'update_field':
hide('field_number_block');
show('with_value_block');
hide('to_field_block');
break;
case 'move_field':
show('field_number_block');
hide('with_value_block');
show('to_field_block');
break;
case 'move_field':
show('field_number_block');
hide('with_value_block');
show('to_field_block');
break;
case 'copy_field':
show('field_number_block');
hide('with_value_block');
show('to_field_block');
break;
case 'copy_field':
show('field_number_block');
hide('with_value_block');
show('to_field_block');
break;
}
}
}
function onConditionalChange(selectObj) {
// get the index of the selected option
var idx = selectObj.selectedIndex;
// get the index of the selected option
var idx = selectObj.selectedIndex;
// get the value of the selected option
var action = selectObj.options[idx].value;
// get the value of the selected option
var action = selectObj.options[idx].value;
switch( action ) {
case '':
hide('conditional_block');
break;
switch( action ) {
case '':
hide('conditional_block');
break;
case 'if':
case 'unless':
show('conditional_block');
break;
}
case 'if':
case 'unless':
show('conditional_block');
break;
}
}
function onConditionalComparisonChange(selectObj) {
// get the index of the selected option
var idx = selectObj.selectedIndex;
// get the index of the selected option
var idx = selectObj.selectedIndex;
// get the value of the selected option
var action = selectObj.options[idx].value;
// get the value of the selected option
var action = selectObj.options[idx].value;
switch( action ) {
case 'equals':
case 'not_equals':
show('conditional_comparison_block');
break;
switch( action ) {
case 'equals':
case 'not_equals':
show('conditional_comparison_block');
break;
default:
hide('conditional_comparison_block');
break;
}
default:
hide('conditional_comparison_block');
break;
}
}
function onToFieldRegexChange( checkboxObj ) {
if ( checkboxObj.checked ) {
show('to_field_regex_value_block');
} else {
hide('to_field_regex_value_block');
}
if ( checkboxObj.checked ) {
show('to_field_regex_value_block');
} else {
hide('to_field_regex_value_block');
}
}
function onConditionalRegexChange( checkboxObj ) {
if ( checkboxObj.checked ) {
document.getElementById( 'match_regex_prefix' ).style.visibility='visible';
} else {
document.getElementById( 'match_regex_prefix' ).style.visibility='hidden';
}
if ( checkboxObj.checked ) {
document.getElementById( 'match_regex_prefix' ).style.visibility='visible';
} else {
document.getElementById( 'match_regex_prefix' ).style.visibility='hidden';
}
}
function show(eltId) {
elt = document.getElementById( eltId );
elt.style.display='inline';
elt = document.getElementById( eltId );
elt.style.display='inline';
}
function hide(eltId) {
clearFormElements( eltId );
elt = document.getElementById( eltId );
elt.style.display='none';
clearFormElements( eltId );
elt = document.getElementById( eltId );
elt.style.display='none';
}
function clearFormElements(divId) {
myBlock = document.getElementById( divId );
myBlock = document.getElementById( divId );
var inputElements = myBlock.getElementsByTagName( "input" );
for (var i = 0; i < inputElements.length; i++) {
switch( inputElements[i].type ) {
case "text":
inputElements[i].value = '';
break;
case "checkbox":
inputElements[i].checked = false;
break;
}
}
var inputElements = myBlock.getElementsByTagName( "input" );
for (var i = 0; i < inputElements.length; i++) {
switch( inputElements[i].type ) {
case "text":
inputElements[i].value = '';
break;
case "checkbox":
inputElements[i].checked = false;
break;
}
}
var selectElements = myBlock.getElementsByTagName( "select" );
for (var i = 0; i < selectElements.length; i++) {
selectElements[i].selectedIndex = 0;
}
var selectElements = myBlock.getElementsByTagName( "select" );
for (var i = 0; i < selectElements.length; i++) {
selectElements[i].selectedIndex = 0;
}
}
function confirmDelete() {
var agree = confirm("Are you sure you wish to delete this template?");
return agree;
var agree = confirm("Are you sure you wish to delete this template?");
return agree;
}
var modaction_legend_innerhtml;
var action_submit_value;
function editAction( mmta_id, ordering, action, field_number, from_field, from_subfield, field_value, to_field,
to_subfield, to_regex, conditional, conditional_field, conditional_subfield,
conditional_comparison, conditional_value, conditional_regex, description
to_subfield, to_regex, conditional, conditional_field, conditional_subfield,
conditional_comparison, conditional_value, conditional_regex, description
) {
document.getElementById('mmta_id').value = mmta_id;
document.getElementById('mmta_id').value = mmta_id;
setSelectByValue( 'action', action );
document.getElementById('action').onchange();
setSelectByValue( 'action', action );
document.getElementById('action').onchange();
setSelectByValue( 'field_number', field_number );
setSelectByValue( 'field_number', field_number );
document.getElementById('from_field').value = from_field;
document.getElementById('from_subfield').value = from_subfield;
document.getElementById('field_value').value = field_value;
document.getElementById('to_field').value = to_field;
document.getElementById('to_subfield').value = to_subfield;
document.getElementById('to_regex').value = to_regex;
document.getElementById('from_field').value = from_field;
document.getElementById('from_subfield').value = from_subfield;
document.getElementById('field_value').value = field_value;
document.getElementById('to_field').value = to_field;
document.getElementById('to_subfield').value = to_subfield;
document.getElementById('to_regex').value = to_regex;
document.getElementById('to_field_regex').checked = to_regex.length;
document.getElementById('to_field_regex').onchange();
document.getElementById('to_field_regex').checked = to_regex.length;
document.getElementById('to_field_regex').onchange();
setSelectByValue( 'conditional', conditional );
document.getElementById('conditional').onchange();
setSelectByValue( 'conditional', conditional );
document.getElementById('conditional').onchange();
document.getElementById('conditional_field').value = conditional_field;
document.getElementById('conditional_subfield').value = conditional_subfield;
document.getElementById('conditional_field').value = conditional_field;
document.getElementById('conditional_subfield').value = conditional_subfield;
setSelectByValue( 'conditional_comparison', conditional_comparison );
document.getElementById('conditional_comparison').onchange();
setSelectByValue( 'conditional_comparison', conditional_comparison );
document.getElementById('conditional_comparison').onchange();
document.getElementById('conditional_value').value = conditional_value;
document.getElementById('conditional_value').value = conditional_value;
document.getElementById('conditional_regex').checked = parseInt( conditional_regex );
document.getElementById('conditional_regex').checked = parseInt( conditional_regex );
document.getElementById('description').value = description;
document.getElementById('description').value = description;
window.modaction_legend_innerhtml = document.getElementById('modaction_legend').innerhtml;
document.getElementById('modaction_legend').innerhtml = "Edit Action " + ordering;
window.modaction_legend_innerhtml = document.getElementById('modaction_legend').innerhtml;
document.getElementById('modaction_legend').innerhtml = "Edit Action " + ordering;
window.action_submit_value = document.getElementById('action_submit').value;
document.getElementById('action_submit').value = "Update Action";
window.action_submit_value = document.getElementById('action_submit').value;
document.getElementById('action_submit').value = "Update Action";
show('cancel_edit');
show('cancel_edit');
}
function cancelEditAction() {
document.getElementById('mmta_id').value = '';
document.getElementById('mmta_id').value = '';
setSelectByValue( 'action', 'delete_field' );
document.getElementById('action').onchange();
setSelectByValue( 'action', 'delete_field' );
document.getElementById('action').onchange();
document.getElementById('from_field').value = '';
document.getElementById('from_subfield').value = '';
document.getElementById('field_value').value = '';
document.getElementById('to_field').value = '';
document.getElementById('to_subfield').value = '';
document.getElementById('to_regex').value = '';
document.getElementById('from_field').value = '';
document.getElementById('from_subfield').value = '';
document.getElementById('field_value').value = '';
document.getElementById('to_field').value = '';
document.getElementById('to_subfield').value = '';
document.getElementById('to_regex').value = '';
document.getElementById('to_field_regex').checked = false;
document.getElementById('to_field_regex').onchange();
document.getElementById('to_field_regex').checked = false;
document.getElementById('to_field_regex').onchange();
setSelectByValue( 'conditional', '' );
document.getElementById('conditional').onchange();
setSelectByValue( 'conditional', '' );
document.getElementById('conditional').onchange();
document.getElementById('conditional_field').value = '';
document.getElementById('conditional_subfield').value = '';
document.getElementById('conditional_field').value = '';
document.getElementById('conditional_subfield').value = '';
setSelectByValue( 'conditional_comparison', '' );
document.getElementById('conditional_comparison').onchange();
setSelectByValue( 'conditional_comparison', '' );
document.getElementById('conditional_comparison').onchange();
document.getElementById('conditional_value').value = '';
document.getElementById('conditional_value').value = '';
document.getElementById('conditional_regex').checked = false;
document.getElementById('conditional_regex').checked = false;
document.getElementById('modaction_legend').innerhtml = window.modaction_legend_innerhtml;
document.getElementById('action_submit').value = window.action_submit_value;
document.getElementById('modaction_legend').innerhtml = window.modaction_legend_innerhtml;
document.getElementById('action_submit').value = window.action_submit_value;
hide('cancel_edit');
hide('cancel_edit');
}
function setSelectByValue( selectId, value ) {
s = document.getElementById( selectId );
s = document.getElementById( selectId );
for ( i = 0; i < s.options.length; i++ ) {
if ( s.options[i].value == value ) {
s.selectedIndex = i;
}
}
for ( i = 0; i < s.options.length; i++ ) {
if ( s.options[i].value == value ) {
s.selectedIndex = i;
}
}
}
</script>
@ -242,251 +242,252 @@ function setSelectByValue( selectId, value ) {
[% INCLUDE 'header.inc' %]
[% INCLUDE 'cat-search.inc' %]
<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a> &rsaquo; MARC Modification Templates</div>
<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a> &rsaquo; MARC modification templates</div>
<div id="doc3" class="yui-t2">
<div id="yui-main">
<div class="yui-b">
<h2>MARC Modification Templates</h2>
<div id="yui-main">
<div class="yui-b">
<h2>MARC modification templates</h2>
[% IF ( TemplatesLoop ) %]
[% IF ( TemplatesLoop ) %]
<form method="get" action="/cgi-bin/koha/tools/marc_modification_templates.pl" id="select_template">
<label for="select_template">Template: </label>
<select name="template_id" id="select_template" style="width:20em;">
[% FOREACH TemplatesLoo IN TemplatesLoop %]
<option value="[% TemplatesLoo.template_id %]" [% IF ( TemplatesLoo.selected ) %] selected [% END %] > [% TemplatesLoo.name %]</option>
[% END %]
</select>
<input type="hidden" name="op" value="select_template">
<input type="submit" value="Go" />
</form>
<form method="get" action="/cgi-bin/koha/tools/marc_modification_templates.pl" id="select_template">
<label for="select_template">Template: </label>
<select name="template_id" id="select_template" style="width:20em;">
[% FOREACH TemplatesLoo IN TemplatesLoop %]
[% IF ( TemplatesLoo.selected ) %]
<option value="[% TemplatesLoo.template_id %]" selected="selected"> [% TemplatesLoo.name %]</option>
[% ELSE %]
<option value="[% TemplatesLoo.template_id %]"> [% TemplatesLoo.name %]</option>
[% END %]
[% END %]
</select>
<input type="hidden" name="op" value="select_template">
<input type="submit" value="Go" />
</form>
<form method="get" action="/cgi-bin/koha/tools/marc_modification_templates.pl" id="delete_template">
<input type="hidden" name="template_id" value="[% template_id %]" />
<input type="hidden" name="op" value="delete_template">
<input type="submit" value="Delete Template" onClick="return confirmDelete()" />
</form>
<form method="get" action="/cgi-bin/koha/tools/marc_modification_templates.pl" id="delete_template">
<input type="hidden" name="template_id" value="[% template_id %]" />
<input type="hidden" name="op" value="delete_template">
<input type="submit" value="Delete template" onClick="return confirmDelete()" />
</form>
[% IF ( ActionsLoop ) %]
<table>
<caption>Actions for this template</caption>
[% IF ( ActionsLoop ) %]
<table>
<caption>Actions for this template</caption>
<tr>
<th>Change Order</th>
<th>Order</th>
<th>Action</th>
<th>Description</th>
<th>&nbsp</th>
<th>&nbsp</th>
</tr>
<tr>
<th>Change Order</th>
<th>Order</th>
<th>Action</th>
<th>Description</th>
<th>&nbsp</th>
<th>&nbsp</th>
</tr>
[% FOREACH ActionsLoo IN ActionsLoop %]
<tr>
<td style="white-space:nowrap;">
<a title="Move Action Up" href="marc_modification_templates.pl?op=move_action&amp;where=up&amp;template_id=[% ActionsLoo.template_id %]&amp;mmta_id=[% ActionsLoo.mmta_id %]">
<img src="/intranet-tmpl/[% theme %]/img/go-up.png" border="0" alt="Go up" />
</a>
[% FOREACH ActionsLoo IN ActionsLoop %]
<tr>
<td style="white-space:nowrap;">
<a title="Move Action Up" href="marc_modification_templates.pl?op=move_action&amp;where=up&amp;template_id=[% ActionsLoo.template_id %]&amp;mmta_id=[% ActionsLoo.mmta_id %]">
<img src="/intranet-tmpl/[% theme %]/img/go-up.png" border="0" alt="Go up" />
</a>
<a title="Move Action To Top" href="marc_modification_templates.pl?op=move_action&amp;where=top&amp;template_id=[% ActionsLoo.template_id %]&amp;mmta_id=[% ActionsLoo.mmta_id %]">
<img src="/intranet-tmpl/[% theme %]/img/go-top.png" border="0" alt="Go top" />
</a>
<a title="Move Action To Top" href="marc_modification_templates.pl?op=move_action&amp;where=top&amp;template_id=[% ActionsLoo.template_id %]&amp;mmta_id=[% ActionsLoo.mmta_id %]">
<img src="/intranet-tmpl/[% theme %]/img/go-top.png" border="0" alt="Go top" />
</a>
<a title="Move Action To Bottom" href="marc_modification_templates.pl?op=move_action&amp;where=bottom&amp;template_id=[% ActionsLoo.template_id %]&amp;mmta_id=[% ActionsLoo.mmta_id %]">
<img src="/intranet-tmpl/[% theme %]/img/go-bottom.png" border="0" alt="Go bottom" />
</a>
<a title="Move Action To Bottom" href="marc_modification_templates.pl?op=move_action&amp;where=bottom&amp;template_id=[% ActionsLoo.template_id %]&amp;mmta_id=[% ActionsLoo.mmta_id %]">
<img src="/intranet-tmpl/[% theme %]/img/go-bottom.png" border="0" alt="Go bottom" />
</a>
<a title="Move Action Down" href="marc_modification_templates.pl?op=move_action&amp;where=down&amp;template_id=[% ActionsLoo.template_id %]&amp;mmta_id=[% ActionsLoo.mmta_id %]">
<img src="/intranet-tmpl/[% theme %]/img/go-down.png" border="0" alt="Go down" />
</a>
</td>
<a title="Move Action Down" href="marc_modification_templates.pl?op=move_action&amp;where=down&amp;template_id=[% ActionsLoo.template_id %]&amp;mmta_id=[% ActionsLoo.mmta_id %]">
<img src="/intranet-tmpl/[% theme %]/img/go-down.png" border="0" alt="Go down" />
</a>
</td>
<td>[% ActionsLoo.ordering %]</td>
<td>
[% IF ( ActionsLoo.action_delete_field ) %] Delete [% END %]
[% IF ( ActionsLoo.action_update_field ) %] Update [% END %]
[% IF ( ActionsLoo.action_move_field ) %] Move [% END %]
[% IF ( ActionsLoo.action_copy_field ) %] Copy [% END %]
<td>[% ActionsLoo.ordering %]</td>
<td>
[% IF ( ActionsLoo.action_delete_field ) %] Delete [% END %]
[% IF ( ActionsLoo.action_update_field ) %] Update [% END %]
[% IF ( ActionsLoo.action_move_field ) %] Move [% END %]
[% IF ( ActionsLoo.action_copy_field ) %] Copy [% END %]
[% UNLESS ( ActionsLoo.action_update_field ) %]
[% IF ( ActionsLoo.field_number ) %]
1st
[% END %]
[% END %]
[% UNLESS ( ActionsLoo.action_update_field ) %]
[% IF ( ActionsLoo.field_number ) %]
1st
[% END %]
[% END %]
field
field
[% ActionsLoo.from_field %][% IF ( ActionsLoo.from_subfield ) %]$[% ActionsLoo.from_subfield %][% END %]
[% ActionsLoo.from_field %][% IF ( ActionsLoo.from_subfield ) %]$[% ActionsLoo.from_subfield %][% END %]
[% IF ( ActionsLoo.field_value ) %]
with value <i>[% ActionsLoo.field_value %]</i>
[% END %]
[% IF ( ActionsLoo.field_value ) %]
with value <i>[% ActionsLoo.field_value %]</i>
[% END %]
[% IF ( ActionsLoo.to_field ) %]
to [% ActionsLoo.to_field %][% IF ( ActionsLoo.to_subfield ) %]$[% ActionsLoo.to_subfield %][% END %]
[% IF ( ActionsLoo.to_field ) %]
to [% ActionsLoo.to_field %][% IF ( ActionsLoo.to_subfield ) %]$[% ActionsLoo.to_subfield %][% END %]
[% IF ( ActionsLoo.to_regex ) %]
using RegEx s<strong>[% ActionsLoo.to_regex %]</strong>
[% END %]
[% END %]
[% IF ( ActionsLoo.to_regex ) %]
using RegEx s<strong>[% ActionsLoo.to_regex %]</strong>
[% END %]
[% END %]
[% IF ( ActionsLoo.conditional ) %]
[% IF ( ActionsLoo.conditional_if ) %] if [% END %]
[% IF ( ActionsLoo.conditional_unless ) %] unless [% END %]
[% IF ( ActionsLoo.conditional ) %]
[% IF ( ActionsLoo.conditional_if ) %] if [% END %]
[% IF ( ActionsLoo.conditional_unless ) %] unless [% END %]
[% ActionsLoo.conditional_field %][% IF ( ActionsLoo.conditional_subfield ) %]$[% ActionsLoo.conditional_subfield %][% END %]
[% ActionsLoo.conditional_field %][% IF ( ActionsLoo.conditional_subfield ) %]$[% ActionsLoo.conditional_subfield %][% END %]
[% IF ( ActionsLoo.conditional_comparison_exists ) %] exists [% END %]
[% IF ( ActionsLoo.conditional_comparison_not_exists ) %] does not exist [% END %]
[% IF ( ActionsLoo.conditional_comparison_equals ) %] matches [% END %]
[% IF ( ActionsLoo.conditional_comparison_not_equals ) %] does not match [% END %]
[% IF ( ActionsLoo.conditional_comparison_exists ) %] exists [% END %]
[% IF ( ActionsLoo.conditional_comparison_not_exists ) %] does not exist [% END %]
[% IF ( ActionsLoo.conditional_comparison_equals ) %] matches [% END %]
[% IF ( ActionsLoo.conditional_comparison_not_equals ) %] does not match [% END %]
[% IF ( ActionsLoo.conditional_regex ) %] RegEx m[% END %]<strong>[% ActionsLoo.conditional_value %]</strong>
[% END %]
</td>
<td>[% ActionsLoo.description %]</td>
<td><a href="#modaction" onclick='editAction(
"[% ActionsLoo.mmta_id |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
"[% ActionsLoo.ordering |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
"[% ActionsLoo.action |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
"[% ActionsLoo.field_number |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
"[% ActionsLoo.from_field |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
"[% ActionsLoo.from_subfield |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
"[% ActionsLoo.field_value |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
"[% ActionsLoo.to_field |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
"[% ActionsLoo.to_subfield |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
"[% ActionsLoo.to_regex |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
"[% ActionsLoo.conditional |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
"[% ActionsLoo.conditional_field |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
"[% ActionsLoo.conditional_subfield |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
"[% ActionsLoo.conditional_comparison |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
"[% ActionsLoo.conditional_value |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
"[% ActionsLoo.conditional_regex |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
"[% ActionsLoo.description |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]"
)'>Edit</a></td>
<td><a href="marc_modification_templates.pl?template_id=[% ActionsLoo.template_id %]&op=delete_action&mmta_id=[% ActionsLoo.mmta_id %]">Delete</a></td>
</tr>
[% END %]
</table>
[% ELSE %]
<div class="dialog message"><p>There are no defined actions for this template.</p></div>
[% END %]
[% IF ( ActionsLoo.conditional_regex ) %] RegEx m[% END %]<strong>[% ActionsLoo.conditional_value %]</strong>
[% END %]
</td>
<td>[% ActionsLoo.description %]</td>
<td><a href="#modaction" onclick='editAction(
"[% ActionsLoo.mmta_id |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
"[% ActionsLoo.ordering |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
"[% ActionsLoo.action |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
"[% ActionsLoo.field_number |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
"[% ActionsLoo.from_field |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
"[% ActionsLoo.from_subfield |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
"[% ActionsLoo.field_value |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
"[% ActionsLoo.to_field |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
"[% ActionsLoo.to_subfield |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
"[% ActionsLoo.to_regex |replace('\\\\', '\\\\') |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
"[% ActionsLoo.conditional |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
"[% ActionsLoo.conditional_field |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
"[% ActionsLoo.conditional_subfield |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
"[% ActionsLoo.conditional_comparison |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
"[% ActionsLoo.conditional_value |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
"[% ActionsLoo.conditional_regex |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
"[% ActionsLoo.description |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]"
)'>Edit</a></td>
<td><a href="marc_modification_templates.pl?template_id=[% ActionsLoo.template_id %]&op=delete_action&mmta_id=[% ActionsLoo.mmta_id %]">Delete</a></td>
</tr>
[% END %]
</table>
[% ELSE %]
<div class="dialog message"><p>There are no defined actions for this template.</p></div>
[% END %]
<form method="post" action="/cgi-bin/koha/tools/marc_modification_templates.pl" id="add_action" >
<a name="modaction"></a>
<fieldset>
<legend id="modaction_legend">Add A New Action</legend>
<form method="post" action="/cgi-bin/koha/tools/marc_modification_templates.pl" id="add_action" >
<a name="modaction"></a>
<fieldset>
<legend id="modaction_legend">Add A New Action</legend>
<select name="action" id="action" onchange="onActionChange(this);">
<option value="delete_field">Delete</option>
<option value="update_field">Add/Update</option>
<option value="move_field">Move</option>
<option value="copy_field">Copy</option>
</select>
<select name="action" id="action" onchange="onActionChange(this);">
<option value="delete_field">Delete</option>
<option value="update_field">Add/Update</option>
<option value="move_field">Move</option>
<option value="copy_field">Copy</option>
</select>
<span id="field_number_block">
<select name="field_number" id="field_number">
<option value="0">All</option>
<option value="1">1st</option>
</select>
</span>
<span id="field_number_block">
<select name="field_number" id="field_number">
<option value="0">All</option>
<option value="1">1st</option>
</select>
</span>
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" />
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" />
<span name="with_value_block" id="with_value_block" style="display:none;">
with value <input type="text" name="field_value" id="field_value" />
</span>
<span name="with_value_block" id="with_value_block" style="display:none;">
with value <input type="text" name="field_value" id="field_value" />
</span>
<span name="to_field_block" id="to_field_block" style="display:none;">
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" />
<span name="to_field_block" id="to_field_block" style="display:none;">
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" />
<span name="to_field_regex_block" id="to_field_regex_block">
<sup>
<label for="to_field_regex">RegEx</label>
<input type="checkbox" name="to_field_regex" id="to_field_regex" onchange="onToFieldRegexChange(this);" />
<span name="to_field_regex_block" id="to_field_regex_block">
<sup>
<label for="to_field_regex">RegEx</label>
<input type="checkbox" name="to_field_regex" id="to_field_regex" onchange="onToFieldRegexChange(this);" />
<span name="to_field_regex_value_block" id="to_field_regex_value_block" style="display:none;">
s<input type="text" name="to_regex" id="to_regex" />
</span>
</sup>
</span>
</span>
<span name="to_field_regex_value_block" id="to_field_regex_value_block" style="display:none;">
s<input type="text" name="to_regex" id="to_regex" />
</span>
</sup>
</span>
</span>
<p/>
<p/>
<select name="conditional" id="conditional" onchange="onConditionalChange(this);">
<option value="" selected />
<option value="if">if</option>
<option value="unless">unless</option>
</select>
<select name="conditional" id="conditional" onchange="onConditionalChange(this);">
<option value="" selected />
<option value="if">if</option>
<option value="unless">unless</option>
</select>
<span name="conditional_block" id="conditional_block" style="display:none;">
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" />
<span name="conditional_block" id="conditional_block" style="display:none;">
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" />
<select name="conditional_comparison" id="conditional_comparison" onchange="onConditionalComparisonChange(this);">
<option value="" />
<option value="exists">exists</option>
<option value="not_exists">doesn't exist</option>
<option value="equals">matches</option>
<option value="not_equals">doesn't match</option>
</select>
<select name="conditional_comparison" id="conditional_comparison" onchange="onConditionalComparisonChange(this);">
<option value="" />
<option value="exists">exists</option>
<option value="not_exists">doesn't exist</option>
<option value="equals">matches</option>
<option value="not_equals">doesn't match</option>
</select>
<span name="conditional_comparison_block" id="conditional_comparison_block" style="display:none;">
<span name="conditional_comparison_block" id="conditional_comparison_block" style="display:none;">
<span id="match_regex_prefix" style="visibility:hidden;">m</span><input type="text" id="conditional_value" name="conditional_value" />
<span id="match_regex_prefix" style="visibility:hidden;">m</span><input type="text" id="conditional_value" name="conditional_value" />
<sup>
<label for="conditional_regex">RegEx</label>
<input type="checkbox" name="conditional_regex" id="conditional_regex" onchange="onConditionalRegexChange(this);" />
</sup>
<sup>
<label for="conditional_regex">RegEx</label>
<input type="checkbox" name="conditional_regex" id="conditional_regex" onchange="onConditionalRegexChange(this);" />
</sup>
</span>
</span>
</span>
</span>
<input type="hidden" name="template_id" value="[% template_id %]" />
<input type="hidden" name="mmta_id" id="mmta_id" />
<input type="hidden" name="op" value="add_action" />
<input type="hidden" name="template_id" value="[% template_id %]" />
<input type="hidden" name="mmta_id" id="mmta_id" />
<input type="hidden" name="op" value="add_action" />
<br/><br/>
<label for="description">Description:</label>
<input type="text" name="description" id="description" size="60" />
<br/><br/>
<label for="description">Description:</label>
<input type="text" name="description" id="description" size="60" />
<br/><br/>
<input id="action_submit" type="submit" value="Add Action" /> <a href="#modaction" id="cancel_edit" onclick="cancelEditAction();" style="display:none;">Cancel</a>
<br/><br/>
<input id="action_submit" type="submit" value="Add Action" /> <a href="#modaction" id="cancel_edit" onclick="cancelEditAction();" style="display:none;">Cancel</a>
</fieldset>
</form>
</fieldset>
</form>
[% ELSE %]
<div class="dialog message"><p>There are no defined templates. Please create a template first.</p></div>
[% END %]
[% ELSE %]
<div class="dialog message"><p>There are no defined templates. Please create a template first.</p></div>
[% END %]
<form method="post" action="/cgi-bin/koha/tools/marc_modification_templates.pl" id="add_template" >
<fieldset>
<legend>Create A New Template</legend>
<form method="post" action="/cgi-bin/koha/tools/marc_modification_templates.pl" id="add_template" >
<fieldset>
<legend>Create a new template</legend>
<label for="template_name">Name: </label>
<input name="template_name" id="template_name" type="text" size="30" />
<label for="template_name">Name: </label>
<input name="template_name" id="template_name" type="text" size="30" />
<input type="hidden" name="op" value="create_template" />
<input type="submit" value="Create Template" />
<input type="hidden" name="op" value="create_template" />
<input type="submit" value="Create template" />
[% IF ( template_id ) %]
<input type="hidden" name="template_id" value="[% template_id %]" />
<input type="checkbox" name="duplicate_current_template" id="duplicate_current_template" />
<label for="duplicate_current_template">Duplicate Current Template</label>
[% END %]
</fieldset>
</form>
[% IF ( template_id ) %]
<input type="hidden" name="template_id" value="[% template_id %]" />
<input type="checkbox" name="duplicate_current_template" id="duplicate_current_template" />
<label for="duplicate_current_template">Duplicate current template</label>
[% END %]
</fieldset>
</form>
</div>
</div>
</div>
</div>
<div class="yui-b">
[% INCLUDE 'tools-menu.inc' %]
</div>
<div class="yui-b">
[% INCLUDE 'tools-menu.inc' %]
</div>
</div>
[% INCLUDE 'intranet-bottom.inc' %]

View File

@ -32,13 +32,14 @@ my $op = $cgi->param('op');
my $template_id = $cgi->param('template_id');
my ($template, $loggedinuser, $cookie)
= get_template_and_user({template_name => "tools/marc_modification_templates.tmpl",
query => $cgi,
type => "intranet",
authnotrequired => 0,
flagsrequired => { tools => 'marc_modfication_templates' },
debug => 1,
});
= get_template_and_user({
template_name => "tools/marc_modification_templates.tmpl",
query => $cgi,
type => "intranet",
authnotrequired => 0,
flagsrequired => { tools => 'marc_modfication_templates' },
debug => 1,
});
if ( $op eq "create_template" ) {
$template_id = '' unless $cgi->param('duplicate_current_template');