Merge "Added some extra tests for ORMRow class"
[lhc/web/wiklou.git] / includes / api / ApiQueryImageInfo.php
index 3e435ba..969293b 100644 (file)
  * @file
  */
 
-if ( !defined( 'MEDIAWIKI' ) ) {
-       // Eclipse helper - will be ignored in production
-       require_once( 'ApiQueryBase.php' );
-}
-
 /**
  * A query action to get image information and upload history.
  *
@@ -318,8 +313,7 @@ class ApiQueryImageInfo extends ApiQueryBase {
                                $vals['commenthidden'] = '';
                        } else {
                                if ( $pcomment ) {
-                                       global $wgUser;
-                                       $vals['parsedcomment'] = $wgUser->getSkin()->formatComment(
+                                       $vals['parsedcomment'] = Linker::formatComment(
                                                $file->getDescription(), $file->getTitle() );
                                }
                                if ( $comment ) {
@@ -348,7 +342,7 @@ class ApiQueryImageInfo extends ApiQueryBase {
                        if ( !is_null( $thumbParams ) ) {
                                $mto = $file->transform( $thumbParams );
                                if ( $mto && !$mto->isError() ) {
-                                       $vals['thumburl'] = wfExpandUrl( $mto->getUrl() );
+                                       $vals['thumburl'] = wfExpandUrl( $mto->getUrl(), PROTO_CURRENT );
 
                                        // bug 23834 - If the URL's are the same, we haven't resized it, so shouldn't give the wanted
                                        // thumbnail sizes for the thumbnail actual size
@@ -370,8 +364,8 @@ class ApiQueryImageInfo extends ApiQueryBase {
                                        $vals['thumberror'] = $mto->toText();
                                }
                        }
-                       $vals['url'] = wfExpandUrl( $file->getFullURL() );
-                       $vals['descriptionurl'] = wfExpandUrl( $file->getDescriptionUrl() );
+                       $vals['url'] = wfExpandUrl( $file->getFullURL(), PROTO_CURRENT );
+                       $vals['descriptionurl'] = wfExpandUrl( $file->getDescriptionUrl(), PROTO_CURRENT );
                }
 
                if ( $sha1 ) {
@@ -436,7 +430,7 @@ class ApiQueryImageInfo extends ApiQueryBase {
         * @param $img File
         * @return string
         */
-       private function getContinueStr( $img ) {
+       protected function getContinueStr( $img ) {
                return $img->getOriginalTitle()->getText() .
                        '|' .  $img->getTimestamp();
        }
@@ -553,6 +547,114 @@ class ApiQueryImageInfo extends ApiQueryBase {
                );
        }
 
+       public static function getResultPropertiesFiltered( $filter = array() ) {
+               $props = array(
+                       'timestamp' => array(
+                               'timestamp' => 'timestamp'
+                       ),
+                       'user' => array(
+                               'userhidden' => 'boolean',
+                               'user' => 'string',
+                               'anon' => 'boolean'
+                       ),
+                       'userid' => array(
+                               'userhidden' => 'boolean',
+                               'userid' => 'integer',
+                               'anon' => 'boolean'
+                       ),
+                       'size' => array(
+                               'size' => 'integer',
+                               'width' => 'integer',
+                               'height' => 'integer',
+                               'pagecount' => array(
+                                       ApiBase::PROP_TYPE => 'integer',
+                                       ApiBase::PROP_NULLABLE => true
+                               )
+                       ),
+                       'comment' => array(
+                               'commenthidden' => 'boolean',
+                               'comment' => array(
+                                       ApiBase::PROP_TYPE => 'string',
+                                       ApiBase::PROP_NULLABLE => true
+                               )
+                       ),
+                       'parsedcomment' => array(
+                               'commenthidden' => 'boolean',
+                               'parsedcomment' => array(
+                                       ApiBase::PROP_TYPE => 'string',
+                                       ApiBase::PROP_NULLABLE => true
+                               )
+                       ),
+                       'url' => array(
+                               'filehidden' => 'boolean',
+                               'thumburl' => array(
+                                       ApiBase::PROP_TYPE => 'string',
+                                       ApiBase::PROP_NULLABLE => true
+                               ),
+                               'thumbwidth' => array(
+                                       ApiBase::PROP_TYPE => 'integer',
+                                       ApiBase::PROP_NULLABLE => true
+                               ),
+                               'thumbheight' => array(
+                                       ApiBase::PROP_TYPE => 'integer',
+                                       ApiBase::PROP_NULLABLE => true
+                               ),
+                               'thumberror' => array(
+                                       ApiBase::PROP_TYPE => 'string',
+                                       ApiBase::PROP_NULLABLE => true
+                               ),
+                               'url' => array(
+                                       ApiBase::PROP_TYPE => 'string',
+                                       ApiBase::PROP_NULLABLE => true
+                               ),
+                               'descriptionurl' => array(
+                                       ApiBase::PROP_TYPE => 'string',
+                                       ApiBase::PROP_NULLABLE => true
+                               )
+                       ),
+                       'sha1' => array(
+                               'filehidden' => 'boolean',
+                               'sha1' => array(
+                                       ApiBase::PROP_TYPE => 'string',
+                                       ApiBase::PROP_NULLABLE => true
+                               )
+                       ),
+                       'mime' => array(
+                               'filehidden' => 'boolean',
+                               'mime' => array(
+                                       ApiBase::PROP_TYPE => 'string',
+                                       ApiBase::PROP_NULLABLE => true
+                               )
+                       ),
+                       'mediatype' => array(
+                               'filehidden' => 'boolean',
+                               'mediatype' => array(
+                                       ApiBase::PROP_TYPE => 'string',
+                                       ApiBase::PROP_NULLABLE => true
+                               )
+                       ),
+                       'archivename' => array(
+                               'filehidden' => 'boolean',
+                               'archivename' => array(
+                                       ApiBase::PROP_TYPE => 'string',
+                                       ApiBase::PROP_NULLABLE => true
+                               )
+                       ),
+                       'bitdepth' => array(
+                               'filehidden' => 'boolean',
+                               'bitdepth' => array(
+                                       ApiBase::PROP_TYPE => 'integer',
+                                       ApiBase::PROP_NULLABLE => true
+                               )
+                       ),
+               );
+               return array_diff_key( $props, array_flip( $filter ) );
+       }
+
+       public function getResultProperties() {
+               return self::getResultPropertiesFiltered();
+       }
+
        public function getDescription() {
                return 'Returns image information and upload history';
        }
@@ -568,7 +670,7 @@ class ApiQueryImageInfo extends ApiQueryBase {
                ) );
        }
 
-       protected function getExamples() {
+       public function getExamples() {
                return array(
                        'api.php?action=query&titles=File:Albert%20Einstein%20Head.jpg&prop=imageinfo',
                        'api.php?action=query&titles=File:Test.jpg&prop=imageinfo&iilimit=50&iiend=20071231235959&iiprop=timestamp|user|url',
@@ -576,7 +678,7 @@ class ApiQueryImageInfo extends ApiQueryBase {
        }
 
        public function getHelpUrls() {
-               return 'http://www.mediawiki.org/wiki/API:Properties#imageinfo_.2F_ii';
+               return 'https://www.mediawiki.org/wiki/API:Properties#imageinfo_.2F_ii';
        }
 
        public function getVersion() {