[7331] | 1 | ##########################################################################
|
---|
[6808] | 2 | #
|
---|
| 3 | # Collage.pm --
|
---|
| 4 | # A component of the Greenstone digital library software
|
---|
| 5 | # from the New Zealand Digital Library Project at the
|
---|
| 6 | # University of Waikato, New Zealand.
|
---|
| 7 | #
|
---|
| 8 | # Copyright (C) 1999 New Zealand Digital Library Project
|
---|
| 9 | #
|
---|
| 10 | # This program is free software; you can redistribute it and/or modify
|
---|
| 11 | # it under the terms of the GNU General Public License as published by
|
---|
| 12 | # the Free Software Foundation; either version 2 of the License, or
|
---|
| 13 | # (at your option) any later version.
|
---|
| 14 | #
|
---|
| 15 | # This program is distributed in the hope that it will be useful,
|
---|
| 16 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 17 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 18 | # GNU General Public License for more details.
|
---|
| 19 | #
|
---|
| 20 | # You should have received a copy of the GNU General Public License
|
---|
| 21 | # along with this program; if not, write to the Free Software
|
---|
| 22 | # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
---|
| 23 | #
|
---|
| 24 | ###########################################################################
|
---|
| 25 |
|
---|
[6968] | 26 | package Collage;
|
---|
[6808] | 27 |
|
---|
| 28 | use BasClas;
|
---|
| 29 | use sorttools;
|
---|
| 30 |
|
---|
| 31 | sub BEGIN {
|
---|
| 32 | @ISA = ('BasClas');
|
---|
| 33 | }
|
---|
| 34 |
|
---|
| 35 | my $arguments =
|
---|
| 36 | [ { 'name' => "buttonname",
|
---|
[6968] | 37 | 'desc' => "{BasClas.buttonname}",
|
---|
[6808] | 38 | 'type' => "string",
|
---|
[6968] | 39 | 'deft' => "Collage",
|
---|
[7331] | 40 | 'reqd' => "no" },
|
---|
| 41 | { 'name' => "geometry",
|
---|
[7405] | 42 | 'desc' => "{Collage.geometry}",
|
---|
[7331] | 43 | 'type' => "string",
|
---|
| 44 | 'deft' => "600x300",
|
---|
| 45 | 'reqd' => "no" },
|
---|
| 46 | { 'name' => "verbosity",
|
---|
| 47 | 'desc' => "{BasClas.verbosity}",
|
---|
| 48 | 'type' => "string",
|
---|
| 49 | 'deft' => "5",
|
---|
| 50 | 'reqd' => "no" },
|
---|
| 51 | { 'name' => "maxDepth",
|
---|
[7405] | 52 | 'desc' => "{Collage.maxDepth}",
|
---|
[7331] | 53 | 'type' => "string",
|
---|
[7345] | 54 | 'deft' => "500"},
|
---|
[7331] | 55 | # { 'name' => "maxDownloads",
|
---|
| 56 | # 'desc' => "{BasClas.maxDownloads}",
|
---|
| 57 | # 'type' => "string",
|
---|
| 58 | # 'deft' => "",
|
---|
| 59 | # 'reqd' => "no" },
|
---|
| 60 | { 'name' => "maxDisplay",
|
---|
[7405] | 61 | 'desc' => "{Collage.maxDisplay}",
|
---|
[7331] | 62 | 'type' => "string",
|
---|
| 63 | 'deft' => "25",
|
---|
| 64 | 'reqd' => "no" },
|
---|
| 65 | { 'name' => "imageType",
|
---|
[7405] | 66 | 'desc' => "{Collage.imageType}",
|
---|
[7331] | 67 | 'type' => "string",
|
---|
[7409] | 68 | 'deft' => ".jpg%%.png",
|
---|
[7331] | 69 | 'reqd' => "no" },
|
---|
| 70 | { 'name' => "bgcolor",
|
---|
[7405] | 71 | 'desc' => "{Collage.bgcolor}",
|
---|
[7331] | 72 | 'type' => "string",
|
---|
| 73 | 'deft' => "#96c29a",
|
---|
| 74 | 'reqd' => "no" },
|
---|
| 75 | { 'name' => "refreshDelay",
|
---|
[7405] | 76 | 'desc' => "{Collage.refreshDelay}",
|
---|
[7331] | 77 | 'type' => "string",
|
---|
| 78 | 'deft' => "1500",
|
---|
| 79 | 'reqd' => "no" },
|
---|
| 80 | { 'name' => "isJava2",
|
---|
[7405] | 81 | 'desc' => "{Collage.isJava2}",
|
---|
[7331] | 82 | 'type' => "string",
|
---|
| 83 | 'deft' => "auto",
|
---|
| 84 | 'reqd' => "no" },
|
---|
| 85 | { 'name' => "imageMustNotHave",
|
---|
[7405] | 86 | 'desc' => "{Collage.imageMustNotHave}",
|
---|
[7331] | 87 | 'type' => "string",
|
---|
[7405] | 88 | 'deft' => "hl=%%x=%%gt=%%gc=%%.pr",
|
---|
[7331] | 89 | 'reqd' => "no" },
|
---|
| 90 | { 'name' => "caption",
|
---|
[7405] | 91 | 'desc' => "{Collage.caption}",
|
---|
[7331] | 92 | 'type' => "string",
|
---|
| 93 | 'deft' => "",
|
---|
| 94 | 'reqd' => "no" }
|
---|
| 95 | ];
|
---|
[6808] | 96 |
|
---|
[7331] | 97 |
|
---|
| 98 |
|
---|
| 99 |
|
---|
[6808] | 100 | my $options = { 'name' => "Collage",
|
---|
| 101 | 'desc' => "{Collage.desc}",
|
---|
[7409] | 102 | 'abstract' => "no",
|
---|
[6808] | 103 | 'inherits' => "Yes",
|
---|
| 104 | 'args' => $arguments };
|
---|
| 105 |
|
---|
| 106 |
|
---|
| 107 | sub new {
|
---|
| 108 | my $class = shift (@_);
|
---|
| 109 | my $self = new BasClas($class, @_);
|
---|
| 110 |
|
---|
| 111 | my $option_list = $self->{'option_list'};
|
---|
| 112 | push( @{$option_list}, $options );
|
---|
| 113 |
|
---|
[6968] | 114 | if ($self->{'info_only'}) {
|
---|
| 115 | # created from classinfo.pl - don't need to parse the arguments
|
---|
| 116 | return bless $self, $class;
|
---|
| 117 | }
|
---|
| 118 |
|
---|
[7331] | 119 | my ($title, $geometry, $verbosity, $maxDepth, $imageType, $bgcolor, $refreshDelay, $isJava2, $caption, $maxDisplay, $maxDownloads, $list);
|
---|
[6808] | 120 |
|
---|
| 121 | if (!parsargv::parse(\@_,
|
---|
[7331] | 122 | q^buttonname/.*/Collage^, \$title,
|
---|
| 123 | q^geometry/.*/600x300^, \$geometry,
|
---|
| 124 | q^verbosity/.*/3^, \$verbosity,
|
---|
[7345] | 125 | q^maxDepth/.*/500^, \$maxDepth,
|
---|
[7331] | 126 | # q^maxDownloads/.*/^, \$maxDownloads,
|
---|
| 127 | q^maxDisplay/.*/25^, \$maxDisplay,
|
---|
| 128 | q^imageType/.*/.jpg%.png^, \$imageType,
|
---|
| 129 | q^bgcolor/.*/\#96c29a^, \$bgcolor,
|
---|
| 130 | q^refreshDelay/.*/1200^, \$refreshDelay,
|
---|
| 131 | q^isJava2/.*/auto^, \$isJava2,
|
---|
| 132 | q^imageMustNotHave/.*/hl=\%x=\%gt=\%gc=\%.pr^, \$imageMustNotHave,
|
---|
| 133 | q^caption/.*/ ^, \$caption,
|
---|
[6808] | 134 | "allow_extra_options")) {
|
---|
| 135 |
|
---|
| 136 | print STDERR "\nIncorrect options passed to $class, check your collect.cfg file\n";
|
---|
| 137 | $self->print_txt_usage(""); # Use default resource bundle
|
---|
| 138 | die "\n";
|
---|
| 139 | }
|
---|
| 140 |
|
---|
| 141 | if (!$title) {
|
---|
| 142 | $title = 'Collage';
|
---|
| 143 | }
|
---|
| 144 |
|
---|
| 145 | $self->{'list'} = $list;
|
---|
| 146 | $self->{'title'} = $title;
|
---|
[7331] | 147 | $self->{'geometry'} = $geometry;
|
---|
| 148 | $self->{'verbosity'} = $verbosity;
|
---|
| 149 | $self->{'maxDepth'} = $maxDepth;
|
---|
| 150 | $self->{'maxDownloads'} = $maxDownloads;
|
---|
| 151 | $self->{'maxDisplay'} = $maxDisplay;
|
---|
| 152 | $self->{'imageType'} = $imageType;
|
---|
| 153 | $self->{'bgcolor'} = $bgcolor;
|
---|
| 154 | $self->{'refreshDelay'} = $refreshDelay;
|
---|
| 155 | $self->{'isJava2'} = $isJava2;
|
---|
| 156 | # $self->{'imageMustNotHave'} = $imageMustNotHave;
|
---|
| 157 | $self->{'caption'} = $caption;
|
---|
[6808] | 158 | return bless $self, $class;
|
---|
| 159 | }
|
---|
| 160 |
|
---|
| 161 | sub init {
|
---|
| 162 | my $self = shift (@_);
|
---|
| 163 |
|
---|
| 164 | $self->{'list'} = [];
|
---|
| 165 | }
|
---|
| 166 |
|
---|
| 167 | sub classify {
|
---|
| 168 |
|
---|
| 169 | my $self = shift (@_);
|
---|
| 170 | my ($doc_obj) = @_;
|
---|
| 171 |
|
---|
| 172 | my $doc_OID = $doc_obj->get_OID();
|
---|
| 173 | push (@{$self->{'list'}}, $doc_OID);
|
---|
| 174 | }
|
---|
| 175 |
|
---|
| 176 | sub get_classify_info {
|
---|
| 177 | my $self = shift (@_);
|
---|
| 178 |
|
---|
[7345] | 179 | my $items_per_page = 2;
|
---|
| 180 | my $max_items_per_page = 20;
|
---|
[6808] | 181 |
|
---|
[7345] | 182 | my @list = @{$self->{'list'}};
|
---|
[6808] | 183 |
|
---|
[7345] | 184 | my $outhandle = $self->{'outhandle'};
|
---|
| 185 | my $verbosity = $self->{'verbosity'};
|
---|
[6808] | 186 |
|
---|
[7345] | 187 | if ($verbosity>1) {
|
---|
| 188 | print $outhandle ("$self->{'title'}\n");
|
---|
| 189 | }
|
---|
[6808] | 190 |
|
---|
[7345] | 191 | my $collage_head = $self->get_entry ($self->{'title'}, "Collage", "Invisible");
|
---|
| 192 | my $collage_curr = $self->get_entry("Collage","VList");
|
---|
| 193 | push (@{$collage_head->{'contains'}},$collage_curr);
|
---|
| 194 |
|
---|
| 195 | my $global_c=1;
|
---|
| 196 | my $within_page_c=1;
|
---|
| 197 |
|
---|
[6808] | 198 | foreach $oid (@list) {
|
---|
[7345] | 199 | if ($within_page_c>$items_per_page) {
|
---|
| 200 | my $title = "Items $global_c+";
|
---|
| 201 | my $nested_node = $self->get_entry($title,"VList");
|
---|
| 202 | push (@{$collage_curr->{'contains'}}, $nested_node);
|
---|
| 203 | $collage_curr = $nested_node;
|
---|
| 204 |
|
---|
| 205 | $within_page_c=1;
|
---|
| 206 |
|
---|
| 207 | $items_per_page++ if ($items_per_page < $max_items_per_page);
|
---|
| 208 | }
|
---|
| 209 |
|
---|
| 210 | push (@{$collage_curr->{'contains'}}, {'OID'=>$oid});
|
---|
| 211 | $global_c++;
|
---|
| 212 | $within_page_c++;
|
---|
[6808] | 213 | }
|
---|
| 214 |
|
---|
[7345] | 215 | return $collage_head;
|
---|
[6808] | 216 | }
|
---|
| 217 |
|
---|
| 218 |
|
---|
| 219 | sub get_entry {
|
---|
| 220 | my $self = shift (@_);
|
---|
| 221 | my ($title, $childtype, $thistype) = @_;
|
---|
[7331] | 222 |
|
---|
[7345] | 223 | # organise into classification structure
|
---|
| 224 | my %classifyinfo = ('childtype'=>$childtype,
|
---|
| 225 | 'Title'=>$title,
|
---|
| 226 | 'parameters'=> $parameters,
|
---|
| 227 | 'contains'=>[]);
|
---|
[7331] | 228 |
|
---|
[7345] | 229 | $classifyinfo{'thistype'} = $thistype if (defined $thistype);
|
---|
[7331] | 230 |
|
---|
[7345] | 231 | if ($childtype eq "Collage") {
|
---|
| 232 | my $geometry = $self->{'geometry'};
|
---|
| 233 | my ($x_dim,$y_dim) = ($geometry =~ m/^(.*)x(.*)$/);
|
---|
| 234 | my $verbosity = $self->{'verbosity'};
|
---|
| 235 | my $maxDepth = $self->{'maxDepth'};
|
---|
| 236 | # my $maxDownloads = $self->{'maxDownloads'};
|
---|
| 237 | my $maxDisplay = $self->{'maxDisplay'};
|
---|
| 238 | my $imageType = $self->{'imageType'};
|
---|
| 239 | my $bgcolor = $self->{'bgcolor'};
|
---|
| 240 | my $refreshDelay = $self->{'refreshDelay'};
|
---|
| 241 | my $isJava2 = $self->{'isJava2'};
|
---|
| 242 | my $imageMustNotHave = $self->{'imageMustNotHave'};
|
---|
| 243 | my $caption = $self->{'caption'};
|
---|
| 244 |
|
---|
| 245 | if (!defined($maxDownloads)) {
|
---|
| 246 | $maxDownloads="";
|
---|
| 247 | }
|
---|
[7331] | 248 |
|
---|
[7345] | 249 | my $parameters;
|
---|
[7331] | 250 |
|
---|
[7345] | 251 | $parameters = "xdim=".$x_dim;
|
---|
| 252 | $parameters .= ";ydim=".$y_dim;
|
---|
| 253 | $parameters .= ";geometry=".$self->{'geometry'};
|
---|
| 254 | $parameters .= ";verbosity=".$self->{'verbosity'};
|
---|
| 255 | $parameters .= ";maxDepth=".$self->{'maxDepth'};
|
---|
| 256 | # $parameters .= ";maxDownloads=".$maxDownloads;
|
---|
| 257 | $parameters .= ";maxDisplay=".$self->{'maxDisplay'};
|
---|
| 258 | $parameters .= ";imageType=".$self->{'imageType'};
|
---|
| 259 | $parameters .= ";bgcolor=".$self->{'bgcolor'};
|
---|
| 260 | $parameters .= ";refreshDelay=".$self->{'refreshDelay'};
|
---|
| 261 | $parameters .= ";isJava2=".$self->{'isJava2'};
|
---|
| 262 | $parameters .= ";caption=".$self->{'caption'};
|
---|
[7331] | 263 |
|
---|
[7345] | 264 | # $parameters .= ";imageMustNotHave=".$self->{'imageMustNotHave'};
|
---|
| 265 |
|
---|
[6808] | 266 |
|
---|
[7345] | 267 | $classifyinfo{'parameters'} = $parameters;
|
---|
| 268 | }
|
---|
| 269 |
|
---|
[6808] | 270 | return \%classifyinfo;
|
---|
| 271 | }
|
---|
| 272 |
|
---|
| 273 | 1;
|
---|