Internal: Load vrview.js when enabling it in video features - refs BT#21289

pull/5023/head
Angel Fernando Quiroz Campos 2 years ago
parent e5ff1de400
commit c90f2b4ddf
  1. 1
      main/inc/global.inc.php
  2. 43
      main/inc/lib/display.lib.php
  3. 25
      main/inc/lib/template.lib.php
  4. 6
      main/template/default/layout/main.js.tpl

@ -627,6 +627,7 @@ if (!empty($language_interface)) {
if (!file_exists($file) || api_get_setting('server_type') === 'test') { if (!file_exists($file) || api_get_setting('server_type') === 'test') {
$template = new Template(); $template = new Template();
$template->assign('quiz_markers_rolls_js', ChamiloApi::getQuizMarkersRollsJS()); $template->assign('quiz_markers_rolls_js', ChamiloApi::getQuizMarkersRollsJS());
$template->assign('is_vrview_enabled', Display::isVrViewEnabled());
// Force use of default to avoid problems // Force use of default to avoid problems
$tpl = 'default/layout/main.js.tpl'; $tpl = 'default/layout/main.js.tpl';
$contents = $template->fetch($tpl); $contents = $template->fetch($tpl);

@ -2867,6 +2867,21 @@ HTML;
return $content; return $content;
} }
public static function isVrViewEnabled(): bool
{
$featuresConf = api_get_configuration_value('video_features');
if (!isset($featuresConf['features'])) {
return false;
}
if (in_array('vrview', $featuresConf['features'])) {
return true;
}
return false;
}
public static function getFrameReadyBlock( public static function getFrameReadyBlock(
string $frameName, string $frameName,
string $itemType = '', string $itemType = '',
@ -2875,6 +2890,8 @@ HTML;
$webPublicPath = api_get_path(WEB_PUBLIC_PATH); $webPublicPath = api_get_path(WEB_PUBLIC_PATH);
$webJsPath = api_get_path(WEB_LIBRARY_JS_PATH); $webJsPath = api_get_path(WEB_LIBRARY_JS_PATH);
$isVrViewEnabled = self::isVrViewEnabled();
$videoFeatures = [ $videoFeatures = [
'playpause', 'playpause',
'current', 'current',
@ -2883,9 +2900,13 @@ HTML;
'tracks', 'tracks',
'volume', 'volume',
'fullscreen', 'fullscreen',
'vrview',
'markersrolls', 'markersrolls',
]; ];
if ($isVrViewEnabled) {
$videoFeatures[] = 'vrview';
}
$features = api_get_configuration_value('video_features'); $features = api_get_configuration_value('video_features');
$videoPluginsJS = []; $videoPluginsJS = [];
$videoPluginCSS = []; $videoPluginCSS = [];
@ -2944,6 +2965,16 @@ HTML;
});'; });';
} }
$strMediaElementAdditionalConf = '';
$strMediaElementJsDeps = '';
$strMediaElementCssDeps = '';
if ($isVrViewEnabled) {
$strMediaElementAdditionalConf = ', vrPath: "'.$webPublicPath.'assets/vrview/build/vrview.js"';
$strMediaElementJsDeps = '{type:"script", src: "'.$webJsPath.'mediaelement/plugins/vrview/vrview.js"},';
$strMediaElementCssDeps = '{type:"stylesheet", src: "'.$webJsPath.'mediaelement/plugins/vrview/vrview.css"},';
}
$videoFeatures = implode("','", $videoFeatures); $videoFeatures = implode("','", $videoFeatures);
$frameReady = ' $frameReady = '
$.frameReady(function() { $.frameReady(function() {
@ -2955,8 +2986,8 @@ HTML;
features: [\''.$videoFeatures.'\'], features: [\''.$videoFeatures.'\'],
success: function(mediaElement, originalNode, instance) { success: function(mediaElement, originalNode, instance) {
'.$videoContextMenyHiddenMejs.PHP_EOL.ChamiloApi::getQuizMarkersRollsJS().' '.$videoContextMenyHiddenMejs.PHP_EOL.ChamiloApi::getQuizMarkersRollsJS().'
}, }
vrPath: "'.$webPublicPath.'assets/vrview/build/vrview.js" '.$strMediaElementAdditionalConf.'
}); });
}); });
}, },
@ -2970,7 +3001,7 @@ HTML;
{type:"script", src:"'.api_get_path(WEB_CODE_PATH).'glossary/glossary.js.php?'.api_get_cidreq().'"}, {type:"script", src:"'.api_get_path(WEB_CODE_PATH).'glossary/glossary.js.php?'.api_get_cidreq().'"},
{type:"script", src: "'.$webPublicPath.'assets/mediaelement/build/mediaelement-and-player.min.js", {type:"script", src: "'.$webPublicPath.'assets/mediaelement/build/mediaelement-and-player.min.js",
deps: [ deps: [
{type:"script", src: "'.$webJsPath.'mediaelement/plugins/vrview/vrview.js"}, '.$strMediaElementJsDeps.'
{type:"script", src: "'.$webJsPath.'mediaelement/plugins/markersrolls/markersrolls.min.js"}, {type:"script", src: "'.$webJsPath.'mediaelement/plugins/markersrolls/markersrolls.min.js"},
'.$videoPluginFiles.' '.$videoPluginFiles.'
]}, ]},
@ -2985,7 +3016,7 @@ HTML;
{type:"script", src:"'.$webPublicPath.'assets/jquery-ui/jquery-ui.min.js"}, {type:"script", src:"'.$webPublicPath.'assets/jquery-ui/jquery-ui.min.js"},
{type:"script", src: "'.$webPublicPath.'assets/mediaelement/build/mediaelement-and-player.min.js", {type:"script", src: "'.$webPublicPath.'assets/mediaelement/build/mediaelement-and-player.min.js",
deps: [ deps: [
{type:"script", src: "'.$webJsPath.'mediaelement/plugins/vrview/vrview.js"}, '.$strMediaElementJsDeps.'
{type:"script", src: "'.$webJsPath.'mediaelement/plugins/markersrolls/markersrolls.min.js"}, {type:"script", src: "'.$webJsPath.'mediaelement/plugins/markersrolls/markersrolls.min.js"},
'.$videoPluginFiles.' '.$videoPluginFiles.'
]}, ]},
@ -3002,7 +3033,7 @@ HTML;
{type:"stylesheet", src:"'.$webPublicPath.'assets/jquery-ui/themes/smoothness/theme.css"}, {type:"stylesheet", src:"'.$webPublicPath.'assets/jquery-ui/themes/smoothness/theme.css"},
{type:"stylesheet", src:"'.$webPublicPath.'css/dialog.css"}, {type:"stylesheet", src:"'.$webPublicPath.'css/dialog.css"},
{type:"stylesheet", src: "'.$webPublicPath.'assets/mediaelement/build/mediaelementplayer.min.css"}, {type:"stylesheet", src: "'.$webPublicPath.'assets/mediaelement/build/mediaelementplayer.min.css"},
{type:"stylesheet", src: "'.$webJsPath.'mediaelement/plugins/vrview/vrview.css"}, '.$strMediaElementCssDeps.'
], '.$jsConditionalFunction.');'; ], '.$jsConditionalFunction.');';
return $frameReady; return $frameReady;

@ -632,7 +632,11 @@ class Template
$css[] = api_get_cdn_path($webPublicPath.'assets/'.$file); $css[] = api_get_cdn_path($webPublicPath.'assets/'.$file);
} }
$css[] = $webJsPath.'mediaelement/plugins/vrview/vrview.css'; $isVrViewEnabled = Display::isVrViewEnabled();
if ($isVrViewEnabled) {
$css[] = $webJsPath.'mediaelement/plugins/vrview/vrview.css';
}
$features = api_get_configuration_value('video_features'); $features = api_get_configuration_value('video_features');
$defaultFeatures = [ $defaultFeatures = [
@ -643,10 +647,13 @@ class Template
'tracks', 'tracks',
'volume', 'volume',
'fullscreen', 'fullscreen',
'vrview',
'markersrolls', 'markersrolls',
]; ];
if ($isVrViewEnabled) {
$defaultFeatures[] = 'vrview';
}
if (!empty($features) && isset($features['features'])) { if (!empty($features) && isset($features['features'])) {
foreach ($features['features'] as $feature) { foreach ($features['features'] as $feature) {
if ($feature === 'vrview') { if ($feature === 'vrview') {
@ -754,17 +761,21 @@ class Template
{ {
global $disable_js_and_css_files, $htmlHeadXtra; global $disable_js_and_css_files, $htmlHeadXtra;
$isoCode = api_get_language_isocode(); $isoCode = api_get_language_isocode();
$isVrViewEnabled = Display::isVrViewEnabled();
$selectLink = 'bootstrap-select/dist/js/i18n/defaults-'.$isoCode.'_'.strtoupper($isoCode).'.min.js'; $selectLink = 'bootstrap-select/dist/js/i18n/defaults-'.$isoCode.'_'.strtoupper($isoCode).'.min.js';
if ($isoCode == 'en') { if ($isoCode == 'en') {
$selectLink = 'bootstrap-select/dist/js/i18n/defaults-'.$isoCode.'_US.min.js'; $selectLink = 'bootstrap-select/dist/js/i18n/defaults-'.$isoCode.'_US.min.js';
} }
// JS files // JS files
$js_files = [ $js_files = [];
'chosen/chosen.jquery.min.js', $js_files[] = 'chosen/chosen.jquery.min.js';
'mediaelement/plugins/vrview/vrview.js',
'mediaelement/plugins/markersrolls/markersrolls.min.js', if ($isVrViewEnabled) {
]; $js_files[] = 'mediaelement/plugins/vrview/vrview.js';
}
$js_files[] = 'mediaelement/plugins/markersrolls/markersrolls.min.js';
if (api_get_setting('accessibility_font_resize') === 'true') { if (api_get_setting('accessibility_font_resize') === 'true') {
$js_files[] = 'fontresize.js'; $js_files[] = 'fontresize.js';

@ -301,8 +301,10 @@ $(function() {
{% endif %} {% endif %}
{{ quiz_markers_rolls_js }} {{ quiz_markers_rolls_js }}
}, }
vrPath: _p.web + 'web/assets/vrview/build/vrview.js' {% if is_vrview_enabled %}
, vrPath: _p.web + 'web/assets/vrview/build/vrview.js'
{% endif %}
}); });
} }
{% if video_context_menu_hidden %} {% if video_context_menu_hidden %}

Loading…
Cancel
Save