Go to the documentation of this file.
21 use Wikimedia\WrappedString;
22 use Wikimedia\WrappedStringList;
39 return $this->
getSkin()->msg( ...func_get_args() );
42 function msg( $str ) {
43 echo $this->
getMsg( $str )->escaped();
55 echo $this->
getMsg( $str )->text();
59 echo $this->
getMsg( $str )->parseAsBlock();
71 if ( isset( $this->
data[
'nav_urls'][
'whatlinkshere'] )
72 && $this->
data[
'nav_urls'][
'whatlinkshere']
74 $toolbox[
'whatlinkshere'] = $this->
data[
'nav_urls'][
'whatlinkshere'];
75 $toolbox[
'whatlinkshere'][
'id'] =
't-whatlinkshere';
77 if ( isset( $this->
data[
'nav_urls'][
'recentchangeslinked'] )
78 && $this->
data[
'nav_urls'][
'recentchangeslinked']
80 $toolbox[
'recentchangeslinked'] = $this->
data[
'nav_urls'][
'recentchangeslinked'];
81 $toolbox[
'recentchangeslinked'][
'msg'] =
'recentchangeslinked-toolbox';
82 $toolbox[
'recentchangeslinked'][
'id'] =
't-recentchangeslinked';
83 $toolbox[
'recentchangeslinked'][
'rel'] =
'nofollow';
85 if ( isset( $this->
data[
'feeds'] ) && $this->
data[
'feeds'] ) {
86 $toolbox[
'feeds'][
'id'] =
'feedlinks';
87 $toolbox[
'feeds'][
'links'] = [];
88 foreach ( $this->
data[
'feeds']
as $key => $feed ) {
89 $toolbox[
'feeds'][
'links'][$key] = $feed;
90 $toolbox[
'feeds'][
'links'][$key][
'id'] =
"feed-$key";
91 $toolbox[
'feeds'][
'links'][$key][
'rel'] =
'alternate';
92 $toolbox[
'feeds'][
'links'][$key][
'type'] =
"application/{$key}+xml";
93 $toolbox[
'feeds'][
'links'][$key][
'class'] =
'feedlink';
96 foreach ( [
'contributions',
'log',
'blockip',
'emailuser',
97 'userrights',
'upload',
'specialpages' ]
as $special
99 if ( isset( $this->
data[
'nav_urls'][$special] ) && $this->
data[
'nav_urls'][$special] ) {
100 $toolbox[$special] = $this->
data[
'nav_urls'][$special];
101 $toolbox[$special][
'id'] =
"t-$special";
104 if ( isset( $this->
data[
'nav_urls'][
'print'] ) && $this->
data[
'nav_urls'][
'print'] ) {
105 $toolbox[
'print'] = $this->
data[
'nav_urls'][
'print'];
106 $toolbox[
'print'][
'id'] =
't-print';
107 $toolbox[
'print'][
'rel'] =
'alternate';
108 $toolbox[
'print'][
'msg'] =
'printableversion';
110 if ( isset( $this->
data[
'nav_urls'][
'permalink'] ) && $this->
data[
'nav_urls'][
'permalink'] ) {
111 $toolbox[
'permalink'] = $this->
data[
'nav_urls'][
'permalink'];
112 $toolbox[
'permalink'][
'id'] =
't-permalink';
114 if ( isset( $this->
data[
'nav_urls'][
'info'] ) && $this->
data[
'nav_urls'][
'info'] ) {
115 $toolbox[
'info'] = $this->
data[
'nav_urls'][
'info'];
116 $toolbox[
'info'][
'id'] =
't-info';
136 $personal_tools = [];
137 foreach ( $this->
get(
'personal_urls' )
as $key => $plink ) {
138 # The class on a personal_urls item is meant to go on the <a> instead
139 # of the <li> so we have to use a single item "links" array instead
140 # of using most of the personal_url's keys directly.
143 [
'single-id' =>
"pt-$key" ],
147 if ( isset( $plink[
'active'] ) ) {
148 $ptool[
'active'] = $plink[
'active'];
150 foreach ( [
'href',
'class',
'text',
'dir',
'data',
'exists' ]
as $k ) {
151 if ( isset( $plink[$k] ) ) {
152 $ptool[
'links'][0][$k] = $plink[$k];
155 $personal_tools[$key] = $ptool;
157 return $personal_tools;
162 $sidebar = $this->
data[
'sidebar'];
163 if ( !isset( $sidebar[
'SEARCH'] ) ) {
164 $sidebar[
'SEARCH'] =
true;
166 if ( !isset( $sidebar[
'TOOLBOX'] ) ) {
167 $sidebar[
'TOOLBOX'] =
true;
169 if ( !isset( $sidebar[
'LANGUAGES'] ) ) {
170 $sidebar[
'LANGUAGES'] =
true;
174 unset( $sidebar[
'SEARCH'] );
177 unset( $sidebar[
'TOOLBOX'] );
180 unset( $sidebar[
'LANGUAGES'] );
184 foreach ( $sidebar
as $boxName =>
$content ) {
188 switch ( $boxName ) {
193 'header' => $this->
getMsg(
'search' )->text(),
194 'generated' =>
false,
199 $msgObj = $this->
getMsg(
'toolbox' );
202 'header' => $msgObj->exists() ? $msgObj->text() :
'toolbox',
203 'generated' =>
false,
208 if ( $this->
data[
'language_urls'] !==
false ) {
209 $msgObj = $this->
getMsg(
'otherlanguages' );
212 'header' => $msgObj->exists() ? $msgObj->text() :
'otherlanguages',
213 'generated' =>
false,
214 'content' => $this->
data[
'language_urls'] ?: [],
219 $msgObj = $this->
getMsg( $boxName );
221 'id' =>
"p-$boxName",
222 'header' => $msgObj->exists() ? $msgObj->text() : $boxName,
231 $hookContents =
null;
232 if ( isset( $boxes[
'TOOLBOX'] ) ) {
239 $hookContents = ob_get_contents();
241 if ( !trim( $hookContents ) ) {
242 $hookContents =
null;
248 foreach ( $boxes
as $boxName => $box ) {
249 if ( is_array( $box[
'content'] ) ) {
251 foreach ( $box[
'content']
as $key => $val ) {
255 if ( $hookContents ) {
260 $boxes[$boxName][
'content'] =
$content;
264 if ( $hookContents ) {
265 $boxes[
'TOOLBOXEND'] = [
266 'id' =>
'p-toolboxend',
267 'header' => $boxes[
'TOOLBOX'][
'header'],
268 'generated' =>
false,
269 'content' =>
"<ul>{$hookContents}</ul>",
273 foreach ( $boxes
as $key => $box ) {
274 if ( $key ===
'TOOLBOXEND' ) {
277 $boxes2[$key] = $box;
278 if ( $key ===
'TOOLBOX' ) {
279 $boxes2[
'TOOLBOXEND'] = $boxes[
'TOOLBOXEND'];
313 [
'class' => [
'after-portlet',
'after-portlet-' .
$name ] ],
374 if ( isset( $item[
'text'] ) ) {
375 $text = $item[
'text'];
377 $text =
wfMessage( $item[
'msg'] ?? $key )->text();
380 $html = htmlspecialchars( $text );
382 if ( isset(
$options[
'text-wrapper'] ) ) {
383 $wrapper =
$options[
'text-wrapper'];
384 if ( isset( $wrapper[
'tag'] ) ) {
385 $wrapper = [ $wrapper ];
387 while (
count( $wrapper ) > 0 ) {
388 $element = array_pop( $wrapper );
393 if ( isset( $item[
'href'] ) || isset(
$options[
'link-fallback'] ) ) {
395 foreach ( [
'single-id',
'text',
'msg',
'tooltiponly',
'context',
'primary',
396 'tooltip-params',
'exists' ]
as $k ) {
400 if ( isset( $attrs[
'data'] ) ) {
401 foreach ( $attrs[
'data']
as $key =>
$value ) {
402 $attrs[
'data-' . $key ] =
$value;
404 unset( $attrs[
'data' ] );
407 if ( isset( $item[
'id'] ) && !isset( $item[
'single-id'] ) ) {
408 $item[
'single-id'] = $item[
'id'];
412 if ( isset( $item[
'tooltip-params'] ) ) {
413 $tooltipParams = $item[
'tooltip-params'];
416 if ( isset( $item[
'single-id'] ) ) {
417 $tooltipOption = isset( $item[
'exists'] ) && $item[
'exists'] ===
false ?
'nonexisting' :
null;
419 if ( isset( $item[
'tooltiponly'] ) && $item[
'tooltiponly'] ) {
430 if ( isset( $tip[
'title'] ) && $tip[
'title'] !==
false ) {
431 $attrs[
'title'] = $tip[
'title'];
433 if ( isset( $tip[
'accesskey'] ) && $tip[
'accesskey'] !==
false ) {
434 $attrs[
'accesskey'] = $tip[
'accesskey'];
438 if ( isset(
$options[
'link-class'] ) ) {
439 if ( isset( $attrs[
'class'] ) ) {
440 $attrs[
'class'] .=
" {$options['link-class']}";
442 $attrs[
'class'] =
$options[
'link-class'];
483 if ( isset( $item[
'links'] ) ) {
485 foreach ( $item[
'links']
as $linkKey =>
$link ) {
488 $html = implode(
' ', $links );
492 foreach ( [
'id',
'class',
'active',
'tag',
'itemtitle' ]
as $k ) {
495 if ( isset( $item[
'id'] ) && !isset( $item[
'single-id'] ) ) {
499 $link[
'single-id'] = $item[
'id'];
501 if ( isset(
$link[
'link-class'] ) ) {
505 unset(
$link[
'link-class'] );
511 foreach ( [
'id',
'class' ]
as $attr ) {
512 if ( isset( $item[$attr] ) ) {
513 $attrs[$attr] = $item[$attr];
516 if ( isset( $item[
'active'] ) && $item[
'active'] ) {
517 if ( !isset( $attrs[
'class'] ) ) {
518 $attrs[
'class'] =
'';
520 $attrs[
'class'] .=
' active';
521 $attrs[
'class'] = trim( $attrs[
'class'] );
523 if ( isset( $item[
'itemtitle'] ) ) {
524 $attrs[
'title'] = $item[
'itemtitle'];
533 'placeholder' =>
wfMessage(
'searchsuggest-search' )->text(),
546 'value' =>
wfMessage( $mode ==
'go' ?
'searcharticle' :
'searchbutton' )->text(),
548 $realAttrs = array_merge(
559 $buttonAttrs = array_merge(
564 unset( $buttonAttrs[
'src'] );
565 unset( $buttonAttrs[
'alt'] );
566 unset( $buttonAttrs[
'width'] );
567 unset( $buttonAttrs[
'height'] );
569 'src' => $attrs[
'src'],
570 'alt' => $attrs[
'alt'] ??
wfMessage(
'searchbutton' )->text(),
571 'width' => $attrs[
'width'] ??
null,
572 'height' => $attrs[
'height'] ??
null,
576 throw new MWException(
'Unknown mode passed to BaseTemplate::makeSearchButton' );
590 $footerlinks = $this->
get(
'footerlinks' );
593 $validFooterLinks = [];
594 foreach ( $footerlinks
as $category => $links ) {
595 $validFooterLinks[$category] = [];
598 $validFooterLinks[$category][] =
$link;
601 if (
count( $validFooterLinks[$category] ) <= 0 ) {
602 unset( $validFooterLinks[$category] );
606 if ( $option ==
'flat' ) {
608 $validFooterLinks = array_merge( ...array_values( $validFooterLinks ) );
611 return $validFooterLinks;
628 $footericons = $this->
get(
'footericons' );
630 if ( $option ==
'icononly' ) {
632 foreach ( $footericons
as &$footerIconsBlock ) {
633 foreach ( $footerIconsBlock
as $footerIconKey => $footerIcon ) {
634 if ( !is_string( $footerIcon ) && !isset( $footerIcon[
'src'] ) ) {
635 unset( $footerIconsBlock[$footerIconKey] );
640 foreach ( $footericons
as $footerIconsKey => &$footerIconsBlock ) {
641 if (
count( $footerIconsBlock ) <= 0 ) {
642 unset( $footericons[$footerIconsKey] );
645 } elseif ( $option ==
'nocopyright' ) {
646 unset( $footericons[
'copyright'][
'copyright'] );
647 if (
count( $footericons[
'copyright'] ) <= 0 ) {
648 unset( $footericons[
'copyright'] );
664 protected function getFooter( $iconStyle =
'icononly', $linkStyle =
'flat' ) {
670 if (
count( $validFooterIcons ) +
count( $validFooterLinks ) > 0 ) {
672 'id' =>
'footer-bottom',
673 'role' =>
'contentinfo',
674 'lang' => $this->
get(
'userlang' ),
675 'dir' => $this->
get(
'dir' )
681 foreach ( $validFooterIcons
as $blockName => $footerIcons ) {
683 'id' => Sanitizer::escapeIdForAttribute(
"f-{$blockName}ico" ),
684 'class' =>
'footer-icons'
686 foreach ( $footerIcons
as $icon ) {
691 if (
count( $validFooterLinks ) > 0 ) {
693 foreach ( $validFooterLinks
as $aLink ) {
696 [
'id' => Sanitizer::escapeIdForAttribute( $aLink ) ],
734 $out =
"<div class=\"mw-indicators mw-body-content\">\n";
739 'id' => Sanitizer::escapeIdForAttribute(
"mw-indicator-$id" ),
740 'class' =>
'mw-indicator',
765 return WrappedString::join(
"\n", [
767 $this->
get(
'bottomscripts' ),
768 $this->
get(
'reporttime' )
getPersonalTools()
Create an array of personal tools items from the data in the quicktemplate stored by SkinTemplate.
getFooterLinks( $option=null)
Returns an array of footerlinks trimmed down to only those footer links that are valid.
msgWiki( $str)
An ugly, ugly hack.
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that probably a stub it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping $template
static getDebugHTML(IContextSource $context)
Returns the HTML to add to the page for the toolbar.
makeSearchButton( $mode, $attrs=[])
getClear()
Get a div with the core visualClear class, for clearing floats.
and how to run hooks for an and one after Each event has a preferably in CamelCase For ArticleDelete hook A clump of code and data that should be run when an event happens This can be either a function and a chunk of data
getSkin()
Get the Skin object related to this object.
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
static tooltipAndAccesskeyAttribs( $name, array $msgParams=[], $options=null)
Returns the attributes for the tooltip and access key.
static closeElement( $element)
Returns "</$element>".
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return an< a > element with HTML attributes $attribs and contents $html will be returned If you return $ret will be returned and may include noclasses & $html
namespace and then decline to actually register it file or subcat img or subcat $title
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Throws a warning that $function is deprecated.
getAfterPortlet( $name)
Allows extensions to hook into known portlets and add stuff to them.
printTrail()
Output getTrail.
makeListItem( $key, $item, $options=[])
Generates a list item for a navigation, portlet, portal, sidebar...
as see the revision history and available at free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to use
getIndicators()
Get the suggested HTML for page status indicators: icons (or short text snippets) usually displayed i...
Allows to change the fields on the form that will be generated $name
getFooter( $iconStyle='icononly', $linkStyle='flat')
Renderer for getFooterIcons and getFooterLinks.
renderAfterPortlet( $name)
getMsg( $name)
Get a Message object with its context set.
makeSearchInput( $attrs=[])
static titleAttrib( $name, $options=null, array $msgParams=[])
Given the id of an interface element, constructs the appropriate title attribute from the system mess...
Generic wrapper for template functions, with interface compatible with what we use of PHPTAL 0....
getToolbox()
Create an array of common toolbox items from the data in the quicktemplate stored by SkinTemplate.
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped & $options
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
getTrail()
Get the basic end-page trail including bottomscripts, reporttime, and debug stuff.
static openElement( $element, $attribs=[])
Identical to rawElement(), but has no third parameter and omits the end tag (and the self-closing '/'...
static rawElement( $element, $attribs=[], $contents='')
Returns an HTML element in a string.
usually copyright or history_copyright This message must be in HTML not wikitext & $link
makeLink( $key, $item, $options=[])
Makes a link, usually used by makeListItem to generate a link for an item in a list used in navigatio...
static element( $element, $attribs=[], $contents='')
Identical to rawElement(), but HTML-escapes $contents (like Xml::element()).
either a unescaped string or a HtmlArmor object after in associative array form externallinks including delete and has completed for all link tables whether this was an auto creation use $formDescriptor instead default is conds Array Extra conditions for the No matching items in log is displayed if loglist is empty msgKey Array If you want a nice box with a set this to the key of the message First element is the message additional optional elements are parameters for the key that are processed with wfMessage() -> params() ->parseAsBlock() - offset Set to overwrite offset parameter in $wgRequest set to '' to unset offset - wrap String Wrap the message in html(usually something like "<
getFooterIcons( $option=null)
Returns an array of footer icons filtered down by options relevant to how the skin wishes to display ...
static run( $event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
New base template for a skin's template extended from QuickTemplate this class features helper method...
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that probably a stub it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping see BaseTemplate::getToolbox and BaseTemplate::makeListItem for details on the format of individual items inside of this array or by returning and letting standard HTTP rendering take place modifiable or by returning false and taking over the output $out