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

Last change on this file since 671 was 668, checked in by sjboddie, 25 years ago

finished off browser classes

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