* (bug 27479) API error when using both prop=pageprops and prop=info&inprop=displaytitle
[lhc/web/wiklou.git] / includes / api / ApiQueryStashImageInfo.php
index ff09a63..e48f6aa 100644 (file)
@@ -38,15 +38,16 @@ class ApiQueryStashImageInfo extends ApiQueryImageInfo {
                $prop = array_flip( $params['prop'] );
 
                $scale = $this->getScale( $params );
-               
+
                $result = $this->getResult();
-               
+
                try {
-                       $stash = new UploadStash();
-               
-                       foreach ( $params['sessionkey'] as $sessionkey ) {      
+                       $stash = RepoGroup::singleton()->getLocalRepo()->getUploadStash();
+
+                       foreach ( $params['sessionkey'] as $sessionkey ) {
                                $file = $stash->getFile( $sessionkey );
-                               $imageInfo = self::getInfo( $file, $prop, $result, $scale );
+                               $finalThumbParam = $this->mergeThumbParams( $file, $scale, $params['urlparam'] );
+                               $imageInfo = self::getInfo( $file, $prop, $result, $finalThumbParam );
                                $result->addValue( array( 'query', $this->getModuleName() ), null, $imageInfo );
                                $result->setIndexedTagName_internal( array( 'query', $this->getModuleName() ), $modulePrefix );
                        }
@@ -57,8 +58,7 @@ class ApiQueryStashImageInfo extends ApiQueryImageInfo {
                        $this->dieUsage( "File not found: " . $e->getMessage(), "invalidsessiondata" );
                } catch ( UploadStashBadPathException $e ) {
                        $this->dieUsage( "Bad path: " . $e->getMessage(), "invalidsessiondata" );
-               }       
-
+               }
        }
 
        /**
@@ -81,7 +81,7 @@ class ApiQueryStashImageInfo extends ApiQueryImageInfo {
 
        public function getAllowedParams() {
                return array(
-                       'sessionkey' => array( 
+                       'sessionkey' => array(
                                ApiBase::PARAM_ISMULTI => true,
                                ApiBase::PARAM_REQUIRED => true,
                                ApiBase::PARAM_DFLT => null
@@ -98,7 +98,11 @@ class ApiQueryStashImageInfo extends ApiQueryImageInfo {
                        'urlheight' => array(
                                ApiBase::PARAM_TYPE => 'integer',
                                ApiBase::PARAM_DFLT => -1
-                       )
+                       ),
+                       'urlparam' => array(
+                               ApiBase::PARAM_TYPE => 'string',
+                               ApiBase::PARAM_DFLT => '',
+                       ),
                );
        }
 
@@ -117,13 +121,15 @@ class ApiQueryStashImageInfo extends ApiQueryImageInfo {
                                ' dimensions   - Alias for size',
                                ' sha1         - Adds sha1 hash for the image',
                                ' mime         - Adds MIME of the image',
-                               ' thumbmime    - Adss MIME of the image thumbnail (requires url)',
+                               ' thumbmime    - Adds MIME of the image thumbnail (requires url)',
                                ' metadata     - Lists EXIF metadata for the version of the image',
                                ' bitdepth     - Adds the bit depth of the version',
                        ),
                        'sessionkey' => 'Session key that identifies a previous upload that was stashed temporarily.',
                        'urlwidth' => "If {$p}prop=url is set, a URL to an image scaled to this width will be returned.",
-                       'urlheight' => "Similar to {$p}urlwidth. Cannot be used without {$p}urlwidth"
+                       'urlheight' => "Similar to {$p}urlwidth. Cannot be used without {$p}urlwidth",
+                       'urlparam' => array( "A handler specific parameter string. For example, pdf's ",
+                               "might use 'page15-100px'. {$p}urlwidth must be used and be consistent with {$p}urlparam" ),
                );
        }