Changeset 438 for trunk/gsdl/src/recpt


Ignore:
Timestamp:
1999-08-09T16:25:19+12:00 (25 years ago)
Author:
sjboddie
Message:

moved OID translation stuff from documentaction::define_external_macros
to receptionist

Location:
trunk/gsdl/src/recpt
Files:
4 edited

Legend:

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

    r437 r438  
    1212/*
    1313   $Log$
     14   Revision 1.18  1999/08/09 04:25:18  sjboddie
     15   moved OID translation stuff from documentaction::define_external_macros
     16   to receptionist
     17
    1418   Revision 1.17  1999/08/09 02:13:53  sjboddie
    1519   fixed small bug in ShowSectionTitles
     
    230234// define all the macros which might be used by other actions
    231235// to produce pages.
    232 void documentaction::define_external_macros (const ColInfoResponse_t &collectinfo, displayclass &disp,
     236void documentaction::define_external_macros (const ColInfoResponse_t &/*collectinfo*/, displayclass &disp,
    233237                         cgiargsclass &args, recptproto *collectproto,
    234238                         ostream &logout) {
     
    248252  // _javaimagesnavbar_  this is the javascript code to shove in to make the
    249253  //                     flashy images used by _navigationbar_ work
    250 
    251   // _cgiargd_           these are overridden if they use the tricky ".xx" syntax
    252   // _cgiargcl_
    253254 
     255
    254256  // can't do anything if collectproto is null (i.e. no collection was specified)
    255257  if (collectproto == NULL) return;
     
    259261  InfoFiltersResponse_t filterinfo;
    260262  FilterResponse_t response;
    261   FilterRequest_t request;
    262263  text_tarray metadata;
    263264  text_t navigationbar, javaimagesnavbar, width, topparent;
     
    267268  text_t &arg_cl = args["cl"];
    268269  text_t &collection = args["c"];
    269 
    270   // if the "gp" (go to page) argument is set we need to set
    271   // the "d" argument to the corresponding page
    272   if ((!arg_d.empty()) && (!args["gp"].empty()) &&
    273       (is_number (args["gp"]))) {
    274     text_t top;
    275     get_top (arg_d, top);
    276     metadata.push_back ("Title");
    277     bool getParents = false;
    278     get_children (top, collection, metadata, getParents, collectproto, response, logout);
    279     ResultDocInfo_tarray::const_iterator dochere = response.docInfo.begin();
    280     ResultDocInfo_tarray::const_iterator docend = response.docInfo.end();
    281     while (dochere != docend) {
    282       if ((*dochere).metadata[0].values[0] == args["gp"]) {
    283     arg_d = (*dochere).OID;
    284     disp.setmacro ("cgiargd", "Global", arg_d);
    285     break;
    286       }
    287       dochere ++;
    288     }
    289     metadata.erase (metadata.begin(), metadata.end());
    290   }
    291 
    292   bool ShowTopPages = true;
    293   text_tmap::const_iterator it = collectinfo.format.find("ShowTopPages");
    294   if ((it != collectinfo.format.end()) && ((*it).second == "false")) ShowTopPages = false;
    295 
    296   // do a call to translate OIDs if required
    297   request.filterName = "NullFilter";
    298   request.filterResultOptions = FROID;
    299   if ((!arg_d.empty()) && (needs_translating (arg_d) || !ShowTopPages)) {
    300     request.docSet.insert (arg_d);
    301     request.fields.push_back ("classifytype");
    302     request.filterResultOptions = FRmetadata;
    303     request.getParents = true;
    304     collectproto->filter (collection, request, response, err, logout);
    305     arg_d = response.docInfo[0].OID;
    306    
    307     text_t &classifytype = response.docInfo[0].metadata[0].values[0];
    308     if (classifytype.empty() || classifytype == "book")
    309       if (!ShowTopPages && is_top (arg_d)) arg_d += ".fc";
    310    
    311     request.clear();
    312     disp.setmacro ("cgiargd", "Global", arg_d);
    313   }
    314   // we'll also check here that the "cl" argument has a "classify" doctype
    315   // (in case ".fc" or ".lc" have screwed up)
    316   if (needs_translating (arg_cl)) {
    317     request.fields.push_back("doctype");
    318     request.docSet.insert (arg_cl);
    319     request.filterResultOptions = FRmetadata;
    320     collectproto->filter (collection, request, response, err, logout);
    321     // set to original value (without .xx stuff) if doctype isn't "classify"
    322     if (response.docInfo[0].metadata[0].values[0] != "classify")
    323       strip_suffix (arg_cl);
    324     else
    325       arg_cl = response.docInfo[0].OID;
    326     disp.setmacro ("cgiargcl", "Global", arg_cl);
    327   }
    328270
    329271  // don't want navigation bar if page is 'detached'
  • trunk/gsdl/src/recpt/documentaction.h

    r431 r438  
    1616#include "action.h"
    1717#include "gsdlconf.h"
     18#include "formattools.h"
    1819
    1920class documentaction : public action {
     
    2829  void highlighttext(text_t &text, TermInfo_tarray &terms, displayclass &disp,
    2930             outconvertclass &outconvert, ostream &textout, ostream &logout);
     31
     32  formatinfo_t formatinfo;
     33 
    3034
    3135public:
  • trunk/gsdl/src/recpt/receptionist.cpp

    r418 r438  
    1212/*
    1313   $Log$
     14   Revision 1.21  1999/08/09 04:25:17  sjboddie
     15   moved OID translation stuff from documentaction::define_external_macros
     16   to receptionist
     17
    1418   Revision 1.20  1999/07/30 02:13:09  sjboddie
    1519   -added collectinfo argument to some functions
     
    503507  // decide on the protocol used for communicating with
    504508  // the collection server
     509  text_t &collection = args["c"];
    505510  recptproto *collectproto = NULL;
    506   if (!args["c"].empty()) {
    507     collectproto = protocols.getrecptproto (args["c"], logout);
    508   }
     511  if (!collection.empty()) {
     512    collectproto = protocols.getrecptproto (collection, logout);
     513  }
     514
     515  // translate "d" and "cl" arguments if required
     516  translate_OIDs (args, collectproto, logout);
    509517
    510518  // produce the page using the desired action
     
    647655
    648656  return true;
     657}
     658
     659// translate_OIDs translates the "d" and "cl" arguments to their correct values
     660// if they use the tricky ".fc", ".lc" type syntax. also sorts out the "d" argument
     661// if the goto page ("gp") argument was used
     662void receptionist::translate_OIDs (cgiargsclass &args, recptproto *collectproto, ostream &logout) {
     663
     664  FilterResponse_t response;
     665  FilterRequest_t request;
     666  comerror_t err;
     667  text_t &arg_d = args["d"];
     668  text_t &arg_cl = args["cl"];
     669  text_t &collection = args["c"];
     670  text_t &arg_gp = args["gp"];
     671
     672  bool ShowTopPages = true;
     673  text_tmap::const_iterator it = collectinfo.format.find("ShowTopPages");
     674  if ((it != collectinfo.format.end()) && ((*it).second == "false")) ShowTopPages = false;
     675 
     676  // do a call to translate OIDs if required
     677  request.filterName = "NullFilter";
     678  request.filterResultOptions = FROID;
     679  if ((!arg_d.empty()) && (needs_translating (arg_d) || !ShowTopPages)) {
     680    request.docSet.insert (arg_d);
     681    request.fields.push_back ("classifytype");
     682    request.filterResultOptions = FRmetadata;
     683    request.getParents = true;
     684    collectproto->filter (collection, request, response, err, logout);
     685    arg_d = response.docInfo[0].OID;
     686   
     687    text_t &classifytype = response.docInfo[0].metadata[0].values[0];
     688    if (classifytype.empty() || classifytype == "Book")
     689      if (!ShowTopPages && is_top (arg_d)) arg_d += ".fc";
     690   
     691    request.clear();
     692  }
     693  // we'll also check here that the "cl" argument has a "classify" doctype
     694  // (in case ".fc" or ".lc" have screwed up)
     695  if (needs_translating (arg_cl)) {
     696    request.fields.push_back("doctype");
     697    request.docSet.insert (arg_cl);
     698    request.filterResultOptions = FRmetadata;
     699    collectproto->filter (collection, request, response, err, logout);
     700    // set to original value (without .xx stuff) if doctype isn't "classify"
     701    if (response.docInfo[0].metadata[0].values[0] != "classify")
     702      strip_suffix (arg_cl);
     703    else
     704      arg_cl = response.docInfo[0].OID;
     705  }
     706
     707  // if the "gp" (go to page) argument is set we need to set
     708  // the "d" argument to the corresponding page
     709  if ((!arg_d.empty()) && (!arg_gp.empty()) && (is_number (arg_gp))) {
     710    text_t top;
     711    get_top (arg_d, top);
     712    text_tarray metadata;
     713    metadata.push_back ("Title");
     714    bool getParents = false;
     715    get_children (top, collection, metadata, getParents, collectproto, response, logout);
     716    ResultDocInfo_tarray::const_iterator dochere = response.docInfo.begin();
     717    ResultDocInfo_tarray::const_iterator docend = response.docInfo.end();
     718    while (dochere != docend) {
     719      if ((*dochere).metadata[0].values[0] == arg_gp) {
     720    arg_d = (*dochere).OID;
     721    break;
     722      }
     723      dochere ++;
     724    }
     725  }
    649726}
    650727
  • trunk/gsdl/src/recpt/receptionist.h

    r418 r438  
    5454  virtual void prepare_page (action *a, cgiargsclass &args, recptproto *collectproto,
    5555                 outconvertclass &outconvert, ostream &logout);
     56 
     57  virtual void translate_OIDs (cgiargsclass &args, recptproto *collectproto, ostream &logout);
     58
    5659  virtual void define_general_macros (cgiargsclass &args, outconvertclass &outconvert,
    5760                      ostream &logout);
Note: See TracChangeset for help on using the changeset viewer.