MediaWiki  1.29.1
ContentHandlerTest.php
Go to the documentation of this file.
1 <?php
3 
9 
10  protected function setUp() {
12  parent::setUp();
13 
14  $this->setMwGlobals( [
15  'wgExtraNamespaces' => [
16  12312 => 'Dummy',
17  12313 => 'Dummy_talk',
18  ],
19  // The below tests assume that namespaces not mentioned here (Help, User, MediaWiki, ..)
20  // default to CONTENT_MODEL_WIKITEXT.
21  'wgNamespaceContentModels' => [
22  12312 => 'testing',
23  ],
24  'wgContentHandlers' => [
25  CONTENT_MODEL_WIKITEXT => 'WikitextContentHandler',
26  CONTENT_MODEL_JAVASCRIPT => 'JavaScriptContentHandler',
27  CONTENT_MODEL_JSON => 'JsonContentHandler',
28  CONTENT_MODEL_CSS => 'CssContentHandler',
29  CONTENT_MODEL_TEXT => 'TextContentHandler',
30  'testing' => 'DummyContentHandlerForTesting',
31  'testing-callbacks' => function( $modelId ) {
32  return new DummyContentHandlerForTesting( $modelId );
33  }
34  ],
35  ] );
36 
37  // Reset namespace cache
39  $wgContLang->resetNamespaces();
40  // And LinkCache
41  MediaWikiServices::getInstance()->resetServiceForTesting( 'LinkCache' );
42  }
43 
44  protected function tearDown() {
46 
47  // Reset namespace cache
49  $wgContLang->resetNamespaces();
50  // And LinkCache
51  MediaWikiServices::getInstance()->resetServiceForTesting( 'LinkCache' );
52 
53  parent::tearDown();
54  }
55 
56  public function addDBDataOnce() {
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]]' );
59  }
60 
61  public static function dataGetDefaultModelFor() {
62  return [
63  [ 'Help:Foo', CONTENT_MODEL_WIKITEXT ],
64  [ 'Help:Foo.js', CONTENT_MODEL_WIKITEXT ],
65  [ 'Help:Foo.css', CONTENT_MODEL_WIKITEXT ],
66  [ 'Help:Foo.json', CONTENT_MODEL_WIKITEXT ],
67  [ 'Help:Foo/bar.js', CONTENT_MODEL_WIKITEXT ],
68  [ 'User:Foo', CONTENT_MODEL_WIKITEXT ],
69  [ 'User:Foo.js', CONTENT_MODEL_WIKITEXT ],
70  [ 'User:Foo.css', CONTENT_MODEL_WIKITEXT ],
71  [ 'User:Foo.json', CONTENT_MODEL_WIKITEXT ],
72  [ 'User:Foo/bar.js', CONTENT_MODEL_JAVASCRIPT ],
73  [ 'User:Foo/bar.css', CONTENT_MODEL_CSS ],
74  [ 'User:Foo/bar.json', CONTENT_MODEL_JSON ],
75  [ 'User:Foo/bar.json.nope', CONTENT_MODEL_WIKITEXT ],
76  [ 'User talk:Foo/bar.css', CONTENT_MODEL_WIKITEXT ],
77  [ 'User:Foo/bar.js.xxx', CONTENT_MODEL_WIKITEXT ],
78  [ 'User:Foo/bar.xxx', CONTENT_MODEL_WIKITEXT ],
79  [ 'MediaWiki:Foo.js', CONTENT_MODEL_JAVASCRIPT ],
80  [ 'MediaWiki:Foo.JS', CONTENT_MODEL_WIKITEXT ],
81  [ 'MediaWiki:Foo.css', CONTENT_MODEL_CSS ],
82  [ 'MediaWiki:Foo.css.xxx', CONTENT_MODEL_WIKITEXT ],
83  [ 'MediaWiki:Foo.CSS', CONTENT_MODEL_WIKITEXT ],
84  [ 'MediaWiki:Foo.json', CONTENT_MODEL_JSON ],
85  [ 'MediaWiki:Foo.JSON', CONTENT_MODEL_WIKITEXT ],
86  ];
87  }
88 
93  public function testGetDefaultModelFor( $title, $expectedModelId ) {
95  $this->assertEquals( $expectedModelId, ContentHandler::getDefaultModelFor( $title ) );
96  }
97 
102  public function testGetForTitle( $title, $expectedContentModel ) {
104  LinkCache::singleton()->addBadLinkObj( $title );
106  $this->assertEquals( $expectedContentModel, $handler->getModelID() );
107  }
108 
109  public static function dataGetLocalizedName() {
110  return [
111  [ null, null ],
112  [ "xyzzy", null ],
113 
114  // XXX: depends on content language
115  [ CONTENT_MODEL_JAVASCRIPT, '/javascript/i' ],
116  ];
117  }
118 
123  public function testGetLocalizedName( $id, $expected ) {
125 
126  if ( $expected ) {
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"
130  );
131  } else {
132  $this->assertEquals( $id, $name, "localization of unknown model $id should have "
133  . "fallen back to use the model id directly."
134  );
135  }
136  }
137 
138  public static function dataGetPageLanguage() {
140 
141  return [
142  [ "Main", $wgLanguageCode ],
143  [ "Dummy:Foo", $wgLanguageCode ],
144  [ "MediaWiki:common.js", 'en' ],
145  [ "User:Foo/common.js", 'en' ],
146  [ "MediaWiki:common.css", 'en' ],
147  [ "User:Foo/common.css", 'en' ],
148  [ "User:Foo", $wgLanguageCode ],
149 
150  [ CONTENT_MODEL_JAVASCRIPT, 'javascript' ],
151  ];
152  }
153 
158  public function testGetPageLanguage( $title, $expected ) {
159  if ( is_string( $title ) ) {
161  LinkCache::singleton()->addBadLinkObj( $title );
162  }
163 
164  $expected = wfGetLangObj( $expected );
165 
167  $lang = $handler->getPageLanguage( $title );
168 
169  $this->assertEquals( $expected->getCode(), $lang->getCode() );
170  }
171 
172  public static function dataGetContentText_Null() {
173  return [
174  [ 'fail' ],
175  [ 'serialize' ],
176  [ 'ignore' ],
177  ];
178  }
179 
184  public function testGetContentText_Null( $contentHandlerTextFallback ) {
185  $this->setMwGlobals( 'wgContentHandlerTextFallback', $contentHandlerTextFallback );
186 
187  $content = null;
188 
190  $this->assertEquals( '', $text );
191  }
192 
193  public static function dataGetContentText_TextContent() {
194  return [
195  [ 'fail' ],
196  [ 'serialize' ],
197  [ 'ignore' ],
198  ];
199  }
200 
205  public function testGetContentText_TextContent( $contentHandlerTextFallback ) {
206  $this->setMwGlobals( 'wgContentHandlerTextFallback', $contentHandlerTextFallback );
207 
208  $content = new WikitextContent( "hello world" );
209 
211  $this->assertEquals( $content->getNativeData(), $text );
212  }
213 
220  $this->setMwGlobals( 'wgContentHandlerTextFallback', 'fail' );
221 
222  $content = new DummyContentForTesting( "hello world" );
223 
225  }
226 
231  $this->setMwGlobals( 'wgContentHandlerTextFallback', 'serialize' );
232 
233  $content = new DummyContentForTesting( "hello world" );
234 
236  $this->assertEquals( $content->serialize(), $text );
237  }
238 
243  $this->setMwGlobals( 'wgContentHandlerTextFallback', 'ignore' );
244 
245  $content = new DummyContentForTesting( "hello world" );
246 
248  $this->assertNull( $text );
249  }
250 
251  /*
252  public static function makeContent( $text, Title $title, $modelId = null, $format = null ) {}
253  */
254 
255  public static function dataMakeContent() {
256  return [
257  [ 'hallo', 'Help:Test', null, null, CONTENT_MODEL_WIKITEXT, 'hallo', false ],
258  [ 'hallo', 'MediaWiki:Test.js', null, null, CONTENT_MODEL_JAVASCRIPT, 'hallo', false ],
259  [ serialize( 'hallo' ), 'Dummy:Test', null, null, "testing", 'hallo', false ],
260 
261  [
262  'hallo',
263  'Help:Test',
264  null,
267  'hallo',
268  false
269  ],
270  [
271  'hallo',
272  'MediaWiki:Test.js',
273  null,
276  'hallo',
277  false
278  ],
279  [ serialize( 'hallo' ), 'Dummy:Test', null, "testing", "testing", 'hallo', false ],
280 
281  [ 'hallo', 'Help:Test', CONTENT_MODEL_CSS, null, CONTENT_MODEL_CSS, 'hallo', false ],
282  [
283  'hallo',
284  'MediaWiki:Test.js',
286  null,
288  'hallo',
289  false
290  ],
291  [
292  serialize( 'hallo' ),
293  'Dummy:Test',
295  null,
297  serialize( 'hallo' ),
298  false
299  ],
300 
301  [ 'hallo', 'Help:Test', CONTENT_MODEL_WIKITEXT, "testing", null, null, true ],
302  [ 'hallo', 'MediaWiki:Test.js', CONTENT_MODEL_CSS, "testing", null, null, true ],
303  [ 'hallo', 'Dummy:Test', CONTENT_MODEL_JAVASCRIPT, "testing", null, null, true ],
304  ];
305  }
306 
311  public function testMakeContent( $data, $title, $modelId, $format,
312  $expectedModelId, $expectedNativeData, $shouldFail
313  ) {
315  LinkCache::singleton()->addBadLinkObj( $title );
316  try {
317  $content = ContentHandler::makeContent( $data, $title, $modelId, $format );
318 
319  if ( $shouldFail ) {
320  $this->fail( "ContentHandler::makeContent should have failed!" );
321  }
322 
323  $this->assertEquals( $expectedModelId, $content->getModel(), 'bad model id' );
324  $this->assertEquals( $expectedNativeData, $content->getNativeData(), 'bads native data' );
325  } catch ( MWException $ex ) {
326  if ( !$shouldFail ) {
327  $this->fail( "ContentHandler::makeContent failed unexpectedly: " . $ex->getMessage() );
328  } else {
329  // dummy, so we don't get the "test did not perform any assertions" message.
330  $this->assertTrue( true );
331  }
332  }
333  }
334 
335  /*
336  * Test if we become a "Created blank page" summary from getAutoSummary if no Content added to
337  * page.
338  */
339  public function testGetAutosummary() {
340  $this->setMwGlobals( 'wgContLang', Language::factory( 'en' ) );
341 
343  $title = Title::newFromText( 'Help:Test' );
344  // Create a new content object with no content
345  $newContent = ContentHandler::makeContent( '', $title, null, null, CONTENT_MODEL_WIKITEXT );
346  // first check, if we become a blank page created summary with the right bitmask
347  $autoSummary = $content->getAutosummary( null, $newContent, 97 );
348  $this->assertEquals( $autoSummary, 'Created blank page' );
349  // now check, what we become with another bitmask
350  $autoSummary = $content->getAutosummary( null, $newContent, 92 );
351  $this->assertEquals( $autoSummary, '' );
352  }
353 
354  /*
355  public function testSupportsSections() {
356  $this->markTestIncomplete( "not yet implemented" );
357  }
358  */
359 
360  public function testSupportsCategories() {
362  $this->assertTrue( $handler->supportsCategories(), 'content model supports categories' );
363  }
364 
365  public function testSupportsDirectEditing() {
367  $this->assertFalse( $handler->supportsDirectEditing(), 'direct editing is not supported' );
368  }
369 
370  public static function dummyHookHandler( $foo, &$text, $bar ) {
371  if ( $text === null || $text === false ) {
372  return false;
373  }
374 
375  $text = strtoupper( $text );
376 
377  return true;
378  }
379 
380  public function provideGetModelForID() {
381  return [
382  [ CONTENT_MODEL_WIKITEXT, 'WikitextContentHandler' ],
383  [ CONTENT_MODEL_JAVASCRIPT, 'JavaScriptContentHandler' ],
384  [ CONTENT_MODEL_JSON, 'JsonContentHandler' ],
385  [ CONTENT_MODEL_CSS, 'CssContentHandler' ],
386  [ CONTENT_MODEL_TEXT, 'TextContentHandler' ],
387  [ 'testing', 'DummyContentHandlerForTesting' ],
388  [ 'testing-callbacks', 'DummyContentHandlerForTesting' ],
389  ];
390  }
391 
395  public function testGetModelForID( $modelId, $handlerClass ) {
397 
398  $this->assertInstanceOf( $handlerClass, $handler );
399  }
400 
401  public function testGetFieldsForSearchIndex() {
402  $searchEngine = $this->newSearchEngine();
403 
405 
406  $fields = $handler->getFieldsForSearchIndex( $searchEngine );
407 
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 );
413  }
414 
415  private function newSearchEngine() {
416  $searchEngine = $this->getMockBuilder( 'SearchEngine' )
417  ->getMock();
418 
419  $searchEngine->expects( $this->any() )
420  ->method( 'makeSearchFieldMapping' )
421  ->will( $this->returnCallback( function( $name, $type ) {
423  } ) );
424 
425  return $searchEngine;
426  }
427 
431  public function testDataIndexFields() {
432  $mockEngine = $this->createMock( 'SearchEngine' );
433  $title = Title::newFromText( 'Not_Main_Page', NS_MAIN );
434  $page = new WikiPage( $title );
435 
436  $this->setTemporaryHook( 'SearchDataForIndex',
437  function (
438  &$fields,
440  WikiPage $page,
443  ) {
444  $fields['testDataField'] = 'test content';
445  } );
446 
447  $output = $page->getContent()->getParserOutput( $title );
448  $data = $page->getContentHandler()->getDataForSearchIndex( $page, $output, $mockEngine );
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'] );
455  }
456 
460  public function testParserOutputForIndexing() {
461  $title = Title::newFromText( 'Smithee', NS_MAIN );
462  $page = new WikiPage( $title );
463 
464  $out = $page->getContentHandler()->getParserOutputForIndexing( $page );
465  $this->assertInstanceOf( ParserOutput::class, $out );
466  $this->assertContains( 'one who smiths', $out->getRawText() );
467  }
468 
472  public function testGetContentModelsHook() {
473  $this->setTemporaryHook( 'GetContentModels', function ( &$models ) {
474  $models[] = 'Ferrari';
475  } );
476  $this->assertContains( 'Ferrari', ContentHandler::getContentModels() );
477  }
478 }
CONTENT_MODEL_JSON
const CONTENT_MODEL_JSON
Definition: Defines.php:237
ContentHandler
A content handler knows how do deal with a specific type of content on a wiki page.
Definition: ContentHandler.php:49
ContentHandler\getForModelID
static getForModelID( $modelId)
Returns the ContentHandler singleton for the given model ID.
Definition: ContentHandler.php:293
ContentHandlerTest\setUp
setUp()
Definition: ContentHandlerTest.php:10
Title\newFromText
static newFromText( $text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
Definition: Title.php:265
ContentHandlerTest\testSupportsCategories
testSupportsCategories()
Definition: ContentHandlerTest.php:360
ParserOutput
Definition: ParserOutput.php:24
false
processing should stop and the error should be shown to the user * false
Definition: hooks.txt:189
ContentHandlerTest\testSupportsDirectEditing
testSupportsDirectEditing()
Definition: ContentHandlerTest.php:365
ContentHandlerTest\addDBDataOnce
addDBDataOnce()
Stub.
Definition: ContentHandlerTest.php:56
$lang
if(!isset( $args[0])) $lang
Definition: testCompression.php:33
CONTENT_MODEL_CSS
const CONTENT_MODEL_CSS
Definition: Defines.php:235
ContentHandlerTest\testGetPageLanguage
testGetPageLanguage( $title, $expected)
dataGetPageLanguage ContentHandler::getPageLanguage
Definition: ContentHandlerTest.php:158
use
as see the revision history and available at free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to use
Definition: MIT-LICENSE.txt:10
ContentHandlerTest\testGetFieldsForSearchIndex
testGetFieldsForSearchIndex()
Definition: ContentHandlerTest.php:401
ContentHandlerTest\tearDown
tearDown()
Definition: ContentHandlerTest.php:44
WikiPage
Class representing a MediaWiki article and history.
Definition: WikiPage.php:36
serialize
serialize()
Definition: ApiMessage.php:177
ContentHandlerTest\testGetAutosummary
testGetAutosummary()
Definition: ContentHandlerTest.php:339
ContentHandlerTest\dataGetDefaultModelFor
static dataGetDefaultModelFor()
Definition: ContentHandlerTest.php:61
ContentHandler\getForTitle
static getForTitle(Title $title)
Returns the appropriate ContentHandler singleton for the given title.
Definition: ContentHandler.php:240
$name
Allows to change the fields on the form that will be generated $name
Definition: hooks.txt:304
CONTENT_MODEL_WIKITEXT
const CONTENT_MODEL_WIKITEXT
Definition: Defines.php:233
$type
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 my talk my contributions etc etc otherwise the built in rate limiting checks are if enabled allows for interception of redirect as a string mapping parameter names to values & $type
Definition: hooks.txt:2536
php
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
Definition: injection.txt:35
ContentHandlerTest\dataGetPageLanguage
static dataGetPageLanguage()
Definition: ContentHandlerTest.php:138
NS_MAIN
const NS_MAIN
Definition: Defines.php:62
ContentHandlerTest\dataGetContentText_Null
static dataGetContentText_Null()
Definition: ContentHandlerTest.php:172
ContentHandler\getDefaultModelFor
static getDefaultModelFor(Title $title)
Returns the name of the default content model to be used for the page with the given title.
Definition: ContentHandler.php:178
MWException
MediaWiki exception.
Definition: MWException.php:26
$title
namespace and then decline to actually register it file or subcat img or subcat $title
Definition: hooks.txt:934
ContentHandler\getContentModels
static getContentModels()
Definition: ContentHandler.php:361
$content
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist Do not use this to implement individual filters if they are compatible with the ChangesListFilter and ChangesListFilterGroup structure use sub classes of those in conjunction with the ChangesListSpecialPageStructuredFilters hook This hook can be used to implement filters that do not implement that or custom behavior that is not an individual filter e g Watchlist and Watchlist you will want to construct new ChangesListBooleanFilter or ChangesListStringOptionsFilter objects When constructing you specify which group they belong to You can reuse existing or create your you must register them with $special registerFilterGroup 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
Definition: hooks.txt:1049
MediaWikiTestCase\setMwGlobals
setMwGlobals( $pairs, $value=null)
Definition: MediaWikiTestCase.php:658
$page
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
Definition: hooks.txt:2536
ContentHandlerTest\testGetContentText_NonTextContent_ignore
testGetContentText_NonTextContent_ignore()
ContentHandler::getContentText.
Definition: ContentHandlerTest.php:242
MediaWikiTestCase
Definition: MediaWikiTestCase.php:13
ContentHandlerTest\testGetDefaultModelFor
testGetDefaultModelFor( $title, $expectedModelId)
dataGetDefaultModelFor ContentHandler::getDefaultModelFor
Definition: ContentHandlerTest.php:93
wfGetLangObj
wfGetLangObj( $langcode=false)
Return a Language object from $langcode.
Definition: GlobalFunctions.php:1321
$output
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist Do not use this to implement individual filters if they are compatible with the ChangesListFilter and ChangesListFilterGroup structure use sub classes of those in conjunction with the ChangesListSpecialPageStructuredFilters hook This hook can be used to implement filters that do not implement that or custom behavior that is not an individual filter e g Watchlist and Watchlist you will want to construct new ChangesListBooleanFilter or ChangesListStringOptionsFilter objects When constructing you specify which group they belong to You can reuse existing or create your you must register them with $special registerFilterGroup 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 the output can only depend on parameters provided to this hook not on global state indicating whether full HTML should be generated If generation of HTML may be but other information should still be present in the ParserOutput object & $output
Definition: hooks.txt:1049
ContentHandlerTest\newSearchEngine
newSearchEngine()
Definition: ContentHandlerTest.php:415
$engine
the value to return A Title object or null for latest all implement SearchIndexField $engine
Definition: hooks.txt:2782
global
when a variable name is used in a it is silently declared as a new masking the global
Definition: design.txt:93
WikitextContent
Content object for wiki text pages.
Definition: WikitextContent.php:33
CONTENT_FORMAT_WIKITEXT
const CONTENT_FORMAT_WIKITEXT
Definition: Defines.php:248
ContentHandlerTest\testGetContentText_NonTextContent_fail
testGetContentText_NonTextContent_fail()
ContentHandler::getContentText should have thrown an exception for non-text Content object MWExceptio...
Definition: ContentHandlerTest.php:219
ContentHandler\makeContent
static makeContent( $text, Title $title=null, $modelId=null, $format=null)
Convenience function for creating a Content object from a given textual representation.
Definition: ContentHandler.php:129
ContentHandlerTest\testGetLocalizedName
testGetLocalizedName( $id, $expected)
dataGetLocalizedName ContentHandler::getLocalizedName
Definition: ContentHandlerTest.php:123
ContentHandlerTest\testGetModelForID
testGetModelForID( $modelId, $handlerClass)
provideGetModelForID
Definition: ContentHandlerTest.php:395
any
they could even be mouse clicks or menu items whatever suits your program You should also get your if any
Definition: COPYING.txt:326
ContentHandler\getLocalizedName
static getLocalizedName( $name, Language $lang=null)
Returns the localized name for a given content model.
Definition: ContentHandler.php:348
$wgLanguageCode
$wgLanguageCode
Site language code.
Definition: DefaultSettings.php:2839
DummyContentForTesting
Definition: DummyContentForTesting.php:3
$handler
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
Definition: hooks.txt:783
SearchEngine
Contain a class for special pages.
Definition: SearchEngine.php:34
DummySearchIndexFieldDefinition
Dummy implementation of SearchIndexFieldDefinition for testing purposes.
Definition: DummySearchIndexFieldDefinition.php:8
ContentHandlerTest\dataMakeContent
static dataMakeContent()
Definition: ContentHandlerTest.php:255
ContentHandler\getContentText
static getContentText(Content $content=null)
Convenience function for getting flat text from a Content object.
Definition: ContentHandler.php:79
ContentHandlerTest\testParserOutputForIndexing
testParserOutputForIndexing()
ContentHandler::getParserOutputForIndexing.
Definition: ContentHandlerTest.php:460
MediaWikiTestCase\insertPage
insertPage( $pageName, $text='Sample page for unit test.', $namespace=null)
Insert a new page.
Definition: MediaWikiTestCase.php:953
LinkCache\singleton
static singleton()
Get an instance of this class.
Definition: LinkCache.php:67
ContentHandlerTest\testGetContentText_Null
testGetContentText_Null( $contentHandlerTextFallback)
dataGetContentText_Null ContentHandler::getContentText
Definition: ContentHandlerTest.php:184
ContentHandlerTest\dataGetLocalizedName
static dataGetLocalizedName()
Definition: ContentHandlerTest.php:109
MWNamespace\getCanonicalNamespaces
static getCanonicalNamespaces( $rebuild=false)
Returns array of all defined namespaces with their canonical (English) names.
Definition: MWNamespace.php:207
ContentHandlerTest\testDataIndexFields
testDataIndexFields()
ContentHandler::getDataForSearchIndex.
Definition: ContentHandlerTest.php:431
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 true
Definition: hooks.txt:1956
ContentHandlerTest\dataGetContentText_TextContent
static dataGetContentText_TextContent()
Definition: ContentHandlerTest.php:193
Language\factory
static factory( $code)
Get a cached or new language object for a given language code.
Definition: Language.php:183
ContentHandlerTest\testGetContentText_TextContent
testGetContentText_TextContent( $contentHandlerTextFallback)
dataGetContentText_TextContent ContentHandler::getContentText
Definition: ContentHandlerTest.php:205
class
you have access to all of the normal MediaWiki so you can get a DB use the etc For full docs on the Maintenance class
Definition: maintenance.txt:52
CONTENT_MODEL_JAVASCRIPT
const CONTENT_MODEL_JAVASCRIPT
Definition: Defines.php:234
CONTENT_FORMAT_JAVASCRIPT
const CONTENT_FORMAT_JAVASCRIPT
Definition: Defines.php:250
ContentHandlerTest\testGetForTitle
testGetForTitle( $title, $expectedContentModel)
dataGetDefaultModelFor ContentHandler::getForTitle
Definition: ContentHandlerTest.php:102
MediaWikiTestCase\setTemporaryHook
setTemporaryHook( $hookName, $handler)
Create a temporary hook handler which will be reset by tearDown.
Definition: MediaWikiTestCase.php:1796
ContentHandlerTest\provideGetModelForID
provideGetModelForID()
Definition: ContentHandlerTest.php:380
MediaWikiServices
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
Definition: injection.txt:23
CONTENT_MODEL_TEXT
const CONTENT_MODEL_TEXT
Definition: Defines.php:236
ContentHandlerTest
ContentHandler Database.
Definition: ContentHandlerTest.php:8
ContentHandlerTest\testGetContentText_NonTextContent_serialize
testGetContentText_NonTextContent_serialize()
ContentHandler::getContentText.
Definition: ContentHandlerTest.php:230
DummyContentHandlerForTesting
Definition: DummyContentHandlerForTesting.php:3
ContentHandlerTest\dummyHookHandler
static dummyHookHandler( $foo, &$text, $bar)
Definition: ContentHandlerTest.php:370
ContentHandlerTest\testGetContentModelsHook
testGetContentModelsHook()
ContentHandler::getContentModels.
Definition: ContentHandlerTest.php:472
ContentHandlerTest\testMakeContent
testMakeContent( $data, $title, $modelId, $format, $expectedModelId, $expectedNativeData, $shouldFail)
dataMakeContent ContentHandler::makeContent
Definition: ContentHandlerTest.php:311
$wgContLang
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
Definition: design.txt:56
$out
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
Definition: hooks.txt:783