From 10f96eaa96713b8a85284956c51455afbb543ce0 Mon Sep 17 00:00:00 2001 From: Warkot Date: Tue, 31 May 2016 00:20:39 +0200 Subject: [PATCH] XW-1478 | extendImageData has to be run even for the first PI --- .../PortableInfoboxRenderService.class.php | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/services/PortableInfoboxRenderService.class.php b/services/PortableInfoboxRenderService.class.php index aa92cde..9352e83 100644 --- a/services/PortableInfoboxRenderService.class.php +++ b/services/PortableInfoboxRenderService.class.php @@ -54,7 +54,6 @@ class PortableInfoboxRenderService extends WikiaService { wfProfileIn( __METHOD__ ); $helper = new PortableInfoboxRenderServiceHelper(); - $dataBag = \Wikia\PortableInfobox\Helpers\PortableInfoboxDataBag::getInstance(); $infoboxHtmlContent = ''; $heroData = [ ]; @@ -88,8 +87,7 @@ class PortableInfoboxRenderService extends WikiaService { } } - // In Mercury SPA content of the first infobox's hero module is already rendered in the article header. - if ( !empty( $heroData ) && !( $helper->isMercury() && empty( $dataBag->isFirstInfoboxAlredyRendered() ) ) ) { + if ( !empty( $heroData ) ) { $infoboxHtmlContent = $this->renderInfoboxHero( $heroData ) . $infoboxHtmlContent; } @@ -104,7 +102,7 @@ class PortableInfoboxRenderService extends WikiaService { $output = ''; } - $dataBag->setFirstInfoboxAlredyRendered( true ); + \Wikia\PortableInfobox\Helpers\PortableInfoboxDataBag::getInstance()->setFirstInfoboxAlredyRendered( true ); wfProfileOut( __METHOD__ ); @@ -162,6 +160,10 @@ class PortableInfoboxRenderService extends WikiaService { private function renderInfoboxHero( $data ) { $helper = new PortableInfoboxRenderServiceHelper(); + // In Mercury SPA content of the first infobox's hero module has been moved to the article header. + $firstInfoboxAlredyRendered = \Wikia\PortableInfobox\Helpers\PortableInfoboxDataBag::getInstance() + ->isFirstInfoboxAlredyRendered(); + if ( array_key_exists( 'image', $data ) ) { $image = $data[ 'image' ][ 0 ]; $image[ 'context' ] = self::MEDIA_CONTEXT_INFOBOX_HERO_IMAGE; @@ -169,15 +171,15 @@ class PortableInfoboxRenderService extends WikiaService { $data[ 'image' ] = $image; if ( !$helper->isMercury() ) { - $markup = $this->renderItem( 'hero-mobile-wikiamobile', $data ); - } else { - $markup = $this->renderItem( 'hero-mobile', $data ); + return $this->renderItem( 'hero-mobile-wikiamobile', $data ); + } elseif ( $firstInfoboxAlredyRendered ) { + return $this->renderItem( 'hero-mobile', $data ); } - } else { - $markup = $this->renderItem( 'title', $data[ 'title' ] ); + } elseif ( !$helper->isMercury() || $firstInfoboxAlredyRendered ) { + return $this->renderItem( 'title', $data[ 'title' ] ); } - return $markup; + return ''; } /**