1 | /**********************************************************************
|
---|
2 | *
|
---|
3 | * niupepavlistbrowserclass.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: niupepavlistbrowserclass.cpp 1023 2000-03-08 20:44:48Z sjboddie $
|
---|
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 | #include "niupepavlistbrowserclass.h"
|
---|
37 | #include <assert.h>
|
---|
38 | #include "OIDtools.h"
|
---|
39 |
|
---|
40 | niupepavlistbrowserclass::niupepavlistbrowserclass () {
|
---|
41 | }
|
---|
42 |
|
---|
43 | niupepavlistbrowserclass::~niupepavlistbrowserclass () {
|
---|
44 | }
|
---|
45 |
|
---|
46 | void niupepavlistbrowserclass::load_metadata_defaults (text_tset &metadata) {
|
---|
47 | metadata.insert ("haschildren");
|
---|
48 | metadata.insert ("doctype");
|
---|
49 | metadata.insert ("abstract");
|
---|
50 | }
|
---|
51 |
|
---|
52 | // get_link_icon attempts to work out what type of icon should be displayed for
|
---|
53 | // the given section and what it should link to.
|
---|
54 | // overridden for niupepa to add links/icons for abstracts as well as
|
---|
55 | // papers
|
---|
56 | void niupepavlistbrowserclass::get_link_icon (ResultDocInfo_t §ion, cgiargsclass &args,
|
---|
57 | const text_t &collink, text_t &link, text_t &icon) {
|
---|
58 |
|
---|
59 | link = "<a href=\"_httpdocument_" + collink;
|
---|
60 | icon = "_document:icontext_";
|
---|
61 | int haschildren = 0;
|
---|
62 |
|
---|
63 | if (section.metadata.count("haschildren") > 0)
|
---|
64 | haschildren = section.metadata["haschildren"].values[0].getint();
|
---|
65 |
|
---|
66 | text_t doctype;
|
---|
67 | if (section.metadata.count("doctype") > 0)
|
---|
68 | doctype = section.metadata["doctype"].values[0];
|
---|
69 |
|
---|
70 | text_t abstract;
|
---|
71 | if (section.metadata.count("abstract") > 0)
|
---|
72 | abstract = section.metadata["abstract"].values[0];
|
---|
73 |
|
---|
74 | text_t &arg_d = args["d"];
|
---|
75 | text_t &arg_cl = args["cl"];
|
---|
76 |
|
---|
77 | if (args["a"] == "q") {
|
---|
78 | // query results
|
---|
79 | if (doctype == "Description") {
|
---|
80 | icon = "_document:iconabstract_";
|
---|
81 | link += "&gg=text";
|
---|
82 | } else if (doctype == "Commentary") {
|
---|
83 | icon = "_document:iconcommentary_";
|
---|
84 | link += "&gg=text";
|
---|
85 | } else {
|
---|
86 | if (is_top (section.OID)) icon = "_document:iconclosedbook_";
|
---|
87 | else if (haschildren == 1) icon = "_document:iconclosedfolder_";
|
---|
88 | }
|
---|
89 | link += "&cl=search&d=" + section.OID + "\">";
|
---|
90 |
|
---|
91 | } else if (!arg_d.empty()) {
|
---|
92 | // document level
|
---|
93 | if (is_top(section.OID)) {
|
---|
94 | icon = "_document:iconopenbook_";
|
---|
95 | if (arg_cl == "search") link = "<a href=\"_httpquery_\">";
|
---|
96 | else link += "&cl=" + arg_cl + "\">";
|
---|
97 |
|
---|
98 | } else if (haschildren == 1) {
|
---|
99 | if ((args["gc"] == "1") ||
|
---|
100 | (is_child_of (section.OID, arg_d)) ||
|
---|
101 | (section.OID == arg_d)) {
|
---|
102 | icon = "_document:iconopenfolder_";
|
---|
103 | link += "&cl=" + arg_cl + "&d=" + section.OID + ".pr\">";
|
---|
104 | } else {
|
---|
105 | icon = "_document:iconclosedfolder_";
|
---|
106 | link += "&cl=" + arg_cl + "&d=" + section.OID + "\">";
|
---|
107 | }
|
---|
108 | } else link += "&cl=" + arg_cl + "&d=" + section.OID + "\">";
|
---|
109 |
|
---|
110 | } else {
|
---|
111 | // classification level
|
---|
112 | if (haschildren == 1) {
|
---|
113 | if (doctype == "classify") {
|
---|
114 | if ((args["gc"] == "1") ||
|
---|
115 | (is_child_of (section.OID, arg_cl)) ||
|
---|
116 | (section.OID == arg_cl)) {
|
---|
117 | icon = "_document:iconopenbookshelf_";
|
---|
118 | link += "&cl=" + section.OID + ".pr\">" + icon + "</a>";
|
---|
119 | } else {
|
---|
120 | icon = "_document:iconclosedbookshelf_";
|
---|
121 | link += "&cl=" + section.OID + "\">" + icon + "</a>";
|
---|
122 | }
|
---|
123 | } else {
|
---|
124 | icon = "_document:iconclosedbook_";
|
---|
125 | if (!abstract.empty())
|
---|
126 | link += "&gg=text&cl=" + arg_cl + "&d=" + abstract + "\">"
|
---|
127 | + "_document:iconabstract_</a>" + link +
|
---|
128 | "&cl=" + arg_cl + "&d=" + section.OID + "\">"
|
---|
129 | + icon + "</a>";
|
---|
130 | else
|
---|
131 | link += "&cl=" + arg_cl + "&d=" + section.OID + "\">"
|
---|
132 | + icon + "</a>";
|
---|
133 | }
|
---|
134 | } else {
|
---|
135 | if (doctype == "classify") link = "";
|
---|
136 | else if (doctype == "Commentary")
|
---|
137 | link += "&gg=text&cl=" + arg_cl + "&d=" + section.OID + "\">"
|
---|
138 | + "_document:iconcommentary_</a>";
|
---|
139 | else if (doctype == "Description")
|
---|
140 | link += "&cl=" + arg_cl + "&d=" + section.OID + "\">"
|
---|
141 | + "_document:iconabstract_</a>";
|
---|
142 | else link += "&cl=" + arg_cl + "&d=" + section.OID + "\">";
|
---|
143 | }
|
---|
144 | }
|
---|
145 | }
|
---|