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