Changeset 1941

Show
Ignore:
Timestamp:
09.02.2001 15:41:33 (19 years ago)
Author:
jmt14
Message:

Modified files:

browsetools.cpp documentaction.cpp formattools.cpp
formattools.h

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

Legend:

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

    r1860 r1941  
    121121} 
    122122 
     123//this function outputs the related documents in the format specified  
     124//in the collection configuration file if the collection preferences 
     125//indicate they wish related documents to be displayed. 
     126void output_related_docs (cgiargsclass &args, recptproto *collectproto,  
     127              formatinfo_t &formatinfo, displayclass &disp,  
     128              outconvertclass &outconvert, ostream &textout,  
     129              ostream &logout) { 
     130 
     131  if (args["d"].empty()) return; //if no OID 
     132  if (args["rd"] != "1") return; //if preferences say no related documents 
     133   
     134  text_tset metadata; 
     135  bool getParents; 
     136  FilterResponse_t response; 
     137 
     138  //create new format pointer and parse the related doc format  
     139  //string specified in the collection config file 
     140  format_t *formatlistptr = new format_t(); 
     141  parse_formatstring (formatinfo.RelatedDocuments, formatlistptr, metadata, getParents); 
     142 
     143  if (!get_info (args["d"], args["c"], metadata, getParents, collectproto, response, logout)) 
     144    return; 
     145   
     146  //get the format string from formattools.cpp 
     147  text_t relateddocs =  get_formatted_string (args["c"],collectproto, response.docInfo[0],  
     148                          disp, formatlistptr, logout); 
     149  //output the related documents 
     150  textout << outconvert << disp << relateddocs; 
     151} 
     152 
     153 
    123154 
    124155static void recurse_contents (ResultDocInfo_t &section, cgiargsclass &args, bool fulltoc, 
     
    542573    output_controls (args, formatinfo.DocumentButtons, collectproto, disp,  
    543574             outconvert, textout, logout); 
    544     textout << "</td><td valign=top>\n"; 
     575    textout << "</td><td valign=top>\n";   
    545576    havecontrols = true; 
    546577  } 
     
    560591  } 
    561592 
    562   if (havecontrols) textout << "</td></tr></table></center>\n"; 
    563 } 
     593  if (havecontrols) textout << "</td></tr></table></center>\n";  
     594 
     595  //if there is a format specified in the config file then 
     596  //try to display the related documents (may not be displayed 
     597  //if preference file does not indicate a wish to display 
     598  //related documents. 
     599  if (!formatinfo.RelatedDocuments.empty()) 
     600    output_related_docs(args, collectproto, formatinfo, disp, outconvert, textout, logout); 
     601  
     602} 
     603 
     604 
  • trunk/gsdl/src/recpt/documentaction.cpp

    r1860 r1941  
    144144  arg_ainfo.savedarginfo = cgiarginfo::must; 
    145145  argsinfo.addarginfo (NULL, arg_ainfo); 
     146 
     147  //rd is whether a document will be displayed 
     148  //with a relevant document list 
     149  arg_ainfo.shortname = "rd"; 
     150  arg_ainfo.longname = "include relevant documents"; 
     151  arg_ainfo.multiplechar = false; 
     152  arg_ainfo.defaultstatus = cgiarginfo::weak; 
     153  arg_ainfo.argdefault = "0"; 
     154  arg_ainfo.savedarginfo = cgiarginfo::must; 
     155  argsinfo.addarginfo (NULL, arg_ainfo); 
     156 
    146157} 
    147158 
     
    183194    if (xinfo != NULL) args["x"] = xinfo->argdefault; 
    184195  } 
     196 
     197  //checks whether rd arg is valid 
     198  int arg_rd = args.getintarg("rd"); 
     199  if (arg_rd != 0 && arg_rd != 1) { 
     200    logout << "Warning: \"rd\" argument out of range (" << arg_rd << ")\n"; 
     201    cgiarginfo *rdinfo = argsinfo.getarginfo ("rd"); 
     202    if (rdinfo != NULL) args["rd"] = rdinfo->argdefault; 
     203  } 
     204 
    185205 
    186206  return true; 
     
    490510         '|', formatinfo.DocumentButtons); 
    491511    else if ((*format_here).first == "DocumentText")  
    492       formatinfo.DocumentText = (*format_here).second; 
     512      formatinfo.DocumentText = (*format_here).second;   
     513    else if ((*format_here).first == "RelatedDocuments") 
     514      formatinfo.RelatedDocuments = (*format_here).second;  
    493515    else if (((*format_here).first == "DocumentUseHTML") &&  
    494516         ((*format_here).second == "true")) 
     
    565587      options.push_back(opt); 
    566588    } 
    567  
     589     
     590    //do not display relation metadata 
     591    disp.setmacro ("relateddoc", "document", "");   
     592        
     593    //if preferences indicate relevant docs should be collected 
     594    //and there is no particular format specified then display 
     595    //this default format. 
     596     if(args["rd"] == "1" && formatinfo.RelatedDocuments.empty()){ 
     597 
     598       text_t relation = ""; //string for displaying relation metadata 
     599 
     600       //call function in formattools.cpp which will return the text of the  
     601       //related documents in a vertical list. This is the default format. 
     602       if (get_info (arg_d, collection, metadata, options, false, collectproto, response, logout))  
     603     relation += get_related_docs(collection, collectproto, response.docInfo[0], logout); 
     604        
     605       //set macro to be the related document string 
     606       disp.setmacro ("relateddoc", "document", relation);  
     607     } 
     608      
     609   
    568610    // get metadata for this document and it's parents 
    569611    if (get_info (arg_d, collection, metadata, options,  
    570612          true, collectproto, response, logout)) { 
     613 
    571614      disp.setmacro ("header", "document", "_textheader_"); 
    572  
     615       
    573616      text_tarray pagetitlearray; 
    574617      if (!response.docInfo[0].metadata["Title"].values[0].empty()) 
    575618    pagetitlearray.push_back (response.docInfo[0].metadata["Title"].values[0]); 
     619       
    576620      if (args["gt"] != "1") { 
    577621    MetadataInfo_t *parenttitle = response.docInfo[0].metadata["Title"].parent; 
     
    627671    } 
    628672 
    629         // Add a macro to display the phind classifier (if appropriate) 
     673        //if the document is not a document from a collection 
     674    //we must set the macro to be an empty string 
     675    disp.setmacro ("relateddoc", "document", "");  
     676 
     677    // Add a macro to display the phind classifier (if appropriate) 
    630678    text_t &childtype = response.docInfo[0].metadata["childtype"].values[0]; 
    631679    if (childtype == "Phind") { 
     
    642690                outconvertclass &outconvert, ostream &textout,  
    643691                ostream &logout) { 
    644  
    645  
     692  
    646693  // must have a valid collection server 
    647694  recptproto *collectproto = protos->getrecptproto (args["c"], logout); 
     
    660707    } 
    661708 
     709   
    662710    if (formatinfo.DocumentUseHTML) { 
    663711       
     
    682730    } 
    683731 
     732    
    684733    textout << outconvert << disp << "_document:header_\n" 
    685734        << "_document:content_\n"; 
    686735       
    687736    // output the table of contents 
     737    logout << "formatinfo.RelatedDocs: " << formatinfo.RelatedDocuments.getcstr() << endl; 
    688738    output_toc (args, browsers, formatinfo, collectproto,  
    689739        disp, outconvert, textout, logout); 
    690      
     740    
     741    //output the related documents (may be the empty string) 
     742    //will not output the docs if a format string is specified 
     743    textout << outconvert << disp << "_document:relateddoc_\n"; 
     744 
    691745    // output the document text 
    692746    textout << "<p>\n"; 
     
    774828  } 
    775829 
     830 
    776831  format_t *formatlistptr = new format_t(); 
    777832  parse_formatstring (formatinfo.DocumentText, formatlistptr, metadata, getParents); 
     
    779834  metadata.insert ("hastxt"); 
    780835  metadata.insert ("haschildren"); 
    781    
     836  
    782837  if (formatinfo.DocumentText == "[Text]") 
    783838    wanttext = 1; 
  • trunk/gsdl/src/recpt/formattools.cpp

    r1610 r1941  
    6969  DocumentHeading = "{Or}{[parent(Top):Title],[Title],untitled}<br>"; 
    7070  DocumentContents = true; 
    71   DocumentArrowsBottom = true; 
     71  DocumentArrowsBottom = true;  
    7272  DocumentButtons.erase (DocumentButtons.begin(), DocumentButtons.end()); 
    7373  //  DocumentButtons.push_back ("Expand Text"); 
     
    7575  DocumentButtons.push_back ("Detach"); 
    7676  DocumentButtons.push_back ("Highlight"); 
     77  RelatedDocuments = ""; 
    7778  DocumentText = "<center><table width=_pagewidth_><tr><td>[Text]</td></tr></table></center>"; 
    7879  formatstrings.erase (formatstrings.begin(), formatstrings.end()); 
     
    171172  return day + " " + month + " " + year; 
    172173 
     174 
     175 
     176//this function gets the information associated with the relation 
     177//metadata for the document associated with 'docinfo'. This relation 
     178//metadata consists of a line of pairs containing 'collection, document OID' 
     179//(this is the OID of the document related to the current document, and 
     180//the collection the related document belongs to). For each of these pairs 
     181//the title metadata is obtained and then an html link between the title 
     182//of the related doc and the document's position (the document will be 
     183//found in "<a href=\"_httpdocument_&c=collection&cl=search&d=OID"> 
     184//(where collection is the related documents collection, and OID is the 
     185//related documents OID).  A list of these html links are made for as many 
     186//related documents as there are. This list is then returned. If there are 
     187//no related documents available for the current document then the string 
     188//'.. no related documents .. ' is returned. 
     189text_t get_related_docs(const text_t& collection, recptproto* collectproto, 
     190               ResultDocInfo_t &docinfo, ostream& logout){ 
     191   
     192  text_tset metadata; 
     193 
     194  //insert the metadata we wish to collect 
     195  metadata.insert("relation");  
     196  metadata.insert("Title");   
     197  metadata.insert("Subject"); //for emails, where title data doesn't apply 
     198  
     199  FilterResponse_t response; 
     200  text_t relation = ""; //string for displaying relation metadata 
     201  text_t relationTitle = ""; //the related documents Title (or subject) 
     202  text_t &relationOID = ""; //the related documents OID   
     203 
     204  //get the information associated with the metadata for current doc 
     205  if (get_info (docinfo.OID, collection, metadata,  
     206        false, collectproto, response, logout)) { 
     207     
     208    //if the relation metadata exists, store for displaying 
     209    if(!response.docInfo[0].metadata["relation"].values.empty()){ 
     210      relationOID += response.docInfo[0].metadata["relation"].values[0]; 
     211 
     212      //split relation data into pairs of collectionname,ID number 
     213      text_tarray relationpairs; 
     214      splitchar (relationOID.begin(), relationOID.end(), ' ', relationpairs); 
     215       
     216      text_tarray::const_iterator currDoc = relationpairs.begin();   
     217      text_tarray::const_iterator lastDoc = relationpairs.end(); 
     218 
     219      //iterate through the pairs to split and display 
     220      while(currDoc != lastDoc){ 
     221     
     222    //split pairs into collectionname and ID  
     223    text_tarray relationdata; 
     224    splitchar ((*currDoc).begin(), (*currDoc).end(), ',', relationdata); 
     225     
     226    //get first element in the array (collection) 
     227    text_tarray::const_iterator doc_data = relationdata.begin(); 
     228    text_t document_collection = *doc_data; 
     229    doc_data++; //increment to get next item in array (oid) 
     230    text_t document_OID = *doc_data; 
     231     
     232    //create html link to related document 
     233    relation += "<a href=\"_httpdocument_&c=" + document_collection; 
     234    relation += "&cl=search&d=" + document_OID; 
     235        
     236    //get the information associated with the metadata for related doc 
     237    if (get_info (document_OID, document_collection, metadata, 
     238              false, collectproto, response, logout)) { 
     239       
     240      //if title metadata doesn't exist, collect subject metadata 
     241      //if that doesn't exist, just call it 'related document' 
     242      if (!response.docInfo[0].metadata["Title"].values[0].empty()) 
     243        relationTitle = response.docInfo[0].metadata["Title"].values[0]; 
     244      else if (!response.docInfo[0].metadata["Subject"].values.empty()) 
     245        relationTitle = response.docInfo[0].metadata["Subject"].values[0]; 
     246      else relationTitle =  "RELATED DOCUMENT"; 
     247       
     248    } 
     249     
     250    //link the related document's title to its page 
     251    relation += "\">" + relationTitle + "</a>";  
     252    relation += "  (" + document_collection + ")<br>"; 
     253     
     254    currDoc++; 
     255      } 
     256    } 
     257     
     258  }  
     259 
     260  if(relation.empty()) //no relation data for documnet 
     261    relation = ".. no related documents .. "; 
     262 
     263  return relation; 
     264} 
     265 
     266 
    173267 
    174268static void get_parent_options (text_t &instring, metadata_t &metaoption) { 
     
    238332  else if (meta == "Text") 
    239333    formatlistptr->command = comDoc; 
     334   
     335  else if (meta == "RelatedDocuments") 
     336   formatlistptr->command = comRel; 
    240337 
    241338  else if (meta == "highlight") 
     
    645742} 
    646743 
     744 
     745 
    647746text_t format_string (const text_t& collection, recptproto* collectproto, 
    648747              ResultDocInfo_t &docinfo, displayclass &disp,  
     
    666765  case comNum: 
    667766    return docinfo.result_num; 
     767  case comRel: //if [RelatedDocuments] appears in format string, collect relation data 
     768    return get_related_docs(collection, collectproto, docinfo, logout); 
    668769  case comMeta: 
    669770 
     
    692793        = get_formatted_string(collection, collectproto,  
    693794                       response.docInfo[0], disp, expanded_formatlistptr,  
    694                        link,icon,highlight, 
    695                        logout); 
     795                       link, icon, highlight, logout); 
    696796           
    697797          return expanded_metavalue; 
  • trunk/gsdl/src/recpt/formattools.h

    r1610 r1941  
    3434 
    3535enum command_t {comIf, comOr, comMeta, comText, comLink, comEndLink, comNum, comIcon,  
    36         comDoc, comHighlight, comEndHighlight}; 
     36        comDoc, comHighlight, comEndHighlight, comRel};//changed 
    3737enum pcommand_t {pNone, pImmediate, pTop, pAll}; 
    3838enum dcommand_t {dMeta, dText}; 
     
    8888  text_tarray DocumentButtons; 
    8989  text_t DocumentText; 
     90  //----------------- 
     91  text_t RelatedDocuments; 
     92  //---------------- 
    9093  text_tmap formatstrings; 
    9194  bool DocumentUseHTML; 
     
    102105 
    103106text_t format_date (const text_t &date); 
     107 
     108 
     109text_t get_related_docs(const text_t& collection, recptproto* collectproto, 
     110              ResultDocInfo_t &docinfo, ostream& logout); 
     111 
    104112 
    105113bool parse_formatstring (const text_t &formatstring, format_t *formatlistptr,  
  • trunk/gsdl/src/recpt/zparse.tab.c

    r1450 r1941  
    11 
    22/*  A Bison parser, made from zparse.y 
    3  by  GNU Bison version 1.27 
    4   */ 
     3    by GNU Bison version 1.28  */ 
    54 
    65#define YYBISON 1  /* Identify Bison output.  */ 
     
    236235/* -*-C-*-  Note some compilers choke on comments on `#line' lines.  */ 
    237236#line 3 "/usr/share/bison.simple" 
    238 /* This file comes from bison-1.27.  */ 
     237/* This file comes from bison-1.28.  */ 
    239238 
    240239/* Skeleton output parser for bison, 
     
    449448#endif 
    450449 
    451 #line 216 "/usr/share/bison.simple" 
     450#line 217 "/usr/share/bison.simple" 
    452451 
    453452/* The user can define YYPARSE_PARAM as the name of an argument to be passed 
     
    942941} 
    943942   /* the action file gets copied in in place of this dollarsign */ 
    944 #line 542 "/usr/share/bison.simple" 
     943#line 543 "/usr/share/bison.simple" 
    945944 
    946945  yyvsp -= yylen;