source: trunk/gsdl/src/recpt/hlistbrowserclass.cpp@ 1266

Last change on this file since 1266 was 995, checked in by sjboddie, 24 years ago

fixed some compiler warnings

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 5.6 KB
Line 
1/**********************************************************************
2 *
3 * hlistbrowserclass.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: hlistbrowserclass.cpp 995 2000-02-29 21:00:38Z sjboddie $
25 *
26 *********************************************************************/
27
28/*
29 $Log$
30 Revision 1.7 2000/02/29 21:00:29 sjboddie
31 fixed some compiler warnings
32
33 Revision 1.6 1999/11/01 22:04:12 sjboddie
34 just a few small changes (that means I can't remember ;)
35
36 Revision 1.5 1999/10/30 23:02:01 sjboddie
37 tidied up, fixed a small bug
38
39 Revision 1.4 1999/10/30 22:15:23 sjboddie
40 added a collection argument
41
42 Revision 1.3 1999/10/20 03:54:21 sjboddie
43 problem with expanded contents
44
45 Revision 1.2 1999/10/14 22:59:34 sjboddie
46 finished off browser classes
47
48 Revision 1.1 1999/10/10 08:14:08 sjboddie
49 - metadata now returns mp rather than array
50 - redesigned browsing support (although it's not finished so
51 won't currently work ;-)
52
53 */
54
55
56#include "hlistbrowserclass.h"
57#include <assert.h>
58#include "OIDtools.h"
59
60hlistbrowserclass::hlistbrowserclass () {
61}
62
63hlistbrowserclass::~hlistbrowserclass () {
64}
65
66// returns the name that specifies the browserclass type
67text_t hlistbrowserclass::get_browser_name () {
68 return "HList";
69}
70
71void hlistbrowserclass::load_metadata_defaults (text_tset &metadata) {
72 metadata.insert ("doctype");
73}
74
75text_t hlistbrowserclass::get_default_formatstring () {
76 return "[link][highlight][Title][/highlight][/link]";
77}
78
79// need to change OID to it's child
80void hlistbrowserclass::processOID (cgiargsclass &args, recptproto *collectproto,
81 ostream &logout) {
82
83 text_t OID = args["d"];
84 bool is_classify = false;
85 if (OID.empty()) {
86 is_classify = true;
87 OID = args["cl"];
88 }
89
90 FilterResponse_t response;
91 text_tset metadata;
92 metadata.insert ("childtype");
93 text_t classifytype = "Invisible";
94 text_t child_doctype;
95
96 text_tarray OIDs;
97
98 while (classifytype == "Invisible") {
99 OIDs.erase (OIDs.begin(), OIDs.end());
100
101 OIDs.push_back (OID);
102 OIDs.push_back (OID + ".fc");
103
104 get_info (OIDs, args["c"], metadata, false, collectproto, response, logout);
105
106 OID = response.docInfo[1].OID;
107 classifytype = response.docInfo[0].metadata["childtype"].values[0];
108 }
109 if (is_classify) args["cl"] = OID;
110 else args["d"] = OID;
111}
112
113int hlistbrowserclass::output_section_group (ResultDocInfo_t &section, cgiargsclass &args,
114 const text_t &/*collection*/, int colnumber,
115 format_t *formatlistptr, bool use_table,
116 text_tset &metadata, bool &getParents,
117 recptproto *collectproto, displayclass &disp,
118 outconvertclass &outconvert, ostream &textout,
119 ostream &logout) {
120
121 // expanded contents are going to cause some nasty recursions
122 // so we'll only continue if being passed the current section
123 if ((args["gc"] == 1) && (section.OID != args["d"])) return 0;
124
125 // get all siblings
126 FilterResponse_t response;
127 text_t &arg_cl = args["cl"];
128 get_children (section.OID + ".pr", args["c"], metadata, getParents,
129 collectproto, response, logout);
130
131
132 if (use_table || colnumber > 0) {
133 textout << "<table><tr><td>";
134 // get tab size
135 text_t tab; int itab;
136 disp.expandstring ("Global", "_tabwidth_", tab);
137 itab = tab.getint();
138 if (colnumber > 0) textout << outconvert << disp
139 << "<img src=\"_httpimg_/space.gif\" width="
140 << (itab*colnumber) << ">";
141 textout << "</td>\n";
142 }
143
144 textout << "<table><tr>\n";
145
146 ResultDocInfo_tarray::iterator tsibling = response.docInfo.begin();
147 ResultDocInfo_tarray::iterator esibling = response.docInfo.end();
148
149 text_t icon, link;
150 while (tsibling != esibling) {
151
152 bool highlight = false;
153 textout << "<td>";
154 text_t &doctype = (*tsibling).metadata["doctype"].values[0];
155
156 if ((*tsibling).OID == section.OID) {
157 link.clear();
158 highlight = true;
159 } else {
160 link = "<a href=\"_httpdocument_";
161 if (doctype == "classify")
162 link += "&cl=" + (*tsibling).OID + "\">";
163 else
164 link += "&cl=" + arg_cl + "&d=" + (*tsibling).OID + "\">";
165 }
166
167 textout << outconvert << disp
168 << get_formatted_string (*tsibling, formatlistptr, link, icon, highlight);
169
170 textout << "</td>\n";
171 tsibling ++;
172 }
173
174 textout << "</tr></table>\n";
175 if (use_table || colnumber > 0) textout << "</tr></table>\n";
176 return 0;
177}
178
179int hlistbrowserclass::output_section_group (FilterResponse_t &/*sections*/, cgiargsclass &/*args*/,
180 const text_t &/*collection*/, int /*colnumber*/,
181 format_t * /*formatlistptr*/, bool /*use_table*/,
182 text_tset &/*metadata*/, bool &/*getParents*/,
183 recptproto * /*collectproto*/, displayclass &/*disp*/,
184 outconvertclass &/*outconvert*/, ostream &/*textout*/,
185 ostream &/*logout*/) {
186 return 0;
187}
Note: See TracBrowser for help on using the repository browser.