Exemplo n.º 1
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.º 2
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.º 3
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;
 }
Exemplo n.º 4
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.º 5
0
 /**
  * Add footer elements to the form
  * @param  $form HTMLForm
  * @return void
  */
 protected function doPostText(HTMLForm &$form)
 {
     global $wgUser, $wgLang;
     # Link to the user's contributions, if applicable
     if ($this->target instanceof User) {
         $contribsPage = SpecialPage::getTitleFor('Contributions', $this->target->getName());
         $links[] = Linker::link($contribsPage, wfMsgExt('ipb-blocklist-contribs', 'escape', $this->target->getName()));
     }
     # Link to unblock the specified user, or to a blank unblock form
     if ($this->target instanceof User) {
         $message = wfMsgExt('ipb-unblock-addr', array('parseinline'), $this->target->getName());
         $list = SpecialPage::getTitleFor('Unblock', $this->target->getName());
     } else {
         $message = wfMsgExt('ipb-unblock', array('parseinline'));
         $list = SpecialPage::getTitleFor('Unblock');
     }
     $links[] = Linker::linkKnown($list, $message, array());
     # Link to the block list
     $links[] = Linker::linkKnown(SpecialPage::getTitleFor('BlockList'), wfMsg('ipb-blocklist'));
     # Link to edit the block dropdown reasons, if applicable
     if ($wgUser->isAllowed('editinterface')) {
         $links[] = Linker::link(Title::makeTitle(NS_MEDIAWIKI, 'Ipbreason-dropdown'), wfMsgHtml('ipb-edit-dropdown'), array(), array('action' => 'edit'));
     }
     $form->addPostText(Html::rawElement('p', array('class' => 'mw-ipb-conveniencelinks'), $wgLang->pipeList($links)));
     if ($this->target instanceof User) {
         # Get relevant extracts from the block and suppression logs, if possible
         $userpage = $this->target->getUserPage();
         $out = '';
         LogEventsList::showLogExtract($out, 'block', $userpage->getPrefixedText(), '', array('lim' => 10, 'msgKey' => array('blocklog-showlog', $userpage->getText()), 'showIfEmpty' => false));
         $form->addPostText($out);
         # Add suppression block entries if allowed
         if ($wgUser->isAllowed('suppressionlog')) {
             LogEventsList::showLogExtract($out, 'suppress', $userpage->getPrefixedText(), '', array('lim' => 10, 'conds' => array('log_action' => array('block', 'reblock', 'unblock')), 'msgKey' => array('blocklog-showsuppresslog', $userpage->getText()), 'showIfEmpty' => false));
             $form->addPostText($out);
         }
     }
 }