Ignore:
Timestamp:
1999-03-01T09:00:19+13:00 (25 years ago)
Author:
rjmcnab
Message:

Fixed a few things.

File:
1 edited

Legend:

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

    r172 r173  
    1212/*
    1313   $Log$
     14   Revision 1.9  1999/02/28 20:00:16  rjmcnab
     15
     16
     17   Fixed a few things.
     18
    1419   Revision 1.8  1999/02/25 21:58:59  rjmcnab
    1520
     
    334339  action *a = actions.getaction (args["a"]);
    335340  if (a != NULL) {
     341    if (a->uses_display(args)) prepare_page (a, args, collectproto, disp, logout);
    336342    if (!a->do_action (args, collectproto, disp, (*outconverter), contentout, logout))
    337343      return false;
     
    543549  return true;
    544550}
     551
     552// prepare_page sets up page parameters, sets display macros
     553// and opens the page ready for output
     554void receptionist::prepare_page (action *a, cgiargsclass &args, recptproto */*collectproto*/,
     555                 displayclass &disp, ostream &logout) {
     556 
     557  // set up page parameters
     558  text_t pageparams;
     559
     560  bool first = true;
     561  if (!args["c"].empty()) {
     562    pageparams +=  "collection=" + args["c"]; first = false;}
     563  if (args.getintarg("u") == 1)
     564    if (first) {pageparams += "style=htmlonly"; first = false;}
     565    else pageparams += ",style=htmlonly";
     566  if (args.getintarg("v") == 1)
     567    if (first) {pageparams += "version=text"; first = false;}
     568    else pageparams += ",version=text";
     569  if (args.getintarg("f") == 1)
     570    if (first) {pageparams += ",queryversion=big"; first = false;}
     571    else pageparams += ",queryversion=big";
     572  if (args["l"] != "en")
     573    if (first) pageparams += ",language=" + args["l"];
     574    else pageparams += ",language=" + args["l"];
     575 
     576  // open the page
     577  disp.openpage(pageparams, MACROPRECEDENCE);
     578
     579
     580  // define general macros
     581  define_general_macros (disp, args, logout);
     582
     583 
     584  // define external macros for each action
     585  actionptrmap::iterator actionhere = actions.begin ();
     586  actionptrmap::iterator actionend = actions.end ();
     587
     588  while (actionhere != actionend) {
     589    assert ((*actionhere).second.a != NULL);
     590    if ((*actionhere).second.a != NULL)
     591      (*actionhere).second.a->define_external_macros (disp, args, logout);
     592    actionhere++;
     593  }
     594
     595
     596  // define internal macros for the current action
     597  a->define_internal_macros (disp, args, logout);
     598}
     599
     600void receptionist::define_general_macros (displayclass &disp, cgiargsclass &args,
     601                      ostream &/*logout*/) {
     602
     603  disp.setmacro ("gwcgi", "Global", configinfo.gwcgi);
     604  disp.setmacro ("httpimg", "Global", configinfo.httpimg);
     605  disp.setmacro("compressedoptions", "Global", get_compressed_arg(args));
     606
     607  // set _cgiargX_ macros for each cgi argument
     608  cgiargsclass::const_iterator argshere = args.begin();
     609  cgiargsclass::const_iterator argsend = args.end();
     610  while (argshere != argsend) {
     611    disp.setmacro ("cgiarg" + (*argshere).first, "Global", (*argshere).second);
     612    argshere ++;
     613  }
     614}
Note: See TracChangeset for help on using the changeset viewer.