21 use Wikimedia\WrappedString;
22 use Wikimedia\WrappedStringList;
40 public function getMsg( $name, ...$params ) {
41 return $this->
getSkin()->msg( $name, ...$params );
44 public function msg( $str ) {
45 echo $this->
getMsg( $str )->escaped();
62 $toolbox = $this->
getSkin()->makeToolbox(
63 $this->data[
'nav_urls'],
68 if ( isset( $this->data[
'sidebar'][
'TOOLBOX'] ) ) {
69 $toolbox = array_merge( $toolbox, $this->data[
'sidebar'][
'TOOLBOX'] ?? [] );
73 $this->getHookRunner()->onBaseTemplateToolbox( $this, $toolbox );
82 return $this->
getSkin()->getPersonalToolsForMakeListItem( $this->
get(
'personal_urls' ) );
92 $sidebar = $this->data[
'sidebar'];
93 if ( !isset( $sidebar[
'SEARCH'] ) ) {
94 $sidebar[
'SEARCH'] =
true;
96 if ( !isset( $sidebar[
'TOOLBOX'] ) ) {
97 $sidebar[
'TOOLBOX'] =
true;
99 if ( !isset( $sidebar[
'LANGUAGES'] ) ) {
100 $sidebar[
'LANGUAGES'] =
true;
103 if ( !isset( $options[
'search'] ) || $options[
'search'] !==
true ) {
104 unset( $sidebar[
'SEARCH'] );
106 if ( isset( $options[
'toolbox'] ) && $options[
'toolbox'] ===
false ) {
107 unset( $sidebar[
'TOOLBOX'] );
109 if ( isset( $options[
'languages'] ) && $options[
'languages'] ===
false ) {
110 unset( $sidebar[
'LANGUAGES'] );
114 foreach ( $sidebar as $boxName =>
$content ) {
118 switch ( $boxName ) {
123 'header' => $this->
getMsg(
'search' )->text(),
124 'generated' =>
false,
129 $msgObj = $this->
getMsg(
'toolbox' );
132 'header' => $msgObj->exists() ? $msgObj->text() :
'toolbox',
133 'generated' =>
false,
138 if ( $this->data[
'language_urls'] !==
false ) {
139 $msgObj = $this->
getMsg(
'otherlanguages' );
142 'header' => $msgObj->exists() ? $msgObj->text() :
'otherlanguages',
143 'generated' =>
false,
144 'content' => $this->data[
'language_urls'] ?: [],
149 $msgObj = $this->
getMsg( $boxName );
151 'id' =>
"p-$boxName",
152 'header' => $msgObj->exists() ? $msgObj->text() : $boxName,
161 $hookContents =
null;
162 if ( isset( $boxes[
'TOOLBOX'] ) ) {
166 $this->getHookRunner()->onSkinTemplateToolboxEnd( $this,
true );
167 $hookContents = ob_get_contents();
169 if ( !trim( $hookContents ) ) {
170 $hookContents =
null;
175 if ( isset( $options[
'htmlOnly'] ) && $options[
'htmlOnly'] ===
true ) {
176 foreach ( $boxes as $boxName => $box ) {
177 if ( is_array( $box[
'content'] ) ) {
179 foreach ( $box[
'content'] as $key => $val ) {
183 if ( $hookContents ) {
188 $boxes[$boxName][
'content'] =
$content;
191 } elseif ( $hookContents ) {
192 $boxes[
'TOOLBOXEND'] = [
193 'id' =>
'p-toolboxend',
194 'header' => $boxes[
'TOOLBOX'][
'header'],
195 'generated' =>
false,
196 'content' =>
"<ul>{$hookContents}</ul>",
200 foreach ( $boxes as $key => $box ) {
201 if ( $key ===
'TOOLBOXEND' ) {
204 $boxes2[$key] = $box;
205 if ( $key ===
'TOOLBOX' ) {
206 $boxes2[
'TOOLBOXEND'] = $boxes[
'TOOLBOXEND'];
237 $this->getHookRunner()->onBaseTemplateAfterPortlet( $this, $name,
$content );
243 [
'class' => [
'after-portlet',
'after-portlet-' . $name ] ],
255 protected function makeLink( $key, $item, $options = [] ) {
256 return $this->
getSkin()->makeLink( $key, $item, $options );
264 return $this->
getSkin()->makeListItem( $key, $item, $options );
271 return $this->
getSkin()->makeSearchInput( $attrs );
278 return $this->
getSkin()->makeSearchButton( $mode, $attrs );
291 $footerlinks = $this->
get(
'footerlinks' );
294 $validFooterLinks = [];
295 foreach ( $footerlinks as $category => $links ) {
296 $validFooterLinks[$category] = [];
297 foreach ( $links as $link ) {
298 if ( isset( $this->data[$link] ) && $this->data[$link] ) {
299 $validFooterLinks[$category][] = $link;
302 if ( count( $validFooterLinks[$category] ) <= 0 ) {
303 unset( $validFooterLinks[$category] );
307 if ( $option ==
'flat' && count( $validFooterLinks ) ) {
309 $validFooterLinks = array_merge( ...array_values( $validFooterLinks ) );
312 return $validFooterLinks;
331 $footericons = $this->
get(
'footericons' );
333 if ( $option ==
'icononly' ) {
335 foreach ( $footericons as $footerIconsKey => &$footerIconsBlock ) {
336 foreach ( $footerIconsBlock as $footerIconKey => $footerIcon ) {
337 if ( !is_string( $footerIcon ) && !isset( $footerIcon[
'src'] ) ) {
338 unset( $footerIconsBlock[$footerIconKey] );
341 if ( $footerIconsBlock === [] ) {
342 unset( $footericons[$footerIconsKey] );
345 } elseif ( $option ==
'nocopyright' ) {
346 unset( $footericons[
'copyright'] );
361 protected function getFooter( $iconStyle =
'icononly', $linkStyle =
'flat' ) {
367 if ( count( $validFooterIcons ) + count( $validFooterLinks ) > 0 ) {
369 'id' =>
'footer-bottom',
370 'class' =>
'mw-footer',
371 'role' =>
'contentinfo',
372 'lang' => $this->
get(
'userlang' ),
373 'dir' => $this->
get(
'dir' )
379 foreach ( $validFooterIcons as $blockName => $footerIcons ) {
382 'class' =>
'footer-icons'
384 foreach ( $footerIcons as $icon ) {
385 $html .= $this->
getSkin()->makeFooterIcon( $icon );
389 if ( count( $validFooterLinks ) > 0 ) {
390 $html .=
Html::openElement(
'ul', [
'id' =>
'f-list',
'class' =>
'footer-places' ] );
391 foreach ( $validFooterLinks as $aLink ) {
401 $html .= $this->
getClear() . $footerEnd;
432 $out =
"<div class=\"mw-indicators mw-body-content\">\n";
433 foreach ( $this->data[
'indicators'] as $id =>
$content ) {
438 'class' =>
'mw-indicator',
463 return WrappedString::join(
"\n", [
465 $this->
get(
'bottomscripts' ),
466 $this->
get(
'reporttime' )