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