Bugzilla – Attachment 4344 Details for
Bug 5453
Variables declaration should not occur in conditionals
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Proposed Patch
0005-Bug-5453-Move-declarations-out-of-conditionals-in-op.patch (text/plain), 11.29 KB, created by
Colin Campbell
on 2011-06-02 14:55:08 UTC
(
hide
)
Description:
Proposed Patch
Filename:
MIME Type:
Creator:
Colin Campbell
Created:
2011-06-02 14:55:08 UTC
Size:
11.29 KB
patch
obsolete
>From 6e900353bf8f9d1e5b0f17608c685b9f3b8bc960 Mon Sep 17 00:00:00 2001 >From: Colin Campbell <colin.campbell@ptfs-europe.com> >Date: Mon, 29 Nov 2010 15:15:47 +0000 >Subject: [PATCH 5/7] Bug 5453 Move declarations out of conditionals in opac >Content-Type: text/plain; charset="utf-8" > >--- > opac/opac-ISBDdetail.pl | 5 +++- > opac/opac-authorities-home.pl | 26 +++++++++++--------- > opac/opac-authoritiesdetail.pl | 16 +++++------- > opac/opac-detail.pl | 5 +++- > opac/opac-search.pl | 49 ++++++++++++++++++++++++++++----------- > opac/opac-topissues.pl | 6 +--- > opac/opac-user.pl | 14 +++++++---- > 7 files changed, 75 insertions(+), 46 deletions(-) > >diff --git a/opac/opac-ISBDdetail.pl b/opac/opac-ISBDdetail.pl >index b50947d..7351788 100755 >--- a/opac/opac-ISBDdetail.pl >+++ b/opac/opac-ISBDdetail.pl >@@ -85,7 +85,10 @@ my $upc = GetNormalizedUPC($record,$marcflavour); > my $ean = GetNormalizedEAN($record,$marcflavour); > my $oclc = GetNormalizedOCLCNumber($record,$marcflavour); > my $isbn = GetNormalizedISBN(undef,$record,$marcflavour); >-my $content_identifier_exists = 1 if ($isbn or $ean or $oclc or $upc); >+my $content_identifier_exists; >+if ( $isbn or $ean or $oclc or $upc ) { >+ $content_identifier_exists = 1; >+} > $template->param( > normalized_upc => $upc, > normalized_ean => $ean, >diff --git a/opac/opac-authorities-home.pl b/opac/opac-authorities-home.pl >index a87030e..acff077 100755 >--- a/opac/opac-authorities-home.pl >+++ b/opac/opac-authorities-home.pl >@@ -41,18 +41,20 @@ $startfrom = 0 if ( !defined $startfrom ); > my ( $template, $loggedinuser, $cookie ); > my $resultsperpage; > >-my $authtypes = getauthtypes; >-my @authtypesloop; >-foreach my $thisauthtype ( sort { $authtypes->{$a}{'authtypetext'} cmp $authtypes->{$b}{'authtypetext'} } >- keys %$authtypes ) >-{ >- my $selected = 1 if $thisauthtype eq $authtypecode; >- my %row = ( >- value => $thisauthtype, >- selected => $selected, >- authtypetext => $authtypes->{$thisauthtype}{'authtypetext'}, >- ); >- push @authtypesloop, \%row; >+my $authtypes = getauthtypes(); >+my @authtypesloop = (); >+foreach my $thisauthtype ( >+ sort { >+ $authtypes->{$a}->{'authtypetext'} >+ cmp $authtypes->{$b}->{'authtypetext'} >+ } >+ keys %{$authtypes} >+ ) { >+ push @authtypesloop, >+ { value => $thisauthtype, >+ selected => $thisauthtype eq $authtypecode, >+ authtypetext => $authtypes->{$thisauthtype}->{'authtypetext'}, >+ }; > } > > if ( $op eq "do_search" ) { >diff --git a/opac/opac-authoritiesdetail.pl b/opac/opac-authoritiesdetail.pl >index 27ca8cc..6610dfd 100755 >--- a/opac/opac-authoritiesdetail.pl >+++ b/opac/opac-authoritiesdetail.pl >@@ -170,16 +170,14 @@ foreach my $field (@fields) { > } > $template->param( "Tab0XX" => \@loop_data ); > >-my $authtypes = getauthtypes; >-my @authtypesloop; >-foreach my $thisauthtype ( keys %$authtypes ) { >- my $selected = 1 if $thisauthtype eq $authtypecode; >- my %row = ( >- value => $thisauthtype, >- selected => $selected, >+my $authtypes = getauthtypes(); >+my @authtypesloop = (); >+foreach my $thisauthtype ( keys %{$authtypes} ) { >+ push @authtypesloop, >+ { value => $thisauthtype, >+ selected => $thisauthtype eq $authtypecode, > authtypetext => $authtypes->{$thisauthtype}{'authtypetext'}, >- ); >- push @authtypesloop, \%row; >+ }; > } > > $template->param( >diff --git a/opac/opac-detail.pl b/opac/opac-detail.pl >index b357a56..d55b6fd 100755 >--- a/opac/opac-detail.pl >+++ b/opac/opac-detail.pl >@@ -281,7 +281,10 @@ my $upc = GetNormalizedUPC($record,$marcflavour); > my $ean = GetNormalizedEAN($record,$marcflavour); > my $oclc = GetNormalizedOCLCNumber($record,$marcflavour); > my $isbn = GetNormalizedISBN(undef,$record,$marcflavour); >-my $content_identifier_exists = 1 if ($isbn or $ean or $oclc or $upc); >+my $content_identifier_exists; >+if ( $isbn or $ean or $oclc or $upc ) { >+ $content_identifier_exists = 1; >+} > $template->param( > normalized_upc => $upc, > normalized_ean => $ean, >diff --git a/opac/opac-search.pl b/opac/opac-search.pl >index 7f247c7..cd34610 100755 >--- a/opac/opac-search.pl >+++ b/opac/opac-search.pl >@@ -207,9 +207,13 @@ if ( $template_type && $template_type eq 'advsearch' ) { > $template->param(outer_sup_servers_loop => $secondary_servers_loop,); > > # set the default sorting >- my $default_sort_by = C4::Context->preference('OPACdefaultSortField')."_".C4::Context->preference('OPACdefaultSortOrder') >- if (C4::Context->preference('OPACdefaultSortField') && C4::Context->preference('OPACdefaultSortOrder')); >- $template->param($default_sort_by => 1); >+ if ( C4::Context->preference('OPACdefaultSortField') >+ && C4::Context->preference('OPACdefaultSortOrder') ) { >+ my $default_sort_by = >+ C4::Context->preference('OPACdefaultSortField') . '_' >+ . C4::Context->preference('OPACdefaultSortOrder'); >+ $template->param( $default_sort_by => 1 ); >+ } > > # determine what to display next to the search boxes (ie, boolean option > # shouldn't appear on the first one, scan indexes should, adding a new >@@ -273,8 +277,13 @@ $tag = $params->{tag} if $params->{tag}; > # sort by is used to sort the query > # in theory can have more than one but generally there's just one > my @sort_by; >-my $default_sort_by = C4::Context->preference('OPACdefaultSortField')."_".C4::Context->preference('OPACdefaultSortOrder') >- if (C4::Context->preference('OPACdefaultSortField') && C4::Context->preference('OPACdefaultSortOrder')); >+my $default_sort_by; >+if ( C4::Context->preference('OPACdefaultSortField') >+ && C4::Context->preference('OPACdefaultSortOrder') ) { >+ $default_sort_by = >+ C4::Context->preference('OPACdefaultSortField') . '_' >+ . C4::Context->preference('OPACdefaultSortOrder'); >+} > > @sort_by = split("\0",$params->{'sort_by'}) if $params->{'sort_by'}; > $sort_by[0] = $default_sort_by if !$sort_by[0] && defined($default_sort_by); >@@ -568,8 +577,13 @@ for (my $i=0;$i<@servers;$i++) { > my $pages = ceil($hits / $results_per_page); > # default page number > my $current_page_number = 1; >- $current_page_number = ($offset / $results_per_page + 1) if $offset; >- my $previous_page_offset = $offset - $results_per_page unless ($offset - $results_per_page <0); >+ if ($offset) { >+ $current_page_number = ( $offset / $results_per_page + 1 ); >+ } >+ my $previous_page_offset; >+ if ( $offset >= $results_per_page ) { >+ $previous_page_offset = $offset - $results_per_page; >+ } > my $next_page_offset = $offset + $results_per_page; > # If we're within the first 10 pages, keep it simple > #warn "current page:".$current_page_number; >@@ -583,11 +597,14 @@ for (my $i=0;$i<@servers;$i++) { > my $this_offset = (($i*$results_per_page)-$results_per_page); > # the page number for this page > my $this_page_number = $i; >- # it should only be highlighted if it's the current page >- my $highlight = 1 if ($this_page_number == $current_page_number); > # put it in the array >- push @page_numbers, { offset => $this_offset, pg => $this_page_number, highlight => $highlight, sort_by => join " ",@sort_by }; >- >+ push @page_numbers, >+ { offset => $this_offset, >+ pg => $this_page_number, >+ highlight => $this_page_number == $current_page_number, >+ sort_by => join ' ', @sort_by >+ }; >+ > } > > } >@@ -596,9 +613,13 @@ for (my $i=0;$i<@servers;$i++) { > for ($i=$current_page_number; $i<=($current_page_number + 20 );$i++) { > my $this_offset = ((($i-9)*$results_per_page)-$results_per_page); > my $this_page_number = $i-9; >- my $highlight = 1 if ($this_page_number == $current_page_number); >- if ($this_page_number <= $pages) { >- push @page_numbers, { offset => $this_offset, pg => $this_page_number, highlight => $highlight, sort_by => join " ",@sort_by }; >+ if ( $this_page_number <= $pages ) { >+ push @page_numbers, >+ { offset => $this_offset, >+ pg => $this_page_number, >+ highlight => $this_page_number == $current_page_number, >+ sort_by => join ' ', @sort_by >+ }; > } > } > >diff --git a/opac/opac-topissues.pl b/opac/opac-topissues.pl >index 80e7c35..6899215 100755 >--- a/opac/opac-topissues.pl >+++ b/opac/opac-topissues.pl >@@ -127,13 +127,11 @@ $template->param( branchloop => GetBranchesLoop(C4::Context->userenv->{'branch'} > my $itype_or_itemtype = (C4::Context->preference("item-level_itypes"))?'itype':'itemtype'; > $itemtypes = GetItemTypes; > my @itemtypesloop; >-my $selected=1; > if (!$advanced_search_types or $advanced_search_types eq 'itemtypes') { > foreach my $thisitemtype ( sort {$itemtypes->{$a}->{'description'} cmp $itemtypes->{$b}->{'description'} } keys %$itemtypes ) { >- my $selected = 1 if $thisitemtype eq $itemtype; > my %row =( value => $thisitemtype, > description => $itemtypes->{$thisitemtype}->{'description'}, >- selected => $selected, >+ selected => $thisitemtype eq $itemtype, > ); > push @itemtypesloop, \%row; > } >@@ -142,7 +140,7 @@ if (!$advanced_search_types or $advanced_search_types eq 'itemtypes') { > for my $thisitemtype (@$advsearchtypes) { > my $selected = 1 if $thisitemtype->{authorised_value} eq $itemtype; > my %row =( value => $thisitemtype->{authorised_value}, >- selected => $selected, >+ selected => $thisitemtype eq $itemtype, > description => $thisitemtype->{'lib'}, > ); > push @itemtypesloop, \%row; >diff --git a/opac/opac-user.pl b/opac/opac-user.pl >index a2f7d9b..2c31ce7 100755 >--- a/opac/opac-user.pl >+++ b/opac/opac-user.pl >@@ -193,13 +193,17 @@ $template->param( show_barcode => 1 ) if $show_barcode; > # load the branches > my $branches = GetBranches(); > my @branch_loop; >-for my $branch_hash (sort keys %$branches ) { >- my $selected=(C4::Context->userenv && ($branch_hash eq C4::Context->userenv->{branch})) if (C4::Context->preference('SearchMyLibraryFirst')); >+for my $branch_hash ( sort keys %{$branches} ) { >+ my $selected; >+ if ( C4::Context->preference('SearchMyLibraryFirst') ) { >+ $selected = >+ ( C4::Context->userenv >+ && ( $branch_hash eq C4::Context->userenv->{branch} ) ); >+ } > push @branch_loop, >- { >- value => "branch: $branch_hash", >+ { value => "branch: $branch_hash", > branchname => $branches->{$branch_hash}->{'branchname'}, >- selected => $selected >+ selected => $selected, > }; > } > $template->param( branchloop => \@branch_loop ); >-- >1.7.5.2 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 5453
:
4340
|
4341
|
4342
|
4343
|
4344
|
4345
|
4346
|
4455
|
4456
|
4457
|
4458
|
4459
|
4460
|
4461