|
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
|
|
|
<<<<<<< HEAD |
|
40
|
|
|
* @param array $project |
|
41
|
|
|
* @param bool $boardView |
|
42
|
|
|
======= |
|
43
|
|
|
* @param array $project |
|
44
|
|
|
* @param bool $boardView |
|
45
|
|
|
>>>>>>> cf0f4459af2fc6f4fa0aac4c6c4655a0abc33333 |
|
46
|
|
|
* |
|
47
|
|
|
* @return string |
|
48
|
|
|
*/ |
|
49
|
|
|
public function render(array $project, $boardView = false) |
|
50
|
|
|
{ |
|
51
|
|
|
<<<<<<< HEAD |
|
|
|
|
|
|
52
|
|
|
|
|
53
|
|
|
return $this->template->render('project/_header/header', [ |
|
54
|
|
|
'project' => $project, |
|
55
|
|
|
'q' => $this->getSearchQuery($project), |
|
56
|
|
|
======= |
|
57
|
|
|
return $this->template->render('project/_header/header', [ |
|
58
|
|
|
'project' => $project, |
|
59
|
|
|
'q' => $this->getSearchQuery($project), |
|
60
|
|
|
>>>>>>> cf0f4459af2fc6f4fa0aac4c6c4655a0abc33333 |
|
61
|
|
|
'board_view' => $boardView, |
|
62
|
|
|
]); |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
/** |
|
66
|
|
|
* Get project description. |
|
67
|
|
|
* |
|
68
|
|
|
* @param array &$project |
|
69
|
|
|
* |
|
70
|
|
|
* @return string |
|
71
|
|
|
*/ |
|
72
|
|
|
public function getDescription(array &$project) |
|
73
|
|
|
{ |
|
74
|
|
|
if ($project['owner_id'] > 0) { |
|
75
|
|
|
$description = t('Project owner: ').'**'.$this->helper->text->e($project['owner_name'] ?: $project['owner_username']).'**'.PHP_EOL.PHP_EOL; |
|
76
|
|
|
|
|
77
|
|
|
if (!empty($project['description'])) { |
|
78
|
|
|
$description .= '***'.PHP_EOL.PHP_EOL; |
|
79
|
|
|
$description .= $project['description']; |
|
80
|
|
|
} |
|
81
|
|
|
} else { |
|
82
|
|
|
$description = $project['description']; |
|
83
|
|
|
} |
|
84
|
|
|
|
|
85
|
|
|
return $description; |
|
86
|
|
|
} |
|
87
|
|
|
} |
|
88
|
|
|
|
The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.