Changeset 4905


Ignore:
Timestamp:
2003-07-12T04:29:59+12:00 (21 years ago)
Author:
sjboddie
Message:

Added 3 functions to change the way that collections are displayed
on the main site. Refer to the comments in the code for a further explanation.

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

Legend:

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

    r4774 r4905  
    2424 *********************************************************************/
    2525
     26// Changelog:
     27
     28// 11th July 2003:
     29
     30//   Added 3 functions to deal with the collection style
     31//   A deciding function and then 2 functions that actually
     32//   do the work for us, either images or pulldown.
     33
     34
    2635#include "OIDtools.h"
    2736#include "pageaction.h"
     
    104113}
    105114
    106 void pageaction::set_homeextra_macro (displayclass &disp, recptprotolistclass *protos,
    107                       cgiargsclass &args, ostream &logout) {
    108   text_t homeextra = "<center><table width=_pagewidth_><tr valign=top>\n";
    109   bool found_valid_col = false;
    110  
     115// This function helps decide whether we want a
     116// images or pulldown style collection display
     117// We refer to the macro files for the options
     118// for images or pulldown menu and use that to
     119// switch to the appropriate function to do the job
     120
     121// Aly Dharshi
     122// 11th July 2003
     123
     124void pageaction::homepagestyle(displayclass &disp, recptprotolistclass *protos,
     125                   cgiargsclass &args, ostream &logout)
     126{
     127
     128  const recptconf &configinfo = recpt->get_configinfo();
     129
     130  if (configinfo.HomePageType == "images") {
     131     home_images(disp, protos, args, configinfo, logout);
     132
     133  } else
     134     {
     135    home_pulldown(disp, protos, args, configinfo, logout);
     136     }
     137}
     138
     139// This function allows for the Greenstone
     140// collection to be displayed in a pull down
     141// menu similar to that in documentaction.cpp
     142
     143// Aly Dharshi
     144// 11th July 2003
     145
     146void pageaction::home_pulldown(displayclass &disp, recptprotolistclass *protos,
     147                   cgiargsclass &args, const recptconf &configinfo,
     148                   ostream &logout) {
     149   
     150   //text_t homeextra = "<center><table width=_pagewidth_><tr valign=top>\n";
     151  //bool found_valid_col = false;
     152
     153   text_t homeextra = "<form method=\"get\" name=\"browse\">\n";
     154   homeextra += "<select name=\"collections\" onChange=\"location.href=";
     155   homeextra += "document.browse.collections.options[document.browse.collections.selectedIndex].value\">\n";
     156
     157   
    111158  recptprotolistclass::iterator rprotolist_here = protos->begin();
    112159  recptprotolistclass::iterator rprotolist_end = protos->end();
     
    164211          }
    165212
     213          FilterResponse_t response;
     214          text_tset metadata;
     215          metadata.insert ("collectionname");
     216          text_t collectionname = *collist_here;
     217         
     218          if (get_info ("collection", *collist_here, metadata, false,
     219                (*rprotolist_here).p, response, logout)) {
     220         if (!response.docInfo[0].metadata["collectionname"].values[0].empty())
     221            collectionname = response.docInfo[0].metadata["collectionname"].values[0];
     222          }
     223         
     224          comerror_t err;
     225          text_t optsite = "";
     226          text_t site_name = (*rprotolist_here).p->get_site_name (err);
     227          if (!site_name.empty()) { optsite = "site="+site_name+"&"; }
     228         
     229          text_t link = "_gwcgi_?"+optsite+"a=p&p=about&c=" + *collist_here + coll_type;
     230          link += "&l=" + args["l"] + "&w=" + args["w"];
     231
     232          // We are "dynamically" overriding so to speak the
     233          // link to the collection aka receptionist.
     234         
     235          if (!cinfo->receptionist.empty())
     236         link = cinfo->receptionist;
     237         
     238         
     239          homeextra += "<option value=\"" + link + "\"";
     240          homeextra += ">" + collectionname + "</option>\n";
     241               
     242        }
     243
     244        collist_here ++;
     245        }
     246       
     247      }
     248      }
     249    rprotolist_here ++;
     250    }
     251   
     252    }
     253  homeextra += "</select>\n";
     254  homeextra += "</form>\n";
     255 
     256  disp.setmacro ("homeextra", "home", homeextra);
     257}
     258 
     259// originally called set_homeextra_macro
     260// this function displays the Greenstone
     261// main page as usual with the graphics for
     262// the collections.
     263
     264// Aly Dharshi
     265// 11th July 2003
     266
     267void pageaction::home_images(displayclass &disp, recptprotolistclass *protos,
     268                 cgiargsclass &args, const recptconf &configinfo,
     269                 ostream &logout) {
     270 
     271  text_t homeextra = "<center><table width=_pagewidth_><tr valign=top>\n";
     272  bool found_valid_col = false;
     273
     274  recptprotolistclass::iterator rprotolist_here = protos->begin();
     275  recptprotolistclass::iterator rprotolist_end = protos->end();
     276  while (rprotolist_here != rprotolist_end) {
     277    if ((*rprotolist_here).p != NULL) {
     278
     279      text_tarray collist;
     280      comerror_t err;
     281      (*rprotolist_here).p->get_collection_list (collist, err, logout);
     282      if (err == noError) {
     283    text_tarray::iterator collist_here = collist.begin();
     284    text_tarray::iterator collist_end = collist.end();
     285
     286    int count = 0;
     287    bool first = true;
     288    while (collist_here != collist_end) {
     289      ColInfoResponse_t *cinfo = recpt->get_collectinfo_ptr ((*rprotolist_here).p, *collist_here, logout);
     290     
     291      if (cinfo != NULL) {
     292        if (cinfo->isPublic && (cinfo->buildDate > 0)) {
     293
     294          text_t coll_type = "&ct=";
     295          if (cinfo->buildType == "mgpp") {
     296        coll_type += "1&qto=";
     297
     298        // now we also want to check search types to set the qto arg
     299        if (cinfo->searchTypes.size() == 0) {
     300          coll_type += "3"; // default to 3 (= both)
     301        } else {
     302          unsigned int search_types = 0;
     303          text_tarray::const_iterator type_here = cinfo->searchTypes.begin();
     304          text_tarray::const_iterator type_end = cinfo->searchTypes.end();
     305         
     306          while (type_here != type_end) {
     307            if (*type_here == "form") {
     308              search_types |= 2;
     309            } else if (*type_here == "plain") {
     310              search_types |= 1;
     311            }
     312            type_here ++;
     313          }
     314          coll_type += search_types;
     315          if (search_types == 3) {
     316            // both were specified, now need to look at the order to see which is the default
     317            type_here = cinfo->searchTypes.begin();
     318            if (*type_here == "form") {
     319              coll_type += "&qt=1"; // set the default to form
     320            }
     321          }
     322 
     323        }
     324          }
     325          else {
     326        coll_type += "0";
     327          }
     328
    166329          found_valid_col = true;
    167330          FilterResponse_t response;
     
    215378
    216379          }
    217           if ((count%3 == 0) && (!first))
     380          if ((count%configinfo.HomePageCols == 0) && (!first))
    218381        homeextra += "</tr><tr valign=top>\n";
    219382         
     
    238401    }
    239402
    240     for (; count%3 != 0; count ++) homeextra += "<td></td>\n";
     403    for (; count%configinfo.HomePageCols != 0; count ++) homeextra += "<td></td>\n";
    241404      }
    242405    }
     
    614777
    615778    if (arg_p == "home") {
    616       set_homeextra_macro (disp, protos, args, logout);
     779      homepagestyle (disp, protos, args, logout);
    617780    } else if (arg_p == "homehelp") {
    618781      set_collectionlist_macro (disp, protos, logout);
  • trunk/gsdl/src/recpt/pageaction.h

    r3774 r4905  
    6666  void configure (const text_t &key, const text_tarray &cfgline);
    6767
    68 protected:
    69   void set_homeextra_macro (displayclass &disp, recptprotolistclass *protos,
    70                 cgiargsclass &args, ostream &logout);
     68 protected:
     69 
     70  void home_images (displayclass &disp, recptprotolistclass *protos,
     71           cgiargsclass &args, const recptconf &configinfo, ostream &logout);
     72 
     73  void home_pulldown (displayclass &disp, recptprotolistclass *protos,
     74              cgiargsclass &args, const recptconf &configinfo, ostream &logout);
     75 
     76  void homepagestyle (displayclass &disp, recptprotolistclass *protos,
     77              cgiargsclass &args, ostream &logout);
     78 
    7179
     80 
    7281  void set_collectionlist_macro (displayclass &disp, recptprotolistclass *protos,
    7382                 ostream &logout);
     
    8392
    8493
     94 
    8595  bool status_disabled;
    8696  bool collector_disabled;
  • trunk/gsdl/src/recpt/receptionist.cpp

    r4290 r4905  
    7373  encodings.erase(encodings.begin(), encodings.end());
    7474
     75  HomePageType = "images";
     76  HomePageCols = 3;
     77 
    7578  // these default page parameters can always be overriden
    7679  // in the configuration file
     
    268271      }
    269272    }
    270    
     273
     274    else if (key == "SiteFormat") {
     275       if (cfgline[0] == "HomePageType") {
     276      configinfo.HomePageType = cfgline[1];
     277       } else if (cfgline[0] == "HomePageCols") {
     278      configinfo.HomePageCols = cfgline[1].getint();
     279       }
     280    }
     281       
    271282    else if (key == "cgiarg") {
    272283      // get shortname
  • trunk/gsdl/src/recpt/receptionist.h

    r3664 r4905  
    9898  bool EmailUserEvents;
    9999
     100  text_t HomePageType;
     101  int HomePageCols;
     102   
    100103  text_tmap pageparams;
    101104  text_t macroprecedence;
Note: See TracChangeset for help on using the changeset viewer.