r96521 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r96520‎ | r96521 | r96522 >
Date:23:40, 7 September 2011
Author:preilly
Status:ok
Tags:
Comment:
mft 96027 to 96520
Modified paths:
  • /branches/wmf/1.17wmf1/extensions/MobileFrontend/MobileFrontend.php (modified) (history)
  • /branches/wmf/1.17wmf1/extensions/MobileFrontend/views/information/leave_feedback.html.php (added) (history)
  • /branches/wmf/1.17wmf1/extensions/MobileFrontend/views/layout/_footmenu_default.html.php (modified) (history)
  • /branches/wmf/1.17wmf1/extensions/MobileFrontend/views/layout/application.html.php (modified) (history)
  • /branches/wmf/1.17wmf1/extensions/MobileFrontend/views/notices/notice_1.html.php (added) (history)

Diff [purge]

Index: branches/wmf/1.17wmf1/extensions/MobileFrontend/MobileFrontend.php
@@ -65,7 +65,7 @@
6666 );
6767
6868 class ExtMobileFrontend {
69 - const VERSION = '0.5.51';
 69+ const VERSION = '0.5.60';
7070
7171 /**
7272 * @var DOMDocument
@@ -103,6 +103,7 @@
104104 public static $disableMobileSiteURL;
105105 public static $viewNormalSiteURL;
106106 public static $currentURL;
 107+ public static $displayNoticeId;
107108
108109 public static $messageKeys = array(
109110 'mobile-frontend-show-button',
@@ -132,6 +133,16 @@
133134 'mobile-frontend-enable-images',
134135 'mobile-frontend-featured-article',
135136 'mobile-frontend-news-items',
 137+ 'mobile-frontend-leave-feedback-title',
 138+ 'mobile-frontend-leave-feedback-notice',
 139+ 'mobile-frontend-leave-feedback-subject',
 140+ 'mobile-frontend-leave-feedback-message',
 141+ 'mobile-frontend-leave-feedback-cancel',
 142+ 'mobile-frontend-leave-feedback-submit',
 143+ 'mobile-frontend-leave-feedback-link-text',
 144+ 'mobile-frontend-leave-feedback',
 145+ 'mobile-frontend-feedback-page',
 146+ 'mobile-frontend-leave-feedback-thanks',
136147 );
137148
138149 public $itemsToRemove = array(
@@ -198,7 +209,16 @@
199210 self::$messages['mobile-frontend-copyright'] = $copyright;
200211
201212 foreach ( self::$messageKeys as $messageKey ) {
202 - self::$messages[$messageKey] = wfMsg( $messageKey );
 213+
 214+ if ( $messageKey == 'mobile-frontend-leave-feedback-notice' ) {
 215+ $linkText = wfMsg( 'mobile-frontend-leave-feedback-link-text' );
 216+ $linkTarget = wfMsgNoTrans( 'mobile-frontend-feedback-page' );
 217+ self::$messages[$messageKey] = wfMsgExt( $messageKey, array( 'replaceafter' ), Html::element( 'a', array( 'href' => Title::newFromText( $linkTarget )->getFullURL(), 'target' => '_blank' ), $linkText ) );
 218+ } elseif ( $messageKey == 'mobile-frontend-feedback-page' ) {
 219+ self::$messages[$messageKey] = wfMsgNoTrans( $messageKey );
 220+ } else {
 221+ self::$messages[$messageKey] = wfMsg( $messageKey );
 222+ }
203223 }
204224
205225 self::$dir = $wgContLang->getDir();
@@ -262,6 +282,7 @@
263283 $action = $wgRequest->getText( 'action' );
264284 self::$disableImages = $wgRequest->getText( 'disableImages', 0 );
265285 self::$enableImages = $wgRequest->getText( 'enableImages', 0 );
 286+ self::$displayNoticeId = $wgRequest->getText( 'noticeid', '' );
266287
267288 if ( self::$disableImages == 1 ) {
268289 $wgRequest->response()->setcookie( 'disableImages', 1 );
@@ -316,7 +337,38 @@
317338 if ( self::$useFormat === 'mobile-wap' ) {
318339 $this->contentFormat = 'WML';
319340 }
 341+
 342+ if ( $mobileAction == 'leave_feedback' ) {
 343+ echo $this->renderLeaveFeedbackXHTML();
 344+ wfProfileOut( __METHOD__ );
 345+ exit();
 346+ }
320347
 348+ if ( $mobileAction == 'leave_feedback_post' ) {
 349+
 350+ $this->getMsg();
 351+
 352+ $subject = $wgRequest->getText( 'subject', '' );
 353+ $message = $wgRequest->getText( 'message', '' );
 354+ $token = $wgRequest->getText( 'edittoken', '' );
 355+
 356+ $title = Title::newFromText( self::$messages['mobile-frontend-feedback-page'] );
 357+
 358+ if ( $title->userCan( 'edit' ) &&
 359+ !$wgUser->isBlockedFrom( $title ) &&
 360+ $wgUser->matchEditToken( $token ) ) {
 361+ $article = new Article( $title, 0 );
 362+ $rawtext = $article->getRawText();
 363+ $rawtext .= "\n== {$subject} == \n {$message} ~~~~ \n <small>User agent: {$userAgent}</small> ";
 364+ $article->doEdit( $rawtext, '' );
 365+ }
 366+
 367+ $location = str_replace( '&mobileaction=leave_feedback_post', '', $wgRequest->getFullRequestURL() . '&noticeid=1' );
 368+ $wgRequest->response()->header( 'Location: ' . $location );
 369+ wfProfileOut( __METHOD__ );
 370+ exit();
 371+ }
 372+
321373 if ( $mobileAction == 'disable_mobile_site' ) {
322374 if ( $this->contentFormat == 'XHTML' ) {
323375 echo $this->renderDisableMobileSiteXHTML();
@@ -437,6 +489,34 @@
438490 }
439491 wfProfileOut( __METHOD__ );
440492 }
 493+
 494+ private function renderLeaveFeedbackXHTML() {
 495+ global $wgRequest, $wgUser;
 496+ wfProfileIn( __METHOD__ );
 497+ if ( $this->contentFormat == 'XHTML' ) {
 498+ $this->getMsg();
 499+ $editToken = $wgUser->editToken();
 500+
 501+ $htmlTitle = self::$messages['mobile-frontend-leave-feedback'];
 502+ $title = self::$messages['mobile-frontend-leave-feedback-title'];
 503+ $notice = self::$messages['mobile-frontend-leave-feedback-notice'];
 504+ $subject = self::$messages['mobile-frontend-leave-feedback-subject'];
 505+ $message = self::$messages['mobile-frontend-leave-feedback-message'];
 506+ $cancel = self::$messages['mobile-frontend-leave-feedback-cancel'];
 507+ $submit = self::$messages['mobile-frontend-leave-feedback-submit'];
 508+
 509+ $feedbackPostURL = str_replace( '&mobileaction=leave_feedback', '', $wgRequest->getFullRequestURL() ) . '&mobileaction=leave_feedback_post';
 510+ require( 'views/layout/_search_webkit.html.php' );
 511+ require( 'views/layout/_footmenu_default.html.php' );
 512+ require( 'views/information/leave_feedback.html.php' );
 513+ $contentHtml = $leaveFeedbackHtml;
 514+ require( 'views/layout/application.html.php' );
 515+ wfProfileOut( __METHOD__ );
 516+ return $applicationHtml;
 517+ }
 518+ wfProfileOut( __METHOD__ );
 519+ return '';
 520+ }
441521
442522 private function renderOptInMobileSiteXHTML() {
443523 wfProfileIn( __METHOD__ );
@@ -663,6 +743,11 @@
664744
665745 $featuredArticle = $this->mainPage->getElementById( 'mp-tfa' );
666746 $newsItems = $this->mainPage->getElementById( 'mp-itn' );
 747+
 748+ $xpath = new DOMXpath( $this->mainPage );
 749+ $elements = $xpath->query( '//*[starts-with(@id, "mp-")]' );
 750+
 751+ $commonAttributes = array('mp-tfa', 'mp-itn');
667752
668753 $content = $this->mainPage->createElement( 'div' );
669754 $content->setAttribute( 'id', 'main_box' );
@@ -679,12 +764,24 @@
680765 $content->appendChild( $newsItems );
681766 }
682767
 768+ foreach ( $elements as $element ) {
 769+ if ( $element->hasAttribute( 'id' ) ) {
 770+ $id = $element->getAttribute( 'id' );
 771+ if ( !in_array( $id, $commonAttributes ) ) {
 772+ $elementTitle = $element->hasAttribute( 'title' ) ? $element->getAttribute( 'title' ) : '';
 773+ $h2UnknownMobileSection = $this->mainPage->createElement( 'h2', $elementTitle );
 774+ $content->appendChild( $h2UnknownMobileSection );
 775+ $content->appendChild( $element );
 776+ }
 777+ }
 778+ }
 779+
683780 $contentHtml = $this->mainPage->saveXML( $content, LIBXML_NOEMPTYTAG );
684781 wfProfileOut( __METHOD__ );
685782 return $contentHtml;
686783 }
687784
688 - public function DOMParse( $html ) {
 785+ public function DOMParse( $html ) {
689786 global $wgSitename;
690787 wfProfileIn( __METHOD__ );
691788 $html = mb_convert_encoding($html, 'HTML-ENTITIES', "UTF-8");
@@ -790,7 +887,7 @@
791888
792889 if ( strlen( $contentHtml ) > 4000 && $this->contentFormat == 'XHTML'
793890 && self::$device['supports_javascript'] === true
794 - && empty( self::$search ) ) {
 891+ && empty( self::$search ) && !self::$isMainPage ) {
795892 $contentHtml = $this->headingTransform( $contentHtml );
796893 } elseif ( $this->contentFormat == 'WML' ) {
797894 header( 'Content-Type: text/vnd.wap.wml' );
@@ -813,6 +910,13 @@
814911 }
815912
816913 if ( $this->contentFormat == 'XHTML' && self::$format != 'json' ) {
 914+ if ( !empty( self::$displayNoticeId ) ) {
 915+ $noticePagePath = 'views/notices/notice_' . intval( self::$displayNoticeId ) . '.html.php';
 916+ if ( file_exists( dirname(__FILE__) . '/' . $noticePagePath ) ) {
 917+ require( $noticePagePath );
 918+ }
 919+ }
 920+
817921 //header( 'Content-Type: application/xhtml+xml; charset=utf-8' );
818922 require( 'views/layout/_search_webkit.html.php' );
819923 require( 'views/layout/_footmenu_default.html.php' );
Index: branches/wmf/1.17wmf1/extensions/MobileFrontend/views/notices/notice_1.html.php
@@ -0,0 +1,9 @@
 2+<?php
 3+
 4+$thanks = self::$messages['mobile-frontend-leave-feedback-thanks'];
 5+
 6+$noticeHtml = <<<EOT
 7+ <div class='mwm-message mwm-notice'>
 8+ {$thanks}
 9+ </div>
 10+EOT;
Property changes on: branches/wmf/1.17wmf1/extensions/MobileFrontend/views/notices/notice_1.html.php
___________________________________________________________________
Added: svn:eol-style
111 + native
Index: branches/wmf/1.17wmf1/extensions/MobileFrontend/views/information/leave_feedback.html.php
@@ -0,0 +1,26 @@
 2+<?php
 3+
 4+$leaveFeedbackHtml = <<<EOT
 5+<form action='{$feedbackPostURL}' method='post'>
 6+<input type="hidden" name="edittoken" value="{$editToken}"/>
 7+<div tabindex="-1">
 8+ <div unselectable="on">
 9+ <span unselectable="on"><p>{$title}</p></span>
 10+ </div>
 11+ <div>
 12+ <div>
 13+ <div><p><small>{$notice}</small>
 14+ </p></div>
 15+ <div><p>{$subject}:<br><input type="text" name="subject" maxlength="60" style="width:40%;"></p>
 16+ </div>
 17+ <div><p>{$message}:<br><textarea name="message" style="width:40%;" rows="5" cols="60"></textarea></p>
 18+ </div>
 19+ </div>
 20+ </div>
 21+ <div><button onClick="javascript:history.back();" type="button"><span>{$cancel}</span></button>
 22+ <input type="submit" value="{$submit}"></input>
 23+ </div>
 24+</div>
 25+</form>
 26+
 27+EOT;
Property changes on: branches/wmf/1.17wmf1/extensions/MobileFrontend/views/information/leave_feedback.html.php
___________________________________________________________________
Added: svn:eol-style
128 + native
Index: branches/wmf/1.17wmf1/extensions/MobileFrontend/views/layout/_footmenu_default.html.php
@@ -5,7 +5,10 @@
66 $copyright = self::$messages['mobile-frontend-copyright'];
77 $disableImages = self::$messages['mobile-frontend-disable-images'];
88 $enableImages = self::$messages['mobile-frontend-enable-images'];
 9+$leaveFeedback = self::$messages['mobile-frontend-leave-feedback'];
910
 11+$leaveFeedbackURL = self::$currentURL . '&mobileaction=leave_feedback';
 12+
1013 $disableMobileSiteURL = self::$disableMobileSiteURL;
1114 $viewNormalSiteURL = self::$viewNormalSiteURL;
1215
@@ -21,7 +24,7 @@
2225 <div id='footer'>
2326 <div class='nav' id='footmenu'>
2427 <div class='mwm-notice'>
25 - <a href="{$viewNormalSiteURL}">{$regularSite}</a> | <a href="{$imagesURL}">{$imagesToggle}</a>
 28+ <a href="{$viewNormalSiteURL}">{$regularSite}</a> | <a href="{$imagesURL}">{$imagesToggle}</a> | <a href="{$leaveFeedbackURL}">{$leaveFeedback}</a>
2629 <div id="perm">
2730 <a href="{$disableMobileSiteURL}">{$permStopRedirect}</a>
2831 </div>
Index: branches/wmf/1.17wmf1/extensions/MobileFrontend/views/layout/application.html.php
@@ -10,6 +10,8 @@
1111 $appleTouchIconTag = "";
1212 }
1313
 14+$noticeHtml = empty( $noticeHtml ) ? '' : $noticeHtml;
 15+
1416 $cssFileName = ( isset( self::$device['css_file_name'] ) ) ? self::$device['css_file_name'] : 'default';
1517
1618 $applicationHtml = <<<EOT
@@ -38,6 +40,7 @@
3941 <body>
4042 {$searchWebkitHtml}
4143 <div class='show' id='content_wrapper'>
 44+ {$noticeHtml}
4245 {$contentHtml}
4346 </div>
4447 {$footerHtml}

Status & tagging log