mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/InputBox
synced 2024-11-13 17:53:26 +00:00
Don't add url parameters to an input box, if the parameter is empty
If a parameter isn't set, it shouldn't be added to the form. Bug: T147048 Change-Id: I7e5aa21528fbc98e9e4d52baca93870f213d4c15
This commit is contained in:
parent
f067d27b8b
commit
a7c83858c6
|
@ -14,13 +14,13 @@ class InputBox {
|
|||
private $mParser;
|
||||
private $mType = '';
|
||||
private $mWidth = 50;
|
||||
private $mPreload = '';
|
||||
private $mPreloadparams = [];
|
||||
private $mEditIntro = '';
|
||||
private $mUseVE = '';
|
||||
private $mSummary = '';
|
||||
private $mNosummary = '';
|
||||
private $mMinor = '';
|
||||
private $mPreload = null;
|
||||
private $mPreloadparams = null;
|
||||
private $mEditIntro = null;
|
||||
private $mUseVE = null;
|
||||
private $mSummary = null;
|
||||
private $mNosummary = null;
|
||||
private $mMinor = null;
|
||||
private $mPage = '';
|
||||
private $mBR = 'yes';
|
||||
private $mDefaultText = '';
|
||||
|
@ -97,7 +97,7 @@ class InputBox {
|
|||
'value' => 'edit',
|
||||
];
|
||||
// check, if VE is installed and VE editor is requested
|
||||
if ( ExtensionRegistry::getInstance()->isLoaded( 'VisualEditor' ) && $this->mUseVE ) {
|
||||
if ( $this->shouldUseVE() ) {
|
||||
$args = [
|
||||
'name' => 'veaction',
|
||||
'value' => 'edit',
|
||||
|
@ -393,15 +393,29 @@ class InputBox {
|
|||
$htmlOut .= Xml::openElement( 'form', $createBoxParams );
|
||||
$editArgs = $this->getEditActionArgs();
|
||||
$htmlOut .= Html::hidden( $editArgs['name'], $editArgs['value'] );
|
||||
$htmlOut .= Html::hidden( 'preload', $this->mPreload );
|
||||
foreach ( $this->mPreloadparams as $preloadparams ) {
|
||||
$htmlOut .= Html::hidden( 'preloadparams[]', $preloadparams );
|
||||
if ( $this->mPreload !== null ) {
|
||||
$htmlOut .= Html::hidden( 'preload', $this->mPreload );
|
||||
}
|
||||
if ( is_array( $this->mPreloadparams ) ) {
|
||||
foreach ( $this->mPreloadparams as $preloadparams ) {
|
||||
$htmlOut .= Html::hidden( 'preloadparams[]', $preloadparams );
|
||||
}
|
||||
}
|
||||
if ( $this->mEditIntro !== null ) {
|
||||
$htmlOut .= Html::hidden( 'editintro', $this->mEditIntro );
|
||||
}
|
||||
if ( $this->mSummary !== null ) {
|
||||
$htmlOut .= Html::hidden( 'summary', $this->mSummary );
|
||||
}
|
||||
if ( $this->mNosummary !== null ) {
|
||||
$htmlOut .= Html::hidden( 'nosummary', $this->mNosummary );
|
||||
}
|
||||
if ( $this->mPrefix !== '' ) {
|
||||
$htmlOut .= Html::hidden( 'prefix', $this->mPrefix );
|
||||
}
|
||||
if ( $this->mMinor !== null ) {
|
||||
$htmlOut .= Html::hidden( 'minor', $this->mMinor );
|
||||
}
|
||||
$htmlOut .= Html::hidden( 'editintro', $this->mEditIntro );
|
||||
$htmlOut .= Html::hidden( 'summary', $this->mSummary );
|
||||
$htmlOut .= Html::hidden( 'nosummary', $this->mNosummary );
|
||||
$htmlOut .= Html::hidden( 'prefix', $this->mPrefix );
|
||||
$htmlOut .= Html::hidden( 'minor', $this->mMinor );
|
||||
if ( $this->mType == 'comment' ) {
|
||||
$htmlOut .= Html::hidden( 'section', 'new' );
|
||||
}
|
||||
|
@ -517,11 +531,17 @@ class InputBox {
|
|||
$htmlOut .= Xml::openElement( 'form', $commentFormParams );
|
||||
$editArgs = $this->getEditActionArgs();
|
||||
$htmlOut .= Html::hidden( $editArgs['name'], $editArgs['value'] );
|
||||
$htmlOut .= Html::hidden( 'preload', $this->mPreload );
|
||||
foreach ( $this->mPreloadparams as $preloadparams ) {
|
||||
$htmlOut .= Html::hidden( 'preloadparams[]', $preloadparams );
|
||||
if ( $this->mPreload !== null ) {
|
||||
$htmlOut .= Html::hidden( 'preload', $this->mPreload );
|
||||
}
|
||||
if ( is_array( $this->mPreloadparams ) ) {
|
||||
foreach ( $this->mPreloadparams as $preloadparams ) {
|
||||
$htmlOut .= Html::hidden( 'preloadparams[]', $preloadparams );
|
||||
}
|
||||
}
|
||||
if ( $this->mEditIntro !== null ) {
|
||||
$htmlOut .= Html::hidden( 'editintro', $this->mEditIntro );
|
||||
}
|
||||
$htmlOut .= Html::hidden( 'editintro', $this->mEditIntro );
|
||||
$htmlOut .= Xml::openElement( 'input',
|
||||
[
|
||||
'type' => $this->mHidden ? 'hidden' : 'text',
|
||||
|
@ -648,4 +668,14 @@ REGEX;
|
|||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true, if the VisualEditor is requested from the inputbox wikitext definition and
|
||||
* if the VisualEditor extension is actually installed or not, false otherwise.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
private function shouldUseVE() {
|
||||
return ExtensionRegistry::getInstance()->isLoaded( 'VisualEditor' ) && $this->mUseVE !== null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,7 +22,233 @@ type=create
|
|||
!! html+tidy
|
||||
<div class="mw-inputbox-centered" style="">
|
||||
<form name="createbox" class="createbox" action="/index.php" method="get" id="createbox">
|
||||
<p><input type="hidden" value="edit" name="action" /><input type="hidden" name="preload" /><input type="hidden" name="editintro" /><input type="hidden" name="summary" /><input type="hidden" name="nosummary" /><input type="hidden" name="prefix" /><input type="hidden" name="minor" /><input type="text" name="title" class="mw-inputbox-input mw-ui-input mw-ui-input-inline createboxInput" value="" placeholder="" size="50" dir="ltr" /><br />
|
||||
<p><input type="hidden" value="edit" name="action" /><input type="text" name="title" class="mw-inputbox-input mw-ui-input mw-ui-input-inline createboxInput" value="" placeholder="" size="50" dir="ltr" /><br />
|
||||
<input type="submit" name="create" class="mw-ui-button mw-ui-progressive createboxButton" value="Create page" /></p>
|
||||
</form>
|
||||
</div>
|
||||
!! end
|
||||
|
||||
!! test
|
||||
InputBox type=create with minor
|
||||
!! wikitext
|
||||
<inputbox>
|
||||
type=create
|
||||
minor=1
|
||||
</inputbox>
|
||||
!! html+tidy
|
||||
<div class="mw-inputbox-centered" style="">
|
||||
<form name="createbox" class="createbox" action="/index.php" method="get" id="createbox">
|
||||
<p><input type="hidden" value="edit" name="action" /><input type="hidden" value="1" name="minor" /><input type="text" name="title" class="mw-inputbox-input mw-ui-input mw-ui-input-inline createboxInput" value="" placeholder="" size="50" dir="ltr" /><br />
|
||||
<input type="submit" name="create" class="mw-ui-button mw-ui-progressive createboxButton" value="Create page" /></p>
|
||||
</form>
|
||||
</div>
|
||||
!! end
|
||||
|
||||
!! test
|
||||
InputBox type=create with minor=0
|
||||
!! wikitext
|
||||
<inputbox>
|
||||
type=create
|
||||
minor=0
|
||||
</inputbox>
|
||||
!! html+tidy
|
||||
<div class="mw-inputbox-centered" style="">
|
||||
<form name="createbox" class="createbox" action="/index.php" method="get" id="createbox">
|
||||
<p><input type="hidden" value="edit" name="action" /><input type="hidden" value="0" name="minor" /><input type="text" name="title" class="mw-inputbox-input mw-ui-input mw-ui-input-inline createboxInput" value="" placeholder="" size="50" dir="ltr" /><br />
|
||||
<input type="submit" name="create" class="mw-ui-button mw-ui-progressive createboxButton" value="Create page" /></p>
|
||||
</form>
|
||||
</div>
|
||||
!! end
|
||||
|
||||
!! test
|
||||
InputBox type=create with preloadparams
|
||||
!! wikitext
|
||||
<inputbox>
|
||||
type=create
|
||||
preloadparams[]=param1
|
||||
preloadparams[]=param2
|
||||
</inputbox>
|
||||
!! html+tidy
|
||||
<div class="mw-inputbox-centered" style="">
|
||||
<form name="createbox" class="createbox" action="/index.php" method="get" id="createbox">
|
||||
<p><input type="hidden" value="edit" name="action" /><input type="hidden" value="param1" name="preloadparams[]" /><input type="hidden" value="param2" name="preloadparams[]" /><input type="text" name="title" class="mw-inputbox-input mw-ui-input mw-ui-input-inline createboxInput" value="" placeholder="" size="50" dir="ltr" /><br />
|
||||
<input type="submit" name="create" class="mw-ui-button mw-ui-progressive createboxButton" value="Create page" /></p>
|
||||
</form>
|
||||
</div>
|
||||
!! end
|
||||
|
||||
!! test
|
||||
InputBox type=create with empty preloadparams
|
||||
!! wikitext
|
||||
<inputbox>
|
||||
type=create
|
||||
preloadparams[]=
|
||||
preloadparams[]=
|
||||
</inputbox>
|
||||
!! html+tidy
|
||||
<div class="mw-inputbox-centered" style="">
|
||||
<form name="createbox" class="createbox" action="/index.php" method="get" id="createbox">
|
||||
<p><input type="hidden" value="edit" name="action" /><input type="hidden" name="preloadparams[]" /><input type="hidden" name="preloadparams[]" /><input type="text" name="title" class="mw-inputbox-input mw-ui-input mw-ui-input-inline createboxInput" value="" placeholder="" size="50" dir="ltr" /><br />
|
||||
<input type="submit" name="create" class="mw-ui-button mw-ui-progressive createboxButton" value="Create page" /></p>
|
||||
</form>
|
||||
</div>
|
||||
!! end
|
||||
|
||||
!! test
|
||||
InputBox type=create with editintro
|
||||
!! wikitext
|
||||
<inputbox>
|
||||
type=create
|
||||
editintro=MediaWiki:Test
|
||||
</inputbox>
|
||||
!! html+tidy
|
||||
<div class="mw-inputbox-centered" style="">
|
||||
<form name="createbox" class="createbox" action="/index.php" method="get" id="createbox">
|
||||
<p><input type="hidden" value="edit" name="action" /><input type="hidden" value="MediaWiki:Test" name="editintro" /><input type="text" name="title" class="mw-inputbox-input mw-ui-input mw-ui-input-inline createboxInput" value="" placeholder="" size="50" dir="ltr" /><br />
|
||||
<input type="submit" name="create" class="mw-ui-button mw-ui-progressive createboxButton" value="Create page" /></p>
|
||||
</form>
|
||||
</div>
|
||||
!! end
|
||||
|
||||
!! test
|
||||
InputBox type=create with empty editintro
|
||||
!! wikitext
|
||||
<inputbox>
|
||||
type=create
|
||||
editintro=
|
||||
</inputbox>
|
||||
!! html+tidy
|
||||
<div class="mw-inputbox-centered" style="">
|
||||
<form name="createbox" class="createbox" action="/index.php" method="get" id="createbox">
|
||||
<p><input type="hidden" value="edit" name="action" /><input type="hidden" name="editintro" /><input type="text" name="title" class="mw-inputbox-input mw-ui-input mw-ui-input-inline createboxInput" value="" placeholder="" size="50" dir="ltr" /><br />
|
||||
<input type="submit" name="create" class="mw-ui-button mw-ui-progressive createboxButton" value="Create page" /></p>
|
||||
</form>
|
||||
</div>
|
||||
!! end
|
||||
|
||||
!! test
|
||||
InputBox type=create with summary
|
||||
!! wikitext
|
||||
<inputbox>
|
||||
type=create
|
||||
summary=Summary test
|
||||
</inputbox>
|
||||
!! html+tidy
|
||||
<div class="mw-inputbox-centered" style="">
|
||||
<form name="createbox" class="createbox" action="/index.php" method="get" id="createbox">
|
||||
<p><input type="hidden" value="edit" name="action" /><input type="hidden" value="Summary test" name="summary" /><input type="text" name="title" class="mw-inputbox-input mw-ui-input mw-ui-input-inline createboxInput" value="" placeholder="" size="50" dir="ltr" /><br />
|
||||
<input type="submit" name="create" class="mw-ui-button mw-ui-progressive createboxButton" value="Create page" /></p>
|
||||
</form>
|
||||
</div>
|
||||
!! end
|
||||
|
||||
!! test
|
||||
InputBox type=create with empty summary
|
||||
!! wikitext
|
||||
<inputbox>
|
||||
type=create
|
||||
summary=
|
||||
</inputbox>
|
||||
!! html+tidy
|
||||
<div class="mw-inputbox-centered" style="">
|
||||
<form name="createbox" class="createbox" action="/index.php" method="get" id="createbox">
|
||||
<p><input type="hidden" value="edit" name="action" /><input type="hidden" name="summary" /><input type="text" name="title" class="mw-inputbox-input mw-ui-input mw-ui-input-inline createboxInput" value="" placeholder="" size="50" dir="ltr" /><br />
|
||||
<input type="submit" name="create" class="mw-ui-button mw-ui-progressive createboxButton" value="Create page" /></p>
|
||||
</form>
|
||||
</div>
|
||||
!! end
|
||||
|
||||
!! test
|
||||
InputBox type=create with nosummary
|
||||
!! wikitext
|
||||
<inputbox>
|
||||
type=create
|
||||
nosummary=true
|
||||
</inputbox>
|
||||
!! html+tidy
|
||||
<div class="mw-inputbox-centered" style="">
|
||||
<form name="createbox" class="createbox" action="/index.php" method="get" id="createbox">
|
||||
<p><input type="hidden" value="edit" name="action" /><input type="hidden" value="true" name="nosummary" /><input type="text" name="title" class="mw-inputbox-input mw-ui-input mw-ui-input-inline createboxInput" value="" placeholder="" size="50" dir="ltr" /><br />
|
||||
<input type="submit" name="create" class="mw-ui-button mw-ui-progressive createboxButton" value="Create page" /></p>
|
||||
</form>
|
||||
</div>
|
||||
!! end
|
||||
|
||||
!! test
|
||||
InputBox type=create with empty nosummary
|
||||
!! wikitext
|
||||
<inputbox>
|
||||
type=create
|
||||
nosummary=
|
||||
</inputbox>
|
||||
!! html+tidy
|
||||
<div class="mw-inputbox-centered" style="">
|
||||
<form name="createbox" class="createbox" action="/index.php" method="get" id="createbox">
|
||||
<p><input type="hidden" value="edit" name="action" /><input type="hidden" name="nosummary" /><input type="text" name="title" class="mw-inputbox-input mw-ui-input mw-ui-input-inline createboxInput" value="" placeholder="" size="50" dir="ltr" /><br />
|
||||
<input type="submit" name="create" class="mw-ui-button mw-ui-progressive createboxButton" value="Create page" /></p>
|
||||
</form>
|
||||
</div>
|
||||
!! end
|
||||
|
||||
!! test
|
||||
InputBox type=create with prefix
|
||||
!! wikitext
|
||||
<inputbox>
|
||||
type=create
|
||||
prefix=Test/
|
||||
</inputbox>
|
||||
!! html+tidy
|
||||
<div class="mw-inputbox-centered" style="">
|
||||
<form name="createbox" class="createbox" action="/index.php" method="get" id="createbox">
|
||||
<p><input type="hidden" value="edit" name="action" /><input type="hidden" value="Test/" name="prefix" /><input type="text" name="title" class="mw-inputbox-input mw-ui-input mw-ui-input-inline createboxInput" value="" placeholder="" size="50" dir="ltr" /><br />
|
||||
<input type="submit" name="create" class="mw-ui-button mw-ui-progressive createboxButton" value="Create page" /></p>
|
||||
</form>
|
||||
</div>
|
||||
!! end
|
||||
|
||||
!! test
|
||||
InputBox type=create with empty prefix
|
||||
!! wikitext
|
||||
<inputbox>
|
||||
type=create
|
||||
prefix=
|
||||
</inputbox>
|
||||
!! html+tidy
|
||||
<div class="mw-inputbox-centered" style="">
|
||||
<form name="createbox" class="createbox" action="/index.php" method="get" id="createbox">
|
||||
<p><input type="hidden" value="edit" name="action" /><input type="text" name="title" class="mw-inputbox-input mw-ui-input mw-ui-input-inline createboxInput" value="" placeholder="" size="50" dir="ltr" /><br />
|
||||
<input type="submit" name="create" class="mw-ui-button mw-ui-progressive createboxButton" value="Create page" /></p>
|
||||
</form>
|
||||
</div>
|
||||
!! end
|
||||
|
||||
!! test
|
||||
InputBox type=create with preload
|
||||
!! wikitext
|
||||
<inputbox>
|
||||
type=create
|
||||
preload=test
|
||||
</inputbox>
|
||||
!! html+tidy
|
||||
<div class="mw-inputbox-centered" style="">
|
||||
<form name="createbox" class="createbox" action="/index.php" method="get" id="createbox">
|
||||
<p><input type="hidden" value="edit" name="action" /><input type="hidden" value="test" name="preload" /><input type="text" name="title" class="mw-inputbox-input mw-ui-input mw-ui-input-inline createboxInput" value="" placeholder="" size="50" dir="ltr" /><br />
|
||||
<input type="submit" name="create" class="mw-ui-button mw-ui-progressive createboxButton" value="Create page" /></p>
|
||||
</form>
|
||||
</div>
|
||||
!! end
|
||||
|
||||
!! test
|
||||
InputBox type=create with empty preload
|
||||
!! wikitext
|
||||
<inputbox>
|
||||
type=create
|
||||
preload=
|
||||
</inputbox>
|
||||
!! html+tidy
|
||||
<div class="mw-inputbox-centered" style="">
|
||||
<form name="createbox" class="createbox" action="/index.php" method="get" id="createbox">
|
||||
<p><input type="hidden" value="edit" name="action" /><input type="hidden" name="preload" /><input type="text" name="title" class="mw-inputbox-input mw-ui-input mw-ui-input-inline createboxInput" value="" placeholder="" size="50" dir="ltr" /><br />
|
||||
<input type="submit" name="create" class="mw-ui-button mw-ui-progressive createboxButton" value="Create page" /></p>
|
||||
</form>
|
||||
</div>
|
||||
|
@ -37,7 +263,7 @@ type=comment
|
|||
!! html+tidy
|
||||
<div class="mw-inputbox-centered" style="">
|
||||
<form name="createbox" class="createbox" action="/index.php" method="get" id="createbox">
|
||||
<p><input type="hidden" value="edit" name="action" /><input type="hidden" name="preload" /><input type="hidden" name="editintro" /><input type="hidden" name="summary" /><input type="hidden" name="nosummary" /><input type="hidden" name="prefix" /><input type="hidden" name="minor" /><input type="hidden" value="new" name="section" /><input type="text" name="title" class="mw-inputbox-input mw-ui-input mw-ui-input-inline createboxInput" value="" placeholder="" size="50" dir="ltr" /><br />
|
||||
<p><input type="hidden" value="edit" name="action" /><input type="hidden" value="new" name="section" /><input type="text" name="title" class="mw-inputbox-input mw-ui-input mw-ui-input-inline createboxInput" value="" placeholder="" size="50" dir="ltr" /><br />
|
||||
<input type="submit" name="create" class="mw-ui-button mw-ui-progressive createboxButton" value="New section" /></p>
|
||||
</form>
|
||||
</div>
|
||||
|
@ -52,7 +278,7 @@ type=commenttitle
|
|||
!! html+tidy
|
||||
<div class="mw-inputbox-centered" style="">
|
||||
<form name="commentbox" class="commentbox" action="/index.php" method="get" id="commentbox">
|
||||
<p><input type="hidden" value="edit" name="action" /><input type="hidden" name="preload" /><input type="hidden" name="editintro" /><input type="text" name="preloadtitle" class="mw-inputbox-input commentboxInput mw-ui-input mw-ui-input-inline" value="" placeholder="" size="50" dir="ltr" /><input type="hidden" value="new" name="section" /><input type="hidden" name="title" /><br />
|
||||
<p><input type="hidden" value="edit" name="action" /><input type="text" name="preloadtitle" class="mw-inputbox-input commentboxInput mw-ui-input mw-ui-input-inline" value="" placeholder="" size="50" dir="ltr" /><input type="hidden" value="new" name="section" /><input type="hidden" name="title" /><br />
|
||||
<input type="submit" name="create" class="mw-ui-button mw-ui-progressive" value="New section" /></p>
|
||||
</form>
|
||||
</div>
|
||||
|
|
Loading…
Reference in a new issue