//Autres auteurs : *@author Aucun *@copyright Tela-Botanica 2000-2005 *@version $Revision: 1.1 $ // +------------------------------------------------------------------------------------------------------+ */ // +------------------------------------------------------------------------------------------------------+ // | ENTETE du PROGRAMME | // +------------------------------------------------------------------------------------------------------+ // ATTENTION - le programme suivant doit renvoyer un tableau, meme vide // sinon l arbre dojo ne fonctionnera pas (ligne 117 $returnArray = array) set_include_path(get_include_path() . PATH_SEPARATOR . '/home/alex/www/api/pear'); include_once ('../../../papyrus/configuration/pap_config.inc.php'); include_once ('../../../api/pear/DB.php'); include_once ('../../../api/json/JSON.php'); define ('PROJET_CHEMIN_APPLI','../'); define ('PROJET_CHEMIN_ICONES', "client/projet/icones/") ; define ('PROJET_CHEMIN_CLASSES', PROJET_CHEMIN_APPLI.'classes/');//le chemin vers les fichiers propre à GSITE define ('PROJET_CHEMIN_FONCTIONS', PROJET_CHEMIN_APPLI.'fonctions/') ; define ('PROJET_CHEMIN_LIBRAIRIE','bibliotheque/');//le chemin de la librairie de fichier php define ('PROJET_CHEMIN_FICHIER', PROJET_CHEMIN_APPLI.'fichiers/') ; // Chemin ou seront créer les dossiers if (file_exists(PROJET_CHEMIN_CLASSES.'document.class.php')) { include_once (PROJET_CHEMIN_CLASSES.'document.class.php') ; } else { echo 'impossible document_class'; } if (file_exists(PROJET_CHEMIN_APPLI.'langues/pro_langue_fr.inc.php')) { include_once PROJET_CHEMIN_APPLI.'langues/pro_langue_fr.inc.php' ; } else { echo 'impossible fichier de langue'; } $GLOBALS['db'] = & DB::connect(PAP_DSN); if (PEAR::isError($db)) { echo ($db->getMessage()); } // we're returning json //header('Content-type: text/json'); $action = $_REQUEST["action"]; $data = $_REQUEST["data"]; $cache = $_REQUEST["dojo.preventCache"]; $data = str_replace("\\\"","\"",$data); // instanciate a json-php instance $json = new services_JSON(); if ( $action == "getChildren") { $jsonData = $json->decode($data); // get the node object $node = $jsonData->node; } function getChildren($node) { // setup the database connction // get the parent node $parent = $node->objectId; if (isset($_REQUEST['id_projet'])) $id_projet = $_REQUEST['id_projet']; if (preg_match ('/projet_([0-9]+)/', $node->objectId, $match)) $id_projet = $match[1]; // correspondance entre l objectid de dojo et id_parent de projet_document if ( $parent == "root" || preg_match ('/projet_([0-9]+)/', $node->objectId, $match)) { $id_parent = 0 ; } else { $id_parent = $node->objectId; } $sql = 'select * from projet_documents where pd_pere='.$id_parent ; if (isset($id_projet)) $sql .= ' and pd_ce_projet='.$id_projet; // assemble the resulting rows into an array of node objects. // Each node object is represented in php by an associative array // the array of associative arrays will then be encoded in json and // returned back to the browser $resultat = $GLOBALS['db']->query($sql); if (DB::isError($resultat)) { die ("Echec de la requete
".$resultat->getMessage()."
".$resultat->getDebugInfo()) ; } $returnArray = array(); $i = 0; while ( $ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) { $document = new document($ligne['pd_id'], $GLOBALS['db'], PROJET_CHEMIN_FICHIER, PROJET_CHEMIN_ICONES); // json attend de l utf8, en lui fournissant des donnees au format htmlentities, // ca passe $node = array( 'title'=> htmlentities($document->getNomLong()), 'widgetId' => 'document_'.$document->getIdDocument(), 'objectId'=> $document->getIdDocument(), 'isFolder'=> $document->isRepertoire(), 'link' => $document->getChemin(), 'childIconSrc' => $document->getCheminIcone(), 'expandIcon' => PROJET_CHEMIN_ICONES.'folder-expanded.gif', 'afterLabel' => ' '.$document->getTailleFormatee() ); $returnArray[$i] = $node; $i++; unset ($document); } return $returnArray; } if ( $action == "getChildren") { $jsonData = $json->decode($data); // get the node object $node = $jsonData->node; $nodeArray = getChildren($node); if (!is_null($nodeArray)) print $json->encode($nodeArray); } ?>