21use Wikimedia\WrappedString;
22use 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();
60 $toolbox = $this->
getSkin()->makeToolbox(
61 $this->data[
'nav_urls'],
66 if ( isset( $this->data[
'sidebar'][
'TOOLBOX'] ) ) {
67 $toolbox = array_merge( $toolbox, $this->data[
'sidebar'][
'TOOLBOX'] ?? [] );
71 $this->getHookRunner()->onBaseTemplateToolbox( $this, $toolbox );
80 return $this->
getSkin()->getPersonalToolsForMakeListItem( $this->
get(
'personal_urls' ) );
90 $sidebar = $this->data[
'sidebar'];
91 if ( !isset( $sidebar[
'SEARCH'] ) ) {
92 $sidebar[
'SEARCH'] =
true;
94 if ( !isset( $sidebar[
'TOOLBOX'] ) ) {
95 $sidebar[
'TOOLBOX'] =
true;
97 if ( !isset( $sidebar[
'LANGUAGES'] ) ) {
98 $sidebar[
'LANGUAGES'] =
true;
101 if ( !isset( $options[
'search'] ) || $options[
'search'] !==
true ) {
102 unset( $sidebar[
'SEARCH'] );
104 if ( isset( $options[
'toolbox'] ) && $options[
'toolbox'] ===
false ) {
105 unset( $sidebar[
'TOOLBOX'] );
107 if ( isset( $options[
'languages'] ) && $options[
'languages'] ===
false ) {
108 unset( $sidebar[
'LANGUAGES'] );
112 foreach ( $sidebar as $boxName =>
$content ) {
116 switch ( $boxName ) {
121 'header' => $this->
getMsg(
'search' )->text(),
122 'generated' =>
false,
127 $msgObj = $this->
getMsg(
'toolbox' );
130 'header' => $msgObj->exists() ? $msgObj->text() :
'toolbox',
131 'generated' =>
false,
136 if ( $this->data[
'language_urls'] !==
false ) {
137 $msgObj = $this->
getMsg(
'otherlanguages' );
140 'header' => $msgObj->exists() ? $msgObj->text() :
'otherlanguages',
141 'generated' =>
false,
142 'content' => $this->data[
'language_urls'] ?: [],
147 $msgObj = $this->
getMsg( $boxName );
149 'id' =>
"p-$boxName",
150 'header' => $msgObj->exists() ? $msgObj->text() : $boxName,
159 $hookContents =
null;
160 if ( isset( $boxes[
'TOOLBOX'] ) ) {
164 $this->getHookRunner()->onSkinTemplateToolboxEnd( $this,
true );
165 $hookContents = ob_get_contents();
167 if ( !trim( $hookContents ) ) {
168 $hookContents =
null;
173 if ( isset( $options[
'htmlOnly'] ) && $options[
'htmlOnly'] ===
true ) {
174 foreach ( $boxes as $boxName => $box ) {
175 if ( is_array( $box[
'content'] ) ) {
177 foreach ( $box[
'content'] as $key => $val ) {
181 if ( $hookContents ) {
186 $boxes[$boxName][
'content'] =
$content;
189 } elseif ( $hookContents ) {
190 $boxes[
'TOOLBOXEND'] = [
191 'id' =>
'p-toolboxend',
192 'header' => $boxes[
'TOOLBOX'][
'header'],
193 'generated' =>
false,
194 'content' =>
"<ul>{$hookContents}</ul>",
198 foreach ( $boxes as $key => $box ) {
199 if ( $key ===
'TOOLBOXEND' ) {
202 $boxes2[$key] = $box;
203 if ( $key ===
'TOOLBOX' ) {
204 $boxes2[
'TOOLBOXEND'] = $boxes[
'TOOLBOXEND'];
235 $this->getHookRunner()->onBaseTemplateAfterPortlet( $this, $name,
$content );
239 $html = Html::rawElement(
241 [
'class' => [
'after-portlet',
'after-portlet-' . $name ] ],
253 protected function makeLink( $key, $item, $options = [] ) {
254 return $this->
getSkin()->makeLink( $key, $item, $options );
262 return $this->
getSkin()->makeListItem( $key, $item, $options );
269 return $this->
getSkin()->makeSearchInput( $attrs );
276 return $this->
getSkin()->makeSearchButton( $mode, $attrs );
289 $footerlinks = $this->
get(
'footerlinks' );
292 $validFooterLinks = [];
293 foreach ( $footerlinks as $category => $links ) {
294 $validFooterLinks[$category] = [];
295 foreach ( $links as $link ) {
296 if ( isset( $this->data[$link] ) && $this->data[$link] ) {
297 $validFooterLinks[$category][] = $link;
300 if ( count( $validFooterLinks[$category] ) <= 0 ) {
301 unset( $validFooterLinks[$category] );
305 if ( $option ==
'flat' && count( $validFooterLinks ) ) {
307 $validFooterLinks = array_merge( ...array_values( $validFooterLinks ) );
310 return $validFooterLinks;
329 $footericons = $this->
get(
'footericons' );
331 if ( $option ==
'icononly' ) {
333 foreach ( $footericons as $footerIconsKey => &$footerIconsBlock ) {
334 foreach ( $footerIconsBlock as $footerIconKey => $footerIcon ) {
335 if ( !is_string( $footerIcon ) && !isset( $footerIcon[
'src'] ) ) {
336 unset( $footerIconsBlock[$footerIconKey] );
339 if ( $footerIconsBlock === [] ) {
340 unset( $footericons[$footerIconsKey] );
343 } elseif ( $option ==
'nocopyright' ) {
344 unset( $footericons[
'copyright'] );
359 protected function getFooter( $iconStyle =
'icononly', $linkStyle =
'flat' ) {
365 if ( count( $validFooterIcons ) + count( $validFooterLinks ) > 0 ) {
366 $html .= Html::openElement(
'div', [
367 'id' =>
'footer-bottom',
368 'class' =>
'mw-footer',
369 'role' =>
'contentinfo',
370 'lang' => $this->
get(
'userlang' ),
371 'dir' => $this->
get(
'dir' )
373 $footerEnd = Html::closeElement(
'div' );
377 foreach ( $validFooterIcons as $blockName => $footerIcons ) {
378 $html .= Html::openElement(
'div', [
379 'id' => Sanitizer::escapeIdForAttribute(
"f-{$blockName}ico" ),
380 'class' =>
'footer-icons'
382 foreach ( $footerIcons as $icon ) {
383 $html .= $this->
getSkin()->makeFooterIcon( $icon );
385 $html .= Html::closeElement(
'div' );
387 if ( count( $validFooterLinks ) > 0 ) {
388 $html .= Html::openElement(
'ul', [
'id' =>
'f-list',
'class' =>
'footer-places' ] );
389 foreach ( $validFooterLinks as $aLink ) {
390 $html .= Html::rawElement(
392 [
'id' => Sanitizer::escapeIdForAttribute( $aLink ) ],
396 $html .= Html::closeElement(
'ul' );
399 $html .= $this->
getClear() . $footerEnd;
411 return Html::element(
'div', [
'class' =>
'visualClear' ] );
430 $out =
"<div class=\"mw-indicators mw-body-content\">\n";
431 foreach ( $this->data[
'indicators'] as $id =>
$content ) {
432 $out .= Html::rawElement(
435 'id' => Sanitizer::escapeIdForAttribute(
"mw-indicator-$id" ),
436 'class' =>
'mw-indicator',
461 return WrappedString::join(
"\n", [
463 $this->
get(
'bottomscripts' ),
464 $this->
get(
'reporttime' )
New base template for a skin's template extended from QuickTemplate this class features helper method...
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.
Generic wrapper for template functions, with interface compatible with what we use of PHPTAL 0....
getSkin()
Get the Skin object related to this object.