diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/Controller/TaskListController.php | 7 | ||||
-rw-r--r-- | app/Core/Base.php | 1 | ||||
-rw-r--r-- | app/Core/Paginator.php | 65 | ||||
-rw-r--r-- | app/Formatter/TaskListFormatter.php | 30 | ||||
-rw-r--r-- | app/ServiceProvider/FormatterProvider.php | 1 | ||||
-rw-r--r-- | app/Template/task_list/task_details.php | 6 |
6 files changed, 86 insertions, 24 deletions
diff --git a/app/Controller/TaskListController.php b/app/Controller/TaskListController.php index 3f48be85..b3709a18 100644 --- a/app/Controller/TaskListController.php +++ b/app/Controller/TaskListController.php @@ -28,6 +28,7 @@ class TaskListController extends BaseController ->setMax(30) ->setOrder(TaskModel::TABLE.'.id') ->setDirection('DESC') + ->setFormatter($this->taskListFormatter) ->setQuery($this->taskLexer ->build($search) ->withFilter(new TaskProjectFilter($project['id'])) @@ -36,10 +37,10 @@ class TaskListController extends BaseController ->calculate(); $this->response->html($this->helper->layout->app('task_list/listing', array( - 'project' => $project, - 'title' => $project['name'], + 'project' => $project, + 'title' => $project['name'], 'description' => $this->helper->projectHeader->getDescription($project), - 'paginator' => $paginator, + 'paginator' => $paginator, ))); } } 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>'; diff --git a/app/Formatter/TaskListFormatter.php b/app/Formatter/TaskListFormatter.php new file mode 100644 index 00000000..01fbbae0 --- /dev/null +++ b/app/Formatter/TaskListFormatter.php @@ -0,0 +1,30 @@ +<?php + +namespace Kanboard\Formatter; + +use Kanboard\Core\Filter\FormatterInterface; + +/** + * Class TaskListFormatter + * + * @package Kanboard\Formatter + * @author Frederic Guillot + */ +class TaskListFormatter extends BaseFormatter implements FormatterInterface +{ + /** + * Apply formatter + * + * @access public + * @return mixed + */ + public function format() + { + $tasks = $this->query->findAll(); + $taskIds = array_column($tasks, 'id'); + $tags = $this->taskTagModel->getTagsByTasks($taskIds); + array_merge_relation($tasks, $tags, 'tags', 'id'); + + return $tasks; + } +} diff --git a/app/ServiceProvider/FormatterProvider.php b/app/ServiceProvider/FormatterProvider.php index dbba3f3c..a9d25208 100644 --- a/app/ServiceProvider/FormatterProvider.php +++ b/app/ServiceProvider/FormatterProvider.php @@ -28,6 +28,7 @@ class FormatterProvider implements ServiceProviderInterface 'TaskCalendarFormatter', 'TaskGanttFormatter', 'TaskICalFormatter', + 'TaskListFormatter', 'TaskSuggestMenuFormatter', 'UserAutoCompleteFormatter', 'UserMentionFormatter', diff --git a/app/Template/task_list/task_details.php b/app/Template/task_list/task_details.php index 223c52af..eeb5747d 100644 --- a/app/Template/task_list/task_details.php +++ b/app/Template/task_list/task_details.php @@ -20,4 +20,10 @@ <?php endif ?> </span> <?php endif ?> + + <?php foreach ($task['tags'] as $tag): ?> + <span class="table-list-category task-list-tag"> + <?= $this->text->e($tag['name']) ?> + </span> + <?php endforeach ?> </div> |