コード例 #1
0
ファイル: Link.php プロジェクト: deltasystems/dewdrop
 public function __invoke(FieldInterface $field)
 {
     $field->addHelperFilter('TableCell.Content', function ($content, TableCell $helper, array $rowData, $rowIndex, $columnIndex) {
         if (!$content) {
             return null;
         }
         if (!$this->urlTemplate || !isset($rowData[$this->id]) || !$rowData[$this->id]) {
             return $content;
         } else {
             $node = new Node('a');
             $node->setHtml($content)->setAttribute('href', sprintf($this->urlTemplate, $rowData[$this->id]))->setAttribute('class', implode(' ', $this->cssClasses));
             if ($this->title) {
                 $node->setAttribute('title', $this->title);
             }
             if ($this->target) {
                 $node->setAttribute('target', $this->target);
             }
             return $node;
         }
     });
 }
コード例 #2
0
ファイル: Pagination.php プロジェクト: deltasystems/dewdrop
 /**
  * Render pagination.
  *
  * @param integer $rowCount The total number of records available.
  * @param integer $pageSize The number of records to show on each page.
  * @param integer $page The currently selected page.
  * @param string $title The title to use in the record count.
  * @return string
  */
 public function direct($rowCount, $pageSize, $page, $title = 'Records')
 {
     $pageCount = ceil($rowCount / $pageSize);
     $node = Node::create('div')->addClass('dewdrop-pagination')->addClass('text-center');
     $out = '';
     if ($rowCount > $pageSize) {
         $out .= "<div class=\"page-current-of-all\">Page {$page} of {$pageCount}</div>" . '<ul class="pagination">';
         $out .= '<li' . ($page > 1 ? '' : ' class="disabled"') . '><a href="' . $this->url($page - 1) . '">&laquo; Previous</a></li>';
         $j = 0;
         for ($i = 1; $i <= $pageCount; $i++) {
             $display = false;
             if ($page < 7 && $i <= 10) {
                 // Current page is in the first 6, show the first 10 pages
                 $display = true;
             } elseif ($page > $pageCount - 6 && $i >= $pageCount - 10) {
                 // Current page is in the last 6, show the last 10 pages
                 $display = true;
             } elseif ($i < 3 || $i > $pageCount - 2 || abs($page - $i) <= 3) {
                 // Always show the first 2, last 2, and middle 6 pages
                 $display = true;
             }
             if ($display) {
                 if ($j + 1 !== $i) {
                     // ellipses
                     $out .= '<li class="disabled"><a href="#">...</a></li>';
                 }
                 $out .= '<li' . ($i === $page ? ' class="disabled"' : '') . '><a href="' . $this->url($i) . "\">{$i}</a></li>";
                 $j = $i;
             }
         }
         $out .= '<li' . ($page < $pageCount ? '' : ' class="disabled"') . '><a href="' . $this->url($page + 1) . '">Next &raquo;</a></li>';
         $out .= '</ul>';
     }
     $out .= sprintf('<div class="row-count">%d %s</div>', (int) $rowCount, $this->view->escapeHtml($title));
     $node->setHtml($out);
     return $node;
 }
コード例 #3
0
 /**
  * Render a filter form using the supplied Fields, SelectFilter and title.
  * By default, this form will use GET so that it geneates a query string
  * that can be used to share search results, but you can use POST if needed
  * for your case.
  *
  * @param Fields $fields
  * @param SelectFilter $selectFilter
  * @param string $title
  * @param string $method
  * @return string
  */
 public function directWithArgs(Fields $fields, SelectFilter $selectFilter, $title, $method = 'GET')
 {
     return Node::create('form')->addClass('filter-form')->setAttribute('data-prefix', $selectFilter->getPrefix())->setAttribute('action', '')->setAttribute('method', $method)->setHtml($this->partial('bootstrap-filter-form.phtml', ['controls' => $this->inline($fields, $selectFilter, $title, $method, true)]));
 }