source: gsdl/trunk/src/recpt/action.cpp@ 14119

Last change on this file since 14119 was 7432, checked in by mdewsnip, 20 years ago

(Human Info) Added language parameter to all calls of get_info, get_children, has_children, and get_contents. Also, removed some of the modifications so it compiles again.

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 5.3 KB
Line 
1/**********************************************************************
2 *
3 * action.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 *********************************************************************/
25
26#include "action.h"
27#include <assert.h>
28
29
30// define all the macros which are related to pages generated
31// by this action
32void action::define_internal_macros (displayclass &/*disp*/, cgiargsclass &/*args*/,
33 recptprotolistclass * /*protos*/, ostream &/*logout*/) {
34}
35
36action::action () {
37}
38
39action::~action () {
40}
41
42// configure should be called once for each configuration line
43void action::configure (const text_t &key, const text_tarray &cfgline) {
44 if (key == "gsdlhome") {
45 gsdlhome = cfgline[0];
46 if (gdbmhome.empty()) gdbmhome = cfgline[0];
47 }
48 if (key == "gdbmhome") {gdbmhome = cfgline[0];}
49}
50
51// init should be called after all the configuration is done but
52// before any other methods are called
53bool action::init (ostream &/*logout*/) {
54 return true;
55}
56
57// returns the "a" argument value that will specify this action
58// this name should be short but does not have to be one character
59// long
60text_t action::get_action_name () {
61 return "nzdl";
62}
63
64// check_cgiargs should be called before get_cgihead_info,
65// define_external_macros, and do_action. If an error is found
66// a message will be written to logout, if the error is severe
67// then the function will return false and no page content
68// should be produced based on the arguments.
69bool action::check_cgiargs (cgiargsinfoclass &/*argsinfo*/, cgiargsclass &/*args*/,
70 recptprotolistclass * /*protos*/, ostream &/*logout*/) {
71 return true;
72}
73
74// check_external_cgiargs should be called after check_cgiargs
75// for all actions. It should only be used to override some other
76// normal behaviour, for example, producing a login page when
77// the requested page needs authentication.
78bool action::check_external_cgiargs (cgiargsinfoclass &/*argsinfo*/,
79 cgiargsclass &/*args*/,
80 outconvertclass &/*outconvert*/,
81 const text_t &/*saveconf*/,
82 ostream &/*logout*/) {
83 return true;
84}
85
86// get_cgihead_info determines the cgi header information for
87// a set of cgi arguments. If response contains location then
88// response_data contains the redirect address. If reponse
89// contains content then reponse_data contains the content-type.
90// Note that images can now be produced by the receptionist.
91void action::get_cgihead_info (cgiargsclass &/*args*/, recptprotolistclass * /*protos*/,
92 response_t &response, text_t &response_data,
93 ostream &/*logout*/) {
94 response = location;
95 response_data = "http://www.nzdl.org";
96}
97
98// uses_display should return true if the receptionist should return
99// true if the display class is needed to output the page content
100// The default is to return true.
101bool action::uses_display (cgiargsclass &/*args*/) {
102 return true;
103}
104
105
106// define all the macros which might be used by other actions
107// to produce pages. These macros should be well documented.
108void action::define_external_macros (displayclass &/*disp*/, cgiargsclass &/*args*/,
109 recptprotolistclass * /*protos*/, ostream &/*logout*/) {
110}
111
112// returns false if there was an error which prevented the action
113// from outputing anything.
114bool action::do_action (cgiargsclass &/*args*/, recptprotolistclass * /*protos*/,
115 browsermapclass * /*browsers*/, displayclass &/*disp*/,
116 outconvertclass &/*outconvert*/, ostream &/*textout*/,
117 ostream &/*logout*/) {
118 return true;
119}
120
121
122bool operator==(const actionptr &x, const actionptr &y) {
123 return (x.a == y.a);
124}
125
126bool operator<(const actionptr &x, const actionptr &y) {
127 return (x.a < y.a);
128}
129
130
131// theaction remains the property of the calling code but
132// should not be deleted until it is removed from this list.
133void actionmapclass::addaction (action *theaction) {
134 // can't add a null action
135 assert (theaction != NULL);
136 if (theaction == NULL) return;
137
138 // can't add an action with no name
139 assert (!(theaction->get_action_name()).empty());
140 if ((theaction->get_action_name()).empty()) return;
141
142 actionptr aptr;
143 aptr.a = theaction;
144 actionptrs[theaction->get_action_name()] = aptr;
145}
146
147// getaction will return NULL if the action could not be found
148action *actionmapclass::getaction (const text_t &key) {
149 // can't find an action with no name
150 assert (!key.empty());
151 if (key.empty()) return NULL;
152
153 iterator here = actionptrs.find (key);
154 if (here == actionptrs.end()) return NULL;
155
156 return (*here).second.a;
157}
Note: See TracBrowser for help on using the repository browser.