. /** * Squared theme. * * @package theme_squared * @copyright 2019 Gareth J Barnard * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ defined('MOODLE_INTERNAL') || die; global $CFG; $h5prenderer = $CFG->dirroot.'/mod/hvp/renderer.php'; if (file_exists($h5prenderer)) { // Be sure to include the H5P renderer so it can be extended. require_once($h5prenderer); /** * Class theme_squared_mod_hvp_renderer */ class theme_squared_mod_hvp_renderer extends mod_hvp_renderer { /** * Add styles when an H5P is displayed. * * @param array $styles Styles that will be applied. * @param array $libraries Libraries that will be shown. * @param string $embedtype How the H5P is displayed. */ public function hvp_alter_styles(&$styles, $libraries, $embedtype) { $toolbox = \theme_squared\toolbox::get_instance(); $content = $toolbox->get_setting('hvpcustomcss'); if (!empty($content)) { $styles[] = (object) array( 'path' => $this->get_style_url($content), 'version' => '' ); } } protected function get_style_url($content) { global $CFG; $syscontext = \context_system::instance(); $itemid = md5($content); return \moodle_url::make_file_url("$CFG->wwwroot/pluginfile.php", "/$syscontext->id/theme_squared/hvp/$itemid/themehvp.css"); } } }