Inputbox: Some code conventions cleanup

Change-Id: I16fcd16d81a7eecc845b5d36fd8af8e14792eea1
This commit is contained in:
Derk-Jan Hartman 2014-05-18 11:07:27 +02:00
parent 9642c6ab5c
commit a1a1e64e46
3 changed files with 28 additions and 28 deletions

View file

@ -48,7 +48,7 @@ class InputBox {
public function render() {
// Handle various types
switch( $this->mType ) {
switch ( $this->mType ) {
case 'create':
case 'comment':
return $this->getCreateForm();
@ -118,7 +118,7 @@ class InputBox {
)
);
if( $this->mPrefix != '' ){
if ( $this->mPrefix != '' ) {
$htmlOut .= Xml::element( 'input',
array(
'name' => 'prefix',
@ -148,9 +148,9 @@ class InputBox {
}
$mainMsg = wfMessage( 'inputbox-ns-main' )->inContentLanguage()->text();
if( $userNS == 'Main' || $userNS == $mainMsg ) {
if ( $userNS == 'Main' || $userNS == $mainMsg ) {
$i = 0;
} elseif( array_search( $userNS, $namespaces ) ) {
} elseif ( array_search( $userNS, $namespaces ) ) {
$i = array_search( $userNS, $namespaces );
} elseif ( isset( $nsAliases[$userNS] ) ) {
$i = $nsAliases[$userNS];
@ -158,13 +158,13 @@ class InputBox {
continue; # Namespace not recognized, skip
}
$showNamespaces[$i] = $userNS;
if( isset( $checkedNS[$userNS] ) && $checkedNS[$userNS] ) {
if ( isset( $checkedNS[$userNS] ) && $checkedNS[$userNS] ) {
$checkedNS[$i] = true;
}
}
# Show valid namespaces
foreach( $showNamespaces as $i => $name ) {
foreach ( $showNamespaces as $i => $name ) {
$checked = array();
// Namespace flagged with "**" or if it's the only one
if ( ( isset( $checkedNS[$i] ) && $checkedNS[$i] ) || count( $showNamespaces ) == 1 ) {
@ -200,7 +200,7 @@ class InputBox {
// Line break
$htmlOut .= $this->mBR;
} elseif( $type == 'search' ) {
} elseif ( $type == 'search' ) {
// Go button
$htmlOut .= Xml::element( 'input',
array(
@ -224,7 +224,7 @@ class InputBox {
);
// Hidden fulltext param for IE (bug 17161)
if( $type == 'fulltext' ) {
if ( $type == 'fulltext' ) {
$htmlOut .= Html::hidden( 'fulltext', 'Search' );
}
@ -333,7 +333,7 @@ class InputBox {
'action' => $wgScript,
'method' => 'get'
);
if( $this->mID !== '' ) {
if ( $this->mID !== '' ) {
$createBoxParams['id'] = Sanitizer::escapeId( $this->mID );
}
$htmlOut .= Xml::openElement( 'form', $createBoxParams );
@ -443,7 +443,7 @@ class InputBox {
'action' => $wgScript,
'method' => 'get'
);
if( $this->mID !== '' ) {
if ( $this->mID !== '' ) {
$moveBoxParams['id'] = Sanitizer::escapeId( $this->mID );
}
$htmlOut .= Xml::openElement( 'form', $moveBoxParams );
@ -515,7 +515,7 @@ class InputBox {
'action' => $wgScript,
'method' => 'get'
);
if( $this->mID !== '' ) {
if ( $this->mID !== '' ) {
$commentFormParams['id'] = Sanitizer::escapeId( $this->mID );
}
$htmlOut .= Xml::openElement( 'form', $commentFormParams );

View file

@ -22,7 +22,7 @@ class InputBoxHooks {
$request = $special->getRequest();
$prefix = $request->getText( 'prefix', '' );
$title = $request->getText( 'wpNewTitle', '' );
if( $special->getName() == 'Movepage' && $prefix !== '' && $title !== '' ) {
if ( $special->getName() == 'Movepage' && $prefix !== '' && $title !== '' ) {
$request->setVal( 'wpNewTitle', $prefix . $title );
$request->unsetVal( 'prefix' );
}
@ -40,27 +40,27 @@ class InputBoxHooks {
// Return output
return $inputBox->render();
}
/**
* <inputbox type=create...> sends requests with action=edit, and
* possibly a &prefix=Foo. So we pick that up here, munge prefix
* <inputbox type=create...> sends requests with action=edit, and
* possibly a &prefix=Foo. So we pick that up here, munge prefix
* and title together, and redirect back out to the real page
* @param $output OutputPage
* @param $article Article
* @param $title Title
* @param $user User
* @param $request WebRequest
* @param $request WebRequest
* @param $wiki MediaWiki
* @return bool
*/
public static function onMediaWikiPerformAction(
$output,
$article,
$title,
$user,
$request,
$wiki )
{
public static function onMediaWikiPerformAction(
$output,
$article,
$title,
$user,
$request,
$wiki
) {
if( $wiki->getAction( $request ) !== 'edit' ){
# not our problem
return true;
@ -69,15 +69,15 @@ class InputBoxHooks {
# Fine
return true;
}
$params = $request->getValues();
$title = $params['prefix'];
if ( isset( $params['title'] ) ){
if ( isset( $params['title'] ) ) {
$title .= $params['title'];
}
unset( $params['prefix'] );
$params['title'] = $title;
global $wgScript;
$output->redirect( wfAppendQuery( $wgScript, $params ), '301' );
return false;

View file

@ -22,7 +22,7 @@
// Check environment
if ( !defined( 'MEDIAWIKI' ) ) {
echo( "This is an extension to the MediaWiki package and cannot be run standalone.\n" );
echo "This is an extension to the MediaWiki package and cannot be run standalone.\n";
die( -1 );
}