Subversion Repositories Applications.papyrus

Rev

Rev 448 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
448 ddelon 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
 
474 alexandre_ 13
*   $Id: projet_derniers_telechargements.php,v 1.2 2005-09-27 16:31:49 alexandre_tb Exp $
448 ddelon 14
*/
15
 
16
// Requete sur les informations d'un projet
17
 
18
// ===========================================================
19
//                  Configuration
20
// ===========================================================
21
 
22
 
23
define ("PROJET_TELECHARGEMENT_NOMBRE", 8) ;
24
 
25
//====================      Les labels      =======================================
26
define ("PROJET_TELECHARGEMENT_TITRE", "Page de téléchargements rapides") ;
27
define ("PROJET_TELECHARGEMENT_DERNIERS", "Derniers documents mis en ligne") ;
28
define ("PROJET_TELECHARGEMENT_TOUS", "Tous les documents, par projet") ;
29
 
30
//=============bibliothèques PEAR  ===================================
31
include_once 'HTML/Table.php' ;
32
include_once 'HTML/TreeMenu.php' ;
33
 
34
// ========== Bibliothèque Projet ====================================
35
include_once 'configuration/projet.config.inc.php' ;
36
include_once PROJET_CHEMIN_CLASSES.'projetControleur.class.php' ;
37
include_once PROJET_CHEMIN_CLASSES.'document.class.php' ;
38
include_once PROJET_CHEMIN_APPLI.'langues/pro_langue_fr.inc.php' ;
39
 
40
 
41
function afficherContenuCorps() {
42
    global $id_projet, $repcourant, $baseURL, $projet ;
43
    global $G_ftpHost,$G_ftpUser,$G_ftpPwd,$G_ftpLocal, $PHP_SELF;
44
 
45
    // à remplacer par un div pour genesia
46
    $res = "<h1>".PROJET_TELECHARGEMENT_TITRE."</h1>\n" ;
47
 
48
    $res .= "<h2>".PROJET_TELECHARGEMENT_DERNIERS."</h2>\n" ;
49
 
50
    $liste_documents = document::getDocumentsRecents( $nombre = 10, $GLOBALS['projet_db'], PROJET_CHEMIN_FICHIER,PROJET_CHEMIN_ICONES) ;
51
 
52
    include_once PROJET_CHEMIN_CLASSES.'HTML_Liste.class.php' ;
53
    include_once PROJET_CHEMIN_CLASSES.'HTML_listeDocuments.class.php' ;
54
    $vue_liste_document = new HTML_listeDocuments($GLOBALS['url'], false, '', $GLOBALS['projet_auth']) ;
55
    $vue_liste_document->setCheminIcones(PROJET_CHEMIN_ICONES) ;
56
    $entete_liste = array (PROJET_FICHIERS_NOM, PROJET_FICHIERS_TAILLE, PROJET_FICHIERS_PAR, PROJET_FICHIERS_CREE_LE) ;
57
    if (!isset($droits)) $droits = PROJET_DROIT_AUCUN ;
58
 
59
    $vue_liste_document->construitEntete($entete_liste) ;
60
    $vue_liste_document->construitListe ($liste_documents, $droits, 'ignore_repertoire', $GLOBALS['projet_db']) ;
61
    $res .= $vue_liste_document->toHTML() ;
62
 
63
    $res .= "<h2>".PROJET_TELECHARGEMENT_TOUS."</h2>\n" ;
64
 
65
    // Création de l'objet TreeMenu
66
    GEN_stockerFichierScript(1, "api/TreeMenu/TreeMenu.js") ;
67
 
68
    // Les noms des fichiers graphiques
69
    $icon         = 'folder.gif';
70
    $expandedIcon = 'folder-expanded.gif';
71
 
72
    $i = 0 ;
73
    // Requete sur les projets
74
    $requete = "SELECT p_titre, p_id FROM projet ORDER BY p_titre" ;
75
    $resultat = $GLOBALS['projet_db']->query ($requete) or die ("Echec <br />".mysql_error()."<br />$requete") ;
76
 
77
    $menu = new HTML_TreeMenu() ;
78
    $node = new HTML_TreeNode(array('text' => "Les projets de Tela Botanica", 'link' => "", 'icon' => $icon, 'expandedIcon' => $expandedIcon));
79
 
80
    while ($ligne = $resultat->fetchRow(DB_FETCHMODE_OBJECT)) {
81
        $titre = $ligne->p_titre ;
82
        $node_1[$i] = &$node->addItem (new HTML_TreeNode(array('text' => $titre, 'link' => "", 'icon' => $icon, 'expandedIcon' => $expandedIcon)));
83
        projet_fichiers (&$node_1[$i], $ligne->p_id) ;
84
        $i++ ;
85
    }
86
    $menu->addItem($node);
87
    $treeMenu = &new HTML_TreeMenu_DHTML($menu, array('images' => 'api/TreeMenu/images', 'defaultClass' => 'text'));
88
    $res .= "<p>".$treeMenu->toHTML()."</p>\n" ;
89
 
90
    return $res ;
91
}
92
 
93
/** fonction projet_fichiers() - Remplie un noeud avec les fichiers et répertoires
94
*
95
* Le noeud est passé en référence. Ainsi, cette fonction ne retourne rien mais modifie le tableau des
96
* noeuds passé en référence.
97
*
98
* return  void
99
*/
100
 
101
function projet_fichiers ($noeud, $id_rep, $pere = 0)
102
{
103
    //Récupération de l'identifiant du répertoire courant
104
 
105
    //La fonction est appelé récursivement quand $pere ne vaut pas null
106
    //$id_rep prend donc la valeur de $pere transmise par l'appel précédent de la fonction.
107
 
108
    // Les noms des fichiers graphiques
109
    $icon = 'folder.gif';
110
    $expandedIcon = 'folder-expanded.gif';
111
 
112
    //Requête pour récupérer les noms des répertoires contenus dans le répertoire courant ($id_rep)
113
    $queryRep =    ' SELECT projet_documents.*'.
114
                            ' FROM projet_documents'.
115
                            ' WHERE projet_documents.pd_pere = '.$pere.
116
                            ' AND projet_documents.pd_visibilite = "public" and pd_ce_projet='.$id_rep.' and pd_ce_type=0'.
117
                            ' ORDER BY projet_documents.pd_nom ASC' ;
118
 
119
    $resultRep = $GLOBALS['projet_db']->query($queryRep) ;
120
    if (DB::isError ($resultRep)) {
121
        die ('Echec de la requete : '.$queryRep.'<br />'.$resultRep->getMessage()) ;
122
    }
123
 
124
    //Stockage des informations sur les répertoires contenu dans le répertoire courant pour affichage dans un arbre.
125
    //Et appel récursif de la fonction pour examiner le contenu de chaque répertoire du répertoire courant.
126
    if ( $resultRep->numRows() != 0 ) {
127
        while ( $ligneRep = $resultRep->fetchRow(DB_FETCHMODE_OBJECT) ) {
128
            //Stockage des informations sur le répertoire courant
129
            $noeud1_1 = &$noeud->addItem(new HTML_TreeNode(
130
                                                        array(
131
                                                            'text' => trim ($ligneRep->pd_nom),
132
                                                            'link' => "", 'icon' => $icon,
133
                                                            'expandedIcon' => $expandedIcon ) ) );
134
            //Appel récursif de fonction courante
135
            projet_fichiers (&$noeud1_1, $id_rep, $ligneRep->pd_id) ;
136
        }
137
    }
138
 
139
    // Requête pour récupérer les fichiers du répertoire courant ($id_rep) et leurs informations
140
    $requete_fichiers = 'SELECT projet_documents.*, gen_type_de_fichier.gtf_type_icone'.
141
                                    ' FROM projet_documents, gen_type_de_fichier'.
142
                                    ' WHERE projet_documents.pd_ce_type= gen_type_de_fichier.gtf_id_type'.
143
                                    ' AND projet_documents.pd_visibilite= "public" ' ;
144
    if ($pere == 0) {
145
        $requete_fichiers .= ' AND projet_documents.pd_ce_projet= '.$id_rep.' and pd_pere=0 and pd_ce_type <> 0' ;
146
    } else {
147
        $requete_fichiers .= ' AND projet_documents.pd_pere= '.$pere.' and pd_ce_type<>0' ;
148
    }
149
    $requete_fichiers .= ' ORDER BY projet_documents.pd_nom ASC' ;
150
 
151
    $resultat_fichiers = $GLOBALS['projet_db']->query($requete_fichiers) ;
152
    if (DB::isError ($resultat_fichiers)) {
153
        die ('Echec de la requete : '.$requete.'<br />'.$resultat_fichiers->getMessage()) ;
154
    }
155
 
156
    //Stockage des informations sur les fichiers du répertoires courant pour affichage dans un arbre
157
    if ( $resultat_fichiers->numRows() != 0 ) {
158
        while ( $ligne_fichiers = $resultat_fichiers->fetchRow(DB_FETCHMODE_OBJECT) ) {
159
            //Ajout de slash devant les caractères spéciaux et suppression des caractères invisibles en début et fin des noms de fichier.
160
            $lien = trim( $ligne_fichiers->pd_nom  );
161
            $noeud_1_2 = &$noeud->addItem (new HTML_TreeNode (
162
                                                            array (
163
                                                                "text" => $lien,
164
                                                                "link" => PROJET_CHEMIN_FICHIER.$ligne_fichiers->pd_lien,
165
                                                                'icon' => $ligne_fichiers->gtf_type_icone,
166
                                                                "linkTarget" => "_blank" ))) ;
167
        }
168
    }
169
}
170
 
171
//------------------------------------------------------------------------------
172
?>