[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"
|
---|
| 27 | #include <assert.h>
|
---|
[15418] | 28 | #include "recptprototools.h"
|
---|
[649] | 29 |
|
---|
| 30 | hlistbrowserclass::hlistbrowserclass () {
|
---|
| 31 | }
|
---|
| 32 |
|
---|
| 33 | hlistbrowserclass::~hlistbrowserclass () {
|
---|
| 34 | }
|
---|
| 35 |
|
---|
[668] | 36 | // returns the name that specifies the browserclass type
|
---|
| 37 | text_t hlistbrowserclass::get_browser_name () {
|
---|
| 38 | return "HList";
|
---|
[649] | 39 | }
|
---|
| 40 |
|
---|
[7392] | 41 | browserclass* hlistbrowserclass::clone()
|
---|
| 42 | {
|
---|
| 43 | return new hlistbrowserclass();
|
---|
| 44 | }
|
---|
| 45 |
|
---|
[751] | 46 | void hlistbrowserclass::load_metadata_defaults (text_tset &metadata) {
|
---|
| 47 | metadata.insert ("doctype");
|
---|
| 48 | }
|
---|
| 49 |
|
---|
[668] | 50 | text_t hlistbrowserclass::get_default_formatstring () {
|
---|
| 51 | return "[link][highlight][Title][/highlight][/link]";
|
---|
[649] | 52 | }
|
---|
| 53 |
|
---|
[668] | 54 | // need to change OID to it's child
|
---|
| 55 | void hlistbrowserclass::processOID (cgiargsclass &args, recptproto *collectproto,
|
---|
| 56 | ostream &logout) {
|
---|
| 57 |
|
---|
| 58 | text_t OID = args["d"];
|
---|
| 59 | bool is_classify = false;
|
---|
| 60 | if (OID.empty()) {
|
---|
| 61 | is_classify = true;
|
---|
| 62 | OID = args["cl"];
|
---|
| 63 | }
|
---|
| 64 |
|
---|
| 65 | FilterResponse_t response;
|
---|
| 66 | text_tset metadata;
|
---|
| 67 | metadata.insert ("childtype");
|
---|
| 68 | text_t classifytype = "Invisible";
|
---|
| 69 | text_tarray OIDs;
|
---|
| 70 |
|
---|
[7215] | 71 | while (classifytype == "Invisible" || classifytype == "HList") {
|
---|
[668] | 72 | OIDs.erase (OIDs.begin(), OIDs.end());
|
---|
| 73 |
|
---|
| 74 | OIDs.push_back (OID);
|
---|
| 75 | OIDs.push_back (OID + ".fc");
|
---|
| 76 |
|
---|
[7432] | 77 | get_info (OIDs, args["c"], args["l"], metadata, false, collectproto, response, logout);
|
---|
[668] | 78 |
|
---|
[11946] | 79 | // Avoid infinite loops in strange situations by checking that the OID has changed
|
---|
| 80 | if (response.docInfo[1].OID == OID) {
|
---|
| 81 | break;
|
---|
| 82 | }
|
---|
[668] | 83 | OID = response.docInfo[1].OID;
|
---|
[7215] | 84 | classifytype = response.docInfo[1].metadata["childtype"].values[0];
|
---|
[668] | 85 | }
|
---|
| 86 | if (is_classify) args["cl"] = OID;
|
---|
| 87 | else args["d"] = OID;
|
---|
[649] | 88 | }
|
---|
| 89 |
|
---|
[668] | 90 | int hlistbrowserclass::output_section_group (ResultDocInfo_t §ion, cgiargsclass &args,
|
---|
[1443] | 91 | const text_t& collection, int colnumber,
|
---|
[751] | 92 | format_t *formatlistptr, bool use_table,
|
---|
| 93 | text_tset &metadata, bool &getParents,
|
---|
[668] | 94 | recptproto *collectproto, displayclass &disp,
|
---|
[751] | 95 | outconvertclass &outconvert, ostream &textout,
|
---|
| 96 | ostream &logout) {
|
---|
[668] | 97 |
|
---|
[730] | 98 | // expanded contents are going to cause some nasty recursions
|
---|
| 99 | // so we'll only continue if being passed the current section
|
---|
| 100 | if ((args["gc"] == 1) && (section.OID != args["d"])) return 0;
|
---|
| 101 |
|
---|
[668] | 102 | // get all siblings
|
---|
| 103 | FilterResponse_t response;
|
---|
| 104 | text_t &arg_cl = args["cl"];
|
---|
[7432] | 105 | get_children (section.OID + ".pr", args["c"], args["l"], metadata, getParents,
|
---|
[668] | 106 | collectproto, response, logout);
|
---|
| 107 |
|
---|
[10947] | 108 | /* use_table is set to true if the format string starts with <td> */
|
---|
[668] | 109 | if (use_table || colnumber > 0) {
|
---|
[3666] | 110 | textout << outconvert << "<table><tr><td>";
|
---|
[668] | 111 | // get tab size
|
---|
| 112 | text_t tab; int itab;
|
---|
[7433] | 113 | disp.expandstring (displayclass::defaultpackage, "_tabwidth_", tab);
|
---|
[668] | 114 | itab = tab.getint();
|
---|
| 115 | if (colnumber > 0) textout << outconvert << disp
|
---|
[12488] | 116 | << "<img alt=\"\" src=\"_httpimg_/space.gif\" width=\""
|
---|
| 117 | << (itab*colnumber) << "\"/>";
|
---|
[3666] | 118 | textout << outconvert << "</td>\n";
|
---|
[668] | 119 | }
|
---|
| 120 |
|
---|
[10947] | 121 | if (use_table)
|
---|
| 122 | textout << outconvert << "<table class=\"h_list\"><tr>\n";
|
---|
| 123 | else
|
---|
| 124 | textout << outconvert << "<div class=\"h_list\">\n";
|
---|
[668] | 125 |
|
---|
| 126 | ResultDocInfo_tarray::iterator tsibling = response.docInfo.begin();
|
---|
| 127 | ResultDocInfo_tarray::iterator esibling = response.docInfo.end();
|
---|
| 128 |
|
---|
| 129 | text_t icon, link;
|
---|
[11637] | 130 |
|
---|
[668] | 131 | while (tsibling != esibling) {
|
---|
| 132 |
|
---|
| 133 | bool highlight = false;
|
---|
[751] | 134 | text_t &doctype = (*tsibling).metadata["doctype"].values[0];
|
---|
[668] | 135 |
|
---|
| 136 | if ((*tsibling).OID == section.OID) {
|
---|
| 137 | link.clear();
|
---|
[11637] | 138 | highlight = true;
|
---|
[668] | 139 | } else {
|
---|
| 140 | link = "<a href=\"_httpdocument_";
|
---|
[751] | 141 | if (doctype == "classify")
|
---|
[10873] | 142 | link += "&cl=" + (*tsibling).OID + "\">";
|
---|
[5124] | 143 | else {
|
---|
[10873] | 144 | link += "&cl=" + arg_cl + "&d=" + (*tsibling).OID;// + "\">";
|
---|
[5124] | 145 | // [modification to allow default document detach settings -- kjdon]
|
---|
| 146 | if (args["xx"]=="1") {
|
---|
| 147 | // documents should be detached
|
---|
[10947] | 148 | link += "&x=1\" target=\"_blank\">";
|
---|
[5124] | 149 | } else {
|
---|
| 150 | link += "\">";
|
---|
| 151 | }
|
---|
| 152 | }
|
---|
[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 | }
|
---|
| 184 |
|
---|
[995] | 185 | int hlistbrowserclass::output_section_group (FilterResponse_t &/*sections*/, cgiargsclass &/*args*/,
|
---|
| 186 | const text_t &/*collection*/, int /*colnumber*/,
|
---|
| 187 | format_t * /*formatlistptr*/, bool /*use_table*/,
|
---|
| 188 | text_tset &/*metadata*/, bool &/*getParents*/,
|
---|
| 189 | recptproto * /*collectproto*/, displayclass &/*disp*/,
|
---|
| 190 | outconvertclass &/*outconvert*/, ostream &/*textout*/,
|
---|
| 191 | ostream &/*logout*/) {
|
---|
| 192 | return 0;
|
---|
| 193 | }
|
---|