Added Documentation, minor reorganization of Code.

git-svn-id: https://svn.libreccm.org/ccm/trunk@2403 8810af33-2d31-482b-a856-94f89814c4df
master
pb 2013-10-30 08:46:19 +00:00
parent 5b78576107
commit a33d058a3d
11 changed files with 182 additions and 128 deletions

View File

@ -23,7 +23,7 @@ package com.arsdigita.forum.categorised;
import com.arsdigita.bebop.PageState;
import com.arsdigita.forum.Forum;
import com.arsdigita.forum.ForumContext;
import com.arsdigita.forum.ui.ForumUserCompactView;
import com.arsdigita.forum.ui.AForumUserCompactView;
import com.arsdigita.kernel.Kernel;
import com.arsdigita.kernel.Party;
import com.arsdigita.kernel.permissions.PermissionDescriptor;
@ -39,7 +39,7 @@ import com.arsdigita.xml.Element;
* @author Chris Gilbert
* @version $Id: $
*/
public class CategorisedForumComponent extends ForumUserCompactView {
public class CategorisedForumComponent extends AForumUserCompactView {
public static final String MODE_CATEGORIES = "categories";

View File

@ -11,7 +11,7 @@ import com.arsdigita.bebop.parameters.ParameterModel;
import com.arsdigita.forum.Forum;
import com.arsdigita.forum.ForumContext;
import com.arsdigita.forum.ForumPageBuilder;
import com.arsdigita.forum.ui.ForumUserCompactView;
import com.arsdigita.forum.ui.AForumUserCompactView;
import com.arsdigita.kernel.ACSObject;
import com.arsdigita.navigation.ui.category.Menu;
import com.arsdigita.navigation.ui.category.Path;
@ -36,7 +36,7 @@ public class CategorisedForumPageBuilder extends ForumPageBuilder {
}
protected ForumUserCompactView getForumComponent() {
protected AForumUserCompactView getForumComponent() {
return new CategorisedForumComponent();
}

View File

@ -49,7 +49,7 @@ import com.arsdigita.util.Assert;
import com.arsdigita.web.Application;
/**
* Main domain class of a forum application representing a discussion forum.
* Main domain class of forum application representing a discussion forum.
*
* It manages creation of new forum instances and provides getters and setters
* for instance specific configuration options.
@ -74,17 +74,15 @@ public class Forum extends Application {
public static final String BASE_DATA_OBJECT_TYPE =
"com.arsdigita.forum.Forum";
public static final String PACKAGE_TYPE = "forum";
public static final String THREAD_SUBSCRIPTION_GROUPS_NAME =
"Thread Subscription Groups";
private static final ForumConfig s_config = new ForumConfig();
static {
s_log.debug("Static initalizer starting...");
s_config.load();
s_log.debug("Static initalizer finished.");
}
/** Retrieve the Config object containing various configuration parameter */
private static final ForumConfig s_config = ForumConfig.getInstanceOf();
/** Service method to provide clients access to configuration. */
public static ForumConfig getConfig() {
return s_config;
}

View File

@ -16,6 +16,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
package com.arsdigita.forum;
import com.arsdigita.kernel.User;
@ -28,7 +29,6 @@ import com.arsdigita.util.parameter.ResourceParameter;
import com.arsdigita.util.parameter.StringParameter;
import com.arsdigita.web.Web;
import java.io.IOException;
import java.io.InputStream;
import org.apache.log4j.Logger;
@ -42,111 +42,139 @@ import org.apache.log4j.Logger;
*/
public class ForumConfig extends AbstractConfig {
/** A logger instance to assist debugging . */
private static final Logger s_log = Logger.getLogger(ForumConfig.class);
private Parameter m_adminEditPosts;
private Parameter m_authorEditPosts;
private Parameter m_authorDeletePosts;
private Parameter m_digestUserEmail;
private Parameter m_replyHostName;
private Parameter m_disablePageCaching;
private Parameter m_adminOnlyCreateTopics;
private Parameter m_maxImageSize;
private Parameter m_maxFileSize;
private final Parameter m_adapters;
private Parameter m_showAllThreadAlerts;
private Parameter m_showNewTabs;
private Parameter m_useWysiwygEditor;
private Parameter m_rejectionMessage;
private Parameter m_threadPageSize;
private Parameter m_threadOrderField;
private Parameter m_threadOrderDir;
private Parameter m_quickFinish;
private Parameter m_deleteSentSubscriptionNotifications;
public ForumConfig() {
/** Singelton config object. */
private static ForumConfig s_conf;
m_adminEditPosts = new BooleanParameter(
/**
* Gain a WorkspaceConfig object.
*
* Singelton pattern, don't instantiate a config object using the
* constructor directly!
* @return Instance of ForumConfig
*/
public static synchronized ForumConfig getInstanceOf() {
if (s_conf == null) {
s_conf = new ForumConfig();
s_conf.load();
}
return s_conf;
}
// ////////////////////////////////////////////////////////////////////////
// set of configuration parameters
// ////////////////////////////////////////////////////////////////////////
/** XML renderer rules. Provide rules for configuring information in
* generated XML */
private final Parameter m_adapters = new ResourceParameter(
"com.arsdigita.forum.traversal_adapters",
Parameter.REQUIRED,
"/WEB-INF/resources/forum-adapters.xml");
/** Admins can edit posts. Whether administrators can edit any posts */
private final Parameter m_adminEditPosts= new BooleanParameter(
"com.arsdigita.forum.admin_can_edit_posts",
Parameter.REQUIRED,
Boolean.TRUE);
m_authorEditPosts = new BooleanParameter(
"com.arsdigita.forum.author_can_edit_posts",
Parameter.REQUIRED,
Boolean.TRUE);
m_authorDeletePosts = new BooleanParameter(
"com.arsdigita.forum.author_can_delete_posts",
Parameter.REQUIRED,
Boolean.TRUE);
m_replyHostName = new StringParameter(
"com.arsdigita.forum.reply_host_name",
Parameter.OPTIONAL,
null);
m_digestUserEmail = new StringParameter(
"com.arsdigita.forum.digest_user_email",
Parameter.OPTIONAL,
null);
m_disablePageCaching = new BooleanParameter(
"com.arsdigita.forum.disable_page_caching",
Parameter.REQUIRED,
Boolean.FALSE);
m_adminOnlyCreateTopics = new BooleanParameter(
/** Prevent other users besides admin to create new topics. Whether only
* admin can create (true) topics or all users (default false) */
private final Parameter m_adminOnlyCreateTopics = new BooleanParameter(
"com.arsdigita.forum.admin_only_to_create_topics",
Parameter.REQUIRED,
Boolean.FALSE);
m_maxImageSize = new IntegerParameter(
/** */
private final Parameter m_authorEditPosts = new BooleanParameter(
"com.arsdigita.forum.author_can_edit_posts",
Parameter.REQUIRED,
Boolean.TRUE);
/** */
private final Parameter m_authorDeletePosts = new BooleanParameter(
"com.arsdigita.forum.author_can_delete_posts",
Parameter.REQUIRED,
Boolean.TRUE);
/** */
private final Parameter m_digestUserEmail = new StringParameter(
"com.arsdigita.forum.digest_user_email",
Parameter.OPTIONAL,
null);
/** */
private final Parameter m_replyHostName = new StringParameter(
"com.arsdigita.forum.reply_host_name",
Parameter.OPTIONAL,
null);
/** */
private final Parameter m_disablePageCaching = new BooleanParameter(
"com.arsdigita.forum.disable_page_caching",
Parameter.REQUIRED,
Boolean.FALSE);
/** */
private final Parameter m_maxImageSize = new IntegerParameter(
"com.arsdigita.forum.maximum_image_size",
Parameter.OPTIONAL, null);
m_maxFileSize = new IntegerParameter(
/** */
private final Parameter m_maxFileSize = new IntegerParameter(
"com.arsdigita.forum.maximum_file_size",
Parameter.OPTIONAL, null);
m_showNewTabs = new BooleanParameter(
"com.arsdigita.forum.show_new_tabs",
Parameter.OPTIONAL,
Boolean.TRUE);
m_showAllThreadAlerts = new BooleanParameter(
/** */
private final Parameter m_showAllThreadAlerts = new BooleanParameter(
"com.arsdigita.forum.show_all_forum_thread_alerts",
Parameter.OPTIONAL,
Boolean.TRUE);
m_useWysiwygEditor = new BooleanParameter(
/** */
private final Parameter m_showNewTabs = new BooleanParameter(
"com.arsdigita.forum.show_new_tabs",
Parameter.OPTIONAL,
Boolean.TRUE);
/** */
private final Parameter m_useWysiwygEditor = new BooleanParameter(
"com.arsdigita.forum.use_wysiwyg_editor",
Parameter.OPTIONAL,
Boolean.FALSE);
m_rejectionMessage = new StringParameter(
/** */
private final Parameter m_rejectionMessage = new StringParameter(
"com.arsdigita.forum.rejection_form_message.example",
Parameter.OPTIONAL,
null);
m_threadPageSize = new IntegerParameter(
/** */
private final Parameter m_threadPageSize = new IntegerParameter(
"com.arsdigita.forum.thread_page_size",
Parameter.REQUIRED, new Integer(10));
m_threadOrderField = new StringParameter(
/** */
private final Parameter m_threadOrderField = new StringParameter(
"com.arsdigita.forum.thread_order_field",
Parameter.REQUIRED, new String("lastUpdate"));
m_threadOrderDir = new StringParameter(
/** */
private final Parameter m_threadOrderDir = new StringParameter(
"com.arsdigita.forum.thread_order_dir",
Parameter.REQUIRED, new String("desc"));
m_quickFinish = new BooleanParameter(
/** */
private final Parameter m_quickFinish = new BooleanParameter(
"com.arsdigita.forum.allow_quick_finish",
Parameter.OPTIONAL,
Boolean.FALSE);
m_deleteSentSubscriptionNotifications = new BooleanParameter(
/** */
private final Parameter m_deleteSentSubscriptionNotifications = new BooleanParameter(
"com.arsdigita.forum.delete_sent_subscription_notifications",
Parameter.OPTIONAL,
Boolean.FALSE);
m_adapters = new ResourceParameter("com.arsdigita.forum.traversal_adapters",
Parameter.REQUIRED,
"/WEB-INF/resources/forum-adapters.xml");
/**
*
*/
public ForumConfig() {
register(m_digestUserEmail);
register(m_adapters);
register(m_adminEditPosts);
register(m_adminOnlyCreateTopics);
register(m_authorEditPosts);
register(m_authorDeletePosts);
register(m_digestUserEmail);
register(m_replyHostName);
register(m_adapters);
register(m_disablePageCaching);
register(m_adminOnlyCreateTopics);
register(m_maxImageSize);
register(m_maxFileSize);
register(m_showAllThreadAlerts);
@ -158,6 +186,7 @@ public class ForumConfig extends AbstractConfig {
register(m_threadOrderDir);
register(m_quickFinish);
register(m_deleteSentSubscriptionNotifications);
loadInfo();
}
@ -169,6 +198,17 @@ public class ForumConfig extends AbstractConfig {
return ((Boolean) get(m_adminEditPosts)).booleanValue();
}
/**
* If true, disables topic tab for non admin users. Topic tab does not
* access control topic creation, so set this to true to maintain control of
* the topics on the forum.
*
* @return
*/
public boolean topicCreationByAdminOnly() {
return ((Boolean) get(m_adminOnlyCreateTopics)).booleanValue();
}
public boolean canAuthorEditPosts() {
return ((Boolean) get(m_authorEditPosts)).booleanValue();
}
@ -203,18 +243,6 @@ public class ForumConfig extends AbstractConfig {
return ((Boolean) get(m_disablePageCaching)).booleanValue();
}
/**
* if true, disables topic tab for non admin users. Topic tab does not
* access control topic creation, so set this to true to maintain control of
* the topics on the forum.
*
*
*
* @return
*/
public boolean topicCreationByAdminOnly() {
return ((Boolean) get(m_adminOnlyCreateTopics)).booleanValue();
}
public User getDigestUser() {
String email = getDigestUserEmail();

View File

@ -3,16 +3,6 @@ com.arsdigita.forum.traversal_adapters.purpose=Rules for configuring information
com.arsdigita.forum.traversal_adapters.format=[string]
com.arsdigita.forum.traversal_adapters.example=/WEB-INF/resources/forum-adapters.xml
com.arsdigita.forum.digest_user_email.title=Digest user email address
com.arsdigita.forum.digest_user_email.purpose=Email address of the user sending digest emails
com.arsdigita.forum.digest_user_email.format=[email]
com.arsdigita.forum.digest_user_email.example=forum-digest@example.com
com.arsdigita.forum.reply_host_name.title=Forum reply host name
com.arsdigita.forum.reply_host_name.purpose=Host name for forums alert replies
com.arsdigita.forum.reply_host_name.format=[hostname]
com.arsdigita.forum.reply_host_name.example=example.com
com.arsdigita.forum.admin_can_edit_posts.title=Admins can edit posts
com.arsdigita.forum.admin_can_edit_posts.purpose=Whether administrators can edit any posts
com.arsdigita.forum.admin_can_edit_posts.format=[boolean]
@ -23,6 +13,16 @@ com.arsdigita.forum.admin_only_to_create_topics.purpose=Whether only admin can c
com.arsdigita.forum.admin_only_to_create_topics.format=[boolean]
com.arsdigita.forum.admin_only_to_create_topics.example=true|false
com.arsdigita.forum.digest_user_email.title=Digest user email address
com.arsdigita.forum.digest_user_email.purpose=Email address of the user sending digest emails
com.arsdigita.forum.digest_user_email.format=[email]
com.arsdigita.forum.digest_user_email.example=forum-digest@example.com
com.arsdigita.forum.reply_host_name.title=Forum reply host name
com.arsdigita.forum.reply_host_name.purpose=Host name for forums alert replies
com.arsdigita.forum.reply_host_name.format=[hostname]
com.arsdigita.forum.reply_host_name.example=example.com
com.arsdigita.forum.author_can_edit_posts.title=Authors can edit posts
com.arsdigita.forum.author_can_edit_posts.purpose=Whether authors can edit their posts
com.arsdigita.forum.author_can_edit_posts.format=[boolean]

View File

@ -29,7 +29,7 @@ import com.arsdigita.bebop.event.RequestListener;
import com.arsdigita.bebop.parameters.BigDecimalParameter;
// import com.arsdigita.bebop.parameters.ParameterModel;
import com.arsdigita.forum.ui.Constants;
import com.arsdigita.forum.ui.ForumUserCompactView;
import com.arsdigita.forum.ui.AForumUserCompactView;
import com.arsdigita.kernel.permissions.PrivilegeDescriptor;
import com.arsdigita.toolbox.ui.ApplicationAuthenticationListener;
import com.arsdigita.xml.Element;
@ -38,7 +38,7 @@ import com.arsdigita.xml.Element;
* Implementation of com.arsdigita.forum.PageBuilder that creates a
* basic forum page with read access check.
* Controls forum.ui classes to generate the xml and display the desired
* elements (here esp. ForumUserCompactView).
* elements (here esp. AForumUserCompactView).
*
* @author chris.gilbert@westsussex.gov.uk
*/
@ -74,7 +74,7 @@ public class ForumPageBuilder implements PageBuilder, Constants {
}
});
ForumUserCompactView forumComp = getForumComponent();
AForumUserCompactView forumComp = getForumComponent();
page.add(forumComp);
BigDecimalParameter topic = new BigDecimalParameter(TOPIC_PARAM);
page.addGlobalStateParam(topic);
@ -94,8 +94,8 @@ public class ForumPageBuilder implements PageBuilder, Constants {
*
* @return
*/
protected ForumUserCompactView getForumComponent() {
return new ForumUserCompactView();
protected AForumUserCompactView getForumComponent() {
return new AForumUserCompactView();
}
/**
@ -104,7 +104,7 @@ public class ForumPageBuilder implements PageBuilder, Constants {
private static class ForumPageRequestListener implements RequestListener {
private BigDecimalParameter m_categorySelection;
private ForumUserCompactView m_forumComp;
private AForumUserCompactView m_forumComp;
/**
* Default Constructor
@ -112,7 +112,7 @@ public class ForumPageBuilder implements PageBuilder, Constants {
* @param forumComp
*/
public ForumPageRequestListener(BigDecimalParameter topicSelection,
ForumUserCompactView forumComp) {
AForumUserCompactView forumComp) {
m_categorySelection = topicSelection;
m_forumComp = forumComp;
}

View File

@ -34,8 +34,8 @@ import org.apache.log4j.Logger;
* caching
* @version $Id: ForumServlet.java 2213 2011-06-22 20:19:06Z pboy $
*/
public class ForumServlet extends BebopApplicationServlet
implements Constants {
public class ForumServlet extends BebopApplicationServlet {
// implements Constants {
/** Private logger instance for debugging purpose */
private static final Logger s_log = Logger.getLogger(ForumServlet.class);

View File

@ -22,11 +22,11 @@ import com.arsdigita.bebop.Page;
// import com.arsdigita.bebop.parameters.ParameterModel;
/**
* @author chris.gilbert@westsussex.gov.uk
*
* Interface for classes that create forum pages. To build a page different
* from the default, provide new implemention and register it with the
* com.arsdigita.forum.ForumPageFactory
*
* @author chris.gilbert@westsussex.gov.uk
*/
public interface PageBuilder {

View File

@ -59,12 +59,14 @@ import com.arsdigita.xml.Element;
* @author Jens Pelzetter (jensp)
* @version $Revision: 1.3 $ $Author: chrisg23 $ $Date: 2006/03/09 13:48:15 $
*/
public class ForumUserCompactView extends ModalContainer implements Constants {
public class AForumUserCompactView extends ModalContainer implements Constants {
/** Private logger instance for debugging purpose. */
private static Logger s_log = Logger.getLogger(ForumUserCompactView.class);
private static Logger s_log = Logger.getLogger(AForumUserCompactView.class);
// Denotes the 6 panels of the user interface, also used as marker to store
// and select the active panel
/** Denotation of the 'threads' forum mode */
public static final String MODE_THREADS = "threads";
/** Denominator of the 'topics' forum mode */
@ -79,31 +81,35 @@ public class ForumUserCompactView extends ModalContainer implements Constants {
/** Denominator of the 'configuration' forum mode (administrators only)*/
public static final String MODE_SETUP = "setup";
/** Holds the current active mode */
private StringParameter m_mode;
/** Object containing the threads panel (main working panel for users) */
/** Container object containing the threads panel (main working panel
* for users) */
// Container section for sub panels:
private ThreadsPanel m_threadsView;
/** Object containing the topics panel */
/** Container object containing the topics panel for user to filter
* threads listing */
private TopicsPanel m_topicsView;
/** Object containing the alerts management panel */
/** Container object containing the alerts management panel for users */
private ForumAlertsView m_alertsView;
/** Object containing the moderation panel */
/** Container object containing the moderation panel (moderators only) */
private ModerationView m_moderationView;
/** Object containing the setup panel */
/** Container object containing the setup panel (admin only) */
private SetupView m_setupView;
/** Object containing the permission management panel*/
/** Container object for the permission management panel (admin only) */
private PermissionsView m_permissionsView;
/**
* Default Constructor. Initializes the forum user interface elements.
*/
public ForumUserCompactView() {
public AForumUserCompactView() {
// determine namespace
super(FORUM_XML_PREFIX + ":forum", FORUM_XML_NS);
m_mode = new StringParameter("mode");
// setup panels which make up the forum
// Create all panels which make up this forum user view
m_threadsView = new ThreadsPanel();
m_topicsView = new TopicsPanel();
m_alertsView = new ForumAlertsView();
@ -112,6 +118,7 @@ public class ForumUserCompactView extends ModalContainer implements Constants {
m_setupView = new SetupView();
m_permissionsView = new PermissionsView();
// Add components to parent ModalContainer
add(m_threadsView);
add(m_topicsView);
add(m_alertsView);
@ -124,13 +131,17 @@ public class ForumUserCompactView extends ModalContainer implements Constants {
}
/**
* Registers state parameters for the page with its model.
* @see com.arsdigita.bebop.SimpleComponent#register(com.arsdigita.bebop.Page)
*
* Adds status information regarding visibility.
* @param p
*/
@Override
public void register(Page p) {
super.register(p);
// Add the current mode to the status properties
p.addGlobalStateParam(m_mode);
}
@ -328,7 +339,7 @@ public class ForumUserCompactView extends ModalContainer implements Constants {
* Generates a forum mode selection entry (usually a tab).
*
*
* @param state
* @param PageState state
* @param parent
* @param mode forum mode (threadspanel, topicspanel, alertpanel, ...) to
* create entry for
@ -344,19 +355,16 @@ public class ForumUserCompactView extends ModalContainer implements Constants {
current = MODE_THREADS; // used as default mode
}
Element content =
parent.newChildElement(FORUM_XML_PREFIX + ":forumMode",
Element content = parent.newChildElement(FORUM_XML_PREFIX + ":forumMode",
FORUM_XML_NS);
state.setControlEvent(this, "mode", mode);
content.addAttribute("mode",
mode);
content.addAttribute("mode", mode);
// add link to switch to 'mode'
try {
content.addAttribute("url",
state.stateAsURL());
content.addAttribute("url", state.stateAsURL());
} catch (IOException ex) {
throw new UncheckedWrapperException("cannot create url", ex);
}

View File

@ -43,7 +43,7 @@ import org.apache.log4j.Logger;
/**
* A reusable Bebop component to display and maintain threads in a given forum
* instance. Currently used as a page component in ForumUserCompactView but may
* instance. Currently used as a page component in AForumUserCompactView but may
* be used (in future) by other styles of forum display or even standalone as
* part of other pages as well. In any case it is the main user view and
* working area of a forum.

View File

@ -0,0 +1,20 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html>
<head>
<title>com.arsdigita.forum</title>
</head>
<body>
<p>
The forum ui package provides the GUI for users of the forum. Another package
provides the GUI for administrators
</p>
<p>
<i>AForumUserCompactView.java</i> is the main entry class. It creates a
rather CCM specific compact view into the forum, showing all threads without
regard of their topic, but enabling to filter the list for specific topics.
In the future their may be a more convenient view as an alternative.
</p>
</body>
</html>