Index: trunk/extensions/MobileFrontend/MobileFrontend.php |
— | — | @@ -129,6 +129,8 @@ |
130 | 130 | public static $hideSearchBox = false; |
131 | 131 | public static $hideLogo = false; |
132 | 132 | public static $languageUrls; |
| 133 | + public static $wsLoginToken; |
| 134 | + public static $wsLoginFormAction; |
133 | 135 | |
134 | 136 | public static $messageKeys = array( |
135 | 137 | 'mobile-frontend-show-button', |
— | — | @@ -408,6 +410,16 @@ |
409 | 411 | if ( Title::newMainPage()->equals( self::$title ) ) { |
410 | 412 | self::$isMainPage = true; |
411 | 413 | } |
| 414 | + |
| 415 | + if ( self::$title == 'Special:UserLogin' ) { |
| 416 | + self::$wsLoginToken = $wgRequest->getSessionData( 'wsLoginToken' ); |
| 417 | + $returnToVal = $wgRequest->getVal( 'returnto' ); |
| 418 | + $returnto = ( !empty ( $returnToVal ) ) ? '&returnto=' . wfUrlencode( $returnToVal ) : ''; |
| 419 | + self::$wsLoginFormAction = self::$title->getLocalURL( 'action=submitlogin&type=login' . $returnto ); |
| 420 | + } else { |
| 421 | + self::$wsLoginToken = ''; |
| 422 | + self::$wsLoginFormAction = ''; |
| 423 | + } |
412 | 424 | |
413 | 425 | self::$htmlTitle = $out->getHTMLTitle(); |
414 | 426 | |
— | — | @@ -1076,18 +1088,16 @@ |
1077 | 1089 | } |
1078 | 1090 | |
1079 | 1091 | /** |
1080 | | - * @param $token string |
1081 | | - * @param $action string |
1082 | 1092 | * @return DomElement |
1083 | 1093 | */ |
1084 | | - public function renderLogin( $token, $action ) { |
| 1094 | + public function renderLogin() { |
1085 | 1095 | $username = self::$messages['mobile-frontend-username']; |
1086 | 1096 | $password = self::$messages['mobile-frontend-password']; |
1087 | 1097 | $login = self::$messages['mobile-frontend-login']; |
1088 | 1098 | $form = Html::openElement( 'form', |
1089 | 1099 | array( 'name' => 'userlogin', |
1090 | 1100 | 'method' => 'post', |
1091 | | - 'action' => $action ) ) . |
| 1101 | + 'action' => self::$wsLoginFormAction ) ) . |
1092 | 1102 | Html::openElement( 'table', |
1093 | 1103 | array( 'class' => 'user-login' ) ) . |
1094 | 1104 | Html::openElement( 'tbody' ) . |
— | — | @@ -1138,7 +1148,7 @@ |
1139 | 1149 | Html::closeElement( 'tr' ) . |
1140 | 1150 | Html::closeElement( 'tbody' ) . |
1141 | 1151 | Html::closeElement( 'table' ) . |
1142 | | - Html::input( 'wpLoginToken', $token, 'hidden' ) . |
| 1152 | + Html::input( 'wpLoginToken', self::$wsLoginToken, 'hidden' ) . |
1143 | 1153 | Html::closeElement( 'form' ); |
1144 | 1154 | return $this->getDomDocumentNodeByTagName( $form, 'form' ); |
1145 | 1155 | } |
— | — | @@ -1188,24 +1198,9 @@ |
1189 | 1199 | if ( self::$title == 'Special:UserLogin' ) { |
1190 | 1200 | $userlogin = $this->doc->getElementById( 'userloginForm' ); |
1191 | 1201 | |
1192 | | - if ( $userlogin && get_class($userlogin) === 'DOMElement' ) { |
1193 | | - $inputs = $userlogin->getElementsByTagName( 'input' ); |
1194 | | - $forms = $userlogin->getElementsByTagName( 'form' ); |
1195 | | - |
1196 | | - if ( $forms ) { |
1197 | | - foreach ( $forms as $form ) { |
1198 | | - $action = $form->getAttribute( 'action' ); |
1199 | | - } |
1200 | | - } |
1201 | | - |
1202 | | - foreach ( $inputs as $input ) { |
1203 | | - if ( $input->getAttribute( 'name' ) === 'wpLoginToken' ) { |
1204 | | - $wpLoginToken = $input->getAttribute( 'value' ); |
1205 | | - } |
1206 | | - } |
1207 | | - |
| 1202 | + if ( !empty( $userlogin ) && get_class($userlogin) === 'DOMElement' ) { |
1208 | 1203 | $firstHeading = $this->doc->getElementById( 'firstHeading' ); |
1209 | | - if ( $firstHeading ) { |
| 1204 | + if ( !empty( $firstHeading ) ) { |
1210 | 1205 | $firstHeading->nodeValue = ''; |
1211 | 1206 | } |
1212 | 1207 | } |
— | — | @@ -1294,8 +1289,8 @@ |
1295 | 1290 | } |
1296 | 1291 | |
1297 | 1292 | if ( self::$title == 'Special:UserLogin' ) { |
1298 | | - if ( isset( $wpLoginToken ) && isset( $action ) && isset( $userlogin ) ) { |
1299 | | - $login = $this->renderLogin( $wpLoginToken, $action ); |
| 1293 | + if ( !empty( $userlogin ) && get_class($userlogin) === 'DOMElement' ) { |
| 1294 | + $login = $this->renderLogin(); |
1300 | 1295 | $loginNode = $this->doc->importNode( $login, true ); |
1301 | 1296 | $userlogin->appendChild( $loginNode ); |
1302 | 1297 | } |