jenkins-bot has submitted this change and it was merged.

Change subject: Allow InputBoxes to be used to move pages
......................................................................


Allow InputBoxes to be used to move pages

Add an option to InputBoxes to allow them to prefill Special:MovePage with
prefixes and other similar options to pages being created

Change-Id: I1740497030b5e9872162a1a261ac38791bb1373a
---
M InputBox.classes.php
M InputBox.hooks.php
M InputBox.php
M i18n/en.json
M i18n/qqq.json
5 files changed, 89 insertions(+), 0 deletions(-)

Approvals:
  Brian Wolff: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/InputBox.classes.php b/InputBox.classes.php
index b3fdd0c..1b34519 100644
--- a/InputBox.classes.php
+++ b/InputBox.classes.php
@@ -52,6 +52,8 @@
                        case 'create':
                        case 'comment':
                                return $this->getCreateForm();
+                       case 'move':
+                               return $this->getMoveForm();
                        case 'commenttitle':
                                return $this->getCommentForm();
                        case 'search':
@@ -421,6 +423,78 @@
        }
 
        /**
+        * Generate move page form
+        */
+       public function getMoveForm() {
+               global $wgScript;
+
+               if ( !$this->mButtonLabel ) {
+                       $this->mButtonLabel = wfMessage( 'inputbox-movearticle' 
)->text();
+               }
+
+               $htmlOut = Xml::openElement( 'div',
+                       array(
+                               'style' => 'margin-left: auto; margin-right: 
auto; text-align: center; background-color:' . $this->mBGColor
+                       )
+               );
+               $moveBoxParams = array(
+                       'name' => 'movebox',
+                       'class' => 'mw-movebox',
+                       'action' => $wgScript,
+                       'method' => 'get'
+               );
+               if( $this->mID !== '' ) {
+                       $moveBoxParams['id'] = Sanitizer::escapeId( $this->mID 
);
+               }
+               $htmlOut .= Xml::openElement( 'form', $moveBoxParams );
+               $htmlOut .= Xml::openElement( 'input',
+                       array(
+                               'type' => 'hidden',
+                               'name' => 'title',
+                               'value' => SpecialPage::getTitleFor( 
'Movepage', $this->mPage )->getPrefixedText(),
+                       )
+               );
+               $htmlOut .= Xml::openElement( 'input',
+                       array(
+                               'type' => 'hidden',
+                               'name' => 'wpReason',
+                               'value' => $this->mSummary,
+                       )
+               );
+               $htmlOut .= Xml::openElement( 'input',
+                       array(
+                               'type' => 'hidden',
+                               'name' => 'prefix',
+                               'value' => $this->mPrefix,
+                       )
+               );
+               $htmlOut .= Xml::openElement( 'input',
+                       array(
+                               'type' => $this->mHidden ? 'hidden' : 'text',
+                               'name' => 'wpNewTitle',
+                               'class' => 'mw-moveboxInput',
+                               'value' => $this->mDefaultText,
+                               'placeholder' => $this->mPlaceholderText,
+                               'size' => $this->mWidth,
+                               'dir' => $this->mDir,
+                       )
+               );
+               $htmlOut .= $this->mBR;
+               $htmlOut .= Xml::openElement( 'input',
+                       array(
+                               'type' => 'submit',
+                               'class' => 'mw-moveboxButton',
+                               'value' => $this->mButtonLabel
+                       )
+               );
+               $htmlOut .= Xml::closeElement( 'form' );
+               $htmlOut .= Xml::closeElement( 'div' );
+
+               // Return HTML
+               return $htmlOut;
+       }
+
+       /**
         * Generate new section form
         */
        public function getCommentForm() {
diff --git a/InputBox.hooks.php b/InputBox.hooks.php
index 7cc6054..75fe679 100644
--- a/InputBox.hooks.php
+++ b/InputBox.hooks.php
@@ -17,6 +17,18 @@
                return true;
        }
 
+       // Prepend prefix to wpNewTitle if necessary
+       public static function onSpecialPageBeforeExecute( $special, $subPage ) 
{
+               $request = $special->getRequest();
+               $prefix = $request->getText( 'prefix', '' );
+               $title = $request->getText( 'wpNewTitle', '' );
+               if( $special->getName() == 'Movepage' && $prefix !== '' && 
$title !== '' ) {
+                       $request->setVal( 'wpNewTitle', $prefix . $title );
+                       $request->unsetVal( 'prefix' );
+               }
+               return true;
+       }
+
        // Render the input box
        public static function render( $input, $args, Parser $parser ) {
                // Create InputBox
diff --git a/InputBox.php b/InputBox.php
index c54065a..6473bd7 100644
--- a/InputBox.php
+++ b/InputBox.php
@@ -53,3 +53,4 @@
 // Register parser hook
 $wgHooks['ParserFirstCallInit'][] = 'InputBoxHooks::register';
 $wgHooks['MediaWikiPerformAction'][] = 
'InputBoxHooks::onMediaWikiPerformAction';
+$wgHooks['SpecialPageBeforeExecute'][] = 
'InputBoxHooks::onSpecialPageBeforeExecute';
diff --git a/i18n/en.json b/i18n/en.json
index 2d04c8e..0787920 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -8,5 +8,6 @@
     "inputbox-tryexact": "Try exact match",
     "inputbox-searchfulltext": "Search full text",
     "inputbox-createarticle": "Create page",
+    "inputbox-movearticle": "Move page",
     "inputbox-ns-main": "Main"
 }
diff --git a/i18n/qqq.json b/i18n/qqq.json
index 35c944f..0a8e921 100644
--- a/i18n/qqq.json
+++ b/i18n/qqq.json
@@ -15,5 +15,6 @@
     "tryexact": "Part of the \"Inputbox\" extension. This message is the text 
of the button to search the page you typed in the inputbox. If the page with 
the exact name exists, you will go directly to that page.",
     "searchfulltext": "Part of the \"Inputbox\" extension. This message is the 
text of the button to search the page you typed in the inputbox. This button 
always goes to the search page, even if the page with the exact name 
exists.\n\nSee also:\n* {{msg-mw|Search}}\n* 
{{msg-mw|Accesskey-search-fulltext}}\n* {{msg-mw|Tooltip-search-fulltext}}",
     "createarticle": "Part of the \"Inputbox\" extension. This message is the 
text of the button to create the page you typed in the 
inputbox.\n{{Identical|Create page}}",
+    "inputbox-movearticle": "Part of the \"Inputbox\" extension. This message 
is the text of the button to move the page to the name you typed in the 
inputbox.",
     "inputbox-ns-main": "Probably refers to the main 
namespace.\n{{Identical|Main}}"
 }
\ No newline at end of file

-- 
To view, visit https://gerrit.wikimedia.org/r/97559
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I1740497030b5e9872162a1a261ac38791bb1373a
Gerrit-PatchSet: 6
Gerrit-Project: mediawiki/extensions/InputBox
Gerrit-Branch: master
Gerrit-Owner: Jackmcbarn <[email protected]>
Gerrit-Reviewer: Anomie <[email protected]>
Gerrit-Reviewer: Brian Wolff <[email protected]>
Gerrit-Reviewer: CSteipp <[email protected]>
Gerrit-Reviewer: Eloquence <[email protected]>
Gerrit-Reviewer: Hoo man <[email protected]>
Gerrit-Reviewer: Jackmcbarn <[email protected]>
Gerrit-Reviewer: Legoktm <[email protected]>
Gerrit-Reviewer: Parent5446 <[email protected]>
Gerrit-Reviewer: Siebrand <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to