Subversion Repositories Applications.projet

Rev

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

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