mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/InputBox
synced 2024-09-24 10:49:06 +00:00
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
This commit is contained in:
parent
f14419180a
commit
c3fd290fff
|
@ -52,6 +52,8 @@ class InputBox {
|
||||||
case 'create':
|
case 'create':
|
||||||
case 'comment':
|
case 'comment':
|
||||||
return $this->getCreateForm();
|
return $this->getCreateForm();
|
||||||
|
case 'move':
|
||||||
|
return $this->getMoveForm();
|
||||||
case 'commenttitle':
|
case 'commenttitle':
|
||||||
return $this->getCommentForm();
|
return $this->getCommentForm();
|
||||||
case 'search':
|
case 'search':
|
||||||
|
@ -420,6 +422,78 @@ class InputBox {
|
||||||
return $htmlOut;
|
return $htmlOut;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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
|
* Generate new section form
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -17,6 +17,18 @@ class InputBoxHooks {
|
||||||
return true;
|
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
|
// Render the input box
|
||||||
public static function render( $input, $args, Parser $parser ) {
|
public static function render( $input, $args, Parser $parser ) {
|
||||||
// Create InputBox
|
// Create InputBox
|
||||||
|
|
|
@ -53,3 +53,4 @@ $wgAutoloadClasses['InputBox'] = $dir . 'InputBox.classes.php';
|
||||||
// Register parser hook
|
// Register parser hook
|
||||||
$wgHooks['ParserFirstCallInit'][] = 'InputBoxHooks::register';
|
$wgHooks['ParserFirstCallInit'][] = 'InputBoxHooks::register';
|
||||||
$wgHooks['MediaWikiPerformAction'][] = 'InputBoxHooks::onMediaWikiPerformAction';
|
$wgHooks['MediaWikiPerformAction'][] = 'InputBoxHooks::onMediaWikiPerformAction';
|
||||||
|
$wgHooks['SpecialPageBeforeExecute'][] = 'InputBoxHooks::onSpecialPageBeforeExecute';
|
||||||
|
|
|
@ -8,5 +8,6 @@
|
||||||
"inputbox-tryexact": "Try exact match",
|
"inputbox-tryexact": "Try exact match",
|
||||||
"inputbox-searchfulltext": "Search full text",
|
"inputbox-searchfulltext": "Search full text",
|
||||||
"inputbox-createarticle": "Create page",
|
"inputbox-createarticle": "Create page",
|
||||||
|
"inputbox-movearticle": "Move page",
|
||||||
"inputbox-ns-main": "Main"
|
"inputbox-ns-main": "Main"
|
||||||
}
|
}
|
||||||
|
|
|
@ -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.",
|
"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}}",
|
"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}}",
|
"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}}"
|
"inputbox-ns-main": "Probably refers to the main namespace.\n{{Identical|Main}}"
|
||||||
}
|
}
|
Loading…
Reference in a new issue