source: trunk/gsdl/perllib/classify/Collage.pm@ 7409

Last change on this file since 7409 was 7409, checked in by davidb, 20 years ago

Abstract field missing from Collage options (fix, and set to noi -- would
be better to write one and set this to yes!)

  • Property svn:keywords set to Author Date Id Revision
File size: 7.4 KB
Line 
1##########################################################################
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
26package Collage;
27
28use BasClas;
29use sorttools;
30
31sub BEGIN {
32 @ISA = ('BasClas');
33}
34
35my $arguments =
36 [ { 'name' => "buttonname",
37 'desc' => "{BasClas.buttonname}",
38 'type' => "string",
39 'deft' => "Collage",
40 'reqd' => "no" },
41 { 'name' => "geometry",
42 'desc' => "{Collage.geometry}",
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",
52 'desc' => "{Collage.maxDepth}",
53 'type' => "string",
54 'deft' => "500"},
55# { 'name' => "maxDownloads",
56# 'desc' => "{BasClas.maxDownloads}",
57# 'type' => "string",
58# 'deft' => "",
59# 'reqd' => "no" },
60 { 'name' => "maxDisplay",
61 'desc' => "{Collage.maxDisplay}",
62 'type' => "string",
63 'deft' => "25",
64 'reqd' => "no" },
65 { 'name' => "imageType",
66 'desc' => "{Collage.imageType}",
67 'type' => "string",
68 'deft' => ".jpg%%.png",
69 'reqd' => "no" },
70 { 'name' => "bgcolor",
71 'desc' => "{Collage.bgcolor}",
72 'type' => "string",
73 'deft' => "#96c29a",
74 'reqd' => "no" },
75 { 'name' => "refreshDelay",
76 'desc' => "{Collage.refreshDelay}",
77 'type' => "string",
78 'deft' => "1500",
79 'reqd' => "no" },
80 { 'name' => "isJava2",
81 'desc' => "{Collage.isJava2}",
82 'type' => "string",
83 'deft' => "auto",
84 'reqd' => "no" },
85 { 'name' => "imageMustNotHave",
86 'desc' => "{Collage.imageMustNotHave}",
87 'type' => "string",
88 'deft' => "hl=%%x=%%gt=%%gc=%%.pr",
89 'reqd' => "no" },
90 { 'name' => "caption",
91 'desc' => "{Collage.caption}",
92 'type' => "string",
93 'deft' => "",
94 'reqd' => "no" }
95 ];
96
97
98
99
100my $options = { 'name' => "Collage",
101 'desc' => "{Collage.desc}",
102 'abstract' => "no",
103 'inherits' => "Yes",
104 'args' => $arguments };
105
106
107sub 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
114 if ($self->{'info_only'}) {
115 # created from classinfo.pl - don't need to parse the arguments
116 return bless $self, $class;
117 }
118
119 my ($title, $geometry, $verbosity, $maxDepth, $imageType, $bgcolor, $refreshDelay, $isJava2, $caption, $maxDisplay, $maxDownloads, $list);
120
121 if (!parsargv::parse(\@_,
122 q^buttonname/.*/Collage^, \$title,
123 q^geometry/.*/600x300^, \$geometry,
124 q^verbosity/.*/3^, \$verbosity,
125 q^maxDepth/.*/500^, \$maxDepth,
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,
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;
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;
158 return bless $self, $class;
159}
160
161sub init {
162 my $self = shift (@_);
163
164 $self->{'list'} = [];
165}
166
167sub 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
176sub get_classify_info {
177 my $self = shift (@_);
178
179 my $items_per_page = 2;
180 my $max_items_per_page = 20;
181
182 my @list = @{$self->{'list'}};
183
184 my $outhandle = $self->{'outhandle'};
185 my $verbosity = $self->{'verbosity'};
186
187 if ($verbosity>1) {
188 print $outhandle ("$self->{'title'}\n");
189 }
190
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
198 foreach $oid (@list) {
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++;
213 }
214
215 return $collage_head;
216}
217
218
219sub get_entry {
220 my $self = shift (@_);
221 my ($title, $childtype, $thistype) = @_;
222
223 # organise into classification structure
224 my %classifyinfo = ('childtype'=>$childtype,
225 'Title'=>$title,
226 'parameters'=> $parameters,
227 'contains'=>[]);
228
229 $classifyinfo{'thistype'} = $thistype if (defined $thistype);
230
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 }
248
249 my $parameters;
250
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'};
263
264# $parameters .= ";imageMustNotHave=".$self->{'imageMustNotHave'};
265
266
267 $classifyinfo{'parameters'} = $parameters;
268 }
269
270 return \%classifyinfo;
271}
272
2731;
Note: See TracBrowser for help on using the repository browser.