Index: trunk/extensions/MobileFrontend/MobileFrontend.php |
— | — | @@ -65,7 +65,7 @@ |
66 | 66 | ); |
67 | 67 | |
68 | 68 | class ExtMobileFrontend { |
69 | | - const VERSION = '0.5.55'; |
| 69 | + const VERSION = '0.5.56'; |
70 | 70 | |
71 | 71 | /** |
72 | 72 | * @var DOMDocument |
— | — | @@ -718,6 +718,18 @@ |
719 | 719 | return $itemToRemoveRecords; |
720 | 720 | } |
721 | 721 | |
| 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 | + |
722 | 734 | public function DOMParseMainPage( $html ) { |
723 | 735 | wfProfileIn( __METHOD__ ); |
724 | 736 | $html = mb_convert_encoding($html, 'HTML-ENTITIES', "UTF-8"); |
— | — | @@ -733,6 +745,29 @@ |
734 | 746 | |
735 | 747 | $featuredArticle = $this->mainPage->getElementById( 'mp-tfa' ); |
736 | 748 | $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 | + } |
737 | 772 | |
738 | 773 | $content = $this->mainPage->createElement( 'div' ); |
739 | 774 | $content->setAttribute( 'id', 'main_box' ); |
— | — | @@ -754,7 +789,7 @@ |
755 | 790 | return $contentHtml; |
756 | 791 | } |
757 | 792 | |
758 | | - public function DOMParse( $html ) { |
| 793 | + public function DOMParse( $html ) { |
759 | 794 | global $wgSitename; |
760 | 795 | wfProfileIn( __METHOD__ ); |
761 | 796 | $html = mb_convert_encoding($html, 'HTML-ENTITIES', "UTF-8"); |
— | — | @@ -860,7 +895,7 @@ |
861 | 896 | |
862 | 897 | if ( strlen( $contentHtml ) > 4000 && $this->contentFormat == 'XHTML' |
863 | 898 | && self::$device['supports_javascript'] === true |
864 | | - && empty( self::$search ) ) { |
| 899 | + && empty( self::$search ) && !self::$isMainPage ) { |
865 | 900 | $contentHtml = $this->headingTransform( $contentHtml ); |
866 | 901 | } elseif ( $this->contentFormat == 'WML' ) { |
867 | 902 | header( 'Content-Type: text/vnd.wap.wml' ); |