diff --git a/contentbank/classes/helper.php b/contentbank/classes/helper.php
index 463f7ede337..f4cb921d279 100644
--- a/contentbank/classes/helper.php
+++ b/contentbank/classes/helper.php
@@ -44,6 +44,8 @@ class helper {
global $PAGE, $DB;
$PAGE->set_context($context);
+ $PAGE->set_heading(self::get_page_heading($context));
+ $PAGE->set_secondary_active_tab('contentbank');
$cburl = new \moodle_url('/contentbank/index.php', ['contextid' => $context->id]);
switch ($context->contextlevel) {
@@ -68,4 +70,27 @@ class helper {
$PAGE->set_pagelayout('standard');
}
}
+
+ /**
+ * Get the page heading based on the current context
+ *
+ * @param \context $context The current context of the page
+ * @return string
+ */
+ public static function get_page_heading(\context $context): string {
+ global $SITE;
+
+ $title = get_string('contentbank');
+ if ($context->id == \context_system::instance()->id) {
+ $title = $SITE->fullname;
+ } else if ($context->contextlevel == CONTEXT_COURSE) {
+ $course = get_course($context->instanceid);
+ $title = $course->fullname;
+ } else if ($context->contextlevel == CONTEXT_COURSECAT) {
+ $category = \core_course_category::get($context->instanceid);
+ $title = $category->get_formatted_name();
+ }
+
+ return $title;
+ }
}
diff --git a/contentbank/classes/output/viewcontent.php b/contentbank/classes/output/viewcontent.php
index 48871a6fb57..b514c4da142 100644
--- a/contentbank/classes/output/viewcontent.php
+++ b/contentbank/classes/output/viewcontent.php
@@ -60,6 +60,100 @@ class viewcontent implements renderable, templatable {
$this->content = $content;
}
+ /**
+ * Get the content of the "More" dropdown in the tertiary navigation
+ *
+ * @return array|null The options to be displayed in a dropdown in the tertiary navigation
+ * @throws \moodle_exception
+ */
+ protected function get_edit_actions_dropdown(): ?array {
+ global $PAGE;
+ $options = [];
+ if ($this->contenttype->can_manage($this->content)) {
+ // Add the visibility item to the menu.
+ switch($this->content->get_visibility()) {
+ case content::VISIBILITY_UNLISTED:
+ $visibilitylabel = get_string('visibilitysetpublic', 'core_contentbank');
+ $newvisibility = content::VISIBILITY_PUBLIC;
+ break;
+ case content::VISIBILITY_PUBLIC:
+ $visibilitylabel = get_string('visibilitysetunlisted', 'core_contentbank');
+ $newvisibility = content::VISIBILITY_UNLISTED;
+ break;
+ default:
+ $url = new \moodle_url('/contentbank/index.php', ['contextid' => $this->content->get_contextid()]);
+ throw new moodle_exception('contentvisibilitynotfound', 'error', $url, $this->content->get_visibility());
+ }
+
+ if ($visibilitylabel) {
+ $options[$visibilitylabel] = [
+ 'data-action' => 'setcontentvisibility',
+ 'data-visibility' => $newvisibility,
+ 'data-contentid' => $this->content->get_id(),
+ ];
+ }
+
+ // Add the rename content item to the menu.
+ $options[get_string('rename')] = [
+ 'data-action' => 'renamecontent',
+ 'data-contentname' => $this->content->get_name(),
+ 'data-contentid' => $this->content->get_id(),
+ ];
+
+ if ($this->contenttype->can_upload()) {
+ $options[get_string('replacecontent', 'contentbank')] = ['data-action' => 'upload'];
+
+ $PAGE->requires->js_call_amd(
+ 'core_contentbank/upload',
+ 'initModal',
+ [
+ '[data-action=upload]',
+ \core_contentbank\form\upload_files::class,
+ $this->content->get_contextid(),
+ $this->content->get_id()
+ ]
+ );
+ }
+ }
+
+ if ($this->contenttype->can_download($this->content)) {
+ $url = new moodle_url($this->contenttype->get_download_url($this->content));
+ $options[get_string('download')] = [
+ 'url' => $url->out()
+ ];
+ }
+
+ // Add the delete content item to the menu.
+ if ($this->contenttype->can_delete($this->content)) {
+ $options[get_string('delete')] = [
+ 'data-action' => 'deletecontent',
+ 'data-contentname' => $this->content->get_name(),
+ 'data-uses' => count($this->content->get_uses()),
+ 'data-contentid' => $this->content->get_id(),
+ 'data-contextid' => $this->content->get_contextid(),
+ ];
+ }
+
+ $dropdown = [];
+ if ($options) {
+ foreach ($options as $key => $attribs) {
+ $url = $attribs['url'] ?? '#';
+ $dropdown['options'][] = [
+ 'label' => $key,
+ 'url' => $url,
+ 'attributes' => array_map(function ($key, $value) {
+ return [
+ 'name' => $key,
+ 'value' => $value
+ ];
+ }, array_keys($attribs), $attribs)
+ ];
+ }
+ }
+
+ return $dropdown;
+ }
+
/**
* Export this data so it can be used as the context for a mustache template.
*
@@ -88,6 +182,11 @@ class viewcontent implements renderable, templatable {
$closeurl = new moodle_url('/contentbank/index.php', ['contextid' => $this->content->get_contextid()]);
$data->closeurl = $closeurl->out(false);
+ $data->actionmenu = $this->get_edit_actions_dropdown();
+ $data->heading = $this->content->get_name();
+ if ($this->content->get_visibility() == content::VISIBILITY_UNLISTED) {
+ $data->heading = get_string('visibilitytitleunlisted', 'contentbank', $data->heading);
+ }
return $data;
}
diff --git a/contentbank/contenttype/h5p/classes/form/editor.php b/contentbank/contenttype/h5p/classes/form/editor.php
index 7ac641be0ab..26dc2d360d6 100644
--- a/contentbank/contenttype/h5p/classes/form/editor.php
+++ b/contentbank/contenttype/h5p/classes/form/editor.php
@@ -51,7 +51,7 @@ class editor extends edit_content {
* Defines the form fields.
*/
protected function definition() {
- global $DB;
+ global $DB, $OUTPUT;
$mform = $this->_form;
$errors = [];
@@ -70,6 +70,7 @@ class editor extends edit_content {
$this->h5peditor = new h5peditor();
$this->set_display_vertical();
+ $mform->addElement('html', $OUTPUT->heading($this->_customdata['heading'], 2));
if ($id) {
// The H5P editor needs the H5P content id (h5p table).
@@ -114,7 +115,6 @@ class editor extends edit_content {
}
$mform->addElement('cancel', 'cancel', get_string('back'));
} else {
- $this->add_action_buttons();
$this->h5peditor->add_editor_to_form($mform);
$this->add_action_buttons();
}
diff --git a/contentbank/edit.php b/contentbank/edit.php
index 353483fa745..f272d4b4599 100644
--- a/contentbank/edit.php
+++ b/contentbank/edit.php
@@ -76,7 +76,8 @@ if (!$contenttype->can_edit($content)) {
$values = [
'contextid' => $contextid,
'plugin' => $pluginname,
- 'id' => $id
+ 'id' => $id,
+ 'heading' => $heading
];
$title = get_string('contentbank');
@@ -91,8 +92,6 @@ $PAGE->navbar->add(get_string('edit'));
$PAGE->set_title($title);
$PAGE->set_pagelayout('incourse');
-$PAGE->set_heading($heading);
-
// Instantiate the content type form.
$editorclass = "$contenttypename\\form\\editor";
if (!class_exists($editorclass)) {
diff --git a/contentbank/index.php b/contentbank/index.php
index 1c44bf5e47a..2ba512e6c66 100644
--- a/contentbank/index.php
+++ b/contentbank/index.php
@@ -52,7 +52,6 @@ if ($contextid == \context_system::instance()->id) {
$PAGE->set_context($context);
}
$PAGE->set_title($title);
-$PAGE->set_heading($title);
$PAGE->add_body_class('limitedwidth');
$PAGE->set_pagetype('contentbank');
$PAGE->set_secondary_active_tab('contentbank');
@@ -110,6 +109,7 @@ if (has_capability('moodle/contentbank:upload', $context)) {
}
echo $OUTPUT->header();
+echo $OUTPUT->heading($title, 2);
echo $OUTPUT->box_start('generalbox');
// If needed, display notifications.
diff --git a/contentbank/templates/contentbankmenu.mustache b/contentbank/templates/contentbankmenu.mustache
new file mode 100644
index 00000000000..dae6f006b1d
--- /dev/null
+++ b/contentbank/templates/contentbankmenu.mustache
@@ -0,0 +1,57 @@
+{{!
+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 comments.
+
+You should have received a copy of the GNU General Public License
+along with Moodle. If not, see