diff options
author | Frederic Guillot <fred@kanboard.net> | 2017-02-26 15:18:49 -0500 |
---|---|---|
committer | Frederic Guillot <fred@kanboard.net> | 2017-02-26 15:18:49 -0500 |
commit | 4a87fb34ba0a88303282923a73a8fef83d7aada3 (patch) | |
tree | 885aab3106a89130fea3aa83e4fe97526a37e43d /app/Core | |
parent | 9bcf97a6c9110afd62b542b92d07d27f945eda96 (diff) |
Display tags in task list view
Diffstat (limited to 'app/Core')
-rw-r--r-- | app/Core/Base.php | 1 | ||||
-rw-r--r-- | app/Core/Paginator.php | 65 |
2 files changed, 45 insertions, 21 deletions
diff --git a/app/Core/Base.php b/app/Core/Base.php index 17ed5b33..3cc5199a 100644 --- a/app/Core/Base.php +++ b/app/Core/Base.php @@ -74,6 +74,7 @@ use Pimple\Container; * @property \Kanboard\Formatter\TaskCalendarFormatter $taskCalendarFormatter * @property \Kanboard\Formatter\TaskGanttFormatter $taskGanttFormatter * @property \Kanboard\Formatter\TaskICalFormatter $taskICalFormatter + * @property \Kanboard\Formatter\TaskListFormatter $taskListFormatter * @property \Kanboard\Formatter\TaskSuggestMenuFormatter $taskSuggestMenuFormatter * @property \Kanboard\Formatter\UserAutoCompleteFormatter $userAutoCompleteFormatter * @property \Kanboard\Formatter\UserMentionFormatter $userMentionFormatter diff --git a/app/Core/Paginator.php b/app/Core/Paginator.php index 9075a713..e724ccd4 100644 --- a/app/Core/Paginator.php +++ b/app/Core/Paginator.php @@ -2,13 +2,14 @@ namespace Kanboard\Core; +use Kanboard\Core\Filter\FormatterInterface; use Pimple\Container; use PicoDb\Table; /** - * Paginator helper + * Paginator Helper * - * @package core + * @package Kanboard\Core * @author Frederic Guillot */ class Paginator @@ -110,6 +111,11 @@ class Paginator private $params = array(); /** + * @var FormatterInterface + */ + protected $formatter = null; + + /** * Constructor * * @access public @@ -125,7 +131,7 @@ class Paginator * * @access public * @param \PicoDb\Table - * @return Paginator + * @return $this */ public function setQuery(Table $query) { @@ -135,6 +141,18 @@ class Paginator } /** + * Set Formatter + * + * @param FormatterInterface $formatter + * @return $this + */ + public function setFormatter(FormatterInterface $formatter) + { + $this->formatter = $formatter; + return $this; + } + + /** * Execute a PicoDb query * * @access public @@ -143,11 +161,16 @@ class Paginator public function executeQuery() { if ($this->query !== null) { - return $this->query - ->offset($this->offset) - ->limit($this->limit) - ->orderBy($this->order, $this->direction) - ->findAll(); + $this->query + ->offset($this->offset) + ->limit($this->limit) + ->orderBy($this->order, $this->direction); + + if ($this->formatter !== null) { + return $this->formatter->withQuery($this->query)->format(); + } else { + return $this->query->findAll(); + } } return array(); @@ -160,7 +183,7 @@ class Paginator * @param string $controller * @param string $action * @param array $params - * @return Paginator + * @return $this */ public function setUrl($controller, $action, array $params = array()) { @@ -175,7 +198,7 @@ class Paginator * * @access public * @param array $items - * @return Paginator + * @return $this */ public function setCollection(array $items) { @@ -199,7 +222,7 @@ class Paginator * * @access public * @param integer $total - * @return Paginator + * @return $this */ public function setTotal($total) { @@ -223,7 +246,7 @@ class Paginator * * @access public * @param integer $page - * @return Paginator + * @return $this */ public function setPage($page) { @@ -247,7 +270,7 @@ class Paginator * * @access public * @param string $order - * @return Paginator + * @return $this */ public function setOrder($order) { @@ -260,7 +283,7 @@ class Paginator * * @access public * @param string $direction - * @return Paginator + * @return $this */ public function setDirection($direction) { @@ -273,7 +296,7 @@ class Paginator * * @access public * @param integer $limit - * @return Paginator + * @return $this */ public function setMax($limit) { @@ -307,7 +330,7 @@ class Paginator * * @access public * @param boolean $condition - * @return Paginator + * @return $this */ public function calculateOnlyIf($condition) { @@ -322,7 +345,7 @@ class Paginator * Calculate the offset value accoring to url params and the page number * * @access public - * @return Paginator + * @return $this */ public function calculate() { @@ -421,7 +444,7 @@ class Paginator * @access public * @return string */ - public function generatPageShowing() + public function generatePageShowing() { return '<span class="pagination-showing">'.t('Showing %d-%d of %d', (($this->getPage() - 1) * $this->getMax() + 1), min($this->getTotal(), $this->getPage() * $this->getMax()), $this->getTotal()).'</span>'; } @@ -432,7 +455,7 @@ class Paginator * @access public * @return boolean */ - public function hasNothingtoShow() + public function hasNothingToShow() { return $this->offset === 0 && ($this->total - $this->offset) <= $this->limit; } @@ -447,9 +470,9 @@ class Paginator { $html = ''; - if (! $this->hasNothingtoShow()) { + if (! $this->hasNothingToShow()) { $html .= '<div class="pagination">'; - $html .= $this->generatPageShowing(); + $html .= $this->generatePageShowing(); $html .= $this->generatePreviousLink(); $html .= $this->generateNextLink(); $html .= '</div>'; |