Update formatting, return of the API classes
authorSiebrand Mazeland <s.mazeland@xs4all.nl>
Thu, 14 Nov 2013 12:56:06 +0000 (13:56 +0100)
committerChad <chadh@wikimedia.org>
Thu, 14 Nov 2013 18:25:45 +0000 (18:25 +0000)
Change-Id: I8c3a5b4396a1c3bba22f676137f640c6aa3c8960

includes/api/ApiQueryLangBacklinks.php
includes/api/ApiQueryLangLinks.php
includes/api/ApiQueryLinks.php
includes/api/ApiQueryLogEvents.php
includes/api/ApiQueryORM.php
includes/api/ApiQueryPageProps.php
includes/api/ApiQueryProtectedTitles.php
includes/api/ApiQueryQueryPage.php
includes/api/ApiQueryRandom.php
includes/api/ApiQueryRecentChanges.php

index 5bd451b..652fa11 100644 (file)
@@ -92,14 +92,14 @@ class ApiQueryLangBacklinks extends ApiQueryGeneratorBase {
                                $this->addOption( 'ORDER BY', array(
                                        'll_title' . $sort,
                                        'll_from' . $sort
-                               ));
+                               ) );
                        }
                } else {
                        $this->addOption( 'ORDER BY', array(
                                'll_lang' . $sort,
                                'll_title' . $sort,
                                'll_from' . $sort
-                       ));
+                       ) );
                }
 
                $this->addOption( 'LIMIT', $params['limit'] + 1 );
@@ -111,7 +111,7 @@ class ApiQueryLangBacklinks extends ApiQueryGeneratorBase {
                $count = 0;
                $result = $this->getResult();
                foreach ( $res as $row ) {
-                       if ( ++ $count > $params['limit'] ) {
+                       if ( ++$count > $params['limit'] ) {
                                // We've reached the one extra which shows that there are additional pages to be had. Stop here...
                                // Continue string preserved in case the redirect query doesn't pass the limit
                                $this->setContinueEnumParameter( 'continue', "{$row->ll_lang}|{$row->ll_title}|{$row->ll_from}" );
index aa796e3..926a1b6 100644 (file)
@@ -86,9 +86,9 @@ class ApiQueryLangLinks extends ApiQueryBase {
                                $this->addOption( 'ORDER BY', 'll_lang' . $sort );
                        } else {
                                $this->addOption( 'ORDER BY', array(
-                                                       'll_from' . $sort,
-                                                       'll_lang' . $sort
-                               ));
+                                       'll_from' . $sort,
+                                       'll_lang' . $sort
+                               ) );
                        }
                }
 
index 937f4f1..c3a130b 100644 (file)
@@ -212,6 +212,7 @@ class ApiQueryLinks extends ApiQueryGeneratorBase {
 
        public function getParamDescription() {
                $desc = $this->description;
+
                return array(
                        'namespace' => "Show {$desc}s in this namespace(s) only",
                        'limit' => "How many {$desc}s to return",
@@ -237,6 +238,7 @@ class ApiQueryLinks extends ApiQueryGeneratorBase {
        public function getExamples() {
                $desc = $this->description;
                $name = $this->getModuleName();
+
                return array(
                        "api.php?action=query&prop={$name}&titles=Main%20Page" => "Get {$desc}s from the [[Main Page]]",
                        "api.php?action=query&generator={$name}&titles=Main%20Page&prop=info" => "Get information about the {$desc} pages in the [[Main Page]]",
index 1a2719e..d177279 100644 (file)
@@ -168,7 +168,7 @@ class ApiQueryLogEvents extends ApiQueryBase {
                $res = $this->select( __METHOD__ );
                $result = $this->getResult();
                foreach ( $res as $row ) {
-                       if ( ++ $count > $limit ) {
+                       if ( ++$count > $limit ) {
                                // We've reached the one extra which shows that there are additional pages to be had. Stop here...
                                $this->setContinueEnumParameter( 'start', wfTimestamp( TS_ISO_8601, $row->log_timestamp ) );
                                break;
@@ -285,6 +285,7 @@ class ApiQueryLogEvents extends ApiQueryBase {
                        $result->setIndexedTagName_recursive( $logParams, 'param' );
                        $vals = array_merge( $vals, $logParams );
                }
+
                return $vals;
        }
 
@@ -392,6 +393,7 @@ class ApiQueryLogEvents extends ApiQueryBase {
 
        public function getAllowedParams() {
                global $wgLogTypes, $wgLogActions, $wgLogActionsHandlers;
+
                return array(
                        'prop' => array(
                                ApiBase::PARAM_ISMULTI => true,
@@ -444,6 +446,7 @@ class ApiQueryLogEvents extends ApiQueryBase {
 
        public function getParamDescription() {
                $p = $this->getModulePrefix();
+
                return array(
                        'prop' => array(
                                'Which properties to get',
@@ -473,6 +476,7 @@ class ApiQueryLogEvents extends ApiQueryBase {
 
        public function getResultProperties() {
                global $wgLogTypes;
+
                return array(
                        'ids' => array(
                                'logid' => 'integer',
index a23ff06..469b297 100644 (file)
@@ -104,7 +104,7 @@ abstract class ApiQueryORM extends ApiQueryBase {
        protected function getParams() {
                return array_filter(
                        $this->extractRequestParams(),
-                       function( $prop ) {
+                       function ( $prop ) {
                                return isset( $prop );
                        }
                );
@@ -260,5 +260,4 @@ abstract class ApiQueryORM extends ApiQueryBase {
 
                return array_merge( $this->getTable()->getFieldDescriptions(), $descriptions );
        }
-
 }
index 2de5710..91a8090 100644 (file)
@@ -115,6 +115,7 @@ class ApiQueryPageProps extends ApiQueryBase {
                if ( !$fit ) {
                        $this->setContinueEnumParameter( 'continue', $page );
                }
+
                return $fit;
        }
 
index 222ad07..4273c0d 100644 (file)
@@ -80,7 +80,7 @@ class ApiQueryProtectedTitles extends ApiQueryGeneratorBase {
                $titles = array();
 
                foreach ( $res as $row ) {
-                       if ( ++ $count > $params['limit'] ) {
+                       if ( ++$count > $params['limit'] ) {
                                // We've reached the one extra which shows that there are additional pages to be had. Stop here...
                                $this->setContinueEnumParameter( 'start', wfTimestamp( TS_ISO_8601, $row->pt_timestamp ) );
                                break;
@@ -148,6 +148,7 @@ class ApiQueryProtectedTitles extends ApiQueryGeneratorBase {
 
        public function getAllowedParams() {
                global $wgRestrictionLevels;
+
                return array(
                        'namespace' => array(
                                ApiBase::PARAM_ISMULTI => true,
@@ -216,6 +217,7 @@ class ApiQueryProtectedTitles extends ApiQueryGeneratorBase {
 
        public function getResultProperties() {
                global $wgRestrictionLevels;
+
                return array(
                        '' => array(
                                'ns' => 'namespace',
index 79fe049..a6e455f 100644 (file)
@@ -138,6 +138,7 @@ class ApiQueryQueryPage extends ApiQueryGeneratorBase {
                if ( $qp->getRestriction() != '' ) {
                        return 'private';
                }
+
                return 'public';
        }
 
index fae3377..b1f5ab9 100644 (file)
@@ -83,8 +83,8 @@ class ApiQueryRandom extends ApiQueryGeneratorBase {
                                // Prevent duplicates
                                if ( !in_array( $row->page_id, $this->pageIDs ) ) {
                                        $fit = $this->getResult()->addValue(
-                                                       array( 'query', $this->getModuleName() ),
-                                                       null, $this->extractRowInfo( $row ) );
+                                               array( 'query', $this->getModuleName() ),
+                                               null, $this->extractRowInfo( $row ) );
                                        if ( !$fit ) {
                                                // We can't really query-continue a random list.
                                                // Return an insanely high value so
@@ -131,6 +131,7 @@ class ApiQueryRandom extends ApiQueryGeneratorBase {
                $vals = array();
                $vals['id'] = intval( $row->page_id );
                ApiQueryBase::addTitleInfo( $vals, $title );
+
                return $vals;
        }
 
index 8d969fc..9abe76b 100644 (file)
@@ -37,9 +37,9 @@ class ApiQueryRecentChanges extends ApiQueryGeneratorBase {
        }
 
        private $fld_comment = false, $fld_parsedcomment = false, $fld_user = false, $fld_userid = false,
-                       $fld_flags = false, $fld_timestamp = false, $fld_title = false, $fld_ids = false,
-                       $fld_sizes = false, $fld_redirect = false, $fld_patrolled = false, $fld_loginfo = false,
-                       $fld_tags = false, $fld_sha1 = false, $token = array();
+               $fld_flags = false, $fld_timestamp = false, $fld_title = false, $fld_ids = false,
+               $fld_sizes = false, $fld_redirect = false, $fld_patrolled = false, $fld_loginfo = false,
+               $fld_tags = false, $fld_sha1 = false, $token = array();
 
        private $tokenFunctions;
 
@@ -64,6 +64,7 @@ class ApiQueryRecentChanges extends ApiQueryGeneratorBase {
                        'patrol' => array( 'ApiQueryRecentChanges', 'getPatrolToken' )
                );
                wfRunHooks( 'APIQueryRecentChangesTokens', array( &$this->tokenFunctions ) );
+
                return $this->tokenFunctions;
        }
 
@@ -80,8 +81,8 @@ class ApiQueryRecentChanges extends ApiQueryGeneratorBase {
 
                if ( $rc ) {
                        if ( ( $wgUser->useRCPatrol() && $rc->getAttribute( 'rc_type' ) == RC_EDIT ) ||
-                               ( $wgUser->useNPPatrol() && $rc->getAttribute( 'rc_type' ) == RC_NEW ) )
-                       {
+                               ( $wgUser->useNPPatrol() && $rc->getAttribute( 'rc_type' ) == RC_NEW )
+                       {
                                $validTokenUser = true;
                        }
                } else {
@@ -96,11 +97,11 @@ class ApiQueryRecentChanges extends ApiQueryGeneratorBase {
                        if ( is_null( $cachedPatrolToken ) ) {
                                $cachedPatrolToken = $wgUser->getEditToken( 'patrol' );
                        }
+
                        return $cachedPatrolToken;
                } else {
                        return false;
                }
-
        }
 
        /**
@@ -155,7 +156,7 @@ class ApiQueryRecentChanges extends ApiQueryGeneratorBase {
                        $cont = explode( '|', $params['continue'] );
                        if ( count( $cont ) != 2 ) {
                                $this->dieUsage( 'Invalid continue param. You should pass the ' .
-                                                               'original value returned by the previous query', '_badcontinue' );
+                                       'original value returned by the previous query', '_badcontinue' );
                        }
 
                        $timestamp = $this->getDB()->addQuotes( wfTimestamp( TS_MW, $cont[0] ) );
@@ -187,10 +188,10 @@ class ApiQueryRecentChanges extends ApiQueryGeneratorBase {
 
                        /* Check for conflicting parameters. */
                        if ( ( isset( $show['minor'] ) && isset( $show['!minor'] ) )
-                                       || ( isset( $show['bot'] ) && isset( $show['!bot'] ) )
-                                       || ( isset( $show['anon'] ) && isset( $show['!anon'] ) )
-                                       || ( isset( $show['redirect'] ) && isset( $show['!redirect'] ) )
-                                       || ( isset( $show['patrolled'] ) && isset( $show['!patrolled'] ) )
+                               || ( isset( $show['bot'] ) && isset( $show['!bot'] ) )
+                               || ( isset( $show['anon'] ) && isset( $show['!anon'] ) )
+                               || ( isset( $show['redirect'] ) && isset( $show['!redirect'] ) )
+                               || ( isset( $show['patrolled'] ) && isset( $show['!patrolled'] ) )
                        ) {
                                $this->dieUsageMsg( 'show' );
                        }
@@ -311,7 +312,7 @@ class ApiQueryRecentChanges extends ApiQueryGeneratorBase {
 
                /* Iterate through the rows, adding data extracted from them to our query result. */
                foreach ( $res as $row ) {
-                       if ( ++ $count > $params['limit'] ) {
+                       if ( ++$count > $params['limit'] ) {
                                // We've reached the one extra which shows that there are additional pages to be had. Stop here...
                                $this->setContinueEnumParameter( 'continue', wfTimestamp( TS_ISO_8601, $row->rc_timestamp ) . '|' . $row->rc_id );
                                break;
@@ -520,6 +521,7 @@ class ApiQueryRecentChanges extends ApiQueryGeneratorBase {
                        foreach ( $type as $t ) {
                                $retval[] = $this->parseRCType( $t );
                        }
+
                        return $retval;
                }
                switch ( $type ) {
@@ -549,6 +551,7 @@ class ApiQueryRecentChanges extends ApiQueryGeneratorBase {
                        // formatComment() calls wfMessage() among other things
                        return 'anon-public-user-private';
                }
+
                return 'public';
        }
 
@@ -640,6 +643,7 @@ class ApiQueryRecentChanges extends ApiQueryGeneratorBase {
 
        public function getParamDescription() {
                $p = $this->getModulePrefix();
+
                return array(
                        'start' => 'The timestamp to start enumerating from',
                        'end' => 'The timestamp to end enumerating',