Subversion Repositories eFlore/Applications.coel-consultation

Rev

Rev 34 | Blame | Compare with Previous | Last modification | View Log | RSS feed

<?php
// declare(encoding='UTF-8');
/**
 * Modèle d'accès à la base de données des Collections pour le module Collections.
 *
 * @package             Collection
 * @category    php 5.2
 * @author              Jean-Pascal MILCENT <jpm@tela-botanica.org>
 * @copyright   2010 Tela-Botanica
 * @license             http://www.cecill.info/licences/Licence_CeCILL_V2-fr.txt Licence CECILL
 * @license             http://www.gnu.org/licenses/gpl.html Licence GNU-GPL
 * @version             SVN: $Id: CollectionDao.php 34 2010-04-23 13:58:21Z jpm $
 *
 */
class CollectionDao extends ColModele {
        const SERVICE_COLLECTION = 'CoelCollection';
        const SERVICE_COLLECTION_A_PERSONNE = 'CoelCollectionAPersonne';
        const SERVICE_COLLECTION_A_PUBLICATION = 'CoelCollectionAPublication';
        const SERVICE_COLLECTION_A_COMMENTAIRE = 'CoelCollectionACommentaire';
        
        /**
         * Retourne l'ensemble des information sur une collection.
         * 
         * @param integer l'id de la collection.
         * @return array un tableau contenant les informations sur la collection.
         */
        public function getCollection($id) {
                $json = file_get_contents("http://www.tela-botanica.org/eflore/coel/jrest/CoelCollection/*/$id/*");
                $donnees = json_decode($json, true);
                return $donnees['collections'];
        }
        
        /**
         * Retourne les collection correspondant à un id strucutre précis.
         * 
         * @param integer l'id d'une structure.
         * @return array un tableau contenant les collections correspondant à l'id structure.
         */
        public function getParIdStructure($id_structure) {
                $url = $this->url_jrest.self::SERVICE_COLLECTION."/ParIdStructure/$id_structure";
                $json = file_get_contents($url);
                $donnees = json_decode($json, true);
                $this->nettoyerTableauDeTableauxAssoc($donnees);
                return $donnees;
        }
        
        /**
         * Retourne l'ensemble des personnes liées à une collection.
         * 
         * @param integer l'id de la collection.
         * @return array un tableau contenant les informations sur les personnes liées à la collection.
         */
        public function getCollectionAPersonne($id_collection) {
                $url = $this->url_jrest.self::SERVICE_COLLECTION_A_PERSONNE."/$id_collection";
                $json = file_get_contents($url);
                $donnees = json_decode($json, true);
                $this->nettoyerTableauDeTableauxAssoc($donnees);
                return $donnees;
        }
        
        /**
         * Retourne l'ensemble des publications liées à une collection.
         * 
         * @param integer l'id de la collection.
         * @return array un tableau contenant les informations sur les publications liées à la collection.
         */
        public function getCollectionAPublication($id_collection) {
                $url = $this->url_jrest.self::SERVICE_COLLECTION_A_PUBLICATION."/$id_collection";
                $json = file_get_contents($url);
                $donnees = json_decode($json, true);
                $this->nettoyerTableauDeTableauxAssoc($donnees);
                return $donnees;
        }
        
        /**
         * Retourne l'ensemble des commentaires publics liés à une collection.
         * 
         * @param integer l'id de la collection.
         * @return array un tableau contenant les informations sur les publications liées à la collection.
         */
        public function getCollectionACommentaire($id_collection) {
                $commentaire_public = '1';
                $url = $this->url_jrest.self::SERVICE_COLLECTION_A_COMMENTAIRE."/$id_collection/$commentaire_public";
                $json = file_get_contents($url);
                $donnees = json_decode($json, true);
                $this->nettoyerTableauDeTableauxAssoc($donnees);
                return $donnees;
        }
}
?>