Subversion Repositories eFlore/Applications.eflore-consultation

Rev

Rev 1009 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1009 aurelien 1
<?php
2
Class Pagination extends aControleur {
3
 
4
	private $depart = 0;
5
	private $limite = 30;
6
	private $total = 1;
7
	private $taille_page = 25;
8
 
9
	protected $urls = null;
10
 
11
	public function Pagination() {
12
		$this->initialiser();
13
	}
14
 
15
	 public function initialiser() {
16
		$this->capturerParametres();
17
		$this->conteneur = new Conteneur();
18
		$this->urls = $this->conteneur->getAppUrls();
19
	}
20
 
21
	private function capturerParametres() {
22
 
23
		if (isset($_GET['navigation_depart'])) {
24
			$this->depart = $_GET['navigation_depart'];
25
			unset($_GET['navigation_depart']);
26
		}
27
		if (isset($_GET['navigation_limite'])) {
28
			$this->limite = $_GET['navigation_limite'];
29
			unset($_GET['navigation_limite']);
30
		}
31
		$this->total = Registre::get('navigation.total');
32
		if (isset($_GET['navigation_taille_page'])) {
33
			$this->taille_page = $_GET['navigation_taille_page'];
34
			unset($_GET['navigation_taille_page']);
35
		}
36
	}
37
 
38
	public function getPagination() {
39
		$donnees = array();
40
 
41
		if ($this->depart == 0) {
42
			$page_en_cours = 1;
43
		} else if ($this->total != 0) {
44
			$page_en_cours = floor(($this->depart + 1)/$this->limite + 1);
45
		}
46
 
47
		$pages_avant_apres = 7;
48
		$pages_debut_intervalle = 0;
49
		$nb_pages = 0;
50
 
51
		if ($page_en_cours < $pages_avant_apres)  {
52
			$pages_debut_intervalle = 1;
53
		} else {
54
			$pages_debut_intervalle = $page_en_cours - $pages_avant_apres + 2;
55
		}
56
		$pages_a_afficher = $this->taille_page;
57
		$intervalle_max = (($page_en_cours) * $this->limite);
58
 
59
		$donnees['url_base_pagination'] = '?'.http_build_query($_GET).'&navigation.limite='.$this->limite.'&navigation.depart=';
60
 
61
		$nb_pages = ceil($this->total/$this->limite);
62
 
63
		if ($page_en_cours == $nb_pages) {
64
			$intervalle_max = $this->total;
65
		}
66
 
67
		$donnees['pages_taille_intervalle'] = $pages_avant_apres;
68
		$donnees['pages_debut_intervalle'] = $pages_debut_intervalle;
69
		$donnees['page_en_cours'] = $page_en_cours;
70
		$donnees['intervalle_min'] = (($page_en_cours-1) * $this->limite);
71
		$donnees['intervalle_max'] = $intervalle_max;
72
		$donnees['nb_resultats'] = $this->total;
73
		$donnees['nb_pages'] = $nb_pages;
74
		$donnees['taille_page'] = $this->limite;
75
 
76
		$vue = $this->getVue('/home/aurelien/web/eflore-consultation/modules/pagination/squelettes/pagination', $donnees);
77
		return $vue;
78
	}
79
}
80
?>