/********************************************************************** * * pagedbrowserclass.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. * * $Id: pagedbrowserclass.cpp 1282 2000-07-13 02:51:10Z sjboddie $ * *********************************************************************/ /* $Log$ Revision 1.11 2000/07/13 02:51:10 sjboddie got DocumentArrowsBottom working for collections using "paged" browsers (like gberg). The whole idea of arrows as used both in the query results page and document pages needs to be revisited to get things working in all situations Revision 1.10 2000/06/29 02:47:20 sjboddie added browser info (i.e VList, HList etc.) to status pages Revision 1.9 2000/03/31 03:04:32 nzdl tidied up some of the browsing code - replaced DocumentImages, DocumentTitles and DocumentHeading with DocumentIcon Revision 1.8 2000/02/17 20:54:00 sjboddie minor change to macro name Revision 1.7 2000/02/17 02:35:48 sjboddie tidied up a bit Revision 1.6 2000/02/15 22:53:51 kjm18 search history stuff added. Revision 1.5 2000/02/06 21:29:11 sjboddie fixed a bug - made some functions virtual for use with cstr collection Revision 1.4 1999/10/30 23:06:25 sjboddie tidied up a bit Revision 1.3 1999/10/30 22:16:37 sjboddie added a collection argument Revision 1.2 1999/10/19 08:40:11 sjboddie fixed some stupid compiler warnings on windows Revision 1.1 1999/10/14 22:59:35 sjboddie finished off browser classes */ #include "pagedbrowserclass.h" #include #include "OIDtools.h" pagedbrowserclass::pagedbrowserclass () { } pagedbrowserclass::~pagedbrowserclass () { } // returns the name that specifies the browserclass type text_t pagedbrowserclass::get_browser_name () { return "Paged"; } void pagedbrowserclass::load_metadata_defaults (text_tset &metadata) { metadata.insert ("Title"); } // if the "gp" (go to page) argument is set we need to set // the "d" argument to the corresponding page // also want to set "d" argument to first child if we're at // an 'Invisible' top level void pagedbrowserclass::processOID (cgiargsclass &args, recptproto *collectproto, ostream &logout) { text_t &arg_d = args["d"]; text_t &arg_gp = args["gp"]; text_tset metadata; bool getParents = false; FilterResponse_t response; if ((!arg_d.empty()) && (!arg_gp.empty()) && (is_number (arg_gp))) { text_t top; get_top (arg_d, top); metadata.insert ("Title"); get_children (top, args["c"], metadata, getParents, collectproto, response, logout); ResultDocInfo_tarray::iterator dochere = response.docInfo.begin(); ResultDocInfo_tarray::iterator docend = response.docInfo.end(); while (dochere != docend) { if ((*dochere).metadata["Title"].values[0] == arg_gp) { arg_d = (*dochere).OID; break; } dochere ++; } } else if (!arg_d.empty() && is_top(arg_d)) { // if top level doc, check if not invisible metadata.insert("thistype"); if (get_info(arg_d, args["c"], metadata, getParents, collectproto, response, logout)) { text_t type = response.docInfo[0].metadata["thistype"].values[0]; if (type=="Invisible") { // display first child arg_d = arg_d + ".fc"; } } } } int pagedbrowserclass::output_section_group (ResultDocInfo_t §ion, 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*/) { // this browser class only handles document levels if (args["d"].empty()) return 0; if (section.OID != args["d"]) { text_t httpprevarrow = "_httpdocument_&cl=" + args["cl"] + "&d=" + section.OID; text_t parentarrow = "_iconprev_\n"; disp.setmacro ("httpprevarrow", "document", httpprevarrow); disp.setmacro ("parentarrow", "document", parentarrow); return 0; } // must be at top level to get to here! textout << outconvert << disp << "" << section.metadata["Title"].values[0] << "_document:textintro_\n"; return 0; } int pagedbrowserclass::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 &arg_d = args["d"]; // this browser class only handles document levels if (arg_d.empty()) return 0; text_t previousOID, previoustitle, nextOID, nexttitle; text_t previousarrow, nextarrow, httpprevarrow, httpnextarrow; bool found = false; // this should be our list of pages ResultDocInfo_tarray::iterator thissection = sections.docInfo.begin(); ResultDocInfo_tarray::iterator endsection = sections.docInfo.end(); while (thissection != endsection) { if (arg_d == (*thissection).OID) { found = true; textout << outconvert << disp << "
_page_" << (*thissection).metadata["Title"].values[0] << "\n"; if (thissection != sections.docInfo.begin()) { previousOID = (*(thissection-1)).OID; previoustitle = (*(thissection-1)).metadata["Title"].values[0]; } else { previousarrow = "_document:parentarrow_"; } if ((thissection+1) != endsection) { nextOID = (*(thissection+1)).OID; nexttitle = (*(thissection+1)).metadata["Title"].values[0]; } break; } thissection ++; } if (!found) { textout << outconvert << disp << "\n"); if (!found) { httpnextarrow = "_httpdocument_&cl=" + args["cl"] + "&d=" + sections.docInfo[0].OID; nextarrow = "" + sections.docInfo[0].metadata["Title"].values[0] + "_iconnext_\n"; } else { if (!previousOID.empty()) { httpprevarrow = "_httpdocument_&cl=" + args["cl"] + "&d=" + previousOID; previousarrow = "_iconprev_" + previoustitle + "\n"; } if (!nextOID.empty()) { httpnextarrow = "_httpdocument_&cl=" + args["cl"] + "&d=" + nextOID; nextarrow = "" + nexttitle + "_iconnext_\n"; } } if (!httpprevarrow.empty()) disp.setmacro ("httpprevarrow", "document", httpprevarrow); if (!httpnextarrow.empty()) disp.setmacro ("httpnextarrow", "document", httpnextarrow); textout << outconvert << disp << "\n" << "\n" << "" << "\n" << "
\n"; } int numpages = sections.docInfo.size(); textout << outconvert << disp << ("_document:textnumpages_(" + text_t(numpages) + ")
" << previousarrow << "_document:gotoform_" << nextarrow << "
\n"; return 0; }