Clarifying unorthodox MIME type
[lhc/web/wiklou.git] / includes / api / ApiQueryImages.php
index 7d0c756..10a5885 100644 (file)
@@ -5,7 +5,7 @@
  *
  * API for MediaWiki 1.8+
  *
- * Copyright (C) 2006 Yuri Astrakhan <FirstnameLastname@gmail.com>
+ * Copyright (C) 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
@@ -29,6 +29,8 @@ if (!defined('MEDIAWIKI')) {
 }
 
 /**
+ * This query adds <images> subelement to all pages with the list of images embedded into those pages.
+ * 
  * @addtogroup API
  */
 class ApiQueryImages extends ApiQueryGeneratorBase {
@@ -47,6 +49,9 @@ class ApiQueryImages extends ApiQueryGeneratorBase {
 
        private function run($resultPageSet = null) {
 
+               if ($this->getPageSet()->getGoodTitleCount() == 0)
+                       return; // nothing to do
+
                $this->addFields(array (
                        'il_from',
                        'il_to'
@@ -72,9 +77,8 @@ class ApiQueryImages extends ApiQueryGeneratorBase {
                                        $lastId = $row->il_from;
                                }
                                
-                               $title = Title :: makeTitle(NS_IMAGE, $row->il_to);
                                $vals = array();
-                               ApiQueryBase :: addTitleInfo($vals, $title);
+                               ApiQueryBase :: addTitleInfo($vals, Title :: makeTitle(NS_IMAGE, $row->il_to));
                                $data[] = $vals;
                        }
 
@@ -94,16 +98,8 @@ class ApiQueryImages extends ApiQueryGeneratorBase {
                $db->freeResult($res);
        }
 
-       private function addPageSubItems($pageId, $data) {
-               $result = $this->getResult();
-               $result->setIndexedTagName($data, 'im');
-               $result->addValue(array ('query', 'pages', intval($pageId)),
-                       'images',
-                       $data);
-       }
-
        protected function getDescription() {
-               return 'Returns all links from the given page(s)';
+               return 'Returns all images contained on the given page(s)';
        }
 
        protected function getExamples() {
@@ -119,4 +115,4 @@ class ApiQueryImages extends ApiQueryGeneratorBase {
                return __CLASS__ . ': $Id$';
        }
 }
-?>
+