[649] | 1 | /**********************************************************************
|
---|
| 2 | *
|
---|
| 3 | * vlistbrowserclass.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 "vlistbrowserclass.h"
|
---|
| 27 | #include <assert.h>
|
---|
| 28 | #include "OIDtools.h"
|
---|
| 29 |
|
---|
| 30 | vlistbrowserclass::vlistbrowserclass () {
|
---|
| 31 | }
|
---|
| 32 |
|
---|
| 33 | vlistbrowserclass::~vlistbrowserclass () {
|
---|
| 34 | }
|
---|
| 35 |
|
---|
| 36 | // returns the name that specifies the browserclass type
|
---|
| 37 | text_t vlistbrowserclass::get_browser_name () {
|
---|
| 38 | return "VList";
|
---|
| 39 | }
|
---|
| 40 |
|
---|
| 41 | void vlistbrowserclass::load_metadata_defaults (text_tset &metadata) {
|
---|
| 42 | metadata.insert ("haschildren");
|
---|
| 43 | metadata.insert ("doctype");
|
---|
| 44 | }
|
---|
| 45 |
|
---|
[668] | 46 | text_t vlistbrowserclass::get_default_formatstring () {
|
---|
| 47 | return "<td>[link][icon][/link]</td><td>[highlight]{Or}{[Title],Untitled}[/highlight]</td>";
|
---|
| 48 | }
|
---|
| 49 |
|
---|
[649] | 50 | int vlistbrowserclass::output_section_group (ResultDocInfo_t §ion, cgiargsclass &args,
|
---|
[752] | 51 | const text_t &collection, int colnumber,
|
---|
| 52 | format_t *formatlistptr, bool use_table,
|
---|
| 53 | text_tset &/*metadata*/, bool &/*getParents*/,
|
---|
[1443] | 54 | recptproto * collectproto, displayclass &disp,
|
---|
[752] | 55 | outconvertclass &outconvert, ostream &textout,
|
---|
[1443] | 56 | ostream& logout) {
|
---|
[649] | 57 |
|
---|
| 58 | text_t link, icon;
|
---|
[747] | 59 |
|
---|
| 60 | text_t collink = collection;
|
---|
| 61 | if (!collink.empty()) collink = "&c=" + collink;
|
---|
| 62 |
|
---|
| 63 | get_link_icon (section, args, collink, link, icon);
|
---|
[668] | 64 | bool highlight = false;
|
---|
| 65 | if (!args["d"].empty()) {
|
---|
| 66 | if (args["d"] == section.OID) highlight = true;
|
---|
| 67 | } else
|
---|
| 68 | if (args["cl"] == section.OID) highlight = true;
|
---|
[649] | 69 |
|
---|
[668] | 70 |
|
---|
| 71 | if (use_table || colnumber > 0) {
|
---|
[1048] | 72 | textout << "<table><tr valign=top>";
|
---|
[668] | 73 | // get tab size
|
---|
| 74 | text_t tab; int itab;
|
---|
| 75 | disp.expandstring ("Global", "_tabwidth_", tab);
|
---|
| 76 | itab = tab.getint();
|
---|
| 77 | if (colnumber > 0) textout << outconvert << disp
|
---|
| 78 | << "<td><img src=\"_httpimg_/space.gif\" width="
|
---|
| 79 | << (itab*colnumber) << "></td>";
|
---|
| 80 | }
|
---|
| 81 |
|
---|
[1443] | 82 | textout << outconvert << disp
|
---|
| 83 | << get_formatted_string (collection, collectproto,
|
---|
| 84 | section, formatlistptr,
|
---|
| 85 | link, icon, highlight, logout);
|
---|
[649] | 86 |
|
---|
[668] | 87 | if (use_table || colnumber > 0) textout << "</tr></table>\n";
|
---|
| 88 |
|
---|
[649] | 89 | return 1;
|
---|
| 90 | }
|
---|
| 91 |
|
---|
[668] | 92 | int vlistbrowserclass::output_section_group (FilterResponse_t §ions, cgiargsclass &args,
|
---|
[752] | 93 | const text_t &collection, int colnumber,
|
---|
| 94 | format_t *formatlistptr, bool use_table,
|
---|
| 95 | text_tset &/*metadata*/, bool &/*getParents*/,
|
---|
[1443] | 96 | recptproto * collectproto, displayclass &disp,
|
---|
[752] | 97 | outconvertclass &outconvert, ostream &textout,
|
---|
[1443] | 98 | ostream& logout) {
|
---|
[668] | 99 |
|
---|
| 100 | text_t link, icon;
|
---|
| 101 | text_t &arg_d = args["d"];
|
---|
| 102 | text_t &arg_cl = args["cl"];
|
---|
| 103 |
|
---|
[747] | 104 | text_t collink = collection;
|
---|
| 105 | if (!collink.empty()) collink = "&c=" + collink;
|
---|
| 106 |
|
---|
[668] | 107 | if (colnumber > 0) {
|
---|
[1048] | 108 | textout << "<table><tr valign=top>";
|
---|
[649] | 109 | // get tab size
|
---|
| 110 | text_t tab; int itab;
|
---|
| 111 | disp.expandstring ("Global", "_tabwidth_", tab);
|
---|
| 112 | itab = tab.getint();
|
---|
| 113 | if (colnumber > 0) textout << outconvert << disp
|
---|
[668] | 114 | << "<td><img src=\"_httpimg_/space.gif\" width="
|
---|
| 115 | << (itab*colnumber) << "></td>";
|
---|
| 116 | textout << "<td>";
|
---|
[649] | 117 | }
|
---|
[668] | 118 | if (use_table) textout << "<table>\n";
|
---|
[649] | 119 |
|
---|
[668] | 120 | ResultDocInfo_tarray::iterator thissection = sections.docInfo.begin();
|
---|
| 121 | ResultDocInfo_tarray::iterator endsection = sections.docInfo.end();
|
---|
[649] | 122 |
|
---|
[668] | 123 | while (thissection != endsection) {
|
---|
| 124 |
|
---|
[747] | 125 | get_link_icon (*thissection, args, collink, link, icon);
|
---|
[668] | 126 | bool highlight = false;
|
---|
| 127 | if (!arg_d.empty()) {
|
---|
| 128 | if (arg_d == (*thissection).OID) highlight = true;
|
---|
| 129 | } else
|
---|
| 130 | if (arg_cl == (*thissection).OID) highlight = true;
|
---|
| 131 |
|
---|
[1048] | 132 | if (use_table || colnumber > 0) textout << "<tr valign=top>";
|
---|
[1443] | 133 | textout << outconvert << disp
|
---|
| 134 | << get_formatted_string (collection, collectproto,
|
---|
| 135 | *thissection, formatlistptr,
|
---|
| 136 | link, icon, highlight, logout);
|
---|
| 137 |
|
---|
[668] | 138 | if (use_table || colnumber > 0) textout << "</tr>";
|
---|
| 139 | textout << "\n";
|
---|
| 140 | thissection ++;
|
---|
| 141 | }
|
---|
| 142 |
|
---|
| 143 | if (use_table) textout << "</table>\n";
|
---|
| 144 | if (colnumber > 0) textout << "</table></td></tr></table>\n";
|
---|
| 145 |
|
---|
| 146 | return 1;
|
---|
[649] | 147 | }
|
---|
| 148 |
|
---|
| 149 |
|
---|
| 150 | // get_link_icon attempts to work out what type of icon should be displayed for
|
---|
| 151 | // the given section and what it should link to.
|
---|
| 152 | void vlistbrowserclass::get_link_icon (ResultDocInfo_t §ion, cgiargsclass &args,
|
---|
[747] | 153 | const text_t &collink, text_t &link, text_t &icon) {
|
---|
[649] | 154 |
|
---|
[747] | 155 | link = "<a href=\"_httpdocument_" + collink;
|
---|
[649] | 156 | icon = "_document:icontext_";
|
---|
[824] | 157 | int haschildren = 0;
|
---|
[649] | 158 |
|
---|
[824] | 159 | if (section.metadata.count("haschildren")>0)
|
---|
[934] | 160 | haschildren = section.metadata["haschildren"].values[0].getint();
|
---|
[824] | 161 |
|
---|
[934] | 162 | text_t doctype;
|
---|
[824] | 163 | if (section.metadata.count("doctype")>0)
|
---|
[934] | 164 | doctype = section.metadata["doctype"].values[0];
|
---|
[824] | 165 |
|
---|
[668] | 166 | text_t &arg_d = args["d"];
|
---|
| 167 | text_t &arg_cl = args["cl"];
|
---|
| 168 |
|
---|
[649] | 169 | if (args["a"] == "q") {
|
---|
| 170 | // query results
|
---|
| 171 | if (is_top (section.OID)) icon = "_document:iconclosedbook_";
|
---|
| 172 | else if (haschildren == 1) icon = "_document:iconclosedfolder_";
|
---|
| 173 | link += "&cl=search&d=" + section.OID + "\">";
|
---|
| 174 |
|
---|
[668] | 175 | } else if (!arg_d.empty()) {
|
---|
[649] | 176 | // document level
|
---|
| 177 | if (is_top(section.OID)) {
|
---|
| 178 | icon = "_document:iconopenbook_";
|
---|
[668] | 179 | if (arg_cl == "search") link = "<a href=\"_httpquery_\">";
|
---|
| 180 | else link += "&cl=" + arg_cl + "\">";
|
---|
[649] | 181 |
|
---|
| 182 | } else if (haschildren == 1) {
|
---|
[668] | 183 | if ((args["gc"] == "1") ||
|
---|
| 184 | (is_child_of (section.OID, arg_d)) ||
|
---|
| 185 | (section.OID == arg_d)) {
|
---|
[649] | 186 | icon = "_document:iconopenfolder_";
|
---|
[668] | 187 | link += "&cl=" + arg_cl + "&d=" + section.OID + ".pr\">";
|
---|
[649] | 188 | } else {
|
---|
| 189 | icon = "_document:iconclosedfolder_";
|
---|
[668] | 190 | link += "&cl=" + arg_cl + "&d=" + section.OID + "\">";
|
---|
[649] | 191 | }
|
---|
[668] | 192 | } else link += "&cl=" + arg_cl + "&d=" + section.OID + "\">";
|
---|
[649] | 193 |
|
---|
| 194 | } else {
|
---|
| 195 | // classification level
|
---|
| 196 | if (haschildren == 1) {
|
---|
| 197 | if (doctype == "classify") {
|
---|
[668] | 198 | if ((args["gc"] == "1") ||
|
---|
| 199 | (is_child_of (section.OID, arg_cl)) ||
|
---|
| 200 | (section.OID == arg_cl)) {
|
---|
[649] | 201 | icon = "_document:iconopenbookshelf_";
|
---|
| 202 | link += "&cl=" + section.OID + ".pr\">";
|
---|
| 203 | } else {
|
---|
| 204 | icon = "_document:iconclosedbookshelf_";
|
---|
| 205 | link += "&cl=" + section.OID + "\">";
|
---|
| 206 | }
|
---|
| 207 | } else {
|
---|
| 208 | icon = "_document:iconclosedbook_";
|
---|
[668] | 209 | link += "&cl=" + arg_cl + "&d=" + section.OID + "\">";
|
---|
[649] | 210 | }
|
---|
| 211 | } else {
|
---|
| 212 | if (doctype == "classify") link = "";
|
---|
[668] | 213 | else link += "&cl=" + arg_cl + "&d=" + section.OID + "\">";
|
---|
[649] | 214 | }
|
---|
| 215 | }
|
---|
| 216 | }
|
---|