1 | /**********************************************************************
|
---|
2 | *
|
---|
3 | * browserclass.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: browserclass.cpp 1254 2000-06-29 02:47:21Z sjboddie $
|
---|
25 | *
|
---|
26 | *********************************************************************/
|
---|
27 |
|
---|
28 | /*
|
---|
29 | $Log$
|
---|
30 | Revision 1.6 2000/06/29 02:47:19 sjboddie
|
---|
31 | added browser info (i.e VList, HList etc.) to status pages
|
---|
32 |
|
---|
33 | Revision 1.5 1999/11/01 22:04:11 sjboddie
|
---|
34 | just a few small changes (that means I can't remember ;)
|
---|
35 |
|
---|
36 | Revision 1.4 1999/10/30 23:02:46 sjboddie
|
---|
37 | tidied things up slightly
|
---|
38 |
|
---|
39 | Revision 1.3 1999/10/30 22:40:00 sjboddie
|
---|
40 | added collection argument
|
---|
41 |
|
---|
42 | Revision 1.2 1999/10/14 22:59:33 sjboddie
|
---|
43 | finished off browser classes
|
---|
44 |
|
---|
45 | Revision 1.1 1999/10/10 08:14:03 sjboddie
|
---|
46 | - metadata now returns mp rather than array
|
---|
47 | - redesigned browsing support (although it's not finished so
|
---|
48 | won't currently work ;-)
|
---|
49 |
|
---|
50 | */
|
---|
51 |
|
---|
52 |
|
---|
53 | #include "browserclass.h"
|
---|
54 | #include <assert.h>
|
---|
55 |
|
---|
56 |
|
---|
57 | browserclass::browserclass () {
|
---|
58 | }
|
---|
59 |
|
---|
60 | browserclass::~browserclass () {
|
---|
61 | }
|
---|
62 |
|
---|
63 | // configure should be called once for each configuration line
|
---|
64 | // the default version does nothing
|
---|
65 | void browserclass::configure (const text_t &/*key*/, const text_tarray &/*cfgline*/) {
|
---|
66 | }
|
---|
67 |
|
---|
68 | // init should be called after all the configuration is done but
|
---|
69 | // before any other methods are called
|
---|
70 | bool browserclass::init (ostream &/*logout*/) {
|
---|
71 | return true;
|
---|
72 | }
|
---|
73 |
|
---|
74 | // returns the name that specifies the browserclass type
|
---|
75 | text_t browserclass::get_browser_name () {
|
---|
76 | return "";
|
---|
77 | }
|
---|
78 |
|
---|
79 | void browserclass::processOID (cgiargsclass &/*args*/, recptproto * /*collectproto*/, ostream &/*logout*/) {
|
---|
80 | }
|
---|
81 |
|
---|
82 | void browserclass::load_metadata_defaults (text_tset &/*metadata*/) {
|
---|
83 | }
|
---|
84 |
|
---|
85 | text_t browserclass::get_default_formatstring () {
|
---|
86 | return "";
|
---|
87 | }
|
---|
88 |
|
---|
89 | void browserclass::set_filter_options (FilterRequest_t &request, cgiargsclass &args) {
|
---|
90 |
|
---|
91 | OptionValue_t option;
|
---|
92 |
|
---|
93 | if (args["a"] == "q") {
|
---|
94 | int arg_m = args.getintarg("m");
|
---|
95 |
|
---|
96 | option.name = "StartResults";
|
---|
97 | option.value = args["r"];
|
---|
98 | request.filterOptions.push_back (option);
|
---|
99 |
|
---|
100 | option.name = "EndResults";
|
---|
101 | int endresults = args.getintarg("o") + (args.getintarg("r") - 1);
|
---|
102 | // int endresults = (args.getintarg("o")*3) + (args.getintarg("r") - 1);
|
---|
103 | if ((endresults > arg_m) && (arg_m != -1)) endresults = arg_m;
|
---|
104 | option.value = endresults;
|
---|
105 | request.filterOptions.push_back (option);
|
---|
106 |
|
---|
107 | } else {
|
---|
108 | option.name = "StartResults";
|
---|
109 | option.value = args["r"];
|
---|
110 | request.filterOptions.push_back (option);
|
---|
111 |
|
---|
112 | option.name = "EndResults";
|
---|
113 | int endresults = 20 + (args.getintarg("r") - 1);
|
---|
114 | option.value = endresults;
|
---|
115 | request.filterOptions.push_back (option);
|
---|
116 | }
|
---|
117 | }
|
---|
118 |
|
---|
119 | int browserclass::output_section_group (ResultDocInfo_t &/*section*/, cgiargsclass &/*args*/,
|
---|
120 | const text_t &/*collection*/, int /*colnumber*/,
|
---|
121 | format_t * /*formatlistptr*/, bool /*use_table*/,
|
---|
122 | text_tset &/*metadata*/, bool &/*getParents*/,
|
---|
123 | recptproto * /*collectproto*/, displayclass &/*disp*/,
|
---|
124 | outconvertclass &/*outconvert*/, ostream &/*textout*/,
|
---|
125 | ostream &/*logout*/) {
|
---|
126 | return 0;
|
---|
127 | }
|
---|
128 |
|
---|
129 | int browserclass::output_section_group (FilterResponse_t &/*sections*/, cgiargsclass &/*args*/,
|
---|
130 | const text_t &/*collection*/, int /*colnumber*/,
|
---|
131 | format_t * /*formatlistptr*/, bool /*use_table*/,
|
---|
132 | text_tset &/*metadata*/, bool &/*getParents*/,
|
---|
133 | recptproto * /*collectproto*/, displayclass &/*disp*/,
|
---|
134 | outconvertclass &/*outconvert*/, ostream &/*textout*/,
|
---|
135 | ostream &/*logout*/) {
|
---|
136 | return 0;
|
---|
137 | }
|
---|
138 |
|
---|
139 | bool operator==(const browserptr &x, const browserptr &y) {
|
---|
140 | return (x.b == y.b);
|
---|
141 | }
|
---|
142 |
|
---|
143 | bool operator<(const browserptr &x, const browserptr &y) {
|
---|
144 | return (x.b < y.b);
|
---|
145 | }
|
---|
146 |
|
---|
147 | // thebrowserclass remains the property of the calling code but
|
---|
148 | // should not be deleted until it is removed from this list.
|
---|
149 | void browsermapclass::addbrowser (browserclass *thebrowserclass) {
|
---|
150 | // can't add a null browserclass
|
---|
151 | assert (thebrowserclass != NULL);
|
---|
152 | if (thebrowserclass == NULL) return;
|
---|
153 |
|
---|
154 | // can't add a browserclass with no name
|
---|
155 | assert (!(thebrowserclass->get_browser_name()).empty());
|
---|
156 | if ((thebrowserclass->get_browser_name()).empty()) return;
|
---|
157 |
|
---|
158 | browserptr aptr;
|
---|
159 | aptr.b = thebrowserclass;
|
---|
160 | browserptrs[thebrowserclass->get_browser_name()] = aptr;
|
---|
161 | }
|
---|
162 |
|
---|
163 | // getbrowser will return the default browser if the browser
|
---|
164 | // could not be found
|
---|
165 | browserclass *browsermapclass::getbrowser (const text_t &key) {
|
---|
166 | // can't find a browser with no name
|
---|
167 | if (key.empty()) return get_default_browser();
|
---|
168 |
|
---|
169 | iterator here = browserptrs.find (key);
|
---|
170 | if (here == browserptrs.end()) return get_default_browser();
|
---|
171 |
|
---|
172 | return (*here).second.b;
|
---|
173 | }
|
---|
174 |
|
---|
175 | void browsermapclass::setdefaultbrowser (const text_t &browsername) {
|
---|
176 | defaultbrowser = browsername;
|
---|
177 | }
|
---|
178 |
|
---|
179 | browserclass *browsermapclass::get_default_browser () {
|
---|
180 |
|
---|
181 | iterator here = browserptrs.find (defaultbrowser);
|
---|
182 | if (here == browserptrs.end())
|
---|
183 | // we'll just take the first in the list if
|
---|
184 | // no valid default was set
|
---|
185 | here = browserptrs.begin();
|
---|
186 | return (*here).second.b;
|
---|
187 | }
|
---|