implemented the first baby steps of "Find"...a "Find Categories" function

This commit is contained in:
Eric J. Bowersox
2003-05-26 09:58:35 +00:00
parent 0ffd03e38b
commit 25569583ea
13 changed files with 306 additions and 27 deletions

View File

@@ -0,0 +1,23 @@
// 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.
//
// The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
// for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
// Copyright (C) 2003 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
//
// Contributor(s):
importPackage(Packages.com.silverwrist.dynamo.util);
req = bsf.lookupBean("request"); // get request
rhelp = bsf.lookupBean("request_help"); // get request helper
// TEMPORARY - redirect to the one find page we have implemented, Categories
dynamo.scriptOutput(new Redirect("SERVLET","find_categories.js.vs"));

View File

@@ -0,0 +1,96 @@
// 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.
//
// The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
// for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
// Copyright (C) 2003 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
//
// Contributor(s):
importPackage(java.lang);
importClass(Packages.com.silverwrist.dynamo.Namespaces);
importPackage(Packages.com.silverwrist.dynamo.iface);
importPackage(Packages.com.silverwrist.dynamo.util);
importClass(Packages.com.silverwrist.venice.SearchMode);
importClass(Packages.com.silverwrist.venice.VeniceNamespaces);
importPackage(Packages.com.silverwrist.venice.community);
importPackage(Packages.com.silverwrist.venice.content);
req = bsf.lookupBean("request"); // get request
rhelp = bsf.lookupBean("request_help"); // get request helper
user = vlib.getUser(req); // get user
// Get the user's configured page size.
pagesize = cast.toInteger(user.getObject(VeniceNamespaces.USER_SETTINGS_NAMESPACE,"search.result.count"));
mode = SearchMode.PREFIX;
term = "";
ofs = 0;
fcount = -1;
results = null;
rc = null;
if (rhelp.isVerb("POST"))
{ // Read the form parameters
mode = SearchMode.getEnum(rhelp.getParameter("mode"));
term = rhelp.getParameter("term");
ofs = rhelp.getParameterInt("ofs",0);
fcount = rhelp.getParameterInt("fcount",-1);
// Adjust offset based on the button that was clicked.
if (rhelp.isImageButtonClicked("search"))
{ // beginning of a new search
ofs = 0;
fcount = -1;
} // end if
else if (rhelp.isImageButtonClicked("previous"))
ofs = Math.max(ofs - pagesize,0);
else if (rhelp.isImageButtonClicked("next"))
ofs += pagesize;
// Get the category service object.
catsvc = vcast.queryCategoryService(rhelp.getRequestObject(Namespaces.DYNAMO_OBJECT_NAMESPACE,"categories"));
try
{ // search for categories!
if (fcount<0)
fcount = catsvc.getSearchCategoryCount(mode,term);
results = catsvc.searchForCategories(mode,term,ofs,pagesize);
} // end try
catch (e)
{ // exception thrown
rc = new ErrorBox("Database Error",e,"SERVLET","find_categories.js.vs");
} // end catch
} // end else
if (rc==null)
{ // create the VelocityView for the output
rc = new VelocityView("Find Categories","find_categories.vm");
rc.setParameter("mode",mode.getName());
rc.setParameter("term",term.toString());
rc.setParameter("ofs",cast.toIntegerObject(ofs));
rc.setParameter("fcount",cast.toIntegerObject(fcount));
rc.setParameter("pagesize",cast.toIntegerObject(pagesize));
if (results!=null)
rc.setParameter("results",results);
// Load the profile menu.
mprov = vcast.queryMenuProvider(req_help.getRequestObject(Namespaces.DYNAMO_OBJECT_NAMESPACE,"venice-menus"));
menu = mprov.getInlineMenu(user,VeniceNamespaces.CONTENT_LAF_NAMESPACE,"find.menu",cast.newIntArray(0));
menu.setSelectedIndex(0);
rc.setParameter("menu",menu);
} // end if
dynamo.scriptOutput(rc);

View File

@@ -120,6 +120,7 @@ if (req_help.isVerb("GET"))
dlg.setValue("no_mass_mail",cast.booleanObject(user.isNoSpam()));
dlg.setValue("locale",user.getObject(VeniceNamespaces.USER_SETTINGS_NAMESPACE,"locale"));
dlg.setValue("tz",user.getObject(VeniceNamespaces.USER_SETTINGS_NAMESPACE,"timezone"));
dlg.setValue("scount",user.getObject(VeniceNamespaces.USER_SETTINGS_NAMESPACE,"search.result.count"));
// prepare the dialog and return it
dlg.setRenderParam("rtgt",stringutils.encodeURL(target));
@@ -226,6 +227,7 @@ if (op=="update")
user.setNoSpam(user,cast.toBoolean(dlg.getValue("no_mass_mail")));
user.setObject(user,VeniceNamespaces.USER_SETTINGS_NAMESPACE,"locale",dlg.getValue("locale"));
user.setObject(user,VeniceNamespaces.USER_SETTINGS_NAMESPACE,"timezone",dlg.getValue("tz"));
user.setObject(user,VeniceNamespaces.USER_SETTINGS_NAMESPACE,"search.result.count",dlg.getValue("scount"));
user.setObject(user,VeniceNamespaces.USER_PROFILE_NAMESPACE,"privacy",priv);
// Set the "profile last updated" date for the user.