<%--
  Copyright 2003 Sun Microsystems, Inc. All rights reserved 
  Use is subject to license terms.
 --%>
<%-- @(#)viewDiscussionNavigation.jsp --%>
<%@page language= "java" import="com.sun.portal.search.util.Encoder,
				com.sun.portal.search.soif.SOIF, 
				com.sun.portal.discussions.providers.Comments,
				java.lang.*, java.util.*" %>

<%@ taglib uri="/tld/jx.tld" prefix="jx" %>
<%@ taglib uri="/tld/desktop.tld" prefix="dt" %>
<%@ taglib uri="/tld/desktopProviderContext.tld" prefix="dtpc" %>

<jx:declare id="dbname" type="java.lang.String"/>
<jx:declare id="dpurl" type="java.lang.String"/>
<jx:declare id="channelName" type="java.lang.String"/>

<tr><td colspan="3"><img src="<dt:scontent/>/images/spacer.gif"></td>
</tr>

<%
Comments comments = (Comments)pageContext.findAttribute("comments");
if (comments != null) {
    SOIF s = (SOIF)comments.getRootSOIF();
    %>

    <tr><td><img src="<dt:scontent/>/images/spacer.gif" width="1" height="1"></td>
    <td width="100%" nowrap>
    <a href="<%=dpurl%>?<%=channelName%>_dmode=full"><span class="discNav">All Discussions</span></a>

    <%-- link to the main discussion item--%>
    <% if (comments.getDiscussionID() != null && (!comments.getDiscussionID().equals(s.getURL()))) { %>
	&nbsp;&nbsp;&nbsp; <a href="<%=dpurl%>?<%=channelName%>_dmode=vl&did=<%=Encoder.urlEncode(comments.getDiscussionID())%>"><span class="discNav">To Discussion</span></a>
    <% } %>

    <% if (!comments.getParentID(s).equals("ROOT")) { %>
	&nbsp;&nbsp;&nbsp; <a href="<%=dpurl%>?<%=channelName%>_dmode=vl&did=<%=Encoder.urlEncode(comments.getParentID(s))%>"><span class="discNav">To Parent</span></a>
    <% } %>

    <%-- if discussion has a reference document.i.e if started from search channel --%>
    <% if (s.getValue("rd-reference-url") != null) { %>
	&nbsp;&nbsp;&nbsp; <a href="<%=s.getValue("rd-reference-url")%>"><span class="discNav">Reference</span></a>
    <% } %>

    <% if (s.getValue("title") != null) { %>
	&nbsp;&nbsp;&nbsp;<a href="<%=dpurl%>?<%=channelName%>_dmode=cmt&ref_id=<%=Encoder.urlEncode(s.getURL())%>&database=<%=dbname%>&t=<%=Encoder.urlEncode(s.getValue("title"), "UTF-8")%>"><span class="discNav">Post Reply</span></a>
   <% } %>

    <jx:if test="$displaySubscription == 'true'">
	<dt:obtainChannel channel="$JSPProvider">
	    <dtpc:providerContext>
            <dtpc:getStringProperty key="searchServer" id="searchServer"/>
            <jx:declare id="searchServer" type="java.lang.String"/>
<%
	    Map pathInfo = new HashMap();
	    pathInfo.put("action", "edit");
	    pathInfo.put("provider", "JSPEditContainer");
	    pathInfo.put("targetprovider", "Subscriptions");
	    pathInfo.put("last", "false");
	    pageContext.setAttribute("pathInfo", pathInfo);
	    Map queryInfo = new HashMap();
	    queryInfo.put("newDiscSubscription",Encoder.urlEncode(s.getURL(), "UTF-8"));
	    queryInfo.put("newDiscTitle",Encoder.urlEncode(s.getValue("title"), "UTF-8"));
            queryInfo.put("newServer",Encoder.urlEncode(searchServer,"UTF-8"));
            queryInfo.put("newDB",Encoder.urlEncode(dbname,"UTF-8"));
	    pageContext.setAttribute("queryInfo", queryInfo);
	    %>
		&nbsp;&nbsp;&nbsp; <a target="ps_main" href='<dtpc:getDesktopURL pathinfo="$pathInfo" querymap="$queryInfo"/>'><span class="discNav">Subscribe</span></A>
	    </dtpc:providerContext>
	</dt:obtainChannel>
    </jx:if>

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

    <tr><td colspan="3"><img src="<dt:scontent/>/images/spacer.gif" width="1" height="10"></td>
    </tr>
<% } %>
