Subversion Repositories Applications.referentiel

Rev

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

Rev 38 Rev 52
Line 11... Line 11...
11
* @license		http://www.cecill.info/licences/Licence_CeCILL_V2-fr.txt Licence CECILL
11
* @license		http://www.cecill.info/licences/Licence_CeCILL_V2-fr.txt Licence CECILL
12
* @license		http://www.gnu.org/licenses/gpl.html Licence GNU-GPL
12
* @license		http://www.gnu.org/licenses/gpl.html Licence GNU-GPL
13
* @version		SVN: $Id$
13
* @version		SVN: $Id$
14
*/
14
*/
15
abstract class Dao {
15
abstract class Dao {
-
 
16
	const ORDRE_ASCENDANT = 'ASC';
-
 
17
	const ORDRE_DESCENDANT = 'DESC';
16
	const HTTP_REQUETE_SEPARATEUR = '&';
18
	const HTTP_REQUETE_SEPARATEUR = '&';
17
	protected $distinction = '0';
19
	protected $distinction = '0';
18
	protected $limite_debut = null;
20
	protected $limite_debut = null;
19
	protected $limite_nbre = null;
21
	protected $limite_nbre = null;
20
	protected $url_jrest = null;
22
	protected $url_jrest = null;
Line 24... Line 26...
24
	}
26
	}
Line 25... Line 27...
25
	
27
	
26
	//+----------------------------------------------------------------------------------------------------------------+
28
	//+----------------------------------------------------------------------------------------------------------------+
Line 27... Line -...
27
	// ACCESSEURS
-
 
28
	
-
 
29
	public function avoirLimitation() {
-
 
30
		$limitation = false;
-
 
31
		if (!is_null($this->limite_debut) && !is_null($this->limite_nbre)) {
-
 
32
			$limitation = true;
-
 
33
		}
-
 
34
		return $limitation;
-
 
35
	}
29
	// ACCESSEURS
36
	
30
	
37
	public function setDistinction($distinct) {
31
	public function setDistinction($distinct) {
38
		$this->distinction = $distinct;
-
 
39
	}
32
		$this->distinction = $distinct;
40
	
33
	}
41
	public function getDistinction() {
34
	public function getDistinction() {
-
 
35
		return $this->distinction;
-
 
36
	}
-
 
37
	public function viderDistinction() {
Line -... Line 38...
-
 
38
		$this->distinction = null;
-
 
39
	}
-
 
40
	
-
 
41
	public function avoirLimitation() {
-
 
42
		$limitation = false;
-
 
43
		if (!is_null($this->limite_debut) && !is_null($this->limite_nbre)) {
-
 
44
			$limitation = true;
42
		return $this->distinction;
45
		}
43
	}
46
		return $limitation;
44
	
47
	}
45
	public function setLimitation($limite_debut, $limite_nbre) {
48
	public function setLimitation($limite_debut, $limite_nbre) {
46
		$this->limite_debut = $limite_debut;
-
 
47
		$this->limite_nbre = $limite_nbre;
49
		$this->limite_debut = $limite_debut;
48
	}
50
		$this->limite_nbre = $limite_nbre;
49
	
51
	}
50
	public function getLimiteDebut() {
52
	public function getLimiteDebut() {
51
		return $this->limite_debut;
53
		return $this->limite_debut;
52
	}
54
	}
-
 
55
	public function getLimiteNbre() {
-
 
56
		return $this->limite_nbre;
-
 
57
	}
-
 
58
	public function viderLimite() {
-
 
59
		$this->limite_debut = null;
-
 
60
		$this->limite_nbre = null;
-
 
61
	}
-
 
62
	
-
 
63
	public function addOrdre($champ, $trie = self::ORDRE_ASCENDANT) {
-
 
64
		if (!isset($this->ordre[$champ])) {
-
 
65
			if (self::ORDRE_ASCENDANT == $trie || self::ORDRE_DESCENDANT == $trie) {
-
 
66
				$this->ordre[$champ] = $trie;
-
 
67
			} else {
-
 
68
				$e = "La valeur pour le trie doit être : {self::ORDRE_ASCENDANT} ou {self::ORDRE_DESCENDANT}.";
-
 
69
				trigger_error($e, E_USER_WARNING);
-
 
70
			}
-
 
71
		} else {
-
 
72
			$e = "Le champ $champ existe déjà dans le tableau des ordres.";
-
 
73
			trigger_error($e, E_USER_WARNING);
-
 
74
		}
-
 
75
	}
-
 
76
	public function getOrdre() {
-
 
77
		$champs = array();
-
 
78
		foreach ($this->ordre as $champ => $trie) {
-
 
79
			$champs[] = "$champ $trie";
-
 
80
		}
-
 
81
		return implode(', ', $champs);
-
 
82
	}
Line 53... Line 83...
53
	public function getLimiteNbre() {
83
	public function viderOrdre() {
54
		return $this->limite_nbre;
84
		$this->ordre = null;
Line 55... Line 85...
55
	}
85
	}
Line 103... Line 133...
103
				$contenu = stream_get_contents($flux);
133
				$contenu = stream_get_contents($flux);
Line 104... Line 134...
104
				
134
				
105
				fclose($flux);
135
				fclose($flux);
106
			}
136
			}
-
 
137
		}
107
		}
138
		$this->reinitialiser();
108
		return $contenu;
139
		return $contenu;
Line 109... Line 140...
109
	}
140
	}
110
	
141
	
Line 114... Line 145...
114
			$parametres[] = 'start='.$this->getLimiteDebut();
145
			$parametres[] = 'start='.$this->getLimiteDebut();
115
		}
146
		}
116
		if (! is_null($this->getLimiteNbre())) {
147
		if (! is_null($this->getLimiteNbre())) {
117
			$parametres[] = 'limit='.$this->getLimiteNbre();
148
			$parametres[] = 'limit='.$this->getLimiteNbre();
118
		}
149
		}
-
 
150
		if (! is_null($this->ordre)) {
-
 
151
			$parametres[] = 'orderby='.urlencode($this->getOrdre());
-
 
152
		}
119
		if ($this->getDistinction() != 0) {
153
		if ($this->getDistinction() != 0) {
120
			$parametres[] = 'distinct='.$this->getDistinction();
154
			$parametres[] = 'distinct='.$this->getDistinction();
121
		}
155
		}
122
		if (count($parametres) > 0) {
156
		if (count($parametres) > 0) {
123
			$url_parametres = implode('&', $parametres);
157
			$url_parametres = implode('&', $parametres);
Line 171... Line 205...
171
			foreach ($messages as $message) {
205
			foreach ($messages as $message) {
172
				Debug::printr("MESSAGE : $date - $uri :\n$message");
206
				Debug::printr("MESSAGE : $date - $uri :\n$message");
173
			}
207
			}
174
		}
208
		}
175
	}
209
	}
-
 
210
	
-
 
211
	private function reinitialiser() {
-
 
212
		$this->viderDistinction();
-
 
213
		$this->viderLimite();
-
 
214
		$this->viderOrdre();
-
 
215
	}
176
}
216
}
177
217