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 );
260 if ( strpos( $element,
' ' ) !==
false ) {
261 wfWarn( __METHOD__ .
" given element name with space '$element'" );
265 if ( $element ==
'input' ) {
293 if ( isset(
$attribs[
'type'] ) && !in_array(
$attribs[
'type'], $validTypes ) ) {
301 if ( $element ==
'button' && !isset(
$attribs[
'type'] ) ) {
305 return "<$element" . self::expandAttributes(
306 self::dropDefaults( $element,
$attribs ) ) .
'>';
317 $element = strtolower( $element );
319 return "</$element>";
342 static $attribDefaults = [
343 'area' => [
'shape' =>
'rect' ],
345 'formaction' =>
'GET',
346 'formenctype' =>
'application/x-www-form-urlencoded',
354 'autocomplete' =>
'on',
355 'enctype' =>
'application/x-www-form-urlencoded',
358 'formaction' =>
'GET',
361 'keygen' => [
'keytype' =>
'rsa' ],
362 'link' => [
'media' =>
'all' ],
363 'menu' => [
'type' =>
'list' ],
364 'script' => [
'type' =>
'text/javascript' ],
367 'type' =>
'text/css',
369 'textarea' => [
'wrap' =>
'soft' ],
372 $element = strtolower( $element );
375 $lcattrib = strtolower( $attrib );
376 if ( is_array(
$value ) ) {
383 if ( isset( $attribDefaults[$element][$lcattrib] )
384 && $attribDefaults[$element][$lcattrib] ==
$value
389 if ( $lcattrib ==
'class' &&
$value ==
'' ) {
395 if ( $element ===
'link'
400 if ( $element ===
'input' ) {
403 if (
$type ===
'checkbox' ||
$type ===
'radio' ) {
410 } elseif (
$type ===
'submit' ) {
423 if ( $element ===
'select' && isset(
$attribs[
'size'] ) ) {
424 if ( in_array(
'multiple',
$attribs )
428 if ( strval(
$attribs[
'size'] ) ==
'4' ) {
433 if ( strval(
$attribs[
'size'] ) ==
'1' ) {
491 if ( is_int( $key ) && in_array( strtolower(
$value ), self::$boolAttribs ) ) {
497 $key = strtolower( $key );
501 $spaceSeparatedListAttributes = [
511 if ( in_array( $key, $spaceSeparatedListAttributes ) ) {
516 if ( is_array(
$value ) ) {
520 if ( is_string( $v ) ) {
523 if ( !isset(
$value[$v] ) ) {
535 $value = implode(
' ', $newValue );
545 } elseif ( is_array(
$value ) ) {
546 throw new MWException(
"HTML attribute $key can not contain a list of values" );
551 if ( in_array( $key, self::$boolAttribs ) ) {
552 $ret .=
" $key=\"\"";
554 $ret .=
" $key=$quote" . Sanitizer::encodeAttribute(
$value ) . $quote;
575 if ( $nonce !==
null ) {
576 $attrs[
'nonce'] = $nonce;
578 wfWarn(
"no nonce set on script. CSP will break it" );
581 if ( preg_match(
'/<\/?script/i', $contents ) ) {
582 wfLogWarning( __METHOD__ .
': Illegal character sequence found in inline script.' );
583 $contents =
'/* ERROR: Invalid script */';
586 return self::rawElement(
'script', $attrs, $contents );
598 $attrs = [
'src' => $url ];
599 if ( $nonce !==
null ) {
600 $attrs[
'nonce'] = $nonce;
602 wfWarn(
"no nonce set on script. CSP will break it" );
605 return self::element(
'script', $attrs );
625 $contents = strtr( $contents, [
629 ']]>' =>
'\5D\5D\3E '
632 if ( preg_match(
'/[<&]/', $contents ) ) {
633 $contents =
"/*<![CDATA[*/$contents/*]]>*/";
636 return self::rawElement(
'style', [
650 return self::element(
'link', [
651 'rel' =>
'stylesheet',
672 if ( in_array(
$type, [
'text',
'search',
'email',
'password',
'number' ] ) ) {
675 if ( in_array(
$type, [
'button',
'reset',
'submit' ] ) ) {
678 return self::element(
'input',
$attribs );
713 if ( $heading !==
'' ) {
714 $html = self::element(
'h2', [], $heading ) .
$html;
716 return self::rawElement(
'div', [
'class' => $className ],
$html );
726 return self::messageBox(
$html,
'warningbox' );
737 return self::messageBox(
$html,
'errorbox', $heading );
747 return self::messageBox(
$html,
'successbox' );
785 return self::element(
'label',
$attribs, $label );
816 if ( substr(
$value, 0, 1 ) ==
"\n" ) {
821 $spacedValue =
"\n" .
$value;
825 return self::element(
'textarea', self::getTextInputAttributes(
$attribs ), $spacedValue );
836 if ( !isset(
$params[
'exclude'] ) || !is_array(
$params[
'exclude'] ) ) {
840 if ( isset(
$params[
'all'] ) ) {
845 if (
$params[
'in-user-lang'] ??
false ) {
849 $lang = MediaWikiServices::getInstance()->getContentLanguage();
863 $nsName =
wfMessage(
'blanknamespace' )->text();
864 } elseif ( is_int( $nsId ) ) {
865 $nsName =
$lang->convertNamespace( $nsId );
867 $optionsOut[$nsId] = $nsName;
890 array $selectAttribs = []
892 ksort( $selectAttribs );
895 if ( isset(
$params[
'selected'] ) ) {
900 if ( preg_match(
'/^\d+$/',
$params[
'selected'] ) ) {
908 if ( !isset(
$params[
'disable'] ) || !is_array(
$params[
'disable'] ) ) {
918 $optionsHtml[] = self::element(
920 'disabled' => in_array( $nsId,
$params[
'disable'] ),
922 'selected' => $nsId ===
$params[
'selected'],
927 if ( !array_key_exists(
'id', $selectAttribs ) ) {
928 $selectAttribs[
'id'] =
'namespace';
931 if ( !array_key_exists(
'name', $selectAttribs ) ) {
932 $selectAttribs[
'name'] =
'namespace';
936 if ( isset(
$params[
'label'] ) ) {
937 $ret .= self::element(
939 'for' => $selectAttribs[
'id'] ??
null,
945 $ret .= self::openElement(
'select', $selectAttribs )
947 . implode(
"\n", $optionsHtml )
949 . self::closeElement(
'select' );
972 $ret .=
"<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n";
975 $attribs[
'xmlns'] =
'http://www.w3.org/1999/xhtml';
982 $ret .=
"<!DOCTYPE html>\n";
1004 # * Any MIME type with a subtype ending in +xml (this implicitly includes application/xhtml+xml)
1005 return (
bool)preg_match(
'!^(text|application)/xml$|^.+/.+\+xml$!', $mimetype );
1018 static function infoBox( $text, $icon, $alt, $class =
'' ) {
1019 $s = self::openElement(
'div', [
'class' =>
"mw-infobox $class" ] );
1021 $s .= self::openElement(
'div', [
'class' =>
'mw-infobox-left' ] ) .
1022 self::element(
'img',
1028 self::closeElement(
'div' );
1030 $s .= self::openElement(
'div', [
'class' =>
'mw-infobox-right' ] ) .
1032 self::closeElement(
'div' );
1033 $s .= self::element(
'div', [
'style' =>
'clear: left;' ],
' ' );
1035 $s .= self::closeElement(
'div' );
1037 $s .= self::element(
'div', [
'style' =>
'clear: left;' ],
' ' );
1067 foreach (
$urls as $density => $url ) {
1070 $density = (
string)(
float)$density;
1071 $candidates[$density] = $url;
1075 ksort( $candidates, SORT_NUMERIC );
1076 $candidates = array_unique( $candidates );
1079 foreach ( $candidates
as $density => $url ) {
1080 $candidates[$density] = $url .
' ' . $density .
'x';
1083 return implode(
", ", $candidates );
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
$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 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
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
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
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))
if(!isset( $args[0])) $lang