Index: trunk/extensions/MobileFrontend/FooterTemplate.php |
— | — | @@ -0,0 +1,50 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +if( !defined( 'MEDIAWIKI' ) ) { |
| 5 | + die( -1 ); |
| 6 | +} |
| 7 | + |
| 8 | +class FooterTemplate extends MobileFrontendTemplate { |
| 9 | + |
| 10 | + public function getHTML() { |
| 11 | + |
| 12 | + $regularSite = $this->data['messages']['mobile-frontend-regular-site']; |
| 13 | + $permStopRedirect = $this->data['messages']['mobile-frontend-perm-stop-redirect']; |
| 14 | + $copyright = $this->data['messages']['mobile-frontend-copyright']; |
| 15 | + $disableImages = $this->data['messages']['mobile-frontend-disable-images']; |
| 16 | + $enableImages = $this->data['messages']['mobile-frontend-enable-images']; |
| 17 | + $leaveFeedback = $this->data['messages']['mobile-frontend-leave-feedback']; |
| 18 | + |
| 19 | + $leaveFeedbackURL = $this->data['leaveFeedbackURL']; |
| 20 | + $disableMobileSiteURL = $this->data['disableMobileSiteURL']; |
| 21 | + $viewNormalSiteURL = $this->data['viewNormalSiteURL']; |
| 22 | + |
| 23 | + if ( $this->data['disableImages'] == 0 ) { |
| 24 | + $imagesToggle = $disableImages; |
| 25 | + $imagesURL = $this->data['disableImagesURL']; |
| 26 | + } else { |
| 27 | + $imagesToggle = $enableImages; |
| 28 | + $imagesURL = $this->data['enableImagesURL']; |
| 29 | + } |
| 30 | + |
| 31 | + $logoutLink = ( !empty( $this->data['logoutHtml'] ) ) ? ' | ' . $this->data['logoutHtml'] : ''; |
| 32 | + |
| 33 | + $feedbackLink = ( $this->data['code'] == 'en' && $this->data['isBetaGroupMember'] ) ? "| <a href=\"{$leaveFeedbackURL}\">{$leaveFeedback}</a>" : ''; |
| 34 | + |
| 35 | + $footerHtml = <<<HTML |
| 36 | + <div id='footer'> |
| 37 | + <div class='nav' id='footmenu'> |
| 38 | + <div class='mwm-notice'> |
| 39 | + <a href="{$viewNormalSiteURL}">{$regularSite}</a> | <a href="{$imagesURL}">{$imagesToggle}</a> {$feedbackLink} {$logoutLink} |
| 40 | + <div id="perm"> |
| 41 | + <a href="{$disableMobileSiteURL}">{$permStopRedirect}</a> |
| 42 | + </div> |
| 43 | + </div> |
| 44 | + </div> |
| 45 | + <div id='copyright'>{$copyright}</div> |
| 46 | + </div> |
| 47 | + |
| 48 | +HTML; |
| 49 | + return $footerHtml; |
| 50 | +} |
| 51 | +} |
Index: trunk/extensions/MobileFrontend/LeaveFeedbackTemplate.php |
— | — | @@ -0,0 +1,37 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +if( !defined( 'MEDIAWIKI' ) ) { |
| 5 | + die( -1 ); |
| 6 | +} |
| 7 | + |
| 8 | +class LeaveFeedbackTemplate extends MobileFrontendTemplate { |
| 9 | + |
| 10 | + public function getHTML() { |
| 11 | + |
| 12 | + $leaveFeedbackHtml = <<<HTML |
| 13 | + <form action='{$this->data['feedbackPostURL']}' method='post'> |
| 14 | + <input type="hidden" name="edittoken" value="{$this->data['editToken']}"/> |
| 15 | + <div tabindex="-1"> |
| 16 | + <div unselectable="on"> |
| 17 | + <span unselectable="on"><p>{$this->data['title']}</p></span> |
| 18 | + </div> |
| 19 | + <div> |
| 20 | + <div> |
| 21 | + <div><p><small>{$this->data['notice']}</small> |
| 22 | + </p></div> |
| 23 | + <div><p>{$this->data['subject']}:<br><input type="text" name="subject" maxlength="60" style="width:40%;"></p> |
| 24 | + </div> |
| 25 | + <div><p>{$this->data['message']}:<br><textarea name="message" style="width:40%;" rows="5" cols="60"></textarea></p> |
| 26 | + </div> |
| 27 | + </div> |
| 28 | + </div> |
| 29 | + <div><button onClick="javascript:history.back();" type="button"><span>{$this->data['cancel']}</span></button> |
| 30 | + <input type="submit" value="{$this->data['submit']}"></input> |
| 31 | + </div> |
| 32 | + </div> |
| 33 | + </form> |
| 34 | + |
| 35 | +HTML; |
| 36 | + return $leaveFeedbackHtml; |
| 37 | + } |
| 38 | +} |
Index: trunk/extensions/MobileFrontend/ApplicationTemplate.php |
— | — | @@ -0,0 +1,72 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +if( !defined( 'MEDIAWIKI' ) ) { |
| 5 | + die( -1 ); |
| 6 | +} |
| 7 | + |
| 8 | +class ApplicationTemplate extends MobileFrontendTemplate { |
| 9 | + |
| 10 | + public function getHTML() { |
| 11 | + |
| 12 | + if ( $this->data['wgAppleTouchIcon'] !== false ) { |
| 13 | + $appleTouchIconTag = Html::element( 'link', array( 'rel' => 'apple-touch-icon', 'href' => $this->data['wgAppleTouchIcon'] ) ); |
| 14 | + } else { |
| 15 | + $appleTouchIconTag = ''; |
| 16 | + } |
| 17 | + |
| 18 | + $betaPrefix = ( $this->data['isBetaGroupMember'] ) ? 'beta_' : ''; |
| 19 | + |
| 20 | + $noticeHtml = empty( $this->data['noticeHtml'] ) ? '' : $this->data['noticeHtml']; |
| 21 | + |
| 22 | + $cssFileName = ( isset( $this->data['device']['css_file_name'] ) ) ? $this->data['device']['css_file_name'] : 'default'; |
| 23 | + |
| 24 | + $startScriptTag = '<script type="text/javascript" language="javascript" src="'; |
| 25 | + $endScriptTag = '"></script>'; |
| 26 | + $javaScriptPath = $this->data['wgExtensionAssetsPath'] . '/MobileFrontend/javascripts/'; |
| 27 | + |
| 28 | + $openSearchScript = $startScriptTag . $javaScriptPath . $betaPrefix . 'opensearch.js?version=12012011126437' . $endScriptTag; |
| 29 | + $jQueryScript = ( $this->data['device']['supports_jquery'] ) ? $startScriptTag . $javaScriptPath . 'jquery-1.7.1.min.js' . $endScriptTag : ''; |
| 30 | + $filePageScript = ( $this->data['isFilePage'] ) ? $startScriptTag . $javaScriptPath . 'filepage.js' . $endScriptTag : ''; |
| 31 | + |
| 32 | + $startLinkTag = "<link href='{$this->data['wgExtensionAssetsPath']}/MobileFrontend/stylesheets/"; |
| 33 | + $endLinkTag = "' media='all' rel='Stylesheet' type='text/css' />"; |
| 34 | + $filePageStyle = ( $this->data['isFilePage'] ) ? $startLinkTag . 'filepage.css' . $endLinkTag : ''; |
| 35 | + |
| 36 | + $applicationHtml = <<<HTML |
| 37 | + <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" |
| 38 | + "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
| 39 | + <html lang='{$this->data['code']}' dir='{$this->data['dir']}' xml:lang='{$this->data['code']}' xmlns='http://www.w3.org/1999/xhtml'> |
| 40 | + <head> |
| 41 | + <title>{$this->data['htmlTitle']}</title> |
| 42 | + <meta http-equiv="content-type" content="application/xhtml+xml; charset=utf-8" /> |
| 43 | + <link href='{$this->data['wgExtensionAssetsPath']}/MobileFrontend/stylesheets/{$betaPrefix}common.css?version=12012011121954' media='all' rel='Stylesheet' type='text/css' /> |
| 44 | + <link href='{$this->data['wgExtensionAssetsPath']}/MobileFrontend/stylesheets/{$cssFileName}.css?version=12012011120715' media='all' rel='Stylesheet' type='text/css' /> |
| 45 | + {$filePageStyle} |
| 46 | + <meta name="ROBOTS" content="NOINDEX, NOFOLLOW" /> |
| 47 | + <meta name="viewport" content="width=device-width, initial-scale=1.0"> |
| 48 | + {$appleTouchIconTag} |
| 49 | + {$jQueryScript} |
| 50 | + <script type='text/javascript'> |
| 51 | + //<![CDATA[ |
| 52 | + var title = "{$this->data['htmlTitle']}"; |
| 53 | + var scriptPath = "{$this->data['wgScriptPath']}"; |
| 54 | + var placeholder = "{$this->data['placeholder']}"; |
| 55 | + //]]> |
| 56 | + </script> |
| 57 | + </head> |
| 58 | + <body> |
| 59 | + {$this->data['searchWebkitHtml']} |
| 60 | + <div class='show' id='content_wrapper'> |
| 61 | + {$noticeHtml} |
| 62 | + {$this->data['contentHtml']} |
| 63 | + </div> |
| 64 | + {$this->data['footerHtml']} |
| 65 | + {$startScriptTag}{$javaScriptPath}{$betaPrefix}application.js?version=12012011120915{$endScriptTag} |
| 66 | + {$openSearchScript} |
| 67 | + {$filePageScript} |
| 68 | + </body> |
| 69 | + </html> |
| 70 | +HTML; |
| 71 | + return $applicationHtml; |
| 72 | + } |
| 73 | +} |
Index: trunk/extensions/MobileFrontend/DisableTemplate.php |
— | — | @@ -0,0 +1,35 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +if( !defined( 'MEDIAWIKI' ) ) { |
| 5 | + die( -1 ); |
| 6 | +} |
| 7 | + |
| 8 | +class DisableTemplate extends MobileFrontendTemplate { |
| 9 | + |
| 10 | + public function getHTML() { |
| 11 | + |
| 12 | + $currentURL = $this->data['currentURL']; |
| 13 | + $currentURL = str_replace( '&mobileaction=disable_mobile_site', '', $currentURL ); |
| 14 | + $mobileRedirectFormAction = $this->data['mobileRedirectFormAction']; |
| 15 | + |
| 16 | + $disableHtml = <<<HTML |
| 17 | + <h1> |
| 18 | + {$this->data['areYouSure']} |
| 19 | + </h1> |
| 20 | + <p> |
| 21 | + {$this->data['explainDisable']} |
| 22 | + </p> |
| 23 | + <div id='disableButtons'> |
| 24 | + <form action='{$this->data['mobileRedirectFormAction']}' method='get'> |
| 25 | + <input name='to' type='hidden' value='{$this->data['currentURL']}' /> |
| 26 | + <input name='expires_in_days' type='hidden' value='3650' /> |
| 27 | + <button id='disableButton' type='submit'>{$this->data['disableButton']}</button> |
| 28 | + </form> |
| 29 | + <form action='/' method='get'> |
| 30 | + <button id='backButton' type='submit'>{$this->data['backButton']}</button> |
| 31 | + </form> |
| 32 | + </div> |
| 33 | +HTML; |
| 34 | + return $disableHtml; |
| 35 | + } |
| 36 | +} |
Index: trunk/extensions/MobileFrontend/SearchTemplate.php |
— | — | @@ -0,0 +1,53 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +if( !defined( 'MEDIAWIKI' ) ) { |
| 5 | + die( -1 ); |
| 6 | +} |
| 7 | + |
| 8 | +class SearchTemplate extends MobileFrontendTemplate { |
| 9 | + |
| 10 | + public function getHTML() { |
| 11 | + |
| 12 | + $searchField = htmlspecialchars( $this->data['searchField'] ); |
| 13 | + $mainPageUrl = $this->data['mainPageUrl']; |
| 14 | + $randomPageUrl = $this->data['randomPageUrl']; |
| 15 | + $homeButton = $this->data['messages']['mobile-frontend-home-button']; |
| 16 | + $randomButton = $this->data['messages']['mobile-frontend-random-button']; |
| 17 | + |
| 18 | + $scriptUrl = wfScript(); |
| 19 | + $searchBoxDisplayNone = ( $this->data['hideSearchBox'] ) ? ' style="display: none;" ' : ''; |
| 20 | + |
| 21 | + $logoDisplayNone = ( $this->data['hideLogo'] ) ? ' style="display: none;" ' : ''; |
| 22 | + |
| 23 | + $openSearchResults = '<div id="results"></div>'; |
| 24 | + |
| 25 | + $languageSelection = $this->data['buildLanguageSelection'] . '<br/>'; |
| 26 | + $languageSelectionText = '<b>' . $this->data['messages']['mobile-frontend-language'] . ':</b><br/>'; |
| 27 | + $languageSelectionDiv = '<div id="languageselectionsection">' . $languageSelectionText . $languageSelection . '</div>'; |
| 28 | + |
| 29 | + $logoOnClick = ( $this->data['device']['supports_javascript'] ) ? 'onclick="javascript:logoClick();"' : ''; |
| 30 | + |
| 31 | + $searchWebkitHtml = <<<HTML |
| 32 | + {$openSearchResults} |
| 33 | + <div id='header'> |
| 34 | + <div id='searchbox' {$logoDisplayNone}> |
| 35 | + <img width="35" height="22" alt='Logo' id='logo' src='{$this->data['wgMobileFrontendLogo']}' {$logoOnClick} {$logoDisplayNone} /> |
| 36 | + <form action='{$scriptUrl}' class='search_bar' method='get' {$searchBoxDisplayNone}> |
| 37 | + <input type="hidden" value="Special:Search" name="title" /> |
| 38 | + <div id="sq" class="divclearable"> |
| 39 | + <input type="text" name="search" id="search" size="22" value="{$searchField}" autocorrect="off" autocomplete="off" autocapitalize="off" maxlength="1024" /> |
| 40 | + <div class="clearlink" id="clearsearch"></div> |
| 41 | + </div> |
| 42 | + <button id='goButton' type='submit'></button> |
| 43 | + </form> |
| 44 | + </div> |
| 45 | + <div class='nav' id='nav' {$logoDisplayNone}> |
| 46 | + {$languageSelectionDiv} |
| 47 | + <button onclick="javascript:location.href='{$mainPageUrl}';" type="submit" id="homeButton">{$homeButton}</button> |
| 48 | + <button onclick="javascript:location.href='{$randomPageUrl}';" type="submit" id="randomButton">{$randomButton}</button> |
| 49 | + </div> |
| 50 | + </div> |
| 51 | +HTML; |
| 52 | + return $searchWebkitHtml; |
| 53 | + } |
| 54 | +} |
Index: trunk/extensions/MobileFrontend/MobileFrontendTemplate.php |
— | — | @@ -0,0 +1,51 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +if( !defined( 'MEDIAWIKI' ) ) { |
| 5 | + die( -1 ); |
| 6 | +} |
| 7 | + |
| 8 | +abstract class MobileFrontendTemplate { |
| 9 | + public $data; |
| 10 | + |
| 11 | + /** |
| 12 | + * Constructor |
| 13 | + */ |
| 14 | + public function __construct() { |
| 15 | + $this->data = array(); |
| 16 | + } |
| 17 | + |
| 18 | + /** |
| 19 | + * Sets the value $value to $name |
| 20 | + * @param $name |
| 21 | + * @param $value |
| 22 | + */ |
| 23 | + public function set( $name, $value ) { |
| 24 | + $this->data[$name] = $value; |
| 25 | + } |
| 26 | + |
| 27 | + /** |
| 28 | + * Sets the value $value to $name |
| 29 | + * @param $name |
| 30 | + * @param $value |
| 31 | + */ |
| 32 | + public function setByArray( $options ) { |
| 33 | + foreach ($options as $name => $value ) { |
| 34 | + $this->set( $name, $value ); |
| 35 | + } |
| 36 | + } |
| 37 | + |
| 38 | + /** |
| 39 | + * Gets the value of $name |
| 40 | + * @param $name |
| 41 | + * @return string |
| 42 | + */ |
| 43 | + public function get( $name ) { |
| 44 | + return $this->data[$name]; |
| 45 | + } |
| 46 | + |
| 47 | + /** |
| 48 | + * Main function, used by classes that subclass MobileFrontendTemplate |
| 49 | + * to show the actual HTML output |
| 50 | + */ |
| 51 | + abstract public function getHTML(); |
| 52 | +} |
\ No newline at end of file |
Index: trunk/extensions/MobileFrontend/MobileFrontend.php |
— | — | @@ -38,9 +38,20 @@ |
39 | 39 | |
40 | 40 | $cwd = dirname( __FILE__ ) . DIRECTORY_SEPARATOR; |
41 | 41 | $wgExtensionMessagesFiles['MobileFrontend'] = $cwd . 'MobileFrontend.i18n.php'; |
| 42 | + |
42 | 43 | // autoload extension classes |
43 | 44 | $wgAutoloadClasses['DeviceDetection'] = $cwd . 'DeviceDetection.php'; |
44 | | -$wgAutoloadClasses['CssDetection'] = $cwd . 'CssDetection.php'; |
| 45 | +$wgAutoloadClasses['CssDetection'] = $cwd . 'CssDetection.php'; |
| 46 | +$wgAutoloadClasses['MobileFrontendTemplate'] = $cwd . 'MobileFrontendTemplate.php'; |
| 47 | +$wgAutoloadClasses['ApplicationTemplate'] = $cwd . 'ApplicationTemplate.php'; |
| 48 | +$wgAutoloadClasses['SearchTemplate'] = $cwd . 'SearchTemplate.php'; |
| 49 | +$wgAutoloadClasses['FooterTemplate'] = $cwd . 'FooterTemplate.php'; |
| 50 | +$wgAutoloadClasses['LeaveFeedbackTemplate'] = $cwd . 'LeaveFeedbackTemplate.php'; |
| 51 | +$wgAutoloadClasses['DisableTemplate'] = $cwd . 'DisableTemplate.php'; |
| 52 | +$wgAutoloadClasses['OptInTemplate'] = $cwd . 'OptInTemplate.php'; |
| 53 | +$wgAutoloadClasses['OptOutTemplate'] = $cwd . 'OptOutTemplate.php'; |
| 54 | +$wgAutoloadClasses['ApplicationWmlTemplate'] = $cwd . 'ApplicationWmlTemplate.php'; |
| 55 | +$wgAutoloadClasses['ThanksNoticeTemplate'] = $cwd . 'ThanksNoticeTemplate.php'; |
45 | 56 | |
46 | 57 | /** |
47 | 58 | * Path to the logo used in the mobile view |
— | — | @@ -88,7 +99,7 @@ |
89 | 100 | } |
90 | 101 | |
91 | 102 | class ExtMobileFrontend { |
92 | | - const VERSION = '0.5.95'; |
| 103 | + const VERSION = '0.5.96'; |
93 | 104 | |
94 | 105 | /** |
95 | 106 | * @var DOMDocument |
— | — | @@ -780,11 +791,39 @@ |
781 | 792 | $submit = self::$messages['mobile-frontend-leave-feedback-submit']; |
782 | 793 | |
783 | 794 | $feedbackPostURL = str_replace( '&mobileaction=leave_feedback', '', $wgRequest->getFullRequestURL() ) . '&mobileaction=leave_feedback_post'; |
784 | | - require( 'views/layout/_search_webkit.html.php' ); |
785 | | - require( 'views/layout/_footmenu_default.html.php' ); |
786 | | - require( 'views/information/leave_feedback.html.php' ); |
| 795 | + //require( 'views/layout/_search_webkit.html.php' ); |
| 796 | + $searchTemplate = $this->getSearchTemplate(); |
| 797 | + $searchWebkitHtml = $searchTemplate->getHTML(); |
| 798 | + //require( 'views/layout/_footmenu_default.html.php' ); |
| 799 | + $footerTemplate = $this->getFooterTemplate(); |
| 800 | + $footerHtml = $footerTemplate->getHTML(); |
| 801 | + //require( 'views/information/leave_feedback.html.php' ); |
| 802 | + $leaveFeedbackTemplate = new LeaveFeedbackTemplate(); |
| 803 | + $options = array( |
| 804 | + 'feedbackPostURL' => str_replace( '&mobileaction=leave_feedback', '', $wgRequest->getFullRequestURL() ) . '&mobileaction=leave_feedback_post', |
| 805 | + 'editToken' => $editToken, |
| 806 | + 'title' => $title, |
| 807 | + 'notice' => $notice, |
| 808 | + 'subject' => $subject, |
| 809 | + 'message' => $message, |
| 810 | + 'cancel' => $cancel, |
| 811 | + 'submit' => $submit, |
| 812 | + ); |
| 813 | + $leaveFeedbackTemplate->setByArray( $options ); |
| 814 | + $leaveFeedbackHtml = $leaveFeedbackTemplate->getHTML(); |
787 | 815 | $contentHtml = $leaveFeedbackHtml; |
788 | | - require( 'views/layout/application.html.php' ); |
| 816 | + //require( 'views/layout/application.html.php' ); |
| 817 | + $noticeHtml = ( !empty( $noticeHtml ) ) ? $noticeHtml : ''; |
| 818 | + $applicationTemplate = $this->getApplicationTemplate(); |
| 819 | + $options = array( |
| 820 | + 'noticeHtml' => $noticeHtml, |
| 821 | + 'htmlTitle' => $htmlTitle, |
| 822 | + 'searchWebkitHtml' => $searchWebkitHtml, |
| 823 | + 'contentHtml' => $contentHtml, |
| 824 | + 'footerHtml' => $footerHtml, |
| 825 | + ); |
| 826 | + $applicationTemplate->setByArray( $options ); |
| 827 | + $applicationHtml = $applicationTemplate->getHTML(); |
789 | 828 | wfProfileOut( __METHOD__ ); |
790 | 829 | return $applicationHtml; |
791 | 830 | } |
— | — | @@ -799,17 +838,32 @@ |
800 | 839 | wfProfileIn( __METHOD__ ); |
801 | 840 | if ( $this->contentFormat == 'XHTML' ) { |
802 | 841 | $this->getMsg(); |
803 | | - $yesButton = self::$messages['mobile-frontend-opt-in-yes-button']; |
804 | | - $noButton = self::$messages['mobile-frontend-opt-in-no-button']; |
805 | | - $htmlTitle = self::$messages['mobile-frontend-opt-in-title']; |
806 | | - $explainOptIn = self::$messages['mobile-frontend-opt-in-explain']; |
807 | | - $optInMessage = self::$messages['mobile-frontend-opt-in-message']; |
808 | | - $formAction = wfExpandUrl( Title::newMainPage()->getFullURL(), PROTO_CURRENT ); |
809 | | - require( 'views/layout/_search_webkit.html.php' ); |
810 | | - require( 'views/layout/_footmenu_default.html.php' ); |
811 | | - require( 'views/information/optin.html.php' ); |
| 842 | + $searchTemplate = $this->getSearchTemplate(); |
| 843 | + $searchWebkitHtml = $searchTemplate->getHTML(); |
| 844 | + $footerTemplate = $this->getFooterTemplate(); |
| 845 | + $footerHtml = $footerTemplate->getHTML(); |
| 846 | + $optInTemplate = new OptInTemplate(); |
| 847 | + $options = array( |
| 848 | + 'explainOptIn' => self::$messages['mobile-frontend-opt-in-explain'], |
| 849 | + 'optInMessage' => self::$messages['mobile-frontend-opt-in-message'], |
| 850 | + 'yesButton' => self::$messages['mobile-frontend-opt-in-yes-button'], |
| 851 | + 'noButton' => self::$messages['mobile-frontend-opt-in-no-button'], |
| 852 | + 'formAction' => wfExpandUrl( Title::newMainPage()->getFullURL(), PROTO_CURRENT ), |
| 853 | + ); |
| 854 | + $optInTemplate->setByArray( $options ); |
| 855 | + $optInHtml = $optInTemplate->getHTML(); |
812 | 856 | $contentHtml = $optInHtml; |
813 | | - require( 'views/layout/application.html.php' ); |
| 857 | + $noticeHtml = ( !empty( $noticeHtml ) ) ? $noticeHtml : ''; |
| 858 | + $applicationTemplate = $this->getApplicationTemplate(); |
| 859 | + $options = array( |
| 860 | + 'noticeHtml' => $noticeHtml, |
| 861 | + 'htmlTitle' => self::$messages['mobile-frontend-opt-in-title'], |
| 862 | + 'searchWebkitHtml' => $searchWebkitHtml, |
| 863 | + 'contentHtml' => $contentHtml, |
| 864 | + 'footerHtml' => $footerHtml, |
| 865 | + ); |
| 866 | + $applicationTemplate->setByArray( $options ); |
| 867 | + $applicationHtml = $applicationTemplate->getHTML(); |
814 | 868 | wfProfileOut( __METHOD__ ); |
815 | 869 | return $applicationHtml; |
816 | 870 | } |
— | — | @@ -824,17 +878,32 @@ |
825 | 879 | wfProfileIn( __METHOD__ ); |
826 | 880 | if ( $this->contentFormat == 'XHTML' ) { |
827 | 881 | $this->getMsg(); |
828 | | - $yesButton = self::$messages['mobile-frontend-opt-out-yes-button']; |
829 | | - $noButton = self::$messages['mobile-frontend-opt-out-no-button']; |
830 | | - $htmlTitle = self::$messages['mobile-frontend-opt-out-title']; |
831 | | - $explainOptOut = self::$messages['mobile-frontend-opt-out-explain']; |
832 | | - $optOutMessage = self::$messages['mobile-frontend-opt-out-message']; |
833 | | - $formAction = wfExpandUrl( Title::newMainPage()->getFullURL(), PROTO_CURRENT ); |
834 | | - require( 'views/layout/_search_webkit.html.php' ); |
835 | | - require( 'views/layout/_footmenu_default.html.php' ); |
836 | | - require( 'views/information/optout.html.php' ); |
| 882 | + $searchTemplate = $this->getSearchTemplate(); |
| 883 | + $searchWebkitHtml = $searchTemplate->getHTML(); |
| 884 | + $footerTemplate = $this->getFooterTemplate(); |
| 885 | + $footerHtml = $footerTemplate->getHTML(); |
| 886 | + $optOutTemplate = new OptOutTemplate(); |
| 887 | + $options = array( |
| 888 | + 'explainOptOut' => self::$messages['mobile-frontend-opt-out-explain'], |
| 889 | + 'optOutMessage' => self::$messages['mobile-frontend-opt-out-message'], |
| 890 | + 'yesButton' => self::$messages['mobile-frontend-opt-out-yes-button'], |
| 891 | + 'noButton' => self::$messages['mobile-frontend-opt-out-no-button'], |
| 892 | + 'formAction' => wfExpandUrl( Title::newMainPage()->getFullURL(), PROTO_CURRENT ), |
| 893 | + ); |
| 894 | + $optOutTemplate->setByArray( $options ); |
| 895 | + $optOutHtml = $optOutTemplate->getHTML(); |
837 | 896 | $contentHtml = $optOutHtml; |
838 | | - require( 'views/layout/application.html.php' ); |
| 897 | + $noticeHtml = ( !empty( $noticeHtml ) ) ? $noticeHtml : ''; |
| 898 | + $applicationTemplate = $this->getApplicationTemplate(); |
| 899 | + $options = array( |
| 900 | + 'noticeHtml' => $noticeHtml, |
| 901 | + 'htmlTitle' => self::$messages['mobile-frontend-opt-out-title'], |
| 902 | + 'searchWebkitHtml' => $searchWebkitHtml, |
| 903 | + 'contentHtml' => $contentHtml, |
| 904 | + 'footerHtml' => $footerHtml, |
| 905 | + ); |
| 906 | + $applicationTemplate->setByArray( $options ); |
| 907 | + $applicationHtml = $applicationTemplate->getHTML(); |
839 | 908 | wfProfileOut( __METHOD__ ); |
840 | 909 | return $applicationHtml; |
841 | 910 | } |
— | — | @@ -855,11 +924,41 @@ |
856 | 925 | $backButton = self::$messages['mobile-frontend-back-button']; |
857 | 926 | $htmlTitle = $areYouSure; |
858 | 927 | $title = $areYouSure; |
859 | | - require( 'views/layout/_search_webkit.html.php' ); |
860 | | - require( 'views/layout/_footmenu_default.html.php' ); |
861 | | - require( 'views/information/disable.html.php' ); |
| 928 | + //require( 'views/layout/_search_webkit.html.php' ); |
| 929 | + $searchTemplate = $this->getSearchTemplate(); |
| 930 | + $searchWebkitHtml = $searchTemplate->getHTML(); |
| 931 | + //require( 'views/layout/_footmenu_default.html.php' ); |
| 932 | + $footerTemplate = $this->getFooterTemplate(); |
| 933 | + $footerHtml = $footerTemplate->getHTML(); |
| 934 | + //require( 'views/information/disable.html.php' ); |
| 935 | + |
| 936 | + $disableTemplate = new DisableTemplate(); |
| 937 | + $options = array( |
| 938 | + 'currentURL' => self::$currentURL, |
| 939 | + 'mobileRedirectFormAction' => self::$mobileRedirectFormAction, |
| 940 | + 'areYouSure' => $areYouSure, |
| 941 | + 'explainDisable' => $explainDisable, |
| 942 | + 'disableButton' => $disableButton, |
| 943 | + 'backButton' => $backButton, |
| 944 | + 'htmlTitle' => $htmlTitle, |
| 945 | + 'title' => $title, |
| 946 | + ); |
| 947 | + $disableTemplate->setByArray( $options ); |
| 948 | + $disableHtml = $disableTemplate->getHTML(); |
| 949 | + |
862 | 950 | $contentHtml = $disableHtml; |
863 | | - require( 'views/layout/application.html.php' ); |
| 951 | + //require( 'views/layout/application.html.php' ); |
| 952 | + $noticeHtml = ( !empty( $noticeHtml ) ) ? $noticeHtml : ''; |
| 953 | + $applicationTemplate = $this->getApplicationTemplate(); |
| 954 | + $options = array( |
| 955 | + 'noticeHtml' => $noticeHtml, |
| 956 | + 'htmlTitle' => $htmlTitle, |
| 957 | + 'searchWebkitHtml' => $searchWebkitHtml, |
| 958 | + 'contentHtml' => $contentHtml, |
| 959 | + 'footerHtml' => $footerHtml, |
| 960 | + ); |
| 961 | + $applicationTemplate->setByArray( $options ); |
| 962 | + $applicationHtml = $applicationTemplate->getHTML(); |
864 | 963 | wfProfileOut( __METHOD__ ); |
865 | 964 | return $applicationHtml; |
866 | 965 | } |
— | — | @@ -1332,20 +1431,7 @@ |
1333 | 1432 | && empty( self::$search ) && !self::$isMainPage ) { |
1334 | 1433 | $contentHtml = $this->headingTransform( $contentHtml ); |
1335 | 1434 | } elseif ( $this->contentFormat == 'WML' ) { |
1336 | | - $homeButton = self::$messages['mobile-frontend-home-button']; |
1337 | | - $randomButton = self::$messages['mobile-frontend-random-button']; |
1338 | 1435 | header( 'Content-Type: text/vnd.wap.wml' ); |
1339 | | - |
1340 | | - // TODO: Content transformations required |
1341 | | - // WML Validator: |
1342 | | - // http://validator.w3.org |
1343 | | - // |
1344 | | - // div -> p |
1345 | | - // no style, no class, no h1-h6, sup, sub, ol, ul, li etc. |
1346 | | - // table requires "columns" property |
1347 | | - // lang and dir officially unsupported (but often work on rtl phones) |
1348 | | - |
1349 | | - // Add segmentation markers |
1350 | 1436 | $contentHtml = $this->headingTransform( $contentHtml ); |
1351 | 1437 | |
1352 | 1438 | // Content removal for WML rendering |
— | — | @@ -1361,21 +1447,46 @@ |
1362 | 1448 | $contentHtml = $searchWml . $contentHtml; |
1363 | 1449 | // Content wrapping |
1364 | 1450 | $contentHtml = $this->createWMLCard( $contentHtml ); |
1365 | | - require( 'views/layout/application.wml.php' ); |
| 1451 | + //require( 'views/layout/application.wml.php' ); |
| 1452 | + $applicationWmlTemplate = new ApplicationWmlTemplate(); |
| 1453 | + $options = array( |
| 1454 | + 'mainPageUrl' => self::$mainPageUrl, |
| 1455 | + 'randomPageUrl' => self::$randomPageUrl, |
| 1456 | + 'dir' => self::$dir, |
| 1457 | + 'code' => self::$code, |
| 1458 | + 'contentHtml' => $contentHtml, |
| 1459 | + 'homeButton' => self::$messages['mobile-frontend-home-button'], |
| 1460 | + 'randomButton' => self::$messages['mobile-frontend-random-button'], |
| 1461 | + ); |
| 1462 | + $applicationWmlTemplate->setByArray( $options ); |
| 1463 | + $applicationHtml = $applicationWmlTemplate->getHTML(); |
1366 | 1464 | } |
1367 | 1465 | |
1368 | 1466 | if ( $this->contentFormat == 'XHTML' && self::$format != 'json' ) { |
1369 | 1467 | if ( !empty( self::$displayNoticeId ) ) { |
1370 | | - $noticePagePath = 'views/notices/notice_' . intval( self::$displayNoticeId ) . '.html.php'; |
1371 | | - if ( file_exists( dirname( __FILE__ ) . '/' . $noticePagePath ) ) { |
1372 | | - require( $noticePagePath ); |
| 1468 | + if ( intval( self::$displayNoticeId ) === 1 ) { |
| 1469 | + $thanksNoticeTemplate = new ThanksNoticeTemplate(); |
| 1470 | + $thanksNoticeTemplate->set( 'messages', self::$messages ); |
| 1471 | + $noticeHtml = $thanksNoticeTemplate->getHTML(); |
1373 | 1472 | } |
1374 | 1473 | } |
1375 | 1474 | |
1376 | 1475 | // header( 'Content-Type: application/xhtml+xml; charset=utf-8' ); |
1377 | | - require( 'views/layout/_search_webkit.html.php' ); |
1378 | | - require( 'views/layout/_footmenu_default.html.php' ); |
1379 | | - require( 'views/layout/application.html.php' ); |
| 1476 | + $searchTemplate = $this->getSearchTemplate(); |
| 1477 | + $searchWebkitHtml = $searchTemplate->getHTML(); |
| 1478 | + $footerTemplate = $this->getFooterTemplate(); |
| 1479 | + $footerHtml = $footerTemplate->getHTML(); |
| 1480 | + $noticeHtml = ( !empty( $noticeHtml ) ) ? $noticeHtml : ''; |
| 1481 | + $applicationTemplate = $this->getApplicationTemplate(); |
| 1482 | + $options = array( |
| 1483 | + 'noticeHtml' => $noticeHtml, |
| 1484 | + 'htmlTitle' => $htmlTitle, |
| 1485 | + 'searchWebkitHtml' => $searchWebkitHtml, |
| 1486 | + 'contentHtml' => $contentHtml, |
| 1487 | + 'footerHtml' => $footerHtml, |
| 1488 | + ); |
| 1489 | + $applicationTemplate->setByArray( $options ); |
| 1490 | + $applicationHtml = $applicationTemplate->getHTML(); |
1380 | 1491 | } |
1381 | 1492 | |
1382 | 1493 | if ( self::$format === 'json' ) { |
— | — | @@ -1399,6 +1510,68 @@ |
1400 | 1511 | return $applicationHtml; |
1401 | 1512 | } |
1402 | 1513 | |
| 1514 | + public function getFooterTemplate() { |
| 1515 | + wfProfileIn( __METHOD__ ); |
| 1516 | + $footerTemplate = new FooterTemplate(); |
| 1517 | + $logoutHtml = ( !empty( $logoutHtml ) ) ? $logoutHtml : ''; |
| 1518 | + $options = array( |
| 1519 | + 'messages' => self::$messages, |
| 1520 | + 'leaveFeedbackURL' => self::$leaveFeedbackURL, |
| 1521 | + 'disableMobileSiteURL' => self::$disableMobileSiteURL, |
| 1522 | + 'viewNormalSiteURL' => self::$viewNormalSiteURL, |
| 1523 | + 'disableImages' => self::$disableImages, |
| 1524 | + 'disableImagesURL' => self::$disableImagesURL, |
| 1525 | + 'enableImagesURL' => self::$enableImagesURL, |
| 1526 | + 'logoutHtml' => $logoutHtml, |
| 1527 | + 'code' => self::$code, |
| 1528 | + 'isBetaGroupMember' => self::$isBetaGroupMember, |
| 1529 | + ); |
| 1530 | + $footerTemplate->setByArray( $options ); |
| 1531 | + wfProfileOut( __METHOD__ ); |
| 1532 | + return $footerTemplate; |
| 1533 | + } |
| 1534 | + |
| 1535 | + public function getSearchTemplate() { |
| 1536 | + global $wgExtensionAssetsPath, $wgMobileFrontendLogo; |
| 1537 | + wfProfileIn( __METHOD__ ); |
| 1538 | + $searchTemplate = new SearchTemplate(); |
| 1539 | + $options = array( |
| 1540 | + 'searchField' => self::$searchField, |
| 1541 | + 'mainPageUrl' => self::$mainPageUrl, |
| 1542 | + 'randomPageUrl' => self::$randomPageUrl, |
| 1543 | + 'messages' => self::$messages, |
| 1544 | + 'hideSearchBox' => self::$hideSearchBox, |
| 1545 | + 'hideLogo' => self::$hideLogo, |
| 1546 | + 'buildLanguageSelection' => self::buildLanguageSelection(), |
| 1547 | + 'device' => self::$device, |
| 1548 | + 'wgExtensionAssetsPath' => $wgExtensionAssetsPath, |
| 1549 | + 'wgMobileFrontendLogo' => $wgMobileFrontendLogo, |
| 1550 | + ); |
| 1551 | + $searchTemplate->setByArray( $options ); |
| 1552 | + wfProfileOut( __METHOD__ ); |
| 1553 | + return $searchTemplate; |
| 1554 | + } |
| 1555 | + |
| 1556 | + public function getApplicationTemplate() { |
| 1557 | + global $wgAppleTouchIcon, $wgExtensionAssetsPath, $wgScriptPath; |
| 1558 | + wfProfileIn( __METHOD__ ); |
| 1559 | + $applicationTemplate = new ApplicationTemplate(); |
| 1560 | + $options = array( |
| 1561 | + 'dir' => self::$dir, |
| 1562 | + 'code' => self::$code, |
| 1563 | + 'placeholder' => self::$messages['mobile-frontend-placeholder'], |
| 1564 | + 'wgAppleTouchIcon' => $wgAppleTouchIcon, |
| 1565 | + 'isBetaGroupMember' => self::$isBetaGroupMember, |
| 1566 | + 'device' => self::$device, |
| 1567 | + 'wgExtensionAssetsPath' => $wgExtensionAssetsPath, |
| 1568 | + 'wgScriptPath' => $wgScriptPath, |
| 1569 | + 'isFilePage' => self::$isFilePage, |
| 1570 | + ); |
| 1571 | + $applicationTemplate->setByArray( $options ); |
| 1572 | + wfProfileOut( __METHOD__ ); |
| 1573 | + return $applicationTemplate; |
| 1574 | + } |
| 1575 | + |
1403 | 1576 | public static function buildLanguageSelection() { |
1404 | 1577 | global $wgLanguageCode; |
1405 | 1578 | wfProfileIn( __METHOD__ ); |
Index: trunk/extensions/MobileFrontend/ApplicationWmlTemplate.php |
— | — | @@ -0,0 +1,33 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +if( !defined( 'MEDIAWIKI' ) ) { |
| 5 | + die( -1 ); |
| 6 | +} |
| 7 | + |
| 8 | +class ApplicationWmlTemplate extends MobileFrontendTemplate { |
| 9 | + |
| 10 | + public function getHTML() { |
| 11 | + $mainPageUrl = $this->data['mainPageUrl']; |
| 12 | + $randomPageUrl = $this->data['randomPageUrl']; |
| 13 | + $dir = $this->data['dir']; |
| 14 | + $code = $this->data['code']; |
| 15 | + |
| 16 | + $applicationHtml = <<<HTML |
| 17 | + <?xml version='1.0' encoding='utf-8' ?> |
| 18 | + <!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.3//EN" |
| 19 | + "http://www.wapforum.org/DTD/wml13.dtd"> |
| 20 | + <wml xml:lang="{$code}" dir="{$dir}"> |
| 21 | + <template> |
| 22 | + <do name="home" type="options" label="{$this->data['homeButton']}" > |
| 23 | + <go href="{$this->data['mainPageUrl']}"/> |
| 24 | + </do> |
| 25 | + <do name="random" type="options" label="{$this->data['randomButton']}"> |
| 26 | + <go href="{$this->data['randomPageUrl']}"/> |
| 27 | + </do> |
| 28 | + </template> |
| 29 | + {$this->data['contentHtml']} |
| 30 | + </wml> |
| 31 | +HTML; |
| 32 | + return $applicationHtml; |
| 33 | + } |
| 34 | +} |
Index: trunk/extensions/MobileFrontend/OptInTemplate.php |
— | — | @@ -0,0 +1,31 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +if( !defined( 'MEDIAWIKI' ) ) { |
| 5 | + die( -1 ); |
| 6 | +} |
| 7 | + |
| 8 | +class OptInTemplate extends MobileFrontendTemplate { |
| 9 | + |
| 10 | + public function getHTML() { |
| 11 | + |
| 12 | + $optInHtml = <<<HTML |
| 13 | + <h1> |
| 14 | + {$this->data['optInMessage']} |
| 15 | + </h1> |
| 16 | + <p> |
| 17 | + {$this->data['explainOptIn']} |
| 18 | + </p> |
| 19 | + <div id='disableButtons'> |
| 20 | + <form action='{$this->data['formAction']}' method='get'> |
| 21 | + <input name='mobileaction' type='hidden' value='opt_in_cookie' /> |
| 22 | + <input name='useformat' type='hidden' value='mobile' /> |
| 23 | + <button id='disableButton' type='submit'>{$this->data['yesButton']}</button> |
| 24 | + </form> |
| 25 | + <form action='/' method='get'> |
| 26 | + <button id='backButton' type='submit'>{$this->data['noButton']}</button> |
| 27 | + </form> |
| 28 | + </div> |
| 29 | +HTML; |
| 30 | + return $optInHtml; |
| 31 | + } |
| 32 | +} |
Index: trunk/extensions/MobileFrontend/OptOutTemplate.php |
— | — | @@ -0,0 +1,30 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +if( !defined( 'MEDIAWIKI' ) ) { |
| 5 | + die( -1 ); |
| 6 | +} |
| 7 | + |
| 8 | +class OptOutTemplate extends MobileFrontendTemplate { |
| 9 | + |
| 10 | + public function getHTML() { |
| 11 | + $optOutHtml = <<<HTML |
| 12 | + <h1> |
| 13 | + {$this->data['optOutMessage']} |
| 14 | + </h1> |
| 15 | + <p> |
| 16 | + {$this->data['explainOptOut']} |
| 17 | + </p> |
| 18 | + <div id='disableButtons'> |
| 19 | + <form action='{$this->data['formAction']}' method='get'> |
| 20 | + <input name='mobileaction' type='hidden' value='opt_out_cookie' /> |
| 21 | + <input name='useformat' type='hidden' value='mobile' /> |
| 22 | + <button id='disableButton' type='submit'>{$this->data['yesButton']}</button> |
| 23 | + </form> |
| 24 | + <form action='/' method='get'> |
| 25 | + <button id='backButton' type='submit'>{$this->data['noButton']}</button> |
| 26 | + </form> |
| 27 | + </div> |
| 28 | +HTML; |
| 29 | + return $optOutHtml; |
| 30 | + } |
| 31 | +} |
Index: trunk/extensions/MobileFrontend/ThanksNoticeTemplate.php |
— | — | @@ -0,0 +1,20 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +if( !defined( 'MEDIAWIKI' ) ) { |
| 5 | + die( -1 ); |
| 6 | +} |
| 7 | + |
| 8 | +class ThanksNoticeTemplate extends MobileFrontendTemplate { |
| 9 | + |
| 10 | + public function getHTML() { |
| 11 | + |
| 12 | + $thanks = $this->data['messages']['mobile-frontend-leave-feedback-thanks']; |
| 13 | + |
| 14 | + $noticeHtml = <<<HTML |
| 15 | + <div class='mwm-message mwm-notice'> |
| 16 | + {$thanks} |
| 17 | + </div> |
| 18 | +HTML; |
| 19 | + return $noticeHtml; |
| 20 | + } |
| 21 | +} |
\ No newline at end of file |