Ignore:
Timestamp:
1999-09-02T12:29:27+12:00 (25 years ago)
Author:
rjmcnab
Message:

added cgi argument "st" - show tips

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl/src/recpt/tipaction.cpp

    r421 r515  
    1212/*
    1313   $Log$
     14   Revision 1.3  1999/09/02 00:29:27  rjmcnab
     15   added cgi argument "st" - show tips
     16
    1417   Revision 1.2  1999/07/30 02:24:45  sjboddie
    1518   added collectinfo argument to some functions
     
    2629
    2730
     31tipaction::tipaction () {
     32  // "st" show tips - "0"=no, "1"=yes
     33  cgiarginfo arg_ainfo;
     34  arg_ainfo.shortname = "st";
     35  arg_ainfo.longname = "show tips";
     36  arg_ainfo.multiplechar = true;
     37  arg_ainfo.defaultstatus = cgiarginfo::weak;
     38  arg_ainfo.argdefault = "1";
     39  arg_ainfo.savedarginfo = cgiarginfo::must;
     40  argsinfo.addarginfo (NULL, arg_ainfo);
     41}
     42
    2843void tipaction::define_external_macros (const ColInfoResponse_t &/*collectinfo*/, displayclass &disp,
    29                     cgiargsclass &/*args*/, recptproto */*collectproto*/,
     44                    cgiargsclass &args, recptproto */*collectproto*/,
    3045                    ostream &logout) {
    31 
    3246  // define_external_macros sets the following macros:
    3347
    34   // _tip:thistip_
    35  
    36   // get the maximum tip number (_tip:tipmax_)
    37   text_t tipmax_str;
    38   disp.expandstring ("tip", "_tipmax_", tipmax_str);
    39   if (tipmax_str.empty()) {
    40     logout << "Warning: _tip:tipmax_ not set. This macro is needed for displaying tips.\n";
    41     return;
     48  // _tip:thistip_  - a random tip (defined if st == "1")
     49
     50  if (args["st"].getint()) {
     51    // get the maximum tip number (_tip:tipmax_)
     52    text_t tipmax_str;
     53    disp.expandstring ("tip", "_tipmax_", tipmax_str);
     54    if (tipmax_str.empty()) {
     55      logout << "Warning: _tip:tipmax_ not set. This macro is needed for displaying tips.\n";
     56      return;
     57    }
     58   
     59    int tipmax = tipmax_str.getint();
     60    if (tipmax < 1) {
     61      logout << "Warning: _tip:tipmax_ was less than 1. No tips were set.\n";
     62      return;
     63    }
     64   
     65    disp.setmacro("thistip", "tip", "_tip" + text_t((rand()%tipmax) + 1) + "_");
    4266  }
    43    
    44   int tipmax = tipmax_str.getint();
    45   if (tipmax < 1) {
    46     logout << "Warning: _tip:tipmax_ was less than 1. No tips were set.\n";
    47     return;
    48   }
    49 
    50   disp.setmacro("thistip", "tip", "_tip" + text_t((rand()%tipmax) + 1) + "_");
    5167}
    5268
Note: See TracChangeset for help on using the changeset viewer.