From: <jbo...@li...> - 2006-05-15 14:05:14
|
Author: soh...@jb... Date: 2006-05-15 10:05:04 -0400 (Mon, 15 May 2006) New Revision: 4229 Added: labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/view/PageNavigator.java 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/ForumsJSFPortlet.java labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/JSFUtil.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/ThemeHelper.java labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/view/ViewCategory.java labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/view/ViewForum.java labs/jbossforums/trunk/forums/src/resources/portal-forums-war/WEB-INF/classes/ResourceJSF.properties labs/jbossforums/trunk/forums/src/resources/portal-forums-war/WEB-INF/forums-config.xml 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/portlet.xml labs/jbossforums/trunk/forums/src/resources/portal-forums-war/views/forums/viewforum_body.xhtml Log: http://jira.jboss.com/jira/browse/JBFORUMS-73 - Display a Forum and its topics http://jira.jboss.com/jira/browse/JBFORUMS-88 - A Generic PageNavigator 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-15 12:29:34 UTC (rev 4228) +++ labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/Constants.java 2006-05-15 14:05:04 UTC (rev 4229) @@ -48,6 +48,7 @@ public static final String p_attachment = "ATTACHMENT"; public static final String p_vote = "vote"; public static final String p_results = "results"; + public static final String p_page = "page"; //other constants------------------------------------------------------------------------------------------------------------------------------- public static final String QUOTE = "quote"; @@ -80,5 +81,26 @@ /** * DOCUMENT_ME */ - public static final int TOPIC_LOCKED = 1; + public static final int TOPIC_LOCKED = 1; + + + /** + * DOCUMENT_ME + */ + int POST_NORMAL = 0; + + /** + * DOCUMENT_ME + */ + int POST_STICKY = 1; + + /** + * DOCUMENT_ME + */ + int POST_ANNOUNCE = 2; + + /** + * DOCUMENT_ME + */ + int POST_GLOBAL_ANNONCE = 3; } Modified: labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/ForumsJSFPortlet.java =================================================================== --- labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/ForumsJSFPortlet.java 2006-05-15 12:29:34 UTC (rev 4228) +++ labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/ForumsJSFPortlet.java 2006-05-15 14:05:04 UTC (rev 4229) @@ -22,11 +22,16 @@ package org.jboss.portlet.forums.ui; import org.apache.myfaces.portlet.MyFacesGenericPortlet; +import org.jboss.portlet.JBossRenderRequest; +import org.jboss.portlet.JBossRenderResponse; import java.io.IOException; +//portlet api import javax.portlet.ActionRequest; import javax.portlet.ActionResponse; +import javax.portlet.RenderRequest; +import javax.portlet.RenderResponse; import javax.portlet.PortletException; /** @@ -40,11 +45,11 @@ * Called by the portlet container to allow the portlet to process an action request. */ public void processAction(ActionRequest request, ActionResponse response) throws PortletException, IOException - { + { this.setupRenderParameters(request,response); super.processAction(request,response); } - + /** * Not sure why this needs to be done... * This method tends to propagate the request parameters over to the JSF layer @@ -65,6 +70,7 @@ String userId = ForumUtil.getParameter(request,Constants.p_userId); String vote = ForumUtil.getParameter(request,Constants.p_vote); String results = ForumUtil.getParameter(request,Constants.p_results); + String page = ForumUtil.getParameter(request,Constants.p_page); if(categoryId!=null && categoryId.trim().length()>0) { response.setRenderParameter(Constants.p_categoryId,categoryId); @@ -109,5 +115,9 @@ { response.setRenderParameter(Constants.p_results,results); } + if(page!=null && page.trim().length()>0) + { + response.setRenderParameter(Constants.p_page,page); + } } } Modified: labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/JSFUtil.java =================================================================== --- labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/JSFUtil.java 2006-05-15 12:29:34 UTC (rev 4228) +++ labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/JSFUtil.java 2006-05-15 14:05:04 UTC (rev 4229) @@ -48,8 +48,6 @@ * * @author sshah * - * TODO To change the template for this generated type comment go to - * Window - Preferences - Java - Code Style - Code Templates */ public static String getRequestParameter(String name) { @@ -138,8 +136,6 @@ * * @author sshah * - * TODO To change the template for this generated type comment go to - * Window - Preferences - Java - Code Style - Code Templates */ public static String handleException(Exception e) { 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-05-15 12:29:34 UTC (rev 4228) +++ labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/PortalUtil.java 2006-05-15 14:05:04 UTC (rev 4229) @@ -137,8 +137,7 @@ { String preference = null; - Object o = - FacesContext.getCurrentInstance().getExternalContext().getRequest(); + Object o = FacesContext.getCurrentInstance().getExternalContext().getRequest(); if (!JSFUtil.isAnonymous() && o instanceof PortletRequest) { PortletRequest request = (PortletRequest) o; 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-15 12:29:34 UTC (rev 4228) +++ labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/ThemeHelper.java 2006-05-15 14:05:04 UTC (rev 4229) @@ -25,9 +25,12 @@ import org.jboss.portlet.forums.ForumsConstants; import org.jboss.portlet.forums.properties.TCCLXProperties; +import org.jboss.portlet.forums.theme.FolderType; import org.jboss.portlet.forums.theme.ForumsTheme; +import org.jboss.portlet.forums.model.Topic; + /** * @author <a href="mailto:soh...@jb...">Sohil Shah</a> * @@ -74,6 +77,11 @@ return ThemeHelper.singleton; } + //method linked to facelet functions--------------------------------------------------------------------------------------------------------- + /** + * + * + */ public static String getURL(String urlKey) { ThemeHelper helper = null; @@ -99,6 +107,31 @@ /** * + * + */ + public static String getFolderTypeURL(Topic topic,boolean isAnonymous) + { + String folderTypeURL = ThemeHelper.getURL("resourceFolderURL"); + + int hotThreshold = 10; + FolderType folderType = ThemeHelper.singleton.theme.getFolderType(topic.getType(), + topic.getStatus(), topic.getReplies() >= hotThreshold); + + if(!isAnonymous) + { + folderTypeURL = folderType.folderNew; + } + else + { + folderTypeURL = folderType.folder; + } + + return folderTypeURL; + } + //-------------------------------------------------------------------------------------------------------------------------------------------- + + /** + * * @return */ public String getResourceForumURL() @@ -113,5 +146,5 @@ public String getResourceForumLockedURL() { return this.theme.resourceForumLockedURL; - } + } } Added: labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/view/PageNavigator.java =================================================================== --- labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/view/PageNavigator.java 2006-05-15 12:29:34 UTC (rev 4228) +++ labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/view/PageNavigator.java 2006-05-15 14:05:04 UTC (rev 4229) @@ -0,0 +1,189 @@ +/* +* JBoss, Home of Professional Open Source +* Copyright 2005, JBoss Inc., and individual contributors as indicated +* by the @authors tag. See the copyright.txt in the distribution for a +* full listing of individual contributors. +* +* This is free software; you can redistribute it and/or modify it +* under the terms of the GNU Lesser General Public License as +* published by the Free Software Foundation; either version 2.1 of +* the License, or (at your option) any later version. +* +* This software is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this software; if not, write to the Free +* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA +* 02110-1301 USA, or see the FSF site: http://www.fsf.org. +*/ +package org.jboss.portlet.forums.ui.view; + +import java.util.Collection; +import java.util.ArrayList; + +/* + * Created on May 11, 2006 + * + * @author <a href="mailto:soh...@jb...">Sohil Shah</a> + */ +public class PageNavigator +{ + /** + * + */ + private int totalPages = 0; + private int pageSize = 0; + private int currentPage = 0; + private Object[] entries = null; + + /** + * + * + */ + public PageNavigator(Object[] entries,int pageSize,int currentPage) + { + if(entries==null) + { + throw new IllegalStateException("PageNavigator cannot be initialized with a null set of entries"); + } + + this.pageSize = pageSize; + this.currentPage = currentPage; + int totalEntries = 0; + if(entries!=null) + { + this.entries = entries; + totalEntries = this.entries.length; + } + + + //calculate the totalNumberofPages that will be made + double totalDbl = totalEntries; + double pageSizeDbl = this.pageSize; + double pageCountDbl = totalDbl/pageSizeDbl; + this.totalPages = (int)Math.ceil(pageCountDbl); + } + + /** + * + * + */ + public int getTotalPages() + { + return this.totalPages; + } + + /** + * + * + */ + public int getCurrentPage() + { + return this.currentPage; + } + + + /** + * + * + */ + public int getBeginIndex() + { + int beginIndex = 0; + + beginIndex = this.currentPage * this.pageSize; + + return beginIndex; + } + + /** + * + * + */ + public int getEndIndex() + { + int endIndex = 0; + + endIndex = this.getBeginIndex() + this.pageSize; + int totalEntries = 0; + if(this.entries!=null) + { + totalEntries = this.entries.length; + } + if(endIndex >= totalEntries) + { + endIndex = totalEntries; + } + + return endIndex; + } + + /** + * + * + */ + public Collection getPage() + { + Collection page = new ArrayList(); + + int beginIndex = this.getBeginIndex(); + int endIndex = this.getEndIndex(); + int totalEntries = 0; + if(this.entries!=null) + { + totalEntries = this.entries.length; + } + + //reset the page navigation if the start cursor is outside the range (both forward and backward) + if(beginIndex >= totalEntries || beginIndex < 0) + { + this.setCurrentPage(0); //go to the first page + beginIndex = this.getBeginIndex(); + endIndex = this.getEndIndex(); + } + + //get the entries for this page + for(int i=beginIndex;i<endIndex;i++) + { + page.add(this.entries[i]); + } + + return page; + } + + + /** + * + * + */ + public String getPageNumber() + { + return String.valueOf(this.getCurrentPage()+1); + } + + /** + * + * + */ + public int[] getPages() + { + int[] pages = new int[this.getTotalPages()]; + for(int i=0;i<pages.length;i++) + { + pages[i] = i+1; + } + return pages; + } + + /** + * + * + */ + public void setCurrentPage(int currentPage) + { + this.currentPage = currentPage; + } +} Modified: labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/view/ViewCategory.java =================================================================== --- labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/view/ViewCategory.java 2006-05-15 12:29:34 UTC (rev 4228) +++ labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/view/ViewCategory.java 2006-05-15 14:05:04 UTC (rev 4229) @@ -113,9 +113,6 @@ /** * * @author sshah - * - * TODO To change the template for this generated type comment go to - * Window - Preferences - Java - Code Style - Code Templates */ public ViewCategory() { Modified: labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/view/ViewForum.java =================================================================== --- labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/view/ViewForum.java 2006-05-15 12:29:34 UTC (rev 4228) +++ labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/view/ViewForum.java 2006-05-15 14:05:04 UTC (rev 4229) @@ -21,11 +21,18 @@ */ package org.jboss.portlet.forums.ui.view; +import java.util.Collection; +import java.util.Iterator; +import java.util.ArrayList; +import java.util.List; + import org.jboss.portlet.forums.model.Forum; +import org.jboss.portlet.forums.model.Topic; import org.jboss.portlet.forums.ui.Constants; import org.jboss.portlet.forums.ui.BaseController; import org.jboss.portlet.forums.ui.JSFUtil; import org.jboss.portlet.forums.ui.ForumUtil; +import org.jboss.portlet.forums.ui.PortalUtil; //jsf imports @@ -35,36 +42,184 @@ * */ public class ViewForum extends BaseController -{ +{ + //preference related data + private int topicsPerForum = 0; //feed in the topicsPerForum value as a managed property + private String topicsPerForumKey = null; //feed in the topicsPerForum preference key as managed property + //business data being generated in this bean by executing ui actions //this is data is created such that it can be consumed by the view components //like facelets private Forum forum = null; - + private PageNavigator pageNavigator = null; + private Collection page = new ArrayList(); + //----------------bean configuration supplied by the forums-config.xml--------------------------------------------------------------------------------------------- - - + /** + * @return Returns the topicsPerForum. + */ + public int getTopicsPerForum() + { + return topicsPerForum; + } + /** + * @param topicsPerForum The topicsPerForum to set. + */ + public void setTopicsPerForum(int topicsPerForum) + { + this.topicsPerForum = topicsPerForum; + } + + /** + * @return Returns the topicsPerForumKey. + */ + public String getTopicsPerForumKey() + { + return topicsPerForumKey; + } + /** + * @param topicsPerForumKey The topicsPerForumKey to set. + */ + public void setTopicsPerForumKey(String topicsPerForumKey) + { + this.topicsPerForumKey = topicsPerForumKey; + } //----------------business data being generated for use by the view components like facelets--------------------------------------------------------------------------------------- + /** + * + */ public Forum getForum() { return this.forum; - } - public String getPagination() + } + + //page navigation related methods on this bean-------------------------------------------------------------------------------------------- + /** + * + */ + public PageNavigator getPageNavigator() { - /** - * TODO: implement real code to get the pagination... - */ - //stub code - return "10"; + return this.pageNavigator; } - public String getPageNumber() + //-------------------------------------------------------------------------------------------- + /** + * + * + */ + public Collection getAnnouncements() { - /** - * TODO: implement real code to get the pageNumber... - */ - //stub code - return "2"; + Collection announcements = new ArrayList(); + Collection topics = this.forum.getTopics(); + if(topics!=null) + { + for(Iterator itr=topics.iterator();itr.hasNext();) + { + Topic cour = (Topic)itr.next(); + if(cour.getType()==Constants.POST_ANNOUNCE) + { + announcements.add(cour); + } + } + } + return announcements; } + + /** + * + * + */ + public boolean isAnnouncementsPresent() + { + boolean present = false; + Collection topics = this.forum.getTopics(); + if(topics!=null) + { + for(Iterator itr=topics.iterator();itr.hasNext();) + { + Topic cour = (Topic)itr.next(); + if(cour.getType()==Constants.POST_ANNOUNCE) + { + present = true; + break; + } + } + } + return present; + } + + /** + * + * + */ + public Collection getStickyThreads() + { + Collection stickyThreads = new ArrayList(); + for(Iterator itr=this.page.iterator();itr.hasNext();) + { + Topic cour = (Topic)itr.next(); + if(cour.getType()==Constants.POST_STICKY) + { + stickyThreads.add(cour); + } + } + return stickyThreads; + } + + /** + * + * + */ + public boolean isStickyThreadsPresent() + { + boolean present = false; + for(Iterator itr=this.page.iterator();itr.hasNext();) + { + Topic cour = (Topic)itr.next(); + if(cour.getType()==Constants.POST_STICKY) + { + present = true; + break; + } + } + return present; + } + + /** + * + * + */ + public Collection getNormalThreads() + { + Collection normalThreads = new ArrayList(); + for(Iterator itr=this.page.iterator();itr.hasNext();) + { + Topic cour = (Topic)itr.next(); + if(cour.getType()==Constants.POST_NORMAL) + { + normalThreads.add(cour); + } + } + return normalThreads; + } + + /** + * + * + */ + public boolean isNormalThreadsPresent() + { + boolean present = false; + for(Iterator itr=this.page.iterator();itr.hasNext();) + { + Topic cour = (Topic)itr.next(); + if(cour.getType()==Constants.POST_NORMAL) + { + present = true; + break; + } + } + return present; + } //------------user preferences------------------------------------------------------------------------------------------------------------- //------------------------------------------------------------------------------------------------------------------------------------- @@ -74,31 +229,97 @@ */ public ViewForum() { - super(); - try - { - this.execute(); - } - catch(Exception e) - { - JSFUtil.handleException(e); - } + super(); } //ui actions supported by this bean---------------------------------------------------------------------------------------------------- + /** + * + */ + 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 the input parameters + String page = ForumUtil.getParameter(Constants.p_page); int forumId = -1; String f = ForumUtil.getParameter(Constants.p_forumId); if(f!=null && f.trim().length()>0) { forumId = Integer.parseInt(f); - } + } + + //grab the data to be displayed for this page if(forumId!=-1) { - // start with a stub implementation + //setup the business objects like the forum, topics etc that will be displayed this.forum = BaseController.getForumsModule().findForumById(new Integer(forumId)); - } + List allTopics = this.forum.getTopics(); + Object[] topicObjects = null; + if(allTopics!=null) + { + //filter out any announcements from this array....Announcements appear on all pages regardless + Collection topics = new ArrayList(); + for(Iterator itr=allTopics.iterator();itr.hasNext();) + { + Topic cour = (Topic)itr.next(); + if(cour.getType()!=Constants.POST_ANNOUNCE) + { + topics.add(cour); + } + } + topicObjects = topics.toArray(); + } + + + //calculate the pageSize of this forum listing of topics + int pageSize = this.topicsPerForum; //default page size + + //get the user's preferred pageSize for viewing a forum and its list of topics, + //instead of using the default page size + String topicsPerForum = PortalUtil.getPreference(this.topicsPerForumKey); + if(topicsPerForum!=null && topicsPerForum.trim().length()>0) + { + int cour = 0; + try{cour = Integer.parseInt(topicsPerForum);}catch(NumberFormatException nfe){} + if(cour>0) + { + pageSize = cour; //here override the default page size with the user's preference + } + } + + //setup the pageNavigator for this forum + this.pageNavigator = new PageNavigator( + topicObjects, //total number of entries to be split up into pages + pageSize, + 0 //currently selected page being displayed, first page by default + ); + + if(page!=null && page.trim().length()>0) + { + //setup the page data + this.pageNavigator.setCurrentPage(Integer.parseInt(page)); + } + + this.page = this.pageNavigator.getPage(); + } } //------------------------------------------------------------------------------------------------------------------------------------- } Modified: labs/jbossforums/trunk/forums/src/resources/portal-forums-war/WEB-INF/classes/ResourceJSF.properties =================================================================== --- labs/jbossforums/trunk/forums/src/resources/portal-forums-war/WEB-INF/classes/ResourceJSF.properties 2006-05-15 12:29:34 UTC (rev 4228) +++ labs/jbossforums/trunk/forums/src/resources/portal-forums-war/WEB-INF/classes/ResourceJSF.properties 2006-05-15 14:05:04 UTC (rev 4229) @@ -366,7 +366,7 @@ Rules_moderate_1=You <b>cannot</b> Rules_moderate_2=moderate this forum -No_topics_post_one=There are no posts in this forum.<br />Click on the <b>Post New Topic</b> link on this page to post one. +No_topics_post_one=There are no posts in this forum.<br/><br/>Click on the <b>New Topic</b> link on this page to post one. # Modified: labs/jbossforums/trunk/forums/src/resources/portal-forums-war/WEB-INF/forums-config.xml =================================================================== --- labs/jbossforums/trunk/forums/src/resources/portal-forums-war/WEB-INF/forums-config.xml 2006-05-15 12:29:34 UTC (rev 4228) +++ labs/jbossforums/trunk/forums/src/resources/portal-forums-war/WEB-INF/forums-config.xml 2006-05-15 14:05:04 UTC (rev 4229) @@ -9,11 +9,11 @@ <!-- general application configuration --> <application> <!-- jbossportal-facelets integration --> - <!--property-resolver>org.jboss.portal.faces.el.DelegatingPropertyResolver</property-resolver> - <view-handler>com.sun.facelets.FaceletPortletViewHandler</view-handler--> + <property-resolver>org.jboss.portal.faces.el.DelegatingPropertyResolver</property-resolver> + <view-handler>com.sun.facelets.FaceletPortletViewHandler</view-handler> <!-- standalone facelets integration --> - <view-handler>com.sun.facelets.FaceletViewHandler</view-handler> + <!--view-handler>com.sun.facelets.FaceletViewHandler</view-handler--> <!-- internationalization --> <locale-config> @@ -107,7 +107,16 @@ <managed-bean> <managed-bean-name>forum</managed-bean-name> <managed-bean-class>org.jboss.portlet.forums.ui.view.ViewForum</managed-bean-class> - <managed-bean-scope>request</managed-bean-scope> + <managed-bean-scope>request</managed-bean-scope> + <!-- user preferences related configuration --> + <managed-property> + <property-name>topicsPerForumKey</property-name> + <value>topicsperforum</value> + </managed-property> + <managed-property> + <property-name>topicsPerForum</property-name> + <value>10</value> + </managed-property> </managed-bean> <navigation-rule> <from-view-id>/views/forums/viewforum_body.xhtml</from-view-id> 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-15 12:29:34 UTC (rev 4228) +++ labs/jbossforums/trunk/forums/src/resources/portal-forums-war/WEB-INF/forums.taglib.xml 2006-05-15 14:05:04 UTC (rev 4229) @@ -26,16 +26,8 @@ <function-name>constantInt</function-name> <function-class>org.jboss.portlet.forums.ui.ConstantsHelper</function-class> <function-signature>int getConstantInt(java.lang.String)</function-signature> - </function> + </function> <!-- - function to get theme URL location - --> - <function> - <function-name>themeURL</function-name> - <function-class>org.jboss.portlet.forums.ui.ThemeHelper</function-class> - <function-signature>java.lang.String getURL(java.lang.String)</function-signature> - </function> - <!-- function generates the contextPath of the application --> <function> @@ -78,5 +70,21 @@ <function-name>votePercent</function-name> <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> + </function> + <!-- + function to get theme URL location + --> + <function> + <function-name>themeURL</function-name> + <function-class>org.jboss.portlet.forums.ui.ThemeHelper</function-class> + <function-signature>java.lang.String getURL(java.lang.String)</function-signature> + </function> + <!-- + function to get folderTypeURL + --> + <function> + <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> </facelet-taglib> \ No newline at end of file Modified: labs/jbossforums/trunk/forums/src/resources/portal-forums-war/WEB-INF/portlet.xml =================================================================== --- labs/jbossforums/trunk/forums/src/resources/portal-forums-war/WEB-INF/portlet.xml 2006-05-15 12:29:34 UTC (rev 4228) +++ labs/jbossforums/trunk/forums/src/resources/portal-forums-war/WEB-INF/portlet.xml 2006-05-15 14:05:04 UTC (rev 4229) @@ -101,5 +101,51 @@ <portlet-info> <title>JSF Forums</title> </portlet-info> + <portlet-preferences> + <preference> + <name>summarymode</name> + <value>0</value> + </preference> + <preference> + <name>summarytopiclimit</name> + <value>6</value> + </preference> + <preference> + <name>summarytopicdays</name> + <value>20</value> + </preference> + <preference> + <name>summarytopicreplies</name> + <value>15</value> + </preference> + <preference> + <name>topicsperforum</name> + <value>10</value> + </preference> + <!-- not yet integrated with the JSF layer --> + <preference> + <name>notifyreply</name> + <value>1</value> + </preference> + <preference> + <name>allowhtml</name> + <value>1</value> + <!-- + <read-only>true</read-only> + --> + </preference> + <preference> + <name>postorder</name> + <value>ascending</value> + </preference> + <preference> + <name>postspertopic</name> + <value>15</value> + </preference> + <preference> + <name>dateformat</name> + <value>EEE MMM d, yyyy HH:mm aaa</value> + </preference> + </portlet-preferences> </portlet> </portlet-app> Modified: labs/jbossforums/trunk/forums/src/resources/portal-forums-war/views/forums/viewforum_body.xhtml =================================================================== --- labs/jbossforums/trunk/forums/src/resources/portal-forums-war/views/forums/viewforum_body.xhtml 2006-05-15 12:29:34 UTC (rev 4228) +++ labs/jbossforums/trunk/forums/src/resources/portal-forums-war/views/forums/viewforum_body.xhtml 2006-05-15 14:05:04 UTC (rev 4229) @@ -33,7 +33,11 @@ <ui:composition template="/views/common/common.xhtml"> <ui:define name="mainContent"> -<c:if test="#{forum.forum!=null && forum.forum.id!=-1}"> + +<c:if test="#{forum.initialized && forum.forum!=null && forum.forum.id!=-1}"> + + + <!-- title, newtopic, forum, and page navigation --> <table width="100%" cellspacing="2" cellpadding="2" border="0" align="center"> <tr> <td align="left" valign="bottom" colspan="2"> @@ -41,10 +45,7 @@ <f:param name="f" value="#{forum.forum.id}"/> <h:outputText value="#{forum.forum.name}"/> </h:outputLink> - </td> - <td align="right" valign="bottom" nowrap="nowrap"> - <span class="gensmall"><b>#{forum.pagination}</b></span> - </td> + </td> </tr> <tr> <td align="left" valign="middle" width="50" colspan="2"> @@ -86,10 +87,58 @@ <h:outputText value="#{forum.forum.name}"/> </h:outputLink> </span> - </td> + </td> + <!-- page navigation --> + <c:if test="#{forum.pageNavigator.totalPages gt 1}"> + <td align="right" valign="middle" nowrap="nowrap"> + <span class="gensmall"></span><br/> + <span class="nav"> + Goto page + <!-- previous link --> + <c:if test="#{forum.pageNavigator.pageNumber gt 1}"> + &nbsp;&nbsp; + <h:outputLink value="#{forums:outputLink(shared.links['forum'],true)}"> + <f:param name="f" value="#{forum.forum.id}"/> + <f:param name="page" value="#{forum.pageNavigator.currentPage-1}"/> + <h:outputText value="Previous"/> + </h:outputLink> + &nbsp;&nbsp; + </c:if> + <!-- actual pages --> + <c:forEach items="#{forum.pageNavigator.pages}" var="page" varStatus="idx"> + <c:choose> + <c:when test="#{forum.pageNavigator.pageNumber==page}"> + <b>${page}</b> + </c:when> + <c:otherwise> + <h:outputLink value="#{forums:outputLink(shared.links['forum'],true)}"> + <f:param name="f" value="#{forum.forum.id}"/> + <f:param name="page" value="#{page-1}"/> + <h:outputText value="${page}"/> + </h:outputLink> + </c:otherwise> + </c:choose> + <c:if test="${idx.index-1 ne forum.pageNavigator.totalPages-1}"> + <f:verbatim>,</f:verbatim> + </c:if> + </c:forEach> + <!-- Next link --> + <c:if test="#{forum.pageNavigator.pageNumber lt forum.pageNavigator.totalPages}"> + &nbsp;&nbsp; + <h:outputLink value="#{forums:outputLink(shared.links['forum'],true)}"> + <f:param name="f" value="#{forum.forum.id}"/> + <f:param name="page" value="#{forum.pageNavigator.currentPage+1}"/> + <h:outputText value="Next"/> + </h:outputLink> + &nbsp;&nbsp; + </c:if> + </span> + </td> + </c:if> </tr> </table> + <!-- display the list of topics associated with this forum --> <table border="0" cellpadding="4" cellspacing="1" width="100%" class="forumline"> <tr> @@ -101,115 +150,268 @@ <th width="50" align="center" class="thTop" nowrap="nowrap">&nbsp;${resource.Views}&nbsp;</th> <th align="center" class="thCornerR" nowrap="nowrap">&nbsp;${resource.Last_Post}&nbsp;</th> </tr> - <!-- TODO: display the list of topics for this forum --> - <c:forEach items="#{forum.forum.topics}" var="topicrow"> - <tr> - <td class="row1" align="center" valign="middle" width="20"> - <img src="#{forums:themeURL('resourceFolderURL')}" width="19" height="18" - alt="${resource.Topic_Moved}" - title="${resource.Topic_Moved}"/> - </td> - <td class="row1" width="100%"> - <span class="topictitle"> - <a href="link to last post"> - <img border="0" src="#{forums:themeURL('resourceIconLatestReplyURL')}"/></a> - <!-- hookup-TOPIC_TYPE --> - <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> - </span> - <span class="gensmall"> - <br/> - ${resource.Goto_page} - </span> - </td> - <td class="row2" align="center" valign="middle"> - <span class="postdetails"> - ${topicrow.replies} - </span> - </td> - <td class="row3" align="center" valign="middle"> - <span class="name"> - ${topicrow.firstPost.poster.user.userName} - </span> - </td> - <td class="row2" align="center" valign="middle"> - <span class="postdetails"> - ${topicrow.viewCount} - </span> - </td> - <td class="row3Right" align="center" valign="middle" nowrap="nowrap"> - <span class="postdetails"> - ${topicrow.lastPostDate} - <br/> - ${topicrow.lastPost.poster.user.userName} - <!-- TODO: LINK TO LAST POST NEEDED --> - <a href="link to lastPost"><img border="0" src="#{forums:themeURL('resourceIconLatestReplyURL')}"/></a> - </span> - </td> - </tr> - </c:forEach> - <!--n:iterate ctx="topicrow"> - <tr> - <td class="row1" align="center" valign="middle" width="20"> - <img src="${n:out("topicrow.TOPIC_FOLDER_IMG")}" width="19" height="18" - alt="${n:out("topicrow.L_TOPIC_FOLDER_ALT")}" - title="${n:out("topicrow.L_TOPIC_FOLDER_ALT")}"/> - </td> - <td class="row1" width="100%"> - <span class="topictitle"> - ${n:out("topicrow.NEWEST_POST_IMG")}${n:out("topicrow.TOPIC_TYPE")} - <a href="${n:out("topicrow.U_VIEW_TOPIC")}" class="topictitle"> - ${n:out("topicrow.TOPIC_TITLE")} - </a> - </span> - <span class="gensmall"> - <br/> - ${n:out("topicrow.GOTO_PAGE")} - </span> - </td> - <td class="row2" align="center" valign="middle"> - <span class="postdetails"> - ${n:out("topicrow.REPLIES")} - </span> - </td> - <td class="row3" align="center" valign="middle"> - <span class="name"> - ${n:out("topicrow.TOPIC_AUTHOR")} - </span> - </td> - <td class="row2" align="center" valign="middle"> - <span class="postdetails"> - ${n:out("topicrow.VIEWS")} - </span> - </td> - <td class="row3Right" align="center" valign="middle" nowrap="nowrap"> - <span class="postdetails"> - ${n:out("topicrow.LAST_POST_TIME")} - <br/> - <n:if ctx="user_auth"> - <a href="${n:out("topicrow.user_auth.POSTER_INFO_LINK")}"> - </n:if> - ${n:out("topicrow.LAST_POST_AUTHOR")} - <n:if ctx="user_auth"></a></n:if> - ${n:out("topicrow.LAST_POST_IMG")} - </span> - </td> - </tr> - </n:iterate> - <n:iterate ctx="switch_no_topics"> - <tr> - <td class="row1" colspan="6" height="30" align="center" valign="middle"> - <span class="gen"> - ${n:out("L_NO_TOPICS")} - </span> - </td> - </tr> - </n:iterate--> + <c:choose> + <c:when test="#{forum.forum.topicCount>0}"> + <c:if test="#{forum.announcementsPresent}"> + <!-- Announcement threads --> + <tr> + <td class="catLeft" colspan="2" height="28"> + <span class="cattitle"> + <a href="" class="cattitle"> + <span>Announcements</span> + </a> + </span> + </td> + <td class="rowpic" colspan="3" align="right">&nbsp;</td> + </tr> + <c:forEach items="#{forum.announcements}" var="topicrow"> + <tr> + <td class="row1" align="center" valign="middle" width="20"> + <img src="#{forums:folderTypeURL(topicrow,forum.anonymous)}" width="19" height="18" + alt="${resource.Topic_Moved}" title="${resource.Topic_Moved}"/> + </td> + <td class="row1" width="100%"> + <span class="topictitle"> + <!-- view newest post image --> + <h:outputLink value="#{forums:outputLink(shared.links['topic'],true)}" style="text-decoration: none;" + alt="#{resource.View_latest_post}" title="#{resource.View_latest_post}"> + <f:param name="t" value="#{topicrow.lastPost.topic.id}"/> + <f:verbatim> + <img border="0" src="#{forums:themeURL('resourceIconLatestReplyURL')}"/> + </f:verbatim> + </h:outputLink> + <!-- topicType --> + <b>Announcement:</b> + <!-- description of the topic --> + <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> + </span> + </td> + <td class="row2" align="center" valign="middle"> + <span class="postdetails"> + ${topicrow.replies} + </span> + </td> + <td class="row3" align="center" valign="middle"> + <span class="name"> + ${topicrow.firstPost.poster.user.userName} + </span> + </td> + <td class="row2" align="center" valign="middle"> + <span class="postdetails"> + ${topicrow.viewCount} + </span> + </td> + <td class="row3Right" align="center" valign="middle" nowrap="nowrap"> + <span class="postdetails"> + <!-- date of the last post on this topic --> + #{forums:dateStr(topicrow.lastPostDate)} + <br/> + <!-- last post poster on this topic --> + <c:choose> + <c:when test="#{forum.anonymous}"> + ${topicrow.lastPost.poster.user.userName} + </c:when> + <c:otherwise> + <h:outputLink value="#{forums:outputLink(shared.links['profile'],true)}"> + <f:param name="uid" value="#{topicrow.lastPost.poster.user.id}"/> + <h:outputText value="${topicrow.lastPost.poster.user.userName}"/> + </h:outputLink> + </c:otherwise> + </c:choose> + <!-- link to the last post in the topic --> + <h:outputLink value="#{forums:outputLink(shared.links['topic'],true)}" style="text-decoration: none;" + alt="#{resource.View_latest_post}" title="#{resource.View_latest_post}"> + <f:param name="t" value="#{topicrow.lastPost.topic.id}"/> + <f:verbatim> + <img border="0" src="#{forums:themeURL('resourceIconLatestReplyURL')}"/> + </f:verbatim> + </h:outputLink> + </span> + </td> + </tr> + </c:forEach> + </c:if> + <c:if test="#{forum.stickyThreadsPresent}"> + <!-- Sticky Threads --> + <tr> + <td class="catLeft" colspan="2" height="28"> + <span class="cattitle"> + <a href="" class="cattitle"> + <span>Sticky Threads</span> + </a> + </span> + </td> + <td class="rowpic" colspan="3" align="right">&nbsp;</td> + </tr> + <c:forEach items="#{forum.stickyThreads}" var="topicrow"> + <tr> + <td class="row1" align="center" valign="middle" width="20"> + <img src="#{forums:folderTypeURL(topicrow,forum.anonymous)}" width="19" height="18" + alt="${resource.Topic_Moved}" title="${resource.Topic_Moved}"/> + </td> + <td class="row1" width="100%"> + <span class="topictitle"> + <!-- view newest post image --> + <h:outputLink value="#{forums:outputLink(shared.links['topic'],true)}" style="text-decoration: none;" + alt="#{resource.View_latest_post}" title="#{resource.View_latest_post}"> + <f:param name="t" value="#{topicrow.lastPost.topic.id}"/> + <f:verbatim> + <img border="0" src="#{forums:themeURL('resourceIconLatestReplyURL')}"/> + </f:verbatim> + </h:outputLink> + <!-- topicType --> + <b>Sticky:</b> + <!-- description of the topic --> + <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> + </span> + </td> + <td class="row2" align="center" valign="middle"> + <span class="postdetails"> + ${topicrow.replies} + </span> + </td> + <td class="row3" align="center" valign="middle"> + <span class="name"> + ${topicrow.firstPost.poster.user.userName} + </span> + </td> + <td class="row2" align="center" valign="middle"> + <span class="postdetails"> + ${topicrow.viewCount} + </span> + </td> + <td class="row3Right" align="center" valign="middle" nowrap="nowrap"> + <span class="postdetails"> + <!-- date of the last post on this topic --> + #{forums:dateStr(topicrow.lastPostDate)} + <br/> + <!-- last post poster on this topic --> + <c:choose> + <c:when test="#{forum.anonymous}"> + ${topicrow.lastPost.poster.user.userName} + </c:when> + <c:otherwise> + <h:outputLink value="#{forums:outputLink(shared.links['profile'],true)}"> + <f:param name="uid" value="#{topicrow.lastPost.poster.user.id}"/> + <h:outputText value="${topicrow.lastPost.poster.user.userName}"/> + </h:outputLink> + </c:otherwise> + </c:choose> + <!-- link to the last post in the topic --> + <h:outputLink value="#{forums:outputLink(shared.links['topic'],true)}" style="text-decoration: none;" + alt="#{resource.View_latest_post}" title="#{resource.View_latest_post}"> + <f:param name="t" value="#{topicrow.lastPost.topic.id}"/> + <f:verbatim> + <img border="0" src="#{forums:themeURL('resourceIconLatestReplyURL')}"/> + </f:verbatim> + </h:outputLink> + </span> + </td> + </tr> + </c:forEach> + </c:if> + <c:if test="#{forum.normalThreadsPresent}"> + <!-- Normal threads --> + <tr> + <td class="catLeft" colspan="2" height="28"> + <span class="cattitle"> + <a href="" class="cattitle"> + <span>Normal Threads</span> + </a> + </span> + </td> + <td class="rowpic" colspan="3" align="right">&nbsp;</td> + </tr> + <c:forEach items="#{forum.normalThreads}" var="topicrow"> + <tr> + <td class="row1" align="center" valign="middle" width="20"> + <img src="#{forums:folderTypeURL(topicrow,forum.anonymous)}" width="19" height="18" + alt="${resource.Topic_Moved}" title="${resource.Topic_Moved}"/> + </td> + <td class="row1" width="100%"> + <span class="topictitle"> + <!-- view newest post image --> + <h:outputLink value="#{forums:outputLink(shared.links['topic'],true)}" style="text-decoration: none;" + alt="#{resource.View_latest_post}" title="#{resource.View_latest_post}"> + <f:param name="t" value="#{topicrow.lastPost.topic.id}"/> + <f:verbatim> + <img border="0" src="#{forums:themeURL('resourceIconLatestReplyURL')}"/> + </f:verbatim> + </h:outputLink> + <!-- topicType (Normal) no need to specify --> + <!-- description of the topic --> + <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> + </span> + </td> + <td class="row2" align="center" valign="middle"> + <span class="postdetails"> + ${topicrow.replies} + </span> + </td> + <td class="row3" align="center" valign="middle"> + <span class="name"> + ${topicrow.firstPost.poster.user.userName} + </span> + </td> + <td class="row2" align="center" valign="middle"> + <span class="postdetails"> + ${topicrow.viewCount} + </span> + </td> + <td class="row3Right" align="center" valign="middle" nowrap="nowrap"> + <span class="postdetails"> + <!-- date of the last post on this topic --> + #{forums:dateStr(topicrow.lastPostDate)} + <br/> + <!-- last post poster on this topic --> + <c:choose> + <c:when test="#{forum.anonymous}"> + ${topicrow.lastPost.poster.user.userName} + </c:when> + <c:otherwise> + <h:outputLink value="#{forums:outputLink(shared.links['profile'],true)}"> + <f:param name="uid" value="#{topicrow.lastPost.poster.user.id}"/> + <h:outputText value="${topicrow.lastPost.poster.user.userName}"/> + </h:outputLink> + </c:otherwise> + </c:choose> + <!-- link to the last post in the topic --> + <h:outputLink value="#{forums:outputLink(shared.links['topic'],true)}" style="text-decoration: none;" + alt="#{resource.View_latest_post}" title="#{resource.View_latest_post}"> + <f:param name="t" value="#{topicrow.lastPost.topic.id}"/> + <f:verbatim> + <img border="0" src="#{forums:themeURL('resourceIconLatestReplyURL')}"/> + </f:verbatim> + </h:outputLink> + </span> + </td> + </tr> + </c:forEach> + </c:if> + </c:when> + <c:otherwise> + <tr> + <td class="row1" colspan="6" height="30" align="center" valign="middle"> + <span class="gen"> + ${resource.No_topics_post_one} + </span> + </td> + </tr> + </c:otherwise> + </c:choose> </table> + <!-- newtopic, forum, and page navigation --> <table width="100%" cellspacing="2" border="0" align="center" cellpadding="2"> <tr> <td align="left" valign="middle" width="50"> @@ -252,23 +454,74 @@ </h:outputLink> </span> </td> - <td align="right" valign="middle" nowrap="nowrap"> - <span class="gensmall"></span> - <br/> - <span class="nav"> - #{forum.pagination} - </span> - </td> + <!-- page navigation --> + <c:if test="#{forum.pageNavigator.totalPages gt 1}"> + <td align="right" valign="middle" nowrap="nowrap"> + <span class="gensmall"></span><br/> + <span class="nav"> + Goto page + <!-- previous link --> + <c:if test="#{forum.pageNavigator.pageNumber gt 1}"> + &nbsp;&nbsp; + <h:outputLink value="#{forums:outputLink(shared.links['forum'],true)}"> + <f:param name="f" value="#{forum.forum.id}"/> + <f:param name="page" value="#{forum.pageNavigator.currentPage-1}"/> + <h:outputText value="Previous"/> + </h:outputLink> + &nbsp;&nbsp; + </c:if> + <!-- actual pages --> + <c:forEach items="#{forum.pageNavigator.pages}" var="page" varStatus="idx"> + <c:choose> + <c:when test="#{forum.pageNavigator.pageNumber==page}"> + <b>${page}</b> + </c:when> + <c:otherwise> + <h:outputLink value="#{forums:outputLink(shared.links['forum'],true)}"> + <f:param name="f" value="#{forum.forum.id}"/> + <f:param name="page" value="#{page-1}"/> + <h:outputText value="${page}"/> + </h:outputLink> + </c:otherwise> + </c:choose> + <c:if test="${idx.index-1 ne forum.pageNavigator.totalPages-1}"> + <f:verbatim>,</f:verbatim> + </c:if> + </c:forEach> + <!-- Next link --> + <c:if test="#{forum.pageNavigator.pageNumber lt forum.pageNavigator.totalPages}"> + &nbsp;&nbsp; + <h:outputLink value="#{forums:outputLink(shared.links['forum'],true)}"> + <f:param name="f" value="#{forum.forum.id}"/> + <f:param name="page" value="#{forum.pageNavigator.currentPage+1}"/> + <h:outputText value="Next"/> + </h:outputLink> + &nbsp;&nbsp; + </c:if> + </span> + </td> + </c:if> </tr> - <tr> - <td align="left" colspan="3"> - <span class="nav"> - #{forum.pageNumber} - </span> - </td> - </tr> - </table> + <!-- the current page number information --> + <c:if test="#{forum.pageNavigator.totalPages gt 1}"> + <tr> + <td>&nbsp;</td> + </tr> + <tr> + <td align="left" colspan="3"> + <span class="nav"> + Page <b>#{forum.pageNavigator.pageNumber}</b> of <b>#{forum.pageNavigator.totalPages}</b> + </span> + </td> + </tr> + <tr> + <td>&nbsp;</td> + </tr> + </c:if> + </table> + + <!-- displaying icons, permissions, and jumpbox --> <table width="100%" cellspacing="0" border="0" align="center" cellpadding="0"> <tr> <td align="left" valign="top"> @@ -319,10 +572,19 @@ </table> </td> <td align="right"> - <span class="gensmall"> - <ui:include src="/views/jumpbox.xhtml"/> - <!-- TODO: hookup real data here...need to extract out the hardcoded html code from the original portlet --> - <!-- S_AUTH_LIST --> + <span class="gensmall"> + <!-- a list of allowed actions on this forum for this user --> + <span class="gensmall"> + <!-- TODO: insert security check to make sure "posting new topics" is allowed in "this forum" --> + You <b>cannot</b> post new topics in this forum <br/> + <!-- TODO: insert security check to make sure "poll creation" is allowed in "this forum" --> + You <b>cannot</b> create polls in this forum <br/> + <!-- TODO: insert security check to make sure "placing votes" is allowed in "this forum" --> + You <b>cannot</b> vote in polls in this forum <br/> + <!-- TODO: insert security check to make sure "moderator access" is allowed on "this forum" --> + You <b>cannot</b> moderate this forum <b/> + </span> + <ui:include src="/views/jumpbox.xhtml"/> </span> </td> </tr> |