venice-main-classic/web/format/find.jsp
Eric J. Bowersox f706cdaf5f partial implementation of conference management; rewrote the whole servlets
layer to eliminate duplicate code and make error checking more efficient
(we now use a system that relies on Throwables to do interesting things)
2001-02-10 07:20:27 +00:00

290 lines
12 KiB
Plaintext

<%--
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.*" %>
<%!
private static String getSIGHostName(SIGContext sig)
{
try
{ // get the host name for the specified SIG
UserProfile prof = sig.getHostProfile();
return prof.getUserName();
} // end try
catch (DataException e)
{ // just return NULL if an exception strikes
return null;
} // end catch
} // end getSIGHostName
private static int getSIGMemberCount(SIGContext sig)
{
try
{ // get the member count for the specified SIG
return sig.getMemberCount();
} // end try
catch (DataException e)
{ // just return -1 if an exception strikes
return -1;
} // end catch
} // end getSIGMemberCount
private static String getActivityString(SIGContext sig, RenderData rdat)
{
return rdat.getActivityString(sig.getLastAccessDate());
} // end getActivityString
%>
<%
FindData data = FindData.retrieve(request);
Variables.failIfNull(data);
RenderData rdat = RenderConfig.createRenderData(application,request,response);
%>
<% data.writeHeader(rdat,out); %>
<%-- Display the search form --%>
<% if (rdat.useHTMLComments()) { %><!-- Find Form --><% } %>
<FORM METHOD="POST" ACTION="<%= rdat.getEncodedServletPath("find") %>">
<INPUT TYPE=HIDDEN NAME="disp" VALUE="<%= data.getDisplayOption() %>">
<INPUT TYPE=HIDDEN NAME="ofs" VALUE="0">
<% if (data.getDisplayOption()==FindData.FD_SIGS) { %>
<% if (rdat.useHTMLComments()) { %><!-- Find SIGs Form --><% } %>
<%= rdat.getStdFontTag(null,4) %><B>Find SIGs:</B></FONT><BR>
<%= rdat.getStdFontTag(null,2) %>
Display all SIGs whose&nbsp;&nbsp;
<SELECT NAME="field" SIZE=1>
<OPTION VALUE="<%= SearchMode.FIELD_SIG_NAME %>"
<% if (data.searchFieldIs(SearchMode.FIELD_SIG_NAME)) { %>SELECTED<% } %> >name</OPTION>
<OPTION VALUE="<%= SearchMode.FIELD_SIG_SYNOPSIS %>"
<% if (data.searchFieldIs(SearchMode.FIELD_SIG_SYNOPSIS)) { %>SELECTED<% } %> >synopsis</OPTION>
</SELECT><BR>
<% } else if (data.getDisplayOption()==FindData.FD_USERS) { %>
<% if (rdat.useHTMLComments()) { %><!-- Find Users Form --><% } %>
<%= rdat.getStdFontTag(null,4) %><B>Find Users:</B></FONT><BR>
<%= rdat.getStdFontTag(null,2) %>
Display all users whose&nbsp;&nbsp;
<SELECT NAME="field" SIZE=1>
<OPTION VALUE="<%= SearchMode.FIELD_USER_NAME %>"
<% if (data.searchFieldIs(SearchMode.FIELD_USER_NAME)) { %>SELECTED<% } %> >user name</OPTION>
<OPTION VALUE="<%= SearchMode.FIELD_USER_DESCRIPTION %>"
<% if (data.searchFieldIs(SearchMode.FIELD_USER_DESCRIPTION)) { %>SELECTED<% } %> >description</OPTION>
<OPTION VALUE="<%= SearchMode.FIELD_USER_GIVEN_NAME %>"
<% if (data.searchFieldIs(SearchMode.FIELD_USER_GIVEN_NAME)) { %>SELECTED<% } %> >first name</OPTION>
<OPTION VALUE="<%= SearchMode.FIELD_USER_FAMILY_NAME %>"
<% if (data.searchFieldIs(SearchMode.FIELD_USER_FAMILY_NAME)) { %>SELECTED<% } %> >last name</OPTION>
</SELECT><BR>
<% } else if (data.getDisplayOption()==FindData.FD_CATEGORIES) { %>
<% if (rdat.useHTMLComments()) { %><!-- Find Categories Form --><% } %>
<%= rdat.getStdFontTag(null,4) %><B>Find Categories:</B></FONT><BR>
<%= rdat.getStdFontTag(null,2) %>
Display all categories whose name&nbsp;&nbsp;
<% } else throw new InternalStateError("display parameter " + data.getDisplayOption() + " invalid"); %>
<SELECT NAME="mode" SIZE=1>
<OPTION VALUE="<%= SearchMode.SEARCH_PREFIX %>"
<% if (data.searchModeIs(SearchMode.SEARCH_PREFIX)) { %>SELECTED<% } %> >starts with the string</OPTION>
<OPTION VALUE="<%= SearchMode.SEARCH_SUBSTRING %>"
<% if (data.searchModeIs(SearchMode.SEARCH_SUBSTRING)) { %>SELECTED<% } %> >contains the string</OPTION>
<OPTION VALUE="<%= SearchMode.SEARCH_REGEXP %>"
<% if (data.searchModeIs(SearchMode.SEARCH_REGEXP)) { %>SELECTED<% } %> >matches the regular
expression</OPTION>
</SELECT>
<% if (data.getDisplayOption()==FindData.FD_CATEGORIES) { %><BR><% } else { %>&nbsp;&nbsp;<% } %>
<INPUT TYPE=TEXT NAME="term" SIZE=32 MAXLENGTH=255 VALUE="<%= data.getSearchTerm() %>"><BR>
<INPUT TYPE=IMAGE NAME="search" SRC="<%= rdat.getFullImagePath("bn_search.gif") %>"
ALT="Search" WIDTH=80 HEIGHT=24 BORDER=0><BR>
</FONT>
</FORM>
<%-- Display the current category --%>
<% String a_head, a_tail; // used for formatting category display %>
<% CategoryDescriptor cat = data.getCategory(); %>
<% if (cat!=null) { %>
<% if (rdat.useHTMLComments()) { %><!-- Display Category Name --><% } %>
<HR><%= rdat.getStdFontTag(null,3) %><B>Category:
<%
a_head = "";
a_tail = "";
if (cat.getCategoryID()>=0)
{ // assign the anchor tags
a_head = "<A HREF=\"" + data.getCatJumpLink(rdat,-1) + "\">";
a_tail = "</A>";
} // end if
%>
<%= a_head %>Top<%= a_tail %>
<% if (cat.getCategoryID()>=0) { %>
<% for (int i=0; i<cat.getNumLevels(); i++) { %>
<%
a_head = ": ";
a_tail = "";
if (i<(cat.getNumLevels()-1))
{ // assign the anchor tags
a_head = ": <A HREF=\"" + data.getCatJumpLink(rdat,cat.getIDAtLevel(i)) + "\">";
a_tail = "</A>";
} // end if
%>
<%= a_head %><%= StringUtil.encodeHTML(cat.getTitleAtLevel(i)) %><%= a_tail %>
<% } // end for %>
<% } // end if (displaying the entire subcategory tree) %>
</B><P>
<%-- Display the subcategory list --%>
<% List subcats = data.getSubCategoryList(); %>
<% if ((subcats!=null) && (subcats.size()>0)) { %>
<% if (rdat.useHTMLComments()) { %><!-- Display SubCategory List --><% } %>
<B>Subcategories:</B><BR>
<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=2>
<% Iterator it = subcats.iterator(); %>
<% while (it.hasNext()) { %>
<TR VALIGN=TOP>
<TD ALIGN=CENTER WIDTH=14>
<IMG SRC="<%= rdat.getFullImagePath("purple-ball.gif") %>" ALT="*" WIDTH=14 HEIGHT=14 BORDER=0>
</TD>
<TD ALIGN=LEFT><%= rdat.getStdFontTag(null,2) %>
<%
CategoryDescriptor c = (CategoryDescriptor)(it.next());
a_head = "<A HREF=\"" + data.getCatJumpLink(rdat,c.getLinkedCategoryID()) + "\">";
%>
<B><%= a_head %><%= StringUtil.encodeHTML(c.getTitleAtLevel(c.getNumLevels()-1)) %></A></B>
<% if (c.isSymbolicLink()) { %><EM>@</EM><% } %>
</FONT></TD>
</TR>
<% } // end while %>
</TABLE>
<% } // end if (displaying subcategory list) %>
</FONT>
<% } // end if (category specified) %>
<% List results = data.getResultsList(); %>
<% if (results!=null) { %>
<% if (rdat.useHTMLComments()) { %><!-- Display Search Results --><% } %>
<%
// Determine the number of results to display and whether to display a "next" button
int dcount = results.size();
boolean go_next = false;
if (dcount>data.getNumResultsDisplayed())
{ // there's a "next"
dcount = data.getNumResultsDisplayed();
go_next = true;
} // end if
%>
<HR>
<TABLE WIDTH="100%" BORDER=0 ALIGN=CENTER><TR VALIGN=MIDDLE>
<TD WIDTH="50%" ALIGN=LEFT><%= rdat.getStdFontTag(null,3) %>
<%-- The initial search results --%>
<B><% if (cat!=null) { %>SIGs in Category<% } else { %>Search Results<% } %></B>
<% if (data.getFindCount()>0) { %>
(Displaying <%= data.getOffset() + 1 %>-<%= data.getOffset() + dcount %> of
<%= data.getFindCount() %>)
<% } else { %>(None)<% } %>
</FONT></TD>
<TD WIDTH="50%" ALIGN=RIGHT>
<% if (go_next || (data.getOffset()>0)) { %>
<%-- The navigational form that allows us to page through the results --%>
<% if (rdat.useHTMLComments()) { %><!-- Navigational Form --><% } %>
<FORM METHOD="POST" ACTION="<%= rdat.getEncodedServletPath("find") %>">
<INPUT TYPE=HIDDEN NAME="disp" VALUE="<%= data.getDisplayOption() %>">
<% if (cat!=null) { %><INPUT TYPE=HIDDEN NAME="cat" VALUE="<%= cat.getCategoryID() %>"><% } %>
<INPUT TYPE=HIDDEN NAME="ofs" VALUE="<%= data.getOffset() %>">
<INPUT TYPE=HIDDEN NAME="field" VALUE="<%= data.getSearchField() %>">
<INPUT TYPE=HIDDEN NAME="mode" VALUE="<%= data.getSearchMode() %>">
<INPUT TYPE=HIDDEN NAME="term" VALUE="<%= data.getSearchTerm() %>">
<INPUT TYPE=HIDDEN NAME="fcount" VALUE="<%= data.getFindCount() %>">
<% if (data.getOffset()>0) { %>
<INPUT TYPE=IMAGE NAME="previous" SRC="<%= rdat.getFullImagePath("bn_ar_previous.gif") %>"
ALT="Previous" WIDTH=80 HEIGHT=24 BORDER=0>
<% } else { %>
<IMG SRC="<%= rdat.getFullImagePath("bn_transparent.gif") %>" WIDTH=80 HEIGHT=24 BORDER=0>
<% } // end if %>
&nbsp;&nbsp;
<% if (go_next) { %>
<INPUT TYPE=IMAGE NAME="next" SRC="<%= rdat.getFullImagePath("bn_ar_next.gif") %>"
ALT="Next" WIDTH=80 HEIGHT=24 BORDER=0>
<% } else { %>
<IMG SRC="<%= rdat.getFullImagePath("bn_transparent.gif") %>" WIDTH=80 HEIGHT=24 BORDER=0>
<% } // end if %>
</FORM>
<% } else { %>&nbsp;<% } %>
</TD>
</TR></TABLE><BR>
<%-- Display the results of the search --%>
<TABLE BORDER=0 ALIGN=LEFT CELLPADDING=0 CELLSPACING=4>
<% for (int i=0; i<dcount; i++) { %>
<TR VALIGN=TOP>
<TD ALIGN=CENTER WIDTH=14>
<IMG SRC="<%= rdat.getFullImagePath("purple-ball.gif") %>" ALT="*" WIDTH=14 HEIGHT=14 BORDER=0>
</TD>
<TD ALIGN=LEFT><%= rdat.getStdFontTag(null,2) %>
<% Object item = results.get(i); %>
<% if (data.getDisplayOption()==FindData.FD_SIGS) { %>
<%
SIGContext sig = (SIGContext)item;
String host_name = getSIGHostName(sig);
int members = getSIGMemberCount(sig);
%>
<A HREF="<%= rdat.getEncodedServletPath("sig/" + sig.getAlias()) %>"><%= StringUtil.encodeHTML(sig.getName()) %></A><BR>
<% if (host_name!=null) { %>
Host: <A HREF="<%= rdat.getEncodedServletPath("user/" + host_name) %>"><%= host_name %></A>
<% } // end if (got host name) %>
<% if (members>=0) { %>
<% if (host_name!=null) { %> - <% } %>
<%= members %> members
<% } // end if (got member count) %>
<% if ((host_name!=null) || (members>=0)) { %><BR><% } %>
Latest activity: <%= getActivityString(sig,rdat) %><BR>
<EM><%= StringUtil.encodeHTML(sig.getSynopsis()) %></EM>
<% } else if (data.getDisplayOption()==FindData.FD_USERS) { %>
<% UserFound uf = (UserFound)item; %>
<A HREF="<%= rdat.getEncodedServletPath("user/" + uf.getName()) %>"><%= uf.getName() %></A><BR>
<%= StringUtil.encodeHTML(uf.getGivenName()) %> <%= StringUtil.encodeHTML(uf.getFamilyName()) %>,
from <%= StringUtil.encodeHTML(uf.getLocality()) %>, <%= StringUtil.encodeHTML(uf.getRegion()) %>
<%= uf.getCountry() %>
<% if (uf.getDescription()!=null) { %><BR><EM><%= StringUtil.encodeHTML(uf.getDescription()) %></EM><% } %>
<% } else if (data.getDisplayOption()==FindData.FD_CATEGORIES) { %>
<% CategoryDescriptor cd = (CategoryDescriptor)item; %>
<A HREF="<%= data.getCatJumpLink(rdat,cd.getLinkedCategoryID()) %>"><%= StringUtil.encodeHTML(cd.toString()) %></A>
<% } %>
</FONT></TD>
</TR>
<% } // end for %>
</TABLE><BR CLEAR=LEFT>
<% } // end if (results found) %>
<% rdat.writeFooter(out); %>