Index: trunk/extensions/MobileFrontend/javascripts/opensearch.js |
— | — | @@ -34,7 +34,7 @@ |
35 | 35 | var xmlHttp; |
36 | 36 | if ( window.XMLHttpRequest ) { |
37 | 37 | xmlHttp = new XMLHttpRequest(); |
38 | | - } else { //IE6, IE5 |
| 38 | + } else { |
39 | 39 | xmlHttp = new ActiveXObject( 'Microsoft.XMLHTTP' ); |
40 | 40 | } |
41 | 41 | xmlHttp.onreadystatechange = function() { |
Index: trunk/extensions/MobileFrontend/javascripts/application.js |
— | — | @@ -1,5 +1,7 @@ |
2 | 2 | var search = document.getElementById( 'search' ); |
3 | 3 | var clearSearch = document.getElementById( 'clearsearch' ); |
| 4 | +var results = document.getElementById( 'results' ); |
| 5 | +var languageSelection = document.getElementById( 'languageselection' ); |
4 | 6 | |
5 | 7 | initClearSearchLink(); |
6 | 8 | |
— | — | @@ -9,12 +11,25 @@ |
10 | 12 | search.addEventListener( 'keyup', _handleClearSearchLink, false ); |
11 | 13 | } |
12 | 14 | |
| 15 | +function navigateToLanguageSelection() { |
| 16 | + var url; |
| 17 | + if ( languageSelection ) { |
| 18 | + url = languageSelection.options[languageSelection.selectedIndex].value; |
| 19 | + if ( url ) { |
| 20 | + location.href = url; |
| 21 | + } |
| 22 | + } |
| 23 | +} |
| 24 | + |
13 | 25 | function _handleClearSearchLink() { |
14 | 26 | if ( clearSearch ) { |
15 | 27 | if ( search.value.length > 0 ) { |
16 | 28 | clearSearch.style.display = 'block'; |
17 | 29 | } else { |
18 | 30 | clearSearch.style.display = 'none'; |
| 31 | + if ( results ) { |
| 32 | + results.style.display = 'none'; |
| 33 | + } |
19 | 34 | } |
20 | 35 | } |
21 | 36 | } |
— | — | @@ -33,6 +48,12 @@ |
34 | 49 | document.getElementById( 'logo' ).onclick = function() { |
35 | 50 | var n = document.getElementById( 'nav' ).style; |
36 | 51 | n.display = n.display == 'block' ? 'none' : 'block'; |
| 52 | + if (n.display == 'block') { |
| 53 | + if ( languageSelection ) { |
| 54 | + var newWidth = languageSelection.offsetWidth + 30; |
| 55 | + n.width = newWidth + 'px'; |
| 56 | + } |
| 57 | + } |
37 | 58 | }; |
38 | 59 | |
39 | 60 | // Also problematic, not working until the page loads... |
Index: trunk/extensions/MobileFrontend/MobileFrontend.php |
— | — | @@ -87,15 +87,12 @@ |
88 | 88 | } |
89 | 89 | |
90 | 90 | class ExtMobileFrontend { |
91 | | - const VERSION = '0.5.77'; |
| 91 | + const VERSION = '0.5.78'; |
92 | 92 | |
93 | 93 | /** |
94 | 94 | * @var DOMDocument |
95 | 95 | */ |
96 | 96 | private $doc, $mainPage; |
97 | | - |
98 | | - public static $messages = array(); |
99 | | - |
100 | 97 | public $contentFormat = ''; |
101 | 98 | public $WMLSectionSeperator = '***************************************************************************'; |
102 | 99 | |
— | — | @@ -103,6 +100,7 @@ |
104 | 101 | * @var Title |
105 | 102 | */ |
106 | 103 | public static $title; |
| 104 | + public static $messages = array(); |
107 | 105 | public static $htmlTitle; |
108 | 106 | public static $dir; |
109 | 107 | public static $code; |
— | — | @@ -129,6 +127,7 @@ |
130 | 128 | public static $mobileRedirectFormAction; |
131 | 129 | public static $isBetaGroupMember = false; |
132 | 130 | public static $hideSearchBox = false; |
| 131 | + public static $languageUrls; |
133 | 132 | |
134 | 133 | public static $messageKeys = array( |
135 | 134 | 'mobile-frontend-show-button', |
— | — | @@ -169,6 +168,7 @@ |
170 | 169 | 'mobile-frontend-feedback-page', |
171 | 170 | 'mobile-frontend-leave-feedback-thanks', |
172 | 171 | 'mobile-frontend-search-submit', |
| 172 | + 'mobile-frontend-language', |
173 | 173 | ); |
174 | 174 | |
175 | 175 | public $itemsToRemove = array( |
— | — | @@ -298,7 +298,7 @@ |
299 | 299 | } |
300 | 300 | |
301 | 301 | public function getMsg() { |
302 | | - global $wgUser, $wgContLang, $wgRequest, $wgServer, $wgMobileRedirectFormAction, $wgMobileDomain; |
| 302 | + global $wgUser, $wgContLang, $wgRequest, $wgServer, $wgMobileRedirectFormAction, $wgMobileDomain, $wgOut, $wgLanguageCode; |
303 | 303 | wfProfileIn( __METHOD__ ); |
304 | 304 | |
305 | 305 | self::$disableImagesURL = $wgRequest->escapeAppendQuery( 'disableImages=1' ); |
— | — | @@ -334,7 +334,48 @@ |
335 | 335 | |
336 | 336 | self::$dir = $wgContLang->getDir(); |
337 | 337 | self::$code = $wgContLang->getCode(); |
| 338 | + |
| 339 | + $languageUrls = array(); |
| 340 | + |
| 341 | + if ( $wgLanguageCode == 'en' ) { |
| 342 | + $languageUrls[] = array( |
| 343 | + 'href' => self::$currentURL, |
| 344 | + 'text' => self::$htmlTitle, |
| 345 | + 'language' => $wgContLang->getLanguageName( $wgLanguageCode ), |
| 346 | + 'class' => 'interwiki-' . $wgLanguageCode, |
| 347 | + 'lang' => $wgLanguageCode, |
| 348 | + ); |
| 349 | + } |
| 350 | + |
| 351 | + foreach( $wgOut->getLanguageLinks() as $l ) { |
| 352 | + if ( preg_match( '!^(\w[-\w]*\w):(.+)$!', $l, $m ) ) { |
| 353 | + $lang = $m[1]; |
| 354 | + $linkText = $m[2]; |
| 355 | + } else { |
| 356 | + continue; //NOTE: shouldn't happen |
| 357 | + } |
338 | 358 | |
| 359 | + $nt = Title::newFromText( $l ); |
| 360 | + $parsedUrl = wfParseUrl( $nt->getFullURL() ); |
| 361 | + if ( stristr( $parsedUrl['host'], $wgMobileDomain ) === false ) { |
| 362 | + $hostParts = explode( '.', $parsedUrl['host'] ); |
| 363 | + $parsedUrl['host'] = $hostParts[0] . $wgMobileDomain . $hostParts[1] . '.' . $hostParts[2]; |
| 364 | + } |
| 365 | + $fragmentDelimiter = ( !empty( $parsedUrl['fragment'] ) ) ? '#' : ''; |
| 366 | + $queryDelimiter = ( !empty( $parsedUrl['query'] ) ) ? '?' : ''; |
| 367 | + $languageUrl = $parsedUrl['scheme'] . '://' . $parsedUrl['host'] . $parsedUrl['path'] . $queryDelimiter . $parsedUrl['query'] . $fragmentDelimiter . $parsedUrl['fragment']; |
| 368 | + |
| 369 | + $languageUrls[] = array( |
| 370 | + 'href' => $languageUrl, |
| 371 | + 'text' => $linkText, |
| 372 | + 'language' => $wgContLang->getLanguageName( $lang ), |
| 373 | + 'class' => 'interwiki-' . $lang, |
| 374 | + 'lang' => $lang, |
| 375 | + ); |
| 376 | + } |
| 377 | + |
| 378 | + self::$languageUrls = $languageUrls; |
| 379 | + |
339 | 380 | $nonMobileServerBaseURL = str_replace( $wgMobileDomain, '.', $wgServer ); |
340 | 381 | self::$mobileRedirectFormAction = ( $wgMobileRedirectFormAction !== false ) ? $wgMobileRedirectFormAction : "{$nonMobileServerBaseURL}/w/mobileRedirect.php"; |
341 | 382 | |
— | — | @@ -518,13 +559,13 @@ |
519 | 560 | |
520 | 561 | // WURFL documentation: http://wurfl.sourceforge.net/help_doc.php |
521 | 562 | // Determine the kind of markup |
522 | | - if ( is_array( $props ) && isset( $props['preferred_markup'] ) && $props['preferred_markup'] ) { |
| 563 | + //if ( is_array( $props ) && isset( $props['preferred_markup'] ) && $props['preferred_markup'] ) { |
523 | 564 | // wfDebug( __METHOD__ . ": preferred markup for this device: " . $props['preferred_markup'] ); |
524 | 565 | // xhtml/html: html_web_3_2, html_web_4_0 |
525 | 566 | // xthml basic/xhtmlmp (wap 2.0): html_wi_w3_xhtmlbasic html_wi_oma_xhtmlmp_1_0 |
526 | 567 | // chtml (imode): html_wi_imode_* |
527 | 568 | // wml (wap 1): wml_1_1, wml_1_2, wml_1_3 |
528 | | - } |
| 569 | + //} |
529 | 570 | // WML options that might influence our 'style' of output |
530 | 571 | // $props['access_key_support'] (for creating easy keypad navigation) |
531 | 572 | // $props['softkey_support'] ( for creating your own menu) |
— | — | @@ -659,7 +700,8 @@ |
660 | 701 | $wgOut->addVaryHeader( 'Application_Version' ); |
661 | 702 | } else { |
662 | 703 | if ( !empty( $_SERVER['HTTP_X_DEVICE'] ) ) { |
663 | | - if ( stripos( $_SERVER['HTTP_X_DEVICE'], 'iphone' ) !== false ) { |
| 704 | + if ( stripos( $_SERVER['HTTP_X_DEVICE'], 'iphone' ) !== false || |
| 705 | + stripos( $_SERVER['HTTP_X_DEVICE'], 'android' ) !== false ) { |
664 | 706 | $wgRequest->response()->header( 'Application_Version: ' . $_SERVER['HTTP_X_DEVICE'] ); |
665 | 707 | $wgOut->addVaryHeader( 'Application_Version' ); |
666 | 708 | } |
— | — | @@ -1185,6 +1227,26 @@ |
1186 | 1228 | wfProfileOut( __METHOD__ ); |
1187 | 1229 | return $applicationHtml; |
1188 | 1230 | } |
| 1231 | + |
| 1232 | + public static function buildLanguageSelection() { |
| 1233 | + global $wgLanguageCode; |
| 1234 | + $output = Html::openElement( 'select', |
| 1235 | + array( 'id' => 'languageselection', |
| 1236 | + 'onchange' => 'javascript:navigateToLanguageSelection();' ) ); |
| 1237 | + foreach (self::$languageUrls as $languageUrl) { |
| 1238 | + if ( $languageUrl['lang'] == $wgLanguageCode ) { |
| 1239 | + $output .= Html::element( 'option', |
| 1240 | + array( 'value' => $languageUrl['href'], 'selected' => 'selected' ), |
| 1241 | + $languageUrl['language'] ); |
| 1242 | + } else { |
| 1243 | + $output .= Html::element( 'option', |
| 1244 | + array( 'value' => $languageUrl['href'] ), |
| 1245 | + $languageUrl['language'] ); |
| 1246 | + } |
| 1247 | + } |
| 1248 | + $output .= Html::closeElement( 'select', array() ); |
| 1249 | + return $output; |
| 1250 | + } |
1189 | 1251 | |
1190 | 1252 | /** |
1191 | 1253 | * Sets up the default logo image used in mobile view if none is set |
Index: trunk/extensions/MobileFrontend/views/layout/_search_webkit.html.php |
— | — | @@ -10,6 +10,12 @@ |
11 | 11 | $scriptUrl = wfScript(); |
12 | 12 | $searchBoxDisplayNone = ( self::$hideSearchBox ) ? ' style="display: none;" ' : ''; |
13 | 13 | |
| 14 | +$openSearchResults = ( self::$isBetaGroupMember ) ? '<div id="results"></div>' : ''; |
| 15 | + |
| 16 | +$languageSelection = self::buildLanguageSelection() . '<br/>'; |
| 17 | +$languageSelectionText = '<b>' . self::$messages['mobile-frontend-language'] . ':</b><br/>'; |
| 18 | +$languageSelectionDiv = ( self::$isBetaGroupMember ) ? '<div id="languageselectionsection">' . $languageSelectionText . $languageSelection . '</div>' : ''; |
| 19 | + |
14 | 20 | $searchWebkitHtml = <<<EOD |
15 | 21 | <div id='header'> |
16 | 22 | <div id='searchbox'> |
— | — | @@ -17,13 +23,15 @@ |
18 | 24 | <form action='{$scriptUrl}' class='search_bar' method='get' {$searchBoxDisplayNone}> |
19 | 25 | <input type="hidden" value="Special:Search" name="title" /> |
20 | 26 | <div id="sq" class="divclearable"> |
21 | | - <input type="text" name="search" id="search" size="22" value="{$searchField}" /> |
| 27 | + <input type="text" name="search" id="search" size="22" value="{$searchField}" autocomplete="off" /> |
22 | 28 | <div class="clearlink" id="clearsearch"></div> |
23 | 29 | </div> |
24 | 30 | <button id='goButton' type='submit'></button> |
25 | 31 | </form> |
| 32 | + {$openSearchResults} |
26 | 33 | </div> |
27 | 34 | <div class='nav' id='nav'> |
| 35 | + {$languageSelectionDiv} |
28 | 36 | <button onclick="javascript:location.href='{$mainPageUrl}';" type="submit" id="homeButton">{$homeButton}</button> |
29 | 37 | <button onclick="javascript:location.href='{$randomPageUrl}';" type="submit" id="randomButton">{$randomButton}</button> |
30 | 38 | </div> |
Index: trunk/extensions/MobileFrontend/views/layout/application.html.php |
— | — | @@ -1,5 +1,5 @@ |
2 | 2 | <?php |
3 | | -global $wgExtensionAssetsPath, $wgAppleTouchIcon; |
| 3 | +global $wgExtensionAssetsPath, $wgAppleTouchIcon, $wgScriptPath; |
4 | 4 | |
5 | 5 | $dir = self::$dir; |
6 | 6 | $code = self::$code; |
— | — | @@ -14,6 +14,12 @@ |
15 | 15 | |
16 | 16 | $cssFileName = ( isset( self::$device['css_file_name'] ) ) ? self::$device['css_file_name'] : 'default'; |
17 | 17 | |
| 18 | +$startScriptTag = '<script type="text/javascript" language="javascript" src="'; |
| 19 | +$endScriptTag = '"></script>'; |
| 20 | +$javaScriptPath = $wgExtensionAssetsPath . '/MobileFrontend/javascripts/'; |
| 21 | + |
| 22 | +$openSearchScript = ( self::$isBetaGroupMember ) ? $startScriptTag . $javaScriptPath . 'opensearch.js?version=10202011120715' . $endScriptTag : ''; |
| 23 | + |
18 | 24 | $applicationHtml = <<<EOT |
19 | 25 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" |
20 | 26 | "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
— | — | @@ -29,6 +35,7 @@ |
30 | 36 | <script type='text/javascript'> |
31 | 37 | //<![CDATA[ |
32 | 38 | var title = "{$htmlTitle}"; |
| 39 | + var scriptPath = "{$wgScriptPath}"; |
33 | 40 | function shouldCache() { |
34 | 41 | return true; |
35 | 42 | } |
— | — | @@ -42,7 +49,8 @@ |
43 | 50 | {$contentHtml} |
44 | 51 | </div> |
45 | 52 | {$footerHtml} |
46 | | - <script type="text/javascript" language="javascript" src="{$wgExtensionAssetsPath}/MobileFrontend/javascripts/application.min.js?version=20111014T172820Z"></script> |
| 53 | + {$startScriptTag}{$javaScriptPath}/application.js?version=10202011120715{$endScriptTag} |
| 54 | + {$openSearchScript} |
47 | 55 | </body> |
48 | 56 | </html> |
49 | 57 | EOT; |