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

Last change on this file since 928 was 928, checked in by kjm18, 24 years ago

search history stuff added.

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