Changeset 870

Show
Ignore:
Timestamp:
26.01.2000 11:39:16 (20 years ago)
Author:
sjboddie
Message:

added DocumentUseHTML - tidied some things up (and messed up some others)

Location:
trunk/gsdl/src/recpt
Files:
2 modified

Legend:

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

    r781 r870  
    2828/* 
    2929   $Log$ 
     30   Revision 1.32  2000/01/25 22:39:15  sjboddie 
     31   added DocumentUseHTML - tidied some things up (and messed up some others) 
     32 
    3033   Revision 1.31  1999/11/13 08:57:00  sjboddie 
    3134   fixed bug in last changes 
     
    250253  arg_ainfo.defaultstatus = cgiarginfo::weak; 
    251254  arg_ainfo.argdefault = "0"; 
     255  arg_ainfo.savedarginfo = cgiarginfo::must; 
     256  argsinfo.addarginfo (NULL, arg_ainfo); 
     257 
     258  // f arg is set to 1 if document is to  
     259  // be displayed in a frame 
     260  arg_ainfo.shortname = "f"; 
     261  arg_ainfo.longname = "frame"; 
     262  arg_ainfo.multiplechar = false; 
     263  arg_ainfo.defaultstatus = cgiarginfo::weak; 
     264  arg_ainfo.argdefault = "0"; 
     265  arg_ainfo.savedarginfo = cgiarginfo::mustnot; 
     266  argsinfo.addarginfo (NULL, arg_ainfo); 
     267 
     268  // fc arg is "1" if search bar is to be included (i.e. if "fc" == 1 
     269  // the httpdocument macro will include "&f=1" 
     270  arg_ainfo.shortname = "fc"; 
     271  arg_ainfo.longname = "include search bar"; 
     272  arg_ainfo.multiplechar = false; 
     273  arg_ainfo.defaultstatus = cgiarginfo::weak; 
     274  arg_ainfo.argdefault = "1"; 
    252275  arg_ainfo.savedarginfo = cgiarginfo::must; 
    253276  argsinfo.addarginfo (NULL, arg_ainfo); 
     
    444467  //                     bar 
    445468   
     469  // _httpdocument_      has '&f=1' added if displaying document inside a frame 
     470 
     471  // _gsdltop_           macro to replace _top targets with 
     472 
     473  // _httppagehome_      overridden home url if html collections have own homepage 
    446474 
    447475  // must have a valid collection server to continue 
     
    456484  FilterResponse_t response; 
    457485  text_tset metadata; 
     486 
     487 
     488  // get info on current collection and load up formatinfo 
     489  // I'd prefer not to do this here as we're getting  
     490  // collection info every time (and probably also getting 
     491  // it in other places some of the time) - One day I'll 
     492  // fix it ... maybe - Stefan. 
     493  ColInfoResponse_t cinfo; 
     494  collectproto->get_collectinfo (collection, cinfo, err, logout); 
     495  load_formatinfo (cinfo.format, args.getintarg("gt")); 
     496 
     497  if (formatinfo.DocumentUseHTML) { 
     498 
     499    // frame stuff 
     500    if (args["fc"] == "1") { 
     501      text_t httpdocument; 
     502      disp.expandstring ("Global", "_httpdocument_", httpdocument); 
     503      httpdocument += "&f=1"; 
     504      disp.setmacro ("httpdocument", "Global", httpdocument); 
     505      disp.setmacro ("gsdltop", "Global", "documenttop"); 
     506    } 
     507    text_tmap::iterator it = cinfo.format.find ("homepage"); 
     508    if (it != cinfo.format.end()) { 
     509      text_t httppagehome; 
     510      if (get_link (args, protos, (*it).second, httppagehome, logout)) 
     511    disp.setmacro ("httppagehome", "Global", httppagehome); 
     512    }  
     513  } 
    458514 
    459515  // don't want navigation bar if page is 'detached' 
     
    481537    } 
    482538  } 
     539} 
     540 
     541bool documentaction::get_link (cgiargsclass &args, recptprotolistclass *protos, 
     542                   const text_t &inlink, text_t &outlink, ostream &logout) { 
     543 
     544  FilterResponse_t response; 
     545  text_tset metadata; 
     546  metadata.insert ("section"); 
     547   
     548  // check current collection first 
     549  recptproto *collectproto = protos->getrecptproto (args["c"], logout); 
     550 
     551  if (get_info (inlink, args["c"], metadata, false, collectproto, response, logout)) { 
     552    if (!response.docInfo[0].metadata["section"].values[0].empty()) { 
     553      outlink = "_httpdocument_&d=" + response.docInfo[0].metadata["section"].values[0]; 
     554      return true; 
     555    } 
     556  } 
     557 
     558  // check all the other enabled collections 
     559 
     560  if (args["ccs"] == "1" && !args["cc"].empty()) { 
     561    text_tarray collections; 
     562    splitchar (args["cc"].begin(), args["cc"].end(), ',', collections); 
     563     
     564    text_tarray::const_iterator col_here = collections.begin(); 
     565    text_tarray::const_iterator col_end = collections.end(); 
     566 
     567    while (col_here != col_end) { 
     568       
     569      // don't need to check current collection again 
     570      if (*col_here == args["c"]) {col_here ++; continue;} 
     571       
     572      collectproto = protos->getrecptproto (*col_here, logout); 
     573       
     574      if (get_info (inlink, *col_here, metadata, false, collectproto, response, logout)) { 
     575    if (!response.docInfo[0].metadata["section"].values[0].empty()) { 
     576      outlink = "_httpdocument_&c=" + *col_here + "&d=" + 
     577        response.docInfo[0].metadata["section"].values[0]; 
     578      return true; 
     579    } 
     580      } 
     581      col_here ++; 
     582    } 
     583  } 
     584  return false; 
    483585} 
    484586 
     
    509611    else if ((*format_here).first == "DocumentText")  
    510612      formatinfo.DocumentText = (*format_here).second; 
     613    else if (((*format_here).first == "DocumentUseHTML") &&  
     614         ((*format_here).second == "true")) 
     615      formatinfo.DocumentUseHTML = true; 
    511616    else  
    512617      formatinfo.formatstrings[(*format_here).first] = (*format_here).second; 
    513  
     618     
    514619    format_here ++; 
    515620  } 
    516621 
    517622  // never want arrows when text is expanded 
    518   if (gt) 
    519     formatinfo.DocumentArrowsBottom = false; 
     623  if (gt) formatinfo.DocumentArrowsBottom = false; 
    520624} 
    521625 
     
    582686  //                        to the archivedir metadata element 
    583687 
    584  
    585688  // must have a valid collection server to continue 
    586689  text_t &collection = args["c"]; 
     
    593696  text_t &arg_d = args["d"]; 
    594697  text_t &arg_cl = args["cl"]; 
    595   int gt = args.getintarg("gt"); 
    596  
    597   // get info on current collection and load up formatinfo 
    598   ColInfoResponse_t cinfo; 
    599   comerror_t err; 
    600   collectproto->get_collectinfo (collection, cinfo, err, logout); 
    601   load_formatinfo (cinfo.format, gt); 
    602698 
    603699  if (!formatinfo.DocumentArrowsBottom) 
     
    628724      if (!response.docInfo[0].metadata["Title"].values[0].empty()) 
    629725    pagetitlearray.push_back (response.docInfo[0].metadata["Title"].values[0]); 
    630       if (!gt) { 
     726      if (args["gt"] != "1") { 
    631727    MetadataInfo_t *parenttitle = response.docInfo[0].metadata["Title"].parent; 
    632728    while (parenttitle != NULL) { 
     
    710806    } 
    711807 
     808    if (formatinfo.DocumentUseHTML) { 
     809       
     810      if (!args["d"].empty()) { 
     811    if (args["f"] == "1") { 
     812      textout << outconvert << disp  
     813          << "<html><head></head>\n" 
     814          << "<frameset rows=\"68,*\" noresize border=0>\n" 
     815          << "<frame scrolling=no frameborder=0 src=\"_gwcgi_?e=_compressedoptions_&a=p&p=nav\">\n" 
     816          << "<frame name=\"documenttop\" frameborder=0 src=\"_gwcgi_?e=_compressedoptions_&a=d&d="  
     817          << args["d"] << "\">" 
     818          << "<noframes>\n" 
     819          << "<p>You must have a frame enabled browser to view this.</p>\n" 
     820          << "</noframes>\n" 
     821          << "</frameset>\n" 
     822          << "</html>\n"; 
     823    } else { 
     824      output_document (OID, args, collectproto, disp, outconvert, textout, logout);  
     825    } 
     826    return true; 
     827      } 
     828    } 
     829 
    712830    textout << outconvert << disp << "_document:header_\n" 
    713831        << "_document:content_\n"; 
    714      
     832       
    715833    // output the table of contents 
    716834    output_toc (args, browsers, formatinfo, collectproto,  
    717835        disp, outconvert, textout, logout); 
    718  
     836     
    719837    // output the document text 
    720838    textout << "<p>\n"; 
  • trunk/gsdl/src/recpt/documentaction.h

    r758 r870  
    4040 
    4141  receptionist *recpt; 
     42 
     43  bool get_link (cgiargsclass &args, recptprotolistclass *protos, 
     44         const text_t &inlink, text_t &outlink, ostream &logout); 
    4245 
    4346  void load_formatinfo (const text_tmap &colformat, int gt);