Changeset 27098
- Timestamp:
- 2013-03-19T15:27:51+13:00 (11 years ago)
- Location:
- main/trunk/greenstone2/perllib
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone2/perllib/classify/List.pm
r26545 r27098 114 114 'desc' => "{List.filter_regex}", 115 115 'type' => "regexp"}, 116 116 { 'name' => "standardize_capitalization", 117 'desc' => "{List.standardize_capitalization}", 118 'type' => "flag"}, 117 119 { 'name' => "removeprefix", 118 120 'desc' => "{BasClas.removeprefix}", … … 404 406 # text-transform the stored lowercase values as capitalize or uppercase (can't CSS 405 407 # text-transform if stored uppercase). 2 CSS text-transforms have been added to core.css 406 $metadata_value = lc($metadata_value);408 my $lc_metadata_value = lc($metadata_value); 407 409 408 410 # We are already working with unicode aware strings at this 409 411 # stage, so we no longer need to convert from utf8 to unicode 410 my $metadata_value_unicode_string = $metadata_value; # $self->convert_utf8_string_to_unicode_string($metadata_value);412 #my $metadata_value_unicode_string = $metadata_value; # $self->convert_utf8_string_to_unicode_string($metadata_value); 411 413 412 414 # Add the metadata value into the list for this combination of metadata group and section 413 push(@{$self->{$metadata_group . ".list"}->{$section_OID}}, $metadata_value_unicode_string); 415 push(@{$self->{$metadata_group . ".list"}->{$section_OID}}, $lc_metadata_value); 416 # add the actual value into the stored values so we can remember the case 417 if (!$self->{'standardize_capitalization'}) { 418 if (defined $self->{$metadata_group . ".actualvalues"}->{$lc_metadata_value}->{$metadata_value}) { 419 $self->{$metadata_group . ".actualvalues"}->{$lc_metadata_value}->{$metadata_value}++; 420 } else { 421 $self->{$metadata_group . ".actualvalues"}->{$lc_metadata_value}->{$metadata_value} = 1; 422 } 423 } 414 424 } 415 425 last if (@metadata_values > 0); … … 801 811 # Otherwise create a sublist (bookshelf) for the metadata value 802 812 else { 813 my $metadata_value_display = $self->get_metadata_value_display($metadata_group, $metadata_value); 803 814 # Note that we don't need to convert from unicode-aware strings 804 815 # to utf8 here, as that is handled elsewhere in the code 805 my %child_classifier_node = ( 'Title' => $metadata_value , # 'Title' => $self->convert_unicode_string_to_utf8_string($metadata_value),816 my %child_classifier_node = ( 'Title' => $metadata_value_display, # 'Title' => $self->convert_unicode_string_to_utf8_string($metadata_value), 806 817 'childtype' => "VList", 807 818 'mdtype' => $metadata_group, … … 918 929 } 919 930 920 931 sub get_metadata_value_display { 932 my $self = shift(@_); 933 my ($metadata_group, $metadata_value) = @_; 934 return $metadata_value if $self->{'standardize_capitalization'}; 935 my $actual_values_hash = $self->{$metadata_group . ".actualvalues"}->{$metadata_value}; 936 my $display_value =""; 937 my $max_count=0; 938 foreach my $v (keys %$actual_values_hash) { 939 if ($actual_values_hash->{$v} > $max_count) { 940 $display_value = $v; 941 $max_count = $actual_values_hash->{$v}; 942 } 943 } 944 return $display_value; 945 } 921 946 1; -
main/trunk/greenstone2/perllib/strings.properties
r26976 r27098 654 654 List.sort_using_unicode_collation:Sort using the Unicode Collation Algorithm. Requires http://www.unicode.org/Public/UCA/latest/allkeys.txt file to be downloaded into perl's lib/Unicode/Collate folder. 655 655 656 List.standardize_capitalization:Metadata values are lowercased for sorting into bookshelves. Set this option to use these lowercase values for bookshelf display names. Otherwise, the majority case variant will be used. 657 656 658 List.use_hlist_for:Metadata fields to use a hlist rather than a vlist. Use ',' to separate the metadata groups and ';' to separate the metadata fields within each group. 657 659
Note:
See TracChangeset
for help on using the changeset viewer.