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