Go to the documentation of this file.
18 'wgExtraNamespaces' =>
array(
20 12313 =>
'Dummy_talk',
24 'wgNamespaceContentModels' =>
array(
27 'wgContentHandlers' =>
array(
32 'testing' =>
'DummyContentHandlerForTesting',
38 $wgContLang->resetNamespaces();
87 $this->assertEquals( $expectedContentModel, $handler->getModelID() );
93 array(
"xyzzy",
null ),
108 $this->assertNotNull(
$name,
"no name found for content model $id" );
109 $this->assertTrue( preg_match( $expected,
$name ) > 0,
110 "content model name for #$id did not match pattern $expected"
113 $this->assertEquals( $id,
$name,
"localization of unknown model $id should have "
114 .
"fallen back to use the model id directly."
123 array(
"Main", $wgLanguageCode ),
124 array(
"Dummy:Foo", $wgLanguageCode ),
125 array(
"MediaWiki:common.js",
'en' ),
126 array(
"User:Foo/common.js",
'en' ),
127 array(
"MediaWiki:common.css",
'en' ),
128 array(
"User:Foo/common.css",
'en' ),
129 array(
"User:Foo", $wgLanguageCode ),
140 if ( is_string(
$title ) ) {
147 $lang = $handler->getPageLanguage(
$title );
149 $this->assertEquals( $expected->getCode(), $lang->getCode() );
155 array(
'serialize' ),
165 $this->
setMwGlobals(
'wgContentHandlerTextFallback', $contentHandlerTextFallback );
170 $this->assertEquals(
'', $text );
176 array(
'serialize' ),
186 $this->
setMwGlobals(
'wgContentHandlerTextFallback', $contentHandlerTextFallback );
191 $this->assertEquals( $content->getNativeData(), $text );
200 $this->
setMwGlobals(
'wgContentHandlerTextFallback',
'fail' );
211 $this->
setMwGlobals(
'wgContentHandlerTextFallback',
'serialize' );
216 $this->assertEquals( $content->serialize(), $text );
223 $this->
setMwGlobals(
'wgContentHandlerTextFallback',
'ignore' );
228 $this->assertNull( $text );
239 array( serialize(
'hallo' ),
'Dummy:Test',
null,
null,
"testing",
'hallo',
false ),
243 array( serialize(
'hallo' ),
'Dummy:Test',
null,
"testing",
"testing",
'hallo',
false ),
259 public function testMakeContent( $data,
$title, $modelId, $format, $expectedModelId, $expectedNativeData, $shouldFail ) {
266 $this->
fail(
"ContentHandler::makeContent should have failed!" );
269 $this->assertEquals( $expectedModelId, $content->getModel(),
'bad model id' );
270 $this->assertEquals( $expectedNativeData, $content->getNativeData(),
'bads native data' );
272 if ( !$shouldFail ) {
273 $this->
fail(
"ContentHandler::makeContent failed unexpectedly: " . $ex->getMessage() );
276 $this->assertTrue(
true );
291 Hooks::register(
'testRunLegacyHooks', __CLASS__ .
'::dummyHookHandler' );
296 $this->assertTrue(
$ok,
"runLegacyHooks should have returned true" );
297 $this->assertEquals(
"TEST TEXT", $content->getNativeData() );
301 if ( $text ===
null || $text ===
false ) {
305 $text = strtoupper( $text );
314 parent::__construct( $dataModel,
array(
"testing" ) );
338 $d = unserialize(
$blob );
355 parent::__construct(
"testing" );
407 return strlen( $this->
data );
Set options of the Parser.
A content handler knows how do deal with a specific type of content on a wiki page.
static newFromText( $text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
and how to run hooks for an and one after Each event has a preferably in CamelCase For ArticleDelete hook A clump of code and data that should be run when an event happens This can be either a function and a chunk of data
serialize( $format=null)
Convenience method for serializing this Content object.
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
getParserOutput(Title $title, $revId=null, ParserOptions $options=null, $generateHtml=true)
testGetPageLanguage( $title, $expected)
@dataProvider dataGetPageLanguage @covers ContentHandler::getPageLanguage
static dataGetDefaultModelFor()
as a message key or array as accepted by ApiBase::dieUsageMsg after processing request parameters Return false to let the request fail
static getForTitle(Title $title)
Returns the appropriate ContentHandler singleton for the given title.
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 content language as $wgContLang
const CONTENT_MODEL_WIKITEXT
getTextForSummary( $maxlength=250)
Returns a textual representation of the content suitable for use in edit summaries and log messages.
static runLegacyHooks( $event, $args=array(), $warn=null)
Call a legacy hook that uses text instead of Content objects.
static dataGetPageLanguage()
static getLocalizedName( $name)
Returns the localized name for a given content model.
static dataGetContentText_Null()
isCountable( $hasLinks=null)
Returns true if this content is countable as a "real" wiki page, provided that it's also in a countab...
static getDefaultModelFor(Title $title)
Returns the name of the default content model to be used for the page with the given title.
testGetContentText_NonTextContent_ignore()
@covers ContentHandler::getContentText
testGetDefaultModelFor( $title, $expectedModelId)
@dataProvider dataGetDefaultModelFor @covers ContentHandler::getDefaultModelFor
wfGetLangObj( $langcode=false)
Return a Language object from $langcode.
testRunLegacyHooks()
@covers ContentHandler::runLegacyHooks
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
when a variable name is used in a it is silently declared as a new masking the global
Content object for wiki text pages.
const CONTENT_FORMAT_WIKITEXT
testGetContentText_NonTextContent_fail()
ContentHandler::getContentText should have thrown an exception for non-text Content object @expectedE...
static makeContent( $text, Title $title=null, $modelId=null, $format=null)
Convenience function for creating a Content object from a given textual representation.
testGetLocalizedName( $id, $expected)
@dataProvider dataGetLocalizedName @covers ContentHandler::getLocalizedName
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 & $options
presenting them properly to the user as errors is done by the caller $title
Allows to change the fields on the form that will be generated $name
static register( $name, $callback)
Attach an event handler to a given hook.
makeEmptyContent()
Creates an empty Content object of the type supported by this ContentHandler.
Base implementation for content objects.
serializeContent(Content $content, $format=null)
getWikitextForTransclusion()
Base interface for content objects.
Represents a title within MediaWiki.
static getContentText(Content $content=null)
Convenience function for getting flat text from a Content object.
testGetContentText_Null( $contentHandlerTextFallback)
@dataProvider dataGetContentText_Null @covers ContentHandler::getContentText
static dataGetLocalizedName()
static getCanonicalNamespaces( $rebuild=false)
Returns array of all defined namespaces with their canonical (English) names.
static dataGetContentText_TextContent()
testGetContentText_TextContent( $contentHandlerTextFallback)
@dataProvider dataGetContentText_TextContent @covers ContentHandler::getContentText
const CONTENT_MODEL_JAVASCRIPT
const CONTENT_FORMAT_JAVASCRIPT
testGetForTitle( $title, $expectedContentModel)
@dataProvider dataGetDefaultModelFor @covers ContentHandler::getForTitle
getSize()
returns the content's nominal size in bogo-bytes.
copy()
Return a copy of this Content object.
@group ContentHandler @group Database
unserializeContent( $blob, $format=null)
testGetContentText_NonTextContent_serialize()
@covers ContentHandler::getContentText
getNativeData()
Returns native represenation of the data.
static dummyHookHandler( $foo, &$text, $bar)
testMakeContent( $data, $title, $modelId, $format, $expectedModelId, $expectedNativeData, $shouldFail)
@dataProvider dataMakeContent @covers ContentHandler::makeContent