Skip to content
Snippets Groups Projects
Select Git revision
  • c062714610629b54703dd6f2e49e9a62c1f004b5
  • main default protected
  • dev/grabowski
  • origin/main
  • hsh_1.22.4
  • 1.22.4
  • 1.22.3
  • 1.22.2
  • 1.22.1
  • 1.22
  • 1.21
  • 1.20.2
  • 1.20.1
  • 1.20.0
  • 1.19.1
  • 1.19
  • 1.18
  • 1.17.2
  • 1.17.1
  • 1.17
  • 1.16
  • 1.15
  • 1.14
  • 1.13
24 results

view_assets.php

Blame
  • view_assets.php 12.23 KiB
    <?php
    // This file is part of Moodle - http://moodle.org/
    //
    // Moodle 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 3 of the License, or
    // (at your option) any later version.
    //
    // Moodle 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 Moodle.  If not, see <http://www.gnu.org/licenses/>.
    
    /**
     * The mod_hvp view assets convenience class for viewing and embedding H5Ps
     *
     * @package    mod_hvp
     * @copyright  2017 Joubel
     * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
     */
    
    namespace mod_hvp;
    
    use moodle_url;
    
    defined('MOODLE_INTERNAL') || die();
    
    /**
     * Handles finding and attaching assets for view
     * @package mod_hvp
     */
    class view_assets {
    
        private $cm;
        private $course;
        private $core;
        private $content;
        private $jsrequires;
        private $cssrequires;
    
        protected $settings;
        protected $embedtype;
        protected $files;
    
        public function __construct($cm, $course, $options = []) {
            $this->cm          = $cm;
            $this->course      = $course;
            $this->core        = framework::instance();
            $this->content     = $this->core->loadContent($cm->instance);
            $this->settings    = hvp_get_core_assets(\context_module::instance($cm->id));
            $this->jsrequires  = [];
            $this->cssrequires = [];
    
            $context        = \context_module::instance($this->cm->id);
            $displayoptions = $this->core->getDisplayOptionsForView($this->content['disable'], $context->instanceid);
            if (isset($options['disabledownload']) && $options['disabledownload']) {
                $displayoptions[\H5PCore::DISPLAY_OPTION_DOWNLOAD] = false;
            }
            if (isset($options['disablefullscreen']) && $options['disablefullscreen']) {
                $this->settings['fullscreenDisabled'] = true;
            }
    
            // Add JavaScript settings for this content.
            $cid                                  = 'cid-' . $this->content['id'];
            $root = self::getsiteroot();
            $this->settings['contents'][ $cid ]   = array(
                'library'         => \H5PCore::libraryToString($this->content['library']),