Ankündigung

Einklappen
Keine Ankündigung bisher.

Paginator Algorithmus

Einklappen

Neue Werbung 2019

Einklappen
X
  • Filter
  • Zeit
  • Anzeigen
Alles löschen
neue Beiträge

  • Scriptangebot Paginator Algorithmus

    Hallo,

    habe einen neuen Paginator-Algorithmus (Alpha Version ). Ist noch nicht ausgereift, aber scheint zu funktionieren. Er erstellt abhängig von der aktuellen Seite ($currentPage) und der Gesamtzahl aller Seiten ($pageCount) einen Array mit Seitenzahlen, die darzustellen sind.

    Könnte so aussehen:
    1 .. 17 18 [19] 20 21 .. 50

    currentPage=19, pageCount=50, smartRange=5 (unterstrichen)

    Der erste und letzte Wert sind immer Seite 1 bzw. die letzte Seite.
    Wenn möglich wird ".." durch die passende Seitenzahl ersetzt, also z.B.

    1 2 [3] 4 5 6 7 .. 50

    Ungetestet sind andere Werte für smartRange, sollte aber auch so gehen, solang die Zahl ungerade ist!


    PHP-Code:
    <?php
    class Util_Paginator
    {
        const 
    DOT_DOT '..';
        
        protected 
    $_currentPage;
        protected 
    $_pageCount;
        protected 
    $_smartRange 5;
        
        public function 
    __construct($pageCount$currentPage)
        {
            
    $this->_pageCount   $pageCount;
            
    $this->_currentPage $currentPage;
        }
        
        public function 
    render()
        {
            
    set_time_limit(3);
            
            if (
    $this->_pageCount <= 1) {
                return 
    $this->_renderPages();
            }
            
    $pagesToDisplay $this->_smartRange 4;
            if (
    $this->_pageCount <= $pagesToDisplay) {
                
    $pages range(1$this->_pageCount);
                return 
    $this->_renderPages($pages);
            }
            
            
    $maxRange  $this->_smartRange 4;
            
    $firstPage max($this->_currentPage $maxRange1);
            
    $lastPage  min($this->_currentPage $maxRange$this->_pageCount);
            
            do {
                
    $dropLeft = ($this->_currentPage $firstPage) > ($lastPage $this->_currentPage);
                if (
    $dropLeft) {
                    ++
    $firstPage;
                } else {
                    --
    $lastPage;
                }
                
    $diff $lastPage $firstPage;
            } while ((
    $diff 1) > $pagesToDisplay);
            
            
            
    $pages        range($firstPage$lastPage);
            
    $pages[0]     = 1;
            if (
    $pages[1] != 2) {
                
    $pages[1] = self::DOT_DOT;
            }
            if (
    $pages[$diff 1] != ($this->_pageCount 1)) {
                
    $pages[$diff 1] = self::DOT_DOT;
            }
            
    $pages[$diff] = $this->_pageCount;
            
            return 
    $this->_renderPages($pages);
        }
        
        protected function 
    _renderPages(array $pages = array())
        {
            echo 
    '<pre>'print_r($pagestrue), '</pre>';
        }
        
        protected function 
    _isValidPage($page)
        {
            return 
    <= $page && $page <= $this->_pageCount;
        }
    }
    ?>
    Die Rendering-Logik fehlt noch, sollte aber das kleinste Problem darstellen.

  • #2
    Hatte ich auch mal vor, sowas zu schreiben. Werd ich bei Gelegenheit mal nachholen.

    Kommentar


    • #3
      Zitat von Chriz Beitrag anzeigen
      Die Rendering-Logik fehlt noch, sollte aber das kleinste Problem darstellen.
      Ist aber m.E. die Hauptaufgabe, die diese Klasse überhaupt zu erfüllen hat.

      Die Daten an sich liegen bereits vor. Die Aufgabe, die noch zu erfüllen ist, ist das Rendering dieser Daten. Außerdem überlässt du wieder einen wesentlichen Teil der Logik der aufrufenden Stelle, wenn die noch entscheiden muss, ob ein Array-Eintrag nun eine Seitenzahl ist und damit verlinkt werden muss, oder ob der Eintrag nur '..' ist, damit nur Füllzeichen und nicht verlinkt werden sollte.
      Würde ich also so umbauen, dass das auch die Hauptfunktionalität dieser Klasse ist - die fertigen Links zurückgeben. Um das ganze flexibel zu halten, ggf. per printf ein Mini-„Templating“ für die Ausgabe einbauen.


      Ob's dazu eine eigene Klasse braucht, wäre die andere Frage - tut's als Funktion m.E. genauso gut. Sowas hab ich auch noch rumfliegen,
      PHP-Code:
      function paginationLinks($num$step$act$before) {
        
      $output '';
        
      $numLinks ceil($num/$step);
        if(
      $act || $act $numLinks) return 'paginationLinks error: param out of bounds!';
        if(
      $numLinks 1) {
          
      $output .= $act == '<u>[1]</u> ' '[1] ';
          if(
      $act $before 2) {
            
      $output .= '... ';
          }
        }
        for(
      $i=max(2$act-$before); $i<=min($numLinks-1$act+$before); ++$i) {
          
      $output .= $act == $i '<u>['.$i.']</u> ' '['.$i.'] ';
        }
        if(
      $act $before $numLinks-1) {
          
      $output .= '... ';
        }
        
      $output .= $act == $numLinks '<u>['.$numLinks.']</u>' '['.$numLinks.']';
        return 
      $output;
      }

      echo 
      paginationLinks(
          
      500// Anzahl der Einträge
          
      10// Anzahl Einträge pro Seite
          
      49// aktuelle Position (Seitennummer)
          
      // Anzahl zu erzeugender Links vor/nach aktueller Seite
      ); 
      Die Funktion will nicht die Anzahl Seiten als Parameter, sondern die Anzahl an Einträgen und wie viele pro Seite dargestellt werden sollen. Kommt zwar in etwa auf's gleiche raus, ist aber m.E. etwas praxisnäher. Außerdem damit flexibler, wenn man dem Nutzer der Seite eine Auswahl zur Verfügung stellt, wie viele Einträge er pro Seite dargestellt haben will.

      Kommentar


      • #4
        Danke für eure Antworten.

        Also ich finde die Ausgabe und das geschickte "Templating" eigentlich weniger anspruchsvoll. Sicherlich machen es fast alle Klassen (inklusive Zend) falsch, da sie Implikationen vornehmen, die unsinnig sind. Aber mit abstrakten CSS-Angaben lässt sich doch eine relativ flexible Ausgabe erzeugen (die noch folgen wird).

        Und um ehrlich zu sein - ich finde die geschickte Zusammenfassung und "Errechnung" von anzuzeigenden Seitenzahlen das schwierigste daran. Mit einem Decorator o.ä. kann der Anwender meinetwegen auch sein eigenes Templating machen.

        Im übrigen ist die do-while-Schleife unnötig, im Prinzip kann man mathematisch berechnen wieviele Werte links und rechts entfernt werden müssen, damit die gewünschte Ausgabe erzeugt wird.

        Dein Skript ChrisB teste ich morgen bei der Arbeit.

        Außerdem überlässt du wieder einen wesentlichen Teil der Logik der aufrufenden Stelle, wenn die noch entscheiden muss, ob ein Array-Eintrag nun eine Seitenzahl ist und damit verlinkt werden muss, oder ob der Eintrag nur '..' ist, damit nur Füllzeichen und nicht verlinkt werden sollte.
        sehe ich eigentlich nicht so, Bedingungen müssen so oder so her. Für Verlinkung, aktuelle Seite markieren, zurück und weiter etc. Ich meine eine einfachere Erzeugung als ein Array mit den Seitenzahlen und einem potentiellen Placeholder ist doch wirklich schwer zu unterbieten.

        Na jedenfalls mir gefällts. Endergebnis wird gepostet, natürlich bereinigt um einige Fehler und das set_time_limit kommt natürlich auch noch raus. Das ist nur der Rettungsanker für Endlosschleifen.

        Kommentar


        • #5
          Habs gerade mal ausprobiert. Sinnvoll wäre imho noch ein min/max-Filter für den current-Wert. Sonst werden seltsame Effekte außerhalb des Grenzbereichs erzeugt.

          Kommentar


          • #6
            Und bei kleinen Werten scheint mir die smart-range nicht zu stimmen. Ist aber viell. auch nur eine Definitionsfrage.

            [edit]
            Ok, geht wohl nicht anders.

            Kommentar


            • #7
              Dann werfe ich nochmal die Pagination-Klasse in den Raum, die ich fürs Gästebuch-Quiz erstellt habe:

              PHP-Code:
              <?php
              class SlimGb_Pagination
              {
                  
              /**
                   * @var SlimGb_Page[]
                   */
                  
              private $pages = array();
                  
              /**
                   * @var string
                   */
                  
              private $info;

                  private 
              $totalEntries;
                  private 
              $offset;
                  private 
              $totalPages;
                  private 
              $currentPage;
                  private 
              $entriesPerPage;
                  private 
              $maxPageLinks;
                  private 
              $pageLinkFormat;
                  
                  public function 
              __construct(SlimGb_Service_Config  $config$totalEntries$offset)
                  {
                      
              $this->entriesPerPage $config['entries']['per_page'];
                      
              $this->maxPageLinks $config['entries']['max_page_links'];
                      
              $this->pageLinkFormat $this->getPageLinkFormat($config['application']['link']);
                      
                      
              $this->totalEntries $totalEntries;
                      
              $this->offset $offset;

                      
              $this->totalPages ceil(bcdiv($this->totalEntries,$this->entriesPerPage1));
                      
              $this->currentPage round(bcdiv($this->offset$this->entriesPerPage1)) + 1;
                      
              $this->currentPage min($this->totalPages$this->currentPage);
                      
              $this->currentPage max(1$this->currentPage);
                      
                      
              $this->createPages();
                      
              $this->info sprintf('Showing %d-%d out of %d entries.'$this->pages[$this->currentPage]->from$this->pages[$this->currentPage]->to$totalEntries);
                  }
                  
                  public function 
              getPages()
                  {
                      return 
              $this->pages;
                  }
                  public function 
              getInfo()
                  {
                      return 
              $this->info;
                  }
                  public function 
              getCurrentPage()
                  {
                      return 
              $this->pages[$this->currentPage];
                  }
                  
                  private function 
              getPageLinkFormat($baseLink)
                  {
                      
              $result $baseLink;
                      if (
              strpos($baseLink'?')!==false) {
                          
              $result .= '&';
                      } else {
                          
              $result .= '?';
                      }
                      
              $result .= 'SlimGb_offset=%d';
                      return 
              $result;
                  }

                  private function 
              createPages()
                  {
                      if (
              $this->totalPages <= $this->maxPageLinks) {
                          
              $this->createAllPages();
                          return;
                      }
                      
              $this->createFirstPages();
                      
              $this->createLastPages();
                      
              $this->createCurrentPages();
                      
              ksort($this->pages);
                  }
                  
                  private function 
              createAllPages()
                  {
                      for(
              $i 1$i <= $this->totalPages; ++$i)
                      {
                          
              $this->pages[$i] = $this->makePage($this->currentPage == $i SlimGb_Page::ACTIVE SlimGb_Page::LINK$i);
                      }
                  }
                  
                  private function 
              createFirstPages()
                  {
                      
              $end bcdiv($this->maxPageLinks30);
                      for(
              $i 1$i $end; ++$i) {
                          
              $this->pages[$i] = $this->makePage(SlimGb_Page::LINK$i);
                      }
                      
              $this->pages[$end] = new SlimGb_Page(SlimGb_Page::DOTS);
                  }
                  
                  private function 
              createLastPages()
                  {
                      
              $start $this->totalPages bcdiv($this->maxPageLinks30) + 1;
                      for(
              $i $this->totalPages$i $start; --$i) {
                          
              $this->pages[$i] = $this->makePage(SlimGb_Page::LINK$i);
                      }
                      
              $this->pages[$start] = new SlimGb_Page(SlimGb_Page::DOTS);
                  }
                  
                  private function 
              createCurrentPages()
                  {
                      
              $this->pages[$this->currentPage] = $this->makePage(SlimGb_Page::ACTIVE$this->currentPage);
                      
              $i $this->currentPage;
                      
              $k 1;
                      while(
              count($this->pages) < $this->maxPageLinks) {
                          
              $i += pow(-1$k) * $k;
                          ++
              $k;
                          if (
              $i >= && $i <= $this->totalPages) {
                              
              $this->pages[$i] = $this->makePage(SlimGb_Page::LINK$i);
                          }
                      }
                  }
                  
                  private function 
              makePage($type$pageNumber)
                  {
                      return new 
              SlimGb_Page(
                          
              $type,
                          
              $pageNumber,
                          
              $this->entriesPerPage * ($pageNumber 1),
                          
              min($this->totalEntries$this->entriesPerPage * ($pageNumber)),
                          
              sprintf($this->pageLinkFormat$this->entriesPerPage * ($pageNumber -1))
                      );
                  }
              }
              Interessant für den Algorithmus sind die create* Methoden. Insgesamt ähnlicher Ansatz aber statt die Anzahl von Links um die aktuelle Seite herum wird die maximale Gesamtzahl festgelegt und diese auf die ersten Seiten, die letzten Seiten und die Seiten links und rechts der aktuellen Seite verteilt, das kann dann z.B. so aussehen (unterstrichen = aktuelle Seite):

              1 2 3 ... 10 11 12 ... 18 19 20
              1 2 3 4 5 6 7 ... 18 19 20
              1 2 3 ... 14 15 16 17 18 19 20

              Kommentar


              • #8
                Ihr seid alle die Masters of Commenting. *scnr*

                Kommentar


                • #9
                  Gerade nochmal die aktuelle, im Einsatz befindliche Variante anbei.

                  Anwendung:
                  PHP-Code:
                  <?php
                  $paginator 
                  = new Gf_Paginator(3012); // gesamt = 30 Seiten, aktuelle Seite = 12
                  /*
                  $paginator->setUrlCallback(function($page) {
                      $get = $_GET;
                      $get["page"] = $page;
                      $parsedUrl = parse_url($_SERVER["REQUEST_URI"]);
                      $url = $parsedUrl["path"];
                      return $url . "?" . http_build_query($get, '', '&amp;');
                  }); // Standardverhalten
                  */
                  echo $paginator->render();
                  Klasse:
                  PHP-Code:
                  <?php
                  /**
                   * Paginator that allows you to paginate through different pages by
                   * rendering an html toolbar.
                   * The paginator generates a meaningful page range that will be displayed
                   * when calling the render() method.
                   *
                   * Please use CSS declarations for styling but feel free to add additional
                   * rendering methods for the output.
                   *
                   * @example
                   * <code>
                   * $paginator = new Gf_Paginator($pageCount, $currentPage);
                   * echo $paginator->render();
                   *
                   * // $pageCount = 20, $currentPage = 8
                   * // [zurück] - [ 1]  ..  [ 6] [ 7] ( 8) [ 9] [10]  ..  [20] - [weiter]
                   *
                   * // $pageCount = 10, $currentPage = 1
                   * // [zurück] - ( 1) [ 2] [ 3] [ 4] [ 5] [ 6] [ 7]  ..  [10] - [weiter]
                   *
                   * // $pageCount = 10, $currentPage = 10
                   * // [zurück] - [ 1]  ..  [ 4] [ 5] [ 6] [ 7] [ 8] [ 9] (10) - [weiter]
                   * </code>
                   *
                   * The "smart range" is the range between both "..".
                   *
                   * @author Christian Reinecke <christian.reinecke@web.de>
                   * @since  2010-11-17
                   */
                  class Gf_Paginator
                  {
                      
                  /**
                       * Internal placeholder for "..", see example at class declaration
                       * for further details.
                       *
                       * @var string
                       */
                      
                  const DOT_DOT '..';


                      
                  /**
                       * current page
                       *
                       * @var int
                       */
                      
                  protected $_currentPage;


                      
                  /**
                       * total number of pages
                       *
                       * @var int
                       */
                      
                  protected $_pageCount;


                      
                  /**
                       * smart range to display
                       * see example in class declaration doc block for further details
                       *
                       * feel free to edit the value (please use setter/getter methods)
                       * but use odd [ungerade] values only
                       *
                       * @var int
                       */
                      
                  protected $_smartRange 5;


                      
                  /**
                       * callback to generate page linking
                       *
                       * @var array|string
                       */
                      
                  protected $_callback;


                      
                  /**
                       * additional callback parameters for page linking callback
                       *
                       * @see Gf_Paginator::$_callback
                       * @var array
                       */
                      
                  protected $_callbackArgs;


                      
                  /**
                       * @param int $pageCount   total number of available pages
                       * @param int $currentPage current page number
                       */
                      
                  public function __construct($pageCount$currentPage)
                      {
                          
                  $pageCount = (int)$pageCount;
                          if (
                  $pageCount 0) {
                              throw new 
                  Exception("invalid page count");
                          }

                          
                  $currentPage = (int)$currentPage;
                          if (
                  $currentPage 1) {
                              throw new 
                  Exception("invalid current page");
                          }

                          if (
                  $pageCount $currentPage) {
                              
                  $currentPage $pageCount;
                          }

                          
                  $this->_pageCount $pageCount;
                          
                  $this->_currentPage $currentPage;
                      }

                      public function 
                  __toString()
                      {
                          return 
                  $this->render();
                      }

                      public function 
                  getCurrentPage()
                      {
                          return 
                  $this->_currentPage;
                      }

                      public function 
                  getPageCount()
                      {
                          return 
                  $this->_pageCount;
                      }

                      public function 
                  setSmartRange($range)
                      {
                          if (!
                  ctype_digit((string)$range) || $range || ($range != 1)) {
                              throw new 
                  Exception("range value must be an unsigned, odd integer >= 3");
                          }
                          
                  $this->_smartRange = (int)$range;
                          return 
                  $this;
                      }

                      public function 
                  getSmartRange()
                      {
                          return 
                  $this->_smartRange;
                      }

                      
                  /**
                       * Sets the callback which will be called for generating
                       * the page linking. The first parameter of the callback will be the
                       * page to link, additional parameters can be defined using the second
                       * argument of this method.
                       *
                       * @param  mixed $callback
                       * @param  array $callbackArgs
                       * @return self $this
                       */
                      
                  public function setUrlCallback($callback, array $callbackArgs = array())
                      {
                          if (!
                  is_callable($callback)) {
                              throw new 
                  Exception("invalid url callback for paginator");
                          }

                          
                  $this->_callback $callback;
                          
                  $this->_callbackArgs $callbackArgs;

                          return 
                  $this;
                      }

                      public function 
                  getRange()
                      {
                          if (
                  $this->_pageCount <= 1) {
                              
                  // we don't need a paginator if there are only
                              // 1 (or less) pages in total
                              
                  return array();
                          }
                          
                  // +4 stands for 1st page, DOT_DOT, DOT_DOT and last page
                          // please see example in class documentation for further details
                          
                  $maxRange $this->_smartRange 4;
                          if (
                  $this->_pageCount <= $maxRange) {
                              
                  // amount of pages to display is so small
                              // that we can just render it out without any
                              // further logic
                              
                  $pages range(1$this->_pageCount);
                              return 
                  $pages;
                          }

                          
                  // we need to calculate the page range that is displayed,
                          // which means the pages around the current page are most important for us

                          // there are several "special" situations, especially when the
                          // current page is near a "border" (near page 1 or near last page)

                          // max range specifies a generous range of pages that will be displayed

                          
                  $firstPage max($this->_currentPage $maxRange1);
                          
                  $lastPage  min($this->_currentPage $maxRange$this->_pageCount);

                          
                  // imagine $currentPage = 2, $pageCount = 20, $smartRange = 5, now
                          // $maxRange  = 5 + 4 = 9
                          // $firstPage = max(2 - 9, 1)  = 1
                          // $lastPage  = min(2 + 9, 20) = 11
                          // so the pages we want to display are between 1 and 11
                          // but we can't display all pages (1, 2, .. 11), because our smart range
                          // is defined with 5.
                          // So now we want to drop unnecessary pages starting from the border (1, 11)

                          
                  do {
                              
                  // drop the border value depending on the absolute distance
                              // to the current page

                              // $dropLeft = (2 - 1) > (11 - 2) = 1 > 9 = false

                              
                  $dropLeft = ($this->_currentPage $firstPage) > ($lastPage $this->_currentPage);
                              if (
                  $dropLeft) {
                                  ++
                  $firstPage;
                              } else {
                                  --
                  $lastPage;
                              }
                              
                  $diff $lastPage $firstPage;

                              
                  // we repeat that until we have exactly the
                              // amount of pages that we want to display
                          
                  } while (($diff 1) > $maxRange);

                          
                  $pages        range($firstPage$lastPage);

                          
                  // our first "page" to display will always be page=1
                          
                  $pages[0]     = 1;

                          
                  // because of the fact that we want an ascending display
                          // of our page numbers, we now check if the second page to
                          // display is page=2, if not, there's obviously a gap, so we
                          // will add the "..".
                          
                  if ($pages[1] != 2) {
                              
                  $pages[1] = self::DOT_DOT;
                          }

                          
                  // same goes for the end of the paginator
                          
                  if ($pages[$diff 1] != ($this->_pageCount 1)) {
                              
                  $pages[$diff 1] = self::DOT_DOT;
                          }
                          
                  $pages[$diff] = $this->_pageCount;

                          
                  // random example
                          // $pages = array(1, "..", 6, 7, 8, 9, 10, "..", 20)

                          
                  return $pages;
                      }


                      
                  /**
                       * method to render html output
                       *
                       * @return string html output for paginator toolbar
                       */
                      
                  public function render()
                      {
                          return 
                  $this->_renderPages($this->getRange());
                      }

                      
                  /**
                       * real rendering method
                       *
                       * @param array $pages an array with page numbers to display
                       */
                      
                  protected function _renderPages(array $pages = array())
                      {
                          if (empty(
                  $pages)) {
                              return 
                  '<div class="paginator empty"></div>';
                          }
                          
                  $html   = array();
                          
                  $html[] = '<div class="paginator">';
                          
                  $html[] = $this->_renderPreviousPage();
                          
                  $html[] = '<div class="pages">';

                          foreach (
                  $pages as $page) {
                              
                  $css null;
                              if (
                  $page == $this->_currentPage) {
                                  
                  $css "current";
                              } elseif (
                  $page == self::DOT_DOT) {
                                  
                  $css "dot-dot";
                              } else {
                                  
                  $css "number";
                              }
                              
                  $html[] = $this->_renderPage($page$page$css);
                          }

                          
                  $html[] = '</div>';
                          
                  $html[] = $this->_renderNextPage();
                          
                  $html[] = '</div>';

                          return 
                  implode(PHP_EOL$html);
                      }

                      
                  /**
                       * restrict to valid page numbers only
                       *
                       * @param  int  $page use integer values only, f.e. int(1); no string-integers like string("1")
                       * @return bool page is valid or not
                       */
                      
                  protected function _isValidPage($page)
                      {
                          return 
                  is_int($page) && <= $page && $page <= $this->_pageCount;
                      }

                      
                  /**
                       * responsible for the html output of the "previous page" label
                       *
                       * @return string html
                       */
                      
                  protected function _renderPreviousPage()
                      {
                          
                  $page  $this->_currentPage 1;
                          
                  $label '<span class="symbol">&laquo;</span>'
                                 
                  '<span class="text">'
                                 
                  htmlspecialchars('zurück')
                                 . 
                  '</span>';
                          return 
                  $this->_renderPage($page$label"previous");
                      }

                      
                  /**
                       * responsible for the html output of the "next page" label
                       *
                       * @return string html
                       */
                      
                  protected function _renderNextPage()
                      {
                          
                  $page  $this->_currentPage 1;
                          
                  $label '<span class="text">'
                                 
                  htmlspecialchars('weiter')
                                 . 
                  '</span>'
                                 
                  '<span class="symbol">&raquo;</span>';
                          return 
                  $this->_renderPage($page$label"next");
                      }

                      
                  /**
                       * responsible for the html output of a specific page label
                       *
                       * @param  int    $page  page number
                       * @param  string $label label of the page
                       * @param  string $css   css class
                       * @return string html
                       */
                      
                  protected function _renderPage($page$label$css null)
                      {
                          
                  $css    = array("page"$css);
                          
                  $css    array_filter($css"mb_strlen");
                          
                  $css    array_unique($css);
                          
                  $css    implode(" "$css);

                          
                  $html   = array();
                          
                  $html[] = '<div class="' $css '">';
                          if (
                  $this->_isValidPage($page)) {
                              
                  $html[] = '<a href="' $this->_getPageUrl($page) . '">';
                          }
                          
                  $html[] = $label;
                          if (
                  $this->_isValidPage($page)) {
                              
                  $html[] = '</a>';
                          }
                          
                  $html[] = '</div>';

                          return 
                  implode($html);
                      }

                      
                  /**
                       * retrieve url for a given page number using defined callback
                       *
                       * @param  int    $page
                       * @return string url/uri
                       */
                      
                  protected function _getPageUrl($page)
                      {
                          if (!
                  is_callable($this->_callback)) {
                              
                  $get         $_GET;
                              
                  $get["page"] = $page;
                              
                  $parsedUrl   parse_url($_SERVER["REQUEST_URI"]);
                              
                  $url         $parsedUrl["path"];
                              return 
                  $url "?" http_build_query($get'''&amp;');
                          }
                          return 
                  call_user_func_array(
                              
                  $this->_callback,
                              
                  array_merge(array($page), $this->_callbackArgs)
                          );
                      }
                  }
                  CSS (unvollständig):
                  Code:
                  div.paginator {
                  	background-image: none;
                  	padding: 0.2em 1em;
                  }
                  
                  div.paginator div.page.previous {
                  	float: left;
                  	width: 10%;	
                  }
                  
                  div.paginator div.pages {
                  	float: left;
                  	width: 80%;
                  	text-align: center;	
                  }
                  
                  div.paginator div.pages div.page a {
                  	padding: 0 1em;
                  }
                  
                  div.paginator div.page.next {
                  	float: right;
                  	width: 10%;
                  	text-align: right;	
                  }
                  
                  div.paginator div.page.current a {
                  	color: white;
                  }
                  
                  div.paginator div.page.number,
                  div.paginator div.page.current {
                  	border: 1px solid transparent;
                  }
                  
                  div.paginator div.page.current {
                  	border-color: silver;
                  	background-color: #005DA8;
                  }
                  
                  div.paginator div.page.previous span.symbol {
                  	padding-right: 0.5em;	
                  }
                  
                  div.paginator div.page.next span.symbol {
                  	padding-left: 0.5em;	
                  }

                  Kommentar

                  Lädt...
                  X