[668] | 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 937 2000-02-17 02:35:48Z sjboddie $
|
---|
| 25 | *
|
---|
| 26 | *********************************************************************/
|
---|
| 27 |
|
---|
| 28 | /*
|
---|
| 29 | $Log$
|
---|
[937] | 30 | Revision 1.7 2000/02/17 02:35:48 sjboddie
|
---|
| 31 | tidied up a bit
|
---|
| 32 |
|
---|
[928] | 33 | Revision 1.6 2000/02/15 22:53:51 kjm18
|
---|
| 34 | search history stuff added.
|
---|
| 35 |
|
---|
[912] | 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 |
|
---|
[753] | 39 | Revision 1.4 1999/10/30 23:06:25 sjboddie
|
---|
| 40 | tidied up a bit
|
---|
| 41 |
|
---|
[747] | 42 | Revision 1.3 1999/10/30 22:16:37 sjboddie
|
---|
| 43 | added a collection argument
|
---|
| 44 |
|
---|
[727] | 45 | Revision 1.2 1999/10/19 08:40:11 sjboddie
|
---|
| 46 | fixed some stupid compiler warnings on windows
|
---|
| 47 |
|
---|
[668] | 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 |
|
---|
| 58 | pagedbrowserclass::pagedbrowserclass () {
|
---|
| 59 | }
|
---|
| 60 |
|
---|
| 61 | pagedbrowserclass::~pagedbrowserclass () {
|
---|
| 62 | }
|
---|
| 63 |
|
---|
| 64 | // returns the name that specifies the browserclass type
|
---|
| 65 | text_t pagedbrowserclass::get_browser_name () {
|
---|
| 66 | return "Paged";
|
---|
| 67 | }
|
---|
| 68 |
|
---|
| 69 |
|
---|
| 70 | void pagedbrowserclass::load_metadata_defaults (text_tset &metadata) {
|
---|
| 71 | metadata.insert ("Title");
|
---|
| 72 | }
|
---|
| 73 |
|
---|
| 74 | text_t pagedbrowserclass::get_default_formatstring () {
|
---|
| 75 | return "";
|
---|
| 76 | }
|
---|
| 77 |
|
---|
[912] | 78 | // if the "gp" (go to page) argument is set we need to set
|
---|
[668] | 79 | // the "d" argument to the corresponding page
|
---|
[937] | 80 | // also want to set "d" argument to first child if we're at
|
---|
| 81 | // an 'Invisible' top level
|
---|
[668] | 82 | void pagedbrowserclass::processOID (cgiargsclass &args, recptproto *collectproto,
|
---|
[912] | 83 | ostream &logout) {
|
---|
[668] | 84 |
|
---|
| 85 | text_t &arg_d = args["d"];
|
---|
| 86 | text_t &arg_gp = args["gp"];
|
---|
[912] | 87 | text_tset metadata;
|
---|
| 88 | bool getParents = false;
|
---|
| 89 | FilterResponse_t response;
|
---|
| 90 |
|
---|
[668] | 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) {
|
---|
[912] | 100 | arg_d = (*dochere).OID;
|
---|
| 101 | break;
|
---|
[668] | 102 | }
|
---|
| 103 | dochere ++;
|
---|
| 104 | }
|
---|
[912] | 105 |
|
---|
| 106 | } else if (!arg_d.empty() && is_top(arg_d)) { // if top level doc, check if not invisible
|
---|
| 107 | metadata.insert("thistype");
|
---|
[937] | 108 | if (get_info(arg_d, args["c"], metadata, getParents, collectproto, response, logout)) {
|
---|
[912] | 109 | text_t type = response.docInfo[0].metadata["thistype"].values[0];
|
---|
| 110 | if (type=="Invisible") { // display first child
|
---|
[937] | 111 | arg_d = arg_d + ".fc";
|
---|
[912] | 112 | }
|
---|
| 113 | }
|
---|
[668] | 114 | }
|
---|
[928] | 115 |
|
---|
| 116 |
|
---|
| 117 |
|
---|
[668] | 118 | }
|
---|
| 119 |
|
---|
| 120 | int pagedbrowserclass::output_section_group (ResultDocInfo_t §ion, cgiargsclass &args,
|
---|
[753] | 121 | const text_t &/*collection*/, int /*colnumber*/,
|
---|
| 122 | format_t * /*formatlistptr*/, bool /*use_table*/,
|
---|
| 123 | text_tset &/*metadata*/, bool &/*getParents*/,
|
---|
[727] | 124 | recptproto * /*collectproto*/, displayclass &disp,
|
---|
[753] | 125 | outconvertclass &outconvert, ostream &textout,
|
---|
| 126 | ostream &/*logout*/) {
|
---|
[668] | 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 |
|
---|
| 146 | int pagedbrowserclass::output_section_group (FilterResponse_t §ions, cgiargsclass &args,
|
---|
[753] | 147 | const text_t &/*collection*/, int /*colnumber*/,
|
---|
| 148 | format_t * /*formatlistptr*/, bool /*use_table*/,
|
---|
| 149 | text_tset &/*metadata*/, bool &/*getParents*/,
|
---|
[727] | 150 | recptproto * /*collectproto*/, displayclass &disp,
|
---|
[753] | 151 | outconvertclass &outconvert, ostream &textout,
|
---|
| 152 | ostream &/*logout*/) {
|
---|
[668] | 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;
|
---|
[753] | 171 | textout << outconvert << disp
|
---|
| 172 | << "<table><tr valign=top><td colspan=3><center><b>_document:textpage_"
|
---|
[668] | 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 |
|
---|
[912] | 180 | if ((thissection+1) != endsection) {
|
---|
[668] | 181 | nextOID = (*(thissection+1)).OID;
|
---|
| 182 | nexttitle = (*(thissection+1)).metadata["Title"].values[0];
|
---|
| 183 | }
|
---|
| 184 | break;
|
---|
| 185 | }
|
---|
| 186 | thissection ++;
|
---|
| 187 | }
|
---|
| 188 |
|
---|
[928] | 189 | if (!found) {
|
---|
| 190 | textout << outconvert << disp
|
---|
| 191 | << "<table><tr valign=top> <td colspan=3><center>\n";
|
---|
| 192 | }
|
---|
[668] | 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 +
|
---|
[928] | 199 | "\">" + sections.docInfo[0].metadata["Title"].values[0] + "_iconnext_</a>\n";
|
---|
[668] | 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 | }
|
---|
[928] | 217 |
|
---|
| 218 |
|
---|
| 219 |
|
---|
| 220 |
|
---|
| 221 |
|
---|
| 222 |
|
---|