source: trunk/gsdl/src/recpt/vlistbrowserclass.cpp@ 673

Last change on this file since 673 was 668, checked in by sjboddie, 25 years ago

finished off browser classes

  • Property svn:keywords set to Author Date Id Revision
File size: 6.7 KB
Line 
1/**********************************************************************
2 *
3 * vlistbrowserclass.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: vlistbrowserclass.cpp 668 1999-10-14 22:59:35Z sjboddie $
25 *
26 *********************************************************************/
27
28/*
29 $Log$
30 Revision 1.2 1999/10/14 22:59:34 sjboddie
31 finished off browser classes
32
33 Revision 1.1 1999/10/10 08:14:11 sjboddie
34 - metadata now returns mp rather than array
35 - redesigned browsing support (although it's not finished so
36 won't currently work ;-)
37
38 */
39
40
41#include "vlistbrowserclass.h"
42#include <assert.h>
43#include "OIDtools.h"
44
45vlistbrowserclass::vlistbrowserclass () {
46}
47
48vlistbrowserclass::~vlistbrowserclass () {
49}
50
51// returns the name that specifies the browserclass type
52text_t vlistbrowserclass::get_browser_name () {
53 return "VList";
54}
55
56void vlistbrowserclass::load_metadata_defaults (text_tset &metadata) {
57 metadata.insert ("haschildren");
58 metadata.insert ("doctype");
59}
60
61text_t vlistbrowserclass::get_default_formatstring () {
62 return "<td>[link][icon][/link]</td><td>[highlight]{Or}{[Title],Untitled}[/highlight]</td>";
63}
64
65int vlistbrowserclass::output_section_group (ResultDocInfo_t &section, cgiargsclass &args,
66 int colnumber, format_t *formatlistptr,
67 bool use_table, text_tset &/*metadata*/, bool &/*getParents*/,
68 recptproto */*collectproto*/, displayclass &disp,
69 outconvertclass &outconvert, ostream &textout, ostream &/*logout*/) {
70
71 text_t link, icon;
72 get_link_icon (section, args, link, icon);
73 bool highlight = false;
74 if (!args["d"].empty()) {
75 if (args["d"] == section.OID) highlight = true;
76 } else
77 if (args["cl"] == section.OID) highlight = true;
78
79
80 if (use_table || colnumber > 0) {
81 textout << "<table><tr>";
82 // get tab size
83 text_t tab; int itab;
84 disp.expandstring ("Global", "_tabwidth_", tab);
85 itab = tab.getint();
86 if (colnumber > 0) textout << outconvert << disp
87 << "<td><img src=\"_httpimg_/space.gif\" width="
88 << (itab*colnumber) << "></td>";
89 }
90
91 textout << outconvert << disp << get_formatted_string (section, formatlistptr,
92 link, icon, highlight);
93
94 if (use_table || colnumber > 0) textout << "</tr></table>\n";
95
96 return 1;
97}
98
99int vlistbrowserclass::output_section_group (FilterResponse_t &sections, cgiargsclass &args,
100 int colnumber, format_t *formatlistptr,
101 bool use_table, text_tset &/*metadata*/, bool &/*getParents*/,
102 recptproto */*collectproto*/, displayclass &disp,
103 outconvertclass &outconvert, ostream &textout, ostream &/*logout*/) {
104
105 text_t link, icon;
106 text_t &arg_d = args["d"];
107 text_t &arg_cl = args["cl"];
108
109 if (colnumber > 0) {
110 textout << "<table><tr>";
111 // get tab size
112 text_t tab; int itab;
113 disp.expandstring ("Global", "_tabwidth_", tab);
114 itab = tab.getint();
115 if (colnumber > 0) textout << outconvert << disp
116 << "<td><img src=\"_httpimg_/space.gif\" width="
117 << (itab*colnumber) << "></td>";
118 textout << "<td>";
119 }
120 if (use_table) textout << "<table>\n";
121
122 ResultDocInfo_tarray::iterator thissection = sections.docInfo.begin();
123 ResultDocInfo_tarray::iterator endsection = sections.docInfo.end();
124
125 while (thissection != endsection) {
126
127 get_link_icon (*thissection, args, link, icon);
128 bool highlight = false;
129 if (!arg_d.empty()) {
130 if (arg_d == (*thissection).OID) highlight = true;
131 } else
132 if (arg_cl == (*thissection).OID) highlight = true;
133
134 if (use_table || colnumber > 0) textout << "<tr>";
135 textout << outconvert << disp << get_formatted_string (*thissection, formatlistptr,
136 link, icon, highlight);
137 if (use_table || colnumber > 0) textout << "</tr>";
138 textout << "\n";
139 thissection ++;
140 }
141
142 if (use_table) textout << "</table>\n";
143 if (colnumber > 0) textout << "</table></td></tr></table>\n";
144
145 return 1;
146}
147
148
149// get_link_icon attempts to work out what type of icon should be displayed for
150// the given section and what it should link to.
151void vlistbrowserclass::get_link_icon (ResultDocInfo_t &section, cgiargsclass &args,
152 text_t &link, text_t &icon) {
153
154 link = "<a href=\"_httpdocument_";
155 icon = "_document:icontext_";
156 int haschildren = section.metadata["haschildren"].values[0].getint();
157 const text_t doctype = section.metadata["doctype"].values[0];
158
159 text_t &arg_d = args["d"];
160 text_t &arg_cl = args["cl"];
161
162 if (args["a"] == "q") {
163 // query results
164 if (is_top (section.OID)) icon = "_document:iconclosedbook_";
165 else if (haschildren == 1) icon = "_document:iconclosedfolder_";
166 link += "&cl=search&d=" + section.OID + "\">";
167
168 } else if (!arg_d.empty()) {
169 // document level
170 if (is_top(section.OID)) {
171 icon = "_document:iconopenbook_";
172 if (arg_cl == "search") link = "<a href=\"_httpquery_\">";
173 else link += "&cl=" + arg_cl + "\">";
174
175 } else if (haschildren == 1) {
176 if ((args["gc"] == "1") ||
177 (is_child_of (section.OID, arg_d)) ||
178 (section.OID == arg_d)) {
179 icon = "_document:iconopenfolder_";
180 link += "&cl=" + arg_cl + "&d=" + section.OID + ".pr\">";
181 } else {
182 icon = "_document:iconclosedfolder_";
183 link += "&cl=" + arg_cl + "&d=" + section.OID + "\">";
184 }
185 } else link += "&cl=" + arg_cl + "&d=" + section.OID + "\">";
186
187 } else {
188 // classification level
189 if (haschildren == 1) {
190 if (doctype == "classify") {
191 if ((args["gc"] == "1") ||
192 (is_child_of (section.OID, arg_cl)) ||
193 (section.OID == arg_cl)) {
194 icon = "_document:iconopenbookshelf_";
195 link += "&cl=" + section.OID + ".pr\">";
196 } else {
197 icon = "_document:iconclosedbookshelf_";
198 link += "&cl=" + section.OID + "\">";
199 }
200 } else {
201 icon = "_document:iconclosedbook_";
202 link += "&cl=" + arg_cl + "&d=" + section.OID + "\">";
203 }
204 } else {
205 if (doctype == "classify") link = "";
206 else link += "&cl=" + arg_cl + "&d=" + section.OID + "\">";
207 }
208 }
209}
Note: See TracBrowser for help on using the repository browser.