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