Index: trunk/extensions/MobileFrontend/MobileFrontend.php |
— | — | @@ -208,7 +208,7 @@ |
209 | 209 | self::$enableImagesURL = $wgRequest->escapeAppendQuery( 'enableImages=1' ); |
210 | 210 | self::$disableMobileSiteURL = $wgRequest->escapeAppendQuery( 'mobileaction=disable_mobile_site' ); |
211 | 211 | self::$viewNormalSiteURL = $wgRequest->escapeAppendQuery( 'mobileaction=view_normal_site' ); |
212 | | - self::$currentURL = htmlspecialchars( $wgRequest->getFullRequestURL() ); |
| 212 | + self::$currentURL = $wgRequest->getFullRequestURL(); |
213 | 213 | self::$leaveFeedbackURL = $wgRequest->escapeAppendQuery( 'mobileaction=leave_feedback' ); |
214 | 214 | |
215 | 215 | $skin = $wgUser->getSkin(); |
— | — | @@ -707,6 +707,12 @@ |
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 | + |
711 | 717 | private function createWMLCard( $s ) { |
712 | 718 | wfProfileIn( __METHOD__ ); |
713 | 719 | $segments = explode( $this->WMLSectionSeperator, $s ); |
— | — | @@ -722,18 +728,22 @@ |
723 | 729 | |
724 | 730 | $useFormatParam = ( isset( self::$useFormat ) ) ? '&' . 'useformat=' . self::$useFormat : ''; |
725 | 731 | |
726 | | - $basePage = htmlspecialchars( $_SERVER['PHP_SELF'] ); |
| 732 | + $basePage = self::$currentURL; |
727 | 733 | |
| 734 | + $basePage = $this->removeQuerystringVar( $this->removeQuerystringVar( $basePage, 'useformat' ), 'seg' ); |
| 735 | + |
| 736 | + $delimiter = ( strpos( $basePage, '?' ) === false ) ? '?' : '&'; |
| 737 | + |
728 | 738 | if ( $idx < $segmentsCount ) { |
729 | | - $card .= "<p><a href=\"{$basePage}?seg={$idx}{$useFormatParam}\">" . self::$messages['mobile-frontend-wml-continue'] . "</a></p>"; |
| 739 | + $card .= "<p><a href=\"{$basePage}{$delimiter}seg={$idx}{$useFormatParam}\">" . self::$messages['mobile-frontend-wml-continue'] . "</a></p>"; |
730 | 740 | } |
731 | 741 | |
732 | 742 | if ( $idx > 1 ) { |
733 | 743 | $back_idx = $requestedSegment - 1; |
734 | | - $card .= "<p><a href=\"{$basePage}?seg={$back_idx}{$useFormatParam}\">" . self::$messages['mobile-frontend-wml-back'] . "</a></p>"; |
| 744 | + $card .= "<p><a href=\"{$basePage}{$delimiter}seg={$back_idx}{$useFormatParam}\">" . self::$messages['mobile-frontend-wml-back'] . "</a></p>"; |
735 | 745 | } |
736 | 746 | |
737 | | - $card .= '</div></card>'; |
| 747 | + $card .= '</card>'; |
738 | 748 | wfProfileOut( __METHOD__ ); |
739 | 749 | return $card; |
740 | 750 | } |
— | — | @@ -921,7 +931,7 @@ |
922 | 932 | && empty( self::$search ) && !self::$isMainPage ) { |
923 | 933 | $contentHtml = $this->headingTransform( $contentHtml ); |
924 | 934 | } elseif ( $this->contentFormat == 'WML' ) { |
925 | | - header( 'Content-Type: text/vnd.wap.wml' ); |
| 935 | + //header( 'Content-Type: text/vnd.wap.wml' ); |
926 | 936 | |
927 | 937 | // TODO: Content transformations required |
928 | 938 | // WML Validator: |