source: trunk/gsdl/src/recpt/extlinkaction.cpp@ 793

Last change on this file since 793 was 756, checked in by sjboddie, 25 years ago

changes to arguments of many functions

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 4.0 KB
Line 
1/**********************************************************************
2 *
3 * extlinkaction.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
27#include <string.h>
28#include "extlinkaction.h"
29
30extlinkaction::extlinkaction () {
31
32 // this action uses cgi variables "a", "d", and "href"
33
34 cgiarginfo arg_ainfo;
35 arg_ainfo.shortname = "a";
36 arg_ainfo.longname = "action";
37 arg_ainfo.multiplechar = true;
38 arg_ainfo.defaultstatus = cgiarginfo::weak;
39 arg_ainfo.argdefault = "extlink";
40 arg_ainfo.savedarginfo = cgiarginfo::must;
41 argsinfo.addarginfo (NULL, arg_ainfo);
42
43 arg_ainfo.shortname = "el";
44 arg_ainfo.longname = "external link preference";
45 arg_ainfo.multiplechar = true;
46 arg_ainfo.defaultstatus = cgiarginfo::weak;
47 arg_ainfo.argdefault = "prompt";
48 arg_ainfo.savedarginfo = cgiarginfo::must;
49 argsinfo.addarginfo (NULL, arg_ainfo);
50
51 arg_ainfo.shortname = "d";
52 arg_ainfo.longname = "document OID";
53 arg_ainfo.multiplechar = true;
54 arg_ainfo.defaultstatus = cgiarginfo::none;
55 arg_ainfo.argdefault = "";
56 arg_ainfo.savedarginfo = cgiarginfo::can;
57 argsinfo.addarginfo (NULL, arg_ainfo);
58
59 arg_ainfo.shortname = "href";
60 arg_ainfo.longname = "URL of external link";
61 arg_ainfo.multiplechar = true;
62 arg_ainfo.defaultstatus = cgiarginfo::none;
63 arg_ainfo.argdefault = "";
64 arg_ainfo.savedarginfo = cgiarginfo::can;
65 argsinfo.addarginfo (NULL, arg_ainfo);
66
67 arg_ainfo.shortname = "rl";
68 arg_ainfo.longname = "is relative link";
69 arg_ainfo.multiplechar = false;
70 arg_ainfo.defaultstatus = cgiarginfo::none;
71 arg_ainfo.argdefault = "0";
72 arg_ainfo.savedarginfo = cgiarginfo::mustnot;
73 argsinfo.addarginfo (NULL, arg_ainfo);
74
75}
76
77extlinkaction::~extlinkaction () {
78}
79
80
81
82void extlinkaction::get_cgihead_info (cgiargsclass &args, recptprotolistclass * /*protos*/,
83 response_t &response, text_t &response_data,
84 ostream &/*logout*/)
85{
86 if (args["el"] == "direct")
87 {
88 response = location;
89 response_data = args["href"];
90 }
91 else
92 {
93 response = content;
94 response_data = "text/html";
95 }
96}
97
98
99
100void extlinkaction::define_internal_macros (displayclass &disp, cgiargsclass &args,
101 recptprotolistclass * /*protos*/,
102 ostream &/*logout*/) {
103
104 // define_internal_macros sets the following macros:
105
106 // _nexturl_ link to external page
107 // _prevdoc_ link to previous document
108
109 disp.setmacro("nexturl", "extlink", args["href"]);
110 disp.setmacro("prevdoc", "extlink", args["d"]);
111}
112
113
114bool extlinkaction::do_action (cgiargsclass &args, recptprotolistclass * /*protos*/,
115 browsermapclass * /*browsers*/, displayclass &disp,
116 outconvertclass &outconvert, ostream &textout,
117 ostream &/*logout*/) {
118
119 if (args["el"] != "direct")
120 {
121 if (args["href"] != "")
122 {
123 textout << outconvert << disp << ("_extlink:header_\n")
124 << ("_extlink:foundcontent_\n")
125 << ("_extlink:footer_\n");
126 }
127 else
128 {
129 textout << outconvert << disp << ("_extlink:header_\n")
130 << ("_extlink:notfoundcontent_\n")
131 << ("_extlink:footer_\n");
132 }
133 }
134
135 return true;
136}
137
138
139
Note: See TracBrowser for help on using the repository browser.