24 $this->assertEquals(
'hello world', $this->
handler->serializeContent(
$content ) );
32 $this->fail(
"serializeContent() should have failed on unknown format" );
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" );
62 $this->assertTrue(
$content->isEmpty() );
63 $this->assertEquals(
'',
$content->getNativeData() );
86 if ( is_string(
$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 ) );
119 $handler =
new WikiTextContentHandler();
159 public function testMerge3( $old, $mine, $yours, $expected ) {
167 $merged = $this->
handler->merge3( $oldContent, $myContent, $yourContent );
169 $this->assertEquals( $expected, $merged ? $merged->getNativeData() : $merged );
175 'Hello there, world!',
178 '/^Redirected page .*Foo/'
185 '/^Created page .*Hello/'
189 'Hello there, world!',
196 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy
197 eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam
198 voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet
199 clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.',
202 '/^Replaced .*Hello/'
225 (
bool)preg_match( $expected,
$summary ),
226 "Autosummary didn't match expected pattern $expected: $summary"
248 $mockEngine = $this->getMock(
'SearchEngine' );
252 $fileHandler = $this->getMockBuilder( FileContentHandler::class )
253 ->disableOriginalConstructor()
254 ->setMethods( [
'getDataForSearchIndex' ] )
257 $handler = $this->getMockBuilder( WikitextContentHandler::class )
258 ->disableOriginalConstructor()
259 ->setMethods( [
'getFileHandler' ] )
262 $handler->method(
'getFileHandler' )->will( $this->returnValue( $fileHandler ) );
263 $fileHandler->expects( $this->once() )
264 ->method(
'getDataForSearchIndex' )
265 ->will( $this->returnValue( [
'file_text' =>
'This is file content' ] ) );
268 $this->assertArrayHasKey(
'file_text', $data );
269 $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.
static getForModelID( $modelId)
Returns the ContentHandler singleton for the given model ID.
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
testSupportsDirectEditing()
static dataGetAutosummary()
testGetAutosummary( $old, $new, $flags, $expected)
dataGetAutosummary WikitextContentHandler::getAutosummary
testMakeEmptyContent()
WikitextContentHandler::makeEmptyContent.
testDataIndexFieldsFile()
testSerializeContent()
WikitextContentHandler::serializeContent.
static provideMakeRedirectContent()
testIsSupportedFormat( $format, $supported)
dataIsSupportedFormat WikitextContentHandler::isSupportedFormat
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
when a variable name is used in a it is silently declared as a new local masking the global
const CONTENT_MODEL_WIKITEXT
const CONTENT_FORMAT_WIKITEXT
namespace and then decline to actually register it file or subcat img or subcat $title
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set and then return false from the hook function Ensure you consume the ChangeTagAfterDelete hook to carry out custom deletion actions as context called by AbstractContent::getParserOutput May be used to override the normal model specific rendering of page content $content
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
it s the revision text itself In either if gzip is the revision text is gzipped $flags
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
namespace are movable Hooks may change this value to override the return value of MWNamespace::isMovable(). 'NewDifferenceEngine' do that in ParserLimitReportFormat instead use this to modify the parameters of the image and a DIV can begin in one section and end in another Make sure your code can handle that case gracefully See the EditSectionClearerLink extension for an example zero but section is usually empty its values are the globals values before the output is cached $page
processing should stop and the error should be shown to the user * false
returning false will NOT prevent logging $e
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