[649] | 1 | /**********************************************************************
|
---|
| 2 | *
|
---|
| 3 | * datelistbrowserclass.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 |
|
---|
[7379] | 26 | #include "gsdl_modules_cfg.h"
|
---|
| 27 | #ifdef GSDL_USE_DATELIST_BROWSER
|
---|
| 28 |
|
---|
[24810] | 29 | #include "browsetoolsclass.h"
|
---|
[649] | 30 | #include "datelistbrowserclass.h"
|
---|
| 31 | #include <assert.h>
|
---|
| 32 |
|
---|
| 33 |
|
---|
| 34 | datelistbrowserclass::datelistbrowserclass () {
|
---|
| 35 | }
|
---|
| 36 |
|
---|
| 37 | datelistbrowserclass::~datelistbrowserclass () {
|
---|
| 38 | }
|
---|
| 39 |
|
---|
[668] | 40 | text_t datelistbrowserclass::get_browser_name () {
|
---|
| 41 | return "DateList";
|
---|
[649] | 42 | }
|
---|
| 43 |
|
---|
[7379] | 44 | browserclass* datelistbrowserclass::clone()
|
---|
| 45 | {
|
---|
| 46 | return new datelistbrowserclass();
|
---|
| 47 | }
|
---|
| 48 |
|
---|
[668] | 49 | void datelistbrowserclass::load_metadata_defaults (text_tset &metadata) {
|
---|
| 50 | metadata.insert ("Date");
|
---|
| 51 | metadata.insert ("doctype");
|
---|
[649] | 52 | }
|
---|
| 53 |
|
---|
[668] | 54 | text_t datelistbrowserclass::get_default_formatstring () {
|
---|
[23453] | 55 | return "<td>[link][icon][/link]</td><td>[highlight]{Or}{[dc.Title],[exp.Title],[ex.Title],Untitled}[/highlight]</td><td>{Or}{[format:dc.Date],[format:exp.Date],[format:ex.Date]}</td>";
|
---|
[649] | 56 | }
|
---|
| 57 |
|
---|
[995] | 58 | int datelistbrowserclass::output_section_group (ResultDocInfo_t &/*section*/, cgiargsclass &/*args*/,
|
---|
| 59 | const text_t &/*collection*/, int /*colnumber*/,
|
---|
| 60 | format_t * /*formatlistptr*/, bool /*use_table*/,
|
---|
| 61 | text_tset &/*metadata*/, bool &/*getParents*/,
|
---|
| 62 | recptproto * /*collectproto*/, displayclass &/*disp*/,
|
---|
| 63 | outconvertclass &/*outconvert*/, ostream &/*textout*/,
|
---|
| 64 | ostream &/*logout*/) {
|
---|
| 65 | return 0;
|
---|
| 66 | }
|
---|
[668] | 67 |
|
---|
| 68 | int datelistbrowserclass::output_section_group (FilterResponse_t §ions, cgiargsclass &args,
|
---|
[1443] | 69 | const text_t &collection, int colnumber, format_t *formatlistptr,
|
---|
[668] | 70 | bool use_table, text_tset &/*metadata*/, bool &/*getParents*/,
|
---|
[1443] | 71 | recptproto * collectproto, displayclass &disp,
|
---|
| 72 | outconvertclass &outconvert, ostream &textout, ostream &logout) {
|
---|
[668] | 73 |
|
---|
[24810] | 74 | browsetoolsclass btools;
|
---|
[668] | 75 | text_t lastyear = "0000";
|
---|
| 76 | text_t lastmonth = "00";
|
---|
| 77 | text_t tabbing, endtabbing;
|
---|
| 78 |
|
---|
| 79 | if (use_table || colnumber > 0) {
|
---|
[3666] | 80 | textout << outconvert << "<table><tr><td>";
|
---|
[668] | 81 | // get tab size
|
---|
| 82 | text_t tab; int itab;
|
---|
[7433] | 83 | disp.expandstring (displayclass::defaultpackage, "_tabwidth_", tab);
|
---|
[668] | 84 | itab = tab.getint();
|
---|
| 85 | if (colnumber > 0)
|
---|
[17860] | 86 | textout << outconvert << "<img alt=\"\" src=\"_httpiconspace_\" width=\"" << (itab*colnumber) << "\"/>";
|
---|
[3666] | 87 | textout << outconvert << "</td><td>";
|
---|
[668] | 88 | }
|
---|
| 89 |
|
---|
[11638] | 90 | textout << outconvert << "<table class=\"date_list\">\n";
|
---|
[668] | 91 |
|
---|
| 92 | ResultDocInfo_tarray::iterator thissection = sections.docInfo.begin();
|
---|
| 93 | ResultDocInfo_tarray::iterator endsection = sections.docInfo.end();
|
---|
[6645] | 94 |
|
---|
| 95 | // use the dm arg as date metadata or else Date
|
---|
| 96 | text_t date_meta = args["dm"];
|
---|
| 97 | if (date_meta == "") {
|
---|
| 98 | date_meta = "Date";
|
---|
| 99 | }
|
---|
[10981] | 100 | text_tarray dates;
|
---|
| 101 | splitchar(date_meta.begin(), date_meta.end(), ',', dates);
|
---|
| 102 |
|
---|
[668] | 103 | while (thissection != endsection) {
|
---|
| 104 |
|
---|
| 105 | text_t &doctype = (*thissection).metadata["doctype"].values[0];
|
---|
| 106 |
|
---|
[10981] | 107 | text_tarray::iterator begin = dates.begin();
|
---|
| 108 | text_tarray::iterator end = dates.end();
|
---|
| 109 | text_t date;
|
---|
| 110 | while (begin!= end && date.empty()) {
|
---|
| 111 | date = (*thissection).metadata[*begin].values[0];
|
---|
| 112 | begin++;
|
---|
| 113 | }
|
---|
[11770] | 114 | text_t thisyear = "";
|
---|
| 115 | text_t thismonth = "";
|
---|
| 116 | if (!date.empty()) {
|
---|
| 117 | text_t::const_iterator datebegin = date.begin();
|
---|
| 118 | int datesize = date.size();
|
---|
[668] | 119 |
|
---|
[11770] | 120 | if (datesize >=4) {
|
---|
| 121 | thisyear = substr (datebegin, datebegin+4);
|
---|
| 122 | thismonth = "00";
|
---|
[13017] | 123 | int pos = 4;
|
---|
| 124 | // allow for yyyy-mm-dd
|
---|
[27108] | 125 | if (datesize > pos && date[pos]=='-') {
|
---|
[13017] | 126 | ++pos;
|
---|
| 127 | }
|
---|
| 128 | if (datesize >= pos+2)
|
---|
| 129 | thismonth = substr (datebegin+pos, datebegin+pos+2);
|
---|
[11770] | 130 | }
|
---|
| 131 | }
|
---|
| 132 |
|
---|
[668] | 133 | text_t link = "<a href=\"_httpdocument_&cl=";
|
---|
| 134 | text_t icon = "_document:iconclosedbook_";
|
---|
| 135 |
|
---|
| 136 | if (doctype == "classify") {
|
---|
| 137 | icon = "_document:iconclosedbookshelf_";
|
---|
| 138 | link += (*thissection).OID + "\">";
|
---|
[5124] | 139 | } else {
|
---|
| 140 | link += args["cl"] + "&d=" + (*thissection).OID; // + "\">";
|
---|
| 141 | // [modification to allow default document detach settings -- kjdon]
|
---|
| 142 | if (args["xx"]=="1") {
|
---|
| 143 | // documents should be detached
|
---|
| 144 | link += "&x=1\" target=\\_blank>";
|
---|
| 145 | } else {
|
---|
| 146 | link += "\">";
|
---|
| 147 | }
|
---|
| 148 | }
|
---|
[668] | 149 |
|
---|
[3666] | 150 | textout << outconvert << "<tr valign=top>";
|
---|
[668] | 151 |
|
---|
[11770] | 152 | if (thisyear != "" && thisyear != lastyear) {
|
---|
[11638] | 153 | textout << outconvert << "<td><span class=\"date_list_year\">" << thisyear << "</span></td>";
|
---|
[668] | 154 | lastyear = thisyear;
|
---|
[11770] | 155 | } else {
|
---|
[3666] | 156 | textout << outconvert << "<td></td>";
|
---|
[11770] | 157 | }
|
---|
| 158 | if (thismonth != "" && thismonth != lastmonth) {
|
---|
[11638] | 159 | textout << outconvert << disp << ("<td><span class=\"date_list_month\">_textmonth" + thismonth + "_</span></td>");
|
---|
[668] | 160 | lastmonth = thismonth;
|
---|
[11770] | 161 | } else {
|
---|
[3666] | 162 | textout << outconvert << "<td></td>";
|
---|
[11770] | 163 | }
|
---|
[3666] | 164 | if (!use_table) textout << outconvert << "<td>\n";
|
---|
[4906] | 165 |
|
---|
| 166 | text_tmap options;
|
---|
| 167 | options["link"] = link;
|
---|
| 168 | options["icon"] = icon;
|
---|
| 169 | options["highlight"] = "0";
|
---|
[24810] | 170 | options["DocImage"] = btools.get_cover_image();
|
---|
| 171 | options["assocfilepath"] = btools.get_assocfile_path();
|
---|
| 172 |
|
---|
[668] | 173 | textout << outconvert << disp
|
---|
[1443] | 174 | << get_formatted_string (collection, collectproto,
|
---|
[1610] | 175 | *thissection, disp, formatlistptr,
|
---|
[4906] | 176 | options, logout) << "\n";
|
---|
[668] | 177 |
|
---|
[3666] | 178 | if (!use_table) textout << outconvert << "</td>";
|
---|
[668] | 179 |
|
---|
[3666] | 180 | textout << outconvert << "</tr>\n";
|
---|
[668] | 181 |
|
---|
[9620] | 182 | ++thissection;
|
---|
[668] | 183 | }
|
---|
| 184 |
|
---|
[3666] | 185 | textout << outconvert << "</table>\n";
|
---|
[668] | 186 |
|
---|
[3666] | 187 | if (use_table || colnumber > 0) textout << outconvert << "</td></tr></table>\n";
|
---|
[668] | 188 | return 1;
|
---|
| 189 | }
|
---|
[7379] | 190 |
|
---|
| 191 | #endif //GSDL_USE_DATELIST_BROWSER
|
---|