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

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

* empty log message *

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