Subversion Repositories Applications.papyrus

Rev

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