source: gsdl/trunk/runtime-src/src/recpt/datelistbrowserclass.cpp@ 17860

Last change on this file since 17860 was 17860, checked in by mdewsnip, 12 years ago

Moved hard-wired usage of space.gif into a macro, so it can be overridden on a collection-specific basis. By Jeffrey at DL Consulting Ltd.

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 5.9 KB
Line 
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
26#include "gsdl_modules_cfg.h"
27#ifdef GSDL_USE_DATELIST_BROWSER
28
29#include "datelistbrowserclass.h"
30#include <assert.h>
31
32
33datelistbrowserclass::datelistbrowserclass () {
34}
35
36datelistbrowserclass::~datelistbrowserclass () {
37}
38
39text_t datelistbrowserclass::get_browser_name () {
40 return "DateList";
41}
42
43browserclass* datelistbrowserclass::clone()
44{
45 return new datelistbrowserclass();
46}
47
48void datelistbrowserclass::load_metadata_defaults (text_tset &metadata) {
49 metadata.insert ("Date");
50 metadata.insert ("doctype");
51}
52
53text_t datelistbrowserclass::get_default_formatstring () {
54 return "<td>[link][icon][/link]</td><td>[highlight]{Or}{[dls.Title],[dc.Title],[Title],Untitled}[/highlight]</td><td>[Date]</td>";
55}
56
57int 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}
66
67int datelistbrowserclass::output_section_group (FilterResponse_t &sections, cgiargsclass &args,
68 const text_t &collection, int colnumber, format_t *formatlistptr,
69 bool use_table, text_tset &/*metadata*/, bool &/*getParents*/,
70 recptproto * collectproto, displayclass &disp,
71 outconvertclass &outconvert, ostream &textout, ostream &logout) {
72
73 text_t lastyear = "0000";
74 text_t lastmonth = "00";
75 text_t tabbing, endtabbing;
76
77 if (use_table || colnumber > 0) {
78 textout << outconvert << "<table><tr><td>";
79 // get tab size
80 text_t tab; int itab;
81 disp.expandstring (displayclass::defaultpackage, "_tabwidth_", tab);
82 itab = tab.getint();
83 if (colnumber > 0)
84 textout << outconvert << "<img alt=\"\" src=\"_httpiconspace_\" width=\"" << (itab*colnumber) << "\"/>";
85 textout << outconvert << "</td><td>";
86 }
87
88 textout << outconvert << "<table class=\"date_list\">\n";
89
90 ResultDocInfo_tarray::iterator thissection = sections.docInfo.begin();
91 ResultDocInfo_tarray::iterator endsection = sections.docInfo.end();
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 }
98 text_tarray dates;
99 splitchar(date_meta.begin(), date_meta.end(), ',', dates);
100
101 while (thissection != endsection) {
102
103 text_t &doctype = (*thissection).metadata["doctype"].values[0];
104
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 }
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();
117
118 if (datesize >=4) {
119 thisyear = substr (datebegin, datebegin+4);
120 thismonth = "00";
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);
128 }
129 }
130
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 + "\">";
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 }
147
148 textout << outconvert << "<tr valign=top>";
149
150 if (thisyear != "" && thisyear != lastyear) {
151 textout << outconvert << "<td><span class=\"date_list_year\">" << thisyear << "</span></td>";
152 lastyear = thisyear;
153 } else {
154 textout << outconvert << "<td></td>";
155 }
156 if (thismonth != "" && thismonth != lastmonth) {
157 textout << outconvert << disp << ("<td><span class=\"date_list_month\">_textmonth" + thismonth + "_</span></td>");
158 lastmonth = thismonth;
159 } else {
160 textout << outconvert << "<td></td>";
161 }
162 if (!use_table) textout << outconvert << "<td>\n";
163
164 text_tmap options;
165 options["link"] = link;
166 options["icon"] = icon;
167 options["highlight"] = "0";
168 textout << outconvert << disp
169 << get_formatted_string (collection, collectproto,
170 *thissection, disp, formatlistptr,
171 options, logout) << "\n";
172
173 if (!use_table) textout << outconvert << "</td>";
174
175 textout << outconvert << "</tr>\n";
176
177 ++thissection;
178 }
179
180 textout << outconvert << "</table>\n";
181
182 if (use_table || colnumber > 0) textout << outconvert << "</td></tr></table>\n";
183 return 1;
184}
185
186#endif //GSDL_USE_DATELIST_BROWSER
Note: See TracBrowser for help on using the repository browser.