Index: branches/wmf/1.17wmf1/extensions/MobileFrontend/MobileFrontend.php |
— | — | @@ -65,7 +65,7 @@ |
66 | 66 | ); |
67 | 67 | |
68 | 68 | class ExtMobileFrontend { |
69 | | - const VERSION = '0.5.51'; |
| 69 | + const VERSION = '0.5.60'; |
70 | 70 | |
71 | 71 | /** |
72 | 72 | * @var DOMDocument |
— | — | @@ -103,6 +103,7 @@ |
104 | 104 | public static $disableMobileSiteURL; |
105 | 105 | public static $viewNormalSiteURL; |
106 | 106 | public static $currentURL; |
| 107 | + public static $displayNoticeId; |
107 | 108 | |
108 | 109 | public static $messageKeys = array( |
109 | 110 | 'mobile-frontend-show-button', |
— | — | @@ -132,6 +133,16 @@ |
133 | 134 | 'mobile-frontend-enable-images', |
134 | 135 | 'mobile-frontend-featured-article', |
135 | 136 | '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', |
136 | 147 | ); |
137 | 148 | |
138 | 149 | public $itemsToRemove = array( |
— | — | @@ -198,7 +209,16 @@ |
199 | 210 | self::$messages['mobile-frontend-copyright'] = $copyright; |
200 | 211 | |
201 | 212 | 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 | + } |
203 | 223 | } |
204 | 224 | |
205 | 225 | self::$dir = $wgContLang->getDir(); |
— | — | @@ -262,6 +282,7 @@ |
263 | 283 | $action = $wgRequest->getText( 'action' ); |
264 | 284 | self::$disableImages = $wgRequest->getText( 'disableImages', 0 ); |
265 | 285 | self::$enableImages = $wgRequest->getText( 'enableImages', 0 ); |
| 286 | + self::$displayNoticeId = $wgRequest->getText( 'noticeid', '' ); |
266 | 287 | |
267 | 288 | if ( self::$disableImages == 1 ) { |
268 | 289 | $wgRequest->response()->setcookie( 'disableImages', 1 ); |
— | — | @@ -316,7 +337,38 @@ |
317 | 338 | if ( self::$useFormat === 'mobile-wap' ) { |
318 | 339 | $this->contentFormat = 'WML'; |
319 | 340 | } |
| 341 | + |
| 342 | + if ( $mobileAction == 'leave_feedback' ) { |
| 343 | + echo $this->renderLeaveFeedbackXHTML(); |
| 344 | + wfProfileOut( __METHOD__ ); |
| 345 | + exit(); |
| 346 | + } |
320 | 347 | |
| 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() . '¬iceid=1' ); |
| 368 | + $wgRequest->response()->header( 'Location: ' . $location ); |
| 369 | + wfProfileOut( __METHOD__ ); |
| 370 | + exit(); |
| 371 | + } |
| 372 | + |
321 | 373 | if ( $mobileAction == 'disable_mobile_site' ) { |
322 | 374 | if ( $this->contentFormat == 'XHTML' ) { |
323 | 375 | echo $this->renderDisableMobileSiteXHTML(); |
— | — | @@ -437,6 +489,34 @@ |
438 | 490 | } |
439 | 491 | wfProfileOut( __METHOD__ ); |
440 | 492 | } |
| 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 | + } |
441 | 521 | |
442 | 522 | private function renderOptInMobileSiteXHTML() { |
443 | 523 | wfProfileIn( __METHOD__ ); |
— | — | @@ -663,6 +743,11 @@ |
664 | 744 | |
665 | 745 | $featuredArticle = $this->mainPage->getElementById( 'mp-tfa' ); |
666 | 746 | $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'); |
667 | 752 | |
668 | 753 | $content = $this->mainPage->createElement( 'div' ); |
669 | 754 | $content->setAttribute( 'id', 'main_box' ); |
— | — | @@ -679,12 +764,24 @@ |
680 | 765 | $content->appendChild( $newsItems ); |
681 | 766 | } |
682 | 767 | |
| 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 | + |
683 | 780 | $contentHtml = $this->mainPage->saveXML( $content, LIBXML_NOEMPTYTAG ); |
684 | 781 | wfProfileOut( __METHOD__ ); |
685 | 782 | return $contentHtml; |
686 | 783 | } |
687 | 784 | |
688 | | - public function DOMParse( $html ) { |
| 785 | + public function DOMParse( $html ) { |
689 | 786 | global $wgSitename; |
690 | 787 | wfProfileIn( __METHOD__ ); |
691 | 788 | $html = mb_convert_encoding($html, 'HTML-ENTITIES', "UTF-8"); |
— | — | @@ -790,7 +887,7 @@ |
791 | 888 | |
792 | 889 | if ( strlen( $contentHtml ) > 4000 && $this->contentFormat == 'XHTML' |
793 | 890 | && self::$device['supports_javascript'] === true |
794 | | - && empty( self::$search ) ) { |
| 891 | + && empty( self::$search ) && !self::$isMainPage ) { |
795 | 892 | $contentHtml = $this->headingTransform( $contentHtml ); |
796 | 893 | } elseif ( $this->contentFormat == 'WML' ) { |
797 | 894 | header( 'Content-Type: text/vnd.wap.wml' ); |
— | — | @@ -813,6 +910,13 @@ |
814 | 911 | } |
815 | 912 | |
816 | 913 | 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 | + |
817 | 921 | //header( 'Content-Type: application/xhtml+xml; charset=utf-8' ); |
818 | 922 | require( 'views/layout/_search_webkit.html.php' ); |
819 | 923 | 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 |
1 | 11 | + 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 |
1 | 28 | + native |
Index: branches/wmf/1.17wmf1/extensions/MobileFrontend/views/layout/_footmenu_default.html.php |
— | — | @@ -5,7 +5,10 @@ |
6 | 6 | $copyright = self::$messages['mobile-frontend-copyright']; |
7 | 7 | $disableImages = self::$messages['mobile-frontend-disable-images']; |
8 | 8 | $enableImages = self::$messages['mobile-frontend-enable-images']; |
| 9 | +$leaveFeedback = self::$messages['mobile-frontend-leave-feedback']; |
9 | 10 | |
| 11 | +$leaveFeedbackURL = self::$currentURL . '&mobileaction=leave_feedback'; |
| 12 | + |
10 | 13 | $disableMobileSiteURL = self::$disableMobileSiteURL; |
11 | 14 | $viewNormalSiteURL = self::$viewNormalSiteURL; |
12 | 15 | |
— | — | @@ -21,7 +24,7 @@ |
22 | 25 | <div id='footer'> |
23 | 26 | <div class='nav' id='footmenu'> |
24 | 27 | <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> |
26 | 29 | <div id="perm"> |
27 | 30 | <a href="{$disableMobileSiteURL}">{$permStopRedirect}</a> |
28 | 31 | </div> |
Index: branches/wmf/1.17wmf1/extensions/MobileFrontend/views/layout/application.html.php |
— | — | @@ -10,6 +10,8 @@ |
11 | 11 | $appleTouchIconTag = ""; |
12 | 12 | } |
13 | 13 | |
| 14 | +$noticeHtml = empty( $noticeHtml ) ? '' : $noticeHtml; |
| 15 | + |
14 | 16 | $cssFileName = ( isset( self::$device['css_file_name'] ) ) ? self::$device['css_file_name'] : 'default'; |
15 | 17 | |
16 | 18 | $applicationHtml = <<<EOT |
— | — | @@ -38,6 +40,7 @@ |
39 | 41 | <body> |
40 | 42 | {$searchWebkitHtml} |
41 | 43 | <div class='show' id='content_wrapper'> |
| 44 | + {$noticeHtml} |
42 | 45 | {$contentHtml} |
43 | 46 | </div> |
44 | 47 | {$footerHtml} |