| File: | C4/ClassSortRoutine/LCC.pm |
| Coverage: | 86.5% |
| line | stmt | bran | cond | sub | time | code |
|---|---|---|---|---|---|---|
| 1 | package C4::ClassSortRoutine::LCC; | |||||
| 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 | 24 24 24 | 17720 73 603 | use strict; | |||
| 21 | 24 24 24 | 201 65 833 | use warnings; | |||
| 22 | ||||||
| 23 | 24 24 24 | 122 62 7098 | use vars qw($VERSION); | |||
| 24 | ||||||
| 25 | # set the version for version checking | |||||
| 26 | $VERSION = 3.00; | |||||
| 27 | ||||||
| 28 - 46 | =head1 NAME
C4::ClassSortRoutine::LCC - generic call number sorting key routine
=head1 SYNOPSIS
use C4::ClassSortRoutine;
my $cn_sort = GetClassSortKey('LCC', $cn_class, $cn_item);
=head1 FUNCTIONS
=head2 get_class_sort_key
my $cn_sort = C4::ClassSortRoutine::LCC::LCC($cn_class, $cn_item);
Generates sorting key for LC call numbers.
=cut | |||||
| 47 | ||||||
| 48 | sub get_class_sort_key { | |||||
| 49 | 31 | 180640 | my ($cn_class, $cn_item) = @_; | |||
| 50 | ||||||
| 51 | 31 | 196 | $cn_class = '' unless defined $cn_class; | |||
| 52 | 31 | 138 | $cn_item = '' unless defined $cn_item; | |||
| 53 | 31 | 173 | my $key = uc "$cn_class $cn_item"; | |||
| 54 | 31 | 141 | $key =~ s/^\s+//; | |||
| 55 | 31 | 162 | $key =~ s/\s+$//; | |||
| 56 | 31 0 0 0 | 426 0 0 0 | $key =~ s/^[^\p{IsAlnum}\s.]//g; | |||
| 57 | 31 | 28508 | $key =~ s/^([A-Z]+)/$1 /; | |||
| 58 | 31 | 150 | $key =~ s/(\.[A-Z])/ $1/g; | |||
| 59 | # handle first digit group | |||||
| 60 | 31 0 | 173 0 | $key =~ s/(\d+)/sprintf("%-05.5d", $1)/xe; | |||
| 61 | 31 | 153 | $key =~ s/\s+/_/g; | |||
| 62 | 31 | 120 | $key =~ s/\./_/g; | |||
| 63 | 31 | 110 | $key =~ s/__/_/g; | |||
| 64 | 31 | 357 | $key =~ s/[^\p{IsAlnum}_]//g; | |||
| 65 | ||||||
| 66 | 31 | 2749 | return $key; | |||
| 67 | ||||||
| 68 | } | |||||
| 69 | ||||||
| 70 | 1; | |||||
| 71 | ||||||
| 72 - 76 | =head1 AUTHOR Koha Development Team <http://koha-community.org/> =cut | |||||
| 77 | ||||||