Merge "API: Add iiprop=canonicaltitle"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Tue, 10 Dec 2013 21:08:30 +0000 (21:08 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Tue, 10 Dec 2013 21:08:30 +0000 (21:08 +0000)
includes/api/ApiQueryImageInfo.php

index 86cba83..bf11a76 100644 (file)
@@ -385,6 +385,7 @@ class ApiQueryImageInfo extends ApiQueryBase {
                        }
                }
 
+               $canonicaltitle = isset( $prop['canonicaltitle'] );
                $url = isset( $prop['url'] );
                $sha1 = isset( $prop['sha1'] );
                $meta = isset( $prop['metadata'] );
@@ -395,7 +396,7 @@ class ApiQueryImageInfo extends ApiQueryBase {
                $bitdepth = isset( $prop['bitdepth'] );
                $uploadwarning = isset( $prop['uploadwarning'] );
 
-               if ( ( $url || $sha1 || $meta || $mime || $mediatype || $archive || $bitdepth )
+               if ( ( $canonicaltitle || $url || $sha1 || $meta || $mime || $mediatype || $archive || $bitdepth )
                        && $file->isDeleted( File::DELETED_FILE )
                ) {
                        $vals['filehidden'] = '';
@@ -404,6 +405,10 @@ class ApiQueryImageInfo extends ApiQueryBase {
                        return $vals;
                }
 
+               if ( $canonicaltitle ) {
+                       $vals['canonicaltitle'] = $file->getTitle()->getPrefixedText();
+               }
+
                if ( $url ) {
                        if ( !is_null( $thumbParams ) ) {
                                $mto = $file->transform( $thumbParams );
@@ -618,6 +623,7 @@ class ApiQueryImageInfo extends ApiQueryBase {
                        'userid' =>         ' userid        - Add the user ID that uploaded the image version',
                        'comment' =>        ' comment       - Comment on the version',
                        'parsedcomment' =>  ' parsedcomment - Parse the comment on the version',
+                       'canonicaltitle' => ' canonicaltitle - Adds the canonical title of the image file',
                        'url' =>            ' url           - Gives URL to the image and the description page',
                        'size' =>           ' size          - Adds the size of the image in bytes ' .
                                'and the height, width and page count (if applicable)',
@@ -737,6 +743,12 @@ class ApiQueryImageInfo extends ApiQueryBase {
                                        ApiBase::PROP_NULLABLE => true
                                )
                        ),
+                       'canonicaltitle' => array(
+                               'canonicaltitle' => array(
+                                       ApiBase::PROP_TYPE => 'string',
+                                       ApiBase::PROP_NULLABLE => true
+                               )
+                       ),
                        'url' => array(
                                'filehidden' => 'boolean',
                                'thumburl' => array(