r97027 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r97026‎ | r97027 | r97028 >
Date:00:16, 14 September 2011
Author:preilly
Status:old
Tags:
Comment:
mft r97026
Modified paths:
  • /branches/wmf/1.17wmf1/extensions/MobileFrontend/MobileFrontend.php (modified) (history)

Diff [purge]

Index: branches/wmf/1.17wmf1/extensions/MobileFrontend/MobileFrontend.php
@@ -208,7 +208,7 @@
209209 self::$enableImagesURL = $wgRequest->escapeAppendQuery( 'enableImages=1' );
210210 self::$disableMobileSiteURL = $wgRequest->escapeAppendQuery( 'mobileaction=disable_mobile_site' );
211211 self::$viewNormalSiteURL = $wgRequest->escapeAppendQuery( 'mobileaction=view_normal_site' );
212 - self::$currentURL = htmlspecialchars( $wgRequest->getFullRequestURL() );
 212+ self::$currentURL = $wgRequest->getFullRequestURL();
213213 self::$leaveFeedbackURL = $wgRequest->escapeAppendQuery( 'mobileaction=leave_feedback' );
214214
215215 $skin = $wgUser->getSkin();
@@ -707,6 +707,12 @@
708708 return $s;
709709 }
710710
 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+
711717 private function createWMLCard( $s ) {
712718 wfProfileIn( __METHOD__ );
713719 $segments = explode( $this->WMLSectionSeperator, $s );
@@ -722,18 +728,22 @@
723729
724730 $useFormatParam = ( isset( self::$useFormat ) ) ? '&' . 'useformat=' . self::$useFormat : '';
725731
726 - $basePage = htmlspecialchars( $_SERVER['PHP_SELF'] );
 732+ $basePage = self::$currentURL;
727733
 734+ $basePage = $this->removeQuerystringVar( $this->removeQuerystringVar( $basePage, 'useformat' ), 'seg' );
 735+
 736+ $delimiter = ( strpos( $basePage, '?' ) === false ) ? '?' : '&';
 737+
728738 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>";
730740 }
731741
732742 if ( $idx > 1 ) {
733743 $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>";
735745 }
736746
737 - $card .= '</div></card>';
 747+ $card .= '</card>';
738748 wfProfileOut( __METHOD__ );
739749 return $card;
740750 }
@@ -921,7 +931,7 @@
922932 && empty( self::$search ) && !self::$isMainPage ) {
923933 $contentHtml = $this->headingTransform( $contentHtml );
924934 } elseif ( $this->contentFormat == 'WML' ) {
925 - header( 'Content-Type: text/vnd.wap.wml' );
 935+ //header( 'Content-Type: text/vnd.wap.wml' );
926936
927937 // TODO: Content transformations required
928938 // WML Validator:

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r97026fix for wml view pagination linkspreilly00:16, 14 September 2011

Status & tagging log