/********************************************************************** * * datelistbrowserclass.cpp -- * Copyright (C) 1999 The New Zealand Digital Library Project * * A component of the Greenstone digital library software * from the New Zealand Digital Library Project at the * University of Waikato, New Zealand. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * *********************************************************************/ #include "datelistbrowserclass.h" #include datelistbrowserclass::datelistbrowserclass () { } datelistbrowserclass::~datelistbrowserclass () { } text_t datelistbrowserclass::get_browser_name () { return "DateList"; } void datelistbrowserclass::load_metadata_defaults (text_tset &metadata) { metadata.insert ("Date"); metadata.insert ("doctype"); } text_t datelistbrowserclass::get_default_formatstring () { return "[link][icon][/link][highlight]{Or}{[Title],Untitled}[/highlight][Date]"; } int datelistbrowserclass::output_section_group (ResultDocInfo_t &/*section*/, cgiargsclass &/*args*/, const text_t &/*collection*/, int /*colnumber*/, format_t * /*formatlistptr*/, bool /*use_table*/, text_tset &/*metadata*/, bool &/*getParents*/, recptproto * /*collectproto*/, displayclass &/*disp*/, outconvertclass &/*outconvert*/, ostream &/*textout*/, ostream &/*logout*/) { return 0; } int datelistbrowserclass::output_section_group (FilterResponse_t §ions, cgiargsclass &args, const text_t &/*collection*/, int colnumber, format_t *formatlistptr, bool use_table, text_tset &/*metadata*/, bool &/*getParents*/, recptproto * /*collectproto*/, displayclass &disp, outconvertclass &outconvert, ostream &textout, ostream &/*logout*/) { text_t lastyear = "0000"; text_t lastmonth = "00"; text_t tabbing, endtabbing; if (use_table || colnumber > 0) { textout << "
"; // get tab size text_t tab; int itab; disp.expandstring ("Global", "_tabwidth_", tab); itab = tab.getint(); if (colnumber > 0) textout << ""; textout<< ""; } textout << "\n"; ResultDocInfo_tarray::iterator thissection = sections.docInfo.begin(); ResultDocInfo_tarray::iterator endsection = sections.docInfo.end(); while (thissection != endsection) { text_t &doctype = (*thissection).metadata["doctype"].values[0]; text_t &date = (*thissection).metadata["Date"].values[0]; // bail on this document if it has no date if (date.empty()) continue; text_t::const_iterator datebegin = date.begin(); int datesize = date.size(); if (datesize < 4) continue; text_t thisyear = substr (datebegin, datebegin+4); text_t thismonth = "00"; if (datesize >= 6) thismonth = substr (datebegin+4, datebegin+6); text_t link = ""; } else link += args["cl"] + "&d=" + (*thissection).OID + "\">"; textout << ""; if (thisyear != lastyear) { textout << outconvert << ""; lastyear = thisyear; } else textout << ""; if (thismonth != lastmonth) { textout << outconvert << disp << (""); lastmonth = thismonth; } else textout << ""; if (!use_table) textout << ""; textout << "\n"; thissection ++; } textout << "
" << thisyear << "_textmonth" + thismonth + "_\n"; textout << outconvert << disp << get_formatted_string (*thissection, formatlistptr, link, icon) << "\n"; if (!use_table) textout << "
\n"; if (use_table || colnumber > 0) textout << "
\n"; return 1; }