r98449 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r98448‎ | r98449 | r98450 >
Date:21:02, 29 September 2011
Author:preilly
Status:ok
Tags:
Comment:
Modified paths:
  • /branches/wmf/1.18wmf1/extensions/MobileFrontend/MobileFrontend.php (modified) (history)

Diff [purge]

Index: branches/wmf/1.18wmf1/extensions/MobileFrontend/MobileFrontend.php
@@ -18,11 +18,11 @@
1919 // Define the extension; allows us make sure the extension is used correctly
2020 define( 'MOBILEFRONTEND', 'MobileFrontend' );
2121 // WURFL installation dir
22 -define( 'WURFL_DIR', dirname(__FILE__) . DIRECTORY_SEPARATOR . 'library' .
 22+define( 'WURFL_DIR', dirname( __FILE__ ) . DIRECTORY_SEPARATOR . 'library' .
2323 DIRECTORY_SEPARATOR . 'WURFL' . DIRECTORY_SEPARATOR );
2424 // WURFL configuration files directory
25 -define( 'RESOURCES_DIR', dirname(__FILE__) . DIRECTORY_SEPARATOR . 'library' .
26 - DIRECTORY_SEPARATOR. 'resources' . DIRECTORY_SEPARATOR );
 25+define( 'RESOURCES_DIR', dirname( __FILE__ ) . DIRECTORY_SEPARATOR . 'library' .
 26+ DIRECTORY_SEPARATOR . 'resources' . DIRECTORY_SEPARATOR );
2727
2828 require_once( WURFL_DIR . 'Application.php' );
2929
@@ -36,9 +36,9 @@
3737 'url' => 'http://www.mediawiki.org/wiki/Extension:MobileFrontend',
3838 );
3939
40 -$cwd = dirname(__FILE__) . DIRECTORY_SEPARATOR;
 40+$cwd = dirname( __FILE__ ) . DIRECTORY_SEPARATOR;
4141 $wgExtensionMessagesFiles['MobileFrontend'] = $cwd . 'MobileFrontend.i18n.php';
42 -//autoload extension classes
 42+// autoload extension classes
4343 $wgAutoloadClasses['DeviceDetection'] = $cwd . 'DeviceDetection.php';
4444 $wgAutoloadClasses['CssDetection'] = $cwd . 'CssDetection.php';
4545
@@ -84,7 +84,7 @@
8585 }
8686
8787 class ExtMobileFrontend {
88 - const VERSION = '0.5.70';
 88+ const VERSION = '0.5.73';
8989
9090 /**
9191 * @var DOMDocument
@@ -125,8 +125,8 @@
126126 public static $displayNoticeId;
127127 public static $leaveFeedbackURL;
128128 public static $mobileRedirectFormAction;
129 -
130 - public static $messageKeys = array(
 129+
 130+ public static $messageKeys = array(
131131 'mobile-frontend-show-button',
132132 'mobile-frontend-hide-button',
133133 'mobile-frontend-back-to-top-of-section',
@@ -198,7 +198,7 @@
199199 '#ogg_player_1',
200200 '.nomobile',
201201 );
202 -
 202+
203203 public function testCanonicalRedirect( $request, $title, $output ) {
204204 $xDevice = isset( $_SERVER['HTTP_X_DEVICE'] ) ? $_SERVER['HTTP_X_DEVICE'] : '';
205205 if ( empty( $xDevice ) ) {
@@ -214,39 +214,49 @@
215215
216216 $title = $obj->getTitle();
217217 $isSpecial = $title->isSpecialPage();
218 -
 218+
219219 if ( ! $isSpecial ) {
220220 $footerlinks = $tpl->data['footerlinks'];
221221 $mobileViewUrl = $wgRequest->escapeAppendQuery( 'useformat=mobile' );
222222
223 - $tpl->set('mobileview', "<a href='{$mobileViewUrl}'>" . wfMsg( 'mobile-frontend-view' ) . "</a>");
 223+ $tpl->set( 'mobileview', "<a href='{$mobileViewUrl}'>" . wfMsg( 'mobile-frontend-view' ) . "</a>" );
224224 $footerlinks['places'][] = 'mobileview';
225 - $tpl->set('footerlinks', $footerlinks);
 225+ $tpl->set( 'footerlinks', $footerlinks );
226226 }
227227 wfProfileOut( __METHOD__ );
228228 return true;
229229 }
 230+
 231+ private function removeQueryStringParameter( $url, $field ) {
 232+ $url = preg_replace( '/(.*)(\?|&)' . $field . '=[^&]+?(&)(.*)/i', '$1$2$4', $url . '&' );
 233+ $url = substr( $url, 0, -1 );
 234+ return $url;
 235+ }
230236
231237 public function getMsg() {
232238 global $wgUser, $wgContLang, $wgRequest, $wgServer, $wgMobileRedirectFormAction, $wgMobileDomain;
233239 wfProfileIn( __METHOD__ );
234 -
 240+
235241 self::$disableImagesURL = $wgRequest->escapeAppendQuery( 'disableImages=1' );
236242 self::$enableImagesURL = $wgRequest->escapeAppendQuery( 'enableImages=1' );
237243 self::$disableMobileSiteURL = $wgRequest->escapeAppendQuery( 'mobileaction=disable_mobile_site' );
238 - self::$viewNormalSiteURL = $wgRequest->escapeAppendQuery( 'mobileaction=view_normal_site' );
239 - self::$currentURL = $wgRequest->getFullRequestURL();
 244+ $parsedUrl = wfParseUrl( $wgRequest->getFullRequestURL() );
 245+ $parsedUrl['host'] = str_replace( $wgMobileDomain, '.', $parsedUrl['host'] );
 246+ $parsedUrl['query'] = $this->removeQueryStringParameter( $parsedUrl['query'], 'useformat' );
 247+ $fragmentDelimiter = ( !empty( $parsedUrl['fragment'] ) ) ? '#' : '';
 248+ self::$viewNormalSiteURL = $parsedUrl['scheme'] . '://' . $parsedUrl['host'] . $parsedUrl['path'] . '?' . $parsedUrl['query'] . $fragmentDelimiter . $parsedUrl['fragment'];
 249+ self::$currentURL = $wgRequest->getFullRequestURL();
240250 self::$leaveFeedbackURL = $wgRequest->escapeAppendQuery( 'mobileaction=leave_feedback' );
241 -
 251+
242252 $skin = $wgUser->getSkin();
243253 $copyright = $skin->getCopyright();
244254 // Need to stash the results of the "wfMsg" call before the Output Buffering handler
245255 // because at this point the database connection is shut down, etc.
246 -
 256+
247257 self::$messages['mobile-frontend-copyright'] = $copyright;
248 -
 258+
249259 foreach ( self::$messageKeys as $messageKey ) {
250 -
 260+
251261 if ( $messageKey == 'mobile-frontend-leave-feedback-notice' ) {
252262 $linkText = wfMsg( 'mobile-frontend-leave-feedback-link-text' );
253263 $linkTarget = wfMsgNoTrans( 'mobile-frontend-feedback-page' );
@@ -260,7 +270,7 @@
261271
262272 self::$dir = $wgContLang->getDir();
263273 self::$code = $wgContLang->getCode();
264 -
 274+
265275 $nonMobileServerBaseURL = str_replace( $wgMobileDomain, '.', $wgServer );
266276 self::$mobileRedirectFormAction = ( $wgMobileRedirectFormAction !== false ) ? $wgMobileRedirectFormAction : "{$nonMobileServerBaseURL}/w/mobileRedirect.php";
267277
@@ -279,15 +289,15 @@
280290 wfProfileIn( __METHOD__ );
281291 // The title
282292 self::$title = $out->getTitle();
283 -
 293+
284294 if ( Title::newMainPage()->equals( self::$title ) ) {
285295 self::$isMainPage = true;
286296 }
287 -
 297+
288298 self::$htmlTitle = $out->getHTMLTitle();
289299
290300 $userAgent = $_SERVER['HTTP_USER_AGENT'];
291 - $uAmd5 = md5($userAgent);
 301+ $uAmd5 = md5( $userAgent );
292302
293303 $key = wfMemcKey( 'mobile', 'ua', $uAmd5 );
294304
@@ -308,8 +318,8 @@
309319 $props = "generic";
310320 }
311321 }
312 - } catch (Exception $e) {
313 - //echo $e->getMessage();
 322+ } catch ( Exception $e ) {
 323+ // echo $e->getMessage();
314324 }
315325
316326 // Note: The WebRequest Class calls are made in this block because
@@ -331,7 +341,7 @@
332342 $location = $this->getRelativeURL( $location );
333343 $wgRequest->response()->header( 'Location: ' . $location . '&mfi=0' );
334344 }
335 -
 345+
336346 if ( self::$disableImages == 0 ) {
337347 $disableImages = $wgRequest->getCookie( 'disableImages' );
338348 if ( $disableImages ) {
@@ -356,18 +366,18 @@
357367 self::$search = $wgRequest->getText( 'search' );
358368 self::$callback = $wgRequest->getText( 'callback' );
359369 self::$searchField = $wgRequest->getText( 'search', '' );
360 -
 370+
361371 $xDevice = isset( $_SERVER['HTTP_X_DEVICE'] ) ? $_SERVER['HTTP_X_DEVICE'] : '';
362372
363373 $acceptHeader = $_SERVER["HTTP_ACCEPT"];
364374 $device = new DeviceDetection();
365 -
 375+
366376 if ( !empty( $xDevice ) ) {
367377 $formatName = $xDevice;
368378 } else {
369379 $formatName = $device->formatName( $userAgent, $acceptHeader );
370380 }
371 -
 381+
372382 self::$device = $device->format( $formatName );
373383
374384 if ( self::$device['view_format'] === 'wml' ) {
@@ -379,7 +389,7 @@
380390 if ( self::$useFormat === 'mobile-wap' ) {
381391 $this->contentFormat = 'WML';
382392 }
383 -
 393+
384394 if ( $mobileAction == 'leave_feedback' ) {
385395 echo $this->renderLeaveFeedbackXHTML();
386396 wfProfileOut( __METHOD__ );
@@ -387,15 +397,15 @@
388398 }
389399
390400 if ( $mobileAction == 'leave_feedback_post' ) {
391 -
 401+
392402 $this->getMsg();
393 -
 403+
394404 $subject = $wgRequest->getText( 'subject', '' );
395405 $message = $wgRequest->getText( 'message', '' );
396406 $token = $wgRequest->getText( 'edittoken', '' );
397 -
 407+
398408 $title = Title::newFromText( self::$messages['mobile-frontend-feedback-page'] );
399 -
 409+
400410 if ( $title->userCan( 'edit' ) &&
401411 !$wgUser->isBlockedFrom( $title ) &&
402412 $wgUser->matchEditToken( $token ) ) {
@@ -404,7 +414,7 @@
405415 $rawtext .= "\n== {$subject} == \n {$message} ~~~~ \n <small>User agent: {$userAgent}</small> ";
406416 $article->doEdit( $rawtext, '' );
407417 }
408 -
 418+
409419 $location = str_replace( '&mobileaction=leave_feedback_post', '', $wgRequest->getFullRequestURL() . '&noticeid=1' );
410420 $location = $this->getRelativeURL( $location );
411421 $wgRequest->response()->header( 'Location: ' . $location );
@@ -449,8 +459,8 @@
450460
451461 // WURFL documentation: http://wurfl.sourceforge.net/help_doc.php
452462 // Determine the kind of markup
453 - if( is_array( $props ) && $props['preferred_markup'] ) {
454 - //wfDebug( __METHOD__ . ": preferred markup for this device: " . $props['preferred_markup'] );
 463+ if ( is_array( $props ) && $props['preferred_markup'] ) {
 464+ // wfDebug( __METHOD__ . ": preferred markup for this device: " . $props['preferred_markup'] );
455465 // xhtml/html: html_web_3_2, html_web_4_0
456466 // xthml basic/xhtmlmp (wap 2.0): html_wi_w3_xhtmlbasic html_wi_oma_xhtmlmp_1_0
457467 // chtml (imode): html_wi_imode_*
@@ -470,10 +480,10 @@
471481
472482 // Determine
473483
474 - if (self::$useFormat === 'mobile' ||
 484+ if ( self::$useFormat === 'mobile' ||
475485 self::$useFormat === 'mobile-wap' ||
476486 !empty( $xDevice ) ) {
477 - if ( $action !== 'edit' &&
 487+ if ( $action !== 'edit' &&
478488 $mobileAction !== 'view_normal_site' ) {
479489 $this->getMsg();
480490 $this->disableCaching();
@@ -498,11 +508,11 @@
499509
500510 private function getBaseDomain() {
501511 wfProfileIn( __METHOD__ );
502 - //Validates value as IP address
503 - if( !IP::isValid( $_SERVER['HTTP_HOST'] ) ) {
 512+ // Validates value as IP address
 513+ if ( !IP::isValid( $_SERVER['HTTP_HOST'] ) ) {
504514 $domainParts = explode( '.', $_SERVER['HTTP_HOST'] );
505515 $domainParts = array_reverse( $domainParts );
506 - //Although some browsers will accept cookies without the initial ., » RFC 2109 requires it to be included.
 516+ // Although some browsers will accept cookies without the initial ., » RFC 2109 requires it to be included.
507517 wfProfileOut( __METHOD__ );
508518 return '.' . $domainParts[1] . '.' . $domainParts[0];
509519 } else {
@@ -514,8 +524,8 @@
515525 private function getRelativeURL( $url ) {
516526 wfProfileIn( __METHOD__ );
517527 $parsedUrl = parse_url( $url );
518 - //Validates value as IP address
519 - if( !IP::isValid( $parsedUrl['host'] ) ) {
 528+ // Validates value as IP address
 529+ if ( !IP::isValid( $parsedUrl['host'] ) ) {
520530 wfProfileOut( __METHOD__ );
521531 $baseUrl = $parsedUrl['scheme'] . '://' . $parsedUrl['host'];
522532 $baseUrl = str_replace( $baseUrl, '', $url );
@@ -537,7 +547,7 @@
538548 }
539549 wfProfileOut( __METHOD__ );
540550 }
541 -
 551+
542552 private function sendXDeviceVaryHeader() {
543553 global $wgOut, $wgRequest;
544554 wfProfileIn( __METHOD__ );
@@ -547,14 +557,14 @@
548558 }
549559 wfProfileOut( __METHOD__ );
550560 }
551 -
 561+
552562 private function renderLeaveFeedbackXHTML() {
553563 global $wgRequest, $wgUser;
554564 wfProfileIn( __METHOD__ );
555565 if ( $this->contentFormat == 'XHTML' ) {
556566 $this->getMsg();
557567 $editToken = $wgUser->editToken();
558 -
 568+
559569 $htmlTitle = self::$messages['mobile-frontend-leave-feedback'];
560570 $title = self::$messages['mobile-frontend-leave-feedback-title'];
561571 $notice = self::$messages['mobile-frontend-leave-feedback-notice'];
@@ -562,7 +572,7 @@
563573 $message = self::$messages['mobile-frontend-leave-feedback-message'];
564574 $cancel = self::$messages['mobile-frontend-leave-feedback-cancel'];
565575 $submit = self::$messages['mobile-frontend-leave-feedback-submit'];
566 -
 576+
567577 $feedbackPostURL = str_replace( '&mobileaction=leave_feedback', '', $wgRequest->getFullRequestURL() ) . '&mobileaction=leave_feedback_post';
568578 require( 'views/layout/_search_webkit.html.php' );
569579 require( 'views/layout/_footmenu_default.html.php' );
@@ -656,7 +666,7 @@
657667 private function headingTransformCallbackXHTML( $matches ) {
658668 wfProfileIn( __METHOD__ );
659669 if ( isset( $matches[0] ) ) {
660 - preg_match('/id="([^"]*)"/', $matches[0], $headlineMatches);
 670+ preg_match( '/id="([^"]*)"/', $matches[0], $headlineMatches );
661671 }
662672
663673 $headlineId = ( isset( $headlineMatches[1] ) ) ? $headlineMatches[1] : '';
@@ -667,35 +677,35 @@
668678 $backToTop = self::$messages['mobile-frontend-back-to-top-of-section'];
669679 ++$headings;
670680 // Back to top link
671 - $base = Html::openElement( 'div',
672 - array( 'id' => 'anchor_' . intval( $headings - 1 ),
673 - 'class' => 'section_anchors', )
 681+ $base = Html::openElement( 'div',
 682+ array( 'id' => 'anchor_' . intval( $headings - 1 ),
 683+ 'class' => 'section_anchors', )
674684 ) .
675685 Html::rawElement( 'a',
676 - array( 'href' => '#section_' . intval( $headings - 1 ),
677 - 'class' => 'back_to_top' ),
678 - '&#8593;' . $backToTop ) .
 686+ array( 'href' => '#section_' . intval( $headings - 1 ),
 687+ 'class' => 'back_to_top' ),
 688+ '&#8593;' . $backToTop ) .
679689 Html::closeElement( 'div' );
680690 // generate the HTML we are going to inject
681691 $buttons = Html::element( 'button',
682 - array('class' => 'section_heading show',
683 - 'section_id' => $headings ),
 692+ array( 'class' => 'section_heading show',
 693+ 'section_id' => $headings ),
684694 $show ) .
685 - Html::element( 'button',
686 - array('class' => 'section_heading hide',
 695+ Html::element( 'button',
 696+ array( 'class' => 'section_heading hide',
687697 'section_id' => $headings ),
688 - $hide );
 698+ $hide );
689699 $base .= Html::openElement( 'h2',
690 - array('class' => 'section_heading',
691 - 'id' => 'section_' . $headings) ) .
 700+ array( 'class' => 'section_heading',
 701+ 'id' => 'section_' . $headings ) ) .
692702 $buttons .
693703 Html::rawElement( 'span',
694 - array( 'id' => $headlineId),
 704+ array( 'id' => $headlineId ),
695705 $matches[2] ) .
696 - Html::closeElement( 'h2' ) .
697 - Html::openElement( 'div',
698 - array('class' => 'content_block',
699 - 'id' => 'content_' . $headings) );
 706+ Html::closeElement( 'h2' ) .
 707+ Html::openElement( 'div',
 708+ array( 'class' => 'content_block',
 709+ 'id' => 'content_' . $headings ) );
700710
701711 if ( $headings > 1 ) {
702712 // Close it up here
@@ -748,11 +758,11 @@
749759
750760 $card .= "<card id='s{$idx}' title='{$title}'><p>{$segments[$requestedSegment]}</p>";
751761 $idx = $requestedSegment + 1;
752 - $segmentsCount = count($segments);
 762+ $segmentsCount = count( $segments );
753763 $card .= "<p>" . $idx . "/" . $segmentsCount . "</p>";
754764
755765 $useFormatParam = ( isset( self::$useFormat ) ) ? '&' . 'useformat=' . self::$useFormat : '';
756 -
 766+
757767 // Title::getLocalUrl doesn't work at this point since PHP 5.1.x, all objects have their destructors called
758768 // before the output buffer callback function executes.
759769 // Thus, globalized objects will not be available as expected in the function.
@@ -760,13 +770,13 @@
761771 $mDefaultQuery = $_GET;
762772 unset( $mDefaultQuery['seg'] );
763773 unset( $mDefaultQuery['useformat'] );
764 -
 774+
765775 $qs = wfArrayToCGI( $mDefaultQuery );
766776 $delimiter = ( !empty( $qs ) ) ? '?' : '';
767777 $basePageParts = wfParseUrl( self::$currentURL );
768778 $basePage = $basePageParts['scheme'] . $basePageParts['delimiter'] . $basePageParts['host'] . $basePageParts['path'] . $delimiter . $qs;
769779 $appendDelimiter = ( $delimiter === '?' ) ? '&' : '?';
770 -
 780+
771781 if ( $idx < $segmentsCount ) {
772782 $card .= "<p><a href=\"{$basePage}{$appendDelimiter}seg={$idx}{$useFormatParam}\">" . self::$messages['mobile-frontend-wml-continue'] . "</a></p>";
773783 }
@@ -794,47 +804,47 @@
795805 CssDetection::detectIdCssOrTag( $itemToRemove, $type, $rawName );
796806 $itemToRemoveRecords[$type][] = $rawName;
797807 }
798 -
 808+
799809 wfProfileOut( __METHOD__ );
800810 return $itemToRemoveRecords;
801811 }
802 -
 812+
803813 public function DOMParseMainPage( $html ) {
804814 wfProfileIn( __METHOD__ );
805 - $html = mb_convert_encoding($html, 'HTML-ENTITIES', "UTF-8");
 815+ $html = mb_convert_encoding( $html, 'HTML-ENTITIES', "UTF-8" );
806816 libxml_use_internal_errors( true );
807817 $this->mainPage = new DOMDocument();
808 - //It seems that loadhtml() does not "attach" the html dtd that defines id as an id-attribute to the DOM.
 818+ // It seems that loadhtml() does not "attach" the html dtd that defines id as an id-attribute to the DOM.
809819 $this->mainPage->loadHTML( '<?xml encoding="UTF-8"><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
810820 <html><head><title></title></head><body>' . $html . '</body></html>' );
811821 libxml_use_internal_errors( false );
812822 $this->mainPage->preserveWhiteSpace = false;
813823 $this->mainPage->strictErrorChecking = false;
814824 $this->mainPage->encoding = 'UTF-8';
815 -
 825+
816826 $featuredArticle = $this->mainPage->getElementById( 'mp-tfa' );
817827 $newsItems = $this->mainPage->getElementById( 'mp-itn' );
818 -
 828+
819829 $xpath = new DOMXpath( $this->mainPage );
820830 $elements = $xpath->query( '//*[starts-with(@id, "mf-")]' );
821 -
822 - $commonAttributes = array('mp-tfa', 'mp-itn');
823831
 832+ $commonAttributes = array( 'mp-tfa', 'mp-itn' );
 833+
824834 $content = $this->mainPage->createElement( 'div' );
825835 $content->setAttribute( 'id', 'main_box' );
826 -
 836+
827837 if ( $featuredArticle ) {
828838 $h2FeaturedArticle = $this->mainPage->createElement( 'h2', self::$messages['mobile-frontend-featured-article'] );
829839 $content->appendChild( $h2FeaturedArticle );
830840 $content->appendChild( $featuredArticle );
831841 }
832 -
 842+
833843 if ( $newsItems ) {
834844 $h2NewsItems = $this->mainPage->createElement( 'h2', self::$messages['mobile-frontend-news-items'] );
835845 $content->appendChild( $h2NewsItems );
836846 $content->appendChild( $newsItems );
837847 }
838 -
 848+
839849 foreach ( $elements as $element ) {
840850 if ( $element->hasAttribute( 'id' ) ) {
841851 $id = $element->getAttribute( 'id' );
@@ -849,16 +859,16 @@
850860 }
851861 }
852862 }
853 -
 863+
854864 $contentHtml = $this->mainPage->saveXML( $content, LIBXML_NOEMPTYTAG );
855865 wfProfileOut( __METHOD__ );
856866 return $contentHtml;
857867 }
858868
859 - public function DOMParse( $html ) {
 869+ public function DOMParse( $html ) {
860870 global $wgSitename;
861871 wfProfileIn( __METHOD__ );
862 - $html = mb_convert_encoding($html, 'HTML-ENTITIES', "UTF-8");
 872+ $html = mb_convert_encoding( $html, 'HTML-ENTITIES', "UTF-8" );
863873 libxml_use_internal_errors( true );
864874 $this->doc = new DOMDocument();
865875 $this->doc->loadHTML( '<?xml encoding="UTF-8">' . $html );
@@ -891,14 +901,14 @@
892902 foreach ( $itemToRemoveRecords['TAG'] as $tagToRemove ) {
893903 $tagToRemoveNodes = $this->doc->getElementsByTagName( $tagToRemove );
894904
895 - foreach( $tagToRemoveNodes as $tagToRemoveNode ) {
 905+ foreach ( $tagToRemoveNodes as $tagToRemoveNode ) {
896906 if ( $tagToRemoveNode ) {
897907 $domElemsToRemove[] = $tagToRemoveNode;
898908 }
899909 }
900910 }
901911
902 - foreach( $domElemsToRemove as $domElement ) {
 912+ foreach ( $domElemsToRemove as $domElement ) {
903913 $domElement->parentNode->removeChild( $domElement );
904914 }
905915
@@ -915,7 +925,7 @@
916926 foreach ( $itemToRemoveRecords['CLASS'] as $classToRemove ) {
917927 $elements = $xpath->query( '//*[@class="' . $classToRemove . '"]' );
918928
919 - foreach( $elements as $element ) {
 929+ foreach ( $elements as $element ) {
920930 $removedElement = $element->parentNode->removeChild( $element );
921931 }
922932 }
@@ -928,15 +938,15 @@
929939 '//' . $parts[0] . '[@class="' . $parts[1] . '"]'
930940 );
931941
932 - foreach( $elements as $element ) {
 942+ foreach ( $elements as $element ) {
933943 $removedElement = $element->parentNode->removeChild( $element );
934944 }
935945 }
936946
937947 // Handle red links with action equal to edit
938948 $redLinks = $xpath->query( '//a[@class="new"]' );
939 - foreach( $redLinks as $redLink ) {
940 - //PHP Bug #36795 — Inappropriate "unterminated entity reference"
 949+ foreach ( $redLinks as $redLink ) {
 950+ // PHP Bug #36795 — Inappropriate "unterminated entity reference"
941951 $spanNode = $this->doc->createElement( "span", str_replace( "&", "&amp;", $redLink->nodeValue ) );
942952
943953 if ( $redLink->hasAttributes() ) {
@@ -951,7 +961,7 @@
952962 $content = $this->doc->getElementById( 'content' );
953963
954964 $contentHtml = $this->doc->saveXML( $content, LIBXML_NOEMPTYTAG );
955 -
 965+
956966 if ( self::$isMainPage ) {
957967 $contentHtml = $this->DOMParseMainPage( $contentHtml );
958968 }
@@ -966,7 +976,7 @@
967977 } elseif ( $this->contentFormat == 'WML' ) {
968978 $homeButton = self::$messages['mobile-frontend-home-button'];
969979 $randomButton = self::$messages['mobile-frontend-random-button'];
970 - //header( 'Content-Type: text/vnd.wap.wml' );
 980+ // header( 'Content-Type: text/vnd.wap.wml' );
971981
972982 // TODO: Content transformations required
973983 // WML Validator:
@@ -988,12 +998,12 @@
989999 if ( $this->contentFormat == 'XHTML' && self::$format != 'json' ) {
9901000 if ( !empty( self::$displayNoticeId ) ) {
9911001 $noticePagePath = 'views/notices/notice_' . intval( self::$displayNoticeId ) . '.html.php';
992 - if ( file_exists( dirname(__FILE__) . '/' . $noticePagePath ) ) {
 1002+ if ( file_exists( dirname( __FILE__ ) . '/' . $noticePagePath ) ) {
9931003 require( $noticePagePath );
9941004 }
9951005 }
996 -
997 - //header( 'Content-Type: application/xhtml+xml; charset=utf-8' );
 1006+
 1007+ // header( 'Content-Type: application/xhtml+xml; charset=utf-8' );
9981008 require( 'views/layout/_search_webkit.html.php' );
9991009 require( 'views/layout/_footmenu_default.html.php' );
10001010 require( 'views/layout/application.html.php' );
@@ -1015,7 +1025,7 @@
10161026 wfProfileOut( __METHOD__ );
10171027 return $json;
10181028 }
1019 -
 1029+
10201030 wfProfileOut( __METHOD__ );
10211031 return $applicationHtml;
10221032 }

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r98427fix for bug 31240 - android browsers render content poorly when viewing deskt...preilly18:38, 29 September 2011
r98442fix for r98427 to avoid false positives on mobile domain removalpreilly20:28, 29 September 2011
r98445fix for r98442 to not use parse_url directlypreilly20:38, 29 September 2011

Status & tagging log