source: main/trunk/greenstone2/runtime-src/src/recpt/tipaction.cpp@ 28762

Last change on this file since 28762 was 22984, checked in by ak19, 14 years ago
  1. Undoing commit of 22934 where decode_commas was called on stem and fold comma separated list: previously separated due to url-encoding of commas. Now that the problem has been fixed at the source, the decode_commas hack is no longer necessary. 2. Commas in stem and fold are no longer url-encoded because the multiple_value field of the continuously-reused struct arg_ainfo is always set back to the default false after ever being set to true. So it no longer subtly stays at true to affect Greenstone functioning in unforeseen ways (such as suddenly and unnecessarily URL-encoding commas where this is not wanted).
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 2.5 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 *********************************************************************/
25
26#include "gsdl_modules_cfg.h"
27#ifdef GSDL_USE_TIP_ACTION
28
29#include "tipaction.h"
30#include <stdlib.h>
31
32
33tipaction::tipaction () {
34 // "st" show tips - "0"=no, "1"=yes
35 cgiarginfo arg_ainfo;
36 arg_ainfo.shortname = "st";
37 arg_ainfo.longname = "show tips";
38 arg_ainfo.multiplechar = true;
39 arg_ainfo.multiplevalue = false;
40 arg_ainfo.defaultstatus = cgiarginfo::weak;
41 arg_ainfo.argdefault = "1";
42 arg_ainfo.savedarginfo = cgiarginfo::must;
43 argsinfo.addarginfo (NULL, arg_ainfo);
44}
45
46void tipaction::define_external_macros (displayclass &disp, cgiargsclass &args,
47 recptprotolistclass * /*protos*/, ostream &logout) {
48
49 // define_external_macros sets the following macros:
50
51 // _tip:thistip_ - a random tip (defined if st == "1")
52
53 if (args["st"].getint()) {
54 // get the maximum tip number (_tip:tipmax_)
55 text_t tipmax_str;
56 disp.expandstring ("tip", "_tipmax_", tipmax_str);
57 if (tipmax_str.empty()) {
58 // don't bother filling up the logs if tip.dm isn't loaded!
59 // logout << "Warning: _tip:tipmax_ not set. This macro is needed for displaying tips.\n";
60 return;
61 }
62
63 int tipmax = tipmax_str.getint();
64 if (tipmax < 1) {
65 // don't bother filling up the logs if tip.dm isn't loaded!
66 // logout << "Warning: _tip:tipmax_ was less than 1. No tips were set.\n";
67 return;
68 }
69
70 disp.setmacro("thistip", "tip", "_tip" + text_t((rand()%tipmax) + 1) + "_");
71 }
72}
73
74#endif //GSDL_USE_TIP_ACTION
Note: See TracBrowser for help on using the repository browser.