2014-12-16 01:06:05 +00:00
|
|
|
/*!
|
|
|
|
* VisualEditor MediaWiki Initialization ImageInfoCache class.
|
|
|
|
*
|
2023-12-01 16:06:11 +00:00
|
|
|
* @copyright See AUTHORS.txt
|
2014-12-16 01:06:05 +00:00
|
|
|
* @license The MIT License (MIT); see LICENSE.txt
|
|
|
|
*/
|
|
|
|
|
2015-04-30 16:03:30 +00:00
|
|
|
/**
|
|
|
|
* Get information about images.
|
2015-08-19 18:21:01 +00:00
|
|
|
*
|
2015-04-30 16:03:30 +00:00
|
|
|
* @class
|
|
|
|
* @extends ve.init.mw.ApiResponseCache
|
|
|
|
* @constructor
|
2018-05-05 14:13:15 +00:00
|
|
|
* @param {mw.Api} [api]
|
2015-04-30 16:03:30 +00:00
|
|
|
*/
|
|
|
|
ve.init.mw.ImageInfoCache = function VeInitMwImageInfoCache() {
|
2018-05-05 14:13:15 +00:00
|
|
|
// Parent constructor
|
|
|
|
ve.init.mw.ImageInfoCache.super.apply( this, arguments );
|
2015-04-30 16:03:30 +00:00
|
|
|
};
|
2015-04-29 16:58:34 +00:00
|
|
|
|
2015-04-30 16:03:30 +00:00
|
|
|
/* Inheritance */
|
2014-12-16 01:06:05 +00:00
|
|
|
|
2015-04-30 16:03:30 +00:00
|
|
|
OO.inheritClass( ve.init.mw.ImageInfoCache, ve.init.mw.ApiResponseCache );
|
2015-04-29 16:58:34 +00:00
|
|
|
|
2015-04-30 16:03:30 +00:00
|
|
|
/* Static methods */
|
2015-04-29 16:58:34 +00:00
|
|
|
|
2015-04-30 16:03:30 +00:00
|
|
|
/**
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
|
|
|
ve.init.mw.ImageInfoCache.static.processPage = function ( page ) {
|
|
|
|
if ( page.imageinfo ) {
|
2015-08-19 17:33:02 +00:00
|
|
|
return page.imageinfo[ 0 ];
|
2017-06-30 12:51:24 +00:00
|
|
|
} else if ( 'missing' in page ) {
|
|
|
|
return { missing: true };
|
2015-04-30 16:03:30 +00:00
|
|
|
}
|
|
|
|
};
|
2015-04-29 16:58:34 +00:00
|
|
|
|
2015-04-30 16:03:30 +00:00
|
|
|
/* Methods */
|
2014-12-16 01:06:05 +00:00
|
|
|
|
2015-04-30 16:03:30 +00:00
|
|
|
/**
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
|
|
|
ve.init.mw.ImageInfoCache.prototype.getRequestPromise = function ( subqueue ) {
|
2016-02-29 16:16:34 +00:00
|
|
|
// If you change what `iiprop`s are being fetched, update
|
|
|
|
// ve.ui.MWMediaDialog to add the same ones to the cache.
|
2018-05-05 14:13:15 +00:00
|
|
|
return this.api.get(
|
2015-04-30 16:03:30 +00:00
|
|
|
{
|
|
|
|
action: 'query',
|
|
|
|
prop: 'imageinfo',
|
|
|
|
indexpageids: '1',
|
|
|
|
iiprop: 'size|mediatype',
|
2016-09-30 16:07:10 +00:00
|
|
|
titles: subqueue
|
2015-04-30 16:03:30 +00:00
|
|
|
},
|
|
|
|
{ type: 'POST' }
|
|
|
|
);
|
|
|
|
};
|