implemented front page content management, finally wired up the user locale
and timezone default mechanism, and did some other bugfixing and stuff
This commit is contained in:
@@ -172,6 +172,30 @@ public class PostOperations extends VeniceServlet
|
||||
|
||||
} // end if ("nuke")
|
||||
|
||||
if (cmd.equals("PU"))
|
||||
{ // we want to publish the message to the front page
|
||||
try
|
||||
{ // attempt to publish the message
|
||||
msg.publish();
|
||||
|
||||
// go back and display stuff
|
||||
throw new RedirectResult(location);
|
||||
|
||||
} // end try
|
||||
catch (DataException de)
|
||||
{ // there was a database error
|
||||
return new ErrorBox("Database Error","Database error publishing message: " + de.getMessage(),
|
||||
location);
|
||||
|
||||
} // end catch
|
||||
catch (AccessError ae)
|
||||
{ // naughty naughty = you can't do this!
|
||||
return new ErrorBox("Access Error",ae.getMessage(),location);
|
||||
|
||||
} // end catch
|
||||
|
||||
} // end if
|
||||
|
||||
// unrecognized command!
|
||||
logger.error("invalid command to PostOperations.doGet: " + cmd);
|
||||
return new ErrorBox("Internal Error","Invalid command to PostOperations.doGet",location);
|
||||
|
||||
@@ -76,7 +76,7 @@ public class Top extends VeniceServlet
|
||||
|
||||
try
|
||||
{ // attempt to get the user content
|
||||
return new TopDisplay(getServletContext(),user);
|
||||
return new TopDisplay(getServletContext(),engine,user);
|
||||
|
||||
} // end try
|
||||
catch (DataException de)
|
||||
|
||||
@@ -565,7 +565,7 @@ public abstract class VeniceServlet extends HttpServlet
|
||||
ServletContext ctxt = getServletContext();
|
||||
VeniceEngine engine = Variables.getVeniceEngine(ctxt);
|
||||
UserContext user = Variables.getUserContext(ctxt,request,request.getSession(true));
|
||||
RenderData rdat = RenderConfig.createRenderData(ctxt,request,response);
|
||||
RenderData rdat = RenderConfig.createRenderData(ctxt,user,request,response);
|
||||
ServletMultipartHandler mphandler = null;
|
||||
VeniceContent content = null;
|
||||
|
||||
|
||||
@@ -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
|
||||
@@ -25,6 +25,11 @@ import com.silverwrist.venice.core.Country;
|
||||
|
||||
public class CDCountryListFormField extends CDPickListFormField
|
||||
{
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Constructors
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public CDCountryListFormField(String name, String caption, String caption2, boolean required,
|
||||
List country_list)
|
||||
{
|
||||
@@ -38,6 +43,11 @@ public class CDCountryListFormField extends CDPickListFormField
|
||||
|
||||
} // end constructor
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Overrides from class CDPickListFormField
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
protected void renderChoice(Writer out, RenderData rdat, Object obj, String my_value) throws IOException
|
||||
{
|
||||
Country c = (Country)obj;
|
||||
@@ -48,6 +58,11 @@ public class CDCountryListFormField extends CDPickListFormField
|
||||
|
||||
} // end renderChoice
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Implementations from interface CDFormField
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public CDFormField duplicate()
|
||||
{
|
||||
return new CDCountryListFormField(this);
|
||||
|
||||
@@ -0,0 +1,106 @@
|
||||
/*
|
||||
* 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 java.io.Writer;
|
||||
import java.io.IOException;
|
||||
import com.silverwrist.util.StringUtil;
|
||||
|
||||
public class CDLocaleListFormField extends CDPickListFormField
|
||||
{
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Private list implementation
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
static class LocaleList extends AbstractList
|
||||
{
|
||||
private Locale[] array; // local array
|
||||
|
||||
LocaleList()
|
||||
{
|
||||
array = Locale.getAvailableLocales();
|
||||
|
||||
} // end constructor
|
||||
|
||||
protected void finalize() throws Throwable
|
||||
{
|
||||
array = null;
|
||||
super.finalize();
|
||||
|
||||
} // end finalize
|
||||
|
||||
public Object get(int index)
|
||||
{
|
||||
return array[index];
|
||||
|
||||
} // end get
|
||||
|
||||
public int size()
|
||||
{
|
||||
return array.length;
|
||||
|
||||
} // end size
|
||||
|
||||
} // end class LocaleList
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Constructors
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public CDLocaleListFormField(String name, String caption, String caption2, boolean required)
|
||||
{
|
||||
super(name,caption,caption2,required,new LocaleList());
|
||||
|
||||
} // end constructor
|
||||
|
||||
protected CDLocaleListFormField(CDLocaleListFormField other)
|
||||
{
|
||||
super(other);
|
||||
|
||||
} // end constructor
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Overrides from class CDPickListFormField
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
protected void renderChoice(Writer out, RenderData rdat, Object obj, String my_value) throws IOException
|
||||
{
|
||||
Locale l = (Locale)obj;
|
||||
out.write("<OPTION VALUE=\"" + l.toString() + "\"");
|
||||
if (l.toString().equals(my_value))
|
||||
out.write(" SELECTED");
|
||||
out.write(">" + StringUtil.encodeHTML(l.getDisplayName()) + "</OPTION>\n");
|
||||
|
||||
} // end renderChoice
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Implementations from interface CDFormField
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public CDFormField duplicate()
|
||||
{
|
||||
return new CDLocaleListFormField(this);
|
||||
|
||||
} // end duplicate
|
||||
|
||||
} // end class CDLocaleListFormField
|
||||
@@ -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
|
||||
@@ -25,8 +25,18 @@ import com.silverwrist.util.StringUtil;
|
||||
|
||||
public abstract class CDPickListFormField extends CDBaseFormField
|
||||
{
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Attributes
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private List choices;
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Constructors
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
protected CDPickListFormField(String name, String caption, String caption2, boolean required,
|
||||
List choices)
|
||||
{
|
||||
@@ -42,9 +52,19 @@ public abstract class CDPickListFormField extends CDBaseFormField
|
||||
|
||||
} // end constructor
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Abstract method declarations
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
protected abstract void renderChoice(Writer out, RenderData rdat, Object obj, String my_value)
|
||||
throws IOException;
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Overrides from class CDBaseFormField
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
protected void renderActualField(Writer out, RenderData rdat) throws IOException
|
||||
{
|
||||
out.write("<SELECT NAME=\"" + getName() + "\" SIZE=1");
|
||||
|
||||
@@ -0,0 +1,106 @@
|
||||
/*
|
||||
* 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 java.io.Writer;
|
||||
import java.io.IOException;
|
||||
import com.silverwrist.util.StringUtil;
|
||||
|
||||
public class CDTimeZoneListFormField extends CDPickListFormField
|
||||
{
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Private list implementation
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
static class TimeZoneList extends AbstractList
|
||||
{
|
||||
private String[] array; // local array
|
||||
|
||||
TimeZoneList()
|
||||
{
|
||||
array = TimeZone.getAvailableIDs();
|
||||
|
||||
} // end constructor
|
||||
|
||||
protected void finalize() throws Throwable
|
||||
{
|
||||
array = null;
|
||||
super.finalize();
|
||||
|
||||
} // end finalize
|
||||
|
||||
public Object get(int index)
|
||||
{
|
||||
return array[index];
|
||||
|
||||
} // end get
|
||||
|
||||
public int size()
|
||||
{
|
||||
return array.length;
|
||||
|
||||
} // end size
|
||||
|
||||
} // end class TimeZoneList
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Constructors
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public CDTimeZoneListFormField(String name, String caption, String caption2, boolean required)
|
||||
{
|
||||
super(name,caption,caption2,required,new TimeZoneList());
|
||||
|
||||
} // end constructor
|
||||
|
||||
protected CDTimeZoneListFormField(CDTimeZoneListFormField other)
|
||||
{
|
||||
super(other);
|
||||
|
||||
} // end constructor
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Overrides from class CDPickListFormField
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
protected void renderChoice(Writer out, RenderData rdat, Object obj, String my_value) throws IOException
|
||||
{
|
||||
String id = (String)obj;
|
||||
out.write("<OPTION VALUE=\"" + id + "\"");
|
||||
if (id.equals(my_value))
|
||||
out.write(" SELECTED");
|
||||
out.write(">" + StringUtil.encodeHTML(id) + "</OPTION>\n");
|
||||
|
||||
} // end renderChoice
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Implementations from interface CDFormField
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public CDFormField duplicate()
|
||||
{
|
||||
return new CDTimeZoneListFormField(this);
|
||||
|
||||
} // end duplicate
|
||||
|
||||
} // end class CDTimeZoneListFormField
|
||||
@@ -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
|
||||
@@ -17,13 +17,19 @@
|
||||
*/
|
||||
package com.silverwrist.venice.servlets.format;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
import com.silverwrist.util.LocaleFactory;
|
||||
import com.silverwrist.util.StringUtil;
|
||||
import com.silverwrist.venice.ValidationException;
|
||||
import com.silverwrist.venice.core.*;
|
||||
|
||||
public class EditProfileDialog extends ContentDialog
|
||||
{
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Constructors
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public EditProfileDialog(List country_list)
|
||||
{
|
||||
super("Edit Your Profile",null,"profform","account");
|
||||
@@ -62,6 +68,9 @@ public class EditProfileDialog extends ContentDialog
|
||||
addFormField(new CDFormCategoryHeader("Personal"));
|
||||
addFormField(new CDTextFormField("descr","Personal description",null,false,32,255));
|
||||
// TODO: add photo selection/uploading method here
|
||||
addFormField(new CDFormCategoryHeader("User Preferences"));
|
||||
addFormField(new CDLocaleListFormField("locale","Default locale","(for formatting dates/times)",true));
|
||||
addFormField(new CDTimeZoneListFormField("tz","Default time zone",null,true));
|
||||
addCommandButton(new CDImageButton("update","bn_update.gif","Update",80,24));
|
||||
addCommandButton(new CDImageButton("cancel","bn_cancel.gif","Cancel",80,24));
|
||||
|
||||
@@ -73,6 +82,22 @@ public class EditProfileDialog extends ContentDialog
|
||||
|
||||
} // end constructor
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Overrides from class Object
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public Object clone()
|
||||
{
|
||||
return new EditProfileDialog(this);
|
||||
|
||||
} // end clone
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Overrides from class ContentDialog
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
protected void validateWholeForm() throws ValidationException
|
||||
{
|
||||
String pass1 = getFieldValue("pass1");
|
||||
@@ -93,6 +118,11 @@ public class EditProfileDialog extends ContentDialog
|
||||
|
||||
} // end validateWholeForm
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* External operations
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public void setTarget(String target)
|
||||
{
|
||||
setHiddenField("tgt",target);
|
||||
@@ -132,6 +162,8 @@ public class EditProfileDialog extends ContentDialog
|
||||
setFieldValue("pvt_email","Y");
|
||||
setFieldValue("url",ci.getURL());
|
||||
setFieldValue("descr",uc.getDescription());
|
||||
setFieldValue("locale",uc.getLocale().toString());
|
||||
setFieldValue("tz",uc.getTimeZone().getID());
|
||||
|
||||
} // end setupDialog
|
||||
|
||||
@@ -172,8 +204,10 @@ public class EditProfileDialog extends ContentDialog
|
||||
// Store the completed contact info.
|
||||
boolean retval = uc.putContactInfo(ci);
|
||||
|
||||
// Save off the user's description.
|
||||
// Save off the user's description and preferences.
|
||||
uc.setDescription(getFieldValue("descr"));
|
||||
uc.setLocale(LocaleFactory.createLocale(getFieldValue("locale")));
|
||||
uc.setTimeZone(TimeZone.getTimeZone(getFieldValue("tz")));
|
||||
|
||||
// Finally, change the password if applicable.
|
||||
foo = getFieldValue("pass1");
|
||||
@@ -192,10 +226,4 @@ public class EditProfileDialog extends ContentDialog
|
||||
|
||||
} // end resetOnError
|
||||
|
||||
public Object clone()
|
||||
{
|
||||
return new EditProfileDialog(this);
|
||||
|
||||
} // end clone
|
||||
|
||||
} // end class EditProfileDialog
|
||||
|
||||
@@ -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
|
||||
@@ -29,6 +29,8 @@ import org.xml.sax.SAXParseException;
|
||||
import com.silverwrist.util.DOMElementHelper;
|
||||
import com.silverwrist.util.StringUtil;
|
||||
import com.silverwrist.venice.core.ConfigException;
|
||||
import com.silverwrist.venice.core.UserContext;
|
||||
import com.silverwrist.venice.servlets.Variables;
|
||||
|
||||
public class RenderConfig
|
||||
{
|
||||
@@ -56,6 +58,7 @@ public class RenderConfig
|
||||
private String image_url;
|
||||
private String static_url;
|
||||
private String site_logo;
|
||||
private Hashtable stock_messages;
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Constructor
|
||||
@@ -171,6 +174,35 @@ public class RenderConfig
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("Site logo: " + image_url);
|
||||
|
||||
Element msg_sect = root_h.getSubElement("messages");
|
||||
if (msg_sect==null)
|
||||
{ // no <messages/> section - bail out now!
|
||||
logger.fatal("config document has no <messages/> section");
|
||||
throw new ConfigException("no <messages/> section found in config file",root);
|
||||
|
||||
} // end if
|
||||
|
||||
// Initialize the stock messages list.
|
||||
stock_messages = new Hashtable();
|
||||
NodeList msg_nodes = msg_sect.getChildNodes();
|
||||
for (int i=0; i<msg_nodes.getLength(); i++)
|
||||
{ // examine all subnodes to add them to the message text
|
||||
Node msgn = msg_nodes.item(i);
|
||||
if (msgn.getNodeType()==Node.ELEMENT_NODE)
|
||||
{ // add it to the hash table by its tag name
|
||||
Element msgel = (Element)msgn;
|
||||
DOMElementHelper h = new DOMElementHelper(msgel);
|
||||
String txt = h.getElementText();
|
||||
if (txt!=null)
|
||||
stock_messages.put(msgel.getTagName(),txt.trim());
|
||||
|
||||
} // end if
|
||||
|
||||
} // end for
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug(stock_messages.size() + " stock messages loaded from config");
|
||||
|
||||
} // end constructor
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
@@ -335,6 +367,19 @@ public class RenderConfig
|
||||
|
||||
} // end writeContentHeader
|
||||
|
||||
String getStockMessage(String identifier)
|
||||
{
|
||||
return (String)(stock_messages.get(identifier));
|
||||
|
||||
} // end getStockMessage
|
||||
|
||||
void writeStockMessage(Writer out, String identifier) throws IOException
|
||||
{
|
||||
String text = (String)(stock_messages.get(identifier));
|
||||
out.write(StringUtil.encodeHTML(text));
|
||||
|
||||
} // end writeStockMessage
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Static operations for use by VeniceServlet
|
||||
*--------------------------------------------------------------------------------
|
||||
@@ -370,7 +415,15 @@ public class RenderConfig
|
||||
public static RenderData createRenderData(ServletContext ctxt, HttpServletRequest request,
|
||||
HttpServletResponse response) throws ServletException
|
||||
{
|
||||
return new RenderData(getRenderConfig(ctxt),request,response);
|
||||
UserContext uc = Variables.getUserContext(ctxt,request,request.getSession(true));
|
||||
return new RenderData(getRenderConfig(ctxt),uc,request,response);
|
||||
|
||||
} // end createRenderData
|
||||
|
||||
public static RenderData createRenderData(ServletContext ctxt, UserContext uc, HttpServletRequest request,
|
||||
HttpServletResponse response) throws ServletException
|
||||
{
|
||||
return new RenderData(getRenderConfig(ctxt),uc,request,response);
|
||||
|
||||
} // end createRenderData
|
||||
|
||||
|
||||
@@ -24,7 +24,9 @@ import javax.servlet.*;
|
||||
import javax.servlet.http.*;
|
||||
import org.apache.log4j.*;
|
||||
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.db.PostLinkRewriter;
|
||||
import com.silverwrist.venice.db.UserNameRewriter;
|
||||
|
||||
@@ -56,7 +58,7 @@ public class RenderData
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
RenderData(RenderConfig rconf, HttpServletRequest request, HttpServletResponse response)
|
||||
RenderData(RenderConfig rconf, UserContext uc, HttpServletRequest request, HttpServletResponse response)
|
||||
{
|
||||
this.rconf = rconf;
|
||||
this.request = request;
|
||||
@@ -67,9 +69,29 @@ public class RenderData
|
||||
if ((encodings!=null) && (encodings.indexOf("gzip")>=0))
|
||||
can_gzip = true;
|
||||
|
||||
// TODO: replace with reading user's preferences
|
||||
my_locale = Locale.getDefault();
|
||||
my_timezone = TimeZone.getDefault();
|
||||
// read the user's preferred locale
|
||||
try
|
||||
{ // get the user default locale
|
||||
my_locale = uc.getLocale();
|
||||
|
||||
} // end try
|
||||
catch (DataException de)
|
||||
{ // locale problems...
|
||||
my_locale = Locale.getDefault();
|
||||
|
||||
} // end catch
|
||||
|
||||
// read the user's preferred time zone
|
||||
try
|
||||
{ // get the user default timezone
|
||||
my_timezone = uc.getTimeZone();
|
||||
|
||||
} // end try
|
||||
catch (DataException de)
|
||||
{ // time zone problems...
|
||||
my_timezone = TimeZone.getDefault();
|
||||
|
||||
} // end catch
|
||||
|
||||
} // end constructor
|
||||
|
||||
@@ -206,6 +228,18 @@ public class RenderData
|
||||
|
||||
} // end writeContentSelectorHeader
|
||||
|
||||
public String getStockMessage(String identifier)
|
||||
{
|
||||
return rconf.getStockMessage(identifier);
|
||||
|
||||
} // end getStockMessage
|
||||
|
||||
public void writeStockMessage(Writer out, String identifier) throws IOException
|
||||
{
|
||||
rconf.writeStockMessage(out,identifier);
|
||||
|
||||
} // end writeStockMessage
|
||||
|
||||
public String formatDateForDisplay(Date date)
|
||||
{
|
||||
DateFormat fmt = DateFormat.getDateTimeInstance(DateFormat.MEDIUM,DateFormat.MEDIUM,my_locale);
|
||||
|
||||
@@ -40,7 +40,9 @@ public class TopDisplay implements ContentRender
|
||||
*/
|
||||
|
||||
private ServletContext ctxt;
|
||||
private VeniceEngine engine;
|
||||
private UserContext uc;
|
||||
private List top_posts;
|
||||
private List descrs;
|
||||
private VeniceContent[] sideboxes;
|
||||
|
||||
@@ -49,11 +51,14 @@ public class TopDisplay implements ContentRender
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public TopDisplay(ServletContext ctxt, UserContext uc) throws DataException, AccessError, ErrorBox
|
||||
public TopDisplay(ServletContext ctxt, VeniceEngine engine, UserContext uc)
|
||||
throws DataException, AccessError, ErrorBox
|
||||
{
|
||||
// Stash some basic information.
|
||||
this.ctxt = ctxt;
|
||||
this.engine = engine;
|
||||
this.uc = uc;
|
||||
this.top_posts = engine.getPublishedMessages(false);
|
||||
this.descrs = uc.getSideBoxList();
|
||||
|
||||
// Create the arrays used to construct sideboxes.
|
||||
@@ -242,4 +247,57 @@ public class TopDisplay implements ContentRender
|
||||
|
||||
} // end renderHere
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* External operations
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public static String getPosterName(TopicMessageContext msg)
|
||||
{
|
||||
try
|
||||
{ // have to guard agains a DataException here
|
||||
return msg.getCreatorName();
|
||||
|
||||
} // end try
|
||||
catch (DataException de)
|
||||
{ // just return "unknown" on failure
|
||||
return "(unknown)";
|
||||
|
||||
} // end catch
|
||||
|
||||
} // end getPosterName
|
||||
|
||||
public static String getMessageBodyText(TopicMessageContext msg)
|
||||
{
|
||||
try
|
||||
{ // have to guard against a DataException here
|
||||
return msg.getBodyText();
|
||||
|
||||
} // end try
|
||||
catch (DataException de)
|
||||
{ // just return an error message
|
||||
return "<EM>(Unable to retrieve message data: " + StringUtil.encodeHTML(de.getMessage()) + ")</EM>";
|
||||
|
||||
} // end catch
|
||||
|
||||
} // end getMessageBodyText
|
||||
|
||||
public int getNumTopPosts()
|
||||
{
|
||||
return top_posts.size();
|
||||
|
||||
} // end getNumTopPosts
|
||||
|
||||
public TopicMessageContext getTopPost(int index)
|
||||
{
|
||||
return (TopicMessageContext)(top_posts.get(index));
|
||||
|
||||
} // end getTopPost
|
||||
|
||||
public boolean displayWelcome()
|
||||
{
|
||||
return !(uc.isLoggedIn());
|
||||
|
||||
} // end displayWelcome
|
||||
|
||||
} // end class TopDisplay
|
||||
|
||||
Reference in New Issue
Block a user