|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace AbterPhp\Website\Template\Builder\ContentList; |
|
6
|
|
|
|
|
7
|
|
|
use AbterPhp\Framework\Constant\Html5; |
|
8
|
|
|
use AbterPhp\Framework\Template\IBuilder; |
|
9
|
|
|
use AbterPhp\Framework\Template\ParsedTemplate; |
|
10
|
|
|
|
|
11
|
|
|
class Base |
|
12
|
|
|
{ |
|
13
|
|
|
protected $defaultListTag = Html5::TAG_UL; |
|
14
|
|
|
protected $defaultItemTag = Html5::TAG_LI; |
|
15
|
|
|
protected $defaultLabelTag = ''; |
|
16
|
|
|
protected $defaultContentTag = ''; |
|
17
|
|
|
protected $defaultImageTag = ''; |
|
18
|
|
|
|
|
19
|
|
|
protected $defaultListClass = 'list-unknown'; |
|
20
|
|
|
protected $defaultItemClass = 'list-item'; |
|
21
|
|
|
protected $defaultLabelClass = 'list-item-label'; |
|
22
|
|
|
protected $defaultContentClass = 'list-item-content'; |
|
23
|
|
|
protected $defaultImageClass = 'list-item-image'; |
|
24
|
|
|
|
|
25
|
|
|
protected $defaultWithLabel = '0'; |
|
26
|
|
|
protected $defaultWithImage = '0'; |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* @param ParsedTemplate|null $template |
|
30
|
|
|
* |
|
31
|
|
|
* @return <string,string> |
|
|
|
|
|
|
32
|
|
|
*/ |
|
33
|
|
|
protected function getWrapperTags(?ParsedTemplate $template = null): array |
|
34
|
|
|
{ |
|
35
|
|
|
if (!$template) { |
|
36
|
|
|
return [ |
|
37
|
|
|
IBuilder::LIST_TAG => $this->defaultListTag, |
|
38
|
|
|
IBuilder::ITEM_TAG => $this->defaultItemTag, |
|
39
|
|
|
IBuilder::LABEL_TAG => $this->defaultLabelTag, |
|
40
|
|
|
IBuilder::CONTENT_TAG => $this->defaultContentTag, |
|
41
|
|
|
IBuilder::IMAGE_TAG => $this->defaultImageTag, |
|
42
|
|
|
]; |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
$listTag = $template->getAttribute(static::LIST_TAG, $this->defaultListTag); |
|
|
|
|
|
|
46
|
|
|
$itemTag = $template->getAttribute(static::ITEM_TAG, $this->defaultItemTag); |
|
|
|
|
|
|
47
|
|
|
$labelTag = $template->getAttribute(static::LABEL_TAG, $this->defaultLabelTag); |
|
|
|
|
|
|
48
|
|
|
$contentTag = $template->getAttribute(static::CONTENT_TAG, $this->defaultContentTag); |
|
|
|
|
|
|
49
|
|
|
$imageTag = $template->getAttribute(static::IMAGE_TAG, $this->defaultImageTag); |
|
|
|
|
|
|
50
|
|
|
|
|
51
|
|
|
return [ |
|
52
|
|
|
IBuilder::LIST_TAG => $listTag, |
|
53
|
|
|
IBuilder::ITEM_TAG => $itemTag, |
|
54
|
|
|
IBuilder::LABEL_TAG => $labelTag, |
|
55
|
|
|
IBuilder::CONTENT_TAG => $contentTag, |
|
56
|
|
|
IBuilder::IMAGE_TAG => $imageTag, |
|
57
|
|
|
]; |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
/** |
|
61
|
|
|
* @param ParsedTemplate|null $template |
|
62
|
|
|
* |
|
63
|
|
|
* @return <string,string> |
|
|
|
|
|
|
64
|
|
|
*/ |
|
65
|
|
|
protected function getWrapperClasses(?ParsedTemplate $template = null): array |
|
66
|
|
|
{ |
|
67
|
|
|
if (!$template) { |
|
68
|
|
|
return [ |
|
69
|
|
|
IBuilder::LIST_CLASS => $this->defaultListClass, |
|
70
|
|
|
IBuilder::ITEM_CLASS => $this->defaultItemClass, |
|
71
|
|
|
IBuilder::LABEL_CLASS => $this->defaultLabelClass, |
|
72
|
|
|
IBuilder::CONTENT_CLASS => $this->defaultContentClass, |
|
73
|
|
|
IBuilder::IMAGE_CLASS => $this->defaultImageClass, |
|
74
|
|
|
]; |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
|
|
$listClass = $template->getAttribute(static::LIST_CLASS, $this->defaultListClass); |
|
|
|
|
|
|
78
|
|
|
$itemClass = $template->getAttribute(static::ITEM_CLASS, $this->defaultItemClass); |
|
|
|
|
|
|
79
|
|
|
$labelClass = $template->getAttribute(static::LABEL_CLASS, $this->defaultLabelClass); |
|
|
|
|
|
|
80
|
|
|
$contentClass = $template->getAttribute(static::CONTENT_CLASS, $this->defaultContentClass); |
|
|
|
|
|
|
81
|
|
|
$imageClass = $template->getAttribute(static::IMAGE_CLASS, $this->defaultImageClass); |
|
|
|
|
|
|
82
|
|
|
|
|
83
|
|
|
return [ |
|
84
|
|
|
IBuilder::LIST_CLASS => $listClass, |
|
85
|
|
|
IBuilder::ITEM_CLASS => $itemClass, |
|
86
|
|
|
IBuilder::LABEL_CLASS => $labelClass, |
|
87
|
|
|
IBuilder::CONTENT_CLASS => $contentClass, |
|
88
|
|
|
IBuilder::IMAGE_CLASS => $imageClass, |
|
89
|
|
|
]; |
|
90
|
|
|
} |
|
91
|
|
|
|
|
92
|
|
|
|
|
93
|
|
|
/** |
|
94
|
|
|
* @param ParsedTemplate|null $template |
|
95
|
|
|
* |
|
96
|
|
|
* @return <string,string> |
|
|
|
|
|
|
97
|
|
|
*/ |
|
98
|
|
|
protected function getOptions(?ParsedTemplate $template = null): array |
|
99
|
|
|
{ |
|
100
|
|
|
if (!$template) { |
|
101
|
|
|
return [ |
|
102
|
|
|
IBuilder::WITH_LABEL_OPTION => (bool)$this->defaultWithLabel, |
|
103
|
|
|
IBuilder::WITH_IMAGE_OPTION => (bool)$this->defaultWithImage, |
|
104
|
|
|
]; |
|
105
|
|
|
} |
|
106
|
|
|
|
|
107
|
|
|
$listClass = $template->getAttribute(static::WITH_LABEL_OPTION, $this->defaultWithLabel); |
|
|
|
|
|
|
108
|
|
|
$itemClass = $template->getAttribute(static::WITH_IMAGE_OPTION, $this->defaultWithImage); |
|
|
|
|
|
|
109
|
|
|
|
|
110
|
|
|
return [ |
|
111
|
|
|
IBuilder::WITH_LABEL_OPTION => (bool)$listClass, |
|
112
|
|
|
IBuilder::WITH_IMAGE_OPTION => (bool)$itemClass, |
|
113
|
|
|
]; |
|
114
|
|
|
} |
|
115
|
|
|
} |
|
116
|
|
|
|