Ignore:
Timestamp:
1999-10-10T21:14:12+13:00 (25 years ago)
Author:
sjboddie
Message:
  • metadata now returns mp rather than array
  • redesigned browsing support (although it's not finished so

won't currently work ;-)

File:
1 edited

Legend:

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

    r604 r649  
    2828/*
    2929   $Log$
     30   Revision 1.26  1999/10/10 08:14:06  sjboddie
     31   - metadata now returns mp rather than array
     32   - redesigned browsing support (although it's not finished so
     33   won't currently work ;-)
     34
    3035   Revision 1.25  1999/09/17 04:46:05  sjboddie
    3136   fixed a couple of problems with 'unknown' classifier
     
    225230}
    226231
    227 bool documentaction::init (ostream &logout) {
    228 
    229   // classify_meta should contain names of all classifiers supported
    230   // by this receptionist. classifications using metadata names not
    231   // in this list will be displayed as "unknown"
    232   classify_meta.insert ("Title");
    233   classify_meta.insert ("List");
    234   classify_meta.insert ("Creator");
    235   classify_meta.insert ("Series");
    236   classify_meta.insert ("Date");
    237   classify_meta.insert ("Subject");
    238   classify_meta.insert ("Organization");
    239   classify_meta.insert ("Howto");
    240   classify_meta.insert ("Topic");
    241   classify_meta.insert ("Browse");
    242   classify_meta.insert ("People");
    243 
    244   return action::init (logout);
    245 }
    246 
    247232bool documentaction::check_cgiargs (cgiargsinfoclass &argsinfo, cgiargsclass &args,
    248233                    ostream &logout) {
     
    284269
    285270void documentaction::get_cgihead_info (cgiargsclass &/*args*/, response_t &response,
    286                      text_t &response_data, ostream &/*logout*/) {
     271                       text_t &response_data, ostream &/*logout*/) {
    287272  response = content;
    288273  response_data = "text/html";
    289274}
    290275
    291 
    292276// set_widthtspace calculates how wide the spaces in the nav bar should
    293277// be and sets the appropriate macro
    294 void documentaction::set_spacemacro (displayclass &disp, const FilterResponse_t &response) {
     278void documentaction::set_spacemacro (displayclass &disp, FilterResponse_t &response) {
    295279
    296280  text_t width;
     
    298282
    299283  int numc = response.docInfo.size();
    300   ResultDocInfo_tarray::const_iterator dochere = response.docInfo.begin();
    301   ResultDocInfo_tarray::const_iterator docend = response.docInfo.end();
     284  ResultDocInfo_tarray::iterator dochere = response.docInfo.begin();
     285  ResultDocInfo_tarray::iterator docend = response.docInfo.end();
    302286   
    303287  disp.expandstring ("Global", "_pagewidth_", width);
     
    308292 
    309293  while (dochere != docend) {
    310     text_t title = (*dochere).metadata[0].values[0];
    311     text_tset::const_iterator it = classify_meta.find (title);
    312     if (it == classify_meta.end()) title = "Unknown";
     294    const text_t &title = (*dochere).metadata["Title"].values[0];
    313295
    314296    disp.expandstring ("document", "_" + title + "width_", width);
     297    if (width == ("_" + title + "width_"))
     298      disp.expandstring ("document", "_defaultwidth_", width);
    315299    iwidth += width.getint();
    316300    dochere ++;
     
    325309
    326310// set_navbarmacros sets _navigationbar_, _javaimagesnavbar_ and _httpbrowseXXX_ macros
    327 void documentaction::set_navbarmacros (displayclass &disp, const FilterResponse_t &response,
     311// reponse contains 1 metadata field (Title)
     312void documentaction::set_navbarmacros (displayclass &disp, FilterResponse_t &response,
    328313                       cgiargsclass &args) {
    329314
     
    334319  get_top (args["cl"], topparent);
    335320  int numc = response.docInfo.size();
    336   ResultDocInfo_tarray::const_iterator dochere = response.docInfo.begin();
    337   ResultDocInfo_tarray::const_iterator docend = response.docInfo.end();
     321  ResultDocInfo_tarray::iterator dochere = response.docInfo.begin();
     322  ResultDocInfo_tarray::iterator docend = response.docInfo.end();
    338323
    339324  navigationbar += "<nobr>\n";
     
    347332   
    348333  while (dochere != docend) {
    349     text_t title = (*dochere).metadata[0].values[0];
    350     const text_t &classifytype = (*dochere).metadata[1].values[0];
    351 
    352     text_tset::const_iterator it = classify_meta.find (title);
    353     if (it == classify_meta.end()) title = "Unknown";
    354      
     334    text_t title = (*dochere).metadata["Title"].values[0];
     335
     336    bool unknown = false;
     337
     338    // test the _XXXwidth_ macro to see if image macros are
     339    // defined for this type of classification - if not we'll
     340    // just display the text
     341    text_t tmpwidth;
     342    disp.expandstring ("document", "_" + title + "width_", tmpwidth);
     343    if (tmpwidth == ("_" + title + "width_")) unknown = true;
     344
    355345    // if we're inside a document all the classification buttons should be enabled
    356     if (arg_d.empty() && ((*dochere).OID == topparent))
    357       navigationbar += "_imagespacer__icontab" + title + "green_";
    358     else {
    359       navigationbar += "_imagespacer__image" + title + "_";
    360      
     346    if (arg_d.empty() && ((*dochere).OID == topparent)) {
     347      if (unknown) navigationbar += "_imagespacer_&nbsp;" + title + "&nbsp;";
     348      else navigationbar += "_imagespacer__icontab" + title + "green_";
     349    } else {
     350
    361351      // set the _httpbrowseXXX_ macro for this classification
    362       text_t link;
    363       if (classifytype == "HTML")
    364     link = "_httppagex_(html)&hp=" + (*dochere).OID + ".fc";
    365       else
    366     link = "_httpdocument_&cl=" + (*dochere).OID;
    367 
    368       if (classifytype == "AZList" || classifytype == "DateList") link += ".fc";
    369       disp.setmacro ("httpbrowse" + title, "Global", link);
    370      
    371     }
    372     javaimagesnavbar += "_java" + title + "_";
     352      if (unknown) navigationbar += "_imagespacer_&nbsp;<a href=\"_httpdocument_&cl=" +
     353             (*dochere).OID + "\">" + title + "</a>&nbsp;";
     354      else {
     355        navigationbar += "_imagespacer__image" + title + "_";
     356        disp.setmacro ("httpbrowse" + title, "Global", "_httpdocument_&cl=" + (*dochere).OID);
     357      }
     358    }
     359    if (!unknown) javaimagesnavbar += "_java" + title + "_";
    373360    dochere ++;
    374361  }
     
    376363  navigationbar += "<!-- End of Navigation Bar -->\n";
    377364  disp.setmacro ("navigationbar", "Global", navigationbar);
    378   if (args.getintarg("v") == 0) 
     365  if (args.getintarg("v") == 0)
    379366    disp.setmacro ("javaimagesnavbar", "Global", javaimagesnavbar);
    380367}
    381 
    382368
    383369// define all the macros which might be used by other actions
    384370// to produce pages.
    385 void documentaction::define_external_macros (const ColInfoResponse_t &/*collectinfo*/, displayclass &disp,
    386                          cgiargsclass &args, recptproto *collectproto,
    387                          ostream &logout) {
     371void documentaction::define_external_macros (const ColInfoResponse_t &/*collectinfo*/,
     372                         displayclass &disp, cgiargsclass &args,
     373                         recptproto *collectproto, ostream &logout) {
    388374 
    389375  // define_external_macros sets the following macros:
     
    413399  InfoFiltersResponse_t filterinfo;
    414400  FilterResponse_t response;
    415   text_tarray metadata;
     401  text_tset metadata;
    416402  text_t &collection = args["c"];
    417403
     
    424410      if (filterinfo.filterNames.find ("BrowseFilter") != filterinfo.filterNames.end()) {
    425411   
    426     metadata.push_back ("Title");
    427     metadata.push_back ("classifytype");
     412    metadata.insert ("Title");
    428413    bool getParents = false;
    429414    get_children ("", collection, metadata, getParents, collectproto, response, logout);
     
    443428}
    444429
    445 
    446430void documentaction::load_formatinfo (const text_tmap &colformat, int gt) {
    447431
     
    454438    ((*format_here).second == "true"))
    455439      formatinfo.DocumentImages = true;
    456     else if (((*format_here).first == "DocumentTopPages") &&
    457          ((*format_here).second == "false"))
    458       formatinfo.DocumentTopPages = false;
    459440    else if ((*format_here).first == "DocumentHeading")
    460441      formatinfo.DocumentHeading = (*format_here).second;
     
    473454    else if ((*format_here).first == "DocumentText")
    474455      formatinfo.DocumentText = (*format_here).second;
     456    else
     457      formatinfo.formatstrings[(*format_here).first] = (*format_here).second;
    475458
    476459    format_here ++;
     
    522505
    523506
    524 // sets the classificationlinks and navarrows macros
    525 void documentaction::get_classificationlinks (const text_t &arg_cl, const text_t &collection,
    526                           recptproto *collectproto, displayclass &disp,
    527                           ostream &logout) {
    528 
    529   FilterResponse_t response;
    530   text_t classificationlinks, navarrows, classtop;
    531   text_tarray metadata;
    532 
    533   metadata.push_back ("Title");
    534   metadata.push_back ("doctype");
    535   bool getParents = false;
    536 
    537   get_top (arg_cl, classtop);
    538   if (get_children (classtop, collection, metadata, getParents, collectproto, response, logout)) {
    539        
    540     // don't want links unless there are 2 or more sections
    541     if (response.docInfo.size() >= 2) {
    542 
    543       classificationlinks += "<!-- Classification Links -->\n";
    544       classificationlinks += "<table width=_pagewidth_ cellpadding=0 cellspacing=0 border=0>\n";
    545       classificationlinks += "<tr><td valign=top><center>\n";
    546      
    547       ResultDocInfo_tarray::const_iterator sechere = response.docInfo.begin();
    548       ResultDocInfo_tarray::const_iterator secend = response.docInfo.end();
    549      
    550       int lenlinks = 0;
    551       while (sechere != secend) {
    552     if ((*sechere).metadata[1].values[0] == "classify") {
    553       const text_t &sectionheading = (*sechere).metadata[0].values[0];
    554      
    555       if (((*sechere).OID == arg_cl) || is_child_of((*sechere).OID, arg_cl)) {
    556        
    557         // set the _httpprevarrow_, _httpnextarrow_ macros while we're here
    558         if (formatinfo.DocumentArrowsBottom) {
    559           if (sechere != response.docInfo.begin())
    560         disp.setmacro ("httpprevarrow", "document", "_httpdocument_&cl=" + (*(sechere-1)).OID);
    561           if ((sechere + 1) != secend)
    562         disp.setmacro ("httpnextarrow", "document", "_httpdocument_&cl=" + (*(sechere+1)).OID);
    563         }
    564        
    565         lenlinks += sectionheading.size();
    566         classificationlinks += "<b>" + sectionheading + "</b>";
    567         if (lenlinks > 50) {
    568           classificationlinks += "<br>\n";
    569           lenlinks = 0;
    570         } else {
    571           if (sechere+1 != secend) classificationlinks += "&nbsp;&nbsp;&nbsp;\n";
    572           lenlinks += 3;
    573         }
    574       } else {
    575         lenlinks += sectionheading.size();
    576         classificationlinks += "<a href=\"_httpdocument_&cl=" + (*sechere).OID + "\">";
    577         classificationlinks += sectionheading + "</a>";
    578         if (lenlinks > 50) {
    579           classificationlinks += "<br>\n";
    580           lenlinks = 0;
    581         } else {
    582           if (sechere+1 != secend) classificationlinks += "&nbsp;&nbsp;&nbsp;\n";
    583           lenlinks += 3;
    584         }
    585       }
    586     }
    587     sechere ++;
    588       }
    589      
    590       classificationlinks += "\n</center></td></tr></table>\n";
    591       classificationlinks += "<!-- End of Classification Links -->\n";
    592      
    593       disp.setmacro ("classificationlinks", "document", classificationlinks);
    594     }
    595   }
    596 }
    597 
    598 
    599507// define all the macros which are related to pages generated
    600508// by this action. we also load up the formatinfo structure
    601509// here (it's used in do_action as well as here)
    602 void documentaction::define_internal_macros (const ColInfoResponse_t &collectinfo, displayclass &disp,
    603                          cgiargsclass &args, recptproto *collectproto,
    604                          ostream &logout) {
     510void documentaction::define_internal_macros (const ColInfoResponse_t &collectinfo,
     511                         displayclass &disp, cgiargsclass &args,
     512                         recptproto *collectproto, ostream &logout) {
    605513 
    606514  // define_internal_macros sets the following macros:
     
    609517 
    610518  // _imagethispage_        the title image to be displayed at top right of page
    611  
    612   // _classificationlinks_  the links between classifications to be displayed
    613   //                        at top of list or datelist classifications
    614 
    615   // _httpprevarrow_        these are set if next or previous arrows
    616   // _httpnextarrow_        are to be used - (i.e. if it's an AZList or a DateList
    617   //                        classifytype at a top level or if it's a Book or a
    618   //                        Hierarchy classifytype at document level
    619519
    620520  // _navarrows_            this may be overridden to "" when format option
     
    633533  if (collectproto == NULL) return;
    634534 
    635   text_tarray metadata;
     535  text_tset metadata;
    636536  FilterResponse_t response;
    637537  text_t &arg_d = args["d"];
     
    644544    disp.setmacro("navarrows", "document", "");
    645545
    646   metadata.push_back ("Title");
    647   metadata.push_back ("classifytype");
    648   metadata.push_back ("archivedir");
     546  metadata.insert ("Title");
    649547 
    650548  if (!arg_d.empty()) {
    651549    // we're at document level
     550
     551    metadata.insert ("archivedir");
    652552   
    653553    // get metadata for this document and it's parents
     
    655555      disp.setmacro ("header", "document", "_textheader_");
    656556
    657       text_t pagetitle;
    658       if (gt)
    659     pagetitle = *(response.docInfo[0].metadata[0].values.begin());
    660       else {
    661     text_tarray::const_iterator this_title = response.docInfo[0].metadata[0].values.begin();
    662     text_tarray::const_iterator end_title = response.docInfo[0].metadata[0].values.end();
    663     while (this_title != end_title) {
    664       if ((this_title + 1) == end_title) pagetitle += *this_title;
    665       else pagetitle += *this_title + ": ";
    666       this_title ++;
     557      text_t pagetitle = response.docInfo[0].metadata["Title"].values[0];
     558      if (!gt) {
     559    MetadataInfo_t *parent = response.docInfo[0].metadata["Title"].parent;
     560    while (parent != NULL) {
     561      pagetitle += ": " + parent->values[0];
     562      parent = parent->parent;
    667563    }
    668564      }
    669565      disp.setmacro ("pagetitle", "document", pagetitle);
    670       disp.setmacro ("thisOID", "Global", response.docInfo[0].metadata[2].values[0]);
    671 
    672       text_t &classifytype = response.docInfo[0].metadata[1].values[0];
    673       if (classifytype.empty()) classifytype = "Book"; // defaults to Book
    674 
    675       // set arrow macros if required
    676       if (((classifytype == "Book") && (formatinfo.DocumentArrowsTop || formatinfo.DocumentArrowsBottom)) ||
    677       ((classifytype == "Hierarchy") && formatinfo.DocumentArrowsBottom))
    678     set_arrow_macros (arg_d, classifytype, formatinfo.DocumentTopPages,
    679               disp, collectproto, collection, logout);
     566      disp.setmacro ("thisOID", "Global", response.docInfo[0].metadata["archivedir"].values[0]);
    680567     
    681568      if (args["u"] != "1")
     
    691578      if (get_info (classtop, collection, metadata, false, collectproto, response, logout)) {
    692579     
    693     text_t title = response.docInfo[0].metadata[0].values[0];
    694     text_t &classifytype = response.docInfo[0].metadata[1].values[0];
    695 
    696     text_tset::const_iterator it = classify_meta.find (title);
    697     if (it == classify_meta.end()) title = "Unknown";
    698 
    699     disp.setmacro ("pagetitle", "document", "_text" + title + "page_");
    700     disp.setmacro ("imagethispage", "document", "_icon" + title + "page_");
    701 
    702     // now get the metadata for each child of top level
    703     // so we can generate the _classificationlinks_ and arrow macros
    704     // (if they're required by the current classification type)
    705    
    706     if ((classifytype == "AZList") || (classifytype == "DateList"))
    707       get_classificationlinks (arg_cl, collection, collectproto, disp, logout);
    708      
     580    text_t &title = response.docInfo[0].metadata["Title"].values[0];
     581    bool unknown = false;
     582
     583    // test the _XXXwidth_ macro to see if image macros are
     584    // defined for this type of classification - if not we'll
     585    // just display the text
     586    text_t tmp;
     587    disp.expandstring ("document", "_" + title + "width_", tmp);
     588    if (tmp == ("_" + title + "width_")) unknown = true;
     589
     590    if (unknown) {
     591      disp.setmacro ("pagetitle", "document", title);
     592      disp.setmacro ("imagethispage", "document", "<h2>" + title + "</h2>");
     593    } else {
     594      disp.setmacro ("pagetitle", "document", "_text" + title + "page_");
     595      disp.setmacro ("imagethispage", "document", "_icon" + title + "page_");
     596    }
    709597      }
    710598    }
     
    713601
    714602
    715 bool documentaction::do_action (cgiargsclass &args, const ColInfoResponse_t &collectinfo,
     603bool documentaction::do_action (cgiargsclass &args, const ColInfoResponse_t &/*collectinfo*/,
    716604                recptproto *collectproto, displayclass &disp,
    717605                outconvertclass &outconvert, ostream &textout,
     
    725613  } else { 
    726614
    727     text_tarray metadata;
    728     FilterResponse_t response;
    729     text_t toptitle, toptype, thistype, formatstring;
    730 
    731     text_t &collection = args["c"];
    732     text_t &arg_d = args["d"];
    733     text_t &arg_cl = args["cl"];
    734    
    735     text_t OID = arg_d;
    736     if (arg_d.empty()) OID = arg_cl;
    737    
     615    text_t OID = args["d"];
     616    if (OID.empty()) OID = args["cl"];
     617    if (OID.empty()) {
     618      textout << outconvert << disp << "Document contains no data_document:footer_\n";
     619      return true;
     620    }
     621
    738622    textout << outconvert << disp << "_document:header_\n"
    739623        << "_document:content_\n";
    740624   
    741     if (arg_d.empty() && arg_cl.empty()) {
    742       textout << outconvert << disp << "Document contains no data_document:footer_\n";
    743       return true;
    744     }
    745    
    746     // get the classifytitle and classifytype for both the top level
    747     // and the current level (using getParent=true)
    748     metadata.push_back ("Title");
    749     metadata.push_back ("classifytype");
    750     if (get_info (OID, collection, metadata, true, collectproto, response, logout)) {
    751       toptitle = response.docInfo[0].metadata[0].values[0];
    752       toptype = response.docInfo[0].metadata[1].values[0];
    753       thistype = response.docInfo[0].metadata[1].values.back();
    754     }
    755 
    756     text_t formatkey = toptype + toptitle;
    757     if (!arg_d.empty()) formatkey = toptype + "Document";
    758 
    759     text_tmap::const_iterator it = collectinfo.format.find(formatkey);
    760     if (it != collectinfo.format.end()) formatstring = (*it).second;
    761 
    762625    // output the table of contents
    763     if (!arg_d.empty()) {
    764      
    765       if (toptype == "Hierarchy")
    766     output_standard_toc (thistype, formatinfo, formatstring, args,
    767                  collectproto, disp, outconvert, textout, logout);
    768 
    769       else
    770     output_document_toc (args, formatinfo, collectproto, disp,
    771                  outconvert, textout, logout);
    772 
    773     } else {
    774       output_standard_toc (thistype, formatinfo, formatstring, args,
    775                collectproto, disp, outconvert, textout, logout);
    776     }
     626    output_toc (args, recpt->get_browsermap_ptr(), formatinfo,
     627        collectproto, disp, outconvert, textout, logout);
    777628
    778629    // output the document text
     
    785636}
    786637
    787 void documentaction::output_text (const ResultDocInfo_t &docinfo, format_t *formatlistptr,
     638void documentaction::output_text (ResultDocInfo_t &docinfo, format_t *formatlistptr,
    788639                  const TermInfo_tarray &terminfo, const text_t &OID,
    789                   bool highlight, const text_t &hastxt, int wanttext,
    790                   text_t &collection, recptproto *collectproto, displayclass &disp,
    791                   outconvertclass &outconvert, ostream &textout,
    792                   ostream &logout) {
     640                  bool highlight, int hastxt, int wanttext,
     641                  text_t &collection, recptproto *collectproto,
     642                  displayclass &disp, outconvertclass &outconvert,
     643                  ostream &textout, ostream &logout) {
    793644 
    794645  DocumentRequest_t docrequest;
     
    796647  comerror_t err;
    797648
    798   if (hastxt == "1") {
     649  if (hastxt == 1) {
    799650
    800651    if (wanttext) {
     
    830681  FilterResponse_t inforesponse;
    831682  FilterResponse_t queryresponse;
    832   text_tarray metadata;
     683  text_tset metadata;
    833684  bool getParents = false;
    834685  bool highlight = false;
     
    849700  parse_formatstring (formatinfo.DocumentText, formatlistptr, metadata, getParents);
    850701
    851   metadata.push_back("hastxt");
    852   metadata.push_back("haschildren");
     702  metadata.insert ("hastxt");
     703  metadata.insert ("haschildren");
    853704 
    854705  if (formatinfo.DocumentText == "[Text]")
     
    864715
    865716  if (get_info (OID, collection, metadata, getParents, collectproto, inforesponse, logout)) {
    866     text_t hastxt = inforesponse.docInfo[0].metadata[metasize-2].values.back();
    867     text_t &haschildren = inforesponse.docInfo[0].metadata[metasize-1].values.back();
     717    int hastxt = inforesponse.docInfo[0].metadata["hastxt"].values[0].getint();
     718    int haschildren = inforesponse.docInfo[0].metadata["haschildren"].values[0].getint();
    868719
    869720    if (arg_gt == 0) {
     
    879730      // text is to be expanded
    880731      text_t exOID = OID;
    881       if (haschildren != "1") exOID = get_parent (OID);
     732      if (haschildren != 1) exOID = get_parent (OID);
    882733      if (exOID.empty()) exOID = OID;
    883734   
    884735      // if we're not in a document (i.e. we're in a top level classification)
    885       // we need to pass the "classify" string to get_contents so that it
     736      // we need to pass "is_classify = true" to get_contents so that it
    886737      // doesn't recurse all the way through each document in the classification
    887       text_t classifytype;
    888       if (args["d"].empty()) classifytype = "classify";
    889 
    890       int i = 0; // not used
    891       get_contents (exOID, classifytype, metadata, i, collection,
     738      bool is_classify = false;
     739      if (args["d"].empty()) is_classify = true;
     740
     741      get_contents (exOID, is_classify, metadata, collection,
    892742            collectproto, inforesponse, logout);
    893743   
    894       ResultDocInfo_tarray::const_iterator sechere = inforesponse.docInfo.begin();
    895       ResultDocInfo_tarray::const_iterator secend = inforesponse.docInfo.end();
     744      ResultDocInfo_tarray::iterator sechere = inforesponse.docInfo.begin();
     745      ResultDocInfo_tarray::iterator secend = inforesponse.docInfo.end();
    896746   
    897747      if (arg_gt == 1) {
     
    902752    int seccount = 0;
    903753    while (sechere != secend) {
    904       const text_t &shastxt = (*sechere).metadata[metasize-2].values.back();
    905       if (shastxt == "1") seccount ++;
     754      int shastxt = (*sechere).metadata["hastxt"].values[0].getint();
     755      if (shastxt == 1) seccount ++;
    906756      if (seccount > 10) break;
    907757      sechere ++;
     
    927777      textout << outconvert << disp << "\n<p><a name=" << count << "></a>\n";
    928778
    929       const text_t &shastxt = (*sechere).metadata[metasize-2].values.back();
     779      int shastxt = (*sechere).metadata["hastxt"].values[0].getint();
    930780
    931781      output_text (*sechere, formatlistptr, queryresponse.termInfo,
Note: See TracChangeset for help on using the changeset viewer.