From 077e413f450df6862257cbe8f9eda0d2ebaf0db7 Mon Sep 17 00:00:00 2001 From: Derek Hulley Date: Tue, 18 Jul 2006 15:47:14 +0000 Subject: [PATCH] Merged V1.3 to HEAD svn merge svn://www.alfresco.org:3691/alfresco/BRANCHES/V1.3@3099 svn://www.alfresco.org:3691/alfresco/BRANCHES/V1.3@3103 . git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@3344 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../alfresco/web/app/servlet/BaseServlet.java | 1 - .../web/bean/forums/CreateReplyDialog.java | 28 ------ .../alfresco/web/bean/forums/ForumsBean.java | 89 ++++++++++++++++++- source/web/jsp/forums/create-reply-dialog.jsp | 29 +----- 4 files changed, 89 insertions(+), 58 deletions(-) diff --git a/source/java/org/alfresco/web/app/servlet/BaseServlet.java b/source/java/org/alfresco/web/app/servlet/BaseServlet.java index ca598c1c63..e810ed4445 100644 --- a/source/java/org/alfresco/web/app/servlet/BaseServlet.java +++ b/source/java/org/alfresco/web/app/servlet/BaseServlet.java @@ -74,7 +74,6 @@ public abstract class BaseServlet extends HttpServlet validRedirectJSPs.add("/jsp/dialog/about.jsp"); validRedirectJSPs.add("/jsp/dialog/advanced-search.jsp"); validRedirectJSPs.add("/jsp/dialog/system-info.jsp"); - validRedirectJSPs.add("/jsp/forums/forums.jsp"); validRedirectJSPs.add("/jsp/users/users.jsp"); validRedirectJSPs.add("/jsp/trashcan/trash-list.jsp"); } diff --git a/source/java/org/alfresco/web/bean/forums/CreateReplyDialog.java b/source/java/org/alfresco/web/bean/forums/CreateReplyDialog.java index 6eb6c0c471..5da944ae4b 100644 --- a/source/java/org/alfresco/web/bean/forums/CreateReplyDialog.java +++ b/source/java/org/alfresco/web/bean/forums/CreateReplyDialog.java @@ -62,32 +62,4 @@ public class CreateReplyDialog extends CreatePostDialog { return Application.getMessage(FacesContext.getCurrentInstance(), "reply"); } - - // ------------------------------------------------------------------------------ - // Bean Getters and Setters - - /** - * Returns the content of the post we are replying to - * - * @return The content - */ - public String getReplyContent() - { - if (this.replyContent == null) - { - // get the content reader of the node we are replying to - NodeRef replyNode = this.browseBean.getDocument().getNodeRef(); - if (replyNode != null) - { - ContentReader reader = this.contentService.getReader(replyNode, ContentModel.PROP_CONTENT); - - if (reader != null) - { - this.replyContent = reader.getContentString(); - } - } - } - - return this.replyContent; - } } diff --git a/source/java/org/alfresco/web/bean/forums/ForumsBean.java b/source/java/org/alfresco/web/bean/forums/ForumsBean.java index f6e14efa61..124d38388c 100644 --- a/source/java/org/alfresco/web/bean/forums/ForumsBean.java +++ b/source/java/org/alfresco/web/bean/forums/ForumsBean.java @@ -17,6 +17,7 @@ package org.alfresco.web.bean.forums; import java.io.IOException; +import java.io.StringWriter; import java.io.Writer; import java.text.MessageFormat; import java.text.SimpleDateFormat; @@ -536,6 +537,61 @@ public class ForumsBean implements IContextListener } } + /** + * Returns the HTML to represent a bubble rendition of the text of the the + * forum article being replied to. + * + * @return The HTML for the bubble + */ + public String getReplyBubbleHTML() + { + try + { + // if the forum being replied to was a new post show the orange bubble + // with the user on the left otherwise show the yellow bubble with the + // user on the right. + StringWriter writer = new StringWriter(); + + FacesContext context = FacesContext.getCurrentInstance(); + Node replyToNode = this.browseBean.getDocument(); + boolean isReplyPost = this.nodeService.hasAspect(replyToNode.getNodeRef(), + ContentModel.ASPECT_REFERENCING); + String contextPath = context.getExternalContext().getRequestContextPath(); + String colour = isReplyPost ? "yellow" : "orange"; + String bgColour = isReplyPost ? "#FFF5A3" : "#FCC75E"; + + // build the HTML to represent the user that posted the article being replied to + StringBuilder replyPosterHTML = new StringBuilder(""); + replyPosterHTML.append("
"); + replyPosterHTML.append((String)replyToNode.getProperties().get("creator")); + replyPosterHTML.append(""); + + // start the table + writer.write(""); + + if (isReplyPost) + { + renderReplyContentHTML(context, replyToNode, writer, contextPath, colour, bgColour); + writer.write(replyPosterHTML.toString()); + } + else + { + writer.write(replyPosterHTML.toString()); + renderReplyContentHTML(context, replyToNode, writer, contextPath, colour, bgColour); + } + + // finish the table + writer.write("
"); + + return writer.toString(); + } + catch (IOException ioe) + { + throw new AlfrescoRuntimeException("Failed to render reply bubble HTML", ioe); + } + } // ------------------------------------------------------------------------------ // IContextListener implementation @@ -947,7 +1003,7 @@ public class ForumsBean implements IContextListener // ------------------------------------------------------------------------------ - // Private helpers + // Helpers /** * Initialise default values from client configuration @@ -984,6 +1040,37 @@ public class ForumsBean implements IContextListener } } + protected void renderReplyContentHTML(FacesContext context, + Node replyToNode, StringWriter writer, + String contextPath, String colour, String bgColour) + throws IOException + { + // get the content of the article being replied to + String replyContent = ""; + ContentReader reader = this.contentService.getReader(replyToNode.getNodeRef(), + ContentModel.PROP_CONTENT); + if (reader != null) + { + replyContent = reader.getContentString(); + } + + // get the date of the article being replied to + String postedDate = Utils.getDateTimeFormat(context). + format(replyToNode.getProperties().get("created")); + + // generate the HTML + writer.write(""); + TopicBubbleViewRenderer.renderBubbleTop(writer, contextPath, colour, bgColour); + writer.write(""); + writer.write(Application.getMessage(context, "posted")); + writer.write(": "); + writer.write(postedDate); + TopicBubbleViewRenderer.renderBubbleMiddle(writer, contextPath, colour); + writer.write(replyContent); + TopicBubbleViewRenderer.renderBubbleBottom(writer, contextPath, colour); + writer.write(""); + } + /** * Class to implement a bubble view for the RichList component used in the topics screen * diff --git a/source/web/jsp/forums/create-reply-dialog.jsp b/source/web/jsp/forums/create-reply-dialog.jsp index b6494456ae..08b120880d 100644 --- a/source/web/jsp/forums/create-reply-dialog.jsp +++ b/source/web/jsp/forums/create-reply-dialog.jsp @@ -19,8 +19,6 @@ <%@ taglib uri="/WEB-INF/alfresco.tld" prefix="a" %> <%@ taglib uri="/WEB-INF/repo.tld" prefix="r" %> -<%@ page import="org.alfresco.web.bean.forums.ForumsBean.TopicBubbleViewRenderer" %> -