These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | namespace Redaxscript\Navigation; |
||
3 | |||
4 | use Redaxscript\Html; |
||
5 | use Redaxscript\Model; |
||
6 | use Redaxscript\Module; |
||
7 | use Redaxscript\Validator; |
||
8 | |||
9 | /** |
||
10 | * children class to create the comment navigation |
||
11 | * |
||
12 | * @since 3.3.0 |
||
13 | * |
||
14 | * @package Redaxscript |
||
15 | * @category Navigation |
||
16 | * @author Henry Ruhs |
||
17 | */ |
||
18 | |||
19 | class Comment extends NavigationAbstract |
||
20 | { |
||
21 | /** |
||
22 | * options of the navigation |
||
23 | * |
||
24 | * @var array |
||
25 | */ |
||
26 | |||
27 | protected $_optionArray = |
||
28 | [ |
||
29 | 'className' => |
||
30 | [ |
||
31 | 'list' => 'rs-list-comments' |
||
32 | ], |
||
33 | 'orderColumn' => 'rank' |
||
34 | ]; |
||
35 | |||
36 | /** |
||
37 | * render the view |
||
38 | * |
||
39 | * @since 3.3.0 |
||
40 | * |
||
41 | * @return string |
||
42 | */ |
||
43 | |||
44 | 2 | public function render() : string |
|
45 | { |
||
46 | 2 | $output = Module\Hook::trigger('navigationCommentStart'); |
|
47 | 2 | $outputItem = null; |
|
48 | 2 | $commentModel = new Model\Comment(); |
|
49 | 2 | $accessValidator = new Validator\Access(); |
|
50 | |||
51 | /* html element */ |
||
52 | |||
53 | 2 | $element = new Html\Element(); |
|
54 | $listElement = $element |
||
55 | 2 | ->copy() |
|
56 | 2 | ->init('ul', |
|
57 | [ |
||
58 | 2 | 'class' => $this->_optionArray['className']['list'] |
|
59 | ]); |
||
60 | 2 | $itemElement = $element->copy()->init('li'); |
|
61 | 2 | $linkElement = $element->copy()->init('a'); |
|
62 | |||
63 | /* query comments */ |
||
64 | |||
65 | $comments = $commentModel |
||
66 | 2 | ->query() |
|
67 | 2 | ->whereLanguageIs($this->_registry->get('language')) |
|
68 | 2 | ->where('status', 1) |
|
69 | 2 | ->orderBySetting($this->_optionArray['orderColumn']) |
|
70 | 2 | ->limit($this->_optionArray['limit']) |
|
71 | 2 | ->findMany(); |
|
72 | |||
73 | /* collect item output */ |
||
74 | |||
75 | 2 | foreach ($comments as $value) |
|
76 | { |
||
77 | 2 | if ($accessValidator->validate($value->access, $this->_registry->get('myGroups'))) |
|
78 | { |
||
79 | $outputItem .= $itemElement |
||
80 | 2 | ->copy() |
|
81 | 2 | ->html($linkElement |
|
82 | 2 | ->copy() |
|
83 | 2 | ->attr( |
|
84 | [ |
||
85 | 2 | 'href' => $this->_registry->get('parameterRoute') . $commentModel->getRouteById($value->id) |
|
86 | ]) |
||
87 | 2 | ->text($value->author . $this->_language->get('colon') . ' ' . $value->text) |
|
88 | ); |
||
89 | } |
||
90 | } |
||
91 | |||
92 | /* collect output */ |
||
93 | |||
94 | 2 | if ($outputItem) |
|
0 ignored issues
–
show
|
|||
95 | { |
||
96 | 2 | $output .= $listElement->html($outputItem); |
|
97 | } |
||
98 | 2 | $output .= Module\Hook::trigger('navigationCommentEnd'); |
|
99 | 2 | return $output; |
|
100 | } |
||
101 | } |
||
102 |
In PHP, under loose comparison (like
==
, or!=
, orswitch
conditions), values of different types might be equal.For
string
values, the empty string''
is a special case, in particular the following results might be unexpected: