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,
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" ) {
}
$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(
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,
$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
# 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);
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;
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
+ };
+
}
}
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
+ };
}
}
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;
}
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;
# 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 );