Exemplo n.º 1
0
 /**
  * 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;
 }
Exemplo n.º 2
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;
         }
     }
 }
 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();
     }
 }
Exemplo n.º 4
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();
 }
 /**
  * @return void
  */
 function listDomains()
 {
     $this->setHeaders();
     $this->getOutput()->setPagetitle($this->msg('openstackmanager-domainlist'));
     $this->getOutput()->addModuleStyles('ext.openstack');
     $domainInfo = array();
     $domainInfo['domainname'] = array('type' => 'text', 'label-message' => 'openstackmanager-domainname', 'default' => '', 'section' => 'domain', 'name' => 'domainname');
     $domainInfo['fqdn'] = array('type' => 'text', 'label-message' => 'openstackmanager-fqdn', 'default' => '', 'section' => 'domain', 'name' => 'fqdn');
     $domainInfo['location'] = array('type' => 'text', 'label-message' => 'openstackmanager-location', 'default' => '', 'section' => 'domain', 'help-message' => 'openstackmanager-location-help', 'name' => 'location');
     $domainInfo['action'] = array('type' => 'hidden', 'default' => 'create', 'name' => 'action');
     $domainForm = new HTMLForm($domainInfo, $this->getContext(), 'openstackmanager-novadomain');
     $domainForm->setSubmitID('novadomain-form-createdomainsubmit');
     $domainForm->setSubmitCallback(array($this, 'tryCreateSubmit'));
     $domainForm->show();
     $headers = array('openstackmanager-domainname', 'openstackmanager-fqdn', 'openstackmanager-location', 'openstackmanager-actions');
     $domains = OpenStackNovaDomain::getAllDomains();
     $domainRows = array();
     foreach ($domains as $domain) {
         $domainRow = array();
         $domainName = $domain->getDomainName();
         $this->pushResourceColumn($domainRow, $domainName);
         $this->pushResourceColumn($domainRow, $domain->getFullyQualifiedDomainName());
         $this->pushResourceColumn($domainRow, $domain->getLocation());
         $this->pushRawResourceColumn($domainRow, $this->createActionLink('openstackmanager-delete', array('action' => 'delete', 'domainname' => $domainName)));
         $domainRows[] = $domainRow;
     }
     if ($domainRows) {
         $out = $this->createResourceTable($headers, $domainRows);
     } else {
         $out = '';
     }
     $this->getOutput()->addHTML($out);
 }
Exemplo n.º 6
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;
 }
 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);
     }
 }
Exemplo n.º 9
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());
     }
 }
Exemplo n.º 10
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.º 11
0
 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();
 }
 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.º 13
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.º 14
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();
 }
 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();
 }
Exemplo n.º 16
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();
 }
 /**
  * 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();
 }
Exemplo n.º 18
0
 private function showResetForm()
 {
     if (!$this->getUser()->isAllowed('editmyoptions')) {
         throw new PermissionsError('editmyoptions');
     }
     $this->getOutput()->addWikiMsg('prefs-reset-intro');
     $context = new DerivativeContext($this->getContext());
     $context->setTitle($this->getPageTitle('reset'));
     // Reset subpage
     $htmlForm = new HTMLForm(array(), $context, 'prefs-restore');
     $htmlForm->setSubmitTextMsg('restoreprefs');
     $htmlForm->setSubmitCallback(array($this, 'submitReset'));
     $htmlForm->suppressReset();
     $htmlForm->show();
 }
Exemplo n.º 19
0
 /**
  * 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;
 }
Exemplo n.º 20
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;
         }
     }
 }
 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();
     }
 }
Exemplo n.º 22
0
 /**
  * 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;
 }
Exemplo n.º 23
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);
     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);
     }
     $this->setHeaders();
     $this->outputHeader();
     $out = $this->getOutput();
     $out->setPageTitle($this->msg('unblockip'));
     $out->addModules(['mediawiki.special', 'mediawiki.userSuggest']);
     $form = new HTMLForm($this->getFields(), $this->getContext());
     $form->setWrapperLegendMsg('unblockip');
     $form->setSubmitCallback([__CLASS__, 'processUIUnblock']);
     $form->setSubmitTextMsg('ipusubmit');
     $form->addPreText($this->msg('unblockiptext')->parseAsBlock());
     if ($form->show()) {
         switch ($this->type) {
             case Block::TYPE_IP:
                 $out->addWikiMsg('unblocked-ip', wfEscapeWikiText($this->target));
                 break;
             case Block::TYPE_USER:
                 $out->addWikiMsg('unblocked', wfEscapeWikiText($this->target));
                 break;
             case Block::TYPE_RANGE:
                 $out->addWikiMsg('unblocked-range', wfEscapeWikiText($this->target));
                 break;
             case Block::TYPE_ID:
             case Block::TYPE_AUTO:
                 $out->addWikiMsg('unblocked-id', wfEscapeWikiText($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.º 25
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, $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;
 }
Exemplo n.º 26
0
 /**
  * Get a form for clearing the watchlist
  *
  * @return HTMLForm
  */
 protected function getClearForm()
 {
     $context = new DerivativeContext($this->getContext());
     $context->setTitle($this->getPageTitle('clear'));
     // Reset subpage
     $form = new HTMLForm(array(), $context);
     $form->setSubmitTextMsg('watchlistedit-clear-submit');
     # Used message keys: 'accesskey-watchlistedit-clear-submit', 'tooltip-watchlistedit-clear-submit'
     $form->setSubmitTooltip('watchlistedit-clear-submit');
     $form->setWrapperLegendMsg('watchlistedit-clear-legend');
     $form->addHeaderText($this->msg('watchlistedit-clear-explain')->parse());
     $form->setSubmitCallback(array($this, 'submitClear'));
     $form->setSubmitDestructive();
     return $form;
 }
Exemplo n.º 27
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;
 }
 /**
  * @return bool
  */
 function configureProject()
 {
     global $wgOpenStackManagerServiceGroupPrefix;
     $this->setHeaders();
     $projectName = $this->getRequest()->getText('projectname');
     $this->getOutput()->setPagetitle($this->msg('openstackmanager-configureproject', $projectName));
     if (!$this->userCanExecute($this->getUser()) && !$this->userLDAP->inRole('projectadmin', $projectName)) {
         $this->notInRole('projectadmin', $projectName);
         return false;
     }
     $project = OpenStackNovaProject::getProjectByName($projectName);
     $volumes = $project->getVolumeSettings();
     $defaultHomedirs = in_array("home", $volumes);
     $defaultProject = in_array("project", $volumes);
     $homePattern = $project->getServiceGroupHomedirPattern();
     $formInfo = array();
     $formInfo['homedirs'] = array('type' => 'check', 'label-message' => 'openstackmanager-configureproject-sharedhomedirs', 'default' => $defaultHomedirs, 'section' => 'volume', 'name' => 'sharedhomedirs');
     $formInfo['storage'] = array('type' => 'check', 'label-message' => 'openstackmanager-configureproject-sharedstorage', 'default' => $defaultProject, 'section' => 'volume', 'name' => 'sharedstorage');
     $formInfo['serviceuserhome'] = array('type' => 'text', 'label-message' => 'openstackmanager-configureproject-serviceuserhome', 'default' => $homePattern, 'section' => 'servicegroup', 'name' => 'serviceuserhome');
     $msg = $this->msg('openstackmanager-configureproject-serviceuserinfo', $wgOpenStackManagerServiceGroupPrefix);
     $formInfo['serviceuserhomeinfo'] = array('type' => 'info', 'section' => 'servicegroup', 'label' => $msg);
     $formInfo['action'] = array('type' => 'hidden', 'default' => 'configureproject', 'name' => 'action');
     $formInfo['projectname'] = array('type' => 'hidden', 'default' => $projectName, 'name' => 'projectname');
     $projectForm = new HTMLForm($formInfo, $this->getContext(), 'openstackmanager-configureproject');
     $projectForm->setSubmitID('novaproject-form-configuresubmit');
     $projectForm->setSubmitCallback(array($this, 'tryConfigureProjectSubmit'));
     $projectForm->show();
     return true;
 }
Exemplo n.º 29
0
 /**
  * Gets an HTMLForm object suitable for showing this form
  */
 public function getForm()
 {
     $form = new HTMLForm($this->getFormDescriptor());
     $form->setSubmitCallback(array($this, 'submit'));
     return $form;
 }
 /**
  * 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'))))));
 }