Ignore:
Timestamp:
1999-05-10T15:40:44+12:00 (25 years ago)
Author:
sjboddie
Message:

lots of changes - slowly getting document action sorted out

File:
1 edited

Legend:

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

    r248 r257  
    1212/*
    1313   $Log$
     14   Revision 1.2  1999/05/10 03:40:35  sjboddie
     15   lots of changes - slowly getting document action sorted out
     16
    1417   Revision 1.1  1999/04/30 01:59:40  sjboddie
    1518   lots of stuff - getting documentaction working (documentaction replaces
     
    3437documentaction::documentaction () {
    3538  // this action uses cgi variables "a", "d", "cl",
    36   // "x", "gc", and "gt"
     39  // "x", "gc", "gt", "gp", and "hl"
    3740  cgiarginfo arg_ainfo;
    3841  arg_ainfo.shortname = "a";
     
    7174
    7275  // in this action "gt" controls the expand/contract
    73   // text function
     76  // text function 0 = not expanded, 1 = expand unless
     77  // there are more than 10 sections containing text,
     78  // 2 = expand all
    7479  arg_ainfo.shortname = "gt";
    7580  arg_ainfo.longname = "expand text";
     
    8893  arg_ainfo.argdefault = "";
    8994  arg_ainfo.savedarginfo = cgiarginfo::mustnot;
     95  argsinfo.addarginfo (NULL, arg_ainfo);
     96
     97  // in this action "hl" is the "highlighting on/
     98  // highlighting off control
     99  arg_ainfo.shortname = "hl";
     100  arg_ainfo.longname = "highlighting on/off";
     101  arg_ainfo.multiplechar = false;
     102  arg_ainfo.defaultstatus = cgiarginfo::weak;
     103  arg_ainfo.argdefault = "1";
     104  arg_ainfo.savedarginfo = cgiarginfo::must;
    90105  argsinfo.addarginfo (NULL, arg_ainfo);
    91106
     
    199214     
    200215      metadata.push_back ("Title");
     216      metadata.push_back ("classifytype");
    201217      get_children ("", args["c"], metadata, collectproto, response, logout);
    202218
     
    236252    dochere = response.docInfo.begin();
    237253    while (dochere != docend) {
     254      const text_t &title = (*dochere).metadata[0].values[0];
     255      const text_t &classifytype = (*dochere).metadata[1].values[0];
     256
    238257      // if we're inside a document all the classification buttons should be enabled
    239258      if (args["d"].empty() && ((*dochere).OID == topparent))
    240         navigationbar += "_imagespacer__icontab" + (*dochere).metadata[0].values[0] + "green_";
     259        navigationbar += "_imagespacer__icontab" + title + "green_";
    241260      else {
    242         navigationbar += "_imagespacer__image" + (*dochere).metadata[0].values[0] + "_";
     261        navigationbar += "_imagespacer__image" + title + "_";
    243262
    244263        // set the _httpbrowseXXX_ macro for this classification
    245         disp.setmacro ("httpbrowse" + (*dochere).metadata[0].values[0],
    246                "Global", "_httpdocument_&cl=" + (*dochere).OID + ".fc");
     264        text_t link = (*dochere).OID;
     265        if (classifytype == "AZList" || classifytype == "Datelist") link += ".fc";
     266        disp.setmacro ("httpbrowse" + title, "Global",
     267               "_httpdocument_&cl=" + link);
    247268      }
    248       javaimagesnavbar += "_java" + (*dochere).metadata[0].values[0] + "_";
     269      javaimagesnavbar += "_java" + title + "_";
    249270      dochere ++;
    250271    }
     
    277298
    278299  // _httpprevarrow_        these are set if next or previous arrows
    279   // _httpnextarrow_        are to be used - (i.e. if it's a List or a Datelist
     300  // _httpnextarrow_        are to be used - (i.e. if it's an AZList or a Datelist
    280301  //                        classifytype at a top level or if it's a Book or a
    281302  //                        Hierarchy classifytype at document level
     
    283304  // _header_               the header macro is overridden if we're not at a top level
    284305  //                        classification to remove the title block
     306
     307  // _javaimagescontent_     this is the javascript code to shove in to make the
     308  //                         flashy buttons work
     309
    285310 
    286311  text_tarray metadata;
     
    292317  if (!args["d"].empty()) {
    293318    // we're at document level
     319    text_t javaimagescontent;
    294320
    295321    // get metadata for top level of document
    296     text_t doctop = args["d"];
    297     text_t classifytype;
     322    text_t doctop;
    298323    get_top (args["d"], doctop);
    299324    if (get_info (doctop, args["c"], metadata, collectproto, response, logout)) {
    300325      disp.setmacro ("header", "document", "_textheader_");
    301       classifytype = response.docInfo[0].metadata[1].values[0];
     326      text_t &classifytype = response.docInfo[0].metadata[1].values[0];
    302327      if (classifytype.empty()) classifytype = "Book"; // defaults to Book
    303328      if ((classifytype == "Book") || (classifytype == "Hierarchy"))
    304329    set_arrow_macros (args["d"], classifytype, disp, collectproto, args["c"], logout);
     330
     331      if (args["u"] != "1") {
     332    javaimagescontent += "_javadetach_";
     333    if (args["gt"] == "1")
     334      javaimagescontent += "_javacontracttext__javacontinue_";
     335    else
     336      javaimagescontent += "_javaexpandtext_";
     337    if (classifytype == "Hierarchy")
     338      if (args["gc"] == "1")
     339        javaimagescontent += "_javacontractcontents_";
     340      else
     341        javaimagescontent += "_javaexpandcontents_";
     342    if (args["hl"] != "1")
     343      javaimagescontent += "_javahighlighting_";
     344    else
     345      javaimagescontent += "_javanohighlighting_";
     346    disp.setmacro ("javaimagescontent", "document", javaimagescontent);
     347      }
    305348    }
    306349  } else {
     
    308351   
    309352      // get metadata for top level classification
    310       text_t classtop = args["cl"];
     353      text_t classtop;
    311354      get_top (args["cl"], classtop);
    312355      if (get_info (classtop, args["c"], metadata, collectproto, response, logout)) {
    313356     
     357    text_t &title = response.docInfo[0].metadata[0].values[0];
     358    text_t &classifytype = response.docInfo[0].metadata[1].values[0];
     359
    314360    disp.setmacro ("imagethispage", "document",
    315                "_icon" + response.docInfo[0].metadata[0].values[0] + "page_");
     361               "_icon" + title + "page_");
    316362
    317363    // now get the metadata for each child of top level
     
    319365    // (if they're required by the current classification type)
    320366   
    321     if ((response.docInfo[0].metadata[1].values[0] == "List") ||
    322         (response.docInfo[0].metadata[1].values[0] == "Datelist")) {
     367    if ((classifytype == "AZList") || (classifytype == "Datelist")) {
    323368     
    324369      text_t classificationlinks, navarrows;
     
    378423  text_tarray metadata;
    379424  FilterResponse_t response;
     425  DocumentRequest_t docrequest;
     426  DocumentResponse_t docresponse;
    380427  text_t topparent, classifytype, classifytitle;
     428  comerror_t err;
     429
     430  text_t &arg_d = args["d"];
     431  text_t &arg_cl = args["cl"];
     432  text_t &collection = args["c"];
     433
     434  text_t OID = arg_d;
     435  if (arg_d.empty()) OID = arg_cl;
    381436
    382437  textout << outconvert << disp << "_document:header_\n"
    383438      << "_document:content_\n";
    384439 
    385   if (args["d"].empty() && args["cl"].empty())
    386     textout << outconvert << "Document contains no data\n";
    387   else {
    388 
    389     if (!args["d"].empty()) get_top (args["d"], topparent);
    390     else get_top (args["cl"], topparent);
    391 
    392     // get the classifytitle and classifytype
    393     metadata.push_back ("Title");
    394     metadata.push_back ("classifytype");
    395     if (get_info (topparent, args["c"], metadata, collectproto, response, logout)) {
    396       classifytitle = response.docInfo[0].metadata[0].values[0];
    397       classifytype = response.docInfo[0].metadata[1].values[0];
     440  if (arg_d.empty() && arg_cl.empty()) {
     441    textout << outconvert << "Document contains no data_document:footer_\n";
     442    return true;
     443  }
     444
     445  // get the classifytitle and classifytype
     446  get_top (OID, topparent);
     447  metadata.push_back ("Title");
     448  metadata.push_back ("classifytype");
     449  if (get_info (topparent, collection, metadata, collectproto, response, logout)) {
     450    classifytitle = response.docInfo[0].metadata[0].values[0];
     451    classifytype = response.docInfo[0].metadata[1].values[0];
     452  }
     453
     454  if (!arg_d.empty()) {
     455   
     456    if (classifytype == "Hierarchy")
     457      output_hierarchy_toc (classifytitle, args, collectproto, disp,
     458                outconvert, textout, logout);
     459    else
     460      // Book is the default for a document level toc - AZList and Datelist don't
     461      // make sense for document level
     462      output_book_toc (classifytitle, args, collectproto, disp,
     463               outconvert, textout, logout);
     464  } else {
     465   
     466    if (classifytype == "Hierarchy")
     467      output_hierarchy_toc (classifytitle, args, collectproto, disp,
     468                outconvert, textout, logout);
     469    else if (classifytype == "Datelist")
     470      output_datelist_toc (classifytitle, args, collectproto, disp,
     471               outconvert, textout, logout);
     472    else
     473      // AZList is the default for a classification level toc - Book doesn't make
     474      // sense for classification level
     475      output_azlist_toc (classifytitle, args, collectproto, disp,
     476             outconvert, textout, logout);
     477  }
     478
     479  // get info on this document
     480  metadata.erase (metadata.begin(), metadata.end());
     481  metadata.push_back("Title");
     482  metadata.push_back("hastxt");
     483  metadata.push_back("haschildren");
     484
     485  if (get_info (OID, collection, metadata, collectproto, response, logout)) {
     486    text_t &title = response.docInfo[0].metadata[0].values[0];
     487    int hastxt = response.docInfo[0].metadata[1].values[0].getint();
     488    int haschildren = response.docInfo[0].metadata[2].values[0].getint();
     489
     490    int gt = args.getintarg("gt");
     491    if (gt == 0) {
     492      if (hastxt == 1) {
     493    // get the text
     494    docrequest.OID = OID;
     495    collectproto->get_document (collection, docrequest, docresponse, err, logout);
     496   
     497    textout << outconvert << disp
     498        << "<p>\n<h3>" << title << "</h3>" << docresponse.doc;
     499      }
     500    } else {
     501
     502      // text is to be expanded
     503      int tmp; // this doesn't get used here
     504      if (!haschildren)
     505    OID = get_parent (OID);
     506
     507      get_contents (OID, classifytype, tmp, collection, collectproto, response, logout);
     508         
     509      ResultDocInfo_tarray::const_iterator sechere = response.docInfo.begin();
     510      ResultDocInfo_tarray::const_iterator secend = response.docInfo.end();
     511         
     512      if (gt == 1) {
     513    // check if there are more than 10 sections containing text to be expanded -
     514    // if there are output warning message - this isn't a great way to do this
     515    // since the sections may be very large or very small - one day I'll fix it
     516    // -- Stefan.
     517    int seccount = 0;
     518    while (sechere != secend) {
     519      if ((*sechere).metadata[3].values[0] == "1") seccount ++;
     520      if (seccount > 10) break;
     521      sechere ++;
     522    }
     523    if (seccount > 10) textout << outconvert << disp << "_document:textltwarning_";
     524    else gt = 2;
     525      }
     526
     527      if (gt == 2) {
     528    // get the text for each section
     529    sechere = response.docInfo.begin();
     530    int count = 0;
     531    while (sechere != secend) {
     532      textout << outconvert << disp << "\n<p><a name=" << count << "><h3>"
     533          << (*sechere).metadata[0].values[0] << "</h3></a>\n";
     534      if ((*sechere).metadata[3].values[0] == "1") {
     535        docrequest.OID = (*sechere).OID;
     536        collectproto->get_document (collection, docrequest, docresponse, err, logout);
     537        textout << outconvert << disp << docresponse.doc;
     538      }
     539      count ++;
     540      sechere ++;
     541    }
     542      }
    398543    }
    399 
    400     if (!args["d"].empty()) {
    401 
    402       if (classifytype == "Hierarchy")
    403     output_hierarchy_toc (classifytitle, args, collectproto, disp,
    404                   outconvert, textout, logout);
    405       else
    406     // Book is the default for a document level toc - List and Datelist don't
    407     // make sense for document level
    408     output_book_toc (classifytitle, args, collectproto, disp,
    409              outconvert, textout, logout);
    410     } else {
    411 
    412       if (classifytype == "Hierarchy")
    413     output_hierarchy_toc (classifytitle, args, collectproto, disp,
    414                   outconvert, textout, logout);
    415       else if (classifytype == "Datelist")
    416     output_datelist_toc (classifytitle, args, collectproto, disp,
    417                  outconvert, textout, logout);
    418       else
    419     // List is the default for a classification level toc - Book doesn't make
    420     // sense for classification level
    421     output_list_toc (classifytitle, args, collectproto, disp,
    422              outconvert, textout, logout);
    423     }
    424 
    425544  }
    426545  textout << outconvert << disp << "_document:footer_\n";
Note: See TracChangeset for help on using the changeset viewer.