summaryrefslogtreecommitdiff
path: root/includes/api/ApiQueryImages.php
diff options
context:
space:
mode:
Diffstat (limited to 'includes/api/ApiQueryImages.php')
-rw-r--r--includes/api/ApiQueryImages.php28
1 files changed, 26 insertions, 2 deletions
diff --git a/includes/api/ApiQueryImages.php b/includes/api/ApiQueryImages.php
index af2920c7..9dfdf341 100644
--- a/includes/api/ApiQueryImages.php
+++ b/includes/api/ApiQueryImages.php
@@ -1,6 +1,6 @@
<?php
/**
- * API for MediaWiki 1.8+
+ *
*
* Created on May 13, 2007
*
@@ -48,6 +48,9 @@ class ApiQueryImages extends ApiQueryGeneratorBase {
$this->run( $resultPageSet );
}
+ /**
+ * @param $resultPageSet ApiPageSet
+ */
private function run( $resultPageSet = null ) {
if ( $this->getPageSet()->getGoodTitleCount() == 0 ) {
return; // nothing to do
@@ -84,6 +87,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 +152,9 @@ class ApiQueryImages extends ApiQueryGeneratorBase {
ApiBase::PARAM_MAX2 => ApiBase::LIMIT_BIG2
),
'continue' => null,
+ 'images' => array(
+ ApiBase::PARAM_ISMULTI => true,
+ )
);
}
@@ -143,6 +162,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.',
);
}
@@ -165,7 +185,11 @@ class ApiQueryImages extends ApiQueryGeneratorBase {
);
}
+ public function getHelpUrls() {
+ return 'https://www.mediawiki.org/wiki/API:Properties#images_.2F_im';
+ }
+
public function getVersion() {
- return __CLASS__ . ': $Id: ApiQueryImages.php 73543 2010-09-22 16:50:09Z platonides $';
+ return __CLASS__ . ': $Id: ApiQueryImages.php 104449 2011-11-28 15:52:04Z reedy $';
}
}