Ignore:
Timestamp:
1999-06-24T17:12:25+12:00 (25 years ago)
Author:
sjboddie
Message:

lots of small changes

File:
1 edited

Legend:

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

    r282 r284  
    1212/*
    1313   $Log$
     14   Revision 1.8  1999/06/24 05:12:20  sjboddie
     15   lots of small changes
     16
    1417   Revision 1.7  1999/06/17 03:06:58  sjboddie
    1518   got detach button working properly - the close book icon is now disabled
     
    148151}
    149152
    150 bool documentaction::check_cgiargs (cgiargsinfoclass &/*argsinfo*/, cgiargsclass &/*args*/,
    151                     ostream &/*logout*/) {
    152   // don't want to check anything yet.
     153bool documentaction::check_cgiargs (cgiargsinfoclass &argsinfo, cgiargsclass &args,
     154                    ostream &logout) {
     155
     156  // note that "gp" argument gets checked in define_external_macros()
     157
     158  // check gc argument
     159  int arg_gc = args.getintarg("gc");
     160  if (arg_gc != 0 && arg_gc != 1) {
     161    logout << "Warning: \"gc\" argument out of range (" << arg_gc << ")\n";
     162    cgiarginfo *gcinfo = argsinfo.getarginfo ("gc");
     163    if (gcinfo != NULL) args["gc"] = gcinfo->argdefault;
     164  }
     165
     166  // check gt argument (may be either 0, 1 or 2)
     167  int arg_gt = args.getintarg("gt");
     168  if (arg_gt != 0 && arg_gt != 1 && arg_gt != 2) {
     169    logout << "Warning: \"gt\" argument out of range (" << arg_gt << ")\n";
     170    cgiarginfo *gtinfo = argsinfo.getarginfo ("gt");
     171    if (gtinfo != NULL) args["gt"] = gtinfo->argdefault;
     172  }
     173
     174  // check hl argument
     175  int arg_hl = args.getintarg("hl");
     176  if (arg_hl != 0 && arg_hl != 1) {
     177    logout << "Warning: \"hl\" argument out of range (" << arg_hl << ")\n";
     178    cgiarginfo *hlinfo = argsinfo.getarginfo ("hl");
     179    if (hlinfo != NULL) args["hl"] = hlinfo->argdefault;
     180  }
     181
     182  // check x argument
     183  int arg_x = args.getintarg("x");
     184  if (arg_x != 0 && arg_x != 1) {
     185    logout << "Warning: \"x\" argument out of range (" << arg_x << ")\n";
     186    cgiarginfo *xinfo = argsinfo.getarginfo ("x");
     187    if (xinfo != NULL) args["x"] = xinfo->argdefault;
     188  }
     189
    153190  return true;
    154191}
     
    380417
    381418      text_t pagetitle;
    382       text_tarray::const_iterator this_title = response.docInfo[0].metadata[0].values.begin();
    383       text_tarray::const_iterator end_title = response.docInfo[0].metadata[0].values.end();
    384       while (this_title != end_title) {
    385     if ((this_title + 1) == end_title) pagetitle += *this_title;
    386     else pagetitle += *this_title + ": ";
    387     this_title ++;
     419      if (args.getintarg("gt") == 2)
     420    pagetitle = *(response.docInfo[0].metadata[0].values.begin());
     421      else {
     422    text_tarray::const_iterator this_title = response.docInfo[0].metadata[0].values.begin();
     423    text_tarray::const_iterator end_title = response.docInfo[0].metadata[0].values.end();
     424    while (this_title != end_title) {
     425      if ((this_title + 1) == end_title) pagetitle += *this_title;
     426      else pagetitle += *this_title + ": ";
     427      this_title ++;
     428    }
    388429      }
    389430      disp.setmacro ("pagetitle", "document", pagetitle);
     
    423464    text_t &classifytype = response.docInfo[0].metadata[1].values[0];
    424465
    425     disp.setmacro ("imagethispage", "document",
    426                "_icon" + title + "page_");
     466    disp.setmacro ("pagetitle", "document", "_text" + title + "page_");
     467
     468    disp.setmacro ("imagethispage", "document", "_icon" + title + "page_");
    427469
    428470    // now get the metadata for each child of top level
     
    495537    text_tarray metadata;
    496538    FilterResponse_t response;
    497     FilterResponse_t queryresponse;
    498     DocumentRequest_t docrequest;
    499     DocumentResponse_t docresponse;
    500539    text_t topparent, classifytype, classifytitle;
    501     comerror_t err;
    502     bool highlight = false;
    503540   
    504541    text_t &arg_d = args["d"];
    505542    text_t &arg_cl = args["cl"];
    506     text_t &collection = args["c"];
    507543   
    508544    text_t OID = arg_d;
     
    515551      textout << outconvert << disp << "Document contains no data_document:footer_\n";
    516552      return true;
    517     }
    518    
    519     // if we have a query string and highlighting is turned on we need
    520     // to redo the query to get the terms for highlighting
    521     if (!args["q"].empty() && args.getintarg("hl")) {
    522       FilterRequest_t request;
    523       text_t quotedstring; // don't use this here
    524       request.filterResultOptions = FRmatchTerms;
    525       if (do_query (request, args, collectproto, quotedstring, queryresponse, logout))
    526     highlight = true;
    527553    }
    528554   
     
    531557    metadata.push_back ("Title");
    532558    metadata.push_back ("classifytype");
    533     if (get_info (topparent, collection, metadata, false, collectproto, response, logout)) {
     559    if (get_info (topparent, args["c"], metadata, false, collectproto, response, logout)) {
    534560      classifytitle = response.docInfo[0].metadata[0].values[0];
    535561      classifytype = response.docInfo[0].metadata[1].values[0];
    536562    }
    537563   
     564    // output the table of contents
    538565    if (!arg_d.empty()) {
    539566     
     
    542569                  outconvert, textout, logout);
    543570      else
    544     // Book is the default for a document level toc - AZList and Datelist don't
    545     // make sense for document level
     571    // Book is the default for a document level toc - AZList, List and
     572    // Datelist don't make sense for document level
    546573    output_book_toc (classifytitle, args, collectproto, disp,
    547574             outconvert, textout, logout);
     
    554581    output_datelist_toc (classifytitle, args, collectproto, disp,
    555582                 outconvert, textout, logout);
     583      else if (classifytype == "List")
     584    output_list_toc (classifytitle, args, collectproto, disp,
     585             outconvert, textout, logout);
    556586      else
    557587    // AZList is the default for a classification level toc - Book doesn't make
     
    560590               outconvert, textout, logout);
    561591    }
    562    
    563     // get info on this document
    564     metadata.erase (metadata.begin(), metadata.end());
    565     metadata.push_back("Title");
    566     metadata.push_back("hastxt");
    567     metadata.push_back("haschildren");
    568    
    569     if (get_info (OID, collection, metadata, false, collectproto, response, logout)) {
    570       text_t &title = response.docInfo[0].metadata[0].values[0];
    571       int hastxt = response.docInfo[0].metadata[1].values[0].getint();
    572       int haschildren = response.docInfo[0].metadata[2].values[0].getint();
     592
     593    // output the document text
     594    output_document (OID, args, collectproto, disp, outconvert, textout, logout);
     595
     596    textout << outconvert << disp << "_document:footer_\n";
     597  }
     598  return true;
     599}
     600
     601
     602void documentaction::output_document (const text_t &OID, cgiargsclass &args,
     603                      recptproto *collectproto, displayclass &disp,
     604                      outconvertclass &outconvert, ostream &textout,
     605                      ostream &logout) {
     606  FilterResponse_t inforesponse;
     607  DocumentRequest_t docrequest;
     608  DocumentResponse_t docresponse;
     609  FilterResponse_t queryresponse;
     610  comerror_t err;
     611  text_tarray metadata;
     612  bool highlight = false;
     613  int arg_gt = args.getintarg("gt");
     614  text_t &collection = args["c"];
     615   
     616  // if we have a query string and highlighting is turned on we need
     617  // to redo the query to get the terms for highlighting
     618  if (!args["q"].empty() && args.getintarg("hl")) {
     619    FilterRequest_t request;
     620    request.filterResultOptions = FRmatchTerms;
     621    text_t quotedquery; // not used
     622    if (do_query (request, args, collectproto, quotedquery, queryresponse, logout))
     623      highlight = true;
     624  }
     625
     626  // get info on this document
     627  metadata.push_back("Title");
     628  metadata.push_back("hastxt");
     629  metadata.push_back("haschildren");
     630   
     631  if (get_info (OID, collection, metadata, false, collectproto, inforesponse, logout)) {
     632    text_t title = inforesponse.docInfo[0].metadata[0].values[0];
     633    int hastxt = inforesponse.docInfo[0].metadata[1].values[0].getint();
     634    int haschildren = inforesponse.docInfo[0].metadata[2].values[0].getint();
    573635     
    574       int gt = args.getintarg("gt");
    575       if (gt == 0) {
    576     if (hastxt == 1) {
    577       // get the text
     636    if (arg_gt == 0) {
     637      if (hastxt == 1) {
     638    // get the text
     639    docrequest.OID = OID;
     640    collectproto->get_document (collection, docrequest, docresponse, err, logout);
     641     
     642    textout << outconvert << disp << "<p>\n<h3>" << title << "</h3>";
     643      if (highlight)
     644        highlighttext(docresponse.doc, queryresponse.termInfo, disp,
     645              outconvert, textout, logout);
     646      else
     647        textout << outconvert << disp << docresponse.doc;
     648      }
     649    } else {
     650   
     651      // text is to be expanded
     652      text_t exOID = OID;
     653      if (!haschildren) exOID = get_parent (OID);
     654   
     655      // if we're not in a document (i.e. we're in a top level classification)
     656      // we need to pass the "classify" string to get_contents so that it
     657      // doesn't recurse all the way through each document in the classification
     658      text_t classifytype;
     659      if (args["d"].empty()) classifytype = "classify";
     660
     661      int i; // not used
     662      get_contents (exOID, classifytype, i, collection, collectproto, inforesponse, logout);
     663   
     664      ResultDocInfo_tarray::const_iterator sechere = inforesponse.docInfo.begin();
     665      ResultDocInfo_tarray::const_iterator secend = inforesponse.docInfo.end();
     666   
     667      if (arg_gt == 1) {
     668    // check if there are more than 10 sections containing text to be expanded -
     669    // if there are output warning message - this isn't a great way to do this
     670    // since the sections may be very large or very small - one day I'll fix it
     671    // -- Stefan.
     672    int seccount = 0;
     673    while (sechere != secend) {
     674      if ((*sechere).metadata[3].values[0] == "1") seccount ++;
     675      if (seccount > 10) break;
     676      sechere ++;
     677    }
     678    if (seccount > 10) {
     679      // more than 10 sections so output warning message and text
     680      // for current section only
     681      textout << outconvert << disp << "_document:textltwarning_";
    578682      docrequest.OID = OID;
    579683      collectproto->get_document (collection, docrequest, docresponse, err, logout);
     
    586690        textout << outconvert << disp << docresponse.doc;
    587691    }
    588       } else {
    589    
    590     // text is to be expanded
    591     int tmp; // this doesn't get used here
    592     if (!haschildren)
    593       OID = get_parent (OID);
    594    
    595     get_contents (OID, classifytype, tmp, collection, collectproto, response, logout);
    596    
    597     ResultDocInfo_tarray::const_iterator sechere = response.docInfo.begin();
    598     ResultDocInfo_tarray::const_iterator secend = response.docInfo.end();
    599    
    600     if (gt == 1) {
    601       // check if there are more than 10 sections containing text to be expanded -
    602       // if there are output warning message - this isn't a great way to do this
    603       // since the sections may be very large or very small - one day I'll fix it
    604       // -- Stefan.
    605       int seccount = 0;
    606       while (sechere != secend) {
    607         if ((*sechere).metadata[3].values[0] == "1") seccount ++;
    608         if (seccount > 10) break;
    609         sechere ++;
     692    else arg_gt = 2;
     693      }
     694
     695      if (arg_gt == 2) {
     696    // get the text for each section
     697    sechere = inforesponse.docInfo.begin();
     698    int count = 0;
     699    while (sechere != secend) {
     700      textout << outconvert << disp << "\n<p><a name=" << count << "><h3>"
     701          << (*sechere).metadata[0].values[0] << "</h3></a>\n";
     702      if ((*sechere).metadata[3].values[0] == "1") {
     703        docrequest.OID = (*sechere).OID;
     704        collectproto->get_document (collection, docrequest, docresponse, err, logout);
     705        if (highlight)
     706          highlighttext(docresponse.doc, queryresponse.termInfo, disp,
     707                outconvert, textout, logout);
     708        else
     709          textout << outconvert << disp << docresponse.doc;
    610710      }
    611       if (seccount > 10) textout << outconvert << disp << "_document:textltwarning_";
    612       else gt = 2;
     711      count ++;
     712      sechere ++;
    613713    }
    614 
    615     if (gt == 2) {
    616     // get the text for each section
    617       sechere = response.docInfo.begin();
    618       int count = 0;
    619       while (sechere != secend) {
    620         textout << outconvert << disp << "\n<p><a name=" << count << "><h3>"
    621             << (*sechere).metadata[0].values[0] << "</h3></a>\n";
    622         if ((*sechere).metadata[3].values[0] == "1") {
    623           docrequest.OID = (*sechere).OID;
    624           collectproto->get_document (collection, docrequest, docresponse, err, logout);
    625           if (highlight)
    626         highlighttext(docresponse.doc, queryresponse.termInfo, disp,
    627                   outconvert, textout, logout);
    628           else
    629         textout << outconvert << disp << docresponse.doc;
    630         }
    631         count ++;
    632         sechere ++;
    633       }
    634     }
    635       }
    636     }
    637     textout << outconvert << disp << "_document:footer_\n";
    638   }
    639   return true;
    640 }
    641 
     714      }
     715    }
     716  }
     717}
    642718
    643719// highlighttext highlights query terms in text string and outputs the resulting text string
Note: See TracChangeset for help on using the changeset viewer.