21 use Wikimedia\WrappedString;
22 use 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'] ?? [] );
81 return $this->
getSkin()->getPersonalToolsForMakeListItem( $this->
get(
'personal_urls' ) );
91 $sidebar = $this->data[
'sidebar'];
92 if ( !isset( $sidebar[
'SEARCH'] ) ) {
93 $sidebar[
'SEARCH'] =
true;
95 if ( !isset( $sidebar[
'TOOLBOX'] ) ) {
96 $sidebar[
'TOOLBOX'] =
true;
98 if ( !isset( $sidebar[
'LANGUAGES'] ) ) {
99 $sidebar[
'LANGUAGES'] =
true;
102 if ( !isset( $options[
'search'] ) || $options[
'search'] !==
true ) {
103 unset( $sidebar[
'SEARCH'] );
105 if ( isset( $options[
'toolbox'] ) && $options[
'toolbox'] ===
false ) {
106 unset( $sidebar[
'TOOLBOX'] );
108 if ( isset( $options[
'languages'] ) && $options[
'languages'] ===
false ) {
109 unset( $sidebar[
'LANGUAGES'] );
113 foreach ( $sidebar as $boxName =>
$content ) {
117 switch ( $boxName ) {
122 'header' => $this->
getMsg(
'search' )->text(),
123 'generated' =>
false,
128 $msgObj = $this->
getMsg(
'toolbox' );
131 'header' => $msgObj->exists() ? $msgObj->text() :
'toolbox',
132 'generated' =>
false,
137 if ( $this->data[
'language_urls'] !==
false ) {
138 $msgObj = $this->
getMsg(
'otherlanguages' );
141 'header' => $msgObj->exists() ? $msgObj->text() :
'otherlanguages',
142 'generated' =>
false,
143 'content' => $this->data[
'language_urls'] ?: [],
148 $msgObj = $this->
getMsg( $boxName );
150 'id' =>
"p-$boxName",
151 'header' => $msgObj->exists() ? $msgObj->text() : $boxName,
159 if ( isset( $options[
'htmlOnly'] ) && $options[
'htmlOnly'] ===
true ) {
160 foreach ( $boxes as $boxName => $box ) {
161 if ( is_array( $box[
'content'] ) ) {
163 foreach ( $box[
'content'] as $key => $val ) {
167 $boxes[$boxName][
'content'] =
$content;
202 [
'class' => [
'after-portlet',
'after-portlet-' . $name ] ],
218 protected function makeLink( $key, $item, $options = [] ) {
219 return $this->
getSkin()->makeLink( $key, $item, $options );
231 return $this->
getSkin()->makeListItem( $key, $item, $options );
241 return $this->
getSkin()->makeSearchInput( $attrs );
252 return $this->
getSkin()->makeSearchButton( $mode, $attrs );
265 $footerlinks = $this->
get(
'footerlinks' );
268 $validFooterLinks = [];
269 foreach ( $footerlinks as $category => $links ) {
270 $validFooterLinks[$category] = [];
271 foreach ( $links as $link ) {
272 if ( isset( $this->data[$link] ) && $this->data[$link] ) {
273 $validFooterLinks[$category][] = $link;
276 if ( count( $validFooterLinks[$category] ) <= 0 ) {
277 unset( $validFooterLinks[$category] );
281 if ( $option ==
'flat' && count( $validFooterLinks ) ) {
283 $validFooterLinks = array_merge( ...array_values( $validFooterLinks ) );
286 return $validFooterLinks;
306 $footericons = $this->
get(
'footericons' );
308 if ( $option ==
'icononly' ) {
310 $this->unsetIconsWithoutImages( $footericons );
311 } elseif ( $option ==
'nocopyright' ) {
312 unset( $footericons[
'copyright'] );
324 private function unsetIconsWithoutImages( array &$icons ) {
326 foreach ( $icons as $iconsKey => &$iconsBlock ) {
327 foreach ( $iconsBlock as $iconKey => $icon ) {
328 if ( !is_string( $icon ) && !isset( $icon[
'src'] ) ) {
329 unset( $iconsBlock[$iconKey] );
332 if ( $iconsBlock === [] ) {
333 unset( $icons[$iconsKey] );
348 protected function getFooter( $iconStyle =
'icononly', $linkStyle =
'flat' ) {
349 $validFooterIcons = $this->
get(
'footericons' );
350 if ( $iconStyle ===
'icononly' ) {
351 $this->unsetIconsWithoutImages( $validFooterIcons );
360 if ( count( $validFooterIcons ) + count( $validFooterLinks ) > 0 ) {
362 'id' =>
'footer-bottom',
363 'class' =>
'mw-footer',
364 'role' =>
'contentinfo',
365 'lang' => $this->
get(
'userlang' ),
366 'dir' => $this->
get(
'dir' )
372 foreach ( $validFooterIcons as $blockName => $footerIcons ) {
375 'class' =>
'footer-icons'
377 foreach ( $footerIcons as $icon ) {
378 $html .= $this->
getSkin()->makeFooterIcon( $icon );
382 if ( count( $validFooterLinks ) > 0 ) {
383 $html .=
Html::openElement(
'ul', [
'id' =>
'f-list',
'class' =>
'footer-places' ] );
384 foreach ( $validFooterLinks as $aLink ) {
394 $html .= $this->
getClear() . $footerEnd;
425 $out =
"<div class=\"mw-indicators\">\n";
426 foreach ( $this->data[
'indicators'] as $id =>
$content ) {
431 'class' =>
'mw-indicator',
464 $options = $skin->getOptions();
466 return $options[
'bodyOnly'] ?
'' : WrappedString::join(
"\n", [
468 $this->get(
'bottomscripts' ),
469 $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=[])
Wrapper for Skin method.
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=[])
Wrapper for Skin method.
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=[])
Wrapper for Skin method.
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=[])
Wrapper for Skin method.
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.
static element( $element, $attribs=[], $contents='')
Identical to rawElement(), but HTML-escapes $contents (like Xml::element()).
static rawElement( $element, $attribs=[], $contents='')
Returns an HTML element in a string.
static openElement( $element, $attribs=[])
Identical to rawElement(), but has no third parameter and omits the end tag (and the self-closing '/'...
static closeElement( $element)
Returns "</$element>".
static getDebugHTML(IContextSource $context)
Returns the HTML to add to the page for the toolbar.
PHP-based skin template that holds data.
getSkin()
Get the Skin object related to this object.
static escapeIdForAttribute( $id, $mode=self::ID_PRIMARY)
Given a section name or other user-generated or otherwise unsafe string, escapes it to be a valid HTM...