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';
167 return self::element(
'a',
168 self::buttonAttributes( $attrs, $modifiers ),
187 $attrs[
'type'] =
'submit';
188 $attrs[
'value'] = $contents;
189 return self::element(
'input', self::buttonAttributes( $attrs, $modifiers ) );
211 $start = self::openElement( $element,
$attribs );
212 if ( in_array( $element, self::$voidElements ) ) {
214 return substr( $start, 0, -1 ) .
'/>';
216 return "$start$contents" . self::closeElement( $element );
233 return self::rawElement( $element,
$attribs, strtr( $contents, [
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'] ) ) {
299 return "<$element" . self::expandAttributes(
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 ) ) {
513 foreach (
$value as $k => $v ) {
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 */';
582 return self::rawElement(
'script', $attrs, $contents );
594 $attrs = [
'src' => $url ];
595 if ( $nonce !==
null ) {
596 $attrs[
'nonce'] = $nonce;
599 wfWarn(
"no nonce set on script. CSP will break it" );
603 return self::element(
'script', $attrs );
623 $contents = strtr( $contents, [
627 ']]>' =>
'\5D\5D\3E '
630 if ( preg_match(
'/[<&]/', $contents ) ) {
631 $contents =
"/*<![CDATA[*/$contents/*]]>*/";
634 return self::rawElement(
'style', [
648 return self::element(
'link', [
649 'rel' =>
'stylesheet',
670 if ( in_array(
$type, [
'text',
'search',
'email',
'password',
'number' ] ) ) {
673 if ( in_array(
$type, [
'button',
'reset',
'submit' ] ) ) {
676 return self::element(
'input',
$attribs );
711 if ( $heading !==
'' ) {
712 $html = self::element(
'h2', [], $heading ) .
$html;
714 return self::rawElement(
'div', [
'class' => $className ],
$html );
724 return self::messageBox(
$html,
'warningbox' );
735 return self::messageBox(
$html,
'errorbox', $heading );
745 return self::messageBox(
$html,
'successbox' );
783 return self::element(
'label',
$attribs, $label );
814 if ( substr(
$value, 0, 1 ) ==
"\n" ) {
819 $spacedValue =
"\n" .
$value;
823 return self::element(
'textarea', self::getTextInputAttributes(
$attribs ), $spacedValue );
834 if ( !isset(
$params[
'exclude'] ) || !is_array(
$params[
'exclude'] ) ) {
838 if ( isset(
$params[
'all'] ) ) {
845 MediaWikiServices::getInstance()->getContentLanguage()->getFormattedNamespaces();
849 foreach (
$options as $nsId => $nsName ) {
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'] ) ) {
911 foreach (
$options as $nsId => $nsName ) {
912 $optionsHtml[] = self::element(
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'] ) ) {
931 $ret .= self::element(
933 'for' => $selectAttribs[
'id'] ??
null,
939 $ret .= self::openElement(
'select', $selectAttribs )
941 . implode(
"\n", $optionsHtml )
943 . self::closeElement(
'select' );
966 $ret .=
"<?xml version=\"1.0\" encoding=\"UTF-8\" ?" .
">\n";
969 $attribs[
'xmlns'] =
'http://www.w3.org/1999/xhtml';
977 $ret .=
"<!DOCTYPE html>\n";
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 =
'' ) {
1014 $s = self::openElement(
'div', [
'class' =>
"mw-infobox $class" ] );
1016 $s .= self::openElement(
'div', [
'class' =>
'mw-infobox-left' ] ) .
1017 self::element(
'img',
1023 self::closeElement(
'div' );
1025 $s .= self::openElement(
'div', [
'class' =>
'mw-infobox-right' ] ) .
1027 self::closeElement(
'div' );
1028 $s .= self::element(
'div', [
'style' =>
'clear: left;' ],
' ' );
1030 $s .= self::closeElement(
'div' );
1032 $s .= self::element(
'div', [
'style' =>
'clear: left;' ],
' ' );
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 );
$wgMimeType
The default Content-Type header.
$wgUseMediaWikiUIEverywhere
Temporary variable that applies MediaWiki UI wherever it can be supported.
$wgHtml5Version
Defines the value of the version attribute in the <html> tag, if any.
$wgXhtmlNamespaces
Permit other namespaces in addition to the w3.org default.
wfWarn( $msg, $callerOffset=1, $level=E_USER_NOTICE)
Send a warning either to the debug log or in a PHP error depending on $wgDevelopmentWarnings.
wfLogWarning( $msg, $callerOffset=1, $level=E_USER_WARNING)
Send a warning as a PHP error and the debug log.
static isNonceRequired(Config $config)
Should we set nonce attribute.
This class is a collection of static functions that serve two purposes:
static inlineScript( $contents, $nonce=null)
Output an HTML script tag with the given contents.
static label( $label, $id, array $attribs=[])
Convenience function for generating a label for inputs.
static textarea( $name, $value='', array $attribs=[])
Convenience function to produce a <textarea> element.
static infoBox( $text, $icon, $alt, $class='')
Get HTML for an info box with an icon.
static namespaceSelectorOptions(array $params=[])
Helper for Html::namespaceSelector().
static linkedScript( $url, $nonce=null)
Output a "<script>" tag linking to the given URL, e.g., "<script src=foo.js></script>".
static buttonAttributes(array $attrs, array $modifiers=[])
Modifies a set of attributes meant for button elements and apply a set of default attributes when $wg...
static linkedStyle( $url, $media='all')
Output a "<link rel=stylesheet>" linking to the given URL for the given media type (if any).
static element( $element, $attribs=[], $contents='')
Identical to rawElement(), but HTML-escapes $contents (like Xml::element()).
static messageBox( $html, $className, $heading='')
Return the HTML for a message box.
static isXmlMimeType( $mimetype)
Determines if the given MIME type is xml.
static linkButton( $contents, array $attrs, array $modifiers=[])
Returns an HTML link element in a string styled as a button (when $wgUseMediaWikiUIEverywhere is enab...
static htmlHeader(array $attribs=[])
Constructs the opening html-tag with necessary doctypes depending on global variables.
static input( $name, $value='', $type='text', array $attribs=[])
Convenience function to produce an "<input>" element.
static dropDefaults( $element, array $attribs)
Given an element name and an associative array of element attributes, return an array that is functio...
static errorBox( $html, $heading='')
Return an error box.
static submitButton( $contents, array $attrs, array $modifiers=[])
Returns an HTML link element in a string styled as a button (when $wgUseMediaWikiUIEverywhere is enab...
static getTextInputAttributes(array $attrs)
Modifies a set of attributes meant for text input elements and apply a set of default attributes.
static radio( $name, $checked=false, array $attribs=[])
Convenience function to produce a radio button (input element with type=radio)
static expandAttributes(array $attribs)
Given an associative array of element attributes, generate a string to stick after the element name i...
static rawElement( $element, $attribs=[], $contents='')
Returns an HTML element in a string.
static warningBox( $html)
Return a warning box.
static namespaceSelector(array $params=[], array $selectAttribs=[])
Build a drop-down box for selecting a namespace.
static openElement( $element, $attribs=[])
Identical to rawElement(), but has no third parameter and omits the end tag (and the self-closing '/'...
static successBox( $html)
Return a success box.
static check( $name, $checked=false, array $attribs=[])
Convenience function to produce a checkbox (input element with type=checkbox)
static srcSet(array $urls)
Generate a srcset attribute value.
static closeElement( $element)
Returns "</$element>".
static hidden( $name, $value, array $attribs=[])
Convenience function to produce an input element with type=hidden.
static inlineStyle( $contents, $media='all', $attribs=[])
Output a "<style>" tag with the given contents for the given media type (if any).
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
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
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
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 "<div ...>$1</div>"). - flags Integer display flags(NO_ACTION_LINK, NO_EXTRA_USER_LINKS) 'LogException':Called before an exception(or PHP error) is logged. This is meant for integration with external error aggregation services
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
Allows to change the fields on the form that will be generated $name
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
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))