1,5 → 1,5 |
<?php |
/*vim: set expandtab tabstop=4 shiftwidth=4: */ |
/*vim: set expandtab tabstop=4 shiftwidth=4: */ |
// +------------------------------------------------------------------------------------------------------+ |
// | PHP version 4.1 | |
// +------------------------------------------------------------------------------------------------------+ |
81,7 → 81,7 |
* @access private |
*/ |
var $_db; |
|
|
/** |
* L'identifiant du document dans la table projet_document. |
* @access private |
89,17 → 89,17 |
var $_id; |
|
/** |
* |
* |
* @access private |
*/ |
var $_chemin_icone; |
|
|
/** |
* L'identifiant du père, peut être à NULL |
* @access private |
*/ |
var $_id_pere; |
|
|
/** |
* L'identifiant du propriétaire. Provient d'un annuaire. Peut être à NULL. |
* @access private |
116,11 → 116,11 |
* |
*/ |
var $_pd_lien ; |
|
|
var $nom_fichier ; |
/** |
* |
* |
* |
* @param int id_document L'identifiant du document dans la base. |
* @param int objetDB un objet PEAR:DB |
* @return void |
130,9 → 130,9 |
{ |
if (is_object($objetDB)) { |
$GLOBALS['projet_db'] = $objetDB; |
} |
} |
$this->_chemin_icone = $chemin_icones ; |
|
|
if ($id_document != "") { |
$requete = "select * from projet_documents where pd_id=".$id_document ; |
$resultat = $GLOBALS['projet_db']->query ($requete) ; |
145,7 → 145,7 |
$this->_id_projet = $ligne->pd_ce_projet; |
$this->_id = $ligne->pd_id ; |
fichier::fichier($chemin.$this->getChemin(), $GLOBALS['projet_db']) ; |
|
|
if (is_object ($this->_type_mime)) $this->_type_mime->setCheminIcone ($chemin_icones) ; |
$this->_id_proprietaire = $ligne->pd_ce_utilisateur ; |
$this->_nom_long = $ligne->pd_nom ; |
153,7 → 153,7 |
$this->_date_mise_a_jour = $ligne->pd_date_de_mise_a_jour ; |
$this->_description = $ligne->pd_description ; |
$this->_pd_lien = $ligne->pd_lien; |
|
|
if ($this->_isRacine($ligne->pd_pere)) { |
$this->_id_pere = 0 ; |
} else { |
161,12 → 161,12 |
} |
} |
} |
|
|
} // end of member function document |
|
/** |
* |
* |
* |
* @param int id_document L'identifiant du document dans la base. |
* @param int objetDB Un objet PEAR:DB |
* @return document |
174,9 → 174,9 |
*/ |
function __construct( $id_document = "", &$objetDB, $chemin = '', $chemin_icones = '' ) |
{ |
|
|
$this->document($id_document, $objetDB, $chemin, $chemin_icones); |
|
|
} // end of member function __construct |
|
|
311,14 → 311,14 |
include_once PROJET_CHEMIN_CLASSES.'projet.class.php'; |
$projet = new projet ($GLOBALS['projet_db'], $this->_id_projet); |
// l arborescence des repertoires |
|
|
$tableau_navigation = $this->getPath($this->_id) ; |
if (is_array ($tableau_navigation))$tableau_navigation = array_reverse($tableau_navigation); |
for ($i = 0; $i < count ($tableau_navigation); $i++) { |
$chemin_repertoire_entre_racine_et_fichier.= $tableau_navigation[$i]."/"; |
$chemin_repertoire_entre_racine_et_fichier.= $tableau_navigation[$i]."/"; |
} |
return $projet->getNomRepertoire().'/'.$chemin_repertoire_entre_racine_et_fichier.$this->nom_fichier ; |
} |
} |
|
|
/** |
331,7 → 331,7 |
* @return Array |
* @access public |
*/ |
|
|
function getCheminIdRepertoire( $id_doc, &$objetDB ) |
{ |
if ($id_doc == "") $id_doc = 0; |
353,6 → 353,7 |
} |
return ($chemin_rep_id_nom); |
} |
|
function getPath( $id_doc) |
{ |
if ($id_doc == "") $id_doc = 0; |
359,20 → 360,24 |
// on commence par rechercher le répertoire père, dans la base de donnée |
$requete = 'select pd_pere, pd_nom, pd_id, pd_ce_type from projet_documents where pd_id='.$id_doc ; |
$resultat = $GLOBALS['projet_db']->query ($requete) ; |
|
if (DB::isError($resultat)) { |
return ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ; |
return ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ; |
} |
$ligne = $resultat->fetchRow (DB_FETCHMODE_OBJECT) ; |
|
$chemin_rep_id_nom = array() ; |
if ($resultat->numRows()>0) { |
if ($ligne->pd_pere == 0) { |
return array(); |
} |
array_push ($chemin_rep_id_nom, $ligne->pd_pere) ; |
$chemin_rep_id_nom = array_merge ($chemin_rep_id_nom, document::getPath($ligne->pd_pere) ); |
if ($resultat->numRows()>0 && $ligne->pd_pere != 0 && $ligne->pd_pere != $ligne->pd_id) { |
|
array_push ($chemin_rep_id_nom, $ligne->pd_pere) ; |
|
// Récursion sur le répertoires ou fichiers fils |
$chemin_rep_id_nom = array_merge ($chemin_rep_id_nom, document::getPath($ligne->pd_pere) ); |
} |
|
return $chemin_rep_id_nom; |
} |
|
/** |
* Calcule le chemin vers le fichier ou le répertoire uploadé |
* renvoie un chaine de la forme dir1/dir2/fichier.ext |
384,7 → 389,7 |
|
if (isset($_FILES['fichier']['name'])) { |
$extension = preg_replace("/^([^\.]+)\.(\w+$)/", "\\2", $_FILES['fichier']['name']) ; |
} |
} |
|
if ($this->_id_pere != '') { |
// On appelle la méthode getCheminIdRepertoire qui renvoie un tableau avec la liste |
394,7 → 399,7 |
$doc_pere = new document ($this->_id_pere, $GLOBALS['projet_db']); |
return $doc_pere->getChemin(); |
$tableau_navigation = $this->getPath($this->_id_pere) ; |
|
|
for ($i = 0; $i < count ($tableau_navigation); $i++) $chemin_repertoire_entre_racine_et_repertoire_a_cree.= $tableau_navigation[$i]."/"; |
$chemin = $chemin_repertoire_entre_racine_et_repertoire_a_cree ; |
} else { |
414,13 → 419,13 |
*/ |
|
function enregistrerSQL ($valeur, $chemin) { |
|
|
// On teste si on a affaire à un répertoire ou un fichier |
if (isset ($_FILES['fichier']['name'])) { |
// On tente de déterminer le type du fichier à partir de son nom dans $valeur['$fichier'] |
$tableau_nom = explode (".", $_FILES['fichier']['name']) ; |
|
// On prend le dernier élément du tableau, si c'est un tableau |
|
// On prend le dernier élément du tableau, si c'est un tableau |
if (is_array($tableau_nom)) { |
$extension = array_pop($tableau_nom) ; |
$type = type_fichier_mime::factory($extension) ; |
493,7 → 498,7 |
* |
* @return true en cas de succès |
*/ |
|
|
function suppressionSQL () { |
$requete = 'delete from projet_documents where pd_id='.$this->_id ; |
$resultat = $GLOBALS['projet_db']->query ($requete) ; |
500,7 → 505,7 |
if ($GLOBALS['projet_db']->affectedRows()) return true ; |
return false ; |
} |
|
|
/** |
* Déplace un document au sein d'un même projet |
* |
517,12 → 522,12 |
$chemin_rep_cible = $repertoire_cible->getChemin(); |
} else { |
// Si le repertoire destination est la racine cad id =0 |
// on cree un document qui aura pour chemin le repertoire du projet |
// on cree un document qui aura pour chemin le repertoire du projet |
include_once PROJET_CHEMIN_CLASSES.'projet.class.php'; |
$projet = new projet ($GLOBALS['projet_db'], $this->_id_projet); |
$chemin_rep_cible = $projet->getNomRepertoire().'/'; |
} |
|
|
$nom_fichier = $this->_pd_lien ; |
$requete = 'update projet_documents set pd_pere='.$repertoire_destination.' where pd_id='.$this->_id ; |
$resultat = $GLOBALS['projet_db']->query ($requete) ; |
532,7 → 537,7 |
} |
//echo $this->_chemin.'<br>'.PROJET_CHEMIN_FICHIER.$chemin_rep_cible.$nom_fichier; |
return fichier::deplace ($this->_chemin, PROJET_CHEMIN_FICHIER.$chemin_rep_cible.$nom_fichier) ; |
|
|
} // end of member function deplace |
|
|
601,7 → 606,7 |
die ('Echec de la requete : '.$requete.'<br />'.$resultat->getMessage()) ; |
} |
$tableau_document = array() ; |
|
|
while ($ligne = $resultat->fetchRow (DB_FETCHMODE_OBJECT)) { |
array_push ($tableau_document, new document ($ligne->pd_id, $objetDB, $chemin, $chemin_icones)) ; |
} |
622,7 → 627,7 |
if (DB::isError ($resultat)) { |
return ('Echec de la requete : '.$requete.'<br />'.$resultat->getMessage()) ; |
} |
|
|
return $resultat; |
} |
/** |
642,7 → 647,7 |
} |
return round ($taille / $diviseur, $precision).' '.$unite; |
} |
|
|
/** |
* Renvoie une liste de document, enfant du document courant |
* qui doit etre un repertoire bien sur |
651,9 → 656,9 |
* @access public |
*/ |
function getDocumentsEnfant() { |
|
|
} |
|
|
} // end of document |
|
|