File: | C4/ClassSortRoutine/Generic.pm |
Coverage: | 86.7% |
line | stmt | bran | cond | sub | time | code |
---|---|---|---|---|---|---|
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 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. | |||||
11 | # | |||||
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. | |||||
15 | # | |||||
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. | |||||
19 | ||||||
20 | 22 22 22 | 584 156 665 | use strict; | |||
21 | 22 22 22 | 229 135 2875 | use warnings; | |||
22 | ||||||
23 | 22 22 22 | 220 138 4824 | use vars qw($VERSION); | |||
24 | ||||||
25 | # set the version for version checking | |||||
26 | $VERSION = 3.00; | |||||
27 | ||||||
28 - 51 | =head1 NAME C4::ClassSortRoutine::Generic - generic call number sorting key routine =head1 SYNOPSIS use C4::ClassSortRoutine; my $cn_sort = GetClassSortKey('Generic', $cn_class, $cn_item); =head1 FUNCTIONS =head2 get_class_sort_key my $cn_sort = C4::ClassSortRoutine::Generic::Generic($cn_class, $cn_item); Generates sorting key using the following rules: * Concatenates class and item part. * Removes leading and trailing whitespace. * Converts each run of whitespace to an underscore. * Converts to upper-case and removes non-alphabetical, non-numeric, non-underscore characters. =cut | |||||
52 | ||||||
53 | sub get_class_sort_key { | |||||
54 | 23 | 166 | my ($cn_class, $cn_item) = @_; | |||
55 | ||||||
56 | 23 | 158 | $cn_class = '' unless defined $cn_class; | |||
57 | 23 | 127 | $cn_item = '' unless defined $cn_item; | |||
58 | 23 | 132 | my $key = uc "$cn_class $cn_item"; | |||
59 | 23 | 139 | $key =~ s/^\s+//; | |||
60 | 23 | 169 | $key =~ s/\s+$//; | |||
61 | 23 | 116 | $key =~ s/\s+/_/g; | |||
62 | 23 0 0 0 | 398 0 0 0 | $key =~ s/[^\p{IsAlnum}_]//g; | |||
63 | 23 | 19710 | return $key; | |||
64 | ||||||
65 | } | |||||
66 | ||||||
67 | 1; | |||||
68 | ||||||
69 - 73 | =head1 AUTHOR Koha Development Team <http://koha-community.org/> =cut | |||||
74 |