Changeset 25558

Show
Ignore:
Timestamp:
09.05.2012 14:50:19 (7 years ago)
Author:
sjm84
Message:

Some minor formatting, and also a minor fix with metadata

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone2/perllib/cgiactions/metadataaction.pm

    r25103 r25558  
    127127    my $url_encoded_metavalue = $gsdl_cgi->param("metavalue"); 
    128128    my $url_decoded_metavalue = &unicode::url_decode($url_encoded_metavalue,1); 
    129  
    130129    my $unicode_array = &unicode::utf82unicode($url_decoded_metavalue); 
    131130 
    132131    $url_decoded_metavalue = join("",map(chr($_),@$unicode_array)); 
    133  
    134132    $gsdl_cgi->param("metavalue",$url_decoded_metavalue); 
    135133 
     
    781779sub dxml_description 
    782780{ 
    783     my ($tagname, $attrHash, $contextArray, $parentDataArray, $parser) = @_; 
    784     my $metamode = $parser->{'parameters'}->{'metamode'}; 
    785  
    786     # Accumulate the metadata 
    787     # NOTE: This appends new metadata element to all description fields. 
    788     # If there are multiple Sections/SubSections, the new metadata block will get appended to all of them 
    789     if (($metamode eq "accumulate") || ($metamode eq "override")) { 
    790     # If get to here and metamode is override, the this means there  
    791     # was no existing value to overide => treat as an append operation 
    792  
    793     # Tack a new metadata tag on to the end of the <Metadata>+ block 
    794     my $metaname = $parser->{'parameters'}->{'metaname'}; 
    795     my $metavalue = $parser->{'parameters'}->{'metavalue'}; 
    796      
    797     my $metadata_attr = { '_content' => $metavalue,  
    798                   'name'     => $metaname,  
    799                   'mode'     => "accumulate" }; 
    800  
    801     my $append_metadata = [ "Metadata" => $metadata_attr ]; 
    802     my $description_content = $attrHash->{'_content'}; 
    803  
    804 ##  print STDERR "**** appending to doc.xml\n"; 
    805  
    806     push(@$description_content,"    ", $append_metadata ,"\n        "); 
    807     $parser->{'parameters'}->{'metamode'} = "done"; 
    808     } 
    809  
     781    my ($tagname, $attrHash, $contextArray, $parentDataArray, $parser) = @_; 
     782    my $metamode = $parser->{'parameters'}->{'metamode'}; 
     783 
     784    # Accumulate the metadata 
     785    # NOTE: This appends new metadata element to all description fields. 
     786    # If there are multiple Sections/SubSections, the new metadata block will get appended to all of them 
     787    if (($metamode eq "accumulate") || ($metamode eq "override")) { 
     788        # If get to here and metamode is override, the this means there  
     789        # was no existing value to overide => treat as an append operation 
     790 
     791        # Tack a new metadata tag on to the end of the <Metadata>+ block 
     792        my $metaname = $parser->{'parameters'}->{'metaname'}; 
     793        my $metavalue = $parser->{'parameters'}->{'metavalue'}; 
     794     
     795        my $metadata_attr = {  
     796            '_content' => $metavalue,  
     797            'name' => $metaname,  
     798            'mode' => "accumulate"  
     799        }; 
     800 
     801        my $append_metadata = [ "Metadata" => $metadata_attr ]; 
     802        my $description_content = $attrHash->{'_content'}; 
     803     
     804        ##  print STDERR "**** appending to doc.xml\n"; 
     805 
     806        if (ref($description_content)) { 
     807            # got some existing interesting nested content 
     808            push(@$description_content, "    ", $append_metadata ,"\n        "); 
     809        } 
     810        else { 
     811            #description_content is most likely a string such as "\n" 
     812            $attrHash->{'_content'} = [$description_content, "    ", $append_metadata ,"\n" ]; 
     813        } 
     814         
     815        $parser->{'parameters'}->{'metamode'} = "done"; 
     816    } 
    810817 
    811818    # RAW is [$tagname => $attrHash] not $tagname => $attrHash!! 
     
    849856    $parser->{'parameters'}->{'curr_section_depth'} = $new_depth; 
    850857    $parser->{'parameters'}->{'curr_section_num'}   = $new_secnum; 
    851  
    852     print STDERR "*** In Section: $new_secnum\n"; 
    853858} 
    854859 
     
    949954     
    950955    return 0; # return 0 for now to indicate no error 
    951              
    952956} 
    953957 
     
    15121516##    $metavalue =~ s/&amp;lt;(.*?)&amp;gt;/<$1>/g; 
    15131517    $metavalue =~ s/&lt;(.*?)&gt;/<$1>/g; 
    1514     print STDERR "*** set import meta: val = $metavalue\n"; 
    15151518     
    15161519    my $metamode   = $self->{'metamode'};