Bug 14544: Get rid of GetSomeShelfNames
[koha-ffzg.git] / C4 / Output.pm
index b7c9556..3ae4c6c 100644 (file)
@@ -8,18 +8,18 @@ package C4::Output;
 #
 # This file is part of Koha.
 #
-# Koha is free software; you can redistribute it and/or modify it under the
-# terms of the GNU General Public License as published by the Free Software
-# Foundation; either version 2 of the License, or (at your option) any later
-# version.
+# Koha is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
 #
-# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
-# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
-# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
+# Koha is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
 #
-# You should have received a copy of the GNU General Public License along
-# with Koha; if not, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+# You should have received a copy of the GNU General Public License
+# along with Koha; if not, see <http://www.gnu.org/licenses>.
 
 
 # NOTE: I'm pretty sure this module is deprecated in favor of
@@ -31,8 +31,6 @@ use strict;
 use URI::Escape;
 
 use C4::Context;
-use C4::Dates qw(format_date);
-use C4::Budgets qw(GetCurrency);
 use C4::Templates;
 
 use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
@@ -53,7 +51,7 @@ BEGIN {
         setlanguagecookie getlanguagecookie pagination_bar parametrized_url
     );
     push @EXPORT, qw(
-        &output_html_with_http_headers &output_ajax_with_http_headers &output_with_http_headers FormatData
+        &output_html_with_http_headers &output_ajax_with_http_headers &output_with_http_headers
     );
 
 }
@@ -67,20 +65,6 @@ C4::Output - Functions for managing output, is slowly being deprecated
 =over 2
 =cut
 
-=item FormatData
-
-FormatData($data_hashref)
-C<$data_hashref> is a ref to data to format
-
-Format dates of data those dates are assumed to contain date in their noun
-Could be used in order to centralize all the formatting for HTML output
-=cut
-
-sub FormatData{
-               my $data_hashref=shift;
-        $$data_hashref{$_} = format_date( $$data_hashref{$_} ) for grep{/date/} keys (%$data_hashref);
-}
-
 =item pagination_bar
 
    pagination_bar($base_url, $nb_pages, $current_page, $startfrom_name)
@@ -101,10 +85,11 @@ This function returns HTML, without any language dependency.
 =cut
 
 sub pagination_bar {
-       my $base_url = (@_ ? shift : $ENV{SCRIPT_NAME} . $ENV{QUERY_STRING}) or return;
+    my $base_url = (@_ ? shift : return);
     my $nb_pages       = (@_) ? shift : 1;
     my $current_page   = (@_) ? shift : undef; # delay default until later
     my $startfrom_name = (@_) ? shift : 'page';
+    my $additional_parameters = shift || {};
 
     # how many pages to show before and after the current page?
     my $pages_around = 2;
@@ -121,6 +106,10 @@ sub pagination_bar {
        $base_url =~ s/$delim$//;               # remove trailing delim
 
     my $url = $base_url . (($base_url =~ m/$delim/ or $base_url =~ m/\?/) ? '&amp;' : '?' ) . $startfrom_name . '=';
+    my $url_suffix;
+    while ( my ( $k, $v ) = each %$additional_parameters ) {
+        $url_suffix .= '&amp;' . $k . '=' . $v;
+    }
     my $pagination_bar = '';
 
     # navigation bar useful only if more than one page to display !
@@ -132,7 +121,9 @@ sub pagination_bar {
                 "\n" . '&nbsp;'
               . '<a href="'
               . $url
-              . '1" rel="start">'
+              . '1'
+              . $url_suffix
+              . '"rel="start">'
               . '&lt;&lt;' . '</a>';
         }
         else {
@@ -149,6 +140,7 @@ sub pagination_bar {
               . '<a href="'
               . $url
               . $previous
+              . $url_suffix
               . '" rel="prev">' . '&lt;' . '</a>';
         }
         else {
@@ -187,7 +179,9 @@ sub pagination_bar {
                         "\n" . '&nbsp;'
                       . '<a href="'
                       . $url
-                      . $page_number . '">'
+                      . $page_number
+                      . $url_suffix
+                      . '">'
                       . $page_number . '</a>';
                 }
                 $last_displayed_page = $page_number;
@@ -202,6 +196,7 @@ sub pagination_bar {
               . '&nbsp;<a href="'
               . $url
               . $next
+              . $url_suffix
               . '" rel="next">' . '&gt;' . '</a>';
         }
         else {
@@ -215,6 +210,7 @@ sub pagination_bar {
               . '&nbsp;<a href="'
               . $url
               . $nb_pages
+              . $url_suffix
               . '" rel="last">'
               . '&gt;&gt;' . '</a>';
         }