source: trunk/niupepa/src/recpt/niupepabrowsetools.cpp@ 2874

Last change on this file since 2874 was 2874, checked in by sjboddie, 22 years ago

* empty log message *

  • Property svn:keywords set to Author Date Id Revision
File size: 6.1 KB
Line 
1/**********************************************************************
2 *
3 * niupepabrowsetools.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: niupepabrowsetools.cpp 2874 2001-12-01 21:25:14Z sjboddie $
25 *
26 *********************************************************************/
27
28#include "niupepabrowsetools.h"
29#include "OIDtools.h"
30#include "cgiutils.h"
31#include "browsetools.h"
32
33static void output_niupepa_controls (cgiargsclass &args, const text_tarray &ibuttons,
34 recptproto *collectproto, displayclass &disp,
35 outconvertclass &outconvert, ostream &textout,
36 ostream &logout) {
37
38 bool hastxt = false, hasimg = false, hasprevimg = false, haspdf = false;
39 text_tarray buttons;
40 text_t &arg_gg = args["gg"];
41 text_t &arg_d = args["d"];
42 FilterResponse_t response;
43 text_tset metadata;
44 text_t doctype;
45 metadata.insert ("hastxt");
46 metadata.insert ("hasimg");
47 metadata.insert ("hasprevimg");
48 metadata.insert ("haspdf");
49 metadata.insert ("doctype");
50 if (!get_info (arg_d, args["c"], metadata, false, collectproto, response, logout))
51 return;
52
53 if (response.docInfo[0].metadata["hastxt"].values[0] == "1") hastxt = true;
54 if (response.docInfo[0].metadata["hasimg"].values[0] == "1") hasimg = true;
55 if (response.docInfo[0].metadata["hasprevimg"].values[0] == "1") hasprevimg = true;
56 if (response.docInfo[0].metadata["haspdf"].values[0] == "1") haspdf = true;
57
58 MetadataInfo_tmap::iterator it = response.docInfo[0].metadata.find ("doctype");
59 if (it != response.docInfo[0].metadata.end()) {
60 if (! (*it).second.values.empty()) doctype = (*it).second.values[0];
61 }
62
63 if (doctype == "Description") {
64 // abstract
65 text_t paper = substr (arg_d.begin(), (arg_d.end() - 8));
66 buttons.push_back ("_document:imageviewpaper_(" + paper + ")");
67 buttons.push_back ("_document:imageabstractintro_");
68
69 } else if (doctype == "Commentary") {
70 // commentary
71
72
73 } else {
74 // newspaper page
75
76 if (arg_gg == "full") {
77 if (hastxt) buttons.push_back ("_document:imageviewtext_");
78 if (hasprevimg) buttons.push_back ("_document:imageprevimage_");
79 } else if (arg_gg == "prev") {
80 if (hastxt) buttons.push_back ("_document:imageviewtext_");
81 if (hasimg) buttons.push_back ("_document:imagefullimage_");
82 } else {
83 if (hasimg) buttons.push_back ("_document:imagefullimage_");
84 if (hasprevimg) buttons.push_back ("_document:imageprevimage_");
85 }
86
87 // see if paper has an abstract
88 text_t abstract;
89 get_top (arg_d, abstract);
90 abstract += "abstract";
91 metadata.erase (metadata.begin(), metadata.end());
92 if (get_info (abstract, args["c"], metadata, false, collectproto, response, logout))
93 buttons.push_back ("_document:imageviewabstract_(" + abstract + "&gg=text)");
94
95 if (haspdf) buttons.push_back ("_document:imagepdf_");
96
97 }
98
99 if (args["u"] != "1") {
100
101 text_tarray::const_iterator here = ibuttons.begin();
102 text_tarray::const_iterator end = ibuttons.end();
103
104 while (here != end) {
105
106 if (*here == "Detach")
107 buttons.push_back ("_document:imagedetach_");
108 else if (*here == "Highlight" && arg_gg == "text") {
109 if (args["hl"] == "1")
110 buttons.push_back ("_document:imagenohighlight_");
111 else
112 buttons.push_back ("_document:imagehighlight_");
113
114 } else if ((*here == "Expand Text") && (doctype.empty()) && (arg_gg == "text")) {
115 if (args.getintarg("gt"))
116 buttons.push_back ("_document:imagecontracttext_");
117 else
118 buttons.push_back ("_document:imageexpandtext_");
119 }
120 here ++;
121 }
122
123 here = buttons.begin();
124 end = buttons.end();
125 int count = 0;
126 while (here != end) {
127 if ((count != 0) && ((count % 3) == 0)) textout << "<br>\n";
128 textout << outconvert << disp << *here;
129 count ++;
130 here ++;
131 }
132 }
133}
134
135
136
137void output_niupepa_toc (cgiargsclass &args, browsermapclass *browsermap,
138 formatinfo_t &formatinfo, recptproto *collectproto,
139 displayclass &disp, outconvertclass &outconvert,
140 ostream &textout, ostream &logout) {
141
142 int tabcount = 0;
143 text_t &arg_d = args["d"];
144
145 // get the cover image (if there is one) and the control buttons
146 // if we're inside a book
147 if (!arg_d.empty()) {
148 textout << outconvert << disp
149 << "<center>\n"
150 << "<p><table cellpadding=0 cellspacing=0 width=_pagewidth_><tr>\n"
151 << "<td align=left valign=top>\n";
152 output_titles (args, collectproto, formatinfo, disp, outconvert, textout, logout);
153 textout << "<p>\n";
154 }
155
156 if (formatinfo.DocumentContents || arg_d.empty()) {
157 if (args.getintarg("gc") == 1) {
158
159 // expanded table of contents
160 expanded_contents (args, tabcount, false, browsermap, formatinfo,
161 collectproto, disp, outconvert, textout, logout);
162 } else {
163
164 // contracted table of contents
165 contracted_contents (args, tabcount, false, browsermap, formatinfo,
166 collectproto, disp, outconvert, textout, logout);
167 }
168 }
169
170 if (!arg_d.empty()) {
171 output_niupepa_controls (args, formatinfo.DocumentButtons, collectproto,
172 disp, outconvert, textout, logout);
173
174 textout << outconvert << disp
175 << "</td>\n"
176 << "<td align=right valign=top>"
177 << "_document:imagethispaper_\n"
178 << "</td></tr>\n"
179 << "</table>\n"
180 << "</center>\n";
181 }
182 textout << outconvert << disp << "_iconblankbar_\n";
183}
184
185
186
187
188
189
190
191
Note: See TracBrowser for help on using the repository browser.