From: <jbo...@li...> - 2006-05-24 00:58:39
|
Author: unibrew Date: 2006-05-23 20:58:31 -0400 (Tue, 23 May 2006) New Revision: 4390 Modified: labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/Constants.java labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/ThemeHelper.java labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/action/ModeratorAction.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_body.xhtml labs/jbossforums/trunk/forums/src/resources/portal-forums-war/views/profile/viewprofile_body.xhtml Log: [JBFORUMS-39] Adding new tag: folderType and some work done on moderator's panel and user profile view Modified: labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/Constants.java =================================================================== --- labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/Constants.java 2006-05-24 00:48:45 UTC (rev 4389) +++ labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/Constants.java 2006-05-24 00:58:31 UTC (rev 4390) @@ -109,4 +109,9 @@ * DOCUMENT_ME */ int POST_GLOBAL_ANNONCE = 3; + + /** + * DOCUMENT_ME + */ + int TOPIC_MOVED = 2; } Modified: labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/ThemeHelper.java =================================================================== --- labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/ThemeHelper.java 2006-05-24 00:48:45 UTC (rev 4389) +++ labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/ThemeHelper.java 2006-05-24 00:58:31 UTC (rev 4390) @@ -21,6 +21,12 @@ */ package org.jboss.portlet.forums.ui; +import java.util.Locale; +import java.util.ResourceBundle; + +import javax.faces.component.UIViewRoot; +import javax.faces.context.FacesContext; + import org.apache.log4j.Logger; import org.jboss.portlet.forums.ForumsConstants; @@ -33,6 +39,7 @@ /** * @author <a href="mailto:soh...@jb...">Sohil Shah</a> + * @author <a href="mailto:rys...@jb...">Ryszard Kozmik</a> * */ public class ThemeHelper @@ -50,6 +57,11 @@ private ForumsTheme theme = null; /** + * If number of posts in topic exceeds this value it means that this topic is hot. + */ + public static final int hotThreshold = 10; + + /** * * */ @@ -59,7 +71,7 @@ this.theme = new ForumsTheme(); //start theme this.theme.setExtendedProperties(new TCCLXProperties(ForumsConstants.THEMENAME, "theme.properties")); - this.theme.start(); + this.theme.start(); } @@ -113,7 +125,7 @@ { String folderTypeURL = ThemeHelper.getURL("resourceFolderURL"); - int hotThreshold = 10; + FolderType folderType = ThemeHelper.singleton.theme.getFolderType(topic.getType(), topic.getStatus(), topic.getReplies() >= hotThreshold); @@ -128,6 +140,52 @@ return folderTypeURL; } + + /** + * + * + */ + public static String getFolderType(Topic topic) + { + + // 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); + + String topicType=null; + + int topicStatus = topic.getStatus(); + FolderType folderType = + ThemeHelper.singleton.theme.getFolderType(topic.getType(), + topicStatus, + topic.getReplies() >= + hotThreshold); + + try { + if (topicStatus != ConstantsHelper.getConstantInt("TOPIC_MOVED")) + { + try + { + topicType = bundle.getString(folderType.type); + } + catch (java.util.MissingResourceException e) + { + topicType = ""; + } + } else + { + topicType = bundle.getString("Topic_Moved"); + } + } catch (Exception e) + { + log.error(ThemeHelper.singleton,e); + return ""; + } + return topicType; + } //-------------------------------------------------------------------------------------------------------------------------------------------- /** 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-05-24 00:48:45 UTC (rev 4389) +++ labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/action/ModeratorAction.java 2006-05-24 00:58:31 UTC (rev 4390) @@ -25,10 +25,20 @@ 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.component.UIComponent; +import javax.faces.component.UIViewRoot; +import javax.faces.component.html.HtmlInputHidden; +import javax.faces.context.FacesContext; + 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; @@ -37,7 +47,7 @@ /** * @author <a href="mailto:rys...@jb...">Ryszard Kozmik</a> */ -public class ModeratorAction +public class ModeratorAction extends BaseController { //business data being generated in this bean by executing ui actions @@ -54,7 +64,8 @@ public Forum getForum() { return this.forum; - } + } + public String getPagination() { /** @@ -75,12 +86,36 @@ public void setCheckboxes(Map checkboxes) { this.checkboxes = checkboxes; + Iterator it = checkboxes.keySet().iterator(); + System.out.println("test"); + while (it.hasNext()) + { + String temp = (String)it.next(); + System.out.println("KEY: "+temp+" VALUE:"+checkboxes.get(temp)); + } } public Map getCheckboxes() { + try { + if (checkboxes!=null) { + Iterator it = checkboxes.keySet().iterator(); + System.out.println("GETCHECKBOXES FULL"); + while (it.hasNext()) + { + Integer temp = (Integer)it.next(); + System.out.println("KEY: "+temp+" VALUE:"+checkboxes.get(temp)); + } + } else + { + System.out.println("GETCHECKBOXES: EMPTY"); + } + } catch (Exception e) + { + e.printStackTrace(); + } return checkboxes; - } + } //------------user preferences------------------------------------------------------------------------------------------------------------- @@ -137,15 +172,19 @@ { // start with a stub implementation this.forum = BaseController.getForumsModule().findForumById(new Integer(forumId)); - checkboxes = new HashMap(forum.getTopicCount()); + //checkboxes = new HashMap(forum.getTopicCount()); + checkboxes=new HashMap(); Iterator it = forum.getTopics().iterator(); while (it.hasNext()) { Topic topic = (Topic)it.next(); - checkboxes.put(topic.getId(),Boolean.FALSE); + //checkboxes.put(topic.getId(),Boolean.FALSE); } - } + } } + + + //------------------------------------------------------------------------------------------------------------------------------------- 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-05-24 00:48:45 UTC (rev 4389) +++ labs/jbossforums/trunk/forums/src/resources/portal-forums-war/WEB-INF/forums.taglib.xml 2006-05-24 00:58:31 UTC (rev 4390) @@ -94,5 +94,13 @@ <function-name>folderTypeURL</function-name> <function-class>org.jboss.portlet.forums.ui.ThemeHelper</function-class> <function-signature>java.lang.String getFolderTypeURL(org.jboss.portlet.forums.model.Topic,boolean)</function-signature> - </function> + </function> + <!-- + function to get folderType + --> + <function> + <function-name>folderType</function-name> + <function-class>org.jboss.portlet.forums.ui.ThemeHelper</function-class> + <function-signature>java.lang.String getFolderType(org.jboss.portlet.forums.model.Topic)</function-signature> + </function> </facelet-taglib> \ No newline at end of file Modified: labs/jbossforums/trunk/forums/src/resources/portal-forums-war/views/moderator/modcp_body.xhtml =================================================================== --- labs/jbossforums/trunk/forums/src/resources/portal-forums-war/views/moderator/modcp_body.xhtml 2006-05-24 00:48:45 UTC (rev 4389) +++ labs/jbossforums/trunk/forums/src/resources/portal-forums-war/views/moderator/modcp_body.xhtml 2006-05-24 00:58:31 UTC (rev 4390) @@ -12,9 +12,9 @@ <!-- TODO: <n:errors/> <n:success/> + +<h:messages layout="table" infoStyle="color:green" warnStyle="color:red" /> --> -<!-- TODO: REWRITE S_POST_DAYS_ACTION -<form method="post" action="${n:out("S_POST_DAYS_ACTION")}">--> <h:form> <table width="100%" cellspacing="2" cellpadding="2" border="0" align="center"> <tr> @@ -48,10 +48,10 @@ <th width="17%" nowrap="nowrap">&nbsp;${resource.Last_Post}&nbsp;</th> <th width="5%" class="thRight" nowrap="nowrap">&nbsp;${resource.Select}&nbsp;</th> </tr> - <c:forEach items="#{moderator.forum.topics}" var="topicrow"> + <c:forEach items="#{moderator.forum.topics}" var="topicrow" > <tr> <td class="row1" align="center" valign="middle"> - <img src="#{forums:themeURL('resourceFolderURL')}" + <img src="#{forums:folderTypeURL(topicrow,moderator.anonymous)}" width="19" height="18" alt="${resource.Topic_Moved}" @@ -59,15 +59,12 @@ </td> <td class="row1"> &nbsp; - <!-- TODO: NEEDS SUPPORT OF EXECUTING THEME METHODS - <span class="topictitle">${n:out("topicrow.TOPIC_TYPE")} - --> + <span class="topictitle">${forums:folderType(topicrow)} <h:outputLink value="#{forums:outputLink(shared.links['topic'],true)}" styleClass="topictitle"> <f:param name="t" value="${topicrow.id}"/> <h:outputText value="${topicrow.subject}"/> </h:outputLink> - - <!-- TODO: LOOK ABOVE </span> --> + </span> </td> <td class="row2" align="center" valign="middle"><span class="postdetails">${topicrow.replies}</span></td> @@ -80,10 +77,6 @@ </c:forEach> <tr align="right"> <td class="catBottom" colspan="5" height="29"> - - <!-- TODO: IT IS PROBABLY USELESS IN JSF IMPLEMENTATION SO IT WILL BE DELETED - ${n:out("S_HIDDEN_FIELDS")} - --> <h:commandButton action="#{moderator.deleteTopic}" class="liteoption" value="${resource.Delete}"> <f:param name="f" value="#{forum.forum.id}"/> @@ -107,13 +100,13 @@ <tr> <td align="left" valign="middle"> <span class="nav"> - <b>#{forum.pagination}</b> + <b>#{moderator.pagination}</b> </span> </td> <td align="right" valign="top" nowrap="nowrap"> <span class="gensmall"></span> <br/> - <span class="nav">#{forum.pageNumber}</span> + <span class="nav">#{moderator.pageNumber}</span> </td> </tr> </table> @@ -127,6 +120,4 @@ </table> </ui:define> </ui:composition> - - </div> Modified: labs/jbossforums/trunk/forums/src/resources/portal-forums-war/views/profile/viewprofile_body.xhtml =================================================================== --- labs/jbossforums/trunk/forums/src/resources/portal-forums-war/views/profile/viewprofile_body.xhtml 2006-05-24 00:48:45 UTC (rev 4389) +++ labs/jbossforums/trunk/forums/src/resources/portal-forums-war/views/profile/viewprofile_body.xhtml 2006-05-24 00:58:31 UTC (rev 4390) @@ -54,7 +54,7 @@ <tr> <th class="thHead" colspan="2" height="25" nowrap="nowrap">${resource.L_VIEWING_PROFILE}</th> </tr> - <!-- <tr> TODO: MISSING AVATAR FEATURE + <!-- <tr> TODO: MISSING AVATAR FEATURE - NEW FEATURE FOR FORUMS <td class="catLeft" width="40%" height="28" align="center"><b><span class="gen">${n:i18n("L_AVATAR")}</span></b> </td> <td class="catRight" width="60%"><b><span class="gen">${n:i18n("L_ABOUT_USER")}</span></b></td> @@ -78,7 +78,8 @@ </td> <td valign="top"> <b><span class="gen">${profile.poster.postCount}</span></b> - <!--<br/><span + <!-- TODO: MISSING STATS - NEW FEATURE FOR FORUMS + <br/><span class="genmed">[${n:out("POST_PERCENT_STATS")} / ${n:out("POST_DAY_STATS")}]</span> <br/><span class="genmed"><a href="${n:out("U_SEARCH_USER")}" class="genmed">${n:i18n("L_SEARCH_USER_POSTS")}</a></span>--> </td> |