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