diff --git a/mod/wiki/admin.php b/mod/wiki/admin.php index 03a835aaa98..1537e01775d 100644 --- a/mod/wiki/admin.php +++ b/mod/wiki/admin.php @@ -105,7 +105,7 @@ if (!empty($toversion) && !empty($fromversion) && confirm_sesskey()) { } //show actual page -$wikipage = new page_wiki_admin($wiki, $subwiki, $cm); +$wikipage = new page_wiki_admin($wiki, $subwiki, $cm, 'modulepage'); $wikipage->set_page($page); $wikipage->print_header(); diff --git a/mod/wiki/classes/output/action_bar.php b/mod/wiki/classes/output/action_bar.php new file mode 100644 index 00000000000..de9672133e3 --- /dev/null +++ b/mod/wiki/classes/output/action_bar.php @@ -0,0 +1,125 @@ +. + +namespace mod_wiki\output; + +use moodle_url; +use templatable; +use renderable; + +/** + * Renderable class for the action bar elements in the wiki activity pages. + * + * @package mod_wiki + * @copyright 2021 Mihail Geshoski + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +class action_bar implements templatable, renderable { + + /** @var int $pageid The database module id. */ + private $pageid; + + /** @var moodle_url $currenturl The URL of the current page. */ + private $currenturl; + + /** @var bool $displayprint Whether to display print wiki button. */ + private $displayprint; + + /** + * The class constructor. + * + * @param int $pageid The wiki page id. + * @param moodle_url $pageurl The URL of the current page. + * @param bool $displayprint Whether to display print wiki button. + */ + public function __construct(int $pageid, moodle_url $pageurl, bool $displayprint = false) { + $this->pageid = $pageid; + $this->currenturl = $pageurl; + $this->displayprint = $displayprint; + } + + /** + * Export the data for the mustache template. + * + * @param \renderer_base $output renderer to be used to render the action bar elements. + * @return array + */ + public function export_for_template(\renderer_base $output): array { + + $urlselect = $this->get_action_selector(); + + $data = [ + 'urlselect' => $urlselect->export_for_template($output), + ]; + + if ($this->displayprint) { + $printlink = new moodle_url('/mod/wiki/prettyview.php', ['pageid' => $this->pageid]); + + $data['printbutton'] = \html_writer::link($printlink, get_string('print', 'mod_wiki'), + ['class' => 'btn btn-secondary', 'target' => "_blank"]); + } + + return $data; + } + + /** + * Returns the URL selector object. + * + * @return \url_select The URL select object. + */ + private function get_action_selector(): \url_select { + global $PAGE; + + $menu = []; + + if (has_capability('mod/wiki:viewpage', $PAGE->context)) { + $viewlink = new moodle_url('/mod/wiki/view.php', ['pageid' => $this->pageid]); + $menu[$viewlink->out(false)] = get_string('view', 'mod_wiki'); + } + + if (has_capability('mod/wiki:editpage', $PAGE->context)) { + $editlink = new moodle_url('/mod/wiki/edit.php', ['pageid' => $this->pageid]); + $menu[$editlink->out(false)] = get_string('edit', 'mod_wiki'); + } + + if (has_capability('mod/wiki:viewcomment', $PAGE->context)) { + $commentslink = new moodle_url('/mod/wiki/comments.php', ['pageid' => $this->pageid]); + $menu[$commentslink->out(false)] = get_string('comments', 'mod_wiki'); + } + + if (has_capability('mod/wiki:viewpage', $PAGE->context)) { + $historylink = new moodle_url('/mod/wiki/history.php', ['pageid' => $this->pageid]); + $menu[$historylink->out(false)] = get_string('history', 'mod_wiki'); + } + + if (has_capability('mod/wiki:viewpage', $PAGE->context)) { + $maplink = new moodle_url('/mod/wiki/map.php', ['pageid' => $this->pageid]); + $menu[$maplink->out(false)] = get_string('map', 'mod_wiki'); + } + + if (has_capability('mod/wiki:viewpage', $PAGE->context)) { + $fileslink = new moodle_url('/mod/wiki/files.php', ['pageid' => $this->pageid]); + $menu[$fileslink->out(false)] = get_string('files', 'mod_wiki'); + } + + if (has_capability('mod/wiki:managewiki', $PAGE->context)) { + $adminlink = new moodle_url('/mod/wiki/admin.php', ['pageid' => $this->pageid]); + $menu[$adminlink->out(false)] = get_string('admin', 'mod_wiki'); + } + + return new \url_select($menu, $this->currenturl->out(false), null, 'wikiactionselect'); + } +} diff --git a/mod/wiki/comments.php b/mod/wiki/comments.php index b5149000797..3f3bffcbb32 100644 --- a/mod/wiki/comments.php +++ b/mod/wiki/comments.php @@ -75,7 +75,7 @@ $event->add_record_snapshot('wiki_subwikis', $subwiki); $event->trigger(); /// Print the page header -$wikipage = new page_wiki_comments($wiki, $subwiki, $cm); +$wikipage = new page_wiki_comments($wiki, $subwiki, $cm, 'modulepage'); $wikipage->set_page($page); diff --git a/mod/wiki/comments_form.php b/mod/wiki/comments_form.php index c8769f9379f..e3dfc168d08 100644 --- a/mod/wiki/comments_form.php +++ b/mod/wiki/comments_form.php @@ -27,7 +27,7 @@ class mod_wiki_comments_form extends moodleform { //------------------------------------------------------------------------------- // buttons - $this->add_action_buttons(false); + $this->add_action_buttons(true); //------------------------------------------------------------------------------- $this->set_data($current); diff --git a/mod/wiki/diff.php b/mod/wiki/diff.php index 71c232ad06b..0c9e9e602f7 100644 --- a/mod/wiki/diff.php +++ b/mod/wiki/diff.php @@ -72,7 +72,7 @@ if (!wiki_user_can_view($subwiki, $wiki)) { print_error('cannotviewpage', 'wiki'); } -$wikipage = new page_wiki_diff($wiki, $subwiki, $cm); +$wikipage = new page_wiki_diff($wiki, $subwiki, $cm, 'modulepage'); $wikipage->set_page($page); $wikipage->set_comparison($compare, $comparewith); diff --git a/mod/wiki/edit.php b/mod/wiki/edit.php index 58b7c09b26f..2bf77a85abd 100644 --- a/mod/wiki/edit.php +++ b/mod/wiki/edit.php @@ -93,7 +93,7 @@ if ($option == get_string('save', 'wiki')) { if (!confirm_sesskey()) { print_error(get_string('invalidsesskey', 'wiki')); } - $wikipage = new page_wiki_preview($wiki, $subwiki, $cm); + $wikipage = new page_wiki_preview($wiki, $subwiki, $cm, 'modulepage'); $wikipage->set_page($page); } else { if ($option == get_string('cancel')) { @@ -102,7 +102,7 @@ if ($option == get_string('save', 'wiki')) { redirect($CFG->wwwroot . '/mod/wiki/view.php?pageid=' . $pageid); } else { - $wikipage = new page_wiki_edit($wiki, $subwiki, $cm); + $wikipage = new page_wiki_edit($wiki, $subwiki, $cm, 'modulepage'); $wikipage->set_page($page); $wikipage->set_upload($option == get_string('upload', 'wiki')); } diff --git a/mod/wiki/editcomments.php b/mod/wiki/editcomments.php index 03229d31eed..ebdddb4cbf6 100644 --- a/mod/wiki/editcomments.php +++ b/mod/wiki/editcomments.php @@ -58,7 +58,7 @@ if (!wiki_user_can_view($subwiki, $wiki)) { print_error('cannotviewpage', 'wiki'); } -$editcomments = new page_wiki_editcomment($wiki, $subwiki, $cm); +$editcomments = new page_wiki_editcomment($wiki, $subwiki, $cm, 'modulepage'); $comment = new stdClass(); if ($action == 'edit') { if (!$comment = $DB->get_record('comments', array('id' => $commentid))) { diff --git a/mod/wiki/files.php b/mod/wiki/files.php index f7730a24d74..16f3f732e89 100644 --- a/mod/wiki/files.php +++ b/mod/wiki/files.php @@ -75,8 +75,8 @@ $course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST) $context = context_module::instance($cm->id); - -$PAGE->set_url('/mod/wiki/files.php', array('pageid'=>$pageid)); +$url = new moodle_url('/mod/wiki/files.php', ['pageid' => $pageid]); +$PAGE->set_url($url); require_course_login($course, true, $cm); if (!wiki_user_can_view($subwiki, $wiki)) { @@ -86,8 +86,12 @@ if (!wiki_user_can_view($subwiki, $wiki)) { $PAGE->set_title(get_string('wikifiles', 'wiki')); $PAGE->set_heading($course->fullname); $PAGE->navbar->add(format_string(get_string('wikifiles', 'wiki'))); +$PAGE->set_secondary_active_tab('modulepage'); + echo $OUTPUT->header(); -echo $OUTPUT->heading(format_string($wiki->name)); +if (!$PAGE->has_secondary_navigation()) { + echo $OUTPUT->heading(format_string($wiki->name)); +} // Render the activity information. $cminfo = cm_info::create($cm); @@ -95,15 +99,12 @@ $completiondetails = \core_completion\cm_completion_details::get_instance($cminf $activitydates = \core\activity_dates::get_dates_for_module($cminfo, $USER->id); echo $OUTPUT->activity_information($cminfo, $completiondetails, $activitydates); -echo $OUTPUT->box(format_module_intro('wiki', $wiki, $PAGE->cm->id), 'generalbox', 'intro'); - $renderer = $PAGE->get_renderer('mod_wiki'); -$tabitems = array('view' => 'view', 'edit' => 'edit', 'comments' => 'comments', 'history' => 'history', 'map' => 'map', 'files' => 'files', 'admin' => 'admin'); - -$options = array('activetab'=>'files'); -echo $renderer->tabs($page, $tabitems, $options); +echo $OUTPUT->box(format_module_intro('wiki', $wiki, $PAGE->cm->id), 'generalbox', 'intro'); +$actionbar = new \mod_wiki\output\action_bar($pageid, $PAGE->url); +echo $renderer->render_action_bar($actionbar); echo $OUTPUT->box_start('generalbox'); echo $renderer->wiki_print_subwiki_selector($PAGE->activityrecord, $subwiki, $page, 'files'); diff --git a/mod/wiki/filesedit.php b/mod/wiki/filesedit.php index 91ed22e61a2..41d363ebd32 100644 --- a/mod/wiki/filesedit.php +++ b/mod/wiki/filesedit.php @@ -78,6 +78,7 @@ $PAGE->set_title($title); $PAGE->set_heading($course->fullname); $PAGE->navbar->add(format_string(get_string('wikifiles', 'wiki')), $CFG->wwwroot . '/mod/wiki/files.php?pageid=' . $pageid); $PAGE->navbar->add(format_string($title)); +$PAGE->set_secondary_active_tab('modulepage'); $data = new stdClass(); $data->returnurl = $returnurl; diff --git a/mod/wiki/history.php b/mod/wiki/history.php index 8ef5f6a112e..e9a8abaaa7b 100644 --- a/mod/wiki/history.php +++ b/mod/wiki/history.php @@ -77,7 +77,7 @@ $event->add_record_snapshot('wiki_subwikis', $subwiki); $event->trigger(); /// Print the page header -$wikipage = new page_wiki_history($wiki, $subwiki, $cm); +$wikipage = new page_wiki_history($wiki, $subwiki, $cm, 'modulepage'); $wikipage->set_page($page); $wikipage->set_paging($paging); diff --git a/mod/wiki/instancecomments.php b/mod/wiki/instancecomments.php index b2466b6b57a..32e99c09ef8 100644 --- a/mod/wiki/instancecomments.php +++ b/mod/wiki/instancecomments.php @@ -69,15 +69,15 @@ if ($action == 'add' || $action == 'edit') { if (!confirm_sesskey()) { print_error(get_string('invalidsesskey', 'wiki')); } - $comm = new page_wiki_handlecomments($wiki, $subwiki, $cm); + $comm = new page_wiki_handlecomments($wiki, $subwiki, $cm, 'modulepage'); $comm->set_page($page); } else { if(!$confirm) { - $comm = new page_wiki_deletecomment($wiki, $subwiki, $cm); + $comm = new page_wiki_deletecomment($wiki, $subwiki, $cm, 'modulepage'); $comm->set_page($page); $comm->set_url(); } else { - $comm = new page_wiki_handlecomments($wiki, $subwiki, $cm); + $comm = new page_wiki_handlecomments($wiki, $subwiki, $cm, 'modulepage'); $comm->set_page($page); if (!confirm_sesskey()) { print_error(get_string('invalidsesskey', 'wiki')); @@ -90,6 +90,9 @@ if ($action == 'delete') { } else { if (empty($newcontent)) { $form = new mod_wiki_comments_form(); + if ($form->is_cancelled()) { + redirect(new moodle_url('/mod/wiki/comments.php', ['pageid' => (int)$pageid])); + } $newcomment = $form->get_data(); $content = $newcomment->entrycomment_editor['text']; } else { diff --git a/mod/wiki/map.php b/mod/wiki/map.php index 63657e45c2b..9d32c031b0e 100644 --- a/mod/wiki/map.php +++ b/mod/wiki/map.php @@ -59,7 +59,7 @@ if (!wiki_user_can_view($subwiki, $wiki)) { print_error('cannotviewpage', 'wiki'); } -$wikipage = new page_wiki_map($wiki, $subwiki, $cm); +$wikipage = new page_wiki_map($wiki, $subwiki, $cm, 'modulepage'); $context = context_module::instance($cm->id); $event = \mod_wiki\event\page_map_viewed::create( diff --git a/mod/wiki/pagelib.php b/mod/wiki/pagelib.php index 3020e107f07..97e4e2709f7 100644 --- a/mod/wiki/pagelib.php +++ b/mod/wiki/pagelib.php @@ -93,13 +93,14 @@ abstract class page_wiki { protected $cm; /** - * page_wiki constructor + * The page_wiki constructor. * - * @param $wiki. Current wiki - * @param $subwiki. Current subwiki. - * @param $cm. Current course_module. + * @param stdClass $wiki Current wiki + * @param stdClass $subwiki Current subwiki. + * @param stdClass $cm Current course_module. + * @param string|null $activesecondarytab Secondary navigation node to be activated on the page, if required */ - function __construct($wiki, $subwiki, $cm) { + public function __construct($wiki, $subwiki, $cm, ?string $activesecondarytab = null) { global $PAGE, $CFG; $this->subwiki = $subwiki; $this->cm = $cm; @@ -110,6 +111,9 @@ abstract class page_wiki { $PAGE->set_cacheable(true); $PAGE->set_cm($cm); $PAGE->set_activity_record($wiki); + if ($activesecondarytab) { + $PAGE->set_secondary_active_tab($activesecondarytab); + } // the search box if (!empty($subwiki->id)) { $search = optional_param('searchstring', null, PARAM_TEXT); @@ -126,27 +130,38 @@ abstract class page_wiki { $PAGE->set_heading($PAGE->course->fullname); $this->set_url(); - if (isset($SESSION->wikipreviousurl) && is_array($SESSION->wikipreviousurl)) { $this->process_session_url(); } $this->set_session_url(); $this->create_navbar(); - $this->setup_tabs(); echo $OUTPUT->header(); $wiki = $PAGE->activityrecord; - echo $OUTPUT->heading(format_string($wiki->name)); + if (!$PAGE->has_secondary_navigation()) { + echo $OUTPUT->heading(format_string($wiki->name)); + } echo $this->wikioutput->wiki_info(); - // tabs are associated with pageid, so if page is empty, tabs should be disabled - if (!empty($this->page) && !empty($this->tabs)) { - echo $this->wikioutput->tabs($this->page, $this->tabs, $this->tabs_options); + if (!empty($this->page)) { + echo $this->action_bar($this->page->id, $PAGE->url); } } + /** + * This method returns the action bar. + * + * @param int $pageid The page id. + * @param moodle_url $pageurl The page url. + * @return string The HTML for the action bar. + */ + protected function action_bar(int $pageid, moodle_url $pageurl): string { + $actionbar = new \mod_wiki\output\action_bar($pageid, $pageurl); + return $this->wikioutput->render_action_bar($actionbar); + } + /** * Protected method to print current page title. */ @@ -302,15 +317,23 @@ class page_wiki_view extends page_wiki { $this->wikioutput->wiki_print_subwiki_selector($PAGE->activityrecord, $this->subwiki, $this->page, 'view'); - if (!empty($this->page)) { - echo $this->wikioutput->prettyview_link($this->page); - } - //echo $this->wikioutput->page_index(); $this->print_pagetitle(); } + /** + * This method returns the action bar. + * + * @param int $pageid The page id. + * @param moodle_url $pageurl The page url. + * @return string The HTML for the action bar. + */ + protected function action_bar(int $pageid, moodle_url $pageurl): string { + $actionbar = new \mod_wiki\output\action_bar($pageid, $pageurl, true); + return $this->wikioutput->render_action_bar($actionbar); + } + function print_content() { global $PAGE, $CFG; @@ -379,9 +402,17 @@ class page_wiki_edit extends page_wiki { protected $deleteuploads = array(); protected $format; - function __construct($wiki, $subwiki, $cm) { + /** + * The page_wiki_edit constructor. + * + * @param stdClass $wiki Current wiki + * @param stdClass $subwiki Current subwiki. + * @param stdClass $cm Current course_module. + * @param string|null $activesecondarytab Secondary navigation node to be activated on the page, if required + */ + public function __construct($wiki, $subwiki, $cm, ?string $activesecondarytab = null) { global $CFG, $PAGE; - parent::__construct($wiki, $subwiki, $cm); + parent::__construct($wiki, $subwiki, $cm, $activesecondarytab); $showfilemanager = false; if (has_capability('mod/wiki:managefiles', context_module::instance($cm->id))) { $showfilemanager = true; @@ -773,6 +804,18 @@ class page_wiki_editcomment extends page_wiki { parent::setup_tabs(array('linkedwhenactive' => 'comments', 'activetab' => 'comments')); } + /** + * This method returns the action bar. + * + * @param int $pageid The page id. + * @param moodle_url $pageurl The page url. + * @return string The HTML for the action bar. + */ + protected function action_bar(int $pageid, moodle_url $pageurl): string { + // The given page does not require an action bar. + return ''; + } + private function add_comment_form() { global $CFG; require_once($CFG->dirroot . '/mod/wiki/editors/wiki_editor.php'); @@ -1126,6 +1169,18 @@ class page_wiki_diff extends page_wiki { parent::setup_tabs(array('linkedwhenactive' => 'history', 'activetab' => 'history')); } + /** + * This method returns the action bar. + * + * @param int $pageid The page id. + * @param moodle_url $pageurl The page url. + * @return string The HTML for the action bar. + */ + protected function action_bar(int $pageid, moodle_url $pageurl): string { + $backlink = new moodle_url('/mod/wiki/history.php', ['pageid' => $pageid]); + return html_writer::link($backlink, get_string('back'), ['class' => 'btn btn-secondary mb-4']); + } + /** * Given two versions of a page, prints a page displaying the differences between them. * @@ -1181,9 +1236,17 @@ class page_wiki_history extends page_wiki { */ private $allversion; - function __construct($wiki, $subwiki, $cm) { + /** + * The page_wiki_history constructor. + * + * @param stdClass $wiki Current wiki. + * @param stdClass $subwiki Current subwiki. + * @param stdClass $cm Current course_module. + * @param string|null $activesecondarytab Secondary navigation node to be activated on the page, if required + */ + public function __construct($wiki, $subwiki, $cm, ?string $activesecondarytab = null) { global $PAGE; - parent::__construct($wiki, $subwiki, $cm); + parent::__construct($wiki, $subwiki, $cm, $activesecondarytab); $PAGE->requires->js_init_call('M.mod_wiki.history', null, true); } @@ -1871,6 +1934,18 @@ class page_wiki_restoreversion extends page_wiki { parent::setup_tabs(array('linkedwhenactive' => 'history', 'activetab' => 'history')); } + /** + * This method returns the action bar. + * + * @param int $pageid The page id. + * @param moodle_url $pageurl The page url. + * @return string The HTML for the action bar. + */ + protected function action_bar(int $pageid, moodle_url $pageurl): string { + // The given page does not require an action bar. + return ''; + } + /** * Prints the restore version content * @@ -1892,13 +1967,12 @@ class page_wiki_restoreversion extends page_wiki { echo $OUTPUT->container_start(); echo html_writer::tag('div', get_string('restoreconfirm', 'wiki', $version->version)); - echo $OUTPUT->container_start(false, 'wiki_restoreform'); - echo '
'; - echo '
'; - echo '
'; - echo '
'; - echo '
'; - echo '
'; + echo $OUTPUT->container_start('mt-2', 'wiki_restoreform'); + $yesbutton = new single_button($restoreurl, get_string('yes'), 'post'); + $nobutton = new single_button($return, get_string('no'), 'post'); + $nobutton->class .= ' ml-2'; + echo $OUTPUT->render($yesbutton); + echo $OUTPUT->render($nobutton); echo $OUTPUT->container_end(); echo $OUTPUT->container_end(); } @@ -1941,6 +2015,18 @@ class page_wiki_deletecomment extends page_wiki { parent::setup_tabs(array('linkedwhenactive' => 'comments', 'activetab' => 'comments')); } + /** + * This method returns the action bar. + * + * @param int $pageid The page id. + * @param moodle_url $pageurl The page url. + * @return string The HTML for the action bar. + */ + protected function action_bar(int $pageid, moodle_url $pageurl): string { + // The given page does not require an action bar. + return ''; + } + /** * Prints the comment deletion confirmation form */ @@ -2096,6 +2182,18 @@ class page_wiki_viewversion extends page_wiki { parent::setup_tabs(array('linkedwhenactive' => 'history', 'activetab' => 'history', 'inactivetabs' => array('edit'))); } + /** + * This method returns the action bar. + * + * @param int $pageid The page id. + * @param moodle_url $pageurl The page url. + * @return string The HTML for the action bar. + */ + protected function action_bar(int $pageid, moodle_url $pageurl): string { + $backlink = new moodle_url('/mod/wiki/history.php', ['pageid' => $pageid]); + return html_writer::link($backlink, get_string('back'), ['class' => 'btn btn-secondary mb-4']); + } + /** * Given an old page version, output the version content * @@ -2400,10 +2498,11 @@ class page_wiki_admin extends page_wiki { * @param mixed $wiki instance of wiki * @param mixed $subwiki instance of subwiki * @param stdClass $cm course module + * @param string|null $activesecondarytab Secondary navigation node to be activated on the page, if required */ - function __construct($wiki, $subwiki, $cm) { + public function __construct($wiki, $subwiki, $cm, ?string $activesecondarytab = null) { global $PAGE; - parent::__construct($wiki, $subwiki, $cm); + parent::__construct($wiki, $subwiki, $cm, $activesecondarytab); $PAGE->requires->js_init_call('M.mod_wiki.deleteversion', null, true); } diff --git a/mod/wiki/renderer.php b/mod/wiki/renderer.php index 3f40fe7745d..78214a19bbc 100644 --- a/mod/wiki/renderer.php +++ b/mod/wiki/renderer.php @@ -542,6 +542,17 @@ class mod_wiki_renderer extends plugin_renderer_base { return $result; } + + /** + * Renders the action bar. + * + * @param \mod_wiki\output\action_bar $actionbar + * @return string The HTML output + */ + public function render_action_bar(\mod_wiki\output\action_bar $actionbar): string { + $data = $actionbar->export_for_template($this); + return $this->render_from_template('mod_wiki/action_bar', $data); + } } class wiki_files_tree implements renderable { diff --git a/mod/wiki/restoreversion.php b/mod/wiki/restoreversion.php index 71245efc094..2f5302a32d2 100644 --- a/mod/wiki/restoreversion.php +++ b/mod/wiki/restoreversion.php @@ -74,7 +74,7 @@ if ($confirm) { } else { - $wikipage = new page_wiki_restoreversion($wiki, $subwiki, $cm); + $wikipage = new page_wiki_restoreversion($wiki, $subwiki, $cm, 'modulepage'); $wikipage->set_page($page); $wikipage->set_versionid($versionid); diff --git a/mod/wiki/styles.css b/mod/wiki/styles.css index 8ee518f6cd8..d54754eb01f 100644 --- a/mod/wiki/styles.css +++ b/mod/wiki/styles.css @@ -123,16 +123,6 @@ border: thin solid black; } -.wiki_restore_yes, -.wiki_deletecomment_yes { - float: left; -} - -.wiki_restore_no, -.wiki_deletecomment_no { - float: right; -} - .wiki_restoreform, .wiki_deletecommentform { width: 10%; diff --git a/mod/wiki/templates/action_bar.mustache b/mod/wiki/templates/action_bar.mustache new file mode 100644 index 00000000000..5bc9e873e35 --- /dev/null +++ b/mod/wiki/templates/action_bar.mustache @@ -0,0 +1,58 @@ +{{! + 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 details. + You should have received a copy of the GNU General Public License + along with Moodle. If not, see . +}} +{{! + @template mod_wiki/action_bar + + Actions bar at the top of the wiki pages. + + Context variables required for this template: + * urlselect - The data object containing the required properties to render core/url_select. + * printbutton - The HTML for the print button. + + Example context (json): + { + "urlselect": { + "id": "url_select_test", + "action": "https://example.com/post", + "formid": "url_select_form", + "sesskey": "sesskey", + "classes": "urlselect", + "label": "", + "helpicon": false, + "showbutton": null, + "options": [ + { + "name": "Some name", + "value": "/mod/data/someurl.php", + "selected": false + } + ], + "disabled": false, + "title": null + }, + "printbutton": "Print" + } +}} +
+
+
+ {{#urlselect}} + {{>core/url_select}} + {{/urlselect}} +
+
+ {{{printbutton}}} +
+
+
diff --git a/mod/wiki/version.php b/mod/wiki/version.php index 564ad991ec5..1b6b9e9a059 100644 --- a/mod/wiki/version.php +++ b/mod/wiki/version.php @@ -33,6 +33,6 @@ defined('MOODLE_INTERNAL') || die(); -$plugin->version = 2021052500; // The current module version (Date: YYYYMMDDXX). +$plugin->version = 2021052501; // The current module version (Date: YYYYMMDDXX). $plugin->requires = 2021052500; // Requires this Moodle version. $plugin->component = 'mod_wiki'; // Full name of the plugin (used for diagnostics) diff --git a/mod/wiki/viewversion.php b/mod/wiki/viewversion.php index 6c622a105a1..5fad2fdac49 100644 --- a/mod/wiki/viewversion.php +++ b/mod/wiki/viewversion.php @@ -64,7 +64,7 @@ if (!wiki_user_can_view($subwiki, $wiki)) { print_error('cannotviewpage', 'wiki'); } -$wikipage = new page_wiki_viewversion($wiki, $subwiki, $cm); +$wikipage = new page_wiki_viewversion($wiki, $subwiki, $cm, 'modulepage'); $wikipage->set_page($page); $wikipage->set_versionid($versionid);