/** * Returns the HTML for the ChooseName form. */ public function getChooseNameForm($userinfo, $messageKey = '', $existingName = '') { global $wgFbDisableLogin; // Keep track of when the first option visible to the user is checked $checked = false; // If a different $messagekey was passed (like 'wrongpassword'), use it instead if ($messageKey == '') { $messageKey = 'facebook-chooseinstructions'; } $html = wfMsgWikiHtml($messageKey); $html .= ' <form action="' . $this->getTitle('ChooseName')->getLocalUrl() . '" method="POST"> <fieldset id="mw-facebook-choosename"> <legend>' . wfMsg('facebook-chooselegend') . '</legend> <table>'; // Let them attach to an existing. If $wgFbDisableLogin is true, then // stand-alone account aren't allowed in the first place if (empty($wgFbDisableLogin)) { $updateChoices = "<br/>\n" . $this->getUpdateOptions($userinfo); // Create the HTML for the "existing account" option $html .= ' <tr> <td class="wm-label"> <input name="wpNameChoice" type="radio" value="existing" id="wpNameChoiceExisting"/> </td> <td class="mw-input"> <label for="wpNameChoiceExisting">' . wfMsg('facebook-chooseexisting') . '</label> <div id="mw-facebook-choosename-update" class="fbInitialHidden"> <label for="wpExistingName">' . wfMsgHtml('facebook-chooseusername') . '</label> <input name="wpExistingName" size="20" value="' . $existingName . '" id="wpExistingName" /> <label for="wpExistingPassword">' . wfMsgHtml('facebook-choosepassword') . '</label> <input name="wpExistingPassword" size="20" value="" type="password" id="wpExistingPassword" /><br/> ' . $updateChoices . ' </div> </td> </tr>'; } // Add the options for nick name, first name and full name if we can get them foreach (array('nick', 'first', 'full') as $option) { $nickname = FacebookUser::getOptionFromInfo($option . 'name', $userinfo); if ($nickname && FacebookUser::userNameOK($nickname)) { $html .= ' <tr> <td class="mw-label"> <input name="wpNameChoice" type="radio" value="' . $option . ($checked ? '' : '" checked="checked') . '" id="wpNameChoice' . $option . '" /> </td> <td class="mw-input"> <label for="wpNameChoice' . $option . '">' . wfMsg('facebook-choose' . $option, $nickname) . '</label> </td> </tr>'; // When the first radio is checked, this flag is set and subsequent options aren't checked $checked = true; } } // The options for auto and manual usernames are always available $html .= ' <tr> <td class="mw-label"> <input name="wpNameChoice" type="radio" value="auto" ' . ($checked ? '' : 'checked="checked" ') . 'id="wpNameChoiceAuto" /> </td> <td class="mw-input"> <label for="wpNameChoiceAuto">' . wfMsg('facebook-chooseauto', FacebookUser::generateUserName()) . '</label> </td> </tr> <tr> <td class="mw-label"> <input name="wpNameChoice" type="radio" value="manual" id="wpNameChoiceManual" /> </td> <td class="mw-input"> <label for="wpNameChoiceManual">' . wfMsg('facebook-choosemanual') . '</label> <input name="wpName2" size="16" value="" id="wpName2" /> </td> </tr>'; // Finish with two options, "Log in" or "Cancel" $html .= ' <tr> <td></td> <td class="mw-submit"> <input type="submit" value="Log in" name="wpOK" /> <input type="submit" value="Cancel" name="wpCancel" />'; // Include returnto and returntoquery parameters if they are set if (!empty($this->mReturnTo)) { $html .= ' <input type="hidden" name="returnto" value="' . $this->mReturnTo . '" />'; // Only need returntoquery if returnto is set if (!empty($this->mReturnToQuery)) { $html .= ' <input type="hidden" name="returntoquery" value="' . $this->mReturnToQuery . '" />'; } } $html .= ' </td> </tr> </table> </fieldset> </form>'; return $html; }