[649] | 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 | *********************************************************************/
|
---|
| 25 |
|
---|
| 26 | #include "hlistbrowserclass.h"
|
---|
[16043] | 27 | #include "OIDtools.h"
|
---|
[15418] | 28 | #include "recptprototools.h"
|
---|
[16045] | 29 | #include "cgiutils.h"
|
---|
[649] | 30 |
|
---|
[16045] | 31 |
|
---|
[649] | 32 | hlistbrowserclass::hlistbrowserclass () {
|
---|
| 33 | }
|
---|
| 34 |
|
---|
| 35 | hlistbrowserclass::~hlistbrowserclass () {
|
---|
| 36 | }
|
---|
| 37 |
|
---|
[668] | 38 | // returns the name that specifies the browserclass type
|
---|
| 39 | text_t hlistbrowserclass::get_browser_name () {
|
---|
| 40 | return "HList";
|
---|
[649] | 41 | }
|
---|
| 42 |
|
---|
[7392] | 43 | browserclass* hlistbrowserclass::clone()
|
---|
| 44 | {
|
---|
| 45 | return new hlistbrowserclass();
|
---|
| 46 | }
|
---|
| 47 |
|
---|
[751] | 48 | void hlistbrowserclass::load_metadata_defaults (text_tset &metadata) {
|
---|
| 49 | metadata.insert ("doctype");
|
---|
| 50 | }
|
---|
| 51 |
|
---|
[668] | 52 | text_t hlistbrowserclass::get_default_formatstring () {
|
---|
| 53 | return "[link][highlight][Title][/highlight][/link]";
|
---|
[649] | 54 | }
|
---|
| 55 |
|
---|
[668] | 56 | // need to change OID to it's child
|
---|
| 57 | void hlistbrowserclass::processOID (cgiargsclass &args, recptproto *collectproto,
|
---|
| 58 | ostream &logout) {
|
---|
| 59 |
|
---|
| 60 | text_t OID = args["d"];
|
---|
| 61 | bool is_classify = false;
|
---|
| 62 | if (OID.empty()) {
|
---|
| 63 | is_classify = true;
|
---|
| 64 | OID = args["cl"];
|
---|
| 65 | }
|
---|
| 66 |
|
---|
| 67 | FilterResponse_t response;
|
---|
| 68 | text_tset metadata;
|
---|
| 69 | metadata.insert ("childtype");
|
---|
| 70 | text_t classifytype = "Invisible";
|
---|
| 71 | text_tarray OIDs;
|
---|
| 72 |
|
---|
[7215] | 73 | while (classifytype == "Invisible" || classifytype == "HList") {
|
---|
[668] | 74 | OIDs.erase (OIDs.begin(), OIDs.end());
|
---|
| 75 |
|
---|
| 76 | OIDs.push_back (OID);
|
---|
| 77 | OIDs.push_back (OID + ".fc");
|
---|
| 78 |
|
---|
[7432] | 79 | get_info (OIDs, args["c"], args["l"], metadata, false, collectproto, response, logout);
|
---|
[668] | 80 |
|
---|
[11946] | 81 | // Avoid infinite loops in strange situations by checking that the OID has changed
|
---|
| 82 | if (response.docInfo[1].OID == OID) {
|
---|
| 83 | break;
|
---|
| 84 | }
|
---|
[668] | 85 | OID = response.docInfo[1].OID;
|
---|
[7215] | 86 | classifytype = response.docInfo[1].metadata["childtype"].values[0];
|
---|
[668] | 87 | }
|
---|
| 88 | if (is_classify) args["cl"] = OID;
|
---|
| 89 | else args["d"] = OID;
|
---|
[649] | 90 | }
|
---|
| 91 |
|
---|
[668] | 92 | int hlistbrowserclass::output_section_group (ResultDocInfo_t §ion, cgiargsclass &args,
|
---|
[1443] | 93 | const text_t& collection, int colnumber,
|
---|
[751] | 94 | format_t *formatlistptr, bool use_table,
|
---|
| 95 | text_tset &metadata, bool &getParents,
|
---|
[668] | 96 | recptproto *collectproto, displayclass &disp,
|
---|
[751] | 97 | outconvertclass &outconvert, ostream &textout,
|
---|
[16043] | 98 | ostream &logout)
|
---|
| 99 | {
|
---|
[730] | 100 | // expanded contents are going to cause some nasty recursions
|
---|
| 101 | // so we'll only continue if being passed the current section
|
---|
| 102 | if ((args["gc"] == 1) && (section.OID != args["d"])) return 0;
|
---|
| 103 |
|
---|
[668] | 104 | // get all siblings
|
---|
| 105 | FilterResponse_t response;
|
---|
[7432] | 106 | get_children (section.OID + ".pr", args["c"], args["l"], metadata, getParents,
|
---|
[668] | 107 | collectproto, response, logout);
|
---|
| 108 |
|
---|
[16043] | 109 | return output_section_group (response, args, collection, colnumber, formatlistptr, use_table, metadata, getParents, collectproto, disp, outconvert, textout, logout);
|
---|
| 110 | }
|
---|
| 111 |
|
---|
| 112 | int hlistbrowserclass::output_section_group (FilterResponse_t &response, cgiargsclass &args,
|
---|
| 113 | const text_t &collection, int colnumber,
|
---|
| 114 | format_t * formatlistptr, bool use_table,
|
---|
| 115 | text_tset &metadata, bool &getParents,
|
---|
| 116 | recptproto * collectproto, displayclass &disp,
|
---|
| 117 | outconvertclass &outconvert, ostream &textout,
|
---|
| 118 | ostream &logout)
|
---|
| 119 | {
|
---|
[10947] | 120 | /* use_table is set to true if the format string starts with <td> */
|
---|
[668] | 121 | if (use_table || colnumber > 0) {
|
---|
[3666] | 122 | textout << outconvert << "<table><tr><td>";
|
---|
[668] | 123 | // get tab size
|
---|
| 124 | text_t tab; int itab;
|
---|
[7433] | 125 | disp.expandstring (displayclass::defaultpackage, "_tabwidth_", tab);
|
---|
[668] | 126 | itab = tab.getint();
|
---|
| 127 | if (colnumber > 0) textout << outconvert << disp
|
---|
[17860] | 128 | << "<img alt=\"\" src=\"_httpiconspace_\" width=\""
|
---|
[12488] | 129 | << (itab*colnumber) << "\"/>";
|
---|
[3666] | 130 | textout << outconvert << "</td>\n";
|
---|
[668] | 131 | }
|
---|
| 132 |
|
---|
[10947] | 133 | if (use_table)
|
---|
| 134 | textout << outconvert << "<table class=\"h_list\"><tr>\n";
|
---|
| 135 | else
|
---|
| 136 | textout << outconvert << "<div class=\"h_list\">\n";
|
---|
[668] | 137 |
|
---|
| 138 | ResultDocInfo_tarray::iterator tsibling = response.docInfo.begin();
|
---|
| 139 | ResultDocInfo_tarray::iterator esibling = response.docInfo.end();
|
---|
| 140 |
|
---|
| 141 | text_t icon, link;
|
---|
[11637] | 142 |
|
---|
[16044] | 143 | while (tsibling != esibling)
|
---|
| 144 | {
|
---|
| 145 | get_link_icon (*tsibling, args, link, icon);
|
---|
[668] | 146 |
|
---|
| 147 | bool highlight = false;
|
---|
[16045] | 148 | if ((*tsibling).OID == args["cl"] || is_child_of ((*tsibling).OID, args["cl"]) ||
|
---|
[16060] | 149 | (*tsibling).OID == args["dcn"] || starts_with (args["dcn"], (*tsibling).OID))
|
---|
[16044] | 150 | {
|
---|
[668] | 151 | link.clear();
|
---|
[16044] | 152 | highlight = true;
|
---|
[668] | 153 | }
|
---|
| 154 |
|
---|
[4906] | 155 | text_tmap options;
|
---|
| 156 | options["link"] = link;
|
---|
| 157 | options["icon"] = icon;
|
---|
| 158 | if (highlight) options["highlight"] = "1";
|
---|
| 159 | else options["highlight"] = "0";
|
---|
| 160 |
|
---|
[2684] | 161 | text_t fmt_str=get_formatted_string (collection, collectproto,
|
---|
| 162 | *tsibling, disp, formatlistptr,
|
---|
[4906] | 163 | options, logout);
|
---|
[668] | 164 |
|
---|
[11637] | 165 | text_t span_class = "h_item";
|
---|
| 166 | if (highlight) {
|
---|
| 167 | // the current option
|
---|
| 168 | span_class += " h_item_current";
|
---|
| 169 | }
|
---|
| 170 |
|
---|
| 171 | textout << outconvert << "<span class=\""<<span_class<<"\">" << disp << fmt_str << "</span>\n";
|
---|
[9620] | 172 | ++tsibling;
|
---|
[668] | 173 | }
|
---|
| 174 |
|
---|
[10947] | 175 | if (use_table)
|
---|
| 176 | textout << outconvert << "</tr></table>\n";
|
---|
| 177 | else
|
---|
| 178 | textout << outconvert << "</div>\n";
|
---|
| 179 |
|
---|
[3666] | 180 | if (use_table || colnumber > 0) textout << outconvert << "</tr></table>\n";
|
---|
[10947] | 181 |
|
---|
[668] | 182 | return 0;
|
---|
| 183 | }
|
---|
[16044] | 184 |
|
---|
| 185 |
|
---|
| 186 | void hlistbrowserclass::get_link_icon (ResultDocInfo_t §ion, cgiargsclass &args, text_t &link, text_t &icon)
|
---|
| 187 | {
|
---|
| 188 | link = "<a href=\"_httpdocument_";
|
---|
| 189 |
|
---|
| 190 | text_t &doctype = section.metadata["doctype"].values[0];
|
---|
| 191 | if (doctype == "classify")
|
---|
| 192 | {
|
---|
[16045] | 193 | // Dynamic classifier nodes
|
---|
| 194 | if (args["a"] == "dc")
|
---|
| 195 | {
|
---|
| 196 | // The node label is going into the URL, so make it CGI-safe
|
---|
| 197 | text_t classifier_node_dcn_cgi_safe = cgi_safe_utf8(section.OID);
|
---|
| 198 | link = "<a href=\"_gwcgi_?c=" + args["c"] + "&a=dc&dcl=" + args["dcl"] + "&dcn=" + classifier_node_dcn_cgi_safe + "\">";
|
---|
| 199 | }
|
---|
| 200 | // Static classifier nodes
|
---|
| 201 | else
|
---|
| 202 | {
|
---|
| 203 | link += "&cl=" + section.OID + "\">";
|
---|
| 204 | }
|
---|
[16044] | 205 | }
|
---|
| 206 | else
|
---|
| 207 | {
|
---|
| 208 | link += "&cl=" + args["cl"] + "&d=" + section.OID;
|
---|
| 209 |
|
---|
| 210 | // [modification to allow default document detach settings -- kjdon]
|
---|
| 211 | if (args["xx"] == "1")
|
---|
| 212 | {
|
---|
| 213 | // documents should be detached
|
---|
| 214 | link += "&x=1\" target=\"_blank\">";
|
---|
| 215 | }
|
---|
| 216 | else
|
---|
| 217 | {
|
---|
| 218 | link += "\">";
|
---|
| 219 | }
|
---|
| 220 | }
|
---|
| 221 | }
|
---|