| 431 | 
           mathias | 
           1 | 
           <?php
  | 
        
        
            | 
            | 
           2 | 
              | 
        
        
            | 
            | 
           3 | 
           /*  +-----------------------------------------------------------------------+
  | 
        
        
            | 
            | 
           4 | 
           *   |projet_derniers_telechargement.php			    	        			|
  | 
        
        
            | 
            | 
           5 | 
           *   +-----------------------------------------------------------------------+
  | 
        
        
            | 
            | 
           6 | 
           *   | Copyright (c) 2001 - 2005 Tela Botanica						        |
  | 
        
        
            | 
            | 
           7 | 
           *   +-----------------------------------------------------------------------+
  | 
        
        
            | 
            | 
           8 | 
           *   | Affiche les derniers fichiers uploader dans le module projet          |
  | 
        
        
            | 
            | 
           9 | 
           *   +-----------------------------------------------------------------------+
  | 
        
        
            | 
            | 
           10 | 
           *   | Auteur : Alexandre Granier <alexandre@tela-botanica.org> 		        |
  | 
        
        
            | 
            | 
           11 | 
           *   +-----------------------------------------------------------------------+
  | 
        
        
            | 
            | 
           12 | 
              | 
        
        
            | 
            | 
           13 | 
           *   $Id: projet_derniers_telechargements.php,v 1.4.2.1 2007-05-11 13:59:27 alexandre_tb Exp $
  | 
        
        
            | 
            | 
           14 | 
           */
  | 
        
        
            | 
            | 
           15 | 
              | 
        
        
            | 
            | 
           16 | 
           // Cette application affiche les derniers  documents uploades dans le module projet
  | 
        
        
            | 
            | 
           17 | 
           // ainsi que tous les documents du module
  | 
        
        
            | 
            | 
           18 | 
              | 
        
        
            | 
            | 
           19 | 
           // ===========================================================
  | 
        
        
            | 
            | 
           20 | 
           //                  Configuration
  | 
        
        
            | 
            | 
           21 | 
           // ===========================================================
  | 
        
        
            | 
            | 
           22 | 
              | 
        
        
            | 
            | 
           23 | 
              | 
        
        
            | 
            | 
           24 | 
           // Le nombre a afficher
  | 
        
        
            | 
            | 
           25 | 
           define ("PROJET_TELECHARGEMENT_NOMBRE", 8) ;
  | 
        
        
            | 
            | 
           26 | 
              | 
        
        
            | 
            | 
           27 | 
           //====================      Les labels      =======================================
  | 
        
        
            | 
            | 
           28 | 
           define ("PROJET_TELECHARGEMENT_TITRE", "Page de téléchargements rapides") ;
  | 
        
        
            | 
            | 
           29 | 
           define ("PROJET_TELECHARGEMENT_DERNIERS", "Derniers documents mis en ligne") ;
  | 
        
        
            | 
            | 
           30 | 
           define ("PROJET_TELECHARGEMENT_TOUS", "Tous les documents, par projet") ;
  | 
        
        
            | 
            | 
           31 | 
              | 
        
        
            | 
            | 
           32 | 
           //=============bibliotheques PEAR  ===================================
  | 
        
        
            | 
            | 
           33 | 
           include_once 'HTML/Table.php' ;
  | 
        
        
            | 
            | 
           34 | 
              | 
        
        
            | 
            | 
           35 | 
           // ========== Bibliotheque Projet ====================================
  | 
        
        
            | 
            | 
           36 | 
           include_once 'configuration/projet.config.inc.php' ;
  | 
        
        
            | 
            | 
           37 | 
           include_once PROJET_CHEMIN_CLASSES.'projetControleur.class.php' ;
  | 
        
        
            | 
            | 
           38 | 
           include_once PROJET_CHEMIN_CLASSES.'document.class.php' ;
  | 
        
        
            | 
            | 
           39 | 
           include_once PROJET_CHEMIN_APPLI.'langues/pro_langue_fr.inc.php' ;
  | 
        
        
            | 
            | 
           40 | 
              | 
        
        
            | 
            | 
           41 | 
              | 
        
        
            | 
            | 
           42 | 
           function afficherContenuCorps() {
  | 
        
        
            | 
            | 
           43 | 
               global $id_projet, $repcourant, $baseURL, $projet ;
  | 
        
        
            | 
            | 
           44 | 
              | 
        
        
            | 
            | 
           45 | 
               if (isset($_GET['service'])) {
  | 
        
        
            | 
            | 
           46 | 
               	if ($_GET['service'] == 'ecouteArbreFichier') {
  | 
        
        
            | 
            | 
           47 | 
               	include_once PROJET_CHEMIN_APPLI.'/services/ecouteArbreFichier.php';
  | 
        
        
            | 
            | 
           48 | 
               	}
  | 
        
        
            | 
            | 
           49 | 
               	if ($_GET['service'] == 'telechargement') {
  | 
        
        
            | 
            | 
           50 | 
               		include_once PROJET_CHEMIN_APPLI.'/services/telechargement.php';
  | 
        
        
            | 
            | 
           51 | 
               	}
  | 
        
        
            | 
            | 
           52 | 
               }
  | 
        
        
            | 
            | 
           53 | 
               // a remplacer par un div pour genesia
  | 
        
        
            | 
            | 
           54 | 
               $res = "<h1>".PROJET_TELECHARGEMENT_TITRE."</h1>\n" ;
  | 
        
        
            | 
            | 
           55 | 
              | 
        
        
            | 
            | 
           56 | 
               $res .= "<h2>".PROJET_TELECHARGEMENT_DERNIERS."</h2>\n" ;
  | 
        
        
            | 
            | 
           57 | 
              | 
        
        
            | 
            | 
           58 | 
               $liste_documents = document::getDocumentsRecents( $nombre = 10, $GLOBALS['projet_db'], PROJET_CHEMIN_FICHIER,PROJET_CHEMIN_ICONES) ;
  | 
        
        
            | 
            | 
           59 | 
              | 
        
        
            | 
            | 
           60 | 
               include_once PROJET_CHEMIN_CLASSES.'HTML_Liste.class.php' ;
  | 
        
        
            | 
            | 
           61 | 
               include_once PROJET_CHEMIN_CLASSES.'HTML_listeDocuments.class.php' ;
  | 
        
        
            | 
            | 
           62 | 
               $vue_liste_document = new HTML_listeDocuments($GLOBALS['url'], false, '', $GLOBALS['projet_auth']) ;
  | 
        
        
            | 
            | 
           63 | 
               $vue_liste_document->setCheminIcones(PROJET_CHEMIN_ICONES) ;
  | 
        
        
            | 
            | 
           64 | 
               $entete_liste = array (PROJET_FICHIERS_NOM, PROJET_FICHIERS_TAILLE, PROJET_FICHIERS_PAR, PROJET_FICHIERS_CREE_LE) ;
  | 
        
        
            | 
            | 
           65 | 
               if (!isset($droits)) $droits = PROJET_DROIT_AUCUN ;
  | 
        
        
            | 
            | 
           66 | 
              | 
        
        
            | 
            | 
           67 | 
               $vue_liste_document->construitEntete($entete_liste) ;
  | 
        
        
            | 
            | 
           68 | 
               $vue_liste_document->construitListe ($liste_documents, $droits, 'ignore_repertoire', $GLOBALS['projet_db']) ;
  | 
        
        
            | 
            | 
           69 | 
               $res .= $vue_liste_document->toHTML('', PROJET_DROIT_AUCUN) ;
  | 
        
        
            | 
            | 
           70 | 
              | 
        
        
            | 
            | 
           71 | 
               $res .= "<h2>".PROJET_TELECHARGEMENT_TOUS."</h2>\n" ;
  | 
        
        
            | 
            | 
           72 | 
              | 
        
        
            | 
            | 
           73 | 
              | 
        
        
            | 
            | 
           74 | 
               // Les noms des fichiers graphiques
  | 
        
        
            | 
            | 
           75 | 
               $icon         = 'folder.gif';
  | 
        
        
            | 
            | 
           76 | 
               $expandedIcon = 'folder-expanded.gif';
  | 
        
        
            | 
            | 
           77 | 
              | 
        
        
            | 
            | 
           78 | 
               $i = 0 ;
  | 
        
        
            | 
            | 
           79 | 
               // Requete sur les projets
  | 
        
        
            | 
            | 
           80 | 
               $requete = "SELECT p_titre, p_id FROM projet ORDER BY p_titre" ;
  | 
        
        
            | 
            | 
           81 | 
               $resultat = $GLOBALS['projet_db']->query ($requete) or die ("Echec <br />".mysql_error()."<br />$requete") ;
  | 
        
        
            | 
            | 
           82 | 
              | 
        
        
            | 
            | 
           83 | 
               $noeudProjet = '' ;
  | 
        
        
            | 
            | 
           84 | 
               while ($ligne = $resultat->fetchRow(DB_FETCHMODE_OBJECT)) {
  | 
        
        
            | 
            | 
           85 | 
                   $titre = $ligne->p_titre ;
  | 
        
        
            | 
            | 
           86 | 
                   $i++ ;
  | 
        
        
            | 
            | 
           87 | 
                   $noeudProjet .= '<div dojoType="TreeNode" title="'.$ligne->p_titre.'" widgetId="projet_'.
  | 
        
        
            | 
            | 
           88 | 
                   				$ligne->p_id.'" objectId="projet_'.$ligne->p_id.'" isFolder="true"></div>'."\n";
  | 
        
        
            | 
            | 
           89 | 
               }
  | 
        
        
            | 
            | 
           90 | 
              | 
        
        
            | 
            | 
           91 | 
               GEN_stockerFichierScript('dojo', 'api/js/dojo/dojo.js', 'text/javascript');
  | 
        
        
            | 
            | 
           92 | 
               GEN_stockerFichierScript('dojoScriptProjet', PROJET_CHEMIN_APPLI.'js/telechargement.js');
  | 
        
        
            | 
            | 
           93 | 
               //$res .= '<p>' ;
  | 
        
        
            | 
            | 
           94 | 
              | 
        
        
            | 
            | 
           95 | 
               $RCPUrl = PROJET_CHEMIN_APPLI.'services/ecouteArbreFichier.php?id_projet='.$id_projet;
  | 
        
        
            | 
            | 
           96 | 
           	$GLOBALS['url']->addQueryString(PROJET_VARIABLE_SERVICE, 'ecouteArbreFichier');
  | 
        
        
            | 
            | 
           97 | 
              | 
        
        
            | 
            | 
           98 | 
           	$RCPUrl = $GLOBALS['url']->getURL();
  | 
        
        
            | 
            | 
           99 | 
               $res .= '<div dojoType="TreeLoadingController" RPCUrl="'.$RCPUrl.'" widgetId="treeController" DNDController="create"></div>
  | 
        
        
            | 
            | 
           100 | 
           				<div dojoType="TreeSelector" widgetId="treeSelector"></div>
  | 
        
        
            | 
            | 
           101 | 
           				<div dojoType="Tree" DNDMode="between" selector="treeSelector" widgetId="bandTree" controller="treeController">
  | 
        
        
            | 
            | 
           102 | 
           				<div dojoType="TreeNode" title="Racine" widgetId="rootNode" objectId="root" isFolder="true">'."\n".
  | 
        
        
            | 
            | 
           103 | 
           			$noeudProjet.'</div></div>';
  | 
        
        
            | 
            | 
           104 | 
              | 
        
        
            | 
            | 
           105 | 
               //$res .= '</p>';
  | 
        
        
            | 
            | 
           106 | 
              | 
        
        
            | 
            | 
           107 | 
               return $res ;
  | 
        
        
            | 
            | 
           108 | 
           }
  | 
        
        
            | 
            | 
           109 | 
              | 
        
        
            | 
            | 
           110 | 
           /** fonction projet_fichiers() - Remplie un noeud avec les fichiers et repertoires
  | 
        
        
            | 
            | 
           111 | 
           *
  | 
        
        
            | 
            | 
           112 | 
           * Le noeud est passe en reference. Ainsi, cette fonction ne retourne rien mais modifie le tableau des
  | 
        
        
            | 
            | 
           113 | 
           * noeuds passe en reference.
  | 
        
        
            | 
            | 
           114 | 
           *
  | 
        
        
            | 
            | 
           115 | 
           * return  void
  | 
        
        
            | 
            | 
           116 | 
           */
  | 
        
        
            | 
            | 
           117 | 
              | 
        
        
            | 
            | 
           118 | 
           function projet_fichiers ($noeud, $id_rep, $pere = 0)
  | 
        
        
            | 
            | 
           119 | 
           {
  | 
        
        
            | 
            | 
           120 | 
               //Recuperation de l'identifiant du repertoire courant
  | 
        
        
            | 
            | 
           121 | 
              | 
        
        
            | 
            | 
           122 | 
               //La fonction est appele recursivement quand $pere ne vaut pas null
  | 
        
        
            | 
            | 
           123 | 
               //$id_rep prend donc la valeur de $pere transmise par l'appel precedent de la fonction.
  | 
        
        
            | 
            | 
           124 | 
              | 
        
        
            | 
            | 
           125 | 
               // Les noms des fichiers graphiques
  | 
        
        
            | 
            | 
           126 | 
               $icon = 'folder.gif';
  | 
        
        
            | 
            | 
           127 | 
               $expandedIcon = 'folder-expanded.gif';
  | 
        
        
            | 
            | 
           128 | 
              | 
        
        
            | 
            | 
           129 | 
               //Requ�te pour r�cup�rer les noms des r�pertoires contenus dans le r�pertoire courant ($id_rep)
  | 
        
        
            | 
            | 
           130 | 
               $queryRep =    ' SELECT projet_documents.*'.
  | 
        
        
            | 
            | 
           131 | 
                                       ' FROM projet_documents'.
  | 
        
        
            | 
            | 
           132 | 
                                       ' WHERE projet_documents.pd_pere = '.$GLOBALS['projet_db']->escapeSimple($pere).
  | 
        
        
            | 
            | 
           133 | 
                                       ' AND projet_documents.pd_visibilite = "public" and pd_ce_projet='.$GLOBALS['projet_db']->escapeSimple($id_rep).' and pd_ce_type=0'.
  | 
        
        
            | 
            | 
           134 | 
                                       ' ORDER BY projet_documents.pd_nom ASC' ;
  | 
        
        
            | 
            | 
           135 | 
              | 
        
        
            | 
            | 
           136 | 
               $resultRep = $GLOBALS['projet_db']->query($queryRep) ;
  | 
        
        
            | 
            | 
           137 | 
               if (DB::isError ($resultRep)) {
  | 
        
        
            | 
            | 
           138 | 
                   die ('Echec de la requete : '.$queryRep.'<br />'.$resultRep->getMessage()) ;
  | 
        
        
            | 
            | 
           139 | 
               }
  | 
        
        
            | 
            | 
           140 | 
              | 
        
        
            | 
            | 
           141 | 
               //Stockage des informations sur les r�pertoires contenu dans le r�pertoire courant pour affichage dans un arbre.
  | 
        
        
            | 
            | 
           142 | 
               //Et appel r�cursif de la fonction pour examiner le contenu de chaque r�pertoire du r�pertoire courant.
  | 
        
        
            | 
            | 
           143 | 
               if ( $resultRep->numRows() != 0 ) {
  | 
        
        
            | 
            | 
           144 | 
                   while ( $ligneRep = $resultRep->fetchRow(DB_FETCHMODE_OBJECT) ) {
  | 
        
        
            | 
            | 
           145 | 
                       //Stockage des informations sur le r�pertoire courant
  | 
        
        
            | 
            | 
           146 | 
                       $noeud1_1 = &$noeud->addItem(new HTML_TreeNode(
  | 
        
        
            | 
            | 
           147 | 
                                                                   array(
  | 
        
        
            | 
            | 
           148 | 
                                                                       'text' => trim ($ligneRep->pd_nom),
  | 
        
        
            | 
            | 
           149 | 
                                                                       'link' => "", 'icon' => $icon,
  | 
        
        
            | 
            | 
           150 | 
                                                                       'expandedIcon' => $expandedIcon ) ) );
  | 
        
        
            | 
            | 
           151 | 
                       //Appel r�cursif de fonction courante
  | 
        
        
            | 
            | 
           152 | 
                       projet_fichiers (&$noeud1_1, $id_rep, $ligneRep->pd_id) ;
  | 
        
        
            | 
            | 
           153 | 
                   }
  | 
        
        
            | 
            | 
           154 | 
               }
  | 
        
        
            | 
            | 
           155 | 
              | 
        
        
            | 
            | 
           156 | 
               // Requ�te pour r�cup�rer les fichiers du r�pertoire courant ($id_rep) et leurs informations
  | 
        
        
            | 
            | 
           157 | 
               $requete_fichiers = 'SELECT projet_documents.*, gen_type_de_fichier.gtf_type_icone'.
  | 
        
        
            | 
            | 
           158 | 
                                               ' FROM projet_documents, gen_type_de_fichier'.
  | 
        
        
            | 
            | 
           159 | 
                                               ' WHERE projet_documents.pd_ce_type= gen_type_de_fichier.gtf_id_type'.
  | 
        
        
            | 
            | 
           160 | 
                                               ' AND projet_documents.pd_visibilite= "public" ' ;
  | 
        
        
            | 
            | 
           161 | 
               if ($pere == 0) {
  | 
        
        
            | 
            | 
           162 | 
                   $requete_fichiers .= ' AND projet_documents.pd_ce_projet= '.$GLOBALS['projet_db']->escapeSimple($id_rep).' and pd_pere=0 and pd_ce_type <> 0' ;
  | 
        
        
            | 
            | 
           163 | 
               } else {
  | 
        
        
            | 
            | 
           164 | 
                   $requete_fichiers .= ' AND projet_documents.pd_pere= '.$GLOBALS['projet_db']->escapeSimple($pere).' and pd_ce_type<>0' ;
  | 
        
        
            | 
            | 
           165 | 
               }
  | 
        
        
            | 
            | 
           166 | 
               $requete_fichiers .= ' ORDER BY projet_documents.pd_nom ASC' ;
  | 
        
        
            | 
            | 
           167 | 
              | 
        
        
            | 
            | 
           168 | 
               $resultat_fichiers = $GLOBALS['projet_db']->query($requete_fichiers) ;
  | 
        
        
            | 
            | 
           169 | 
               if (DB::isError ($resultat_fichiers)) {
  | 
        
        
            | 
            | 
           170 | 
                   die ('Echec de la requete : '.$requete_fichiers.'<br />'.$resultat_fichiers->getMessage()) ;
  | 
        
        
            | 
            | 
           171 | 
               }
  | 
        
        
            | 
            | 
           172 | 
              | 
        
        
            | 
            | 
           173 | 
               //Stockage des informations sur les fichiers du r�pertoires courant pour affichage dans un arbre
  | 
        
        
            | 
            | 
           174 | 
               if ( $resultat_fichiers->numRows() != 0 ) {
  | 
        
        
            | 
            | 
           175 | 
                   while ( $ligne_fichiers = $resultat_fichiers->fetchRow(DB_FETCHMODE_OBJECT) ) {
  | 
        
        
            | 
            | 
           176 | 
                       //Ajout de slash devant les caract�res sp�ciaux et suppression des caract�res invisibles en d�but et fin des noms de fichier.
  | 
        
        
            | 
            | 
           177 | 
                       $lien = trim( $ligne_fichiers->pd_nom  );
  | 
        
        
            | 
            | 
           178 | 
                       $noeud_1_2 = &$noeud->addItem (new HTML_TreeNode (
  | 
        
        
            | 
            | 
           179 | 
                                                                       array (
  | 
        
        
            | 
            | 
           180 | 
                                                                           "text" => $lien,
  | 
        
        
            | 
            | 
           181 | 
                                                                           "link" => PROJET_CHEMIN_FICHIER.$ligne_fichiers->pd_lien,
  | 
        
        
            | 
            | 
           182 | 
                                                                           'icon' => $ligne_fichiers->gtf_type_icone,
  | 
        
        
            | 
            | 
           183 | 
                                                                           "linkTarget" => "_blank" ))) ;
  | 
        
        
            | 
            | 
           184 | 
                   }
  | 
        
        
            | 
            | 
           185 | 
               }
  | 
        
        
            | 
            | 
           186 | 
           }
  | 
        
        
            | 
            | 
           187 | 
              | 
        
        
            | 
            | 
           188 | 
           /* +--Fin du code ----------------------------------------------------------------------------------------+
  | 
        
        
            | 
            | 
           189 | 
           *
  | 
        
        
            | 
            | 
           190 | 
           * $Log: projet_derniers_telechargements.php,v $
  | 
        
        
            | 
            | 
           191 | 
           * Revision 1.4.2.1  2007-05-11 13:59:27  alexandre_tb
  | 
        
        
            | 
            | 
           192 | 
           * adaptation a ecouteArbreFichier qui est maintenant appele par papyrus.php
  | 
        
        
            | 
            | 
           193 | 
           *
  | 
        
        
            | 
            | 
           194 | 
           * Revision 1.4  2007/04/19 09:17:35  alexandre_tb
  | 
        
        
            | 
            | 
           195 | 
           * utilisation de dojo pour afficher l arbre des derniers documents
  | 
        
        
            | 
            | 
           196 | 
           *
  | 
        
        
            | 
            | 
           197 | 
           * Revision 1.3  2005/10/06 08:23:48  alexandre_tb
  | 
        
        
            | 
            | 
           198 | 
           * Ajout de commentaires
  | 
        
        
            | 
            | 
           199 | 
           *
  | 
        
        
            | 
            | 
           200 | 
           *
  | 
        
        
            | 
            | 
           201 | 
           *
  | 
        
        
            | 
            | 
           202 | 
           * +-- Fin du code ----------------------------------------------------------------------------------------+
  | 
        
        
            | 
            | 
           203 | 
           */
  | 
        
        
            | 
            | 
           204 | 
              | 
        
        
            | 
            | 
           205 | 
           ?>
  |