Paladox has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/312327

Change subject: Test
......................................................................

Test

Change-Id: Ifae0fbc6883b679a115608191c432c0b8d0ca9ab
---
M TimedMediaHandler.hooks.php
M TimedMediaHandler.php
M TimedMediaHandler_body.php
M TimedMediaIframeOutput.php
M TimedMediaTransformOutput.php
5 files changed, 188 insertions(+), 109 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/TimedMediaHandler 
refs/changes/27/312327/1

diff --git a/TimedMediaHandler.hooks.php b/TimedMediaHandler.hooks.php
index ff28845..138febf 100644
--- a/TimedMediaHandler.hooks.php
+++ b/TimedMediaHandler.hooks.php
@@ -32,14 +32,114 @@
        // But for now we register them dynamically, because they are config 
dependent,
        // while we have two players
        public static function resourceLoaderRegisterModules( &$resourceLoader 
) {
-               global $wgTmhWebPlayer;
+               global $wgTmhWebPlayer, $wgUser, $wgTMHBetaFeature;
 
                $baseExtensionResource = [
                        'localBasePath' => __DIR__,
                        'remoteExtPath' => 'TimedMediaHandler',
                ];
 
-               if ( $wgTmhWebPlayer === 'mwembed' ) {
+               $resourceModulesVj = [
+                       'ext.tmh.video-js' => $baseExtensionResource + [
+                                       'scripts' => 
'resources/videojs/video.js',
+                                       'styles' => 
'resources/videojs/video-js.css',
+                                       'targets' => [ 'mobile', 'desktop' ],
+                                       'languageScripts' => [
+                                               'ar' => 
'resources/videojs/lang/ar.js',
+                                               'ba' => 
'resources/videojs/lang/ba.js',
+                                               'bg' => 
'resources/videojs/lang/bg.js',
+                                               'ca' => 
'resources/videojs/lang/ca.js',
+                                               'cs' => 
'resources/videojs/lang/cs.js',
+                                               'da' => 
'resources/videojs/lang/da.js',
+                                               'de' => 
'resources/videojs/lang/de.js',
+                                               'el' => 
'resources/videojs/lang/el.js',
+                                               'en' => 
'resources/videojs/lang/en.js',
+                                               'es' => 
'resources/videojs/lang/es.js',
+                                               'fa' => 
'resources/videojs/lang/fa.js',
+                                               'fi' => 
'resources/videojs/lang/fi.js',
+                                               'fr' => 
'resources/videojs/lang/fr.js',
+                                               'hr' => 
'resources/videojs/lang/hr.js',
+                                               'hu' => 
'resources/videojs/lang/hu.js',
+                                               'it' => 
'resources/videojs/lang/it.js',
+                                               'ja' => 
'resources/videojs/lang/ja.js',
+                                               'ko' => 
'resources/videojs/lang/ko.js',
+                                               'nb' => 
'resources/videojs/lang/nb.js',
+                                               'nl' => 
'resources/videojs/lang/nl.js',
+                                               'nn' => 
'resources/videojs/lang/nn.js',
+                                               'pl' => 
'resources/videojs/lang/pl.js',
+                                               'pt-BR' => 
'resources/videojs/lang/pt-BR.js',
+                                               'ru' => 
'resources/videojs/lang/ru.js',
+                                               'sr' => 
'resources/videojs/lang/sr.js',
+                                               'sv' => 
'resources/videojs/lang/sv.js',
+                                               'tr' => 
'resources/videojs/lang/tr.js',
+                                               'uk' => 
'resources/videojs/lang/uk.js',
+                                               'vi' => 
'resources/videojs/lang/vi.js',
+                                               'zh-CN' => 
'resources/videojs/lang/zh-CN.js',
+                                               'zh-TW' => 
'resources/videojs/lang/zh-TW.js',
+                                       ],
+                               ],
+                       'ext.tmh.videojs-ogvjs' => $baseExtensionResource + [
+                                       'scripts' => 
'resources/videojs-ogvjs/videojs-ogvjs.js',
+                                       'targets' => [ 'mobile', 'desktop' ],
+                                       'dependencies' => [
+                                               'ext.tmh.video-js',
+                                               'ext.tmh.OgvJs',
+                                       ],
+                               ],
+                       'ext.tmh.videojs-resolution-switcher' => 
$baseExtensionResource + [
+                                       'scripts' => 
'resources/videojs-resolution-switcher/videojs-resolution-switcher.js',
+                                       'styles' => 
'resources/videojs-resolution-switcher/videojs-resolution-switcher.css',
+                                       'targets' => [ 'mobile', 'desktop' ],
+                                       'dependencies' => [
+                                               'ext.tmh.video-js',
+                                       ],
+                               ],
+                       'ext.tmh.videojs-responsive-layout' => 
$baseExtensionResource + [
+                                       'scripts' => 
'resources/videojs-responsive-layout/videojs-responsive-layout.js',
+                                       'targets' => [ 'mobile', 'desktop' ],
+                                       'dependencies' => [
+                                               'ext.tmh.video-js',
+                                       ],
+                               ],
+                       'ext.tmh.videojs-replay' => $baseExtensionResource + [
+                               'scripts' => 
'resources/videojs-replay/videojs-replay.js',
+                               'styles' => 
'resources/videojs-replay/videojs-replay.css',
+                               'targets' => [ 'mobile', 'desktop' ],
+                               'dependencies' => [
+                                       'ext.tmh.video-js',
+                               ],
+                       ],
+                       'ext.tmh.mw-info-button' => $baseExtensionResource + [
+                               'scripts' => 
'resources/mw-info-button/mw-info-button.js',
+                               'styles' => 
'resources/mw-info-button/mw-info-button.css',
+                               'targets' => [ 'mobile', 'desktop' ],
+                               'dependencies' => [
+                                       'ext.tmh.video-js',
+                               ],
+                       ],
+                       'ext.tmh.player' => $baseExtensionResource + [
+                                       'scripts' => 
'resources/ext.tmh.player.js',
+                                       'targets' => [ 'mobile', 'desktop' ],
+                                       'dependencies' => [
+                                               'ext.tmh.video-js',
+                                               
'ext.tmh.videojs-resolution-switcher',
+                                               'ext.tmh.videojs-ogvjs',
+                                               
'ext.tmh.videojs-responsive-layout',
+                                               'ext.tmh.videojs-replay',
+                                               'ext.tmh.mw-info-button',
+                                       ],
+                               ],
+                       'ext.tmh.player.styles' => $baseExtensionResource + [
+                                       'styles' => 
'resources/ext.tmh.player.styles.less',
+                                       'targets' => [ 'mobile', 'desktop' ],
+                               ],
+               ];
+
+               if ( $wgTMHBetaFeature && class_exists( 'BetaFeatures' ) &&
+                       BetaFeatures::isFeatureEnabled( $wgUser, 'tmh-videojs' 
) &&
+                       !$wgTmhWebPlayer === 'videojs' ) {
+                               $resourceModules = array_merge( 
$resourceModules, $resourceModulesVj );
+               } elseif ( $wgTmhWebPlayer === 'mwembed' ) {
                        $resourceModules = [
                                'mw.PopUpMediaTransform' => 
$baseExtensionResource + [
                                                'scripts' => 
'resources/mw.PopUpThumbVideo.js',
@@ -84,101 +184,7 @@
                                        ],
                        ];
                } elseif ( $wgTmhWebPlayer === 'videojs' ) {
-                       $resourceModules = [
-                               'ext.tmh.video-js' => $baseExtensionResource + [
-                                               'scripts' => 
'resources/videojs/video.js',
-                                               'styles' => 
'resources/videojs/video-js.css',
-                                               'targets' => [ 'mobile', 
'desktop' ],
-                                               'languageScripts' => [
-                                                       'ar' => 
'resources/videojs/lang/ar.js',
-                                                       'ba' => 
'resources/videojs/lang/ba.js',
-                                                       'bg' => 
'resources/videojs/lang/bg.js',
-                                                       'ca' => 
'resources/videojs/lang/ca.js',
-                                                       'cs' => 
'resources/videojs/lang/cs.js',
-                                                       'da' => 
'resources/videojs/lang/da.js',
-                                                       'de' => 
'resources/videojs/lang/de.js',
-                                                       'el' => 
'resources/videojs/lang/el.js',
-                                                       'en' => 
'resources/videojs/lang/en.js',
-                                                       'es' => 
'resources/videojs/lang/es.js',
-                                                       'fa' => 
'resources/videojs/lang/fa.js',
-                                                       'fi' => 
'resources/videojs/lang/fi.js',
-                                                       'fr' => 
'resources/videojs/lang/fr.js',
-                                                       'hr' => 
'resources/videojs/lang/hr.js',
-                                                       'hu' => 
'resources/videojs/lang/hu.js',
-                                                       'it' => 
'resources/videojs/lang/it.js',
-                                                       'ja' => 
'resources/videojs/lang/ja.js',
-                                                       'ko' => 
'resources/videojs/lang/ko.js',
-                                                       'nb' => 
'resources/videojs/lang/nb.js',
-                                                       'nl' => 
'resources/videojs/lang/nl.js',
-                                                       'nn' => 
'resources/videojs/lang/nn.js',
-                                                       'pl' => 
'resources/videojs/lang/pl.js',
-                                                       'pt-BR' => 
'resources/videojs/lang/pt-BR.js',
-                                                       'ru' => 
'resources/videojs/lang/ru.js',
-                                                       'sr' => 
'resources/videojs/lang/sr.js',
-                                                       'sv' => 
'resources/videojs/lang/sv.js',
-                                                       'tr' => 
'resources/videojs/lang/tr.js',
-                                                       'uk' => 
'resources/videojs/lang/uk.js',
-                                                       'vi' => 
'resources/videojs/lang/vi.js',
-                                                       'zh-CN' => 
'resources/videojs/lang/zh-CN.js',
-                                                       'zh-TW' => 
'resources/videojs/lang/zh-TW.js',
-                                               ],
-                                       ],
-                               'ext.tmh.videojs-ogvjs' => 
$baseExtensionResource + [
-                                               'scripts' => 
'resources/videojs-ogvjs/videojs-ogvjs.js',
-                                               'targets' => [ 'mobile', 
'desktop' ],
-                                               'dependencies' => [
-                                                       'ext.tmh.video-js',
-                                                       'ext.tmh.OgvJs',
-                                               ],
-                                       ],
-                               'ext.tmh.videojs-resolution-switcher' => 
$baseExtensionResource + [
-                                               'scripts' => 
'resources/videojs-resolution-switcher/videojs-resolution-switcher.js',
-                                               'styles' => 
'resources/videojs-resolution-switcher/videojs-resolution-switcher.css',
-                                               'targets' => [ 'mobile', 
'desktop' ],
-                                               'dependencies' => [
-                                                       'ext.tmh.video-js',
-                                               ],
-                                       ],
-                               'ext.tmh.videojs-responsive-layout' => 
$baseExtensionResource + [
-                                               'scripts' => 
'resources/videojs-responsive-layout/videojs-responsive-layout.js',
-                                               'targets' => [ 'mobile', 
'desktop' ],
-                                               'dependencies' => [
-                                                       'ext.tmh.video-js',
-                                               ],
-                                       ],
-                               'ext.tmh.videojs-replay' => 
$baseExtensionResource + [
-                                       'scripts' => 
'resources/videojs-replay/videojs-replay.js',
-                                       'styles' => 
'resources/videojs-replay/videojs-replay.css',
-                                       'targets' => [ 'mobile', 'desktop' ],
-                                       'dependencies' => [
-                                               'ext.tmh.video-js',
-                                       ],
-                               ],
-                               'ext.tmh.mw-info-button' => 
$baseExtensionResource + [
-                                       'scripts' => 
'resources/mw-info-button/mw-info-button.js',
-                                       'styles' => 
'resources/mw-info-button/mw-info-button.css',
-                                       'targets' => [ 'mobile', 'desktop' ],
-                                       'dependencies' => [
-                                               'ext.tmh.video-js',
-                                       ],
-                               ],
-                               'ext.tmh.player' => $baseExtensionResource + [
-                                               'scripts' => 
'resources/ext.tmh.player.js',
-                                               'targets' => [ 'mobile', 
'desktop' ],
-                                               'dependencies' => [
-                                                       'ext.tmh.video-js',
-                                                       
'ext.tmh.videojs-resolution-switcher',
-                                                       'ext.tmh.videojs-ogvjs',
-                                                       
'ext.tmh.videojs-responsive-layout',
-                                                       
'ext.tmh.videojs-replay',
-                                                       
'ext.tmh.mw-info-button',
-                                               ],
-                                       ],
-                               'ext.tmh.player.styles' => 
$baseExtensionResource + [
-                                               'styles' => 
'resources/ext.tmh.player.styles.less',
-                                               'targets' => [ 'mobile', 
'desktop' ],
-                                       ],
-                       ];
+                       $resourceModules = array_merge( $resourceModules, 
$resourceModulesVj );
                }
 
                $resourceLoader->register( $resourceModules );
@@ -390,11 +396,16 @@
         * @return bool
         */
        private static function onImagePageHooks( $file, $out ) {
-               global $wgTmhWebPlayer;
+               global $wgTmhWebPlayer, $wgUser, $wgTMHBetaFeature;
 
                $handler = $file->getHandler();
                if ( $handler !== false && $handler instanceof 
TimedMediaHandler ) {
-                       if ( $wgTmhWebPlayer === 'mwembed' ) {
+                       if ( $wgTMHBetaFeature && class_exists( 'BetaFeatures' 
) &&
+                               BetaFeatures::isFeatureEnabled( $wgUser, 
'tmh-videojs' ) &&
+                               !$wgTmhWebPlayer === 'videojs' ) {
+                                       $out->addModuleStyles( 
'ext.tmh.player.styles' );
+                                       $out->addModules( 'ext.tmh.player' );
+                       } elseif ( $wgTmhWebPlayer === 'mwembed' ) {
                                $out->addModuleStyles( 
'ext.tmh.thumbnail.styles' );
                                $out->addModules( [
                                        'mw.MediaWikiPlayer.loader',
@@ -653,7 +664,7 @@
         * @return bool
         */
        static function pageOutputHook( &$out, &$sk ) {
-               global $wgTimedTextNS, $wgTmhWebPlayer;
+               global $wgTimedTextNS, $wgTmhWebPlayer, $wgUser, 
$wgTMHBetaFeature;
 
                $title = $out->getTitle();
                $namespace = $title->getNamespace();
@@ -671,7 +682,12 @@
                        }
                }
 
-               if ( $wgTmhWebPlayer === 'mwembed' ) {
+               if ( $wgTMHBetaFeature && class_exists( 'BetaFeatures' ) &&
+                       BetaFeatures::isFeatureEnabled( $wgUser, 'tmh-videojs' 
) &&
+                       !$wgTmhWebPlayer === 'videojs' ) {
+                               $out->addModuleStyles( 'ext.tmh.player.styles' 
);
+                               $out->addModules( 'ext.tmh.player' );
+               } elseif ( $wgTmhWebPlayer === 'mwembed' ) {
                        $out->addModuleStyles( 'ext.tmh.thumbnail.styles' );
                        $out->addModules( [
                                'mw.MediaWikiPlayer.loader',
@@ -729,4 +745,28 @@
                }
                return true;
        }
+
+       public static function onGetBetaFeaturePreferences( $user, &$prefs ) {
+               global $wgTMHBetaFeature, $wgTmhWebPlayer;
+
+               if ( $wgTMHBetaFeature && !$wgTmhWebPlayer === 'videojs' ) {
+                       $prefs['tmh-videojs'] = array(
+                               // The first two are message keys
+                               'label-message' => 
'tmh-beta-feature-message-videojs',
+                               'desc-message' => 
'tmh-beta-feature-description-videojs',
+                               // Paths to images that represents the feature.
+                               // The image is usually different for ltr and 
rtl languages.
+                               // Images for specific languages can also 
specified using the language code.
+                               'screenshot' => array(
+                                       'ru' => "",
+                                       'ltr' => "",
+                                       'rtl' => "",
+                               ),
+                               // Link to information on the feature - use 
subpages on mw.org, maybe?
+                               'info-link' => 
'https://www.mediawiki.org/wiki/Extension:MyExtension',
+                               // Link to discussion about the feature - talk 
pages might work
+                               'discussion-link' => 
'https://www.mediawiki.org/wiki/Extension_talk:MyExtension',
+                       );
+               }
+       }
 }
diff --git a/TimedMediaHandler.php b/TimedMediaHandler.php
index 1d4faf1..4c17472 100644
--- a/TimedMediaHandler.php
+++ b/TimedMediaHandler.php
@@ -17,6 +17,10 @@
 $wgAvailableRights[] = 'transcode-reset';
 $wgAvailableRights[] = 'transcode-status';
 
+// Controls weather to enable videojs beta feature
+// Requires the BetaFeature extension be installed.
+$wgTMHBetaFeature = false;
+
 // Configure the webplayer. Allowed values: mwembed, videojs
 $wgTmhWebPlayer = 'mwembed';
 
@@ -323,6 +327,10 @@
 $wgAutoloadClasses['SpecialTimedMediaHandler'] = 
"$timedMediaDir/SpecialTimedMediaHandler.php";
 $wgAutoloadClasses['SpecialOrphanedTimedText'] = 
"$timedMediaDir/SpecialOrphanedTimedText.php";
 
+if ( class_exists( 'BetaFeatures' ) ) {
+       $wgHooks['GetBetaFeaturePreferences'][] = 
'TimedMediaHandlerHooks::onGetBetaFeaturePreferences';
+}
+
 // This way if you set a variable like $wgTimedTextNS in LocalSettings.php
 // after you include TimedMediaHandler we can still read the variable values
 // See also T123695 and T123823
diff --git a/TimedMediaHandler_body.php b/TimedMediaHandler_body.php
index 2339fff..ec6cb84 100644
--- a/TimedMediaHandler_body.php
+++ b/TimedMediaHandler_body.php
@@ -197,14 +197,19 @@
         * @param $file File
         */
        function parserTransformHook( $parser, $file ) {
-               global $wgTmhWebPlayer;
+               global $wgTmhWebPlayer, $wgUser, $wgTMHBetaFeature;
 
                $parserOutput = $parser->getOutput();
                if ( isset( $parserOutput->hasTimedMediaTransform ) ) {
                        return;
                }
                $parserOutput->hasTimedMediaTransform = true;
-               if ( $wgTmhWebPlayer == 'mwembed' ) {
+               if ( $wgTMHBetaFeature && class_exists( 'BetaFeatures' ) &&
+                       BetaFeatures::isFeatureEnabled( $wgUser, 'tmh-videojs' 
) &&
+                       !$wgTmhWebPlayer === 'videojs' ) {
+                               $parserOutput->addModuleStyles( 
'ext.tmh.player.styles' );
+                               $parserOutput->addModules( 'ext.tmh.player' );
+               } elseif ( $wgTmhWebPlayer == 'mwembed' ) {
                        $parserOutput->addModuleStyles( 
'ext.tmh.thumbnail.styles' );
                        $parserOutput->addModules( [
                                'mw.MediaWikiPlayer.loader',
diff --git a/TimedMediaIframeOutput.php b/TimedMediaIframeOutput.php
index e3ba8e1..56fa9d2 100644
--- a/TimedMediaIframeOutput.php
+++ b/TimedMediaIframeOutput.php
@@ -46,7 +46,8 @@
         * @throws Exception
         */
        static function outputIframe( $title ) {
-               global $wgEnableIframeEmbed, $wgOut, $wgBreakFrames, 
$wgTmhWebPlayer;
+               global $wgEnableIframeEmbed, $wgOut, $wgBreakFrames, 
$wgTmhWebPlayer, $wgUser,
+                       $wgTMHBetaFeature;
 
                if ( !$wgEnableIframeEmbed ) {
                        return false;
@@ -68,7 +69,12 @@
                $wgOut->allowClickjacking();
                $wgOut->disallowUserJs();
 
-               if ( $wgTmhWebPlayer == 'mwembed' ) {
+               if ( $wgTMHBetaFeature && class_exists( 'BetaFeatures' ) &&
+                       BetaFeatures::isFeatureEnabled( $wgUser, 'tmh-videojs' 
) &&
+                       !$wgTmhWebPlayer === 'videojs' ) {
+                               $wgOut->addModules( 'ext.tmh.player' );
+                               $wgOut->addModuleStyles( 
'ext.tmh.player.styles' );
+               } elseif ( $wgTmhWebPlayer == 'mwembed' ) {
                        $wgOut->addModules( [ 'mw.MediaWikiPlayer.loader', 
'ext.tmh.embedPlayerIframe' ] );
                        $wgOut->addModuleStyles( 'embedPlayerIframeStyle' );
                } elseif ( $wgTmhWebPlayer === 'videojs' ) {
diff --git a/TimedMediaTransformOutput.php b/TimedMediaTransformOutput.php
index f1ae1fc..f526b47 100644
--- a/TimedMediaTransformOutput.php
+++ b/TimedMediaTransformOutput.php
@@ -297,7 +297,7 @@
         * @return string
         */
        function getHtmlMediaTagOutput( $sizeOverride = [], $autoPlay = false ) 
{
-               global $wgTmhWebPlayer;
+               global $wgTmhWebPlayer, $wgUser, $wgTMHBetaFeature;
 
                // Try to get the first source src attribute ( usually this 
should be the source file )
                $mediaSources = $this->getMediaSources();
@@ -361,7 +361,11 @@
                        self::htmlTagSet( 'track', $mediaTracks )
                );
 
-               if ( $wgTmhWebPlayer === 'videojs' ) {
+               if ( $wgTMHBetaFeature && class_exists( 'BetaFeatures' ) &&
+                       BetaFeatures::isFeatureEnabled( $wgUser, 'tmh-videojs' 
) &&
+                       !$wgTmhWebPlayer === 'videojs' ) {
+                               return $s;
+               } elseif ( $wgTmhWebPlayer === 'videojs' ) {
                        return $s;
                } // else mwEmbed player
 
@@ -398,7 +402,7 @@
         * @return array
         */
        function getMediaAttr( $sizeOverride = false, $autoPlay = false ) {
-               global $wgVideoPlayerSkin, $wgTmhWebPlayer;
+               global $wgVideoPlayerSkin, $wgTmhWebPlayer, $wgUser, 
$wgTMHBetaFeature;
 
                // Normalize values
                $length = floatval( $this->length );
@@ -437,7 +441,23 @@
                        unset( $mediaAttr[ 'poster' ] );
                }
 
-               if ( $wgTmhWebPlayer === 'videojs' ) {
+               if ( $wgTMHBetaFeature && class_exists( 'BetaFeatures' ) &&
+                       BetaFeatures::isFeatureEnabled( $wgUser, 'tmh-videojs' 
) &&
+                       !$wgTmhWebPlayer === 'videojs' ) {
+                               $mediaAttr['class'] = 'video-js ' . 
$wgVideoPlayerSkin;
+                               $mediaAttr['width'] = intval( $width );
+                               if ( $this->isVideo ) {
+                                       $mediaAttr['height'] = intval( $height 
);
+                               } else {
+                                       unset( $mediaAttr['height'] );
+                               }
+                               if ( $this->fillwindow ) {
+                                       unset( $mediaAttr['width'] );
+                                       unset( $mediaAttr['height'] );
+                                       $mediaAttr[ 'class' ] .= ' vjs-fluid';
+                                       $mediaAttr[ 'data-player' ] = 
'fillwindow';
+                               }
+               } elseif ( $wgTmhWebPlayer === 'videojs' ) {
                        $mediaAttr['class'] = 'video-js ' . $wgVideoPlayerSkin;
                        $mediaAttr['width'] = intval( $width );
                        if ( $this->isVideo ) {

-- 
To view, visit https://gerrit.wikimedia.org/r/312327
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ifae0fbc6883b679a115608191c432c0b8d0ca9ab
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/TimedMediaHandler
Gerrit-Branch: master
Gerrit-Owner: Paladox <thomasmulhall...@yahoo.com>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to