MediaWiki  master
SpecialNewSection.php
Go to the documentation of this file.
1 <?php
25  public function __construct() {
26  parent::__construct( 'NewSection' );
27  $this->mAllowedRedirectParams = [ 'preloadtitle', 'nosummary', 'editintro',
28  'preload', 'preloadparams', 'summary' ];
29  }
30 
34  public function getRedirect( $subpage ) {
35  if ( $subpage === null || $subpage === '' ) {
36  return false;
37  }
38  $this->mAddedRedirectParams['title'] = $subpage;
39  $this->mAddedRedirectParams['action'] = 'edit';
40  $this->mAddedRedirectParams['section'] = 'new';
41  return true;
42  }
43 
44  protected function showNoRedirectPage() {
45  $this->setHeaders();
46  $this->outputHeader();
47  $this->addHelpLink( 'Help:New section' );
48  $this->showForm();
49  }
50 
51  private function showForm() {
52  $form = HTMLForm::factory( 'ooui', [
53  'page' => [
54  'type' => 'title',
55  'name' => 'page',
56  'label-message' => 'newsection-page',
57  'required' => true,
58  'creatable' => true,
59  ],
60  ], $this->getContext(), 'newsection' );
61  $form->setSubmitTextMsg( 'newsection-submit' );
62  $form->setSubmitCallback( [ $this, 'onFormSubmit' ] );
63  $form->show();
64  }
65 
66  public function onFormSubmit( $formData ) {
67  $title = $formData['page'];
69  $query = [ 'action' => 'edit', 'section' => 'new' ];
70  $url = $page->getFullUrlForRedirect( $query );
71  $this->getOutput()->redirect( $url );
72  }
73 
74  public function isListed() {
75  return true;
76  }
77 
78  protected function getGroupName() {
79  return 'redirects';
80  }
81 }
SpecialPage\getOutput
getOutput()
Get the OutputPage being used for this instance.
Definition: SpecialPage.php:790
RedirectSpecialPage
Shortcut to construct a special page alias.
Definition: RedirectSpecialPage.php:31
SpecialNewSection\getGroupName
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
Definition: SpecialNewSection.php:78
SpecialNewSection\__construct
__construct()
Definition: SpecialNewSection.php:25
SpecialPage\addHelpLink
addHelpLink( $to, $overrideBaseUrl=false)
Adds help link with an icon via page indicators.
Definition: SpecialPage.php:948
SpecialNewSection
Definition: SpecialNewSection.php:24
$title
$title
Definition: testCompression.php:38
SpecialPage\setHeaders
setHeaders()
Sets headers - this should be called from the execute() method of all derived classes!
Definition: SpecialPage.php:618
SpecialPage\getContext
getContext()
Gets the context this SpecialPage is executed in.
Definition: SpecialPage.php:764
Title\newFromTextThrow
static newFromTextThrow( $text, $defaultNamespace=NS_MAIN)
Like Title::newFromText(), but throws MalformedTitleException when the title is invalid,...
Definition: Title.php:430
SpecialNewSection\showForm
showForm()
Definition: SpecialNewSection.php:51
SpecialNewSection\onFormSubmit
onFormSubmit( $formData)
Definition: SpecialNewSection.php:66
SpecialNewSection\getRedirect
getRedirect( $subpage)
If the special page is a redirect, then get the Title object it redirects to.False otherwise....
Definition: SpecialNewSection.php:34
SpecialNewSection\isListed
isListed()
Whether this special page is listed in Special:SpecialPages.
Definition: SpecialNewSection.php:74
HTMLForm\factory
static factory( $displayFormat,... $arguments)
Construct a HTMLForm object for given display type.
Definition: HTMLForm.php:326
SpecialNewSection\showNoRedirectPage
showNoRedirectPage()
Definition: SpecialNewSection.php:44
SpecialPage\outputHeader
outputHeader( $summaryMessageKey='')
Outputs a summary message on top of special pages Per default the message key is the canonical name o...
Definition: SpecialPage.php:709