Ignore:
Timestamp:
2000-07-13T10:21:53+12:00 (24 years ago)
Author:
sjboddie
Message:

merged changes to trunk into New_Config_Format branch

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/New_Config_Format-branch/gsdl/src/recpt/pageaction.cpp

    r1033 r1279  
    2828/*
    2929   $Log$
     30   Revision 1.29.4.1  2000/07/12 22:21:41  sjboddie
     31   merged changes to trunk into New_Config_Format branch
     32
     33   Revision 1.34  2000/07/12 04:51:05  nzdl
     34   added an error message when no "valid" collections are available
     35
     36   Revision 1.33  2000/07/05 21:49:33  sjboddie
     37   Receptionist now caches collection information to avoid making multiple
     38   get_collectinfo calls to collection server
     39
     40   Revision 1.32  2000/06/27 23:02:40  sjboddie
     41   Tidied up the way collections are displayed on 'standard' homepage.
     42   Removed all the nzdl.org specific stuff.
     43
     44   Revision 1.31  2000/06/23 03:48:08  sjboddie
     45   Added Arabic language and encoding options to the preferences page. This
     46   is a much more complex task than it should be (you even have to recompile!)
     47   but it's not really worth fixing until the new config file format is
     48   finalised.
     49
     50   Revision 1.30  2000/06/14 22:33:42  sjboddie
     51   Added French and Spanish language selection options to the preferences
     52   page. I really don't like how this is currently implemented (i.e. you
     53   have to recompile the library to do something so simple), it might have
     54   to wait until the new configuration file stuff is done before it's fixed
     55   though.
     56
    3057   Revision 1.29  2000/03/19 21:16:46  nzdl
    3158   added german language interface
     
    186213
    187214  text_t homeextra = "<center><table width=_pagewidth_><tr valign=top>\n";
     215  bool found_valid_col = false;
    188216 
    189217  recptprotolistclass::iterator rprotolist_here = protos->begin();
     
    198226    text_tarray::iterator collist_here = collist.begin();
    199227    text_tarray::iterator collist_end = collist.end();
    200    
    201     int row1 = 9;
    202     int row2 = 8;
    203     int count = 1;
     228
     229    int count = 0;
     230    bool first = true;
    204231    while (collist_here != collist_end) {
    205232     
    206       ColInfoResponse_t cinfo;
    207       (*rprotolist_here).p->get_collectinfo (*collist_here, cinfo, err, logout);
     233      ColInfoResponse_t *cinfo = recpt->get_collectinfo_ptr ((*rprotolist_here).p, *collist_here, logout);
    208234     
    209       if (err == noError) {
    210         if (cinfo.isPublic && (cinfo.buildDate > 0)) {
     235      if (cinfo != NULL) {
     236        if (cinfo->isPublic && (cinfo->buildDate > 0)) {
    211237         
     238          found_valid_col = true;
    212239          FilterResponse_t response;
    213240          text_tset metadata;
     
    233260          }
    234261       
    235           if ((count == 1) || (count == (row1+1)) || (count == ((row1+row2)+1)))
    236         homeextra += "<td align=center>";
    237           else homeextra += "<p>";
    238 
    239           if (*collist_here == "niupepa") {
    240         homeextra += "<a href=\"_httpmusiclibrary_\">_iconmusiclibrary_</a>\n";
    241         if ((count == row1) || (count == (row1+row2))) homeextra += "</td>";
    242         count ++;
    243         if ((count == 1) || (count == (row1+1)) || (count == ((row1+row2)+1)))
    244           homeextra += "<td align=center>";
    245         else homeextra += "<p>";
    246           }
     262          if ((count%3 == 0) && (!first))
     263        homeextra += "</tr><tr valign=top>\n";
    247264         
    248265          text_t link = "<a href=\"_gwcgi_?a=p&p=about&c=" + *collist_here + "\">";
     
    250267        link = "<a href=\"_gwcgi_?a=p&p=about&l=zh&nw=u&c=" + *collist_here + "\">";
    251268          if (*collist_here == "arabic")
    252         link = "<a href=\"_gwcgi_?a=p&p=about&w=a&c=" + *collist_here + "\">";
    253 
    254           if (!cinfo.receptionist.empty())
    255         link = "<a href=\"" + cinfo.receptionist + "\">";
     269        link = "<a href=\"_gwcgi_?a=p&p=about&l=ar&nw=u&c=" + *collist_here + "\">";
     270
     271          if (!cinfo->receptionist.empty())
     272        link = "<a href=\"" + cinfo->receptionist + "\">";
    256273         
    257           homeextra += link + collectionname + "</a>\n";
    258          
    259           if ((count == row1) || (count == (row1+row2)))
    260         homeextra += "</td>";
     274          homeextra += "<td>" + link + collectionname + "</a></td>\n";
    261275         
    262276          count ++;
     277          first = false;
    263278        }
    264279      }
     
    266281      collist_here ++;
    267282    }
    268     homeextra += "</tr></table></center>\n";
    269     disp.setmacro ("homeextra", "home", homeextra);
     283    for (; count%3 != 0; count ++) homeextra += "<td></td>\n";
    270284      }
    271285    }
    272286    rprotolist_here ++;
    273287  }
     288
     289  if (!found_valid_col) {
     290    homeextra += "<td>No valid (i.e. built and public) collections are available</td>\n";
     291  }
     292  homeextra += "</tr></table></center>\n";
     293  disp.setmacro ("homeextra", "home", homeextra);
     294
    274295}
    275296
     
    319340
    320341 
     342  if (recpt == NULL) {
     343    logout << "ERROR (pageaction::define_internal_macros): This action does not contain\n"
     344       << "      information about any receptionists. The method set_receptionist was\n"
     345       << "      probably not called from the module which instantiated this action.\n";
     346    return;
     347  }
     348
    321349  text_t &arg_p = args["p"];
    322350  text_t &arg_c = args["c"];
    323   ColInfoResponse_t cinfo;
    324   comerror_t err;
     351  ColInfoResponse_t *cinfo = NULL;
    325352
    326353  recptproto* collectproto = protos->getrecptproto (arg_c, logout);
    327354  if (collectproto != NULL) {
    328     collectproto->get_collectinfo (arg_c, cinfo, err, logout);
    329 
    330     disp.setmacro ("numdocs", "Global", cinfo.numDocs);
     355    cinfo = recpt->get_collectinfo_ptr (collectproto, arg_c, logout);
     356
     357    disp.setmacro ("numdocs", "Global", cinfo->numDocs);
    331358    unsigned long current_time = time(NULL);
    332     unsigned long builddate = (current_time - cinfo.buildDate) / 86400;
     359    unsigned long builddate = (current_time - cinfo->buildDate) / 86400;
    333360    disp.setmacro ("builddate", "Global", builddate);
    334361  }
     
    340367    // _collectionoption_
    341368
    342     if (args["ccs"] == "1" && collectproto != NULL && (cinfo.ccsCols.size() > 1)) {
     369    if (args["ccs"] == "1" && collectproto != NULL && (cinfo->ccsCols.size() > 1)) {
    343370      text_t collectionoption = "_textcollectionoption_";
    344       text_tarray::const_iterator col_here = cinfo.ccsCols.begin();
    345       text_tarray::const_iterator col_end = cinfo.ccsCols.end();
     371      text_tarray::const_iterator col_here = cinfo->ccsCols.begin();
     372      text_tarray::const_iterator col_end = cinfo->ccsCols.end();
    346373      int count = 0;
    347374      while (col_here != col_end) {
    348375    text_t colname;
    349376    if (*col_here == arg_c) {
    350         colname = cinfo.collectionmeta["collectionname"];
     377        colname = cinfo->collectionmeta["collectionname"];
    351378    } else {
    352       ColInfoResponse_t this_cinfo;
    353       collectproto->get_collectinfo (*col_here, this_cinfo, err, logout);
    354       if (err != noError) {col_here ++; continue;}
    355       colname = this_cinfo.collectionmeta["collectionname"];
     379      ColInfoResponse_t *this_cinfo = recpt->get_collectinfo_ptr (collectproto, *col_here, logout);
     380      if (this_cinfo == NULL) {col_here ++; continue;}
     381      colname = this_cinfo->collectionmeta["collectionname"];
    356382    }
    357383
     
    369395    // _htmloptions_
    370396   
    371     text_tmap::const_iterator it = cinfo.format.find ("DocumentUseHTML");
    372     if ((it != cinfo.format.end()) && ((*it).second == "true")) {
     397    text_tmap::const_iterator it = cinfo->format.find ("DocumentUseHTML");
     398    if ((it != cinfo->format.end()) && ((*it).second == "true")) {
    373399      disp.setmacro ("htmloptions", "preferences", "_htmloptionson_");
    374400
     
    376402      // _PreferenceDocsFromWeb_
    377403
    378       it = cinfo.format.find ("PreferenceDocsFromWeb");
    379       if ((it == cinfo.format.end()) || ((*it).second == "true"))
     404      it = cinfo->format.find ("PreferenceDocsFromWeb");
     405      if ((it == cinfo->format.end()) || ((*it).second == "true"))
    380406    disp.setmacro ("PreferenceDocsFromWeb", "preferences", "1");
    381407    }
     
    392418    text_tarray languages;
    393419    languages.push_back ("en");
     420    languages.push_back ("fr");
    394421    languages.push_back ("de");
     422    languages.push_back ("es");
    395423    languages.push_back ("mi");
    396424    languages.push_back ("zh");
     425    languages.push_back ("ar");
    397426    text_tarray::const_iterator this_lang = languages.begin();
    398427    text_tarray::const_iterator end_lang = languages.end();
    399428
    400429    text_t languageoption = "_textlanguage_\n<select name=\"l\" onChange=\"updatel();\">\n";
    401     it = cinfo.format.find ("PreferenceLanguages");
    402     if ((it != cinfo.format.end()) && (!(*it).second.empty())) {
     430    it = cinfo->format.find ("PreferenceLanguages");
     431    if ((it != cinfo->format.end()) && (!(*it).second.empty())) {
    403432      text_tset pref_langs;
    404433      splitchar ((*it).second.begin(), (*it).second.end(), '|', pref_langs);
     
    471500         
    472501      // if HTML collection there's no how to read document text
    473       text_tmap::const_iterator it = cinfo.format.find ("HelpNoDocs");
    474       if ((it != cinfo.format.end()) && ((*it).second == "true")) {
     502      text_tmap::const_iterator it = cinfo->format.find ("HelpNoDocs");
     503      if ((it != cinfo->format.end()) && ((*it).second == "true")) {
    475504    disp.setmacro ("topicreadingdocs", "help", "");
    476505    disp.setmacro ("texthelpreadingdocs", "help", "");
    477506      }
    478       it = cinfo.format.find ("HelpBibDocs");
    479       if ((it != cinfo.format.end()) && ((*it).second == "true")) {
     507      it = cinfo->format.find ("HelpBibDocs");
     508      if ((it != cinfo->format.end()) && ((*it).second == "true")) {
    480509    disp.setmacro ("texthelpreadingdocs", "help", "_bibtexthelpreadingdocs_");
    481510    disp.setmacro ("textreadingdocs", "help", "_bibtextreadingdocs_");
    482511      }
    483       it = cinfo.format.find ("HelpBookDocs");
    484       if ((it != cinfo.format.end()) && ((*it).second == "true")) {
     512      it = cinfo->format.find ("HelpBookDocs");
     513      if ((it != cinfo->format.end()) && ((*it).second == "true")) {
    485514    disp.setmacro ("texthelpreadingdocs", "help", "_booktexthelpreadingdocs_");
    486515    disp.setmacro ("textreadingdocs", "help", "_booktextreadingdocs_");
     
    491520
    492521      // _textsubcollections_
    493       if (args["ccs"] == "1" && (cinfo.ccsCols.size() > 1)) {
    494     text_t textsubcollections = "_textsubcols1_(" + text_t(cinfo.ccsCols.size()) + ")";
    495     text_tarray::const_iterator here = cinfo.ccsCols.begin();
    496     text_tarray::const_iterator end = cinfo.ccsCols.end();
     522      if (args["ccs"] == "1" && (cinfo->ccsCols.size() > 1)) {
     523    text_t textsubcollections = "_textsubcols1_(" + text_t(cinfo->ccsCols.size()) + ")";
     524    text_tarray::const_iterator here = cinfo->ccsCols.begin();
     525    text_tarray::const_iterator end = cinfo->ccsCols.end();
    497526    bool first = true;
    498527    int count = 0;
     
    500529      if (*here == arg_c) {
    501530        if (!first) textsubcollections += "<br>";
    502         textsubcollections += "\n" + cinfo.collectionmeta["collectionname"] + "\n";
     531        textsubcollections += "\n" + cinfo->collectionmeta["collectionname"] + "\n";
    503532      } else {
    504         ColInfoResponse_t this_cinfo;
    505         collectproto->get_collectinfo (*here, this_cinfo, err, logout);
    506         if (err != noError) {here ++; continue;}
     533        ColInfoResponse_t *this_cinfo = recpt->get_collectinfo_ptr (collectproto, *here, logout);
     534        if (this_cinfo == NULL) {here ++; continue;}
    507535        if (!first) textsubcollections += "<br>";
    508         textsubcollections += "\n" + this_cinfo.collectionmeta["collectionname"] + "\n";
     536        textsubcollections += "\n" + this_cinfo->collectionmeta["collectionname"] + "\n";
    509537      }
    510538      count ++;
Note: See TracChangeset for help on using the changeset viewer.