/** * Get the HTML form segment for a single question * @param $question SecurePoll_Question * @param $options Array of options, in the order they should be displayed * @return string */ function getQuestionForm( $question, $options ) { $name = 'securepoll_q' . $question->getId(); $s = ''; foreach ( $options as $option ) { $optionHTML = $option->parseMessageInline( 'text' ); $optionId = $option->getId(); $radioId = "{$name}_opt{$optionId}"; $s .= '<div class="securepoll-option-choose">' . Xml::radio( $name, $optionId, false, array( 'id' => $radioId ) ) . ' ' . Xml::tags( 'label', array( 'for' => $radioId ), $optionHTML ) . "</div>\n"; } return $s; }
function formatOptions($options, $value) { $html = ''; $attribs = $this->getAttributes(array('disabled', 'tabindex')); $elementFunc = array('Html', $this->mOptionsLabelsNotFromMessage ? 'rawElement' : 'element'); # @todo Should this produce an unordered list perhaps? foreach ($options as $label => $info) { if (is_array($info)) { $html .= Html::rawElement('h1', array(), $label) . "\n"; $html .= $this->formatOptions($info, $value); } else { $id = Sanitizer::escapeId($this->mID . "-{$info}"); $radio = Xml::radio($this->mName, $info, $info === $value, $attribs + array('id' => $id)); $radio .= ' ' . call_user_func($elementFunc, 'label', array('for' => $id), $label); $html .= ' ' . Html::rawElement('div', array('class' => 'mw-htmlform-flatlist-item'), $radio); } } return $html; }
function formatOptions($options, $value) { global $wgUseMediaWikiUIEverywhere; $html = ''; $attribs = $this->getAttributes(['disabled', 'tabindex']); $elementFunc = ['Html', $this->mOptionsLabelsNotFromMessage ? 'rawElement' : 'element']; # @todo Should this produce an unordered list perhaps? foreach ($options as $label => $info) { if (is_array($info)) { $html .= Html::rawElement('h1', [], $label) . "\n"; $html .= $this->formatOptions($info, $value); } else { $id = Sanitizer::escapeId($this->mID . "-{$info}"); $classes = ['mw-htmlform-flatlist-item']; if ($wgUseMediaWikiUIEverywhere || $this->mParent instanceof VFormHTMLForm) { $classes[] = 'mw-ui-radio'; } $radio = Xml::radio($this->mName, $info, $info === $value, $attribs + ['id' => $id]); $radio .= ' ' . call_user_func($elementFunc, 'label', ['for' => $id], $label); $html .= ' ' . Html::rawElement('div', ['class' => $classes], $radio); } } return $html; }
/** * Displays a form to let the user choose an account to attach with the * given OpenID * * @param $openid String: OpenID url * @param $sreg Array: options get from OpenID * @param $messagekey String or null: message name to display at the top */ function chooseNameForm( $openid, $sreg, $ax, $messagekey = null ) { global $wgOut, $wgOpenIDAllowExistingAccountSelection, $wgAllowRealName, $wgUser; global $wgOpenIDProposeUsernameFromSREG, $wgOpenIDAllowAutomaticUsername, $wgOpenIDAllowNewAccountname; if ( $messagekey ) { $wgOut->addWikiMsg( $messagekey ); } $wgOut->addWikiMsg( 'openidchooseinstructions' ); $wgOut->addHTML( Xml::openElement( 'form', array( 'action' => $this->getTitle( 'ChooseName' )->getLocalUrl(), 'method' => 'POST' ) ) . "\n" . Xml::fieldset( wfMsg( 'openidchooselegend' ), false, array( 'id' => 'mw-openid-choosename' ) ) . "\n" . Xml::openElement( 'table' ) ); $def = false; if ( $wgOpenIDAllowExistingAccountSelection ) { # Let them attach it to an existing user # Grab the UserName in the cookie if it exists global $wgCookiePrefix; $name = ''; if ( isset( $_COOKIE["{$wgCookiePrefix}UserName"] ) ) { $name = trim( $_COOKIE["{$wgCookiePrefix}UserName"] ); } # show OpenID Attributes $oidAttributesToAccept = array( 'fullname', 'nickname', 'email', 'language' ); $oidAttributes = array(); foreach ( $oidAttributesToAccept as $oidAttr ) { if ( $oidAttr == 'fullname' && !$wgAllowRealName ) { continue; } if ( array_key_exists( $oidAttr, $sreg ) ) { $checkName = 'wpUpdateUserInfo' . $oidAttr; $oidAttributes[] = Xml::tags( 'li', array(), Xml::check( $checkName, false, array( 'id' => $checkName ) ) . Xml::tags( 'label', array( 'for' => $checkName ), wfMsgHtml( "openid$oidAttr" ) . wfMsgExt( 'colon-separator', array( 'escapenoentities' ) ) . Xml::tags( 'i', array(), $sreg[$oidAttr] ) ) ); } } $oidAttributesUpdate = ''; if ( count( $oidAttributes ) > 0 ) { $oidAttributesUpdate = "<br />\n" . wfMsgHtml( 'openidupdateuserinfo' ) . "\n" . Xml::tags( 'ul', array(), implode( "\n", $oidAttributes ) ); } $wgOut->addHTML( Xml::openElement( 'tr' ) . Xml::tags( 'td', array( 'class' => 'mw-label' ), Xml::radio( 'wpNameChoice', 'existing', !$def, array( 'id' => 'wpNameChoiceExisting' ) ) ) . "\n" . Xml::tags( 'td', array( 'class' => 'mw-input' ), Xml::label( wfMsg( 'openidchooseexisting' ), 'wpNameChoiceExisting' ) . "<br />\n" . wfMsgHtml( 'openidchooseusername' ) . "\n" . Xml::input( 'wpExistingName', 16, $name, array( 'id' => 'wpExistingName' ) ) . "\n" . wfMsgHtml( 'openidchoosepassword' ) . "\n" . Xml::password( 'wpExistingPassword' ) . "\n" . $oidAttributesUpdate . "\n" ) . "\n" . Xml::closeElement( 'tr' ) . "\n" ); $def = true; } // $wgOpenIDAllowExistingAccountSelection # These are only available if all visitors are allowed to create accounts if ( $wgUser->isAllowed( 'createaccount' ) && !$wgUser->isBlockedFromCreateAccount() ) { if ( $wgOpenIDProposeUsernameFromSREG ) { # These options won't exist if we can't get them. if ( array_key_exists( 'nickname', $sreg ) && $this->userNameOK( $sreg['nickname'] ) ) { $wgOut->addHTML( Xml::openElement( 'tr' ) . Xml::tags( 'td', array( 'class' => 'mw-label' ), Xml::radio( 'wpNameChoice', 'nick', !$def, array( 'id' => 'wpNameChoiceNick' ) ) ) . Xml::tags( 'td', array( 'class' => 'mw-input' ), Xml::label( wfMsg( 'openidchoosenick', $sreg['nickname'] ), 'wpNameChoiceNick' ) ) . Xml::closeElement( 'tr' ) . "\n" ); } # These options won't exist if we can't get them. $fullname = null; if ( array_key_exists( 'fullname', $sreg ) ) { $fullname = $sreg['fullname']; } if ( array_key_exists( 'http://axschema.org/namePerson/first', $ax ) || array_key_exists( 'http://axschema.org/namePerson/last', $ax ) ) { $fullname = $ax['http://axschema.org/namePerson/first'][0] . " " . $ax['http://axschema.org/namePerson/last'][0]; } if ( $fullname && $this->userNameOK( $fullname ) ) { $wgOut->addHTML( Xml::openElement( 'tr' ) . Xml::tags( 'td', array( 'class' => 'mw-label' ), Xml::radio( 'wpNameChoice', 'full', !$def, array( 'id' => 'wpNameChoiceFull' ) ) ) . Xml::tags( 'td', array( 'class' => 'mw-input' ), Xml::label( wfMsg( 'openidchoosefull', $fullname ), 'wpNameChoiceFull' ) ) . Xml::closeElement( 'tr' ) . "\n" ); $def = true; } $idname = $this->toUserName( $openid ); if ( $idname && $this->userNameOK( $idname ) ) { $wgOut->addHTML( Xml::openElement( 'tr' ) . Xml::tags( 'td', array( 'class' => 'mw-label' ), Xml::radio( 'wpNameChoice', 'url', !$def, array( 'id' => 'wpNameChoiceUrl' ) ) ) . Xml::tags( 'td', array( 'class' => 'mw-input' ), Xml::label( wfMsg( 'openidchooseurl', $idname ), 'wpNameChoiceUrl' ) ) . Xml::closeElement( 'tr' ) . "\n" ); $def = true; } } // if $wgOpenIDProposeUsernameFromSREG if ( $wgOpenIDAllowAutomaticUsername ) { $wgOut->addHTML( Xml::openElement( 'tr' ) . Xml::tags( 'td', array( 'class' => 'mw-label' ), Xml::radio( 'wpNameChoice', 'auto', !$def, array( 'id' => 'wpNameChoiceAuto' ) ) ) . Xml::tags( 'td', array( 'class' => 'mw-input' ), Xml::label( wfMsg( 'openidchooseauto', $this->automaticName( $sreg ) ), 'wpNameChoiceAuto' ) ) . Xml::closeElement( 'tr' ) . "\n" ); } if ( $wgOpenIDAllowNewAccountname ) { $wgOut->addHTML( Xml::openElement( 'tr' ) . Xml::tags( 'td', array( 'class' => 'mw-label' ), Xml::radio( 'wpNameChoice', 'manual', !$def, array( 'id' => 'wpNameChoiceManual' ) ) ) . Xml::tags( 'td', array( 'class' => 'mw-input' ), Xml::label( wfMsg( 'openidchoosemanual' ), 'wpNameChoiceManual' ) . ' ' . Xml::input( 'wpNameValue', 16, false, array( 'id' => 'wpNameValue' ) ) ) . Xml::closeElement( 'tr' ) . "\n" ); } } // These are only available if all visitors are allowed to create accounts # These are always available $wgOut->addHTML( Xml::openElement( 'tr' ) . "\n" . Xml::element( 'td', array(), '' ) . "\n" . Xml::tags( 'td', array( 'class' => 'mw-submit' ), Xml::submitButton( wfMsg( 'userlogin' ), array( 'name' => 'wpOK' ) ) . Xml::submitButton( wfMsg( 'cancel' ), array( 'name' => 'wpCancel' ) ) ) . "\n" . Xml::closeElement( 'tr' ) . "\n" . Xml::closeElement( 'table' ) . Xml::closeElement( 'fieldset' ) . Xml::closeElement( 'form' ) ); }
/** * Build a radio button that switches the log type when you click it */ private function getLogSwitcher($type, $id, $message, $fullUrl) { $htmlOut = ''; $htmlOut .= Xml::radio('log_type', $id, $this->logType == $type ? true : false, array('onclick' => "switchLogs( '" . $fullUrl . "', '" . $type . "' )")); $htmlOut .= Xml::label(wfMsg($message), $id); return $htmlOut; }
function formatRevisionRow($row) { $rev = new Revision($row); $stxt = ''; $last = $this->msg('last')->escaped(); $ts = wfTimestamp(TS_MW, $row->rev_timestamp); $checkBox = Xml::radio('mergepoint', $ts, $this->mTimestamp === $ts); $user = $this->getUser(); $pageLink = Linker::linkKnown($rev->getTitle(), htmlspecialchars($this->getLanguage()->userTimeAndDate($ts, $user)), [], ['oldid' => $rev->getId()]); if ($rev->isDeleted(Revision::DELETED_TEXT)) { $pageLink = '<span class="history-deleted">' . $pageLink . '</span>'; } # Last link if (!$rev->userCan(Revision::DELETED_TEXT, $user)) { $last = $this->msg('last')->escaped(); } elseif (isset($this->prevId[$row->rev_id])) { $last = Linker::linkKnown($rev->getTitle(), $this->msg('last')->escaped(), [], ['diff' => $row->rev_id, 'oldid' => $this->prevId[$row->rev_id]]); } $userLink = Linker::revUserTools($rev); $size = $row->rev_len; if (!is_null($size)) { $stxt = Linker::formatRevisionSize($size); } $comment = Linker::revComment($rev); return Html::rawElement('li', [], $this->msg('mergehistory-revisionrow')->rawParams($checkBox, $last, $pageLink, $userLink, $stxt, $comment)->escaped()); }
/** * @return string HTML */ protected function buildCheckBoxes() { $html = '<table>'; // If there is just one item, use checkboxes $list = $this->getList(); if ($list->length() == 1) { $list->reset(); $bitfield = $list->current()->getBits(); // existing field if ($this->submitClicked) { $bitfield = RevisionDeleter::extractBitfield($this->extractBitParams(), $bitfield); } foreach ($this->checks as $item) { // Messages: revdelete-hide-text, revdelete-hide-image, revdelete-hide-name, // revdelete-hide-comment, revdelete-hide-user, revdelete-hide-restricted list($message, $name, $field) = $item; $innerHTML = Xml::checkLabel($this->msg($message)->text(), $name, $name, $bitfield & $field); if ($field == Revision::DELETED_RESTRICTED) { $innerHTML = "<b>{$innerHTML}</b>"; } $line = Xml::tags('td', array('class' => 'mw-input'), $innerHTML); $html .= "<tr>{$line}</tr>\n"; } } else { // Otherwise, use tri-state radios $html .= '<tr>'; $html .= '<th class="mw-revdel-checkbox">' . $this->msg('revdelete-radio-same')->escaped() . '</th>'; $html .= '<th class="mw-revdel-checkbox">' . $this->msg('revdelete-radio-unset')->escaped() . '</th>'; $html .= '<th class="mw-revdel-checkbox">' . $this->msg('revdelete-radio-set')->escaped() . '</th>'; $html .= "<th></th></tr>\n"; foreach ($this->checks as $item) { // Messages: revdelete-hide-text, revdelete-hide-image, revdelete-hide-name, // revdelete-hide-comment, revdelete-hide-user, revdelete-hide-restricted list($message, $name, $field) = $item; // If there are several items, use third state by default... if ($this->submitClicked) { $selected = $this->getRequest()->getInt($name, 0); } else { $selected = -1; // use existing field } $line = '<td class="mw-revdel-checkbox">' . Xml::radio($name, -1, $selected == -1) . '</td>'; $line .= '<td class="mw-revdel-checkbox">' . Xml::radio($name, 0, $selected == 0) . '</td>'; $line .= '<td class="mw-revdel-checkbox">' . Xml::radio($name, 1, $selected == 1) . '</td>'; $label = $this->msg($message)->escaped(); if ($field == Revision::DELETED_RESTRICTED) { $label = "<b>{$label}</b>"; } $line .= "<td>{$label}</td>"; $html .= "<tr>{$line}</tr>\n"; } } $html .= '</table>'; return $html; }
/** * @param $msg string */ protected function showAccountConfirmForm($msg = '') { global $wgAccountRequestTypes; $out = $this->getOutput(); $reqUser = $this->getUser(); $titleObj = $this->getFullTitle(); $accountReq = $this->accountReq; // convenience if (!$accountReq || $accountReq->isDeleted() && !$this->showRejects) { $out->addHTML($this->msg('confirmaccount-badid')->escaped()); $out->returnToMain(true, $titleObj); return; } # Output any failure message if ($msg != '') { $out->addHTML('<div class="errorbox">' . $msg . '</div><div class="visualClear"></div>'); } $out->addWikiMsg('confirmaccount-text'); $rejectTimestamp = $accountReq->getRejectTimestamp(); $heldTimestamp = $accountReq->getHeldTimestamp(); $reason = strlen($accountReq->getHandlingComment()) ? htmlspecialchars($accountReq->getHandlingComment()) : $this->msg('confirmaccount-noreason')->escaped(); $adminId = $accountReq->getHandlingUser(); if ($rejectTimestamp) { $datim = $this->getLanguage()->timeanddate($rejectTimestamp, true); $date = $this->getLanguage()->date($rejectTimestamp, true); $time = $this->getLanguage()->time($rejectTimestamp, true); # Auto-rejected requests have a user ID of zero if ($adminId) { $out->addHTML('<p><b>' . $this->msg('confirmaccount-reject', User::whoIs($adminId), $datim, $date, $time)->parse() . '</b></p>'); $out->addHTML('<p><strong>' . $this->msg('confirmaccount-rational')->escaped() . '</strong><i> ' . $reason . '</i></p>'); } else { $out->addHTML("<p><i> {$reason} </i></p>"); } } elseif ($heldTimestamp) { $datim = $this->getLanguage()->timeanddate($heldTimestamp, true); $date = $this->getLanguage()->date($heldTimestamp, true); $time = $this->getLanguage()->time($heldTimestamp, true); $out->addHTML('<p><b>' . $this->msg('confirmaccount-held', User::whoIs($adminId), $datim, $date, $time)->parse() . '</b></p>'); $out->addHTML('<p><strong>' . $this->msg('confirmaccount-rational')->escaped() . '</strong><i> ' . $reason . '</i></p>'); } $form = Xml::openElement('form', array('method' => 'post', 'name' => 'accountconfirm', 'action' => $titleObj->getLocalUrl())); $form .= "<fieldset>"; $form .= '<legend>' . $this->msg('confirmaccount-leg-user')->escaped() . '</legend>'; $form .= '<table cellpadding=\'4\'>'; $form .= "<tr><td>" . Xml::label($this->msg('username')->text(), 'wpNewName') . "</td>"; $form .= "<td>" . Xml::input('wpNewName', 30, $this->reqUsername, array('id' => 'wpNewName')) . "</td></tr>\n"; $econf = ''; if ($accountReq->getEmailAuthTimestamp()) { $econf = ' <strong>' . $this->msg('confirmaccount-econf')->escaped() . '</strong>'; } $form .= "<tr><td>" . $this->msg('confirmaccount-email')->escaped() . "</td>"; $form .= "<td>" . htmlspecialchars($accountReq->getEmail()) . $econf . "</td></tr>\n"; if (count($wgAccountRequestTypes) > 1) { $options = array(); $form .= "<tr><td><strong>" . $this->msg('confirmaccount-reqtype')->escaped() . "</strong></td><td>"; foreach ($wgAccountRequestTypes as $i => $params) { // Give grep a chance to find the usages: confirmaccount-pos-0, confirmaccount-pos-1 $options[] = Xml::option($this->msg("confirmaccount-pos-{$i}")->text(), $i, $i == $this->reqType); } $form .= Xml::openElement('select', array('name' => "wpType")); $form .= implode("\n", $options); $form .= Xml::closeElement('select') . "\n"; $form .= "</td></tr>\n"; } $form .= '</table></fieldset>'; $userAreas = ConfirmAccount::getUserAreaConfig(); if ($this->hasItem('AreasOfInterest') && count($userAreas) > 0) { $form .= '<fieldset>'; $form .= '<legend>' . $this->msg('confirmaccount-leg-areas')->escaped() . '</legend>'; $form .= "<div style='height:150px; overflow:scroll; background-color:#f9f9f9;'>"; $form .= "<table cellspacing='5' cellpadding='0' style='background-color:#f9f9f9;'><tr valign='top'>"; $count = 0; foreach ($userAreas as $name => $conf) { $count++; if ($count > 5) { $form .= "</tr><tr valign='top'>"; $count = 1; } $formName = "wpArea-" . htmlspecialchars(str_replace(' ', '_', $name)); if ($conf['project'] != '') { $pg = Linker::linkKnown(Title::newFromText($conf['project']), $this->msg('requestaccount-info')->escaped()); } else { $pg = ''; } $form .= "<td>" . Xml::checkLabel($name, $formName, $formName, $this->reqAreas[$name] > 0) . " {$pg}</td>\n"; } $form .= "</tr></table></div>"; $form .= '</fieldset>'; } if ($this->hasItem('Biography') || $this->hasItem('RealName')) { $form .= '<fieldset>'; $form .= '<legend>' . $this->msg('confirmaccount-leg-person')->escaped() . '</legend>'; if ($this->hasItem('RealName')) { $form .= '<table cellpadding=\'4\'>'; $form .= "<tr><td>" . $this->msg('confirmaccount-real')->escaped() . "</td>"; $form .= "<td>" . htmlspecialchars($accountReq->getRealName()) . "</td></tr>\n"; $form .= '</table>'; } if ($this->hasItem('Biography')) { $form .= "<p>" . $this->msg('confirmaccount-bio')->escaped() . "\n"; $form .= "<textarea tabindex='1' name='wpNewBio' id='wpNewBio' rows='12' cols='80' style='width:100%; background-color:#f9f9f9;'>" . htmlspecialchars($this->reqBio) . "</textarea></p>\n"; } $form .= '</fieldset>'; } if ($this->hasItem('CV') || $this->hasItem('Notes') || $this->hasItem('Links')) { $form .= '<fieldset>'; $form .= '<legend>' . $this->msg('confirmaccount-leg-other')->escaped() . '</legend>'; if ($this->hasItem('CV')) { $form .= '<p>' . $this->msg('confirmaccount-attach')->escaped() . ' '; if ($accountReq->getFileName() !== null) { $form .= Linker::makeKnownLinkObj($titleObj, htmlspecialchars($accountReq->getFileName()), 'file=' . $accountReq->getFileStorageKey()); } else { $form .= $this->msg('confirmaccount-none-p')->escaped(); } } if ($this->hasItem('Notes')) { $form .= "</p><p>" . $this->msg('confirmaccount-notes')->escaped() . "\n"; $form .= "<textarea tabindex='1' readonly='readonly' name='wpNotes' id='wpNotes' rows='3' cols='80' style='width:100%'>" . htmlspecialchars($accountReq->getNotes()) . "</textarea></p>\n"; } if ($this->hasItem('Links')) { $form .= "<p>" . $this->msg('confirmaccount-urls')->escaped() . "</p>\n"; $form .= self::parseLinks($accountReq->getUrls()); } $form .= '</fieldset>'; } if ($reqUser->isAllowed('requestips')) { $blokip = SpecialPage::getTitleFor('Block'); $link = Linker::makeKnownLinkObj($blokip, $this->msg('confirmaccount-blockip')->escaped(), 'ip=' . $accountReq->getIP() . '&wpCreateAccount=1'); $form .= '<fieldset>'; $form .= '<legend>' . $this->msg('confirmaccount-leg-ip')->escaped() . '</legend>'; $wordSeparator = $this->msg('word-separator')->plain(); $form .= "<p>"; // @todo FIXME: Bad i18n. Should probably be something like // "confirmaccount-ip $1 ($2)" to get rid of this mess. $form .= $this->msg('confirmaccount-ip')->escaped(); $form .= $wordSeparator; $form .= htmlspecialchars($accountReq->getIP()); $form .= $wordSeparator; $form .= $this->msg('parentheses')->rawParams($link)->escaped(); $form .= "</p>\n"; if ($accountReq->getXFF()) { $form .= "<p>" . $this->msg('confirmaccount-xff')->escaped() . $wordSeparator . htmlspecialchars($accountReq->getXFF()) . "</p>\n"; } if ($accountReq->getAgent()) { $form .= "<p>" . $this->msg('confirmaccount-agent')->escaped() . $wordSeparator . htmlspecialchars($accountReq->getAgent()) . "</p>\n"; } $form .= '</fieldset>'; } $form .= '<fieldset>'; $form .= '<legend>' . $this->msg('confirmaccount-legend')->escaped() . '</legend>'; $form .= "<strong>" . $this->msg('confirmaccount-confirm')->parse() . "</strong>\n"; $form .= "<table cellpadding='5'><tr>"; $form .= "<td>" . Xml::radio('wpSubmitType', 'accept', $this->submitType == 'accept', array('id' => 'submitCreate', 'onclick' => 'document.getElementById("wpComment").style.display="block"')); $form .= ' ' . Xml::label($this->msg('confirmaccount-create')->text(), 'submitCreate') . "</td>\n"; $form .= "<td>" . Xml::radio('wpSubmitType', 'reject', $this->submitType == 'reject', array('id' => 'submitDeny', 'onclick' => 'document.getElementById("wpComment").style.display="block"')); $form .= ' ' . Xml::label($this->msg('confirmaccount-deny')->text(), 'submitDeny') . "</td>\n"; $form .= "<td>" . Xml::radio('wpSubmitType', 'hold', $this->submitType == 'hold', array('id' => 'submitHold', 'onclick' => 'document.getElementById("wpComment").style.display="block"')); $form .= ' ' . Xml::label($this->msg('confirmaccount-hold')->text(), 'submitHold') . "</td>\n"; $form .= "<td>" . Xml::radio('wpSubmitType', 'spam', $this->submitType == 'spam', array('id' => 'submitSpam', 'onclick' => 'document.getElementById("wpComment").style.display="none"')); $form .= ' ' . Xml::label($this->msg('confirmaccount-spam')->text(), 'submitSpam') . "</td>\n"; $form .= "</tr></table>"; $form .= "<div id='wpComment'><p>" . $this->msg('confirmaccount-reason')->escaped() . "</p>\n"; $form .= "<p><textarea name='wpReason' id='wpReason' rows='3' cols='80' style='width:80%; display=block;'>" . htmlspecialchars($this->reason) . "</textarea></p></div>\n"; $form .= "<p>" . Xml::submitButton($this->msg('confirmaccount-submit')->text()) . "</p>\n"; $form .= '</fieldset>'; $form .= Html::Hidden('title', $titleObj->getPrefixedDBKey()) . "\n"; $form .= Html::Hidden('action', 'reject'); $form .= Html::Hidden('acrid', $accountReq->getId()); $form .= Html::Hidden('wpShowRejects', $this->showRejects); $form .= Html::Hidden('wpEditToken', $reqUser->getEditToken($accountReq->getId())) . "\n"; $form .= Xml::closeElement('form'); $out->addHTML($form); global $wgMemc; # Set a key to who is looking at this request. # Have it expire in 10 minutes... $key = wfMemcKey('acctrequest', 'view', $accountReq->getId()); $wgMemc->set($key, $reqUser->getID(), 60 * 10); }
/** * Get a set of labelled radio buttons. * * @param $params Array * Parameters are: * var: The variable to be configured (required) * label: The message name for the label (required) * itemLabelPrefix: The message name prefix for the item labels (required) * values: List of allowed values (required) * itemAttribs Array of attribute arrays, outer key is the value name (optional) * commonAttribs Attribute array applied to all items * controlName: The name for the input element (optional) * value: The current value of the variable (optional) * help: The html for the help text (optional) * * @return string */ public function getRadioSet($params) { if (!isset($params['controlName'])) { $params['controlName'] = 'config_' . $params['var']; } if (!isset($params['value'])) { $params['value'] = $this->getVar($params['var']); } if (!isset($params['label'])) { $label = ''; } else { $label = $params['label']; } if (!isset($params['help'])) { $params['help'] = ""; } $s = "<ul>\n"; foreach ($params['values'] as $value) { $itemAttribs = array(); if (isset($params['commonAttribs'])) { $itemAttribs = $params['commonAttribs']; } if (isset($params['itemAttribs'][$value])) { $itemAttribs = $params['itemAttribs'][$value] + $itemAttribs; } $checked = $value == $params['value']; $id = $params['controlName'] . '_' . $value; $itemAttribs['id'] = $id; $itemAttribs['tabindex'] = $this->nextTabIndex(); $s .= '<li>' . Xml::radio($params['controlName'], $value, $checked, $itemAttribs) . ' ' . Xml::tags('label', array('for' => $id), $this->parse(wfMessage($params['itemLabelPrefix'] . strtolower($value))->plain())) . "</li>\n"; } $s .= "</ul>\n"; return $this->label($label, $params['controlName'], $s, $params['help']); }
public static function getHTML($cur_value, $input_name, $is_mandatory, $is_disabled, $other_args) { global $sfgTabIndex, $sfgFieldNum, $sfgShowOnSelect; // Standardize $cur_value if (is_null($cur_value)) { $cur_value = ''; } if (($possible_values = $other_args['possible_values']) == null) { // If it's a Boolean property, display 'Yes' and 'No' // as the values. if (array_key_exists('property_type', $other_args) && $other_args['property_type'] == '_boo') { $possible_values = array(SFUtils::getWordForYesOrNo(true), SFUtils::getWordForYesOrNo(false)); } else { $possible_values = array(); } } // Add a "None" value at the beginning, unless this is a // mandatory field and there's a current value in place (either // through a default value or because we're editing an existing // page). if (!$is_mandatory || $cur_value === '') { array_unshift($possible_values, ''); } // Set $cur_value to be one of the allowed options, if it isn't // already - that makes it easier to automatically have one of // the radiobuttons be checked at the beginning. if (!in_array($cur_value, $possible_values)) { if (in_array('', $possible_values)) { $cur_value = ''; } elseif (count($possible_values) == 0) { $cur_value = ''; } else { $cur_value = $possible_values[0]; } } $text = "\n"; $itemClass = 'radioButtonItem'; if (array_key_exists('class', $other_args)) { $itemClass .= ' ' . $other_args['class']; } $itemAttrs = array('class' => $itemClass); foreach ($possible_values as $possible_value) { $sfgTabIndex++; $sfgFieldNum++; $input_id = "input_{$sfgFieldNum}"; $radiobutton_attrs = array('id' => $input_id, 'tabindex' => $sfgTabIndex); $isChecked = false; if ($cur_value == $possible_value) { $isChecked = true; //$radiobutton_attrs['checked'] = true; } if ($is_disabled) { $radiobutton_attrs['disabled'] = true; } if ($possible_value === '') { // blank/"None" value $label = wfMessage('sf_formedit_none')->text(); } elseif (array_key_exists('value_labels', $other_args) && is_array($other_args['value_labels']) && array_key_exists($possible_value, $other_args['value_labels'])) { $label = htmlspecialchars($other_args['value_labels'][$possible_value]); } else { $label = $possible_value; } $text .= "\t" . Html::rawElement('label', $itemAttrs, Xml::radio($input_name, $possible_value, $isChecked, $radiobutton_attrs) . " {$label}") . "\n"; } $spanClass = 'radioButtonSpan'; if (array_key_exists('class', $other_args)) { $spanClass .= ' ' . $other_args['class']; } if ($is_mandatory) { $spanClass .= ' mandatoryFieldSpan'; } $spanID = "span_{$sfgFieldNum}"; // Do the 'show on select' handling. if (array_key_exists('show on select', $other_args)) { $spanClass .= ' sfShowIfChecked'; foreach ($other_args['show on select'] as $div_id => $options) { if (array_key_exists($spanID, $sfgShowOnSelect)) { $sfgShowOnSelect[$spanID][] = array($options, $div_id); } else { $sfgShowOnSelect[$spanID] = array(array($options, $div_id)); } } } $spanAttrs = array('id' => $spanID, 'class' => $spanClass); $text = Html::rawElement('span', $spanAttrs, $text); return $text; }
/** * Constructs a table row with label and radio input in two columns. * @param string $name Option name. * @param FormOptions $opts * @param string[] $alts List of alternatives. * @return string Html. */ protected function eRadio($name, FormOptions $opts, array $alts) { // Give grep a chance to find the usages: // translate-statsf-scale, translate-statsf-count $label = 'translate-statsf-' . $name; $label = $this->msg($label)->escaped(); $s = '<tr><td>' . $label . '</td><td>'; $options = array(); foreach ($alts as $alt) { $id = "{$name}-{$alt}"; $radio = Xml::radio($name, $alt, $alt === $opts[$name], array('id' => $id)) . ' '; $options[] = $radio . ' ' . $this->eLabel($id); } $s .= implode(' ', $options); $s .= '</td></tr>' . "\n"; return $s; }
protected function generateBillingFields() { global $wgScriptPath; $scriptPath = "{$wgScriptPath}/extensions/DonationInterface/gateway_forms/includes"; $form = ''; /* $form .= '<tr>'; $form .= '<td style="text-align:center;" colspan="2"><big><b>' . wfMsg( 'donate_interface-paypal-button' ) . '</b></big><br/><a href="#" onclick="document.payment.PaypalRedirect.value=1;document.payment.submit();"><img src="' . $scriptPath . '/paypal.png"/></a></td>'; $form .= '</tr>'; */ // amount $otherChecked = false; $amount = -1; if ($this->getEscapedValue('amount') != 250 && $this->getEscapedValue('amount') != 150 && $this->getEscapedValue('amount') != 100 && $this->getEscapedValue('amount') != 75 && $this->getEscapedValue('amount') != 50 && $this->getEscapedValue('amount') != 35 && $this->getEscapedValue('amount') != 20 && $this->getEscapedValue('amountOther') > 0) { $otherChecked = true; $amount = $this->getEscapedValue('amountOther'); } $form .= '<tr>'; $form .= '<td colspan="2"><span class="creditcard-error-msg">' . $this->form_errors['amount'] . '</span></td>'; $form .= '</tr>'; $form .= '<tr>'; $form .= '<td class="label"><div style="padding-top:4px;">' . Xml::label(wfMsg('donate_interface-donor-amount'), 'amount') . '</div></td>'; $form .= '<td>' . '<table cellspacing="3" cellpadding="0" border="0" style="margin-bottom:0.2em;"><tr>' . '<td>' . Xml::radio('amount', 20, $this->getEscapedValue('amount') == 20, array('onfocus' => 'clearField2( document.getElementById(\'amountOther\'), "Other" )')) . '$20 ' . '</td>' . '<td>' . Xml::radio('amount', 35, $this->getEscapedValue('amount') == 35, array('onfocus' => 'clearField2( document.getElementById(\'amountOther\'), "Other" )')) . '$35 ' . '</td>' . '<td>' . Xml::radio('amount', 50, $this->getEscapedValue('amount') == 50, array('onfocus' => 'clearField2( document.getElementById(\'amountOther\'), "Other" )')) . '$50 ' . '</td>' . '<td>' . Xml::radio('amount', 75, $this->getEscapedValue('amount') == 75, array('onfocus' => 'clearField2( document.getElementById(\'amountOther\'), "Other" )')) . '$75 ' . '</td>' . '</tr><tr>' . '<td>' . Xml::radio('amount', 100, $this->getEscapedValue('amount') == 100, array('onfocus' => 'clearField2( document.getElementById(\'amountOther\'), "Other" )')) . '$100 ' . '</td>' . '<td>' . Xml::radio('amount', 150, $this->getEscapedValue('amount') == 150, array('onfocus' => 'clearField2( document.getElementById(\'amountOther\'), "Other" )')) . '$150 ' . '</td>' . '<td>' . Xml::radio('amount', 250, $this->getEscapedValue('amount') == 250, array('onfocus' => 'clearField2( document.getElementById(\'amountOther\'), "Other" )')) . '$250 ' . '</td>' . '<td>' . Xml::radio('amount', $amount, $otherChecked, array('id' => 'otherRadio')) . Xml::input('amountOther', '7', $this->getEscapedValue('amountOther'), array('type' => 'text', 'onfocus' => 'clearField(this, "Other");document.getElementById("otherRadio").checked=true;', 'maxlength' => '10', 'onblur' => 'document.getElementById("otherRadio").value = this.value;', 'id' => 'amountOther')) . Html::hidden('currency_code', 'USD') . '</td>' . '</tr></table>' . '</td>'; $form .= '</tr>'; // Payment type $form .= '<tr>'; $form .= '<td class="label""><div style="padding-top:9px;">' . wfMsg('donate_interface-payment-type') . '</div></td>'; $form .= '<td>' . '<p style="border: 1px solid rgb(187, 187, 187); float: left; -moz-border-radius: 5px 5px 5px 5px; margin: 0 8px 0 0; padding: 5px 5px 5px 3px; white-space: nowrap;">' . Xml::radio('card_type', 'cc1', $this->getEscapedValue('card_type') == 'cc1', array('id' => 'cc1radio', 'onclick' => 'switchToCreditCard()')) . '<label for="cc1radio">' . Xml::element('img', array('src' => $wgScriptPath . "/extensions/DonationInterface/gateway_forms/includes/card-visa.png")) . '</label>' . ' <label for="cc1radio">' . Xml::element('img', array('src' => $wgScriptPath . "/extensions/DonationInterface/gateway_forms/includes/card-mastercard.png")) . '</label>' . ' <label for="cc1radio">' . Xml::element('img', array('src' => $wgScriptPath . "/extensions/DonationInterface/gateway_forms/includes/card-amex.png")) . '</label>' . ' <label for="cc1radio">' . Xml::element('img', array('src' => $wgScriptPath . "/extensions/DonationInterface/gateway_forms/includes/card-discover.png")) . '</label>' . '</p>' . '<p style="border: 1px solid transparent; float: left; -moz-border-radius: 5px 5px 5px 5px; margin: 0; padding: 5px 5px 5px 3px; white-space: nowrap;">' . Xml::radio('card_type', 'pp', $this->getEscapedValue('card_type') == 'pp', array('id' => 'ppradio', 'onclick' => 'switchToPayPal()')) . '<label for="ppradio">' . Xml::element('img', array('src' => $wgScriptPath . "/extensions/DonationInterface/gateway_forms/includes/card-paypal.png")) . '</label>' . '</p>' . '</td>'; $form .= '</tr>'; $form .= '</table>'; if ($this->getEscapedValue('card_type') == 'cc1' || $this->getEscapedValue('card_type') == 'cc2' || $this->getEscapedValue('card_type') == 'cc3' || $this->getEscapedValue('card_type') == 'cc4') { $form .= Xml::openElement('table', array('id' => 'payflow-table-cc')); } else { $form .= Xml::openElement('table', array('id' => 'payflow-table-cc', 'style' => 'display: none;')); } $form .= '<tr>'; $form .= '<td colspan="2"><h3 class="cc_header">' . wfMsg('donate_interface-cc-form-header-personal') . Xml::element('img', array('src' => $wgScriptPath . "/extensions/DonationInterface/gateway_forms/includes/padlock.gif", 'style' => 'vertical-align:baseline;margin-left:8px;')) . '</h3></td>'; $form .= '</tr>'; // card number $form .= $this->getCardNumberField(); // expiry $form .= '<tr>'; $form .= '<td class="label">' . Xml::label(wfMsg('donate_interface-donor-expiration'), 'expiration') . '</td>'; $form .= '<td>' . $this->generateExpiryMonthDropdown() . ' / ' . $this->generateExpiryYearDropdown() . '</td>'; $form .= '</tr>'; // cvv $form .= $this->getCvvField(); // name $form .= '<tr>'; $form .= '<td colspan=2><span class="creditcard-error-msg">' . $this->form_errors['fname'] . '</span></td>'; $form .= '</tr>'; $form .= '<tr>'; $form .= '<td colspan=2><span class="creditcard-error-msg">' . $this->form_errors['lname'] . '</span></td>'; $form .= '</tr>'; $form .= '<tr>'; $form .= '<td class="label">' . Xml::label(wfMsg('donate_interface-name-on-card'), 'fname') . '</td>'; $form .= '<td>' . Xml::input('fname', '30', $this->getEscapedValue('fname'), array('type' => 'text', 'onfocus' => 'clearField( this, \'' . wfMsg('donate_interface-donor-fname') . '\' )', 'maxlength' => '25', 'class' => 'required', 'id' => 'fname')) . Xml::input('lname', '30', $this->getEscapedValue('lname'), array('type' => 'text', 'onfocus' => 'clearField( this, \'' . wfMsg('donate_interface-donor-lname') . '\' )', 'maxlength' => '25', 'id' => 'lname')) . '</td>'; $form .= "</tr>"; // street $form .= '<tr>'; $form .= '<td colspan=2><span class="creditcard-error-msg">' . $this->form_errors['street'] . '</span></td>'; $form .= '</tr>'; $form .= '<tr>'; $form .= '<td class="label">' . Xml::label(wfMsg('donate_interface-billing-address'), 'street') . '</td>'; $form .= '<td>' . Xml::input('street', '30', $this->getEscapedValue('street'), array('type' => 'text', 'onfocus' => 'clearField( this, \'' . wfMsg('donate_interface-donor-street') . '\' )', 'maxlength' => '100', 'id' => 'street', 'class' => 'fullwidth')) . '</td>'; $form .= '</tr>'; // city $form .= '<tr>'; $form .= '<td colspan=2><span class="creditcard-error-msg">' . $this->form_errors['city'] . '</span></td>'; $form .= '</tr>'; $form .= '<tr>'; $form .= '<td class="label"> </td>'; $form .= '<td>' . Xml::input('city', '18', $this->getEscapedValue('city'), array('type' => 'text', 'onfocus' => 'clearField( this, \'' . wfMsg('donate_interface-donor-city') . '\' )', 'maxlength' => '40', 'id' => 'city')) . ' ' . $this->generateStateDropdown() . ' ' . Xml::input('zip', '5', $this->getEscapedValue('zip'), array('type' => 'text', 'onfocus' => 'clearField( this, \'' . wfMsg('donate_interface-zip-code') . '\' )', 'maxlength' => '10', 'id' => 'zip')) . Html::hidden('country', 'US') . '</td>'; $form .= '</tr>'; // country /* $form .= '<tr>'; $form .= '<td colspan=2><span class="creditcard-error-msg">' . $this->form_errors['country'] . '</span></td>'; $form .= '</tr>'; $form .= '<tr>'; $form .= '<td class="label"> </td>'; $form .= '<td>' . $this->generateCountryDropdown() . '</td>'; $form .= '</tr>'; */ // email $form .= '<tr>'; $form .= '<td colspan=2><span class="creditcard-error-msg">' . $this->form_errors['emailAdd'] . '</span></td>'; $form .= '</tr>'; $form .= '<tr>'; $form .= '<td class="label">' . Xml::label(wfMsg('donate_interface-email-receipt'), 'emailAdd') . '</td>'; $form .= '<td>' . Xml::input('emailAdd', '30', $this->getEscapedValue('email'), array('type' => 'text', 'onfocus' => 'clearField( this, \'' . wfMsg('donate_interface-donor-email') . '\' )', 'maxlength' => '64', 'id' => 'emailAdd', 'class' => 'fullwidth')) . Html::hidden('email-opt', 1) . '</td>'; $form .= '</tr>'; return $form; }
public function vote($vid) { global $wgOut, $wgUser; $wgOut->setPagetitle(wfMsg('poll-title-vote')); if (!$wgUser->isAllowed('poll-vote')) { $wgOut->addWikiMsg('poll-vote-right-error'); $wgOut->addHtml('<a href="' . $this->getTitle()->getFullURL('action=list') . '">' . wfMsg('poll-back') . '</a>'); } else { $dbr = wfGetDB(DB_SLAVE); $query = $dbr->select('poll', 'question, alternative_1, alternative_2, alternative_3, alternative_4, alternative_5, alternative_6, creater, multi', array('id' => $vid)); while ($row = $dbr->fetchObject($query)) { $question = htmlentities($row->question, ENT_QUOTES, 'UTF-8'); $alternative_1 = htmlentities($row->alternative_1, ENT_QUOTES, 'UTF-8'); $alternative_2 = htmlentities($row->alternative_2, ENT_QUOTES, 'UTF-8'); $alternative_3 = htmlentities($row->alternative_3, ENT_QUOTES, 'UTF-8'); $alternative_4 = htmlentities($row->alternative_4, ENT_QUOTES, 'UTF-8'); $alternative_5 = htmlentities($row->alternative_5, ENT_QUOTES, 'UTF-8'); $alternative_6 = htmlentities($row->alternative_6, ENT_QUOTES, 'UTF-8'); $creater = htmlentities($row->creater, ENT_QUOTES, 'UTF-8'); $multi = $row->multi; } if (!isset($question) or $question == "") { $wgOut->addWikiMsg('poll-invalid-id'); $wgOut->addHtml('<a href="' . $this->getTitle()->getFullURL('action=list') . '">' . wfMsg('poll-back') . '</a>'); return; } $wgOut->addHtml(Xml::openElement('form', array('method' => 'post', 'action' => $this->getTitle()->getFullURL('action=submit&id=' . $vid)))); $wgOut->addHtml(Xml::openElement('table')); $wgOut->addHtml('<tr><th>' . $question . '</th></tr>'); if ($multi != 1) { $wgOut->addHtml('<tr><td>' . Xml::radio('vote', '1') . ' ' . $alternative_1 . '</td></tr>'); $wgOut->addHtml('<tr><td>' . Xml::radio('vote', '2') . ' ' . $alternative_2 . '</td></tr>'); if ($alternative_3 != "") { $wgOut->addHtml('<tr><td>' . Xml::radio('vote', '3') . ' ' . $alternative_3 . '</td></tr>'); } if ($alternative_4 != "") { $wgOut->addHtml('<tr><td>' . Xml::radio('vote', '4') . ' ' . $alternative_4 . '</td></tr>'); } if ($alternative_5 != "") { $wgOut->addHtml('<tr><td>' . Xml::radio('vote', '5') . ' ' . $alternative_5 . '</td></tr>'); } if ($alternative_6 != "") { $wgOut->addHtml('<tr><td>' . Xml::radio('vote', '6') . ' ' . $alternative_6 . '</td></tr>'); } $wgOut->addHtml('<tr><td>' . wfMsg('poll-vote-other') . ' ' . Xml::input('vote_other') . '</td></tr>'); } if ($multi == 1) { $wgOut->addHtml('<tr><td>' . Xml::check('vote_1') . ' ' . $alternative_1 . '</td></tr>'); $wgOut->addHtml('<tr><td>' . Xml::check('vote_2') . ' ' . $alternative_2 . '</td></tr>'); if ($alternative_3 != "") { $wgOut->addHtml('<tr><td>' . Xml::check('vote_3') . ' ' . $alternative_3 . '</td></tr>'); } if ($alternative_4 != "") { $wgOut->addHtml('<tr><td>' . Xml::check('vote_4') . ' ' . $alternative_4 . '</td></tr>'); } if ($alternative_5 != "") { $wgOut->addHtml('<tr><td>' . Xml::check('vote_5') . ' ' . $alternative_5 . '</td></tr>'); } if ($alternative_6 != "") { $wgOut->addHtml('<tr><td>' . Xml::check('vote_6') . ' ' . $alternative_6 . '</td></tr>'); } $wgOut->addHtml('<tr><td>' . wfMsg('poll-vote-other') . ' ' . Xml::input('vote_other') . '</td></tr>'); } $wgOut->addHtml('<tr><td>' . Xml::submitButton(wfMsg('poll-submit')) . '' . Html::Hidden('type', 'vote') . '' . Html::Hidden('multi', $multi) . ' <a href="' . $this->getTitle()->getFullURL('action=score&id=' . $vid) . '">' . wfMsg('poll-title-score') . '</a></td></tr>'); $wgOut->addHtml('<tr><td>'); $wgOut->addWikiText('<small>' . wfMsg('poll-score-created', $creater) . '</small>'); $wgOut->addHtml('</td></tr>'); $wgOut->addHtml(Xml::closeElement('table')); if ($wgUser->isAllowed('poll-admin') || $creater == $wgUser->getName()) { $wgOut->addHtml(wfMsg('poll-administration') . ' <a href="' . $this->getTitle()->getFullURL('action=change&id=' . $vid) . '">' . wfMsg('poll-change') . '</a> · <a href="' . $this->getTitle()->getFullURL('action=delete&id=' . $vid) . '">' . wfMsg('poll-delete') . '</a>'); } $wgOut->addHtml(Xml::closeElement('form')); } }
<form method="get" action="<?php echo $action; ?> "> <div style="padding:3px"><?php echo wfMsgExt('tagsreportpagesfound', 'parsemag', !is_array($tagList) ? 0 : array_sum($tagList)); ?> </div> <?php if (!empty($tagList)) { foreach ($tagList as $tag => $cnt) { ?> <div style="margin:4px 10px"> <label> <span style="vertical-align: middle;"><?php echo Xml::radio('target', $tag, $tag == $mTag); ?> </span> <span style="vertical-align: middle; font-family: monospace;" class="tagname"><?php echo $tag; ?> </span> <span style="vertical-align: middle;" class="tagcount"><?php echo wfMsg('tagsreportpages', $cnt); ?> </span> </label> </div> <?php } }
function doForm($user, $reason, $checktype, $ip, $xff, $name) { global $wgOut, $wgTitle; $action = $wgTitle->escapeLocalUrl(); # Fill in requested type if it makes sense $encipusers = 0; $encipedits = 0; $encuserips = 0; if ($checktype == 'subipusers' && ($ip || $xff)) { $encipusers = 1; } else { if ($checktype == 'subipedits' && ($ip || $xff)) { $encipedits = 1; } else { if ($checktype == 'subuserips' && $name) { $encuserips = 1; } else { if ($ip || $xff) { $encipedits = 1; } else { $encuserips = 1; } } } } # Compile our nice form # User box length should fit things like "2001:0db8:85a3:08d3:1319:8a2e:0370:7344/100/xff" $wgOut->addWikiText(wfMsg('checkuser-summary') . "\n\n[[" . $this->getLogSubpageTitle()->getPrefixedText() . '|' . wfMsg('checkuser-showlog') . ']]'); $form = "<form name='checkuser' action='{$action}' method='post'>"; $form .= "<fieldset><legend>" . wfMsgHtml("checkuser-query") . "</legend>"; $form .= "<table border='0' cellpadding='2'><tr>"; $form .= "<td>" . wfMsgHtml("checkuser-target") . ":</td>"; $form .= "<td>" . Xml::input('user', 46, $user, array('id' => 'checktarget')) . "</td>"; $form .= "</tr><tr>"; $form .= "<td></td><td class='checkuserradios'><table border='0' cellpadding='3'><tr>"; $form .= "<td>" . Xml::radio('checktype', 'subuserips', $encuserips, array('id' => 'subuserips')); $form .= " " . Xml::label(wfMsgHtml("checkuser-ips"), 'subuserips') . "</td>"; $form .= "<td>" . Xml::radio('checktype', 'subipedits', $encipedits, array('id' => 'subipedits')); $form .= " " . Xml::label(wfMsgHtml("checkuser-edits"), 'subipedits') . "</td>"; $form .= "<td>" . Xml::radio('checktype', 'subipusers', $encipusers, array('id' => 'subipusers')); $form .= " " . Xml::label(wfMsgHtml("checkuser-users"), 'subipusers') . "</td>"; $form .= "</tr></table></td>"; $form .= "</tr><tr>"; $form .= "<td>" . wfMsgHtml("checkuser-reason") . ":</td>"; $form .= "<td>" . Xml::input('reason', 46, $reason, array('maxlength' => '150', 'id' => 'checkreason')); $form .= " " . Xml::submitButton(wfMsgHtml('checkuser-check')) . "</td>"; $form .= "</tr></table></fieldset></form>"; # Output form $wgOut->addHTML($form); }
function formatRevisionRow($row) { $rev = new Revision($row); $stxt = ''; $last = $this->message['last']; $ts = wfTimestamp(TS_MW, $row->rev_timestamp); $checkBox = Xml::radio('mergepoint', $ts, false); $pageLink = Linker::linkKnown($rev->getTitle(), htmlspecialchars($this->getLanguage()->timeanddate($ts)), array(), array('oldid' => $rev->getId())); if ($rev->isDeleted(Revision::DELETED_TEXT)) { $pageLink = '<span class="history-deleted">' . $pageLink . '</span>'; } # Last link if (!$rev->userCan(Revision::DELETED_TEXT, $this->getUser())) { $last = $this->message['last']; } elseif (isset($this->prevId[$row->rev_id])) { $last = Linker::linkKnown($rev->getTitle(), $this->message['last'], array(), array('diff' => $row->rev_id, 'oldid' => $this->prevId[$row->rev_id])); } $userLink = Linker::revUserTools($rev); $size = $row->rev_len; if (!is_null($size)) { $stxt = Linker::formatRevisionSize($size); } $comment = Linker::revComment($rev); return "<li>{$checkBox} ({$last}) {$pageLink} . . {$userLink} {$stxt} {$comment}</li>"; }
function wfRadio($name, $value, $checked = false, $attribs = array()) { wfDeprecated(__FUNCTION__); return Xml::radio($name, $value, $checked, $attribs); }
function wfRadio($name, $value, $checked = false, $attribs = array()) { return Xml::radio($name, $value, $checked, $attribs); }
/** * @return string Formatted HTML * @private */ function getSizeLimit($sizetype, $size) { $out = Xml::radio('sizetype', 'min', $sizetype == 'min', array('id' => 'wpmin')); $out .= Xml::label(wfMsg("minimum-size"), 'wpmin'); $out .= " " . Xml::radio('sizetype', 'max', $sizetype == 'max', array('id' => 'wpmax')); $out .= Xml::label(wfMsg("maximum-size"), 'wpmax'); $out .= " " . Xml::input('size', 9, $size, array('id' => 'wpsize')); $out .= ' ' . wfMsgHtml('pagesize'); return $out; }
/** * Get a set of labelled radio buttons. You probably want to use getRadioSet(), not this. * * @see getRadioSet * * @return array */ public function getRadioElements($params) { if (!isset($params['controlName'])) { $params['controlName'] = 'config_' . $params['var']; } if (!isset($params['value'])) { $params['value'] = $this->getVar($params['var']); } $items = array(); foreach ($params['values'] as $value) { $itemAttribs = array(); if (isset($params['commonAttribs'])) { $itemAttribs = $params['commonAttribs']; } if (isset($params['itemAttribs'][$value])) { $itemAttribs = $params['itemAttribs'][$value] + $itemAttribs; } $checked = $value == $params['value']; $id = $params['controlName'] . '_' . $value; $itemAttribs['id'] = $id; $itemAttribs['tabindex'] = $this->nextTabIndex(); $items[$value] = Xml::radio($params['controlName'], $value, $checked, $itemAttribs) . ' ' . Xml::tags('label', array('for' => $id), $this->parse(isset($params['itemLabels']) ? wfMessage($params['itemLabels'][$value])->plain() : wfMessage($params['itemLabelPrefix'] . strtolower($value))->plain())); } return $items; }
/** * Constructs a table row with label and radio input in two columns. * @param $name string Option name. * @param $opts FormOptions * @param $alts \list{String} List of alternatives. * @return \string Html. */ protected function eRadio( $name, FormOptions $opts, array $alts ) { $label = 'translate-statsf-' . $name; $label = wfMsgExt( $label, array( 'parsemag', 'escapenoentities' ) ); $s = '<tr><td>' . $label . '</td><td>'; $options = array(); foreach ( $alts as $alt ) { $id = "$name-$alt"; $radio = Xml::radio( $name, $alt, $alt === $opts[$name], array( 'id' => $id ) ) . ' '; $options[] = $radio . ' ' . $this->eLabel( $id ); } $s .= implode( ' ', $options ); $s .= '</td></tr>' . "\n"; return $s; }
protected function showForm($user, $reason, $checktype, $ip, $xff, $name, $period) { global $wgOut, $wgUser; $action = $this->getTitle()->escapeLocalUrl(); # Fill in requested type if it makes sense $encipusers = $encedits = $encuserips = 0; if ($checktype == 'subipusers' && ($ip || $xff)) { $encipusers = 1; } elseif ($checktype == 'subuserips' && $name) { $encuserips = 1; } elseif ($checktype == 'subedits') { $encedits = 1; # Defaults otherwise } elseif ($ip || $xff) { $encedits = 1; } else { $encuserips = 1; } # Compile our nice form... # Username field should fit things like "2001:0db8:85a3:08d3:1319:8a2e:0370:7344/100/xff" $this->showGuide(); // explanation text $form = Xml::openElement('form', array('action' => $action, 'name' => 'checkuserform', 'id' => 'checkuserform', 'method' => 'post')); $form .= '<fieldset><legend>' . wfMsgHtml('checkuser-query') . '</legend>'; $form .= Xml::openElement('table', array('style' => 'border:0')); $form .= '<tr>'; $form .= '<td>' . wfMsgHtml('checkuser-target') . '</td>'; $form .= '<td>' . Xml::input('user', 46, $user, array('id' => 'checktarget')); $form .= ' ' . $this->getPeriodMenu($period) . '</td>'; $form .= '</tr><tr>'; $form .= '<td></td>'; $form .= Xml::openElement('td', array('class' => 'checkuserradios')); $form .= Xml::openElement('table', array('style' => 'border:0')); $form .= '<tr>'; $form .= '<td>' . Xml::radio('checktype', 'subuserips', $encuserips, array('id' => 'subuserips')); $form .= ' ' . Xml::label(wfMsg('checkuser-ips'), 'subuserips') . '</td>'; $form .= '<td>' . Xml::radio('checktype', 'subedits', $encedits, array('id' => 'subedits')); $form .= ' ' . Xml::label(wfMsg('checkuser-edits'), 'subedits') . '</td>'; $form .= '<td>' . Xml::radio('checktype', 'subipusers', $encipusers, array('id' => 'subipusers')); $form .= ' ' . Xml::label(wfMsg('checkuser-users'), 'subipusers') . '</td>'; $form .= '</tr>'; $form .= Xml::closeElement('table'); $form .= Xml::closeElement('td'); $form .= '</tr><tr>'; $form .= '<td>' . wfMsgHtml('checkuser-reason') . '</td>'; $form .= '<td>' . Xml::input('reason', 46, $reason, array('maxlength' => '150', 'id' => 'checkreason')); $form .= '   ' . Xml::submitButton(wfMsg('checkuser-check'), array('id' => 'checkusersubmit', 'name' => 'checkusersubmit')) . '</td>'; $form .= '</tr>'; $form .= Xml::closeElement('table'); $form .= '</fieldset>'; $form .= Xml::closeElement('form'); # Output form $wgOut->addHTML($form); }
protected function taskLinks($tasks) { $user = $this->getUser(); foreach ($tasks as $index => $id) { $task = TranslateTasks::getTask($id); if (!$task) { unset($tasks[$index]); continue; } if (!$task->isAllowedFor($user)) { unset($tasks[$index]); continue; } } $sep = Html::element('br'); $count = count($tasks); if ($count === 0) { return $sep . $this->msg('translate-taction-disabled')->escaped(); } elseif ($count === 1) { $id = array_pop($tasks); // If there is only one task, and it is the default task, hide it. // If someone disables the default task for action, we will show // a list of alternative task(s), but not showing anything // by default. */ if ($this->defaults['task'] === $id) { return ''; } // Give grep a chance to find the usages: // translate-taskui-view, translate-taskui-untranslated, translate-taskui-optional, // translate-taskui-acceptqueue, translate-taskui-reviewall, // translate-taskui-export-to-file, translate-taskui-export-as-po return $sep . Html::rawElement('label', array(), Xml::radio('task', $id, true) . ' ' . $this->msg("translate-taskui-{$id}")->escaped()); } else { $output = ''; foreach ($tasks as $id) { // Give grep a chance to find the usages: // translate-taskui-view, translate-taskui-untranslated, translate-taskui-optional, // translate-taskui-acceptqueue, translate-taskui-reviewall, // translate-taskui-export-to-file, translate-taskui-export-as-po $output .= Html::rawElement('label', array(), Xml::radio('task', $id, $this->options['task'] === $id) . ' ' . $this->msg("translate-taskui-{$id}")->escaped()) . ' '; } return $sep . $output; } }
function formatRevisionRow($row) { global $wgUser, $wgLang; $rev = new Revision($row); $stxt = ''; $last = $this->message['last']; $ts = wfTimestamp(TS_MW, $row->rev_timestamp); $checkBox = Xml::radio("mergepoint", $ts, false); $pageLink = $this->sk->makeKnownLinkObj($rev->getTitle(), htmlspecialchars($wgLang->timeanddate($ts)), 'oldid=' . $rev->getId()); if ($rev->isDeleted(Revision::DELETED_TEXT)) { $pageLink = '<span class="history-deleted">' . $pageLink . '</span>'; } # Last link if (!$rev->userCan(Revision::DELETED_TEXT)) { $last = $this->message['last']; } else { if (isset($this->prevId[$row->rev_id])) { $last = $this->sk->makeKnownLinkObj($rev->getTitle(), $this->message['last'], "diff=" . $row->rev_id . "&oldid=" . $this->prevId[$row->rev_id]); } } $userLink = $this->sk->revUserTools($rev); if (!is_null($size = $row->rev_len)) { $stxt = $this->sk->formatRevisionSize($size); } $comment = $this->sk->revComment($rev); return "<li>{$checkBox} ({$last}) {$pageLink} . . {$userLink} {$stxt} {$comment}</li>"; }
private function displayNavigation() { global $wgOut; $groupSelector = new XmlSelect('group', 'group-select'); // pull groups $groups = MessageGroups::singleton()->getGroups(); foreach ($groups as $group) { if (!$group->isMeta()) { continue; } $groupSelector->addOption($group->getLabel(), $group->getId()); } $fields = array(); $fields['transstats-choose-group'] = $groupSelector->getHTML(); $fields['transstats-group-mode-all'] = Xml::radio('mode', 0, empty($this->mMode)); $fields['transstats-group-mode-supress0'] = Xml::radio('mode', 1, $this->mMode == 1); $fields['transstats-group-mode-supress100'] = Xml::radio('mode', 2, $this->mMode == 2); $fields['transstats-group-mode-only100'] = Xml::radio('mode', 3, $this->mMode == 3); $fields['transstats-group-langlist'] = Xml::input('langlist', false, $this->mLanglistPlain); $out = Xml::openElement('form'); $out .= Xml::buildForm($fields); $out .= Html::hidden('title', 'Special:' . $this->getName()); // FIXME: this is silly... $out .= Xml::submitButton(wfMsg('transstats-submit')); $out .= Xml::closeElement('form'); $wgOut->addHTML($out); }
function formatOptions($options, $value) { $html = ''; $attribs = array(); if (!empty($this->mParams['disabled'])) { $attribs['disabled'] = 'disabled'; } # TODO: should this produce an unordered list perhaps? foreach ($options as $label => $info) { if (is_array($info)) { $html .= Html::rawElement('h1', array(), $label) . "\n"; $html .= $this->formatOptions($info, $value); } else { $id = Sanitizer::escapeId($this->mID . "-{$info}"); $radio = Xml::radio($this->mName, $info, $info == $value, $attribs + array('id' => $id)); $radio .= ' ' . Html::rawElement('label', array('for' => $id), $label); $html .= ' ' . Html::rawElement('div', array('class' => 'mw-htmlform-flatlist-item'), $radio); } } return $html; }
protected function generateBillingFields() { global $wgScriptPath; $scriptPath = "{$wgScriptPath}/extensions/DonationInterface/gateway_forms/includes"; $form = ''; /* $form .= '<tr>'; $form .= '<td style="text-align:center;" colspan="2"><big><b>' . wfMsg( 'donate_interface-paypal-button' ) . '</b></big><br/><a href="#" onclick="document.payment.PaypalRedirect.value=1;document.payment.submit();"><img src="' . $scriptPath . '/paypal.png"/></a></td>'; $form .= '</tr>'; */ // amount $otherChecked = false; $amount = -1; if ($this->getEscapedValue('amount') != 100 && $this->getEscapedValue('amount') != 50 && $this->getEscapedValue('amount') != 35 && $this->getEscapedValue('amount') != 20 && $this->getEscapedValue('amountOther') > 0) { $otherChecked = true; $amount = $this->getEscapedValue('amountOther'); } $form .= '<tr>'; $form .= '<td colspan="2"><span class="creditcard-error-msg">' . $this->form_errors['amount'] . '</span></td>'; $form .= '</tr>'; $form .= '<tr>'; $form .= '<td class="label">' . Xml::label(wfMsg('donate_interface-donor-amount'), 'amount') . '</td>'; $form .= '<td>' . Xml::radio('amount', 100, $this->getEscapedValue('amount') == 100, array('onfocus' => 'clearField2( document.getElementById(\'amountOther\'), "Other" )')) . '100 ' . Xml::radio('amount', 50, $this->getEscapedValue('amount') == 50, array('onfocus' => 'clearField2( document.getElementById(\'amountOther\'), "Other" )')) . '50 ' . Xml::radio('amount', 35, $this->getEscapedValue('amount') == 35, array('onfocus' => 'clearField2( document.getElementById(\'amountOther\'), "Other" )')) . '35 ' . Xml::radio('amount', 20, $this->getEscapedValue('amount') == 20, array('onfocus' => 'clearField2( document.getElementById(\'amountOther\'), "Other" )')) . '20 ' . '</td>'; $form .= '</tr>'; $form .= '<tr>'; $form .= '<td class="label"></td>'; $form .= '<td>' . Xml::radio('amount', $amount, $otherChecked, array('id' => 'otherRadio')) . Xml::input('amountOther', '7', $this->getEscapedValue('amountOther'), array('type' => 'text', 'onfocus' => 'clearField(this, "Other");document.getElementById("otherRadio").checked=true;', 'maxlength' => '10', 'onblur' => 'document.getElementById("otherRadio").value = this.value;', 'id' => 'amountOther')) . ' ' . $this->generateCurrencyDropdown() . '</td>'; $form .= '</tr>'; // email opt-in $email_opt_value = $this->gateway->posted ? $this->getEscapedValue('email-opt') : true; $form .= '<tr>'; $form .= '<td class="label"> </td>'; $form .= '<td class="check-option">' . Xml::check('email-opt', $email_opt_value); $form .= ' '; // put the label inside Xml::openElement so any HTML in the msg might get rendered (right, Germany?) $form .= Xml::openElement('label', array('for' => 'email-opt')); $form .= wfMsg('donate_interface-email-agreement'); $form .= Xml::closeElement('label'); $form .= '</td>'; $form .= '</tr>'; $form .= '<tr>'; $form .= '<td class="label">' . wfMsg('donate_interface-payment-type') . '</td>'; $form .= '<td>' . Xml::radio('card_type', 'cc1', $this->getEscapedValue('card_type') == 'cc1', array('id' => 'cc1radio', 'onclick' => 'switchToCreditCard()')) . '<label for="cc1radio">' . Xml::element('img', array('src' => $wgScriptPath . "/extensions/DonationInterface/gateway_forms/includes/card-visa.png")) . '</label>' . Xml::radio('card_type', 'cc2', $this->getEscapedValue('card_type') == 'cc2', array('id' => 'cc2radio', 'onclick' => 'switchToCreditCard()')) . '<label for="cc2radio">' . Xml::element('img', array('src' => $wgScriptPath . "/extensions/DonationInterface/gateway_forms/includes/card-mastercard.png")) . '</label>' . Xml::radio('card_type', 'cc3', $this->getEscapedValue('card_type') == 'cc3', array('id' => 'cc3radio', 'onclick' => 'switchToCreditCard()')) . '<label for="cc3radio">' . Xml::element('img', array('src' => $wgScriptPath . "/extensions/DonationInterface/gateway_forms/includes/card-amex.png")) . '</label>' . Xml::radio('card_type', 'cc4', $this->getEscapedValue('card_type') == 'cc4', array('id' => 'cc4radio', 'onclick' => 'switchToCreditCard()')) . '<label for="cc4radio">' . Xml::element('img', array('src' => $wgScriptPath . "/extensions/DonationInterface/gateway_forms/includes/card-discover.png")) . '</label>' . Xml::radio('card_type', 'pp', $this->getEscapedValue('card_type') == 'pp', array('id' => 'ppradio', 'onclick' => 'switchToPayPal()')) . '<label for="ppradio">' . Xml::element('img', array('src' => $wgScriptPath . "/extensions/DonationInterface/gateway_forms/includes/card-paypal.png")) . '</label>' . '</td>'; $form .= '</tr>'; $form .= '</table>'; if ($this->getEscapedValue('card_type') == 'cc1' || $this->getEscapedValue('card_type') == 'cc2' || $this->getEscapedValue('card_type') == 'cc3' || $this->getEscapedValue('card_type') == 'cc4') { $form .= Xml::openElement('table', array('id' => 'payflow-table-cc')); } else { $form .= Xml::openElement('table', array('id' => 'payflow-table-cc', 'style' => 'display: none;')); } // name $form .= $this->getNameField(); // email $form .= $this->getEmailField(); $form .= '<tr>'; $form .= '<td colspan=2><span class="creditcard-error-msg"> </span></td>'; $form .= '</tr>'; // card number $form .= $this->getCardNumberField(); // cvv $form .= $this->getCvvField(); // expiry $form .= $this->getExpiryField(); // street $form .= $this->getStreetField(); // city $form .= $this->getCityField(); // state $form .= $this->getStateField(); // zip $form .= '<tr>'; $form .= '<td colspan=2><span class="creditcard-error-msg">' . $this->form_errors['zip'] . '</span></td>'; $form .= '</tr>'; $form .= '<tr>'; $form .= '<td class="label">' . Xml::label(wfMsg('donate_interface-donor-postal'), 'zip') . '</td>'; $form .= '<td>' . Xml::input('zip', '15', $this->getEscapedValue('zip'), array('type' => 'text', 'maxlength' => '15', 'id' => 'zip')) . '</td>'; $form .= '</tr>'; // country $form .= $this->getCountryField(); return $form; }
function getQuestionForm( $question, $options ) { global $wgRequest; $name = 'securepoll_q' . $question->getId(); list( $min, $max ) = $this->getMinMax( $question ); $labels = $this->getColumnLabels( $question ); $s = "<table class=\"securepoll-ballot-table\">\n" . "<tr>\n" . "<th> </th>\n"; foreach ( $labels as $label ) { $s .= Html::rawElement( 'th', array(), $label ) . "\n"; } $s .= "</tr>\n"; $defaultScore = $question->getProperty( 'default-score' ); foreach ( $options as $option ) { $optionHTML = $option->parseMessageInline( 'text' ); $optionId = $option->getId(); $inputId = "{$name}_opt{$optionId}"; $oldValue = $wgRequest->getVal( $inputId, $defaultScore ); $s .= "<tr class=\"securepoll-ballot-row\">\n" . Xml::tags( 'td', array( 'class' => 'securepoll-ballot-optlabel' ), $this->errorLocationIndicator( $inputId ) . $optionHTML ); foreach ( $labels as $score => $label ) { $s .= Xml::tags( 'td', array(), Xml::radio( $inputId, $score, !strcmp( $oldValue, $score ), array( 'title' => $label ) ) ) . "\n"; } $s .= "</tr>\n"; } $s .= "</table>\n"; return $s; }
/** * Builds and returns the amount form field. * This function is not used by any RapidHTML forms. * @return string */ protected function getAmountField() { $otherChecked = false; $amount = -1; if ($this->getEscapedValue('amount') != 100 && $this->getEscapedValue('amount') != 50 && $this->getEscapedValue('amount') != 35 && $this->getEscapedValue('amount') != 20 && $this->getEscapedValue('amountOther') > 0) { $otherChecked = true; $amount = $this->getEscapedValue('amountOther'); } $form = '<tr>'; $form .= '<td colspan="2"><span class="creditcard-error-msg">' . $this->form_errors['amount'] . '</span></td>'; $form .= '</tr>'; $form .= '<tr>'; $form .= '<td class="label">' . Xml::label(wfMsg('donate_interface-donor-amount'), 'amount') . '</td>'; $form .= '<td>' . Xml::radio('amount', 100, $this->getEscapedValue('amount') == 100) . '100 ' . Xml::radio('amount', 50, $this->getEscapedValue('amount') == 50) . '50 ' . Xml::radio('amount', 35, $this->getEscapedValue('amount') == 35) . '35 ' . Xml::radio('amount', 20, $this->getEscapedValue('amount') == 20) . '20 ' . '</td>'; $form .= '</tr>'; $form .= '<tr>'; $form .= '<td class="label"></td>'; $form .= '<td>' . Xml::radio('amount', $amount, $otherChecked, array('id' => 'otherRadio')) . Xml::input('amountOther', '7', $this->getEscapedValue('amountOther'), array('type' => 'text', 'onfocus' => 'clearField( this, \'' . wfMsg('donate_interface-other') . '\' )', 'onblur' => 'document.getElementById("otherRadio").value = this.value;if (this.value > 0) document.getElementById("otherRadio").checked=true;', 'maxlength' => '10', 'id' => 'amountOther')) . ' ' . $this->generateCurrencyDropdown() . '</td>'; $form .= '</tr>'; return $form; }