public function testGetOtherProjectsSidebarGenerator() { $settings = new SettingsArray(array('siteGlobalID' => 'enwiki', 'otherProjectsLinks' => array('enwiktionary'))); $siteLinkLookup = new MockRepository(); $siteStore = new HashSiteStore(TestSites::getSites()); $factory = new OtherProjectsSidebarGeneratorFactory($settings, $siteLinkLookup, $siteStore); $otherProjectSidebarGenerator = $factory->getOtherProjectsSidebarGenerator(); $this->assertInstanceOf('Wikibase\\Client\\Hooks\\OtherProjectsSidebarGenerator', $otherProjectSidebarGenerator); }
/** * @param Title $title * @param ParserOutput $out */ public function updateOtherProjectsLinksData(Title $title, ParserOutput $out) { $itemId = $this->getItemIdForTitle($title); if ($itemId) { $otherProjectsSidebarGenerator = $this->otherProjectsSidebarGeneratorFactory->getOtherProjectsSidebarGenerator(); $otherProjects = $otherProjectsSidebarGenerator->buildProjectLinkSidebar($title); $out->setExtensionData('wikibase-otherprojects-sidebar', $otherProjects); } else { $out->setExtensionData('wikibase-otherprojects-sidebar', array()); } }
/** * Adds the "other projects" section to the sidebar, if enabled project wide or * the user has the beta featured enabled. * * @param Skin $skin * @param array &$sidebar * * @return bool */ public function doSidebarBeforeOutput(Skin $skin, array &$sidebar) { $outputPage = $skin->getContext()->getOutput(); $title = $outputPage->getTitle(); if (!$this->namespaceChecker->isWikibaseEnabled($title->getNamespace()) || !$outputPage->getProperty('wikibase_item')) { return true; } $betaFeatureEnabled = class_exists('\\BetaFeatures') && $this->otherProjectsLinksBeta && \BetaFeatures::isFeatureEnabled($skin->getContext()->getUser(), 'wikibase-otherprojects'); if ($this->otherProjectsLinksDefault || $betaFeatureEnabled) { $otherProjectsSidebar = $outputPage->getProperty('wikibase-otherprojects-sidebar'); // in case of stuff in cache without the other projects if ($otherProjectsSidebar === null) { $otherProjectsSidebarGenerator = $this->otherProjectsSidebarGeneratorFactory->getOtherProjectsSidebarGenerator(); $otherProjectsSidebar = $otherProjectsSidebarGenerator->buildProjectLinkSidebar($title); } if (!empty($otherProjectsSidebar)) { $sidebar['wikibase-otherprojects'] = $otherProjectsSidebar; } } return true; }