2002-01-06 19:05:37 -07:00
|
|
|
// The contents of this file are subject to the Mozilla Public License Version 1.1
|
|
|
|
// (the "License"); you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
|
|
|
//
|
|
|
|
// Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
|
|
|
// WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
|
|
|
// language governing rights and limitations under the License.
|
|
|
|
//
|
|
|
|
// The Original Code is the Venice Web Communities System.
|
|
|
|
//
|
2006-01-25 21:40:34 -07:00
|
|
|
// The Initial Developer of the Original Code is Eric J. Bowersox <erbo@users.sf.net>,
|
2002-01-06 19:05:37 -07:00
|
|
|
// for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
2002-01-18 18:28:51 -07:00
|
|
|
// Copyright (C) 2001-02 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
2002-01-06 19:05:37 -07:00
|
|
|
//
|
|
|
|
// Contributor(s):
|
|
|
|
|
|
|
|
importPackage(java.util);
|
|
|
|
importPackage(Packages.com.silverwrist.venice.core);
|
|
|
|
importPackage(Packages.com.silverwrist.venice.except);
|
|
|
|
importPackage(Packages.com.silverwrist.venice.ui);
|
|
|
|
importPackage(Packages.com.silverwrist.venice.ui.conf);
|
2002-01-09 10:55:47 -07:00
|
|
|
importPackage(Packages.com.silverwrist.venice.ui.conf.view);
|
2002-01-06 19:05:37 -07:00
|
|
|
importPackage(Packages.com.silverwrist.venice.ui.helpers);
|
|
|
|
importPackage(Packages.com.silverwrist.venice.ui.view);
|
|
|
|
|
|
|
|
// get the request object and the community
|
|
|
|
rinput = bsf.lookupBean("request");
|
|
|
|
comm = rinput.getCommunity(true,"top.js.vs");
|
|
|
|
on_error = "conf/conferences.js.vs?cc=" + comm.communityID;
|
|
|
|
|
|
|
|
// get the current conference
|
|
|
|
currc = new CurrentConference(rinput);
|
|
|
|
conf = currc.getConference(false,"conf/conferences.js.vs?cc=" + comm.communityID);
|
|
|
|
|
|
|
|
// get the topic
|
|
|
|
topic = null;
|
|
|
|
if (conf!=null)
|
|
|
|
{ // get the topic
|
|
|
|
on_error = "conf/topics.js.vs?cc=" + comm.communityID + "&conf=" + conf.confID;
|
|
|
|
topic = currc.getTopic(false,"conf/topics.js.vs?cc=" + comm.communityID + "&conf=" + conf.confID);
|
|
|
|
if (topic!=null)
|
|
|
|
on_error = "conf/posts.js.vs?cc=" + comm.communityID + "&conf=" + conf.confID + "&top="
|
|
|
|
+ topic.topicNumber;
|
|
|
|
|
|
|
|
} // end if
|
|
|
|
|
2002-01-09 10:55:47 -07:00
|
|
|
view = new FindPostView(comm,conf,topic);
|
2002-01-06 19:05:37 -07:00
|
|
|
view.maxResults = rinput.engine.getStdNumSearchResults();
|
|
|
|
|
|
|
|
if ("GET"==rinput.verb)
|
|
|
|
{ // display the find dialog
|
|
|
|
vlib.output(view);
|
|
|
|
vlib.done();
|
|
|
|
|
|
|
|
} // end if
|
|
|
|
|
|
|
|
// Retrieve the search term parameter.
|
|
|
|
tmp = rinput.getParameter("term");
|
|
|
|
if (tmp==null)
|
|
|
|
view.term = "";
|
|
|
|
else
|
|
|
|
view.term = tmp;
|
|
|
|
|
|
|
|
// Retrieve the offset and find count parameters.
|
|
|
|
view.offset = rinput.getParameterInt("ofs",0);
|
|
|
|
view.findCount = rinput.getParameterInt("fcount",-1);
|
|
|
|
|
|
|
|
// Adjust the search return offset based on the command button click.
|
2002-01-18 18:28:51 -07:00
|
|
|
// EJB 1/18/2002 - N.B.: some browsers can POST the "Search" form without triggering the
|
|
|
|
// "Search" button (by just pressing Enter), so we include the hidden "newsearch" parameter
|
|
|
|
// to distinguish between the two
|
|
|
|
if (rinput.isImageButtonClicked("search") || (rinput.getParameterInt("newsearch",0)==1))
|
2002-01-06 19:05:37 -07:00
|
|
|
view.offset = 0;
|
|
|
|
else if (rinput.isImageButtonClicked("previous"))
|
|
|
|
view.offset = Math.max(view.offset - view.maxResults,0); // go backwards
|
|
|
|
else if (rinput.isImageButtonClicked("next"))
|
|
|
|
view.offset += view.maxResults; // go forwards instead
|
|
|
|
else
|
|
|
|
throw new InternalStateError("Unable to determine what action triggered the form.");
|
|
|
|
|
|
|
|
rc = null;
|
|
|
|
try
|
|
|
|
{ // do the search
|
|
|
|
if (topic!=null)
|
|
|
|
{ // search the topic
|
2002-01-09 16:45:27 -07:00
|
|
|
view.results = topic.searchPosts(view.term,view.offset,view.maxResults);
|
2002-01-06 19:05:37 -07:00
|
|
|
if (view.findCount<0)
|
2002-01-09 16:45:27 -07:00
|
|
|
view.findCount = topic.getSearchPostCount(view.term);
|
2002-01-06 19:05:37 -07:00
|
|
|
|
|
|
|
} // end if
|
|
|
|
else if (conf!=null)
|
|
|
|
{ // search the conference
|
2002-01-09 16:45:27 -07:00
|
|
|
view.results = conf.searchPosts(view.term,view.offset,view.maxResults);
|
2002-01-06 19:05:37 -07:00
|
|
|
if (view.findCount<0)
|
2002-01-09 16:45:27 -07:00
|
|
|
view.findCount = conf.getSearchPostCount(view.term);
|
2002-01-06 19:05:37 -07:00
|
|
|
|
|
|
|
} // end else if
|
|
|
|
else
|
|
|
|
{ // search the community
|
2002-01-09 16:45:27 -07:00
|
|
|
view.results = comm.searchPosts(view.term,view.offset,view.maxResults);
|
2002-01-06 19:05:37 -07:00
|
|
|
if (view.findCount<0)
|
2002-01-09 16:45:27 -07:00
|
|
|
view.findCount = comm.getSearchPostCount(view.term);
|
2002-01-06 19:05:37 -07:00
|
|
|
|
|
|
|
} // end else
|
|
|
|
|
|
|
|
rc = view;
|
|
|
|
|
|
|
|
} // end try
|
|
|
|
catch (e)
|
|
|
|
{ // error doing the find
|
|
|
|
etype = vlib.exceptionType(e) + "";
|
|
|
|
if (etype.match("DataException"))
|
|
|
|
rc = new ErrorBox("Database Error","Database error on find: " + e.message,on_error);
|
|
|
|
else if (etype.match("AccessError"))
|
|
|
|
rc = new ErrorBox("Access Error",e.message,on_error);
|
|
|
|
else
|
|
|
|
rc = e;
|
|
|
|
|
|
|
|
} // end catch
|
|
|
|
|
|
|
|
vlib.output(rc);
|