jenkins-bot has submitted this change and it was merged.

Change subject: Add other projects sidebar
......................................................................


Add other projects sidebar

Bug: T141771

Change-Id: I4c5cb093ca24c4a2755d8745edc92830778c5d25
---
M includes/AboutTopicRenderer.php
M includes/specials/SpecialAboutTopic.php
M tests/phpunit/includes/AboutTopicRendererTest.php
3 files changed, 49 insertions(+), 8 deletions(-)

Approvals:
  Hoo man: Looks good to me, but someone else must approve
  Thiemo Mättig (WMDE): Looks good to me, approved
  jenkins-bot: Verified



diff --git a/includes/AboutTopicRenderer.php b/includes/AboutTopicRenderer.php
index b3dd674..c87a35e 100644
--- a/includes/AboutTopicRenderer.php
+++ b/includes/AboutTopicRenderer.php
@@ -2,17 +2,18 @@
 
 namespace ArticlePlaceholder;
 
+use Language;
 use OOUI;
+use SiteLookup;
 use SpecialPage;
 use Title;
-use Wikibase\Client\Store\TitleFactory;
+use User;
+use OutputPage;
 use Wikibase\DataModel\Entity\ItemId;
+use Wikibase\Client\Store\TitleFactory;
+use Wikibase\Client\Hooks\OtherProjectsSidebarGeneratorFactory;
 use Wikibase\Lib\Store\LanguageFallbackLabelDescriptionLookupFactory;
 use Wikibase\Lib\Store\SiteLinkLookup;
-use OutputPage;
-use SiteLookup;
-use Language;
-use User;
 
 /**
  * The AboutTopic SpecialPage for the ArticlePlaceholder extension
@@ -49,24 +50,32 @@
        private $titleFactory;
 
        /**
+        * @var OtherProjectsSidebarGeneratorFactory
+        */
+       private $otherProjectsSidebarGeneratorFactory;
+
+       /**
         * @param LanguageFallbackLabelDescriptionLookupFactory 
$termLookupFactory
         * @param SiteLinkLookup $siteLinkLookup
         * @param SiteLookup $siteLookup
         * @param string $langLinkSiteGroup
         * @param TitleFactory $titleFactory
+        * @param OtherProjectsSidebarGeneratorFactory 
$otherProjectsSidebarGeneratorFactory
         */
        public function __construct(
                LanguageFallbackLabelDescriptionLookupFactory 
$termLookupFactory,
                SiteLinkLookup $siteLinkLookup,
                SiteLookup $siteLookup,
                $langLinkSiteGroup,
-               TitleFactory $titleFactory
+               TitleFactory $titleFactory,
+               OtherProjectsSidebarGeneratorFactory 
$otherProjectsSidebarGeneratorFactory
        ) {
                $this->termLookupFactory = $termLookupFactory;
                $this->siteLinkLookup = $siteLinkLookup;
                $this->siteLookup = $siteLookup;
                $this->langLinkSiteGroup = $langLinkSiteGroup;
                $this->titleFactory = $titleFactory;
+               $this->otherProjectsSidebarGeneratorFactory = 
$otherProjectsSidebarGeneratorFactory;
        }
 
        /**
@@ -93,6 +102,7 @@
                        $this->showCreateArticle( $labelTitle, $output );
                }
                $this->showLanguageLinks( $entityId, $output );
+               $this->setOtherProjectsLinks( $entityId, $output );
        }
 
        /**
@@ -164,4 +174,18 @@
                $output->setLanguageLinks( $languageLinks );
        }
 
+       /**
+        * Set other projects links
+        * @param ItemId $itemId
+        * @param OutputPage $output
+        */
+       private function setOtherProjectsLinks( ItemId $itemId, OutputPage 
$output ) {
+               $otherProjectsSidebarGenerator = 
$this->otherProjectsSidebarGeneratorFactory
+                       ->getOtherProjectsSidebarGenerator();
+
+               $otherProjects = 
$otherProjectsSidebarGenerator->buildProjectLinkSidebarFromItemId( $itemId );
+               $output->setProperty( 'wikibase-otherprojects-sidebar', 
$otherProjects );
+               $output->setProperty( 'wikibase_item', 
$itemId->getSerialization() );
+       }
+
 }
diff --git a/includes/specials/SpecialAboutTopic.php 
b/includes/specials/SpecialAboutTopic.php
index bea94fc..e0d8176 100644
--- a/includes/specials/SpecialAboutTopic.php
+++ b/includes/specials/SpecialAboutTopic.php
@@ -30,7 +30,8 @@
                                
$wikibaseClient->getStore()->getSiteLinkLookup(),
                                $wikibaseClient->getSiteStore(),
                                $wikibaseClient->getLangLinkSiteGroup(),
-                               new TitleFactory()
+                               new TitleFactory(),
+                               
$wikibaseClient->getOtherProjectsSidebarGeneratorFactory()
                        ),
                        $wikibaseClient->getEntityIdParser(),
                        $wikibaseClient->getStore()->getSiteLinkLookup(),
diff --git a/tests/phpunit/includes/AboutTopicRendererTest.php 
b/tests/phpunit/includes/AboutTopicRendererTest.php
index 34f6d26..4f3f004 100644
--- a/tests/phpunit/includes/AboutTopicRendererTest.php
+++ b/tests/phpunit/includes/AboutTopicRendererTest.php
@@ -13,6 +13,8 @@
 use User;
 use OutputPage;
 use Wikibase\Client\Store\TitleFactory;
+use Wikibase\Client\Hooks\OtherProjectsSidebarGenerator;
+use Wikibase\Client\Hooks\OtherProjectsSidebarGeneratorFactory;
 use Wikibase\DataModel\Entity\ItemId;
 use Wikibase\DataModel\SiteLink;
 use Wikibase\DataModel\Services\Lookup\LabelDescriptionLookup;
@@ -40,12 +42,26 @@
                $title = SpecialPage::getTitleFor( 'AboutTopic' );
                $context->getOutput()->setTitle( $title );
 
+               $otherProjectsSidebarGenerator = $this->getMockBuilder( 
OtherProjectsSidebarGenerator::class )
+                       ->disableOriginalConstructor()
+                       ->getMock();
+
+               $otherProjectsSidebarGeneratorFactory = $this->getMockBuilder(
+                       OtherProjectsSidebarGeneratorFactory::class
+               )->disableOriginalConstructor()
+               ->getMock();
+
+               $otherProjectsSidebarGeneratorFactory->expects( $this->any() )
+                       ->method( 'getOtherProjectsSidebarGenerator' )
+                       ->will( $this->returnValue( 
$otherProjectsSidebarGenerator ) );
+
                $instance = new AboutTopicRenderer(
                        $this->getTermLookupFactory(),
                        $this->getSiteLinkLookup(),
                        $this->getSiteLookup(),
                        'wikipedia',
-                       new TitleFactory()
+                       new TitleFactory(),
+                       $otherProjectsSidebarGeneratorFactory
                );
 
                $instance->showPlaceholder(

-- 
To view, visit https://gerrit.wikimedia.org/r/302728
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I4c5cb093ca24c4a2755d8745edc92830778c5d25
Gerrit-PatchSet: 16
Gerrit-Project: mediawiki/extensions/ArticlePlaceholder
Gerrit-Branch: master
Gerrit-Owner: Lucie Kaffee <[email protected]>
Gerrit-Reviewer: Aude <[email protected]>
Gerrit-Reviewer: Daniel Kinzler <[email protected]>
Gerrit-Reviewer: Hoo man <[email protected]>
Gerrit-Reviewer: Lucie Kaffee <[email protected]>
Gerrit-Reviewer: Thiemo Mättig (WMDE) <[email protected]>
Gerrit-Reviewer: Tpt <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to