Subversion Repositories eFlore/Applications.coel-consultation

Rev

Rev 67 | Rev 150 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
17 jpm 1
<?php
2
// declare(encoding='UTF-8');
3
/**
144 jpm 4
 * DAO des Collections pour le module Collections.
17 jpm 5
 *
144 jpm 6
 * @package	Collection
17 jpm 7
 * @category	php 5.2
8
 * @author		Jean-Pascal MILCENT <jpm@tela-botanica.org>
9
 * @copyright	2010 Tela-Botanica
144 jpm 10
 * @license	http://www.cecill.info/licences/Licence_CeCILL_V2-fr.txt Licence CECILL
11
 * @license	http://www.gnu.org/licenses/gpl.html Licence GNU-GPL
12
 * @version	SVN: $Id: CollectionDao.php 144 2010-08-30 16:22:52Z jpm $
17 jpm 13
 *
14
 */
144 jpm 15
class CollectionDao extends Dao {
19 jpm 16
	const SERVICE_COLLECTION = 'CoelCollection';
17
	const SERVICE_COLLECTION_A_PERSONNE = 'CoelCollectionAPersonne';
18
	const SERVICE_COLLECTION_A_PUBLICATION = 'CoelCollectionAPublication';
19
	const SERVICE_COLLECTION_A_COMMENTAIRE = 'CoelCollectionACommentaire';
20 jpm 20
 
17 jpm 21
	/**
22
	 * Retourne l'ensemble des information sur une collection.
23
	 *
24
	 * @param integer l'id de la collection.
25
	 * @return array un tableau contenant les informations sur la collection.
26
	 */
27
	public function getCollection($id) {
144 jpm 28
		$url = $this->url_jrest.self::SERVICE_COLLECTION."/*/$id/*";
29
		$json = $this->envoyerRequeteConsultation($url);
17 jpm 30
		$donnees = json_decode($json, true);
34 jpm 31
		return $donnees['collections'];
17 jpm 32
	}
33
 
34
	/**
18 jpm 35
	 * Retourne les collection correspondant à un id strucutre précis.
36
	 *
37
	 * @param integer l'id d'une structure.
38
	 * @return array un tableau contenant les collections correspondant à l'id structure.
39
	 */
40
	public function getParIdStructure($id_structure) {
19 jpm 41
		$url = $this->url_jrest.self::SERVICE_COLLECTION."/ParIdStructure/$id_structure";
144 jpm 42
		$json = $this->envoyerRequeteConsultation($url);
18 jpm 43
		$donnees = json_decode($json, true);
44
		return $donnees;
45
	}
46
 
47
	/**
17 jpm 48
	 * Retourne l'ensemble des personnes liées à une collection.
49
	 *
50
	 * @param integer l'id de la collection.
51
	 * @return array un tableau contenant les informations sur les personnes liées à la collection.
52
	 */
144 jpm 53
	public function getPersonnesLiees($id_collection) {
54
		$this->addOrdre('cp_nom');
55
		$donnees = $this->getCollectionAPersonne($id_collection);
56
		return $donnees['collectionsAPersonne'];
57
	}
58
 
59
	/**
60
	 * Retourne le nombre de personnes liées à une collection.
61
	 *
62
	 * @param integer l'id de la collection.
63
	 * @return integer le nombre de personnes liées à la collection.
64
	 */
65
	public function getNbrePersonnesLiees($id_collection) {
66
		$donnees = $this->getCollectionAPersonne($id_collection);
67
		return $donnees['nbElements'];
68
	}
69
 
70
	private function getCollectionAPersonne($id_collection) {
19 jpm 71
		$url = $this->url_jrest.self::SERVICE_COLLECTION_A_PERSONNE."/$id_collection";
144 jpm 72
		$json = $this->envoyerRequeteConsultation($url);
17 jpm 73
		$donnees = json_decode($json, true);
144 jpm 74
		return $donnees;
17 jpm 75
	}
76
 
77
	/**
78
	 * Retourne l'ensemble des publications liées à une collection.
79
	 *
80
	 * @param integer l'id de la collection.
81
	 * @return array un tableau contenant les informations sur les publications liées à la collection.
82
	 */
144 jpm 83
	public function getPublicationsLiees($id_collection) {
19 jpm 84
		$url = $this->url_jrest.self::SERVICE_COLLECTION_A_PUBLICATION."/$id_collection";
144 jpm 85
		$json = $this->envoyerRequeteConsultation($url);
17 jpm 86
		$donnees = json_decode($json, true);
67 jpm 87
		return $donnees['collectionsAPublication'];
17 jpm 88
	}
19 jpm 89
 
90
	/**
91
	 * Retourne l'ensemble des commentaires publics liés à une collection.
92
	 *
93
	 * @param integer l'id de la collection.
94
	 * @return array un tableau contenant les informations sur les publications liées à la collection.
95
	 */
144 jpm 96
	public function getCommentairesLies($id_collection) {
19 jpm 97
		$commentaire_public = '1';
98
		$url = $this->url_jrest.self::SERVICE_COLLECTION_A_COMMENTAIRE."/$id_collection/$commentaire_public";
144 jpm 99
		$json = $this->envoyerRequeteConsultation($url);
19 jpm 100
		$donnees = json_decode($json, true);
67 jpm 101
		return $donnees['collectionsACommentaire'];
19 jpm 102
	}
17 jpm 103
}
104
?>