root/trunk/gsdl/src/recpt/pagedbrowserclass.cpp @ 937

Revision 937, 7.0 KB (checked in by sjboddie, 20 years ago)

tidied up a bit

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