API: fix copyright symbol, coding style cleanup, more braces
authorJack Phoenix <ashley@users.mediawiki.org>
Wed, 24 Feb 2010 14:45:19 +0000 (14:45 +0000)
committerJack Phoenix <ashley@users.mediawiki.org>
Wed, 24 Feb 2010 14:45:19 +0000 (14:45 +0000)
includes/api/ApiQueryImages.php
includes/api/ApiQueryInfo.php
includes/api/ApiQueryLangLinks.php
includes/api/ApiQueryLinks.php
includes/api/ApiQueryLogEvents.php
includes/api/ApiQueryProtectedTitles.php
includes/api/ApiQueryRandom.php
includes/api/ApiQueryRecentChanges.php
includes/api/ApiQueryRevisions.php
includes/api/ApiQuerySearch.php

index ba6fdcb..b6dfc1a 100644 (file)
@@ -1,11 +1,11 @@
 <?php
 
-/*
+/**
  * Created on May 13, 2007
  *
  * API for MediaWiki 1.8+
  *
- * Copyright (C) 2006 Yuri Astrakhan <Firstname><Lastname>@gmail.com
+ * Copyright © 2006 Yuri Astrakhan <Firstname><Lastname>@gmail.com
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -25,7 +25,7 @@
 
 if ( !defined( 'MEDIAWIKI' ) ) {
        // Eclipse helper - will be ignored in production
-       require_once ( "ApiQueryBase.php" );
+       require_once( "ApiQueryBase.php" );
 }
 
 /**
@@ -36,7 +36,7 @@ if ( !defined( 'MEDIAWIKI' ) ) {
 class ApiQueryImages extends ApiQueryGeneratorBase {
 
        public function __construct( $query, $moduleName ) {
-               parent :: __construct( $query, $moduleName, 'im' );
+               parent::__construct( $query, $moduleName, 'im' );
        }
 
        public function execute() {
@@ -48,12 +48,12 @@ class ApiQueryImages extends ApiQueryGeneratorBase {
        }
 
        private function run( $resultPageSet = null ) {
-
-               if ( $this->getPageSet()->getGoodTitleCount() == 0 )
+               if ( $this->getPageSet()->getGoodTitleCount() == 0 ) {
                        return; // nothing to do
+               }
 
                $params = $this->extractRequestParams();
-               $this->addFields( array (
+               $this->addFields( array(
                        'il_from',
                        'il_to'
                ) );
@@ -62,21 +62,25 @@ class ApiQueryImages extends ApiQueryGeneratorBase {
                $this->addWhereFld( 'il_from', array_keys( $this->getPageSet()->getGoodTitles() ) );
                if ( !is_null( $params['continue'] ) ) {
                        $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" );
+                       if ( count( $cont ) != 2 ) {
+                               $this->dieUsage( 'Invalid continue param. You should pass the ' .
+                                       'original value returned by the previous query', '_badcontinue' );
+                       }
                        $ilfrom = intval( $cont[0] );
                        $ilto = $this->getDB()->strencode( $this->titleToKey( $cont[1] ) );
-                       $this->addWhere( "il_from > $ilfrom OR " .
-                                       "(il_from = $ilfrom AND " .
-                                       "il_to >= '$ilto')" );
+                       $this->addWhere(
+                               "il_from > $ilfrom OR " .
+                               "(il_from = $ilfrom AND " .
+                               "il_to >= '$ilto')"
+                       );
                }
 
                // Don't order by il_from if it's constant in the WHERE clause
-               if ( count( $this->getPageSet()->getGoodTitles() ) == 1 )
+               if ( count( $this->getPageSet()->getGoodTitles() ) == 1 ) {
                        $this->addOption( 'ORDER BY', 'il_to' );
-               else
+               } else {
                        $this->addOption( 'ORDER BY', 'il_from, il_to' );
+               }
                $this->addOption( 'LIMIT', $params['limit'] + 1 );
 
                $db = $this->getDB();
@@ -93,17 +97,15 @@ class ApiQueryImages extends ApiQueryGeneratorBase {
                                        break;
                                }
                                $vals = array();
-                               ApiQueryBase :: addTitleInfo( $vals, Title :: makeTitle( NS_FILE, $row->il_to ) );
+                               ApiQueryBase::addTitleInfo( $vals, Title::makeTitle( NS_FILE, $row->il_to ) );
                                $fit = $this->addPageSubItem( $row->il_from, $vals );
-                               if ( !$fit )
-                               {
+                               if ( !$fit ) {
                                        $this->setContinueEnumParameter( 'continue', $row->il_from .
                                                        '|' . $this->keyToTitle( $row->il_to ) );
                                        break;
                                }
                        }
                } else {
-
                        $titles = array();
                        $count = 0;
                        while ( $row = $db->fetchObject( $res ) ) {
@@ -114,7 +116,7 @@ class ApiQueryImages extends ApiQueryGeneratorBase {
                                                        '|' . $this->keyToTitle( $row->il_to ) );
                                        break;
                                }
-                               $titles[] = Title :: makeTitle( NS_FILE, $row->il_to );
+                               $titles[] = Title::makeTitle( NS_FILE, $row->il_to );
                        }
                        $resultPageSet->populateFromTitles( $titles );
                }
@@ -124,18 +126,18 @@ class ApiQueryImages extends ApiQueryGeneratorBase {
 
        public function getAllowedParams() {
                return array(
-                               'limit' => array(
-                                       ApiBase :: PARAM_DFLT => 10,
-                                       ApiBase :: PARAM_TYPE => 'limit',
-                                       ApiBase :: PARAM_MIN => 1,
-                                       ApiBase :: PARAM_MAX => ApiBase :: LIMIT_BIG1,
-                                       ApiBase :: PARAM_MAX2 => ApiBase :: LIMIT_BIG2
-                               ),
-                               'continue' => null,
+                       'limit' => array(
+                               ApiBase::PARAM_DFLT => 10,
+                               ApiBase::PARAM_TYPE => 'limit',
+                               ApiBase::PARAM_MIN => 1,
+                               ApiBase::PARAM_MAX => ApiBase::LIMIT_BIG1,
+                               ApiBase::PARAM_MAX2 => ApiBase::LIMIT_BIG2
+                       ),
+                       'continue' => null,
                );
        }
 
-       public function getParamDescription () {
+       public function getParamDescription() {
                return array(
                        'limit' => 'How many images to return',
                        'continue' => 'When more results are available, use this to continue',
@@ -145,7 +147,7 @@ class ApiQueryImages extends ApiQueryGeneratorBase {
        public function getDescription() {
                return 'Returns all images contained on the given page(s)';
        }
-       
+
        public function getPossibleErrors() {
                return array_merge( parent::getPossibleErrors(), array(
                        array( 'code' => '_badcontinue', 'info' => 'Invalid continue param. You should pass the original value returned by the previous query' ),
@@ -153,12 +155,12 @@ class ApiQueryImages extends ApiQueryGeneratorBase {
        }
 
        protected function getExamples() {
-               return array (
-                               "Get a list of images used in the [[Main Page]]:",
-                               "  api.php?action=query&prop=images&titles=Main%20Page",
-                               "Get information about all images used in the [[Main Page]]:",
-                               "  api.php?action=query&generator=images&titles=Main%20Page&prop=info"
-                       );
+               return array(
+                       'Get a list of images used in the [[Main Page]]:',
+                       '  api.php?action=query&prop=images&titles=Main%20Page',
+                       'Get information about all images used in the [[Main Page]]:',
+                       '  api.php?action=query&generator=images&titles=Main%20Page&prop=info'
+               );
        }
 
        public function getVersion() {
index e562c4d..442e4e6 100644 (file)
@@ -1,11 +1,11 @@
 <?php
 
-/*
+/**
  * Created on Sep 25, 2006
  *
  * API for MediaWiki 1.8+
  *
- * Copyright (C) 2006 Yuri Astrakhan <Firstname><Lastname>@gmail.com
+ * Copyright © 2006 Yuri Astrakhan <Firstname><Lastname>@gmail.com
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -25,7 +25,7 @@
 
 if ( !defined( 'MEDIAWIKI' ) ) {
        // Eclipse helper - will be ignored in production
-       require_once ( 'ApiQueryBase.php' );
+       require_once( 'ApiQueryBase.php' );
 }
 
 /**
@@ -41,7 +41,7 @@ class ApiQueryInfo extends ApiQueryBase {
                $fld_preload = false;
 
        public function __construct( $query, $moduleName ) {
-               parent :: __construct( $query, $moduleName, 'in' );
+               parent::__construct( $query, $moduleName, 'in' );
        }
 
        public function requestExtraData( $pageSet ) {
@@ -62,12 +62,14 @@ class ApiQueryInfo extends ApiQueryBase {
         */
        protected function getTokenFunctions() {
                // Don't call the hooks twice
-               if ( isset( $this->tokenFunctions ) )
+               if ( isset( $this->tokenFunctions ) ) {
                        return $this->tokenFunctions;
+               }
 
                // If we're in JSON callback mode, no tokens can be obtained
-               if ( !is_null( $this->getMain()->getRequest()->getVal( 'callback' ) ) )
+               if ( !is_null( $this->getMain()->getRequest()->getVal( 'callback' ) ) ) {
                        return array();
+               }
 
                $this->tokenFunctions = array(
                        'edit' => array( 'ApiQueryInfo', 'getEditToken' ),
@@ -83,109 +85,115 @@ class ApiQueryInfo extends ApiQueryBase {
                return $this->tokenFunctions;
        }
 
-       public static function getEditToken( $pageid, $title )
-       {
+       public static function getEditToken( $pageid, $title ) {
                // We could check for $title->userCan('edit') here,
                // but that's too expensive for this purpose
                // and would break caching
                global $wgUser;
-               if ( !$wgUser->isAllowed( 'edit' ) )
+               if ( !$wgUser->isAllowed( 'edit' ) ) {
                        return false;
+               }
 
                // The edit token is always the same, let's exploit that
                static $cachedEditToken = null;
-               if ( !is_null( $cachedEditToken ) )
+               if ( !is_null( $cachedEditToken ) ) {
                        return $cachedEditToken;
+               }
 
                $cachedEditToken = $wgUser->editToken();
                return $cachedEditToken;
        }
 
-       public static function getDeleteToken( $pageid, $title )
-       {
+       public static function getDeleteToken( $pageid, $title ) {
                global $wgUser;
-               if ( !$wgUser->isAllowed( 'delete' ) )
+               if ( !$wgUser->isAllowed( 'delete' ) ) {
                        return false;
+               }
 
                static $cachedDeleteToken = null;
-               if ( !is_null( $cachedDeleteToken ) )
+               if ( !is_null( $cachedDeleteToken ) ) {
                        return $cachedDeleteToken;
+               }
 
                $cachedDeleteToken = $wgUser->editToken();
                return $cachedDeleteToken;
        }
 
-       public static function getProtectToken( $pageid, $title )
-       {
+       public static function getProtectToken( $pageid, $title ) {
                global $wgUser;
-               if ( !$wgUser->isAllowed( 'protect' ) )
+               if ( !$wgUser->isAllowed( 'protect' ) ) {
                        return false;
+               }
 
                static $cachedProtectToken = null;
-               if ( !is_null( $cachedProtectToken ) )
+               if ( !is_null( $cachedProtectToken ) ) {
                        return $cachedProtectToken;
+               }
 
                $cachedProtectToken = $wgUser->editToken();
                return $cachedProtectToken;
        }
 
-       public static function getMoveToken( $pageid, $title )
-       {
+       public static function getMoveToken( $pageid, $title ) {
                global $wgUser;
-               if ( !$wgUser->isAllowed( 'move' ) )
+               if ( !$wgUser->isAllowed( 'move' ) ) {
                        return false;
+               }
 
                static $cachedMoveToken = null;
-               if ( !is_null( $cachedMoveToken ) )
+               if ( !is_null( $cachedMoveToken ) ) {
                        return $cachedMoveToken;
+               }
 
                $cachedMoveToken = $wgUser->editToken();
                return $cachedMoveToken;
        }
 
-       public static function getBlockToken( $pageid, $title )
-       {
+       public static function getBlockToken( $pageid, $title ) {
                global $wgUser;
-               if ( !$wgUser->isAllowed( 'block' ) )
+               if ( !$wgUser->isAllowed( 'block' ) ) {
                        return false;
+               }
 
                static $cachedBlockToken = null;
-               if ( !is_null( $cachedBlockToken ) )
+               if ( !is_null( $cachedBlockToken ) ) {
                        return $cachedBlockToken;
+               }
 
                $cachedBlockToken = $wgUser->editToken();
                return $cachedBlockToken;
        }
 
-       public static function getUnblockToken( $pageid, $title )
-       {
+       public static function getUnblockToken( $pageid, $title ) {
                // Currently, this is exactly the same as the block token
                return self::getBlockToken( $pageid, $title );
        }
 
-       public static function getEmailToken( $pageid, $title )
-       {
+       public static function getEmailToken( $pageid, $title ) {
                global $wgUser;
-               if ( !$wgUser->canSendEmail() || $wgUser->isBlockedFromEmailUser() )
+               if ( !$wgUser->canSendEmail() || $wgUser->isBlockedFromEmailUser() ) {
                        return false;
+               }
 
                static $cachedEmailToken = null;
-               if ( !is_null( $cachedEmailToken ) )
+               if ( !is_null( $cachedEmailToken ) ) {
                        return $cachedEmailToken;
+               }
 
                $cachedEmailToken = $wgUser->editToken();
                return $cachedEmailToken;
        }
 
-       public static function getImportToken( $pageid, $title )
-       {
+       public static function getImportToken( $pageid, $title ) {
                global $wgUser;
-               if ( !$wgUser->isAllowed( 'import' ) )
+               if ( !$wgUser->isAllowed( 'import' ) ) {
                        return false;
+               }
 
                static $cachedImportToken = null;
-               if ( !is_null( $cachedImportToken ) )
+               if ( !is_null( $cachedImportToken ) ) {
                        return $cachedImportToken;
+               }
 
                $cachedImportToken = $wgUser->editToken();
                return $cachedImportToken;
@@ -201,7 +209,7 @@ class ApiQueryInfo extends ApiQueryBase {
                        $this->fld_subjectid = isset( $prop['subjectid'] );
                        $this->fld_url = isset( $prop['url'] );
                        $this->fld_readable = isset( $prop['readable'] );
-                       $this->fld_preload = isset ( $prop['preload'] );
+                       $this->fld_preload = isset( $prop['preload'] );
                }
 
                $pageSet = $this->getPageSet();
@@ -211,19 +219,19 @@ class ApiQueryInfo extends ApiQueryBase {
                $result = $this->getResult();
 
                uasort( $this->everything, array( 'Title', 'compare' ) );
-               if ( !is_null( $this->params['continue'] ) )
-               {
+               if ( !is_null( $this->params['continue'] ) ) {
                        // Throw away any titles we're gonna skip so they don't
                        // clutter queries
                        $cont = explode( '|', $this->params['continue'] );
-                       if ( count( $cont ) != 2 )
-                               $this->dieUsage( "Invalid continue param. You should pass the original " .
-                                               "value returned by the previous query", "_badcontinue" );
+                       if ( count( $cont ) != 2 ) {
+                               $this->dieUsage( 'Invalid continue param. You should pass the original ' .
+                                               'value returned by the previous query', '_badcontinue' );
+                       }
                        $conttitle = Title::makeTitleSafe( $cont[0], $cont[1] );
-                       foreach ( $this->everything as $pageid => $title )
-                       {
-                               if ( Title::compare( $title, $conttitle ) >= 0 )
+                       foreach ( $this->everything as $pageid => $title ) {
+                               if ( Title::compare( $title, $conttitle ) >= 0 ) {
                                        break;
+                               }
                                unset( $this->titles[$pageid] );
                                unset( $this->missing[$pageid] );
                                unset( $this->everything[$pageid] );
@@ -240,24 +248,26 @@ class ApiQueryInfo extends ApiQueryBase {
 
                $db = $this->getDB();
                // Get protection info if requested
-               if ( $this->fld_protection )
+               if ( $this->fld_protection ) {
                        $this->getProtectionInfo();
+               }
 
-               if ( $this->fld_watched )
+               if ( $this->fld_watched ) {
                        $this->getWatchedInfo();
+               }
 
                // Run the talkid/subjectid query if requested
-               if ( $this->fld_talkid || $this->fld_subjectid )
+               if ( $this->fld_talkid || $this->fld_subjectid ) {
                        $this->getTSIDs();
+               }
 
                foreach ( $this->everything as $pageid => $title ) {
                        $pageInfo = $this->extractPageInfo( $pageid, $title );
-                       $fit = $result->addValue( array (
+                       $fit = $result->addValue( array(
                                'query',
                                'pages'
                        ), $pageid, $pageInfo );
-                       if ( !$fit )
-                       {
+                       if ( !$fit ) {
                                $this->setContinueEnumParameter( 'continue',
                                                $title->getNamespace() . '|' .
                                                $title->getText() );
@@ -272,64 +282,72 @@ class ApiQueryInfo extends ApiQueryBase {
         * @param $title Title object
         * @return array
         */
-       private function extractPageInfo( $pageid, $title )
-       {
+       private function extractPageInfo( $pageid, $title ) {
                $pageInfo = array();
-               if ( $title->exists() )
-               {
+               if ( $title->exists() ) {
                        $pageInfo['touched'] = wfTimestamp( TS_ISO_8601, $this->pageTouched[$pageid] );
                        $pageInfo['lastrevid'] = intval( $this->pageLatest[$pageid] );
                        $pageInfo['counter'] = intval( $this->pageCounter[$pageid] );
                        $pageInfo['length'] = intval( $this->pageLength[$pageid] );
-                       if ( $this->pageIsRedir[$pageid] )
+                       if ( $this->pageIsRedir[$pageid] ) {
                                $pageInfo['redirect'] = '';
-                       if ( $this->pageIsNew[$pageid] )
+                       }
+                       if ( $this->pageIsNew[$pageid] ) {
                                $pageInfo['new'] = '';
+                       }
                }
 
                if ( !is_null( $this->params['token'] ) ) {
                        $tokenFunctions = $this->getTokenFunctions();
                        $pageInfo['starttimestamp'] = wfTimestamp( TS_ISO_8601, time() );
-                       foreach ( $this->params['token'] as $t )
-                       {
+                       foreach ( $this->params['token'] as $t ) {
                                $val = call_user_func( $tokenFunctions[$t], $pageid, $title );
-                               if ( $val === false )
+                               if ( $val === false ) {
                                        $this->setWarning( "Action '$t' is not allowed for the current user" );
-                               else
+                               } else {
                                        $pageInfo[$t . 'token'] = $val;
+                               }
                        }
                }
 
                if ( $this->fld_protection ) {
                        $pageInfo['protection'] = array();
-                       if ( isset( $this->protections[$title->getNamespace()][$title->getDBkey()] ) )
+                       if ( isset( $this->protections[$title->getNamespace()][$title->getDBkey()] ) ) {
                                $pageInfo['protection'] =
                                        $this->protections[$title->getNamespace()][$title->getDBkey()];
+                       }
                        $this->getResult()->setIndexedTagName( $pageInfo['protection'], 'pr' );
                }
 
                if ( $this->fld_watched && isset( $this->watched[$title->getNamespace()][$title->getDBkey()] ) )
+               {
                        $pageInfo['watched'] = '';
-       
+               }
+
                if ( $this->fld_talkid && isset( $this->talkids[$title->getNamespace()][$title->getDBkey()] ) )
+               {
                        $pageInfo['talkid'] = $this->talkids[$title->getNamespace()][$title->getDBkey()];
+               }
 
                if ( $this->fld_subjectid && isset( $this->subjectids[$title->getNamespace()][$title->getDBkey()] ) )
+               {
                        $pageInfo['subjectid'] = $this->subjectids[$title->getNamespace()][$title->getDBkey()];
+               }
 
                if ( $this->fld_url ) {
                        $pageInfo['fullurl'] = $title->getFullURL();
                        $pageInfo['editurl'] = $title->getFullURL( 'action=edit' );
                }
-               if ( $this->fld_readable && $title->userCanRead() )
+               if ( $this->fld_readable && $title->userCanRead() ) {
                        $pageInfo['readable'] = '';
-                       
+               }
+
                if ( $this->fld_preload ) {
-                       if ( $title->exists() )
+                       if ( $title->exists() ) {
                                $pageInfo['preload'] = '';
-                       else {
+                       else {
                                wfRunHooks( 'EditFormPreloadText', array( &$text, &$title ) );
-                       
+
                                $pageInfo['preload'] = $text;
                        }
                }
@@ -339,14 +357,12 @@ class ApiQueryInfo extends ApiQueryBase {
        /**
         * Get information about protections and put it in $protections
         */
-       private function getProtectionInfo()
-       {
+       private function getProtectionInfo() {
                $this->protections = array();
                $db = $this->getDB();
 
                // Get normal protections for existing titles
-               if ( count( $this->titles ) )
-               {
+               if ( count( $this->titles ) ) {
                        $this->resetQueryParams();
                        $this->addTables( array( 'page_restrictions', 'page' ) );
                        $this->addWhere( 'page_id=pr_page' );
@@ -362,8 +378,9 @@ class ApiQueryInfo extends ApiQueryBase {
                                        'level' => $row->pr_level,
                                        'expiry' => Block::decodeExpiry( $row->pr_expiry, TS_ISO_8601 )
                                );
-                               if ( $row->pr_cascade )
+                               if ( $row->pr_cascade ) {
                                        $a['cascade'] = '';
+                               }
                                $this->protections[$row->page_namespace][$row->page_title][] = $a;
 
                                // Also check old restrictions
@@ -375,8 +392,9 @@ class ApiQueryInfo extends ApiQueryBase {
                                                        // old old format should be treated as edit/move restriction
                                                        $restriction = trim( $temp[0] );
 
-                                                       if ( $restriction == '' )
+                                                       if ( $restriction == '' ) {
                                                                continue;
+                                                       }
                                                        $this->protections[$row->page_namespace][$row->page_title][] = array(
                                                                'type' => 'edit',
                                                                'level' => $restriction,
@@ -389,8 +407,9 @@ class ApiQueryInfo extends ApiQueryBase {
                                                        );
                                                } else {
                                                        $restriction = trim( $temp[1] );
-                                                       if ( $restriction == '' )
+                                                       if ( $restriction == '' ) {
                                                                continue;
+                                                       }
                                                        $this->protections[$row->page_namespace][$row->page_title][] = array(
                                                                'type' => $temp[0],
                                                                'level' => $restriction,
@@ -404,8 +423,7 @@ class ApiQueryInfo extends ApiQueryBase {
                }
 
                // Get protections for missing titles
-               if ( count( $this->missing ) )
-               {
+               if ( count( $this->missing ) ) {
                        $this->resetQueryParams();
                        $lb = new LinkBatch( $this->missing );
                        $this->addTables( 'protected_titles' );
@@ -425,10 +443,11 @@ class ApiQueryInfo extends ApiQueryBase {
                // Cascading protections
                $images = $others = array();
                foreach ( $this->everything as $title )
-                       if ( $title->getNamespace() == NS_FILE )
+                       if ( $title->getNamespace() == NS_FILE ) {
                                $images[] = $title->getDBkey();
-                       else
+                       } else {
                                $others[] = $title;
+                       }
 
                if ( count( $others ) ) {
                        // Non-images: check templatelinks
@@ -483,24 +502,23 @@ class ApiQueryInfo extends ApiQueryBase {
 
        /**
         * Get talk page IDs (if requested) and subject page IDs (if requested)
-        * and put them in $talkids and $subjectids 
+        * and put them in $talkids and $subjectids
         */
-       private function getTSIDs()
-       {
+       private function getTSIDs() {
                $getTitles = $this->talkids = $this->subjectids = array();
                $db = $this->getDB();
-               foreach ( $this->everything as $t )
-               {
-                       if ( MWNamespace::isTalk( $t->getNamespace() ) )
-                       {
-                               if ( $this->fld_subjectid )
+               foreach ( $this->everything as $t ) {
+                       if ( MWNamespace::isTalk( $t->getNamespace() ) ) {
+                               if ( $this->fld_subjectid ) {
                                        $getTitles[] = $t->getSubjectPage();
-                       }
-                       else if ( $this->fld_talkid )
+                               }
+                       } elseif ( $this->fld_talkid ) {
                                $getTitles[] = $t->getTalkPage();
+                       }
                }
-               if ( !count( $getTitles ) )
+               if ( !count( $getTitles ) ) {
                        return;
+               }
 
                // Construct a custom WHERE clause that matches
                // all titles in $getTitles
@@ -510,26 +528,26 @@ class ApiQueryInfo extends ApiQueryBase {
                $this->addFields( array( 'page_title', 'page_namespace', 'page_id' ) );
                $this->addWhere( $lb->constructSet( 'page', $db ) );
                $res = $this->select( __METHOD__ );
-               while ( $row = $db->fetchObject( $res ) )
-               {
-                       if ( MWNamespace::isTalk( $row->page_namespace ) )
+               while ( $row = $db->fetchObject( $res ) ) {
+                       if ( MWNamespace::isTalk( $row->page_namespace ) ) {
                                $this->talkids[MWNamespace::getSubject( $row->page_namespace )][$row->page_title] =
                                                intval( $row->page_id );
-                       else
+                       } else {
                                $this->subjectids[MWNamespace::getTalk( $row->page_namespace )][$row->page_title] =
                                                intval( $row->page_id );
+                       }
                }
        }
 
        /**
         * Get information about watched status and put it in $watched
         */
-       private function getWatchedInfo()
-       {
+       private function getWatchedInfo() {
                global $wgUser;
 
-               if ( $wgUser->isAnon() || count( $this->titles ) == 0 )
+               if ( $wgUser->isAnon() || count( $this->titles ) == 0 ) {
                        return;
+               }
 
                $this->watched = array();
                $db = $this->getDB();
@@ -554,11 +572,11 @@ class ApiQueryInfo extends ApiQueryBase {
        }
 
        public function getAllowedParams() {
-               return array (
-                       'prop' => array (
-                               ApiBase :: PARAM_DFLT => null,
-                               ApiBase :: PARAM_ISMULTI => true,
-                               ApiBase :: PARAM_TYPE => array (
+               return array(
+                       'prop' => array(
+                               ApiBase::PARAM_DFLT => null,
+                               ApiBase::PARAM_ISMULTI => true,
+                               ApiBase::PARAM_TYPE => array(
                                        'protection',
                                        'talkid',
                                        'watched',
@@ -567,18 +585,18 @@ class ApiQueryInfo extends ApiQueryBase {
                                        'readable',
                                        'preload'
                                ) ),
-                       'token' => array (
-                               ApiBase :: PARAM_DFLT => null,
-                               ApiBase :: PARAM_ISMULTI => true,
-                               ApiBase :: PARAM_TYPE => array_keys( $this->getTokenFunctions() )
+                       'token' => array(
+                               ApiBase::PARAM_DFLT => null,
+                               ApiBase::PARAM_ISMULTI => true,
+                               ApiBase::PARAM_TYPE => array_keys( $this->getTokenFunctions() )
                        ),
                        'continue' => null,
                );
        }
 
        public function getParamDescription() {
-               return array (
-                       'prop' => array (
+               return array(
+                       'prop' => array(
                                'Which additional properties to get:',
                                ' protection   - List the protection level of each page',
                                ' talkid       - The page ID of the talk page for each non-talk page',
@@ -596,7 +614,7 @@ class ApiQueryInfo extends ApiQueryBase {
        public function getDescription() {
                return 'Get basic page information such as namespace, title, last touched date, ...';
        }
-       
+
        public function getPossibleErrors() {
                return array_merge( parent::getPossibleErrors(), array(
                        array( 'code' => '_badcontinue', 'info' => 'Invalid continue param. You should pass the original value returned by the previous query' ),
@@ -604,7 +622,7 @@ class ApiQueryInfo extends ApiQueryBase {
        }
 
        protected function getExamples() {
-               return array (
+               return array(
                        'api.php?action=query&prop=info&titles=Main%20Page',
                        'api.php?action=query&prop=info&inprop=protection&titles=Main%20Page'
                );
index 8e54950..10aad5a 100644 (file)
@@ -1,11 +1,11 @@
 <?php
 
-/*
+/**
  * Created on May 13, 2007
  *
  * API for MediaWiki 1.8+
  *
- * Copyright (C) 2006 Yuri Astrakhan <Firstname><Lastname>@gmail.com
+ * Copyright © 2006 Yuri Astrakhan <Firstname><Lastname>@gmail.com
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -25,7 +25,7 @@
 
 if ( !defined( 'MEDIAWIKI' ) ) {
        // Eclipse helper - will be ignored in production
-       require_once ( "ApiQueryBase.php" );
+       require_once( "ApiQueryBase.php" );
 }
 
 /**
@@ -36,15 +36,16 @@ if ( !defined( 'MEDIAWIKI' ) ) {
 class ApiQueryLangLinks extends ApiQueryBase {
 
        public function __construct( $query, $moduleName ) {
-               parent :: __construct( $query, $moduleName, 'll' );
+               parent::__construct( $query, $moduleName, 'll' );
        }
 
        public function execute() {
-               if ( $this->getPageSet()->getGoodTitleCount() == 0 )
+               if ( $this->getPageSet()->getGoodTitleCount() == 0 ) {
                        return;
+               }
 
                $params = $this->extractRequestParams();
-               $this->addFields( array (
+               $this->addFields( array(
                        'll_from',
                        'll_lang',
                        'll_title'
@@ -54,21 +55,25 @@ class ApiQueryLangLinks extends ApiQueryBase {
                $this->addWhereFld( 'll_from', array_keys( $this->getPageSet()->getGoodTitles() ) );
                if ( !is_null( $params['continue'] ) ) {
                        $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" );
+                       if ( count( $cont ) != 2 ) {
+                               $this->dieUsage( 'Invalid continue param. You should pass the ' .
+                                       'original value returned by the previous query', '_badcontinue' );
+                       }
                        $llfrom = intval( $cont[0] );
                        $lllang = $this->getDB()->strencode( $cont[1] );
-                       $this->addWhere( "ll_from > $llfrom OR " .
-                                       "(ll_from = $llfrom AND " .
-                                       "ll_lang >= '$lllang')" );
+                       $this->addWhere(
+                               "ll_from > $llfrom OR " .
+                               "(ll_from = $llfrom AND " .
+                               "ll_lang >= '$lllang')"
+                       );
                }
 
                // Don't order by ll_from if it's constant in the WHERE clause
-               if ( count( $this->getPageSet()->getGoodTitles() ) == 1 )
+               if ( count( $this->getPageSet()->getGoodTitles() ) == 1 ) {
                        $this->addOption( 'ORDER BY', 'll_lang' );
-               else
+               } else {
                        $this->addOption( 'ORDER BY', 'll_from, ll_lang' );
+               }
                $this->addOption( 'LIMIT', $params['limit'] + 1 );
                $res = $this->select( __METHOD__ );
 
@@ -82,10 +87,9 @@ class ApiQueryLangLinks extends ApiQueryBase {
                                break;
                        }
                        $entry = array( 'lang' => $row->ll_lang );
-                       ApiResult :: setContent( $entry, $row->ll_title );
+                       ApiResult::setContent( $entry, $row->ll_title );
                        $fit = $this->addPageSubItem( $row->ll_from, $entry );
-                       if ( !$fit )
-                       {
+                       if ( !$fit ) {
                                $this->setContinueEnumParameter( 'continue', "{$row->ll_from}|{$row->ll_lang}" );
                                break;
                        }
@@ -95,18 +99,18 @@ class ApiQueryLangLinks extends ApiQueryBase {
 
        public function getAllowedParams() {
                return array(
-                               'limit' => array(
-                                       ApiBase :: PARAM_DFLT => 10,
-                                       ApiBase :: PARAM_TYPE => 'limit',
-                                       ApiBase :: PARAM_MIN => 1,
-                                       ApiBase :: PARAM_MAX => ApiBase :: LIMIT_BIG1,
-                                       ApiBase :: PARAM_MAX2 => ApiBase :: LIMIT_BIG2
-                               ),
-                               'continue' => null,
+                       'limit' => array(
+                               ApiBase::PARAM_DFLT => 10,
+                               ApiBase::PARAM_TYPE => 'limit',
+                               ApiBase::PARAM_MIN => 1,
+                               ApiBase::PARAM_MAX => ApiBase::LIMIT_BIG1,
+                               ApiBase::PARAM_MAX2 => ApiBase::LIMIT_BIG2
+                       ),
+                       'continue' => null,
                );
        }
 
-       public function getParamDescription () {
+       public function getParamDescription() {
                return array(
                        'limit' => 'How many langlinks to return',
                        'continue' => 'When more results are available, use this to continue',
@@ -116,7 +120,7 @@ class ApiQueryLangLinks extends ApiQueryBase {
        public function getDescription() {
                return 'Returns all interlanguage links from the given page(s)';
        }
-       
+
        public function getPossibleErrors() {
                return array_merge( parent::getPossibleErrors(), array(
                        array( 'code' => '_badcontinue', 'info' => 'Invalid continue param. You should pass the original value returned by the previous query' ),
@@ -124,10 +128,10 @@ class ApiQueryLangLinks extends ApiQueryBase {
        }
 
        protected function getExamples() {
-               return array (
-                               "Get interlanguage links from the [[Main Page]]:",
-                               "  api.php?action=query&prop=langlinks&titles=Main%20Page&redirects",
-                       );
+               return array(
+                       'Get interlanguage links from the [[Main Page]]:',
+                       '  api.php?action=query&prop=langlinks&titles=Main%20Page&redirects',
+               );
        }
 
        public function getVersion() {
index a557377..08777fc 100644 (file)
@@ -1,11 +1,11 @@
 <?php
 
-/*
+/**
  * Created on May 12, 2007
  *
  * API for MediaWiki 1.8+
  *
- * Copyright (C) 2006 Yuri Astrakhan <Firstname><Lastname>@gmail.com
+ * Copyright © 2006 Yuri Astrakhan <Firstname><Lastname>@gmail.com
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -25,7 +25,7 @@
 
 if ( !defined( 'MEDIAWIKI' ) ) {
        // Eclipse helper - will be ignored in production
-       require_once ( "ApiQueryBase.php" );
+       require_once( "ApiQueryBase.php" );
 }
 
 /**
@@ -41,23 +41,22 @@ class ApiQueryLinks extends ApiQueryGeneratorBase {
        private $table, $prefix, $description;
 
        public function __construct( $query, $moduleName ) {
-
                switch ( $moduleName ) {
-                       case self::LINKS :
+                       case self::LINKS:
                                $this->table = 'pagelinks';
                                $this->prefix = 'pl';
                                $this->description = 'link';
                                break;
-                       case self::TEMPLATES :
+                       case self::TEMPLATES:
                                $this->table = 'templatelinks';
                                $this->prefix = 'tl';
                                $this->description = 'template';
                                break;
-                       default :
-                               ApiBase :: dieDebug( __METHOD__, 'Unknown module name' );
+                       default:
+                               ApiBase::dieDebug( __METHOD__, 'Unknown module name' );
                }
 
-               parent :: __construct( $query, $moduleName, $this->prefix );
+               parent::__construct( $query, $moduleName, $this->prefix );
        }
 
        public function execute() {
@@ -69,13 +68,13 @@ class ApiQueryLinks extends ApiQueryGeneratorBase {
        }
 
        private function run( $resultPageSet = null ) {
-
-               if ( $this->getPageSet()->getGoodTitleCount() == 0 )
+               if ( $this->getPageSet()->getGoodTitleCount() == 0 ) {
                        return; // nothing to do
+               }
 
                $params = $this->extractRequestParams();
 
-               $this->addFields( array (
+               $this->addFields( array(
                        $this->prefix . '_from AS pl_from',
                        $this->prefix . '_namespace AS pl_namespace',
                        $this->prefix . '_title AS pl_title'
@@ -87,17 +86,20 @@ class ApiQueryLinks extends ApiQueryGeneratorBase {
 
                if ( !is_null( $params['continue'] ) ) {
                        $cont = explode( '|', $params['continue'] );
-                       if ( count( $cont ) != 3 )
-                               $this->dieUsage( "Invalid continue param. You should pass the " .
-                                       "original value returned by the previous query", "_badcontinue" );
+                       if ( count( $cont ) != 3 ) {
+                               $this->dieUsage( 'Invalid continue param. You should pass the ' .
+                                       'original value returned by the previous query', '_badcontinue' );
+                       }
                        $plfrom = intval( $cont[0] );
                        $plns = intval( $cont[1] );
                        $pltitle = $this->getDB()->strencode( $this->titleToKey( $cont[2] ) );
-                       $this->addWhere( "{$this->prefix}_from > $plfrom OR " .
-                                       "({$this->prefix}_from = $plfrom AND " .
-                                       "({$this->prefix}_namespace > $plns OR " .
-                                       "({$this->prefix}_namespace = $plns AND " .
-                                       "{$this->prefix}_title >= '$pltitle')))" );
+                       $this->addWhere(
+                               "{$this->prefix}_from > $plfrom OR " .
+                               "({$this->prefix}_from = $plfrom AND " .
+                               "({$this->prefix}_namespace > $plns OR " .
+                               "({$this->prefix}_namespace = $plns AND " .
+                               "{$this->prefix}_title >= '$pltitle')))"
+                       );
                }
 
                // Here's some MySQL craziness going on: if you use WHERE foo='bar'
@@ -106,13 +108,15 @@ class ApiQueryLinks extends ApiQueryGeneratorBase {
                // already. To work around this, we drop constant fields in the WHERE
                // clause from the ORDER BY clause
                $order = array();
-               if ( count( $this->getPageSet()->getGoodTitles() ) != 1 )
+               if ( count( $this->getPageSet()->getGoodTitles() ) != 1 ) {
                        $order[] = "{$this->prefix}_from";
-               if ( count( $params['namespace'] ) != 1 )
+               }
+               if ( count( $params['namespace'] ) != 1 ) {
                        $order[] = "{$this->prefix}_namespace";
+               }
 
                $order[] = "{$this->prefix}_title";
-               $this->addOption( 'ORDER BY', implode( ", ", $order ) );
+               $this->addOption( 'ORDER BY', implode( ', ', $order ) );
                $this->addOption( 'USE INDEX', "{$this->prefix}_from" );
                $this->addOption( 'LIMIT', $params['limit'] + 1 );
 
@@ -131,10 +135,9 @@ class ApiQueryLinks extends ApiQueryGeneratorBase {
                                        break;
                                }
                                $vals = array();
-                               ApiQueryBase :: addTitleInfo( $vals, Title :: makeTitle( $row->pl_namespace, $row->pl_title ) );
+                               ApiQueryBase::addTitleInfo( $vals, Title::makeTitle( $row->pl_namespace, $row->pl_title ) );
                                $fit = $this->addPageSubItem( $row->pl_from, $vals );
-                               if ( !$fit )
-                               {
+                               if ( !$fit ) {
                                        $this->setContinueEnumParameter( 'continue',
                                                "{$row->pl_from}|{$row->pl_namespace}|" .
                                                $this->keyToTitle( $row->pl_title ) );
@@ -153,7 +156,7 @@ class ApiQueryLinks extends ApiQueryGeneratorBase {
                                                $this->keyToTitle( $row->pl_title ) );
                                        break;
                                }
-                               $titles[] = Title :: makeTitle( $row->pl_namespace, $row->pl_title );
+                               $titles[] = Title::makeTitle( $row->pl_namespace, $row->pl_title );
                        }
                        $resultPageSet->populateFromTitles( $titles );
                }
@@ -161,30 +164,28 @@ class ApiQueryLinks extends ApiQueryGeneratorBase {
                $db->freeResult( $res );
        }
 
-       public function getAllowedParams()
-       {
+       public function getAllowedParams() {
                return array(
-                               'namespace' => array(
-                                       ApiBase :: PARAM_TYPE => 'namespace',
-                                       ApiBase :: PARAM_ISMULTI => true
-                               ),
-                               'limit' => array(
-                                       ApiBase :: PARAM_DFLT => 10,
-                                       ApiBase :: PARAM_TYPE => 'limit',
-                                       ApiBase :: PARAM_MIN => 1,
-                                       ApiBase :: PARAM_MAX => ApiBase :: LIMIT_BIG1,
-                                       ApiBase :: PARAM_MAX2 => ApiBase :: LIMIT_BIG2
-                               ),
-                               'continue' => null,
-                       );
+                       'namespace' => array(
+                               ApiBase::PARAM_TYPE => 'namespace',
+                               ApiBase::PARAM_ISMULTI => true
+                       ),
+                       'limit' => array(
+                               ApiBase::PARAM_DFLT => 10,
+                               ApiBase::PARAM_TYPE => 'limit',
+                               ApiBase::PARAM_MIN => 1,
+                               ApiBase::PARAM_MAX => ApiBase::LIMIT_BIG1,
+                               ApiBase::PARAM_MAX2 => ApiBase::LIMIT_BIG2
+                       ),
+                       'continue' => null,
+               );
        }
 
-       public function getParamDescription()
-       {
+       public function getParamDescription() {
                return array(
-                               'namespace' => "Show {$this->description}s in this namespace(s) only",
-                               'limit' => "How many {$this->description}s to return",
-                               'continue' => 'When more results are available, use this to continue',
+                       'namespace' => "Show {$this->description}s in this namespace(s) only",
+                       'limit' => "How many {$this->description}s to return",
+                       'continue' => 'When more results are available, use this to continue',
                );
        }
 
@@ -193,14 +194,14 @@ class ApiQueryLinks extends ApiQueryGeneratorBase {
        }
 
        protected function getExamples() {
-               return array (
-                               "Get {$this->description}s from the [[Main Page]]:",
-                               "  api.php?action=query&prop={$this->getModuleName()}&titles=Main%20Page",
-                               "Get information about the {$this->description} pages in the [[Main Page]]:",
-                               "  api.php?action=query&generator={$this->getModuleName()}&titles=Main%20Page&prop=info",
-                               "Get {$this->description}s from the Main Page in the User and Template namespaces:",
-                               "  api.php?action=query&prop={$this->getModuleName()}&titles=Main%20Page&{$this->prefix}namespace=2|10"
-                       );
+               return array(
+                       "Get {$this->description}s from the [[Main Page]]:",
+                       "  api.php?action=query&prop={$this->getModuleName()}&titles=Main%20Page",
+                       "Get information about the {$this->description} pages in the [[Main Page]]:",
+                       "  api.php?action=query&generator={$this->getModuleName()}&titles=Main%20Page&prop=info",
+                       "Get {$this->description}s from the Main Page in the User and Template namespaces:",
+                       "  api.php?action=query&prop={$this->getModuleName()}&titles=Main%20Page&{$this->prefix}namespace=2|10"
+               );
        }
 
        public function getVersion() {
index fdc6f4a..aa36b85 100644 (file)
@@ -1,11 +1,11 @@
 <?php
 
-/*
+/**
  * Created on Oct 16, 2006
  *
  * API for MediaWiki 1.8+
  *
- * Copyright (C) 2006 Yuri Astrakhan <Firstname><Lastname>@gmail.com
+ * Copyright © 2006 Yuri Astrakhan <Firstname><Lastname>@gmail.com
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -25,7 +25,7 @@
 
 if ( !defined( 'MEDIAWIKI' ) ) {
        // Eclipse helper - will be ignored in production
-       require_once ( 'ApiQueryBase.php' );
+       require_once( 'ApiQueryBase.php' );
 }
 
 /**
@@ -36,15 +36,15 @@ if ( !defined( 'MEDIAWIKI' ) ) {
 class ApiQueryLogEvents extends ApiQueryBase {
 
        public function __construct( $query, $moduleName ) {
-               parent :: __construct( $query, $moduleName, 'le' );
+               parent::__construct( $query, $moduleName, 'le' );
        }
 
        public function execute() {
                $params = $this->extractRequestParams();
                $db = $this->getDB();
-               
+
                $prop = array_flip( $params['prop'] );
-               
+
                $this->fld_ids = isset( $prop['ids'] );
                $this->fld_title = isset( $prop['title'] );
                $this->fld_type = isset( $prop['type'] );
@@ -58,8 +58,9 @@ class ApiQueryLogEvents extends ApiQueryBase {
                list( $tbl_logging, $tbl_page, $tbl_user ) = $db->tableNamesN( 'logging', 'page', 'user' );
 
                $hideLogs = LogEventsList::getExcludeClause( $db );
-               if ( $hideLogs !== false )
+               if ( $hideLogs !== false ) {
                        $this->addWhere( $hideLogs );
+               }
 
                // Order is significant here
                $this->addTables( array( 'logging', 'user', 'page' ) );
@@ -72,7 +73,7 @@ class ApiQueryLogEvents extends ApiQueryBase {
                                        'log_title=page_title' ) ) ) );
                $index = array( 'logging' => 'times' ); // default, may change
 
-               $this->addFields( array (
+               $this->addFields( array(
                        'log_type',
                        'log_action',
                        'log_timestamp',
@@ -87,26 +88,26 @@ class ApiQueryLogEvents extends ApiQueryBase {
                $this->addFieldsIf( 'log_title', $this->fld_title );
                $this->addFieldsIf( 'log_comment', $this->fld_comment || $this->fld_parsedcomment );
                $this->addFieldsIf( 'log_params', $this->fld_details );
-               
+
                if ( $this->fld_tags ) {
                        $this->addTables( 'tag_summary' );
                        $this->addJoinConds( array( 'tag_summary' => array( 'LEFT JOIN', 'log_id=ts_log_id' ) ) );
                        $this->addFields( 'ts_tags' );
                }
-               
+
                if ( !is_null( $params['tag'] ) ) {
                        $this->addTables( 'change_tag' );
                        $this->addJoinConds( array( 'change_tag' => array( 'INNER JOIN', array( 'log_id=ct_log_id' ) ) ) );
                        $this->addWhereFld( 'ct_tag', $params['tag'] );
                        global $wgOldChangeTagsIndex;
-                       $index['change_tag'] = $wgOldChangeTagsIndex ?  'ct_tag' : 'change_tag_tag_id';
+                       $index['change_tag'] = $wgOldChangeTagsIndex ? 'ct_tag' : 'change_tag_tag_id';
                }
-               
+
                if ( !is_null( $params['type'] ) ) {
                        $this->addWhereFld( 'log_type', $params['type'] );
                        $index['logging'] = 'type_time';
                }
-               
+
                $this->addWhereRange( 'log_timestamp', $params['dir'], $params['start'], $params['end'] );
 
                $limit = $params['limit'];
@@ -115,17 +116,19 @@ class ApiQueryLogEvents extends ApiQueryBase {
                $user = $params['user'];
                if ( !is_null( $user ) ) {
                        $userid = User::idFromName( $user );
-                       if ( !$userid )
+                       if ( !$userid ) {
                                $this->dieUsage( "User name $user not found", 'param_user' );
+                       }
                        $this->addWhereFld( 'log_user', $userid );
                        $index['logging'] = 'user_time';
                }
 
                $title = $params['title'];
                if ( !is_null( $title ) ) {
-                       $titleObj = Title :: newFromText( $title );
-                       if ( is_null( $titleObj ) )
+                       $titleObj = Title::newFromText( $title );
+                       if ( is_null( $titleObj ) ) {
                                $this->dieUsage( "Bad title value '$title'", 'param_title' );
+                       }
                        $this->addWhereFld( 'log_namespace', $titleObj->getNamespace() );
                        $this->addWhereFld( 'log_title', $titleObj->getDBkey() );
 
@@ -153,11 +156,11 @@ class ApiQueryLogEvents extends ApiQueryBase {
                        }
 
                        $vals = $this->extractRowInfo( $row );
-                       if ( !$vals )
+                       if ( !$vals ) {
                                continue;
+                       }
                        $fit = $this->getResult()->addValue( array( 'query', $this->getModuleName() ), null, $vals );
-                       if ( !$fit )
-                       {
+                       if ( !$fit ) {
                                $this->setContinueEnumParameter( 'start', wfTimestamp( TS_ISO_8601, $row->log_timestamp ) );
                                break;
                        }
@@ -166,20 +169,20 @@ class ApiQueryLogEvents extends ApiQueryBase {
 
                $this->getResult()->setIndexedTagName_internal( array( 'query', $this->getModuleName() ), 'item' );
        }
-       
+
        public static function addLogParams( $result, &$vals, $params, $type, $ts ) {
                $params = explode( "\n", $params );
                switch ( $type ) {
                        case 'move':
-                               if ( isset ( $params[0] ) ) {
-                                       $title = Title :: newFromText( $params[0] );
+                               if ( isset( $params[0] ) ) {
+                                       $title = Title::newFromText( $params[0] );
                                        if ( $title ) {
                                                $vals2 = array();
-                                               ApiQueryBase :: addTitleInfo( $vals2, $title, "new_" );
+                                               ApiQueryBase::addTitleInfo( $vals2, $title, 'new_' );
                                                $vals[$type] = $vals2;
                                        }
                                }
-                               if ( isset ( $params[1] ) && $params[1] ) {
+                               if ( isset( $params[1] ) && $params[1] ) {
                                        $vals[$type]['suppressedredirect'] = '';
                                }
                                $params = null;
@@ -239,9 +242,11 @@ class ApiQueryLogEvents extends ApiQueryBase {
                        if ( LogEventsList::isDeleted( $row, LogPage::DELETED_ACTION ) ) {
                                $vals['actionhidden'] = '';
                        } else {
-                               self::addLogParams( $this->getResult(), $vals,
+                               self::addLogParams(
+                                       $this->getResult(), $vals,
                                        $row->log_params, $row->log_type,
-                                       $row->log_timestamp );
+                                       $row->log_timestamp
+                               );
                        }
                }
 
@@ -257,14 +262,15 @@ class ApiQueryLogEvents extends ApiQueryBase {
                if ( $this->fld_timestamp ) {
                        $vals['timestamp'] = wfTimestamp( TS_ISO_8601, $row->log_timestamp );
                }
-               
+
                if ( ( $this->fld_comment || $this->fld_parsedcomment ) && isset( $row->log_comment ) ) {
                        if ( LogEventsList::isDeleted( $row, LogPage::DELETED_COMMENT ) ) {
                                $vals['commenthidden'] = '';
                        } else {
-                               if ( $this->fld_comment )
+                               if ( $this->fld_comment ) {
                                        $vals['comment'] = $row->log_comment;
-                               
+                               }
+
                                if ( $this->fld_parsedcomment ) {
                                        global $wgUser;
                                        $vals['parsedcomment'] = $wgUser->getSkin()->formatComment( $row->log_comment, $title );
@@ -281,17 +287,17 @@ class ApiQueryLogEvents extends ApiQueryBase {
                                $vals['tags'] = array();
                        }
                }
-               
+
                return $vals;
        }
-       
+
        public function getAllowedParams() {
                global $wgLogTypes;
-               return array (
-                       'prop' => array (
-                               ApiBase :: PARAM_ISMULTI => true,
-                               ApiBase :: PARAM_DFLT => 'ids|title|type|user|timestamp|comment|details',
-                               ApiBase :: PARAM_TYPE => array (
+               return array(
+                       'prop' => array(
+                               ApiBase::PARAM_ISMULTI => true,
+                               ApiBase::PARAM_DFLT => 'ids|title|type|user|timestamp|comment|details',
+                               ApiBase::PARAM_TYPE => array(
                                        'ids',
                                        'title',
                                        'type',
@@ -303,18 +309,18 @@ class ApiQueryLogEvents extends ApiQueryBase {
                                        'tags'
                                )
                        ),
-                       'type' => array (
-                               ApiBase :: PARAM_TYPE => $wgLogTypes
+                       'type' => array(
+                               ApiBase::PARAM_TYPE => $wgLogTypes
                        ),
-                       'start' => array (
-                               ApiBase :: PARAM_TYPE => 'timestamp'
+                       'start' => array(
+                               ApiBase::PARAM_TYPE => 'timestamp'
                        ),
-                       'end' => array (
-                               ApiBase :: PARAM_TYPE => 'timestamp'
+                       'end' => array(
+                               ApiBase::PARAM_TYPE => 'timestamp'
                        ),
-                       'dir' => array (
-                               ApiBase :: PARAM_DFLT => 'older',
-                               ApiBase :: PARAM_TYPE => array (
+                       'dir' => array(
+                               ApiBase::PARAM_DFLT => 'older',
+                               ApiBase::PARAM_TYPE => array(
                                        'newer',
                                        'older'
                                )
@@ -322,18 +328,18 @@ class ApiQueryLogEvents extends ApiQueryBase {
                        'user' => null,
                        'title' => null,
                        'tag' => null,
-                       'limit' => array (
-                               ApiBase :: PARAM_DFLT => 10,
-                               ApiBase :: PARAM_TYPE => 'limit',
-                               ApiBase :: PARAM_MIN => 1,
-                               ApiBase :: PARAM_MAX => ApiBase :: LIMIT_BIG1,
-                               ApiBase :: PARAM_MAX2 => ApiBase :: LIMIT_BIG2
+                       'limit' => array(
+                               ApiBase::PARAM_DFLT => 10,
+                               ApiBase::PARAM_TYPE => 'limit',
+                               ApiBase::PARAM_MIN => 1,
+                               ApiBase::PARAM_MAX => ApiBase::LIMIT_BIG1,
+                               ApiBase::PARAM_MAX2 => ApiBase::LIMIT_BIG2
                        )
                );
        }
 
        public function getParamDescription() {
-               return array (
+               return array(
                        'prop' => 'Which properties to get',
                        'type' => 'Filter log entries to only this type(s)',
                        'start' => 'The timestamp to start enumerating from.',
@@ -349,7 +355,7 @@ class ApiQueryLogEvents extends ApiQueryBase {
        public function getDescription() {
                return 'Get events from logs.';
        }
-       
+
        public function getPossibleErrors() {
                return array_merge( parent::getPossibleErrors(), array(
                        array( 'code' => 'param_user', 'info' => 'User name $user not found' ),
@@ -358,7 +364,7 @@ class ApiQueryLogEvents extends ApiQueryBase {
        }
 
        protected function getExamples() {
-               return array (
+               return array(
                        'api.php?action=query&list=logevents'
                );
        }
index 939118e..9f5b51a 100644 (file)
@@ -1,11 +1,11 @@
 <?php
 
-/*
+/**
  * Created on Feb 13, 2009
  *
  * API for MediaWiki 1.8+
  *
- * Copyright (C) 2009 Roan Kattouw <Firstname>.<Lastname>@home.nl
+ * Copyright © 2009 Roan Kattouw <Firstname>.<Lastname>@home.nl
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -25,7 +25,7 @@
 
 if ( !defined( 'MEDIAWIKI' ) ) {
        // Eclipse helper - will be ignored in production
-       require_once ( 'ApiQueryBase.php' );
+       require_once( 'ApiQueryBase.php' );
 }
 
 /**
@@ -36,7 +36,7 @@ if ( !defined( 'MEDIAWIKI' ) ) {
 class ApiQueryProtectedTitles extends ApiQueryGeneratorBase {
 
        public function __construct( $query, $moduleName ) {
-               parent :: __construct( $query, $moduleName, 'pt' );
+               parent::__construct( $query, $moduleName, 'pt' );
        }
 
        public function execute() {
@@ -63,9 +63,8 @@ class ApiQueryProtectedTitles extends ApiQueryGeneratorBase {
                $this->addWhereRange( 'pt_timestamp', $params['dir'], $params['start'], $params['end'] );
                $this->addWhereFld( 'pt_namespace', $params['namespace'] );
                $this->addWhereFld( 'pt_create_perm', $params['level'] );
-               
-               if ( isset( $prop['user'] ) )
-               {
+
+               if ( isset( $prop['user'] ) ) {
                        $this->addTables( 'user' );
                        $this->addFields( 'user_name' );
                        $this->addJoinConds( array( 'user' => array( 'LEFT JOIN',
@@ -89,26 +88,31 @@ class ApiQueryProtectedTitles extends ApiQueryGeneratorBase {
                        if ( is_null( $resultPageSet ) ) {
                                $vals = array();
                                ApiQueryBase::addTitleInfo( $vals, $title );
-                               if ( isset( $prop['timestamp'] ) )
+                               if ( isset( $prop['timestamp'] ) ) {
                                        $vals['timestamp'] = wfTimestamp( TS_ISO_8601, $row->pt_timestamp );
-                                       
-                               if ( isset( $prop['user'] ) && !is_null( $row->user_name ) )
+                               }
+
+                               if ( isset( $prop['user'] ) && !is_null( $row->user_name ) ) {
                                        $vals['user'] = $row->user_name;
-                                       
-                               if ( isset( $prop['comment'] ) )
+                               }
+
+                               if ( isset( $prop['comment'] ) ) {
                                        $vals['comment'] = $row->pt_reason;
-                                       
+                               }
+
                                if ( isset( $prop['parsedcomment'] ) ) {
                                        global $wgUser;
                                        $vals['parsedcomment'] = $wgUser->getSkin()->formatComment( $row->pt_reason, $title );
                                }
-                                       
-                               if ( isset( $prop['expiry'] ) )
+
+                               if ( isset( $prop['expiry'] ) ) {
                                        $vals['expiry'] = Block::decodeExpiry( $row->pt_expiry, TS_ISO_8601 );
-                                       
-                               if ( isset( $prop['level'] ) )
+                               }
+
+                               if ( isset( $prop['level'] ) ) {
                                        $vals['level'] = $row->pt_create_perm;
-                               
+                               }
+
                                $fit = $result->addValue( array( 'query', $this->getModuleName() ), null, $vals );
                                if ( !$fit ) {
                                        $this->setContinueEnumParameter( 'start',
@@ -120,47 +124,48 @@ class ApiQueryProtectedTitles extends ApiQueryGeneratorBase {
                        }
                }
                $db->freeResult( $res );
-               if ( is_null( $resultPageSet ) )
+               if ( is_null( $resultPageSet ) ) {
                        $result->setIndexedTagName_internal( array( 'query', $this->getModuleName() ), $this->getModulePrefix() );
-               else
+               } else {
                        $resultPageSet->populateFromTitles( $titles );
+               }
        }
 
        public function getAllowedParams() {
                global $wgRestrictionLevels;
-               return array (
-                       'namespace' => array (
-                               ApiBase :: PARAM_ISMULTI => true,
-                               ApiBase :: PARAM_TYPE => 'namespace',
+               return array(
+                       'namespace' => array(
+                               ApiBase::PARAM_ISMULTI => true,
+                               ApiBase::PARAM_TYPE => 'namespace',
                        ),
                        'level' => array(
-                               ApiBase :: PARAM_ISMULTI => true,
-                               ApiBase :: PARAM_TYPE => array_diff( $wgRestrictionLevels, array( '' ) )
+                               ApiBase::PARAM_ISMULTI => true,
+                               ApiBase::PARAM_TYPE => array_diff( $wgRestrictionLevels, array( '' ) )
                        ),
                        'limit' => array (
-                               ApiBase :: PARAM_DFLT => 10,
-                               ApiBase :: PARAM_TYPE => 'limit',
-                               ApiBase :: PARAM_MIN => 1,
-                               ApiBase :: PARAM_MAX => ApiBase :: LIMIT_BIG1,
-                               ApiBase :: PARAM_MAX2 => ApiBase :: LIMIT_BIG2
+                               ApiBase::PARAM_DFLT => 10,
+                               ApiBase::PARAM_TYPE => 'limit',
+                               ApiBase::PARAM_MIN => 1,
+                               ApiBase::PARAM_MAX => ApiBase::LIMIT_BIG1,
+                               ApiBase::PARAM_MAX2 => ApiBase::LIMIT_BIG2
                        ),
-                       'dir' => array (
-                               ApiBase :: PARAM_DFLT => 'older',
-                               ApiBase :: PARAM_TYPE => array (
+                       'dir' => array(
+                               ApiBase::PARAM_DFLT => 'older',
+                               ApiBase::PARAM_TYPE => array(
                                        'older',
                                        'newer'
                                )
                        ),
                        'start' => array(
-                               ApiBase :: PARAM_TYPE => 'timestamp'
+                               ApiBase::PARAM_TYPE => 'timestamp'
                        ),
                        'end' => array(
-                               ApiBase :: PARAM_TYPE => 'timestamp'
+                               ApiBase::PARAM_TYPE => 'timestamp'
                        ),
                        'prop' => array(
-                               ApiBase :: PARAM_ISMULTI => true,
-                               ApiBase :: PARAM_DFLT => 'timestamp|level',
-                               ApiBase :: PARAM_TYPE => array(
+                               ApiBase::PARAM_ISMULTI => true,
+                               ApiBase::PARAM_DFLT => 'timestamp|level',
+                               ApiBase::PARAM_TYPE => array(
                                        'timestamp',
                                        'user',
                                        'comment',
@@ -173,7 +178,7 @@ class ApiQueryProtectedTitles extends ApiQueryGeneratorBase {
        }
 
        public function getParamDescription() {
-               return array (
+               return array(
                        'namespace' => 'Only list titles in these namespaces',
                        'start' => 'Start listing at this protection timestamp',
                        'end' => 'Stop listing at this protection timestamp',
@@ -189,7 +194,7 @@ class ApiQueryProtectedTitles extends ApiQueryGeneratorBase {
        }
 
        protected function getExamples() {
-               return array (
+               return array(
                        'api.php?action=query&list=protectedtitles',
                );
        }
index 5bf9cbb..3135e54 100644 (file)
@@ -1,11 +1,11 @@
 <?php
 
-/*
+/**
  * Created on Monday, January 28, 2008
  *
  * API for MediaWiki 1.8+
  *
- * Copyright (C) 2008 Brent Garber
+ * Copyright © 2008 Brent Garber
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -25,7 +25,7 @@
 
 if ( !defined( 'MEDIAWIKI' ) ) {
        // Eclipse helper - will be ignored in production
-       require_once ( 'ApiQueryBase.php' );
+       require_once( 'ApiQueryBase.php' );
 }
 
 /**
@@ -37,7 +37,7 @@ if ( !defined( 'MEDIAWIKI' ) ) {
  class ApiQueryRandom extends ApiQueryGeneratorBase {
 
        public function __construct( $query, $moduleName ) {
-               parent :: __construct( $query, $moduleName, 'rn' );
+               parent::__construct( $query, $moduleName, 'rn' );
        }
 
        public function execute() {
@@ -56,10 +56,11 @@ if ( !defined( 'MEDIAWIKI' ) ) {
                $this->addWhereRange( 'page_random', 'newer', $randstr, null );
                $this->addWhereFld( 'page_is_redirect', $redirect );
                $this->addOption( 'USE INDEX', 'page_random' );
-               if ( is_null( $resultPageSet ) )
+               if ( is_null( $resultPageSet ) ) {
                        $this->addFields( array( 'page_id', 'page_title', 'page_namespace' ) );
-               else
+               } else {
                        $this->addFields( $resultPageSet->getPageTableFields() );
+               }
        }
 
        protected function runQuery( &$resultPageSet ) {
@@ -68,24 +69,23 @@ if ( !defined( 'MEDIAWIKI' ) ) {
                $count = 0;
                while ( $row = $db->fetchObject( $res ) ) {
                        $count++;
-                       if ( is_null( $resultPageSet ) )
-                       {
+                       if ( is_null( $resultPageSet ) ) {
                                // Prevent duplicates
-                               if ( !in_array( $row->page_id, $this->pageIDs ) )
-                               {
+                               if ( !in_array( $row->page_id, $this->pageIDs ) ) {
                                        $fit = $this->getResult()->addValue(
                                                        array( 'query', $this->getModuleName() ),
                                                        null, $this->extractRowInfo( $row ) );
-                                       if ( !$fit )
+                                       if ( !$fit ) {
                                                // We can't really query-continue a random list.
                                                // Return an insanely high value so
                                                // $count < $limit is false
                                                return 1E9;
+                                       }
                                        $this->pageIDs[] = $row->page_id;
                                }
-                       }
-                       else
+                       } else {
                                $resultPageSet->processDbRow( $row );
+                       }
                }
                $db->freeResult( $res );
                return $count;
@@ -95,17 +95,16 @@ if ( !defined( 'MEDIAWIKI' ) ) {
                $params = $this->extractRequestParams();
                $result = $this->getResult();
                $this->pageIDs = array();
-               
+
                $this->prepareQuery( wfRandom(), $params['limit'], $params['namespace'], $resultPageSet, $params['redirect'] );
                $count = $this->runQuery( $resultPageSet );
-               if ( $count < $params['limit'] )
-               {
+               if ( $count < $params['limit'] ) {
                        /* We got too few pages, we probably picked a high value
                         * for page_random. We'll just take the lowest ones, see
                         * also the comment in Title::getRandomTitle()
                         */
-                        $this->prepareQuery( 0, $params['limit'] - $count, $params['namespace'], $resultPageSet, $params['redirect'] );
-                        $this->runQuery( $resultPageSet );
+                       $this->prepareQuery( 0, $params['limit'] - $count, $params['namespace'], $resultPageSet, $params['redirect'] );
+                       $this->runQuery( $resultPageSet );
                }
 
                if ( is_null( $resultPageSet ) ) {
@@ -122,24 +121,24 @@ if ( !defined( 'MEDIAWIKI' ) ) {
        }
 
        public function getAllowedParams() {
-               return array (
+               return array(
                        'namespace' => array(
-                               ApiBase :: PARAM_TYPE => 'namespace',
-                               ApiBase :: PARAM_ISMULTI => true
+                               ApiBase::PARAM_TYPE => 'namespace',
+                               ApiBase::PARAM_ISMULTI => true
                        ),
-                       'limit' => array (
-                               ApiBase :: PARAM_TYPE => 'limit',
-                               ApiBase :: PARAM_DFLT => 1,
-                               ApiBase :: PARAM_MIN => 1,
-                               ApiBase :: PARAM_MAX => 10,
-                               ApiBase :: PARAM_MAX2 => 20
+                       'limit' => array(
+                               ApiBase::PARAM_TYPE => 'limit',
+                               ApiBase::PARAM_DFLT => 1,
+                               ApiBase::PARAM_MIN => 1,
+                               ApiBase::PARAM_MAX => 10,
+                               ApiBase::PARAM_MAX2 => 20
                        ),
                        'redirect' => false,
                );
        }
 
        public function getParamDescription() {
-               return array (
+               return array(
                        'namespace' => 'Return pages in these namespaces only',
                        'limit' => 'Limit how many random pages will be returned',
                        'redirect' => 'Load a random redirect instead of a random page'
@@ -147,10 +146,11 @@ if ( !defined( 'MEDIAWIKI' ) ) {
        }
 
        public function getDescription() {
-               return array(   'Get a set of random pages',
-                               'NOTE: Pages are listed in a fixed sequence, only the starting point is random. This means that if, for example, "Main Page" is the first ',
-                               '      random page on your list, "List of fictional monkeys" will *always* be second, "List of people on stamps of Vanuatu" third, etc.',
-                               'NOTE: If the number of pages in the namespace is lower than rnlimit, you will get fewer pages. You will not get the same page twice.'
+               return array(
+                       'Get a set of random pages',
+                       'NOTE: Pages are listed in a fixed sequence, only the starting point is random. This means that if, for example, "Main Page" is the first ',
+                       '      random page on your list, "List of fictional monkeys" will *always* be second, "List of people on stamps of Vanuatu" third, etc.',
+                       'NOTE: If the number of pages in the namespace is lower than rnlimit, you will get fewer pages. You will not get the same page twice.'
                );
        }
 
index e74e2f6..1955e4a 100644 (file)
@@ -1,11 +1,11 @@
 <?php
 
-/*
+/**
  * Created on Oct 19, 2006
  *
  * API for MediaWiki 1.8+
  *
- * Copyright (C) 2006 Yuri Astrakhan <Firstname><Lastname>@gmail.com
+ * Copyright © 2006 Yuri Astrakhan <Firstname><Lastname>@gmail.com
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -25,7 +25,7 @@
 
 if ( !defined( 'MEDIAWIKI' ) ) {
        // Eclipse helper - will be ignored in production
-       require_once ( 'ApiQueryBase.php' );
+       require_once( 'ApiQueryBase.php' );
 }
 
 /**
@@ -37,7 +37,7 @@ if ( !defined( 'MEDIAWIKI' ) ) {
 class ApiQueryRecentChanges extends ApiQueryBase {
 
        public function __construct( $query, $moduleName ) {
-               parent :: __construct( $query, $moduleName, 'rc' );
+               parent::__construct( $query, $moduleName, 'rc' );
        }
 
        private $fld_comment = false, $fld_parsedcomment = false, $fld_user = false, $fld_flags = false,
@@ -51,12 +51,14 @@ class ApiQueryRecentChanges extends ApiQueryBase {
         */
        protected function getTokenFunctions() {
                // Don't call the hooks twice
-               if ( isset( $this->tokenFunctions ) )
+               if ( isset( $this->tokenFunctions ) ) {
                        return $this->tokenFunctions;
+               }
 
                // If we're in JSON callback mode, no tokens can be obtained
-               if ( !is_null( $this->getMain()->getRequest()->getVal( 'callback' ) ) )
+               if ( !is_null( $this->getMain()->getRequest()->getVal( 'callback' ) ) ) {
                        return array();
+               }
 
                $this->tokenFunctions = array(
                        'patrol' => array( 'ApiQueryRecentChanges', 'getPatrolToken' )
@@ -64,18 +66,20 @@ class ApiQueryRecentChanges extends ApiQueryBase {
                wfRunHooks( 'APIQueryRecentChangesTokens', array( &$this->tokenFunctions ) );
                return $this->tokenFunctions;
        }
-       
-       public static function getPatrolToken( $pageid, $title, $rc )
-       {
+
+       public static function getPatrolToken( $pageid, $title, $rc ) {
                global $wgUser;
                if ( !$wgUser->useRCPatrol() && ( !$wgUser->useNPPatrol() ||
-                                $rc->getAttribute( 'rc_type' ) != RC_NEW ) )
+                               $rc->getAttribute( 'rc_type' ) != RC_NEW ) )
+               {
                        return false;
-               
+               }
+
                // The patrol token is always the same, let's exploit that
                static $cachedPatrolToken = null;
-               if ( !is_null( $cachedPatrolToken ) )
+               if ( !is_null( $cachedPatrolToken ) ) {
                        return $cachedPatrolToken;
+               }
 
                $cachedPatrolToken = $wgUser->editToken();
                return $cachedPatrolToken;
@@ -86,14 +90,14 @@ class ApiQueryRecentChanges extends ApiQueryBase {
         * @param $prop associative array of properties, only keys are used here
         */
        public function initProperties( $prop ) {
-               $this->fld_comment = isset ( $prop['comment'] );
-               $this->fld_parsedcomment = isset ( $prop['parsedcomment'] );
-               $this->fld_user = isset ( $prop['user'] );
-               $this->fld_flags = isset ( $prop['flags'] );
-               $this->fld_timestamp = isset ( $prop['timestamp'] );
-               $this->fld_title = isset ( $prop['title'] );
-               $this->fld_ids = isset ( $prop['ids'] );
-               $this->fld_sizes = isset ( $prop['sizes'] );
+               $this->fld_comment = isset( $prop['comment'] );
+               $this->fld_parsedcomment = isset( $prop['parsedcomment'] );
+               $this->fld_user = isset( $prop['user'] );
+               $this->fld_flags = isset( $prop['flags'] );
+               $this->fld_timestamp = isset( $prop['timestamp'] );
+               $this->fld_title = isset( $prop['title'] );
+               $this->fld_ids = isset( $prop['ids'] );
+               $this->fld_sizes = isset( $prop['sizes'] );
                $this->fld_redirect = isset( $prop['redirect'] );
                $this->fld_patrolled = isset( $prop['patrolled'] );
                $this->fld_loginfo = isset( $prop['loginfo'] );
@@ -119,59 +123,64 @@ class ApiQueryRecentChanges extends ApiQueryBase {
                $this->addWhereFld( 'rc_namespace', $params['namespace'] );
                $this->addWhereFld( 'rc_deleted', 0 );
 
-               if ( !is_null( $params['type'] ) )
-                               $this->addWhereFld( 'rc_type', $this->parseRCType( $params['type'] ) );
+               if ( !is_null( $params['type'] ) ) {
+                       $this->addWhereFld( 'rc_type', $this->parseRCType( $params['type'] ) );
+               }
 
                if ( !is_null( $params['show'] ) ) {
                        $show = array_flip( $params['show'] );
 
                        /* 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'] ) ) ) {
-
+                       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'] ) )
+                       )
+                       {
                                $this->dieUsageMsg( array( 'show' ) );
                        }
-                       
+
                        // Check permissions
                        global $wgUser;
                        if ( ( isset( $show['patrolled'] ) || isset( $show['!patrolled'] ) ) && !$wgUser->useRCPatrol() && !$wgUser->useNPPatrol() )
-                               $this->dieUsage( "You need the patrol right to request the patrolled flag", 'permissiondenied' );
+                       {
+                               $this->dieUsage( 'You need the patrol right to request the patrolled flag', 'permissiondenied' );
+                       }
 
                        /* Add additional conditions to query depending upon parameters. */
-                       $this->addWhereIf( 'rc_minor = 0', isset ( $show['!minor'] ) );
-                       $this->addWhereIf( 'rc_minor != 0', isset ( $show['minor'] ) );
-                       $this->addWhereIf( 'rc_bot = 0', isset ( $show['!bot'] ) );
-                       $this->addWhereIf( 'rc_bot != 0', isset ( $show['bot'] ) );
-                       $this->addWhereIf( 'rc_user = 0', isset ( $show['anon'] ) );
-                       $this->addWhereIf( 'rc_user != 0', isset ( $show['!anon'] ) );
+                       $this->addWhereIf( 'rc_minor = 0', isset( $show['!minor'] ) );
+                       $this->addWhereIf( 'rc_minor != 0', isset( $show['minor'] ) );
+                       $this->addWhereIf( 'rc_bot = 0', isset( $show['!bot'] ) );
+                       $this->addWhereIf( 'rc_bot != 0', isset( $show['bot'] ) );
+                       $this->addWhereIf( 'rc_user = 0', isset( $show['anon'] ) );
+                       $this->addWhereIf( 'rc_user != 0', isset( $show['!anon'] ) );
                        $this->addWhereIf( 'rc_patrolled = 0', isset( $show['!patrolled'] ) );
                        $this->addWhereIf( 'rc_patrolled != 0', isset( $show['patrolled'] ) );
-                       $this->addWhereIf( 'page_is_redirect = 1', isset ( $show['redirect'] ) );
-                       
+                       $this->addWhereIf( 'page_is_redirect = 1', isset( $show['redirect'] ) );
+
                        // Don't throw log entries out the window here
-                       $this->addWhereIf( 'page_is_redirect = 0 OR page_is_redirect IS NULL', isset ( $show['!redirect'] ) );
+                       $this->addWhereIf( 'page_is_redirect = 0 OR page_is_redirect IS NULL', isset( $show['!redirect'] ) );
                }
-               
-               if ( !is_null( $params['user'] ) && !is_null( $param['excludeuser'] ) )
+
+               if ( !is_null( $params['user'] ) && !is_null( $param['excludeuser'] ) ) {
                        $this->dieUsage( 'user and excludeuser cannot be used together', 'user-excludeuser' );
-                       
-               if ( !is_null( $params['user'] ) )
-               {
+               }
+
+               if ( !is_null( $params['user'] ) ) {
                        $this->addWhereFld( 'rc_user_text', $params['user'] );
                        $index['recentchanges'] = 'rc_user_text';
                }
-               
-               if ( !is_null( $params['excludeuser'] ) )
+
+               if ( !is_null( $params['excludeuser'] ) ) {
                        // We don't use the rc_user_text index here because
                        // * it would require us to sort by rc_user_text before rc_timestamp
                        // * the != condition doesn't throw out too many rows anyway
                        $this->addWhere( 'rc_user_text != ' . $this->getDB()->addQuotes( $params['excludeuser'] ) );
+               }
 
                /* Add the fields we're concerned with to our query. */
-               $this->addFields( array (
+               $this->addFields( array(
                        'rc_timestamp',
                        'rc_namespace',
                        'rc_title',
@@ -190,7 +199,9 @@ class ApiQueryRecentChanges extends ApiQueryBase {
 
                        global $wgUser;
                        if ( $this->fld_patrolled && !$wgUser->useRCPatrol() && !$wgUser->useNPPatrol() )
-                               $this->dieUsage( "You need the patrol right to request the patrolled flag", 'permissiondenied' );
+                       {
+                               $this->dieUsage( 'You need the patrol right to request the patrolled flag', 'permissiondenied' );
+                       }
 
                        /* Add fields to our query if they are specified as a needed parameter. */
                        $this->addFieldsIf( 'rc_id', $this->fld_ids );
@@ -216,21 +227,21 @@ class ApiQueryRecentChanges extends ApiQueryBase {
                                $this->addFields( 'page_is_redirect' );
                        }
                }
-               
+
                if ( $this->fld_tags ) {
                        $this->addTables( 'tag_summary' );
                        $this->addJoinConds( array( 'tag_summary' => array( 'LEFT JOIN', array( 'rc_id=ts_rc_id' ) ) ) );
                        $this->addFields( 'ts_tags' );
                }
-                       
+
                if ( !is_null( $params['tag'] ) ) {
                        $this->addTables( 'change_tag' );
                        $this->addJoinConds( array( 'change_tag' => array( 'INNER JOIN', array( 'rc_id=ct_rc_id' ) ) ) );
                        $this->addWhereFld( 'ct_tag' , $params['tag'] );
                        global $wgOldChangeTagsIndex;
-                       $index['change_tag'] = $wgOldChangeTagsIndex ?  'ct_tag' : 'change_tag_tag_id';
+                       $index['change_tag'] = $wgOldChangeTagsIndex ? 'ct_tag' : 'change_tag_tag_id';
                }
-               
+
                $this->token = $params['token'];
                $this->addOption( 'LIMIT', $params['limit'] + 1 );
                $this->addOption( 'USE INDEX', $index );
@@ -252,11 +263,11 @@ class ApiQueryRecentChanges extends ApiQueryBase {
                        $vals = $this->extractRowInfo( $row );
 
                        /* Add that row's data to our final output. */
-                       if ( !$vals )
+                       if ( !$vals ) {
                                continue;
+                       }
                        $fit = $this->getResult()->addValue( array( 'query', $this->getModuleName() ), null, $vals );
-                       if ( !$fit )
-                       {
+                       if ( !$fit ) {
                                $this->setContinueEnumParameter( 'start', wfTimestamp( TS_ISO_8601, $row->rc_timestamp ) );
                                break;
                        }
@@ -279,15 +290,17 @@ class ApiQueryRecentChanges extends ApiQueryBase {
                /* If page was moved somewhere, get the title of the move target. */
                $movedToTitle = false;
                if ( isset( $row->rc_moved_to_title ) && $row->rc_moved_to_title !== '' )
-                       $movedToTitle = Title :: makeTitle( $row->rc_moved_to_ns, $row->rc_moved_to_title );
+               {
+                       $movedToTitle = Title::makeTitle( $row->rc_moved_to_ns, $row->rc_moved_to_title );
+               }
 
                /* Determine the title of the page that has been changed. */
-               $title = Title :: makeTitle( $row->rc_namespace, $row->rc_title );
+               $title = Title::makeTitle( $row->rc_namespace, $row->rc_title );
 
                /* Our output data. */
-               $vals = array ();
+               $vals = array();
 
-               $type = intval ( $row->rc_type );
+               $type = intval( $row->rc_type );
 
                /* Determine what kind of change this was. */
                switch ( $type ) {
@@ -312,9 +325,10 @@ class ApiQueryRecentChanges extends ApiQueryBase {
 
                /* Create a new entry in the result for the title. */
                if ( $this->fld_title ) {
-                       ApiQueryBase :: addTitleInfo( $vals, $title );
-                       if ( $movedToTitle )
-                               ApiQueryBase :: addTitleInfo( $vals, $movedToTitle, "new_" );
+                       ApiQueryBase::addTitleInfo( $vals, $title );
+                       if ( $movedToTitle ) {
+                               ApiQueryBase::addTitleInfo( $vals, $movedToTitle, 'new_' );
+                       }
                }
 
                /* Add ids, such as rcid, pageid, revid, and oldid to the change's info. */
@@ -328,18 +342,22 @@ class ApiQueryRecentChanges extends ApiQueryBase {
                /* Add user data and 'anon' flag, if use is anonymous. */
                if ( $this->fld_user ) {
                        $vals['user'] = $row->rc_user_text;
-                       if ( !$row->rc_user )
+                       if ( !$row->rc_user ) {
                                $vals['anon'] = '';
+                       }
                }
 
                /* Add flags, such as new, minor, bot. */
                if ( $this->fld_flags ) {
-                       if ( $row->rc_bot )
+                       if ( $row->rc_bot ) {
                                $vals['bot'] = '';
-                       if ( $row->rc_new )
+                       }
+                       if ( $row->rc_new ) {
                                $vals['new'] = '';
-                       if ( $row->rc_minor )
+                       }
+                       if ( $row->rc_minor ) {
                                $vals['minor'] = '';
+                       }
                }
 
                /* Add sizes of each revision. (Only available on 1.10+) */
@@ -349,35 +367,42 @@ class ApiQueryRecentChanges extends ApiQueryBase {
                }
 
                /* Add the timestamp. */
-               if ( $this->fld_timestamp )
+               if ( $this->fld_timestamp ) {
                        $vals['timestamp'] = wfTimestamp( TS_ISO_8601, $row->rc_timestamp );
+               }
 
                /* Add edit summary / log summary. */
-               if ( $this->fld_comment && isset( $row->rc_comment ) )
+               if ( $this->fld_comment && isset( $row->rc_comment ) ) {
                        $vals['comment'] = $row->rc_comment;
-               
+               }
+
                if ( $this->fld_parsedcomment && isset( $row->rc_comment ) ) {
                        global $wgUser;
                        $vals['parsedcomment'] = $wgUser->getSkin()->formatComment( $row->rc_comment, $title );
                }
 
-               if ( $this->fld_redirect )
-                       if ( $row->page_is_redirect )
+               if ( $this->fld_redirect ) {
+                       if ( $row->page_is_redirect ) {
                                $vals['redirect'] = '';
+                       }
+               }
 
                /* Add the patrolled flag */
-               if ( $this->fld_patrolled && $row->rc_patrolled == 1 )
+               if ( $this->fld_patrolled && $row->rc_patrolled == 1 ) {
                        $vals['patrolled'] = '';
-                       
+               }
+
                if ( $this->fld_loginfo && $row->rc_type == RC_LOG ) {
                        $vals['logid'] = intval( $row->rc_logid );
                        $vals['logtype'] = $row->rc_log_type;
                        $vals['logaction'] = $row->rc_log_action;
-                       ApiQueryLogEvents::addLogParams( $this->getResult(),
+                       ApiQueryLogEvents::addLogParams(
+                               $this->getResult(),
                                $vals, $row->rc_params,
-                               $row->rc_log_type, $row->rc_timestamp );
+                               $row->rc_log_type, $row->rc_timestamp
+                       );
                }
-               
+
                if ( $this->fld_tags ) {
                        if ( $row->ts_tags ) {
                                $tags = explode( ',', $row->ts_tags );
@@ -387,71 +412,71 @@ class ApiQueryRecentChanges extends ApiQueryBase {
                                $vals['tags'] = array();
                        }
                }
-                       
-               if ( !is_null( $this->token ) )
-               {
+
+               if ( !is_null( $this->token ) ) {
                        $tokenFunctions = $this->getTokenFunctions();
-                       foreach ( $this->token as $t )
-                       {
+                       foreach ( $this->token as $t ) {
                                $val = call_user_func( $tokenFunctions[$t], $row->rc_cur_id,
                                        $title, RecentChange::newFromRow( $row ) );
-                               if ( $val === false )
+                               if ( $val === false ) {
                                        $this->setWarning( "Action '$t' is not allowed for the current user" );
-                               else
+                               } else {
                                        $vals[$t . 'token'] = $val;
+                               }
                        }
                }
 
                return $vals;
        }
 
-       private function parseRCType( $type )
-       {
-                       if ( is_array( $type ) )
-                       {
-                                       $retval = array();
-                                       foreach ( $type as $t )
-                                                       $retval[] = $this->parseRCType( $t );
-                                       return $retval;
-                       }
-                       switch( $type )
-                       {
-                                       case 'edit': return RC_EDIT;
-                                       case 'new': return RC_NEW;
-                                       case 'log': return RC_LOG;
+       private function parseRCType( $type ) {
+               if ( is_array( $type ) ) {
+                       $retval = array();
+                       foreach ( $type as $t ) {
+                               $retval[] = $this->parseRCType( $t );
                        }
+                       return $retval;
+               }
+               switch( $type ) {
+                       case 'edit':
+                               return RC_EDIT;
+                       case 'new':
+                               return RC_NEW;
+                       case 'log':
+                               return RC_LOG;
+               }
        }
 
        public function getAllowedParams() {
-               return array (
-                       'start' => array (
-                               ApiBase :: PARAM_TYPE => 'timestamp'
+               return array(
+                       'start' => array(
+                               ApiBase::PARAM_TYPE => 'timestamp'
                        ),
-                       'end' => array (
-                               ApiBase :: PARAM_TYPE => 'timestamp'
+                       'end' => array(
+                               ApiBase::PARAM_TYPE => 'timestamp'
                        ),
-                       'dir' => array (
-                               ApiBase :: PARAM_DFLT => 'older',
-                               ApiBase :: PARAM_TYPE => array (
+                       'dir' => array(
+                               ApiBase::PARAM_DFLT => 'older',
+                               ApiBase::PARAM_TYPE => array(
                                        'newer',
                                        'older'
                                )
                        ),
-                       'namespace' => array (
-                               ApiBase :: PARAM_ISMULTI => true,
-                               ApiBase :: PARAM_TYPE => 'namespace'
+                       'namespace' => array(
+                               ApiBase::PARAM_ISMULTI => true,
+                               ApiBase::PARAM_TYPE => 'namespace'
                        ),
                        'user' => array(
-                               ApiBase :: PARAM_TYPE => 'user'
+                               ApiBase::PARAM_TYPE => 'user'
                        ),
                        'excludeuser' => array(
-                               ApiBase :: PARAM_TYPE => 'user'
+                               ApiBase::PARAM_TYPE => 'user'
                        ),
                        'tag' => null,
-                       'prop' => array (
-                               ApiBase :: PARAM_ISMULTI => true,
-                               ApiBase :: PARAM_DFLT => 'title|timestamp|ids',
-                               ApiBase :: PARAM_TYPE => array (
+                       'prop' => array(
+                               ApiBase::PARAM_ISMULTI => true,
+                               ApiBase::PARAM_DFLT => 'title|timestamp|ids',
+                               ApiBase::PARAM_TYPE => array(
                                        'user',
                                        'comment',
                                        'parsedcomment',
@@ -467,12 +492,12 @@ class ApiQueryRecentChanges extends ApiQueryBase {
                                )
                        ),
                        'token' => array(
-                               ApiBase :: PARAM_TYPE => array_keys( $this->getTokenFunctions() ),
-                               ApiBase :: PARAM_ISMULTI => true
+                               ApiBase::PARAM_TYPE => array_keys( $this->getTokenFunctions() ),
+                               ApiBase::PARAM_ISMULTI => true
                        ),
-                       'show' => array (
-                               ApiBase :: PARAM_ISMULTI => true,
-                               ApiBase :: PARAM_TYPE => array (
+                       'show' => array(
+                               ApiBase::PARAM_ISMULTI => true,
+                               ApiBase::PARAM_TYPE => array(
                                        'minor',
                                        '!minor',
                                        'bot',
@@ -485,16 +510,16 @@ class ApiQueryRecentChanges extends ApiQueryBase {
                                        '!patrolled'
                                )
                        ),
-                       'limit' => array (
-                               ApiBase :: PARAM_DFLT => 10,
-                               ApiBase :: PARAM_TYPE => 'limit',
-                               ApiBase :: PARAM_MIN => 1,
-                               ApiBase :: PARAM_MAX => ApiBase :: LIMIT_BIG1,
-                               ApiBase :: PARAM_MAX2 => ApiBase :: LIMIT_BIG2
+                       'limit' => array(
+                               ApiBase::PARAM_DFLT => 10,
+                               ApiBase::PARAM_TYPE => 'limit',
+                               ApiBase::PARAM_MIN => 1,
+                               ApiBase::PARAM_MAX => ApiBase::LIMIT_BIG1,
+                               ApiBase::PARAM_MAX2 => ApiBase::LIMIT_BIG2
                        ),
-                       'type' => array (
-                               ApiBase :: PARAM_ISMULTI => true,
-                               ApiBase :: PARAM_TYPE => array (
+                       'type' => array(
+                               ApiBase::PARAM_ISMULTI => true,
+                               ApiBase::PARAM_TYPE => array(
                                        'edit',
                                        'new',
                                        'log'
@@ -504,7 +529,7 @@ class ApiQueryRecentChanges extends ApiQueryBase {
        }
 
        public function getParamDescription() {
-               return array (
+               return array(
                        'start' => 'The timestamp to start enumerating from.',
                        'end' => 'The timestamp to end enumerating.',
                        'dir' => 'In which direction to enumerate.',
@@ -513,7 +538,7 @@ class ApiQueryRecentChanges extends ApiQueryBase {
                        'excludeuser' => 'Don\'t list changes by this user',
                        'prop' => 'Include additional pieces of information',
                        'token' => 'Which tokens to obtain for each change',
-                       'show' => array (
+                       'show' => array(
                                'Show only items that meet this criteria.',
                                'For example, to see only minor edits done by logged-in users, set show=minor|!anon'
                        ),
@@ -526,7 +551,7 @@ class ApiQueryRecentChanges extends ApiQueryBase {
        public function getDescription() {
                return 'Enumerate recent changes';
        }
-       
+
        public function getPossibleErrors() {
                return array_merge( parent::getPossibleErrors(), array(
                        array( 'show' ),
@@ -536,7 +561,7 @@ class ApiQueryRecentChanges extends ApiQueryBase {
        }
 
        protected function getExamples() {
-               return array (
+               return array(
                        'api.php?action=query&list=recentchanges'
                );
        }
index e8e33df..0f0becc 100644 (file)
@@ -1,11 +1,11 @@
 <?php
 
-/*
+/**
  * Created on Sep 7, 2006
  *
  * API for MediaWiki 1.8+
  *
- * Copyright (C) 2006 Yuri Astrakhan <Firstname><Lastname>@gmail.com
+ * Copyright © 2006 Yuri Astrakhan <Firstname><Lastname>@gmail.com
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -25,7 +25,7 @@
 
 if ( !defined( 'MEDIAWIKI' ) ) {
        // Eclipse helper - will be ignored in production
-       require_once ( 'ApiQueryBase.php' );
+       require_once( 'ApiQueryBase.php' );
 }
 
 /**
@@ -38,7 +38,7 @@ if ( !defined( 'MEDIAWIKI' ) ) {
 class ApiQueryRevisions extends ApiQueryBase {
 
        public function __construct( $query, $moduleName ) {
-               parent :: __construct( $query, $moduleName, 'rv' );
+               parent::__construct( $query, $moduleName, 'rv' );
        }
 
        private $fld_ids = false, $fld_flags = false, $fld_timestamp = false, $fld_size = false,
@@ -50,12 +50,14 @@ class ApiQueryRevisions extends ApiQueryBase {
                // should return token or false
 
                // Don't call the hooks twice
-               if ( isset( $this->tokenFunctions ) )
+               if ( isset( $this->tokenFunctions ) ) {
                        return $this->tokenFunctions;
+               }
 
                // If we're in JSON callback mode, no tokens can be obtained
-               if ( !is_null( $this->getMain()->getRequest()->getVal( 'callback' ) ) )
+               if ( !is_null( $this->getMain()->getRequest()->getVal( 'callback' ) ) ) {
                        return array();
+               }
 
                $this->tokenFunctions = array(
                        'rollback' => array( 'ApiQueryRevisions', 'getRollbackToken' )
@@ -64,11 +66,11 @@ class ApiQueryRevisions extends ApiQueryBase {
                return $this->tokenFunctions;
        }
 
-       public static function getRollbackToken( $pageid, $title, $rev )
-       {
+       public static function getRollbackToken( $pageid, $title, $rev ) {
                global $wgUser;
-               if ( !$wgUser->isAllowed( 'rollback' ) )
+               if ( !$wgUser->isAllowed( 'rollback' ) ) {
                        return false;
+               }
                return $wgUser->editToken( array( $title->getPrefixedText(),
                                                $rev->getUserText() ) );
        }
@@ -91,31 +93,38 @@ class ApiQueryRevisions extends ApiQueryBase {
                $revCount = $pageSet->getRevisionCount();
 
                // Optimization -- nothing to do
-               if ( $revCount === 0 && $pageCount === 0 )
+               if ( $revCount === 0 && $pageCount === 0 ) {
                        return;
+               }
 
-               if ( $revCount > 0 && $enumRevMode )
+               if ( $revCount > 0 && $enumRevMode ) {
                        $this->dieUsage( 'The revids= parameter may not be used with the list options (limit, startid, endid, dirNewer, start, end).', 'revids' );
+               }
 
-               if ( $pageCount > 1 && $enumRevMode )
+               if ( $pageCount > 1 && $enumRevMode ) {
                        $this->dieUsage( 'titles, pageids or a generator was used to supply multiple pages, but the limit, startid, endid, dirNewer, user, excludeuser, start and end parameters may only be used on a single page.', 'multpages' );
+               }
 
                $this->diffto = $this->difftotext = null;
                if ( !is_null( $params['difftotext'] ) ) {
                        $this->difftotext = $params['difftotext'];
-               } else if ( !is_null( $params['diffto'] ) ) {
-                       if ( $params['diffto'] == 'cur' )
+               } elseif ( !is_null( $params['diffto'] ) ) {
+                       if ( $params['diffto'] == 'cur' ) {
                                $params['diffto'] = 0;
+                       }
                        if ( ( !ctype_digit( $params['diffto'] ) || $params['diffto'] < 0 )
                                        && $params['diffto'] != 'prev' && $params['diffto'] != 'next' )
+                       {
                                $this->dieUsage( 'rvdiffto must be set to a non-negative number, "prev", "next" or "cur"', 'diffto' );
+                       }
                        // Check whether the revision exists and is readable,
                        // DifferenceEngine returns a rather ambiguous empty
                        // string if that's not the case
                        if ( $params['diffto'] != 0 ) {
                                $difftoRev = Revision::newFromID( $params['diffto'] );
-                               if ( !$difftoRev )
+                               if ( !$difftoRev ) {
                                        $this->dieUsageMsg( array( 'nosuchrevid', $params['diffto'] ) );
+                               }
                                if ( !$difftoRev->userCan( Revision::DELETED_TEXT ) ) {
                                        $this->setWarning( "Couldn't diff to r{$difftoRev->getID()}: content is hidden" );
                                        $params['diffto'] = null;
@@ -149,29 +158,29 @@ class ApiQueryRevisions extends ApiQueryBase {
                        $this->addFields( Revision::selectPageFields() );
                }
 
-               if ( isset ( $prop['tags'] ) ) {
+               if ( isset( $prop['tags'] ) ) {
                        $this->fld_tags = true;
                        $this->addTables( 'tag_summary' );
                        $this->addJoinConds( array( 'tag_summary' => array( 'LEFT JOIN', array( 'rev_id=ts_rev_id' ) ) ) );
                        $this->addFields( 'ts_tags' );
                }
-               
+
                if ( !is_null( $params['tag'] ) ) {
                        $this->addTables( 'change_tag' );
                        $this->addJoinConds( array( 'change_tag' => array( 'INNER JOIN', array( 'rev_id=ct_rev_id' ) ) ) );
                        $this->addWhereFld( 'ct_tag' , $params['tag'] );
                        global $wgOldChangeTagsIndex;
-                       $index['change_tag'] = $wgOldChangeTagsIndex ?  'ct_tag' : 'change_tag_tag_id';
+                       $index['change_tag'] = $wgOldChangeTagsIndex ? 'ct_tag' : 'change_tag_tag_id';
                }
-               
-               if ( isset( $prop['content'] ) || !is_null( $this->difftotext ) ) {
 
+               if ( isset( $prop['content'] ) || !is_null( $this->difftotext ) ) {
                        // For each page we will request, the user must have read rights for that page
                        foreach ( $pageSet->getGoodTitles() as $title ) {
-                               if ( !$title->userCanRead() )
+                               if ( !$title->userCanRead() ) {
                                        $this->dieUsage(
                                                'The current user is not allowed to read ' . $title->getPrefixedText(),
                                                'accessdenied' );
+                               }
                        }
 
                        $this->addTables( 'text' );
@@ -183,10 +192,11 @@ class ApiQueryRevisions extends ApiQueryBase {
 
                        $this->expandTemplates = $params['expandtemplates'];
                        $this->generateXML = $params['generatexml'];
-                       if ( isset( $params['section'] ) )
+                       if ( isset( $params['section'] ) ) {
                                $this->section = $params['section'];
-                       else
+                       } else {
                                $this->section = false;
+                       }
                }
 
                $userMax = ( $this->fld_content ? ApiBase::LIMIT_SML1 : ApiBase::LIMIT_BIG1 );
@@ -198,16 +208,20 @@ class ApiQueryRevisions extends ApiQueryBase {
                }
 
                if ( $enumRevMode ) {
-
                        // This is mostly to prevent parameter errors (and optimize SQL?)
                        if ( !is_null( $params['startid'] ) && !is_null( $params['start'] ) )
+                       {
                                $this->dieUsage( 'start and startid cannot be used together', 'badparams' );
+                       }
 
-                       if ( !is_null( $params['endid'] ) && !is_null( $params['end'] ) )
+                       if ( !is_null( $params['endid'] ) && !is_null( $params['end'] ) ) {
                                $this->dieUsage( 'end and endid cannot be used together', 'badparams' );
+                       }
 
                        if ( !is_null( $params['user'] ) && !is_null( $params['excludeuser'] ) )
+                       {
                                $this->dieUsage( 'user and excludeuser cannot be used together', 'badparams' );
+                       }
 
                        // This code makes an assumption that sorting by rev_id and rev_timestamp produces
                        // the same result. This way users may request revisions starting at a given time,
@@ -215,11 +229,10 @@ class ApiQueryRevisions extends ApiQueryBase {
                        // Switching to rev_id removes the potential problem of having more than
                        // one row with the same timestamp for the same page.
                        // The order needs to be the same as start parameter to avoid SQL filesort.
-
-                       if ( is_null( $params['startid'] ) && is_null( $params['endid'] ) )
+                       if ( is_null( $params['startid'] ) && is_null( $params['endid'] ) ) {
                                $this->addWhereRange( 'rev_timestamp', $params['dir'],
                                        $params['start'], $params['end'] );
-                       else {
+                       else {
                                $this->addWhereRange( 'rev_id', $params['dir'],
                                        $params['startid'], $params['endid'] );
                                // One of start and end can be set
@@ -229,8 +242,9 @@ class ApiQueryRevisions extends ApiQueryBase {
                        }
 
                        // must manually initialize unset limit
-                       if ( is_null( $limit ) )
+                       if ( is_null( $limit ) ) {
                                $limit = 10;
+                       }
                        $this->validateLimit( 'limit', $limit, 1, $userMax, $botMax );
 
                        // There is only one ID, use it
@@ -247,86 +261,90 @@ class ApiQueryRevisions extends ApiQueryBase {
                                // Paranoia: avoid brute force searches (bug 17342)
                                $this->addWhere( $db->bitAnd( 'rev_deleted', Revision::DELETED_USER ) . ' = 0' );
                        }
-               }
-               elseif ( $revCount > 0 ) {
+               } elseif ( $revCount > 0 ) {
                        $max = $this->getMain()->canApiHighLimits() ? $botMax : $userMax;
                        $revs = $pageSet->getRevisionIDs();
-                       if ( self::truncateArray( $revs, $max ) )
+                       if ( self::truncateArray( $revs, $max ) ) {
                                $this->setWarning( "Too many values supplied for parameter 'revids': the limit is $max" );
+                       }
 
                        // Get all revision IDs
                        $this->addWhereFld( 'rev_id', array_keys( $revs ) );
 
-                       if ( !is_null( $params['continue'] ) )
+                       if ( !is_null( $params['continue'] ) ) {
                                $this->addWhere( "rev_id >= '" . intval( $params['continue'] ) . "'" );
+                       }
                        $this->addOption( 'ORDER BY', 'rev_id' );
 
                        // assumption testing -- we should never get more then $revCount rows.
                        $limit = $revCount;
-               }
-               elseif ( $pageCount > 0 ) {
+               } elseif ( $pageCount > 0 ) {
                        $max = $this->getMain()->canApiHighLimits() ? $botMax : $userMax;
                        $titles = $pageSet->getGoodTitles();
-                       if ( self::truncateArray( $titles, $max ) )
+                       if ( self::truncateArray( $titles, $max ) ) {
                                $this->setWarning( "Too many values supplied for parameter 'titles': the limit is $max" );
-                       
+                       }
+
                        // When working in multi-page non-enumeration mode,
                        // limit to the latest revision only
                        $this->addWhere( 'page_id=rev_page' );
                        $this->addWhere( 'page_latest=rev_id' );
-                       
+
                        // Get all page IDs
                        $this->addWhereFld( 'page_id', array_keys( $titles ) );
                        // Every time someone relies on equality propagation, god kills a kitten :)
                        $this->addWhereFld( 'rev_page', array_keys( $titles ) );
-                       
-                       if ( !is_null( $params['continue'] ) )
-                       {
+
+                       if ( !is_null( $params['continue'] ) ) {
                                $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" );
+                               if ( count( $cont ) != 2 ) {
+                                       $this->dieUsage( 'Invalid continue param. You should pass the original ' .
+                                                       'value returned by the previous query', '_badcontinue' );
+                               }
                                $pageid = intval( $cont[0] );
                                $revid = intval( $cont[1] );
-                               $this->addWhere( "rev_page > '$pageid' OR " .
-                                               "(rev_page = '$pageid' AND " .
-                                               "rev_id >= '$revid')" );
+                               $this->addWhere(
+                                       "rev_page > '$pageid' OR " .
+                                       "(rev_page = '$pageid' AND " .
+                                       "rev_id >= '$revid')"
+                               );
                        }
                        $this->addOption( 'ORDER BY', 'rev_page, rev_id' );
 
                        // assumption testing -- we should never get more then $pageCount rows.
                        $limit = $pageCount;
-               } else
-                       ApiBase :: dieDebug( __METHOD__, 'param validation?' );
+               } else {
+                       ApiBase::dieDebug( __METHOD__, 'param validation?' );
+               }
 
                $this->addOption( 'LIMIT', $limit + 1 );
                $this->addOption( 'USE INDEX', $index );
 
-               $data = array ();
+               $data = array();
                $count = 0;
                $res = $this->select( __METHOD__ );
 
                while ( $row = $db->fetchObject( $res ) ) {
-
                        if ( ++ $count > $limit ) {
                                // We've reached the one extra which shows that there are additional pages to be had. Stop here...
-                               if ( !$enumRevMode )
-                                       ApiBase :: dieDebug( __METHOD__, 'Got more rows then expected' ); // bug report
+                               if ( !$enumRevMode ) {
+                                       ApiBase::dieDebug( __METHOD__, 'Got more rows then expected' ); // bug report
+                               }
                                $this->setContinueEnumParameter( 'startid', intval( $row->rev_id ) );
                                break;
                        }
-                       
+
                        //
                        $fit = $this->addPageSubItem( $row->rev_page, $this->extractRowInfo( $row ), 'rev' );
-                       if ( !$fit )
-                       {
-                               if ( $enumRevMode )
+                       if ( !$fit ) {
+                               if ( $enumRevMode ) {
                                        $this->setContinueEnumParameter( 'startid', intval( $row->rev_id ) );
-                               else if ( $revCount > 0 )
+                               } elseif ( $revCount > 0 ) {
                                        $this->setContinueEnumParameter( 'continue', intval( $row->rev_id ) );
-                               else
+                               } else {
                                        $this->setContinueEnumParameter( 'continue', intval( $row->rev_page ) .
                                                '|' . intval( $row->rev_id ) );
+                               }
                                break;
                        }
                }
@@ -336,25 +354,28 @@ class ApiQueryRevisions extends ApiQueryBase {
        private function extractRowInfo( $row ) {
                $revision = new Revision( $row );
                $title = $revision->getTitle();
-               $vals = array ();
+               $vals = array();
 
                if ( $this->fld_ids ) {
                        $vals['revid'] = intval( $revision->getId() );
-                       // $vals['oldid'] = intval($row->rev_text_id);  // todo: should this be exposed?
-                       if ( !is_null( $revision->getParentId() ) )
+                       // $vals['oldid'] = intval( $row->rev_text_id ); // todo: should this be exposed?
+                       if ( !is_null( $revision->getParentId() ) ) {
                                $vals['parentid'] = intval( $revision->getParentId() );
+                       }
                }
 
-               if ( $this->fld_flags && $revision->isMinor() )
+               if ( $this->fld_flags && $revision->isMinor() ) {
                        $vals['minor'] = '';
+               }
 
                if ( $this->fld_user ) {
                        if ( $revision->isDeleted( Revision::DELETED_USER ) ) {
                                $vals['userhidden'] = '';
                        } else {
                                $vals['user'] = $revision->getUserText();
-                               if ( !$revision->getUser() )
+                               if ( !$revision->getUser() ) {
                                        $vals['anon'] = '';
+                               }
                        }
                }
 
@@ -371,11 +392,11 @@ class ApiQueryRevisions extends ApiQueryBase {
                                $vals['commenthidden'] = '';
                        } else {
                                $comment = $revision->getComment();
-                               if ( strval( $comment ) !== '' )
-                               {
-                                       if ( $this->fld_comment )
+                               if ( strval( $comment ) !== '' ) {
+                                       if ( $this->fld_comment ) {
                                                $vals['comment'] = $comment;
-                                       
+                                       }
+
                                        if ( $this->fld_parsedcomment ) {
                                                global $wgUser;
                                                $vals['parsedcomment'] = $wgUser->getSkin()->formatComment( $comment, $title );
@@ -393,20 +414,19 @@ class ApiQueryRevisions extends ApiQueryBase {
                                $vals['tags'] = array();
                        }
                }
-               
-               if ( !is_null( $this->token ) )
-               {
+
+               if ( !is_null( $this->token ) ) {
                        $tokenFunctions = $this->getTokenFunctions();
-                       foreach ( $this->token as $t )
-                       {
+                       foreach ( $this->token as $t ) {
                                $val = call_user_func( $tokenFunctions[$t], $title->getArticleID(), $title, $revision );
-                               if ( $val === false )
+                               if ( $val === false ) {
                                        $this->setWarning( "Action '$t' is not allowed for the current user" );
-                               else
+                               } else {
                                        $vals[$t . 'token'] = $val;
+                               }
                        }
                }
-               
+
                $text = null;
                if ( $this->fld_content || !is_null( $this->difftotext ) ) {
                        global $wgParser;
@@ -416,8 +436,9 @@ class ApiQueryRevisions extends ApiQueryBase {
                        // will have less input
                        if ( $this->section !== false ) {
                                $text = $wgParser->getSection( $text, $this->section, false );
-                               if ( $text === false )
+                               if ( $text === false ) {
                                        $this->dieUsage( "There is no section {$this->section} in r" . $revision->getId(), 'nosuchsection' );
+                               }
                        }
                }
                if ( $this->fld_content && !$revision->isDeleted( Revision::DELETED_TEXT ) ) {
@@ -430,13 +451,13 @@ class ApiQueryRevisions extends ApiQueryBase {
                                        $xml = $dom->__toString();
                                }
                                $vals['parsetree'] = $xml;
-                               
+
                        }
                        if ( $this->expandTemplates ) {
                                $text = $wgParser->preprocess( $text, $title, new ParserOptions() );
                        }
-                       ApiResult :: setContent( $vals, $text );
-               } else if ( $this->fld_content ) {
+                       ApiResult::setContent( $vals, $text );
+               } elseif ( $this->fld_content ) {
                        $vals['texthidden'] = '';
                }
 
@@ -455,8 +476,9 @@ class ApiQueryRevisions extends ApiQueryBase {
                                }
                                $difftext = $engine->getDiffBody();
                                ApiResult::setContent( $vals['diff'], $difftext );
-                               if ( !$engine->wasCacheHit() )
+                               if ( !$engine->wasCacheHit() ) {
                                        $n++;
+                               }
                        } else {
                                $vals['diff']['notcached'] = '';
                        }
@@ -465,11 +487,11 @@ class ApiQueryRevisions extends ApiQueryBase {
        }
 
        public function getAllowedParams() {
-               return array (
-                       'prop' => array (
-                               ApiBase :: PARAM_ISMULTI => true,
-                               ApiBase :: PARAM_DFLT => 'ids|timestamp|flags|comment|user',
-                               ApiBase :: PARAM_TYPE => array (
+               return array(
+                       'prop' => array(
+                               ApiBase::PARAM_ISMULTI => true,
+                               ApiBase::PARAM_DFLT => 'ids|timestamp|flags|comment|user',
+                               ApiBase::PARAM_TYPE => array(
                                        'ids',
                                        'flags',
                                        'timestamp',
@@ -481,44 +503,44 @@ class ApiQueryRevisions extends ApiQueryBase {
                                        'tags'
                                )
                        ),
-                       'limit' => array (
-                               ApiBase :: PARAM_TYPE => 'limit',
-                               ApiBase :: PARAM_MIN => 1,
-                               ApiBase :: PARAM_MAX => ApiBase :: LIMIT_BIG1,
-                               ApiBase :: PARAM_MAX2 => ApiBase :: LIMIT_BIG2
+                       'limit' => array(
+                               ApiBase::PARAM_TYPE => 'limit',
+                               ApiBase::PARAM_MIN => 1,
+                               ApiBase::PARAM_MAX => ApiBase::LIMIT_BIG1,
+                               ApiBase::PARAM_MAX2 => ApiBase::LIMIT_BIG2
                        ),
-                       'startid' => array (
-                               ApiBase :: PARAM_TYPE => 'integer'
+                       'startid' => array(
+                               ApiBase::PARAM_TYPE => 'integer'
                        ),
-                       'endid' => array (
-                               ApiBase :: PARAM_TYPE => 'integer'
+                       'endid' => array(
+                               ApiBase::PARAM_TYPE => 'integer'
                        ),
-                       'start' => array (
-                               ApiBase :: PARAM_TYPE => 'timestamp'
+                       'start' => array(
+                               ApiBase::PARAM_TYPE => 'timestamp'
                        ),
-                       'end' => array (
-                               ApiBase :: PARAM_TYPE => 'timestamp'
+                       'end' => array(
+                               ApiBase::PARAM_TYPE => 'timestamp'
                        ),
-                       'dir' => array (
-                               ApiBase :: PARAM_DFLT => 'older',
-                               ApiBase :: PARAM_TYPE => array (
+                       'dir' => array(
+                               ApiBase::PARAM_DFLT => 'older',
+                               ApiBase::PARAM_TYPE => array(
                                        'newer',
                                        'older'
                                )
                        ),
                        'user' => array(
-                               ApiBase :: PARAM_TYPE => 'user'
+                               ApiBase::PARAM_TYPE => 'user'
                        ),
                        'excludeuser' => array(
-                               ApiBase :: PARAM_TYPE => 'user'
+                               ApiBase::PARAM_TYPE => 'user'
                        ),
                        'tag' => null,
                        'expandtemplates' => false,
                        'generatexml' => false,
                        'section' => null,
                        'token' => array(
-                               ApiBase :: PARAM_TYPE => array_keys( $this->getTokenFunctions() ),
-                               ApiBase :: PARAM_ISMULTI => true
+                               ApiBase::PARAM_TYPE => array_keys( $this->getTokenFunctions() ),
+                               ApiBase::PARAM_ISMULTI => true
                        ),
                        'continue' => null,
                        'diffto' => null,
@@ -527,7 +549,7 @@ class ApiQueryRevisions extends ApiQueryBase {
        }
 
        public function getParamDescription() {
-               return array (
+               return array(
                        'prop' => 'Which properties to get for each revision.',
                        'limit' => 'Limit how many revisions will be returned (enum)',
                        'startid' => 'From which revision id to start enumeration (enum)',
@@ -551,7 +573,7 @@ class ApiQueryRevisions extends ApiQueryBase {
        }
 
        public function getDescription() {
-               return array (
+               return array(
                        'Get revision information.',
                        'This module may be used in several ways:',
                        ' 1) Get data about a set of pages (last revision), by setting titles or pageids parameter.',
@@ -560,7 +582,7 @@ class ApiQueryRevisions extends ApiQueryBase {
                        'All parameters marked as (enum) may only be used with a single page (#2).'
                );
        }
-       
+
        public function getPossibleErrors() {
                return array_merge( parent::getPossibleErrors(), array(
                        array( 'nosuchrevid', 'diffto' ),
@@ -575,7 +597,7 @@ class ApiQueryRevisions extends ApiQueryBase {
        }
 
        protected function getExamples() {
-               return array (
+               return array(
                        'Get data with content for the last revision of titles "API" and "Main Page":',
                        '  api.php?action=query&prop=revisions&titles=API|Main%20Page&rvprop=timestamp|user|comment|content',
                        'Get last 5 revisions of the "Main Page":',
index cb7dc33..9e42caf 100644 (file)
@@ -1,11 +1,11 @@
 <?php
 
-/*
+/**
  * Created on July 30, 2007
  *
  * API for MediaWiki 1.8+
  *
- * Copyright (C) 2007 Yuri Astrakhan <Firstname><Lastname>@gmail.com
+ * Copyright © 2007 Yuri Astrakhan <Firstname><Lastname>@gmail.com
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -25,7 +25,7 @@
 
 if ( !defined( 'MEDIAWIKI' ) ) {
        // Eclipse helper - will be ignored in production
-       require_once ( 'ApiQueryBase.php' );
+       require_once( 'ApiQueryBase.php' );
 }
 
 /**
@@ -36,7 +36,7 @@ if ( !defined( 'MEDIAWIKI' ) ) {
 class ApiQuerySearch extends ApiQueryGeneratorBase {
 
        public function __construct( $query, $moduleName ) {
-               parent :: __construct( $query, $moduleName, 'sr' );
+               parent::__construct( $query, $moduleName, 'sr' );
        }
 
        public function execute() {
@@ -57,9 +57,10 @@ class ApiQuerySearch extends ApiQueryGeneratorBase {
                $what = $params['what'];
                $searchInfo = array_flip( $params['info'] );
                $prop = array_flip( $params['prop'] );
-               
-               if ( strval( $query ) === '' )
-                       $this->dieUsage( "empty search string is not allowed", 'param-search' );
+
+               if ( strval( $query ) === '' ) {
+                       $this->dieUsage( 'empty search string is not allowed', 'param-search' );
+               }
 
                // Create search engine instance and set options
                $search = SearchEngine::create();
@@ -79,7 +80,7 @@ class ApiQuerySearch extends ApiQueryGeneratorBase {
                        // In the future, the default should be for a combined index.
                        $what = 'title';
                        $matches = $search->searchTitle( $query );
-                       
+
                        // Not all search engines support a separate title search,
                        // for instance the Lucene-based engine we use on Wikipedia.
                        // In this case, fall back to full-text search (which will
@@ -89,9 +90,10 @@ class ApiQuerySearch extends ApiQueryGeneratorBase {
                                $matches = $search->searchText( $query );
                        }
                }
-               if ( is_null( $matches ) )
+               if ( is_null( $matches ) ) {
                        $this->dieUsage( "{$what} search is disabled", "search-{$what}-disabled" );
-               
+               }
+
                // Add search meta data to result
                if ( isset( $searchInfo['totalhits'] ) ) {
                        $totalhits = $matches->getTotalHits();
@@ -107,7 +109,7 @@ class ApiQuerySearch extends ApiQueryGeneratorBase {
 
                // Add the search results to the result
                $terms = $wgContLang->convertForSearchResult( $matches->termMatches() );
-               $titles = array ();
+               $titles = array();
                $count = 0;
                while ( $result = $matches->next() ) {
                        if ( ++ $count > $limit ) {
@@ -117,23 +119,28 @@ class ApiQuerySearch extends ApiQueryGeneratorBase {
                        }
 
                        // Silently skip broken and missing titles
-                       if ( $result->isBrokenTitle() || $result->isMissingRevision() )
+                       if ( $result->isBrokenTitle() || $result->isMissingRevision() ) {
                                continue;
-                       
+                       }
+
                        $title = $result->getTitle();
                        if ( is_null( $resultPageSet ) ) {
                                $vals = array();
                                ApiQueryBase::addTitleInfo( $vals, $title );
-                               
-                               if ( isset( $prop['snippet'] ) )
+
+                               if ( isset( $prop['snippet'] ) ) {
                                        $vals['snippet'] = $result->getTextSnippet( $terms );
-                               if ( isset( $prop['size'] ) )
+                               }
+                               if ( isset( $prop['size'] ) ) {
                                        $vals['size'] = $result->getByteSize();
-                               if ( isset( $prop['wordcount'] ) )
+                               }
+                               if ( isset( $prop['wordcount'] ) ) {
                                        $vals['wordcount'] = $result->getWordCount();
-                               if ( isset( $prop['timestamp'] ) )
+                               }
+                               if ( isset( $prop['timestamp'] ) ) {
                                        $vals['timestamp'] = wfTimestamp( TS_ISO_8601, $result->getTimestamp() );
-                               
+                               }
+
                                // Add item to results and see whether it fits
                                $fit = $this->getResult()->addValue( array( 'query', $this->getModuleName() ),
                                                null, $vals );
@@ -156,52 +163,52 @@ class ApiQuerySearch extends ApiQueryGeneratorBase {
        }
 
        public function getAllowedParams() {
-               return array (
+               return array(
                        'search' => null,
-                       'namespace' => array (
-                               ApiBase :: PARAM_DFLT => 0,
-                               ApiBase :: PARAM_TYPE => 'namespace',
-                               ApiBase :: PARAM_ISMULTI => true,
+                       'namespace' => array(
+                               ApiBase::PARAM_DFLT => 0,
+                               ApiBase::PARAM_TYPE => 'namespace',
+                               ApiBase::PARAM_ISMULTI => true,
                        ),
-                       'what' => array (
-                               ApiBase :: PARAM_DFLT => null,
-                               ApiBase :: PARAM_TYPE => array (
+                       'what' => array(
+                               ApiBase::PARAM_DFLT => null,
+                               ApiBase::PARAM_TYPE => array(
                                        'title',
                                        'text',
                                )
                        ),
                        'info' => array(
-                               ApiBase :: PARAM_DFLT => 'totalhits|suggestion',
-                               ApiBase :: PARAM_TYPE => array (
+                               ApiBase::PARAM_DFLT => 'totalhits|suggestion',
+                               ApiBase::PARAM_TYPE => array(
                                        'totalhits',
                                        'suggestion',
                                ),
-                               ApiBase :: PARAM_ISMULTI => true,
+                               ApiBase::PARAM_ISMULTI => true,
                        ),
                        'prop' => array(
-                               ApiBase :: PARAM_DFLT => 'size|wordcount|timestamp|snippet',
-                               ApiBase :: PARAM_TYPE => array (
+                               ApiBase::PARAM_DFLT => 'size|wordcount|timestamp|snippet',
+                               ApiBase::PARAM_TYPE => array(
                                        'size',
                                        'wordcount',
                                        'timestamp',
                                        'snippet',
                                ),
-                               ApiBase :: PARAM_ISMULTI => true,
+                               ApiBase::PARAM_ISMULTI => true,
                        ),
                        'redirects' => false,
                        'offset' => 0,
-                       'limit' => array (
-                               ApiBase :: PARAM_DFLT => 10,
-                               ApiBase :: PARAM_TYPE => 'limit',
-                               ApiBase :: PARAM_MIN => 1,
-                               ApiBase :: PARAM_MAX => ApiBase :: LIMIT_SML1,
-                               ApiBase :: PARAM_MAX2 => ApiBase :: LIMIT_SML2
+                       'limit' => array(
+                               ApiBase::PARAM_DFLT => 10,
+                               ApiBase::PARAM_TYPE => 'limit',
+                               ApiBase::PARAM_MIN => 1,
+                               ApiBase::PARAM_MAX => ApiBase::LIMIT_SML1,
+                               ApiBase::PARAM_MAX2 => ApiBase::LIMIT_SML2
                        )
                );
        }
 
        public function getParamDescription() {
-               return array (
+               return array(
                        'search' => 'Search for all page titles (or content) that has this value.',
                        'namespace' => 'The namespace(s) to enumerate.',
                        'what' => 'Search inside the text or titles.',
@@ -216,7 +223,7 @@ class ApiQuerySearch extends ApiQueryGeneratorBase {
        public function getDescription() {
                return 'Perform a full text search';
        }
-       
+
        public function getPossibleErrors() {
                return array_merge( parent::getPossibleErrors(), array(
                        array( 'code' => 'param-search', 'info' => 'empty search string is not allowed' ),
@@ -226,7 +233,7 @@ class ApiQuerySearch extends ApiQueryGeneratorBase {
        }
 
        protected function getExamples() {
-               return array (
+               return array(
                        'api.php?action=query&list=search&srsearch=meaning',
                        'api.php?action=query&list=search&srwhat=text&srsearch=meaning',
                        'api.php?action=query&generator=search&gsrsearch=meaning&prop=info',