<%--
  Copyright 2003 Sun Microsystems, Inc. All rights reserved 
  Use is subject to license terms.
 --%>
<%-- @(#)fullDiscussionDisplay.jsp --%>
<%@page language= "java" import="com.sun.portal.providers.jsp.JSPProvider, 
				com.sun.portal.search.util.Encoder, com.sun.portal.search.util.DateParser,
				java.lang.*, java.util.*, java.text.*" %> 
<%@page errorPage="error.jsp" %> 
<%@ taglib uri="/tld/jx.tld" prefix="jx" %> 
<%@ taglib uri="/tld/desktop.tld" prefix="dt" %> 
<%@ taglib uri="/tld/search.tld" prefix="search" %> 

<%-- Get portal config information and portal desktop theme values --%> 
<%@ include file= "portal.jsp" %> 

<%-- Get portal config information and portal desktop theme values --%>
<jx:declare id="tFontColor" type="java.lang.String"/>
<jx:declare id="tFontFace" type="java.lang.String"/>
<jx:declare id="tTitleBarColor" type="java.lang.String" />
<jx:declare id="tTitleFontColor" type="java.lang.String" />
<jx:declare id="tBorderColor" type="java.lang.String"/>
<jx:declare id="tBgColor" type="java.lang.String"/>

<jx:declare id="desktopUrl" type="java.lang.String"/>
<jx:declare id="dpurl" type="java.lang.String"/>
<jx:declare id="desktopPathInfo" type="java.lang.String"/>
<jx:declare id="desktopPathInfo2" type="java.lang.String"/>
<jx:declare id="channelName" type="java.lang.String"/>
<jx:declare id="locale" type="java.util.Locale"/>

<STYLE type="text/css">
    .discMessage{font-family: <%=tFontFace%>; color: <%=tFontColor%>; font-size:x-small; font-weight: bold;}
    .discTitle{font-family: <%=tFontFace%>; font-size:small; font-weight: bold;}
    .discDate{font-family: <%=tFontFace%>; color: <%=tFontColor%>; font-size:small;}
    .discRating{font-family: <%=tFontFace%>; font-size:small; font-weight: bold;}
    .discDesc{font-family: <%=tFontFace%>; color: <%=tFontColor%>; font-size:small;}
    .discFilter{font-family: <%=tFontFace%>; color: <%=tBorderColor%>; font-size:small;font-weight:bold;}
    .discButton{background: <%=tTitleBarColor%>; color: <%=tTitleFontColor%>; font-family: <%=tFontFace%>; font-size:small; font-weight: bold;}
</STYLE>

<table cellpadding="0" cellspacing="0" border="0" width="100%" bgcolor="<%=tBgColor%>">

<tr><td img="<dt:scontent/>/images/spacer.gif" width="1" height="20"></td>
</tr>

<!-- display search box -->
<jx:if test="$displaySearch">
    <%@ include file="searchUI.jsp" %>
</jx:if>

<tr><td img="<dt:scontent/>/images/spacer.gif" width="1" height="20"></td>
</tr>

<FORM NAME="dform">
<INPUT type=HIDDEN name="<%=channelName%>_dmode" value="full">
<INPUT type=HIDDEN name="database" value="">
<INPUT type=HIDDEN name="page" value="1">
<!-- Beginning of about search results -->
<search:getNoHits id= "noHits"/>

<font color="<%=tFontColor%>" face="<%=tFontFace%>" size="-1">
<jx:choose>
<jx:when test="$noHits">
    <search:getPage id="pg"/>
    <tr> 
    <td class="discMessage">No <jx:if test="$pg != 1"></jx:if>discussions found.</td>
    </tr>
</jx:when> 
<jx:otherwise> 

    <!-- Beginning of about search results --> 
    <tr> 
    <td class="discMessage">Discussions <search:getFirstHit/> - <search:getToHit/> (out of <search:getHitCount/>)</td>
    </tr>

    <tr>
    <td bgcolor="<%=tTitleBarColor%>"><img src="<dt:scontent/>/images/spacer.gif" alt="" width=1 height=1></td>
    </tr>

    <tr><td img="<dt:scontent/>/images/spacer.gif" width="1" height="20"></td>
    </tr>

    <!-- Beginning of display results --> 
    <search:getResult id="resultstream"/> 
    <tr>
    <td>
    <UL>
    <search:getNextResult input="$resultstream">
    <LI>
    <search:getURL id="url"/>
    <jx:declare id="url" type="java.lang.String"/>

    <jx:choose>
    <jx:when test="$vdw">
	<span class="discTitle"><a target="ps_main" href="<%=desktopPathInfo2%>?<%=channelName%>_dmode=vl&did=<%=Encoder.urlEncode(url)%>"><search:getValue attribute="title" escape="true" truncate="50"/></a></span> - 
    </jx:when>
    <jx:otherwise>
	<span class="discTitle"><a href="<%=dpurl%>?<%=channelName%>_dmode=vl&did=<%=Encoder.urlEncode(url)%>"><search:getValue attribute="title" escape="true" truncate="50"/></a></span> - 
    </jx:otherwise>
    </jx:choose>

    <search:getValue attribute="author" id="author"/>
    <jx:choose>
    <jx:when test="$author == null">
      <jx:set var="author" value="$anonymousAuthor"/>
    </jx:when>
    <jx:when test="$author == ''">
      <jx:set var="author" value="$anonymousAuthor"/>
    </jx:when>
    <jx:when test="$author == 'authlessanonymous'">
      <jx:set var="author" value="$anonymousAuthor"/>
    </jx:when>
    <jx:otherwise>
    </jx:otherwise>
    </jx:choose>

    <span class="discTitle"><%=pageContext.getAttribute("author")%></span>
    <search:getValue attribute="rd-last-changed" id="lastPost"/>
    <jx:declare id="lastPost" type="java.lang.String"/>

    <jx:if test="$lastPost != ''">
	<% DateFormat df = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.SHORT, locale); 
	 try {
	    Date d = DateParser.parse(lastPost); %>
	    <span class="discDate">on <%=df.format(d)%></span>
        <% } catch (Exception e) { } %>
    </jx:if>

    <%-- Convert integer pkrating values to user-friendly text --%>
    <search:getValue attribute="rd-rating" id="pkrating"/>
    <jx:if test="$pkrating != null">
    <% 
    String pkrating = (String)pageContext.getAttribute("pkrating");
    if (pkrating.equals("-1")) {
       pkrating = "Irrelevant";
    } else if (pkrating.equals("0")) {
       pkrating = "Routine";
    } else if (pkrating.equals("1")) {
       pkrating = "Interesting";
    } else if (pkrating.equals("2")) {
       pkrating = "Important";
    } else if (pkrating.equals("3")) {
       pkrating = "Must Read";
    } else {
       pkrating = "Routine";
    } %>
    <span class="discRating">(<%=pkrating%>)</span>

    <%-- Display of description is optional. Based on the 'showDescription' property value --%>
    </jx:if>
    <jx:if test="$showDesc">
	<br>
	<span class="discDesc"><search:getValue attribute= "description" escape="true"/></span>
	<br>&nbsp;
    </jx:if>
    </LI>
    </search:getNextResult> 
    </UL></font>
    </td>
    </tr>

    <tr><td img="<dt:scontent/>/images/spacer.gif" width="1" height="20"></td>
    </tr>

    <!-- Display page footer -->
    <tr>
    <td>
    <search:getTotalPages id="total2"/>
    <%@ include file="pageFooter.jsp" %>
    </td>
    </tr>
</jx:otherwise>
</jx:choose>

<tr><td img="<dt:scontent/>/images/spacer.gif" width="1" height="20"></td>
</tr>
</table>
</FORM>
