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

Last change on this file since 757 was 751, checked in by sjboddie, 25 years ago

tidied up, fixed a small bug

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