MediaWiki REL1_37
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'];
68 $page = Title::newFromTextThrow( $title );
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}
Shortcut to construct a special page alias.
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
getRedirect( $subpage)
If the special page is a redirect, then get the Title object it redirects to.False otherwise....
isListed()
Whether this special page is listed in Special:SpecialPages.
outputHeader( $summaryMessageKey='')
Outputs a summary message on top of special pages Per default the message key is the canonical name o...
setHeaders()
Sets headers - this should be called from the execute() method of all derived classes!
getOutput()
Get the OutputPage being used for this instance.
getContext()
Gets the context this SpecialPage is executed in.
addHelpLink( $to, $overrideBaseUrl=false)
Adds help link with an icon via page indicators.