Select Git revision
view_assets.php
-
Ben Fesili authoredBen Fesili authored
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']),