summaryrefslogtreecommitdiff
path: root/app/Controller
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2015-09-20 22:18:56 -0400
committerFrederic Guillot <fred@kanboard.net>2015-09-20 22:18:56 -0400
commit689687dd4ee186cb9cf5d0230b4648e242c53b10 (patch)
tree3d26bc2079c6eb45790ba604b3a79997be4768ab /app/Controller
parentf579663adcbc0b202d9a068d734e8f9284dc3a37 (diff)
Add formatters
Diffstat (limited to 'app/Controller')
-rw-r--r--app/Controller/App.php4
-rw-r--r--app/Controller/Calendar.php16
-rw-r--r--app/Controller/Gantt.php6
-rw-r--r--app/Controller/Ical.php27
4 files changed, 34 insertions, 19 deletions
diff --git a/app/Controller/App.php b/app/Controller/App.php
index fe1e648c..41be4608 100644
--- a/app/Controller/App.php
+++ b/app/Controller/App.php
@@ -213,7 +213,7 @@ class App extends Base
{
$search = $this->request->getStringParam('term');
- $filter = $this->taskFilter
+ $filter = $this->taskFilterAutoCompleteFormatter
->create()
->filterByProjects($this->projectPermission->getActiveMemberProjectIds($this->userSession->getId()))
->excludeTasks(array($this->request->getIntegerParam('exclude_task_id')));
@@ -226,6 +226,6 @@ class App extends Base
$filter->filterByTitle($search);
}
- $this->response->json($filter->toAutoCompletion());
+ $this->response->json($filter->format());
}
}
diff --git a/app/Controller/Calendar.php b/app/Controller/Calendar.php
index 5ac92622..7050e54b 100644
--- a/app/Controller/Calendar.php
+++ b/app/Controller/Calendar.php
@@ -37,20 +37,20 @@ class Calendar extends Base
$end = $this->request->getStringParam('end');
// Common filter
- $filter = $this->taskFilter
+ $filter = $this->taskFilterCalendarFormatter
->search($this->userSession->getFilters($project_id))
->filterByProject($project_id);
// Tasks
if ($this->config->get('calendar_project_tasks', 'date_started') === 'date_creation') {
- $events = $filter->copy()->filterByCreationDateRange($start, $end)->toDateTimeCalendarEvents('date_creation', 'date_completed');
+ $events = $filter->copy()->filterByCreationDateRange($start, $end)->setColumns('date_creation', 'date_completed')->format();
}
else {
- $events = $filter->copy()->filterByStartDateRange($start, $end)->toDateTimeCalendarEvents('date_started', 'date_completed');
+ $events = $filter->copy()->filterByStartDateRange($start, $end)->setColumns('date_started', 'date_completed')->format();
}
// Tasks with due date
- $events = array_merge($events, $filter->copy()->filterByDueDateRange($start, $end)->toAllDayCalendarEvents());
+ $events = array_merge($events, $filter->copy()->filterByDueDateRange($start, $end)->setColumns('date_due')->setFullDay()->format());
$events = $this->hook->merge('controller:calendar:project:events', $events, array(
'project_id' => $project_id,
@@ -71,17 +71,17 @@ class Calendar extends Base
$user_id = $this->request->getIntegerParam('user_id');
$start = $this->request->getStringParam('start');
$end = $this->request->getStringParam('end');
- $filter = $this->taskFilter->create()->filterByOwner($user_id)->filterByStatus(TaskModel::STATUS_OPEN);
+ $filter = $this->taskFilterCalendarFormatter->create()->filterByOwner($user_id)->filterByStatus(TaskModel::STATUS_OPEN);
// Task with due date
- $events = $filter->copy()->filterByDueDateRange($start, $end)->toAllDayCalendarEvents();
+ $events = $filter->copy()->filterByDueDateRange($start, $end)->setColumns('date_due')->setFullDay()->format();
// Tasks
if ($this->config->get('calendar_user_tasks', 'date_started') === 'date_creation') {
- $events = array_merge($events, $filter->copy()->filterByCreationDateRange($start, $end)->toDateTimeCalendarEvents('date_creation', 'date_completed'));
+ $events = array_merge($events, $filter->copy()->filterByCreationDateRange($start, $end)->setColumns('date_creation', 'date_completed')->format());
}
else {
- $events = array_merge($events, $filter->copy()->filterByStartDateRange($start, $end)->toDateTimeCalendarEvents('date_started', 'date_completed'));
+ $events = array_merge($events, $filter->copy()->filterByStartDateRange($start, $end)->setColumns('date_started', 'date_completed')->format());
}
// Subtasks time tracking
diff --git a/app/Controller/Gantt.php b/app/Controller/Gantt.php
index a2d3f363..879ab377 100644
--- a/app/Controller/Gantt.php
+++ b/app/Controller/Gantt.php
@@ -25,7 +25,7 @@ class Gantt extends Base
}
$this->response->html($this->template->layout('gantt/projects', array(
- 'projects' => $this->project->getGanttBars($project_ids),
+ 'projects' => $this->projectGanttFormatter->filter($project_ids)->format(),
'title' => t('Gantt chart for all projects'),
'board_selector' => $this->projectPermission->getAllowedProjects($this->userSession->getId()),
)));
@@ -57,7 +57,7 @@ class Gantt extends Base
public function project()
{
$params = $this->getProjectFilters('gantt', 'project');
- $filter = $this->taskFilter->search($params['filters']['search'])->filterByProject($params['project']['id']);
+ $filter = $this->taskFilterGanttFormatter->search($params['filters']['search'])->filterByProject($params['project']['id']);
$sorting = $this->request->getStringParam('sorting', 'board');
if ($sorting === 'date') {
@@ -70,7 +70,7 @@ class Gantt extends Base
$this->response->html($this->template->layout('gantt/project', $params + array(
'users_list' => $this->projectPermission->getMemberList($params['project']['id'], false),
'sorting' => $sorting,
- 'tasks' => $filter->toGanttBars(),
+ 'tasks' => $filter->format(),
)));
}
diff --git a/app/Controller/Ical.php b/app/Controller/Ical.php
index 0129915e..e89b7e38 100644
--- a/app/Controller/Ical.php
+++ b/app/Controller/Ical.php
@@ -29,7 +29,7 @@ class Ical extends Base
}
// Common filter
- $filter = $this->taskFilter
+ $filter = $this->taskFilterICalendarFormatter
->create()
->filterByOwner($user['id']);
@@ -58,7 +58,7 @@ class Ical extends Base
}
// Common filter
- $filter = $this->taskFilter
+ $filter = $this->taskFilterICalendarFormatter
->create()
->filterByProject($project['id']);
@@ -83,16 +83,31 @@ class Ical extends Base
// Tasks
if ($this->config->get('calendar_project_tasks', 'date_started') === 'date_creation') {
- $filter->copy()->filterByCreationDateRange($start, $end)->addDateTimeIcalEvents('date_creation', 'date_completed', $calendar);
+ $filter
+ ->copy()
+ ->filterByCreationDateRange($start, $end)
+ ->setColumns('date_creation', 'date_completed')
+ ->setCalendar($calendar)
+ ->addDateTimeEvents();
}
else {
- $filter->copy()->filterByStartDateRange($start, $end)->addDateTimeIcalEvents('date_started', 'date_completed', $calendar);
+ $filter
+ ->copy()
+ ->filterByStartDateRange($start, $end)
+ ->setColumns('date_started', 'date_completed')
+ ->setCalendar($calendar)
+ ->addDateTimeEvents($calendar);
}
// Tasks with due date
- $filter->copy()->filterByDueDateRange($start, $end)->addAllDayIcalEvents('date_due', $calendar);
+ $filter
+ ->copy()
+ ->filterByDueDateRange($start, $end)
+ ->setColumns('date_due')
+ ->setCalendar($calendar)
+ ->addFullDayEvents($calendar);
$this->response->contentType('text/calendar; charset=utf-8');
- echo $calendar->render();
+ echo $filter->setCalendar($calendar)->format();
}
}