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

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

added a collection argument

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