New file |
0,0 → 1,202 |
<?php |
|
/* +-----------------------------------------------------------------------+ |
* |projet_derniers_telechargement.php | |
* +-----------------------------------------------------------------------+ |
* | Copyright (c) 2001 - 2005 Tela Botanica | |
* +-----------------------------------------------------------------------+ |
* | Affiche les derniers fichiers uploader dans le module projet | |
* +-----------------------------------------------------------------------+ |
* | Auteur : Alexandre Granier <alexandre@tela-botanica.org> | |
* +-----------------------------------------------------------------------+ |
|
* $Id: projet_derniers_telechargements.php,v 1.5 2007-06-25 12:15:06 alexandre_tb Exp $ |
*/ |
|
// Cette application affiche les derniers documents uploades dans le module projet |
// ainsi que tous les documents du module |
|
// =========================================================== |
// Configuration |
// =========================================================== |
|
|
// Le nombre a afficher |
define ("PROJET_TELECHARGEMENT_NOMBRE", 8) ; |
|
//==================== Les labels ======================================= |
define ("PROJET_TELECHARGEMENT_TITRE", "Page de téléchargements rapides") ; |
define ("PROJET_TELECHARGEMENT_DERNIERS", "Derniers documents mis en ligne") ; |
define ("PROJET_TELECHARGEMENT_TOUS", "Tous les documents, par projet") ; |
|
//=============bibliotheques PEAR =================================== |
include_once 'HTML/Table.php' ; |
|
// ========== Bibliotheque Projet ==================================== |
include_once 'configuration/projet.config.inc.php' ; |
include_once PROJET_CHEMIN_CLASSES.'projetControleur.class.php' ; |
include_once PROJET_CHEMIN_CLASSES.'document.class.php' ; |
include_once PROJET_CHEMIN_APPLI.'langues/pro_langue_fr.inc.php' ; |
|
|
function afficherContenuCorps() { |
global $id_projet, $repcourant, $baseURL, $projet ; |
|
if (isset($_GET['service'])) { |
if ($_GET['service'] == 'ecouteArbreFichier') { |
include_once PROJET_CHEMIN_APPLI.'/services/ecouteArbreFichier.php'; |
} |
if ($_GET['service'] == 'telechargement') { |
include_once PROJET_CHEMIN_APPLI.'/services/telechargement.php'; |
} |
} |
// a remplacer par un div pour genesia |
$res = "<h1>".PROJET_TELECHARGEMENT_TITRE."</h1>\n" ; |
|
$res .= "<h2>".PROJET_TELECHARGEMENT_DERNIERS."</h2>\n" ; |
|
$liste_documents = document::getDocumentsRecents( $nombre = 10, $GLOBALS['projet_db'], PROJET_CHEMIN_FICHIER,PROJET_CHEMIN_ICONES) ; |
|
include_once PROJET_CHEMIN_CLASSES.'HTML_Liste.class.php' ; |
include_once PROJET_CHEMIN_CLASSES.'HTML_listeDocuments.class.php' ; |
$vue_liste_document = new HTML_listeDocuments($GLOBALS['url'], false, '', $GLOBALS['projet_auth']) ; |
$vue_liste_document->setCheminIcones(PROJET_CHEMIN_ICONES) ; |
$entete_liste = array (PROJET_FICHIERS_NOM, PROJET_FICHIERS_TAILLE, PROJET_FICHIERS_PAR, PROJET_FICHIERS_CREE_LE) ; |
if (!isset($droits)) $droits = PROJET_DROIT_AUCUN ; |
|
$vue_liste_document->construitEntete($entete_liste) ; |
$vue_liste_document->construitListe ($liste_documents, $droits, 'ignore_repertoire', $GLOBALS['projet_db']) ; |
$res .= $vue_liste_document->toHTML('', PROJET_DROIT_AUCUN) ; |
|
$res .= "<h2>".PROJET_TELECHARGEMENT_TOUS."</h2>\n" ; |
|
|
// Les noms des fichiers graphiques |
$icon = 'folder.gif'; |
$expandedIcon = 'folder-expanded.gif'; |
|
$i = 0 ; |
// Requete sur les projets |
$requete = "SELECT p_titre, p_id FROM projet ORDER BY p_titre" ; |
$resultat = $GLOBALS['projet_db']->query ($requete) or die ("Echec <br />".mysql_error()."<br />$requete") ; |
|
$noeudProjet = '' ; |
while ($ligne = $resultat->fetchRow(DB_FETCHMODE_OBJECT)) { |
$titre = $ligne->p_titre ; |
$i++ ; |
$noeudProjet .= '<div dojoType="TreeNode" title="'.$ligne->p_titre.'" widgetId="projet_'. |
$ligne->p_id.'" objectId="projet_'.$ligne->p_id.'" isFolder="true"></div>'."\n"; |
} |
|
GEN_stockerFichierScript('dojo', 'api/js/dojo/dojo.js', 'text/javascript'); |
GEN_stockerFichierScript('dojoScriptProjet', PROJET_CHEMIN_APPLI.'js/telechargement.js'); |
//$res .= '<p>' ; |
|
$RCPUrl = PROJET_CHEMIN_APPLI.'services/ecouteArbreFichier.php?id_projet='.$id_projet; |
$GLOBALS['url']->addQueryString(PROJET_VARIABLE_SERVICE, 'ecouteArbreFichier'); |
|
$RCPUrl = $GLOBALS['url']->getURL(); |
$res .= '<div dojoType="TreeLoadingController" RPCUrl="'.$RCPUrl.'" widgetId="treeController" DNDController="create"></div> |
<div dojoType="TreeSelector" widgetId="treeSelector"></div> |
<div dojoType="Tree" DNDMode="between" selector="treeSelector" widgetId="bandTree" controller="treeController"> |
<div dojoType="TreeNode" title="Racine" widgetId="rootNode" objectId="root" isFolder="true">'."\n". |
$noeudProjet.'</div></div>'; |
|
//$res .= '</p>'; |
|
return $res ; |
} |
|
/** fonction projet_fichiers() - Remplie un noeud avec les fichiers et repertoires |
* |
* Le noeud est passe en reference. Ainsi, cette fonction ne retourne rien mais modifie le tableau des |
* noeuds passe en reference. |
* |
* return void |
*/ |
|
function projet_fichiers ($noeud, $id_rep, $pere = 0) |
{ |
//Recuperation de l'identifiant du repertoire courant |
|
//La fonction est appele recursivement quand $pere ne vaut pas null |
//$id_rep prend donc la valeur de $pere transmise par l'appel precedent de la fonction. |
|
// Les noms des fichiers graphiques |
$icon = 'folder.gif'; |
$expandedIcon = 'folder-expanded.gif'; |
|
//Requête pour récupérer les noms des répertoires contenus dans le répertoire courant ($id_rep) |
$queryRep = ' SELECT projet_documents.*'. |
' FROM projet_documents'. |
' WHERE projet_documents.pd_pere = '.$pere. |
' AND projet_documents.pd_visibilite = "public" and pd_ce_projet='.$id_rep.' and pd_ce_type=0'. |
' ORDER BY projet_documents.pd_nom ASC' ; |
|
$resultRep = $GLOBALS['projet_db']->query($queryRep) ; |
if (DB::isError ($resultRep)) { |
die ('Echec de la requete : '.$queryRep.'<br />'.$resultRep->getMessage()) ; |
} |
|
//Stockage des informations sur les répertoires contenu dans le répertoire courant pour affichage dans un arbre. |
//Et appel récursif de la fonction pour examiner le contenu de chaque répertoire du répertoire courant. |
if ( $resultRep->numRows() != 0 ) { |
while ( $ligneRep = $resultRep->fetchRow(DB_FETCHMODE_OBJECT) ) { |
//Stockage des informations sur le répertoire courant |
$noeud1_1 = &$noeud->addItem(new HTML_TreeNode( |
array( |
'text' => trim ($ligneRep->pd_nom), |
'link' => "", 'icon' => $icon, |
'expandedIcon' => $expandedIcon ) ) ); |
//Appel récursif de fonction courante |
projet_fichiers (&$noeud1_1, $id_rep, $ligneRep->pd_id) ; |
} |
} |
|
// Requête pour récupérer les fichiers du répertoire courant ($id_rep) et leurs informations |
$requete_fichiers = 'SELECT projet_documents.*, gen_type_de_fichier.gtf_type_icone'. |
' FROM projet_documents, gen_type_de_fichier'. |
' WHERE projet_documents.pd_ce_type= gen_type_de_fichier.gtf_id_type'. |
' AND projet_documents.pd_visibilite= "public" ' ; |
if ($pere == 0) { |
$requete_fichiers .= ' AND projet_documents.pd_ce_projet= '.$id_rep.' and pd_pere=0 and pd_ce_type <> 0' ; |
} else { |
$requete_fichiers .= ' AND projet_documents.pd_pere= '.$pere.' and pd_ce_type<>0' ; |
} |
$requete_fichiers .= ' ORDER BY projet_documents.pd_nom ASC' ; |
|
$resultat_fichiers = $GLOBALS['projet_db']->query($requete_fichiers) ; |
if (DB::isError ($resultat_fichiers)) { |
die ('Echec de la requete : '.$requete_fichiers.'<br />'.$resultat_fichiers->getMessage()) ; |
} |
|
//Stockage des informations sur les fichiers du répertoires courant pour affichage dans un arbre |
if ( $resultat_fichiers->numRows() != 0 ) { |
while ( $ligne_fichiers = $resultat_fichiers->fetchRow(DB_FETCHMODE_OBJECT) ) { |
//Ajout de slash devant les caractères spéciaux et suppression des caractères invisibles en début et fin des noms de fichier. |
$lien = trim( $ligne_fichiers->pd_nom ); |
$noeud_1_2 = &$noeud->addItem (new HTML_TreeNode ( |
array ( |
"text" => $lien, |
"link" => PROJET_CHEMIN_FICHIER.$ligne_fichiers->pd_lien, |
'icon' => $ligne_fichiers->gtf_type_icone, |
"linkTarget" => "_blank" ))) ; |
} |
} |
} |
|
/* +--Fin du code ----------------------------------------------------------------------------------------+ |
* |
* $Log: not supported by cvs2svn $ |
* Revision 1.4 2007/04/19 09:17:35 alexandre_tb |
* utilisation de dojo pour afficher l arbre des derniers documents |
* |
* Revision 1.3 2005/10/06 08:23:48 alexandre_tb |
* Ajout de commentaires |
* |
* |
* |
* +-- Fin du code ----------------------------------------------------------------------------------------+ |
*/ |
|
?> |