Changeset 33898 for main/trunk/greenstone2/perllib/sorttools.pm
- Timestamp:
- 2020-02-04T12:59:00+13:00 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone2/perllib/sorttools.pm
r33476 r33898 33 33 34 34 use strict; 35 use Unicode::Normalize; 35 36 36 37 my $has_custom_sort = 0; … … 65 66 # moved here from BasClas so import can share it 66 67 sub format_metadata_for_sorting { 67 my ($metaname, $metavalue, $doc_obj) = @_; 68 69 if ($has_custom_sort && defined (&customsorttools::format_metadata_for_sorting)) { 70 return &customsorttools::format_metadata_for_sorting($metaname, $metavalue, $doc_obj); 71 } 68 my ($metaname, $metavalue, $doc_obj, $casefold, $accentfold) = @_; 72 69 73 70 if (!defined $metaname || $metaname !~ /\S/ || ! defined $metavalue || $metavalue !~ /\S/) { 74 71 return ""; 72 } 73 74 if ($has_custom_sort && defined (&customsorttools::format_metadata_for_sorting)) { 75 return &customsorttools::format_metadata_for_sorting($metaname, $metavalue, $doc_obj, $casefold, $accentfold); 75 76 } 76 77 … … 85 86 } 86 87 $lang = 'en' unless defined $lang; 87 88 89 if (defined $casefold && $casefold eq "true") { 90 $metavalue = lc($metavalue); 91 } 92 if (defined $accentfold && $accentfold eq "true") { 93 $metavalue = NFKD($metavalue); 94 $metavalue =~ s/\p{NonspacingMark}//g; 95 } 96 88 97 # is this metadata likely to be a name? 89 98 my $function_name="format_string_name_$lang"; … … 117 126 } 118 127 119 $$stringref = lc($$stringref);120 128 $$stringref =~ s/&[^\;]+\;//g; # html entities 121 129 $$stringref =~ s/^\s*(the|a|an)\b//; # articles … … 133 141 } 134 142 135 $$stringref =~ tr/A-Z/a-z/;136 143 $$stringref =~ s/&\S+;//g; 137 144 … … 163 170 } 164 171 165 $$stringref = lc($$stringref);166 172 $$stringref =~ s/&[^\;]+\;//g; # html entities 167 173 $$stringref =~ s/^\s*(les?|la|une?)\b//; # articles … … 179 185 } 180 186 181 $$stringref = lc($$stringref);182 187 $$stringref =~ s/&[^\;]+\;//g; # html entities 183 188 $$stringref =~ s/^\s*(la|el)\b//; # articles
Note:
See TracChangeset
for help on using the changeset viewer.