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\View; |
||
3 | |||
4 | use Redaxscript\Dater; |
||
5 | use Redaxscript\Html; |
||
6 | use Redaxscript\Model; |
||
7 | use Redaxscript\Module; |
||
8 | use Redaxscript\Validator; |
||
9 | |||
10 | /** |
||
11 | * children class to create the result list |
||
12 | * |
||
13 | * @since 3.0.0 |
||
14 | * |
||
15 | * @package Redaxscript |
||
16 | * @category View |
||
17 | * @author Henry Ruhs |
||
18 | * @author Balázs Szilágyi |
||
19 | */ |
||
20 | |||
21 | class ResultList extends ViewAbstract |
||
22 | { |
||
23 | /** |
||
24 | * render the view |
||
25 | * |
||
26 | * @since 3.0.0 |
||
27 | * |
||
28 | * @param array $resultArray array for the result |
||
29 | * |
||
30 | * @return string |
||
31 | */ |
||
32 | |||
33 | 4 | public function render(array $resultArray = []) : string |
|
34 | { |
||
35 | 4 | $output = Module\Hook::trigger('resultListStart'); |
|
36 | 4 | $accessValidator = new Validator\Access(); |
|
37 | 4 | $contentModel = new Model\Content(); |
|
38 | 4 | $dater = new Dater(); |
|
39 | 4 | $parameterRoute = $this->_registry->get('parameterRoute'); |
|
40 | |||
41 | /* html element */ |
||
42 | |||
43 | 4 | $element = new Html\Element(); |
|
44 | $titleElement = $element |
||
45 | 4 | ->copy() |
|
46 | 4 | ->init('h2', |
|
47 | [ |
||
48 | 4 | 'class' => 'rs-title-result' |
|
49 | ]); |
||
50 | $listElement = $element |
||
51 | 4 | ->copy() |
|
52 | 4 | ->init('ol', |
|
53 | [ |
||
54 | 4 | 'class' => 'rs-list-result' |
|
55 | ]); |
||
56 | 4 | $itemElement = $element->copy()->init('li'); |
|
57 | $linkElement = $element |
||
58 | 4 | ->copy() |
|
59 | 4 | ->init('a', |
|
60 | [ |
||
61 | 4 | 'class' => 'rs-link-result' |
|
62 | ]); |
||
63 | $textElement = $element |
||
64 | 4 | ->copy() |
|
65 | 4 | ->init('span', |
|
66 | [ |
||
67 | 4 | 'class' => 'rs-text-result-date' |
|
68 | ]); |
||
69 | |||
70 | /* process results */ |
||
71 | |||
72 | 4 | foreach ($resultArray as $table => $result) |
|
73 | { |
||
74 | 4 | $outputItem = null; |
|
75 | 4 | if ($result) |
|
76 | { |
||
77 | /* collect item output */ |
||
78 | |||
79 | 4 | foreach ($result as $value) |
|
80 | { |
||
81 | 4 | if ($accessValidator->validate($result->access, $this->_registry->get('myGroups'))) |
|
82 | { |
||
83 | 4 | $dater->init($value->date); |
|
84 | $linkElement |
||
85 | 4 | ->attr('href', $parameterRoute . $contentModel->getRouteByTableAndId($table, $value->id)) |
|
86 | 4 | ->text($value->title ? : $value->author); |
|
87 | 4 | $textElement->text($dater->formatDate()); |
|
88 | 4 | $outputItem .= $itemElement->html($linkElement . $textElement); |
|
89 | } |
||
90 | } |
||
91 | |||
92 | /* collect output */ |
||
93 | |||
94 | 4 | if ($outputItem) |
|
0 ignored issues
–
show
|
|||
95 | { |
||
96 | 4 | $titleElement->text($this->_language->get($table)); |
|
97 | 4 | $listElement->html($outputItem); |
|
98 | 4 | $output .= $titleElement . $listElement; |
|
99 | } |
||
100 | } |
||
101 | } |
||
102 | 4 | $output .= Module\Hook::trigger('resultListEnd'); |
|
103 | 4 | return $output; |
|
104 | } |
||
105 | } |
||
106 |
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: