src/UI/Components/Pagination.php
public function render()
  {
    $html = parent::render();

    $items = '';

    // Affichage lien FIRST
    if ($this->currentPage > 1) {
      $first = $this->getElementTemplate('first');
      $first = str_replace('%page%', 1, $first);
      $items .= $first;
    }

    // Affichage previous
    if ($this->currentPage > 1) {
      $prev = $this->getElementTemplate('previous');
      $prev = str_replace('%page%', $this->currentPage - 1, $prev);
      $items .= $prev;
    }

    // Affichage des pages
    $startPage = $this->currentPage - floor($this->maxShowedPages / 2);
    $endPage   = $this->currentPage + floor($this->maxShowedPages / 2);
    if ($startPage < 1) {
      $endPage += (1 - $startPage);
      $startPage = 1;
    }
    if ($endPage > $this->nbPages) {
      $endPage = $this->nbPages;
    }
    if (($endPage - $startPage + 1) != $this->maxShowedPages) {
      $startPage = $endPage - $this->maxShowedPages + 1;
      if ($startPage < 1) {
        $startPage = 1;
      }
    }
    for ($i = $startPage; $i <= $endPage; $i++) {
      if ($this->currentPage == $i) {
        $page = $this->getElementTemplate('selectedpage');
      } else {
        $page = $this->getElementTemplate('page');
      }
      $page = str_replace('%page%', $i, $page);
      $items .= $page;
    }

    // Affichage next
    if ($this->currentPage < $this->nbPages) {
      $next = $this->getElementTemplate('next');
      $next = str_replace('%page%', $this->currentPage + 1, $next);
      $items .= $next;
    }

    // Affichage last
    if ($this->currentPage != $this->nbPages && $this->nbPages > 0) {
      $last = $this->getElementTemplate('last');
      $last = str_replace('%page%', $this->nbPages, $last);
      $items .= $last;
    }

    $html = str_replace('%items%', $items, $html);

    return $html;
  }
public function render()
  {
    $html = parent::render();

    $items = '';

    // Affichage lien FIRST
    if ($this->currentPage > 1) {
      $first = $this->getElementTemplate('first');
      $first = str_replace('%page%', 1, $first);
      $items .= $first;
    }

    // Affichage previous
    if ($this->currentPage > 1) {
      $prev = $this->getElementTemplate('previous');
      $prev = str_replace('%page%', $this->currentPage - 1, $prev);
      $items .= $prev;
    }

    // Affichage des pages
    $startPage = $this->currentPage - floor($this->maxShowedPages / 2);
    $endPage   = $this->currentPage + floor($this->maxShowedPages / 2);
    if ($startPage < 1) {
      $endPage += (1 - $startPage);
      $startPage = 1;
    }
    if ($endPage > $this->nbPages) {
      $endPage = $this->nbPages;
    }
    if (($endPage - $startPage + 1) != $this->maxShowedPages) {
      $startPage = $endPage - $this->maxShowedPages + 1;
      if ($startPage < 1) {
        $startPage = 1;
      }
    }
    for ($i = $startPage; $i <= $endPage; $i++) {
      if ($this->currentPage == $i) {
        $page = $this->getElementTemplate('selectedpage');
      } else {
        $page = $this->getElementTemplate('page');
      }
      $page = str_replace('%page%', $i, $page);
      $items .= $page;
    }

    // Affichage next
    if ($this->currentPage < $this->nbPages) {
      $next = $this->getElementTemplate('next');
      $next = str_replace('%page%', $this->currentPage + 1, $next);
      $items .= $next;
    }

    // Affichage last
    if ($this->currentPage != $this->nbPages && $this->nbPages > 0) {
      $last = $this->getElementTemplate('last');
      $last = str_replace('%page%', $this->nbPages, $last);
      $items .= $last;
    }

    $html = str_replace('%items%', $items, $html);

    return $html;
  }
public function render ( ) { $ html = parent :: render ( ) ; $ items = '' ; // Affichage lien FIRST
 if ( $ this -> currentPage > 1 ) { $ first = $ this -> getElementTemplate ( 'first' ) ; $ first = str_replace ( '%page%' , 1 , $ first ) ; $ items .= $ first ; } // Affichage previous
 if ( $ this -> currentPage > 1 ) { $ prev = $ this -> getElementTemplate ( 'previous' ) ; $ prev = str_replace ( '%page%' , $ this -> currentPage - 1 , $ prev ) ; $ items .= $ prev ; } // Affichage des pages
 $ startPage = $ this -> currentPage - floor ( $ this -> maxShowedPages / 2 ) ; $ endPage = $ this -> currentPage + floor ( $ this -> maxShowedPages / 2 ) ; if ( $ startPage < 1 ) { $ endPage += ( 1 - $ startPage ) ; $ startPage = 1 ; } if ( $ endPage > $ this -> nbPages ) { $ endPage = $ this -> nbPages ; } if ( ( $ endPage - $ startPage + 1 ) != $ this -> maxShowedPages ) { $ startPage = $ endPage - $ this -> maxShowedPages + 1 ; if ( $ startPage < 1 ) { $ startPage = 1 ; } } for ( $ i = $ startPage ; $ i <= $ endPage ; $ i ++ ) { if ( $ this -> currentPage == $ i ) { $ page = $ this -> getElementTemplate ( 'selectedpage' ) ; } else { $ page = $ this -> getElementTemplate ( 'page' ) ; } $ page = str_replace ( '%page%' , $ i , $ page ) ; $ items .= $ page ; } // Affichage next
 if ( $ this -> currentPage < $ this -> nbPages ) { $ next = $ this -> getElementTemplate ( 'next' ) ; $ next = str_replace ( '%page%' , $ this -> currentPage + 1 , $ next ) ; $ items .= $ next ; } // Affichage last
 if ( $ this -> currentPage != $ this -> nbPages && $ this -> nbPages > 0 ) { $ last = $ this -> getElementTemplate ( 'last' ) ; $ last = str_replace ( '%page%' , $ this -> nbPages , $ last ) ; $ items .= $ last ; } $ html = str_replace ( '%items%' , $ items , $ html ) ; return $ html ; }
Effectue un rendu du composant

@return string
Effectue un rendu du composant