source: trunk/gsdl/src/recpt/pagedbrowserclass.cpp@ 1282

Last change on this file since 1282 was 1282, checked in by sjboddie, 24 years ago

got DocumentArrowsBottom working for collections using "paged" browsers
(like gberg). The whole idea of arrows as used both in the query results
page and document pages needs to be revisited to get things working in
all situations

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 8.0 KB
Line 
1/**********************************************************************
2 *
3 * pagedbrowserclass.cpp --
4 * Copyright (C) 1999 The New Zealand Digital Library Project
5 *
6 * A component of the Greenstone digital library software
7 * from the New Zealand Digital Library Project at the
8 * University of Waikato, New Zealand.
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 * $Id: pagedbrowserclass.cpp 1282 2000-07-13 02:51:10Z sjboddie $
25 *
26 *********************************************************************/
27
28/*
29 $Log$
30 Revision 1.11 2000/07/13 02:51:10 sjboddie
31 got DocumentArrowsBottom working for collections using "paged" browsers
32 (like gberg). The whole idea of arrows as used both in the query results
33 page and document pages needs to be revisited to get things working in
34 all situations
35
36 Revision 1.10 2000/06/29 02:47:20 sjboddie
37 added browser info (i.e VList, HList etc.) to status pages
38
39 Revision 1.9 2000/03/31 03:04:32 nzdl
40 tidied up some of the browsing code - replaced DocumentImages,
41 DocumentTitles and DocumentHeading with DocumentIcon
42
43 Revision 1.8 2000/02/17 20:54:00 sjboddie
44 minor change to macro name
45
46 Revision 1.7 2000/02/17 02:35:48 sjboddie
47 tidied up a bit
48
49 Revision 1.6 2000/02/15 22:53:51 kjm18
50 search history stuff added.
51
52 Revision 1.5 2000/02/06 21:29:11 sjboddie
53 fixed a bug - made some functions virtual for use with cstr collection
54
55 Revision 1.4 1999/10/30 23:06:25 sjboddie
56 tidied up a bit
57
58 Revision 1.3 1999/10/30 22:16:37 sjboddie
59 added a collection argument
60
61 Revision 1.2 1999/10/19 08:40:11 sjboddie
62 fixed some stupid compiler warnings on windows
63
64 Revision 1.1 1999/10/14 22:59:35 sjboddie
65 finished off browser classes
66
67 */
68
69
70#include "pagedbrowserclass.h"
71#include <assert.h>
72#include "OIDtools.h"
73
74pagedbrowserclass::pagedbrowserclass () {
75}
76
77pagedbrowserclass::~pagedbrowserclass () {
78}
79
80// returns the name that specifies the browserclass type
81text_t pagedbrowserclass::get_browser_name () {
82 return "Paged";
83}
84
85
86void pagedbrowserclass::load_metadata_defaults (text_tset &metadata) {
87 metadata.insert ("Title");
88}
89
90// if the "gp" (go to page) argument is set we need to set
91// the "d" argument to the corresponding page
92// also want to set "d" argument to first child if we're at
93// an 'Invisible' top level
94void pagedbrowserclass::processOID (cgiargsclass &args, recptproto *collectproto,
95 ostream &logout) {
96
97 text_t &arg_d = args["d"];
98 text_t &arg_gp = args["gp"];
99 text_tset metadata;
100 bool getParents = false;
101 FilterResponse_t response;
102
103 if ((!arg_d.empty()) && (!arg_gp.empty()) && (is_number (arg_gp))) {
104 text_t top;
105 get_top (arg_d, top);
106 metadata.insert ("Title");
107 get_children (top, args["c"], metadata, getParents, collectproto, response, logout);
108 ResultDocInfo_tarray::iterator dochere = response.docInfo.begin();
109 ResultDocInfo_tarray::iterator docend = response.docInfo.end();
110 while (dochere != docend) {
111 if ((*dochere).metadata["Title"].values[0] == arg_gp) {
112 arg_d = (*dochere).OID;
113 break;
114 }
115 dochere ++;
116 }
117
118 } else if (!arg_d.empty() && is_top(arg_d)) { // if top level doc, check if not invisible
119 metadata.insert("thistype");
120 if (get_info(arg_d, args["c"], metadata, getParents, collectproto, response, logout)) {
121 text_t type = response.docInfo[0].metadata["thistype"].values[0];
122 if (type=="Invisible") { // display first child
123 arg_d = arg_d + ".fc";
124 }
125 }
126 }
127
128
129
130}
131
132int pagedbrowserclass::output_section_group (ResultDocInfo_t &section, cgiargsclass &args,
133 const text_t &/*collection*/, int /*colnumber*/,
134 format_t * /*formatlistptr*/, bool /*use_table*/,
135 text_tset &/*metadata*/, bool &/*getParents*/,
136 recptproto * /*collectproto*/, displayclass &disp,
137 outconvertclass &outconvert, ostream &textout,
138 ostream &/*logout*/) {
139
140 // this browser class only handles document levels
141 if (args["d"].empty()) return 0;
142
143 if (section.OID != args["d"]) {
144 text_t httpprevarrow = "_httpdocument_&cl=" + args["cl"] + "&d=" + section.OID;
145 text_t parentarrow = "<a href=\"" + httpprevarrow + "\">_iconprev_</a>\n";
146 disp.setmacro ("httpprevarrow", "document", httpprevarrow);
147 disp.setmacro ("parentarrow", "document", parentarrow);
148 return 0;
149 }
150
151 // must be at top level to get to here!
152 textout << outconvert << disp << "<b>" << section.metadata["Title"].values[0]
153 << "_document:textintro_</b>\n";
154
155 return 0;
156}
157
158int pagedbrowserclass::output_section_group (FilterResponse_t &sections, cgiargsclass &args,
159 const text_t &/*collection*/, int /*colnumber*/,
160 format_t * /*formatlistptr*/, bool /*use_table*/,
161 text_tset &/*metadata*/, bool &/*getParents*/,
162 recptproto * /*collectproto*/, displayclass &disp,
163 outconvertclass &outconvert, ostream &textout,
164 ostream &/*logout*/) {
165
166 text_t &arg_d = args["d"];
167
168 // this browser class only handles document levels
169 if (arg_d.empty()) return 0;
170
171 text_t previousOID, previoustitle, nextOID, nexttitle;
172 text_t previousarrow, nextarrow, httpprevarrow, httpnextarrow;
173 bool found = false;
174
175 // this should be our list of pages
176
177 ResultDocInfo_tarray::iterator thissection = sections.docInfo.begin();
178 ResultDocInfo_tarray::iterator endsection = sections.docInfo.end();
179
180 while (thissection != endsection) {
181 if (arg_d == (*thissection).OID) {
182 found = true;
183 textout << outconvert << disp
184 << "<table><tr valign=top><td colspan=3><center><b>_page_"
185 << (*thissection).metadata["Title"].values[0] << "</b>\n";
186 if (thissection != sections.docInfo.begin()) {
187 previousOID = (*(thissection-1)).OID;
188 previoustitle = (*(thissection-1)).metadata["Title"].values[0];
189 } else {
190 previousarrow = "_document:parentarrow_";
191 }
192
193 if ((thissection+1) != endsection) {
194 nextOID = (*(thissection+1)).OID;
195 nexttitle = (*(thissection+1)).metadata["Title"].values[0];
196 }
197 break;
198 }
199 thissection ++;
200 }
201
202 if (!found) {
203 textout << outconvert << disp
204 << "<table><tr valign=top> <td colspan=3><center>\n";
205 }
206 int numpages = sections.docInfo.size();
207 textout << outconvert << disp
208 << ("_document:textnumpages_(" + text_t(numpages) + ")</center></td></tr>\n");
209
210 if (!found) {
211 httpnextarrow = "_httpdocument_&cl=" + args["cl"] + "&d=" + sections.docInfo[0].OID;
212 nextarrow = "<a href=\"" + httpnextarrow + "\">" +
213 sections.docInfo[0].metadata["Title"].values[0] + "_iconnext_</a>\n";
214
215 } else {
216 if (!previousOID.empty()) {
217 httpprevarrow = "_httpdocument_&cl=" + args["cl"] + "&d=" + previousOID;
218 previousarrow = "<a href=\"" + httpprevarrow + "\">_iconprev_" + previoustitle + "</a>\n";
219 }
220 if (!nextOID.empty()) {
221 httpnextarrow = "_httpdocument_&cl=" + args["cl"] + "&d=" + nextOID;
222 nextarrow = "<a href=\"" + httpnextarrow + "\">" + nexttitle + "_iconnext_</a>\n";
223 }
224 }
225
226 if (!httpprevarrow.empty()) disp.setmacro ("httpprevarrow", "document", httpprevarrow);
227 if (!httpnextarrow.empty()) disp.setmacro ("httpnextarrow", "document", httpnextarrow);
228
229 textout << outconvert << disp << "<tr valign=middle>\n"
230 << "<td align=right>" << previousarrow << "</td>\n"
231 << "<td align=center valign=top>_document:gotoform_</td>"
232 << "<td align=left>" << nextarrow << "</td>\n"
233 << "</tr></table>\n";
234
235 return 0;
236}
237
238
239
240
241
242
Note: See TracBrowser for help on using the repository browser.