Skip to content

Commit

Permalink
Fix for och5p plugins compatibility (#359)
Browse files Browse the repository at this point in the history
  • Loading branch information
ferishili authored Aug 19, 2023
1 parent 1768570 commit 8f8ca5d
Show file tree
Hide file tree
Showing 2 changed files with 107 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Changes

### Unreleased

* 2023-08-18 - Improvement: Add CSS and Scripts for local_och5p local_och5pcore to the theme renderer.
* 2023-08-13 - Improvement: Make the fonts in the dark navbar variants always fully white (not only when hovered) to improve the contrast.
* 2023-08-13 - Feature: Smart menus, solves #137

Expand Down
106 changes: 106 additions & 0 deletions renderers.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ class theme_boost_union_core_h5p_renderer extends \core_h5p\output\renderer {
* @param string $embedtype How the H5P is displayed.
*/
public function h5p_alter_styles(&$styles, $libraries, $embedtype) {
global $CFG;

// Build the H5P CSS file URL.
$h5pcssurl = new moodle_url('/theme/boost_union/h5p/styles.php');

Expand All @@ -51,6 +53,57 @@ public function h5p_alter_styles(&$styles, $libraries, $embedtype) {
'path' => $h5pcssurl->out(),
'version' => '?ver='.theme_get_revision(),
);

// If the local_och5pcore plugin is installed, add some more styles.
if (file_exists($CFG->dirroot.'/local/och5pcore/version.php')) {
// If H5P interactive videos are installed.
if (isset($libraries['H5P.InteractiveVideo']) && $libraries['H5P.InteractiveVideo']['majorVersion'] == '1') {
// Adding H5PEditor css file.
$h5peditoravurl = new moodle_url('/local/och5pcore/lib/style/H5PEditor.AV.css');
$styles[] = (object) array(
'path' => $h5peditoravurl->out(),
'version' => '?ver='.theme_get_revision(),
);

// Adding opencast font css file.
$ocfontsurl = new moodle_url('/local/och5pcore/lib/style/oc-fonts.css');
$styles[] = (object) array(
'path' => $ocfontsurl->out(),
'version' => '?ver='.theme_get_revision(),
);
}
}
}

/**
* Add scripts when an H5P is displayed.
*
* @param array $scripts Scripts that will be applied.
* @param array $libraries Libraries that will be displayed.
* @param string $embedtype How the H5P is displayed.
*/
public function h5p_alter_scripts(&$scripts, $libraries, $embedtype) {
global $CFG;

// If the local_och5pcore plugin is installed, add some more scripts.
if (file_exists($CFG->dirroot.'/local/och5pcore/version.php')) {
// If H5P interactive videos are installed.
if (isset($libraries['H5P.InteractiveVideo']) && $libraries['H5P.InteractiveVideo']['majorVersion'] == '1') {
// Adding LTI related script into scripts array.
$h5prunltiurl = new moodle_url('/local/och5pcore/lib/js/H5PRunLTI.js');
$scripts[] = (object) array(
'path' => $h5prunltiurl->out(),
'version' => '?ver='.theme_get_revision(),
);

// Adding editor script to scripts array.
$h5peditoravurl = new moodle_url('/local/och5pcore/lib/js/H5PEditor.AV.js');
$scripts[] = (object) array(
'path' => $h5peditoravurl->out(),
'version' => '?ver='.theme_get_revision(),
);
}
}
}
}

Expand Down Expand Up @@ -79,6 +132,8 @@ class theme_boost_union_mod_hvp_renderer extends mod_hvp_renderer {
* @param string $embedtype How the H5P is displayed.
*/
public function hvp_alter_styles(&$styles, $libraries, $embedtype) {
global $CFG;

// Build the H5P CSS file URL.
$h5pcssurl = new moodle_url('/theme/boost_union/h5p/styles.php');

Expand All @@ -87,6 +142,57 @@ public function hvp_alter_styles(&$styles, $libraries, $embedtype) {
'path' => $h5pcssurl->out(),
'version' => '?ver='.theme_get_revision(),
);

// If the local_och5p plugin is installed, add some more styles.
if (file_exists($CFG->dirroot.'/local/och5p/version.php')) {
// If H5P interactive videos are installed.
if (isset($libraries['H5P.InteractiveVideo']) && $libraries['H5P.InteractiveVideo']['majorVersion'] == '1') {
// Adding H5PEditor css file.
$h5peditoravurl = new moodle_url('/local/och5p/lib/style/H5PEditor.AV.css');
$styles[] = (object) array(
'path' => $h5peditoravurl->out(),
'version' => '?ver='.theme_get_revision(),
);

// Adding opencast font css file.
$ocfontsurl = new moodle_url('/local/och5p/lib/style/oc-fonts.css');
$styles[] = (object) array(
'path' => $ocfontsurl->out(),
'version' => '?ver='.theme_get_revision(),
);
}
}
}

/**
* Add scripts when an H5P is displayed.
*
* @param array $scripts Scripts that will be applied.
* @param array $libraries Libraries that will be displayed.
* @param string $embedtype How the H5P is displayed.
*/
public function hvp_alter_scripts(&$scripts, $libraries, $embedtype) {
global $CFG;

// If the local_och5p plugin is installed, add some more scripts.
if (file_exists($CFG->dirroot.'/local/och5p/version.php')) {
// If H5P interactive videos are installed.
if (isset($libraries['H5P.InteractiveVideo']) && $libraries['H5P.InteractiveVideo']['majorVersion'] == '1') {
// Adding LTI related script into scripts array.
$h5prunltiurl = new moodle_url('/local/och5p/lib/js/H5PRunLTI.js');
$scripts[] = (object) array(
'path' => $h5prunltiurl->out(),
'version' => '?ver='.theme_get_revision(),
);

// Adding editor script to scripts array.
$h5peditoravurl = new moodle_url('/local/och5p/lib/js/H5PEditor.AV.js');
$scripts[] = (object) array(
'path' => $h5peditoravurl->out(),
'version' => '?ver='.theme_get_revision(),
);
}
}
}
}
}
Expand Down

0 comments on commit 8f8ca5d

Please sign in to comment.