/**
  * 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();
 }
 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;
         }
     }
 }
 /**
  * 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();
 }
 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'));
 }
 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());
     }
 }
 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());
     }
 }
 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;
         }
     }
 }
 function execute($par)
 {
     $this->setHeaders();
     $this->outputHeader();
     $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'));
     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->setAction($this->getTitle()->getFullUrl());
     $form->setSubmitCallback(array($this, 'onSubmit'));
     $form->setWrapperLegend($this->msg('pageswithprop-legend'));
     $form->addHeaderText($this->msg('pageswithprop-text')->parseAsBlock());
     $form->setSubmitTextMsg('pageswithprop-submit');
     $form->prepareForm();
     $form->displayForm(false);
     if ($propname !== '' && $propname !== null) {
         $form->trySubmit();
     }
 }
Exemple #9
0
 /**
  * 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;
 }
 public function alterForm(HTMLForm $form)
 {
     global $wgPasswordResetRoutes;
     $form->setDisplayFormat('vform');
     // Turn the old-school line around the form off.
     // XXX This wouldn't be necessary here if we could set the format of
     // the HTMLForm to 'vform' at its creation, but there's no way to do so
     // from a FormSpecialPage class.
     $form->setWrapperLegend(false);
     $form->addHiddenFields($this->getRequest()->getValues('returnto', 'returntoquery'));
     $i = 0;
     if (isset($wgPasswordResetRoutes['username']) && $wgPasswordResetRoutes['username']) {
         $i++;
     }
     if (isset($wgPasswordResetRoutes['email']) && $wgPasswordResetRoutes['email']) {
         $i++;
     }
     if (isset($wgPasswordResetRoutes['domain']) && $wgPasswordResetRoutes['domain']) {
         $i++;
     }
     $message = $i > 1 ? 'passwordreset-text-many' : 'passwordreset-text-one';
     $form->setHeaderText($this->msg($message, $i)->parseAsBlock());
     $form->setSubmitTextMsg('mailmypassword');
 }
 /**
  * @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();
 }
 public function alterForm(HTMLForm $form)
 {
     $form->setDisplayFormat('vform');
     $form->setWrapperLegend(false);
 }
Exemple #13
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);
     }
 }
 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;
 }
 /**
  * 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();
     }
 }
 public function alterForm(HTMLForm $form)
 {
     $form->setDisplayFormat('vform');
     $form->setWrapperLegend(false);
     wfRunHooks('LanguageSelector', array($this->getOutput(), 'mw-languageselector'));
 }
	/**
	 * 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();
		}
	}
 protected function alterForm(HTMLForm $form)
 {
     $form->setWrapperLegend(false)->setHeaderText($this->msg('lockdbtext')->parseAsBlock())->setSubmitTextMsg('lockbtn');
 }
 /**
  * (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;
 }
Exemple #20
0
 protected function alterForm(HTMLForm $form)
 {
     $form->setWrapperLegend(wfMsgHtml('filerevert-legend'));
     $form->setSubmitText(wfMsg('filerevert-submit'));
     $form->addHiddenField('oldimage', $this->getRequest()->getText('oldimage'));
 }
 /**
  * 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;
 }