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

Last change on this file since 757 was 727, checked in by sjboddie, 25 years ago

fixed some stupid compiler warnings on windows

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