source: trunk/gsdl/src/recpt/datelistbrowserclass.cpp@ 995

Last change on this file since 995 was 995, checked in by sjboddie, 24 years ago

fixed some compiler warnings

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 5.1 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 * $Id: datelistbrowserclass.cpp 995 2000-02-29 21:00:38Z sjboddie $
25 *
26 *********************************************************************/
27
28/*
29 $Log$
30 Revision 1.5 2000/02/29 21:00:27 sjboddie
31 fixed some compiler warnings
32
33 Revision 1.4 1999/11/01 22:04:11 sjboddie
34 just a few small changes (that means I can't remember ;)
35
36 Revision 1.3 1999/10/19 08:40:11 sjboddie
37 fixed some stupid compiler warnings on windows
38
39 Revision 1.2 1999/10/14 22:59:33 sjboddie
40 finished off browser classes
41
42 Revision 1.1 1999/10/10 08:14:05 sjboddie
43 - metadata now returns mp rather than array
44 - redesigned browsing support (although it's not finished so
45 won't currently work ;-)
46
47 */
48
49
50#include "datelistbrowserclass.h"
51#include <assert.h>
52
53
54datelistbrowserclass::datelistbrowserclass () {
55}
56
57datelistbrowserclass::~datelistbrowserclass () {
58}
59
60text_t datelistbrowserclass::get_browser_name () {
61 return "DateList";
62}
63
64void datelistbrowserclass::load_metadata_defaults (text_tset &metadata) {
65 metadata.insert ("Date");
66 metadata.insert ("doctype");
67}
68
69text_t datelistbrowserclass::get_default_formatstring () {
70 return "<td>[link][icon][/link]</td><td>[highlight]{Or}{[Title],Untitled}[/highlight]</td><td>[Date]</td>";
71}
72
73int datelistbrowserclass::output_section_group (ResultDocInfo_t &/*section*/, cgiargsclass &/*args*/,
74 const text_t &/*collection*/, int /*colnumber*/,
75 format_t * /*formatlistptr*/, bool /*use_table*/,
76 text_tset &/*metadata*/, bool &/*getParents*/,
77 recptproto * /*collectproto*/, displayclass &/*disp*/,
78 outconvertclass &/*outconvert*/, ostream &/*textout*/,
79 ostream &/*logout*/) {
80 return 0;
81}
82
83int datelistbrowserclass::output_section_group (FilterResponse_t &sections, cgiargsclass &args,
84 const text_t &/*collection*/, int colnumber, format_t *formatlistptr,
85 bool use_table, text_tset &/*metadata*/, bool &/*getParents*/,
86 recptproto * /*collectproto*/, displayclass &disp,
87 outconvertclass &outconvert, ostream &textout, ostream &/*logout*/) {
88
89 text_t lastyear = "0000";
90 text_t lastmonth = "00";
91 text_t tabbing, endtabbing;
92
93 if (use_table || colnumber > 0) {
94 textout << "<table><tr><td>";
95 // get tab size
96 text_t tab; int itab;
97 disp.expandstring ("Global", "_tabwidth_", tab);
98 itab = tab.getint();
99 if (colnumber > 0)
100 textout << "<img src=\"_httpimg_/space.gif\" width=" << (itab*colnumber) << ">";
101 textout<< "</td><td>";
102 }
103
104 textout << "<table>\n";
105
106 ResultDocInfo_tarray::iterator thissection = sections.docInfo.begin();
107 ResultDocInfo_tarray::iterator endsection = sections.docInfo.end();
108
109 while (thissection != endsection) {
110
111 text_t &doctype = (*thissection).metadata["doctype"].values[0];
112 text_t &date = (*thissection).metadata["Date"].values[0];
113
114 // bail on this document if it has no date
115 if (date.empty()) continue;
116
117 text_t::const_iterator datebegin = date.begin();
118 int datesize = date.size();
119
120 if (datesize < 4) continue;
121 text_t thisyear = substr (datebegin, datebegin+4);
122 text_t thismonth = "00";
123 if (datesize >= 6)
124 thismonth = substr (datebegin+4, datebegin+6);
125
126 text_t link = "<a href=\"_httpdocument_&cl=";
127 text_t icon = "_document:iconclosedbook_";
128
129 if (doctype == "classify") {
130 icon = "_document:iconclosedbookshelf_";
131 link += (*thissection).OID + "\">";
132 } else link += args["cl"] + "&d=" + (*thissection).OID + "\">";
133
134 textout << "<tr valign=top>";
135
136 if (thisyear != lastyear) {
137 textout << outconvert << "<td><b>" << thisyear << "</b></td>";
138 lastyear = thisyear;
139 } else
140 textout << "<td></td>";
141
142 if (thismonth != lastmonth) {
143 textout << outconvert << disp << ("<td><b>_textmonth" + thismonth + "_</b></td>");
144 lastmonth = thismonth;
145 } else
146 textout << "<td></td>";
147
148 if (!use_table) textout << "<td>\n";
149
150 textout << outconvert << disp
151 << get_formatted_string (*thissection, formatlistptr, link, icon) << "\n";
152
153 if (!use_table) textout << "</td>";
154
155 textout << "</tr>\n";
156
157 thissection ++;
158 }
159
160 textout << "</table>\n";
161
162 if (use_table || colnumber > 0) textout << "</td></tr></table>\n";
163 return 1;
164}
Note: See TracBrowser for help on using the repository browser.