source: tags/gsdl-2_25-distribution/niupepa/src/recpt/niupepabrowsetools.cpp@ 1389

Last change on this file since 1389 was 1023, checked in by sjboddie, 24 years ago

Initial revision

  • Property svn:keywords set to Author Date Id Revision
File size: 5.9 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 1023 2000-03-08 20:44:48Z 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
94 if (args["u"] != "1") {
95
96 text_tarray::const_iterator here = ibuttons.begin();
97 text_tarray::const_iterator end = ibuttons.end();
98
99 while (here != end) {
100
101 if (*here == "Detach")
102 buttons.push_back ("_document:imagedetach_");
103 else if (*here == "Highlight" && arg_gg == "text") {
104 if (args["hl"] == "1")
105 buttons.push_back ("_document:imagenohighlight_");
106 else
107 buttons.push_back ("_document:imagehighlight_");
108
109 } else if ((*here == "Expand Text") && (doctype.empty()) && (arg_gg == "text")) {
110 if (args.getintarg("gt"))
111 buttons.push_back ("_document:imagecontracttext_");
112 else
113 buttons.push_back ("_document:imageexpandtext_");
114 }
115 here ++;
116 }
117
118 here = buttons.begin();
119 end = buttons.end();
120 int count = 0;
121 while (here != end) {
122 if ((count != 0) && ((count % 3) == 0)) textout << "<br>\n";
123 textout << outconvert << disp << *here;
124 count ++;
125 here ++;
126 }
127 }
128}
129
130
131
132void output_niupepa_toc (cgiargsclass &args, browsermapclass *browsermap,
133 formatinfo_t &formatinfo, recptproto *collectproto,
134 displayclass &disp, outconvertclass &outconvert,
135 ostream &textout, ostream &logout) {
136
137 int tabcount = 0;
138 text_t &arg_d = args["d"];
139
140 // get the cover image (if there is one) and the control buttons
141 // if we're inside a book
142 if (!arg_d.empty()) {
143 textout << outconvert << disp
144 << "<center>\n"
145 << "<p><table cellpadding=0 cellspacing=0 width=_pagewidth_><tr>\n"
146 << "<td align=left valign=top>\n";
147 output_titles (args, collectproto, formatinfo, disp, outconvert, textout, logout);
148 textout << "<p>\n";
149 }
150
151 if (formatinfo.DocumentContents || arg_d.empty()) {
152 if (args.getintarg("gc") == 1) {
153
154 // expanded table of contents
155 expanded_contents (args, tabcount, false, browsermap, formatinfo,
156 collectproto, disp, outconvert, textout, logout);
157 } else {
158
159 // contracted table of contents
160 contracted_contents (args, tabcount, false, browsermap, formatinfo,
161 collectproto, disp, outconvert, textout, logout);
162 }
163 }
164
165 if (!arg_d.empty()) {
166 output_niupepa_controls (args, formatinfo.DocumentButtons, collectproto,
167 disp, outconvert, textout, logout);
168
169 textout << outconvert << disp
170 << "</td>\n"
171 << "<td align=right valign=top>"
172 << "_document:imagethispaper_\n"
173 << "</td></tr>\n"
174 << "</table>\n"
175 << "</center>\n";
176 }
177 textout << outconvert << disp << "_iconblankbar_\n";
178}
179
180
181
182
183
184
185
186
Note: See TracBrowser for help on using the repository browser.