https://www.mediawiki.org/wiki/Special:Code/MediaWiki/113460

Revision: 113460
Author:   maxsem
Date:     2012-03-09 09:10:35 +0000 (Fri, 09 Mar 2012)
Log Message:
-----------
Killed with fire <div id="content"> where possible

Modified Paths:
--------------
    trunk/extensions/MobileFrontend/MobileFormatter.php
    trunk/extensions/MobileFrontend/api/ApiMobileView.php
    trunk/extensions/MobileFrontend/api/ApiParseExtender.php
    trunk/extensions/MobileFrontend/api/ApiQueryExcerpts.php
    trunk/extensions/MobileFrontend/tests/MobileFormatterTest.php

Modified: trunk/extensions/MobileFrontend/MobileFormatter.php
===================================================================
--- trunk/extensions/MobileFrontend/MobileFormatter.php 2012-03-09 08:34:01 UTC 
(rev 113459)
+++ trunk/extensions/MobileFrontend/MobileFormatter.php 2012-03-09 09:10:35 UTC 
(rev 113460)
@@ -103,13 +103,9 @@
        /**
         * Turns a chunk of HTML into a proper document
         * @param string $html
-        * @param bool $contentDiv
         * @return string
         */
-       public static function wrapHTML( $html, $contentDiv = true ) {
-               if ( $contentDiv ) {
-                       $html = '<div id="content">' . $html . '</div>';
-               }
+       public static function wrapHTML( $html ) {
                return '<!doctype html><html><head></head><body>' . $html . 
'</body></html>';
        }
 
@@ -308,6 +304,9 @@
                        $elements = implode( '|', $this->elementsToFlatten );
                        $html = preg_replace( "#</?($elements)[^>]*>#is", '', 
$html );
                }
+               if ( !$element ) {
+                       $html = preg_replace( 
'/<!--.*?-->|^.*?<body>|<\/body>.*$/s', '', $html );
+               }
                
                wfProfileOut( __METHOD__ );
                return $html;

Modified: trunk/extensions/MobileFrontend/api/ApiMobileView.php
===================================================================
--- trunk/extensions/MobileFrontend/api/ApiMobileView.php       2012-03-09 
08:34:01 UTC (rev 113459)
+++ trunk/extensions/MobileFrontend/api/ApiMobileView.php       2012-03-09 
09:10:35 UTC (rev 113460)
@@ -93,7 +93,7 @@
                );
                $mf->removeImages( $noImages );
                $mf->filterContent();
-               $html = $mf->getText( 'content' );
+               $html = $mf->getText();
                $data = array();
                $data['sections'] = $parserOutput->getSections();
                $chunks = preg_split( '/<h(?=[1-6]\b)/i', $html );

Modified: trunk/extensions/MobileFrontend/api/ApiParseExtender.php
===================================================================
--- trunk/extensions/MobileFrontend/api/ApiParseExtender.php    2012-03-09 
08:34:01 UTC (rev 113459)
+++ trunk/extensions/MobileFrontend/api/ApiParseExtender.php    2012-03-09 
09:10:35 UTC (rev 113460)
@@ -81,7 +81,7 @@
                                $mf->removeImages( $params['noimages'] );
                                $mf->setIsMainPage( $params['mainpage'] );
                                $mf->filterContent();
-                               $data['parse']['text'] = $mf->getText( 
'content' );
+                               $data['parse']['text'] = $mf->getText();
 
                                $result->addValue( null, 
$module->getModuleName(), $data['parse'] );
                        }

Modified: trunk/extensions/MobileFrontend/api/ApiQueryExcerpts.php
===================================================================
--- trunk/extensions/MobileFrontend/api/ApiQueryExcerpts.php    2012-03-09 
08:34:01 UTC (rev 113459)
+++ trunk/extensions/MobileFrontend/api/ApiQueryExcerpts.php    2012-03-09 
09:10:35 UTC (rev 113460)
@@ -120,7 +120,6 @@
                }
                $mf->filterContent();
                $text = $mf->getText();
-               $text = preg_replace( '/<!--.*?-->|^.*?<body>|<\/body>.*$/s', 
'', $text );
                if ( $plainText ) {
                        $text = html_entity_decode( $text );
                }

Modified: trunk/extensions/MobileFrontend/tests/MobileFormatterTest.php
===================================================================
--- trunk/extensions/MobileFrontend/tests/MobileFormatterTest.php       
2012-03-09 08:34:01 UTC (rev 113459)
+++ trunk/extensions/MobileFrontend/tests/MobileFormatterTest.php       
2012-03-09 09:10:35 UTC (rev 113460)
@@ -15,8 +15,7 @@
                        $callback( $mf );
                }
                $mf->filterContent();
-               $html = $mf->getText( 'content' );
-               $html = preg_replace( '/^<div.*?>|<\\/div>$/', '', $html ); // 
Forgive me father for I have sinned
+               $html = $mf->getText();
                $this->assertEquals( str_replace( "\n", '', $expected ), 
str_replace( "\n", '', $html ) );
        }
 


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

Reply via email to