* API: added version information to each module (available via api.php?version command)
[lhc/web/wiklou.git] / includes / api / ApiQueryAllpages.php
index 0a715eb..393dc61 100644 (file)
@@ -26,7 +26,7 @@
 
 if (!defined('MEDIAWIKI')) {
        // Eclipse helper - will be ignored in production
-       require_once ("ApiQueryBase.php");
+       require_once ('ApiQueryBase.php');
 }
 
 class ApiQueryAllpages extends ApiQueryBase {
@@ -48,9 +48,7 @@ class ApiQueryAllpages extends ApiQueryBase {
 
                if ($apfilterredir === 'redirects')
                        $where['page_is_redirect'] = 1;
-               else
-                       if ($apfilterredir === 'nonredirects')
-                               $where['page_is_redirect'] = 0;
+               elseif ($apfilterredir === 'nonredirects') $where['page_is_redirect'] = 0;
 
                $this->profileDBIn();
                $res = $db->select('page', array (
@@ -63,9 +61,9 @@ class ApiQueryAllpages extends ApiQueryBase {
                        'ORDER BY' => 'page_namespace, page_title'
                ));
                $this->profileDBOut();
-               
+
                $data = array ();
-               $data['_element'] = 'p';
+               ApiResult :: setIndexedTagName($data, 'p');
                $count = 0;
                while ($row = $db->fetchObject($res)) {
                        if (++ $count > $aplimit) {
@@ -73,7 +71,7 @@ class ApiQueryAllpages extends ApiQueryBase {
                                $msg = array (
                                        'continue' => 'apfrom=' . ApiQueryBase :: keyToTitle($row->page_title
                                ));
-                               $this->getResult()->addMessage('query-status', 'allpages', $msg);
+                               $this->getResult()->addValue('query-status', 'allpages', $msg);
                                break;
                        }
 
@@ -87,13 +85,12 @@ class ApiQueryAllpages extends ApiQueryBase {
                                if ($title->getNamespace() !== 0)
                                        $pagedata['ns'] = $title->getNamespace();
                                $pagedata['title'] = $title->getPrefixedText();
-                               $pagedata['*'] = '';
 
                                $data[$id] = $pagedata;
                        }
                }
                $db->freeResult($res);
-               $this->getResult()->addMessage('query', 'allpages', $data);
+               $this->getResult()->addValue('query', 'allpages', $data);
        }
 
        protected function getAllowedParams() {
@@ -108,23 +105,23 @@ class ApiQueryAllpages extends ApiQueryBase {
                return array (
                        'apfrom' => null,
                        'apnamespace' => array (
-                               GN_ENUM_DFLT => 0,
-                               GN_ENUM_TYPE => $validNamespaces
+                               ApiBase :: PARAM_DFLT => 0,
+                               ApiBase :: PARAM_TYPE => $validNamespaces
                        ),
                        'apfilterredir' => array (
-                               GN_ENUM_DFLT => 'all',
-                               GN_ENUM_TYPE => array (
+                               ApiBase :: PARAM_DFLT => 'all',
+                               ApiBase :: PARAM_TYPE => array (
                                        'all',
                                        'redirects',
                                        'nonredirects'
                                )
                        ),
                        'aplimit' => array (
-                               GN_ENUM_DFLT => 10,
-                               GN_ENUM_TYPE => 'limit',
-                               GN_ENUM_MIN => 1,
-                               GN_ENUM_MAX1 => 500,
-                               GN_ENUM_MAX2 => 5000
+                               ApiBase :: PARAM_DFLT => 10,
+                               ApiBase :: PARAM_TYPE => 'limit',
+                               ApiBase :: PARAM_MIN => 1,
+                               ApiBase :: PARAM_MAX1 => 500,
+                               ApiBase :: PARAM_MAX2 => 5000
                        )
                );
        }
@@ -143,8 +140,13 @@ class ApiQueryAllpages extends ApiQueryBase {
                        'api.php?action=query&list=allpages&apfrom=B&aplimit=5'
                );
        }
+
        public function getCanGenerate() {
                return true;
        }
+
+       public function getVersion() {
+               return __CLASS__ . ': $Id$';
+       }
 }
 ?>
\ No newline at end of file