Subversion Repositories eFlore/Applications.coel-consultation

Rev

Rev 67 | Rev 150 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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