111 if ( $wgUseMediaWikiUIEverywhere ) {
112 if ( isset( $attrs[
'class'] ) ) {
113 if ( is_array( $attrs[
'class'] ) ) {
114 $attrs[
'class'][] =
'mw-ui-button';
115 $attrs[
'class'] = array_merge( $attrs[
'class'], $modifiers );
117 $attrs[
'class'] = implode(
' ', $attrs[
'class'] );
119 $attrs[
'class'] .=
' mw-ui-button ' . implode(
' ', $modifiers );
123 $attrs[
'class'] =
'mw-ui-button ' . implode(
' ', $modifiers );
138 if ( $wgUseMediaWikiUIEverywhere ) {
139 if ( isset( $attrs[
'class'] ) ) {
140 if ( is_array( $attrs[
'class'] ) ) {
141 $attrs[
'class'][] =
'mw-ui-input';
143 $attrs[
'class'] .=
' mw-ui-input';
146 $attrs[
'class'] =
'mw-ui-input';
166 return self::element(
'a',
167 self::buttonAttributes( $attrs, $modifiers ),
186 $attrs[
'type'] =
'submit';
187 $attrs[
'value'] = $contents;
188 return self::element(
'input', self::buttonAttributes( $attrs, $modifiers ) );
210 $start = self::openElement( $element,
$attribs );
211 if ( in_array( $element, self::$voidElements ) ) {
213 return substr( $start, 0, -1 ) .
'/>';
215 return "$start$contents" . self::closeElement( $element );
230 return self::rawElement( $element,
$attribs, strtr( $contents, [
251 $element = strtolower( $element );
254 if ( $element ==
'input' ) {
282 if ( isset(
$attribs[
'type'] ) && !in_array(
$attribs[
'type'], $validTypes ) ) {
290 if ( $element ==
'button' && !isset(
$attribs[
'type'] ) ) {
294 return "<$element" . self::expandAttributes(
295 self::dropDefaults( $element,
$attribs ) ) .
'>';
306 $element = strtolower( $element );
308 return "</$element>";
331 static $attribDefaults = [
332 'area' => [
'shape' =>
'rect' ],
334 'formaction' =>
'GET',
335 'formenctype' =>
'application/x-www-form-urlencoded',
343 'autocomplete' =>
'on',
344 'enctype' =>
'application/x-www-form-urlencoded',
347 'formaction' =>
'GET',
350 'keygen' => [
'keytype' =>
'rsa' ],
351 'link' => [
'media' =>
'all' ],
352 'menu' => [
'type' =>
'list' ],
353 'script' => [
'type' =>
'text/javascript' ],
356 'type' =>
'text/css',
358 'textarea' => [
'wrap' =>
'soft' ],
361 $element = strtolower( $element );
363 foreach ( $attribs
as $attrib =>
$value ) {
364 $lcattrib = strtolower( $attrib );
365 if ( is_array(
$value ) ) {
372 if ( isset( $attribDefaults[$element][$lcattrib] )
373 && $attribDefaults[$element][$lcattrib] ==
$value
375 unset( $attribs[$attrib] );
378 if ( $lcattrib ==
'class' &&
$value ==
'' ) {
379 unset( $attribs[$attrib] );
384 if ( $element ===
'link'
385 && isset( $attribs[
'type'] ) && strval( $attribs[
'type'] ) ==
'text/css'
387 unset( $attribs[
'type'] );
389 if ( $element ===
'input' ) {
390 $type = isset( $attribs[
'type'] ) ? $attribs[
'type'] : null;
391 $value = isset( $attribs[
'value'] ) ? $attribs[
'value'] : null;
392 if (
$type ===
'checkbox' ||
$type ===
'radio' ) {
397 unset( $attribs[
'value'] );
399 } elseif (
$type ===
'submit' ) {
408 unset( $attribs[
'value'] );
412 if ( $element ===
'select' && isset( $attribs[
'size'] ) ) {
413 if ( in_array(
'multiple', $attribs )
414 || ( isset( $attribs[
'multiple'] ) && $attribs[
'multiple'] !==
false )
417 if ( strval( $attribs[
'size'] ) ==
'4' ) {
418 unset( $attribs[
'size'] );
422 if ( strval( $attribs[
'size'] ) ==
'1' ) {
423 unset( $attribs[
'size'] );
472 foreach ( $attribs
as $key =>
$value ) {
480 if ( is_int( $key ) && in_array( strtolower(
$value ), self::$boolAttribs ) ) {
486 $key = strtolower( $key );
499 if ( in_array( $key, [
'max',
'min',
'pattern',
'required' ] )
500 || $key ===
'step' &&
$value !==
'any' ) {
506 $spaceSeparatedListAttributes = [
516 if ( in_array( $key, $spaceSeparatedListAttributes ) ) {
521 if ( is_array(
$value ) ) {
525 if ( is_string( $v ) ) {
528 if ( !isset(
$value[$v] ) ) {
540 $value = implode(
' ', $newValue );
550 } elseif ( is_array(
$value ) ) {
551 throw new MWException(
"HTML attribute $key can not contain a list of values" );
556 if ( in_array( $key, self::$boolAttribs ) ) {
557 $ret .=
" $key=\"\"";
580 $ret .=
" $key=$quote" . strtr(
$value, $map ) . $quote;
598 if ( preg_match(
'/[<&]/', $contents ) ) {
599 $contents =
"/*<![CDATA[*/$contents/*]]>*/";
602 return self::rawElement(
'script', $attrs, $contents );
613 $attrs = [
'src' => $url ];
615 return self::element(
'script', $attrs );
632 $contents = strtr( $contents, [
636 ']]>' =>
'\5D\5D\3E '
639 if ( preg_match(
'/[<&]/', $contents ) ) {
640 $contents =
"/*<![CDATA[*/$contents/*]]>*/";
643 return self::rawElement(
'style', [
657 return self::element(
'link', [
658 'rel' =>
'stylesheet',
679 if ( in_array(
$type, [
'text',
'search',
'email',
'password',
'number' ] ) ) {
682 if ( in_array(
$type, [
'button',
'reset',
'submit' ] ) ) {
685 return self::element(
'input',
$attribs );
746 return self::element(
'label',
$attribs, $label );
777 if ( substr(
$value, 0, 1 ) ==
"\n" ) {
782 $spacedValue =
"\n" .
$value;
786 return self::element(
'textarea', self::getTextInputAttributes(
$attribs ), $spacedValue );
799 if ( !isset(
$params[
'exclude'] ) || !is_array(
$params[
'exclude'] ) ) {
803 if ( isset(
$params[
'all'] ) ) {
809 $options += $wgContLang->getFormattedNamespaces();
820 $nsName =
wfMessage(
'blanknamespace' )->text();
821 } elseif ( is_int( $nsId ) ) {
822 $nsName = $wgContLang->convertNamespace( $nsId );
824 $optionsOut[$nsId] = $nsName;
847 array $selectAttribs = []
849 ksort( $selectAttribs );
852 if ( isset(
$params[
'selected'] ) ) {
857 if ( preg_match(
'/^\d+$/',
$params[
'selected'] ) ) {
865 if ( !isset(
$params[
'disable'] ) || !is_array(
$params[
'disable'] ) ) {
875 $optionsHtml[] = self::element(
877 'disabled' => in_array( $nsId,
$params[
'disable'] ),
879 'selected' => $nsId ===
$params[
'selected'],
884 if ( !array_key_exists(
'id', $selectAttribs ) ) {
885 $selectAttribs[
'id'] =
'namespace';
888 if ( !array_key_exists(
'name', $selectAttribs ) ) {
889 $selectAttribs[
'name'] =
'namespace';
893 if ( isset(
$params[
'label'] ) ) {
894 $ret .= self::element(
896 'for' => isset( $selectAttribs[
'id'] ) ? $selectAttribs[
'id'] : null,
902 $ret .= self::openElement(
'select', $selectAttribs )
904 . implode(
"\n", $optionsHtml )
906 . self::closeElement(
'select' );
924 $isXHTML = self::isXmlMimeType( $wgMimeType );
929 $ret .=
"<?xml version=\"1.0\" encoding=\"UTF-8\" ?" .
">\n";
932 $attribs[
'xmlns'] =
'http://www.w3.org/1999/xhtml';
935 foreach ( $wgXhtmlNamespaces
as $tag => $ns ) {
940 $ret .=
"<!DOCTYPE html>\n";
943 if ( $wgHtml5Version ) {
959 # http://www.whatwg.org/html/infrastructure.html#xml-mime-type
962 # * Any MIME type with a subtype ending in +xml (this implicitly includes application/xhtml+xml)
963 return (
bool)preg_match(
'!^(text|application)/xml$|^.+/.+\+xml$!', $mimetype );
976 static function infoBox( $text, $icon, $alt, $class =
'' ) {
977 $s = self::openElement(
'div', [
'class' =>
"mw-infobox $class" ] );
979 $s .= self::openElement(
'div', [
'class' =>
'mw-infobox-left' ] ) .
980 self::element(
'img',
986 self::closeElement(
'div' );
988 $s .= self::openElement(
'div', [
'class' =>
'mw-infobox-right' ] ) .
990 self::closeElement(
'div' );
991 $s .= self::element(
'div', [
'style' =>
'clear: left;' ],
' ' );
993 $s .= self::closeElement(
'div' );
995 $s .= self::element(
'div', [
'style' =>
'clear: left;' ],
' ' );
1025 foreach ( $urls
as $density => $url ) {
1028 $density = (
string)(
float)$density;
1029 $candidates[$density] = $url;
1033 ksort( $candidates, SORT_NUMERIC );
1034 $candidates = array_unique( $candidates );
1037 foreach ( $candidates
as $density => $url ) {
1038 $candidates[$density] = $url .
' ' . $density .
'x';
1041 return implode(
", ", $candidates );
static closeElement($element)
Returns "$element>".
static inlineScript($contents)
Output a "".
when a variable name is used in a it is silently declared as a new local masking the global
static infoBox($text, $icon, $alt, $class= '')
Get HTML for an info box with an icon.
static radio($name, $checked=false, array $attribs=[])
Convenience function to produce a radio button (input element with type=radio)
static getTextInputAttributes(array $attrs)
Modifies a set of attributes meant for text input elements and apply a set of default attributes...
static openElement($element, $attribs=[])
Identical to rawElement(), but has no third parameter and omits the end tag (and the self-closing '/'...
static textarea($name, $value= '', array $attribs=[])
Convenience function to produce a
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 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 unsetoffset-wrap String Wrap the message in html(usually something like"<
static dropDefaults($element, array $attribs)
Given an element name and an associative array of element attributes, return an array that is functio...
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set and then return false from the hook function Ensure you consume the ChangeTagAfterDelete hook to carry out custom deletion actions as context called by AbstractContent::getParserOutput May be used to override the normal model specific rendering of page content as context as context $options
static check($name, $checked=false, array $attribs=[])
Convenience function to produce a checkbox (input element with type=checkbox)
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
$wgUseMediaWikiUIEverywhere
Temporary variable that applies MediaWiki UI wherever it can be supported.
static inlineStyle($contents, $media= 'all')
Output a "