* API: added version information to each module (available via api.php?version command)
[lhc/web/wiklou.git] / includes / api / ApiQueryInfo.php
index 2387189..baee279 100644 (file)
 
 if (!defined('MEDIAWIKI')) {
        // Eclipse helper - will be ignored in production
-       require_once ("ApiQueryBase.php");
+       require_once ('ApiQueryBase.php');
 }
 
 class ApiQueryInfo extends ApiQueryBase {
 
+       //      private $mParameters;
+
        public function __construct($query, $moduleName, $generator = false) {
                parent :: __construct($query, $moduleName, $generator);
        }
 
+       public function requestExtraData() {
+               $pageSet = $this->getPageSet();
+               $pageSet->requestField('page_is_redirect');
+               $pageSet->requestField('page_touched');
+               $pageSet->requestField('page_latest');
+       }
+
        public function execute() {
 
-       }
+               $pageSet = $this->getPageSet();
+               $titles = $pageSet->getGoodTitles();
+               $result = & $this->getResult();
 
-       protected function getAllowedParams() {
-               return array (
-                       'param' => 'default',
-                       'enumparam' => array (
-                               GN_ENUM_DFLT => 'default',
-                               GN_ENUM_ISMULTI => false,
-                               GN_ENUM_TYPE => array (
-                                       'a',
-                                       'b'
-                               )
-                       )
-               );
-       }
+               $pageIsRedir = $pageSet->getCustomField('page_is_redirect');
+               $pageTouched = $pageSet->getCustomField('page_touched');
+               $pageLatest = $pageSet->getCustomField('page_latest');
+
+               foreach ($titles as $pageid => $title) {
+                       $pageInfo = array ('touched' => $pageTouched[$pageid], 'lastrevid' => $pageLatest[$pageid]);
+
+                       if ($pageIsRedir[$pageid])
+                               $pageInfo['redirect'] = '';
 
-       protected function getParamDescription() {
-               return array ();
+                       $result->addValue(array (
+                               'query',
+                               'pages'
+                       ), $pageid, $pageInfo);
+               }
        }
 
        protected function getDescription() {
-               return 'module a';
+               return 'Get basic page information such as namespace, title, last touched date, ...';
        }
 
        protected function getExamples() {
                return array (
-                       'http://...'
+                       'api.php?action=query&prop=info&titles=Main%20Page'
                );
        }
+
+       public function getVersion() {
+               return __CLASS__ . ': $Id$';
+       }
 }
 ?>
\ No newline at end of file