21use Wikimedia\WrappedString;
22use Wikimedia\WrappedStringList;
42 public function getMsg( $name, ...$params ) {
43 return $this->
getSkin()->msg( $name, ...$params );
46 public function msg( $str ) {
47 echo $this->
getMsg( $str )->escaped();
64 $toolbox = $this->
getSkin()->makeToolbox(
65 $this->data[
'nav_urls'],
70 if ( isset( $this->data[
'sidebar'][
'TOOLBOX'] ) ) {
71 $toolbox = array_merge( $toolbox, $this->data[
'sidebar'][
'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,
160 if ( isset( $options[
'htmlOnly'] ) && $options[
'htmlOnly'] ===
true ) {
161 foreach ( $boxes as $boxName => $box ) {
162 if ( is_array( $box[
'content'] ) ) {
164 foreach ( $box[
'content'] as $key => $val ) {
168 $boxes[$boxName][
'content'] =
$content;
199 $this->getHookRunner()->onBaseTemplateAfterPortlet( $this, $name,
$content );
203 $html = Html::rawElement(
205 [
'class' => [
'after-portlet',
'after-portlet-' . $name ] ],
217 protected function makeLink( $key, $item, $options = [] ) {
218 return $this->
getSkin()->makeLink( $key, $item, $options );
226 return $this->
getSkin()->makeListItem( $key, $item, $options );
233 return $this->
getSkin()->makeSearchInput( $attrs );
240 return $this->
getSkin()->makeSearchButton( $mode, $attrs );
253 $footerlinks = $this->
get(
'footerlinks' );
256 $validFooterLinks = [];
257 foreach ( $footerlinks as $category => $links ) {
258 $validFooterLinks[$category] = [];
259 foreach ( $links as $link ) {
260 if ( isset( $this->data[$link] ) && $this->data[$link] ) {
261 $validFooterLinks[$category][] = $link;
264 if ( count( $validFooterLinks[$category] ) <= 0 ) {
265 unset( $validFooterLinks[$category] );
269 if ( $option ==
'flat' && count( $validFooterLinks ) ) {
271 $validFooterLinks = array_merge( ...array_values( $validFooterLinks ) );
274 return $validFooterLinks;
294 $footericons = $this->
get(
'footericons' );
296 if ( $option ==
'icononly' ) {
298 $this->unsetIconsWithoutImages( $footericons );
299 } elseif ( $option ==
'nocopyright' ) {
300 unset( $footericons[
'copyright'] );
312 private function unsetIconsWithoutImages( array &$icons ) {
314 foreach ( $icons as $iconsKey => &$iconsBlock ) {
315 foreach ( $iconsBlock as $iconKey => $icon ) {
316 if ( !is_string( $icon ) && !isset( $icon[
'src'] ) ) {
317 unset( $iconsBlock[$iconKey] );
320 if ( $iconsBlock === [] ) {
321 unset( $icons[$iconsKey] );
336 protected function getFooter( $iconStyle =
'icononly', $linkStyle =
'flat' ) {
337 $validFooterIcons = $this->
get(
'footericons' );
338 if ( $iconStyle ===
'icononly' ) {
339 $this->unsetIconsWithoutImages( $validFooterIcons );
348 if ( count( $validFooterIcons ) + count( $validFooterLinks ) > 0 ) {
349 $html .= Html::openElement(
'div', [
350 'id' =>
'footer-bottom',
351 'class' =>
'mw-footer',
352 'role' =>
'contentinfo',
353 'lang' => $this->
get(
'userlang' ),
354 'dir' => $this->
get(
'dir' )
356 $footerEnd = Html::closeElement(
'div' );
360 foreach ( $validFooterIcons as $blockName => $footerIcons ) {
361 $html .= Html::openElement(
'div', [
362 'id' => Sanitizer::escapeIdForAttribute(
"f-{$blockName}ico" ),
363 'class' =>
'footer-icons'
365 foreach ( $footerIcons as $icon ) {
366 $html .= $this->
getSkin()->makeFooterIcon( $icon );
368 $html .= Html::closeElement(
'div' );
370 if ( count( $validFooterLinks ) > 0 ) {
371 $html .= Html::openElement(
'ul', [
'id' =>
'f-list',
'class' =>
'footer-places' ] );
372 foreach ( $validFooterLinks as $aLink ) {
373 $html .= Html::rawElement(
375 [
'id' => Sanitizer::escapeIdForAttribute( $aLink ) ],
379 $html .= Html::closeElement(
'ul' );
382 $html .= $this->
getClear() . $footerEnd;
394 return Html::element(
'div', [
'class' =>
'visualClear' ] );
413 $out =
"<div class=\"mw-indicators\">\n";
414 foreach ( $this->data[
'indicators'] as $id =>
$content ) {
415 $out .= Html::rawElement(
418 'id' => Sanitizer::escapeIdForAttribute(
"mw-indicator-$id" ),
419 'class' =>
'mw-indicator',
452 $options = $skin->getOptions();
454 return $options[
'bodyOnly'] ?
'' : WrappedString::join(
"\n", [
455 MWDebug::getDebugHTML( $skin->getContext() ),
456 $this->get(
'bottomscripts' ),
457 $this->get(
'reporttime' )
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Logs a warning that a deprecated feature was used.
Extended QuickTemplate with additional MediaWiki-specific helper methods.
getFooterLinks( $option=null)
Returns an array of footerlinks trimmed down to only those footer links that are valid.
makeSearchButton( $mode, $attrs=[])
renderAfterPortlet( $name)
getToolbox()
Create an array of common toolbox items from the data in the quicktemplate stored by SkinTemplate and...
getTrail()
Get the basic end-page trail including bottomscripts, reporttime, and debug stuff.
printTrail()
Output getTrail.
makeLink( $key, $item, $options=[])
getFooterIcons( $option=null)
Returns an array of footer icons filtered down by options relevant to how the skin wishes to display ...
makeListItem( $key, $item, $options=[])
getMsg( $name,... $params)
Get a Message object with its context set.
getIndicators()
Get the suggested HTML for page status indicators: icons (or short text snippets) usually displayed i...
makeSearchInput( $attrs=[])
getFooter( $iconStyle='icononly', $linkStyle='flat')
Renderer for getFooterIcons and getFooterLinks.
getClear()
Get a div with the core visualClear class, for clearing floats.
getAfterPortlet( $name)
Allows extensions to hook into known portlets and add stuff to them.
PHP-based skin template that holds data.
getSkin()
Get the Skin object related to this object.