Changeset 28034
- Timestamp:
- 2013-08-13T14:28:29+12:00 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone2/perllib/collConfigxml.pm
r27803 r28034 34 34 35 35 # A mapping hash to resolve name discrepancy between gs2 and gs3. 36 # the first item is the gs3 element name from collectionConfig, the second one 37 # is the internal name for the option 36 38 my $nameMap = {"key" => "value", 37 39 "creator" => "creator", … … 60 62 "buildType" => "buildtype", 61 63 "orthogonalBuildTypes" => "orthogonalbuildtypes", 62 "buildOption" => "buildOption"63 #"buildOptions" => "buildOptions", "importOptions" => "importOptions", no actual equivalents for importOptions and buildOptions in GS264 64 }; 65 65 # A hash structure which is returned by sub read_cfg_file. 66 66 my $data = {}; 67 67 68 my $repeatedBlock = q/^(browse|pluginList)$/; #|buildOptionList)$/;68 my $repeatedBlock = q/^(browse|pluginList)$/; 69 69 70 70 # use those unique attribute values to locate the text within the elements … … 74 74 my $displayItemNames = q/^(name|description)$/; 75 75 76 # these options get set at top level 77 my $topleveloptionexp = q/^(importOption|buildOption)$/; 78 76 79 # For storing the attributes during the StartTag subroutine, so that 77 80 # we can use it later in Text (or EndTag) subroutines … … 87 90 my $hashexp = q/^(subcollection)$/; # add other element names that should be represented by hash expressions here 88 91 my $hashhashexp = q/^(displayItem)$/; # add other (collectionmeta) element names that should be represented by hashes of hashes here. 89 90 my $generalOptions = q/^(importOptions|buildOptions)$/; # becomes GS2 toplevel map of (name, value) pairs91 92 92 93 my $defaults = q/^(defaultIndex|defaultLevel|defaultIndexLanguage|languageMetadata)$/; … … 200 201 #@ Handle index|sort|facet|level|indexOption|indexSubcollection|indexLanguage 201 202 elsif ($element =~ /$arrayexp/) { 202 my $key = $nameMap->{$element}; 203 my $key = $nameMap->{$element}; # 203 204 if (!defined $data->{$key}) { 204 205 $data->{$key} = []; … … 209 210 } 210 211 } 211 212 #***************************************** 213 elsif ($element eq "buildOption") { 214 print STDERR "**** BUILD OPTION PAIR $name $value\n"; 215 $data->{$name} = $value; 216 } 212 # importOption and buildOption, just stored at top level, name=value, 213 # as per gs2 version 214 elsif ($element =~ /$topleveloptionexp/) { 215 if (defined $name) { 216 if (!defined $value) { 217 # flag option, set to true 218 $value = "true"; 219 } 220 $data->{$name} = $value; 221 } 222 } 217 223 218 224 #@ plugout options … … 287 293 } 288 294 289 #@ Handling each importOptions/buildOptions element290 elsif ($element =~ /$generalOptions/) {291 $currentLevel = $element;292 #my $key = $nameMap->{$element}; # importOptions and buildOptions map to themselves, no equivalents in GS2293 294 # define a map of string pairs295 if (!defined $data->{$element}) {296 $data->{$element} = {};297 }298 }299 #@ Handling the option elements in an importOptions/buildOptions element, which are of the form:300 # <importOptions><option name="n" value="v"/><option .../></importOptions>301 # these get stored in-memory at the top level as (n, v) pairs, just as in GS2302 elsif ($currentLevel =~ /$generalOptions/ and $element eq "option") {303 if (defined $name and $name =~ /\w/) {304 305 # if a flag's value is on or 1, set it to true. If the value is off or 0, set it to false. (GS2 expects true/false)306 # But such on/off flags (like -gli) need not be given a value, in which case the value defaults to 'true' again.307 308 if(defined $value and $value =~ /\w/) {309 310 if ($value =~ m/^(on|1)$/) {311 $value = "true";312 } elsif ($value =~ m/^(off|0)$/) {313 $value = "false";314 } # else, use whatever value is provided315 316 }317 else {318 $value = "true";319 }320 $data->{$name} = $value; #$data->{$currentLevel}->{$name} = $value;321 #print "@@@@ Added $currentLevel option: $name=$value\n";322 }323 }324 295 325 296 } … … 327 298 sub EndTag { 328 299 my ($expat, $element) = @_; 329 my $endTags = q/^(browse|pluginList|displayItemList|indexOption |importOptions|buildOptions)$/; #|buildOptionList)$/;300 my $endTags = q/^(browse|pluginList|displayItemList|indexOption)$/; #|buildOptionList)$/; 330 301 if ($element =~ /$endTags/) { 331 302 $currentIndex = 0;
Note:
See TracChangeset
for help on using the changeset viewer.