[1023] | 1 | /**********************************************************************
|
---|
| 2 | *
|
---|
| 3 | * niupepadocaction.cpp --
|
---|
| 4 | * A component of the Greenstone digital library software
|
---|
| 5 | * from the New Zealand Digital Library Project at the
|
---|
| 6 | * University of Waikato, New Zealand.
|
---|
| 7 | *
|
---|
| 8 | * Copyright (C) 1999 The New Zealand Digital Library Project
|
---|
| 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: niupepadocaction.cpp 1521 2000-09-08 03:17:08Z nzdl $
|
---|
| 25 | *
|
---|
| 26 | *********************************************************************/
|
---|
| 27 |
|
---|
| 28 | /*
|
---|
| 29 | $Log$
|
---|
[1521] | 30 | Revision 1.2 2000/09/08 03:17:08 nzdl
|
---|
| 31 | updated niupepa collection
|
---|
[1023] | 32 |
|
---|
[1521] | 33 | Revision 1.1.1.1 2000/03/08 20:44:50 sjboddie
|
---|
| 34 | added niupepa to CVS
|
---|
| 35 |
|
---|
[1023] | 36 | Revision 1.2 1999/09/07 22:19:50 sjboddie
|
---|
| 37 | added GPL header
|
---|
| 38 |
|
---|
| 39 | Revision 1.1 1999/08/29 23:35:07 sjboddie
|
---|
| 40 | niupepa receptionist
|
---|
| 41 |
|
---|
| 42 | */
|
---|
| 43 |
|
---|
| 44 |
|
---|
| 45 | #include <string.h>
|
---|
| 46 | #include "niupepadocaction.h"
|
---|
| 47 | #include "niupepabrowsetools.h"
|
---|
| 48 | #include "OIDtools.h"
|
---|
| 49 | #include "querytools.h"
|
---|
| 50 | #include "unitool.h"
|
---|
| 51 |
|
---|
| 52 | niupepadocaction::niupepadocaction () {
|
---|
| 53 | // this action uses cgi variable "gg" as well as
|
---|
| 54 | // those used by the standard documentaction
|
---|
| 55 |
|
---|
| 56 | cgiarginfo arg_ainfo;
|
---|
| 57 |
|
---|
| 58 | // in this action "gg" is the format of the
|
---|
| 59 | // document to view (i.e. "text", "prev" or "full")
|
---|
| 60 | arg_ainfo.shortname = "gg";
|
---|
| 61 | arg_ainfo.longname = "document format";
|
---|
| 62 | arg_ainfo.multiplechar = true;
|
---|
| 63 | arg_ainfo.defaultstatus = cgiarginfo::weak;
|
---|
| 64 | arg_ainfo.argdefault = "text";
|
---|
| 65 | arg_ainfo.savedarginfo = cgiarginfo::must;
|
---|
| 66 | argsinfo.addarginfo (NULL, arg_ainfo);
|
---|
| 67 | }
|
---|
| 68 |
|
---|
| 69 | niupepadocaction::~niupepadocaction () {
|
---|
| 70 | }
|
---|
| 71 |
|
---|
| 72 | void niupepadocaction::set_java_macros (cgiargsclass &args, displayclass &disp) {
|
---|
| 73 |
|
---|
| 74 | text_t javaimagescontent = "_javaextras__javacommentary__javaviewabstract__javaviewpaper__javaabstractintro_";
|
---|
| 75 |
|
---|
| 76 | text_t &arg_gg = args["gg"];
|
---|
| 77 |
|
---|
| 78 | if (arg_gg == "full")
|
---|
| 79 | javaimagescontent += "_javaprevimage__javaviewtext_";
|
---|
| 80 | else if (arg_gg == "prev")
|
---|
| 81 | javaimagescontent += "_javafullimage__javaviewtext_";
|
---|
| 82 | else
|
---|
| 83 | javaimagescontent += "_javafullimage__javaprevimage_";
|
---|
| 84 |
|
---|
| 85 |
|
---|
| 86 | int arg_gt = args.getintarg("gt");
|
---|
| 87 | int arg_hl = args.getintarg("hl");
|
---|
| 88 |
|
---|
| 89 | text_tarray::const_iterator button_here = formatinfo.DocumentButtons.begin();
|
---|
| 90 | text_tarray::const_iterator button_end = formatinfo.DocumentButtons.end();
|
---|
| 91 |
|
---|
| 92 | while (button_here != button_end) {
|
---|
| 93 | if (*button_here == "Detach")
|
---|
| 94 | javaimagescontent += "_javadetach_";
|
---|
| 95 | else if (*button_here == "Expand Text" && arg_gg == "text") {
|
---|
| 96 | if (arg_gt == 1)
|
---|
| 97 | javaimagescontent += "_javacontracttext__javacontinue_";
|
---|
| 98 | else if (arg_gt == 2)
|
---|
| 99 | javaimagescontent += "_javacontracttext_";
|
---|
| 100 | else
|
---|
| 101 | javaimagescontent += "_javaexpandtext_";
|
---|
| 102 | } else if (*button_here == "Highlight" && arg_gg == "text") {
|
---|
| 103 | if (arg_hl == 1)
|
---|
| 104 | javaimagescontent += "_javanohighlighting_";
|
---|
| 105 | else
|
---|
| 106 | javaimagescontent += "_javahighlighting_";
|
---|
| 107 | }
|
---|
| 108 | button_here ++;
|
---|
| 109 | }
|
---|
| 110 | disp.setmacro ("javaimagescontent", "document", javaimagescontent);
|
---|
| 111 | }
|
---|
| 112 |
|
---|
| 113 | // define all the macros which are related to pages generated
|
---|
| 114 | // by this action. we also load up the formatinfo structure
|
---|
| 115 | // here (it's used in do_action as well as here)
|
---|
| 116 | void niupepadocaction::define_internal_macros (displayclass &disp, cgiargsclass &args,
|
---|
| 117 | recptprotolistclass *protos, ostream &logout) {
|
---|
| 118 |
|
---|
| 119 |
|
---|
| 120 | // define_internal_macros sets the following macros (as well as those defined
|
---|
| 121 | // by documentaction::define_internal_macros)
|
---|
| 122 |
|
---|
| 123 | // _httpthiscommentary_ the link to the papers commentary
|
---|
| 124 |
|
---|
| 125 | // _httpiconthispaper_ the http address of the cover image
|
---|
| 126 |
|
---|
| 127 | documentaction::define_internal_macros (disp, args, protos, logout);
|
---|
| 128 |
|
---|
| 129 | text_t &arg_d = args["d"];
|
---|
| 130 | text_t &collection = args["c"];
|
---|
| 131 | text_tset metadata;
|
---|
| 132 | FilterResponse_t response;
|
---|
| 133 |
|
---|
| 134 | recptproto *collectproto = protos->getrecptproto (collection, logout);
|
---|
| 135 | if (collectproto == NULL) return;
|
---|
| 136 |
|
---|
| 137 | if (!arg_d.empty()) {
|
---|
| 138 | // we're at document level
|
---|
| 139 |
|
---|
| 140 | text_t series = substr (arg_d.begin(), findchar (arg_d.begin(), arg_d.end(), '_'));
|
---|
| 141 | if ((series.size() > 10) && (substr ((series.end()-10), series.end()) == "commentary")) {
|
---|
| 142 | series = substr (series.begin(), (series.end()-10));
|
---|
| 143 | } else {
|
---|
| 144 | text_t commentaryOID = series + "commentary";
|
---|
| 145 |
|
---|
| 146 | // set _httpthiscommentary_ if commentary exists
|
---|
| 147 | if (get_info (commentaryOID, collection, metadata, false, collectproto, response, logout))
|
---|
| 148 | disp.setmacro ("httpthiscommentary", "document", "_httpdocument_&gg=text&d=" + commentaryOID);
|
---|
| 149 | }
|
---|
| 150 | // _httpiconthispaper_
|
---|
| 151 | disp.setmacro ("httpiconthispaper", "document", "_httpcollimg_/" + series + "/cover");
|
---|
| 152 | }
|
---|
| 153 | }
|
---|
| 154 |
|
---|
| 155 | void niupepadocaction::output_document (const text_t &OID, cgiargsclass &args,
|
---|
| 156 | recptproto *collectproto, displayclass &disp,
|
---|
| 157 | outconvertclass &outconvert, ostream &textout,
|
---|
| 158 | ostream &logout) {
|
---|
| 159 | FilterResponse_t response;
|
---|
| 160 | text_tset metadata;
|
---|
| 161 | text_t &arg_gg = args["gg"];
|
---|
| 162 | text_t &collection = args["c"];
|
---|
| 163 |
|
---|
| 164 | if (arg_gg == "full") {
|
---|
| 165 |
|
---|
| 166 | // fullsize image
|
---|
| 167 |
|
---|
| 168 | metadata.insert ("hasimg");
|
---|
| 169 | metadata.insert ("Source");
|
---|
| 170 | if (!get_info (OID, collection, metadata, false, collectproto, response, logout))
|
---|
| 171 | return;
|
---|
| 172 | if (response.docInfo[0].metadata["hasimg"].values[0] == "1") {
|
---|
| 173 | textout << outconvert << disp
|
---|
| 174 | << "<p><img src=\"_httpcollimg_/_thisOID_/"
|
---|
| 175 | << response.docInfo[0].metadata["Source"].values[0] << ".gif\">\n";
|
---|
| 176 | } else {
|
---|
| 177 | textout << outconvert << disp << "_missingimage_\n";
|
---|
| 178 | }
|
---|
| 179 |
|
---|
| 180 | } else if (arg_gg == "prev") {
|
---|
| 181 |
|
---|
| 182 | // preview image
|
---|
| 183 |
|
---|
| 184 | metadata.insert ("hasprevimg");
|
---|
| 185 | metadata.insert ("Source");
|
---|
| 186 | if (!get_info (OID, collection, metadata, false, collectproto, response, logout))
|
---|
| 187 | return;
|
---|
| 188 | if (response.docInfo[0].metadata["hasprevimg"].values[0] == "1") {
|
---|
| 189 | textout << outconvert << disp
|
---|
| 190 | << "<center>\n"
|
---|
| 191 | << "<p><img src=\"_httpcollimg_/_thisOID_/"
|
---|
| 192 | << response.docInfo[0].metadata["Source"].values[0] << "_p.gif\">\n"
|
---|
| 193 | << "</center>\n";
|
---|
| 194 | } else {
|
---|
| 195 | textout << outconvert << disp << "_missingimage_\n";
|
---|
| 196 | }
|
---|
| 197 | } else {
|
---|
| 198 |
|
---|
| 199 | // text
|
---|
| 200 | metadata.insert ("hastxt");
|
---|
| 201 | if (!get_info (OID, collection, metadata, false, collectproto, response, logout))
|
---|
| 202 | return;
|
---|
| 203 | if (response.docInfo[0].metadata["hastxt"].values[0] == "1") {
|
---|
| 204 | documentaction::output_document (OID, args, collectproto, disp,
|
---|
| 205 | outconvert, textout, logout);
|
---|
| 206 | } else {
|
---|
| 207 | textout << outconvert << disp << "_missingtext_\n";
|
---|
| 208 | }
|
---|
| 209 | }
|
---|
| 210 | }
|
---|
| 211 |
|
---|
| 212 |
|
---|
| 213 | // this is only overridden so we can call output_niupepa_toc instead
|
---|
| 214 | // of output_toc -- we should find a tidier way to do this both here
|
---|
| 215 | // and in the cstr collection
|
---|
| 216 | bool niupepadocaction::do_action (cgiargsclass &args, recptprotolistclass *protos,
|
---|
| 217 | browsermapclass *browsers, displayclass &disp,
|
---|
| 218 | outconvertclass &outconvert, ostream &textout,
|
---|
| 219 | ostream &logout) {
|
---|
| 220 |
|
---|
| 221 |
|
---|
| 222 | // must have a valid collection server
|
---|
| 223 | recptproto *collectproto = protos->getrecptproto (args["c"], logout);
|
---|
| 224 | if (collectproto == NULL) {
|
---|
| 225 | logout << "documentaction::do_action called with NULL collectproto\n";
|
---|
| 226 | textout << outconvert << disp << "_document:header_\n"
|
---|
| 227 | << "Error: Attempt to get document without setting collection\n"
|
---|
| 228 | << "_document:footer_\n";
|
---|
| 229 | } else {
|
---|
| 230 |
|
---|
| 231 | text_t OID = args["d"];
|
---|
| 232 | if (OID.empty()) OID = args["cl"];
|
---|
| 233 | if (OID.empty()) {
|
---|
| 234 | textout << outconvert << disp << "Document contains no data_document:footer_\n";
|
---|
| 235 | return true;
|
---|
| 236 | }
|
---|
| 237 |
|
---|
| 238 | if (formatinfo.DocumentUseHTML) {
|
---|
| 239 |
|
---|
| 240 | if (!args["d"].empty()) {
|
---|
| 241 | if (args["f"] == "1") {
|
---|
| 242 | textout << outconvert << disp
|
---|
| 243 | << "<html><head></head>\n"
|
---|
| 244 | << "<frameset rows=\"68,*\" noresize border=0>\n"
|
---|
| 245 | << "<frame scrolling=no frameborder=0 src=\"_gwcgi_?e=_compressedoptions_&a=p&p=nav\">\n"
|
---|
| 246 | << "<frame name=\"documenttop\" frameborder=0 src=\"_gwcgi_?e=_compressedoptions_&a=d&d="
|
---|
| 247 | << args["d"] << "\">"
|
---|
| 248 | << "<noframes>\n"
|
---|
| 249 | << "<p>You must have a frame enabled browser to view this.</p>\n"
|
---|
| 250 | << "</noframes>\n"
|
---|
| 251 | << "</frameset>\n"
|
---|
| 252 | << "</html>\n";
|
---|
| 253 | } else {
|
---|
| 254 | output_document (OID, args, collectproto, disp, outconvert, textout, logout);
|
---|
| 255 | }
|
---|
| 256 | return true;
|
---|
| 257 | }
|
---|
| 258 | }
|
---|
| 259 |
|
---|
| 260 | textout << outconvert << disp << "_document:header_\n"
|
---|
| 261 | << "_document:content_\n";
|
---|
| 262 |
|
---|
| 263 | // output the table of contents
|
---|
| 264 | output_niupepa_toc (args, browsers, formatinfo, collectproto,
|
---|
| 265 | disp, outconvert, textout, logout);
|
---|
| 266 |
|
---|
| 267 | // output the document text
|
---|
| 268 | if (!args["d"].empty()) {
|
---|
| 269 | textout << "<p>\n";
|
---|
| 270 | output_document (OID, args, collectproto, disp, outconvert, textout, logout);
|
---|
| 271 | }
|
---|
| 272 |
|
---|
| 273 | textout << outconvert << disp << "_document:footer_\n";
|
---|
| 274 | }
|
---|
| 275 | return true;
|
---|
| 276 | }
|
---|