2014-09-05 00:45:36 +00:00
|
|
|
/*
|
|
|
|
* This file is part of the MediaWiki extension MultimediaViewer.
|
|
|
|
*
|
|
|
|
* MultimediaViewer is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* MultimediaViewer is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with MultimediaViewer. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
( function ( mw, $, oo ) {
|
|
|
|
var AL;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Writes EventLogging entries for duration measurements
|
2016-07-18 13:49:27 +00:00
|
|
|
*
|
2014-09-05 00:45:36 +00:00
|
|
|
* @class mw.mmv.logging.AttributionLogger
|
|
|
|
* @extends mw.mmv.logging.Logger
|
|
|
|
* @constructor
|
|
|
|
*/
|
2014-09-26 06:53:38 +00:00
|
|
|
function AttributionLogger() {}
|
2014-09-05 00:45:36 +00:00
|
|
|
|
|
|
|
oo.inheritClass( AttributionLogger, mw.mmv.logging.Logger );
|
|
|
|
|
|
|
|
AL = AttributionLogger.prototype;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @override
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
|
|
|
AL.samplingFactor = mw.config.get( 'wgMultimediaViewer' ).attributionSamplingFactor;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @override
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
|
|
|
AL.schema = 'MultimediaViewerAttribution';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Logs attribution data
|
2016-07-18 13:49:27 +00:00
|
|
|
*
|
2014-09-05 00:45:36 +00:00
|
|
|
* @param {mw.mmv.model.Image} image Image data
|
|
|
|
*/
|
|
|
|
AL.logAttribution = function ( image ) {
|
|
|
|
var data;
|
|
|
|
|
|
|
|
data = {
|
|
|
|
authorPresent: !!image.author,
|
|
|
|
sourcePresent: !!image.source,
|
|
|
|
licensePresent: !!image.license,
|
|
|
|
loggedIn: !mw.user.isAnon(),
|
|
|
|
samplingFactor: this.samplingFactor
|
|
|
|
};
|
2015-02-19 23:30:29 +00:00
|
|
|
|
|
|
|
if ( this.isEnabled() ) {
|
|
|
|
mw.log( 'author: ' + ( data.authorPresent ? 'present' : 'absent' ) +
|
|
|
|
', source: ' + ( data.sourcePresent ? 'present' : 'absent' ) +
|
|
|
|
', license: ' + ( data.licensePresent ? 'present' : 'absent' ) );
|
|
|
|
}
|
2014-09-05 00:45:36 +00:00
|
|
|
|
|
|
|
this.log( data );
|
|
|
|
};
|
|
|
|
|
2014-09-26 18:37:53 +00:00
|
|
|
mw.mmv.logging.AttributionLogger = AttributionLogger;
|
2014-09-05 00:45:36 +00:00
|
|
|
mw.mmv.attributionLogger = new AttributionLogger();
|
2014-11-17 22:18:23 +00:00
|
|
|
}( mediaWiki, jQuery, OO ) );
|