Changeset 9931


Ignore:
Timestamp:
2005-05-23T16:36:40+12:00 (19 years ago)
Author:
kjdon
Message:

getting collectionmeta from teh colinforesponse now, not using a get_info via the protocol. this means that collmeta will be read from the config file not from the database - it will not require rebuilding for changes to take effect.

Location:
trunk/gsdl/src/recpt
Files:
9 edited

Legend:

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

    r9620 r9931  
    797797    text_tarray::iterator collist_here = collist.begin();
    798798    text_tarray::iterator collist_end = collist.end();
    799     FilterResponse_t response;
    800     text_tset metadata;
    801     metadata.insert ("collectionname");
    802799    while (collist_here != collist_end) {
    803800      ColInfoResponse_t *cinfo = recpt->get_collectinfo_ptr ((*rprotolist_here).p, *collist_here, logout);
    804801      if (cinfo != NULL) {
    805         text_t collectionname = *collist_here;
    806         if (!cinfo->collectionmeta["collectionname"].empty()) {
    807           // get collection name from the collection cfg file
    808           collectionname = cinfo->collectionmeta["collectionname"];
    809         } else if (get_info ("collection", *collist_here, args["l"], metadata, false,
    810                  (*rprotolist_here).p, response, logout)) {
    811           // get collection name from gdbm file
    812           collectionname = response.docInfo[0].metadata["collectionname"].values[0];
     802        text_t collectionname = cinfo->get_collectionmeta("collectionname", args["l"]);
     803        if (collectionname.empty()) {
     804          collectionname = *collist_here;
    813805        }
    814806        dirnames.push_back(*collist_here);
  • trunk/gsdl/src/recpt/extlinkaction.cpp

    r9620 r9931  
    217217   
    218218    recptproto *collectproto = protos->getrecptproto (*col_here, logout);
    219    
    220219    if (get_info (args["href"], *col_here, args["l"], metadata, false, collectproto, response, logout)) {
    221220      if (!response.docInfo[0].metadata["section"].values[0].empty()) {
    222         text_t collectionname = *col_here;
    223         metadata.erase (metadata.begin(), metadata.end());
    224         metadata.insert ("collectionname");
    225         FilterResponse_t nresponse;
    226         if (get_info ("collection", *col_here, args["l"], metadata, false, collectproto, nresponse, logout)) {
    227           if (!nresponse.docInfo[0].metadata["collectionname"].values[0].empty())
    228         collectionname = nresponse.docInfo[0].metadata["collectionname"].values[0];
     221        ColInfoResponse_t *cinfo = recpt->get_collectinfo_ptr (collectproto, *col_here, logout);
     222        text_t collectionname = cinfo->get_collectionmeta("collectionname", args["l"]); //
     223        if (collectionname.empty()) {
     224          collectionname = *col_here;
    229225        }
    230226        textout << outconvert << disp << ("_extlink:header_\n")
  • trunk/gsdl/src/recpt/extlinkaction.h

    r7371 r9931  
    3131
    3232#include "action.h"
     33#include "receptionist.h"
    3334
    3435class extlinkaction : public action {
     
    3839  extlinkaction ();
    3940  virtual ~extlinkaction ();
     41
     42  void set_receptionist (receptionist *therecpt) {recpt=therecpt;}
    4043
    4144  text_t get_action_name () {return "extlink";}
     
    5558
    5659protected:
     60 
     61  receptionist *recpt;
     62 
    5763  bool get_link (cgiargsclass &args, recptprotolistclass *protos,
    5864         text_t &link, ostream &logout);
  • trunk/gsdl/src/recpt/librarymain.cpp

    r8073 r9931  
    182182
    183183#ifdef GSDL_USE_EXTLINK_ACTION
    184   recpt.add_action (new extlinkaction());
     184  extlinkaction *aextlinkaction = new extlinkaction();
     185  aextlinkaction->set_receptionist(&recpt);
     186  recpt.add_action (aextlinkaction);
    185187#endif
    186188       
  • trunk/gsdl/src/recpt/pageaction.cpp

    r9676 r9931  
    219219        coll_type += "0";
    220220          }
    221 
    222           FilterResponse_t response;
    223           text_tset metadata;
    224           metadata.insert ("collectionname");
    225           text_t lang = args["l"];
    226           if (!lang.empty()) {
    227         metadata.insert ("collectionname:"+lang);
    228           }
    229           text_t collectionname = *collist_here;
    230          
    231           if (get_info ("collection", *collist_here, "", metadata, false,
    232                 (*rprotolist_here).p, response, logout)) {
    233         if (!lang.empty() && !response.docInfo[0].metadata["collectionname:"+lang].values[0].empty()) {
    234           collectionname = response.docInfo[0].metadata["collectionname:"+lang].values[0];
    235         } else if (!response.docInfo[0].metadata["collectionname"].values[0].empty()) {
    236           collectionname = response.docInfo[0].metadata["collectionname"].values[0];
    237         }
     221          text_t collectionname = cinfo->get_collectionmeta("collectionname", args["l"]);
     222          if (collectionname.empty()) {
     223        collectionname = *collist_here;
    238224          }
    239225         
     
    351337
    352338          found_valid_col = true;
    353           FilterResponse_t response;
    354           text_tset metadata;
    355           metadata.insert ("collectionname");
    356           metadata.insert ("iconcollection");
    357           metadata.insert ("iconcollectionsmall");
    358           // also look for lang specific values
    359           text_t lang = args["l"];
    360           if (!lang.empty()) {
    361         metadata.insert ("collectionname:"+lang);
    362         metadata.insert ("iconcollection:"+lang);
    363         metadata.insert ("iconcollectionsmall:"+lang);
     339          text_t collectionname = *collist_here;
     340          text_t alt = cinfo->get_collectionmeta("collectionname", args["l"]);
     341          if (alt.empty()) {
     342        alt = collectionname;
    364343          }
    365           text_t collectionname = *collist_here;
    366           text_t alt = collectionname;
    367 
    368           if (get_info ("collection", *collist_here, "", metadata, false,
    369                 (*rprotolist_here).p, response, logout)) {
    370         // get the "collectionname"
    371         if (!lang.empty() && !response.docInfo[0].metadata["collectionname:"+lang].values[0].empty()) {
    372           alt = response.docInfo[0].metadata["collectionname:"+lang].values[0];
    373         } else if (!response.docInfo[0].metadata["collectionname"].values[0].empty()) {
    374           alt = response.docInfo[0].metadata["collectionname"].values[0];
     344         
     345          // url to image: try iconcollectionsmall, then iconcollection
     346          text_t iconurl = cinfo->get_collectionmeta("iconcollectionsmall", args["l"]);
     347          if (iconurl.empty()) {
     348        iconurl = cinfo->get_collectionmeta("iconcollection", args["l"]);
     349          }
     350         
     351          if (!iconurl.empty()) {
     352       
     353        // check to see URL is local to colserver
     354        text_t::iterator iconurl_head = iconurl.begin();
     355        text_t iconhead = substr(iconurl_head,iconurl_head+16);
     356        if (iconhead=="_httpcollection_") {
     357         
     358          // local and using _httpcollection_
     359          text_t icontail = substr(iconurl_head+16,iconurl.end());
     360          iconurl = "http://" + cinfo->httpdomain
     361            + cinfo->httpprefix + "/collect/"
     362            + *collist_here + "/" + icontail;
     363        }
     364        else if (iconurl[0]=='/') {
     365         
     366          // local but with full path
     367          iconurl = "http://" + cinfo->httpdomain + iconurl;
    375368        }
    376369       
    377         text_t iconurl;
    378         iconurl.clear();
    379 
    380         if (!lang.empty() &&!response.docInfo[0].metadata["iconcollectionsmall:"+lang].values[0].empty()) {
    381          iconurl = response.docInfo[0].metadata["iconcollectionsmall:"+lang].values[0];
    382         } else if (!response.docInfo[0].metadata["iconcollectionsmall"].values[0].empty()) {
    383           iconurl = response.docInfo[0].metadata["iconcollectionsmall"].values[0];
    384         } else if (!lang.empty() && !response.docInfo[0].metadata["iconcollection:"+lang].values[0].empty()) {
    385           iconurl = response.docInfo[0].metadata["iconcollection:"+lang].values[0];
    386         } else if (!response.docInfo[0].metadata["iconcollection"].values[0].empty()) {
    387           iconurl = response.docInfo[0].metadata["iconcollection"].values[0];
    388         }
    389        
    390         if (!iconurl.empty())
    391           {
    392             // check to see URL is local to colserver
    393             text_t::iterator iconurl_head = iconurl.begin();
    394             text_t iconhead = substr(iconurl_head,iconurl_head+16);
    395             if (iconhead=="_httpcollection_")
    396               {
    397             // local and using _httpcollection_
    398             text_t icontail = substr(iconurl_head+16,iconurl.end());
    399             iconurl = "http://" + cinfo->httpdomain
    400               + cinfo->httpprefix + "/collect/"
    401               + *collist_here + "/" + icontail;
    402               }
    403             else if (iconurl[0]=='/')
    404               {
    405             // local but with full path
    406             iconurl = "http://" + cinfo->httpdomain + iconurl;
    407               }
    408 
    409             collectionname
    410               = "<img width=150 border=1 src=\"" + iconurl + "\" alt=\"" + alt + "\">";
    411           }
    412         else
    413           {
    414             collectionname = alt;
    415           }
    416 
     370        collectionname
     371          = "<img width=150 border=1 src=\"" + iconurl + "\" alt=\"" + alt + "\">";
     372          } else {
     373        collectionname = alt;
    417374          }
     375         
    418376          if ((count%configinfo.HomePageCols == 0) && (!first))
    419377        homeextra += "</tr><tr valign=top>\n";
     
    426384          text_t link = "<a href=\"_gwcgi_?"+optsite+"a=p&p=about&c=" + *collist_here + coll_type;
    427385          link += "&l=" + args["l"] + "&w=" + args["w"] + "\">";
    428 
     386         
    429387          if (!cinfo->receptionist.empty())
    430388        link = "<a href=\"" + cinfo->receptionist + "\">";
     
    453411}
    454412
    455 void pageaction::set_collectionlist_macro (displayclass &disp, recptprotolistclass *protos,
     413void pageaction::set_collectionlist_macro (displayclass &disp,
     414                       recptprotolistclass *protos,
     415                       cgiargsclass &args,
    456416                       ostream &logout) {
    457417
     
    522482        coll_type += "0";
    523483          }
    524           FilterResponse_t response;
    525           text_tset metadata;
    526           metadata.insert ("collectionname");
    527           text_t collectionname = *collist_here;
    528 
    529           if (get_info ("collection", *collist_here, "", metadata, false,
    530                 (*rprotolist_here).p, response, logout)) {
    531         if (!response.docInfo[0].metadata["collectionname"].values[0].empty()) {
    532           collectionname = response.docInfo[0].metadata["collectionname"].values[0];
    533         }
     484          text_t collectionname = cinfo->get_collectionmeta("collectionname", args["l"]);
     485          if (collectionname.empty()) {
     486        collectionname = *collist_here;
    534487          }
    535488         
     
    836789    }
    837790  }
    838 
     791 
     792 
    839793  if (arg_p == "home" || arg_p == "homehelp") {
    840794    if (status_disabled) disp.setmacro ("textgoadmin", "home", "");
     
    845799      homepagestyle (disp, protos, args, logout);
    846800    } else if (arg_p == "homehelp") {
    847       set_collectionlist_macro (disp, protos, logout);
     801      set_collectionlist_macro (disp, protos, args, logout);
    848802    }
    849803
     
    878832    text_t colname;
    879833    if (*col_here == arg_c) {
    880         colname = cinfo->collectionmeta["collectionname"];
     834        colname = cinfo->get_collectionmeta("collectionname", args["l"]);
    881835    } else {
    882836      ColInfoResponse_t *this_cinfo = recpt->get_collectinfo_ptr (collectproto, *col_here, logout);
    883837      if (this_cinfo == NULL) {++col_here; continue;}
    884       colname = this_cinfo->collectionmeta["collectionname"];
     838      colname = this_cinfo->get_collectionmeta("collectionname", args["l"]);
    885839    }
    886 
     840    if (colname.empty()) {
     841      colname = *col_here;
     842    }
    887843    ++count;
    888844    collectionoption += "<input type=checkbox name=\"cc\" value=\"" +
     
    1003959      if (*here == arg_c) {
    1004960        if (!first) textsubcollections += "<br>";
    1005         textsubcollections += "\n" + cinfo->collectionmeta["collectionname"] + "\n";
     961        textsubcollections += "\n" + cinfo->get_collectionmeta("collectionname", args["l"]) + "\n";
    1006962      } else {
    1007963        ColInfoResponse_t *this_cinfo = recpt->get_collectinfo_ptr (collectproto, *here, logout);
    1008964        if (this_cinfo == NULL) {++here; continue;}
    1009965        if (!first) textsubcollections += "<br>";
    1010         textsubcollections += "\n" + this_cinfo->collectionmeta["collectionname"] + "\n";
     966        textsubcollections += "\n" + this_cinfo->get_collectionmeta("collectionname", args["l"]) + "\n";
    1011967      }
    1012968      ++count;
  • trunk/gsdl/src/recpt/pageaction.h

    r7762 r9931  
    4848
    4949  text_t get_action_name () {return "p";}
    50 
     50 
    5151  bool check_cgiargs (cgiargsinfoclass &argsinfo, cgiargsclass &args,
    5252              recptprotolistclass *protos, ostream &logout);
     
    8080 
    8181  void set_collectionlist_macro (displayclass &disp, recptprotolistclass *protos,
    82                  ostream &logout);
     82                 cgiargsclass &args, ostream &logout);
    8383
    8484  void set_documentation_macro (displayclass &disp);
  • trunk/gsdl/src/recpt/queryaction.cpp

    r9698 r9931  
    975975          text_tset::const_iterator t = collections.find (*collist_here);
    976976          if (t != collections.end()) textout << outconvert << " checked";
    977 
    978           textout << outconvert
    979               << " name=cc value=\"" << *collist_here << "\">";
    980977         
    981           if (!cinfo->collectionmeta["collectionname"].empty())
    982         textout << outconvert << disp << cinfo->collectionmeta["collectionname"];
    983           else
    984         textout << outconvert << *collist_here;
    985          
    986           textout << outconvert << "<br>\n";
     978          text_t collectionname = cinfo->get_collectionmeta("collectionname", args["l"]);
     979          if (collectionname.empty()) {
     980        collectionname = *collist_here;
     981          }
     982          textout << outconvert << disp
     983              << " name=cc value=\"" << *collist_here << "\">"
     984              << collectionname << "<br>\n";
     985
    987986         
    988987        }
  • trunk/gsdl/src/recpt/receptionist.cpp

    r9674 r9931  
    13961396  disp.setmacro ("httpprefix", displayclass::defaultpackage, configinfo.httpprefix);
    13971397
    1398   // get relevant info from the collection
    1399   if (!collection.empty()) {
    1400     ColInfoResponse_t cinfo;
    1401     comerror_t err;
    1402     recptproto *collectproto = protocols.getrecptproto (collection, logout);
    1403     if (collectproto != NULL) {
    1404       collectproto->get_collectinfo (collection, cinfo, err, logout);
    1405       text_t httpcollection;
    1406       if (!cinfo.httpdomain.empty()) httpcollection = "http://";
    1407       httpcollection += cinfo.httpdomain + cinfo.httpprefix + "/collect/"
    1408     + collection;
    1409       disp.setmacro ("httpcollection", displayclass::defaultpackage,
    1410              httpcollection);
    1411       // as of gsdl 2.53, collect.cfg can specify macros
    1412       if (cinfo.collection_macros.size() > 0) {
    1413     macros_map::const_iterator this_macro=cinfo.collection_macros.begin();
    1414     macros_map::const_iterator done_macro=cinfo.collection_macros.end();
    1415     while (this_macro != done_macro) {
    1416 
    1417       disp.setcollectionmacro("Global",           // package
    1418                   this_macro->first,          // macro name
    1419                   this_macro->second.first,   // params
    1420                   this_macro->second.second); // value
    1421       ++this_macro;
    1422     }
    1423       } // col macros
    1424     } // collectproto != NULL
    1425   }
    14261398
    14271399  text_t compressedoptions = get_compressed_arg(args, logout);
     
    14981470        if (!lang.empty()) {
    14991471          if (args["l"]==lang) {
    1500         disp.setmacro (name, displayclass::defaultpackage, (*here).second.values[0]);
     1472        disp.setcollectionmacro(displayclass::defaultpackage, name, "", (*here).second.values[0]);
    15011473          }
    15021474        }
    15031475        else { // the default one
    1504           disp.setmacro ((*here).first, displayclass::defaultpackage, (*here).second.values[0]);
     1476          disp.setcollectionmacro(displayclass::defaultpackage, (*here).first,  "", (*here).second.values[0]);
    15051477        }
    15061478      }
     
    15251497    }
    15261498  }
     1499
     1500  if (!collection.empty()) {
     1501    ColInfoResponse_t cinfo;
     1502    comerror_t err;
     1503    recptproto *collectproto = protocols.getrecptproto (collection, logout);
     1504    if (collectproto != NULL) {
     1505      collectproto->get_collectinfo (collection, cinfo, err, logout);
     1506      text_t httpcollection;
     1507      if (!cinfo.httpdomain.empty()) httpcollection = "http://";
     1508      httpcollection += cinfo.httpdomain + cinfo.httpprefix + "/collect/"
     1509    + collection;
     1510      disp.setmacro ("httpcollection", displayclass::defaultpackage,
     1511             httpcollection);
     1512      // as of gsdl 2.53, collect.cfg can specify macros
     1513      if (cinfo.collection_macros.size() > 0) {
     1514    macros_map::const_iterator this_macro=cinfo.collection_macros.begin();
     1515    macros_map::const_iterator done_macro=cinfo.collection_macros.end();
     1516    while (this_macro != done_macro) {
     1517
     1518      disp.setcollectionmacro("Global",           // package
     1519                  this_macro->first,          // macro name
     1520                  this_macro->second.first,   // params
     1521                  this_macro->second.second); // value
     1522      ++this_macro;
     1523    }
     1524      } // col macros
     1525    } // collectproto != NULL
     1526  }
     1527
    15271528}
    15281529
  • trunk/gsdl/src/recpt/statusaction.cpp

    r9620 r9931  
    5252}
    5353
    54 void statusaction::output_welcome (cgiargsclass &/*args*/, recptprotolistclass *protos,
     54void statusaction::output_welcome (cgiargsclass &args, recptprotolistclass *protos,
    5555                   displayclass &disp, outconvertclass &outconvert,
    5656                   ostream &textout, ostream &logout) {
     
    9090      ColInfoResponse_t *cinfo = recpt->get_collectinfo_ptr ((*rprotolist_here).p, *collist_here, logout);
    9191      if (cinfo != NULL) {
    92         text_t collname = *collist_here;
    93         text_tmap::iterator it = cinfo->collectionmeta.find("collectionname");
    94         if (it != cinfo->collectionmeta.end()) collname = (*it).second;
     92        text_t collname = cinfo->get_collectionmeta("collectionname", args["l"]);
     93        if (collname.empty()) {
     94          collname = *collist_here;
     95        }
    9596
    9697        textout << "<td>";
     
    594595
    595596      textout << "<tr><th valign=top>collection metadata</th><td><table>\n";
    596       text_tmap::iterator meta_here = collectinfo->collectionmeta.begin();
    597       text_tmap::iterator meta_end = collectinfo->collectionmeta.end();
     597      collectionmeta_map::iterator meta_here = collectinfo->collectionmeta.begin();
     598      collectionmeta_map::iterator meta_end = collectinfo->collectionmeta.end();
     599     
    598600      while (meta_here != meta_end) {
    599     textout << outconvert << "<tr><td>" << (*meta_here).first
    600         << "</td><td>" << (*meta_here).second << "</td></tr>\n";
     601    textout << outconvert << "<tr><td valign=top>" << (*meta_here).first
     602        << "</td><td><table>" ;
     603        text_tmap lang_map = (*meta_here).second;
     604    text_tmap::iterator lang_here = lang_map.begin();
     605    text_tmap::iterator lang_end = lang_map.end();
     606    while (lang_here != lang_end) {
     607      textout << outconvert << "<tr><td>" << (*lang_here).first
     608            << "</td><td>" << (*lang_here).second << "</td></tr>\n";
     609     
     610      ++lang_here;
     611    }
     612    textout << outconvert << "</table></td></tr>\n";
    601613    ++meta_here;
    602614      }
     
    607619      text_tmap::iterator format_end = collectinfo->format.end();
    608620      while (format_here != format_end) {
    609     textout << outconvert << "<tr><td>" << (*format_here).first
     621    textout << outconvert << "<tr><td valign=top>" << (*format_here).first
    610622        << "</td><td>" << html_safe((*format_here).second) << "</td></tr>\n";
    611623    ++format_here;
Note: See TracChangeset for help on using the changeset viewer.