<%--
  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-02 Eric J. Bowersox/Silverwrist Design Studios.  All Rights Reserved.

  Contributor(s): 
--%>
<%@ page import = "java.util.*" %>
<%@ page import = "com.silverwrist.venice.core.*" %>
<%@ page import = "com.silverwrist.venice.ui.conf.CurrentConference" %>
<%@ page import = "com.silverwrist.venice.ui.conf.view.FindPostView" %>
<%@ page import = "com.silverwrist.venice.ui.view.JSPView" %>
<%@ taglib uri="/tlds/util" prefix="util" %>
<%
  FindPostView view = FindPostView.get(request);
%>
<util:comment>Find Posts</util:comment>
<util:header title="Find Posts">
  <% if (view.getTopic()!=null) { %>
    <util:subtitle>in Topic: <%= view.getTopic().getName() %></util:subtitle>
  <% } else if (view.getConference()!=null) { %>
    <util:subtitle>
      in Conference: <util:escape><%= view.getConference().getName() %></util:escape>
    </util:subtitle>
  <% } else { %>
    <util:subtitle>
      in Community: <util:escape><%= view.getCommunity().getName() %></util:escape>
    </util:subtitle>
  <% } // end if %>
</util:header>
<util:font color="content.fg" size="content"><util:xlink>
  <% if (view.getTopic()!=null) { %>
    <util:href type="servlet">conf/posts.js.vs?cc=<%= view.getCommunity().getCommunityID() %>&conf=<%= view.getConference().getConfID() %>&top=<%= view.getTopic().getTopicNumber() %></util:href>
    <util:text>Return to Topic</util:text>
  <% } else if (view.getConference()!=null) { %>
    <util:href type="servlet">conf/topics.js.vs?cc=<%= view.getCommunity().getCommunityID() %>&conf=<%= view.getConference().getConfID() %></util:href>
    <util:text>Return to Topic List</util:text>
  <% } else { %>
    <util:href type="servlet">conf/conferences.js.vs?cc=<%= view.getCommunity().getCommunityID() %></util:href>
    <util:text>Return to Conference List</util:text>
  <% } // end if %>
</util:xlink></util:font><P>

<util:form action="conf/find.js.vs" type="servlet"><DIV CLASS="content">
  <INPUT TYPE="HIDDEN" NAME="cc" VALUE="<%= view.getCommunity().getCommunityID() %>">
  <% if (view.getConference()!=null) { %>
    <INPUT TYPE="HIDDEN" NAME="conf" VALUE="<%= view.getConference().getConfID() %>">
    <% if (view.getTopic()!=null) { %>
      <INPUT TYPE="HIDDEN" NAME="top" VALUE="<%= view.getTopic().getTopicNumber() %>">
    <% } // end if %>
  <% } // end if %>
  <INPUT TYPE="HIDDEN" NAME="ofs" VALUE="0">
  <INPUT TYPE="HIDDEN" NAME="fcount" VALUE="-1">
  <INPUT TYPE="HIDDEN" NAME="newsearch" VALUE="1"><%-- EJB 1/18/2002 --%>
  <util:font color="content.fg" size="content">
    Keywords: <SPAN CLASS="cinput"><INPUT TYPE=TEXT CLASS="cinput" NAME="term" SIZE=64 MAXLENGTH=255
                                          VALUE="<%= view.getTerm() %>"></SPAN>
  </util:font><BR>
  <util:button id="search" type="input"/>
</DIV></util:form><P>

<% List results = view.getResults(); %>
<% if (results!=null) { %>
  <util:comment>Display Search Results</util:comment>
  <%
    // Determine the number of results to display and whether to display a "next" button
    int dcount = results.size();
    boolean go_next = false;
    if (dcount>view.getMaxResults())
    { // there's a "next"
      dcount = view.getMaxResults();
      go_next = true;

    } // end if
  %>
  <HR>
  <TABLE WIDTH="100%" BORDER=0 ALIGN=CENTER><TR VALIGN=MIDDLE>
    <TD WIDTH="50%" ALIGN=LEFT CLASS="content"><util:font color="content.fg" size="3">
      <%-- The initial search results --%>
      <B>Search Results</B>
      <% if (view.getFindCount()>0) { %>
        (Displaying <%= view.getOffset() + 1 %>-<%= view.getOffset() + dcount %> of
        <%= view.getFindCount() %>)
      <% } else { %>(None)<% } %>
    </util:font></TD>

    <TD WIDTH="50%" ALIGN=RIGHT CLASS="content">
      <% if (go_next || (view.getOffset()>0)) { %>
        <%-- The navigational form that allows us to page through the results --%>
        <util:comment>Navigational form</util:comment>
        <util:form action="conf/find.js.vs" type="servlet"><DIV CLASS="content">
          <INPUT TYPE="HIDDEN" NAME="cc" VALUE="<%= view.getCommunity().getCommunityID() %>">
          <% if (view.getConference()!=null) { %>
            <INPUT TYPE="HIDDEN" NAME="conf" VALUE="<%= view.getConference().getConfID() %>">
            <% if (view.getTopic()!=null) { %>
              <INPUT TYPE="HIDDEN" NAME="top" VALUE="<%= view.getTopic().getTopicNumber() %>">
            <% } // end if %>
          <% } // end if %>
          <INPUT TYPE=HIDDEN NAME="term" VALUE="<%= view.getTerm() %>">
          <INPUT TYPE=HIDDEN NAME="ofs" VALUE="<%= view.getOffset() %>">
          <INPUT TYPE=HIDDEN NAME="fcount" VALUE="<%= view.getFindCount() %>">
          <INPUT TYPE=HIDDEN NAME="newsearch" VALUE="0"><%-- EJB 1/18/2002 --%>
          <% if (view.getOffset()>0) { %>
            <util:button id="previous" type="input"/>
          <% } else { %>
            <util:button id="_null_"/>
          <% } // end if %>
          &nbsp;&nbsp;
          <% if (go_next) { %>
            <util:button id="next" type="input"/>
          <% } else { %>
            <util:button id="_null_"/>
          <% } // end if %>
        </DIV></util:form>
      <% } else { %>&nbsp;<% } %>
    </TD>
  </TR></TABLE><BR>

  <% if (results.size()>0) { %><%-- EJB 1/18/2002 - omit headers if there's nothing to say --%>
    <%-- Display the results of the search --%>
    <TABLE BORDER=0 ALIGN=LEFT CELLPADDING=0 CELLSPACING=6>
      <TR VALIGN=TOP>
        <TH ALIGN=LEFT CLASS="CONTENT">
          <util:font color="content.fg" size="content"><B><U>Post Link</U></B></util:font>
        </TH>
        <TH ALIGN=LEFT CLASS="CONTENT">
          <util:font color="content.fg" size="content"><B><U>Author</U></B></util:font>
        </TH>
        <TH ALIGN=LEFT CLASS="CONTENT">
          <util:font color="content.fg" size="content"><B><U>Post Date</U></B></util:font>
        </TH>
        <TH ALIGN=LEFT CLASS="CONTENT">
          <util:font color="content.fg" size="content"><B><U>Lines</U></B></util:font>
        </TH>
        <TH ALIGN=LEFT CLASS="CONTENT">&nbsp;</TH>
      </TR>
      <% for (int i=0; i<dcount; i++) { %>
        <TR VALIGN=TOP>
          <% TopicMessageFound post = (TopicMessageFound)(results.get(i)); %>
          <TD ALIGN=LEFT CLASS="content"><util:font color="content.fg" size="content"><util:xlink>
            <util:href type="servlet">go/<%= post.getIdentifier() %></util:href>
            <util:text><%= post.getIdentifier() %></util:text>
          </util:xlink></util:font></TD>
          <TD ALIGN=LEFT CLASS="content"><util:font color="content.fg" size="content"><util:xlink>
            <util:href type="servlet">user/<%= post.getAuthor() %></util:href>
            <util:text><%= post.getAuthor() %></util:text>
          </util:xlink></util:font></TD>
          <TD ALIGN=LEFT CLASS="content" NOWRAP><util:font color="content.fg" size="content">
            <%= view.formatDate(post.getPostDate()) %>
          </util:font></TD>
          <TD ALIGN=LEFT CLASS="content"><util:font color="content.fg" size="content">
            <%= post.getLineCount() %>
          </util:font></TD>
          <TD ALIGN=LEFT CLASS="content"><util:font color="content.fg" size="content">
            <util:escape><%= post.getText() %></util:escape>
          </util:font></TD>
        </TR>
      <% } // end for %>
    </TABLE><BR CLEAR=LEFT>
  <% } // end if %>
<% } // end if %>



