r96365 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r96364‎ | r96365 | r96366 >
Date:20:07, 6 September 2011
Author:preilly
Status:ok
Tags:
Comment:
fix for bug 30785 - missing main page on mobile frontend
Modified paths:
  • /trunk/extensions/MobileFrontend/MobileFrontend.php (modified) (history)

Diff [purge]

Index: trunk/extensions/MobileFrontend/MobileFrontend.php
@@ -65,7 +65,7 @@
6666 );
6767
6868 class ExtMobileFrontend {
69 - const VERSION = '0.5.55';
 69+ const VERSION = '0.5.56';
7070
7171 /**
7272 * @var DOMDocument
@@ -718,6 +718,18 @@
719719 return $itemToRemoveRecords;
720720 }
721721
 722+ private function getClassElement($DOMElement, $Node, $className) {
 723+ $children = $DOMElement->childNodes;
 724+ foreach ( $children as $child ) {
 725+ if ( $child->hasAttributes() &&
 726+ $child->getAttribute( 'class' ) == $className ) {
 727+ $$Node = $child;
 728+ return $$Node;
 729+ }
 730+ }
 731+ return $DOMElement;
 732+ }
 733+
722734 public function DOMParseMainPage( $html ) {
723735 wfProfileIn( __METHOD__ );
724736 $html = mb_convert_encoding($html, 'HTML-ENTITIES', "UTF-8");
@@ -733,6 +745,29 @@
734746
735747 $featuredArticle = $this->mainPage->getElementById( 'mp-tfa' );
736748 $newsItems = $this->mainPage->getElementById( 'mp-itn' );
 749+
 750+ switch ( self::$code ) {
 751+ case 'de':
 752+ $featuredArticle = $this->mainPage->getElementById( 'hauptseite-artikel' );
 753+ $featuredArticle = $this->getClassElement($featuredArticle, 'featuredArticle', 'inhalt' );
 754+
 755+ $newsItems = $this->mainPage->getElementById( 'hauptseite-nachrichten' );
 756+ $newsItems = $this->getClassElement($newsItems, 'newsItems', 'inhalt' );
 757+ break;
 758+ case 'fr':
 759+ $featuredArticle = $this->mainPage->getElementById( 'accueil-lumieresur' );
 760+ $newsItems = $this->mainPage->getElementById( 'accueil-actualite' );
 761+ break;
 762+ case 'ku':
 763+ $newsItems = $this->mainPage->getElementById( 'hauptseite-wikipedia' );
 764+ $newsItems = $this->getClassElement($newsItems, 'newsItems', 'inhalt' );
 765+ break;
 766+ case 'bh':
 767+ $featuredArticle = $this->mainPage->getElementById( 'mp-featured_article' );
 768+ break;
 769+ case 'ja':
 770+ break;
 771+ }
737772
738773 $content = $this->mainPage->createElement( 'div' );
739774 $content->setAttribute( 'id', 'main_box' );
@@ -754,7 +789,7 @@
755790 return $contentHtml;
756791 }
757792
758 - public function DOMParse( $html ) {
 793+ public function DOMParse( $html ) {
759794 global $wgSitename;
760795 wfProfileIn( __METHOD__ );
761796 $html = mb_convert_encoding($html, 'HTML-ENTITIES', "UTF-8");
@@ -860,7 +895,7 @@
861896
862897 if ( strlen( $contentHtml ) > 4000 && $this->contentFormat == 'XHTML'
863898 && self::$device['supports_javascript'] === true
864 - && empty( self::$search ) ) {
 899+ && empty( self::$search ) && !self::$isMainPage ) {
865900 $contentHtml = $this->headingTransform( $contentHtml );
866901 } elseif ( $this->contentFormat == 'WML' ) {
867902 header( 'Content-Type: text/vnd.wap.wml' );

Follow-up revisions

RevisionCommit summaryAuthorDate
r96520newer fix for bug 30785 - missing main page on mobile frontendpreilly23:34, 7 September 2011

Status & tagging log