http://www.mediawiki.org/wiki/Special:Code/MediaWiki/73740

Revision: 73740
Author:   nikerabbit
Date:     2010-09-25 10:44:12 +0000 (Sat, 25 Sep 2010)

Log Message:
-----------
New api meta module + small fixes to the previous one

Modified Paths:
--------------
    trunk/extensions/Translate/Translate.php
    trunk/extensions/Translate/_autoload.php
    trunk/extensions/Translate/api/ApiQueryMessageCollection.php

Added Paths:
-----------
    trunk/extensions/Translate/api/ApiQueryMessageGroups.php

Modified: trunk/extensions/Translate/Translate.php
===================================================================
--- trunk/extensions/Translate/Translate.php    2010-09-25 10:39:05 UTC (rev 
73739)
+++ trunk/extensions/Translate/Translate.php    2010-09-25 10:44:12 UTC (rev 
73740)
@@ -79,6 +79,7 @@
 
 // API
 $wgAPIListModules['messagecollection'] = 'ApiQueryMessageCollection';
+$wgAPIMetaModules['messagegroups'] = 'ApiQueryMessageGroups';
 
 // Register hooks.
 $wgHooks['EditPage::showEditForm:initial'][] = 'TranslateEditAddons::addTools';

Modified: trunk/extensions/Translate/_autoload.php
===================================================================
--- trunk/extensions/Translate/_autoload.php    2010-09-25 10:39:05 UTC (rev 
73739)
+++ trunk/extensions/Translate/_autoload.php    2010-09-25 10:44:12 UTC (rev 
73740)
@@ -178,5 +178,6 @@
  * @{
  */
 $wgAutoloadClasses['ApiQueryMessageCollection'] = $dir . 
'api/ApiQueryMessageCollection.php';
+$wgAutoloadClasses['ApiQueryMessageGroups'] = $dir . 
'api/ApiQueryMessageGroups.php';
 
 /*...@}*/

Modified: trunk/extensions/Translate/api/ApiQueryMessageCollection.php
===================================================================
--- trunk/extensions/Translate/api/ApiQueryMessageCollection.php        
2010-09-25 10:39:05 UTC (rev 73739)
+++ trunk/extensions/Translate/api/ApiQueryMessageCollection.php        
2010-09-25 10:44:12 UTC (rev 73740)
@@ -4,7 +4,7 @@
  *
  * @file
  * @author Niklas Laxström
- * @copyright Copyright © 2007-2010, Niklas Laxström
+ * @copyright Copyright © 2010, Niklas Laxström
  * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 
2.0 or later
  */
 
@@ -32,7 +32,6 @@
        }
 
        private function run( $resultPageSet = null ) {
-               $db = $this->getDB();
                $params = $this->extractRequestParams();
 
                $group = MessageGroups::getGroup( $params['group'] );

Added: trunk/extensions/Translate/api/ApiQueryMessageGroups.php
===================================================================
--- trunk/extensions/Translate/api/ApiQueryMessageGroups.php                    
        (rev 0)
+++ trunk/extensions/Translate/api/ApiQueryMessageGroups.php    2010-09-25 
10:44:12 UTC (rev 73740)
@@ -0,0 +1,58 @@
+<?php
+/**
+ * Api module for querying MessageGroups.
+ *
+ * @file
+ * @author Niklas Laxström
+ * @copyright Copyright © 2010, Niklas Laxström
+ * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 
2.0 or later
+ */
+
+/**
+ * Api module for querying MessageGroups.
+ *
+ * @ingroup API TranslateAPI
+ */
+class ApiQueryMessageGroups extends ApiQueryBase {
+
+       public function __construct( $query, $moduleName ) {
+               parent::__construct( $query, $moduleName, 'mg' );
+       }
+
+       public function getCacheMode( $params ) {
+               return 'public';
+       }
+
+       public function execute() {
+               $params = $this->extractRequestParams();
+               $groups = MessageGroups::singleton()->getGroups();
+               $result = $this->getResult();
+
+               foreach ( $groups as $id => $g ) {
+                       $a = array();
+                       $a['id'] = $id;
+                       $a['label'] = $g->getLabel();
+                       $a['description'] = $g->getDescription();
+                       $a['class'] = get_class( $g );
+                       $a['exists'] = $g->exists();
+                       $fit = $result->addValue( array( 'query', 
$this->getModuleName() ), null, $a );
+               }
+
+               $result->setIndexedTagName_internal( array( 'query', 
$this->getModuleName() ), 'group' );
+
+       }
+
+       public function getDescription() {
+               return 'Return information about message groups';
+       }
+
+       protected function getExamples() {
+               return array(
+                       'api.php?action=query&meta=messagegroups',
+               );
+       }
+
+       public function getVersion() {
+               return __CLASS__ . ': $Id$';
+       }
+}


Property changes on: trunk/extensions/Translate/api/ApiQueryMessageGroups.php
___________________________________________________________________
Added: svn:keywords
   + Id
Added: svn:eol-style
   + native



_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to