THE GREAT RENAMING! All that was "SIG" should now be "community," except for

the database and the URLs (for backward compatibility).  Do a full rebuild
after browsing this one!
This commit is contained in:
Eric J. Bowersox
2001-11-07 08:43:09 +00:00
parent fe352efbd1
commit dde12bdf2e
131 changed files with 2573 additions and 2503 deletions

View File

@@ -0,0 +1,198 @@
/*
* 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 CommunityBox implements SideBoxFactory
{
/*--------------------------------------------------------------------------------
* Internal class that implements the actual sidebox
*--------------------------------------------------------------------------------
*/
class CommunityBoxImpl implements ContentRender, ColorSelectors
{
private UserContext uc;
private List comm_list;
CommunityBoxImpl(UserContext uc) throws DataException
{
this.uc = uc;
this.comm_list = uc.getMemberCommunities();
} // end constructor
public String getPageTitle(RenderData rdat)
{
if (title_image!=null)
{ // return an image rendering
ImageHandler ih = (uc.isLoggedIn() ? title_image : anon_title_image);
return ih.getRendering(rdat);
} // end if
else
{ // return a title string
String rc = (uc.isLoggedIn() ? title : anon_title);
return StringUtil.encodeHTML(rc);
} // end else
} // end getPageTitle
public String getPageQID()
{
return null;
} // end getPageQID
public void renderHere(Writer out, RenderData rdat) throws IOException
{
if (comm_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 = comm_list.iterator();
while (it.hasNext())
{ // write each community out in turn
CommunityContext comm = (CommunityContext)(it.next());
out.write("<TR VALIGN=MIDDLE>\n<TD ALIGN=CENTER WIDTH=" + bullet.getWidth() + ">");
bullet.renderHere(out,rdat);
out.write("</TD>\n<TD ALIGN=LEFT CLASS=\"sidebox\">\n<A CLASS=\"sidebox\" HREF=\""
+ rdat.getEncodedServletPath("sig/" + comm.getAlias()) + "\">" + link_font + "<B>"
+ StringUtil.encodeHTML(comm.getName()) + "</B></FONT></A>\n");
if (comm.isAdmin())
{ // write the host tag at the end
out.write("&nbsp;");
host.renderHere(out,rdat);
} // end if
out.write("</TD>\n</TR>\n");
} // end while
out.write("</TABLE>\n");
} // end if
else // write the "no communities" 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.canCreateCommunity())
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 CommunityBoxImpl
/*--------------------------------------------------------------------------------
* Attributes
*--------------------------------------------------------------------------------
*/
private ImageHandler title_image; // title image for sidebox for logged-in users
private ImageHandler anon_title_image; // title image for sidebox for not-logged-in users
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 communities
private String manage_link; // "Manage" link text
private String create_new_link; // "Create New" link text
private ImageHandler bullet; // bullet image
private ImageHandler host; // host image
/*--------------------------------------------------------------------------------
* Constructor
*--------------------------------------------------------------------------------
*/
public CommunityBox()
{ // do nothing
} // end constructor
/*--------------------------------------------------------------------------------
* Implementations from interface SideBoxFactory
*--------------------------------------------------------------------------------
*/
public void setConfiguration(Element cfg) throws ConfigException
{
DOMElementHelper cfg_h = new DOMElementHelper(cfg);
title_image = new ImageHandler(cfg_h.getSubElement("title-image"));
if (title_image.isDefined())
{ // we're using image titles...
title = anon_title = null;
anon_title_image = new ImageHandler(cfg_h.getSubElement("anon-title-image"));
if (!(anon_title_image.isDefined()))
anon_title_image = title_image;
} // end if
else
{ // standard textual title
title_image = anon_title_image = null;
title = cfg_h.getSubElementText("title");
if (title==null)
throw new ConfigException("no <title/> specified for community list sidebox",cfg);
title += ":";
anon_title = cfg_h.getSubElementText("anon-title");
if (anon_title==null)
anon_title = title;
else
anon_title += ":";
} // end else
null_message = cfg_h.getSubElementText("null-msg");
if (null_message==null)
null_message = "You are not a member of any communities.";
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";
bullet = new ImageHandler(cfg_h.getSubElement("bullet"),"purple-ball.gif","*",14,14);
host = new ImageHandler(cfg_h.getSubElement("host-image"),"tag_host.gif","Host!",40,20);
} // end setConfiguration
public VeniceContent create(VeniceEngine engine, UserContext uc) throws DataException
{
return new CommunityBoxImpl(uc);
} // end create
} // end class CommunityBox