Index: trunk/extensions/MobileFrontend/MobileFrontend.php |
— | — | @@ -707,13 +707,8 @@ |
708 | 708 | return $s; |
709 | 709 | } |
710 | 710 | |
711 | | - private function removeQuerystringVar( $url, $key ) { |
712 | | - $url = preg_replace( '/(.*)(\?|&)' . $key . '=[^&]+?(&)(.*)/i', '$1$2$4', $url . '&' ); |
713 | | - $url = substr( $url, 0, -1 ); |
714 | | - return ( $url ); |
715 | | - } |
716 | | - |
717 | 711 | private function createWMLCard( $s ) { |
| 712 | + global $wgRequest; |
718 | 713 | wfProfileIn( __METHOD__ ); |
719 | 714 | $segments = explode( $this->WMLSectionSeperator, $s ); |
720 | 715 | $card = ''; |
— | — | @@ -727,20 +722,28 @@ |
728 | 723 | $card .= "<p>" . $idx . "/" . $segmentsCount . "</p>"; |
729 | 724 | |
730 | 725 | $useFormatParam = ( isset( self::$useFormat ) ) ? '&' . 'useformat=' . self::$useFormat : ''; |
731 | | - |
732 | | - $basePage = self::$currentURL; |
733 | | - |
734 | | - $basePage = $this->removeQuerystringVar( $this->removeQuerystringVar( $basePage, 'useformat' ), 'seg' ); |
735 | | - |
736 | | - $delimiter = ( strpos( $basePage, '?' ) === false ) ? '?' : '&'; |
737 | 726 | |
| 727 | + // Title::getLocalUrl doesn't work at this point since PHP 5.1.x, all objects have their destructors called |
| 728 | + // before the output buffer callback function executes. |
| 729 | + // Thus, globalized objects will not be available as expected in the function. |
| 730 | + // This is stated to be intended behavior, as per the following: [http://bugs.php.net/bug.php?id=40104] |
| 731 | + $mDefaultQuery = $wgRequest->getQueryValues(); |
| 732 | + unset( $mDefaultQuery['seg'] ); |
| 733 | + unset( $mDefaultQuery['useformat'] ); |
| 734 | + |
| 735 | + $qs = wfArrayToCGI( $mDefaultQuery ); |
| 736 | + $delimiter = ( !empty( $qs ) ) ? '?' : ''; |
| 737 | + $basePageParts = wfParseUrl( self::$currentURL ); |
| 738 | + $basePage = $basePageParts['scheme'] . $basePageParts['delimiter'] . $basePageParts['host'] . $basePageParts['path'] . $delimiter . $qs; |
| 739 | + $appendDelimiter = ( $delimiter === '?' ) ? '&' : '?'; |
| 740 | + |
738 | 741 | if ( $idx < $segmentsCount ) { |
739 | | - $card .= "<p><a href=\"{$basePage}{$delimiter}seg={$idx}{$useFormatParam}\">" . self::$messages['mobile-frontend-wml-continue'] . "</a></p>"; |
| 742 | + $card .= "<p><a href=\"{$basePage}{$appendDelimiter}seg={$idx}{$useFormatParam}\">" . self::$messages['mobile-frontend-wml-continue'] . "</a></p>"; |
740 | 743 | } |
741 | 744 | |
742 | 745 | if ( $idx > 1 ) { |
743 | 746 | $back_idx = $requestedSegment - 1; |
744 | | - $card .= "<p><a href=\"{$basePage}{$delimiter}seg={$back_idx}{$useFormatParam}\">" . self::$messages['mobile-frontend-wml-back'] . "</a></p>"; |
| 747 | + $card .= "<p><a href=\"{$basePage}{$appendDelimiter}seg={$back_idx}{$useFormatParam}\">" . self::$messages['mobile-frontend-wml-back'] . "</a></p>"; |
745 | 748 | } |
746 | 749 | |
747 | 750 | $card .= '</card>'; |
— | — | @@ -931,6 +934,8 @@ |
932 | 935 | && empty( self::$search ) && !self::$isMainPage ) { |
933 | 936 | $contentHtml = $this->headingTransform( $contentHtml ); |
934 | 937 | } elseif ( $this->contentFormat == 'WML' ) { |
| 938 | + $homeButton = self::$messages['mobile-frontend-home-button']; |
| 939 | + $randomButton = self::$messages['mobile-frontend-random-button']; |
935 | 940 | //header( 'Content-Type: text/vnd.wap.wml' ); |
936 | 941 | |
937 | 942 | // TODO: Content transformations required |