1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of Jitamin. |
5
|
|
|
* |
6
|
|
|
* Copyright (C) Jitamin Team |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace Jitamin\Helper; |
13
|
|
|
|
14
|
|
|
use Jitamin\Foundation\Base; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* Subtask helpers. |
18
|
|
|
*/ |
19
|
|
|
class SubtaskHelper extends Base |
20
|
|
|
{ |
21
|
|
|
/** |
22
|
|
|
* Get the title. |
23
|
|
|
* |
24
|
|
|
* @param array $subtask |
25
|
|
|
* |
26
|
|
|
* @return string |
27
|
|
|
*/ |
28
|
|
|
public function getTitle(array $subtask) |
29
|
|
|
{ |
30
|
|
|
if ($subtask['status'] == 0) { |
31
|
|
|
$html = '<i class="fa fa-square-o fa-fw" title="'.t('Backlog').'"></i>'; |
32
|
|
|
} elseif ($subtask['status'] == 1) { |
33
|
|
|
$html = '<i class="fa fa-caret-square-o-right fa-fw" title="'.t('Work in progress').'"></i>'; |
34
|
|
|
} else { |
35
|
|
|
$html = '<i class="fa fa-check-square-o fa-fw" title="'.t('Done').'"></i>'; |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
return $html.$this->helper->text->e($subtask['title']); |
|
|
|
|
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* Get the link to toggle subtask status. |
43
|
|
|
* |
44
|
|
|
* @param array $subtask |
45
|
|
|
* @param int $project_id |
46
|
|
|
* @param bool $refresh_table |
47
|
|
|
* |
48
|
|
|
* @return string |
49
|
|
|
*/ |
50
|
|
|
public function toggleStatus(array $subtask, $project_id, $refresh_table = false) |
51
|
|
|
{ |
52
|
|
|
if (!$this->helper->user->hasProjectAccess('Task/Subtask/SubtaskController', 'edit', $project_id)) { |
|
|
|
|
53
|
|
|
return $this->getTitle($subtask); |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
$params = ['task_id' => $subtask['task_id'], 'subtask_id' => $subtask['id'], 'refresh-table' => (int) $refresh_table]; |
57
|
|
|
|
58
|
|
|
if ($subtask['status'] == 0 && isset($this->sessionStorage->hasSubtaskInProgress) && $this->sessionStorage->hasSubtaskInProgress) { |
|
|
|
|
59
|
|
|
return $this->helper->url->link($this->getTitle($subtask), 'Task/Subtask/SubtaskRestrictionController', 'show', $params, false, 'popover'); |
|
|
|
|
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
$class = 'subtask-toggle-status '.($refresh_table ? 'subtask-refresh-table' : ''); |
63
|
|
|
|
64
|
|
|
return $this->helper->url->link($this->getTitle($subtask), 'Task/Subtask/SubtaskStatusController', 'change', $params, false, $class); |
|
|
|
|
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* Display a select field of title. |
69
|
|
|
* |
70
|
|
|
* @param array $values Form values |
71
|
|
|
* @param array $errors Form errors |
72
|
|
|
* @param array $attributes |
73
|
|
|
* |
74
|
|
|
* @return string |
75
|
|
|
*/ |
76
|
|
|
public function selectTitle(array $values, array $errors = [], array $attributes = []) |
77
|
|
|
{ |
78
|
|
|
$attributes = array_merge(['tabindex="1"', 'required', 'maxlength="255"'], $attributes); |
79
|
|
|
|
80
|
|
|
$html = $this->helper->form->label(t('Title'), 'title'); |
|
|
|
|
81
|
|
|
$html .= $this->helper->form->text('title', $values, $errors, $attributes); |
|
|
|
|
82
|
|
|
|
83
|
|
|
return $html; |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* Display a select field of assignee. |
88
|
|
|
* |
89
|
|
|
* @param array $values Form values |
90
|
|
|
* @param array $errors Form errors |
91
|
|
|
* @param array $attributes |
92
|
|
|
* |
93
|
|
|
* @return string |
94
|
|
|
*/ |
95
|
|
View Code Duplication |
public function selectAssignee(array $users, array $values, array $errors = [], array $attributes = []) |
|
|
|
|
96
|
|
|
{ |
97
|
|
|
$attributes = array_merge(['tabindex="2"'], $attributes); |
98
|
|
|
|
99
|
|
|
$html = $this->helper->form->label(t('Assignee'), 'user_id'); |
|
|
|
|
100
|
|
|
$html .= $this->helper->form->select('user_id', $users, $values, $errors, $attributes); |
|
|
|
|
101
|
|
|
$html .= ' '; |
102
|
|
|
$html .= '<small>'; |
103
|
|
|
$html .= '<a href="#" class="assign-me" data-target-id="form-user_id" data-current-id="'.$this->userSession->getId().'" title="'.t('Assign to me').'">'.t('Me').'</a>'; |
|
|
|
|
104
|
|
|
$html .= '</small>'; |
105
|
|
|
|
106
|
|
|
return $html; |
107
|
|
|
} |
108
|
|
|
|
109
|
|
|
/** |
110
|
|
|
* Display a select field of time estimated. |
111
|
|
|
* |
112
|
|
|
* @param array $values Form values |
113
|
|
|
* @param array $errors Form errors |
114
|
|
|
* @param array $attributes |
115
|
|
|
* |
116
|
|
|
* @return string |
117
|
|
|
*/ |
118
|
|
View Code Duplication |
public function selectTimeEstimated(array $values, array $errors = [], array $attributes = []) |
|
|
|
|
119
|
|
|
{ |
120
|
|
|
$attributes = array_merge(['tabindex="3"'], $attributes); |
121
|
|
|
|
122
|
|
|
$html = $this->helper->form->label(t('Original estimate'), 'time_estimated'); |
|
|
|
|
123
|
|
|
$html .= $this->helper->form->numeric('time_estimated', $values, $errors, $attributes); |
|
|
|
|
124
|
|
|
$html .= ' '.t('hours'); |
125
|
|
|
|
126
|
|
|
return $html; |
127
|
|
|
} |
128
|
|
|
|
129
|
|
|
/** |
130
|
|
|
* Display a select field of time spent. |
131
|
|
|
* |
132
|
|
|
* @param array $values Form values |
133
|
|
|
* @param array $errors Form errors |
134
|
|
|
* @param array $attributes |
135
|
|
|
* |
136
|
|
|
* @return string |
137
|
|
|
*/ |
138
|
|
View Code Duplication |
public function selectTimeSpent(array $values, array $errors = [], array $attributes = []) |
|
|
|
|
139
|
|
|
{ |
140
|
|
|
$attributes = array_merge(['tabindex="4"'], $attributes); |
141
|
|
|
|
142
|
|
|
$html = $this->helper->form->label(t('Time spent'), 'time_spent'); |
|
|
|
|
143
|
|
|
$html .= $this->helper->form->numeric('time_spent', $values, $errors, $attributes); |
|
|
|
|
144
|
|
|
$html .= ' '.t('hours'); |
145
|
|
|
|
146
|
|
|
return $html; |
147
|
|
|
} |
148
|
|
|
} |
149
|
|
|
|
Since your code implements the magic getter
_get
, this function will be called for any read access on an undefined variable. You can add the@property
annotation to your class or interface to document the existence of this variable.If the property has read access only, you can use the @property-read annotation instead.
Of course, you may also just have mistyped another name, in which case you should fix the error.
See also the PhpDoc documentation for @property.