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
|
|
|
* Project Header Helper. |
18
|
|
|
*/ |
19
|
|
|
class ProjectHeaderHelper extends Base |
20
|
|
|
{ |
21
|
|
|
/** |
22
|
|
|
* Get current query. |
23
|
|
|
* |
24
|
|
|
* @param array $project |
25
|
|
|
* |
26
|
|
|
* @return string |
27
|
|
|
*/ |
28
|
|
|
public function getSearchQuery(array $project) |
29
|
|
|
{ |
30
|
|
|
$query = $this->request->getStringParam('q', $this->userSession->getFilters($project['id'])); |
|
|
|
|
31
|
|
|
$this->userSession->setFilters($project['id'], $query); |
|
|
|
|
32
|
|
|
|
33
|
|
|
return urldecode($query); |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* Render project header (views switcher and search box). |
38
|
|
|
* |
39
|
|
|
* @param array $project |
40
|
|
|
* @param bool $boardView |
41
|
|
|
* |
42
|
|
|
* @return string |
43
|
|
|
*/ |
44
|
|
|
public function render(array $project, $boardView = false) |
45
|
|
|
{ |
46
|
|
|
return $this->template->render('project/_header/header', [ |
|
|
|
|
47
|
|
|
'project' => $project, |
48
|
|
|
'q' => $this->getSearchQuery($project), |
49
|
|
|
'board_view' => $boardView, |
50
|
|
|
]); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* Get project description. |
55
|
|
|
* |
56
|
|
|
* @param array &$project |
57
|
|
|
* |
58
|
|
|
* @return string |
59
|
|
|
*/ |
60
|
|
|
public function getDescription(array &$project) |
61
|
|
|
{ |
62
|
|
|
if ($project['owner_id'] > 0) { |
63
|
|
|
$description = t('Project owner: ').'**'.$this->helper->text->e($project['owner_name'] ?: $project['owner_username']).'**'.PHP_EOL.PHP_EOL; |
|
|
|
|
64
|
|
|
|
65
|
|
|
if (!empty($project['description'])) { |
66
|
|
|
$description .= '***'.PHP_EOL.PHP_EOL; |
67
|
|
|
$description .= $project['description']; |
68
|
|
|
} |
69
|
|
|
} else { |
70
|
|
|
$description = $project['description']; |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
return $description; |
74
|
|
|
} |
75
|
|
|
} |
76
|
|
|
|
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.