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