r93595 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r93594‎ | r93595 | r93596 >
Date:17:18, 31 July 2011
Author:hartman
Status:resolved (Comments)
Tags:
Comment:
Instead of scraping the page title, use the actual title from the title object (and the actual <title>)
Modified paths:
  • /trunk/extensions/MobileFrontend/MobileFrontend.php (modified) (history)
  • /trunk/extensions/MobileFrontend/library/resources/wurfl-config.xml (modified) (history)
  • /trunk/extensions/MobileFrontend/views/layout/_footmenu_default.html.php (modified) (history)
  • /trunk/extensions/MobileFrontend/views/layout/application.html.php (modified) (history)

Diff [purge]

Index: trunk/extensions/MobileFrontend/library/resources/wurfl-config.xml
@@ -8,7 +8,11 @@
99 </wurfl>
1010 <allow-reload>true</allow-reload>
1111 <persistence>
 12+ <provider>file</provider>
 13+ <params>/tmp</params>
 14+<!--
1215 <provider>mwmemcache</provider>
1316 <params>serverip=127.0.0.1</params>
 17+-->
1418 </persistence>
1519 </wurfl-config>
Index: trunk/extensions/MobileFrontend/MobileFrontend.php
@@ -57,6 +57,8 @@
5858
5959 public $contentFormat = '';
6060 public $WMLSectionSeperator = '***************************************************************************';
 61+ public static $title;
 62+ public static $htmlTitle;
6163 public static $dir;
6264 public static $code;
6365 public static $device;
@@ -122,6 +124,10 @@
123125 public function onOutputPageBeforeHTML( &$out, &$text ) {
124126 global $wgContLang, $wgRequest, $wgMemc, $wgUser;
125127
 128+ // The title
 129+ self::$title = $out->getTitle();
 130+ self::$htmlTitle = $out->getHTMLTitle();
 131+
126132 // Need to get copyright footer from skin. The footer changes depending
127133 // on whether we're using the WikimediaMessages extension or not.
128134 $skin=$wgUser->getSkin();
@@ -278,7 +284,7 @@
279285 $explainDisable = self::$messages['mobile-frontend-explain-disable'];
280286 $disableButton = self::$messages['mobile-frontend-disable-button'];
281287 $backButton = self::$messages['mobile-frontend-back-button'];
282 - $title = $areYouSure;
 288+ $htmlTitle = $areYouSure;
283289 $cssFileName = ( isset( self::$device['css_file_name'] ) ) ? self::$device['css_file_name'] : 'default';
284290 require( 'views/notices/_donate.html.php' );
285291 require( 'views/layout/_search_webkit.html.php' );
@@ -360,11 +366,12 @@
361367 return $s;
362368 }
363369
364 - private function createWMLCard( $s, $title = '' ) {
 370+ private function createWMLCard( $s ) {
365371 $segments = explode( $this->WMLSectionSeperator, $s );
366372 $card = '';
367373 $idx = 0;
368374 $requestedSegment = self::$requestedSegment;
 375+ $title = htmlspecialchars( self::$title->getText() );
369376
370377 $card .= "<card id='{$idx}' title='{$title}'><p>{$segments[$requestedSegment]}</p>";
371378 $idx = $requestedSegment + 1;
@@ -415,12 +422,6 @@
416423
417424 $itemToRemoveRecords = $this->parseItemsToRemove();
418425
419 - $titleNode = $this->doc->getElementsByTagName( 'title' );
420 -
421 - if ( $titleNode->length > 0 ) {
422 - $title = $titleNode->item( 0 )->nodeValue;
423 - }
424 -
425426 // Tags
426427
427428 // You can't remove DOMNodes from a DOMNodeList as you're iterating
@@ -516,6 +517,9 @@
517518 $homeButton = self::$messages['mobile-frontend-home-button'];
518519 $randomButton = self::$messages['mobile-frontend-random-button'];
519520
 521+ $title = htmlspecialchars( self::$title->getText() );
 522+ $htmlTitle = htmlspecialchars( self::$htmlTitle );
 523+
520524 $cssFileName = ( isset( self::$device['css_file_name'] ) ) ? self::$device['css_file_name'] : 'default';
521525
522526 if ( strlen( $contentHtml ) > 4000 && $this->contentFormat == 'XHTML'
@@ -538,7 +542,7 @@
539543 $contentHtml = $this->headingTransform( $contentHtml );
540544
541545 // Content wrapping
542 - $contentHtml = $this->createWMLCard( $contentHtml, $title );
 546+ $contentHtml = $this->createWMLCard( $contentHtml );
543547 require( 'views/layout/application.wml.php' );
544548 }
545549
@@ -552,7 +556,7 @@
553557 header( 'Content-Type: application/json' );
554558 header( 'Content-Disposition: attachment; filename="data.js";' );
555559 $json_data = array();
556 - $json_data['title'] = $title;
 560+ $json_data['title'] = self::$title->getText();
557561 $json_data['html'] = $contentHtml;
558562
559563 $json = json_encode( $json_data );
Index: trunk/extensions/MobileFrontend/views/layout/_footmenu_default.html.php
@@ -4,9 +4,9 @@
55 <div id='footer'>
66 <div class='nav' id='footmenu'>
77 <div class='mwm-notice'>
8 - <a href="?mAction=view_normal_site">{$regularSite}</a>
 8+ <a href="{$regularSiteUrl}">{$regularSite}</a>
99 <div id="perm">
10 - <a href="?mAction=disable_mobile_site">{$permStopRedirect}</a>
 10+ <a href="{$permStopRedirectUrl}">{$permStopRedirect}</a>
1111 </div>
1212 </div>
1313 </div>
Index: trunk/extensions/MobileFrontend/views/layout/application.html.php
@@ -11,7 +11,7 @@
1212 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
1313 <html lang='{$code}' dir='{$dir}' xml:lang='{$code}' xmlns='http://www.w3.org/1999/xhtml'>
1414 <head>
15 - <title>{$title}</title>
 15+ <title>{$htmlTitle}</title>
1616 <meta http-equiv="content-type" content="text/html; charset=utf-8" />
1717 <link href='{$wgExtensionAssetsPath}/MobileFrontend/stylesheets/{$cssFileName}.css' media='all' rel='Stylesheet' type='text/css' />
1818 <meta name="ROBOTS" content="NOINDEX, NOFOLLOW" />

Follow-up revisions

RevisionCommit summaryAuthorDate
r93596Follow up to r93595hartman17:28, 31 July 2011
r93605Partial revert of r93595hartman19:18, 31 July 2011

Comments

#Comment by Eloquence (talk | contribs)   19:16, 31 July 2011

Mh, I'm guessing the wurfl-config.xml change was accidentally committed as part of this rev? It did have the nice side effect of fixing WURFL for me. ;-) Obviously hardcoding config options here is wrong -- would be nice to move this into a config flag for the extension.

#Comment by TheDJ (talk | contribs)   19:19, 31 July 2011

Thx. Yeah I already made a note somewhere that we really should be using inmemoryconfig of wurfl.

http://www.scientiamobile.com/api-doc/php/WURFL_Configuration/WURFL_Configuration_InMemoryConfig.html

Status & tagging log