<%--
  The contents of this file are subject to the Mozilla Public License Version 1.1
  (the "License"); you may not use this file except in compliance with the License.
  You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.

  Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
  WARRANTY OF ANY KIND, either express or implied. See the License for the specific
  language governing rights and limitations under the License.
  
  The Original Code is the Venice Web Communities System.
  
  The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
  for Silverwrist Design Studios.  Portions created by Eric J. Bowersox are
  Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios.  All Rights Reserved.

  Contributor(s): 
--%>
<%@ page import = "java.util.*" %>
<%@ page import = "com.silverwrist.util.StringUtil" %>
<%@ page import = "com.silverwrist.venice.core.*" %>
<%@ page import = "com.silverwrist.venice.servlets.Variables" %>
<%@ page import = "com.silverwrist.venice.servlets.format.*" %>
<%
  TopicListing data = TopicListing.retrieve(request);
  Variables.failIfNull(data);
  RenderData rdat = RenderConfig.createRenderData(application,request,response);
  String stdfont = rdat.getStdFontTag(ColorSelectors.CONTENT_FOREGROUND,2);
  String self = "confdisp?" + data.getLocator();
  String tmp;
%>
<% if (rdat.useHTMLComments()) { %><!-- Topic list for conf #<%= data.getConfID() %> --><% } %>
<% rdat.writeContentHeader(out,"Topics in " + data.getConfName(),null); %>
<%= stdfont %>
  <DIV ALIGN="LEFT" CLASS="content">
    <A HREF="<%= rdat.getEncodedServletPath("confops?sig=" + data.getCommunityID()) %>"><IMG
     SRC="<%= rdat.getFullImagePath("bn_conference_list.gif") %>" ALT="Conference List" WIDTH=80 HEIGHT=24
     BORDER=0></A>&nbsp;
    <% if (data.canCreateTopic()) { %>
      <% tmp = rdat.getEncodedServletPath("confops?" + data.getLocator() + "&cmd=T"); %>
      <A HREF="<%= tmp %>"><IMG SRC="<%= rdat.getFullImagePath("bn_add_topic.gif") %>" ALT="Add Topic"
                            WIDTH=80 HEIGHT=24 BORDER=0></A>&nbsp;
    <% } // end if %>
    <% if (data.canDoReadNew()) { %>
      <A HREF="<%= rdat.getEncodedServletPath("confdisp?" + data.getNextLocator() + "&rnm=1") %>"><IMG
       SRC="<%= rdat.getFullImagePath("bn_read_new.gif") %>" ALT="Read New" WIDTH=80 HEIGHT=24
       BORDER=0></A>&nbsp;
    <% } // end if %>
    <A HREF="<%= rdat.getEncodedServletPath("confops?" + data.getLocator() + "&cmd=Q") %>"><IMG
       SRC="<%= rdat.getFullImagePath("bn_manage.gif") %>" ALT="Manage" WIDTH=80 HEIGHT=24
       BORDER=0></A>&nbsp;
    <% if (data.canAddToHotlist()) { %>
      <A HREF="<%= rdat.getEncodedServletPath("confops?" + data.getLocator() + "&cmd=H") %>"><IMG
         SRC="<%= rdat.getFullImagePath("bn_add_to_hotlist.gif") %>" ALT="Add to HotList" WIDTH=80
	 HEIGHT=24 BORDER=0></A>&nbsp;
    <% } // end if %>
  </DIV>
  <% if (data.anyTopics()) { %>
    <TABLE WIDTH="100%" BORDER=0 CELLPADDING=0 CELLSPACING=3>
      <TR VALIGN=TOP>
        <TD ALIGN=LEFT WIDTH="1%" CLASS="content" NOWRAP><%= stdfont %>
          <% tmp = self + "&sort="
                 + (data.isSort(ConferenceContext.SORT_NUMBER) ? -ConferenceContext.SORT_NUMBER
                                                               : ConferenceContext.SORT_NUMBER); %>
          <B><A HREF="<%= rdat.getEncodedServletPath(tmp) %>">#</A></B>
        </FONT></TD>
        <TD ALIGN=LEFT CLASS="content"><%= stdfont %>
          <% tmp = self + "&sort="
                 + (data.isSort(ConferenceContext.SORT_NAME) ? -ConferenceContext.SORT_NAME
                                                             : ConferenceContext.SORT_NAME); %>
          <B><A HREF="<%= rdat.getEncodedServletPath(tmp) %>">Topic Name</A></B>
        </FONT></TD>
        <TD ALIGN=RIGHT CLASS="content" NOWRAP><%= stdfont %>
          <% tmp = self + "&sort="
                 + (data.isSort(ConferenceContext.SORT_UNREAD) ? -ConferenceContext.SORT_UNREAD
                                                               : ConferenceContext.SORT_UNREAD); %>
          <B><A HREF="<%= rdat.getEncodedServletPath(tmp) %>">New</A></B>
        </FONT></TD>
        <TD ALIGN=RIGHT CLASS="content" NOWRAP><%= stdfont %>
          <% tmp = self + "&sort="
                 + (data.isSort(ConferenceContext.SORT_TOTAL) ? -ConferenceContext.SORT_TOTAL
                                                              : ConferenceContext.SORT_TOTAL); %>
          <B><A HREF="<%= rdat.getEncodedServletPath(tmp) %>">Total</A></B>
        </FONT></TD>
        <TD ALIGN=LEFT CLASS="content" NOWRAP><%= stdfont %>
          <% tmp = self + "&sort="
                 + (data.isSort(ConferenceContext.SORT_DATE) ? -ConferenceContext.SORT_DATE
                                                             : ConferenceContext.SORT_DATE); %>
          <B><A HREF="<%= rdat.getEncodedServletPath(tmp) %>">Last Response</A></B>
        </FONT></TD>
      </TR>
      <TR VALIGN=TOP><TD ALIGN=LEFT COLSPAN=5>&nbsp;</TD></TR>
      <% Iterator it = data.getTopicIterator(); %>
      <% while (it.hasNext()) { %>
        <%
          TopicContext topic = (TopicContext)(it.next());
          tmp = self + "&top=" + topic.getTopicNumber() + "&rnm=1";
        %>
        <TR VALIGN=TOP>
          <TD ALIGN=LEFT WIDTH="1%" CLASS="content" NOWRAP><%= stdfont %>
	    <A HREF="<%= rdat.getEncodedServletPath(tmp) %>"><%= topic.getTopicNumber() %></A>&nbsp;&nbsp;
          </FONT></TD>
          <TD ALIGN=LEFT CLASS="content"><%= stdfont %>
            <A HREF="<%= rdat.getEncodedServletPath(tmp) %>"><%= topic.getName() %></A>
            <% if (topic.isArchived() && !(data.isView(ConferenceContext.DISPLAY_ARCHIVED))) { %>
              <EM>(archived)</EM>
            <% } else if (topic.isFrozen()) { %>
              <EM>(frozen)</EM>
            <% } // end if %>
          </FONT></TD>
          <TD ALIGN=RIGHT CLASS="content" NOWRAP><%= stdfont %>
            <A HREF="<%= rdat.getEncodedServletPath(tmp) %>"><%= topic.getUnreadMessages() %></A>
          </FONT></TD>
          <TD ALIGN=RIGHT CLASS="content" NOWRAP><%= stdfont %>
          <A HREF="<%= rdat.getEncodedServletPath(self + "&top=" + topic.getTopicNumber()
                                                  + "&p1=0&p2=-1") %>"><%= topic.getTotalMessages() %></A>
          </FONT></TD>
          <TD ALIGN=LEFT CLASS="content" NOWRAP><%= stdfont %>
            <A HREF="<%= rdat.getEncodedServletPath(tmp) %>"><%= rdat.formatDateForDisplay(topic.getLastUpdateDate()) %></A>
          </FONT></TD>
        </TR>
      <% } // end while (more topics in enumeration) %>
    </TABLE><P>
  <% } else { %>
    <%
      switch (data.getViewOption()) 
      {
        case ConferenceContext.DISPLAY_NEW:
    %>
          <EM>No topics with unread messages found.</EM>
    <%
          break;
        case ConferenceContext.DISPLAY_ACTIVE:
        case ConferenceContext.DISPLAY_ALL:
    %>
          <EM>No active topics found.</EM>
    <%
          break;
        case ConferenceContext.DISPLAY_HIDDEN:
    %>
          <EM>No hidden topics found.</EM>
    <%
          break;
        case ConferenceContext.DISPLAY_ARCHIVED:
    %>
          <EM>No archived topics found.</EM>
    <%
          break;
        default:
    %>
          <EM>Invalid display option selected.</EM>
    <%
          break;
      } // end switch
    %>
    <P>
  <% } // end if %>
  <DIV ALIGN="CENTER" CLASS="content">
    <B>[</B>
    <% if (data.isView(ConferenceContext.DISPLAY_NEW)) { %>
      <B>New</B>
    <% } else { %>
      <A HREF="<%= rdat.getEncodedServletPath(self + "&view=" + ConferenceContext.DISPLAY_NEW) %>">New</A>
    <% } // end if %>
    <B>|</B>
    <% if (data.isView(ConferenceContext.DISPLAY_ACTIVE)) { %>
      <B>Active</B>
    <% } else { %>
      <A HREF="<%= rdat.getEncodedServletPath(self + "&view="
                                              + ConferenceContext.DISPLAY_ACTIVE) %>">Active</A>
    <% } // end if %>
    <B>|</B>
    <% if (data.isView(ConferenceContext.DISPLAY_ALL)) { %>
      <B>All</B>
    <% } else { %>
      <A HREF="<%= rdat.getEncodedServletPath(self + "&view=" + ConferenceContext.DISPLAY_ALL) %>">All</A>
    <% } // end if %>
    <B>|</B>
    <% if (data.isView(ConferenceContext.DISPLAY_HIDDEN)) { %>
      <B>Hidden</B>
    <% } else { %>
      <A HREF="<%= rdat.getEncodedServletPath(self + "&view="
                                              + ConferenceContext.DISPLAY_HIDDEN) %>">Hidden</A>
    <% } // end if %>
    <B>|</B>
    <% if (data.isView(ConferenceContext.DISPLAY_ARCHIVED)) { %>
      <B>Archived</B>
    <% } else { %>
      <A HREF="<%= rdat.getEncodedServletPath(self + "&view="
                                              + ConferenceContext.DISPLAY_ARCHIVED) %>">Archived</A>
    <% } // end if %>
    <B>]</B>
  </DIV>
</FONT>
