,
* 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.Writer;
import java.io.IOException;
import java.util.*;
import com.silverwrist.util.StringUtil;
import com.silverwrist.venice.core.*;
public class MenuCommunity implements ComponentRender, ColorSelectors
{
/*--------------------------------------------------------------------------------
* Attributes
*--------------------------------------------------------------------------------
*/
private String image_url; // path to actual image
private boolean image_url_needs_fixup = false; // do we need to fix image path up?
private String title; // title for menu
private List items_list; // list of menu items
private int cid; // community ID
private boolean show_unjoin; // show the "Unjoin" menu choice?
/*--------------------------------------------------------------------------------
* Constructor
*--------------------------------------------------------------------------------
*/
public MenuCommunity(CommunityContext ctxt)
{
try
{ // retrieve the contact info for this puppy
ContactInfo ci = ctxt.getContactInfo();
image_url = ci.getPhotoURL();
if (StringUtil.isStringEmpty(image_url))
{ // just hit the default
image_url = "sig_other.jpg";
image_url_needs_fixup = true;
} // end if
} // end try
catch (DataException e)
{ // if we couldn't get the contact info, screw it
image_url = null;
} // end catch
title = ctxt.getName();
items_list = ctxt.getCommunityFeaturesList();
cid = ctxt.getCommunityID();
show_unjoin = ctxt.canUnjoin();
} // end constructor
/*--------------------------------------------------------------------------------
* Implementations from interface ComponentRender
*--------------------------------------------------------------------------------
*/
public void renderHere(Writer out, RenderData rdat) throws IOException
{
String hilite = "";
if (image_url!=null)
{ // display the image by URL
if (image_url_needs_fixup)
{ // fix up the URL...
image_url = rdat.getFullImagePath(image_url);
image_url_needs_fixup = false;
} // end if
out.write("\n");
} // end if
// display the title
out.write("" + StringUtil.encodeHTML(title) + "");
// display the menu items
Iterator it = items_list.iterator();
String cparm = "sig=" + cid;
while (it.hasNext())
{ // display each menu item in turn
CommunityFeature ftr = (CommunityFeature)(it.next());
out.write("
\n" + hilite
+ StringUtil.encodeHTML(ftr.getName()) + "\n");
} // end while
if (show_unjoin)
out.write("\n"
+ hilite + "Unjoin\n");
out.write("\n"); // all done...
} // end renderHere
/*--------------------------------------------------------------------------------
* External operations
*--------------------------------------------------------------------------------
*/
public int getID()
{
return cid;
} // end getID
} // end class MenuCommunity