9 protected function setUp() {
14 'wgExtraNamespaces' => [
16 12313 =>
'Dummy_talk',
20 'wgNamespaceContentModels' => [
23 'wgContentHandlers' => [
29 'testing' =>
'DummyContentHandlerForTesting',
30 'testing-callbacks' =>
function( $modelId ) {
38 $wgContLang->resetNamespaces();
40 MediaWikiServices::getInstance()->resetServiceForTesting(
'LinkCache' );
48 $wgContLang->resetNamespaces();
50 MediaWikiServices::getInstance()->resetServiceForTesting(
'LinkCache' );
89 $this->assertEquals( $expectedModelId, ContentHandler::getDefaultModelFor(
$title ) );
100 $this->assertEquals( $expectedContentModel,
$handler->getModelID() );
118 $name = ContentHandler::getLocalizedName( $id );
121 $this->assertNotNull(
$name,
"no name found for content model $id" );
122 $this->assertTrue( preg_match( $expected,
$name ) > 0,
123 "content model name for #$id did not match pattern $expected"
126 $this->assertEquals( $id,
$name,
"localization of unknown model $id should have "
127 .
"fallen back to use the model id directly."
138 [
"MediaWiki:common.js",
'en' ],
139 [
"User:Foo/common.js",
'en' ],
140 [
"MediaWiki:common.css",
'en' ],
141 [
"User:Foo/common.css",
'en' ],
153 if ( is_string(
$title ) ) {
163 $this->assertEquals( $expected->getCode(),
$lang->getCode() );
179 $this->
setMwGlobals(
'wgContentHandlerTextFallback', $contentHandlerTextFallback );
183 $text = ContentHandler::getContentText(
$content );
184 $this->assertEquals(
'', $text );
200 $this->
setMwGlobals(
'wgContentHandlerTextFallback', $contentHandlerTextFallback );
204 $text = ContentHandler::getContentText(
$content );
205 $this->assertEquals(
$content->getNativeData(), $text );
214 $this->
setMwGlobals(
'wgContentHandlerTextFallback',
'fail' );
218 ContentHandler::getContentText(
$content );
225 $this->
setMwGlobals(
'wgContentHandlerTextFallback',
'serialize' );
229 $text = ContentHandler::getContentText(
$content );
230 $this->assertEquals(
$content->serialize(), $text );
237 $this->
setMwGlobals(
'wgContentHandlerTextFallback',
'ignore' );
241 $text = ContentHandler::getContentText(
$content );
242 $this->assertNull( $text );
253 [
serialize(
'hallo' ),
'Dummy:Test', null, null,
"testing",
'hallo',
false ],
273 [
serialize(
'hallo' ),
'Dummy:Test', null,
"testing",
"testing",
'hallo',
false ],
306 $expectedModelId, $expectedNativeData, $shouldFail
311 $content = ContentHandler::makeContent( $data,
$title, $modelId, $format );
314 $this->fail(
"ContentHandler::makeContent should have failed!" );
317 $this->assertEquals( $expectedModelId,
$content->getModel(),
'bad model id' );
318 $this->assertEquals( $expectedNativeData,
$content->getNativeData(),
'bads native data' );
320 if ( !$shouldFail ) {
321 $this->fail(
"ContentHandler::makeContent failed unexpectedly: " . $ex->getMessage() );
324 $this->assertTrue(
true );
341 $autoSummary =
$content->getAutosummary( null, $newContent, 97 );
342 $this->assertEquals( $autoSummary,
'Created blank page' );
344 $autoSummary =
$content->getAutosummary( null, $newContent, 92 );
345 $this->assertEquals( $autoSummary,
'' );
356 $this->assertTrue(
$handler->supportsCategories(),
'content model supports categories' );
361 $this->assertFalse(
$handler->supportsDirectEditing(),
'direct editing is not supported' );
368 Hooks::register(
'testRunLegacyHooks', __CLASS__ .
'::dummyHookHandler' );
371 $ok = ContentHandler::runLegacyHooks(
372 'testRunLegacyHooks',
377 $this->assertTrue( $ok,
"runLegacyHooks should have returned true" );
378 $this->assertEquals(
"TEST TEXT",
$content->getNativeData() );
382 if ( $text === null || $text ===
false ) {
386 $text = strtoupper( $text );
398 [
'testing',
'DummyContentHandlerForTesting' ],
399 [
'testing-callbacks',
'DummyContentHandlerForTesting' ],
407 $handler = ContentHandler::getForModelID( $modelId );
409 $this->assertInstanceOf( $handlerClass,
$handler );
const CONTENT_MODEL_WIKITEXT
testGetContentText_NonTextContent_fail()
ContentHandler::getContentText should have thrown an exception for non-text Content object MWExceptio...
testRunLegacyHooks()
ContentHandler::runLegacyHooks.
static dummyHookHandler($foo, &$text, $bar)
testGetContentText_Null($contentHandlerTextFallback)
dataGetContentText_Null ContentHandler::getContentText
processing should stop and the error should be shown to the user * false
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
testGetDefaultModelFor($title, $expectedModelId)
dataGetDefaultModelFor ContentHandler::getDefaultModelFor
testSupportsDirectEditing()
if(!isset($args[0])) $lang
testGetModelForID($modelId, $handlerClass)
provideGetModelForID
testGetLocalizedName($id, $expected)
dataGetLocalizedName ContentHandler::getLocalizedName
testMakeContent($data, $title, $modelId, $format, $expectedModelId, $expectedNativeData, $shouldFail)
dataMakeContent ContentHandler::makeContent
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 MediaWikiServices
static newFromText($text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
static dataGetPageLanguage()
when a variable name is used in a it is silently declared as a new local masking the global
testGetForTitle($title, $expectedContentModel)
dataGetDefaultModelFor ContentHandler::getForTitle
$wgLanguageCode
Site language code.
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
static dataGetDefaultModelFor()
static register($name, $callback)
Attach an event handler to a given hook.
static singleton()
Get an instance of this class.
testGetPageLanguage($title, $expected)
dataGetPageLanguage ContentHandler::getPageLanguage
static dataGetContentText_Null()
Allows to change the fields on the form that will be generated are created Can be used to omit specific feeds from being outputted You must not use this hook to add use OutputPage::addFeedLink() instead.&$feedLinks conditions will AND in the final query as a Content object as a Content object $title
Content object for wiki text pages.
CONTENT_MODEL_JAVASCRIPT
Uploads have to be specially set up to be secure.
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
testGetContentText_TextContent($contentHandlerTextFallback)
dataGetContentText_TextContent ContentHandler::getContentText
static dataGetContentText_TextContent()
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 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
const CONTENT_FORMAT_JAVASCRIPT
const CONTENT_FORMAT_WIKITEXT
testGetContentText_NonTextContent_serialize()
ContentHandler::getContentText.
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 $handler
static factory($code)
Get a cached or new language object for a given language code.
static dataGetLocalizedName()
static getCanonicalNamespaces($rebuild=false)
Returns array of all defined namespaces with their canonical (English) names.
testGetContentText_NonTextContent_ignore()
ContentHandler::getContentText.
wfGetLangObj($langcode=false)
Return a Language object from $langcode.
Allows to change the fields on the form that will be generated $name