2 // This file is part of Moodle - http://moodle.org/
4 // Moodle is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
9 // Moodle is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License
15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
18 * Contains helper class for the content bank.
20 * @package core_contentbank
21 * @copyright 2020 Amaia Anabitarte <amaia@moodle.com>
22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
25 namespace core_contentbank
;
28 * Helper class for the content bank.
30 * @package core_contentbank
31 * @copyright 2020 Amaia Anabitarte <amaia@moodle.com>
32 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
37 * Getting content bank page ready for the breadcrumbs.
39 * @param \context $context Context of the current page.
40 * @param string $title Title of the current page.
41 * @param bool $internal True if is an internal page, false otherwise.
43 public static function get_page_ready(\context
$context, string $title, bool $internal = false): void
{
46 $PAGE->set_context($context);
47 $cburl = new \
moodle_url('/contentbank/index.php', ['contextid' => $context->id
]);
49 switch ($context->contextlevel
) {
51 $courseid = $context->instanceid
;
52 $course = $DB->get_record('course', ['id' => $courseid], '*', MUST_EXIST
);
53 $PAGE->set_course($course);
54 \navigation_node
::override_active_url(new \
moodle_url('/course/view.php', ['id' => $courseid]));
55 $PAGE->navbar
->add($title, $cburl);
56 $PAGE->set_pagelayout('incourse');
58 case CONTEXT_COURSECAT
:
59 $coursecat = $context->instanceid
;
60 \navigation_node
::override_active_url(new \
moodle_url('/course/index.php', ['categoryid' => $coursecat]));
61 $PAGE->navbar
->add($title, $cburl);
62 $PAGE->set_pagelayout('coursecategory');
65 if ($node = $PAGE->navigation
->find('contentbank', \global_navigation
::TYPE_CUSTOM
)) {
68 $PAGE->set_pagelayout('standard');