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

Last change on this file since 919 was 765, checked in by sjboddie, 24 years ago

just a few small changes (that means I can't remember ;)

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