1
|
|
|
<?php |
2
|
|
|
namespace Redaxscript\Navigation; |
3
|
|
|
|
4
|
|
|
use Redaxscript\Filesystem; |
5
|
|
|
use Redaxscript\Html; |
6
|
|
|
use Redaxscript\Module; |
7
|
|
|
|
8
|
|
|
/** |
9
|
|
|
* children class to create the language navigation |
10
|
|
|
* |
11
|
|
|
* @since 3.3.0 |
12
|
|
|
* |
13
|
|
|
* @package Redaxscript |
14
|
|
|
* @category Navigation |
15
|
|
|
* @author Henry Ruhs |
16
|
|
|
*/ |
17
|
|
|
|
18
|
|
|
class Template extends NavigationAbstract |
19
|
|
|
{ |
20
|
|
|
/** |
21
|
|
|
* options of the navigation |
22
|
|
|
* |
23
|
|
|
* @var array |
24
|
|
|
*/ |
25
|
|
|
|
26
|
|
|
protected $_optionArray = |
27
|
|
|
[ |
28
|
|
|
'className' => |
29
|
|
|
[ |
30
|
|
|
'list' => 'rs-list-templates', |
31
|
|
|
'active' => 'rs-item-active' |
32
|
|
|
] |
33
|
|
|
]; |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* render the view |
37
|
|
|
* |
38
|
|
|
* @since 3.3.0 |
39
|
|
|
* |
40
|
|
|
* @return string |
41
|
|
|
*/ |
42
|
|
|
|
43
|
3 |
|
public function render() : string |
44
|
|
|
{ |
45
|
3 |
|
$output = Module\Hook::trigger('navigationTemplateStart'); |
46
|
3 |
|
$outputItem = null; |
47
|
|
|
|
48
|
|
|
/* html element */ |
49
|
|
|
|
50
|
3 |
|
$element = new Html\Element(); |
51
|
|
|
$listElement = $element |
52
|
3 |
|
->copy() |
53
|
3 |
|
->init('ul', |
54
|
|
|
[ |
55
|
3 |
|
'class' => $this->_optionArray['className']['list'] |
56
|
|
|
]); |
57
|
3 |
|
$itemElement = $element->copy()->init('li'); |
58
|
3 |
|
$linkElement = $element->copy()->init('a'); |
59
|
3 |
|
$textElement = $element->copy()->init('span'); |
60
|
|
|
|
61
|
|
|
/* template directory */ |
62
|
|
|
|
63
|
3 |
|
$templateFilesystem = new Filesystem\Filesystem(); |
64
|
3 |
|
$templateFilesystem->init('templates', false, |
65
|
|
|
[ |
66
|
3 |
|
'admin', |
67
|
|
|
'console', |
68
|
|
|
'install' |
69
|
|
|
]); |
70
|
3 |
|
$templateFilesystemArray = $templateFilesystem->getSortArray(); |
71
|
|
|
|
72
|
|
|
/* collect item output */ |
73
|
|
|
|
74
|
3 |
|
foreach ($templateFilesystemArray as $value) |
75
|
|
|
{ |
76
|
|
|
$outputItem .= $itemElement |
77
|
3 |
|
->copy() |
78
|
3 |
|
->addClass($this->_registry->get('template') === $value ? $this->_optionArray['className']['active'] : null) |
79
|
3 |
|
->html($linkElement |
80
|
3 |
|
->copy() |
81
|
3 |
|
->attr( |
82
|
|
|
[ |
83
|
3 |
|
'href' => $this->_registry->get('parameterRoute') . $this->_registry->get('fullRoute') . $this->_registry->get('templateRoute') . $value, |
84
|
3 |
|
'rel' => 'nofollow' |
85
|
|
|
]) |
86
|
3 |
|
->text($value) |
87
|
|
|
); |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
/* collect output */ |
91
|
|
|
|
92
|
3 |
|
$output .= $listElement->html($outputItem ? : $itemElement->html($textElement->text($this->_language->get('template_no')))); |
|
|
|
|
93
|
3 |
|
$output .= Module\Hook::trigger('navigationTemplateEnd'); |
94
|
3 |
|
return $output; |
95
|
|
|
} |
96
|
|
|
} |
97
|
|
|
|
This check looks at variables that are passed out again to other methods.
If the outgoing method call has stricter type requirements than the method itself, an issue is raised.
An additional type check may prevent trouble.