2016-04-19 12:45:09 +00:00
|
|
|
<?php
|
2016-05-12 16:01:50 +00:00
|
|
|
use MediaWiki\MediaWikiServices;
|
2016-04-19 12:45:09 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* RevisionSlider extension hooks
|
|
|
|
*
|
|
|
|
* @file
|
|
|
|
* @ingroup Extensions
|
|
|
|
* @license GPL-2.0+
|
|
|
|
*/
|
|
|
|
class RevisionSliderHooks {
|
2016-04-28 10:18:52 +00:00
|
|
|
|
2016-05-03 11:29:02 +00:00
|
|
|
public static function onDiffViewHeader(
|
|
|
|
DifferenceEngine $diff,
|
|
|
|
Revision $oldRev,
|
|
|
|
Revision $newRev
|
|
|
|
) {
|
2016-05-04 13:59:07 +00:00
|
|
|
global $wgUser;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* If this extension is deployed with the BetaFeatures extension then require the
|
|
|
|
* current user to have it enabled as a BetaFeature.
|
|
|
|
*/
|
|
|
|
if (
|
|
|
|
class_exists( BetaFeatures::class ) &&
|
|
|
|
!BetaFeatures::isFeatureEnabled( $wgUser, 'revisionslider' ) )
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-05-12 16:01:50 +00:00
|
|
|
$config = MediaWikiServices::getInstance()->getMainConfig();
|
|
|
|
$timeOffset = $config->get( 'LocalTZoffset' );
|
|
|
|
if ( is_null( $config->get( 'Localtimezone' ) ) ) {
|
|
|
|
$timeOffset = 0;
|
|
|
|
} elseif ( is_null( $timeOffset ) ) {
|
|
|
|
$timeOffset = 0;
|
|
|
|
}
|
|
|
|
|
2016-05-03 11:29:02 +00:00
|
|
|
$out = RequestContext::getMain()->getOutput();
|
2016-05-03 11:44:01 +00:00
|
|
|
$out->addModules( 'ext.RevisionSlider.init' );
|
2016-05-12 15:55:02 +00:00
|
|
|
$out->addJsConfigVars( 'extRevisionSliderOldRev', $oldRev->getId() );
|
|
|
|
$out->addJsConfigVars( 'extRevisionSliderNewRev', $newRev->getId() );
|
2016-05-12 16:01:50 +00:00
|
|
|
$out->addJsConfigVars( 'extRevisionSliderTimeOffset', intval( $timeOffset ) );
|
2016-05-03 11:36:34 +00:00
|
|
|
$out->addHTML(
|
2016-05-06 10:37:30 +00:00
|
|
|
Html::rawElement(
|
|
|
|
'div',
|
|
|
|
[
|
2016-05-30 10:06:44 +00:00
|
|
|
'id' => 'mw-revision-slider-container',
|
2016-05-06 10:37:30 +00:00
|
|
|
'style' => 'min-height: 150px;',
|
|
|
|
],
|
|
|
|
Html::element(
|
|
|
|
'p',
|
|
|
|
[
|
2016-05-30 10:06:44 +00:00
|
|
|
'id' => 'mw-revision-slider-placeholder',
|
2016-05-06 10:37:30 +00:00
|
|
|
'style' => 'text-align: center',
|
|
|
|
],
|
|
|
|
( new Message( 'revisionslider-loading-placeholder' ) )->parse()
|
|
|
|
) .
|
|
|
|
Html::rawElement(
|
|
|
|
'noscript',
|
2016-05-09 08:18:34 +00:00
|
|
|
[],
|
2016-05-06 10:37:30 +00:00
|
|
|
Html::element(
|
|
|
|
'p',
|
|
|
|
[ 'style' => 'text-align: center' ],
|
|
|
|
( new Message( 'revisionslider-loading-noscript' ) )->parse()
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
2016-05-03 11:36:34 +00:00
|
|
|
);
|
2016-05-04 13:59:07 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function getBetaFeaturePreferences( $user, &$prefs ) {
|
2016-05-09 08:18:34 +00:00
|
|
|
$prefs['revisionslider'] = [
|
2016-05-04 13:59:07 +00:00
|
|
|
'label-message' => 'revisionslider-beta-feature-message',
|
|
|
|
'desc-message' => 'revisionslider-beta-feature-description',
|
|
|
|
'info-link' => 'https://www.mediawiki.org/wiki/Extension:RevisionSlider',
|
|
|
|
'discussion-link' => 'https://www.mediawiki.org/wiki/Extension_talk:RevisionSlider',
|
2016-05-09 08:18:34 +00:00
|
|
|
];
|
2016-05-03 11:29:02 +00:00
|
|
|
}
|
|
|
|
|
2016-04-28 10:18:52 +00:00
|
|
|
public static function onResourceLoaderTestModules( array &$testModules, ResourceLoader $rl ) {
|
|
|
|
$testModules['qunit']['ext.RevisionSlider.tests'] = [
|
|
|
|
'scripts' => [
|
|
|
|
'tests/RevisionSlider.Revision.test.js',
|
2016-05-03 11:26:42 +00:00
|
|
|
'tests/RevisionSlider.Pointer.test.js',
|
|
|
|
'tests/RevisionSlider.PointerView.test.js',
|
2016-05-10 12:42:05 +00:00
|
|
|
'tests/RevisionSlider.Slider.test.js',
|
|
|
|
'tests/RevisionSlider.SliderView.test.js',
|
|
|
|
'tests/RevisionSlider.RevisionList.test.js',
|
2016-04-28 10:18:52 +00:00
|
|
|
],
|
|
|
|
'dependencies' => [
|
2016-05-03 11:26:42 +00:00
|
|
|
'ext.RevisionSlider.Revision',
|
|
|
|
'ext.RevisionSlider.Pointer',
|
|
|
|
'ext.RevisionSlider.PointerView',
|
2016-05-10 12:42:05 +00:00
|
|
|
'ext.RevisionSlider.Slider',
|
|
|
|
'ext.RevisionSlider.SliderView',
|
|
|
|
'ext.RevisionSlider.RevisionList',
|
2016-05-10 16:45:11 +00:00
|
|
|
'jquery.ui.draggable',
|
|
|
|
'jquery.ui.tooltip',
|
|
|
|
'jquery.tipsy',
|
2016-04-28 10:18:52 +00:00
|
|
|
],
|
|
|
|
'localBasePath' => __DIR__,
|
|
|
|
];
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2016-04-19 12:45:09 +00:00
|
|
|
}
|