From: <jbo...@li...> - 2006-06-30 13:54:05
|
Author: unibrew Date: 2006-06-30 09:53:54 -0400 (Fri, 30 Jun 2006) New Revision: 4887 Modified: labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/ForumUtil.java labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/PortalUtil.java labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/action/ModeratorAction.java labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/action/SplitTopic.java labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/view/ViewTopic.java labs/jbossforums/trunk/forums/src/resources/portal-forums-war/WEB-INF/forums.taglib.xml labs/jbossforums/trunk/forums/src/resources/portal-forums-war/views/moderator/modcp_split.xhtml labs/jbossforums/trunk/forums/src/resources/portal-forums-war/views/topics/viewtopic_body.xhtml Log: [JBFORUMS-54] Working on SplitTopic view and on new tag for SplitView and TopicView. Clearing ModeratorAction. Modified: labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/ForumUtil.java =================================================================== --- labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/ForumUtil.java 2006-06-30 08:05:20 UTC (rev 4886) +++ labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/ForumUtil.java 2006-06-30 13:53:54 UTC (rev 4887) @@ -24,9 +24,14 @@ import java.text.DecimalFormat; import java.util.Date; +import javax.faces.context.FacesContext; + import javax.portlet.ActionRequest; +import javax.portlet.PortletRequest; +import org.jboss.portal.format.render.bbcodehtml.ToHTMLConfig; + /** * @author <a href="mailto:soh...@jb...">Sohil Shah</a> * @@ -93,4 +98,5 @@ return dateStr; } + } Modified: labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/PortalUtil.java =================================================================== --- labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/PortalUtil.java 2006-06-30 08:05:20 UTC (rev 4886) +++ labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/PortalUtil.java 2006-06-30 13:53:54 UTC (rev 4887) @@ -22,6 +22,8 @@ package org.jboss.portlet.forums.ui; +import java.io.StringWriter; + import java.util.Date; import java.util.Iterator; @@ -29,8 +31,13 @@ import java.text.SimpleDateFormat; +import java.util.Locale; import java.util.Map; +import java.util.ResourceBundle; + +import javax.faces.component.UIViewRoot; + import org.apache.log4j.Logger; //jsf @@ -44,10 +51,17 @@ import javax.portlet.RenderResponse; import javax.portlet.PortletRequest; +import javax.servlet.ServletRequest; + +import javax.servlet.http.HttpServletRequest; + import org.jboss.portal.core.CoreConstants; import org.jboss.portal.core.modules.ModuleConstants; import org.jboss.portal.core.modules.UserModule; import org.jboss.portal.core.model.User; +import org.jboss.portal.format.render.bbcodehtml.ToHTMLConfig; +import org.jboss.portal.format.render.bbcodehtml.ToHTMLRenderer; +import org.jboss.portal.format.util.CLLoader; import org.jboss.portlet.forums.ForumsConstants; import org.jboss.portlet.forums.model.Poster; import org.jboss.portlet.forums.impl.PosterImpl; @@ -67,6 +81,7 @@ */ public class PortalUtil { + private static CLLoader loader = new CLLoader("template"); private static Logger log = Logger.getLogger(PortalUtil.class); private static CoreConstants coreConstants = new CoreConstants() { @@ -314,7 +329,78 @@ return poster; } + + /** + * + * @return + */ + public static String formatMessage( String text , boolean allowHTML ) { + Object req = FacesContext.getCurrentInstance().getExternalContext().getRequest(); + + if (allowHTML) + { + getToHTMLRenderer(req).getConfig().setFilterMode(ToHTMLConfig.FILTER_MODE_ALWAYS_PRINT); + getToHTMLRenderer(req).getConfig().setOuputMode(ToHTMLConfig.OUTPUT_MODE_REMOVE); + } + else + { + getToHTMLRenderer(req).getConfig().setFilterMode(ToHTMLConfig.FILTER_MODE_NEVER_PRINT); + getToHTMLRenderer(req).getConfig().setOuputMode(ToHTMLConfig.OUTPUT_MODE_REMOVE); + } + return formatTitle(req, text); + } + + /** + * + * @param text + * @return + */ + public static String formatTitle(Object req, String text) + { + StringWriter stringWriter = new StringWriter(); + getToHTMLRenderer(req).setWriter(stringWriter); + System.out.println("REQ: "+req+" TEXT: "+text); + getToHTMLRenderer(req).render(text.toCharArray(), 0, text.length()); + return stringWriter.toString(); + } + + /** + * + * @return + */ + private static ToHTMLRenderer getToHTMLRenderer(Object req) { + ToHTMLRenderer renderer = null; + PortletRequest porReq = null; + HttpServletRequest serReq = null; + if (req instanceof PortletRequest) { + porReq = (PortletRequest)req; + renderer = (ToHTMLRenderer)porReq.getPortletSession().getAttribute("RENDERER"); + } else { + serReq = (HttpServletRequest)req; + // TODO: GETTING RENDERER FROM APPLICATION SCOPE ATTRIBUTE + } + if (renderer == null) { + + // Getting ResourceBundle with current Locale + FacesContext ctx = FacesContext.getCurrentInstance(); + UIViewRoot uiRoot = ctx.getViewRoot(); + Locale locale = uiRoot.getLocale(); + ClassLoader ldr = Thread.currentThread().getContextClassLoader(); + ResourceBundle bundle = ResourceBundle.getBundle("ResourceJSF", locale, ldr); + // Create the HTMLRenderer for BBCode + ToHTMLConfig config = new ToHTMLConfig(); + config.setLoader(loader); + renderer = new ToHTMLRenderer(config, bundle); + if (porReq!=null) { + porReq.getPortletSession().setAttribute("RENDERER", renderer); + } else if (serReq!=null){ + // TODO: SETTING RENDERER IN APPLICATION SCOPE ATTRIBUTE + } + } + return renderer; + } + /** * * @return Modified: labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/action/ModeratorAction.java =================================================================== --- labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/action/ModeratorAction.java 2006-06-30 08:05:20 UTC (rev 4886) +++ labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/action/ModeratorAction.java 2006-06-30 13:53:54 UTC (rev 4887) @@ -26,23 +26,17 @@ import java.util.Collection; import java.util.HashMap; import java.util.Iterator; -import java.util.List; import java.util.Locale; import java.util.Map; import java.util.ResourceBundle; import javax.faces.application.FacesMessage; -import javax.faces.component.UIComponent; import javax.faces.component.UIViewRoot; -import javax.faces.component.html.HtmlInputHidden; import javax.faces.context.FacesContext; -import org.jboss.portlet.forums.ForumsModuleExtension; import org.jboss.portlet.forums.model.Forum; import org.jboss.portlet.forums.model.Topic; -import org.jboss.portlet.forums.theme.FolderType; -import org.jboss.portlet.forums.theme.ForumsTheme; import org.jboss.portlet.forums.ui.BaseController; import org.jboss.portlet.forums.ui.Constants; import org.jboss.portlet.forums.ui.ForumUtil; @@ -416,7 +410,6 @@ if(f!=null && f.trim().length()>0) { forumId = Integer.parseInt(f); - System.out.println("HELLO 1"); } checkboxes=new HashMap(); @@ -433,7 +426,6 @@ Integer.parseInt(this.userPreferences.getPreference(Constants.TOPICS_FORUM_KEY)), currentPage //currently selected page being displayed, first page by default ); - System.out.println("HELLO 2"); this.page = this.pageNavigator.getPage(); } else { // trying to get forumId from topicId read from request @@ -451,10 +443,7 @@ ); this.page = this.pageNavigator.getPage(); } - System.out.println("HELLO 3"); } - - System.out.println("FORUM: "+this.forum); } Modified: labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/action/SplitTopic.java =================================================================== --- labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/action/SplitTopic.java 2006-06-30 08:05:20 UTC (rev 4886) +++ labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/action/SplitTopic.java 2006-06-30 13:53:54 UTC (rev 4887) @@ -22,7 +22,15 @@ package org.jboss.portlet.forums.ui.action; +import java.util.Collection; +import java.util.Map; + +import org.jboss.portlet.forums.model.Topic; import org.jboss.portlet.forums.ui.BaseController; +import org.jboss.portlet.forums.ui.Constants; +import org.jboss.portlet.forums.ui.ForumUtil; +import org.jboss.portlet.forums.ui.JSFUtil; +import org.jboss.portlet.forums.ui.view.PageNavigator; /** * @author <a href="mailto:rys...@jb...">Ryszard Kozmik</a> @@ -30,8 +38,9 @@ public class SplitTopic extends BaseController { private String newTopicTitle; + private Map checkboxes; + private Topic topic; - public void setNewTopicTitle(String newTopicTitle) { this.newTopicTitle = newTopicTitle; } @@ -39,4 +48,54 @@ public String getNewTopicTitle() { return newTopicTitle; } + + public void setCheckboxes(Map checkboxes) + { + this.checkboxes = checkboxes; + } + + public Map getCheckboxes() + { + return checkboxes; + } + + public Topic getTopic() { + return topic; + } + + + /** + * + */ + public boolean isInitialized() + { + boolean initialized = false; + try + { + this.execute(); + initialized = true; + } + catch(Exception e) + { + JSFUtil.handleException(e); + } + return initialized; + } + + private void execute() throws Exception + { + //parse input data + int topicId = -1; + String t = ForumUtil.getParameter(Constants.p_topicId); + String page = ForumUtil.getParameter(Constants.p_page); + if (t != null && t.trim().length() > 0) { + topicId = Integer.parseInt(t); + } + + //process the topic information + if (topicId != -1) { + this.topic = BaseController.getForumsModule().findTopicById(new Integer(topicId)); + } + } + } Modified: labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/view/ViewTopic.java =================================================================== --- labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/view/ViewTopic.java 2006-06-30 08:05:20 UTC (rev 4886) +++ labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/view/ViewTopic.java 2006-06-30 13:53:54 UTC (rev 4887) @@ -52,8 +52,8 @@ */ private Topic topic; private boolean rowClass; - private long postDays=0L; // This is value of selectItem describing time constraint for displayed posts - private PageNavigator pageNavigator = null; + private long postDays=0L; // This is value of selectItem describing time constraint for displayed posts + private PageNavigator pageNavigator = null; private Collection page = new ArrayList(); /** @@ -183,45 +183,40 @@ /** * This method gets topicId from parameters and tries to find topic with that id. */ - private void execute() throws Exception - { + private void execute() throws Exception { //parse input data - int topicId = -1; - String t = ForumUtil.getParameter(Constants.p_topicId); - String page = ForumUtil.getParameter(Constants.p_page); - if(t!=null && t.trim().length()>0) - { - topicId = Integer.parseInt(t); - } - - //process the topic information - if(topicId!=-1) - { - this.topic = BaseController.getForumsModule().findTopicById(new Integer(topicId)); - Collection posts = this.topic.getPosts(); - - if(posts!=null && posts.size()>0) - { - int currentPage = 0; - if(page!=null && page.trim().length()>0) - { - //setup the page data - currentPage = Integer.parseInt(page); - } - - //setup the pageNavigator - this.pageNavigator = new PageNavigator( - posts.toArray(), //total number of entries to be split up into pages - Integer.parseInt(this.userPreferences.getPreference(Constants.POSTS_TOPIC_KEY)), - currentPage //currently selected page being displayed, first page by default - ); - - - - this.page = this.pageNavigator.getPage(); - } - } - } + int topicId = -1; + String t = ForumUtil.getParameter(Constants.p_topicId); + String page = ForumUtil.getParameter(Constants.p_page); + if (t != null && t.trim().length() > 0) { + topicId = Integer.parseInt(t); + } + + //process the topic information + if (topicId != -1) { + this.topic = + BaseController.getForumsModule().findTopicById(new Integer(topicId)); + Collection posts = this.topic.getPosts(); + + if (posts != null && posts.size() > 0) { + int currentPage = 0; + if (page != null && page.trim().length() > 0) { + //setup the page data + currentPage = Integer.parseInt(page); + } + + //setup the pageNavigator + //total number of entries to be split up into pages + //currently selected page being displayed, first page by default + this.pageNavigator = + new PageNavigator(posts.toArray(), Integer.parseInt(this.userPreferences.getPreference(Constants.POSTS_TOPIC_KEY)), + currentPage); + + + this.page = this.pageNavigator.getPage(); + } + } + } //implement this functionality later in 1.1.0 release of forums------------------------------------------------------------------------------------------------------------------------------------------------- Modified: labs/jbossforums/trunk/forums/src/resources/portal-forums-war/WEB-INF/forums.taglib.xml =================================================================== --- labs/jbossforums/trunk/forums/src/resources/portal-forums-war/WEB-INF/forums.taglib.xml 2006-06-30 08:05:20 UTC (rev 4886) +++ labs/jbossforums/trunk/forums/src/resources/portal-forums-war/WEB-INF/forums.taglib.xml 2006-06-30 13:53:54 UTC (rev 4887) @@ -67,9 +67,8 @@ <function-name>dateStr</function-name> <function-class>org.jboss.portlet.forums.ui.ForumUtil</function-class> <function-signature>java.lang.String getDateStr(java.util.Date)</function-signature> - </function> + </function> - <!-- application specific functions --> <!-- function calculates the vote percent for the specified poll option @@ -79,6 +78,15 @@ <function-class>org.jboss.portlet.forums.ui.PortalUtil</function-class> <function-signature>float getVotePercent(org.jboss.portlet.forums.model.Poll,org.jboss.portlet.forums.model.PollOption)</function-signature> </function> + + <!-- + Method for processing posts' messages. + --> + <function> + <function-name>formatMessage</function-name> + <function-class>org.jboss.portlet.forums.ui.PortalUtil</function-class> + <function-signature>java.lang.String formatMessage(java.lang.String,boolean)</function-signature> + </function> <!-- function to get theme URL location --> Modified: labs/jbossforums/trunk/forums/src/resources/portal-forums-war/views/moderator/modcp_split.xhtml =================================================================== --- labs/jbossforums/trunk/forums/src/resources/portal-forums-war/views/moderator/modcp_split.xhtml 2006-06-30 08:05:20 UTC (rev 4886) +++ labs/jbossforums/trunk/forums/src/resources/portal-forums-war/views/moderator/modcp_split.xhtml 2006-06-30 13:53:54 UTC (rev 4887) @@ -32,7 +32,7 @@ <ui:composition template="/views/common/common.xhtml"> <ui:define name="mainContent"> <c:if test="#{splitTopic.initialized && splitTopic.topic!=null && splitTopic.topic.id!=-1}"> -<forums:isAllowed fragment="acl://moderateForum" contextData="#{splitTopic.forum}"> +<forums:isAllowed fragment="acl://moderateForum" contextData="#{splitTopic.topic.forum}"> <h:messages layout="table" infoStyle="color:green" warnStyle="color:red"/> <h:form> @@ -43,8 +43,8 @@ ->&nbsp; <h:outputLink value="#{forums:outputLink(shared.links['forum'],true)}" styleClass="nav"> - <f:param name="f" value="#{splitTopic.forum.id}"/> - <h:outputText value="#{splitTopic.forum.name}"/> + <f:param name="f" value="#{splitTopic.topic.forum.id}"/> + <h:outputText value="#{splitTopic.topic.forum.name}"/> </h:outputLink> </span> </td> @@ -104,18 +104,18 @@ border="0" align="center"> <tr> <td width="50%" align="center"> - <h:commandButton action="{splitTopic.splitPosts}" + <h:commandButton action="${splitTopic.splitPosts}" type="submit" class="liteoption" name="split_type_all" - value="{resource.L_SPLIT_POSTS}"/> + value="${resource.L_SPLIT_POSTS}"/> </td> <td width="50%" align="center"> - <h:commandButton action="{splitTopic.splitAfter}" + <h:commandButton action="${splitTopic.splitAfter}" type="submit" class="liteoption" name="split_type_beyond" - value="{resource.L_SPLIT_AFTER}"/> + value="${resource.L_SPLIT_AFTER}"/> </td> </tr> </table> @@ -128,23 +128,23 @@ </tr> <c:forEach items="#{splitTopic.topic.posts}" var="postrow" varStatus="status" > <tr> - <td align="left" valign="top" class="${n:out("postrow.ROW_CLASS")}"> + <td align="left" valign="top" class='${(status.index%2==0)?"row1":"row2"}'> <span class="name"> - <a name="${n:out("postrow.U_POST_ID")}"></a> - ${n:out("postrow.POSTER_NAME")} + <a name="${postrow.id}"></a> + ${postrow.poster.user.userName} </span> </td> - <td width="100%" valign="top" class="${n:out("postrow.ROW_CLASS")}"> + <td width="100%" valign="top" class='${(status.index%2==0)?"row1":"row2"}'> <table width="100%" cellspacing="0" cellpadding="3" border="0"> <tr> <td valign="middle"> - <img src="${n:out("postrow.IMG_MINIPOST")}" alt="${resource.L_POST}"> + <img src="#{forums:themeURL('resourceIconMinipostURL')}" alt="${resource.L_POST}" /> <span class="postdetails"> ${resource.L_POSTED}: - ${n:out("postrow.POST_DATE")} - + #{forums:dateStr(postrow.createDate)} + &nbsp;&nbsp;&nbsp;&nbsp; ${resource.L_POST_SUBJECT}: - ${n:out("postrow.POST_SUBJECT")} + ${postrow.message.subject} </span> </td> </tr> @@ -152,25 +152,25 @@ <td valign="top"> <hr size="1"/> <span class="postbody"> - ${n:out("postrow.MESSAGE")} + <!-- TODO: PROBLEM WITH THIS TAG!: #{forums:formatMessage(postrow.message.text,??false??)}--> + ${postrow.message.text} + <br /><br /> + ${postrow.poster.user.signature} </span> </td> </tr> </table> </td> - <td width="5%" align="center" class="${n:out("postrow.ROW_CLASS")}"> - <%--${n:out("postrow.S_SPLIT_CHECKBOX")}--%> - <input type="checkbox" - name="post_id_list[${n:out("postrow.POST_ROW_INDEX")}]" - value="${n:out("postrow.POST_ID")}"/> + <td width="5%" align="center" class='${(status.index%2==0)?"row1":"row2"}'> + <h:selectBooleanCheckbox value="#{splitTopic.checkboxes[postrow.id]}"/> </td> </tr> <tr> <td colspan="3" height="1" class="row3"> - <img src="${n:out("postrow.IMG_SPACER")}" width="1" height="1" alt="."> + <img src="#{forums:themeURL('resourceIconSpacerURL')}" width="1" height="1" alt="." /> </td> </tr> - </n:iterate> + </c:forEach> <tr> <td class="catBottom" colspan="3" height="28"> <table width="60%" cellspacing="0" cellpadding="0" border="0" align="center"> @@ -182,7 +182,6 @@ <td width="50%" align="center"> <input class="liteoption" type="submit" name="split_type_beyond" value="${resource.L_SPLIT_AFTER}"/> - ${n:out("S_HIDDEN_FIELDS")} </td> </tr> </table> @@ -191,11 +190,10 @@ </table> <table width="100%" cellspacing="2" border="0" align="center" cellpadding="2"> <tr> - <td align="right" valign="top"> - <span class="gensmall"> - ${n:out("S_TIMEZONE")} - </span> - </td> + <!-- integrate jumpbox here --> + <td align="right" valign="top" nowrap="nowrap"> + <ui:include src="/views/jumpbox.xhtml"/> + </td> </tr> </table> </h:form> Modified: labs/jbossforums/trunk/forums/src/resources/portal-forums-war/views/topics/viewtopic_body.xhtml =================================================================== --- labs/jbossforums/trunk/forums/src/resources/portal-forums-war/views/topics/viewtopic_body.xhtml 2006-06-30 08:05:20 UTC (rev 4886) +++ labs/jbossforums/trunk/forums/src/resources/portal-forums-war/views/topics/viewtopic_body.xhtml 2006-06-30 13:53:54 UTC (rev 4887) @@ -256,11 +256,12 @@ </h:outputLink> <span class="postdetails"> ${resource.Posted}:&nbsp; - <h:outputText value="${postrow.createDate}"> - <f:convertDateTime pattern="EEE MMM d, yyyy HH:mm:ss aaa" /> - </h:outputText> + #{forums:dateStr(postrow.createDate)} <span class="gen">&nbsp;</span> - &nbsp; &nbsp;${resource.Post_subject}&nbsp;:&nbsp;${postrow.message.subject} + &nbsp;&nbsp; + ${resource.Post_subject} + &nbsp;:&nbsp; + ${postrow.message.subject} </span> </td> <!-- "Quote", "Edit", and "Delete" buttons --> @@ -305,7 +306,12 @@ </tr> <tr> <td colspan="2"> - <span class="postbody">${postrow.message.text}</span> + <span class="postbody"> + <!-- TODO: PROBLEM WITH THIS TAG!: #{forums:formatMessage(postrow.message.text,??false??)}--> + ${postrow.message.text} + <br /><br /> + ${postrow.poster.user.signature} + </span> <c:if test="postrow.attachments">--> <ui:include src="/views/topics/attachmentsview.xhtml"> @@ -339,11 +345,6 @@ </c:if> </td> </tr> - <tr> - <td colspan="2"> - <span class="postbody">${postrow.poster.user.signature}</span> - </td> - </tr> </table> </td> </tr> |