]> git.koha-community.org Git - koha.git/blob - C4/ClassSortRoutine/Generic.pm
Bug 16011: $VERSION - Remove the $VERSION init
[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 use vars qw();
24
25 # set the version for version checking
26
27 =head1 NAME 
28
29 C4::ClassSortRoutine::Generic - generic call number sorting key routine
30
31 =head1 SYNOPSIS
32
33 use C4::ClassSortRoutine;
34
35 my $cn_sort = GetClassSortKey('Generic', $cn_class, $cn_item);
36
37 =head1 FUNCTIONS
38
39 =head2 get_class_sort_key
40
41   my $cn_sort = C4::ClassSortRoutine::Generic::Generic($cn_class, $cn_item);
42
43 Generates sorting key using the following rules:
44
45 * Concatenates class and item part.
46 * Removes leading and trailing whitespace.
47 * Converts each run of whitespace to an underscore.
48 * Converts to upper-case and removes non-alphabetical, non-numeric, non-underscore characters.
49
50 =cut
51
52 sub get_class_sort_key {
53     my ($cn_class, $cn_item) = @_;
54
55     $cn_class = '' unless defined $cn_class;
56     $cn_item  = '' unless defined $cn_item;
57     my $key = uc "$cn_class $cn_item";
58     $key =~ s/^\s+//;
59     $key =~ s/\s+$//;
60     $key =~ s/\s+/_/g;
61     $key =~ s/[^\p{IsAlnum}_]//g;
62     return $key;
63
64 }
65
66 1;
67
68 =head1 AUTHOR
69
70 Koha Development Team <http://koha-community.org/>
71
72 =cut
73