public static function typeSelector($name = 'type', $value = '', $id = false) { $s = new XmlSelect($name, $id, $value); $s->addOption(wfMsg('userrestrictiontype-none'), ''); $s->addOption(wfMsg('userrestrictiontype-page'), UserRestriction::PAGE); $s->addOption(wfMsg('userrestrictiontype-namespace'), UserRestriction::NAMESPACE); return $s->getHTML(); }
/** * Hooks SpecialRecentChangesPanel. See the hook documentation for * documentation of the function parameters. * * Adds a HTMl selector into $items * @param $items * @param $opts * @return bool true */ public static function translationFilterForm( &$items, $opts ) { $opts->consumeValue( 'translations' ); $default = $opts->getValue( 'translations' ); $label = Xml::label( wfMsg( 'translate-rc-translation-filter' ), 'mw-translation-filter' ); $select = new XmlSelect( 'translations', 'mw-translation-filter', $default ); $select->addOption( wfMsg( 'translate-rc-translation-filter-no' ), 'noaction' ); $select->addOption( wfMsg( 'translate-rc-translation-filter-only' ), 'only' ); $select->addOption( wfMsg( 'translate-rc-translation-filter-filter' ), 'filter' ); $select->addOption( wfMsg( 'translate-rc-translation-filter-site' ), 'site' ); $items['translations'] = array( $label, $select->getHTML() ); return true; }
function execute($params) { global $wgOut, $wgUser, $wgRequest; $wgOut->setPageTitle('WikiFactory Reporter'); $wgOut->setRobotpolicy('noindex,nofollow'); $wgOut->setArticleRelated(false); if (!$wgUser->isAllowed('wikifactory')) { $this->displayRestrictionError(); return; } $this->varid = $wgRequest->getInt('varid'); $this->disable_limit = $wgRequest->getBool('nolimit'); /***********************************************/ $vars = WikiFactory::getVariables("cv_name", 0, 0); $select = new XmlSelect('varid', false, $this->varid); if (!empty($this->varid)) { //the cast is because the Xml select uses === to detect the default $select->setDefault((string) $this->varid); //change the name, using the var name $variable = WikiFactory::getVarById($this->varid, 0); $wgOut->setPageTitle('WikiFactory Reporter: ' . $variable->cv_name); } foreach ($vars as $variable) { $select->addOption("{$variable->cv_name} ({$variable->cv_id})", $variable->cv_id); } $action = self::getTitle()->getLocalURL(); $wgOut->addHTML("<form action='{$action}' method='get'>\n"); $wgOut->addHTML($select->getHTML()); $wgOut->addHTML("<input type='submit'>\n"); $wgOut->addHTML("</form>\n"); /***********************************************/ if (!empty($this->varid)) { $wgOut->addHTML($this->getCustomSettings()); } }
protected function showToolbar() { $langSelector = Xml::languageSelector( $this->lang ); $fontSelector = new XmlSelect(); $fontSelector->setAttribute( 'id', 'webfonts-font-chooser' ); $sizeSelector = new XmlSelect(); $sizeSelector->setAttribute( 'id', 'webfonts-size-chooser' ); for ( $size = 8; $size <= 28; $size += 2 ) { $sizeSelector->addOption( $size , $size ); } $sizeSelector->setDefault( 16 ); $bold = Html::Element( 'button', array( 'id' => 'webfonts-preview-bold' ) , 'B' ); $italic = Html::Element( 'button', array( 'id' => 'webfonts-preview-italic' ) , 'I' ); $underline = Html::Element( 'button', array( 'id' => 'webfonts-preview-underline' ) , 'U' ); $download = Html::Element( 'a', array( 'id' => 'webfonts-preview-download', 'href' => '#' ) , wfMsg( 'webfonts-preview-download' ) ); return Html::openElement( 'div', array( 'id' => 'webfonts-preview-toolbar' ) ) . $langSelector[1] . $fontSelector->getHtml() . $sizeSelector->getHtml() . $bold . $italic . $underline . $download . Html::closeElement( 'div' ); }
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); }
/** * Helper function get module selector. * * @param $selectedId \string Which value should be selected by default * @return \string HTML5-compatible select-element. */ protected function moduleSelector($selectedId) { $selector = new XmlSelect('module', 'module', $selectedId); foreach ($this->aModules as $code) { $selector->addOption(wfMsg('translate-magic-' . $code), $code); } return $selector->getHTML(); }
static function onRcForm( &$items, $opts ) { global $wmincProjects, $wmincProjectSite, $wmincLangCodeLength; list( $projectvalue, $codevalue ) = self::getValues(); $opts->consumeValue( 'rc-testwiki-project' ); $opts->consumeValue( 'rc-testwiki-code' ); $label = Xml::label( wfMsg( 'wminc-testwiki' ), 'rc-testwiki' ); $select = new XmlSelect( 'rc-testwiki-project', 'rc-testwiki-project', $projectvalue ); $select->addOption( wfMsg( 'wminc-testwiki-none' ), 'none' ); foreach( $wmincProjects as $prefix => $name ) { $select->addOption( $name, $prefix ); } $select->addOption( $wmincProjectSite['name'], $wmincProjectSite['short'] ); $langcode = Xml::input( 'rc-testwiki-code', (int)$wmincLangCodeLength, $codevalue, array( 'id' => 'rc-testwiki-code', 'maxlength' => (int)$wmincLangCodeLength ) ); $items['testwiki'] = array( $label, $select->getHTML() . ' ' . $langcode ); return true; }
/** * Adding default later on should set the correct selection or * raise an exception. * To handle this, we need to render the options in getHtml() * @covers XmlSelect::setDefault */ public function testSetDefaultAfterAddingOptions() { $this->select->addOption('foo1'); $this->select->addOption('bar1'); $this->select->addOption('foo2'); $this->select->setDefault('bar1'); # setting default after adding options $this->assertEquals('<select><option value="foo1">foo1</option>' . "\n" . '<option value="bar1" selected="">bar1</option>' . "\n" . '<option value="foo2">foo2</option></select>', $this->select->getHTML()); }
protected function buildSelect($list, $name, $default = '') { sort($list); $select = new XmlSelect($name); $select->setDefault($default); foreach ($list as $wiki) { $select->addOption($wiki); } return $select->getHTML(); }
/** * Helper function get module selector. * * @param string $selectedId Which value should be selected by default * @return string HTML5-compatible select-element. */ protected function moduleSelector($selectedId) { // Give grep a chance to find the usages: // translate-magic-words, translate-magic-special, translate-magic-namespace $selector = new XmlSelect('module', 'module', $selectedId); foreach ($this->aModules as $code) { $selector->addOption($this->msg('translate-magic-' . $code)->text(), $code); } return $selector->getHTML(); }
/** * Output a form to allow searching for a user */ function switchForm() { global $wgScript; $knownwiki = $this->getRequest()->getVal('wpKnownWiki'); $knownwiki = $knownwiki ? $knownwiki : wfWikiId(); // Generate wiki selector $selector = new XmlSelect('wpKnownWiki', 'wpKnownWiki', $knownwiki); foreach (CentralAuthUser::getWikiList() as $wiki) { $selector->addOption($wiki); } $this->getOutput()->addModuleStyles('mediawiki.special'); $this->getOutput()->addHTML(Xml::openElement('form', array('method' => 'get', 'action' => $wgScript, 'name' => 'uluser', 'id' => 'mw-userrights-form1')) . Html::hidden('title', $this->getTitle()) . Xml::openElement('fieldset') . Xml::element('legend', array(), wfMsg('userrights-lookup-user')) . Xml::inputLabel(wfMsg('userrights-user-editname'), 'user', 'username', 30, $this->mTarget) . ' <br />' . Xml::label(wfMsg('centralauth-globalgrouppermissions-knownwiki'), 'wpKnownWiki') . ' ' . $selector->getHTML() . '<br />' . Xml::submitButton(wfMsg('editusergroup')) . Xml::closeElement('fieldset') . Xml::closeElement('form') . "\n"); }
/** * JavsScript selector for language codes. * @return JsSelectToInput */ protected static function languageSelector() { if (is_callable(array('LanguageNames', 'getNames'))) { $lang = RequestContext::getMain()->getLanguage(); $languages = LanguageNames::getNames($lang->getCode(), LanguageNames::FALLBACK_NORMAL); } else { $languages = Language::fetchLanguageNames(); } ksort($languages); $selector = new XmlSelect('mw-language-selector', 'mw-language-selector'); foreach ($languages as $code => $name) { $selector->addOption("{$code} - {$name}", $code); } $jsSelect = new JsSelectToInput($selector); $jsSelect->setSourceId('mw-language-selector'); return $jsSelect; }
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-breakdown'] = Xml::check('breakdown', false); $out = Xml::openElement('form'); $out .= Xml::buildForm($fields); $out .= Xml::submitButton(wfMsg('transstats-submit')); $out .= Xml::closeElement('form'); $wgOut->addHTML($out); }
/** * Message input fieldset * * @param $title Title (default: null) * @return \string HTML for fieldset. */ function namespaceMessageForm(Title $title = null) { global $wgScript; $namespaces = new XmlSelect('namespace', 'namespace'); $namespaces->setDefault($title->getNamespace()); foreach ($this->getSortedNamespaces() as $text => $index) { $namespaces->addOption($text, $index); } $out = Xml::openElement('div', array('class' => 'namespaceoptions')); $out .= Xml::openElement('form', array('method' => 'get', 'action' => $wgScript)); $out .= Html::hidden('title', $this->getTitle()->getPrefixedText()); $out .= Xml::openElement('fieldset'); $out .= Xml::element('legend', null, wfMsg('translate-translations-fieldset-title')); $out .= Xml::openElement('table', array('id' => 'nsselect', 'class' => 'allpages')); $out .= "<tr>\n\t\t\t\t<td class='mw-label'>" . Xml::label(wfMsg('translate-translations-messagename'), 'message') . "</td>\n\t\t\t\t<td class='mw-input'>" . Xml::input('message', 30, $title->getText(), array('id' => 'message')) . "</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td class='mw-label'>" . Xml::label(wfMsg('translate-translations-project'), 'namespace') . "</td>\n\t\t\t\t<td class='mw-input'>" . $namespaces->getHTML() . ' ' . Xml::submitButton(wfMsg('allpagessubmit')) . "</td>\n\t\t\t\t</tr>"; $out .= Xml::closeElement('table'); $out .= Xml::closeElement('fieldset'); $out .= Xml::closeElement('form'); $out .= Xml::closeElement('div'); return $out; }
function execute() { global $wgCookieExpiration; $expirationDays = ceil($wgCookieExpiration / (3600 * 24)); ?> <div class="mw-ui-container"> <?php if ($this->haveData('languages')) { ?> <div id="languagelinks"> <p><?php $this->html('languages'); ?> </p> </div> <?php } if (!wfMessage('signupstart')->isDisabled()) { ?> <div id="signupstart"><?php $this->msgWiki('signupstart'); ?> </div> <?php } ?> <div id="userloginForm"> <h2 class="createaccount-join"> <?php $this->msg($this->data['loggedin'] ? 'createacct-another-join' : 'createacct-join'); ?> </h2> <form name="userlogin2" id="userlogin2" class="mw-ui-vform" method="post" action="<?php $this->text('action'); ?> "> <section class="mw-form-header"> <?php $this->html('header'); /* extensions such as ConfirmEdit add form HTML here */ ?> </section> <!-- This element is used by the mediawiki.special.userlogin.signup.js module. --> <div id="mw-createacct-status-area" <?php if ($this->data['message']) { ?> class="<?php echo $this->data['messagetype']; ?> box" <?php } else { ?> style="display: none;" <?php } ?> > <?php if ($this->data['message']) { ?> <?php if ($this->data['messagetype'] == 'error') { ?> <strong><?php $this->msg('createacct-error'); ?> </strong> <br /> <?php } ?> <?php $this->html('message'); ?> <?php } ?> </div> <div> <label for='wpName2'> <?php $this->msg('userlogin-yourname'); ?> <span class="mw-ui-flush-right"><?php echo $this->getMsg('createacct-helpusername')->parse(); ?> </span> </label> <?php echo Html::input('wpName', $this->data['name'], 'text', array('class' => 'mw-input loginText', 'id' => 'wpName2', 'tabindex' => '1', 'size' => '20', 'required', 'placeholder' => $this->getMsg($this->data['loggedin'] ? 'createacct-another-username-ph' : 'userlogin-yourname-ph')->text())); ?> </div> <div> <?php if ($this->data['createemail']) { ?> <label class="mw-ui-checkbox-label"> <input name="wpCreateaccountMail" type="checkbox" value="1" id="wpCreateaccountMail" tabindex="2" <?php if ($this->data['createemailset']) { echo 'checked="checked"'; } ?> > <?php $this->msg('createaccountmail'); ?> </label> <?php } ?> </div> <div class="mw-row-password"> <label for='wpPassword2'><?php $this->msg('userlogin-yourpassword'); ?> </label> <?php echo Html::input('wpPassword', null, 'password', array('class' => 'mw-input loginPassword', 'id' => 'wpPassword2', 'tabindex' => '3', 'size' => '20', 'required', 'placeholder' => $this->getMsg('createacct-yourpassword-ph')->text()) + User::passwordChangeInputAttribs()); ?> </div> <?php if ($this->data['usedomain']) { $select = new XmlSelect('wpDomain', false, $this->data['domain']); $select->setAttribute('tabindex', 4); foreach ($this->data['domainnames'] as $dom) { $select->addOption($dom); } ?> <div id="mw-user-domain-section"> <label for="wpDomain"><?php $this->msg('yourdomainname'); ?> </label> <div class="mw-input"> <?php echo $select->getHTML(); ?> </div> </div> <?php } ?> <div class="mw-row-password"> <label for='wpRetype'><?php $this->msg('createacct-yourpasswordagain'); ?> </label> <?php echo Html::input('wpRetype', null, 'password', array('class' => 'mw-input loginPassword', 'id' => 'wpRetype', 'tabindex' => '5', 'size' => '20', 'required', 'placeholder' => $this->getMsg('createacct-yourpasswordagain-ph')->text()) + User::passwordChangeInputAttribs()); ?> </div> <div> <?php if ($this->data['useemail']) { ?> <label for='wpEmail'> <?php $this->msg($this->data['emailrequired'] ? 'createacct-emailrequired' : 'createacct-emailoptional'); ?> </label> <?php echo Html::input('wpEmail', $this->data['email'], 'email', array('class' => 'mw-input loginText', 'id' => 'wpEmail', 'tabindex' => '6', 'size' => '20', 'required' => $this->data['emailrequired'], 'placeholder' => $this->getMsg($this->data['loggedin'] ? 'createacct-another-email-ph' : 'createacct-email-ph')->text())); ?> <?php } ?> </div> <?php if ($this->data['userealname']) { ?> <div> <label for='wpRealName'><?php $this->msg('createacct-realname'); ?> </label> <input type='text' class='mw-input loginText' name="wpRealName" id="wpRealName" tabindex="7" value="<?php $this->text('realname'); ?> " size='20' /> <div class="prefsectiontip"> <?php $this->msgWiki($this->data['loggedin'] ? 'createacct-another-realname-tip' : 'prefs-help-realname'); ?> </div> </div> <?php } ?> <?php if ($this->data['usereason']) { ?> <div> <label for='wpReason'><?php $this->msg('createacct-reason'); ?> </label> <?php echo Html::input('wpReason', $this->data['reason'], 'text', array('class' => 'mw-input loginText', 'id' => 'wpReason', 'tabindex' => '8', 'size' => '20', 'placeholder' => $this->getMsg('createacct-reason-ph')->text())); ?> </div> <?php } ?> <?php $tabIndex = 9; if (isset($this->data['extraInput']) && is_array($this->data['extraInput'])) { foreach ($this->data['extraInput'] as $inputItem) { ?> <div> <?php // If it's a checkbox, output the whole thing (assume it has a msg). if ($inputItem['type'] == 'checkbox') { ?> <label class="mw-ui-checkbox-label"> <input name="<?php echo htmlspecialchars($inputItem['name']); ?> " id="<?php echo htmlspecialchars($inputItem['name']); ?> " type="checkbox" value="1" tabindex="<?php echo $tabIndex++; ?> " <?php if (!empty($inputItem['value'])) { echo 'checked="checked"'; } ?> > <?php $this->msgHtml($inputItem['msg']); ?> </label> <?php } else { // Not a checkbox. // TODO (bug 31909) support other input types, e.g. select boxes. ?> <?php if (!empty($inputItem['msg'])) { ?> <label for="<?php echo htmlspecialchars($inputItem['name']); ?> "> <?php $this->msgWiki($inputItem['msg']); ?> </label> <?php } ?> <input type="<?php echo htmlspecialchars($inputItem['type']); ?> " class="mw-input" name="<?php echo htmlspecialchars($inputItem['name']); ?> " tabindex="<?php echo $tabIndex++; ?> " value="<?php echo htmlspecialchars($inputItem['value']); ?> " id="<?php echo htmlspecialchars($inputItem['name']); ?> " /> <?php } ?> <?php if ($inputItem['helptext'] !== false) { ?> <div class="prefsectiontip"> <?php $this->msgWiki($inputItem['helptext']); ?> </div> <?php } ?> </div> <?php } } // JS attempts to move the image CAPTCHA below this part of the form, // so skip one index. $tabIndex++; ?> <div class="mw-submit"> <?php echo Html::input('wpCreateaccount', $this->getMsg($this->data['loggedin'] ? 'createacct-another-submit' : 'createacct-submit'), 'submit', array('class' => "mw-ui-button mw-ui-big mw-ui-block mw-ui-constructive", 'id' => 'wpCreateaccount', 'tabindex' => $tabIndex++)); ?> </div> <?php if ($this->haveData('uselang')) { ?> <input type="hidden" name="uselang" value="<?php $this->text('uselang'); ?> " /><?php } ?> <?php if ($this->haveData('token')) { ?> <input type="hidden" name="wpCreateaccountToken" value="<?php $this->text('token'); ?> " /><?php } ?> </form> <?php if (!wfMessage('signupend')->isDisabled()) { ?> <div id="signupend"><?php $this->html('signupend'); ?> </div> <?php } ?> </div> <div class="mw-createacct-benefits-container"> <h2><?php $this->msg('createacct-benefit-heading'); ?> </h2> <div class="mw-createacct-benefits-list"> <?php for ($benefitIdx = 1; $benefitIdx <= $this->data['benefitCount']; $benefitIdx++) { // Pass each benefit's head text (by default a number) as a parameter to the body's message for PLURAL handling. $headUnescaped = $this->getMsg("createacct-benefit-head{$benefitIdx}")->text(); ?> <div class="mw-number-text <?php $this->msg("createacct-benefit-icon{$benefitIdx}"); ?> "> <h3><?php $this->msg("createacct-benefit-head{$benefitIdx}"); ?> </h3> <p><?php echo $this->getMsg("createacct-benefit-body{$benefitIdx}")->params($headUnescaped)->escaped(); ?> </p> </div> <?php } ?> </div> </div> </div> <?php }
/** * Show a drop-down box of special pages * @return string */ function specialPagesList() { global $wgScript; $select = new XmlSelect('title'); $pages = SpecialPageFactory::getUsablePages(); array_unshift($pages, SpecialPageFactory::getPage('SpecialPages')); foreach ($pages as $obj) { $select->addOption($obj->getDescription(), $obj->getTitle()->getPrefixedDBkey()); } return Html::rawElement('form', array('id' => 'specialpages', 'method' => 'get', 'action' => $wgScript), $select->getHTML() . Xml::submitButton(wfMessage('go')->text())); }
/** * Get a "<select>" for selecting languages. * * @param string $name * @param string $label * @param string $selectedCode * @param string $helpHtml * * @return string */ public function getLanguageSelector($name, $label, $selectedCode, $helpHtml = '') { global $wgDummyLanguageCodes; $output = $helpHtml; $select = new XmlSelect($name, $name, $selectedCode); $select->setAttribute('tabindex', $this->parent->nextTabIndex()); $languages = Language::fetchLanguageNames(); ksort($languages); foreach ($languages as $code => $lang) { if (isset($wgDummyLanguageCodes[$code])) { continue; } $select->addOption("{$code} - {$lang}", $code); } $output .= $select->getHTML(); return $this->parent->label($label, $name, $output); }
/** * Build protection level selector * * @param string $action Action to protect * @param string $selected Current protection level * @return string HTML fragment */ function buildSelector($action, $selected) { // If the form is disabled, display all relevant levels. Otherwise, // just show the ones this user can use. $levels = MWNamespace::getRestrictionLevels($this->mTitle->getNamespace(), $this->disabled ? null : $this->mContext->getUser()); $id = 'mwProtect-level-' . $action; $select = new XmlSelect($id, $id, $selected); $select->setAttribute('size', count($levels)); if ($this->disabled) { $select->setAttribute('disabled', 'disabled'); } foreach ($levels as $key) { $select->addOption($this->getOptionLabel($key), $key); } return $select->getHTML(); }
function getExistingSelector($warnMsg) { $existingSelector = new XmlSelect('wpFilterWarnMessage', 'mw-abusefilter-warn-message-existing', $warnMsg == 'abusefilter-warning' ? 'abusefilter-warning' : 'other'); // Find other messages. $dbr = wfGetDB(DB_SLAVE); $res = $dbr->select('page', array('page_title'), array('page_namespace' => 8, 'page_title LIKE ' . $dbr->addQuotes('Abusefilter-warning%')), __METHOD__); $existingSelector->addOption('abusefilter-warning'); $lang = $this->getLanguage(); foreach ($res as $row) { if ($lang->lcfirst($row->page_title) == $lang->lcfirst($warnMsg)) { $existingSelector->setDefault($lang->lcfirst($warnMsg)); } if ($row->page_title != 'Abusefilter-warning') { $existingSelector->addOption($lang->lcfirst($row->page_title)); } } $existingSelector->addOption(wfMsg('abusefilter-edit-warn-other'), 'other'); return $existingSelector->getHTML(); }
/** * Drop down menu for selection of actions that can be used to filter the log * @param array $types * @param string $action * @return string * @since 1.27 */ private function getActionSelector($types, $action) { if ($this->allowedActions === null || !count($this->allowedActions)) { return ''; } $html = ''; $html .= Xml::label(wfMessage('log-action-filter-' . $types[0])->text(), 'action-filter-' . $types[0]) . "\n"; $select = new XmlSelect('subtype'); $select->addOption(wfMessage('log-action-filter-all')->text(), ''); foreach ($this->allowedActions as $value) { $msgKey = 'log-action-filter-' . $types[0] . '-' . $value; $select->addOption(wfMessage($msgKey)->text(), $value); } $select->setDefault($action); $html .= $select->getHTML(); return $html; }
/** * @param $group * @return string */ function buildWikiSetSelector($group) { $sets = WikiSet::getAllWikiSets(); $default = WikiSet::getWikiSetForGroup($group); if (!$this->userCanEdit($this->getUser())) { $set = WikiSet::newFromID($default); if ($set) { return Linker::link(SpecialPage::getTitleFor('WikiSets', $set->getId()), htmlspecialchars($set->getName())); } else { return $this->msg('centralauth-editgroup-nowikiset'); } } $select = new XmlSelect('set', 'wikiset', $default); $select->addOption($this->msg('centralauth-editgroup-noset')->text(), '0'); /** * @var $set WikiSet */ foreach ($sets as $set) { $select->addOption($set->getName(), $set->getID()); } $editlink = $this->msg('centralauth-editgroup-editsets')->parse(); return $select->getHTML() . " {$editlink}"; }
protected function _executeDelete($wgFarmer) { global $wgOut, $wgUser, $wgRequest; if (!$wgFarmer->getActiveWiki()->isDefaultWiki()) { $wgOut->wrapWikiMsg("== \$1 ==\n\$2", 'farmer-notaccessible', 'farmer-notaccessible-test'); return; } if (!MediaWikiFarmer::userIsFarmerAdmin($wgUser)) { $wgOut->wrapWikiMsg("== \$1 ==\n\$2", 'farmer-permissiondenied', 'farmer-permissiondenied-text'); return; } if ($wgRequest->wasPosted() && ($wiki = $wgRequest->getVal('wpWiki')) && $wiki != '-1') { if ($wgRequest->getCheck('wpConfirm')) { $wgOut->wrapWikiMsg('<div class="successbox">$1</div>', array('farmer-deleting', $wiki)); $log = new LogPage('farmer'); $log->addEntry('delete', $this->getTitle(), $wgRequest->getVal('wpReason'), array($wiki)); $deleteWiki = MediaWikiFarmer_Wiki::factory($wiki); $deleteWiki->deleteWiki(); } else { $wgOut->addWikiMsg('farmer-delete-confirm-wiki', $wiki); $wgOut->addHTML(Xml::openElement('form', array('method' => 'post', 'name' => 'deleteWiki')) . "\n" . Xml::buildForm(array('farmer-delete-reason' => Xml::input('wpReason', false, $wgRequest->getVal('wpReason')), 'farmer-delete-confirm' => Xml::check('wpConfirm')), 'farmer-delete-form-submit') . "\n" . Html::Hidden('wpWiki', $wiki) . "\n" . Xml::closeElement('form')); } return; } $list = $wgFarmer->getFarmList(); $wgOut->wrapWikiMsg("== \$1 ==\n\$2", 'farmer-delete-title', 'farmer-delete-text'); $select = new XmlSelect('wpWiki', false, $wgRequest->getVal('wpWiki')); $select->addOption(wfMsg('farmer-delete-form'), '-1'); foreach ($list as $wiki) { if ($wiki['name'] != $wgFarmer->getDefaultWiki()) { $name = $wiki['name']; $title = $wiki['title']; $select->addOption("{$name} - {$title}", $name); } } $wgOut->addHTML(Xml::openElement('form', array('method' => 'post', 'name' => 'deleteWiki')) . "\n" . $select->getHTML() . "\n" . Xml::submitButton(wfMsg('farmer-delete-form-submit')) . "\n" . Xml::closeElement('form')); }
/** * @return string */ function getPageHeader() { list($self) = explode('/', $this->getTitle()->getPrefixedDBkey()); $this->getOutput()->addModules('mediawiki.userSuggest'); # Form tag $out = Xml::openElement('form', array('method' => 'get', 'action' => wfScript(), 'id' => 'mw-listusers-form')) . Xml::fieldset($this->msg('listusers')->text()) . Html::hidden('title', $self); # Username field (with autocompletion support) $out .= Xml::label($this->msg('listusersfrom')->text(), 'offset') . ' ' . Html::input('username', $this->requestedUser, 'text', array('class' => 'mw-autocomplete-user', 'id' => 'offset', 'size' => 20, 'autofocus' => $this->requestedUser === '')) . ' '; # Group drop-down list $sel = new XmlSelect('group', 'group', $this->requestedGroup); $sel->addOption($this->msg('group-all')->text(), ''); foreach ($this->getAllGroups() as $group => $groupText) { $sel->addOption($groupText, $group); } $out .= Xml::label($this->msg('group')->text(), 'group') . ' '; $out .= $sel->getHTML() . '<br />'; $out .= Xml::checkLabel($this->msg('listusers-editsonly')->text(), 'editsOnly', 'editsOnly', $this->editsOnly); $out .= ' '; $out .= Xml::checkLabel($this->msg('listusers-creationsort')->text(), 'creationSort', 'creationSort', $this->creationSort); $out .= ' '; $out .= Xml::checkLabel($this->msg('listusers-desc')->text(), 'desc', 'desc', $this->mDefaultDirection); $out .= '<br />'; Hooks::run('SpecialListusersHeaderForm', array($this, &$out)); # Submit button and form bottom $out .= Html::hidden('limit', $this->mLimit); $out .= Xml::submitButton($this->msg('listusers-submit')->text()); Hooks::run('SpecialListusersHeader', array($this, &$out)); $out .= Xml::closeElement('fieldset') . Xml::closeElement('form'); return $out; }
/** * Standard language selector in Translate extension. * @param string $language Language code of the language the names should be localised to. * @param bool $labelOption * @return XmlSelect */ public static function getLanguageSelector($language, $labelOption = false) { $languages = self::getLanguageNames($language); ksort($languages); $selector = new XmlSelect(); if ($labelOption !== false) { $selector->addOption($labelOption, '-'); } foreach ($languages as $code => $name) { $selector->addOption("{$code} - {$name}", $code); } return $selector; }
/** * Returns log page selector. * @return XmlSelect * @since 1.19 */ public function getTypeSelector() { $typesByName = array(); // Temporary array // First pass to load the log names foreach (LogPage::validTypes() as $type) { $page = new LogPage($type); $restriction = $page->getRestriction(); if ($this->getUser()->isAllowed($restriction)) { $typesByName[$type] = $page->getName()->text(); } } // Second pass to sort by name asort($typesByName); // Always put "All public logs" on top $public = $typesByName['']; unset($typesByName['']); $typesByName = array('' => $public) + $typesByName; $select = new XmlSelect('type'); foreach ($typesByName as $type => $name) { $select->addOption($name, $type); } return $select; }
function execute() { global $wgCookieExpiration; $expirationDays = ceil($wgCookieExpiration / (3600 * 24)); ?> <div class="mw-ui-container"> <div id="userloginprompt"><?php $this->msgWiki('loginprompt'); ?> </div> <?php if ($this->haveData('languages')) { ?> <div id="languagelinks"> <p><?php $this->html('languages'); ?> </p> </div> <?php } ?> <div id="userloginForm"> <form name="userlogin" class="mw-ui-vform" method="post" action="<?php $this->text('action'); ?> "> <?php if ($this->data['loggedin']) { ?> <div class="warningbox"> <?php echo $this->getMsg('userlogin-loggedin')->params($this->data['loggedinuser'])->parse(); ?> </div> <?php } ?> <section class="mw-form-header"> <?php $this->html('header'); /* extensions such as ConfirmEdit add form HTML here */ ?> </section> <?php if ($this->data['message']) { ?> <div class="<?php $this->text('messagetype'); ?> box"> <?php if ($this->data['messagetype'] == 'error') { ?> <strong><?php $this->msg('loginerror'); ?> </strong> <br /> <?php } ?> <?php $this->html('message'); ?> </div> <?php } ?> <?php if ($this->data['formheader']) { ?> <div class="mw-form-formheader"> <?php $this->html('formheader'); /* extensions such as MobileFrontend add HTML here */ ?> </div> <?php } ?> <div class="mw-ui-vform-field"> <label for="wpName1"> <?php $this->msg('userlogin-yourname'); if ($this->data['secureLoginUrl']) { echo Html::element('a', ['href' => $this->data['secureLoginUrl'], 'class' => 'mw-ui-flush-right mw-secure'], $this->getMsg('userlogin-signwithsecure')->text()); } ?> </label> <?php echo Html::input('wpName', $this->data['name'], 'text', ['class' => 'loginText mw-ui-input', 'id' => 'wpName1', 'tabindex' => '1', 'required' => true, 'autofocus' => !$this->data['name'], 'placeholder' => $this->getMsg('userlogin-yourname-ph')->text()]); ?> </div> <div class="mw-ui-vform-field"> <label for="wpPassword1"> <?php $this->msg('userlogin-yourpassword'); ?> </label> <?php echo Html::input('wpPassword', null, 'password', ['class' => 'loginPassword mw-ui-input', 'id' => 'wpPassword1', 'tabindex' => '2', 'autofocus' => (bool) $this->data['name'], 'placeholder' => $this->getMsg('userlogin-yourpassword-ph')->text()]); ?> </div> <?php if (isset($this->data['usedomain']) && $this->data['usedomain']) { $select = new XmlSelect('wpDomain', false, $this->data['domain']); $select->setAttribute('tabindex', 3); foreach ($this->data['domainnames'] as $dom) { $select->addOption($dom); } ?> <div class="mw-ui-vform-field" id="mw-user-domain-section"> <label for="wpDomain"><?php $this->msg('yourdomainname'); ?> </label> <?php echo $select->getHTML(); ?> </div> <?php } ?> <?php if ($this->haveData('extrafields')) { echo $this->data['extrafields']; } ?> <div class="mw-ui-vform-field"> <?php if ($this->data['canremember']) { ?> <div class="mw-ui-checkbox"> <input name="wpRemember" type="checkbox" value="1" id="wpRemember" tabindex="4" <?php if ($this->data['remember']) { echo 'checked="checked"'; } ?> ><label for="wpRemember"> <?php echo $this->getMsg('userlogin-remembermypassword')->numParams($expirationDays)->escaped(); ?> </label> </div> <?php } ?> </div> <div class="mw-ui-vform-field"> <?php $attrs = ['id' => 'wpLoginAttempt', 'name' => 'wpLoginAttempt', 'tabindex' => '6']; $modifiers = ['mw-ui-progressive']; echo Html::submitButton($this->getMsg('pt-login-button')->text(), $attrs, $modifiers); ?> </div> <div class="mw-ui-vform-field mw-form-related-link-container" id="mw-userlogin-help"> <?php echo Html::element('a', ['href' => Skin::makeInternalOrExternalUrl(wfMessage('helplogin-url')->inContentLanguage()->text())], $this->getMsg('userlogin-helplink2')->text()); ?> </div> <?php if ($this->data['useemail'] && $this->data['canreset'] && $this->data['resetlink'] === true) { echo Html::rawElement('div', ['class' => 'mw-ui-vform-field mw-form-related-link-container'], Linker::link(SpecialPage::getTitleFor('PasswordReset'), $this->getMsg('userlogin-resetpassword-link')->escaped())); } if ($this->haveData('createOrLoginHref')) { if ($this->data['loggedin']) { ?> <div class="mw-form-related-link-container mw-ui-vform-field"> <a href="<?php $this->text('createOrLoginHref'); ?> " id="mw-createaccount-join" tabindex="7"><?php $this->msg('userlogin-createanother'); ?> </a> </div> <?php } else { ?> <div id="mw-createaccount-cta" class="mw-ui-vform-field"> <?php $this->msg('userlogin-noaccount'); ?> <a href="<?php $this->text('createOrLoginHref'); ?> " id="mw-createaccount-join" tabindex="7" class="mw-ui-button"><?php $this->msg('userlogin-joinproject'); ?> </a> </div> <?php } } // Hidden fields $fields = ''; if ($this->haveData('uselang')) { $fields .= Html::hidden('uselang', $this->data['uselang']); } if ($this->haveData('token')) { $fields .= Html::hidden('wpLoginToken', $this->data['token']); } if ($this->data['cansecurelogin']) { $fields .= Html::hidden('wpForceHttps', $this->data['stickhttps']); } if ($this->data['cansecurelogin'] && $this->haveData('fromhttp')) { $fields .= Html::hidden('wpFromhttp', $this->data['fromhttp']); } echo $fields; ?> </form> </div> </div> <?php }
/** * @param $name * @param $value * @return string */ function buildTypeSelector($name, $value) { $select = new XmlSelect($name, 'set-type', $value); foreach (array(WikiSet::OPTIN, WikiSet::OPTOUT) as $type) { $select->addOption(wfMsg("centralauth-editset-{$type}"), $type); } return $select->getHTML(); }
/** * Get a form to select the wiki to configure */ protected function getWikiSelectForm() { global $wgConfigureWikis, $wgScript; if ($wgConfigureWikis === false || !$this->isUserAllowedInterwiki()) { return ''; } $form = '<fieldset><legend>' . $this->msg('configure-select-wiki')->escaped() . '</legend>'; $form .= $this->msg('configure-select-wiki-view-desc')->parseAsBlock(); $form .= Xml::openElement('form', array('method' => 'get', 'action' => $wgScript)); $form .= Html::Hidden('title', $this->getTitle()->getPrefixedDBkey()); $all = $this->getRequest()->getVal('view', 'all') == 'all'; $form .= Xml::radioLabel($this->msg('configure-select-wiki-view-all')->text(), 'view', 'all', 'wiki-all', $all); $form .= "<br />\n"; $form .= Xml::radioLabel($this->msg('configure-select-wiki-view-specific')->text(), 'view', 'specific', 'wiki-specific', !$all) . ' '; if (is_array($wgConfigureWikis)) { $selector = new XmlSelect('wiki', 'wiki', $this->mWiki); foreach ($wgConfigureWikis as $wiki) { $selector->addOption($wiki); } $form .= $selector->getHTML() . "<br />"; } else { $form .= Xml::input('wiki', false, $this->mWiki) . "<br />"; } $form .= Xml::submitButton($this->msg('configure-select-wiki-submit')->text()); $form .= '</form></fieldset>'; return $form; }
function cutoffselector($options) { // Cast everything to strings immediately, so that we know all of the values have the same // precision, and can be compared with '==='. 2/24 has a few more decimal places than its // default string representation, for example, and would confuse comparisons. // Misleadingly, the 'days' option supports hours too. $days = array_map('strval', array(1 / 24, 2 / 24, 6 / 24, 12 / 24, 1, 3, 7)); $userWatchlistOption = (string) $this->getUser()->getOption('watchlistdays'); // add the user preference, if it isn't available already if (!in_array($userWatchlistOption, $days) && $userWatchlistOption !== '0') { $days[] = $userWatchlistOption; } $maxDays = (string) ($this->getConfig()->get('RCMaxAge') / (3600 * 24)); // add the maximum possible value, if it isn't available already if (!in_array($maxDays, $days)) { $days[] = $maxDays; } $selected = (string) $options['days']; if ($selected <= 0) { $selected = $maxDays; } // add the currently selected value, if it isn't available already if (!in_array($selected, $days)) { $days[] = $selected; } $select = new XmlSelect('days', 'days', $selected); asort($days); foreach ($days as $value) { if ($value < 1) { $name = $this->msg('hours')->numParams($value * 24)->text(); } else { $name = $this->msg('days')->numParams($value)->text(); } $select->addOption($name, $value); } return $select->getHTML() . "\n<br />\n"; }
/** * Returns query form fields. * @param $opts Form options. * @return Array of form fields. */ protected static function getQueryFormFields( FormOptions $opts ) { global $wgWikilogEnableTags; $fields = array(); $fields['wikilog'] = Xml::inputLabelSep( wfMsg( 'wikilog-form-wikilog' ), 'wikilog', 'wl-wikilog', 40, str_replace( '_', ' ', $opts->consumeValue( 'wikilog' ) ) ); $fields['category'] = Xml::inputLabelSep( wfMsg( 'wikilog-form-category' ), 'category', 'wl-category', 40, str_replace( '_', ' ', $opts->consumeValue( 'category' ) ) ); $fields['author'] = Xml::inputLabelSep( wfMsg( 'wikilog-form-author' ), 'author', 'wl-author', 40, str_replace( '_', ' ', $opts->consumeValue( 'author' ) ) ); if ( $wgWikilogEnableTags ) { $fields['tag'] = Xml::inputLabelSep( wfMsg( 'wikilog-form-tag' ), 'tag', 'wl-tag', 40, str_replace( '_', ' ', $opts->consumeValue( 'tag' ) ) ); } $fields['date'] = array( Xml::label( wfMsg( 'wikilog-form-date' ), 'wl-month' ), Xml::monthSelector( $opts->consumeValue( 'month' ), '', 'wl-month' ) . " " . Xml::input( 'year', 4, $opts->consumeValue( 'year' ), array( 'maxlength' => 4 ) ) ); $opts->consumeValue( 'day' ); // ignore day, not really useful $statusSelect = new XmlSelect( 'show', 'wl-status', $opts->consumeValue( 'show' ) ); $statusSelect->addOption( wfMsg( 'wikilog-show-all' ), 'all' ); $statusSelect->addOption( wfMsg( 'wikilog-show-published' ), 'published' ); $statusSelect->addOption( wfMsg( 'wikilog-show-drafts' ), 'drafts' ); $fields['status'] = array( Xml::label( wfMsg( 'wikilog-form-status' ), 'wl-status' ), $statusSelect->getHTML() ); $fields['submit'] = Xml::submitbutton( wfMsg( 'allpagessubmit' ) ); return $fields; }