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

Last change on this file since 727 was 723, checked in by davidb, 25 years ago

Support for building collections through web pages
and internal and external links in collection documents

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 3.9 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
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}
69
70extlinkaction::~extlinkaction () {
71}
72
73
74
75void extlinkaction::get_cgihead_info (cgiargsclass &args, response_t &response,
76 text_t &response_data, ostream &/*logout*/)
77{
78 if (args["el"] == "direct")
79 {
80 response = location;
81 response_data = args["href"];
82 }
83 else
84 {
85 response = content;
86 response_data = "text/html";
87 }
88}
89
90
91
92void extlinkaction::define_internal_macros (const ColInfoResponse_t &/*collectinfo*/, displayclass &disp,
93 cgiargsclass &args, recptproto *collectproto,
94 ostream &/*logout*/) {
95
96 // define_internal_macros sets the following macros:
97
98 // _nexturl_ link to external page
99 // _prevdoc_ link to previous document
100
101 // can't do anything if collectproto is null (i.e. no collection was specified)
102 if (collectproto == NULL) return;
103
104 disp.setmacro("nexturl", "extlink", args["href"]);
105 disp.setmacro("prevdoc", "extlink", args["d"]);
106}
107
108
109bool extlinkaction::do_action (cgiargsclass &args, const ColInfoResponse_t &/*collectinfo*/,
110 recptproto * /*collectproto*/, displayclass &disp,
111 outconvertclass &outconvert, ostream &textout,
112 ostream &/*logout*/) {
113
114 if (args["el"] != "direct")
115 {
116 if (args["href"] != "")
117 {
118 textout << outconvert << disp << ("_extlink:header_\n")
119 << ("_extlink:foundcontent_\n")
120 << ("_extlink:footer_\n");
121 }
122 else
123 {
124 textout << outconvert << disp << ("_extlink:header_\n")
125 << ("_extlink:notfoundcontent_\n")
126 << ("_extlink:footer_\n");
127 }
128 }
129
130 return true;
131}
132
133
134
Note: See TracBrowser for help on using the repository browser.