14 public function testUserLink( $expected, $userId, $userName, $altUserName =
false, $msg =
'' ) {
16 'wgArticlePath' =>
'/wiki/$1',
31 # - optional altUserName
35 # ## ANONYMOUS USER ########################################
37 '<a href="/wiki/Special:Contributions/JohnDoe" '
38 .
'class="mw-userlink mw-anonuserlink" '
39 .
'title="Special:Contributions/JohnDoe"><bdi>JohnDoe</bdi></a>',
43 '<a href="/wiki/Special:Contributions/::1" '
44 .
'class="mw-userlink mw-anonuserlink" '
45 .
'title="Special:Contributions/::1"><bdi>::1</bdi></a>',
47 'Anonymous with pretty IPv6'
50 '<a href="/wiki/Special:Contributions/0:0:0:0:0:0:0:1" '
51 .
'class="mw-userlink mw-anonuserlink" '
52 .
'title="Special:Contributions/0:0:0:0:0:0:0:1"><bdi>::1</bdi></a>',
53 0,
'0:0:0:0:0:0:0:1',
false,
54 'Anonymous with almost pretty IPv6'
57 '<a href="/wiki/Special:Contributions/0000:0000:0000:0000:0000:0000:0000:0001" '
58 .
'class="mw-userlink mw-anonuserlink" '
59 .
'title="Special:Contributions/0000:0000:0000:0000:0000:0000:0000:0001"><bdi>::1</bdi></a>',
60 0,
'0000:0000:0000:0000:0000:0000:0000:0001',
false,
61 'Anonymous with full IPv6'
64 '<a href="/wiki/Special:Contributions/::1" '
65 .
'class="mw-userlink mw-anonuserlink" '
66 .
'title="Special:Contributions/::1"><bdi>AlternativeUsername</bdi></a>',
67 0,
'::1',
'AlternativeUsername',
68 'Anonymous with pretty IPv6 and an alternative username'
73 '<a href="/wiki/Special:Contributions/127.0.0.1" '
74 .
'class="mw-userlink mw-anonuserlink" '
75 .
'title="Special:Contributions/127.0.0.1"><bdi>127.0.0.1</bdi></a>',
76 0,
'127.0.0.1',
false,
80 '<a href="/wiki/Special:Contributions/127.0.0.1" '
81 .
'class="mw-userlink mw-anonuserlink" '
82 .
'title="Special:Contributions/127.0.0.1"><bdi>AlternativeUsername</bdi></a>',
83 0,
'127.0.0.1',
'AlternativeUsername',
84 'Anonymous with IPv4 and an alternative username'
87 # ## Regular user ##########################################
99 $expected, $comment, $title =
false, $local =
false, $wikiId =
null
104 'enwiki' =>
'//en.example.org',
105 'dewiki' =>
'//de.example.org',
112 $conf->suffixes = [
'wiki' ];
115 'wgScript' =>
'/wiki/index.php',
116 'wgArticlePath' =>
'/wiki/$1',
117 'wgCapitalLinks' =>
true,
121 if ( $title ===
false ) {
123 $title = Title::newFromText(
'Special:BlankPage' );
147 "'''not bolded'''",
151 "try <script>evil</scipt> things",
152 "try <script>evil</scipt> things",
156 '<a href="/wiki/Special:BlankPage#autocomment" title="Special:BlankPage">→</a><span dir="auto"><span class="autocomment">autocomment</span></span>',
160 '<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>',
164 '<a href="/wiki/Special:BlankPage#autocomment" title="Special:BlankPage">→</a><span dir="auto"><span class="autocomment">autocomment: </span> post</span>',
165 "/* autocomment */ post",
168 'pre <a href="/wiki/Special:BlankPage#autocomment" title="Special:BlankPage">→</a><span dir="auto"><span class="autocomment">autocomment</span></span>',
169 "pre /* autocomment */",
172 'pre <a href="/wiki/Special:BlankPage#autocomment" title="Special:BlankPage">→</a><span dir="auto"><span class="autocomment">autocomment: </span> post</span>',
173 "pre /* autocomment */ post",
176 '<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>',
177 "/* autocomment */ multiple? /* autocomment2 */ ",
180 '<a href="/wiki/Special:BlankPage#autocomment_containing_.2F.2A" title="Special:BlankPage">→</a><span dir="auto"><span class="autocomment">autocomment containing /*: </span> T70361</span>',
181 "/* autocomment containing /* */ T70361"
184 '<a href="/wiki/Special:BlankPage#autocomment_containing_.22quotes.22" title="Special:BlankPage">→</a><span dir="auto"><span class="autocomment">autocomment containing "quotes"</span></span>',
185 "/* autocomment containing \"quotes\" */"
188 '<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>',
189 "/* autocomment containing <script>tags</script> */"
192 '<a href="#autocomment">→</a><span dir="auto"><span class="autocomment">autocomment</span></span>',
197 '<span dir="auto"><span class="autocomment">autocomment</span></span>',
202 '<a href="/wiki/Special:BlankPage#autocomment" title="Special:BlankPage">→</a><span dir="auto"><span class="autocomment">autocomment</span></span>',
207 '<a class="external" rel="nofollow" href="//en.example.org/w/Special:BlankPage#autocomment">→</a><span dir="auto"><span class="autocomment">autocomment</span></span>',
209 false,
false, $wikiId
213 'abc <a href="/wiki/index.php?title=Link&action=edit&redlink=1" class="new" title="Link (page does not exist)">link</a> def',
217 'abc <a href="/wiki/index.php?title=Link&action=edit&redlink=1" class="new" title="Link (page does not exist)">text</a> def',
218 "abc [[link|text]] def",
221 'abc <a href="/wiki/Special:BlankPage" title="Special:BlankPage">Special:BlankPage</a> def',
222 "abc [[Special:BlankPage|]] def",
225 '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',
226 "abc [[%C4%85%C5%9B%C5%BC]] def",
229 'abc <a href="/wiki/Special:BlankPage#section" title="Special:BlankPage">#section</a> def',
230 "abc [[#section]] def",
233 'abc <a href="/wiki/index.php?title=/subpage&action=edit&redlink=1" class="new" title="/subpage (page does not exist)">/subpage</a> def',
234 "abc [[/subpage]] def",
237 'abc <a href="/wiki/index.php?title=%22evil!%22&action=edit&redlink=1" class="new" title=""evil!" (page does not exist)">"evil!"</a> def',
238 "abc [[\"evil!\"]] def",
241 'abc [[<script>very evil</script>]] def',
242 "abc [[<script>very evil</script>]] def",
249 'abc <a href="/wiki/index.php?title=Link&action=edit&redlink=1" class="new" title="Link (page does not exist)">link</a> def',
254 'abc <a class="external" rel="nofollow" href="//en.example.org/w/Link">link</a> def',
256 false,
false, $wikiId
270 'enwiki' =>
'//en.example.org'
276 $conf->suffixes = [
'wiki' ];
278 'wgScript' =>
'/wiki/index.php',
279 'wgArticlePath' =>
'/wiki/$1',
280 'wgCapitalLinks' =>
true,
294 'foo bar <a href="/wiki/Special:BlankPage" title="Special:BlankPage">Special:BlankPage</a>',
295 'foo bar [[Special:BlankPage]]',
299 '<a class="external" rel="nofollow" href="//en.example.org/w/Foo%27bar">Foo\'bar</a>',
304 'foo bar <a class="external" rel="nofollow" href="//en.example.org/w/Special:BlankPage">Special:BlankPage</a>',
305 'foo bar [[Special:BlankPage]]',
309 'foo bar <a class="external" rel="nofollow" href="//en.example.org/w/File:Example">Image:Example</a>',
310 'foo bar [[Image:Example]]',
325 '<a href="/wiki/Special:BlankPage" title="Special:BlankPage">foobar</a>'
332 '<a href="/wiki/Special:BlankPage" title="Special:BlankPage" bar="baz">Special:BlankPage</a>'
339 '<a href="/w/index.php?title=Special:BlankPage&bar=baz" title="Special:BlankPage">Special:BlankPage</a>'
346 '<a href="http://example.org/wiki/Special:BlankPage" title="Special:BlankPage">Special:BlankPage</a>'
354 '<a href="/wiki/Special:BlankPage?foo=bar" title="Special:BlankPage">Special:BlankPage</a>'
374 'wgArticlePath' =>
'/wiki/$1',
375 'wgServer' =>
'//example.org',
376 'wgCanonicalServer' =>
'http://example.org',
377 'wgScriptPath' =>
'/w',
378 'wgScript' =>
'/w/index.php',
381 $this->
setMwGlobals(
'wgHooks', [
'LinkBegin' => [ $callback ] ] );
382 $title = SpecialPage::getTitleFor(
'Blankpage' );
384 $this->assertEquals( $expected,
$out );
394 '<a href="/wiki/Special:BlankPage" title="Special:BlankPage">foobar</a>'
401 '<a href="/wiki/Special:BlankPage" title="Special:BlankPage" bar="baz">Special:BlankPage</a>'
406 $ret =
'blahblahblah';
421 'wgArticlePath' =>
'/wiki/$1',
424 $this->
setMwGlobals(
'wgHooks', [
'LinkEnd' => [ $callback ] ] );
426 $title = SpecialPage::getTitleFor(
'Blankpage' );
428 $this->assertEquals( $expected,
$out );
436 $linkCache = MediaWikiServices::getInstance()->getLinkCache();
437 $foobarTitle = Title::makeTitle(
NS_MAIN,
'FooBar' );
438 $redirectTitle = Title::makeTitle(
NS_MAIN,
'Redirect' );
439 $userTitle = Title::makeTitle( NS_USER,
'Someuser' );
440 $linkCache->addGoodLinkObj(
446 $linkCache->addGoodLinkObj(
453 $linkCache->addGoodLinkObj(
testUserLink( $expected, $userId, $userName, $altUserName=false, $msg='')
provideCasesForUserLink Linker::userLink
testLinkEndHook( $callback, $expected)
MediaWiki\Linker\LinkRenderer::buildAElement provideLinkEndHook.
testGetLinkColour()
Linker::getLinkColour.
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 getLinkColour(LinkTarget $t, $threshold)
Return the CSS colour of a known link.
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
if(is_array($mode)) switch( $mode) $input