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

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

finished off browser classes

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