Reworked the sidebox implementation to depend less on the database and more

on XML config files...the implementation should now be much more customizable
and less klunky.  Added a provision for implementing "generic" (JSP-driven)
sideboxes.  Implemented the sidebox configure button on the front page
(finally!).  Implemented a random password generator class which will be used
in a future implementation of reminder-driven automatic forgotten-password
changing.  Fixed some minor funnies in SIG menu generation.
This commit is contained in:
Eric J. Bowersox
2001-11-04 05:57:58 +00:00
parent bf040973ba
commit 1c69955046
32 changed files with 2049 additions and 495 deletions

View File

@@ -87,6 +87,24 @@ public class Settings extends VeniceServlet
} // end findHotlistIndex
private static int getBoxIDParameter(ServletRequest request) throws ErrorBox
{
String foo = request.getParameter("box");
if (foo==null)
throw new ErrorBox(null,"Parameter not specified!","settings?cmd=B");
try
{ // parse the integer and get the box ID
return Integer.parseInt(foo);
} // end try
catch (NumberFormatException e)
{ // error in parsing...
throw new ErrorBox(null,"Parameter invalid!","settings?cmd=B");
} // end catch
} // end getBoxIDParameter
/*--------------------------------------------------------------------------------
* Overrides from class HttpServlet
*--------------------------------------------------------------------------------
@@ -258,10 +276,148 @@ public class Settings extends VeniceServlet
} // end if ("SX" command)
if (cmd.equals("B"))
{ // "B" - Configure Sideboxes
try
{ // return the sidebox viewer
setMyLocation(request,"settings?cmd=B");
return new SideBoxList(engine,user);
} // end try
catch (DataException de)
{ // Database error getting sidebox list
return new ErrorBox("Database Error","Error getting sidebox list: " + de.getMessage(),"top");
} // end catch
} // end if ("B" command)
if (cmd.equals("BU") || cmd.equals("BD") || cmd.equals("BX"))
{ // move sidebox up or down in list, or delete it
int boxid = getBoxIDParameter(request);
try
{ // get the box ID, find it in the list
List sidebox_list = user.getSideBoxList();
UserSideBoxDescriptor prev = null;
UserSideBoxDescriptor curr = null;
Iterator it = sidebox_list.iterator();
boolean found = false;
while (!found && it.hasNext())
{ // track the previous descriptor so we can do the swap
prev = curr;
curr = (UserSideBoxDescriptor)(it.next());
if (curr.getID()==boxid)
{ // found it - trip the loop exit
found = true;
if (cmd.equals("BD"))
{ // make "prev" actually be the NEXT descriptor
if (it.hasNext())
prev = (UserSideBoxDescriptor)(it.next());
else
prev = null;
} // end if
} // end if (found)
} // end while
if (found)
{ // the current one needs to be operated on
if (cmd.equals("BX"))
curr.remove(); // remove the "current" sidebox
else if (prev!=null)
{ // exchange the sequence numbers of "curr" and "prev"
int seq_curr = curr.getSequence();
int seq_prev = prev.getSequence();
curr.setSequence(seq_prev); // do the first "set"
boolean restore = true;
try
{ // do the second "set"
prev.setSequence(seq_curr);
restore = false;
} // end try
finally
{ // restore first if second failed
if (restore)
curr.setSequence(seq_curr);
} // end finally
} // end else if
// else just fall out and do nothing
} // end if
// else just fall out and don't do anything
} // end try
catch (DataException de)
{ // there was a data problem
return new ErrorBox("Database Error","Error adjusting sidebox list: " + de.getMessage(),
"settings?cmd=B");
} // end catch
try
{ // return the sidebox viewer
setMyLocation(request,"settings?cmd=B");
return new SideBoxList(engine,user);
} // end try
catch (DataException de)
{ // Database error getting sidebox list
return new ErrorBox("Database Error","Error getting sidebox list: " + de.getMessage(),"top");
} // end catch
} // end if ("BD"/"BU"/"BX" commands)
// command not found!
logger.error("invalid command to Settings.doGet: " + cmd);
return new ErrorBox("Internal Error","Invalid command to Settings.doGet","top");
} // end doVeniceGet
protected VeniceContent doVenicePost(HttpServletRequest request, VeniceEngine engine,
UserContext user, RenderData rdat)
throws ServletException, IOException, VeniceServletResult
{
String cmd = getStandardCommandParam(request);
if (cmd.equals("BA"))
{ // "BA" - add new sidebox
int boxid = getBoxIDParameter(request);
try
{ // add the sidebox
user.addSideBox(boxid);
} // end try
catch (DataException de)
{ // error adding to sideboxes
return new ErrorBox("Database Error","Error adding to sidebox list: " + de.getMessage(),
"settings?cmd=B");
} // end catch
try
{ // return the sidebox viewer
setMyLocation(request,"settings?cmd=B");
return new SideBoxList(engine,user);
} // end try
catch (DataException de)
{ // Database error getting sidebox list
return new ErrorBox("Database Error","Error getting sidebox list: " + de.getMessage(),"top");
} // end catch
} // end if ("BA" command)
// command not found!
logger.error("invalid command to Settings.doGet: " + cmd);
return new ErrorBox("Internal Error","Invalid command to Settings.doGet","top");
} // end doVenicePost
} // end class Settings

View File

@@ -80,7 +80,7 @@ public class Variables
try
{ // extract the configuration file name and create the engine
VeniceEngine engine = Startup.createEngine(cfgfile);
VeniceEngine engine = Startup.createEngine(cfgfile,root_file_path);
ctxt.setAttribute(ENGINE_ATTRIBUTE,engine);
return engine;

View File

@@ -7,7 +7,7 @@
* 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 Community System.
* 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

View File

@@ -29,10 +29,14 @@ import org.xml.sax.SAXParseException;
import com.silverwrist.util.DOMElementHelper;
import com.silverwrist.util.IOUtil;
import com.silverwrist.util.StringUtil;
import com.silverwrist.venice.core.AccessError;
import com.silverwrist.venice.core.ConfigException;
import com.silverwrist.venice.core.DataException;
import com.silverwrist.venice.core.UserContext;
import com.silverwrist.venice.core.VeniceEngine;
import com.silverwrist.venice.servlets.Variables;
import com.silverwrist.venice.servlets.format.menus.LeftMenu;
import com.silverwrist.venice.servlets.format.sideboxes.SideBoxFactory;
public class RenderConfig implements ColorSelectors
{
@@ -44,7 +48,7 @@ public class RenderConfig implements ColorSelectors
protected static final String ATTR_NAME = "com.silverwrist.venice.servlets.RenderConfig";
protected static final String CONFIG_FILE_PARAM = "render.config";
private static Category logger = Category.getInstance(RenderConfig.class.getName());
private static Category logger = Category.getInstance(RenderConfig.class);
private static Map colornames_map;
@@ -71,6 +75,7 @@ public class RenderConfig implements ColorSelectors
private HashMap menus;
private String[] colors_array;
private int footer_logo_scale;
private Map sidebox_factories;
/*--------------------------------------------------------------------------------
* Constructor
@@ -263,6 +268,101 @@ public class RenderConfig implements ColorSelectors
if (logger.isDebugEnabled())
logger.debug("Site logo: " + site_logo);
// Load the sidebox configuration information.
String sidebox_config = paths_sect_h.getSubElementText("sidebox-config");
if (sidebox_config==null)
{ // the sidebox config was not present
logger.fatal("<paths/> section has no <sidebox-config/> element");
throw new ConfigException("no <sidebox-config/> found in <paths/> section",paths_sect);
} // end if
if (!(sidebox_config.startsWith("/")))
sidebox_config = root_file_path + sidebox_config;
Document sb_doc = loadConfiguration(sidebox_config);
Element sb_root = sb_doc.getDocumentElement();
if (!(sb_root.getTagName().equals("sidebox-config")))
{ // the sidebox configuration file isn't the right type
logger.fatal("config document is not a <sidebox-config/> document (root tag: <"
+ sb_root.getTagName() + "/>)");
throw new ConfigException("document is not a <sidebox-config/> document",sb_root);
} // end if
NodeList sb_nodes = sb_root.getChildNodes();
HashMap tmp_factories = new HashMap();
for (i=0; i<sb_nodes.getLength(); i++)
{ // extract each sidebox section from the list and build a new master sidebox object
Node s = sb_nodes.item(i);
if ((s.getNodeType()==Node.ELEMENT_NODE) && (s.getNodeName().equals("sidebox")))
{ // get the various attributes of the sidebox
Element sb = (Element)s;
try
{ // get the ID of the sidebox first
tmp = sb.getAttribute("id");
if (StringUtil.isStringEmpty(tmp))
{ // there was no ID specified for the sidebox
logger.fatal("<sidebox/> specified with no ID!");
throw new ConfigException("no ID specified in <sidebox/>",sb);
} // end if
// convert to an integer which we'll be using later in the HashMap
Integer id = new Integer(tmp);
// get the name of the factory class
DOMElementHelper sb_h = new DOMElementHelper(sb);
tmp = sb_h.getSubElementText("factory-class");
if (StringUtil.isStringEmpty(tmp))
{ // the factory class was not specified!
logger.fatal("<sidebox/> config incomplete (missing <factory-class/>)!");
throw new ConfigException("configuration of <sidebox/> is not complete!",sb);
} // end if
Class factory_class = Class.forName(tmp);
SideBoxFactory factory = (SideBoxFactory)(factory_class.newInstance());
factory.setConfiguration(sb);
tmp_factories.put(id,factory);
} // end if
catch (NumberFormatException e1)
{ // ID value was not an integer
logger.fatal("<sidebox/> ID not numeric!");
throw new ConfigException("non-numeric ID specified in <sidebox/>",sb);
} // end catch
catch (ClassNotFoundException e2)
{ // sidebox could not be configured
logger.fatal("<sidebox/> config <factory-class/> not valid!",e2);
throw new ConfigException("<factory-class/> in <sidebox/> is not a valid class!",sb);
} // end catch
catch (IllegalAccessException e3)
{ // could not access class and/or constructor
logger.fatal("<sidebox/> <factory-class/> is not accessible!",e3);
throw new ConfigException("<factory-class/> in <sidebox/> is not accessible!",sb);
} // end catch
catch (InstantiationException e4)
{ // unable to create the class
logger.fatal("<sidebox/> <factory-class/> could not be instantiated!",e4);
throw new ConfigException("<factory-class/> in <sidebox/> could not be created!",sb);
} // end catch
catch (ClassCastException e5)
{ // the class is not a SideBoxFactory implementor - cannot create
logger.fatal("<sidebox/> <factory-class/> is not a SideBoxFactory!",e5);
throw new ConfigException("<factory-class/> in <sidebox/> is not the correct type!",sb);
} // end catch
} // end if
} // end for
sidebox_factories = Collections.unmodifiableMap(tmp_factories);
Element msg_sect = root_h.getSubElement("messages");
if (msg_sect==null)
{ // no <messages/> section - bail out now!
@@ -602,6 +702,15 @@ public class RenderConfig implements ColorSelectors
} // end useStyleSheet
VeniceContent createSideBox(int id, VeniceEngine engine, UserContext uc) throws AccessError, DataException
{
SideBoxFactory fact = (SideBoxFactory)(sidebox_factories.get(new Integer(id)));
if (fact==null)
throw new DataException("invalid sidebox ID!");
return fact.create(engine,uc);
} // end createSideBox
/*--------------------------------------------------------------------------------
* Static operations for use by VeniceServlet
*--------------------------------------------------------------------------------

View File

@@ -28,6 +28,7 @@ import com.silverwrist.util.StringUtil;
import com.silverwrist.venice.core.DataException;
import com.silverwrist.venice.core.IDUtils;
import com.silverwrist.venice.core.UserContext;
import com.silverwrist.venice.core.VeniceEngine;
import com.silverwrist.venice.db.PostLinkRewriter;
import com.silverwrist.venice.db.UserNameRewriter;
import com.silverwrist.venice.servlets.format.menus.LeftMenu;

View File

@@ -1,115 +0,0 @@
/*
* 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) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
*
* Contributor(s):
*/
package com.silverwrist.venice.servlets.format;
import java.io.*;
import java.util.*;
import com.silverwrist.util.StringUtil;
import com.silverwrist.venice.core.*;
public class SideBoxConferences implements ContentRender, ColorSelectors
{
/*--------------------------------------------------------------------------------
* Attributes
*--------------------------------------------------------------------------------
*/
private UserContext uc;
private List hotlist;
/*--------------------------------------------------------------------------------
* Constructor
*--------------------------------------------------------------------------------
*/
public SideBoxConferences(UserContext uc, String parameter) throws DataException
{
this.uc = uc;
this.hotlist = uc.getConferenceHotlist();
} // end constructor
/*--------------------------------------------------------------------------------
* Implementations from interface VeniceContent
*--------------------------------------------------------------------------------
*/
public String getPageTitle(RenderData rdat)
{
if (uc.isLoggedIn())
return "Your Conference Hotlist:";
else
return "Featured Conferences:";
} // end getPageTitle
public String getPageQID()
{
return null;
} // end getPageQID
/*--------------------------------------------------------------------------------
* Implementations from interface ContentRender
*--------------------------------------------------------------------------------
*/
public void renderHere(Writer out, RenderData rdat) throws IOException
{
String norm_font = rdat.getStdFontTag(SIDEBOX_CONTENT_FOREGROUND,2);
String hilite = rdat.getStdFontTag(SIDEBOX_CONTENT_LINK,2);
String purple_ball = rdat.getFullImagePath("purple-ball.gif");
String new_image = rdat.getFullImagePath("tag_new.gif");
if (hotlist.size()>0)
{ // display the list of conferences
out.write("<TABLE ALIGN=CENTER BORDER=0 CELLPADDING=0 CELLSPACING=2>\n");
Iterator it = hotlist.iterator();
while (it.hasNext())
{ // display the names of the conferences and SIGs one by one
ConferenceHotlistEntry hle = (ConferenceHotlistEntry)(it.next());
ConferenceContext conf = hle.getConference();
String href = "confdisp?sig=" + conf.getEnclosingSIG().getSIGID() + "&conf=" + conf.getConfID();
out.write("<TR VALIGN=MIDDLE>\n<TD ALIGN=CENTER WIDTH=14><IMG SRC=\"" + purple_ball
+ "\" ALT=\"*\" WIDTH=14 HEIGHT=14 BORDER=0></TD>\n<TD ALIGN=LEFT CLASS=\"sidebox\">\n"
+ norm_font + "<B><A CLASS=\"sidebox\" HREF=\"" + rdat.getEncodedServletPath(href) + "\">"
+ hilite + StringUtil.encodeHTML(conf.getName()) + "</FONT></A></B> ("
+ StringUtil.encodeHTML(conf.getEnclosingSIG().getName()) + ")</FONT>\n");
if (conf.anyUnread())
out.write("&nbsp;<A HREF=\"" + rdat.getEncodedServletPath(href + "&rnm=1") + "\"><IMG SRC=\""
+ new_image + "\" ALT=\"New!\" BORDER=0 WIDTH=40 HEIGHT=20></A>\n");
out.write("</TD>\n</TR>\n");
} // end while
out.write("</TABLE>\n");
} // end if
else
out.write(norm_font + "<EM>You have no conferences in your hotlist.</EM></FONT>\n");
if (uc.isLoggedIn())
{ // write the link at the end
out.write("<P>" + rdat.getStdFontTag(SIDEBOX_CONTENT_FOREGROUND,1) + "<B>[ <A CLASS=\"sidebox\" HREF=\""
+ rdat.getEncodedServletPath("settings?cmd=H") + "\">"
+ rdat.getStdFontTag(SIDEBOX_CONTENT_LINK,1) + "Manage</FONT></A> ]</B></FONT>");
} // end if
} // end renderHere
} // end class SideBoxConferences

View File

@@ -0,0 +1,156 @@
/*
* 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) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
*
* Contributor(s):
*/
package com.silverwrist.venice.servlets.format;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
import com.silverwrist.venice.core.*;
public class SideBoxList implements JSPRender
{
/*--------------------------------------------------------------------------------
* Static data members
*--------------------------------------------------------------------------------
*/
// Attribute name for request attribute
protected static final String ATTR_NAME = "com.silverwrist.venice.content.SideBoxList";
/*--------------------------------------------------------------------------------
* Attributes
*--------------------------------------------------------------------------------
*/
private UserContext uc; // user context
private List in_list; // sideboxes that are "in"
private List out_list; // sideboxes that are "out"
/*--------------------------------------------------------------------------------
* Constructor
*--------------------------------------------------------------------------------
*/
public SideBoxList(VeniceEngine engine, UserContext uc) throws DataException
{
this.uc = uc;
this.in_list = uc.getSideBoxList();
HashSet ids = new HashSet(in_list.size());
Iterator it = in_list.iterator();
while (it.hasNext())
{ // add the IDs of all the sideboxes to the set
SideBoxDescriptor d = (SideBoxDescriptor)(it.next());
ids.add(new Integer(d.getID()));
} // end while
List all_list = engine.getMasterSideBoxList();
if (all_list.size()>in_list.size())
{ // allocate an ArrayList to hold the sideboxes
out_list = new ArrayList(all_list.size()-in_list.size());
it = all_list.iterator();
while (it.hasNext())
{ // get all sideboxes not in the "in" list and put them in the "out" list
SideBoxDescriptor d = (SideBoxDescriptor)(it.next());
if (!(ids.contains(new Integer(d.getID()))))
out_list.add(d);
} // end while
} // end if
else // all sideboxes are "in"...
out_list = Collections.EMPTY_LIST;
} // end constructor
/*--------------------------------------------------------------------------------
* External static functions
*--------------------------------------------------------------------------------
*/
public static SideBoxList retrieve(ServletRequest request)
{
return (SideBoxList)(request.getAttribute(ATTR_NAME));
} // end retrieve
/*--------------------------------------------------------------------------------
* Implementations from interface VeniceContent
*--------------------------------------------------------------------------------
*/
public String getPageTitle(RenderData rdat)
{
return "Your Front Page Configuration";
} // end getPageTitle
public String getPageQID()
{
return null;
} // end getPageQID
/*--------------------------------------------------------------------------------
* Implementations from interface JSPRender
*--------------------------------------------------------------------------------
*/
public void store(ServletRequest request)
{
request.setAttribute(ATTR_NAME,this);
} // end store
public String getTargetJSPName()
{
return "sideboxlist.jsp";
} // end getTargetJSPName
/*--------------------------------------------------------------------------------
* External operations
*--------------------------------------------------------------------------------
*/
public int getInListSize()
{
return in_list.size();
} // end getInListSize
public SideBoxDescriptor getInListItem(int index)
{
return (SideBoxDescriptor)(in_list.get(index));
} // end getInListItem
public int getOutListSize()
{
return out_list.size();
} // end getOutListSize
public SideBoxDescriptor getOutListItem(int index)
{
return (SideBoxDescriptor)(out_list.get(index));
} // end getInListItem
} // end class SideBoxList

View File

@@ -1,121 +0,0 @@
/*
* 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) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
*
* Contributor(s):
*/
package com.silverwrist.venice.servlets.format;
import java.io.*;
import java.util.*;
import com.silverwrist.util.StringUtil;
import com.silverwrist.venice.core.*;
public class SideBoxSIGs implements ContentRender, ColorSelectors
{
/*--------------------------------------------------------------------------------
* Attributes
*--------------------------------------------------------------------------------
*/
private UserContext uc;
private List sig_list;
/*--------------------------------------------------------------------------------
* Constructor
*--------------------------------------------------------------------------------
*/
public SideBoxSIGs(UserContext uc, String parameter) throws DataException
{
this.uc = uc;
this.sig_list = uc.getMemberSIGs();
} // end constructor
/*--------------------------------------------------------------------------------
* Implementations from interface VeniceContent
*--------------------------------------------------------------------------------
*/
public String getPageTitle(RenderData rdat)
{
if (uc.isLoggedIn())
return "Your SIGs:";
else
return "Featured SIGs:";
} // end getPageTitle
public String getPageQID()
{
return null;
} // end getPageQID
/*--------------------------------------------------------------------------------
* Implementations from interface ContentRender
*--------------------------------------------------------------------------------
*/
public void renderHere(Writer out, RenderData rdat) throws IOException
{
if (sig_list.size()>0)
{ // display the list of available SIGs
String purple_ball = rdat.getFullImagePath("purple-ball.gif");
String link_font = rdat.getStdFontTag(SIDEBOX_CONTENT_LINK,2);
String host_image = null;
out.write("<TABLE ALIGN=CENTER BORDER=0 CELLPADDING=0 CELLSPACING=2>\n");
Iterator it = sig_list.iterator();
while (it.hasNext())
{ // display the names of the SIGs one by one
SIGContext sig = (SIGContext)(it.next());
out.write("<TR VALIGN=MIDDLE>\n<TD ALIGN=CENTER WIDTH=14><IMG SRC=\"" + purple_ball
+ "\" ALT=\"*\" WIDTH=14 HEIGHT=14 BORDER=0></TD>\n<TD ALIGN=LEFT CLASS=\"sidebox\">\n"
+ "<A CLASS=\"sidebox\" HREF=\"" + rdat.getEncodedServletPath("sig/" + sig.getAlias())
+ "\">" + link_font + "<B>" + StringUtil.encodeHTML(sig.getName()) + "</B></FONT></A>\n");
if (sig.isAdmin())
{ // write the "Host!" image at the end
if (host_image==null)
host_image = rdat.getFullImagePath("tag_host.gif");
out.write("&nbsp;<IMG SRC=\"" + host_image + "\" ALT=\"Host!\" BORDER=0 WIDTH=40 HEIGHT=20>\n");
} // end if
out.write("</TD>\n</TR>\n");
} // end while
out.write("</TABLE>\n");
} // end if
else
out.write(rdat.getStdFontTag(SIDEBOX_CONTENT_FOREGROUND,2)
+ "<EM>You are not a member of any SIGs.</EM></FONT>\n");
if (uc.isLoggedIn())
{ // write the two links at the end
String hilite = rdat.getStdFontTag(SIDEBOX_CONTENT_LINK,1);
out.write("<P>" + rdat.getStdFontTag(SIDEBOX_CONTENT_FOREGROUND,1) + "<B>[ <A CLASS=\"sidebox\" HREF=\""
+ rdat.getEncodedServletPath("settings?cmd=S") + "\">" + hilite
+ "Manage</FONT></A> | <A CLASS=\"sidebox\" HREF=\""
+ rdat.getEncodedServletPath("sigops?cmd=C") + "\">" + hilite
+ "Create New</FONT></A> ]</B></FONT>");
} // end if
} // end renderHere
} // end class SideBoxSIGs

View File

@@ -52,7 +52,7 @@ public class TopDisplay implements ContentRender, ColorSelectors
*/
public TopDisplay(ServletContext ctxt, VeniceEngine engine, UserContext uc)
throws DataException, AccessError, ErrorBox
throws ServletException, DataException, AccessError
{
// Stash some basic information.
this.ctxt = ctxt;
@@ -61,72 +61,13 @@ public class TopDisplay implements ContentRender, ColorSelectors
this.top_posts = engine.getPublishedMessages(false);
this.descrs = uc.getSideBoxList();
// Create the arrays used to construct sideboxes.
Class[] ctor_argtypes = new Class[2];
ctor_argtypes[0] = UserContext.class;
ctor_argtypes[1] = String.class;
Object[] ctor_args = new Object[2];
ctor_args[0] = uc;
// Create the actual sideboxes.
// Create the sideboxes.
sideboxes = new VeniceContent[descrs.size()];
RenderConfig rconf = RenderConfig.getRenderConfig(ctxt);
for (int i=0; i<descrs.size(); i++)
{ // create each sidebox in turn...
SideBoxDescriptor d = (SideBoxDescriptor)(descrs.get(i));
String cn = "com.silverwrist.venice.servlets.format." + d.getClassname();
try
{ // get the class name and the constructor pointer
Class sb_class = Class.forName(cn);
if (!(VeniceContent.class.isAssignableFrom(sb_class)))
throw new ErrorBox(null,"Invalid sidebox class: " + cn,null);
java.lang.reflect.Constructor ctor = sb_class.getDeclaredConstructor(ctor_argtypes);
// create the side box!
ctor_args[1] = d.getParameter();
sideboxes[i] = (VeniceContent)(ctor.newInstance(ctor_args));
} // end try
catch (ClassNotFoundException cnfe)
{ // Class.forName didn't work? yIkes!
throw new ErrorBox(null,"Cannot find sidebox class: " + cn,null);
} // end catch
catch (NoSuchMethodException nsme)
{ // no constructor matching the prototype? yIkes!
throw new ErrorBox(null,"Cannot find sidebox class constructor: " + cn,null);
} // end catch
catch (SecurityException se)
{ // how'd we trip the security manager? oh well...
throw new ErrorBox(null,"Security violation on class: " + cn,null);
} // end catch
catch (InstantiationException ie)
{ // the target class is an abstract class - oh, that's not right!
throw new ErrorBox(null,"Invalid sidebox class: " + cn,null);
} // end catch
catch (IllegalAccessException iae1)
{ // the constructor isn't public - oh, that's not right!
throw new ErrorBox(null,"Invalid sidebox class: " + cn,null);
} // end catch
catch (IllegalArgumentException iae2)
{ // the arguments to the constructor are wrong - we should've caught this!
throw new ErrorBox(null,"Invalid constructor call: " + cn,null);
} // end catch
catch (java.lang.reflect.InvocationTargetException ite)
{ // the constructor itself threw an exception
Throwable sub_e = ite.getTargetException();
if (sub_e instanceof DataException)
throw (DataException)sub_e;
if (sub_e instanceof AccessError)
throw (AccessError)sub_e;
throw new ErrorBox(null,"Unknown exception creating: " + cn,null);
} // end catch
sideboxes[i] = rconf.createSideBox(d.getID(),engine,uc);
} // end for
@@ -196,8 +137,7 @@ public class TopDisplay implements ContentRender, ColorSelectors
out.write("<TABLE ALIGN=CENTER WIDTH=200 BORDER=0 CELLPADDING=2 CELLSPACING=0>"
+ "<TR VALIGN=MIDDLE BGCOLOR=\"" + rdat.getStdColor(SIDEBOX_TITLE_BACKGROUND)
+ "\"><TD ALIGN=LEFT CLASS=\"sideboxtop\">\n"
+ rdat.getStdFontTag(SIDEBOX_TITLE_FOREGROUND,3) + "<B>"
+ StringUtil.encodeHTML(sideboxes[i].getPageTitle(rdat))
+ rdat.getStdFontTag(SIDEBOX_TITLE_FOREGROUND,3) + "<B>" + sideboxes[i].getPageTitle(rdat)
+ "</B></FONT>\n</TD></TR><TR VALIGN=TOP BGCOLOR=\""
+ rdat.getStdColor(SIDEBOX_CONTENT_BACKGROUND) + "\"><TD ALIGN=LEFT CLASS=\"sidebox\">\n");
@@ -243,7 +183,7 @@ public class TopDisplay implements ContentRender, ColorSelectors
if (uc.isLoggedIn())
{ // write the Configure button below the sideboxes
out.write("<A HREF=\"" + rdat.getEncodedServletPath("TODO") + "\"><IMG SRC=\""
out.write("<A HREF=\"" + rdat.getEncodedServletPath("settings?cmd=B") + "\"><IMG SRC=\""
+ rdat.getFullImagePath("bn_configure.gif")
+ "\" ALT=\"Configure\" WIDTH=80 HEIGHT=24 BORDER=0></A>\n");

View File

@@ -0,0 +1,277 @@
/*
* 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) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
*
* Contributor(s):
*/
package com.silverwrist.venice.servlets.format.sideboxes;
import java.io.*;
import java.util.*;
import org.w3c.dom.*;
import com.silverwrist.util.DOMElementHelper;
import com.silverwrist.util.StringUtil;
import com.silverwrist.venice.core.*;
import com.silverwrist.venice.servlets.format.*;
public class ConferenceBox implements SideBoxFactory
{
/*--------------------------------------------------------------------------------
* Internal class that implements the actual sidebox
*--------------------------------------------------------------------------------
*/
class ConferenceBoxImpl implements ContentRender, ColorSelectors
{
private UserContext uc; // current user context
private List hotlist; // current conference hotlist
ConferenceBoxImpl(UserContext uc) throws DataException
{
this.uc = uc;
this.hotlist = uc.getConferenceHotlist();
} // end constructor
public String getPageTitle(RenderData rdat)
{
if (uc.isLoggedIn())
return title;
else
return anon_title;
} // end getPageTitle
public String getPageQID()
{
return null;
} // end getPageQID
public void renderHere(Writer out, RenderData rdat) throws IOException
{
String norm_font = rdat.getStdFontTag(SIDEBOX_CONTENT_FOREGROUND,2);
if (hotlist.size()>0)
{ // write out the hotlist....
String hilite = rdat.getStdFontTag(SIDEBOX_CONTENT_LINK,2);
out.write("<TABLE ALIGN=CENTER BORDER=0 CELLPADDING=0 CELLSPACING=2>\n");
Iterator it = hotlist.iterator();
while (it.hasNext())
{ // get the next hotlist entry and add it to the display
ConferenceHotlistEntry hle = (ConferenceHotlistEntry)(it.next());
ConferenceContext conf = hle.getConference();
String href = "confdisp?sig=" + conf.getEnclosingSIG().getSIGID() + "&conf=" + conf.getConfID();
out.write("<TR VALIGN=MIDDLE>\n<TD ALIGN=CENTER WIDTH=" + bullet_width + ">");
renderBullet(out,rdat);
out.write("</TD>\n<TD ALIGN=LEFT CLASS=\"sidebox\">\n" + norm_font
+ "<B><A CLASS=\"sidebox\" HREF=\"" + rdat.getEncodedServletPath(href) + "\">" + hilite
+ StringUtil.encodeHTML(conf.getName()) + "</FONT></A></B> ("
+ StringUtil.encodeHTML(conf.getEnclosingSIG().getName()) + ")</FONT>\n");
if (conf.anyUnread())
{ // write out the new-messages tag and its enclosing link
out.write("&nbsp;<A HREF=\"" + rdat.getEncodedServletPath(href + "&rnm=1") + "\">");
renderNewMessageTag(out,rdat);
out.write("</A>\n");
} // end if
out.write("</TD>\n</TR>\n");
} // end while
out.write("</TABLE>\n");
} // end if
else // write the "null" message
out.write(norm_font + "<EM>" + null_message + "</EM></FONT>\n");
if (uc.isLoggedIn())
{ // write the link at the end
out.write("<P>" + rdat.getStdFontTag(SIDEBOX_CONTENT_FOREGROUND,1)
+ "<B>[ <A CLASS=\"sidebox\" HREF=\"" + rdat.getEncodedServletPath("settings?cmd=H") + "\">"
+ rdat.getStdFontTag(SIDEBOX_CONTENT_LINK,1) + manage_link + "</FONT></A> ]</B></FONT>");
} // end if
} // end renderHere
} // end class ConferenceBoxImpl
/*--------------------------------------------------------------------------------
* Attributes
*--------------------------------------------------------------------------------
*/
private String title; // title of sidebox for logged-in users
private String anon_title; // title of sidebox for not-logged-in users
private String null_message; // message if they have no hotlist conferences
private String manage_link; // "Manage" link text
private String bullet_url; // URL to bullet image
private boolean bullet_fixup; // does bullet image need to be run through getFullImagePath?
private int bullet_width; // width of bullet image
private int bullet_height; // height of bullet image
private String newmsg_url; // URL to new messages tag image
private boolean newmsg_fixup; // does new messages image need to be run through getFullImagePath?
private String newmsg_alt; // ALT text to use for new message tag image
private int newmsg_width; // width of new message tag image
private int newmsg_height; // height of new message tag image
/*--------------------------------------------------------------------------------
* Constructor
*--------------------------------------------------------------------------------
*/
public ConferenceBox()
{ // do nothing
} // end constructor
/*--------------------------------------------------------------------------------
* Internal operations
*--------------------------------------------------------------------------------
*/
private void renderBullet(Writer out, RenderData rdat) throws IOException
{
synchronized (this)
{ // this may be called by more than one class, so protect this part
if (bullet_fixup)
{ // fix up the bullet URL
bullet_url = rdat.getFullImagePath(bullet_url);
bullet_fixup = false;
} // end if
} // end synchronized block
out.write("<IMG SRC=\"" + bullet_url + "\" ALT=\"*\" WIDTH=" + bullet_width + " HEIGHT=" + bullet_height
+ " BORDER=0>");
} // end renderBullet
private void renderNewMessageTag(Writer out, RenderData rdat) throws IOException
{
synchronized (this)
{ // this may be called by more than one class, so protect this part
if (newmsg_fixup)
{ // fix up the host tag URL
newmsg_url = rdat.getFullImagePath(newmsg_url);
newmsg_fixup = false;
} // end if
} // end synchronized block
out.write("<IMG SRC=\"" + newmsg_url + "\" ALT=\"" + newmsg_alt + "\" WIDTH=" + newmsg_width + " HEIGHT="
+ newmsg_height + " BORDER=0>");
} // end renderNewMessageTag
/*--------------------------------------------------------------------------------
* Implementations from interface SideBoxFactory
*--------------------------------------------------------------------------------
*/
public void setConfiguration(Element cfg) throws ConfigException
{
DOMElementHelper cfg_h = new DOMElementHelper(cfg);
title = cfg_h.getSubElementText("title");
if (title==null)
throw new ConfigException("no <title/> specified for conference list sidebox",cfg);
title += ":";
anon_title = cfg_h.getSubElementText("anon-title");
if (anon_title==null)
anon_title = title;
else
anon_title += ":";
null_message = cfg_h.getSubElementText("null-msg");
if (null_message==null)
null_message = "You are not a member of any SIGs.";
manage_link = cfg_h.getSubElementText("manage-link");
if (manage_link==null)
manage_link = "Manage";
Element x = cfg_h.getSubElement("bullet");
if (x!=null)
{ // get the parameters for the bullet image
DOMElementHelper x_h = new DOMElementHelper(x);
bullet_url = x_h.getElementText();
if (StringUtil.isStringEmpty(bullet_url))
{ // default the bullet URL and fixup parameter
bullet_url = "purple-ball.gif";
bullet_fixup = true;
} // end if
else // get the "fixup" parameter
bullet_fixup = x_h.hasAttribute("fixup");
Integer xi = x_h.getAttributeInt("width");
bullet_width = (xi!=null) ? xi.intValue() : 14;
xi = x_h.getAttributeInt("height");
bullet_height = (xi!=null) ? xi.intValue() : 14;
} // end if
else
{ // just default all the bullet parameters
bullet_url = "purple-ball.gif";
bullet_fixup = true;
bullet_width = 14;
bullet_height = 14;
} // end else
x = cfg_h.getSubElement("new-image");
if (x!=null)
{ // get the parameters for the host tag image
DOMElementHelper x_h = new DOMElementHelper(x);
newmsg_url = x_h.getElementText();
if (StringUtil.isStringEmpty(newmsg_url))
{ // default the host tag image URL and fixup parameter
newmsg_url = "tag_new.gif";
newmsg_fixup = true;
} // end if
else // get the "fixup" parameter
newmsg_fixup = x_h.hasAttribute("fixup");
newmsg_alt = x.getAttribute("alt");
if (StringUtil.isStringEmpty(newmsg_alt))
newmsg_alt = "New!";
Integer xi = x_h.getAttributeInt("width");
newmsg_width = (xi!=null) ? xi.intValue() : 40;
xi = x_h.getAttributeInt("height");
newmsg_height = (xi!=null) ? xi.intValue() : 20;
} // end if
else
{ // just default all the host tag parameters
newmsg_url = "tag_new.gif";
newmsg_fixup = true;
newmsg_alt = "New!";
newmsg_width = 40;
newmsg_height = 20;
} // end else
} // end setConfiguration
public VeniceContent create(VeniceEngine engine, UserContext uc) throws AccessError, DataException
{
return new ConferenceBoxImpl(uc);
} // end create
} // end class ConferenceBox

View File

@@ -0,0 +1,133 @@
/*
* 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) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
*
* Contributor(s):
*/
package com.silverwrist.venice.servlets.format.sideboxes;
import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
import com.silverwrist.venice.core.*;
import com.silverwrist.venice.servlets.format.*;
public class JSPSideBox implements JSPRender
{
/*--------------------------------------------------------------------------------
* Static data members
*--------------------------------------------------------------------------------
*/
// Attribute name for request attribute
protected static final String ATTR_NAME = "com.silverwrist.venice.content.sidebox.JSP";
/*--------------------------------------------------------------------------------
* Attributes
*--------------------------------------------------------------------------------
*/
private JSPSideBoxFactory factory;
private VeniceEngine engine;
private UserContext uc;
/*--------------------------------------------------------------------------------
* Constructor
*--------------------------------------------------------------------------------
*/
JSPSideBox(JSPSideBoxFactory factory, VeniceEngine engine, UserContext uc)
{
this.factory = factory;
this.engine = engine;
this.uc = uc;
} // end constructor
/*--------------------------------------------------------------------------------
* External static functions
*--------------------------------------------------------------------------------
*/
public static JSPSideBox retrieve(ServletRequest request)
{
return (JSPSideBox)(request.getAttribute(ATTR_NAME));
} // end retrieve
/*--------------------------------------------------------------------------------
* Implementations from interface VeniceContent
*--------------------------------------------------------------------------------
*/
public String getPageTitle(RenderData rdat)
{
return factory.getTitle(uc.isLoggedIn());
} // end getPageTitle
public String getPageQID()
{
return null;
} // end getPageQID
/*--------------------------------------------------------------------------------
* Implementations from interface JSPRender
*--------------------------------------------------------------------------------
*/
public void store(ServletRequest request)
{
request.setAttribute(ATTR_NAME,this);
} // end store
public String getTargetJSPName()
{
return factory.getTargetJSPName();
} // end getTargetJSPName
/*--------------------------------------------------------------------------------
* External operations
*--------------------------------------------------------------------------------
*/
public VeniceEngine getEngine()
{
return engine;
} // end getEngine
public UserContext getUser()
{
return uc;
} // end getUser
public String getString(String key)
{
return factory.getString(key);
} // end getString
public String replaceStrings(String base)
{
return factory.replaceStrings(base);
} // end replaceStrings
} // end class JSPSideBox

View File

@@ -0,0 +1,131 @@
/*
* 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) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
*
* Contributor(s):
*/
package com.silverwrist.venice.servlets.format.sideboxes;
import java.io.*;
import java.util.*;
import org.w3c.dom.*;
import com.silverwrist.util.DOMElementHelper;
import com.silverwrist.util.StringUtil;
import com.silverwrist.venice.core.*;
import com.silverwrist.venice.servlets.format.*;
public class JSPSideBoxFactory implements SideBoxFactory
{
/*--------------------------------------------------------------------------------
* Attributes
*--------------------------------------------------------------------------------
*/
private String title; // title of sidebox for logged-in users
private String anon_title; // title of sidebox for not-logged-in users
private String format_jsp; // name of formatting JSP file
private Map strings; // the strings we can access from the JSP page
/*--------------------------------------------------------------------------------
* Constructor
*--------------------------------------------------------------------------------
*/
public JSPSideBoxFactory()
{ // do nothing
} // end constructor
/*--------------------------------------------------------------------------------
* Internal functions
*--------------------------------------------------------------------------------
*/
String getTitle(boolean logged_in)
{
return (logged_in ? title : anon_title);
} // end getTitle
String getTargetJSPName()
{
return format_jsp;
} // end getTargetJSPName
String getString(String key)
{
return (String)(strings.get(key));
} // end getString
String replaceStrings(String base)
{
return StringUtil.replaceAllVariables(base,strings);
} // end replaceStrings
/*--------------------------------------------------------------------------------
* Implementations from interface SideBoxFactory
*--------------------------------------------------------------------------------
*/
public void setConfiguration(Element cfg) throws ConfigException
{
DOMElementHelper cfg_h = new DOMElementHelper(cfg);
title = cfg_h.getSubElementText("title");
if (title==null)
throw new ConfigException("no <title/> specified for sidebox",cfg);
title += ":";
anon_title = cfg_h.getSubElementText("anon-title");
if (anon_title==null)
anon_title = title;
else
anon_title += ":";
format_jsp = cfg_h.getSubElementText("format-jsp");
if (format_jsp==null)
throw new ConfigException("no <format-jsp/> specified for sidebox",cfg);
Element s = cfg_h.getSubElement("strings");
if (s!=null)
{ // we've got some replacement strings to add
HashMap tmp = new HashMap();
NodeList sl = s.getChildNodes();
for (int i=0; i<sl.getLength(); i++)
{ // get all the replacement strings and add them to the map
Node n = sl.item(i);
if (n.getNodeType()==Node.ELEMENT_NODE)
{ // get the text inside this subelement and save it off
DOMElementHelper s_h = new DOMElementHelper((Element)n);
tmp.put(n.getNodeName(),s_h.getElementText());
} // end if
} // end for
strings = Collections.unmodifiableMap(tmp);
} // end if
else // no replacement strings
strings = Collections.EMPTY_MAP;
} // end setConfiguration
public VeniceContent create(VeniceEngine engine, UserContext uc)
{
return new JSPSideBox(this,engine,uc);
} // end create
} // end class JSPSideBoxFactory

View File

@@ -0,0 +1,282 @@
/*
* 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) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
*
* Contributor(s):
*/
package com.silverwrist.venice.servlets.format.sideboxes;
import java.io.*;
import java.util.*;
import org.w3c.dom.*;
import com.silverwrist.util.DOMElementHelper;
import com.silverwrist.util.StringUtil;
import com.silverwrist.venice.core.*;
import com.silverwrist.venice.servlets.format.*;
public class SIGBox implements SideBoxFactory
{
/*--------------------------------------------------------------------------------
* Internal class that implements the actual sidebox
*--------------------------------------------------------------------------------
*/
class SIGBoxImpl implements ContentRender, ColorSelectors
{
private UserContext uc;
private List sig_list;
SIGBoxImpl(UserContext uc) throws DataException
{
this.uc = uc;
this.sig_list = uc.getMemberSIGs();
} // end constructor
public String getPageTitle(RenderData rdat)
{
if (uc.isLoggedIn())
return title;
else
return anon_title;
} // end getPageTitle
public String getPageQID()
{
return null;
} // end getPageQID
public void renderHere(Writer out, RenderData rdat) throws IOException
{
if (sig_list.size()>0)
{ // load up the rendering data and render the contents of the list
String link_font = rdat.getStdFontTag(SIDEBOX_CONTENT_LINK,2);
out.write("<TABLE ALIGN=CENTER BORDER=0 CELLPADDING=0 CELLSPACING=2>\n");
Iterator it = sig_list.iterator();
while (it.hasNext())
{ // write each SIG out in turn
SIGContext sig = (SIGContext)(it.next());
out.write("<TR VALIGN=MIDDLE>\n<TD ALIGN=CENTER WIDTH=" + bullet_width + ">");
renderBullet(out,rdat);
out.write("</TD>\n<TD ALIGN=LEFT CLASS=\"sidebox\">\n<A CLASS=\"sidebox\" HREF=\""
+ rdat.getEncodedServletPath("sig/" + sig.getAlias()) + "\">" + link_font + "<B>"
+ StringUtil.encodeHTML(sig.getName()) + "</B></FONT></A>\n");
if (sig.isAdmin())
{ // write the host tag at the end
out.write("&nbsp;");
renderHostTag(out,rdat);
} // end if
out.write("</TD>\n</TR>\n");
} // end while
out.write("</TABLE>\n");
} // end if
else // write the "no SIGs" message
out.write(rdat.getStdFontTag(SIDEBOX_CONTENT_FOREGROUND,2) + "<EM>" + null_message + "</EM></FONT>\n");
if (uc.isLoggedIn())
{ // write the links at the end
String hilite = rdat.getStdFontTag(SIDEBOX_CONTENT_LINK,1);
out.write("<P>" + rdat.getStdFontTag(SIDEBOX_CONTENT_FOREGROUND,1)
+ "<B>[ <A CLASS=\"sidebox\" HREF=\"" + rdat.getEncodedServletPath("settings?cmd=S")
+ "\">" + hilite + manage_link + "</FONT></A> ");
if (uc.canCreateSIG())
out.write("| <A CLASS=\"sidebox\" HREF=\"" + rdat.getEncodedServletPath("sigops?cmd=C") + "\">"
+ hilite + create_new_link + "</FONT></A> ");
out.write("]</B></FONT>");
} // end if
} // end renderHere
} // end class SIGBoxImpl
/*--------------------------------------------------------------------------------
* Attributes
*--------------------------------------------------------------------------------
*/
private String title; // title of sidebox for logged-in users
private String anon_title; // title of sidebox for not-logged-in users
private String null_message; // message if they're not a member of any SIGs
private String manage_link; // "Manage" link text
private String create_new_link; // "Create New" link text
private String bullet_url; // URL to bullet image
private boolean bullet_fixup; // does bullet image need to be run through getFullImagePath?
private int bullet_width; // width of bullet image
private int bullet_height; // height of bullet image
private String host_url; // URL to host tag image
private boolean host_fixup; // does host tag image need to be run through getFullImagePath?
private String host_alt; // ALT text to use for host tag image
private int host_width; // width of host tag image
private int host_height; // height of host tag image
/*--------------------------------------------------------------------------------
* Constructor
*--------------------------------------------------------------------------------
*/
public SIGBox()
{ // do nothing
} // end constructor
/*--------------------------------------------------------------------------------
* Internal operations
*--------------------------------------------------------------------------------
*/
private void renderBullet(Writer out, RenderData rdat) throws IOException
{
synchronized (this)
{ // this may be called by more than one class, so protect this part
if (bullet_fixup)
{ // fix up the bullet URL
bullet_url = rdat.getFullImagePath(bullet_url);
bullet_fixup = false;
} // end if
} // end synchronized block
out.write("<IMG SRC=\"" + bullet_url + "\" ALT=\"*\" WIDTH=" + bullet_width + " HEIGHT=" + bullet_height
+ " BORDER=0>");
} // end renderBullet
private void renderHostTag(Writer out, RenderData rdat) throws IOException
{
synchronized (this)
{ // this may be called by more than one class, so protect this part
if (host_fixup)
{ // fix up the host tag URL
host_url = rdat.getFullImagePath(host_url);
host_fixup = false;
} // end if
} // end synchronized block
out.write("<IMG SRC=\"" + host_url + "\" ALT=\"" + host_alt + "\" WIDTH=" + host_width + " HEIGHT="
+ host_height + " BORDER=0>");
} // end renderBullet
/*--------------------------------------------------------------------------------
* Implementations from interface SideBoxFactory
*--------------------------------------------------------------------------------
*/
public void setConfiguration(Element cfg) throws ConfigException
{
DOMElementHelper cfg_h = new DOMElementHelper(cfg);
title = cfg_h.getSubElementText("title");
if (title==null)
throw new ConfigException("no <title/> specified for SIG list sidebox",cfg);
title += ":";
anon_title = cfg_h.getSubElementText("anon-title");
if (anon_title==null)
anon_title = title;
else
anon_title += ":";
null_message = cfg_h.getSubElementText("null-msg");
if (null_message==null)
null_message = "You are not a member of any SIGs.";
manage_link = cfg_h.getSubElementText("manage-link");
if (manage_link==null)
manage_link = "Manage";
create_new_link = cfg_h.getSubElementText("create-new-link");
if (create_new_link==null)
create_new_link = "Create New";
Element x = cfg_h.getSubElement("bullet");
if (x!=null)
{ // get the parameters for the bullet image
DOMElementHelper x_h = new DOMElementHelper(x);
bullet_url = x_h.getElementText();
if (StringUtil.isStringEmpty(bullet_url))
{ // default the bullet URL and fixup parameter
bullet_url = "purple-ball.gif";
bullet_fixup = true;
} // end if
else // get the "fixup" parameter
bullet_fixup = x_h.hasAttribute("fixup");
Integer xi = x_h.getAttributeInt("width");
bullet_width = (xi!=null) ? xi.intValue() : 14;
xi = x_h.getAttributeInt("height");
bullet_height = (xi!=null) ? xi.intValue() : 14;
} // end if
else
{ // just default all the bullet parameters
bullet_url = "purple-ball.gif";
bullet_fixup = true;
bullet_width = 14;
bullet_height = 14;
} // end else
x = cfg_h.getSubElement("host-image");
if (x!=null)
{ // get the parameters for the host tag image
DOMElementHelper x_h = new DOMElementHelper(x);
host_url = x_h.getElementText();
if (StringUtil.isStringEmpty(host_url))
{ // default the host tag image URL and fixup parameter
host_url = "tag_host.gif";
host_fixup = true;
} // end if
else // get the "fixup" parameter
host_fixup = x_h.hasAttribute("fixup");
host_alt = x.getAttribute("alt");
if (StringUtil.isStringEmpty(host_alt))
host_alt = "Host!";
Integer xi = x_h.getAttributeInt("width");
host_width = (xi!=null) ? xi.intValue() : 40;
xi = x_h.getAttributeInt("height");
host_height = (xi!=null) ? xi.intValue() : 20;
} // end if
else
{ // just default all the host tag parameters
host_url = "tag_host.gif";
host_fixup = true;
host_alt = "Host!";
host_width = 40;
host_height = 20;
} // end else
} // end setConfiguration
public VeniceContent create(VeniceEngine engine, UserContext uc) throws DataException
{
return new SIGBoxImpl(uc);
} // end create
} // end class SIGBox

View File

@@ -0,0 +1,35 @@
/*
* 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) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
*
* Contributor(s):
*/
package com.silverwrist.venice.servlets.format.sideboxes;
import org.w3c.dom.*;
import com.silverwrist.venice.core.ConfigException;
import com.silverwrist.venice.core.AccessError;
import com.silverwrist.venice.core.DataException;
import com.silverwrist.venice.core.SideBoxDescriptor;
import com.silverwrist.venice.core.UserContext;
import com.silverwrist.venice.core.VeniceEngine;
import com.silverwrist.venice.servlets.format.VeniceContent;
public interface SideBoxFactory
{
public abstract void setConfiguration(Element cfg) throws ConfigException;
public abstract VeniceContent create(VeniceEngine engine, UserContext uc) throws AccessError, DataException;
} // end interface SideBoxFactory