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

Last change on this file since 827 was 827, checked in by davidb, 24 years ago

added call to cgi_safe to ensure href correctly formatted.

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