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

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

problem with expanded contents

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