From a1a1e64e462430e8faf98a1a014ba9499b59f6bd Mon Sep 17 00:00:00 2001 From: Derk-Jan Hartman Date: Sun, 18 May 2014 11:07:27 +0200 Subject: [PATCH] Inputbox: Some code conventions cleanup Change-Id: I16fcd16d81a7eecc845b5d36fd8af8e14792eea1 --- InputBox.classes.php | 22 +++++++++++----------- InputBox.hooks.php | 32 ++++++++++++++++---------------- InputBox.php | 2 +- 3 files changed, 28 insertions(+), 28 deletions(-) diff --git a/InputBox.classes.php b/InputBox.classes.php index ef2d0c62..f747e093 100644 --- a/InputBox.classes.php +++ b/InputBox.classes.php @@ -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 ); diff --git a/InputBox.hooks.php b/InputBox.hooks.php index 75fe6790..624d250c 100644 --- a/InputBox.hooks.php +++ b/InputBox.hooks.php @@ -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(); } - + /** - * sends requests with action=edit, and - * possibly a &prefix=Foo. So we pick that up here, munge prefix + * 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; diff --git a/InputBox.php b/InputBox.php index 6473bd7b..c06037a3 100644 --- a/InputBox.php +++ b/InputBox.php @@ -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 ); }