Merge "Inputbox: Some code conventions cleanup"

This commit is contained in:
jenkins-bot 2014-05-19 16:56:55 +00:00 committed by Gerrit Code Review
commit d9dc4ca640
3 changed files with 28 additions and 28 deletions

View file

@ -49,7 +49,7 @@ class InputBox {
public function render() {
// Handle various types
switch( $this->mType ) {
switch ( $this->mType ) {
case 'create':
case 'comment':
return $this->getCreateForm();
@ -127,7 +127,7 @@ class InputBox {
)
);
if( $this->mPrefix != '' ){
if ( $this->mPrefix != '' ) {
$htmlOut .= Xml::element( 'input',
array(
'name' => 'prefix',
@ -157,9 +157,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];
@ -167,13 +167,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 ) {
@ -209,7 +209,7 @@ class InputBox {
// Line break
$htmlOut .= $this->mBR;
} elseif( $type == 'search' ) {
} elseif ( $type == 'search' ) {
// Go button
$htmlOut .= Xml::element( 'input',
array(
@ -233,7 +233,7 @@ class InputBox {
);
// Hidden fulltext param for IE (bug 17161)
if( $type == 'fulltext' ) {
if ( $type == 'fulltext' ) {
$htmlOut .= Html::hidden( 'fulltext', 'Search' );
}
@ -349,7 +349,7 @@ class InputBox {
'action' => $wgScript,
'method' => 'get'
);
if( $this->mID !== '' ) {
if ( $this->mID !== '' ) {
$createBoxParams['id'] = Sanitizer::escapeId( $this->mID );
}
$htmlOut .= Xml::openElement( 'form', $createBoxParams );
@ -460,7 +460,7 @@ class InputBox {
'action' => $wgScript,
'method' => 'get'
);
if( $this->mID !== '' ) {
if ( $this->mID !== '' ) {
$moveBoxParams['id'] = Sanitizer::escapeId( $this->mID );
}
$htmlOut .= Xml::openElement( 'form', $moveBoxParams );
@ -533,7 +533,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 );
}