Changeset 4774


Ignore:
Timestamp:
2003-06-24T12:28:40+12:00 (21 years ago)
Author:
sjboddie
Message:

No longer show search page (or search form on "about" page) if a collection
doesn't have at least one searchable index. Note that this change includes
the addition of an is_searchable() function to the protocol.

Location:
trunk/gsdl
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl/macros/about.dm

    r3250 r4774  
    2424
    2525_If_("_cgiargct_" eq "0",
    26      _If_("_cgiargu_" ne "1",_query:queryform_<p>_iconblankbar_),
     26     _If_("_cgiargu_" ne "1",_aboutqueryform_),
    2727     <!-- no query form for mgpp - doesn\'t work from p=about -->
    2828    )
     
    3131<h3>_help:textsimplehelpheading_</h3>
    3232_help:simplehelp_
     33}
     34
     35# _aboutqueryform_ is reset to "" in the server if the collection isn't
     36# searchable
     37_aboutqueryform_ {
     38_query:queryform_
     39<p>_iconblankbar_</p>
    3340}
    3441
  • trunk/gsdl/src/colservr/collectserver.cpp

    r4751 r4774  
    310310}
    311311
     312void collectserver::is_searchable (bool &issearchable, comerror_t &err,
     313                   ostream &logout) {
     314
     315  sourcelistclass::iterator source_here = sources.begin();
     316  sourcelistclass::iterator source_end = sources.end();
     317  while (source_here != source_end) {
     318    assert ((*source_here).s != NULL);
     319    if (((*source_here).s != NULL) &&
     320    ((*source_here).s->is_searchable (issearchable, err, logout))) {
     321      if (err != noError) return;
     322      break;
     323    }
     324    source_here++;
     325  }
     326}
     327
    312328
    313329bool operator==(const collectserverptr &x, const collectserverptr &y) {
  • trunk/gsdl/src/colservr/collectserver.h

    r2173 r4774  
    127127                 comerror_t &err, ostream &logout);
    128128
     129  virtual void is_searchable (bool &issearchable, comerror_t &err,
     130                  ostream &logout);
     131
    129132};
    130133
  • trunk/gsdl/src/colservr/mggdbmsource.cpp

    r4742 r4774  
    353353  return true;
    354354}
     355
     356bool mggdbmsourceclass::is_searchable(bool &issearchable, comerror_t &err, ostream &logout) {
     357  err = noError;
     358  issearchable = false;
     359
     360  text_tarray fromarray;
     361  indexmap.getfromarray(fromarray);
     362  if (fromarray.size() == 0) {
     363    return true;
     364  } else if (fromarray.size() == 1) {
     365    if (fromarray[0] == "dummy:text") {
     366      // always return true - issearchable is false here though
     367      return true;
     368    }
     369  }
     370  issearchable = true;
     371  return true;
     372}
  • trunk/gsdl/src/colservr/mggdbmsource.h

    r1322 r4774  
    8282  bool get_document (const text_t &OID, text_t &doc,
    8383             comerror_t &err, ostream &logout);
     84  bool is_searchable(bool &issearchable, comerror_t &err, ostream &logout);
    8485};
    8586
  • trunk/gsdl/src/colservr/source.cpp

    r1285 r4774  
    7777}
    7878
     79bool sourceclass::is_searchable(bool &issearchable, comerror_t &err, ostream &logout) {
     80
     81  // currently defaults to claiming the collection is searchable!!
     82  issearchable = true;
     83
     84  err = noError;
     85 
     86  return false;
     87}
    7988
    8089bool operator==(const sourceptr &x, const sourceptr &y) {
  • trunk/gsdl/src/colservr/source.h

    r1285 r4774  
    5858  virtual bool get_document (const text_t &OID, text_t &doc,
    5959                 comerror_t &err, ostream &logout);
     60
     61  virtual bool is_searchable(bool &issearchable, comerror_t &err, ostream &logout);
    6062};
    6163
  • trunk/gsdl/src/recpt/documentaction.cpp

    r4740 r4774  
    246246// set_widthtspace calculates how wide the spaces in the nav bar should
    247247// be and sets the appropriate macro
    248 void documentaction::set_spacemacro (displayclass &disp, FilterResponse_t &response) {
     248void documentaction::set_spacemacro (displayclass &disp, FilterResponse_t &response,
     249                     bool has_search_button) {
    249250
    250251  text_t width;
     
    258259  twidth = width.getint();
    259260     
    260   disp.expandstring ("query", "_searchwidth_", width);
    261   iwidth += width.getint();
    262  
    263  
     261  if (has_search_button) {
     262    disp.expandstring ("query", "_searchwidth_", width);
     263    iwidth += width.getint();
     264  } else {
     265    numc -= 1;
     266  }
    264267 
    265268  while (dochere != docend) {
     
    283286// reponse contains 1 metadata field (Title)
    284287void documentaction::set_navbarmacros (displayclass &disp, FilterResponse_t &response,
    285                        cgiargsclass &args) {
     288                       bool has_search_button, cgiargsclass &args) {
    286289
    287290  text_t topparent;
     
    295298
    296299  navigationbar += "<nobr>\n";
    297   if (args["a"] == "q") {
    298     navigationbar += "_icontabsearchgreen_";
    299   } else {
    300     navigationbar += "_imagesearch_";
    301   }
    302  
    303  
    304   if (numc == 0) navigationbar += "_imagespacer_";
    305    
     300  if (has_search_button) {
     301    if (args["a"] == "q") {
     302      navigationbar += "_icontabsearchgreen_";
     303    } else {
     304      navigationbar += "_imagesearch_";
     305    }
     306  }
     307 
     308  if (has_search_button || numc == 0) navigationbar += "_imagespacer_";
     309 
     310  bool first = true;
    306311  while (dochere != docend) {
     312
     313    if (!first) navigationbar += "_imagespacer_";
     314
    307315    text_t title = (*dochere).metadata["Title"].values[0];
    308316
     
    318326    // if we're inside a document all the classification buttons should be enabled
    319327    if (arg_d.empty() && ((*dochere).OID == topparent)) {
    320       if (unknown) navigationbar += "_imagespacer_&nbsp;" + title + "&nbsp;";
    321       else navigationbar += "_imagespacer__icontab" + title + "green_";
     328      if (unknown) navigationbar += "&nbsp;" + title + "&nbsp;";
     329      else navigationbar += "_icontab" + title + "green_";
    322330    } else {
    323331
    324332      // set the _httpbrowseXXX_ macro for this classification
    325       if (unknown) navigationbar += "_imagespacer_&nbsp;<a href=\"_httpdocument_&cl=" +
     333      if (unknown) navigationbar += "&nbsp;<a href=\"_httpdocument_&cl=" +
    326334             (*dochere).OID + "\">" + title + "</a>&nbsp;";
    327335      else {
    328         navigationbar += "_imagespacer__image" + title + "_";
     336        navigationbar += "_image" + title + "_";
    329337        disp.setmacro ("httpbrowse" + title, "Global", "_httpdocument_&cl=" + (*dochere).OID);
    330338      }
    331339    }
    332340    dochere ++;
     341    first = false;
    333342  }
    334343  navigationbar += "\n</nobr>\n";
     
    431440    get_children ("", collection, metadata, getParents, collectproto, response, logout);
    432441   
     442    bool has_search_button = true;
     443    collectproto->is_searchable(collection, has_search_button, err, logout);
     444    if (err != noError) has_search_button = true;
     445
    433446    // calculate width of spacers and set _widthtspace_ macro
    434     if (args.getintarg("v") == 0) set_spacemacro (disp, response);
     447    if (args.getintarg("v") == 0) set_spacemacro (disp, response, has_search_button);
    435448
    436449    // set _navigationbar_ macro
    437     set_navbarmacros (disp, response, args);
     450    set_navbarmacros (disp, response, has_search_button, args);
    438451   
    439452      }
     
    443456         << get_comerror_string (err);
    444457    }
    445  
    446  
    447458  }
    448459  text_tmap::iterator usability = cinfo.format.find("Usability");
  • trunk/gsdl/src/recpt/documentaction.h

    r3546 r4774  
    4444  void load_formatinfo (const text_tmap &colformat, int gt);
    4545
    46   void set_spacemacro (displayclass &disp, FilterResponse_t &response);
     46  void set_spacemacro (displayclass &disp, FilterResponse_t &response,
     47               bool has_search_button);
    4748
    4849  void set_navbarmacros (displayclass &disp, FilterResponse_t &response,
    49              cgiargsclass &args);
     50             bool has_search_button, cgiargsclass &args);
    5051
    5152  virtual void output_text (ResultDocInfo_t &docinfo, format_t *formatlistptr,
  • trunk/gsdl/src/recpt/nullproto.cpp

    r2212 r4774  
    154154  else err = protocolError;
    155155}
     156
     157void nullproto::is_searchable (const text_t &collection, bool &issearchable,
     158                   comerror_t &err, ostream &logout) {
     159  issearchable = false;
     160  collectserver *cserver = cset->getCollectServer (collection);
     161  if (cserver != NULL) cserver->is_searchable (issearchable, err, logout);
     162  else err = protocolError;
     163}
  • trunk/gsdl/src/recpt/nullproto.h

    r2113 r4774  
    9090             comerror_t &err, ostream &logout);
    9191
     92  void is_searchable (const text_t &collection, bool &issearchable,
     93              comerror_t &err, ostream &logout);
     94
     95
    9296};
    9397
  • trunk/gsdl/src/recpt/pageaction.cpp

    r4770 r4774  
    526526  //                       was pressed
    527527
     528  // _aboutqueryform_      will be set to "" if the collection isn't searchable
    528529
    529530  // if page is "help"
     
    604605    disp.setmacro("usabilityscript", "Global", "_usabshowscript_");
    605606      }
    606      
    607607    }
    608608  }
     
    740740    }
    741741    textsubcollections += "_textsubcols2_";
    742     if (count > 1)
     742    if (count > 1) {
    743743      disp.setmacro ("textsubcollections", "about", textsubcollections);
     744    }
     745      }
     746
     747      comerror_t err;
     748      bool issearchable = true;
     749      collectproto->is_searchable(args["c"], issearchable, err, logout);
     750      if (err != noError) issearchable = true;
     751      outconvertclass t;
     752      if (!issearchable) {
     753    disp.setmacro ("aboutqueryform", "about", "");
    744754      }
    745755    }
  • trunk/gsdl/src/recpt/recptproto.cpp

    r2113 r4774  
    126126}
    127127
     128// sets issearchable to true if the given colection is searchable
     129void recptproto::is_searchable (const text_t &/*collection*/, bool &issearchable,
     130                comerror_t &err, ostream &/*logout*/) {
     131  issearchable = false; // no collections are supported by this class
     132  err = noError;
     133}
     134
    128135
    129136
  • trunk/gsdl/src/recpt/recptproto.h

    r2113 r4774  
    126126                 DocumentResponse_t &response,
    127127                 comerror_t &err, ostream &logout);
     128
     129  virtual void is_searchable (const text_t &collection, bool &issearchable,
     130                  comerror_t &err, ostream &logout);
     131
    128132};
    129133
Note: See TracChangeset for help on using the changeset viewer.