<?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 des dossiers en mode miniatures
// Nom      : miniatures.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="repGalerie">
   <xsl:variable name="commentGlobal" select="commentGlobal"/>
   <xsl:if test='(commentGlobal != "")'>
     <div id="headerDetails">
        <xsl:value-of select='commentGlobal'/>
     </div>
   </xsl:if>
   <ul class='v1' name="dragLayer" id="dragLayer">

   <xsl:for-each select="ent">
    <xsl:variable name="nom" select="nom"/>
    <xsl:variable name="num" select="num"/>
    <xsl:variable name="lnk" select="lnk"/>
    <xsl:variable name="vis" select="vis"/>
    <xsl:variable name="tai" select="tai"/>
    <xsl:variable name="ext" select="ext"/>
    <xsl:variable name="prm" select="prm"/>
    <xsl:variable name="cmt" select="cmt"/>
    <xsl:variable name="dtm" select="dtm"/>
    <xsl:variable name="pro" select="pro"/>
    <xsl:variable name="web" select="web"/>
    <xsl:if test='(pro = "sup")'>
       <script language="javascript">boutonUp="<xsl:value-of select='lnk'/>";</script>
    </xsl:if>
    <xsl:variable name="action">
      <xsl:choose>
        <xsl:when test='(prm = "R") or (prm = "RW")'>
          initAction("")
        </xsl:when>
      <xsl:otherwise>
        rien()
        </xsl:otherwise>
      </xsl:choose>
    </xsl:variable>

    <li class='cible' onclick='if (altClick==0) {$action}' onmouseover='this.className="cadre";if ((typeof(chargeContext)!="undefined")&amp;&amp;(attenteClic==false)) chargeContext({$num});' onmouseout='this.className="cible";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='tai' value="{$tai}" />
      <input type='hidden' name='prm' value="{$prm}" />
      <input type='hidden' name='pro' value="{$pro}" />
      <input type='hidden' name='dtm' value="{$dtm}" />
      <input type='hidden' name='web' value="{$web}" />
      <input type='hidden' name='srv' value="" />
    </form>

     <u>
      <div class='caseimg'>
       <xsl:if test='(pro != "url")'>
          <xsl:if test='(ext != "ico")'>
            <img src='<?php echo $_SESSION["ws"]["cheminIcn"]?>{vis}' title="{$nom}"/>
          </xsl:if>
          <xsl:if test='(ext = "ico")'>
            <img src='<?php echo $_SESSION["ws"]["cheminIcn"]?>{vis}' title="{$nom}" style="width:64px;height:64px"/>
         </xsl:if>
       </xsl:if>
       <xsl:if test='(pro = "url")'>
           <xsl:choose>
             <xsl:when test="contains(vis,'http')">
               <img src='{vis}' style='position:relative;' width='100' title="{$nom}" />
        </xsl:when>
         <xsl:otherwise>
               <img src='{vis}' style='position:relative;' title="{$nom}" />
         </xsl:otherwise>
         </xsl:choose>
        </xsl:if>
      </div>
     </u>
      <div class='nom'>
        <u>
        <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"]?>' title='<?php echo $_SESSION["ws"]["dia"]["readOnly"]?>'/>
        </xsl:if>
        <xsl:if test='(prm = "W")'>
              <img src='<?php echo $_SESSION["ws"]["cheminImg"]?>verrou2.<?php echo $_SESSION["ws"]["formatExt"]?>' title='<?php echo $_SESSION["ws"]["dia"]["writeOnly"]?>' />
        </xsl:if>
        <xsl:if test='(prm = "N")'>
              <img src='<?php echo $_SESSION["ws"]["cheminImg"]?>verrou3.<?php echo $_SESSION["ws"]["formatExt"]?>' title='<?php echo $_SESSION["ws"]["dia"]["locked"]?>' />
        </xsl:if>
        <xsl:choose>
          <xsl:when test="contains(nom,'%u')">
            <xsl:value-of select="substring(nom,0,60)"/>
            <xsl:if test='(string-length(nom) &gt; 59)'>...</xsl:if>
          </xsl:when>
          <xsl:otherwise>

          <xsl:choose>
            <xsl:when test='(cmt != "") or (pro = "url") or (prm != "RW")'>
              <xsl:value-of select="substring(nom,0,8)"/>
              <xsl:if test='(string-length(nom) &gt; 7)'>...</xsl:if>
            </xsl:when>
            <xsl:otherwise>
              <xsl:value-of select="substring(nom,0,10)"/>
              <xsl:if test='(string-length(nom) &gt; 9)'>...</xsl:if>
            </xsl:otherwise>
          </xsl:choose>
        
          </xsl:otherwise>
        </xsl:choose>
        </u>
        <xsl:if test='(cmt != "")'>
        <img src='<?php echo $_SESSION["ws"]["cheminImg"]?>infocomment.<?php echo $_SESSION["ws"]["formatExt"]?>' title='{$cmt}' onmouseover="altClick=1;" onmouseout="altClick=0;" onclick="memoContext();montrerCommentaire(iciLien);return false;"/>
        </xsl:if>
        <xsl:if test='(pro = "url")'>
            <img src='<?php echo $_SESSION["ws"]["cheminImg"]?>infolien.<?php echo $_SESSION["ws"]["formatExt"]?>' title="{$web}"/>
        </xsl:if>
      </div>

      <div class='extension'><b>
        <xsl:if test='(pro = "url") and (ext != "url")'>
          <?php echo $_SESSION["ws"]["dia"]["linkTo"]?> <xsl:value-of select="ext"/>
        </xsl:if>
        <xsl:if test='(pro = "url") and (ext = "url")'>
          <?php echo $_SESSION["ws"]["dia"]["webSite"]?>
        </xsl:if>
        <xsl:if test='(pro = "local")'>
          <xsl:value-of select="ext"/>
        </xsl:if>
        <xsl:if test='(pro = "dossier")'>
          <?php echo $_SESSION["ws"]["dia"]["rep"]?>
        </xsl:if>
        <xsl:if test='(pro = "sup")'>
          <?php echo $_SESSION["ws"]["dia"]["niveauSup"]?>
        </xsl:if>

        <xsl:if test='($tai &gt; 0) and (ext != "")'>
          -
        </xsl:if>

        <xsl:if test="($tai &gt; 0) and ($tai &lt; 1024)">
          <xsl:value-of select="number(tai)"/> <?php echo $_SESSION["ws"]["dia"]["octet"]?>
        </xsl:if>
        <xsl:if test="($tai &gt;= 1024) and ($tai &lt; 1048576)">
          <xsl:value-of select="format-number(number(tai) div number(1024),'#.00')"/> K<?php echo $_SESSION["ws"]["dia"]["octet"]?>
        </xsl:if>
        <xsl:if test="($tai &gt;= 1048576) and ($tai &lt; 1073741824)">
          <xsl:value-of select="format-number(number(tai) div number(1048576),'#.00')"/> M<?php echo $_SESSION["ws"]["dia"]["octet"]?>
        </xsl:if>
        <xsl:if test="($tai &gt;= 1073741824)">
          <xsl:value-of select="format-number(number(tai) div number(1073741824),'#.00')"/> G<?php echo $_SESSION["ws"]["dia"]["octet"]?>
        </xsl:if>
      </b>
      <?php if ($navig=="OP") { ?>
        <img src='<?php echo $_SESSION["ws"]["cheminImg"]?>menuContext.<?php echo $_SESSION["ws"]["formatExt"]?>' onclick="reloadContext()" title="<?php echo $_SESSION["ws"]["dia"]["menuContext"]?>"/>
      <?php } ?>
      </div>

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

</xsl:stylesheet>
