http://www.mediawiki.org/wiki/Special:Code/MediaWiki/73701
Revision: 73701
Author: neilk
Date: 2010-09-25 01:48:28 +0000 (Sat, 25 Sep 2010)
Log Message:
-----------
metadata / image info for file and thumbnail
Modified Paths:
--------------
branches/uploadwizard/extensions/UploadWizard/SessionStash.php
branches/uploadwizard/phase3/includes/api/ApiUpload.php
Modified: branches/uploadwizard/extensions/UploadWizard/SessionStash.php
===================================================================
--- branches/uploadwizard/extensions/UploadWizard/SessionStash.php
2010-09-25 01:44:44 UTC (rev 73700)
+++ branches/uploadwizard/extensions/UploadWizard/SessionStash.php
2010-09-25 01:48:28 UTC (rev 73701)
@@ -123,7 +123,7 @@
$_SESSION[UploadBase::SESSION_KEYNAME][$key] = $stashData;
- wfDebug( "SESSION\n=====\n " . print_r( $_SESSION, 1 ) . "\n" );
+ //wfDebug( "SESSION\n=====\n " . print_r( $_SESSION, 1 ) . "\n"
);
return $this->getFile( $key );
}
@@ -278,10 +278,26 @@
}
/**
- * Override transform to replace the url with a SessionStash url
+ * Parent classes use this method, for no obvious reason, to return the
path (relative to wiki root, I assume).
+ * But with this class, the URL is unrelated to the path.
+ *
+ * @return {String} url
+ */
+ public function getFullUrl() {
+ return $this->getUrl();
+ }
+
+
+ /**
+ * Typically, transform() returns a ThumbnailImage, which you can think
of as being the exact
+ * equivalent of an HTML thumbnail on Wikipedia. So its URL is the
full-size file, not the thumbnail's URL.
+ *
+ * Here we override transform() to stash the thumbnail file, and then
+ * provide a way to get at the stashed thumbnail file to extract
properties such as its URL
+ *
* @param {Array} parameters suitable for File::transform()
* @param {Bitmask} flags suitable for File::transform()
- * @return {ThumbnailImage} with modified url
+ * @return {ThumbnailImage} with additional File thumbnailFile property
*/
public function transform( $params, $flags=0 ) {
@@ -292,15 +308,17 @@
$thumb = parent::transform( $params, $flags );
$key = $this->thumbName($params);
- // remove extension, so it's stored under '120px-123456'
+
+ // remove extension, so it's stored in the session under
'120px-123456'
// this makes it uniform with the other session key for the
original, '123456'
$n = strrpos( $key, '.' );
if ( $n !== false ) {
$key = substr( $key, 0, $n );
}
+ // stash the thumbnail File, and provide our caller with a way
to get at its properties
$stashedThumbFile = $this->sessionStash->stashFile( $key,
$thumb->path );
- $thumb->url = $stashedThumbFile->getUrl();
+ $thumb->thumbnailFile = $stashedThumbFile;
return $thumb;
Modified: branches/uploadwizard/phase3/includes/api/ApiUpload.php
===================================================================
--- branches/uploadwizard/phase3/includes/api/ApiUpload.php 2010-09-25
01:44:44 UTC (rev 73700)
+++ branches/uploadwizard/phase3/includes/api/ApiUpload.php 2010-09-25
01:48:28 UTC (rev 73701)
@@ -114,7 +114,21 @@
} catch (Exception $e) {
$this->dieUsage( 'Obtaining stash file failed:
' . $e->getText(), 'stashfailed' );
}
-
+
+ // return data to the client similar to an imageinfo
call
+ $props = array(
+ 'url' => true,
+ 'size' => true,
+ 'sha1' => true,
+ 'mime' => true,
+ 'bitdepth' => true,
+ 'metadata' => true
+ );
+
+ $result[ 'imageinfo' ] = ApiQueryImageInfo::getInfo(
$file, $props, $this->getResult(), null );
+ // XXX get the rest of the image info including exif
data and so on
+
+
// move all this to the session, so it can look up the
thumbnail itself, and return opaque url
// with proper extension.
@@ -127,20 +141,14 @@
$thumbWidth = $thumbWidthParam;
}
}
- if ( ! $thumb = $file->getThumbnail( $thumbWidth ) ) {
+ $thumbnailImage = null;
+ if ( ! $thumbnailImage = $file->getThumbnail(
$thumbWidth ) ) {
$this->dieUsageMsg( 'Could not obtain
thumbnail', 'nothumb' );
}
- // get thumbnail urls from the SessionRepo, add to
results
- // XXX make this more like the usual imageinfo /
thumbnail info API
- $result[ 'thumbnail' ] = array(
- 'url' => $thumb->getUrl(),
- 'width' => $thumb->getWidth(),
- 'height' => $thumb->getHeight(),
- );
+ $thumbFile = $thumbnailImage->thumbnailFile;
+ $result[ 'thumbnailimageinfo' ] =
ApiQueryImageInfo::getInfo( $thumbFile, $props, $this->getResult(), null );
-
- // XXX get the rest of the image info including exif
data and so on
$this->getResult()->addValue( null,
$this->getModuleName(), $result );
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs