Bug 22483: (QA follow-up) Corrections to logic in check_cookie_auth
[koha.git] / C4 / ClassSortRoutine / Generic.pm
1 package C4::ClassSortRoutine::Generic;
2
3 # Copyright (C) 2007 LibLime
4
5 # This file is part of Koha.
6 #
7 # Koha is free software; you can redistribute it and/or modify it
8 # under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 3 of the License, or
10 # (at your option) any later version.
11 #
12 # Koha is distributed in the hope that it will be useful, but
13 # WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
16 #
17 # You should have received a copy of the GNU General Public License
18 # along with Koha; if not, see <http://www.gnu.org/licenses>.
19
20 use strict;
21 use warnings;
22
23
24
25 =head1 NAME 
26
27 C4::ClassSortRoutine::Generic - generic call number sorting key routine
28
29 =head1 SYNOPSIS
30
31 use C4::ClassSortRoutine;
32
33 my $cn_sort = GetClassSortKey('Generic', $cn_class, $cn_item);
34
35 =head1 FUNCTIONS
36
37 =head2 get_class_sort_key
38
39   my $cn_sort = C4::ClassSortRoutine::Generic::Generic($cn_class, $cn_item);
40
41 Generates sorting key using the following rules:
42
43 * Concatenates class and item part.
44 * Removes leading and trailing whitespace.
45 * Converts each run of whitespace to an underscore.
46 * Converts to upper-case and removes non-alphabetical, non-numeric, non-underscore characters.
47
48 =cut
49
50 sub get_class_sort_key {
51     my ($cn_class, $cn_item) = @_;
52
53     $cn_class = '' unless defined $cn_class;
54     $cn_item  = '' unless defined $cn_item;
55     my $key = uc "$cn_class $cn_item";
56     $key =~ s/^\s+//;
57     $key =~ s/\s+$//;
58     $key =~ s/\s+/_/g;
59     $key =~ s/[^\p{IsAlnum}_]//g;
60     return $key;
61
62 }
63
64 1;
65
66 =head1 AUTHOR
67
68 Koha Development Team <http://koha-community.org/>
69
70 =cut
71