/** * Display form for testing spell checking feature */ function spellCheckingForm($languages) { $fields = array('text' => array('class' => 'HTMLTextField', 'label-message' => 'spellchecker-info-spellcheck-text'), 'lang' => array('class' => 'HTMLSelectField', 'label-message' => 'spellchecker-info-spellcheck-languages', 'options' => array_combine($languages, $languages))); $form = new HTMLForm($fields); $form->setTitle($this->title); $form->setSubmitText($this->app->runFunction('wfMsg', 'spellchecker-info-spellcheck-submit')); $form->loadData(); $form->displayForm(''); // page was POSTed, perform spell cheking if ($this->request->wasPosted()) { $text = $this->request->getText('wptext'); $langCode = $this->request->getText('wplang'); // create spell checking service $service = new SpellCheckerService($langCode); $info = $service->getInfo(); // check the spelling (returns true or array of spelling suggestions) $data = $service->checkWord($text); // print out results if ($data === true) { $result = $this->app->runFunction('wfMsg', 'spellchecker-info-spellcheck-is-correct', $text); } else { $result = $this->app->runFunction('wfMsg', 'spellchecker-info-spellcheck-suggestions', $text, implode(', ', $data)); } $this->out->addHtml("<p>{$result}</p>"); $this->out->addHtml("<p><small>{$info['desc']} / {$info['lang']}</small></p>"); } }
/** * Main execution point * * @param string $par title fragment */ public function execute($par) { $this->setHeaders(); $this->outputHeader(); $out = $this->getOutput(); $lang = $this->getLanguage(); $out->setPageTitle($this->msg('ipblocklist')); $out->addModuleStyles('mediawiki.special'); $request = $this->getRequest(); $par = $request->getVal('ip', $par); $this->target = trim($request->getVal('wpTarget', $par)); $this->options = $request->getArray('wpOptions', array()); $action = $request->getText('action'); if ($action == 'unblock' || $action == 'submit' && $request->wasPosted()) { # B/C @since 1.18: Unblock interface is now at Special:Unblock $title = SpecialPage::getTitleFor('Unblock', $this->target); $out->redirect($title->getFullURL()); return; } # Just show the block list $fields = array('Target' => array('type' => 'text', 'label-message' => 'ipadressorusername', 'tabindex' => '1', 'size' => '45', 'default' => $this->target), 'Options' => array('type' => 'multiselect', 'options' => array($this->msg('blocklist-userblocks')->text() => 'userblocks', $this->msg('blocklist-tempblocks')->text() => 'tempblocks', $this->msg('blocklist-addressblocks')->text() => 'addressblocks', $this->msg('blocklist-rangeblocks')->text() => 'rangeblocks'), 'flatlist' => true), 'Limit' => array('class' => 'HTMLBlockedUsersItemSelect', 'label-message' => 'table_pager_limit_label', 'options' => array($lang->formatNum(20) => 20, $lang->formatNum(50) => 50, $lang->formatNum(100) => 100, $lang->formatNum(250) => 250, $lang->formatNum(500) => 500), 'name' => 'limit', 'default' => 50)); $form = new HTMLForm($fields, $this->getContext()); $form->setTitle($this->getTitle()); // Remove subpage $form->setMethod('get'); $form->setWrapperLegendMsg('ipblocklist-legend'); $form->setSubmitTextMsg('ipblocklist-submit'); $form->prepareForm(); $form->displayForm(''); $this->showList(); }
public function show($par) { $formFields = array('account' => array('type' => 'text', 'validation-callback' => array(__CLASS__, 'validateUser'), 'label-message' => 'disableaccount-user'), 'confirm' => array('type' => 'toggle', 'validation-callback' => array(__CLASS__, 'checkConfirmation'), 'label-message' => 'disableaccount-confirm')); $htmlForm = new HTMLForm($formFields, 'disableaccount'); $htmlForm->setSubmitCallback(array(__CLASS__, 'submit')); $htmlForm->setTitle($this->getTitle()); $htmlForm->show(); }
function execute($par) { global $wgOut, $wgUser, $wgEmailAuthentication; $this->setHeaders(); if (!$this->userCanExecute($wgUser)) { $this->displayRestrictionError(); return; } $error = SpecialEmailUser::getPermissionsError($wgUser, $wgUser->editToken()); if ($error) { switch ($error) { case 'blockedemailuser': $wgOut->blockedPage(); return; case 'actionthrottledtext': $wgOut->rateLimited(); return; case 'mailnologin': $wgOut->showErrorPage('mailnologin', 'mailnologintext'); return; default: list($title, $msg, $params) = $error; $wgOut->showErrorPage($title, $msg, $params); return; } } $dbr = wfGetDB(DB_SLAVE); # $conds can be not that strict but cannot be too strict. $conds = array("user_email <> ''"); if ($wgEmailAuthentication) { $conds[] = 'user_email_authenticated IS NOT NULL'; } $res = $dbr->select('user', '*', $conds); $users = UserArray::newFromResult($res); $usernames = array(); foreach ($users as $user) { if ($user->canReceiveEmail() && $user->getId() != $wgUser->getId()) { $usernames[$user->getName()] = $user->getId(); } } $this->userIds = array_values($usernames); if (empty($usernames)) { # No one to send mail to $wgOut->addWikiMsg('emailusers-norecipient'); $wgOut->returnToMain(); return; } $form = array('target' => array('type' => 'multiselect', 'label-message' => 'emailto', 'options' => $usernames, 'validation-callback' => array($this, 'validateTarget')), 'target-reverse' => array('type' => 'check', 'default' => true, 'label-message' => 'emailusers-target-reverse'), 'subject' => array('type' => 'text', 'default' => wfMsg('defemailsubject'), 'label-message' => 'emailsubject'), 'text' => array('type' => 'textarea', 'label-message' => 'emailmessage'), 'ccme' => array('type' => 'check', 'default' => $wgUser->getOption('ccmeonemails'), 'label-message' => 'emailccme')); $htmlForm = new HTMLForm($form); $htmlForm->setTitle($this->getTitle($par)); $htmlForm->setSubmitCallback(array($this, 'submit')); $this->outputHeader(); if ($htmlForm->show()) { $wgOut->addWikiMsg('emailsenttext'); $htmlForm->displayForm(false); } }
function buildForm() { $form = new HTMLForm($this->getFormFields(), 'lqt-' . $this->getPageName()); $par = $this->mThread->title()->getPrefixedText(); $form->setSubmitText($this->getSubmitText()); $form->setTitle(SpecialPage::getTitleFor($this->getPageName(), $par)); $form->setSubmitCallback(array($this, 'trySubmit')); return $form; }
public function execute($par) { $this->setHeaders(); $this->outputHeader(); $out = $this->getOutput(); $out->addModuleStyles('mediawiki.special'); $this->mTarget = is_null($par) ? $this->getRequest()->getVal('wpTarget', $this->getRequest()->getVal('target', '')) : $par; // error out if sending user cannot do this $error = self::getPermissionsError($this->getUser(), $this->getRequest()->getVal('wpEditToken')); switch ($error) { case null: # Wahey! break; case 'badaccess': throw new PermissionsError('sendemail'); case 'blockedemailuser': throw new UserBlockedError($this->getUser()->mBlock); case 'actionthrottledtext': throw new ThrottledError(); case 'mailnologin': case 'usermaildisabled': throw new ErrorPageError($error, "{$error}text"); default: # It's a hook error list($title, $msg, $params) = $error; throw new ErrorPageError($title, $msg, $params); } // Got a valid target user name? Else ask for one. $ret = self::getTarget($this->mTarget); if (!$ret instanceof User) { if ($this->mTarget != '') { $ret = $ret == 'notarget' ? 'emailnotarget' : $ret . 'text'; $out->wrapWikiMsg("<p class='error'>\$1</p>", $ret); } $out->addHTML($this->userForm($this->mTarget)); return false; } $this->mTargetObj = $ret; $form = new HTMLForm($this->getFormFields(), $this->getContext()); $form->addPreText(wfMsgExt('emailpagetext', 'parseinline')); $form->setSubmitText(wfMsg('emailsend')); $form->setTitle($this->getTitle()); $form->setSubmitCallback(array(__CLASS__, 'submit')); $form->setWrapperLegend(wfMsgExt('email-legend', 'parsemag')); $form->loadData(); if (!wfRunHooks('EmailUserForm', array(&$form))) { return false; } $out->setPageTitle($this->msg('emailpage')); $result = $form->show(); if ($result === true || $result instanceof Status && $result->isGood()) { $out->setPageTitle($this->msg('emailsent')); $out->addWikiMsg('emailsenttext'); $out->returnToMain(false, $this->mTargetObj->getUserPage()); } }
private function showResetForm() { $this->getOutput()->addWikiMsg('prefs-reset-intro'); $htmlForm = new HTMLForm(array(), $this->getContext(), 'prefs-restore'); $htmlForm->setSubmitText(wfMsg('restoreprefs')); $htmlForm->setTitle($this->getTitle('reset')); $htmlForm->setSubmitCallback(array($this, 'submitReset')); $htmlForm->suppressReset(); $htmlForm->show(); }
function execute($par) { global $wgRequest; $this->setHeaders(); $form = new HTMLForm(array('TitleText' => array('type' => 'text', 'label-message' => 'luafoo-convert-title'))); $form->setSubmitText(wfMsg('luafoo-convert-submit')); $form->setSubmitCallback(array($this, 'showTranslation')); $form->setTitle($this->getTitle()); $form->show(); }
public function execute($par) { $this->checkPermissions(); $this->setHeaders(); $form = new HTMLForm(array('dbname' => array('default' => $par, 'filter-callback' => array('SpecialCreateWiki', 'filter'), 'label-message' => 'createwiki-label-dbname', 'maxlength' => 30, 'required' => true, 'size' => 30, 'type' => 'text', 'validation-callback' => array('SpecialCreateWiki', 'validateDBname')), 'founder' => array('filter-callback' => array('SpecialCreateWiki', 'filter'), 'label-message' => 'createwiki-label-founder', 'required' => true, 'size' => 30, 'type' => 'text', 'validation-callback' => array('SpecialCreateWiki', 'validateFounder')), 'comment' => array('label-message' => 'createwiki-label-comment', 'maxlength' => 79, 'size' => 79, 'type' => 'text'))); $form->setSubmitTextMsg('createwiki-label-create'); $form->setTitle($this->getPageTitle()); $form->setSubmitCallback(array('SpecialCreateWiki', 'processInput')); $form->show(); }
public function execute($par) { global $wgRequest, $wgOut, $wgUser; $this->setHeaders(); $this->outputHeader(); $this->mTarget = is_null($par) ? $wgRequest->getVal('wpTarget', $wgRequest->getVal('target', '')) : $par; $ret = self::getTarget($this->mTarget); if ($ret instanceof User) { $this->mTargetObj = $ret; } else { $wgOut->showErrorPage("{$ret}title", "{$ret}text"); return false; } $error = self::getPermissionsError($wgUser, $wgRequest->getVal('wpEditToken')); switch ($error) { case null: # Wahey! break; case 'badaccess': $wgOut->permissionRequired('sendemail'); return; case 'blockedemailuser': $wgOut->blockedPage(); return; case 'actionthrottledtext': $wgOut->rateLimited(); return; case 'mailnologin': case 'usermaildisabled': $wgOut->showErrorPage($error, "{$error}text"); return; default: # It's a hook error list($title, $msg, $params) = $error; $wgOut->showErrorPage($title, $msg, $params); return; } $form = new HTMLForm($this->getFormFields()); $form->addPreText(wfMsgExt('emailpagetext', 'parseinline')); $form->setSubmitText(wfMsg('emailsend')); $form->setTitle($this->getTitle()); $form->setSubmitCallback(array(__CLASS__, 'submit')); $form->setWrapperLegend(wfMsgExt('email-legend', 'parsemag')); $form->loadData(); if (!wfRunHooks('EmailUserForm', array(&$form))) { return false; } $wgOut->setPagetitle(wfMsg('emailpage')); $result = $form->show(); if ($result === true || $result instanceof Status && $result->isGood()) { $wgOut->setPagetitle(wfMsg('emailsent')); $wgOut->addWikiMsg('emailsenttext'); $wgOut->returnToMain(false, $this->mTargetObj->getUserPage()); } }
function execute($par) { global $wgOut; $wgOut->setPageTitle(wfMsg('communityhiring-header')); $formDescriptor = array('about-intro' => array('type' => 'info', 'default' => wfMsgExt('communityhiring-about-intro', 'parse'), 'raw' => 1, 'section' => 'aboutyou'), 'given-name' => array('type' => 'text', 'label-message' => 'communityhiring-given', 'section' => 'aboutyou', 'validation-callback' => array($this, 'validateRequired')), 'family-name' => array('type' => 'text', 'label-message' => 'communityhiring-family', 'section' => 'aboutyou', 'validation-callback' => array($this, 'validateRequired')), 'address-line1' => array('type' => 'textarea', 'label-message' => 'communityhiring-address', 'section' => 'aboutyou', 'rows' => '3', 'cols' => '20'), 'address-city' => array('type' => 'text', 'label-message' => 'communityhiring-address-city', 'section' => 'aboutyou', 'validation-callback' => array($this, 'validateRequired')), 'address-postal' => array('type' => 'text', 'label-message' => 'communityhiring-address-postal', 'section' => 'aboutyou'), 'address-country' => array('type' => 'text', 'label-message' => 'communityhiring-address-country', 'section' => 'aboutyou', 'validation-callback' => array($this, 'validateRequired')), 'phone' => array('type' => 'text', 'label-message' => 'communityhiring-phone', 'section' => 'aboutyou'), 'email' => array('type' => 'text', 'label-message' => 'communityhiring-email', 'section' => 'aboutyou', 'validation-callback' => array($this, 'validateRequired')), 'paragraph-intro' => array('type' => 'info', 'default' => wfMsgExt('communityhiring-paragraphs-intro', 'parse'), 'raw' => 1, 'section' => 'paragraphs', 'vertical-label' => 1, 'validation-callback' => array($this, 'validateRequired')), 'significance' => array('type' => 'textarea', 'label-message' => 'communityhiring-significance', 'section' => 'paragraphs', 'rows' => 10, 'vertical-label' => 1, 'validation-callback' => array($this, 'validateRequired')), 'excitement' => array('type' => 'textarea', 'label-message' => 'communityhiring-excitement', 'section' => 'paragraphs', 'rows' => 10, 'vertical-label' => 1, 'validation-callback' => array($this, 'validateRequired')), 'experiences' => array('type' => 'textarea', 'label-message' => 'communityhiring-experiences', 'section' => 'paragraphs', 'rows' => 10, 'vertical-label' => 1, 'validation-callback' => array($this, 'validateRequired')), 'other' => array('type' => 'textarea', 'label-message' => 'communityhiring-other', 'section' => 'paragraphs', 'rows' => 10, 'vertical-label' => 1), 'languages' => array('type' => 'textarea', 'options' => array_flip(Language::getLanguageNames()), 'section' => 'demonstrative/languages', 'rows' => '3', 'label-message' => 'communityhiring-languages-label', 'vertical-label' => 1, 'validation-callback' => array($this, 'validateRequired')), 'contributor' => array('type' => 'radio', 'label-message' => 'communityhiring-contributor', 'section' => 'demonstrative/involvement', 'options' => array('Yes' => 'yes', 'No' => 'no')), 'usernames' => array('type' => 'textarea', 'rows' => '3', 'cols' => '20', 'label-message' => 'communityhiring-usernames', 'section' => 'demonstrative/involvement', 'vertical-label' => 1), 'wikimedia-links' => array('type' => 'textarea', 'label-message' => 'communityhiring-links', 'section' => 'demonstrative/involvement', 'rows' => '3', 'cols' => '20', 'vertical-label' => 1), 'other-links' => array('type' => 'textarea', 'label-message' => 'communityhiring-links-other', 'section' => 'demonstrative', 'rows' => '3', 'cols' => '20', 'vertical-label' => 1), 'availability-time' => array('type' => 'text', 'label-message' => 'communityhiring-availability-intro', 'section' => 'availability', 'vertical-label' => 1, 'validation-callback' => array($this, 'validateRequired')), 'availability-info' => array('type' => 'textarea', 'label-message' => 'communityhiring-availability-info', 'section' => 'availability', 'rows' => '5', 'cols' => '20', 'vertical-label' => 1), 'relocation' => array('type' => 'radio', 'label-message' => 'communityhiring-relocation-ok', 'section' => 'availability', 'vertical-label' => 1, 'options' => array('Yes' => 'yes', 'No' => 'no', 'It would be hard, but maybe I would' => 'maybe')), 'research' => array('type' => 'textarea', 'rows' => '5', 'label-message' => 'communityhiring-research', 'vertical-label' => 1, 'validation-callback' => array($this, 'validateRequired'))); $form = new HTMLForm($formDescriptor, 'communityhiring'); $form->setIntro(wfMsgExt('communityhiring-intro', 'parse')); $form->setSubmitCallback(array($this, 'submit')); $form->setTitle($this->getTitle()); $form->show(); }
function showResetForm() { global $wgOut; $wgOut->addWikiMsg('prefs-reset-intro'); $htmlForm = new HTMLForm(array(), 'prefs-restore'); $htmlForm->setSubmitText(wfMsg('restoreprefs')); $htmlForm->setTitle($this->getTitle('reset')); $htmlForm->setSubmitCallback(array(__CLASS__, 'submitReset')); $htmlForm->suppressReset(); $htmlForm->show(); }
/** * Show a form for filtering namespace and username * * @param $par String * @return String */ public function execute($par) { $this->setHeaders(); $this->outputHeader(); $form = new HTMLForm(array('Page1' => array('type' => 'text', 'name' => 'page1', 'label-message' => 'compare-page1', 'size' => '40', 'section' => 'page1'), 'Revision1' => array('type' => 'int', 'name' => 'rev1', 'label-message' => 'compare-rev1', 'size' => '8', 'section' => 'page1'), 'Page2' => array('type' => 'text', 'name' => 'page2', 'label-message' => 'compare-page2', 'size' => '40', 'section' => 'page2'), 'Revision2' => array('type' => 'int', 'name' => 'rev2', 'label-message' => 'compare-rev2', 'size' => '8', 'section' => 'page2'), 'Action' => array('type' => 'hidden', 'name' => 'action'), 'Diffonly' => array('type' => 'hidden', 'name' => 'diffonly')), 'compare'); $form->setSubmitText(wfMsg('compare-submit')); $form->suppressReset(); $form->setMethod('get'); $form->setTitle($this->getTitle()); $form->loadData(); $form->displayForm(''); self::showDiff($form->mFieldData); }
/** * Get a form for editing the watchlist in "raw" mode * * @return HTMLForm */ protected function getRawForm() { $titles = implode($this->getWatchlist(), "\n"); $fields = array('Titles' => array('type' => 'textarea', 'label-message' => 'watchlistedit-raw-titles', 'default' => $titles)); $form = new HTMLForm($fields, $this->getContext()); $form->setTitle($this->getTitle('raw')); $form->setSubmitTextMsg('watchlistedit-raw-submit'); # Used message keys: 'accesskey-watchlistedit-raw-submit', 'tooltip-watchlistedit-raw-submit' $form->setSubmitTooltip('watchlistedit-raw-submit'); $form->setWrapperLegendMsg('watchlistedit-raw-legend'); $form->addHeaderText($this->msg('watchlistedit-raw-explain')->parse()); $form->setSubmitCallback(array($this, 'submitRaw')); return $form; }
/** * Default action when we don't have a subpage -- just show links to the uploads we have, * Also show a button to clear stashed files * @param Status : $status - the result of processRequest */ private function showUploads($status = null) { global $wgOut; if ($status === null) { $status = Status::newGood(); } // sets the title, etc. $this->setHeaders(); $this->outputHeader(); // create the form, which will also be used to execute a callback to process incoming form data // this design is extremely dubious, but supposedly HTMLForm is our standard now? $form = new HTMLForm(array('Clear' => array('type' => 'hidden', 'default' => true, 'name' => 'clear')), 'clearStashedUploads'); $form->setSubmitCallback(array(__CLASS__, 'tryClearStashedUploads')); $form->setTitle($this->getTitle()); $form->setSubmitText(wfMsg('uploadstash-clear')); $form->prepareForm(); $formResult = $form->tryAuthorizedSubmit(); // show the files + form, if there are any, or just say there are none $refreshHtml = Html::element('a', array('href' => $this->getTitle()->getLocalURL()), wfMsg('uploadstash-refresh')); $files = $this->stash->listFiles(); if (count($files)) { sort($files); $fileListItemsHtml = ''; foreach ($files as $file) { // TODO: Use Linker::link or even construct the list in plain wikitext $fileListItemsHtml .= Html::rawElement('li', array(), Html::element('a', array('href' => $this->getTitle("file/{$file}")->getLocalURL()), $file)); } $wgOut->addHtml(Html::rawElement('ul', array(), $fileListItemsHtml)); $form->displayForm($formResult); $wgOut->addHtml(Html::rawElement('p', array(), $refreshHtml)); } else { $wgOut->addHtml(Html::rawElement('p', array(), Html::element('span', array(), wfMsg('uploadstash-nofiles')) . ' ' . $refreshHtml)); } return true; }
/** * @return bool */ function addHost() { $this->setHeaders(); $this->getOutput()->setPagetitle($this->msg('openstackmanager-addhost')); $project = $this->getRequest()->getText('project'); $region = $this->getRequest()->getText('region'); if (!$this->userLDAP->inRole('projectadmin', $project)) { $this->notInRole('projectadmin', $project); return false; } $id = $this->getRequest()->getText('id'); $addressInfo = array(); $addressInfo['project'] = array('type' => 'hidden', 'default' => $project, 'name' => 'project'); $addressInfo['region'] = array('type' => 'hidden', 'default' => $region, 'name' => 'region'); $addressInfo['id'] = array('type' => 'hidden', 'default' => $id, 'name' => 'id'); $addressInfo['hostname'] = array('type' => 'text', 'default' => '', 'validation-callback' => array($this, 'validateDomain'), 'label-message' => 'openstackmanager-hostname', 'name' => 'hostname'); $domains = OpenStackNovaDomain::getAllDomains('public'); $domain_keys = array(); foreach ($domains as $domain) { $domainname = $domain->getDomainName(); $domain_keys[$domainname] = $domainname; } $addressInfo['domain'] = array('type' => 'select', 'options' => $domain_keys, 'label-message' => 'openstackmanager-dnsdomain', 'name' => 'domain'); $addressInfo['action'] = array('type' => 'hidden', 'default' => 'addhost', 'name' => 'action'); $addressForm = new HTMLForm($addressInfo, $this->getContext(), 'openstackmanager-novaaddress'); $addressForm->setTitle(SpecialPage::getTitleFor('NovaAddress')); $addressForm->setSubmitID('novaaddress-form-addhostsubmit'); $addressForm->setSubmitCallback(array($this, 'tryAddHostSubmit')); $addressForm->show(); return true; }
/** * Get a form for editing the watchlist in "raw" mode * * @return HTMLForm */ protected function getRawForm() { $titles = implode($this->getWatchlist(), "\n"); $fields = array('Titles' => array('type' => 'textarea', 'label-message' => 'watchlistedit-raw-titles', 'default' => $titles)); $form = new HTMLForm($fields); $form->setTitle($this->getTitle('raw')); $form->setSubmitText(wfMessage('watchlistedit-raw-submit')->text()); $form->setWrapperLegend(wfMessage('watchlistedit-raw-legend')->text()); $form->addHeaderText(wfMessage('watchlistedit-raw-explain')->parse()); $form->setSubmitCallback(array($this, 'submitRaw')); return $form; }
function getForm() { $fields = array(); $fields['limit'] = array('type' => 'select', 'name' => 'limit', 'label-message' => 'table_pager_limit_label', 'options' => $this->getLimitSelectList(), 'default' => $this->mLimit); if (!$this->getConfig()->get('MiserMode')) { $fields['ilsearch'] = array('type' => 'text', 'name' => 'ilsearch', 'id' => 'mw-ilsearch', 'label-message' => 'listfiles_search_for', 'default' => $this->mSearch, 'size' => '40', 'maxlength' => '255'); } $this->getOutput()->addModules('mediawiki.userSuggest'); $fields['user'] = array('type' => 'text', 'name' => 'user', 'id' => 'mw-listfiles-user', 'label-message' => 'username', 'default' => $this->mUserName, 'size' => '40', 'maxlength' => '255', 'cssclass' => 'mw-autocomplete-user'); $fields['ilshowall'] = array('type' => 'check', 'name' => 'ilshowall', 'id' => 'mw-listfiles-show-all', 'label-message' => 'listfiles-show-all', 'default' => $this->mShowAll); $query = $this->getRequest()->getQueryValues(); unset($query['title']); unset($query['limit']); unset($query['ilsearch']); unset($query['ilshowall']); unset($query['user']); $form = new HTMLForm($fields, $this->getContext()); $form->setMethod('get'); $form->setTitle($this->getTitle()); $form->setId('mw-listfiles-form'); $form->setWrapperLegendMsg('listfiles'); $form->setSubmitTextMsg('table_pager_limit_submit'); $form->addHiddenFields($query); $form->prepareForm(); $form->displayForm(''); }
/** * Show the survey. * * @since 0.1 * * @param Survey $survey */ protected function showSurvey(Survey $survey) { $fields = array(); $fields[] = array('type' => 'hidden', 'default' => $survey->getId(), 'name' => 'survey-id', 'id' => 'survey-id'); $fields[] = array('type' => 'hidden', 'default' => $survey->getField('name'), 'name' => 'survey-name', 'id' => 'survey-name'); $fields[] = array('type' => 'hidden', 'default' => $survey->getField('expiry'), 'name' => 'survey-expiry', 'id' => 'survey-expiry'); $fields[] = array('class' => 'SurveyNameField', 'default' => $survey->getField('name'), 'label-message' => 'survey-special-label-name', 'style' => 'font-weight: bold;'); $fields[] = array('type' => 'text', 'default' => $survey->getField('title'), 'label-message' => 'survey-special-label-title', 'id' => 'survey-title', 'name' => 'survey-title'); $fields[] = array('type' => 'check', 'default' => $survey->getField('enabled') ? '1' : '0', 'label-message' => 'survey-special-label-enabled', 'id' => 'survey-enabled', 'name' => 'survey-enabled'); $fields[] = array('type' => 'radio', 'default' => $survey->getField('user_type'), 'label-message' => 'survey-special-label-usertype', 'id' => 'survey-user_type', 'name' => 'survey-user_type', 'options' => array(wfMsg('survey-user-type-all') => Survey::$USER_ALL, wfMsg('survey-user-type-loggedin') => Survey::$USER_LOGGEDIN, wfMsg('survey-user-type-confirmed') => Survey::$USER_CONFIRMED, wfMsg('survey-user-type-editor') => Survey::$USER_EDITOR, wfMsg('survey-user-type-anon') => Survey::$USER_ANON)); $fields[] = array('type' => 'select', 'default' => $survey->getField('ratio'), 'label-message' => 'survey-special-label-ratio', 'id' => 'survey-ratio', 'name' => 'survey-ratio', 'options' => $this->getNumericalOptions(array_merge(array(0.01, 0.1), range(1, 100)))); $fields[] = array('type' => 'select', 'default' => $survey->getField('min_pages'), 'label-message' => 'survey-special-label-minpages', 'id' => 'survey-min_pages', 'name' => 'survey-min_pages', 'options' => $this->getNumericalOptions(range(0, 250))); $fields[] = array('type' => 'text', 'default' => $survey->getField('header'), 'label-message' => 'survey-special-label-header', 'id' => 'survey-header', 'name' => 'survey-header'); $fields[] = array('type' => 'text', 'default' => $survey->getField('footer'), 'label-message' => 'survey-special-label-footer', 'id' => 'survey-footer', 'name' => 'survey-footer'); $fields[] = array('type' => 'text', 'default' => $survey->getField('thanks'), 'label-message' => 'survey-special-label-thanks', 'id' => 'survey-thanks', 'name' => 'survey-thanks'); foreach ($survey->getQuestions() as $question) { $fields[] = array('class' => 'SurveyQuestionField', 'options' => $question->toArray()); } // getContext was added in 1.18 and since that version is // the second argument for the HTMLForm constructor. if (version_compare($GLOBALS['wgVersion'], '1.18', '>=')) { $form = new HTMLForm($fields, $this->getContext()); } else { $form = new HTMLForm($fields); $form->setTitle($this->getTitle()); } $form->setSubmitText(wfMsg('surveys-special-save')); $form->addButton('cancelEdit', wfMsg('cancel'), 'cancelEdit', array('onclick' => 'window.location="' . SpecialPage::getTitleFor('Surveys')->getFullURL() . '";return false;')); $form->show(); }
/** * @expectedException LogicException */ public function testGetHTML_noPrepare() { $form = new HTMLForm([]); $form->setTitle(Title::newFromText('Foo')); $form->getHTML(false); }
function getForm() { global $wgMiserMode; $fields = array('like' => array('type' => 'text', 'label-message' => 'newimages-label', 'name' => 'like'), 'showbots' => array('type' => 'check', 'label' => $this->msg('showhidebots', $this->msg('show')->plain())->escaped(), 'name' => 'showbots'), 'limit' => array('type' => 'hidden', 'default' => $this->mLimit, 'name' => 'limit'), 'offset' => array('type' => 'hidden', 'default' => $this->getRequest()->getText('offset'), 'name' => 'offset')); if ($wgMiserMode) { unset($fields['like']); } $form = new HTMLForm($fields, $this->getContext()); $form->setTitle($this->getTitle()); $form->setSubmitTextMsg('ilsubmit'); $form->setMethod('get'); $form->setWrapperLegendMsg('newimages-legend'); return $form; }
/** * @param $id * @return mixed */ function showHideForm($id) { if (!$this->getUser()->isAllowed('abusefilter-hide-log')) { $this->getOutput()->addWikiMsg('abusefilter-log-hide-forbidden'); return; } $dbr = wfGetDB(DB_SLAVE); $row = $dbr->selectRow(array('abuse_filter_log', 'abuse_filter'), '*', array('afl_id' => $id), __METHOD__, array(), array('abuse_filter' => array('LEFT JOIN', 'af_id=afl_filter'))); if (!$row) { return; } $formInfo = array('logid' => array('type' => 'info', 'default' => $id, 'label-message' => 'abusefilter-log-hide-id'), 'reason' => array('type' => 'text', 'label-message' => 'abusefilter-log-hide-reason'), 'hidden' => array('type' => 'toggle', 'default' => $row->afl_deleted, 'label-message' => 'abusefilter-log-hide-hidden')); $form = new HTMLForm($formInfo, $this->getContext()); $form->setTitle($this->getPageTitle()); $form->setWrapperLegend($this->msg('abusefilter-log-hide-legend')->text()); $form->addHiddenField('hide', $id); $form->setSubmitCallback(array($this, 'saveHideForm')); $form->show(); }