Changeset 32062
- Timestamp:
- 2017-11-14T13:40:47+13:00 (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone2/perllib/cgiactions/metadataaction.pm
r32061 r32062 67 67 my $getmeta_action_table = 68 68 { 69 # unused and untested 70 # when DocEdit=1, need to retrieve a doc's full text (or doc section's full text) from archives 71 "get-archives-text" => { 72 'compulsory-args' => [ "d" ] }, 73 #'compulsory-args' => [ "d" ], 74 #'optional-args' => [ "section" ] }, 75 69 76 #GET METHODS 70 77 "get-import-metadata" => { … … 888 895 } 889 896 897 # unused and untested 898 sub get_archives_text 899 { 900 my $self = shift @_; 901 902 my $username = $self->{'username'}; 903 my $collect = $self->{'collect'}; 904 my $gsdl_cgi = $self->{'gsdl_cgi'}; 905 # my $gsdlhome = $self->{'gsdlhome'}; 906 my $infodbtype = $self->{'infodbtype'}; 907 908 # Obtain the collect dir 909 my $site = $self->{'site'}; 910 my $collect_dir = $gsdl_cgi->get_collection_dir($site); 911 912 my $archive_dir = &util::filename_cat($collect_dir, $collect, "archives"); 913 914 # look up additional args 915 my ($docid, $docid_secnum) = ($self->{'d'} =~ m/^(.*?)(\..*)?$/); 916 $docid_secnum = "" if (!defined $docid_secnum); 917 918 my $arcinfo_doc_filename = &dbutil::get_infodb_file_path($infodbtype, "archiveinf-doc", $archive_dir); 919 my $doc_rec = &dbutil::read_infodb_entry($infodbtype, $arcinfo_doc_filename, $docid); 920 921 # This now stores the full pathname 922 my $doc_filename = $doc_rec->{'doc-file'}->[0]; 923 924 my $metaname = undef; 925 my $metapos = -1; 926 927 $gsdl_cgi->generate_ok_message($self->get_metadata_from_archive_xml($gsdl_cgi, &util::filename_cat($archive_dir, $doc_filename), $metaname, $metapos, $docid_secnum)); 928 929 } 930 890 931 sub get_metadata_from_archive_xml 891 932 { … … 935 976 } 936 977 978 # unused and untested 979 sub get_text_from_archive_xml 980 { 981 my $self = shift @_; 982 my ($gsdl_cgi, $doc_xml_filename, $secid) = @_; 983 984 # To monitor which section/subsection number we are in 985 my @start_rules = ('Section' => \&dxml_start_section); 986 987 # set the callback functions for the elements in doc.xml we're interested in, <Content> 988 my @rules = 989 ( 990 _default => 'raw', 991 'Content' => \&gfdxml_text # gfdxml = get from doc xml? 992 ); 993 994 my $parser = XML::Rules->new 995 ( 996 start_rules => \@start_rules, 997 rules => \@rules, 998 output_encoding => 'utf8' 999 ); 1000 1001 my $xml_in = ""; 1002 if (!open(MIN,"<$doc_xml_filename")) 1003 { 1004 $gsdl_cgi->generate_error("Unable to read in $doc_xml_filename: $!"); 1005 } 1006 else 1007 { 1008 # Read them in 1009 my $line; 1010 while (defined ($line=<MIN>)) { 1011 $xml_in .= $line; 1012 } 1013 close(MIN); 1014 1015 $parser->parse($xml_in, {secid => $secid}); 1016 1017 if(defined $parser->{'pad'}->{'textcontent'}) 1018 { 1019 return $parser->{'pad'}->{'textcontent'}; 1020 } 1021 else 1022 { 1023 return ""; 1024 } 1025 } 1026 } 1027 937 1028 sub gfdxml_metadata 938 1029 { … … 962 1053 } 963 1054 1055 # unused and untested - for get_archives_text 1056 sub gfdxml_text 1057 { 1058 my ($tagname, $attrHash, $contextArray, $parentDataArray, $parser) = @_; 1059 1060 if($parser->{'parameters'}->{'secid'} eq $parser->{'parameters'}->{'curr_section_num'}) 1061 { 1062 $parser->{'pad'}->{'textcontent'} = $attrHash->{'_content'}; # the textnode content 1063 1064 } 1065 else { 1066 return; 1067 } 1068 } 964 1069 965 1070 sub dxml_start_section … … 993 1098 } 994 1099 else { 995 # back up to parent section => lop poff tail1100 # back up to parent section => lop off tail 996 1101 $new_secnum = $old_secnum; 997 1102 $new_secnum =~ s/\.\d+$//; … … 1001 1106 $parser->{'parameters'}->{'curr_section_num'} = $new_secnum; 1002 1107 1003 1108 1; 1004 1109 } 1005 1110
Note:
See TracChangeset
for help on using the changeset viewer.