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' ); }
function getInputHTML($value) { $datalist = new XmlSelect(false, $this->mName . '-datalist'); $datalist->setTagName('datalist'); $datalist->addOptions($this->getOptions()); return parent::getInputHTML($value) . $datalist->getHTML(); }
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 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()); } }
function getInputHTML($value) { $valInSelect = false; if ($value !== false) { $value = strval($value); $valInSelect = in_array($value, HTMLFormField::flattenOptions($this->getOptions()), true); } $selected = $valInSelect ? $value : 'other'; $select = new XmlSelect($this->mName, $this->mID, $selected); $select->addOptions($this->getOptions()); $select->setAttribute('class', 'mw-htmlform-select-or-other'); $tbAttribs = array('id' => $this->mID . '-other', 'size' => $this->getSize()); if (!empty($this->mParams['disabled'])) { $select->setAttribute('disabled', 'disabled'); $tbAttribs['disabled'] = 'disabled'; } if (isset($this->mParams['tabindex'])) { $select->setAttribute('tabindex', $this->mParams['tabindex']); $tbAttribs['tabindex'] = $this->mParams['tabindex']; } $select = $select->getHTML(); if (isset($this->mParams['maxlength'])) { $tbAttribs['maxlength'] = $this->mParams['maxlength']; } if ($this->mClass !== '') { $tbAttribs['class'] = $this->mClass; } $textbox = Html::input($this->mName . '-other', $valInSelect ? '' : $value, 'text', $tbAttribs); return "{$select}<br />\n{$textbox}"; }
/** * 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(); }
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(); }
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"); }
function constructCreateForm() { global $wgOut, $wgScript; global $wgUserProperties, $wgActivityModes; $wgOut->addHTML(Xml::openElement('form', array('action' => $this->getTitle()->getLocalURL(), 'method' => 'post'))); $wgOut->addHTML(Xml::element('h2', null, wfMsg('nss-create-account-header')) . "\n"); $wgOut->addHTML("<table border=\"1\" id=\"newuser\">\n"); $props = array_merge(array('username', 'email'), $wgUserProperties); foreach ($props as $i) { $msg = 'am-' . $i; $wgOut->addHTML("\t<tr><th>" . (wfEmptyMsg($msg, wfMsg($msg)) ? $i : wfMsgHtml($msg)) . "</th><td>" . Xml::input("am-" . str_replace(' ', '_', $i), 40) . "</td></tr>\n"); } global $wgActivityModes; $select = new XmlSelect("am-active"); $select->setDefault('active'); $select->setAttribute('width', '100%'); foreach ($wgActivityModes as $key) { $select->addOption($key); } $wgOut->addHTML("\t<tr><th>" . wfMsgHtml('am-active') . "</th><td>" . $select->getHTML() . "</td></tr>\n"); $wgOut->addHTML("</table>\n"); $wgOut->addHTML("<div id=\"newaccount-submit\">\n" . Html::Hidden('action', 'create') . Xml::checkLabel(wfMsg('nss-no-mail'), 'nss-no-mail', 'nss-no-mail') . "<br />\n" . Xml::element('input', array('type' => 'submit', 'value' => wfMsg('nss-create-account'))) . "</div>\n</form>\n"); $wgOut->addHTML(Xml::openElement('form', array('action' => $this->getTitle()->getLocalURL(), 'method' => 'post'))); $wgOut->addHTML("<div id=\"newaccount-raw\">\n" . Xml::textarea('nss-create-account-raw', '') . "\n" . Html::Hidden('action', 'create-raw') . Xml::checkLabel(wfMsg('nss-no-mail'), 'nss-no-mail', 'nss-no-mail') . "<br />\n" . Xml::element('input', array('type' => 'submit', 'value' => wfMsg('nss-create-account'))) . "</div>\n</form>\n"); }
/** * Executes the special page * * @param $param string the parameter passed in the url */ public function execute($param) { $out = $this->getOutput(); $title = Title::newFromText($param); if ($title) { $pageId = $title->getArticleID(); } else { $out->addWikiMsg('articlefeedbackv5-invalid-page-id'); return; } $ratings = $this->fetchOverallRating($pageId); $found = isset($ratings['found']) ? $ratings['found'] : null; $rating = isset($ratings['rating']) ? $ratings['rating'] : null; $out->setPagetitle($this->msg('articlefeedbackv5-special-pagetitle', $title)->escaped()); if (!$pageId) { $out->addWikiMsg('articlefeedbackv5-invalid-page-id'); } else { # TODO: Fix links. $out->addHTML(Html::openElement('div', array('id' => 'articleFeedbackv5-header-links')) . Linker::link(Title::newFromText($param), $this->msg('articlefeedbackv5-go-to-article')->escaped()) . ' | ' . Linker::link(Title::newFromText($param), $this->msg('articlefeedbackv5-discussion-page')->escaped()) . ' | ' . Linker::link(Title::newFromText($param), $this->msg('articlefeedbackv5-whats-this')->escaped()) . Html::closeElement('div')); } $out->addHTML(Html::openElement('div', array('id' => 'articleFeedbackv5-showing-count-wrap')) . $this->msg('articlefeedbackv5-special-showing', Html::element('span', array('id' => 'articleFeedbackv5-feedback-count-total'), '0')) . Html::closeElement('div')); if ($found) { $out->addHtml(Html::openElement('div', array('id' => 'articleFeedbackv5-percent-found-wrap')) . $this->msg('articlefeedbackv5-percent-found', $found)->escaped() . Html::closeElement('div')); } # if ( $rating ) { # $out->addWikiMsg( 'articlefeedbackv5-overall-rating', $rating ); # } $out->addWikiMsg('articlefeedbackv5-special-title'); $out->addJsConfigVars('afPageId', $pageId); $out->addModules('jquery.articleFeedbackv5.special'); $sortLabels = array(); $sortOpts = array('newest', 'oldest'); foreach ($sortOpts as $sort) { $sortLabels[] = Html::element('a', array('href' => '#', 'id' => 'articleFeedbackv5-special-sort-' . $sort, 'class' => 'articleFeedbackv5-sort-link'), $this->msg('articlefeedbackv5-special-sort-' . $sort)->text()); } $opts = array(); $counts = $this->getFilterCounts($pageId); foreach ($this->filters as $filter) { $count = isset($counts[$filter]) ? $counts[$filter] : 0; $key = $this->msg('articlefeedbackv5-special-filter-' . $filter, $count)->escaped(); $opts[(string) $key] = $filter; } $filterSelect = new XmlSelect(false, 'articleFeedbackv5-filter'); $filterSelect->addOptions($opts); $out->addHTML(Html::openElement('div', array('id' => 'articleFeedbackv5-sort-filter-controls')) . $this->msg('articlefeedbackv5-special-sort-label-before')->escaped() . implode($this->msg('pipe-separator')->escaped(), $sortLabels) . $this->msg('articlefeedbackv5-special-sort-label-after')->escaped() . $this->msg('articlefeedbackv5-special-filter-label-before')->escaped() . $filterSelect->getHTML() . $this->msg('articlefeedbackv5-special-filter-label-after')->escaped() . Html::element('a', array('href' => '#', 'id' => 'articleFeedbackv5-special-add-feedback'), $this->msg('articlefeedbackv5-special-add-feedback')->text()) . Html::closeElement('div')); $out->addHTML(Html::element('div', array('id' => 'articleFeedbackv5-show-feedback')) . Html::element('a', array('href' => '#', 'id' => 'articleFeedbackv5-show-more'), $this->msg('articlefeedbackv5-special-more')->text())); }
/** * 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; }
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; }
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; }
/** * Returns the whole input element and injects needed JavaScript * @throws MWException * @return string Html code. */ public function getHtmlAndPrepareJS() { if ($this->sourceId === false) { if (is_callable(array($this->select, 'getAttribute'))) { $this->sourceId = $this->select->getAttribute['id']; } if (!$this->sourceId) { throw new MWException("ID needs to be specified for the selector"); } } self::injectJs(); $html = $this->select->getHtml(); $html .= $this->getButton($this->msg, $this->sourceId, $this->targetId); return $html; }
/** * @covers XmlSelect::setAttribute * @covers XmlSelect::getAttribute */ public function testGetAttributes() { # create some attributes $this->select->setAttribute('dummy', 0x777); $this->select->setAttribute('string', 'euro €'); $this->select->setAttribute(1911, 'razor'); # verify we can retrieve them $this->assertEquals($this->select->getAttribute('dummy'), 0x777); $this->assertEquals($this->select->getAttribute('string'), 'euro €'); $this->assertEquals($this->select->getAttribute(1911), 'razor'); # inexistant keys should give us 'null' $this->assertEquals($this->select->getAttribute('I DO NOT EXIT'), null); # verify string / integer $this->assertEquals($this->select->getAttribute('1911'), 'razor'); $this->assertEquals($this->select->getAttribute('dummy'), 0x777); }
function getInputHTML($value) { $select = new XmlSelect($this->mName, $this->mID, strval($value)); if (!empty($this->mParams['disabled'])) { $select->setAttribute('disabled', 'disabled'); } if (isset($this->mParams['tabindex'])) { $select->setAttribute('tabindex', $this->mParams['tabindex']); } if ($this->mClass !== '') { $select->setAttribute('class', $this->mClass); } $select->addOptions($this->getOptions()); return $select->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 getInputHTML($value) { $select = new XmlSelect($this->mName, $this->mID, strval($value)); if (!empty($this->mParams['disabled'])) { $select->setAttribute('disabled', 'disabled'); } $allowedParams = ['tabindex', 'size']; $customParams = $this->getAttributes($allowedParams); foreach ($customParams as $name => $value) { $select->setAttribute($name, $value); } if ($this->mClass !== '') { $select->setAttribute('class', $this->mClass); } $select->addOptions($this->getOptions()); return $select->getHTML(); }
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"; }
/** * @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}"; }
/** * Get a "<select>" element which has options for each of the allowed limits * * @param $attribs String: Extra attributes to set * @return String: HTML fragment */ public function getLimitSelect( $attribs = array() ) { $select = new XmlSelect( 'limit', false, $this->mLimit ); $select->addOptions( $this->getLimitSelectList() ); foreach ( $attribs as $name => $value ) { $select->setAttribute( $name, $value ); } return $select->getHTML(); }
/** * @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(); }
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')); }
/** * 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; }
/** * 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; }
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())); }