* (bug 26482) add a imimages param to prop=images
authorSam Reed <reedy@users.mediawiki.org>
Wed, 5 Jan 2011 02:52:04 +0000 (02:52 +0000)
committerSam Reed <reedy@users.mediawiki.org>
Wed, 5 Jan 2011 02:52:04 +0000 (02:52 +0000)
RELEASE-NOTES
includes/LinkBatch.php
includes/api/ApiQueryImages.php

index 0260cc4..45108fb 100644 (file)
@@ -72,6 +72,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
 * (bug 26560) On allusers if limit < total number of users, last user gets duplicate
 * (bug 25135) add "normalized" to action=parse
 * (bug 26460) Add support for listing category members by category pageid
+* (bug 26482) add a imimages param to prop=images
 
 === Languages updated in 1.18 ===
 
index e689f96..77c4edd 100644 (file)
@@ -32,6 +32,10 @@ class LinkBatch {
                $this->caller = $caller;
        }
 
+       /**
+        * @param  $title Title
+        * @return void
+        */
        public function addObj( $title ) {
                if ( is_object( $title ) ) {
                        $this->add( $title->getNamespace(), $title->getDBkey() );
index 4451985..16d770c 100644 (file)
@@ -84,6 +84,19 @@ class ApiQueryImages extends ApiQueryGeneratorBase {
                }
                $this->addOption( 'LIMIT', $params['limit'] + 1 );
 
+               if ( !is_null( $params['images'] ) ) {
+                       $images = array();
+                       foreach ( $params['images'] as $img ) {
+                               $title = Title::newFromText( $img );
+                               if ( !$title || $title->getNamespace() != NS_FILE ) {
+                                       $this->setWarning( "``$img'' is not a file" );
+                               } else {
+                                       $images[] = $title->getDBkey();
+                               }
+                       }
+                       $this->addWhereFld( 'il_to', $images );
+               }
+
                $res = $this->select( __METHOD__ );
 
                if ( is_null( $resultPageSet ) ) {
@@ -136,6 +149,9 @@ class ApiQueryImages extends ApiQueryGeneratorBase {
                                ApiBase::PARAM_MAX2 => ApiBase::LIMIT_BIG2
                        ),
                        'continue' => null,
+                       'images' => array(
+                               ApiBase::PARAM_ISMULTI => true,
+                       )
                );
        }
 
@@ -143,6 +159,7 @@ class ApiQueryImages extends ApiQueryGeneratorBase {
                return array(
                        'limit' => 'How many images to return',
                        'continue' => 'When more results are available, use this to continue',
+                       'images' => 'Only list these images. Useful for checking whether a certain page has a certain Image.',
                );
        }