source: main/tags/2.25/gsdl/src/recpt/vlistbrowserclass.cpp@ 25514

Last change on this file since 25514 was 1285, checked in by sjboddie, 24 years ago

Removed CVS logging information from source files

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