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

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

fixed a bug - made some functions virtual for use with cstr collection

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