16 $user->setName(
'127.0.0.1' );
19 $this->context->setTitle( Title::newFromText(
'Test' ) );
20 $this->context->setUser(
$user );
24 'wgTextModelsToParse' => [
30 'wgCapitalLinks' =>
true,
49 'TextContentTest_testGetParserOutput',
51 "hello ''world'' & [[stuff]]\n",
"hello ''world'' & [[stuff]]",
65 $expectedFields =
null
72 $html = $po->getText();
73 $html = preg_replace(
'#<!--.*?-->#sm',
'',
$html );
75 $this->assertEquals( $expectedHtml, trim(
$html ) );
77 if ( $expectedFields ) {
78 foreach ( $expectedFields
as $field => $exp ) {
79 $f =
'get' . ucfirst( $field );
80 $v = call_user_func( [ $po, $f ] );
82 if ( is_array( $exp ) ) {
85 $this->assertEquals( $exp, $v );
96 # 0: no signature resolution
106 # 2: newline normalization
107 "LF\n\nCRLF\r\n\r\nCR\r\rEND",
108 "LF\n\nCRLF\n\nCR\n\nEND",
124 $this->context->getTitle(),
125 $this->context->getUser(),
129 $this->assertEquals( $expected,
$content->getNativeData() );
152 $this->assertEquals( $expected,
$content->getNativeData() );
157 [
'#REDIRECT [[Test]]',
171 if ( is_null( $expected ) ) {
172 $this->assertNull(
$t,
"text should not have generated a redirect target: $text" );
174 $this->assertEquals( $expected,
$t->getPrefixedText() );
185 $this->assertEquals( !is_null( $expected ),
$content->isRedirect() );
223 $v =
$content->isCountable( $hasLinks, $this->context->getTitle() );
228 'isCountable() returned unexpected value ' . var_export( $v,
true )
229 .
' instead of ' . var_export( $expected,
true )
230 .
" in mode `$mode` for text \"$text\""
244 [
'[[hello world]].',
258 $this->assertEquals( $expected,
$content->getTextForSummary( $maxlength ) );
267 $this->assertEquals(
'hello world.',
$content->getTextForSearchIndex() );
277 $this->assertTrue(
$content->equals( $copy ),
'copy must be equal to original' );
278 $this->assertEquals(
'hello world.', $copy->getNativeData() );
287 $this->assertEquals( 12,
$content->getSize() );
296 $this->assertEquals(
'hello world.',
$content->getNativeData() );
305 $this->assertEquals(
'hello world.',
$content->getWikitextForTransclusion() );
331 [
'hallo welt.',
false ],
342 $this->assertEquals( $empty,
$content->isEmpty() );
360 $this->assertEquals( $equal, $a->
equals( $b ) );
365 [
"TextContentTest_testGetSecondaryDataUpdates_1",
369 [
"TextContentTest_testGetSecondaryDataUpdates_2",
393 foreach ( $updates
as $update ) {
394 $class = get_class( $update );
395 $updates[$class] = $update;
398 if ( !$expectedStuff ) {
399 $this->assertTrue(
true );
403 foreach ( $expectedStuff
as $class => $fieldValues ) {
404 $this->assertArrayHasKey( $class, $updates,
"missing an update of type $class" );
406 $update = $updates[$class];
408 foreach ( $fieldValues
as $field =>
$value ) {
409 $v = $update->$field; #
if the field doesn
't exist, just crash and burn
410 $this->assertEquals( $value, $v, "unexpected value for field $field in instance of $class" );
414 $page->doDeleteArticle( '' );
417 public static function provideConvert() {
421 CONTENT_MODEL_WIKITEXT,
427 CONTENT_MODEL_WIKITEXT,
439 CONTENT_MODEL_JAVASCRIPT,
450 public function testConvert( $text, $model, $lossy, $expectedNative ) {
451 $content = $this->newContent( $text );
453 $converted = $content->convert( $model, $lossy );
455 if ( $expectedNative === false ) {
456 $this->assertFalse( $converted, "conversion to $model was expected to fail!" );
458 $this->assertInstanceOf( '
Content', $converted );
459 $this->assertEquals( $expectedNative, $converted->getNativeData() );
467 public function testNormalizeLineEndings( $input, $expected ) {
468 $this->assertEquals( $expected, TextContent::normalizeLineEndings( $input ) );
471 public static function provideNormalizeLineEndings() {
static makeContent( $text, Title $title=null, $modelId=null, $format=null)
Convenience function for creating a Content object from a given textual representation.
WebRequest clone which takes values from a provided array.
Content for JavaScript pages.
static destroySingleton()
Destroy the current singleton instance.
static newFromUserAndLang(User $user, Language $lang)
Get a ParserOptions object from a given user and language.
Group all the pieces relevant to the context of a request into one instance.
ContentHandler Database ^— needed, because we do need the database to test link updates.
testGetContentHandler()
TextContent::getContentHandler.
testGetTextForSearchIndex()
TextContent::getTextForSearchIndex.
testGetModel()
TextContent::getModel.
testGetNativeData()
TextContent::getNativeData.
testGetSize()
TextContent::getSize.
testGetParserOutput( $title, $model, $text, $expectedHtml, $expectedFields=null)
dataGetParserOutput TextContent::getParserOutput
testPreloadTransform( $text, $expected)
dataPreloadTransform TextContent::preloadTransform
testCopy()
TextContent::copy.
static dataGetParserOutput()
testEquals(Content $a, Content $b=null, $equal=false)
dataEquals TextContent::equals
testGetWikitextForTransclusion()
TextContent::getWikitextForTransclusion.
testIsEmpty( $text, $empty)
dataIsEmpty TextContent::isEmpty
static dataGetRedirectTarget()
testIsRedirect( $text, $expected)
dataGetRedirectTarget TextContent::isRedirect
testGetRedirectTarget( $text, $expected)
dataGetRedirectTarget TextContent::getRedirectTarget
testDeletionUpdates( $title, $model, $text, $expectedStuff)
dataGetDeletionUpdates TextContent::getDeletionUpdates
static dataGetDeletionUpdates()
testIsCountable( $text, $hasLinks, $mode, $expected)
dataIsCountable Database TextContent::isCountable
testGetTextForSummary( $text, $maxlength, $expected)
dataGetTextForSummary TextContent::getTextForSummary
static dataPreSaveTransform()
static dataPreloadTransform()
testPreSaveTransform( $text, $expected)
dataPreSaveTransform TextContent::preSaveTransform
static dataGetTextForSummary()
Content object implementation for representing flat text.
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
static factory(Title $title)
Create a WikiPage object of the appropriate class for the given title.
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
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
const CONTENT_MODEL_WIKITEXT
const CONTENT_MODEL_JAVASCRIPT
please add to it if you re going to add events to the MediaWiki code where normally authentication against an external auth plugin would be creating a local account $user
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 as context as context $options
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
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
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 an< a > element with HTML attributes $attribs and contents $html will be returned If you return $ret will be returned and may include noclasses & $html
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
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
Base interface for content objects.
equals(Content $that=null)
Returns true if this Content objects is conceptually equivalent to the given Content object.