Kaldari has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/189154

Change subject: Making MobileFormatter preserve the CentralAuth 1x1 images
......................................................................

Making MobileFormatter preserve the CentralAuth 1x1 images

Related change: I7e4120e5
Bug: T87290

Change-Id: I3c2f4137a280010d1760b2fc97a3d4953a196813
---
M includes/MobileFormatter.php
1 file changed, 15 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MobileFrontend 
refs/changes/54/189154/1

diff --git a/includes/MobileFormatter.php b/includes/MobileFormatter.php
index e2e23c9..b99ed72 100644
--- a/includes/MobileFormatter.php
+++ b/includes/MobileFormatter.php
@@ -169,15 +169,19 @@
        protected function parseMainPage( DOMDocument $mainPage ) {
                $featuredArticle = $mainPage->getElementById( 'mp-tfa' );
                $newsItems = $mainPage->getElementById( 'mp-itn' );
+               $centralAuthImages = $mainPage->getElementById( 
'central-auth-images' );
 
+               // Collect all the Main Page DOM elements that have an id 
starting with 'mf-'
                $xpath = new DOMXpath( $mainPage );
                $elements = $xpath->query( '//*[starts-with(@id, "mf-")]' );
 
-               $commonAttributes = array( 'mp-tfa', 'mp-itn' );
+               $commonAttributes = array( 'mp-tfa', 'mp-itn', 
'central-auth-images' );
 
+               // Start building the new Main Page content in the $content var
                $content = $mainPage->createElement( 'div' );
                $content->setAttribute( 'id', 'mainpage' );
 
+               // If there is a featured article section, add it to the new 
Main Page content
                if ( $featuredArticle ) {
                        $h2FeaturedArticle = $mainPage->createElement(
                                'h2',
@@ -187,17 +191,21 @@
                        $content->appendChild( $featuredArticle );
                }
 
+               // If there is a news section, add it to the new Main Page 
content
                if ( $newsItems ) {
                        $h2NewsItems = $mainPage->createElement( 'h2', 
$this->msg( 'mobile-frontend-news-items' ) );
                        $content->appendChild( $h2NewsItems );
                        $content->appendChild( $newsItems );
                }
 
+               // Go through all the collected Main Page DOM elements and 
format them for mobile
                /** @var $element DOMElement */
                foreach ( $elements as $element ) {
                        if ( $element->hasAttribute( 'id' ) ) {
                                $id = $element->getAttribute( 'id' );
+                               // Filter out sections processed explicitly
                                if ( !in_array( $id, $commonAttributes ) ) {
+                                       // Convert title attributes into h2 
headers
                                        $sectionTitle = $element->hasAttribute( 
'title' ) ? $element->getAttribute( 'title' ) : '';
                                        if ( $sectionTitle !== '' ) {
                                                $element->removeAttribute( 
'title' );
@@ -212,6 +220,12 @@
                                }
                        }
                }
+
+               // If there are CentralAuth 1x1 images, preserve them unmodified
+               if ( $centralAuthImages ) {
+                       $content->appendChild( $centralAuthImages );
+               }
+
                if ( $content->childNodes->length == 0 ) {
                        $content = null;
                }

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I3c2f4137a280010d1760b2fc97a3d4953a196813
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: Kaldari <[email protected]>

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

Reply via email to