Changeset 17570
- Timestamp:
- 2008-10-23T09:11:16+13:00 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
gsdl/trunk/bin/script/buildcol.pl
r17118 r17570 20 20 # along with this program; if not, write to the Free Software 21 21 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 22 #23 # @note 11/04/03 Added usage datastructure - John Thompson24 22 # 25 23 # @author New Zealand Digital Library Project unless otherwise stated … … 63 61 no strict 'subs'; # allow barewords (eg STDERR) as function arguments 64 62 65 # used in updating Collectionconfig.xml in create_images()66 use Twig;67 63 68 64 my $mode_list = … … 118 114 'reqd' => "no", 119 115 'hiddengli' => "yes" }, 120 { 'name' => "create_images",121 'desc' => "{buildcol.create_images}",122 'type' => "flag",123 'reqd' => "no",124 'modegli' => "4" },125 116 { 'name' => "debug", 126 117 'desc' => "{buildcol.debug}", … … 285 276 $debug, $mode, $indexname, $removeold, $keepold, $incremental, 286 277 $remove_empty_classifications, 287 $c reate_images, $collectdir, $build, $type, $textindex,278 $collectdir, $build, $type, $textindex, 288 279 $no_strip_html, $no_text, $faillog, $gli, $index, $language, 289 280 $sections_index_document_metadata, $maxnumeric, … … 443 434 } 444 435 445 446 if (defined $collectcfg->{'create_images'} && $collectcfg->{'create_images'} =~ /^true$/i) {447 $create_images = 1;448 }449 436 if ($buildtype eq "mgpp" && defined $collectcfg->{'textcompress'}) { 450 437 $textindex = $collectcfg->{'textcompress'}; … … 482 469 else { 483 470 $textindex = "section:text"; 484 }485 486 # create default images if required487 if ($create_images) {488 my $collection_name = $collection;489 $collection_name = $collectcfg->{'collectionmeta'}->{'collectionname'}->{'default'}490 if defined $collectcfg->{'collectionmeta'}->{'collectionname'}->{'default'};491 &create_images ($collection_name);492 471 } 493 472 … … 612 591 ## main() ## 613 592 614 ## @method create_images()615 #616 # [Used to create default cover images... from what I'm not quite sure - John]617 #618 sub create_images {619 my ($collection_name) = @_;620 621 my $image_script = &util::filename_cat ($ENV{'GSDLHOME'}, "bin", "script", "gimp", "title_icon-1.2.pl");622 if (!-e $image_script) {623 &gsprintf($out, "{buildcol.no_image_script}", $image_script);624 &gsprintf($out, "{buildcol.no_default_images}\n\n");625 return;626 }627 628 my $imagedir = &util::filename_cat ($ENV{'GSDLCOLLECTDIR'}, "images");629 630 &util::mk_all_dir ($imagedir);631 632 # create the images633 system ("$image_script -size 1.5 -image_dir \"$imagedir\" -filename $collection.gif -text \"$collection_name\"");634 system ("$image_script -image_dir \"$imagedir\" -filename ${collection}sm.gif -text \"$collection_name\"");635 636 if ($gs_mode eq "gs3") {637 # update the CollectionConfig.xml file638 # what we need to do is find in CollectionConfig.xml the two elements with attributes 'icon' and 'smallicon'639 # and replace the node text with $collection.gif and ${collection}sm.gif respectively. If they don't exist,640 # create new ones by using the image names.641 642 643 my $found = 0; my $foundsm = 0;644 645 my $twig = XML::Twig->new();646 $twig->parsefile($configfilename);647 my $root = $twig->root;648 my $displayItemList = $root->first_child('displayItemList');649 my @displayItem = $displayItemList->children('displayItem');650 foreach my $displayItem (@displayItem) {651 my $att_value = $displayItem->{'att'}->{'name'};652 653 if($att_value eq 'icon') {654 $found = 1;655 }656 elsif ( $att_value eq 'smallicon') {657 $foundsm = 1;658 }659 }660 661 if ($found eq 0) { print "write icon";662 my $icon_displayItem_element = XML::Twig::Elt->new('displayItem');663 $icon_displayItem_element->set_att('name', '$collection.gif');664 $icon_displayItem_element->set_att('lang', 'en');665 $icon_displayItem_element->set_text("$collection.gif");666 $icon_displayItem_element->paste('last_child', $displayItemList);667 }668 if ($foundsm eq 0) {669 my $smallicon_displayItem_element = XML::Twig::Elt->new('displayItem');670 $smallicon_displayItem_element->set_att('name', 'smallicon');671 $smallicon_displayItem_element->set_att('lang', 'en');672 $smallicon_displayItem_element->set_text("${collection}sm.gif");673 $smallicon_displayItem_element->paste('last_child', $displayItemList);674 675 676 }677 open (OUT, ">$configfilename") or die "cannot open file $configfilename for output: $!";678 #select OUT;679 $twig->print( \*OUT );680 close OUT;681 return;682 }683 684 # update the collect.cfg configuration file (this will need685 # to be changed when the config file format changes)686 if (!open (CFGFILE, $configfilename)) {687 &gsprintf($out, "{buildcol.cannot_open_cfg_file}\n", $configfilename);688 &gsprintf($out, "{buildcol.unlinked_col_images}\n");689 return;690 }691 692 my $line = ""; my $file = "";693 my $found = 0; my $foundsm = 0;694 while (defined ($line = <CFGFILE>)) {695 if ($line =~ /collectionmeta\s+iconcollection\s+/) {696 $line = "collectionmeta iconcollection _httpprefix_/collect/$collection/images/$collection.gif\n";697 $found = 1;698 } elsif ($line =~ /collectionmeta\s+iconcollectionsmall\s+/) {699 $line = "collectionmeta iconcollectionsmall _httpprefix_/collect/$collection/images/${collection}sm.gif\n";700 $foundsm = 1;701 }702 $file .= $line;703 }704 close CFGFILE;705 706 $file .= "collectionmeta iconcollection _httpprefix_/collect/$collection/images/$collection.gif\n" if !$found;707 $file .= "collectionmeta iconcollectionsmall _httpprefix_/collect/$collection/images/${collection}sm.gif\n" if !$foundsm;708 709 if (!open (CFGFILE, ">$configfilename")) {710 &gsprintf($out, "{buildcol.cannot_open_cfg_file}\n", $configfilename);711 &gsprintf($out, "{buildcol.unlinked_col_images}\n");712 return;713 }714 print CFGFILE $file;715 close CFGFILE;716 }717 ## create_images() ##718 593 719 594 ## @method make_absolute()
Note:
See TracChangeset
for help on using the changeset viewer.