MDL-71913 mod_folder: Add tertiary navigation

This commit is contained in:
Mihail Geshoski 2021-07-14 23:11:36 +08:00
parent 0dd4ddb1e8
commit 671375115f
5 changed files with 38 additions and 37 deletions

View File

@ -42,6 +42,7 @@ $PAGE->set_url('/mod/folder/edit.php', array('id' => $cm->id));
$PAGE->set_title($course->shortname.': '.$folder->name);
$PAGE->set_heading($course->fullname);
$PAGE->set_activity_record($folder);
$PAGE->set_secondary_active_tab('modulepage');
$data = new stdClass();
$data->id = $cm->id;
@ -78,7 +79,9 @@ if ($mform->is_cancelled()) {
}
echo $OUTPUT->header();
echo $OUTPUT->heading(format_string($folder->name));
if (!$PAGE->has_secondary_navigation()) {
echo $OUTPUT->heading(format_string($folder->name));
}
echo $OUTPUT->box_start('generalbox foldertree');
$mform->display();
echo $OUTPUT->box_end();

View File

@ -48,9 +48,12 @@ $strlastmodified = get_string('lastmodified');
$PAGE->set_url('/mod/folder/index.php', array('id' => $course->id));
$PAGE->set_title($course->shortname.': '.$strfolders);
$PAGE->set_heading($course->fullname);
$PAGE->set_secondary_active_tab('coursehome');
$PAGE->navbar->add($strfolders);
echo $OUTPUT->header();
echo $OUTPUT->heading($strfolders);
if (!$PAGE->has_secondary_navigation()) {
echo $OUTPUT->heading($strfolders);
}
if (!$folders = get_all_instances_in_course('folder', $course)) {
notice(get_string('thereareno', 'moodle', $strfolders), "$CFG->wwwroot/course/view.php?id=$course->id");

View File

@ -55,6 +55,32 @@ class mod_folder_renderer extends plugin_renderer_base {
$output .= format_module_intro('folder', $folder, $cm->id, false);
}
}
$buttons = '';
// Display the "Edit" button if current user can edit folder contents.
// Do not display it on the course page for the teachers because there
// is an "Edit settings" button right next to it with the same functionality.
$canmanagefolderfiles = has_capability('mod/folder:managefiles', $context);
$canmanagecourseactivities = has_capability('moodle/course:manageactivities', $context);
if ($canmanagefolderfiles && ($folder->display != FOLDER_DISPLAY_INLINE || !$canmanagecourseactivities)) {
$editbutton = new single_button(new moodle_url('/mod/folder/edit.php', ['id' => $cm->id]),
get_string('edit'), 'post', true);
$buttons .= $this->render($editbutton);
}
// Do not append the edit button on the course page.
$downloadable = folder_archive_available($folder, $cm);
if ($downloadable) {
$downloadbutton = new single_button(new moodle_url('/mod/folder/download_folder.php', ['id' => $cm->id]),
get_string('downloadfolder', 'folder'), 'get');
$downloadbutton->class .= ' ml-auto';
$buttons .= $this->render($downloadbutton);
}
if ($buttons) {
$output .= $this->output->container_start("box generalbox d-flex mb-3 folderbuttons");
$output .= $buttons;
$output .= $this->output->container_end();
}
$foldertree = new folder_tree($folder, $cm);
if ($folder->display == FOLDER_DISPLAY_INLINE) {
@ -65,39 +91,6 @@ class mod_folder_renderer extends plugin_renderer_base {
$output .= $this->render($foldertree);
$output .= $this->output->container_end();
// Do not append the edit button on the course page.
$downloadable = folder_archive_available($folder, $cm);
$buttons = '';
if ($downloadable) {
$downloadbutton = $this->output->single_button(
new moodle_url('/mod/folder/download_folder.php', array('id' => $cm->id)),
get_string('downloadfolder', 'folder'),
'get'
);
$buttons .= $downloadbutton;
}
// Display the "Edit" button if current user can edit folder contents.
// Do not display it on the course page for the teachers because there
// is an "Edit settings" button right next to it with the same functionality.
if (has_capability('mod/folder:managefiles', $context) &&
($folder->display != FOLDER_DISPLAY_INLINE || !has_capability('moodle/course:manageactivities', $context))) {
$editbutton = $this->output->single_button(
new moodle_url('/mod/folder/edit.php', array('id' => $cm->id)),
get_string('edit')
);
$buttons .= $editbutton;
}
if ($buttons) {
$output .= $this->output->container_start("box generalbox pt-0 pb-3 folderbuttons");
$output .= $buttons;
$output .= $this->output->container_end();
}
return $output;
}

View File

@ -24,7 +24,7 @@
defined('MOODLE_INTERNAL') || die();
$plugin->version = 2021052501; // The current module version (Date: YYYYMMDDXX).
$plugin->version = 2021052502; // The current module version (Date: YYYYMMDDXX).
$plugin->requires = 2021052500; // Requires this Moodle version.
$plugin->component = 'mod_folder'; // Full name of the plugin (used for diagnostics)
$plugin->cron = 0;

View File

@ -74,7 +74,9 @@ $output = $PAGE->get_renderer('mod_folder');
echo $output->header();
echo $output->heading(format_string($folder->name), 2);
if (!$PAGE->has_secondary_navigation()) {
echo $output->heading(format_string($folder->name), 2);
}
// Render the activity information.
$cminfo = cm_info::create($cm);