1 | /**********************************************************************
|
---|
2 | *
|
---|
3 | * niupepapagedbrowserclass.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: niupepapagedbrowserclass.cpp 2876 2001-12-01 22:04:38Z None $
|
---|
25 | *
|
---|
26 | *********************************************************************/
|
---|
27 |
|
---|
28 | /*
|
---|
29 | $Log$
|
---|
30 | Revision 1.1 2000/03/08 20:44:50 sjboddie
|
---|
31 | Initial revision
|
---|
32 |
|
---|
33 |
|
---|
34 | */
|
---|
35 |
|
---|
36 |
|
---|
37 | #include "niupepapagedbrowserclass.h"
|
---|
38 | #include <assert.h>
|
---|
39 | #include "OIDtools.h"
|
---|
40 |
|
---|
41 | niupepapagedbrowserclass::niupepapagedbrowserclass () {
|
---|
42 | }
|
---|
43 |
|
---|
44 | niupepapagedbrowserclass::~niupepapagedbrowserclass () {
|
---|
45 | }
|
---|
46 |
|
---|
47 | // if the "gp" (go to page) argument is set we need to set
|
---|
48 | // the "d" argument to the corresponding page
|
---|
49 | // also want to set "d" argument to first child if we're at
|
---|
50 | // an 'Invisible' top level
|
---|
51 | // this is overridden for niupepa collection as we want to set "gg"
|
---|
52 | // argument to be 'prev' if it's text and there isn't any text,
|
---|
53 | // 'full' if it's prev and there is no prev, 'text' if it's prev
|
---|
54 | // and there's no full or prev, 'prev' if it's full and there's
|
---|
55 | // no full, 'text' if it's full and there's no full or prev.
|
---|
56 | // default to text if all else fails
|
---|
57 | void niupepapagedbrowserclass::processOID (cgiargsclass &args, recptproto *collectproto,
|
---|
58 | ostream &logout) {
|
---|
59 |
|
---|
60 | text_t &arg_d = args["d"];
|
---|
61 | text_t &arg_gp = args["gp"];
|
---|
62 | text_t &arg_gg = args["gg"];
|
---|
63 | text_tset metadata;
|
---|
64 | FilterResponse_t response;
|
---|
65 |
|
---|
66 | bool hastxt = false, hasimg = false, hasprevimg = false;
|
---|
67 |
|
---|
68 | if ((!arg_d.empty()) && (!arg_gp.empty()) && (is_number (arg_gp))) {
|
---|
69 | text_t top;
|
---|
70 | get_top (arg_d, top);
|
---|
71 | metadata.insert ("Title");
|
---|
72 | get_children (top, args["c"], metadata, false, collectproto, response, logout);
|
---|
73 | ResultDocInfo_tarray::iterator dochere = response.docInfo.begin();
|
---|
74 | ResultDocInfo_tarray::iterator docend = response.docInfo.end();
|
---|
75 | while (dochere != docend) {
|
---|
76 | if ((*dochere).metadata["Title"].values[0] == arg_gp) {
|
---|
77 | arg_d = (*dochere).OID;
|
---|
78 | break;
|
---|
79 | }
|
---|
80 | dochere ++;
|
---|
81 | }
|
---|
82 |
|
---|
83 | } else if (!arg_d.empty() && is_top(arg_d)) { // if top level doc, check if not invisible
|
---|
84 | metadata.insert("thistype");
|
---|
85 | if (get_info(arg_d, args["c"], metadata, false, collectproto, response, logout)) {
|
---|
86 | text_t type = response.docInfo[0].metadata["thistype"].values[0];
|
---|
87 | if (type=="Invisible") { // display first child
|
---|
88 | arg_d = arg_d + ".fc";
|
---|
89 | }
|
---|
90 | }
|
---|
91 | }
|
---|
92 |
|
---|
93 | metadata.erase (metadata.begin(), metadata.end());
|
---|
94 | metadata.insert ("hastxt");
|
---|
95 | metadata.insert ("hasimg");
|
---|
96 | metadata.insert ("hasprevimg");
|
---|
97 | if (get_info(arg_d, args["c"], metadata, false, collectproto, response, logout)) {
|
---|
98 | if (response.docInfo[0].metadata["hastxt"].values[0] == "1") hastxt = true;
|
---|
99 | if (response.docInfo[0].metadata["hasimg"].values[0] == "1") hasimg = true;
|
---|
100 | if (response.docInfo[0].metadata["hasprevimg"].values[0] == "1") hasprevimg = true;
|
---|
101 | }
|
---|
102 |
|
---|
103 | if (arg_gg == "text" && !hastxt) {
|
---|
104 | if (hasprevimg) arg_gg = "prev";
|
---|
105 | else if (hasimg) arg_gg = "full";
|
---|
106 | } else if (arg_gg == "prev" && !hasprevimg) {
|
---|
107 | if (hasimg) arg_gg = "full";
|
---|
108 | else arg_gg = "text";
|
---|
109 | } else if (arg_gg == "full" && !hasimg) {
|
---|
110 | if (hasprevimg) arg_gg = "prev";
|
---|
111 | else arg_gg = "text";
|
---|
112 | }
|
---|
113 | }
|
---|