Changeset 14028
- Timestamp:
- 2007-04-30T15:53:08+12:00 (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl/bin/script/buildcol.pl
r12964 r14028 33 33 unshift (@INC, "$ENV{'GSDLHOME'}/perllib"); 34 34 unshift (@INC, "$ENV{'GSDLHOME'}/perllib/cpan"); 35 unshift (@INC, "$ENV{'GSDLHOME'}/perllib/cpan/XML/XPath"); 35 36 unshift (@INC, "$ENV{'GSDLHOME'}/perllib/plugins"); 36 37 unshift (@INC, "$ENV{'GSDLHOME'}/perllib/classify"); … … 48 49 no strict 'refs'; # allow filehandles to be variables and vice versa 49 50 no strict 'subs'; # allow barewords (eg STDERR) as function arguments 51 52 # used in updating Collectionconfig.xml in create_images() 53 use Twig; 50 54 51 55 my $mode_list = … … 215 219 my $out; 216 220 221 # used to signify "gs2"(default) or "gs3" 222 my $gs_mode = "gs2"; 223 217 224 ## @method gsprintf() 218 225 # Print a string to the screen after looking it up from a locale dependant … … 340 347 unshift (@INC, "$ENV{'GSDLCOLLECTDIR'}/perllib/plugins"); 341 348 342 # read the configuration file 349 # read the configuration file (for gs2) 343 350 $configfilename = &util::filename_cat ($ENV{'GSDLCOLLECTDIR'}, "etc", "collect.cfg"); 344 351 my ($collectcfg, $buildtype); 345 352 346 if (!-e $configfilename) { 353 if (-e $configfilename) { 354 $collectcfg = &colcfg::read_collect_cfg ($configfilename); 355 $gs_mode = "gs2"; 356 } 357 else { 358 359 # If it is gs3 360 $configfilename = &util::filename_cat ($ENV{'GSDLCOLLECTDIR'}, "etc", "collectionConfig.xml"); 361 362 if (!-e $configfilename) { 347 363 &gsprintf($out, "{common.cannot_find_cfg_file}\n", $configfilename) && die; 348 } 349 350 $collectcfg = &colcfg::read_collect_cfg ($configfilename); 364 } 365 else { 366 $collectcfg = &colcfg::read_collection_cfg_xml ($configfilename); 367 $gs_mode = "gs3"; 368 } 369 } 351 370 352 371 if ($verbosity !~ /\d+/) { … … 600 619 system ("$image_script -image_dir \"$imagedir\" -filename ${collection}sm.gif -text \"$collection_name\""); 601 620 621 if ($gs_mode eq "gs3") { 622 # update the CollectionConfig.xml file 623 # what we need to do is find in CollectionConfig.xml the two elements with attributes 'icon' and 'smallicon' 624 # and replace the node text with $collection.gif and ${collection}sm.gif respectively. If they don't exist, 625 # create new ones by using the image names. 626 627 628 my $found = 0; my $foundsm = 0; 629 630 my $twig = XML::Twig->new(); 631 $twig->parsefile($configfilename); 632 my $root = $twig->root; 633 my $displayItemList = $root->first_child('displayItemList'); 634 my @displayItem = $displayItemList->children('displayItem'); 635 foreach my $displayItem (@displayItem) { 636 my $att_value = $displayItem->{'att'}->{'name'}; 637 638 if($att_value eq 'icon') { 639 $found = 1; 640 } 641 elsif ( $att_value eq 'smallicon') { 642 $foundsm = 1; 643 } 644 } 645 646 if ($found eq 0) { print "write icon"; 647 my $icon_displayItem_element = XML::Twig::Elt->new('displayItem'); 648 $icon_displayItem_element->set_att('name', '$collection.gif'); 649 $icon_displayItem_element->set_att('lang', 'en'); 650 $icon_displayItem_element->set_text("$collection.gif"); 651 $icon_displayItem_element->paste('last_child', $displayItemList); 652 } 653 if ($foundsm eq 0) { 654 my $smallicon_displayItem_element = XML::Twig::Elt->new('displayItem'); 655 $smallicon_displayItem_element->set_att('name', 'smallicon'); 656 $smallicon_displayItem_element->set_att('lang', 'en'); 657 $smallicon_displayItem_element->set_text("${collection}sm.gif"); 658 $smallicon_displayItem_element->paste('last_child', $displayItemList); 659 660 661 } 662 open (OUT, ">$configfilename") or die "cannot open file $configfilename for output: $!"; 663 #select OUT; 664 $twig->print( \*OUT ); 665 close OUT; 666 return; 667 } 668 602 669 # update the collect.cfg configuration file (this will need 603 670 # to be changed when the config file format changes)
Note:
See TracChangeset
for help on using the changeset viewer.