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

Last change on this file since 673 was 668, checked in by sjboddie, 25 years ago

finished off browser classes

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