Jackmcbarn has uploaded a new change for review.
https://gerrit.wikimedia.org/r/97559
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.i18n.php
M InputBox.php
4 files changed, 92 insertions(+), 0 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/InputBox
refs/changes/59/97559/1
diff --git a/InputBox.classes.php b/InputBox.classes.php
index 380015c..c62fb20 100644
--- a/InputBox.classes.php
+++ b/InputBox.classes.php
@@ -34,6 +34,7 @@
private $mInline = false;
private $mPrefix = '';
private $mDir = '';
+ private $mWpNewTitle = '';
/* Functions */
@@ -52,6 +53,8 @@
case 'create':
case 'comment':
return $this->getCreateForm();
+ case 'move':
+ return $this->getMoveForm();
case 'commenttitle':
return $this->getCommentForm();
case 'search':
@@ -421,6 +424,79 @@
}
/**
+ * Generate move page form
+ */
+ public function getMoveForm() {
+ global $wgScript;
+
+ if ( !$this->mButtonLabel ) {
+ $this->mButtonLabel = wfMessage( 'movearticle'
)->escaped();
+ }
+
+ $htmlOut = Xml::openElement( 'div',
+ array(
+ 'style' => 'margin-left: auto; margin-right:
auto; text-align: center; background-color:' . $this->mBGColor
+ )
+ );
+ $moveBoxParams = array(
+ 'name' => 'movebox',
+ 'class' => 'movebox',
+ 'action' => $wgScript,
+ 'method' => 'get'
+ );
+ if( isset( $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')->getPrefixedText() . '/' . str_replace( '
', '_', $this->mPage ),
+ )
+ );
+ $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' => 'moveboxInput',
+ 'value' => $this->mDefaultText,
+ 'placeholder' => $this->mPlaceholderText,
+ 'size' => $this->mWidth,
+ 'dir' => $this->mDir,
+ )
+ );
+ $htmlOut .= $this->mBR;
+ $htmlOut .= Xml::openElement( 'input',
+ array(
+ 'type' => 'submit',
+ 'name' => 'move',
+ 'class' => 'moveboxButton',
+ 'value' => $this->mButtonLabel
+ )
+ );
+ $htmlOut .= Xml::closeElement( 'form' );
+ $htmlOut .= Xml::closeElement( 'div' );
+
+ // Return HTML
+ return $htmlOut;
+ }
+
+ /**
* Generate new section form
*/
public function getCommentForm() {
@@ -553,6 +629,7 @@
'inline' => 'mInline',
'prefix' => 'mPrefix',
'dir' => 'mDir',
+ 'wpNewTitle' => 'mWpNewTitle',
);
foreach ( $options as $name => $var ) {
if ( isset( $values[$name] ) ) {
diff --git a/InputBox.hooks.php b/InputBox.hooks.php
index 7cc6054..2d779ec 100644
--- a/InputBox.hooks.php
+++ b/InputBox.hooks.php
@@ -17,6 +17,17 @@
return true;
}
+ // Prepend prefix to wgNewTitle if necessary
+ public static function attachPrefix( ) {
+ global $wgRequest;
+ $prefix = $wgRequest->getText( 'prefix', '' );
+ $title = $wgRequest->getText( 'wpNewTitle', '' );
+ if( $prefix !== '' && $title !== '' ) {
+ $wgRequest->setVal( 'wpNewTitle', $prefix . $title );
+ $wgRequest->unsetVal( 'prefix' );
+ }
+ }
+
// Render the input box
public static function render( $input, $args, Parser $parser ) {
// Create InputBox
diff --git a/InputBox.i18n.php b/InputBox.i18n.php
index 0d05d03..c1f4e65 100644
--- a/InputBox.i18n.php
+++ b/InputBox.i18n.php
@@ -22,6 +22,7 @@
'tryexact' => 'Try exact match',
'searchfulltext' => 'Search full text',
'createarticle' => 'Create page',
+ 'movearticle' => 'Move page',
'inputbox-ns-main' => 'Main',
);
@@ -53,6 +54,7 @@
* {{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.
{{Identical|Create page}}',
+ '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.
{{Identical|Main}}',
);
diff --git a/InputBox.php b/InputBox.php
index b54baa3..132b9bf 100644
--- a/InputBox.php
+++ b/InputBox.php
@@ -52,3 +52,5 @@
// Register parser hook
$wgHooks['ParserFirstCallInit'][] = 'InputBoxHooks::register';
$wgHooks['MediaWikiPerformAction'][] =
'InputBoxHooks::onMediaWikiPerformAction';
+
+$wgExtensionFunctions[] = 'InputBoxHooks::attachPrefix';
--
To view, visit https://gerrit.wikimedia.org/r/97559
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I1740497030b5e9872162a1a261ac38791bb1373a
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/InputBox
Gerrit-Branch: master
Gerrit-Owner: Jackmcbarn <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits