Exemplo n.º 1
0
 /**
  * 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();
 }
Exemplo n.º 2
0
 /**
  * Main execution point
  *
  * @param $par String title fragment
  */
 public function execute($par)
 {
     global $wgOut, $wgRequest, $wgLang;
     $this->setHeaders();
     $this->outputHeader();
     $wgOut->setPageTitle(wfMsg('ipblocklist'));
     $wgOut->addModuleStyles('mediawiki.special');
     $par = $wgRequest->getVal('ip', $par);
     $this->target = trim($wgRequest->getVal('wpTarget', $par));
     $this->options = $wgRequest->getArray('wpOptions', array());
     $action = $wgRequest->getText('action');
     if ($action == 'unblock' || $action == 'submit' && $wgRequest->wasPosted()) {
         # B/C @since 1.18: Unblock interface is now at Special:Unblock
         $title = SpecialPage::getTitleFor('Unblock', $this->target);
         $wgOut->redirect($title->getFullUrl());
         return;
     }
     # Just show the block list
     $fields = array('Target' => array('type' => 'text', 'label-message' => 'ipadressorusername', 'tabindex' => '1', 'size' => '45'), 'Options' => array('type' => 'multiselect', 'options' => array(wfMsg('blocklist-userblocks') => 'userblocks', wfMsg('blocklist-tempblocks') => 'tempblocks', wfMsg('blocklist-addressblocks') => 'addressblocks'), 'flatlist' => true), 'Limit' => array('class' => 'HTMLBlockedUsersItemSelect', 'label-message' => 'table_pager_limit_label', 'options' => array($wgLang->formatNum(20) => 20, $wgLang->formatNum(50) => 50, $wgLang->formatNum(100) => 100, $wgLang->formatNum(250) => 250, $wgLang->formatNum(500) => 500), 'name' => 'limit', 'default' => 50));
     $form = new HTMLForm($fields, $this->getContext());
     $form->setMethod('get');
     $form->setWrapperLegend(wfMsg('ipblocklist-legend'));
     $form->setSubmitText(wfMsg('ipblocklist-submit'));
     $form->prepareForm();
     $form->displayForm('');
     $this->showList();
 }
 /**
  * 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>");
     }
 }
Exemplo n.º 4
0
 public function execute($par)
 {
     $this->checkPermissions();
     $this->checkReadOnly();
     list($this->target, $this->type) = SpecialBlock::getTargetAndType($par, $this->getRequest());
     $this->block = Block::newFromTarget($this->target);
     $this->setHeaders();
     $this->outputHeader();
     $out = $this->getOutput();
     $out->setPageTitle($this->msg('unblockip'));
     $out->addModules('mediawiki.special');
     $form = new HTMLForm($this->getFields(), $this->getContext());
     $form->setWrapperLegend(wfMsg('unblockip'));
     $form->setSubmitCallback(array(__CLASS__, 'processUIUnblock'));
     $form->setSubmitText(wfMsg('ipusubmit'));
     $form->addPreText(wfMsgExt('unblockiptext', 'parse'));
     if ($form->show()) {
         switch ($this->type) {
             case Block::TYPE_USER:
             case Block::TYPE_IP:
                 $out->addWikiMsg('unblocked', $this->target);
                 break;
             case Block::TYPE_RANGE:
                 $out->addWikiMsg('unblocked-range', $this->target);
                 break;
             case Block::TYPE_ID:
             case Block::TYPE_AUTO:
                 $out->addWikiMsg('unblocked-id', $this->target);
                 break;
         }
     }
 }
Exemplo n.º 5
0
 function buildForm()
 {
     $form = new HTMLForm($this->getFormFields(), $this->getContext(), 'lqt-' . $this->getPageName());
     $par = $this->mThread->title()->getPrefixedText();
     $form->setSubmitText($this->getSubmitText());
     $form->setSubmitCallback(array($this, 'trySubmit'));
     return $form;
 }
Exemplo n.º 6
0
 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());
     }
 }
 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();
 }
Exemplo n.º 8
0
 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();
 }
Exemplo n.º 9
0
 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());
     }
 }
Exemplo n.º 10
0
 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();
 }
Exemplo n.º 11
0
 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();
 }
Exemplo n.º 12
0
 /**
  * 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);
 }
Exemplo n.º 13
0
 public function execute($par)
 {
     global $wgUser, $wgOut, $wgRequest;
     # Check permissions
     if (!$this->userCanExecute($wgUser)) {
         $this->displayRestrictionError();
         return;
     }
     # Check for database lock
     if (wfReadOnly()) {
         throw new ReadOnlyError();
     }
     list($this->target, $this->type) = SpecialBlock::getTargetAndType($par, $wgRequest);
     $this->block = Block::newFromTarget($this->target);
     # bug 15810: blocked admins should have limited access here.  This won't allow sysops
     # to remove autoblocks on themselves, but they should have ipblock-exempt anyway
     $status = SpecialBlock::checkUnblockSelf($this->target);
     if ($status !== true) {
         throw new ErrorPageError('badaccess', $status);
     }
     $wgOut->setPageTitle(wfMsg('unblockip'));
     $wgOut->addModules('mediawiki.special');
     $form = new HTMLForm($this->getFields(), $this->getContext());
     $form->setWrapperLegend(wfMsg('unblockip'));
     $form->setSubmitCallback(array(__CLASS__, 'processUnblock'));
     $form->setSubmitText(wfMsg('ipusubmit'));
     $form->addPreText(wfMsgExt('unblockiptext', 'parse'));
     if ($form->show()) {
         switch ($this->type) {
             case Block::TYPE_USER:
             case Block::TYPE_IP:
                 $wgOut->addWikiMsg('unblocked', $this->target);
                 break;
             case Block::TYPE_RANGE:
                 $wgOut->addWikiMsg('unblocked-range', $this->target);
                 break;
             case Block::TYPE_ID:
             case Block::TYPE_AUTO:
                 $wgOut->addWikiMsg('unblocked-id', $this->target);
                 break;
         }
     }
 }
 /**
  * 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();
 }
Exemplo n.º 15
0
 /**
  * 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();
 }
Exemplo n.º 16
0
 /**
  * Create and display the enrollment form.
  *
  * @since 0.1
  *
  * @param EPTerm $term
  */
 protected function showEnrollmentForm(EPTerm $term)
 {
     $this->getOutput()->addWikiMsg('ep-enroll-header');
     $form = new HTMLForm($this->getFormFields(), $this->getContext());
     $form->setSubmitCallback(array($this, 'handleSubmission'));
     $form->setSubmitText(wfMsg('educationprogram-org-submit'));
     $form->setWrapperLegend($this->msg('ep-enroll-legend'));
     if ($form->show()) {
         $this->onSuccess();
     }
 }
 protected function form()
 {
     $out = $this->getOutput();
     $out->addModules('mediawiki.userSuggest');
     // Consume values
     $this->opts->consumeValue('offset');
     // don't carry offset, DWIW
     $namespace = $this->opts->consumeValue('namespace');
     $username = $this->opts->consumeValue('username');
     $tagFilterVal = $this->opts->consumeValue('tagfilter');
     $nsinvert = $this->opts->consumeValue('invert');
     // Check username input validity
     $ut = Title::makeTitleSafe(NS_USER, $username);
     $userText = $ut ? $ut->getText() : '';
     // Store query values in hidden fields so that form submission doesn't lose them
     $hidden = array();
     foreach ($this->opts->getUnconsumedValues() as $key => $value) {
         $hidden[] = Html::hidden($key, $value);
     }
     $hidden = implode("\n", $hidden);
     $form = array('namespace' => array('type' => 'namespaceselect', 'name' => 'namespace', 'label-message' => 'namespace', 'default' => $namespace), 'nsinvert' => array('type' => 'check', 'name' => 'invert', 'label-message' => 'invert', 'default' => $nsinvert, 'tooltip' => 'invert'), 'tagFilter' => array('type' => 'tagfilter', 'name' => 'tagfilter', 'label-raw' => $this->msg('tag-filter')->parse(), 'default' => $tagFilterVal), 'username' => array('type' => 'text', 'name' => 'username', 'label-message' => 'newpages-username', 'default' => $userText, 'id' => 'mw-np-username', 'size' => 30, 'cssclass' => 'mw-autocomplete-user'));
     $htmlForm = new HTMLForm($form, $this->getContext());
     $htmlForm->setSubmitText($this->msg('allpagessubmit')->text());
     $htmlForm->setSubmitProgressive();
     // The form should be visible on each request (inclusive requests with submitted forms), so
     // return always false here.
     $htmlForm->setSubmitCallback(function () {
         return false;
     });
     $htmlForm->setMethod('get');
     $out->addHtml(Xml::fieldset($this->msg('newpages')->text()));
     $htmlForm->show();
     $out->addHtml(Html::rawElement('div', null, $this->filterLinks()) . Xml::closeElement('fieldset'));
 }
Exemplo n.º 18
0
 public function execute($par)
 {
     global $wgUser, $wgOut, $wgRequest;
     # Permission check
     if (!$this->userCanExecute($wgUser)) {
         $this->displayRestrictionError();
         return;
     }
     # Can't block when the database is locked
     if (wfReadOnly()) {
         throw new ReadOnlyError();
     }
     # Extract variables from the request.  Try not to get into a situation where we
     # need to extract *every* variable from the form just for processing here, but
     # there are legitimate uses for some variables
     list($this->target, $this->type) = self::getTargetAndType($par, $wgRequest);
     if ($this->target instanceof User) {
         # Set the 'relevant user' in the skin, so it displays links like Contributions,
         # User logs, UserRights, etc.
         $this->getSkin()->setRelevantUser($this->target);
     }
     list($this->previousTarget, ) = Block::parseTarget($wgRequest->getVal('wpPreviousTarget'));
     $this->requestedHideUser = $wgRequest->getBool('wpHideUser');
     # bug 15810: blocked admins should have limited access here
     $status = self::checkUnblockSelf($this->target);
     if ($status !== true) {
         throw new ErrorPageError('badaccess', $status);
     }
     $wgOut->setPageTitle(wfMsg('blockip-title'));
     $wgOut->addModules('mediawiki.special', 'mediawiki.special.block');
     $out = $this->getOutput();
     $out->setPageTitle(wfMsg('blockip-title'));
     $out->addModules(array('mediawiki.special', 'mediawiki.special.block'));
     $fields = $this->getFormFields();
     $this->maybeAlterFormDefaults($fields);
     $form = new HTMLForm($fields, $this->getContext());
     $form->setWrapperLegend(wfMsg('blockip-legend'));
     $form->setSubmitCallback(array(__CLASS__, 'processForm'));
     $t = $this->alreadyBlocked ? wfMsg('ipb-change-block') : wfMsg('ipbsubmit');
     $form->setSubmitText($t);
     $this->doPreText($form);
     $this->doHeadertext($form);
     $this->doPostText($form);
     if ($form->show()) {
         $wgOut->setPageTitle(wfMsg('blockipsuccesssub'));
         $wgOut->addWikiMsg('blockipsuccesstext', $this->target);
     }
 }
Exemplo n.º 19
0
 /**
  * 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 alterForm(HTMLForm $form)
 {
     $form->setMethod('GET');
     $form->setAction($this->getPageTitle()->getLocalURL());
     $form->setSubmitText($this->msg('centralauth-rename-viewprogress')->text());
 }
Exemplo n.º 21
0
 protected function alterForm(HTMLForm $form)
 {
     $form->setSubmitText(wfMsg('confirm-unwatch-button'));
 }
Exemplo n.º 22
0
 protected function alterForm(HTMLForm $form)
 {
     $form->setWrapperLegend(wfMsgHtml('filerevert-legend'));
     $form->setSubmitText(wfMsg('filerevert-submit'));
     $form->addHiddenField('oldimage', $this->getRequest()->getText('oldimage'));
 }
 /**
  * Display the signup form for this contest.
  *
  * @since 0.1
  *
  * @param Contest $contest
  * @param integer|false $challengeId
  */
 protected function showSignupForm(Contest $contest, $challengeId = false)
 {
     $form = new HTMLForm($this->getFormFields($contest, $challengeId), $this->getContext());
     $form->setSubmitCallback(array($this, 'handleSubmission'));
     $form->setSubmitText(wfMsg('contest-signup-submit'));
     if ($form->show()) {
         $this->onSuccess($contest);
     } else {
         $this->getOutput()->addModules('contest.special.signup');
     }
     $this->getOutput()->addScript(Skin::makeVariablesScript(array('ContestConfig' => array('rules_page' => ContestUtils::getParsedArticleContent($contest->getField('rules_page'))))));
 }
	/**
	 * 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();
		}
	}
 /**
  * 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;
 }
 /**
  * Show the page content.
  *
  * @since 0.1
  *
  * @param ContestContestant $contestant
  */
 protected function showSubmissionPage(ContestContestant $contestant)
 {
     $request = $this->getRequest();
     $contest = $contestant->getContest();
     if ($request->getCheck('new')) {
         $this->showSuccess('contest-mycontests-signup-success', $contest->getField('name'));
     } elseif ($request->getCheck('added')) {
         $this->showSuccess('contest-mycontests-addition-success');
     } elseif ($request->getCheck('updated')) {
         $this->showSuccess('contest-mycontests-updated-success');
     } elseif ($request->wasPosted() && !$this->getUser()->matchEditToken($request->getVal('wpEditToken'))) {
         $this->showError('contest-mycontests-sessionfail');
     }
     $output = $this->getOutput();
     $output->setPageTitle($contest->getField('name'));
     $output->addHTML('<div style="clear:both;"></div>');
     $output->addWikiMsg('contest-submission-header', $contest->getField('name'));
     $form = new HTMLForm($this->getFormFields($contestant), $this->getContext());
     $form->setSubmitCallback(array($this, 'handleSubmission'));
     $form->setSubmitText(wfMsg('contest-submission-submit'));
     /**
      * @var $challenge ContestChallenge
      */
     $challenge = ContestChallenge::s()->selectRow(array('title', 'text'), array('id' => $contestant->getField('challenge_id')));
     if ($challenge !== false) {
         $challengeName = $challenge->getField('title');
         $challengeDescription = $challenge->getField('text');
         $output->addWikiMsg('contest-submission-challenge', $challengeName);
         $output->addWikiMsg('contest-submission-challenge-description', $challengeName, $challengeDescription);
     }
     if ($form->show()) {
         $query = is_null($this->submissionState) ? '' : $this->submissionState;
         $output->redirect($this->getTitle($contest->getField('name'))->getLocalURL($query));
     } else {
         $output->addModules('contest.special.submission');
     }
 }
Exemplo n.º 27
0
 public function alterForm(HTMLForm $form)
 {
     $form->setSubmitText(wfMessage("mailmypassword"));
 }
Exemplo n.º 28
0
 function getForm()
 {
     global $wgMiserMode;
     $fields = array('like' => array('type' => 'text', 'label-message' => 'newimages-label', 'name' => 'like'), 'showbots' => array('type' => 'check', 'label' => wfMessage('showhidebots', wfMsg('show')), 'name' => 'showbots'), 'limit' => array('type' => 'hidden', 'default' => $this->getRequest()->getText('limit'), '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->setSubmitText(wfMsg('ilsubmit'));
     $form->setMethod('get');
     $form->setWrapperLegend(wfMsg('newimages-legend'));
     return $form;
 }
Exemplo n.º 29
0
 /**
  * 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;
 }
 /**
  * (non-PHPdoc)
  * @see FormSpecialPage::getForm()
  * @return HTMLForm|null
  */
 protected function getForm()
 {
     $fields = $this->getFormFields();
     if ($this->isNew()) {
         $fields['isnew'] = array('type' => 'hidden', 'default' => 1);
     }
     $form = new HTMLForm($fields, $this->getContext());
     $form->setSubmitCallback(array($this, 'handleSubmission'));
     $form->setSubmitText(wfMsg('educationprogram-org-submit'));
     $action = $this->isNew() ? 'add' : 'edit';
     $form->setWrapperLegend($this->msg(strtolower($this->getName()) . '-' . $action . '-legend'));
     $form->addButton('cancelEdit', wfMsg('cancel'), 'cancelEdit', array('target-url' => SpecialPage::getTitleFor($this->listPage)->getFullURL()));
     //		$form->addButton(
     //			'deleteEdit',
     //			wfMsg( 'delete' ),
     //			'deleteEdit'
     //		);
     return $form;
 }