<% /** * $RCSfile: index.jsp,v $ * $Revision: 1.21 $ * $Date: 2002/08/10 19:30:41 $ */ %> <%@ page import="java.util.*, com.jivesoftware.util.*, com.jivesoftware.forum.*, com.jivesoftware.forum.util.*" errorPage="error.jsp" %> <% // global.jsp is a collection of utility methods and global variables. // Page authorization and the creation of the authToken and forumFactory // variables is handled there. %> <%@ include file="global.jsp" %> <% // Put the request URI and query string in the session as an attribute. // This is done so the error.jsp and auth.jsp pages can figure out what // page sent it an error and redirect appropriately. setRedirectURL(request); %> <% // The category ID might be passed into this page: long categoryID = ParamUtils.getLongParameter(request,"cat",-1L); // If the category is -1, try loading the category id from the session. This way, // the user will return to the category they used to be on: if (categoryID == -1L) { try { categoryID = Long.parseLong((String)session.getAttribute("jive.category.id")); } catch (NumberFormatException ignored) {} } // If the category ID is -1, the initial category will be the root category: ForumCategory category = null; if (categoryID <= forumFactory.getRootForumCategory().getID()) { category = forumFactory.getRootForumCategory(); } else { category = forumFactory.getForumCategory(categoryID); // Store the category ID in the session. If the user returns to this page, they'll see // the category they were on: session.setAttribute("jive.category.id", String.valueOf(category.getID())); } // Load the root category ForumCategory rootCategory = forumFactory.getRootForumCategory(); int totalDepth = rootCategory.getRecursiveCategoryCount(); boolean oneCategoryLevel = (totalDepth - category.getCategoryCount()) == 0; %> <% // Header include. Pass a title into the header page. String title = SkinUtils.getLocalizedString("skin.default.index.title",locale); %> <%@ include file="header.jsp" %>
<%-- Breadcrumbs (see admin tool to customize): --%> " color="<%= JiveGlobals.getJiveProperty("skin.default.linkColor") %>"> <%= SkinUtils.getLocalizedString("skin.default.global.home",locale) %> » " ><%= SkinUtils.getLocalizedString("skin.default.global.forums",locale) %>

<%-- Text describing your community - settable via the admin tool: --%> " face="<%= JiveGlobals.getJiveProperty("skin.default.fontFace") %>" color="<%= JiveGlobals.getJiveProperty("skin.default.textColor") %>"> <% if (!"false".equals(JiveGlobals.getJiveProperty("skin.default.useDefaultWelcomeText"))) { %> <%= SkinUtils.getLocalizedString("skin.default.global.community_text", locale) %> <% } else { %> <%= JiveGlobals.getJiveProperty("skin.default.communityDescription") %> <% } %>

<%@ include file="loginbox.jsp" %>

<%-- Forum listing cell: --%> <% // If the category is not the root category, print out a link to go // back to the root category if (category.getID() != rootCategory.getID()) { %>
" face="<%= JiveGlobals.getJiveProperty("skin.default.fontFace") %>"> <%-- back to main category --%> <%= SkinUtils.getLocalizedString("skin.default.index.back_to_main_cat",locale) %> <% List parents = new java.util.LinkedList(); parents.add(category); ForumCategory parentCat = category.getParentCategory(); while (parentCat.getID() != rootCategory.getID()) { parents.add(0, parentCat); parentCat = parentCat.getParentCategory(); } for (int i=0; i » <%= c.getName() %> <% } else { %> » <%= c.getName() %> <% } } %>
<% } %> " cellpadding="0" cellspacing="0" border="0" width="100%">
" cellpadding="4" cellspacing="1" border="0" width="100%"> "> <% // Start by displaying the name of the category, if the current // category is not the root category: if (rootCategory.getID() != category.getID()) { %> "> <% } // Next, list all forums in the current category: Iterator forums = category.forums(); // If there are no forums in this category and if this is not the // root category, print a message that indicates there are no forums // in this category: if (!forums.hasNext() && rootCategory.getID() != category.getID()) { %> "> <% } while (forums.hasNext()) { Forum forum = (Forum)forums.next(); String description = forum.getDescription(); ForumMessage lastPost = null; if (!"false".equals(JiveGlobals.getJiveProperty("skin.default.showLastPostLink"))) { lastPost = SkinUtils.getLastPost(forum); } %> "> <% } // end of while loop to display forums // Now display any subcategories in this forum: Iterator subCategories = category.categories(); while (subCategories.hasNext()) { ForumCategory subCategory = (ForumCategory)subCategories.next(); // There are 2 ways to display this subcategory. It will be either // "closed" or "open". "Closed" means we'll print out the category // name and we'll make it a link so the user can click on it and // drill down to the category. No forums will be displayed. "Open" // means we'll show the category name (not a link) and the forums // under it. We only show a category open when 1) the current // category is the root category and 2) when the total depth of the // category tree is 1 (meaning only 1 level of subcategories). // "Closed" case: if (category.getID() != rootCategory.getID() || !oneCategoryLevel) { %> "> <% } // "Open" case: else { %> "> <% // Iterate through the forums in this subcategory, print them: Iterator subForums = subCategory.forums(); if (!subForums.hasNext()) { %> "> <% } while (subForums.hasNext()) { Forum forum = (Forum)subForums.next(); String description = forum.getDescription(); ForumMessage lastPost = null; if (!"false".equals(JiveGlobals.getJiveProperty("skin.default.showLastPostLink"))) { lastPost = SkinUtils.getLastPost(forum); } %> "> <% } // end while to print out sub-forums } // end "open" case } // end while for print out subscategories %>
" color="<%= JiveGlobals.getJiveProperty("skin.default.tableHeaderTextColor") %>" face="<%= JiveGlobals.getJiveProperty("skin.default.headerFontFace") %>"> <%-- FORUM NAME --%> FORUM / CATEGORY NAME " color="<%= JiveGlobals.getJiveProperty("skin.default.tableHeaderTextColor") %>" face="<%= JiveGlobals.getJiveProperty("skin.default.headerFontFace") %>"> <%-- TOPICS/MESSAGES --%> <%= SkinUtils.getLocalizedString("skin.default.index.topics_messages",locale).toUpperCase(locale) %> " color="<%= JiveGlobals.getJiveProperty("skin.default.tableHeaderTextColor") %>" face="<%= JiveGlobals.getJiveProperty("skin.default.headerFontFace") %>"> <%-- LAST POST --%> <%= SkinUtils.getLocalizedString("skin.default.global.last_post",locale).toUpperCase(locale) %>
" face="<%= JiveGlobals.getJiveProperty("skin.default.categoryFontFace") %>" color="<%= JiveGlobals.getJiveProperty("skin.default.categoryTextColor") %>"> <%= category.getName() %>
" face="<%= JiveGlobals.getJiveProperty("skin.default.fontFace") %>" color="<%= JiveGlobals.getJiveProperty("skin.default.textColor") %>"> <%= SkinUtils.getLocalizedString("skin.default.index.no_forums_in_category", locale) %>
<% if (SkinUtils.isNew(forum, lastVisited)) { %> <% } else { %> <% } %> " face="<%= JiveGlobals.getJiveProperty("skin.default.fontFace") %>" color="<%= JiveGlobals.getJiveProperty("skin.default.textColor") %>"> <%= forum.getName() %>
<%= (description!=null)?description:"" %>
" face="<%= JiveGlobals.getJiveProperty("skin.default.fontFace") %>" color="<%= JiveGlobals.getJiveProperty("skin.default.textColor") %>"> <%= SkinUtils.getLocalizedNumber(forum.getThreadCount(),locale) %> <%= SkinUtils.getLocalizedString("skin.default.global.slash",locale) %> <%= SkinUtils.getLocalizedNumber(forum.getMessageCount(),locale) %> " face="<%= JiveGlobals.getJiveProperty("skin.default.fontFace") %>" color="<%= JiveGlobals.getJiveProperty("skin.default.textColor") %>"> <%= SkinUtils.formatDate(request,pageUser,forum.getModifiedDate()) %> <% if (lastPost != null) { User lastPostAuthor = lastPost.getUser(); %>
"> <% StringBuffer buf = new StringBuffer("[[name]] »"); String lastPostLink = buf.toString(); if (lastPostAuthor == null) { String name = lastPost.getProperty("name"); if (name != null) { lastPostLink = StringUtils.replace(lastPostLink, "[[name]]", ""+name+""); List nameDisplay = new ArrayList(1); nameDisplay.add(lastPostLink); %> <%= SkinUtils.getLocalizedString("skin.default.global.last_post_by", locale, nameDisplay) %> <% } else { lastPostLink = StringUtils.replace(lastPostLink, "[[name]]", "Guest"); List nameDisplay = new ArrayList(1); nameDisplay.add(lastPostLink); %> <%= SkinUtils.getLocalizedString("skin.default.global.last_post_by", locale, nameDisplay) %> <% } } else { lastPostLink = StringUtils.replace(lastPostLink, "[[name]]", lastPostAuthor.getUsername()); List nameDisplay = new ArrayList(1); nameDisplay.add(lastPostLink); %> <%= SkinUtils.getLocalizedString("skin.default.global.last_post_by", locale, nameDisplay) %> <% } %> <% } %>
" face="<%= JiveGlobals.getJiveProperty("skin.default.categoryFontFace") %>" color="<%= JiveGlobals.getJiveProperty("skin.default.categoryTextColor") %>"> <%= subCategory.getName() %> <% if (subCategory.getDescription() != null) { %>
<%= subCategory.getDescription() %>
<% } %>
" face="<%= JiveGlobals.getJiveProperty("skin.default.categoryFontFace") %>" color="<%= JiveGlobals.getJiveProperty("skin.default.categoryTextColor") %>"> <%= subCategory.getName() %> <% if (subCategory.getDescription() != null) { %>
<%= subCategory.getDescription() %>
<% } %>
" face="<%= JiveGlobals.getJiveProperty("skin.default.fontFace") %>" color="<%= JiveGlobals.getJiveProperty("skin.default.textColor") %>"> <%= SkinUtils.getLocalizedString("skin.default.index.no_forums_in_category", locale) %>
<% if (SkinUtils.isNew(forum, lastVisited)) { %> <% } else { %> <% } %> " face="<%= JiveGlobals.getJiveProperty("skin.default.fontFace") %>" color="<%= JiveGlobals.getJiveProperty("skin.default.textColor") %>"> <%= forum.getName() %>
<%= (description!=null)?description:"" %>
" face="<%= JiveGlobals.getJiveProperty("skin.default.fontFace") %>" color="<%= JiveGlobals.getJiveProperty("skin.default.textColor") %>"> <%= SkinUtils.getLocalizedNumber(forum.getThreadCount(),locale) %> <%= SkinUtils.getLocalizedString("skin.default.global.slash",locale) %> <%= SkinUtils.getLocalizedNumber(forum.getMessageCount(),locale) %> " face="<%= JiveGlobals.getJiveProperty("skin.default.fontFace") %>" color="<%= JiveGlobals.getJiveProperty("skin.default.textColor") %>"> <%= SkinUtils.formatDate(request,pageUser,forum.getModifiedDate()) %> <% if (lastPost != null) { User lastPostAuthor = lastPost.getUser(); %>
"> <% StringBuffer buf = new StringBuffer("[[name]] »"); String lastPostLink = buf.toString(); if (lastPostAuthor == null) { String name = lastPost.getProperty("name"); if (name != null) { lastPostLink = StringUtils.replace(lastPostLink, "[[name]]", ""+name+""); List nameDisplay = new ArrayList(1); nameDisplay.add(lastPostLink); %> <%= SkinUtils.getLocalizedString("skin.default.global.last_post_by", locale, nameDisplay) %> <% } else { lastPostLink = StringUtils.replace(lastPostLink, "[[name]]", "Guest"); List nameDisplay = new ArrayList(1); nameDisplay.add(lastPostLink); %> <%= SkinUtils.getLocalizedString("skin.default.global.last_post_by", locale, nameDisplay) %> <% } } else { lastPostLink = StringUtils.replace(lastPostLink, "[[name]]", lastPostAuthor.getUsername()); List nameDisplay = new ArrayList(1); nameDisplay.add(lastPostLink); %> <%= SkinUtils.getLocalizedString("skin.default.global.last_post_by", locale, nameDisplay) %> <% } %> <% } %>

<%-- The message "Denotes new messages since your last visit": --%>
" face="<%= JiveGlobals.getJiveProperty("skin.default.fontFace") %>" color="<%= JiveGlobals.getJiveProperty("skin.default.textColor") %>"> <%= SkinUtils.getLocalizedString("skin.default.index.new_messages_explained",locale) %>
<%-- end forum listing cell --%>

<%-- Popular discussions / search box cell: --%> <% // Only show search if it is enabled: if ("true".equals(JiveGlobals.getJiveProperty("search.enabled"))) { %> <%@ include file="searchbox.jsp" %>

<% } // end if search is enabled %> <% // Get an iterator of popular discussions Iterator popularDiscussions = forumFactory.popularThreads(); // only show the popular discussions box if there *are* popular discussions: if (popularDiscussions.hasNext()) { %> " cellpadding="1" cellspacing="0" border="0" width="200">
" cellpadding="4" cellspacing="0" border="0" width="100%">
" color="<%= JiveGlobals.getJiveProperty("skin.default.sidebarHeaderTextColor") %>" face="<%= JiveGlobals.getJiveProperty("skin.default.headerFontFace") %>"> <%= SkinUtils.getLocalizedString("skin.default.index.popular_discussions",locale).toUpperCase(locale) %>
" cellpadding="3" cellspacing="0" border="0" width="100%"> <% // Loop through the iterator of popular discussions: while (popularDiscussions.hasNext()) { ForumThread thread = (ForumThread)popularDiscussions.next(); String subject = thread.getName(); // Clip the length of the subject if it's over a certain length. // This prevents long subjects from screwing up the layout of // the page. if (subject.length() > 25) { subject = StringUtils.chopAtWord(subject, 50) + SkinUtils.getLocalizedString("skin.default.global.elipse",locale); } // Get the forum associated with this thread Forum forum = thread.getForum(); // Number of replies to the thread int numReplies = thread.getMessageCount()-1; %> <% } // end while %>
<%-- Bullet: --%> " face="<%= JiveGlobals.getJiveProperty("skin.default.fontFace") %>"> " face="<%= JiveGlobals.getJiveProperty("skin.default.fontFace") %>"> <%= subject %>
<%= SkinUtils.getLocalizedString("skin.default.global.replies",locale) %><%= SkinUtils.getLocalizedString("skin.default.global.colon",locale) %> <%= SkinUtils.getLocalizedNumber(numReplies,locale) %>
" face="<%= JiveGlobals.getJiveProperty("skin.default.buttonFontFace") %>"> <%= forum.getName() %>
<% } // end if popularDiscussions.hasNext() %> <%-- end popular discussions / search box cell --%>

<%@ include file="footer.jsp" %>