[Koha-patches] [PATCH] refactor: removing a few unnecessary loops and moving HTML out of script into template
Andrew Moore
andrew.moore at liblime.com
Wed Dec 17 23:30:46 CET 2008
---
cataloguing/additem.pl | 21 +++++--------------
.../prog/en/modules/cataloguing/additem.tmpl | 4 ++-
2 files changed, 9 insertions(+), 16 deletions(-)
diff --git a/cataloguing/additem.pl b/cataloguing/additem.pl
index f8780c2..a0b78d4 100755
--- a/cataloguing/additem.pl
+++ b/cataloguing/additem.pl
@@ -228,12 +228,7 @@ foreach my $field (@fields) {
push(@big_array, \%this_row);
}
}
-#fill big_row with missing data
-foreach my $subfield_code (keys(%witness)) {
- for (my $i=0;$i<=$#big_array;$i++) {
- $big_array[$i]{$subfield_code}=" " unless ($big_array[$i]{$subfield_code});
- }
-}
+
my ($holdingbrtagf,$holdingbrtagsubf) = &GetMarcFromKohaField("items.holdingbranch",$frameworkcode);
@big_array = sort {$a->{$holdingbrtagsubf} cmp $b->{$holdingbrtagsubf}} @big_array;
@@ -241,17 +236,13 @@ my ($holdingbrtagf,$holdingbrtagsubf) = &GetMarcFromKohaField("items.holdingbran
# First, the existing items for display
my @item_value_loop;
my @header_value_loop;
-for (my $i=0;$i<=$#big_array; $i++) {
- my $items_data;
- foreach my $subfield_code (sort keys(%witness)) {
- $items_data .="<td>".$big_array[$i]{$subfield_code}."</td>";
- }
+for my $row ( @big_array ) {
my %row_data;
- $items_data =~ s/"/"/g;
- $row_data{item_value} = $items_data;
- $row_data{itemnumber} = $big_array[$i]->{itemnumber};
+ my @item_fields = map +{ field => $_ || '' }, @$row{ sort keys(%witness) };
+ $row_data{item_value} = [ @item_fields ];
+ $row_data{itemnumber} = $row->{itemnumber};
#reporting this_row values
- $row_data{'nomod'} = $big_array[$i]{'nomod'};
+ $row_data{'nomod'} = $row->{'nomod'};
push(@item_value_loop,\%row_data);
}
foreach my $subfield_code (sort keys(%witness)) {
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tmpl
index 740a47a..866438a 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tmpl
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tmpl
@@ -181,7 +181,9 @@ function CreateKey(){
<tr id="row<!-- TMPL_VAR NAME="itemnumber" -->">
<!-- TMPL_IF Name="nomod"--> <td colspan="2"> </td><!--TMPL_ELSE--><td><a href="additem.pl?op=edititem&biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->&itemnumber=<!-- TMPL_VAR NAME="itemnumber" -->">Edit</a></td>
<td><a class="delete" href="/cgi-bin/koha/cataloguing/additem.pl?op=delitem&biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->&itemnumber=<!-- TMPL_VAR NAME="itemnumber" -->" onclick="confirm_deletion(<!-- TMPL_VAR NAME="biblionumber" -->,<!-- TMPL_VAR NAME="itemnumber" -->); return false;">Delete</a></td><!--/TMPL_IF-->
- <!-- TMPL_VAR NAME="item_value" -->
+ <!-- TMPL_LOOP NAME="item_value" -->
+ <td><!-- TMPL_VAR ESCAPE=HTML NAME="field" --></td>
+ <!-- /TMPL_LOOP -->
</tr>
<!-- /TMPL_LOOP -->
</table>
--
1.5.6
More information about the Koha-patches
mailing list