|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* File holding the Structure class |
|
4
|
|
|
* |
|
5
|
|
|
* This file is part of the MediaWiki skin Chameleon. |
|
6
|
|
|
* |
|
7
|
|
|
* @copyright 2013 - 2014, Stephan Gambke |
|
8
|
|
|
* @license GNU General Public License, version 3 (or any later version) |
|
9
|
|
|
* |
|
10
|
|
|
* The Chameleon skin is free software: you can redistribute it and/or modify |
|
11
|
|
|
* it under the terms of the GNU General Public License as published by the Free |
|
12
|
|
|
* Software Foundation, either version 3 of the License, or (at your option) any |
|
13
|
|
|
* later version. |
|
14
|
|
|
* |
|
15
|
|
|
* The Chameleon skin is distributed in the hope that it will be useful, but |
|
16
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
17
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more |
|
18
|
|
|
* details. |
|
19
|
|
|
* |
|
20
|
|
|
* You should have received a copy of the GNU General Public License along |
|
21
|
|
|
* with this program. If not, see <http://www.gnu.org/licenses/>. |
|
22
|
|
|
* |
|
23
|
|
|
* @file |
|
24
|
|
|
* @ingroup Skins |
|
25
|
|
|
*/ |
|
26
|
|
|
|
|
27
|
|
|
namespace Skins\Chameleon\Components; |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* The Structure class. |
|
31
|
|
|
* |
|
32
|
|
|
* @author Stephan Gambke |
|
33
|
|
|
* @since 1.0 |
|
34
|
|
|
* @ingroup Skins |
|
35
|
|
|
*/ |
|
36
|
|
|
class Structure extends Component { |
|
37
|
|
|
|
|
38
|
|
|
private $subcomponents; |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* Builds the HTML code for the component |
|
42
|
|
|
* |
|
43
|
|
|
* @return String the HTML code |
|
44
|
|
|
*/ |
|
45
|
7 |
|
public function getHtml(){ |
|
46
|
7 |
|
$ret = ''; |
|
47
|
|
|
|
|
48
|
7 |
|
foreach ( $this->getSubcomponents() as $component ) { |
|
49
|
5 |
|
$ret .= $component->getHtml(); |
|
50
|
7 |
|
} |
|
51
|
|
|
|
|
52
|
7 |
|
return $ret; |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
/** |
|
56
|
|
|
* @return string[] the resource loader modules needed by this component |
|
57
|
|
|
*/ |
|
58
|
|
|
public function getResourceLoaderModules() { |
|
59
|
|
|
$modules = array(); |
|
60
|
|
|
|
|
61
|
|
|
foreach ( $this->getSubcomponents() as $component ) { |
|
62
|
|
|
$modules = array_merge( $modules, $component->getResourceLoaderModules() ); |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
return $modules; |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
/** |
|
69
|
|
|
* @return Component[] |
|
70
|
|
|
*/ |
|
71
|
83 |
|
protected function getSubcomponents() { |
|
72
|
|
|
|
|
73
|
83 |
|
if ( !isset ( $this->subcomponents ) ) { |
|
74
|
|
|
|
|
75
|
83 |
|
$this->subcomponents = array(); |
|
76
|
|
|
|
|
77
|
83 |
|
$domElement = $this->getDomElement(); |
|
78
|
|
|
|
|
79
|
83 |
|
if ( $domElement !== null && is_a( $domElement, 'DomElement' ) ) { |
|
80
|
|
|
|
|
81
|
78 |
|
$children = $this->getDomElement()->childNodes; |
|
82
|
|
|
|
|
83
|
78 |
|
foreach ( $children as $child ) { |
|
84
|
73 |
|
if ( is_a( $child, 'DOMElement' ) ) { |
|
85
|
73 |
|
$this->subcomponents[ ] = $this->getSkinTemplate()->getComponent( $child, $this->getIndent() + 1 ); |
|
86
|
73 |
|
} |
|
87
|
78 |
|
} |
|
88
|
|
|
|
|
89
|
78 |
|
} |
|
90
|
83 |
|
} |
|
91
|
|
|
|
|
92
|
83 |
|
return $this->subcomponents; |
|
93
|
|
|
} |
|
94
|
|
|
|
|
95
|
|
|
} |
|
96
|
|
|
|