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