Beispiel #1
0
 /**
  * Build page list.
  * The root node is returned.
  *
  * @return DOMNode
  */
 public function build()
 {
     $pager = new Toolbar('pager');
     if (!empty($_GET)) {
         $this->setProperty('get_string', http_build_query($_GET));
     }
     if (!empty($this->properties)) {
         foreach ($this->properties as $propName => $propValue) {
             $pager->setProperty($propName, $propValue);
         }
     }
     $pager->setProperty('from', translate('TXT_FROM'));
     $pager->setProperty('to', translate('TXT_TO'));
     //$pager->setProperty('total', translate('TXT_TOTAL'));
     $pager->setProperty('records', $this->recordsCount);
     $total = $this->numPages;
     $current = $this->currentPage;
     $visible = self::VISIBLE_PAGES_COUNT;
     $startSeparator = $endSeparator = false;
     for ($i = 1; $i <= $total; $i++) {
         if ($i > $visible && $i < $current - $visible) {
             if (!$startSeparator) {
                 $pager->attachControl(new Separator('sep_start'));
             }
             $startSeparator = true;
             continue;
         } elseif ($i > $current + $visible && $i <= $total - $visible) {
             if (!$endSeparator) {
                 $pager->attachControl(new Separator('sep_end'));
             }
             $endSeparator = true;
             continue;
         } else {
             $control = new Link("page" . $i, $i, $i);
             if ($i == $current) {
                 $control->disable();
             }
             $pager->attachControl($control);
         }
     }
     return $pager->build();
 }