source: trunk/gsdl/src/recpt/tipaction.cpp@ 533

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

added GPL notice

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 2.6 KB
Line 
1/**********************************************************************
2 *
3 * tipaction.cpp -- define random tip macros
4 * Copyright (C) 1999 DigiLib Systems Limited, New Zealand
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: tipaction.cpp 533 1999-09-07 04:57:01Z sjboddie $
25 *
26 *********************************************************************/
27
28/*
29 $Log$
30 Revision 1.4 1999/09/07 04:57:00 sjboddie
31 added GPL notice
32
33 Revision 1.3 1999/09/02 00:29:27 rjmcnab
34 added cgi argument "st" - show tips
35
36 Revision 1.2 1999/07/30 02:24:45 sjboddie
37 added collectinfo argument to some functions
38
39 Revision 1.1 1999/07/09 02:18:27 rjmcnab
40 Initial revision.
41
42
43 */
44
45
46#include "tipaction.h"
47#include <stdlib.h>
48
49
50tipaction::tipaction () {
51 // "st" show tips - "0"=no, "1"=yes
52 cgiarginfo arg_ainfo;
53 arg_ainfo.shortname = "st";
54 arg_ainfo.longname = "show tips";
55 arg_ainfo.multiplechar = true;
56 arg_ainfo.defaultstatus = cgiarginfo::weak;
57 arg_ainfo.argdefault = "1";
58 arg_ainfo.savedarginfo = cgiarginfo::must;
59 argsinfo.addarginfo (NULL, arg_ainfo);
60}
61
62void tipaction::define_external_macros (const ColInfoResponse_t &/*collectinfo*/, displayclass &disp,
63 cgiargsclass &args, recptproto */*collectproto*/,
64 ostream &logout) {
65 // define_external_macros sets the following macros:
66
67 // _tip:thistip_ - a random tip (defined if st == "1")
68
69 if (args["st"].getint()) {
70 // get the maximum tip number (_tip:tipmax_)
71 text_t tipmax_str;
72 disp.expandstring ("tip", "_tipmax_", tipmax_str);
73 if (tipmax_str.empty()) {
74 logout << "Warning: _tip:tipmax_ not set. This macro is needed for displaying tips.\n";
75 return;
76 }
77
78 int tipmax = tipmax_str.getint();
79 if (tipmax < 1) {
80 logout << "Warning: _tip:tipmax_ was less than 1. No tips were set.\n";
81 return;
82 }
83
84 disp.setmacro("thistip", "tip", "_tip" + text_t((rand()%tipmax) + 1) + "_");
85 }
86}
87
Note: See TracBrowser for help on using the repository browser.