Merge "skins: Allow Toolbox links to be configured from MediaWiki:Sidebar"
This commit is contained in:
commit
cd4c36148f
2 changed files with 45 additions and 3 deletions
|
|
@ -1534,10 +1534,13 @@ abstract class Skin extends ContextSource {
|
|||
)
|
||||
: $callback();
|
||||
|
||||
$sidebar['TOOLBOX'] = $this->makeToolbox(
|
||||
$this->buildNavUrls(),
|
||||
$this->buildFeedUrls()
|
||||
$sidebar['TOOLBOX'] = array_merge(
|
||||
$this->makeToolbox(
|
||||
$this->buildNavUrls(),
|
||||
$this->buildFeedUrls()
|
||||
), $sidebar['TOOLBOX'] ?? []
|
||||
);
|
||||
|
||||
$sidebar['LANGUAGES'] = $this->getLanguages();
|
||||
// Apply post-processing to the cached value
|
||||
$this->getHookRunner()->onSidebarBeforeOutput( $this, $sidebar );
|
||||
|
|
|
|||
|
|
@ -585,4 +585,43 @@ class SkinTest extends MediaWikiIntegrationTestCase {
|
|||
$this->assertArrayContains( [ 'myhook' => 'foo 1' ], $foo2->buildSidebar(), 'cache hit' );
|
||||
$this->assertArrayContains( [ 'myhook' => 'bar 2' ], $bar->buildSidebar(), 'cache miss' );
|
||||
}
|
||||
|
||||
public function testBuildSidebarWithUserAddedContent() {
|
||||
$this->overrideConfigValues( [
|
||||
MainConfigNames::UseDatabaseMessages => true,
|
||||
MainConfigNames::EnableSidebarCache => false
|
||||
] );
|
||||
$foo1 = new class( 'foo' ) extends Skin {
|
||||
public function outputPage() {
|
||||
}
|
||||
};
|
||||
$this->editPage( 'MediaWiki:Sidebar', <<<EOS
|
||||
* navigation
|
||||
** mainpage|mainpage-description
|
||||
** recentchanges-url|recentchanges
|
||||
** randompage-url|randompage
|
||||
** helppage|help-mediawiki
|
||||
* SEARCH
|
||||
* TOOLBOX
|
||||
** A|B
|
||||
* LANGUAGES
|
||||
** C|D
|
||||
EOS );
|
||||
|
||||
$context = RequestContext::newExtraneousContext( Title::makeTitle( NS_MAIN, 'Main Page' ) );
|
||||
$foo1->setContext( $context );
|
||||
|
||||
$this->assertArrayContains( [ [ 'id' => 'n-B', 'text' => 'B' ] ], $foo1->buildSidebar()['TOOLBOX'], 'Toolbox has user defined links' );
|
||||
|
||||
$hasUserDefinedLinks = false;
|
||||
$languageLinks = $foo1->buildSidebar()['LANGUAGES'];
|
||||
foreach ( $languageLinks as $languageLink ) {
|
||||
if ( $languageLink['id'] === 'n-D' ) {
|
||||
$hasUserDefinedLinks = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$this->assertSame( false, $hasUserDefinedLinks, 'Languages does not support user defined links' );
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue