Ignore:
Timestamp:
1999-08-20T13:00:22+12:00 (25 years ago)
Author:
sjboddie
Message:

split some of the larger functions up to simplify the creation of
collection specific receptionists

File:
1 edited

Legend:

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

    r450 r464  
    1212/*
    1313   $Log$
     14   Revision 1.22  1999/08/20 01:00:22  sjboddie
     15   split some of the larger functions up to simplify the creation of
     16   collection specific receptionists
     17
    1418   Revision 1.21  1999/08/11 23:28:03  sjboddie
    1519   -added support for html classifier
     
    373377
    374378
    375 // define all the macros which are related to pages generated
    376 // by this action. we also load up the formatinfo structure
    377 // here (it's used in do_action as well as here)
    378 void documentaction::define_internal_macros (const ColInfoResponse_t &collectinfo, displayclass &disp,
    379                          cgiargsclass &args, recptproto *collectproto,
    380                          ostream &logout) {
    381 
    382   // define_internal_macros sets the following macros:
    383 
    384   // _pagetitle_            the title to be displayed at the top of the browser window
    385  
    386   // _imagethispage_        the title image to be displayed at top right of page
    387 
    388   // _classificationlinks_  the links between classifications to be displayed
    389   //                        at top of list or datelist classifications
    390 
    391   // _httpprevarrow_        these are set if next or previous arrows
    392   // _httpnextarrow_        are to be used - (i.e. if it's an AZList or a DateList
    393   //                        classifytype at a top level or if it's a Book or a
    394   //                        Hierarchy classifytype at document level
    395 
    396   // _navarrows_            this may be overridden to "" when format option
    397   //                        DocumentArrowsBottom is false
    398 
    399   // _header_               the header macro is overridden if we're not at a top level
    400   //                        classification to remove the title block
    401 
    402   // _javaimagescontent_    this is the javascript code to shove in to make the
    403   //                        flashy buttons work
    404 
    405   // _thisOID_              the OID (directory) of the current document - this corresponds
    406   //                        to the archivedir metadata element
    407 
    408   // can't do anything if collectproto is null (i.e. no collection was specified)
    409   if (collectproto == NULL) return;
    410 
    411   // load up formatinfo
     379void documentaction::load_formatinfo (const text_tmap &colformat, int gt) {
     380
    412381  formatinfo.clear();
    413   text_tmap::const_iterator format_here = collectinfo.format.begin();
    414   text_tmap::const_iterator format_end = collectinfo.format.end();
     382  text_tmap::const_iterator format_here = colformat.begin();
     383  text_tmap::const_iterator format_end = colformat.end();
    415384
    416385  while (format_here != format_end) {
     
    441410  }
    442411
     412  // never want arrows when text is expanded
     413  if (gt) {
     414    formatinfo.DocumentArrowsBottom = false;
     415    formatinfo.DocumentArrowsTop = false;
     416  }
     417}
     418
     419void documentaction::set_java_macros (cgiargsclass &args, displayclass &disp) {
     420
     421  text_t javaimagescontent = "_javaextras_";
     422   
     423  int arg_gt = args.getintarg("gt");
     424  int arg_gc = args.getintarg("gc");
     425  int arg_hl = args.getintarg("hl");
     426
     427  text_tarray::const_iterator button_here = formatinfo.DocumentButtons.begin();
     428  text_tarray::const_iterator button_end = formatinfo.DocumentButtons.end();
     429
     430  while (button_here != button_end) {
     431    if (*button_here == "Detach")
     432      javaimagescontent += "_javadetach_";
     433    else if (*button_here == "Expand Text") {
     434      if (arg_gt == 1)
     435    javaimagescontent += "_javacontracttext__javacontinue_";
     436      else if (arg_gt == 2)
     437    javaimagescontent += "_javacontracttext_";
     438      else
     439    javaimagescontent += "_javaexpandtext_";
     440    } else if (*button_here == "Expand Contents") {
     441      if (arg_gc == 1)
     442    javaimagescontent += "_javacontractcontents_";
     443      else
     444    javaimagescontent += "_javaexpandcontents_";
     445    } else if (*button_here == "Highlight") {
     446      if (arg_hl == 1)
     447    javaimagescontent += "_javanohighlighting_";
     448      else
     449    javaimagescontent += "_javahighlighting_";
     450    }
     451    button_here ++;
     452  }
     453  disp.setmacro ("javaimagescontent", "document", javaimagescontent);
     454}
     455
     456
     457// sets the classificationlinks and navarrows macros
     458void documentaction::get_classificationlinks (const text_t &arg_cl, const text_t &collection,
     459                          recptproto *collectproto, displayclass &disp,
     460                          ostream &logout) {
     461
     462  FilterResponse_t response;
     463  text_t classificationlinks, navarrows, classtop;
     464  text_tarray metadata;
     465
     466  metadata.push_back ("Title");
     467  metadata.push_back ("doctype");
     468  bool getParents = false;
     469
     470  get_top (arg_cl, classtop);
     471  if (get_children (classtop, collection, metadata, getParents, collectproto, response, logout)) {
     472       
     473    // don't want links unless there are 2 or more sections
     474    if (response.docInfo.size() >= 2) {
     475
     476      classificationlinks += "<!-- Classification Links -->\n";
     477      classificationlinks += "<table width=_pagewidth_ cellpadding=0 cellspacing=0 border=0>\n";
     478      classificationlinks += "<tr><td valign=top><center>\n";
     479     
     480      ResultDocInfo_tarray::const_iterator sechere = response.docInfo.begin();
     481      ResultDocInfo_tarray::const_iterator secend = response.docInfo.end();
     482     
     483      int lenlinks = 0;
     484      while (sechere != secend) {
     485    if ((*sechere).metadata[1].values[0] == "classify") {
     486      const text_t &sectionheading = (*sechere).metadata[0].values[0];
     487     
     488      if (((*sechere).OID == arg_cl) || is_child_of((*sechere).OID, arg_cl)) {
     489       
     490        // set the _httpprevarrow_, _httpnextarrow_ macros while we're here
     491        if (formatinfo.DocumentArrowsBottom) {
     492          if (sechere != response.docInfo.begin())
     493        disp.setmacro ("httpprevarrow", "document", "_httpdocument_&cl=" + (*(sechere-1)).OID);
     494          if ((sechere + 1) != secend)
     495        disp.setmacro ("httpnextarrow", "document", "_httpdocument_&cl=" + (*(sechere+1)).OID);
     496        }
     497       
     498        lenlinks += sectionheading.size();
     499        classificationlinks += "<b>" + sectionheading + "</b>";
     500        if (lenlinks > 50) {
     501          classificationlinks += "<br>\n";
     502          lenlinks = 0;
     503        } else {
     504          if (sechere+1 != secend) classificationlinks += "&nbsp;&nbsp;&nbsp;\n";
     505          lenlinks += 3;
     506        }
     507      } else {
     508        lenlinks += sectionheading.size();
     509        classificationlinks += "<a href=\"_httpdocument_&cl=" + (*sechere).OID + "\">";
     510        classificationlinks += sectionheading + "</a>";
     511        if (lenlinks > 50) {
     512          classificationlinks += "<br>\n";
     513          lenlinks = 0;
     514        } else {
     515          if (sechere+1 != secend) classificationlinks += "&nbsp;&nbsp;&nbsp;\n";
     516          lenlinks += 3;
     517        }
     518      }
     519    }
     520    sechere ++;
     521      }
     522     
     523      classificationlinks += "\n</center></td></tr></table>\n";
     524      classificationlinks += "<!-- End of Classification Links -->\n";
     525     
     526      disp.setmacro ("classificationlinks", "document", classificationlinks);
     527    }
     528  }
     529}
     530
     531
     532// define all the macros which are related to pages generated
     533// by this action. we also load up the formatinfo structure
     534// here (it's used in do_action as well as here)
     535void documentaction::define_internal_macros (const ColInfoResponse_t &collectinfo, displayclass &disp,
     536                         cgiargsclass &args, recptproto *collectproto,
     537                         ostream &logout) {
     538 
     539  // define_internal_macros sets the following macros:
     540 
     541  // _pagetitle_            the title to be displayed at the top of the browser window
     542 
     543  // _imagethispage_        the title image to be displayed at top right of page
     544 
     545  // _classificationlinks_  the links between classifications to be displayed
     546  //                        at top of list or datelist classifications
     547
     548  // _httpprevarrow_        these are set if next or previous arrows
     549  // _httpnextarrow_        are to be used - (i.e. if it's an AZList or a DateList
     550  //                        classifytype at a top level or if it's a Book or a
     551  //                        Hierarchy classifytype at document level
     552
     553  // _navarrows_            this may be overridden to "" when format option
     554  //                        DocumentArrowsBottom is false
     555
     556  // _header_               the header macro is overridden if we're not at a top level
     557  //                        classification to remove the title block
     558
     559  // _javaimagescontent_    this is the javascript code to shove in to make the
     560  //                        flashy buttons work
     561
     562  // _thisOID_              the OID (directory) of the current document - this corresponds
     563  //                        to the archivedir metadata element
     564
     565  // can't do anything if collectproto is null (i.e. no collection was specified)
     566  if (collectproto == NULL) return;
     567 
    443568  text_tarray metadata;
    444569  FilterResponse_t response;
     
    446571  text_t &arg_cl = args["cl"];
    447572  text_t &collection = args["c"];
     573  int gt = args.getintarg("gt");
     574  load_formatinfo (collectinfo.format, gt);
    448575
    449576  if (!formatinfo.DocumentArrowsBottom)
     
    456583  if (!arg_d.empty()) {
    457584    // we're at document level
    458     text_t javaimagescontent;
    459 
     585   
    460586    // get metadata for this document and it's parents
    461587    if (get_info (arg_d, collection, metadata, true, collectproto, response, logout)) {
     
    463589
    464590      text_t pagetitle;
    465       if (args.getintarg("gt") == 2)
     591      if (gt)
    466592    pagetitle = *(response.docInfo[0].metadata[0].values.begin());
    467593      else {
     
    486612              disp, collectproto, collection, logout);
    487613     
    488      
    489       if (args["u"] != "1") {
    490     javaimagescontent = "_javaextras_";
    491    
    492     int arg_gt = args.getintarg("gt");
    493     int arg_gc = args.getintarg("gc");
    494     int arg_hl = args.getintarg("hl");
    495 
    496     text_tarray::const_iterator button_here = formatinfo.DocumentButtons.begin();
    497     text_tarray::const_iterator button_end = formatinfo.DocumentButtons.end();
    498 
    499     while (button_here != button_end) {
    500       if (*button_here == "Detach")
    501         javaimagescontent += "_javadetach_";
    502       else if (*button_here == "Expand Text") {
    503         if (arg_gt == 1)
    504           javaimagescontent += "_javacontracttext__javacontinue_";
    505         else if (arg_gt == 2)
    506           javaimagescontent += "_javacontracttext_";
    507         else
    508           javaimagescontent += "_javaexpandtext_";
    509       } else if (*button_here == "Expand Contents") {
    510           if (arg_gc == 1)
    511         javaimagescontent += "_javacontractcontents_";
    512           else
    513         javaimagescontent += "_javaexpandcontents_";
    514       } else if (*button_here == "Highlight") {
    515         if (arg_hl == 1)
    516           javaimagescontent += "_javanohighlighting_";
    517         else
    518           javaimagescontent += "_javahighlighting_";
    519       }
    520       button_here ++;
    521     }
    522     disp.setmacro ("javaimagescontent", "document", javaimagescontent);
    523       }
     614      if (args["u"] != "1")
     615    set_java_macros (args, disp);
     616
    524617    }
    525618  } else {
     
    535628
    536629    disp.setmacro ("pagetitle", "document", "_text" + title + "page_");
    537 
    538630    disp.setmacro ("imagethispage", "document", "_icon" + title + "page_");
    539631
     
    542634    // (if they're required by the current classification type)
    543635   
    544     if ((classifytype == "AZList") || (classifytype == "DateList")) {
    545      
    546       text_t classificationlinks, navarrows;
    547       text_t link = "<a href=\"_httpdocument_&cl=";
    548 
    549       metadata.erase(metadata.begin(), metadata.end());
    550       metadata.push_back ("Title");
    551       metadata.push_back ("doctype");
    552       bool getParents = false;
    553       if (get_children (classtop, collection, metadata, getParents, collectproto, response, logout)) {
    554        
    555         // don't want links unless there are 2 or more sections
    556         if (response.docInfo.size() >= 2) {
    557          
    558           classificationlinks += "<!-- Classification Links -->\n";
    559           classificationlinks += "<table width=_pagewidth_ cellpadding=0 cellspacing=0 border=0>\n";
    560           classificationlinks += "<tr><td valign=top><center>\n";
    561          
    562           ResultDocInfo_tarray::const_iterator sechere = response.docInfo.begin();
    563           ResultDocInfo_tarray::const_iterator secend = response.docInfo.end();
    564          
    565           int lenlinks = 0;
    566           while (sechere != secend) {
    567         if ((*sechere).metadata[1].values[0] == "classify") {
    568           const text_t &sectionheading = (*sechere).metadata[0].values[0];
    569 
    570           if (((*sechere).OID == arg_cl) || is_child_of((*sechere).OID, arg_cl)) {
    571            
    572             // set the _httpprevarrow_, _httpnextarrow_ macros while we're here
    573             if (formatinfo.DocumentArrowsBottom) {
    574               if (sechere != response.docInfo.begin())
    575             disp.setmacro ("httpprevarrow", "document", "_httpdocument_&cl=" + (*(sechere-1)).OID);
    576               if ((sechere + 1) != secend)
    577             disp.setmacro ("httpnextarrow", "document", "_httpdocument_&cl=" + (*(sechere+1)).OID);
    578             }
    579 
    580             lenlinks += sectionheading.size();
    581             classificationlinks += "<b>" + sectionheading + "</b>";
    582             if (lenlinks > 50) {
    583               classificationlinks += "<br>\n";
    584               lenlinks = 0;
    585             } else {
    586               if (sechere+1 != secend) classificationlinks += "&nbsp;&nbsp;&nbsp;\n";
    587               lenlinks += 3;
    588             }
    589           } else {
    590             lenlinks += sectionheading.size();
    591             classificationlinks += link + (*sechere).OID + "\">";
    592             classificationlinks += sectionheading + "</a>";
    593             if (lenlinks > 50) {
    594               classificationlinks += "<br>\n";
    595               lenlinks = 0;
    596             } else {
    597               if (sechere+1 != secend) classificationlinks += "&nbsp;&nbsp;&nbsp;\n";
    598               lenlinks += 3;
    599             }
    600           }
    601         }
    602         sechere ++;
    603           }
    604          
    605           classificationlinks += "\n</center></td></tr></table>\n";
    606           classificationlinks += "<!-- End of Classification Links -->\n";
    607          
    608           disp.setmacro ("classificationlinks", "document", classificationlinks);
    609         }
    610       }
    611     }
     636    if ((classifytype == "AZList") || (classifytype == "DateList"))
     637      get_classificationlinks (arg_cl, collection, collectproto, disp, logout);
     638     
    612639      }
    613640    }
    614641  }
    615642}
     643
    616644
    617645bool documentaction::do_action (cgiargsclass &args, const ColInfoResponse_t &collectinfo,
Note: See TracChangeset for help on using the changeset viewer.