Create Special:NewSection special page
authorDannyS712 <DannyS712.enwiki@gmail.com>
Sun, 23 Jun 2019 02:17:38 +0000 (02:17 +0000)
committerDannyS712 <DannyS712.enwiki@gmail.com>
Fri, 2 Aug 2019 12:34:13 +0000 (12:34 +0000)
Bug: T207577
Change-Id: If69a8e13b524f55f78b2f61aadf1f9045fda5ff2

RELEASE-NOTES-1.34
autoload.php
includes/specialpage/SpecialPageFactory.php
includes/specials/SpecialNewSection.php [new file with mode: 0644]
languages/i18n/en.json
languages/i18n/qqq.json
languages/messages/MessagesEn.php

index 549f7e8..95db78a 100644 (file)
@@ -62,6 +62,11 @@ For notes on 1.33.x and older releases, see HISTORY.
 === New user-facing features in 1.34 ===
 * Special:Mute has been added as a quick way for users to block unwanted emails
   from other users originating from Special:EmailUser.
+* (T207577) Special:NewSection has been created as a shortcut to creating a new
+  section on a page. When linked to, its subpage is used as the target
+  ([[Special:NewSection/Test]] redirects to creating a new section in "Test").
+  Otherwise, it displays a basic interface to allow the end user to specify
+  the target manually.
 
 === New developer features in 1.34 ===
 * Language::formatTimePeriod now supports the new 'avoidhours' option to output
index 0b93f49..5fde341 100644 (file)
@@ -1395,6 +1395,7 @@ $wgAutoloadLocalClasses = [
        'SpecialMytalk' => __DIR__ . '/includes/specials/redirects/SpecialMytalk.php',
        'SpecialMyuploads' => __DIR__ . '/includes/specials/redirects/SpecialMyuploads.php',
        'SpecialNewFiles' => __DIR__ . '/includes/specials/SpecialNewimages.php',
+       'SpecialNewSection' => __DIR__ . '/includes/specials/SpecialNewSection.php',
        'SpecialNewpages' => __DIR__ . '/includes/specials/SpecialNewpages.php',
        'SpecialPage' => __DIR__ . '/includes/specialpage/SpecialPage.php',
        'SpecialPageAction' => __DIR__ . '/includes/actions/SpecialPageAction.php',
index 40172ab..051926d 100644 (file)
@@ -200,6 +200,7 @@ class SpecialPageFactory {
                'Mytalk' => \SpecialMytalk::class,
                'Myuploads' => \SpecialMyuploads::class,
                'AllMyUploads' => \SpecialAllMyUploads::class,
+               'NewSection' => \SpecialNewSection::class,
                'PermanentLink' => \SpecialPermanentLink::class,
                'Redirect' => \SpecialRedirect::class,
                'Revisiondelete' => \SpecialRevisionDelete::class,
diff --git a/includes/specials/SpecialNewSection.php b/includes/specials/SpecialNewSection.php
new file mode 100644 (file)
index 0000000..b503141
--- /dev/null
@@ -0,0 +1,76 @@
+<?php
+/**
+ * Redirect from Special:NewSection/$1 to index.php?title=$1&action=edit&section=new.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ * @file
+ * @ingroup SpecialPage
+ */
+class SpecialNewSection extends RedirectSpecialPage {
+       public function __construct() {
+               parent::__construct( 'NewSection' );
+               $this->mAllowedRedirectParams = [ 'preloadtitle', 'nosummary', 'editintro',
+                       'preload', 'preloadparams[]', 'summary' ];
+       }
+
+       /**
+        * @inheritDoc
+        */
+       public function getRedirect( $subpage ) {
+               if ( $subpage === null || $subpage === '' ) {
+                       return false;
+               }
+               $this->mAddedRedirectParams['title'] = $subpage;
+               $this->mAddedRedirectParams['action'] = 'edit';
+               $this->mAddedRedirectParams['section'] = 'new';
+               return true;
+       }
+
+       protected function showNoRedirectPage() {
+               $this->setHeaders();
+               $this->outputHeader();
+               $this->showForm();
+       }
+
+       private function showForm() {
+               $form = HTMLForm::factory( 'ooui', [
+                       'page' => [
+                               'type' => 'text',
+                               'name' => 'page',
+                               'label-message' => 'newsection-page',
+                       ],
+               ], $this->getContext(), 'newsection' );
+               $form->setSubmitTextMsg( 'newsection-submit' );
+               $form->setSubmitCallback( [ $this, 'onFormSubmit' ] );
+               $form->show();
+       }
+
+       public function onFormSubmit( $formData ) {
+               $page = $formData['page'];
+               $query = [ 'action' => 'edit', 'section' => 'new' ];
+               $url = $page->getFullUrlForRedirect( $query );
+               $this->getOutput()->redirect( $url );
+       }
+
+       public function isListed() {
+               return true;
+       }
+
+       protected function getGroupName() {
+               return 'redirects';
+       }
+}
index 244b281..6d324f6 100644 (file)
        "permanentlink-revid": "Revision ID",
        "permanentlink-submit": "Go to revision",
        "permanentlink-summary": "",
+       "newsection": "New section",
+       "newsection-page": "Target page",
+       "newsection-submit": "Go to page",
+       "newsection-summary": "",
        "dberr-problems": "Sorry! This site is experiencing technical difficulties.",
        "dberr-again": "Try waiting a few minutes and reloading.",
        "dberr-info": "(Cannot access the database: $1)",
index 63ff375..14df22c 100644 (file)
        "permanentlink-revid": "Label for the field for the revision ID in [[Special:PermanentLink]]\n{{Identical|Revision ID}}",
        "permanentlink-submit": "Submit button on [[Special:PermanentLink]]",
        "permanentlink-summary": "{{doc-specialpagesummary|permanentlink}}",
+       "newsection": "The title of [[Special:NewSection]]",
+       "newsection-page": "Label for the field for the target page in [[Special:NewSection]]",
+       "newsection-submit": "Submit button on [[Special:NewSection]]",
+       "newsection-summary": "{{doc-specialpagessummary|newsection}}",
        "dberr-problems": "This message does not allow any wiki nor html markup.",
        "dberr-again": "This message does not allow any wiki nor html markup.",
        "dberr-info": "This message does not allow any wiki nor html markup. Parameters:\n* $1 - database server name\nSee also:\n* {{msg-mw|Dberr-info-hidden}} - hides database server name",
index 22313a4..fc21843 100644 (file)
@@ -454,6 +454,7 @@ $specialPageAliases = [
        'Mytalk'                    => [ 'MyTalk' ],
        'Myuploads'                 => [ 'MyUploads', 'MyFiles' ],
        'Newimages'                 => [ 'NewFiles', 'NewImages' ],
+       'NewSection'                => [ 'NewSection', 'Newsection' ],
        'Newpages'                  => [ 'NewPages' ],
        'PagesWithProp'             => [ 'PagesWithProp', 'Pageswithprop', 'PagesByProp', 'Pagesbyprop' ],
        'PageData'                  => [ 'PageData' ],