Bug 3746 - add to OPACViewOthersSuggestions description
[koha.git] / C4 / ClassSortRoutine / LCC.pm
bloba4e34b29d307b1c7a5161d8e6385137e6a6264b4
1 package C4::ClassSortRoutine::LCC;
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 with
17 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
18 # Suite 330, Boston, MA 02111-1307 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::LCC - generic call number sorting key routine
32 =head1 SYNOPSIS
34 use C4::ClassSortRoutine;
36 my $cn_sort = GetClassSortKey('LCC', $cn_class, $cn_item);
38 =head1 FUNCTIONS
40 =head2 get_class_sort_key
42 my $cn_sort = C4::ClassSortRoutine::LCC::LCC($cn_class, $cn_item);
44 Generates sorting key for LC call numbers.
46 =cut
48 sub get_class_sort_key {
49 my ($cn_class, $cn_item) = @_;
51 $cn_class = '' unless defined $cn_class;
52 $cn_item = '' unless defined $cn_item;
53 my $key = uc "$cn_class $cn_item";
54 $key =~ s/^\s+//;
55 $key =~ s/\s+$//;
56 $key =~ s/^[^\p{IsAlnum}\s.]//g;
57 $key =~ s/^([A-Z]+)/$1 /;
58 $key =~ s/(\.[A-Z])/ $1/g;
59 # handle first digit group
60 $key =~ s/(\d+)/sprintf("%-05.5d", $1)/xe;
61 $key =~ s/\s+/_/g;
62 $key =~ s/\./_/g;
63 $key =~ s/__/_/g;
64 $key =~ s/[^\p{IsAlnum}_]//g;
66 return $key;
72 =head1 AUTHOR
74 Koha Developement team <info@koha.org>
76 =cut