ApiBase.php:
[lhc/web/wiklou.git] / includes / api / ApiQuerySiteinfo.php
index 5ec4e32..d2a4c18 100644 (file)
@@ -1,10 +1,9 @@
 <?php
-
 /**
- * Created on Sep 25, 2006
- *
  * API for MediaWiki 1.8+
  *
+ * Created on Sep 25, 2006
+ *
  * Copyright © 2006 Yuri Astrakhan <Firstname><Lastname>@gmail.com
  *
  * This program is free software; you can redistribute it and/or modify
  *
  * You should have received a copy of the GNU General Public License along
  * with this program; if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  * http://www.gnu.org/copyleft/gpl.html
+ *
+ * @file
  */
 
 if ( !defined( 'MEDIAWIKI' ) ) {
@@ -99,7 +100,7 @@ class ApiQuerySiteinfo extends ApiQueryBase {
        }
 
        protected function appendGeneralInfo( $property ) {
-               global $wgContLang, $wgLang;
+               global $wgContLang;
 
                $data = array();
                $mainPage = Title::newMainPage();
@@ -128,7 +129,7 @@ class ApiQuerySiteinfo extends ApiQueryBase {
                if ( $wgContLang->isRTL() ) {
                        $data['rtl'] = '';
                }
-               $data['fallback8bitEncoding'] = $wgLang->fallback8bitEncoding();
+               $data['fallback8bitEncoding'] = $wgContLang->fallback8bitEncoding();
 
                if ( wfReadOnly() ) {
                        $data['readonly'] = '';
@@ -209,9 +210,9 @@ class ApiQuerySiteinfo extends ApiQueryBase {
        }
 
        protected function appendSpecialPageAliases( $property ) {
-               global $wgLang;
+               global $wgContLang;
                $data = array();
-               foreach ( $wgLang->getSpecialPageAliases() as $specialpage => $aliases )
+               foreach ( $wgContLang->getSpecialPageAliases() as $specialpage => $aliases )
                {
                        $arr = array( 'realname' => $specialpage, 'aliases' => $aliases );
                        $this->getResult()->setIndexedTagName( $arr['aliases'], 'alias' );
@@ -252,18 +253,17 @@ class ApiQuerySiteinfo extends ApiQueryBase {
 
                $this->addOption( 'ORDER BY', 'iw_prefix' );
 
-               $db = $this->getDB();
                $res = $this->select( __METHOD__ );
 
                $data = array();
                $langNames = Language::getLanguageNames();
-               while ( $row = $db->fetchObject( $res ) ) {
+               foreach ( $res as $row ) {
                        $val = array();
                        $val['prefix'] = $row->iw_prefix;
                        if ( $row->iw_local == '1' ) {
                                $val['local'] = '';
                        }
-//                     $val['trans'] = intval( $row->iw_trans ); // should this be exposed?
+                       // $val['trans'] = intval( $row->iw_trans ); // should this be exposed?
                        if ( isset( $langNames[$row->iw_prefix] ) ) {
                                $val['language'] = $langNames[$row->iw_prefix];
                        }
@@ -271,7 +271,6 @@ class ApiQuerySiteinfo extends ApiQueryBase {
 
                        $data[] = $val;
                }
-               $db->freeResult( $res );
 
                $this->getResult()->setIndexedTagName( $data, 'iw' );
                return $this->getResult()->addValue( 'query', $property, $data );
@@ -324,7 +323,8 @@ class ApiQuerySiteinfo extends ApiQueryBase {
        }
 
        protected function appendUserGroups( $property, $numberInGroup ) {
-               global $wgGroupPermissions;
+               global $wgGroupPermissions, $wgAddGroups, $wgRemoveGroups, $wgGroupsAddToSelf, $wgGroupsRemoveFromSelf;
+               
                $data = array();
                foreach ( $wgGroupPermissions as $group => $permissions ) {
                        $arr = array(
@@ -334,11 +334,25 @@ class ApiQuerySiteinfo extends ApiQueryBase {
                        if ( $numberInGroup ) {
                                $arr['number'] = SiteStats::numberInGroup( $group );
                        }
-
+                       
+                       $groupArr = array(
+                               'add' => $wgAddGroups,
+                               'remove' => $wgRemoveGroups,
+                               'add-self' => $wgGroupsAddToSelf,
+                               'remove-self' => $wgGroupsRemoveFromSelf
+                       );
+                       
+                       foreach( $groupArr as $type => $rights ) {
+                               if( isset( $rights[$group] ) ) {
+                                       $arr[$type] = $rights[$group];
+                                       $this->getResult()->setIndexedTagName( $arr[$type], 'group' );
+                               }
+                       }
+                       
                        $this->getResult()->setIndexedTagName( $arr['rights'], 'permission' );
                        $data[] = $arr;
                }
-
+               
                $this->getResult()->setIndexedTagName( $data, 'group' );
                return $this->getResult()->addValue( 'query', $property, $data );
        }
@@ -429,6 +443,10 @@ class ApiQuerySiteinfo extends ApiQueryBase {
                return $this->getResult()->addValue( 'query', $property, $data );
        }
 
+       public function getCacheMode( $params ) {
+               return 'public';
+       }
+
        public function getAllowedParams() {
                return array(
                        'prop' => array(