Subversion Repositories eFlore/Applications.eflore-consultation

Rev

Rev 1009 | Blame | Last modification | View Log | RSS feed

<?php
Class Pagination extends aControleur {
        
        private $depart = 0;
        private $limite = 30;
        private $total = 1;
        private $taille_page = 25;
        
        protected $urls = null;
        
        public function Pagination() {
                $this->initialiser();
        }

         public function initialiser() {
                $this->capturerParametres();
                $this->conteneur = new Conteneur();
                $this->urls = $this->conteneur->getAppUrls();
        }
        
        private function capturerParametres() {
                
                if (isset($_GET['navigation_depart'])) {
                        $this->depart = $_GET['navigation_depart'];
                        unset($_GET['navigation_depart']);
                }
                if (isset($_GET['navigation_limite'])) {
                        $this->limite = $_GET['navigation_limite'];
                        unset($_GET['navigation_limite']);
                }
                $this->total = Registre::get('navigation.total');
                if (isset($_GET['navigation_taille_page'])) {
                        $this->taille_page = $_GET['navigation_taille_page'];
                        unset($_GET['navigation_taille_page']);
                }
        }
        
        public function getPagination() {
                $donnees = array();
                 
                if ($this->depart == 0) {
                        $page_en_cours = 1;
                } else if ($this->total != 0) {
                        $page_en_cours = floor(($this->depart + 1)/$this->limite + 1);
                }
                 
                $pages_avant_apres = 7;
                $pages_debut_intervalle = 0;
                $nb_pages = 0;
                 
                if ($page_en_cours < $pages_avant_apres)  {
                        $pages_debut_intervalle = 1;
                } else {
                        $pages_debut_intervalle = $page_en_cours - $pages_avant_apres + 2;
                }        
                $pages_a_afficher = $this->taille_page;  
                $intervalle_max = (($page_en_cours) * $this->limite);
                
                $donnees['url_base_pagination'] = '?'.http_build_query($_GET).'&navigation.limite='.$this->limite.'&navigation.depart=';
                 
                $nb_pages = ceil($this->total/$this->limite);
                
                if ($page_en_cours == $nb_pages) {
                        $intervalle_max = $this->total;
                }
                 
                $donnees['pages_taille_intervalle'] = $pages_avant_apres;
                $donnees['pages_debut_intervalle'] = $pages_debut_intervalle;
                $donnees['page_en_cours'] = $page_en_cours;
                $donnees['intervalle_min'] = (($page_en_cours-1) * $this->limite);
                $donnees['intervalle_max'] = $intervalle_max;
                $donnees['nb_resultats'] = $this->total;
                $donnees['nb_pages'] = $nb_pages;
                $donnees['taille_page'] = $this->limite;
                
                $vue = $this->getVue('/home/aurelien/web/eflore-consultation/modules/pagination/squelettes/pagination', $donnees);
                return $vue;
        }
}
?>