Minor markup correction to send Cart form
[koha.git] / C4 / ClassSortRoutine / Generic.pm
blob924e6a8d850143ba84da3e14f6fca93ad06adc63
1 package C4::ClassSortRoutine::Generic;
3 # Copyright (C) 2007 LibLime
4 #
5 # This file is part of Koha.
7 # Koha is free software; you can redistribute it and/or modify it under the
8 # terms of the GNU General Public License as published by the Free Software
9 # Foundation; either version 2 of the License, or (at your option) any later
10 # version.
12 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License along
17 # with Koha; if not, write to the Free Software Foundation, Inc.,
18 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 use strict;
21 use warnings;
23 use vars qw($VERSION);
25 # set the version for version checking
26 $VERSION = 3.00;
28 =head1 NAME
30 C4::ClassSortRoutine::Generic - generic call number sorting key routine
32 =head1 SYNOPSIS
34 use C4::ClassSortRoutine;
36 my $cn_sort = GetClassSortKey('Generic', $cn_class, $cn_item);
38 =head1 FUNCTIONS
40 =head2 get_class_sort_key
42 my $cn_sort = C4::ClassSortRoutine::Generic::Generic($cn_class, $cn_item);
44 Generates sorting key using the following rules:
46 * Concatenates class and item part.
47 * Removes leading and trailing whitespace.
48 * Converts each run of whitespace to an underscore.
49 * Converts to upper-case and removes non-alphabetical, non-numeric, non-underscore characters.
51 =cut
53 sub get_class_sort_key {
54 my ($cn_class, $cn_item) = @_;
56 $cn_class = '' unless defined $cn_class;
57 $cn_item = '' unless defined $cn_item;
58 my $key = uc "$cn_class $cn_item";
59 $key =~ s/^\s+//;
60 $key =~ s/\s+$//;
61 $key =~ s/\s+/_/g;
62 $key =~ s/[^\p{IsAlnum}_]//g;
63 return $key;
69 =head1 AUTHOR
71 Koha Development Team <http://koha-community.org/>
73 =cut