<?php
/************************************************************************/
/*                                WEBSHARE                              */
/************************************************************************/
//
// Copyright (c) 2008 by Virginie Vivancos
// http://www.webshare.fr
//
// This program is free software. You can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License.
//
// =======================================================================
// Fonction : XSL d'affichage de l'arborescence des dossiers
// Nom      : format.xsl.php
// Version  : 0.6.5
// Date     : 28/05/08
// =======================================================================
session_start();
header('Content-Type: application/xml');
echo '<'.'?xml version="1.0" encoding="UTF-8"'.'?>';
include_once "../fonctions.php";

?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" version="4.0" encoding="UTF-8" indent="yes"
                doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"
                doctype-system="declarations.dtd"
    />
<xsl:template match="/" name="document">
<xsl:apply-templates/>
  </xsl:template>

  <xsl:template match="repArbre">
    <xsl:apply-templates select="contArbre" />
  </xsl:template>

  <xsl:template match="contArbre">
    <xsl:variable name="cnx" select="cnx"/>
    <xsl:variable name="serveur" select="serveur"/>
    <xsl:variable name="espacetotal" select="espacetotal"/>
    <xsl:variable name="espacelibre" select="espacelibre"/>
    <xsl:variable name="espaceutil"  select="espaceutil"/>

    <xsl:variable name="total">
        <xsl:if test="($espacetotal &gt; 0) and ($espacetotal &lt; 1024)">
          <xsl:value-of select="number(espacetotal)"/> <?php echo $_SESSION["ws"]["dia"]["octet"]?>
        </xsl:if>
        <xsl:if test="($espacetotal &gt;= 1024) and ($espacetotal &lt; 1048576)">
          <xsl:value-of select="format-number(number(espacetotal) div number(1024),'#.00')"/> K<?php echo $_SESSION["ws"]["dia"]["octet"]?>
        </xsl:if>
        <xsl:if test="($espacetotal &gt;= 1048576) and ($espacetotal &lt; 1073741824)">
          <xsl:value-of select="format-number(number(espacetotal) div number(1048576),'#.00')"/> M<?php echo $_SESSION["ws"]["dia"]["octet"]?>
        </xsl:if>
        <xsl:if test="($espacetotal &gt;= 1073741824)">
          <xsl:value-of select="format-number(number(espacetotal) div number(1073741824),'#.00')"/> G<?php echo $_SESSION["ws"]["dia"]["octet"]?>
        </xsl:if>
    </xsl:variable>
    
    <xsl:variable name="libre">
        <xsl:if test="($espacelibre &gt; 0) and ($espacelibre &lt; 1024)">
          <xsl:value-of select="number(espacelibre)"/> <?php echo $_SESSION["ws"]["dia"]["octet"]?>
        </xsl:if>
        <xsl:if test="($espacelibre &gt;= 1024) and ($espacelibre &lt; 1048576)">
          <xsl:value-of select="format-number(number(espacelibre) div number(1024),'#.00')"/> K<?php echo $_SESSION["ws"]["dia"]["octet"]?>
        </xsl:if>
        <xsl:if test="($espacelibre &gt;= 1048576) and ($espacelibre &lt; 1073741824)">
          <xsl:value-of select="format-number(number(espacelibre) div number(1048576),'#.00')"/> M<?php echo $_SESSION["ws"]["dia"]["octet"]?>
        </xsl:if>
        <xsl:if test="($espacelibre &gt;= 1073741824)">
          <xsl:value-of select="format-number(number(espacelibre) div number(1073741824),'#.00')"/> G<?php echo $_SESSION["ws"]["dia"]["octet"]?>
        </xsl:if>
    </xsl:variable>

    <xsl:variable name="util">
        <xsl:if test="($espaceutil &gt; 0) and ($espaceutil &lt; 1024)">
          <xsl:value-of select="number(espaceutil)"/> <?php echo $_SESSION["ws"]["dia"]["octet"]?>
        </xsl:if>
        <xsl:if test="($espaceutil &gt;= 1024) and ($espaceutil &lt; 1048576)">
          <xsl:value-of select="format-number(number(espaceutil) div number(1024),'#.00')"/> K<?php echo $_SESSION["ws"]["dia"]["octet"]?>
        </xsl:if>
        <xsl:if test="($espaceutil &gt;= 1048576) and ($espaceutil &lt; 1073741824)">
          <xsl:value-of select="format-number(number(espaceutil) div number(1048576),'#.00')"/> M<?php echo $_SESSION["ws"]["dia"]["octet"]?>
        </xsl:if>
        <xsl:if test="($espaceutil &gt;= 1073741824)">
          <xsl:value-of select="format-number(number(espaceutil) div number(1073741824),'#.00')"/> G<?php echo $_SESSION["ws"]["dia"]["octet"]?>
        </xsl:if>
    </xsl:variable>
        
    <xsl:variable name="detail">
      <xsl:choose>
        <xsl:when test="($espacelibre &gt;= 0)">
          - <?php echo $_SESSION["ws"]["dia"]["used"]?> : <xsl:value-of select="$util"/>, <?php echo $_SESSION["ws"]["dia"]["free"]?> : <xsl:value-of select="$libre"/>, <?php echo $_SESSION["ws"]["dia"]["total"]?> : <xsl:value-of select="$total"/>
        </xsl:when>
        <xsl:otherwise>
        </xsl:otherwise>
      </xsl:choose>
    </xsl:variable>

    <div class='rubrique' style='width:98%' title='<?php echo $_SESSION["ws"]["dia"]["nameShare"]?> {$serveur} {$detail}'><nobr>
    <img src='{$cnx}' />
    <b><xsl:value-of select="serveur"/> </b> </nobr></div>
    <xsl:apply-templates select="brc" />
  <br/>
  </xsl:template>

  <xsl:template match="brc">
    <xsl:variable name="lnk" select="lnk"/>
    <xsl:variable name="nom" select="nom"/>
    <xsl:variable name="ext" select="ext"/>
    <xsl:variable name="prm" select="prm"/>
    <xsl:variable name="pro" select="pro"/>
    <xsl:variable name="url" select="url"/>
    <xsl:variable name="num" select="num"/>
    <xsl:variable name="web" select="web"/>
    <xsl:variable name="srv" select="ancestor::contArbre/serveur"/>

  <div style="width:100%;overflow:hidden">
   <div style="width:100%;overflow:hidden" class="repArbre" onmouseover='clicDiv=1; if ((typeof(chargeContext)!="undefined")&amp;&amp;(attenteClic==false)) chargeContext(-{$num});' onmouseout='clicDiv=0; if ((typeof(chargeContext)!="undefined")&amp;&amp;(attenteClic==false)) chargeContext(0);'>
     <form name='param-{$num}'>
        <input type='hidden' name='num' value="-{$num}" />
        <input type='hidden' name='lnk' value="{$lnk}" />
        <input type='hidden' name='nom' value="{$nom}" />
        <input type='hidden' name='ext' value="{$ext}" />
        <input type='hidden' name='prm' value="{$prm}" />
        <input type='hidden' name='pro' value="{$pro}" />
        <input type='hidden' name='srv' value="{$srv}" />
        <input type='hidden' name='web' value="{$web}" />
        <input type='hidden' name='dtm' value="" />
        <input type='hidden' name='tai' value="0" />
      </form>
    <nobr>
    <div style="visibility:visible;position:absolute;"></div>
    <xsl:if test='(prm = "R") or (prm = "RW")'>
      <xsl:choose>
      <xsl:when test="child::brc">
        <img id="arrid{$srv}{$lnk}" src='<?php echo $_SESSION["ws"]["cheminImg"]?>plus.<?php echo $_SESSION["ws"]["formatExt"]?>' onclick='devoile("divid{$srv}{$lnk}","arrid{$srv}{$lnk}")'/>
      </xsl:when>
      <xsl:otherwise>
        <img src='<?php echo $_SESSION["ws"]["cheminImg"]?>fondvide.<?php echo $_SESSION["ws"]["formatExt"]?>' />
      </xsl:otherwise>
    </xsl:choose>
      <xsl:choose>
        <xsl:when test="(url = 'url')">
          <span class='lien' onclick='initAction("")'>
          <img id="urlid{$srv}{$lnk}" src='<?php echo $_SESSION["ws"]["cheminImg"]?>minilien.<?php echo $_SESSION["ws"]["formatExt"]?>' width='22' height='22'/>
          <u><u onmouseover='this.className="lienover"' onmouseout='this.className="lien"'>
            <xsl:value-of select="nom"/>
          </u></u>
          </span>
        </xsl:when>
        <xsl:otherwise>
          <span class='lien' onclick='initAction("")'>
          <img id="imgid{$srv}{$lnk}" src='<?php echo $_SESSION["ws"]["cheminImg"]?>miniclose.<?php echo $_SESSION["ws"]["formatExt"]?>'/>
          <u><u onmouseover='this.className="lienover"' onmouseout='this.className="lien"' title='{$nom}'>
            <xsl:value-of select="nom"/>
          </u></u>
          </span>
        </xsl:otherwise>
        </xsl:choose>
    <xsl:if test='(prm = "R") and ("1" = "<?php echo $_SESSION["ws"]["typeUser"]?>")'>
      <img src='<?php echo $_SESSION["ws"]["cheminImg"]?>verrou1.<?php echo $_SESSION["ws"]["formatExt"]?>' alt='<?php echo $_SESSION["ws"]["dia"]["readOnly"]?>'/>
    </xsl:if>
    </xsl:if>

    <xsl:if test='(prm = "N")'>
      <img src='<?php echo $_SESSION["ws"]["cheminImg"]?>fondvide.<?php echo $_SESSION["ws"]["formatExt"]?>'/>
        <img src='<?php echo $_SESSION["ws"]["cheminImg"]?>miniclose.<?php echo $_SESSION["ws"]["formatExt"]?>'/>
        <u>
          <xsl:value-of select="nom"/>
        </u>
      <img src='<?php echo $_SESSION["ws"]["cheminImg"]?>verrou3.<?php echo $_SESSION["ws"]["formatExt"]?>' alt='<?php echo $_SESSION["ws"]["dia"]["locked"]?>'/>
    </xsl:if>

    <xsl:if test='(prm = "W")'>
      <img src='<?php echo $_SESSION["ws"]["cheminImg"]?>fondvide.<?php echo $_SESSION["ws"]["formatExt"]?>'/>
        <img src='<?php echo $_SESSION["ws"]["cheminImg"]?>miniclose.<?php echo $_SESSION["ws"]["formatExt"]?>'/>
        <u>
          <xsl:value-of select="nom"/>
        </u>
      <img src='<?php echo $_SESSION["ws"]["cheminImg"]?>verrou2.<?php echo $_SESSION["ws"]["formatExt"]?>' alt='<?php echo $_SESSION["ws"]["dia"]["writeOnly"]?>'/>
    </xsl:if>
    <br/>
   </nobr>
   </div>

    <div id="divid{$srv}{$lnk}" class='masque'>
      <xsl:if test="child::brc">
        <xsl:apply-templates select="brc" />
      </xsl:if>
    </div>
  </div>

  </xsl:template>

  <xsl:template match="repAdresse">
   <span id="autoshow" style="display:none">
      ...
   </span>
   <xsl:for-each select="dossier">
    <xsl:variable name="action" select="action"/>
    <xsl:variable name="lien" select="lien"/>
    <xsl:variable name="visu" select="visu"/>
    <xsl:variable name="nom" select="nom"/>

    <xsl:choose>
    <xsl:when test="following::dossier">

    <span class="autohide">
    <img src='<?php echo $_SESSION["ws"]["cheminImg"]?>{visu}'/>
    <xsl:choose>
      <xsl:when test='(action = "none")'>
      <u>
        <xsl:value-of select="nom"/>
      </u>
      </xsl:when>
      <xsl:otherwise>
        <span class='lien' onmouseover='iciNom="{$nom}"; iciLien="{$lien}"; iciType="adresse"; iciPro="dossier";' onclick='naviguer("{$lien}")' onmouseout='iciNom=""; iciType="defaut";'>
        <u onmouseover='this.className="lienover"' onmouseout='this.className="lien"'>
          <xsl:value-of select="nom"/>
        </u>
        </span>
      </xsl:otherwise>
    </xsl:choose>
    </span>

    </xsl:when>
    <xsl:otherwise>

    <img src='<?php echo $_SESSION["ws"]["cheminImg"]?>{visu}'/>
    <xsl:choose>
      <xsl:when test='(action = "none")'>
      <u>
        <xsl:value-of select="nom"/>
      </u>
      </xsl:when>
      <xsl:otherwise>
        <span class='lien' onmouseover='iciNom="{$nom}"; iciLien="{$lien}"; iciType="adresse"; iciPro="dossier";' onclick='naviguer("{$lien}")' onmouseout='iciNom=""; iciType="defaut";'>
        <u onmouseover='this.className="lienover"' onmouseout='this.className="lien"'>
          <xsl:value-of select="nom"/>
        </u>
        </span>
      </xsl:otherwise>
    </xsl:choose>

    </xsl:otherwise>
    </xsl:choose>

   </xsl:for-each>
  </xsl:template>

</xsl:stylesheet>
