venice-dynamo-rewrite/venice-data/scripts/comm/profile.js
2003-06-17 01:41:36 +00:00

108 lines
4.5 KiB
JavaScript

// 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);
importPackage(java.util);
importPackage(Packages.com.silverwrist.util);
importClass(Packages.com.silverwrist.dynamo.Namespaces);
importPackage(Packages.com.silverwrist.dynamo.except);
importPackage(Packages.com.silverwrist.dynamo.iface);
importPackage(Packages.com.silverwrist.venice.content);
importPackage(Packages.com.silverwrist.venice.iface);
importPackage(Packages.com.silverwrist.venice.menu);
req = bsf.lookupBean("request");
req_help = bsf.lookupBean("request_help");
user = vlib.getUser(req);
comm = vlib.getCommunity(req);
// get the global properties store
globals = vcast.getGlobalPropertiesStore(req);
// Construct the VelocityView we want to use.
rc = new VelocityView(comm.getName() + ": Profile","comm/profile.vm");
rc.menuSelector = "community";
rc.pageQID = "comm/profile.js.vs?cc=" + comm.getCID();
rc.setParameter("community",comm);
// Get a rendering for the community logo.
logorender = vcast.queryRenderImage(req_help.getRequestObject(Namespaces.DYNAMO_OBJECT_NAMESPACE,
"venice-communitylogo"));
logo_url = PropertyUtils.getPropertyNoErr(comm,VeniceNamespaces.COMMUNITY_PROFILE_NAMESPACE,"url.logo");
if (logo_url==null)
{ // get the logo default
url = globals.getObject(VeniceNamespaces.COMMUNITY_GLOBALS_NAMESPACE,"community.nologo.url");
urltype = globals.getObject(VeniceNamespaces.COMMUNITY_GLOBALS_NAMESPACE,"community.nologo.url.type");
rewriter = cast.queryURLRewriter(req);
logo_url = rewriter.rewriteURL(urltype,url);
} // end if
rc.setParameter("logo",logorender.getRenderingObject(logo_url));
// Get the "use category" flag.
opts = cast.toOptionSet(globals.getObject(VeniceNamespaces.COMMUNITY_GLOBALS_NAMESPACE,"options"));
if (opts.get(0))
rc.setParameter("use_category",Boolean.TRUE);
// Set the parameters that correspond to single properties.
rc.setParameter("synopsis",PropertyUtils.getPropertyNoErr(comm,VeniceNamespaces.COMMUNITY_PROFILE_NAMESPACE,
"synopsis"));
rc.setParameter("rules",PropertyUtils.getPropertyNoErr(comm,VeniceNamespaces.COMMUNITY_PROFILE_NAMESPACE,"rules"));
rc.setParameter("language",comm.getObject(VeniceNamespaces.COMMUNITY_PROFILE_NAMESPACE,"language"));
// Fill in the location list.
locs = new ArrayList();
tmp = PropertyUtils.getPropertyNoErr(comm,VeniceNamespaces.COMMUNITY_PROFILE_NAMESPACE,"company.name");
if (stringutils.isNotEmpty(tmp))
locs.add(tmp);
tmp = PropertyUtils.getPropertyNoErr(comm,VeniceNamespaces.COMMUNITY_PROFILE_NAMESPACE,"address.1");
if (stringutils.isNotEmpty(tmp))
locs.add(tmp);
tmp = PropertyUtils.getPropertyNoErr(comm,VeniceNamespaces.COMMUNITY_PROFILE_NAMESPACE,"address.2");
if (stringutils.isNotEmpty(tmp))
locs.add(tmp);
tmp = "";
t_city = PropertyUtils.getPropertyNoErr(comm,VeniceNamespaces.COMMUNITY_PROFILE_NAMESPACE,"locality");
t_state = PropertyUtils.getPropertyNoErr(comm,VeniceNamespaces.COMMUNITY_PROFILE_NAMESPACE,"region");
if (stringutils.isNotEmpty(t_city))
{ // combine these in a proper manner
if (stringutils.isNotEmpty(t_state))
tmp = t_city + ", " + t_state;
else
tmp = t_city;
} // end if
else if (stringutils.isNotEmpty(t_state))
tmp = t_state;
t_zip = PropertyUtils.getPropertyNoErr(comm,VeniceNamespaces.COMMUNITY_PROFILE_NAMESPACE,"postal.code");
if (stringutils.isNotEmpty(t_zip))
{ // tack postal code on at the end
if (stringutils.isNotEmpty(tmp))
tmp += " ";
tmp += t_zip;
} // end if
if (stringutils.isNotEmpty(tmp))
locs.add(tmp);
tmp = PropertyUtils.getPropertyNoErr(comm,VeniceNamespaces.COMMUNITY_PROFILE_NAMESPACE,"country");
if (tmp!=null)
locs.add(tmp.getName());
rc.setParameter("location",locs);
dynamo.scriptOutput(rc); // all done!