Subversion Repositories Applications.projet

Rev

Rev 11 | Rev 197 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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