function execute($par) { $this->setHeaders(); $this->outputHeader(); $this->getOutput()->addModuleStyles('mediawiki.special.pagesWithProp'); $request = $this->getRequest(); $propname = $request->getVal('propname', $par); $dbr = wfGetDB(DB_SLAVE); $res = $dbr->select('page_props', 'pp_propname', '', __METHOD__, array('DISTINCT', 'ORDER BY' => 'pp_propname')); $propnames = array(); foreach ($res as $row) { $propnames[$row->pp_propname] = $row->pp_propname; } $form = new HTMLForm(array('propname' => array('type' => 'selectorother', 'name' => 'propname', 'options' => $propnames, 'default' => $propname, 'label-message' => 'pageswithprop-prop', 'required' => true)), $this->getContext()); $form->setMethod('get'); $form->setSubmitCallback(array($this, 'onSubmit')); $form->setWrapperLegendMsg('pageswithprop-legend'); $form->addHeaderText($this->msg('pageswithprop-text')->parseAsBlock()); $form->setSubmitTextMsg('pageswithprop-submit'); $form->prepareForm(); $form->displayForm(false); if ($propname !== '' && $propname !== null) { $form->trySubmit(); } }
/** * 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->setMethod('get'); $form->setWrapperLegendMsg('ipblocklist-legend'); $form->setSubmitTextMsg('ipblocklist-submit'); $form->prepareForm(); $form->displayForm(''); $this->showList(); }
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); } }
/** * 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', 'validation-callback' => array($this, 'checkExistingTitle')), 'Revision1' => array('type' => 'int', 'name' => 'rev1', 'label-message' => 'compare-rev1', 'size' => '8', 'section' => 'page1', 'validation-callback' => array($this, 'checkExistingRevision')), 'Page2' => array('type' => 'text', 'name' => 'page2', 'label-message' => 'compare-page2', 'size' => '40', 'section' => 'page2', 'validation-callback' => array($this, 'checkExistingTitle')), 'Revision2' => array('type' => 'int', 'name' => 'rev2', 'label-message' => 'compare-rev2', 'size' => '8', 'section' => 'page2', 'validation-callback' => array($this, 'checkExistingRevision')), 'Action' => array('type' => 'hidden', 'name' => 'action'), 'Diffonly' => array('type' => 'hidden', 'name' => 'diffonly'), 'Unhide' => array('type' => 'hidden', 'name' => 'unhide')), $this->getContext(), 'compare'); $form->setSubmitTextMsg('compare-submit'); $form->suppressReset(); $form->setMethod('get'); $form->setSubmitCallback(array(__CLASS__, 'showDiff')); $form->loadData(); $form->displayForm(''); $form->trySubmit(); }
/** * 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); }
public function execute( $par ) { $out = $this->getOutput(); $request = $this->getRequest(); $this->setHeaders(); $this->outputHeader(); $out->setPageTitle( $this->msg( 'ss-assessment-log' ) ); $fields = array( 'Project' => array( 'type' => 'text', 'label-message' => 'ss-project', 'tabindex' => '1' ) ); $project = $request->getText( 'wpProject' ); $filters = array_filter( array( 'l_project' => $project ) ); $form = new HTMLForm( $fields, $this->getContext() ); $form->setMethod( 'get' ); $form->prepareForm(); $form->displayForm( '' ); $pager = new AssessmentLogPager( $this, $filters ); if( $pager->getNumRows() ) { $out->addHTML( $pager->getNavigationBar() . '<table>' . Html::rawElement( 'tr', array(), Html::element( 'td', array(), wfMessage( 'ss-action' ) ) . Html::element( 'td', array(), wfMessage( 'ss-old' ) ) . Html::element( 'td', array(), wfMessage( 'ss-new' ) ) . Html::element( 'td', array(), wfMessage( 'ss-article' ) ) . Html::element( 'td', array(), wfMessage( 'ss-project' ) ) . Html::element( 'td', array(), wfMessage( 'ss-timestamp' ) ) ) . $pager->getBody() . '</table>' . $pager->getNavigationBar() ); } else { $out->addWikiMsg( 'ss-assessment-log-empty' ); } }
public function execute($par) { $this->setHeaders(); $this->outputHeader(); $this->getOutput()->addModuleStyles('mediawiki.special.pagesWithProp'); $request = $this->getRequest(); $propname = $request->getVal('propname', $par); $propnames = $this->getExistingPropNames(); $form = new HTMLForm(array('propname' => array('type' => 'selectorother', 'name' => 'propname', 'options' => $propnames, 'default' => $propname, 'label-message' => 'pageswithprop-prop', 'required' => true)), $this->getContext()); $form->setMethod('get'); $form->setSubmitCallback(array($this, 'onSubmit')); $form->setWrapperLegendMsg('pageswithprop-legend'); $form->addHeaderText($this->msg('pageswithprop-text')->parseAsBlock()); $form->setSubmitTextMsg('pageswithprop-submit'); $form->prepareForm(); $form->displayForm(false); if ($propname !== '' && $propname !== null) { $form->trySubmit(); } }
/** * 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; }
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(''); }
public function execute( $par ) { $out = $this->getOutput(); $lang = $this->getLanguage(); $request = $this->getRequest(); if( $request->wasPosted() ) { $out->disable(); $action = $request->getVal( 'action' ); $selection_name = $request->getText( 'selection' ); if( $action == 'addtoselection' ) { $success = Selection::addEntries( $selection_name, $entries ); $sel_page = new SpecialSelection(); $url = $sel_page->getTitle()->getLinkUrl( array( 'name' => $selection_name ) ); $return = array( 'status' => $success, 'selection_url' => $url ); } echo json_encode($return); return; } $fields = array( 'Project-Name' => array( 'type' => 'text', 'label-message' => 'ss-project', 'tabindex' => '1' ), 'Importance' => array( 'type' => 'text', 'label-message' => 'ss-importance', 'tabindex' => '2' ), 'Quality' => array( 'type' => 'text', 'label-message' => 'ss-quality', 'tabindex' => '3' ) ); $project = $request->getText( 'wpProject' ); $importance = $request->getText( 'wpImportance' ); $quality = $request->getText( 'wpQuality' ); $filters = array_filter( array( 'r_project' => $project, 'r_importance' => $importance, 'r_quality' => $quality ) ); $this->setHeaders(); $this->outputHeader(); $out->setPageTitle( $this->msg( 'ss-filter-ratings' ) ); $form = new HTMLForm( $fields, $this->getContext() ); $form->setMethod( 'get' ); $form->prepareForm(); $form->displayForm( '' ); $pager = new RatingsPager( $this, $filters ); if ( $pager->getNumRows() ) { $out->addHTML( $pager->getNavigationBar() . $pager->getBody() ); } else { $out->addWikiMsg( 'ss-ratings-empty' ); } return; }
/** * TODO */ protected function showForm() { $form = new HTMLForm( $this->getFormFields(), $this->getContext() ); $form->setWrapperLegend( wfMsg( 'vipsscaler-form-legend' ) ); $form->setSubmitText( wfMsg( 'vipsscaler-form-submit' ) ); $form->setSubmitCallback( array( __CLASS__, 'processForm' ) ); $form->setMethod( 'get' ); // Looks like HTMLForm does not actually show the form if submission // was correct. So we have to show it again. // See HTMLForm::show() $result = $form->show(); if( $result === true || $result instanceof Status && $result->isGood() ) { $form->displayForm( $result ); $this->showThumbnails(); } }