16 [
'hello this is ~~~',
17 "hello this is [[Special:Contributions/127.0.0.1|127.0.0.1]]",
19 [
'hello \'\'this\'\' is <nowiki>~~~</nowiki>',
20 'hello \'\'this\'\' is <nowiki>~~~</nowiki>',
31 $title = Title::newFromText( str_replace(
'::',
'__', __METHOD__ ) );
33 $user->setName(
"127.0.0.1" );
34 $popts = ParserOptions::newFromUser(
$user );
37 $this->assertEquals( $expected, $text );
50 "<p class='foo'>Text.</p>",
51 "<p class='foo'>Text.</p>",
58 "<p>Text.</p><p>More text.</p>",
59 "<p>Text.</p><p>More text.</p>",
72 $this->assertEquals( $expected, Parser::stripOuterParagraph( $text ) );
82 $title = Title::newFromText(
'foo' );
84 $wgParser->setHook(
'recursivecallparser', [ $this,
'helperParserFunc' ] );
85 $wgParser->parse(
'<recursivecallparser>baz</recursivecallparser>',
$title, $po );
89 $title = Title::newFromText(
'foo' );
99 $title = Title::newFromText( str_replace(
'::',
'__', __METHOD__ ) );
101 $frame =
$wgParser->getPreprocessor()->newFrame();
103 [
'pre',
'foo',
'style' =>
'margin-left: 1.6em' ]
108 'text' =>
'<pre style="margin-left: 1.6em">foo</pre>',
109 ],
$ret,
'callParserFunction works for {{#tag:pre|foo|style=margin-left: 1.6em}}' );
119 $title = Title::newFromText( str_replace(
'::',
'__', __METHOD__ ) );
128 'fromtitle' =>
$title->getPrefixedDBkey(),
138 'fromtitle' =>
false,
139 'byteoffset' =>
null,
148 'fromtitle' =>
$title->getPrefixedDBkey(),
152 ],
$out->getSections(),
'getSections() with proper value when <h2> is used' );
159 $this->assertEquals( $expected, Parser::normalizeLinkUrl( $url ), $explanation );
165 'Escaping of unsafe characters',
166 'http://example.org/foo bar?param[]="value"¶m[]=valüe',
167 'http://example.org/foo%20bar?param%5B%5D=%22value%22¶m%5B%5D=val%C3%BCe',
170 'Case normalization of percent-encoded characters',
171 'http://example.org/%ab%cD%Ef%FF',
172 'http://example.org/%AB%CD%EF%FF',
175 'Unescaping of safe characters',
176 'http://example.org/%3C%66%6f%6F%3E?%3C%66%6f%6F%3E#%3C%66%6f%6F%3E',
177 'http://example.org/%3Cfoo%3E?%3Cfoo%3E#%3Cfoo%3E',
180 'Context-sensitive replacement of sometimes-safe characters',
181 'http://example.org/%23%2F%3F%26%3D%2B%3B?%23%2F%3F%26%3D%2B%3B#%23%2F%3F%26%3D%2B%3B',
182 'http://example.org/%23%2F%3F&=+;?%23/?%26%3D%2B%3B#%23/?&=+;',
185 'IPv6 links aren\'t escaped',
186 'http://[::1]/foobar',
187 'http://[::1]/foobar',
190 'non-IPv6 links aren\'t unescaped',
191 'http://%5B::1%5D/foobar',
192 'http://%5B::1%5D/foobar',
199 $title = Title::newFromText(
'foo' );
202 $text =
$wgParser->getOutput()->getText();
204 $this->assertContains(
'Hello World', $text );
205 $this->assertContains(
'<div', $text );
206 $this->assertContains(
'class="mw-parser-output"', $text );
214 $title = $this->getMock( Title::class );
215 $title->method(
'getPrefixedDBkey' )->willReturn(
$name );
216 $title->method(
'getPrefixedText' )->willReturn(
$name );
219 $title->method(
'getNamespace' )->willReturn( 0 );
220 $title->method(
'getPageLanguage' )->willReturn( Language::factory(
'en' ) );
228 $frank = $this->getMockBuilder( User::class )
229 ->disableOriginalConstructor()
232 $frank->method(
'getName' )->willReturn(
'Frank' );
234 $text =
'* user:{{REVISIONUSER}};id:{{REVISIONID}};time:{{REVISIONTIMESTAMP}};';
237 yield
'current' => [ $text, $po, 0,
'user:CurrentAuthor;id:200;time:20160606000000;' ];
238 yield
'current with ID' => [ $text, $po, 200,
'user:CurrentAuthor;id:200;time:20160606000000;' ];
240 $text =
'* user:{{REVISIONUSER}};id:{{REVISIONID}};time:{{REVISIONTIMESTAMP}};';
243 yield
'old' => [ $text, $po, 100,
'user:OldAuthor;id:100;time:20140404000000;' ];
246 $oldRevision->setId( 100 );
248 $oldRevision->setTimestamp(
'20141111111111' );
249 $oldRevision->setContent( SlotRecord::MAIN,
new WikitextContent(
'FAUX' ) );
252 $po->setCurrentRevisionCallback(
function ()
use ( $oldRevision ) {
253 return new Revision( $oldRevision );
256 yield
'old with override' => [ $text, $po, 100,
'user:FauxAuthor;id:100;time:20141111111111;' ];
258 $text =
'* user:{{REVISIONUSER}};user-subst:{{subst:REVISIONUSER}};';
261 $po->setIsPreview(
true );
263 yield
'preview without override, using context' => [
271 $text =
'* user:{{REVISIONUSER}};time:{{REVISIONTIMESTAMP}};'
272 .
'user-subst:{{subst:REVISIONUSER}};time-subst:{{subst:REVISIONTIMESTAMP}};';
276 $newRevision->setTimestamp(
'20180808000000' );
277 $newRevision->setContent( SlotRecord::MAIN,
new WikitextContent(
'NEW' ) );
280 $po->setIsPreview(
true );
281 $po->setCurrentRevisionCallback(
function ()
use ( $newRevision ) {
282 return new Revision( $newRevision );
289 'user:NewAuthor;time:20180808000000;',
290 'user-subst:NewAuthor;time-subst:20180808000000;',
294 $po->setCurrentRevisionCallback(
function ()
use ( $newRevision ) {
295 return new Revision( $newRevision );
298 yield
'pre-save' => [
302 'user:NewAuthor;time:20180808000000;',
303 'user-subst:NewAuthor;time-subst:20180808000000;',
306 $text =
"(ONE)<includeonly>(TWO)</includeonly>"
307 .
"<noinclude>#{{:ParserRevisionAccessTest}}#</noinclude>";
311 $newRevision->setTimestamp(
'20180808000000' );
312 $newRevision->setContent( SlotRecord::MAIN,
new WikitextContent( $text ) );
315 $po->setIsPreview(
true );
316 $po->setCurrentRevisionCallback(
function ()
use ( $newRevision ) {
317 return new Revision( $newRevision );
320 yield
'preview with self-transclude' => [ $text, $po,
null,
'(ONE)#(ONE)(TWO)#' ];
331 $expectedInPst =
null
340 $oldRevision->setId( 100 );
342 $oldRevision->setTimestamp(
'20140404000000' );
343 $oldRevision->setContent( SlotRecord::MAIN,
new WikitextContent(
'OLD' ) );
346 $currentRevision->setId( 200 );
348 $currentRevision->setTimestamp(
'20160606000000' );
349 $currentRevision->setContent( SlotRecord::MAIN,
new WikitextContent(
'CURRENT' ) );
351 $revisionStore = $this->getMockBuilder( RevisionStore::class )
352 ->disableOriginalConstructor()
356 ->method(
'getKnownCurrentRevision' )
358 [
$title, 100, $oldRevision ],
359 [
$title, 200, $currentRevision ],
360 [
$title, 0, $currentRevision ],
364 ->method(
'getRevisionById' )
366 [ 100, 0, $oldRevision ],
367 [ 200, 0, $currentRevision ],
370 $this->
setService(
'RevisionStore', $revisionStore );
375 $this->assertContains( $expectedInHtml,
$html,
'In HTML' );
377 if ( $expectedInPst !==
null ) {
379 $this->assertContains( $expectedInPst, $pst,
'After Pre-Safe Transform' );
385 [
'1/2',
'html5',
'#1/2' ],
386 [
'1/2',
'legacy',
'#1.2F2' ],
392 $this->
setMwGlobals( [
'wgFragmentMode' => [ $mode ] ] );
395 $this->assertEquals(
$result, $expected );
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
Database Parser BlockLevelPass.
static provideStripOuterParagraph()
static provideGuessSectionNameFromWikiText()
testNormalizeLinkUrl( $explanation, $url, $expected)
provideNormalizeLinkUrl
testGetSections()
Parser ParserOutput::getSections.
testStripOuterParagraph( $text, $expected)
provideStripOuterParagraph
testPreSaveTransform( $text, $expected)
providePreSaveTransform
testRevisionAccess( $text, ParserOptions $po, $revId, $expectedInHtml, $expectedInPst=null)
provideRevisionAccess
static providePreSaveTransform()
testGuessSectionNameFromWikiText( $input, $mode, $expected)
provideGuessSectionNameFromWikiText
helperParserFunc( $input, $args, $parser)
static provideNormalizeLinkUrl()
testRecursiveParse()
MWException Parser state cleared while parsing.
Set options of the Parser.
enableLimitReport( $x=true)
Enable limit report in an HTML comment on output.
Variant of the Message class.
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
Content object for wiki text pages.
see documentation in includes Linker php for Linker::makeImageLink or false for current used if you return false $parser
The index of the header message $result[1]=The index of the body text message $result[2 through n]=Parameters passed to body text message. Please note the header message cannot receive/use parameters. 'ImgAuthModifyHeaders':Executed just before a file is streamed to a user via img_auth.php, allowing headers to be modified beforehand. $title:LinkTarget object & $headers:HTTP headers(name=> value, names are case insensitive). Two headers get special handling:If-Modified-Since(value must be a valid HTTP date) and Range(must be of the form "bytes=(\d*-\d*)") will be honored when streaming the file. 'ImportHandleLogItemXMLTag':When parsing a XML tag in a log item. Return false to stop further processing of the tag $reader:XMLReader object $logInfo:Array of information 'ImportHandlePageXMLTag':When parsing a XML tag in a page. Return false to stop further processing of the tag $reader:XMLReader object & $pageInfo:Array of information 'ImportHandleRevisionXMLTag':When parsing a XML tag in a page revision. Return false to stop further processing of the tag $reader:XMLReader object $pageInfo:Array of page information $revisionInfo:Array of revision information 'ImportHandleToplevelXMLTag':When parsing a top level XML tag. Return false to stop further processing of the tag $reader:XMLReader object 'ImportHandleUnknownUser':When a user doesn 't exist locally, this hook is called to give extensions an opportunity to auto-create it. If the auto-creation is successful, return false. $name:User name 'ImportHandleUploadXMLTag':When parsing a XML tag in a file upload. Return false to stop further processing of the tag $reader:XMLReader object $revisionInfo:Array of information 'ImportLogInterwikiLink':Hook to change the interwiki link used in log entries and edit summaries for transwiki imports. & $fullInterwikiPrefix:Interwiki prefix, may contain colons. & $pageTitle:String that contains page title. 'ImportSources':Called when reading from the $wgImportSources configuration variable. Can be used to lazy-load the import sources list. & $importSources:The value of $wgImportSources. Modify as necessary. See the comment in DefaultSettings.php for the detail of how to structure this array. 'InfoAction':When building information to display on the action=info page. $context:IContextSource object & $pageInfo:Array of information 'InitializeArticleMaybeRedirect':MediaWiki check to see if title is a redirect. & $title:Title object for the current page & $request:WebRequest & $ignoreRedirect:boolean to skip redirect check & $target:Title/string of redirect target & $article:Article object 'InternalParseBeforeLinks':during Parser 's internalParse method before links but after nowiki/noinclude/includeonly/onlyinclude and other processings. & $parser:Parser object & $text:string containing partially parsed text & $stripState:Parser 's internal StripState object 'InternalParseBeforeSanitize':during Parser 's internalParse method just before the parser removes unwanted/dangerous HTML tags and after nowiki/noinclude/includeonly/onlyinclude and other processings. Ideal for syntax-extensions after template/parser function execution which respect nowiki and HTML-comments. & $parser:Parser object & $text:string containing partially parsed text & $stripState:Parser 's internal StripState object 'InterwikiLoadPrefix':When resolving if a given prefix is an interwiki or not. Return true without providing an interwiki to continue interwiki search. $prefix:interwiki prefix we are looking for. & $iwData:output array describing the interwiki with keys iw_url, iw_local, iw_trans and optionally iw_api and iw_wikiid. 'InvalidateEmailComplete':Called after a user 's email has been invalidated successfully. $user:user(object) whose email is being invalidated 'IRCLineURL':When constructing the URL to use in an IRC notification. Callee may modify $url and $query, URL will be constructed as $url . $query & $url:URL to index.php & $query:Query string $rc:RecentChange object that triggered url generation 'IsFileCacheable':Override the result of Article::isFileCacheable()(if true) & $article:article(object) being checked 'IsTrustedProxy':Override the result of IP::isTrustedProxy() & $ip:IP being check & $result:Change this value to override the result of IP::isTrustedProxy() 'IsUploadAllowedFromUrl':Override the result of UploadFromUrl::isAllowedUrl() $url:URL used to upload from & $allowed:Boolean indicating if uploading is allowed for given URL 'isValidEmailAddr':Override the result of Sanitizer::validateEmail(), for instance to return false if the domain name doesn 't match your organization. $addr:The e-mail address entered by the user & $result:Set this and return false to override the internal checks 'isValidPassword':Override the result of User::isValidPassword() $password:The password entered by the user & $result:Set this and return false to override the internal checks $user:User the password is being validated for 'Language::getMessagesFileName':$code:The language code or the language we 're looking for a messages file for & $file:The messages file path, you can override this to change the location. 'LanguageGetNamespaces':Provide custom ordering for namespaces or remove namespaces. Do not use this hook to add namespaces. Use CanonicalNamespaces for that. & $namespaces:Array of namespaces indexed by their numbers 'LanguageGetTranslatedLanguageNames':Provide translated language names. & $names:array of language code=> language name $code:language of the preferred translations 'LanguageLinks':Manipulate a page 's language links. This is called in various places to allow extensions to define the effective language links for a page. $title:The page 's Title. & $links:Array with elements of the form "language:title" in the order that they will be output. & $linkFlags:Associative array mapping prefixed links to arrays of flags. Currently unused, but planned to provide support for marking individual language links in the UI, e.g. for featured articles. 'LanguageSelector':Hook to change the language selector available on a page. $out:The output page. $cssClassName:CSS class name of the language selector. 'LinkBegin':DEPRECATED since 1.28! Use HtmlPageLinkRendererBegin instead. Used when generating internal and interwiki links in Linker::link(), before processing starts. Return false to skip default processing and return $ret. See documentation for Linker::link() for details on the expected meanings of parameters. $skin:the Skin object $target:the Title that the link is pointing to & $html:the contents that the< a > tag should have(raw HTML) $result
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that When $user is not it can be in the form of< username >< more info > e g for bot passwords intended to be added to log contexts Fields it might only if the login was with a bot password 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
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 & $ret
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
return true to allow those checks to and false if checking is done & $user
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