Go to the documentation of this file.
113 if ( isset( $attrs[
'class'] ) ) {
114 if ( is_array( $attrs[
'class'] ) ) {
115 $attrs[
'class'][] =
'mw-ui-button';
116 $attrs[
'class'] = array_merge( $attrs[
'class'], $modifiers );
118 $attrs[
'class'] = implode(
' ', $attrs[
'class'] );
120 $attrs[
'class'] .=
' mw-ui-button ' . implode(
' ', $modifiers );
124 $attrs[
'class'] =
'mw-ui-button ' . implode(
' ', $modifiers );
140 if ( isset( $attrs[
'class'] ) ) {
141 if ( is_array( $attrs[
'class'] ) ) {
142 $attrs[
'class'][] =
'mw-ui-input';
144 $attrs[
'class'] .=
' mw-ui-input';
147 $attrs[
'class'] =
'mw-ui-input';
168 self::buttonAttributes( $attrs, $modifiers ),
187 $attrs[
'type'] =
'submit';
188 $attrs[
'value'] = $contents;
189 return self::element(
'input', self::buttonAttributes( $attrs, $modifiers ) );
212 if ( in_array( $element, self::$voidElements ) ) {
214 return substr( $start, 0, -1 ) .
'/>';
256 $element = strtolower( $element );
259 if ( $element ==
'input' ) {
287 if ( isset(
$attribs[
'type'] ) && !in_array(
$attribs[
'type'], $validTypes ) ) {
295 if ( $element ==
'button' && !isset(
$attribs[
'type'] ) ) {
300 self::dropDefaults( $element,
$attribs ) ) .
'>';
311 $element = strtolower( $element );
313 return "</$element>";
336 static $attribDefaults = [
337 'area' => [
'shape' =>
'rect' ],
339 'formaction' =>
'GET',
340 'formenctype' =>
'application/x-www-form-urlencoded',
348 'autocomplete' =>
'on',
349 'enctype' =>
'application/x-www-form-urlencoded',
352 'formaction' =>
'GET',
355 'keygen' => [
'keytype' =>
'rsa' ],
356 'link' => [
'media' =>
'all' ],
357 'menu' => [
'type' =>
'list' ],
358 'script' => [
'type' =>
'text/javascript' ],
361 'type' =>
'text/css',
363 'textarea' => [
'wrap' =>
'soft' ],
366 $element = strtolower( $element );
369 $lcattrib = strtolower( $attrib );
370 if ( is_array(
$value ) ) {
377 if ( isset( $attribDefaults[$element][$lcattrib] )
378 && $attribDefaults[$element][$lcattrib] ==
$value
383 if ( $lcattrib ==
'class' &&
$value ==
'' ) {
389 if ( $element ===
'link'
394 if ( $element ===
'input' ) {
397 if (
$type ===
'checkbox' ||
$type ===
'radio' ) {
404 } elseif (
$type ===
'submit' ) {
417 if ( $element ===
'select' && isset(
$attribs[
'size'] ) ) {
418 if ( in_array(
'multiple',
$attribs )
422 if ( strval(
$attribs[
'size'] ) ==
'4' ) {
427 if ( strval(
$attribs[
'size'] ) ==
'1' ) {
485 if ( is_int( $key ) && in_array( strtolower(
$value ), self::$boolAttribs ) ) {
491 $key = strtolower( $key );
495 $spaceSeparatedListAttributes = [
505 if ( in_array( $key, $spaceSeparatedListAttributes ) ) {
510 if ( is_array(
$value ) ) {
514 if ( is_string( $v ) ) {
517 if ( !isset(
$value[$v] ) ) {
529 $value = implode(
' ', $newValue );
539 } elseif ( is_array(
$value ) ) {
540 throw new MWException(
"HTML attribute $key can not contain a list of values" );
545 if ( in_array( $key, self::$boolAttribs ) ) {
546 $ret .=
" $key=\"\"";
548 $ret .=
" $key=$quote" . Sanitizer::encodeAttribute(
$value ) . $quote;
569 if ( $nonce !==
null ) {
570 $attrs[
'nonce'] = $nonce;
573 wfWarn(
"no nonce set on script. CSP will break it" );
577 if ( preg_match(
'/<\/?script/i', $contents ) ) {
578 wfLogWarning( __METHOD__ .
': Illegal character sequence found in inline script.' );
579 $contents =
'/* ERROR: Invalid script */';
594 $attrs = [
'src' => $url ];
595 if ( $nonce !==
null ) {
596 $attrs[
'nonce'] = $nonce;
599 wfWarn(
"no nonce set on script. CSP will break it" );
623 $contents = strtr( $contents, [
627 ']]>' =>
'\5D\5D\3E '
630 if ( preg_match(
'/[<&]/', $contents ) ) {
631 $contents =
"/*<![CDATA[*/$contents/*]]>*/";
649 'rel' =>
'stylesheet',
670 if ( in_array(
$type, [
'text',
'search',
'email',
'password',
'number' ] ) ) {
673 if ( in_array(
$type, [
'button',
'reset',
'submit' ] ) ) {
711 if ( $heading !==
'' ) {
814 if ( substr(
$value, 0, 1 ) ==
"\n" ) {
819 $spacedValue =
"\n" .
$value;
834 if ( !isset(
$params[
'exclude'] ) || !is_array(
$params[
'exclude'] ) ) {
838 if ( isset(
$params[
'all'] ) ) {
845 MediaWikiServices::getInstance()->getContentLanguage()->getFormattedNamespaces();
856 $nsName =
wfMessage(
'blanknamespace' )->text();
857 } elseif ( is_int( $nsId ) ) {
858 $nsName = MediaWikiServices::getInstance()->getContentLanguage()->
859 convertNamespace( $nsId );
861 $optionsOut[$nsId] = $nsName;
884 array $selectAttribs = []
886 ksort( $selectAttribs );
889 if ( isset(
$params[
'selected'] ) ) {
894 if ( preg_match(
'/^\d+$/',
$params[
'selected'] ) ) {
902 if ( !isset(
$params[
'disable'] ) || !is_array(
$params[
'disable'] ) ) {
914 'disabled' => in_array( $nsId,
$params[
'disable'] ),
916 'selected' => $nsId ===
$params[
'selected'],
921 if ( !array_key_exists(
'id', $selectAttribs ) ) {
922 $selectAttribs[
'id'] =
'namespace';
925 if ( !array_key_exists(
'name', $selectAttribs ) ) {
926 $selectAttribs[
'name'] =
'namespace';
930 if ( isset(
$params[
'label'] ) ) {
933 'for' => $selectAttribs[
'id'] ??
null,
941 . implode(
"\n", $optionsHtml )
966 $ret .=
"<?xml version=\"1.0\" encoding=\"UTF-8\" ?" .
">\n";
969 $attribs[
'xmlns'] =
'http://www.w3.org/1999/xhtml';
977 $ret .=
"<!DOCTYPE html>\n";
996 # https://html.spec.whatwg.org/multipage/infrastructure.html#xml-mime-type
999 # * Any MIME type with a subtype ending in +xml (this implicitly includes application/xhtml+xml)
1000 return (
bool)preg_match(
'!^(text|application)/xml$|^.+/.+\+xml$!', $mimetype );
1013 static function infoBox( $text, $icon, $alt, $class =
'' ) {
1062 foreach ( $urls
as $density => $url ) {
1065 $density = (
string)(
float)$density;
1066 $candidates[$density] = $url;
1070 ksort( $candidates, SORT_NUMERIC );
1071 $candidates = array_unique( $candidates );
1074 foreach ( $candidates
as $density => $url ) {
1075 $candidates[$density] = $url .
' ' . $density .
'x';
1078 return implode(
", ", $candidates );
static errorBox( $html, $heading='')
Return an error box.
static linkButton( $contents, array $attrs, array $modifiers=[])
Returns an HTML link element in a string styled as a button (when $wgUseMediaWikiUIEverywhere is enab...
static textarea( $name, $value='', array $attribs=[])
Convenience function to produce a <textarea> element.
$wgMimeType
The default Content-Type header.
static getTextInputAttributes(array $attrs)
Modifies a set of attributes meant for text input elements and apply a set of default attributes.
static check( $name, $checked=false, array $attribs=[])
Convenience function to produce a checkbox (input element with type=checkbox)
$wgUseMediaWikiUIEverywhere
Temporary variable that applies MediaWiki UI wherever it can be supported.
static expandAttributes(array $attribs)
Given an associative array of element attributes, generate a string to stick after the element name i...
static htmlHeader(array $attribs=[])
Constructs the opening html-tag with necessary doctypes depending on global variables.
wfLogWarning( $msg, $callerOffset=1, $level=E_USER_WARNING)
Send a warning as a PHP error and the debug log.
static buttonAttributes(array $attrs, array $modifiers=[])
Modifies a set of attributes meant for button elements and apply a set of default attributes when $wg...
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 successBox( $html)
Return a success box.
static input( $name, $value='', $type='text', array $attribs=[])
Convenience function to produce an "<input>" element.
static closeElement( $element)
Returns "</$element>".
static isXmlMimeType( $mimetype)
Determines if the given MIME type is xml.
static linkedScript( $url, $nonce=null)
Output a "<script>" tag linking to the given URL, e.g., "<script src=foo.js></script>".
static srcSet(array $urls)
Generate a srcset attribute value.
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
$wgHtml5Version
Defines the value of the version attribute in the <html> tag, if any.
static dropDefaults( $element, array $attribs)
Given an element name and an associative array of element attributes, return an array that is functio...
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 after processing & $attribs
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
static radio( $name, $checked=false, array $attribs=[])
Convenience function to produce a radio button (input element with type=radio)
static warningBox( $html)
Return a warning box.
The wiki should then use memcached to cache various data To use multiple just add more items to the array To increase the weight of a make its entry a array("192.168.0.1:11211", 2))
static label( $label, $id, array $attribs=[])
Convenience function for generating a label for inputs.
This code would result in ircNotify being run twice when an article is and once for brion Hooks can return three possible true was required This is the default since MediaWiki *some string
static infoBox( $text, $icon, $alt, $class='')
Get HTML for an info box with an icon.
Allows to change the fields on the form that will be generated $name
static inlineStyle( $contents, $media='all', $attribs=[])
Output a "<style>" tag with the given contents for the given media type (if any).
static hidden( $name, $value, array $attribs=[])
Convenience function to produce an input element with type=hidden.
static inlineScript( $contents, $nonce=null)
Output an HTML script tag with the given contents.
static namespaceSelectorOptions(array $params=[])
Helper for Html::namespaceSelector().
static namespaceSelector(array $params=[], array $selectAttribs=[])
Build a drop-down box for selecting a namespace.
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 & $ret
static submitButton( $contents, array $attrs, array $modifiers=[])
Returns an HTML link element in a string styled as a button (when $wgUseMediaWikiUIEverywhere is enab...
static getMain()
Get the RequestContext object associated with the main request.
static isNonceRequired(Config $config)
Should we set nonce attribute.
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
static linkedStyle( $url, $media='all')
Output a "<link rel=stylesheet>" linking to the given URL for the given media type (if any).
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
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.
wfWarn( $msg, $callerOffset=1, $level=E_USER_NOTICE)
Send a warning either to the debug log or in a PHP error depending on $wgDevelopmentWarnings.
$wgXhtmlNamespaces
Permit other namespaces in addition to the w3.org default.
static element( $element, $attribs=[], $contents='')
Identical to rawElement(), but HTML-escapes $contents (like Xml::element()).
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 MediaWikiServices
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 "<
static messageBox( $html, $className, $heading='')
Return the HTML for a message box.
This class is a collection of static functions that serve two purposes: