1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
<?php
namespace Kanboard\Formatter;
use Kanboard\Core\Filter\FormatterInterface;
/**
* Calendar event formatter for task filter
*
* @package formatter
* @author Frederic Guillot
*/
class TaskCalendarFormatter extends BaseTaskCalendarFormatter implements FormatterInterface
{
/**
* Full day event flag
*
* @access private
* @var boolean
*/
private $fullDay = false;
/**
* When called calendar events will be full day
*
* @access public
* @return FormatterInterface
*/
public function setFullDay()
{
$this->fullDay = true;
return $this;
}
/**
* Transform tasks to calendar events
*
* @access public
* @return array
*/
public function format()
{
$events = array();
foreach ($this->query->findAll() as $task) {
$events[] = array(
'timezoneParam' => $this->timezone->getCurrentTimezone(),
'id' => $task['id'],
'title' => t('#%d', $task['id']).' '.$task['title'],
'backgroundColor' => $this->color->getBackgroundColor($task['color_id']),
'borderColor' => $this->color->getBorderColor($task['color_id']),
'textColor' => 'black',
'url' => $this->helper->url->to('TaskViewController', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id'])),
'start' => date($this->getDateTimeFormat(), $task[$this->startColumn]),
'end' => date($this->getDateTimeFormat(), $task[$this->endColumn] ?: time()),
'editable' => $this->fullDay,
'allday' => $this->fullDay,
);
}
return $events;
}
/**
* Get DateTime format for event
*
* @access private
* @return string
*/
private function getDateTimeFormat()
{
return $this->fullDay ? 'Y-m-d' : 'Y-m-d\TH:i:s';
}
}
|