8 protected function setUp() {
12 $langObj->setNamespaces( [
24 9 =>
'MediaWiki_talk',
26 11 =>
'Template_talk',
33 'wgUseMediaWikiUIEverywhere' =>
false,
42 'Converting a null list of attributes'
45 'Converting an empty list of attributes'
53 $this->setExpectedException(
'MWException' );
64 'Opening element with no attributes'
75 'Terminated empty element'
84 '<input name="name" value="0" />',
86 'Input with a value of 0 (bug 23797)'
95 '<element>hello <there> you & you</element>',
96 Xml::element(
'element', null,
'hello <there> you & you' ),
97 'Element with no attributes and content that needs escaping'
106 'replace " > and < with their HTML entitites'
115 '<element key="value" <>="<>">',
116 Xml::element(
'element', [
'key' =>
'value',
'<>' =>
'<>' ], null ),
117 'Element attributes, keys are not escaped'
128 'openElement() shortcut'
136 $this->assertEquals(
'</element>',
Xml::closeElement(
'element' ),
'closeElement() shortcut' );
143 $curYear = intval( gmdate(
'Y' ) );
144 $prevYear = $curYear - 1;
146 $curMonth = intval( gmdate(
'n' ) );
148 $nextMonth = $curMonth + 1;
149 if ( $nextMonth == 13 ) {
154 '<label for="year">From year (and earlier):</label> ' .
155 '<input id="year" maxlength="4" size="7" type="number" value="2011" name="year"/> ' .
156 '<label for="month">From month (and earlier):</label> ' .
157 '<select name="month" id="month" class="mw-month-selector">' .
158 '<option value="-1">all</option>' .
"\n" .
159 '<option value="1">January</option>' .
"\n" .
160 '<option value="2" selected="">February</option>' .
"\n" .
161 '<option value="3">March</option>' .
"\n" .
162 '<option value="4">April</option>' .
"\n" .
163 '<option value="5">May</option>' .
"\n" .
164 '<option value="6">June</option>' .
"\n" .
165 '<option value="7">July</option>' .
"\n" .
166 '<option value="8">August</option>' .
"\n" .
167 '<option value="9">September</option>' .
"\n" .
168 '<option value="10">October</option>' .
"\n" .
169 '<option value="11">November</option>' .
"\n" .
170 '<option value="12">December</option></select>',
172 "Date menu for february 2011"
175 '<label for="year">From year (and earlier):</label> ' .
176 '<input id="year" maxlength="4" size="7" type="number" value="2011" name="year"/> ' .
177 '<label for="month">From month (and earlier):</label> ' .
178 '<select name="month" id="month" class="mw-month-selector">' .
179 '<option value="-1">all</option>' .
"\n" .
180 '<option value="1">January</option>' .
"\n" .
181 '<option value="2">February</option>' .
"\n" .
182 '<option value="3">March</option>' .
"\n" .
183 '<option value="4">April</option>' .
"\n" .
184 '<option value="5">May</option>' .
"\n" .
185 '<option value="6">June</option>' .
"\n" .
186 '<option value="7">July</option>' .
"\n" .
187 '<option value="8">August</option>' .
"\n" .
188 '<option value="9">September</option>' .
"\n" .
189 '<option value="10">October</option>' .
"\n" .
190 '<option value="11">November</option>' .
"\n" .
191 '<option value="12">December</option></select>',
193 "Date menu with negative month for 'All'"
198 "Date menu year is the current one when not specified"
201 $wantedYear = $nextMonth == 1 ? $curYear : $prevYear;
205 "Date menu next month is 11 months ago"
209 '<label for="year">From year (and earlier):</label> ' .
210 '<input id="year" maxlength="4" size="7" type="number" name="year"/> ' .
211 '<label for="month">From month (and earlier):</label> ' .
212 '<select name="month" id="month" class="mw-month-selector">' .
213 '<option value="-1">all</option>' .
"\n" .
214 '<option value="1">January</option>' .
"\n" .
215 '<option value="2">February</option>' .
"\n" .
216 '<option value="3">March</option>' .
"\n" .
217 '<option value="4">April</option>' .
"\n" .
218 '<option value="5">May</option>' .
"\n" .
219 '<option value="6">June</option>' .
"\n" .
220 '<option value="7">July</option>' .
"\n" .
221 '<option value="8">August</option>' .
"\n" .
222 '<option value="9">September</option>' .
"\n" .
223 '<option value="10">October</option>' .
"\n" .
224 '<option value="11">November</option>' .
"\n" .
225 '<option value="12">December</option></select>',
227 "Date menu with neither year or month"
236 '<textarea name="name" id="name" cols="40" rows="5"></textarea>',
238 'textarea() with not content'
247 '<textarea name="name" id="name" cols="20" rows="10"><txt></textarea>',
249 'textarea() with custom attribs'
258 '<label for="id">name</label>',
260 'label() with no attribs'
269 '<label for="id">name</label>',
270 Xml::label(
'name',
'id', [
'generated' =>
true ] ),
271 'label() can not be given a generated attribute'
274 '<label for="id" class="nice">name</label>',
275 Xml::label(
'name',
'id', [
'class' =>
'nice' ] ),
276 'label() can get a class attribute'
279 '<label for="id" title="nice tooltip">name</label>',
280 Xml::label(
'name',
'id', [
'title' =>
'nice tooltip' ] ),
281 'label() can get a title attribute'
284 '<label for="id" class="nice" title="nice tooltip">name</label>',
288 'title' =>
'nice tooltip',
289 'anotherattr' =>
'value',
292 'label() skip all attributes but "class" and "title"'
301 [
'id' =>
'testlang' ],
wfMessage(
'yourlanguage' ) );
303 '<label for="testlang">Language:</label>',
315 'escapeJsString() with special characters'
326 'encodeJsVar() with boolean'
337 'encodeJsVar() with null'
348 'encodeJsVar() with array'
353 'encodeJsVar() with associative array'
364 'encodeJsVar() with object'
375 'encodeJsVar() with int'
386 'encodeJsVar() with float'
397 'encodeJsVar() with int-like string'
408 'encodeJsVar() with float-like string'
testEncodeJsVarNull()
Xml::encodeJsVar.
testEscapeJsStringSpecialChars()
Xml::escapeJsString.
static element($element, $attribs=null, $contents= '', $allowShortTag=true)
Format an XML element with given attributes and, optionally, text content.
testTextareaAttribs()
Xml::textarea.
testEncodeJsVarObject()
Xml::encodeJsVar.
static expandAttributes($attribs)
Given an array of ('attributename' => 'value'), it generates the code to set the XML attributes : att...
testLabelAttributeCanOnlyBeClassOrTitle()
Xml::label.
static input($name, $size=false, $value=false, $attribs=[])
Convenience function to build an HTML text input field.
testEncodeJsVarFloatString()
Xml::encodeJsVar.
testEncodeJsVarArray()
Xml::encodeJsVar.
testElementEscaping()
Xml::element.
testTextareaNoContent()
Xml::textarea.
static label($label, $id, $attribs=[])
Convenience function to build an HTML form label.
testExpandAttributes()
Xml::expandAttributes.
testLabelCreation()
Xml::label.
static closeElement($element)
Shortcut to close an XML element.
testExpandAttributesException()
Xml::expandAttributes.
testElementAttributes()
Xml::element.
testEncodeJsVarIntString()
Xml::encodeJsVar.
testOpenElement()
Xml::openElement.
static languageSelector($selected, $customisedOnly=true, $inLanguage=null, $overrideAttrs=[], Message $msg=null)
Construct a language selector appropriate for use in a form or preferences.
static openElement($element, $attribs=null)
This opens an XML element.
static dateMenu($year, $month)
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 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 escapeJsString($string)
Returns an escaped string suitable for inclusion in a string literal for JavaScript source code...
testElementOpen()
Xml::element.
testEncodeJsVarFloat()
Xml::encodeJsVar.
testEncodeJsVarBoolean()
Xml::encodeJsVar.
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
testElementEmpty()
Xml::element.
static encodeJsVar($value, $pretty=false)
Encode a variable of arbitrary type to JavaScript.
static textarea($name, $content, $cols=40, $rows=5, $attribs=[])
Shortcut for creating textareas.
testEscapeTagsOnly()
Xml::escapeTagsOnly.
testElementInputCanHaveAValueOfZero()
Xml::input.
testDateMenu()
Xml::dateMenu.
testLanguageSelector()
Xml::languageSelector.
static factory($code)
Get a cached or new language object for a given language code.
static escapeTagsOnly($in)
Replace " > and < with their respective HTML entities ( ", >, <)
testCloseElement()
Xml::closeElement.
testEncodeJsVarInt()
Xml::encodeJsVar.