24 $this->assertEquals(
'hello world', $this->
handler->serializeContent( $content ) );
31 $this->
handler->serializeContent( $content,
'dummy/foo' );
32 $this->fail(
"serializeContent() should have failed on unknown format" );
42 $content = $this->
handler->unserializeContent(
'hello world' );
43 $this->assertEquals(
'hello world', $content->getNativeData() );
46 $this->assertEquals(
'hello world', $content->getNativeData() );
49 $this->
handler->unserializeContent(
'hello world',
'dummy/foo' );
50 $this->fail(
"unserializeContent() should have failed on unknown format" );
60 $content = $this->
handler->makeEmptyContent();
62 $this->assertTrue( $content->isEmpty() );
63 $this->assertEquals(
'', $content->getNativeData() );
86 if ( is_string( $title ) ) {
87 $title = Title::newFromText( $title );
89 $content = $this->
handler->makeRedirectContent( $title );
90 $this->assertEquals( $expected, $content->serialize() );
95 [
'Hello',
'#REDIRECT [[Hello]]' ],
96 [
'Template:Hello',
'#REDIRECT [[Template:Hello]]' ],
97 [
'Hello#section',
'#REDIRECT [[Hello#section]]' ],
98 [
'user:john_doe#section',
'#REDIRECT [[User:John doe#section]]' ],
99 [
'MEDIAWIKI:FOOBAR',
'#REDIRECT [[MediaWiki:FOOBAR]]' ],
100 [
'Category:Foo',
'#REDIRECT [[:Category:Foo]]' ],
101 [ Title::makeTitle(
NS_MAIN,
'en:Foo' ),
'#REDIRECT [[en:Foo]]' ],
102 [ Title::makeTitle(
NS_MAIN,
'Foo',
'',
'en' ),
'#REDIRECT [[:en:Foo]]' ],
104 Title::makeTitle(
NS_MAIN,
'Bar',
'fragment',
'google' ),
105 '#REDIRECT [[google:Bar#fragment]]'
115 $this->assertEquals( $supported, $this->
handler->isSupportedFormat( $format ) );
122 $handler =
new WikiTextContentHandler();
162 public function testMerge3( $old, $mine, $yours, $expected ) {
170 $merged = $this->
handler->merge3( $oldContent, $myContent, $yourContent );
172 $this->assertEquals( $expected, $merged ? $merged->getNativeData() : $merged );
178 'Hello there, world!',
181 '/^Redirected page .*Foo/'
188 '/^Created page .*Hello/'
195 '/^Created blank page$/'
199 'Hello there, world!',
206 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy
207 eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam
208 voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet
209 clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.',
212 '/^Replaced .*Hello/'
232 $summary = $this->
handler->getAutosummary( $oldContent, $newContent, $flags );
235 (
bool)preg_match( $expected, $summary ),
236 "Autosummary didn't match expected pattern $expected: $summary"
260 'mw-removed-redirect'
267 'mw-changed-redirect-target'
292 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy
293 eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam
294 voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet
295 clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.',
302 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy
303 eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam
304 voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet
305 clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.',
306 'Duis purus odio, rhoncus et finibus dapibus, facilisis ac urna. Pellentesque
307 arcu, tristique nec tempus nec, suscipit vel arcu. Sed non dolor nec ligula
308 congue tempor. Quisque pellentesque finibus orci a molestie. Nam maximus, purus
309 euismod finibus mollis, dui ante malesuada felis, dignissim rutrum diam sapien.',
322 'mw-new-redirect' =>
true,
323 'mw-removed-redirect' =>
true,
324 'mw-changed-redirect-target' =>
true,
325 'mw-newpage' =>
true,
326 'mw-newblank' =>
true,
328 'mw-replace' =>
true,
333 $tag = $this->
handler->getChangeTag( $oldContent, $newContent, $flags );
335 $this->assertSame( $expected, $tag );
342 $mockEngine = $this->createMock( SearchEngine::class );
343 $title = Title::newFromText(
'Somefile.jpg',
NS_FILE );
346 $fileHandler = $this->getMockBuilder( FileContentHandler::class )
347 ->disableOriginalConstructor()
348 ->setMethods( [
'getDataForSearchIndex' ] )
351 $handler = $this->getMockBuilder( WikitextContentHandler::class )
352 ->disableOriginalConstructor()
353 ->setMethods( [
'getFileHandler' ] )
356 $handler->method(
'getFileHandler' )->will( $this->returnValue( $fileHandler ) );
357 $fileHandler->expects( $this->once() )
358 ->method(
'getDataForSearchIndex' )
359 ->will( $this->returnValue( [
'file_text' =>
'This is file content' ] ) );
362 $this->assertArrayHasKey(
'file_text', $data );
363 $this->assertEquals(
'This is file content', $data[
'file_text'] );
A content handler knows how do deal with a specific type of content on a wiki page.
supportsDirectEditing()
Return true if this content model supports direct editing, such as via EditPage.
getDataForSearchIndex(WikiPage $page, ParserOutput $output, SearchEngine $engine)
Return fields to be indexed by search engine as representation of this document.
static clearCache()
Clear the self::$mObjects variable For use in parser tests.
Class representing a MediaWiki article and history.
testMerge3( $old, $mine, $yours, $expected)
dataMerge3 WikitextContentHandler::merge3
testMakeRedirectContent( $title, $expected)
provideMakeRedirectContent
testGetChangeTag( $old, $new, $flags, $expected)
dataGetChangeTag WikitextContentHandler::getChangeTag
testSupportsDirectEditing()
WikitextContentHandler::supportsDirectEditing.
static dataGetAutosummary()
testGetAutosummary( $old, $new, $flags, $expected)
dataGetAutosummary WikitextContentHandler::getAutosummary
testMakeEmptyContent()
WikitextContentHandler::makeEmptyContent.
testDataIndexFieldsFile()
WikitextContentHandler::getDataForSearchIndex.
testSerializeContent()
WikitextContentHandler::serializeContent.
static provideMakeRedirectContent()
testIsSupportedFormat( $format, $supported)
dataIsSupportedFormat WikitextContentHandler::isSupportedFormat
static dataGetChangeTag()
testUnserializeContent()
WikitextContentHandler::unserializeContent.
static dataIsSupportedFormat()
Content object for wiki text pages.
this class mediates it Skin Encapsulates a look and feel for the wiki All of the functions that render HTML and make choices about how to render it are here and are called from various other places when and is meant to be subclassed with other skins that may override some of its functions The User object contains a reference to a and so rather than having a global skin object we just rely on the global User and get the skin with $wgUser and also has some character encoding functions and other locale stuff The current user interface language is instantiated as and the local content language as $wgContLang
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 modifiable modifiable after all normalizations have been except for the $wgMaxImageArea check set to true or false to override the $wgMaxImageArea check result gives extension the possibility to transform it themselves set to a MediaTransformOutput the error message to be returned in an array you should do so by altering $wgNamespaceProtection and $wgNamespaceContentModels outside the handler
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
processing should stop and the error should be shown to the user * false
returning false will NOT prevent logging $e
const CONTENT_MODEL_WIKITEXT
const CONTENT_FORMAT_WIKITEXT