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