source: branches/New_Config_Format-branch/gsdl/src/recpt/pagedbrowserclass.cpp@ 1279

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

merged changes to trunk into New_Config_Format branch

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