<?xml version="1.0"?> 
<xsl:stylesheet 
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
  version="1.0"
  xmlns:java="http://xml.apache.org/xslt/java"
  exclude-result-prefixes="java"
>
  <xsl:template match="wiki.show">
    <xsl:variable name="found"><xsl:if test="result/@found='true'">true</xsl:if></xsl:variable>
    <!-- 
    <xsl:call-template name="util.xml"/>
     -->
    <!-- if coming from wiki.page, show place within wiki tree -->
        <xsl:if test="params/showCrumbs">
      <font size="+2">
    <xsl:call-template name="dumpCrumbs">
      <xsl:with-param name="path"><xsl:value-of select="result/@path"/></xsl:with-param>
    </xsl:call-template>
      </font>
        </xsl:if>

    <xsl:if test="not(result/@found)">
    <xsl:if test="(java:hasPermission($user,'org.benow.web.wiki.WikiService.edit'))">
        Not Found: <xsl:value-of select="params/name"/>      
          (<a class="font-color: black" href="/admin/dev/index.page?op=promptCreateItem&amp;type=wiki&amp;item={params/name}&amp;from={url}"><img border="0" src="/images/icons/edit_small.png"/>Create <xsl:value-of select="result/name"/></a>)
    </xsl:if>      
    </xsl:if>

<!-- 
<xsl:call-template name="util.xml"/>
-->        
    <xsl:if test="result/@can-edit='true'">
      <span style="font-size: 12px" onMouseOver="document.getElementById('wiki').style.background='#FFEAEA';" onMouseOut="document.getElementById('wiki').style.background='';">
          (<a class="font-color: black" href="/admin/dev/index.page?op=view&amp;type=wiki&amp;item={result/name}&amp;from={url}"><img border="0" src="/images/icons/edit_small.png"/>Edit <xsl:value-of select="result/name"/></a>)
      </span>
    </xsl:if>
        <xsl:if test="params/showCrumbs">
          <p/>
        </xsl:if>
    <xsl:if test="$found='true'">
      <div id="wiki">
      <xsl:value-of select="result/body"/>
      </div>
    </xsl:if>
  </xsl:template>
  
  <xsl:template name="dumpCrumbs">
    <xsl:param name="path"/>
    <xsl:param name="prefix"/>

    <xsl:choose>
      <xsl:when test="contains($path,'/') and $path!='/'">
        <xsl:variable name="curr"><xsl:value-of select="substring-before($path,'/')"/></xsl:variable>
        <xsl:variable name="to"><xsl:value-of select="$prefix"/>/<xsl:value-of select="$curr"/></xsl:variable>
        
        <a href="/wiki.page?sheet={$to}/"><xsl:value-of select="$curr"/></a>/<xsl:call-template name="dumpCrumbs">
          <xsl:with-param name="path"><xsl:value-of select="substring-after($path,'/')"/></xsl:with-param>
          <xsl:with-param name="prefix"><xsl:value-of select="$to"/></xsl:with-param>
        </xsl:call-template>
      </xsl:when>
      <xsl:when test="$path=''"/>
      <xsl:otherwise><xsl:value-of select="$path"/></xsl:otherwise>
    </xsl:choose>
  </xsl:template>
    
    
</xsl:stylesheet>

