Changeset 10276
- Timestamp:
- 2005-07-25T13:56:23+12:00 (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl/perllib/plugins/PagedImgPlug.pm
r10254 r10276 228 228 if(defined $arguments){ push(@{$hashArgOptLists->{"ArgList"}},@{$arguments});} 229 229 if(defined $options) { push(@{$hashArgOptLists->{"OptList"}},$options)}; 230 230 231 231 my $self = (defined $hashArgOptLists)? new XMLPlug($pluginlist,$inputargs,$hashArgOptLists): new XMLPlug($pluginlist,$inputargs); 232 232 … … 256 256 my $section = shift (@_); #the current section 257 257 my $rotate = shift (@_); # whether to rotate the image or not 258 258 $rotate = 0 unless defined $rotate; 259 259 260 my $top=0; 260 261 if ($section eq $doc_obj->get_top_section()) { … … 279 280 my $converted = 0; 280 281 my $rotated=0; 282 281 283 if ($converttotype ne "" && $filename !~ /$converttotype$/) { 282 284 $converted=1; … … 528 530 # include directories 529 531 530 sub read {532 sub read_into_doc_obj { 531 533 my $self = shift (@_); 532 534 my ($pluginfo, $base_dir, $file, $metadata, $processor, $maxdocs, $total_count, $gli) = @_; 533 535 my $outhandle = $self->{'outhandle'}; 534 536 my $smart_block = $self->{'smart_block'}; 535 537 536 538 my $filename = &util::filename_cat($base_dir, $file); 537 539 538 540 if ($self->associate_with($file,$filename,$metadata)) { 539 541 # a form of smart block … … 541 543 return 0; # blocked 542 544 } 543 545 544 546 if ($smart_block) { 545 547 if (defined $self->{'file_blocks'}->{$filename} && $self->{'file_blocks'}->{$filename} == 1){ … … 557 559 558 560 print $outhandle "PagedImgPlug processing \"$filename\"\n" 559 561 if $self->{'verbosity'} > 1; 560 562 print STDERR "<Processing n='$file' p='PagedImgPlug'>\n" if ($gli); 561 563 562 564 # here we need to decide if we have an old text .item file, or a new xml 563 565 # .item file - for now the test is if the first non-empty line is … … 572 574 } 573 575 chomp $line; 574 if ($line =~ / ^<PagedDocument/) {576 if ($line =~ /<PagedDocument/) { 575 577 $xml_version = 1; 576 578 } 577 579 close ITEMFILE; 580 #print STDERR "xml version = $xml_version\n"; 578 581 my $doc_obj; 579 582 if ($xml_version) { 580 581 583 $file =~ s/^[\/\\]+//; # $file often begins with / so we'll tidy it up 582 584 $self->{'file'} = $file; … … 644 646 my $section = $doc_obj->get_top_section(); 645 647 $self->extra_metadata ($doc_obj, $section, $metadata); 646 647 # do plugin specific processing of doc_obj - don't need this unless 648 # something inherits from PagedImgPlug 648 #my $text=""; 649 # do plugin specific processing of doc_obj 649 650 #unless (defined ($self->process(\$text, $pluginfo, $base_dir, $file, $metadata, $doc_obj))) { 650 # print STDERR "<ProcessingError n='$file'>\n" if ($gli); 651 # return -1; 652 # } 653 651 #print STDERR "<ProcessingError n='$file'>\n" if ($gli); 652 #return -1; 653 #} 654 654 # do any automatic metadata extraction 655 655 $self->auto_extract_metadata ($doc_obj); 656 656 657 # process the document 658 $processor->process($doc_obj); 659 657 $self->{'num_processed'}++; 658 return (1,$doc_obj); 659 } 660 661 sub read 662 { 663 my $self = shift (@_); 664 my ($pluginfo, $base_dir, $file, $metadata, $processor, $maxdocs, $total_count, $gli) = @_; 665 666 my ($process_status,$doc_obj) = $self->read_into_doc_obj(@_); 667 668 if ((defined $process_status) && ($process_status == 1)) { 669 # process the document 670 $processor->process($doc_obj); 671 672 #if(defined($self->{'places_filename'})){ 673 # &util::rm($self->{'places_filename'}); 674 # $self->{'places_filename'} = undef; 675 #} 676 #$self->{'num_processed'} ++; 677 undef $doc_obj; 678 } 679 660 680 # clean up temporary files - we do this here instead of in 661 681 # process_image becuase associated files aren't actually copied … … 663 683 if (defined $self->{'tmp_filename1'} && 664 684 -e $self->{'tmp_filename1'}) { 665 685 &util::rm($self->{'tmp_filename1'}) 666 686 } 667 687 if (defined $self->{'tmp_filename2'} && 668 688 -e $self->{'tmp_filename2'}) { 669 689 &util::rm($self->{'tmp_filename2'}) 670 690 } 671 691 if (defined $self->{'tmp_filename3'} && … … 673 693 &util::rm($self->{'tmp_filename3'}) 674 694 } 675 676 $self->{'num_processed'}++; 677 678 return 1; 695 # if process_status == 1, then the file has been processed. 696 return $process_status; 679 697 } 680 698 … … 699 717 } 700 718 my ($txtfile) = $_{'txtfile'}; 701 if (defined($txtfile) ) {719 if (defined($txtfile)&& $txtfile ne "") { 702 720 $self->process_text ($self->{'base_dir'}.$txtfile, $txtfile, $doc_obj, $self->{'current_section'}); 703 721 } else { … … 793 811 # set the gsdlthistype metadata to Paged - this ensures this document will 794 812 # be treated as a Paged doc, even if Titles are not numeric 795 796 813 $doc_obj->set_utf8_metadata_element ($topsection, "gsdlthistype", "Paged"); 797 814 } else { … … 862 879 # Do encoding stuff 863 880 my ($language, $encoding) = $self->textcat_get_language_encoding ($fullpath); 864 881 865 882 my $text=""; 866 883 &BasPlug::read_file($self, $fullpath, $encoding, $language, \$text);
Note:
See TracChangeset
for help on using the changeset viewer.