15 'wgExtraNamespaces' => [
17 12313 =>
'Dummy_talk',
21 'wgNamespaceContentModels' => [
24 'wgContentHandlers' => [
30 'testing' =>
'DummyContentHandlerForTesting',
31 'testing-callbacks' =>
function ( $modelId ) {
38 MWNamespace::getCanonicalNamespaces(
true );
41 MediaWikiServices::getInstance()->resetServiceForTesting(
'LinkCache' );
48 MWNamespace::getCanonicalNamespaces(
true );
51 MediaWikiServices::getInstance()->resetServiceForTesting(
'LinkCache' );
57 $this->
insertPage(
'Not_Main_Page',
'This is not a main page' );
58 $this->
insertPage(
'Smithee',
'A smithee is one who smiths. See also [[Alan Smithee]]' );
94 $title = Title::newFromText( $title );
103 $title = Title::newFromText( $title );
104 LinkCache::singleton()->addBadLinkObj( $title );
106 $this->assertEquals( $expectedContentModel,
$handler->getModelID() );
127 $this->assertNotNull( $name,
"no name found for content model $id" );
128 $this->assertTrue( preg_match( $expected, $name ) > 0,
129 "content model name for #$id did not match pattern $expected"
132 $this->assertEquals( $id, $name,
"localization of unknown model $id should have "
133 .
"fallen back to use the model id directly."
144 [
"MediaWiki:common.js",
'en' ],
145 [
"User:Foo/common.js",
'en' ],
146 [
"MediaWiki:common.css",
'en' ],
147 [
"User:Foo/common.css",
'en' ],
159 if ( is_string( $title ) ) {
160 $title = Title::newFromText( $title );
161 LinkCache::singleton()->addBadLinkObj( $title );
169 $this->assertEquals( $expected->getCode(),
$lang->getCode() );
185 $this->
setMwGlobals(
'wgContentHandlerTextFallback', $contentHandlerTextFallback );
190 $this->assertEquals(
'', $text );
206 $this->
setMwGlobals(
'wgContentHandlerTextFallback', $contentHandlerTextFallback );
211 $this->assertEquals( $content->getNativeData(), $text );
220 $this->
setMwGlobals(
'wgContentHandlerTextFallback',
'fail' );
231 $this->
setMwGlobals(
'wgContentHandlerTextFallback',
'serialize' );
236 $this->assertEquals( $content->serialize(), $text );
243 $this->
setMwGlobals(
'wgContentHandlerTextFallback',
'ignore' );
248 $this->assertNull( $text );
259 [
serialize(
'hallo' ),
'Dummy:Test',
null,
null,
"testing",
'hallo',
false ],
279 [
serialize(
'hallo' ),
'Dummy:Test',
null,
"testing",
"testing",
'hallo',
false ],
312 $expectedModelId, $expectedNativeData, $shouldFail
314 $title = Title::newFromText( $title );
315 LinkCache::singleton()->addBadLinkObj( $title );
320 $this->fail(
"ContentHandler::makeContent should have failed!" );
323 $this->assertEquals( $expectedModelId, $content->getModel(),
'bad model id' );
324 $this->assertEquals( $expectedNativeData, $content->getNativeData(),
'bads native data' );
326 if ( !$shouldFail ) {
327 $this->fail(
"ContentHandler::makeContent failed unexpectedly: " . $ex->getMessage() );
330 $this->assertTrue(
true );
340 $this->
setMwGlobals(
'wgContLang', Language::factory(
'en' ) );
343 $title = Title::newFromText(
'Help:Test' );
347 $autoSummary = $content->getAutosummary(
null, $newContent, 97 );
348 $this->assertEquals( $autoSummary,
'Created blank page' );
350 $autoSummary = $content->getAutosummary(
null, $newContent, 92 );
351 $this->assertEquals( $autoSummary,
'' );
362 $this->assertTrue(
$handler->supportsCategories(),
'content model supports categories' );
367 $this->assertFalse(
$handler->supportsDirectEditing(),
'direct editing is not supported' );
371 if ( $text ===
null || $text ===
false ) {
375 $text = strtoupper( $text );
387 [
'testing',
'DummyContentHandlerForTesting' ],
388 [
'testing-callbacks',
'DummyContentHandlerForTesting' ],
398 $this->assertInstanceOf( $handlerClass,
$handler );
406 $fields =
$handler->getFieldsForSearchIndex( $searchEngine );
408 $this->assertArrayHasKey(
'category', $fields );
409 $this->assertArrayHasKey(
'external_link', $fields );
410 $this->assertArrayHasKey(
'outgoing_link', $fields );
411 $this->assertArrayHasKey(
'template', $fields );
412 $this->assertArrayHasKey(
'content_model', $fields );
416 $searchEngine = $this->getMockBuilder(
'SearchEngine' )
419 $searchEngine->expects( $this->
any() )
420 ->method(
'makeSearchFieldMapping' )
421 ->will( $this->returnCallback(
function ( $name,
$type ) {
425 return $searchEngine;
432 $mockEngine = $this->createMock(
'SearchEngine' );
433 $title = Title::newFromText(
'Not_Main_Page',
NS_MAIN );
444 $fields[
'testDataField'] =
'test content';
449 $this->assertArrayHasKey(
'text', $data );
450 $this->assertArrayHasKey(
'text_bytes', $data );
451 $this->assertArrayHasKey(
'language', $data );
452 $this->assertArrayHasKey(
'testDataField', $data );
453 $this->assertEquals(
'test content', $data[
'testDataField'] );
454 $this->assertEquals(
'wikitext', $data[
'content_model'] );
461 $title = Title::newFromText(
'Smithee',
NS_MAIN );
464 $out = $page->getContentHandler()->getParserOutputForIndexing( $page );
465 $this->assertInstanceOf( ParserOutput::class,
$out );
466 $this->assertContains(
'one who smiths',
$out->getRawText() );
474 $models[] =
'Ferrari';
they could even be mouse clicks or menu items whatever suits your program You should also get your if any
$wgLanguageCode
Site language code.
wfGetLangObj( $langcode=false)
Return a Language object from $langcode.
testGetPageLanguage( $title, $expected)
dataGetPageLanguage ContentHandler::getPageLanguage
testGetContentText_Null( $contentHandlerTextFallback)
dataGetContentText_Null ContentHandler::getContentText
testGetContentText_TextContent( $contentHandlerTextFallback)
dataGetContentText_TextContent ContentHandler::getContentText
testGetFieldsForSearchIndex()
static dataGetLocalizedName()
testGetContentText_NonTextContent_ignore()
ContentHandler::getContentText.
testGetModelForID( $modelId, $handlerClass)
provideGetModelForID
testMakeContent( $data, $title, $modelId, $format, $expectedModelId, $expectedNativeData, $shouldFail)
dataMakeContent ContentHandler::makeContent
testSupportsDirectEditing()
static dataGetContentText_Null()
testGetDefaultModelFor( $title, $expectedModelId)
dataGetDefaultModelFor ContentHandler::getDefaultModelFor
testGetContentModelsHook()
ContentHandler::getContentModels.
testGetContentText_NonTextContent_fail()
ContentHandler::getContentText should have thrown an exception for non-text Content object MWExceptio...
static dummyHookHandler( $foo, &$text, $bar)
testDataIndexFields()
ContentHandler::getDataForSearchIndex.
static dataGetPageLanguage()
static dataGetContentText_TextContent()
testParserOutputForIndexing()
ContentHandler::getParserOutputForIndexing.
testGetForTitle( $title, $expectedContentModel)
dataGetDefaultModelFor ContentHandler::getForTitle
testGetLocalizedName( $id, $expected)
dataGetLocalizedName ContentHandler::getLocalizedName
static dataGetDefaultModelFor()
testGetContentText_NonTextContent_serialize()
ContentHandler::getContentText.
A content handler knows how do deal with a specific type of content on a wiki page.
static makeContent( $text, Title $title=null, $modelId=null, $format=null)
Convenience function for creating a Content object from a given textual representation.
static getForModelID( $modelId)
Returns the ContentHandler singleton for the given model ID.
static getForTitle(Title $title)
Returns the appropriate ContentHandler singleton for the given title.
static getContentModels()
static getDefaultModelFor(Title $title)
Returns the name of the default content model to be used for the page with the given title.
static getLocalizedName( $name, Language $lang=null)
Returns the localized name for a given content model.
static getContentText(Content $content=null)
Convenience function for getting flat text from a Content object.
Dummy implementation of SearchIndexFieldDefinition for testing purposes.
Contain a class for special pages.
Class representing a MediaWiki article and history.
getContent( $audience=Revision::FOR_PUBLIC, User $user=null)
Get the content of the current revision.
getContentHandler()
Returns the ContentHandler instance to be used to deal with the content of this WikiPage.
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
static configuration should be added through ResourceLoaderGetConfigVars instead can be used to get the real title after the basic globals have been set but before ordinary actions take place $output
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
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
the value to return A Title object or null for latest all implement SearchIndexField $engine
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
processing should stop and the error should be shown to the user * false
const CONTENT_FORMAT_JAVASCRIPT
const CONTENT_MODEL_WIKITEXT
const CONTENT_FORMAT_WIKITEXT
const CONTENT_MODEL_JAVASCRIPT
if(!isset( $args[0])) $lang