From 1f05665cf34c4468fa57e89de20a11c51eada0f5 Mon Sep 17 00:00:00 2001 From: Sam Reed Date: Thu, 30 Dec 2010 17:06:09 +0000 Subject: [PATCH] Styleli[zs]e the API up to date (Been a while since) --- includes/api/ApiBase.php | 2 +- includes/api/ApiEditPage.php | 26 +++++++++---------- includes/api/ApiFeedWatchlist.php | 2 +- includes/api/ApiParse.php | 2 +- includes/api/ApiQuery.php | 4 +-- includes/api/ApiQueryAllmessages.php | 4 +-- includes/api/ApiQueryAllpages.php | 2 +- includes/api/ApiQueryBacklinks.php | 4 +-- includes/api/ApiQueryLogEvents.php | 2 +- includes/api/ApiQueryPageProps.php | 32 +++++++++++------------ includes/api/ApiQueryRecentChanges.php | 2 +- includes/api/ApiQueryRevisions.php | 10 +++---- includes/api/ApiQuerySiteinfo.php | 20 +++++++------- includes/api/ApiQueryWatchlist.php | 2 +- includes/api/ApiRsd.php | 2 +- includes/api/ApiUpload.php | 36 +++++++++++++------------- 16 files changed, 76 insertions(+), 76 deletions(-) diff --git a/includes/api/ApiBase.php b/includes/api/ApiBase.php index b37010812f..9d14a9bbdf 100644 --- a/includes/api/ApiBase.php +++ b/includes/api/ApiBase.php @@ -373,7 +373,7 @@ abstract class ApiBase { $isArray = is_array( $paramSettings[self::PARAM_TYPE] ); if ( !$isArray - || $isArray && count( $paramSettings[self::PARAM_TYPE] ) > self::LIMIT_SML1) { + || $isArray && count( $paramSettings[self::PARAM_TYPE] ) > self::LIMIT_SML1 ) { $desc .= $paramPrefix . "Maximum number of values " . self::LIMIT_SML1 . " (" . self::LIMIT_SML2 . " for bots)"; } diff --git a/includes/api/ApiEditPage.php b/includes/api/ApiEditPage.php index 62954ec806..d300a8bbe3 100644 --- a/includes/api/ApiEditPage.php +++ b/includes/api/ApiEditPage.php @@ -57,32 +57,32 @@ class ApiEditPage extends ApiBase { if ( !$titleObj || $titleObj->isExternal() ) { $this->dieUsageMsg( array( 'invalidtitle', $params['title'] ) ); } - - if( $params['redirect'] ) { - if( $titleObj->isRedirect() ) { + + if ( $params['redirect'] ) { + if ( $titleObj->isRedirect() ) { $oldTitle = $titleObj; - + $titles = Title::newFromRedirectArray( Revision::newFromTitle( $oldTitle )->getText( Revision::FOR_THIS_USER ) ); - //array_shift( $titles ); - + // array_shift( $titles ); + $this->getResult()->addValue( null, 'foo', $titles ); - - + + $redirValues = array(); foreach ( $titles as $id => $newTitle ) { - - if( !isset( $titles[ $id - 1 ] ) ) { + + if ( !isset( $titles[ $id - 1 ] ) ) { $titles[ $id - 1 ] = $oldTitle; } - + $redirValues[] = array( 'from' => $titles[ $id - 1 ]->getPrefixedText(), 'to' => $newTitle->getPrefixedText() ); - + $titleObj = $newTitle; } - + $this->getResult()->setIndexedTagName( $redirValues, 'r' ); $this->getResult()->addValue( null, 'redirects', $redirValues ); diff --git a/includes/api/ApiFeedWatchlist.php b/includes/api/ApiFeedWatchlist.php index ac887110f3..1d6b22c874 100644 --- a/includes/api/ApiFeedWatchlist.php +++ b/includes/api/ApiFeedWatchlist.php @@ -189,7 +189,7 @@ class ApiFeedWatchlist extends ApiBase { 'allrev' => 'Include multiple revisions of the same page within given timeframe', 'wlowner' => "The user whose watchlist you want (must be accompanied by {$this->getModulePrefix()}token if it's not you)", 'wltoken' => 'Security token that requested user set in their preferences', - 'linktodiffs'=> 'Link to change differences instead of article pages' + 'linktodiffs' => 'Link to change differences instead of article pages' ); } diff --git a/includes/api/ApiParse.php b/includes/api/ApiParse.php index 12da330949..acb89051ee 100644 --- a/includes/api/ApiParse.php +++ b/includes/api/ApiParse.php @@ -93,7 +93,7 @@ class ApiParse extends ApiBase { $wgTitle = $titleObj; - //If for some reason the "oldid" is actually the current revision, it may be cached + // If for some reason the "oldid" is actually the current revision, it may be cached if ( $titleObj->getLatestRevID() === $oldid ) { $p_result = false; $pcache = ParserCache::singleton(); diff --git a/includes/api/ApiQuery.php b/includes/api/ApiQuery.php index 04069590b4..c087c9677c 100644 --- a/includes/api/ApiQuery.php +++ b/includes/api/ApiQuery.php @@ -45,7 +45,7 @@ class ApiQuery extends ApiBase { private $mPropModuleNames, $mListModuleNames, $mMetaModuleNames; /** - * @var ApiPageSet + * @var ApiPageSet */ private $mPageSet; @@ -471,7 +471,7 @@ class ApiQuery extends ApiBase { private function doExport( $pageSet, $result ) { $exportTitles = array(); $titles = $pageSet->getGoodTitles(); - if( count( $titles ) ) { + if ( count( $titles ) ) { foreach ( $titles as $title ) { if ( $title->userCanRead() ) { $exportTitles[] = $title; diff --git a/includes/api/ApiQueryAllmessages.php b/includes/api/ApiQueryAllmessages.php index bf76b86b61..d242299b80 100644 --- a/includes/api/ApiQueryAllmessages.php +++ b/includes/api/ApiQueryAllmessages.php @@ -83,8 +83,8 @@ class ApiQueryAllmessages extends ApiQueryBase { if ( $skip && $message === $params['from'] ) { $skip = false; } - - if( $useto && $message > $params['to'] ) { + + if ( $useto && $message > $params['to'] ) { break; } diff --git a/includes/api/ApiQueryAllpages.php b/includes/api/ApiQueryAllpages.php index 830d8d79fa..8aa78f0892 100644 --- a/includes/api/ApiQueryAllpages.php +++ b/includes/api/ApiQueryAllpages.php @@ -75,7 +75,7 @@ class ApiQueryAllpages extends ApiQueryGeneratorBase { $from = ( is_null( $params['from'] ) ? null : $this->titlePartToKey( $params['from'] ) ); $to = ( is_null( $params['to'] ) ? null : $this->titlePartToKey( $params['to'] ) ); $this->addWhereRange( 'page_title', $dir, $from, $to ); - + if ( isset( $params['prefix'] ) ) { $this->addWhere( 'page_title' . $db->buildLike( $this->titlePartToKey( $params['prefix'] ), $db->anyString() ) ); } diff --git a/includes/api/ApiQueryBacklinks.php b/includes/api/ApiQueryBacklinks.php index 3835f48415..2900b7c57e 100644 --- a/includes/api/ApiQueryBacklinks.php +++ b/includes/api/ApiQueryBacklinks.php @@ -248,9 +248,9 @@ class ApiQueryBacklinks extends ApiQueryGeneratorBase { // We've reached the one extra which shows that there are additional pages to be had. Stop here... // We need to keep the parent page of this redir in if ( $this->hasNS ) { - $parentID = $this->pageMap[$row->{$this->bl_ns}][$row->{$this->bl_title}]; + $parentID = $this->pageMap[$row-> { $this->bl_ns } ][$row-> { $this->bl_title } ]; } else { - $parentID = $this->pageMap[NS_IMAGE][$row->{$this->bl_title}]; + $parentID = $this->pageMap[NS_IMAGE][$row-> { $this->bl_title } ]; } $this->continueStr = $this->getContinueRedirStr( $parentID, $row->page_id ); break; diff --git a/includes/api/ApiQueryLogEvents.php b/includes/api/ApiQueryLogEvents.php index b14379df0a..34dcc598f1 100644 --- a/includes/api/ApiQueryLogEvents.php +++ b/includes/api/ApiQueryLogEvents.php @@ -285,7 +285,7 @@ class ApiQueryLogEvents extends ApiQueryBase { if ( $this->fld_userid ) { $vals['userid'] = $row->user_id; } - + if ( !$row->log_user ) { $vals['anon'] = ''; } diff --git a/includes/api/ApiQueryPageProps.php b/includes/api/ApiQueryPageProps.php index 6eb8b806dc..46d04b194d 100644 --- a/includes/api/ApiQueryPageProps.php +++ b/includes/api/ApiQueryPageProps.php @@ -44,54 +44,54 @@ class ApiQueryPageProps extends ApiQueryBase { public function execute() { $this->params = $this->extractRequestParams(); - + # Only operate on existing pages $pages = $this->getPageSet()->getGoodTitles(); if ( !count( $pages ) ) { # Nothing to do return; } - + $this->addTables( 'page_props' ); $this->addFields( array( 'pp_page', 'pp_propname', 'pp_value' ) ); $this->addWhereFld( 'pp_page', array_keys( $pages ) ); - + if ( $this->params['continue'] ) { $this->addWhere( 'pp_page >=' . intval( $this->params['continue'] ) ); } - + # Force a sort order to ensure that properties are grouped by page $this->addOption( 'ORDER BY', 'pp_page' ); - + $res = $this->select( __METHOD__ ); $currentPage = 0; # Id of the page currently processed $props = array(); $result = $this->getResult(); - + foreach ( $res as $row ) { if ( $currentPage != $row->pp_page ) { - # Different page than previous row, so add the properties to + # Different page than previous row, so add the properties to # the result and save the new page id - + if ( $currentPage ) { if ( !$this->addPageProps( $result, $currentPage, $props ) ) { # addPageProps() indicated that the result did not fit # so stop adding data. Reset props so that it doesn't # get added again after loop exit - + $props = array(); break; } - + $props = array(); } - + $currentPage = $row->pp_page; } - + $props[$row->pp_propname] = $row->pp_value; } - + if ( count( $props ) ) { # Add any remaining properties to the results $this->addPageProps( $result, $currentPage, $props ); @@ -99,7 +99,7 @@ class ApiQueryPageProps extends ApiQueryBase { } /** - * Add page properties to an ApiResult, adding a continue + * Add page properties to an ApiResult, adding a continue * parameter if it doesn't fit. * * @param $result ApiResult @@ -109,7 +109,7 @@ class ApiQueryPageProps extends ApiQueryBase { */ private function addPageProps( $result, $page, $props ) { $fit = $result->addValue( array( 'query', 'pages' ), $page, $props ); - + if ( !$fit ) { $this->setContinueEnumParameter( 'continue', $page ); } @@ -120,7 +120,7 @@ class ApiQueryPageProps extends ApiQueryBase { return 'public'; } - public function getAllowedParams() { + public function getAllowedParams() { return array( 'continue' => null ); } diff --git a/includes/api/ApiQueryRecentChanges.php b/includes/api/ApiQueryRecentChanges.php index 4defffe054..8b5d864a95 100644 --- a/includes/api/ApiQueryRecentChanges.php +++ b/includes/api/ApiQueryRecentChanges.php @@ -84,7 +84,7 @@ class ApiQueryRecentChanges extends ApiQueryBase { if ( is_null( $cachedPatrolToken ) ) { $cachedPatrolToken = $wgUser->editToken( 'patrol' ); } - + return $cachedPatrolToken; } diff --git a/includes/api/ApiQueryRevisions.php b/includes/api/ApiQueryRevisions.php index d65b496042..5565555b34 100644 --- a/includes/api/ApiQueryRevisions.php +++ b/includes/api/ApiQueryRevisions.php @@ -169,7 +169,7 @@ class ApiQueryRevisions extends ApiQueryBase { $this->getResult()->setParsedLimit( $this->getModuleName(), $limit ); } - + if ( !is_null( $this->token ) || $pageCount > 0 ) { $this->addFields( Revision::selectPageFields() ); } @@ -224,7 +224,7 @@ class ApiQueryRevisions extends ApiQueryBase { } } - //Bug 24166 - API error when using rvprop=tags + // Bug 24166 - API error when using rvprop=tags $this->addTables( 'revision' ); @@ -480,10 +480,10 @@ class ApiQueryRevisions extends ApiQueryBase { } if ( $this->parseContent ) { global $wgEnableParserCache; - + $popts = new ParserOptions(); $popts->setTidy( true ); - + $articleObj = new Article( $title ); $p_result = false; @@ -498,7 +498,7 @@ class ApiQueryRevisions extends ApiQueryBase { $pcache->save( $p_result, $articleObj, $popts ); } } - + $text = $p_result->getText(); } ApiResult::setContent( $vals, $text ); diff --git a/includes/api/ApiQuerySiteinfo.php b/includes/api/ApiQuerySiteinfo.php index 1ba8476fca..9a0722b4dd 100644 --- a/includes/api/ApiQuerySiteinfo.php +++ b/includes/api/ApiQuerySiteinfo.php @@ -324,44 +324,44 @@ class ApiQuerySiteinfo extends ApiQueryBase { protected function appendUserGroups( $property, $numberInGroup ) { global $wgGroupPermissions, $wgAddGroups, $wgRemoveGroups, $wgGroupsAddToSelf, $wgGroupsRemoveFromSelf; - + $data = array(); foreach ( $wgGroupPermissions as $group => $permissions ) { $arr = array( 'name' => $group, 'rights' => array_keys( $permissions, true ), ); - + if ( $numberInGroup ) { global $wgAutopromote; - + if ( $group == 'user' ) { $arr['number'] = SiteStats::users(); - + // '*' and autopromote groups have no size } elseif ( $group !== '*' && !isset( $wgAutopromote[$group] ) ) { $arr['number'] = SiteStats::numberInGroup( $group ); } } - + $groupArr = array( 'add' => $wgAddGroups, 'remove' => $wgRemoveGroups, 'add-self' => $wgGroupsAddToSelf, 'remove-self' => $wgGroupsRemoveFromSelf ); - - foreach( $groupArr as $type => $rights ) { - if( isset( $rights[$group] ) ) { + + foreach ( $groupArr as $type => $rights ) { + if ( isset( $rights[$group] ) ) { $arr[$type] = $rights[$group]; $this->getResult()->setIndexedTagName( $arr[$type], 'group' ); } } - + $this->getResult()->setIndexedTagName( $arr['rights'], 'permission' ); $data[] = $arr; } - + $this->getResult()->setIndexedTagName( $data, 'group' ); return $this->getResult()->addValue( 'query', $property, $data ); } diff --git a/includes/api/ApiQueryWatchlist.php b/includes/api/ApiQueryWatchlist.php index cca57d1e2f..971563269a 100644 --- a/includes/api/ApiQueryWatchlist.php +++ b/includes/api/ApiQueryWatchlist.php @@ -236,7 +236,7 @@ class ApiQueryWatchlist extends ApiQueryGeneratorBase { } if ( $this->fld_userid ) { - $vals['user'] = $row->rc_user; + $vals['user'] = $row->rc_user; } if ( !$row->rc_user ) { diff --git a/includes/api/ApiRsd.php b/includes/api/ApiRsd.php index 1274c85cfd..1a0f69a7c2 100644 --- a/includes/api/ApiRsd.php +++ b/includes/api/ApiRsd.php @@ -169,7 +169,7 @@ class ApiFormatXmlRsd extends ApiFormatXml { parent::__construct( $main, $format ); $this->setRootElement( 'rsd' ); } - + public function getMimeType() { return 'application/rsd+xml'; } diff --git a/includes/api/ApiUpload.php b/includes/api/ApiUpload.php index 92abb61fc4..ca6571e147 100644 --- a/includes/api/ApiUpload.php +++ b/includes/api/ApiUpload.php @@ -86,25 +86,25 @@ class ApiUpload extends ApiBase { // Prepare the API result $result = array(); - + $warnings = $this->getApiWarnings(); - if ( $warnings ) { + if ( $warnings ) { $result['result'] = 'Warning'; $result['warnings'] = $warnings; // in case the warnings can be fixed with some further user action, let's stash this upload // and return a key they can use to restart it - try { + try { $result['sessionkey'] = $this->performStash(); - } catch ( MWException $e ) { + } catch ( MWException $e ) { $result['warnings']['stashfailed'] = $e->getMessage(); } - } elseif ( $this->mParams['stash'] ) { + } elseif ( $this->mParams['stash'] ) { // Some uploads can request they be stashed, so as not to publish them immediately. // In this case, a failure to stash ought to be fatal try { - $result['result'] = 'Success'; + $result['result'] = 'Success'; $result['sessionkey'] = $this->performStash(); - } catch ( MWException $e ) { + } catch ( MWException $e ) { $this->dieUsage( $e->getMessage(), 'stashfailed' ); } } else { @@ -113,12 +113,12 @@ class ApiUpload extends ApiBase { $result = $this->performUpload(); } - if ( $result['result'] === 'Success' ) { + if ( $result['result'] === 'Success' ) { $result['imageinfo'] = $this->mUpload->getImageInfo( $this->getResult() ); } $this->getResult()->addValue( null, $this->getModuleName(), $result ); - + // Cleanup any temporary mess $this->mUpload->cleanupTempFile(); } @@ -133,7 +133,7 @@ class ApiUpload extends ApiBase { try { $sessionKey = $this->mUpload->stashSessionFile()->getSessionKey(); } catch ( MWException $e ) { - throw new MWException( 'Stashing temporary file failed: ' . get_class($e) . ' ' . $e->getMessage() ); + throw new MWException( 'Stashing temporary file failed: ' . get_class( $e ) . ' ' . $e->getMessage() ); } return $sessionKey; } @@ -141,9 +141,9 @@ class ApiUpload extends ApiBase { /** * Select an upload module and set it to mUpload. Dies on failure. If the - * request was a status request and not a true upload, returns false; + * request was a status request and not a true upload, returns false; * otherwise true - * + * * @return bool */ protected function selectUploadModule() { @@ -158,7 +158,7 @@ class ApiUpload extends ApiBase { // Status request for an async upload $sessionData = UploadFromUrlJob::getSessionData( $this->mParams['statuskey'] ); if ( !isset( $sessionData['result'] ) ) { - $this->dieUsage( 'No result in session data', 'missingresult'); + $this->dieUsage( 'No result in session data', 'missingresult' ); } if ( $sessionData['result'] == 'Warning' ) { $sessionData['warnings'] = $this->transformWarnings( $sessionData['warnings'] ); @@ -166,15 +166,15 @@ class ApiUpload extends ApiBase { } $this->getResult()->addValue( null, $this->getModuleName(), $sessionData ); return false; - - } + + } // The following modules all require the filename parameter to be set if ( is_null( $this->mParams['filename'] ) ) { $this->dieUsageMsg( array( 'missingparam', 'filename' ) ); } - + if ( $this->mParams['sessionkey'] ) { // Upload stashed in a previous request @@ -207,7 +207,7 @@ class ApiUpload extends ApiBase { $this->dieUsage( 'Using leavemessage without ignorewarnings is not supported', 'missing-ignorewarnings' ); } - + if ( $this->mParams['leavemessage'] ) { $async = 'async-leavemessage'; } else { @@ -219,7 +219,7 @@ class ApiUpload extends ApiBase { $this->mParams['url'], $async ); } - + return true; } -- 2.20.1