Styleli[zs]e the API up to date (Been a while since)
authorSam Reed <reedy@users.mediawiki.org>
Thu, 30 Dec 2010 17:06:09 +0000 (17:06 +0000)
committerSam Reed <reedy@users.mediawiki.org>
Thu, 30 Dec 2010 17:06:09 +0000 (17:06 +0000)
16 files changed:
includes/api/ApiBase.php
includes/api/ApiEditPage.php
includes/api/ApiFeedWatchlist.php
includes/api/ApiParse.php
includes/api/ApiQuery.php
includes/api/ApiQueryAllmessages.php
includes/api/ApiQueryAllpages.php
includes/api/ApiQueryBacklinks.php
includes/api/ApiQueryLogEvents.php
includes/api/ApiQueryPageProps.php
includes/api/ApiQueryRecentChanges.php
includes/api/ApiQueryRevisions.php
includes/api/ApiQuerySiteinfo.php
includes/api/ApiQueryWatchlist.php
includes/api/ApiRsd.php
includes/api/ApiUpload.php

index b370108..9d14a9b 100644 (file)
@@ -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)";
                                                        }
index 62954ec..d300a8b 100644 (file)
@@ -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 );
 
index ac88711..1d6b22c 100644 (file)
@@ -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'
                );
        }
 
index 12da330..acb8905 100644 (file)
@@ -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();
index 0406959..c087c96 100644 (file)
@@ -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;
index bf76b86..d242299 100644 (file)
@@ -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;
                        }
 
index 830d8d7..8aa78f0 100644 (file)
@@ -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() ) );
                }
index 3835f48..2900b7c 100644 (file)
@@ -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;
index b14379d..34dcc59 100644 (file)
@@ -285,7 +285,7 @@ class ApiQueryLogEvents extends ApiQueryBase {
                                if ( $this->fld_userid ) {
                                        $vals['userid'] = $row->user_id;
                                }
-                               
+
                                if ( !$row->log_user ) {
                                        $vals['anon'] = '';
                                }
index 6eb8b80..46d04b1 100644 (file)
@@ -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 );
        }
 
index 4defffe..8b5d864 100644 (file)
@@ -84,7 +84,7 @@ class ApiQueryRecentChanges extends ApiQueryBase {
                if ( is_null( $cachedPatrolToken ) ) {
                        $cachedPatrolToken = $wgUser->editToken( 'patrol' );
                }
-               
+
                return $cachedPatrolToken;
        }
 
index d65b496..5565555 100644 (file)
@@ -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 );
index 1ba8476..9a0722b 100644 (file)
@@ -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 );
        }
index cca57d1..9715632 100644 (file)
@@ -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 ) {
index 1274c85..1a0f69a 100644 (file)
@@ -169,7 +169,7 @@ class ApiFormatXmlRsd extends ApiFormatXml {
                parent::__construct( $main, $format );
                $this->setRootElement( 'rsd' );
        }
-       
+
        public function getMimeType() {
                return 'application/rsd+xml';
        }
index 92abb61..ca6571e 100644 (file)
@@ -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;
        }