From 60150bd06812c4f3fab863ee7a17552a9c268b6e Mon Sep 17 00:00:00 2001 From: Peter Dias Date: Thu, 16 Dec 2021 07:35:07 +0800 Subject: [PATCH] MDL-73360 glossary: Add heading when creating entries --- mod/glossary/classes/output/standard_action_bar.php | 6 +++++- mod/glossary/edit.php | 10 +++++++++- mod/glossary/export.php | 2 ++ mod/glossary/import.php | 7 +++++-- mod/glossary/import_form.php | 2 +- mod/glossary/showentry.php | 5 +++++ mod/glossary/templates/standard_action_menu.mustache | 3 ++- 7 files changed, 29 insertions(+), 6 deletions(-) diff --git a/mod/glossary/classes/output/standard_action_bar.php b/mod/glossary/classes/output/standard_action_bar.php index 699b6ac782d..cce62a628be 100644 --- a/mod/glossary/classes/output/standard_action_bar.php +++ b/mod/glossary/classes/output/standard_action_bar.php @@ -175,6 +175,7 @@ class standard_action_bar implements renderable, templatable { global $USER, $CFG; $items = []; $buttons = []; + $openinnewwindow = []; if (has_capability('mod/glossary:import', $this->context)) { $items['button'] = new single_button( @@ -204,6 +205,7 @@ class standard_action_bar implements renderable, templatable { ); $printurl = new moodle_url('/mod/glossary/print.php', $params); $buttons[get_string('printerfriendly', 'glossary')] = $printurl->out(false); + $openinnewwindow[] = $printurl->out(false); } if (!empty($CFG->enablerssfeeds) && !empty($CFG->glossary_enablerssfeeds) @@ -213,6 +215,7 @@ class standard_action_bar implements renderable, templatable { $string = get_string('rssfeed', 'glossary'); $url = new moodle_url(rss_get_url($this->context->id, $USER->id, 'mod_glossary', $this->cm->instance)); $buttons[$string] = $url->out(false); + $openinnewwindow[] = $url->out(false); } foreach ($items as $key => $value) { @@ -223,7 +226,8 @@ class standard_action_bar implements renderable, templatable { foreach ($buttons as $index => $value) { $items['select']['options'][] = [ 'url' => $value, - 'string' => $index + 'string' => $index, + 'openinnewwindow' => ($openinnewwindow ? in_array($value, $openinnewwindow) : false) ]; } } diff --git a/mod/glossary/edit.php b/mod/glossary/edit.php index 7a3841604cd..d48d4e64d46 100644 --- a/mod/glossary/edit.php +++ b/mod/glossary/edit.php @@ -83,8 +83,16 @@ if (!empty($id)) { $PAGE->set_title($glossary->name); $PAGE->set_heading($course->fullname); $PAGE->set_secondary_active_tab('modulepage'); -$PAGE->activityheader->set_hidecompletion(true); +$PAGE->activityheader->set_attrs([ + 'hidecompletion' => true, + 'description' => '' +]); echo $OUTPUT->header(); +if (!$id) { + echo $OUTPUT->heading(get_string('addsingleentry', 'mod_glossary')); +} else { + echo $OUTPUT->heading(get_string('editentry', 'mod_glossary')); +} $data = new StdClass(); $data->tags = core_tag_tag::get_item_tags_array('mod_glossary', 'glossary_entries', $id); diff --git a/mod/glossary/export.php b/mod/glossary/export.php index cd91134951e..0cf95b48929 100644 --- a/mod/glossary/export.php +++ b/mod/glossary/export.php @@ -54,6 +54,8 @@ $PAGE->set_secondary_active_tab('modulepage'); $PAGE->activityheader->disable(); echo $OUTPUT->header(); +echo html_writer::link(new moodle_url('view.php', ['id' => $cm->id]), + get_string('back'), ['class' => 'btn btn-secondary mb-2']); echo $OUTPUT->heading($strexportentries); echo $OUTPUT->box_start('glossarydisplay generalbox'); $exporturl = moodle_url::make_pluginfile_url($context->id, 'mod_glossary', 'export', 0, "/$cat/", 'export.xml', true); diff --git a/mod/glossary/import.php b/mod/glossary/import.php index b2e90c0ee1d..942c5372e45 100644 --- a/mod/glossary/import.php +++ b/mod/glossary/import.php @@ -52,11 +52,14 @@ $PAGE->set_heading($course->fullname); $PAGE->set_secondary_active_tab('modulepage'); $PAGE->activityheader->disable(); +$form = new mod_glossary_import_form(''); +if ($form->is_cancelled()) { + redirect(new moodle_url('view.php', ['id' => $id])); +} + echo $OUTPUT->header(); echo $OUTPUT->heading($strimportentries); -$form = new mod_glossary_import_form(); - if ( !$data = $form->get_data() ) { echo $OUTPUT->box_start('glossarydisplay generalbox'); // display upload form diff --git a/mod/glossary/import_form.php b/mod/glossary/import_form.php index 22255c1a1c7..ae9ceabb0f9 100644 --- a/mod/glossary/import_form.php +++ b/mod/glossary/import_form.php @@ -23,6 +23,6 @@ class mod_glossary_import_form extends moodleform { $submit_string = get_string('submit'); $mform->addElement('hidden', 'id'); $mform->setType('id', PARAM_INT); - $this->add_action_buttons(false, $submit_string); + $this->add_action_buttons(true, $submit_string); } } diff --git a/mod/glossary/showentry.php b/mod/glossary/showentry.php index 8a85f48ee81..89706ccad03 100644 --- a/mod/glossary/showentry.php +++ b/mod/glossary/showentry.php @@ -79,6 +79,11 @@ if (!empty($courseid)) { echo $OUTPUT->header(); // Needs to be something here to allow linking back to the whole glossary } +if ($glossary) { + $url = new moodle_url('view.php', ['id' => $cm->id]); + echo html_writer::link($url, get_string('back'), ['class' => 'btn btn-secondary mb-2']); +} + if ($entries) { glossary_print_dynaentry($courseid, $entries, $displayformat); } diff --git a/mod/glossary/templates/standard_action_menu.mustache b/mod/glossary/templates/standard_action_menu.mustache index a45ce837296..cb35d1873fe 100644 --- a/mod/glossary/templates/standard_action_menu.mustache +++ b/mod/glossary/templates/standard_action_menu.mustache @@ -142,7 +142,8 @@