Переглянути джерело

Minor - add missing function from 1.11.x, remove unused function

Julio Montoya 6 роки тому
батько
коміт
d5b91ea861
2 змінених файлів з 68 додано та 18 видалено
  1. 11 2
      main/document/showinframes.php
  2. 57 16
      main/inc/lib/display.lib.php

+ 11 - 2
main/document/showinframes.php

@@ -86,7 +86,8 @@ $is_visible = DocumentManager::check_visibility_tree(
     api_get_course_info(),
     api_get_session_id(),
     api_get_user_id(),
-    api_get_group_id()
+    api_get_group_id(),
+    false
 );
 
 if (!$is_allowed_to_edit && !$is_visible) {
@@ -277,7 +278,15 @@ if ($execute_iframe) {
         $content = Security::remove_XSS(file_get_contents($file_url_sys));
         echo $content;
     } else {
-        echo '<iframe id="mainFrame" name="mainFrame" border="0" frameborder="0" scrolling="no" style="width:100%;" height="600" src="'.$file_url_web.'&rand='.mt_rand(1, 10000).'" height="500" allowfullscreen="true" webkitallowfullscreen="true" mozallowfullscreen="true"></iframe>';
+        echo '<iframe 
+            id="mainFrame" 
+            name="mainFrame" 
+            border="0" 
+            frameborder="0" 
+            scrolling="no" 
+            style="width:100%;" height="600" 
+            src="'.$file_url_web.'&rand='.mt_rand(1, 10000).'" 
+            height="500" allowfullscreen="true" webkitallowfullscreen="true" mozallowfullscreen="true"></iframe>';
     }
 }
 Display::display_footer();

+ 57 - 16
main/inc/lib/display.lib.php

@@ -2718,6 +2718,56 @@ HTML;
               </div>';
     }
 
+    /**
+     * @param string $frameName
+     *
+     * @return string
+     */
+    public static function getFrameReadyBlock($frameName)
+    {
+        $defaultFeatures = ['playpause', 'current', 'progress', 'duration', 'tracks', 'volume', 'fullscreen', 'vrview'];
+        $features = api_get_configuration_value('video_features');
+        if (!empty($features) && isset($features['features'])) {
+            foreach ($features['features'] as $feature) {
+                if ($feature === 'vrview') {
+                    continue;
+                }
+                $defaultFeatures[] = $feature;
+            }
+        }
+
+        $defaultFeatures = implode("','", $defaultFeatures);
+        $frameReady = '
+          $.frameReady(function() {
+            $(document).ready(function () {
+                $("video:not(.skip), audio:not(.skip)").mediaelementplayer({
+                    pluginPath: "'.api_get_path(WEB_PUBLIC_PATH).'assets/mediaelement/build/",            
+                    features: ["'.$defaultFeatures.'"],
+                    success: function(mediaElement, originalNode, instance) {
+                    },
+                    vrPath: "'.api_get_path(WEB_PUBLIC_PATH).'assets/vrview/build/vrview.js"
+                });
+            });
+          }, "'.$frameName.'",
+          {
+            load: [
+                { type:"script", id:"_fr1", src:"'.api_get_jquery_web_path().'"},
+                { type:"script", id:"_fr7", src:"'.api_get_path(WEB_PUBLIC_PATH).'assets/MathJax/MathJax.js?config=AM_HTMLorMML"},
+                { type:"script", id:"_fr4", src:"'.api_get_path(WEB_PUBLIC_PATH).'assets/jquery-ui/jquery-ui.min.js"},
+                { type:"stylesheet", id:"_fr5", src:"'.api_get_path(WEB_PUBLIC_PATH).'assets/jquery-ui/themes/smoothness/jquery-ui.min.css"},
+                { type:"stylesheet", id:"_fr6", src:"'.api_get_path(WEB_PUBLIC_PATH).'assets/jquery-ui/themes/smoothness/theme.css"},
+                { type:"script", id:"_fr2", src:"'.api_get_path(WEB_LIBRARY_PATH).'javascript/jquery.highlight.js"},
+                { type:"script", id:"_fr3", src:"'.api_get_path(WEB_CODE_PATH).'glossary/glossary.js.php?'.api_get_cidreq().'"},
+                {type: "script", id: "_media1", src: "'.api_get_path(WEB_PUBLIC_PATH).'assets/mediaelement/build/mediaelement-and-player.min.js"},
+                {type: "stylesheet", id: "_media2", src: "'.api_get_path(WEB_PUBLIC_PATH).'assets/mediaelement/build/mediaelementplayer.min.css"},                
+                {type: "stylesheet", id: "_media4", src: "'.api_get_path(WEB_PUBLIC_PATH).'assets/mediaelement/plugins/vrview/vrview.css"},
+                {type: "script", id: "_media4", src: "'.api_get_path(WEB_PUBLIC_PATH).'assets/mediaelement/plugins/vrview/vrview.js"},
+            ]
+          });';
+
+        return $frameReady;
+    }
+
     public static function dropdownMenu($items = [], array $attr = [])
     {
         $links = null;
@@ -2731,6 +2781,11 @@ HTML;
         return  $html;
     }
 
+    /**
+     * @param $id
+     *
+     * @return array|mixed
+     */
     public static function randomColor($id)
     {
         static $colors = [];
@@ -2744,9 +2799,9 @@ HTML;
             $c3 = hexdec(substr($color, 4, 2));
             $luminosity = $c1 + $c2 + $c3;
 
-            $type = "#000000";
+            $type = '#000000';
             if ($luminosity < (255 + 255 + 255) / 2) {
-                $type = "#FFFFFF";
+                $type = '#FFFFFF';
             }
 
             $result = [
@@ -2758,18 +2813,4 @@ HTML;
             return $result; // example: #fc443a
         }
     }
-
-    /**
-     * Displays the reduced page header (without banner).
-     */
-    private static function set_header()
-    {
-        global $show_learnpath, $tool_name;
-        self::$global_template = new Template(
-            $tool_name,
-            false,
-            false,
-            $show_learnpath
-        );
-    }
 }