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

Last change on this file since 5225 was 5124, checked in by kjdon, 21 years ago

made some small changes to allow the user to specify that documents should be detached by default - the links in the search list and classifier lists lead to new windows being opened for the documents. there is a new arg xx, which is 0 by default, but if its 1, it means that docs should be detached. affected classes are documentaction - this is where I defined the arg, just because the x arg is there, and the browser classes where the links to the documents are created. I have only changed vlist, hlist and datelist browser classes - I didn't think the others needed changing. to use this, you need to set the arg to 1 in main.cfg (for all collections), or add it to the receptionist thingy in a colls collect.cfg file

  • 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 *********************************************************************/
25
26#include "datelistbrowserclass.h"
27#include <assert.h>
28
29
30datelistbrowserclass::datelistbrowserclass () {
31}
32
33datelistbrowserclass::~datelistbrowserclass () {
34}
35
36text_t datelistbrowserclass::get_browser_name () {
37 return "DateList";
38}
39
40void datelistbrowserclass::load_metadata_defaults (text_tset &metadata) {
41 metadata.insert ("Date");
42 metadata.insert ("doctype");
43}
44
45text_t datelistbrowserclass::get_default_formatstring () {
46 return "<td>[link][icon][/link]</td><td>[highlight]{Or}{[Title],Untitled}[/highlight]</td><td>[Date]</td>";
47}
48
49int datelistbrowserclass::output_section_group (ResultDocInfo_t &/*section*/, cgiargsclass &/*args*/,
50 const text_t &/*collection*/, int /*colnumber*/,
51 format_t * /*formatlistptr*/, bool /*use_table*/,
52 text_tset &/*metadata*/, bool &/*getParents*/,
53 recptproto * /*collectproto*/, displayclass &/*disp*/,
54 outconvertclass &/*outconvert*/, ostream &/*textout*/,
55 ostream &/*logout*/) {
56 return 0;
57}
58
59int datelistbrowserclass::output_section_group (FilterResponse_t &sections, cgiargsclass &args,
60 const text_t &collection, int colnumber, format_t *formatlistptr,
61 bool use_table, text_tset &/*metadata*/, bool &/*getParents*/,
62 recptproto * collectproto, displayclass &disp,
63 outconvertclass &outconvert, ostream &textout, ostream &logout) {
64
65 text_t lastyear = "0000";
66 text_t lastmonth = "00";
67 text_t tabbing, endtabbing;
68
69 if (use_table || colnumber > 0) {
70 textout << outconvert << "<table><tr><td>";
71 // get tab size
72 text_t tab; int itab;
73 disp.expandstring ("Global", "_tabwidth_", tab);
74 itab = tab.getint();
75 if (colnumber > 0)
76 textout << outconvert << "<img src=\"_httpimg_/space.gif\" width=" << (itab*colnumber) << ">";
77 textout << outconvert << "</td><td>";
78 }
79
80 textout << outconvert << "<table>\n";
81
82 ResultDocInfo_tarray::iterator thissection = sections.docInfo.begin();
83 ResultDocInfo_tarray::iterator endsection = sections.docInfo.end();
84
85 while (thissection != endsection) {
86
87 text_t &doctype = (*thissection).metadata["doctype"].values[0];
88 text_t &date = (*thissection).metadata["Date"].values[0];
89
90 // bail on this document if it has no date
91 if (date.empty()) continue;
92
93 text_t::const_iterator datebegin = date.begin();
94 int datesize = date.size();
95
96 if (datesize < 4) continue;
97 text_t thisyear = substr (datebegin, datebegin+4);
98 text_t thismonth = "00";
99 if (datesize >= 6)
100 thismonth = substr (datebegin+4, datebegin+6);
101
102 text_t link = "<a href=\"_httpdocument_&cl=";
103 text_t icon = "_document:iconclosedbook_";
104
105 if (doctype == "classify") {
106 icon = "_document:iconclosedbookshelf_";
107 link += (*thissection).OID + "\">";
108 } else {
109 link += args["cl"] + "&d=" + (*thissection).OID; // + "\">";
110 // [modification to allow default document detach settings -- kjdon]
111 if (args["xx"]=="1") {
112 // documents should be detached
113 link += "&x=1\" target=\\_blank>";
114 } else {
115 link += "\">";
116 }
117 }
118
119 textout << outconvert << "<tr valign=top>";
120
121 if (thisyear != lastyear) {
122 textout << outconvert << "<td><b>" << thisyear << "</b></td>";
123 lastyear = thisyear;
124 } else
125 textout << outconvert << "<td></td>";
126
127 if (thismonth != lastmonth) {
128 textout << outconvert << disp << ("<td><b>_textmonth" + thismonth + "_</b></td>");
129 lastmonth = thismonth;
130 } else
131 textout << outconvert << "<td></td>";
132
133 if (!use_table) textout << outconvert << "<td>\n";
134
135 text_tmap options;
136 options["link"] = link;
137 options["icon"] = icon;
138 options["highlight"] = "0";
139 textout << outconvert << disp
140 << get_formatted_string (collection, collectproto,
141 *thissection, disp, formatlistptr,
142 options, logout) << "\n";
143
144 if (!use_table) textout << outconvert << "</td>";
145
146 textout << outconvert << "</tr>\n";
147
148 thissection ++;
149 }
150
151 textout << outconvert << "</table>\n";
152
153 if (use_table || colnumber > 0) textout << outconvert << "</td></tr></table>\n";
154 return 1;
155}
Note: See TracBrowser for help on using the repository browser.