13 public function testUserLink( $expected, $userId, $userName, $altUserName =
false, $msg =
'' ) {
15 'wgArticlePath' =>
'/wiki/$1',
30 # - optional altUserName
34 # ## ANONYMOUS USER ########################################
36 '<a href="/wiki/Special:Contributions/JohnDoe" '
37 .
'class="mw-userlink mw-anonuserlink" '
38 .
'title="Special:Contributions/JohnDoe"><bdi>JohnDoe</bdi></a>',
42 '<a href="/wiki/Special:Contributions/::1" '
43 .
'class="mw-userlink mw-anonuserlink" '
44 .
'title="Special:Contributions/::1"><bdi>::1</bdi></a>',
46 'Anonymous with pretty IPv6'
49 '<a href="/wiki/Special:Contributions/0:0:0:0:0:0:0:1" '
50 .
'class="mw-userlink mw-anonuserlink" '
51 .
'title="Special:Contributions/0:0:0:0:0:0:0:1"><bdi>::1</bdi></a>',
52 0,
'0:0:0:0:0:0:0:1',
false,
53 'Anonymous with almost pretty IPv6'
56 '<a href="/wiki/Special:Contributions/0000:0000:0000:0000:0000:0000:0000:0001" '
57 .
'class="mw-userlink mw-anonuserlink" '
58 .
'title="Special:Contributions/0000:0000:0000:0000:0000:0000:0000:0001"><bdi>::1</bdi></a>',
59 0,
'0000:0000:0000:0000:0000:0000:0000:0001',
false,
60 'Anonymous with full IPv6'
63 '<a href="/wiki/Special:Contributions/::1" '
64 .
'class="mw-userlink mw-anonuserlink" '
65 .
'title="Special:Contributions/::1"><bdi>AlternativeUsername</bdi></a>',
66 0,
'::1',
'AlternativeUsername',
67 'Anonymous with pretty IPv6 and an alternative username'
72 '<a href="/wiki/Special:Contributions/127.0.0.1" '
73 .
'class="mw-userlink mw-anonuserlink" '
74 .
'title="Special:Contributions/127.0.0.1"><bdi>127.0.0.1</bdi></a>',
75 0,
'127.0.0.1',
false,
79 '<a href="/wiki/Special:Contributions/127.0.0.1" '
80 .
'class="mw-userlink mw-anonuserlink" '
81 .
'title="Special:Contributions/127.0.0.1"><bdi>AlternativeUsername</bdi></a>',
82 0,
'127.0.0.1',
'AlternativeUsername',
83 'Anonymous with IPv4 and an alternative username'
86 # ## Regular user ##########################################
98 $expected, $comment, $title =
false, $local =
false, $wikiId =
null
103 'enwiki' =>
'//en.example.org',
104 'dewiki' =>
'//de.example.org',
111 $conf->suffixes = [
'wiki' ];
114 'wgScript' =>
'/wiki/index.php',
115 'wgArticlePath' =>
'/wiki/$1',
116 'wgCapitalLinks' =>
true,
122 $title = Title::newFromText(
'Special:BlankPage' );
146 "'''not bolded'''",
150 "try <script>evil</scipt> things",
151 "try <script>evil</scipt> things",
155 '<a href="/wiki/Special:BlankPage#autocomment" title="Special:BlankPage">→</a><span dir="auto"><span class="autocomment">autocomment</span></span>',
159 '<a href="/wiki/Special:BlankPage#linkie.3F" title="Special:BlankPage">→</a><span dir="auto"><span class="autocomment"><a href="/wiki/index.php?title=Linkie%3F&action=edit&redlink=1" class="new" title="Linkie? (page does not exist)">linkie?</a></span></span>',
163 '<a href="/wiki/Special:BlankPage#autocomment" title="Special:BlankPage">→</a><span dir="auto"><span class="autocomment">autocomment: </span> post</span>',
164 "/* autocomment */ post",
167 'pre <a href="/wiki/Special:BlankPage#autocomment" title="Special:BlankPage">→</a><span dir="auto"><span class="autocomment">autocomment</span></span>',
168 "pre /* autocomment */",
171 'pre <a href="/wiki/Special:BlankPage#autocomment" title="Special:BlankPage">→</a><span dir="auto"><span class="autocomment">autocomment: </span> post</span>',
172 "pre /* autocomment */ post",
175 '<a href="/wiki/Special:BlankPage#autocomment" title="Special:BlankPage">→</a><span dir="auto"><span class="autocomment">autocomment: </span> multiple? <a href="/wiki/Special:BlankPage#autocomment2" title="Special:BlankPage">→</a><span dir="auto"><span class="autocomment">autocomment2: </span> </span></span>',
176 "/* autocomment */ multiple? /* autocomment2 */ ",
179 '<a href="/wiki/Special:BlankPage#autocomment_containing_.2F.2A" title="Special:BlankPage">→</a><span dir="auto"><span class="autocomment">autocomment containing /*: </span> T70361</span>',
180 "/* autocomment containing /* */ T70361"
183 '<a href="/wiki/Special:BlankPage#autocomment_containing_.22quotes.22" title="Special:BlankPage">→</a><span dir="auto"><span class="autocomment">autocomment containing "quotes"</span></span>',
184 "/* autocomment containing \"quotes\" */"
187 '<a href="/wiki/Special:BlankPage#autocomment_containing_.3Cscript.3Etags.3C.2Fscript.3E" title="Special:BlankPage">→</a><span dir="auto"><span class="autocomment">autocomment containing <script>tags</script></span></span>',
188 "/* autocomment containing <script>tags</script> */"
191 '<a href="#autocomment">→</a><span dir="auto"><span class="autocomment">autocomment</span></span>',
196 '<span dir="auto"><span class="autocomment">autocomment</span></span>',
201 '<a href="/wiki/Special:BlankPage#autocomment" title="Special:BlankPage">→</a><span dir="auto"><span class="autocomment">autocomment</span></span>',
206 '<a class="external" rel="nofollow" href="//en.example.org/w/Special:BlankPage#autocomment">→</a><span dir="auto"><span class="autocomment">autocomment</span></span>',
208 false,
false, $wikiId
212 'abc <a href="/wiki/index.php?title=Link&action=edit&redlink=1" class="new" title="Link (page does not exist)">link</a> def',
216 'abc <a href="/wiki/index.php?title=Link&action=edit&redlink=1" class="new" title="Link (page does not exist)">text</a> def',
217 "abc [[link|text]] def",
220 'abc <a href="/wiki/Special:BlankPage" title="Special:BlankPage">Special:BlankPage</a> def',
221 "abc [[Special:BlankPage|]] def",
224 'abc <a href="/wiki/index.php?title=%C4%84%C5%9B%C5%BC&action=edit&redlink=1" class="new" title="Ąśż (page does not exist)">ąśż</a> def',
225 "abc [[%C4%85%C5%9B%C5%BC]] def",
228 'abc <a href="/wiki/Special:BlankPage#section" title="Special:BlankPage">#section</a> def',
229 "abc [[#section]] def",
232 'abc <a href="/wiki/index.php?title=/subpage&action=edit&redlink=1" class="new" title="/subpage (page does not exist)">/subpage</a> def',
233 "abc [[/subpage]] def",
236 'abc <a href="/wiki/index.php?title=%22evil!%22&action=edit&redlink=1" class="new" title=""evil!" (page does not exist)">"evil!"</a> def',
237 "abc [[\"evil!\"]] def",
240 'abc [[<script>very evil</script>]] def',
241 "abc [[<script>very evil</script>]] def",
248 'abc <a href="/wiki/index.php?title=Link&action=edit&redlink=1" class="new" title="Link (page does not exist)">link</a> def',
253 'abc <a class="external" rel="nofollow" href="//en.example.org/w/Link">link</a> def',
255 false,
false, $wikiId
269 'enwiki' =>
'//en.example.org'
275 $conf->suffixes = [
'wiki' ];
277 'wgScript' =>
'/wiki/index.php',
278 'wgArticlePath' =>
'/wiki/$1',
279 'wgCapitalLinks' =>
true,
293 'foo bar <a href="/wiki/Special:BlankPage" title="Special:BlankPage">Special:BlankPage</a>',
294 'foo bar [[Special:BlankPage]]',
298 '<a href="/wiki/Special:BlankPage" title="Special:BlankPage">Special:BlankPage</a>',
299 '[[ :Special:BlankPage]]',
303 '<a class="external" rel="nofollow" href="//en.example.org/w/Foo%27bar">Foo\'bar</a>',
308 'foo bar <a class="external" rel="nofollow" href="//en.example.org/w/Special:BlankPage">Special:BlankPage</a>',
309 'foo bar [[Special:BlankPage]]',
313 'foo bar <a class="external" rel="nofollow" href="//en.example.org/w/File:Example">Image:Example</a>',
314 'foo bar [[Image:Example]]',
329 '<a href="/wiki/Special:BlankPage" title="Special:BlankPage">foobar</a>'
336 '<a href="/wiki/Special:BlankPage" title="Special:BlankPage" bar="baz">Special:BlankPage</a>'
343 '<a href="/w/index.php?title=Special:BlankPage&bar=baz" title="Special:BlankPage">Special:BlankPage</a>'
350 '<a href="http://example.org/wiki/Special:BlankPage" title="Special:BlankPage">Special:BlankPage</a>'
358 '<a href="/wiki/Special:BlankPage?foo=bar" title="Special:BlankPage">Special:BlankPage</a>'
377 $this->
hideDeprecated(
'LinkBegin hook (used in hook-LinkBegin-closure)' );
379 'wgArticlePath' =>
'/wiki/$1',
380 'wgServer' =>
'//example.org',
381 'wgCanonicalServer' =>
'http://example.org',
382 'wgScriptPath' =>
'/w',
383 'wgScript' =>
'/w/index.php',
386 $this->
setMwGlobals(
'wgHooks', [
'LinkBegin' => [ $callback ] ] );
387 $title = SpecialPage::getTitleFor(
'Blankpage' );
389 $this->assertEquals( $expected,
$out );
399 '<a href="/wiki/Special:BlankPage" title="Special:BlankPage">foobar</a>'
406 '<a href="/wiki/Special:BlankPage" title="Special:BlankPage" bar="baz">Special:BlankPage</a>'
411 $ret =
'blahblahblah';
425 $this->
hideDeprecated(
'LinkEnd hook (used in hook-LinkEnd-closure)' );
427 'wgArticlePath' =>
'/wiki/$1',
430 $this->
setMwGlobals(
'wgHooks', [
'LinkEnd' => [ $callback ] ] );
432 $title = SpecialPage::getTitleFor(
'Blankpage' );
434 $this->assertEquals( $expected,
$out );
testUserLink( $expected, $userId, $userName, $altUserName=false, $msg='')
provideCasesForUserLink Linker::userLink
testLinkEndHook( $callback, $expected)
MediaWiki\Linker\LinkRenderer::buildAElement provideLinkEndHook.
provideCasesForFormatComment()
testLinkBeginHook( $callback, $expected)
MediaWiki\Linker\LinkRenderer::runLegacyBeginHook provideLinkBeginHook.
static provideCasesForFormatLinksInComment()
testFormatComment( $expected, $comment, $title=false, $local=false, $wikiId=null)
provideCasesForFormatComment Linker::formatComment Linker::formatAutocomments Linker::formatLinksInCo...
testFormatLinksInComment( $expected, $input, $wiki)
Linker::formatLinksInComment provideCasesForFormatLinksInComment.
static provideLinkEndHook()
static provideLinkBeginHook()
static provideCasesForUserLink()
static link( $target, $html=null, $customAttribs=[], $query=[], $options=[])
This function returns an HTML link to the given target.
static userLink( $userId, $userName, $altUserName=false)
Make user link (or user contributions for unregistered users)
static formatLinksInComment( $comment, $title=null, $local=false, $wikiId=null)
Formats wiki links and media links in text; all other wiki formatting is ignored.
static formatComment( $comment, $title=null, $local=false, $wikiId=null)
This function is called by all recent changes variants, by the page history, and by the user contribu...
This is a class for holding configuration settings, particularly for multi-wiki sites.
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
namespace and then decline to actually register it file or subcat img or subcat $title
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 true
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
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that probably a stub it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping see BaseTemplate::getToolbox and BaseTemplate::makeListItem for details on the format of individual items inside of this array or by returning and letting standard HTTP rendering take place modifiable or by returning false and taking over the output $out
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
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
null for the local wiki Added should default to null in handler for backwards compatibility add a value to it if you want to add a cookie that have to vary cache options can modify $query
processing should stop and the error should be shown to the user * false
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
if(is_array($mode)) switch( $mode) $input