/********************************************************************** * * niupepapagedbrowserclass.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: niupepapagedbrowserclass.cpp 1023 2000-03-08 20:44:48Z sjboddie $ * *********************************************************************/ /* $Log$ Revision 1.1 2000/03/08 20:44:50 sjboddie Initial revision */ #include "niupepapagedbrowserclass.h" #include #include "OIDtools.h" niupepapagedbrowserclass::niupepapagedbrowserclass () { } niupepapagedbrowserclass::~niupepapagedbrowserclass () { } // 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 // this is overridden for niupepa collection as we want to set "gg" // argument to be 'prev' if it's text and there isn't any text, // 'full' if it's prev and there is no prev, 'text' if it's prev // and there's no full or prev, 'prev' if it's full and there's // no full, 'text' if it's full and there's no full or prev. // default to text if all else fails void niupepapagedbrowserclass::processOID (cgiargsclass &args, recptproto *collectproto, ostream &logout) { text_t &arg_d = args["d"]; text_t &arg_gp = args["gp"]; text_t &arg_gg = args["gg"]; text_tset metadata; FilterResponse_t response; bool hastxt = false, hasimg = false, hasprevimg = false; 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, false, 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, false, collectproto, response, logout)) { text_t type = response.docInfo[0].metadata["thistype"].values[0]; if (type=="Invisible") { // display first child arg_d = arg_d + ".fc"; } } } metadata.erase (metadata.begin(), metadata.end()); metadata.insert ("hastxt"); metadata.insert ("hasimg"); metadata.insert ("hasprevimg"); if (get_info(arg_d, args["c"], metadata, false, collectproto, response, logout)) { if (response.docInfo[0].metadata["hastxt"].values[0] == "1") hastxt = true; if (response.docInfo[0].metadata["hasimg"].values[0] == "1") hasimg = true; if (response.docInfo[0].metadata["hasprevimg"].values[0] == "1") hasprevimg = true; } if (arg_gg == "text" && !hastxt) { if (hasprevimg) arg_gg = "prev"; else if (hasimg) arg_gg = "full"; } else if (arg_gg == "prev" && !hasprevimg) { if (hasimg) arg_gg = "full"; else arg_gg = "text"; } else if (arg_gg == "full" && !hasimg) { if (hasprevimg) arg_gg = "prev"; else arg_gg = "text"; } }