function showResetForm() { $this->getOutput()->addWikiMsg('prefs-reset-intro'); $htmlForm = new HTMLForm(array(), $this->getContext(), 'prefs-restore'); $htmlForm->setSubmitText(wfMsg('restoreprefs')); $htmlForm->addHiddenField('username', $this->target); $htmlForm->addHiddenField('reset', '1'); $htmlForm->setSubmitCallback(array($this, 'submitReset')); $htmlForm->suppressReset(); $htmlForm->show(); }
protected function alterForm(HTMLForm $form) { $form->setWrapperLegendMsg('filerevert-legend'); $form->setSubmitTextMsg('filerevert-submit'); $form->addHiddenField('oldimage', $this->getRequest()->getText('oldimage')); $form->setTokenSalt(['revert', $this->getTitle()->getPrefixedDBkey()]); }
/** * Show the special page * * @param $par Mixed: parameter passed to the page or null * @return bool|null */ public function execute($par) { global $wgExtensionAssetsPath; $out = $this->getOutput(); // Add CSS if (defined('MW_SUPPORTS_RESOURCE_MODULES')) { $out->addModuleStyles('ext.video'); } else { $out->addExtensionStyle($wgExtensionAssetsPath . '/Video/Video.css'); } // If the user doesn't have the required 'addvideo' permission, display an error if (!$this->userCanExecute($this->getUser())) { $this->displayRestrictionError(); return; } // Show a message if the database is in read-only mode if (wfReadOnly()) { throw new ReadOnlyError(); } // If user is blocked, s/he doesn't need to access this page if ($this->getUser()->isBlocked()) { throw new UserBlockedError($this->getUser()->mBlock); } $this->setHeaders(); $form = new HTMLForm($this->getFormFields(), $this->getContext()); $form->setIntro(wfMsgExt('video-addvideo-instructions', 'parse')); $form->setWrapperLegend(wfMsg('video-addvideo-title')); $form->setSubmitText(wfMsg('video-addvideo-button')); $form->setSubmitCallback(array($this, 'submit')); if ($this->getRequest()->getCheck('forReUpload')) { $form->addHiddenField('forReUpload', true); } $form->show(); }
/** * Get the HTMLForm to control behavior * @return HTMLForm|null */ protected function getForm() { $this->fields = $this->getFormFields(); // Give hooks a chance to alter the form, adding extra fields or text etc wfRunHooks('ActionModifyFormFields', array($this->getName(), &$this->fields, $this->page)); $form = new HTMLForm($this->fields, $this->getContext(), $this->getName()); $form->setSubmitCallback(array($this, 'onSubmit')); // Retain query parameters (uselang etc) $form->addHiddenField('action', $this->getName()); // Might not be the same as the query string $params = array_diff_key($this->getRequest()->getQueryValues(), array('action' => null, 'title' => null)); $form->addHiddenField('redirectparams', wfArrayToCgi($params)); $form->addPreText($this->preText()); $form->addPostText($this->postText()); $this->alterForm($form); // Give hooks a chance to alter the form, adding extra fields or text etc wfRunHooks('ActionBeforeFormDisplay', array($this->getName(), &$form, $this->page)); return $form; }
protected function alterForm(HTMLForm $form) { $form->setSubmitTextMsg('confirm-rollback-button'); $form->setTokenSalt('rollback'); // Copy parameters from GET to confirmation form $from = $this->getRequest()->getVal('from'); if ($from === null) { throw new BadRequestError('rollbackfailed', 'rollback-missingparam'); } foreach (['from', 'bot', 'hidediff', 'summary'] as $param) { $val = $this->getRequest()->getVal($param); if ($val !== null) { $form->addHiddenField($param, $val); } } }
/** * Get the HTMLForm to control behavior * @return HTMLForm|null */ protected function getForm() { $this->fields = $this->getFormFields(); // Give hooks a chance to alter the form, adding extra fields or text etc Hooks::run('ActionModifyFormFields', [$this->getName(), &$this->fields, $this->page]); $form = new HTMLForm($this->fields, $this->getContext(), $this->getName()); $form->setSubmitCallback([$this, 'onSubmit']); $title = $this->getTitle(); $form->setAction($title->getLocalURL(['action' => $this->getName()])); // Retain query parameters (uselang etc) $params = array_diff_key($this->getRequest()->getQueryValues(), ['action' => null, 'title' => null]); if ($params) { $form->addHiddenField('redirectparams', wfArrayToCgi($params)); } $form->addPreText($this->preText()); $form->addPostText($this->postText()); $this->alterForm($form); // Give hooks a chance to alter the form, adding extra fields or text etc Hooks::run('ActionBeforeFormDisplay', [$this->getName(), &$form, $this->page]); return $form; }
/** * Show form if user wants to delete all data */ public function showDeletionForm() { $out = $this->out; $max_length = $this->max_string_formfield_length; $out->setPageTitle($out->msg('helperscripts')); $html = ''; $html .= $this->getHTMLJavascriptLoader(); $html .= "<div class='javascripthide'>"; if (!empty($error_message)) { $html .= "<br>"; $html .= "<div class = 'error'>{$error_message}</div>"; } $html .= "</div>"; $out->addHTML($html); $descriptor = array(); $descriptor['phrase'] = array('label-message' => 'phrase-message', 'class' => 'HTMLTextField', 'type' => 'password', 'maxlength' => $max_length * 20); $html_form = new HTMLForm($descriptor, $out->getContext()); $html_form->setSubmitText($out->msg('delete-submit')); $html_form->addHiddenField('phrase_posted', 'phrase_posted'); $html_form->setSubmitCallback(array('SpecialHelperScripts', 'processInput')); return $html_form->show(); }
protected function alterForm(HTMLForm $form) { $form->setWrapperLegend(wfMsgHtml('filerevert-legend')); $form->setSubmitText(wfMsg('filerevert-submit')); $form->addHiddenField('oldimage', $this->getRequest()->getText('oldimage')); }
/** * Get the HTMLForm to control behaviour * @return HTMLForm|null */ protected function getForm() { $this->fields = $this->getFormFields(); $form = new HTMLForm($this->fields, $this->getContext()); $form->setSubmitCallback(array($this, 'onSubmit')); $form->setWrapperLegend($this->msg(strtolower($this->getName()) . '-legend')); $form->addHeaderText($this->msg(strtolower($this->getName()) . '-text')->parseAsBlock()); // Retain query parameters (uselang etc) $params = array_diff_key($this->getRequest()->getQueryValues(), array('title' => null)); $form->addHiddenField('redirectparams', wfArrayToCGI($params)); $form->addPreText($this->preText()); $form->addPostText($this->postText()); $this->alterForm($form); // Give hooks a chance to alter the form, adding extra fields or text etc wfRunHooks("Special{$this->getName()}BeforeFormDisplay", array(&$form)); return $form; }
/** * Get the HTMLForm to control behavior * @return HTMLForm|null */ protected function getForm() { $this->fields = $this->getFormFields(); $form = new HTMLForm($this->fields, $this->getContext(), $this->getMessagePrefix()); $form->setSubmitCallback(array($this, 'onSubmit')); // If the form is a compact vertical form, then don't output this ugly // fieldset surrounding it. // XXX Special pages can setDisplayFormat to 'vform' in alterForm(), but that // is called after this. if (!$form->isVForm()) { $form->setWrapperLegendMsg($this->getMessagePrefix() . '-legend'); } $headerMsg = $this->msg($this->getMessagePrefix() . '-text'); if (!$headerMsg->isDisabled()) { $form->addHeaderText($headerMsg->parseAsBlock()); } // Retain query parameters (uselang etc) $params = array_diff_key($this->getRequest()->getQueryValues(), array('title' => null)); $form->addHiddenField('redirectparams', wfArrayToCgi($params)); $form->addPreText($this->preText()); $form->addPostText($this->postText()); $this->alterForm($form); // Give hooks a chance to alter the form, adding extra fields or text etc wfRunHooks('SpecialPageBeforeFormDisplay', array($this->getName(), &$form)); 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(); }
/** * Constructs and show form 2 */ public function showForm2(array $collection_data, array $collection_name_data, RequestContext $context, $error_message = '') { global $wgArticleUrl; $article_url = $wgArticleUrl; $max_int_formfield_length = $this->max_int_formfield_length; $out = $this->out; $collection_data = $this->HTMLSpecialCharachtersArray($collection_data); $collection_name_data = $this->HTMLSpecialCharachtersArray($collection_name_data); $collections_message = implode(', ', $collection_name_data) . "."; $out->setPageTitle($out->msg('stylometricanalysis-options')); $html = ""; $html .= $this->getHTMLJavascriptLoader(); $html .= "<div class='javascripthide'>"; $html .= "<a href='" . $article_url . "Special:StylometricAnalysis' class='link-transparent' title='Go Back'>Go Back</a>"; $html .= "<br><br>"; $html .= $out->msg('stylometricanalysis-chosencollections') . $collections_message . "<br>"; $html .= $out->msg('stylometricanalysis-chosencollection2'); $html .= "<br><br>"; //display the error if (!empty($error_message)) { $html .= "<div class = 'error'>" . $error_message . "</div>"; } $html .= "</div>"; $out->addHTML($html); $descriptor = array(); $descriptor['removenonalpha'] = array('label' => 'Remove non-alpha', 'class' => 'HTMLCheckField', 'section' => 'stylometricanalysis-section-import'); $descriptor['lowercase'] = array('label' => 'Lowercase', 'class' => 'HTMLCheckField', 'section' => 'stylometricanalysis-section-import'); $descriptor['tokenizer'] = array('label' => 'Tokenizer', 'class' => 'HTMLSelectField', 'options' => array('Whitespace' => 'whitespace', 'Words' => 'words'), 'default' => 'whitespace', 'section' => 'stylometricanalysis-section-preprocess'); $descriptor['minimumsize'] = array('label' => 'Minimum Size', 'class' => 'HTMLTextField', 'default' => 0, 'size' => $max_int_formfield_length, 'maxlength' => $max_int_formfield_length, 'section' => 'stylometricanalysis-section-preprocess'); $descriptor['maximumsize'] = array('label' => 'Maximum Size', 'class' => 'HTMLTextField', 'default' => 10000, 'size' => $max_int_formfield_length, 'maxlength' => $max_int_formfield_length, 'section' => 'stylometricanalysis-section-preprocess'); $descriptor['segmentsize'] = array('label' => 'Segment Size', 'class' => 'HTMLTextField', 'default' => 0, 'size' => $max_int_formfield_length, 'maxlength' => $max_int_formfield_length, 'section' => 'stylometricanalysis-section-preprocess'); $descriptor['stepsize'] = array('label' => 'Step Size', 'class' => 'HTMLTextField', 'default' => 0, 'size' => $max_int_formfield_length, 'maxlength' => $max_int_formfield_length, 'section' => 'stylometricanalysis-section-preprocess'); $descriptor['removepronouns'] = array('label' => 'Remove Pronouns', 'class' => 'HTMLCheckField', 'section' => 'stylometricanalysis-section-preprocess'); $descriptor['vectorspace'] = array('label' => 'Vector Space', 'class' => 'HTMLSelectField', 'options' => array('tf' => 'tf', 'tf_scaled' => 'tf_scaled', 'tf_std' => 'tf_std', 'tf_idf' => 'tf_idf', 'bin' => 'bin'), 'default' => 'tf', 'section' => 'stylometricanalysis-section-feature'); $descriptor['featuretype'] = array('label' => 'Feature Type', 'class' => 'HTMLSelectField', 'options' => array('word' => 'word', 'char' => 'char', 'char_wb' => 'char_wb'), 'default' => 'word', 'section' => 'stylometricanalysis-section-feature'); $descriptor['ngramsize'] = array('label' => 'Ngram Size', 'class' => 'HTMLTextField', 'default' => 1, 'size' => $max_int_formfield_length, 'maxlength' => $max_int_formfield_length, 'section' => 'stylometricanalysis-section-feature'); $descriptor['mfi'] = array('label' => 'MFI', 'class' => 'HTMLTextField', 'default' => 100, 'size' => $max_int_formfield_length, 'maxlength' => $max_int_formfield_length, 'section' => 'stylometricanalysis-section-feature'); $descriptor['minimumdf'] = array('class' => 'HTMLTextField', 'label' => 'Minimum DF', 'default' => 0.0, 'size' => $max_int_formfield_length, 'maxlength' => $max_int_formfield_length, 'section' => 'stylometricanalysis-section-feature'); $descriptor['maximumdf'] = array('class' => 'HTMLTextField', 'label' => 'Maximum DF', 'default' => 0.9, 'size' => $max_int_formfield_length, 'maxlength' => $max_int_formfield_length, 'section' => 'stylometricanalysis-section-feature'); $descriptor['visualization1'] = array('label' => 'Visualization1', 'class' => 'HTMLSelectField', 'options' => array('PCA Scatterplot' => 'pcascatterplot', 'TNSE Scatterplot' => 'tnsescatterplot', 'Distance Matrix Clustering' => 'distancematrix', 'Variability Based Neighbour Clustering' => 'neighbourclustering'), 'default' => 'pcascatterplot', 'section' => 'stylometricanalysis-section-visualization'); $descriptor['visualization2'] = array('label' => 'Visualization2', 'class' => 'HTMLSelectField', 'options' => array('PCA Scatterplot' => 'pcascatterplot', 'TNSE Scatterplot' => 'tnsescatterplot', 'Distance Matrix Clustering' => 'distancematrix', 'Variability Based Neighbour Clustering' => 'neighbourclustering'), 'default' => 'pcascatterplot', 'section' => 'stylometricanalysis-section-visualization'); $html_form = new HTMLForm($descriptor, $context); $html_form->setSubmitText($out->msg('stylometricanalysis-submit')); $html_form->addHiddenField('collection_data', json_encode($collection_data)); $html_form->addHiddenField('form_2_posted', 'form_2_posted'); $html_form->setSubmitCallback(array('SpecialStylometricAnalysis', 'callbackForm2')); $html_form->show(); return true; }
/** * 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->addHiddenField('clear', true, array('type' => 'boolean')); $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) { $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; }
protected function alterForm(HTMLForm $form) { $form->setDisplayFormat('vform'); $form->setId('mw-changeemail-form'); $form->setTableId('mw-changeemail-table'); $form->setWrapperLegend(false); $form->setSubmitTextMsg('changeemail-submit'); $form->addHiddenField('returnto', $this->getRequest()->getVal('returnto')); }
protected function alterForm(HTMLForm $form) { $form->setId('mw-changeemail-form'); $form->setTableId('mw-changeemail-table'); $form->setWrapperLegendMsg('changeemail-header'); $form->setSubmitTextMsg('changeemail-submit'); $form->addButton('wpCancel', $this->msg('changeemail-cancel')->text()); $form->addHiddenField('returnto', $this->getRequest()->getVal('returnto')); }
/** * This function shows the form when editing a manuscript title * * See https://www.mediawiki.org/wiki/HTMLForm/tutorial for information on the MediaWiki form builder */ public function showEditPageSingleCollectionForm($error_message = '', $collection_title, $manuscript_old_title, $manuscript_url_old_title) { global $wgArticleUrl; $out = $this->out; $user_name = $this->user_name; $max_length = $this->max_string_formfield_length; $out->setPageTitle($out->msg('userpage-welcome') . ' ' . $user_name); $edit_token = $out->getUser()->getEditToken(); $html = ""; $html .= $this->getHTMLUserPageMenuBar($out, $edit_token, array('button', 'button', 'button-active')); $html .= $this->getHTMLJavascriptLoaderDots(); $html .= "<div class='javascripthide'>"; $html .= "<form class='summarypage-form' id='userpage-collection' action='" . $wgArticleUrl . "Special:UserPage' method='post'>"; $html .= "<input type='submit' class='button-transparent' value='" . $out->msg('userpage-goback') . "'>"; $html .= "<input type='hidden' name='collection_title' value='" . htmlspecialchars($collection_title) . "'>"; $html .= "<input type='hidden' name='wpEditToken' value='{$edit_token}'>"; $html .= "<input type='hidden' name='single_collection_posted' value='single_collection_posted'>"; $html .= "</form>"; $html .= "<h2>" . $out->msg('userpage-edittitle') . " " . $manuscript_old_title . "</h2>"; $html .= $out->msg('userpage-edittitleinstruction'); $html .= "<br><br>"; if (!empty($error_message)) { $html .= "<div class='error'>" . $error_message . "</div>"; } $html .= "</div>"; $out->addHTML($html); $descriptor = array(); $descriptor['manuscript_new_title'] = array('label-message' => 'userpage-newmanuscripttitle', 'class' => 'HTMLTextField', 'default' => $manuscript_old_title, 'maxlength' => $max_length); $html_form = new HTMLForm($descriptor, $out->getContext()); $html_form->setSubmitText($out->msg('metadata-submit')); $html_form->addHiddenField('collection_title', $collection_title); $html_form->addHiddenField('old_title_posted', $manuscript_old_title); $html_form->addHiddenField('url_old_title_posted', $manuscript_url_old_title); $html_form->addHiddenField('save_new_page_title_collection_posted', 'save_new_collection_title_posted'); $html_form->addHiddenField('save_page_posted', 'save_page_posted'); $html_form->setSubmitCallback(array('SpecialUserPage', 'processInput')); return $html_form->show(); }