From fe5b0dd94ebc1fded7c49e1b65cc16100318a485 Mon Sep 17 00:00:00 2001 From: Alexander Bias Date: Mon, 14 Oct 2024 09:05:20 +0200 Subject: [PATCH] Upgrade: Adopt changes from MDL-81960 and use new \core\url class, at least in our own / non-adopted code. --- CHANGES.md | 1 + classes/output/core_renderer.php | 6 ++-- classes/output/navigation/primary.php | 2 +- classes/output/tool_policy_renderer.php | 2 +- classes/smartmenu_item.php | 8 ++--- classes/table/flavours_overview.php | 8 ++--- classes/table/smartmenus_items.php | 14 ++++---- classes/table/smartmenus_menus.php | 16 ++++----- flavours/edit.php | 18 +++++----- flavours/flavourslib.php | 2 +- flavours/overview.php | 4 +-- flavours/preview.php | 8 ++--- flavours/styles.php | 2 +- locallib.php | 40 ++++++++++----------- locallogin.php | 4 +-- renderers.php | 20 +++++------ settings.php | 48 ++++++++++++------------- settings_infobanner_resetdismissed.php | 6 ++-- settings_overview.php | 14 ++++---- smartmenus/edit.php | 14 ++++---- smartmenus/edit_items.php | 16 ++++----- smartmenus/items.php | 12 +++---- smartmenus/menus.php | 4 +-- 23 files changed, 135 insertions(+), 134 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index b95d50b85d0..e32ae7a7e52 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -6,6 +6,7 @@ Changes ### Unreleased +* 2024-10-14 - Upgrade: Adopt changes from MDL-81960 and use new \core\url class, at least in our own / non-adopted code. * 2024-10-14 - Upgrade: Adopt changes from MDL-81920 and use new \core\lang_string class. * 2024-10-14 - Upgrade: Adopt changes from MDL-81031 and use new \core\user class. * 2024-10-14 - Upgrade: Adopt changes from MDL-66903 and use new \core\component class. diff --git a/classes/output/core_renderer.php b/classes/output/core_renderer.php index 334d8f28090..bbc9ba5f744 100644 --- a/classes/output/core_renderer.php +++ b/classes/output/core_renderer.php @@ -85,7 +85,7 @@ public function favicon() { $hasflavourfavicon = true; // Compose the URL to the flavour's favicon. - $flavourfaviconurl = moodle_url::make_pluginfile_url( + $flavourfaviconurl = \core\url::make_pluginfile_url( context_system::instance()->id, 'theme_boost_union', 'flavours_look_favicon', @@ -167,7 +167,7 @@ public function get_logo_url($maxwidth = null, $maxheight = 200) { $hasflavourlogo = true; // Compose the URL to the flavour's logo. - $flavourlogourl = core\url::make_pluginfile_url( + $flavourlogourl = \core\url::make_pluginfile_url( context_system::instance()->id, 'theme_boost_union', 'flavours_look_logo', @@ -264,7 +264,7 @@ public function get_compact_logo_url($maxwidth = 300, $maxheight = 300) { $hasflavourlogo = true; // Compose the URL to the flavour's compact logo. - $flavourlogourl = core\url::make_pluginfile_url( + $flavourlogourl = \core\url::make_pluginfile_url( context_system::instance()->id, 'theme_boost_union', 'flavours_look_logocompact', diff --git a/classes/output/navigation/primary.php b/classes/output/navigation/primary.php index ded227a4396..a5e72e10e34 100644 --- a/classes/output/navigation/primary.php +++ b/classes/output/navigation/primary.php @@ -201,7 +201,7 @@ public function get_user_menu(renderer_base $output): array { 'text' => get_string('setpreferredlanglink', 'theme_boost_union'), 'link' => true, 'isactive' => false, - 'url' => new \moodle_url('/user/language.php'), + 'url' => new \core\url('/user/language.php'), ]; $sm->items[] = $spfnode; diff --git a/classes/output/tool_policy_renderer.php b/classes/output/tool_policy_renderer.php index 1693141e54d..518882e14fd 100644 --- a/classes/output/tool_policy_renderer.php +++ b/classes/output/tool_policy_renderer.php @@ -34,7 +34,7 @@ class tool_policy_renderer extends \tool_policy\output\renderer { */ public function header() { // Check that only the /admin/tool/policy/viewall.php page is affected. - $pageurl = new \moodle_url('/admin/tool/policy/viewall.php'); + $pageurl = new \core\url('/admin/tool/policy/viewall.php'); if ($pageurl->compare($this->page->url, URL_MATCH_BASE) == true) { // If the admin wants to show navigation on the policy page. diff --git a/classes/smartmenu_item.php b/classes/smartmenu_item.php index 394e13e4c49..a6d5a86b885 100644 --- a/classes/smartmenu_item.php +++ b/classes/smartmenu_item.php @@ -576,7 +576,7 @@ public function get_itemimage($itemid) { // Get the first file. $file = reset($files); - $url = \moodle_url::make_pluginfile_url( + $url = \core\url::make_pluginfile_url( $file->get_contextid(), $file->get_component(), $file->get_filearea(), @@ -625,13 +625,13 @@ protected function generate_heading() { } /** - * Generate the item as static menu item, Send the custom URL to moodle_url to make this work with relative URL. + * Generate the item as static menu item, Send the custom URL to core\url to make this work with relative URL. * * @return string */ protected function generate_static_item() { - $staticurl = new \moodle_url($this->item->url); + $staticurl = new \core\url($this->item->url); return $this->generate_node_data( $this->item->title, // Title. @@ -704,7 +704,7 @@ protected function generate_dynamic_item() { $items = []; // Build the items data into nodes. foreach ($records as $record) { - $url = new \moodle_url('/course/view.php', ['id' => $record->id]); + $url = new \core\url('/course/view.php', ['id' => $record->id]); $rkey = 'item-'.$this->item->id.'-dynamic-'.$record->id; // Get the course image from overview files. $itemimage = $this->get_course_image($record); diff --git a/classes/table/flavours_overview.php b/classes/table/flavours_overview.php index 8c1e701fb97..f52d6129f30 100644 --- a/classes/table/flavours_overview.php +++ b/classes/table/flavours_overview.php @@ -96,7 +96,7 @@ public function col_updown($data) { global $OUTPUT; // Prepare action URL. - $actionurl = new \moodle_url('/theme/boost_union/flavours/overview.php'); + $actionurl = new \core\url('/theme/boost_union/flavours/overview.php'); // Initialize column value. $updown = ''; @@ -182,14 +182,14 @@ public function col_actions($data) { // Preview. $actions[] = [ - 'url' => new \moodle_url('/theme/boost_union/flavours/preview.php', ['id' => $data->id]), + 'url' => new \core\url('/theme/boost_union/flavours/preview.php', ['id' => $data->id]), 'icon' => new \pix_icon('i/search', get_string('flavoursedit', 'theme_boost_union')), 'attributes' => ['class' => 'action-preview'], ]; // Edit. $actions[] = [ - 'url' => new \moodle_url('/theme/boost_union/flavours/edit.php', + 'url' => new \core\url('/theme/boost_union/flavours/edit.php', ['action' => 'edit', 'id' => $data->id, 'sesskey' => sesskey()]), 'icon' => new \pix_icon('t/edit', get_string('flavoursedit', 'theme_boost_union')), 'attributes' => ['class' => 'action-edit'], @@ -197,7 +197,7 @@ public function col_actions($data) { // Delete. $actions[] = [ - 'url' => new \moodle_url('/theme/boost_union/flavours/edit.php', + 'url' => new \core\url('/theme/boost_union/flavours/edit.php', ['action' => 'delete', 'id' => $data->id, 'sesskey' => sesskey()]), 'icon' => new \pix_icon('t/delete', get_string('flavourspreview', 'theme_boost_union')), 'attributes' => ['class' => 'action-delete'], diff --git a/classes/table/smartmenus_items.php b/classes/table/smartmenus_items.php index d538431b94d..26bbbfb25b9 100644 --- a/classes/table/smartmenus_items.php +++ b/classes/table/smartmenus_items.php @@ -231,7 +231,7 @@ public function col_updown($data) { global $OUTPUT; // Prepare action URL. - $actionurl = new \moodle_url('/theme/boost_union/smartmenus/items.php'); + $actionurl = new \core\url('/theme/boost_union/smartmenus/items.php'); // Initialize column value. $updown = ''; @@ -283,7 +283,7 @@ public function col_actions($data) { global $OUTPUT; // Prepare action URL. - $actionurl = new \moodle_url('/theme/boost_union/smartmenus/items.php'); + $actionurl = new \core\url('/theme/boost_union/smartmenus/items.php'); // Initialize actions. $actions = []; @@ -291,13 +291,13 @@ public function col_actions($data) { // Show/Hide. if ($data->visible) { $actions[] = [ - 'url' => new \moodle_url($actionurl, ['action' => 'hide', 'id' => $data->id, 'sesskey' => sesskey()]), + 'url' => new \core\url($actionurl, ['action' => 'hide', 'id' => $data->id, 'sesskey' => sesskey()]), 'icon' => new \pix_icon('t/hide', get_string('hide')), 'attributes' => ['class' => 'action-hide'], ]; } else { $actions[] = [ - 'url' => new \moodle_url($actionurl, ['action' => 'show', 'id' => $data->id, 'sesskey' => sesskey()]), + 'url' => new \core\url($actionurl, ['action' => 'show', 'id' => $data->id, 'sesskey' => sesskey()]), 'icon' => new \pix_icon('t/show', get_string('show')), 'attributes' => ['class' => 'action-show'], ]; @@ -305,7 +305,7 @@ public function col_actions($data) { // Edit. $actions[] = [ - 'url' => new \moodle_url('/theme/boost_union/smartmenus/edit_items.php', + 'url' => new \core\url('/theme/boost_union/smartmenus/edit_items.php', ['id' => $data->id, 'sesskey' => sesskey()]), 'icon' => new \pix_icon('t/edit', get_string('edit')), 'attributes' => ['class' => 'action-edit'], @@ -313,14 +313,14 @@ public function col_actions($data) { // Duplicate. $actions[] = [ - 'url' => new \moodle_url($actionurl, ['action' => 'copy', 'id' => $data->id, 'sesskey' => sesskey()]), + 'url' => new \core\url($actionurl, ['action' => 'copy', 'id' => $data->id, 'sesskey' => sesskey()]), 'icon' => new \pix_icon('t/copy', get_string('smartmenusmenuitemduplicate', 'theme_boost_union')), 'attributes' => ['class' => 'action-copy'], ]; // Delete. $actions[] = [ - 'url' => new \moodle_url($actionurl, ['action' => 'delete', 'id' => $data->id, 'sesskey' => sesskey()]), + 'url' => new \core\url($actionurl, ['action' => 'delete', 'id' => $data->id, 'sesskey' => sesskey()]), 'icon' => new \pix_icon('t/delete', get_string('delete')), 'attributes' => ['class' => 'action-delete'], 'confirm' => new \confirm_action(get_string('smartmenusmenuitemdeleteconfirm', 'theme_boost_union')), diff --git a/classes/table/smartmenus_menus.php b/classes/table/smartmenus_menus.php index c6ad38e923e..7cf275706ad 100644 --- a/classes/table/smartmenus_menus.php +++ b/classes/table/smartmenus_menus.php @@ -150,7 +150,7 @@ public function col_updown($data) { global $OUTPUT; // Prepare action URL. - $actionurl = new \moodle_url('/theme/boost_union/smartmenus/menus.php'); + $actionurl = new \core\url('/theme/boost_union/smartmenus/menus.php'); // Initialize column value. $updown = ''; @@ -202,7 +202,7 @@ public function col_actions($data) { global $OUTPUT; // Prepare action URL. - $actionurl = new \moodle_url('/theme/boost_union/smartmenus/menus.php'); + $actionurl = new \core\url('/theme/boost_union/smartmenus/menus.php'); // Initialize actions. $actions = []; @@ -210,13 +210,13 @@ public function col_actions($data) { // Show/Hide. if ($data->visible) { $actions[] = [ - 'url' => new \moodle_url($actionurl, ['action' => 'hide', 'id' => $data->id, 'sesskey' => sesskey()]), + 'url' => new \core\url($actionurl, ['action' => 'hide', 'id' => $data->id, 'sesskey' => sesskey()]), 'icon' => new \pix_icon('t/hide', get_string('hide')), 'attributes' => ['class' => 'action-hide'], ]; } else { $actions[] = [ - 'url' => new \moodle_url($actionurl, ['action' => 'show', 'id' => $data->id, 'sesskey' => sesskey()]), + 'url' => new \core\url($actionurl, ['action' => 'show', 'id' => $data->id, 'sesskey' => sesskey()]), 'icon' => new \pix_icon('t/show', get_string('show')), 'attributes' => ['class' => 'action-show'], ]; @@ -224,28 +224,28 @@ public function col_actions($data) { // Edit. $actions[] = [ - 'url' => new \moodle_url('/theme/boost_union/smartmenus/edit.php', ['id' => $data->id, 'sesskey' => sesskey()]), + 'url' => new \core\url('/theme/boost_union/smartmenus/edit.php', ['id' => $data->id, 'sesskey' => sesskey()]), 'icon' => new \pix_icon('t/edit', get_string('edit')), 'attributes' => ['class' => 'action-edit'], ]; // Duplicate. $actions[] = [ - 'url' => new \moodle_url($actionurl, ['action' => 'copy', 'id' => $data->id, 'sesskey' => sesskey()]), + 'url' => new \core\url($actionurl, ['action' => 'copy', 'id' => $data->id, 'sesskey' => sesskey()]), 'icon' => new \pix_icon('t/copy', get_string('smartmenusmenuduplicate', 'theme_boost_union')), 'attributes' => ['class' => 'action-copy'], ]; // List items. $actions[] = [ - 'url' => new \moodle_url('/theme/boost_union/smartmenus/items.php', ['menu' => $data->id]), + 'url' => new \core\url('/theme/boost_union/smartmenus/items.php', ['menu' => $data->id]), 'icon' => new \pix_icon('e/bullet_list', get_string('list')), 'attributes' => ['class' => 'action-list-items'], ]; // Delete. $actions[] = [ - 'url' => new \moodle_url($actionurl, ['action' => 'delete', 'id' => $data->id, 'sesskey' => sesskey()]), + 'url' => new \core\url($actionurl, ['action' => 'delete', 'id' => $data->id, 'sesskey' => sesskey()]), 'icon' => new \pix_icon('t/delete', get_string('delete')), 'attributes' => ['class' => 'action-delete'], 'confirm' => new \confirm_action(get_string('smartmenusmenudeleteconfirm', 'theme_boost_union')), diff --git a/flavours/edit.php b/flavours/edit.php index c80ff03a638..d1738ecb34f 100644 --- a/flavours/edit.php +++ b/flavours/edit.php @@ -45,11 +45,11 @@ // Prepare the page. $PAGE->set_context($context); -$PAGE->set_url(new moodle_url('/theme/boost_union/flavours/edit.php', ['action' => $action])); +$PAGE->set_url(new core\url('/theme/boost_union/flavours/edit.php', ['action' => $action])); $PAGE->set_cacheable(false); -$PAGE->navbar->add(get_string('pluginname', 'theme_boost_union'), new moodle_url('/admin/category.php', +$PAGE->navbar->add(get_string('pluginname', 'theme_boost_union'), new core\url('/admin/category.php', ['category' => 'theme_boost_union'])); -$PAGE->navbar->add(get_string('flavoursflavours', 'theme_boost_union'), new moodle_url('/theme/boost_union/flavours/overview.php')); +$PAGE->navbar->add(get_string('flavoursflavours', 'theme_boost_union'), new core\url('/theme/boost_union/flavours/overview.php')); switch ($action) { case 'create': $PAGE->set_title(theme_boost_union_get_externaladminpage_title(get_string('flavourscreateflavour', 'theme_boost_union'))); @@ -138,12 +138,12 @@ \core\notification::success(get_string('flavoursnotificationcreated', 'theme_boost_union')); // Redirect to overview page. - redirect(new moodle_url('/theme/boost_union/flavours/overview.php')); + redirect(new core\url('/theme/boost_union/flavours/overview.php')); // Otherwise if the form was cancelled. } else if ($form->is_cancelled()) { // Redirect to overview page. - redirect(new moodle_url('/theme/boost_union/flavours/overview.php')); + redirect(new core\url('/theme/boost_union/flavours/overview.php')); } break; @@ -212,12 +212,12 @@ \core\notification::success(get_string('flavoursnotificationedited', 'theme_boost_union')); // Redirect to overview page. - redirect(new moodle_url('/theme/boost_union/flavours/overview.php')); + redirect(new core\url('/theme/boost_union/flavours/overview.php')); // Otherwise if the form was cancelled. } else if ($form->is_cancelled()) { // Redirect to overview page. - redirect(new moodle_url('/theme/boost_union/flavours/overview.php')); + redirect(new core\url('/theme/boost_union/flavours/overview.php')); // Otherwise if the form was not yet submitted. } else { @@ -295,12 +295,12 @@ \core\notification::success(get_string('flavoursnotificationdeleted', 'theme_boost_union')); // Redirect to overview page. - redirect(new moodle_url('/theme/boost_union/flavours/overview.php')); + redirect(new core\url('/theme/boost_union/flavours/overview.php')); // Otherwise if the form was cancelled. } else if ($form->is_cancelled()) { // Redirect to overview page. - redirect(new moodle_url('/theme/boost_union/flavours/overview.php')); + redirect(new core\url('/theme/boost_union/flavours/overview.php')); // Otherwise if the form was not yet submitted. } else { diff --git a/flavours/flavourslib.php b/flavours/flavourslib.php index 5ded5fb397c..1f3c8f49d91 100644 --- a/flavours/flavourslib.php +++ b/flavours/flavourslib.php @@ -54,7 +54,7 @@ function theme_boost_union_get_flavour_which_applies() { // Otherwise. } else { // If we are on the preview page. - $previewurl = new moodle_url('/theme/boost_union/flavours/preview.php'); + $previewurl = new core\url('/theme/boost_union/flavours/preview.php'); if ($previewurl->compare($PAGE->url, URL_MATCH_BASE) == true) { // Get the flavour from the URL. $previewflavourid = required_param('id', PARAM_INT); diff --git a/flavours/overview.php b/flavours/overview.php index 05fa51f7823..6234001d8e8 100644 --- a/flavours/overview.php +++ b/flavours/overview.php @@ -47,7 +47,7 @@ // Prepare the page (to make sure that all necessary information is already set even if we just handle the actions as a start). $PAGE->set_context($context); -$PAGE->set_url(new moodle_url('/theme/boost_union/flavours/overview.php')); +$PAGE->set_url(new core\url('/theme/boost_union/flavours/overview.php')); $PAGE->set_cacheable(false); // Process actions. @@ -119,7 +119,7 @@ // Prepare 'Create flavours' button. $createbutton = $OUTPUT->box_start(); $createbutton .= $OUTPUT->single_button( - new \moodle_url('/theme/boost_union/flavours/edit.php', ['action' => 'create', 'sesskey' => sesskey()]), + new \core\url('/theme/boost_union/flavours/edit.php', ['action' => 'create', 'sesskey' => sesskey()]), get_string('flavourscreateflavour', 'theme_boost_union'), 'get'); $createbutton .= $OUTPUT->box_end(); diff --git a/flavours/preview.php b/flavours/preview.php index 4b4b544c466..a14d597c173 100644 --- a/flavours/preview.php +++ b/flavours/preview.php @@ -42,11 +42,11 @@ // Prepare the page. $PAGE->set_context($context); -$PAGE->set_url(new moodle_url('/theme/boost_union/flavours/preview.php', ['id' => $flavourid])); +$PAGE->set_url(new core\url('/theme/boost_union/flavours/preview.php', ['id' => $flavourid])); $PAGE->set_cacheable(false); -$PAGE->navbar->add(get_string('pluginname', 'theme_boost_union'), new moodle_url('/admin/category.php', +$PAGE->navbar->add(get_string('pluginname', 'theme_boost_union'), new core\url('/admin/category.php', ['category' => 'theme_boost_union'])); -$PAGE->navbar->add(get_string('flavoursflavours', 'theme_boost_union'), new moodle_url('/theme/boost_union/flavours/overview.php')); +$PAGE->navbar->add(get_string('flavoursflavours', 'theme_boost_union'), new core\url('/theme/boost_union/flavours/overview.php')); $PAGE->set_title(theme_boost_union_get_externaladminpage_title(get_string('flavourspreviewflavour', 'theme_boost_union'))); $PAGE->set_heading(get_string('flavourspreviewflavour', 'theme_boost_union')); $PAGE->navbar->add(get_string('flavourspreviewflavour', 'theme_boost_union')); @@ -60,7 +60,7 @@ // Show back to overview button. echo $OUTPUT->box_start('text-center'); echo $OUTPUT->single_button( - new \moodle_url('/theme/boost_union/flavours/overview.php'), + new \core\url('/theme/boost_union/flavours/overview.php'), get_string('flavoursbacktooverview', 'theme_boost_union'), 'get'); echo $OUTPUT->box_end(); diff --git a/flavours/styles.php b/flavours/styles.php index 5d67c4b6341..c5ef1c93ed1 100644 --- a/flavours/styles.php +++ b/flavours/styles.php @@ -74,7 +74,7 @@ // If the flavour has a background image. if ($flavour->look_backgroundimage != null) { // Compose the URL to the flavour's background image. - $backgroundimageurl = moodle_url::make_pluginfile_url( + $backgroundimageurl = core\url::make_pluginfile_url( context_system::instance()->id, 'theme_boost_union', 'flavours_look_backgroundimage', $flavourid, '/'.theme_get_revision(), '/'.$flavour->look_backgroundimage); diff --git a/locallib.php b/locallib.php index a0953fb36ab..a246948d53e 100644 --- a/locallib.php +++ b/locallib.php @@ -54,7 +54,7 @@ function theme_boost_union_get_course_related_hints() { $hintcoursehiddentext = ''; // The general hint will only be shown when the course is viewed. - if ($PAGE->url->compare(new moodle_url('/course/view.php'), URL_MATCH_BASE)) { + if ($PAGE->url->compare(new core\url('/course/view.php'), URL_MATCH_BASE)) { // Use the default hint text for hidden courses. $hintcoursehiddentext = get_string('showhintcoursehiddengeneral', 'theme_boost_union'); } @@ -62,9 +62,9 @@ function theme_boost_union_get_course_related_hints() { // If the setting showhintcoursehiddennotifications is set too and we view a forum (e.g. announcement) within a hidden // course a hint will be shown that no notifications via forums will be sent out to students. if (get_config('theme_boost_union', 'showhintforumnotifications') == THEME_BOOST_UNION_SETTING_SELECT_YES - && ($PAGE->url->compare(new moodle_url('/mod/forum/view.php'), URL_MATCH_BASE) || - $PAGE->url->compare(new moodle_url('/mod/forum/discuss.php'), URL_MATCH_BASE) || - $PAGE->url->compare(new moodle_url('/mod/forum/post.php'), URL_MATCH_BASE))) { + && ($PAGE->url->compare(new core\url('/mod/forum/view.php'), URL_MATCH_BASE) || + $PAGE->url->compare(new core\url('/mod/forum/discuss.php'), URL_MATCH_BASE) || + $PAGE->url->compare(new core\url('/mod/forum/post.php'), URL_MATCH_BASE))) { // Use the specialized hint text for hidden courses on forum pages. $hintcoursehiddentext = get_string('showhintforumnotifications', 'theme_boost_union'); } @@ -92,7 +92,7 @@ function theme_boost_union_get_course_related_hints() { if (get_config('theme_boost_union', 'showhintcourseguestaccess') == THEME_BOOST_UNION_SETTING_SELECT_YES && is_guest(\context_course::instance($COURSE->id), $USER->id) && $PAGE->has_set_url() - && $PAGE->url->compare(new moodle_url('/course/view.php'), URL_MATCH_BASE) + && $PAGE->url->compare(new core\url('/course/view.php'), URL_MATCH_BASE) && !is_role_switched($COURSE->id)) { // Require self enrolment library. @@ -132,7 +132,7 @@ function theme_boost_union_get_course_related_hints() { if (get_config('theme_boost_union', 'showhintcourseselfenrol') == THEME_BOOST_UNION_SETTING_SELECT_YES && has_capability('theme/boost_union:viewhintcourseselfenrol', \context_course::instance($COURSE->id)) && $PAGE->has_set_url() - && $PAGE->url->compare(new moodle_url('/course/view.php'), URL_MATCH_BASE) + && $PAGE->url->compare(new core\url('/course/view.php'), URL_MATCH_BASE) && $COURSE->visible == true) { // Get the active enrol instances for this course. @@ -226,7 +226,7 @@ function theme_boost_union_get_course_related_hints() { foreach ($selfenrolinstances as $selfenrolinstanceid => $selfenrolinstanceobject) { // If the user has the capability to config self enrolments, enrich the instance name with the settings link. if (has_capability('enrol/self:config', \context_course::instance($COURSE->id))) { - $url = new moodle_url('/enrol/editinstance.php', ['courseid' => $COURSE->id, + $url = new core\url('/enrol/editinstance.php', ['courseid' => $COURSE->id, 'id' => $selfenrolinstanceid, 'type' => 'self', ]); $selfenrolinstanceobject->name = html_writer::link($url, $selfenrolinstanceobject->name); } @@ -282,7 +282,7 @@ function theme_boost_union_get_course_related_hints() { $role = $opts->metadata['rolename']; // Get the URL to switch back (normal role). - $url = new moodle_url('/course/switchrole.php', + $url = new core\url('/course/switchrole.php', ['id' => $COURSE->id, 'sesskey' => sesskey(), 'switchrole' => 0, @@ -308,7 +308,7 @@ function theme_boost_union_get_course_related_hints() { */ function theme_boost_union_get_staticpage_link($page) { // Compose the URL object. - $url = new moodle_url('/theme/boost_union/pages/'.$page.'.php'); + $url = new core\url('/theme/boost_union/pages/'.$page.'.php'); // Return the string representation of the URL. return $url->out(); @@ -601,7 +601,7 @@ function theme_boost_union_get_urloftilebackgroundimage($tileno) { $file = reset($files); // Build and return the image URL. - return moodle_url::make_pluginfile_url($file->get_contextid(), $file->get_component(), $file->get_filearea(), + return core\url::make_pluginfile_url($file->get_contextid(), $file->get_component(), $file->get_filearea(), $file->get_itemid(), $file->get_filepath(), $file->get_filename()); } @@ -647,7 +647,7 @@ function theme_boost_union_get_urlofslidebackgroundimage($slideno) { $file = reset($files); // Build and return the image URL. - return moodle_url::make_pluginfile_url($file->get_contextid(), $file->get_component(), $file->get_filearea(), + return core\url::make_pluginfile_url($file->get_contextid(), $file->get_component(), $file->get_filearea(), $file->get_itemid(), $file->get_filepath(), $file->get_filename()); } @@ -672,7 +672,7 @@ function theme_boost_union_get_loginbackgroundimage_scss() { foreach ($files as $file) { $count++; // Get url from file. - $url = moodle_url::make_pluginfile_url($file->get_contextid(), $file->get_component(), $file->get_filearea(), + $url = core\url::make_pluginfile_url($file->get_contextid(), $file->get_component(), $file->get_filearea(), $file->get_itemid(), $file->get_filepath(), $file->get_filename()); // Add this url to the body class loginbackgroundimage[n] as a background image. $scss .= 'body.pagelayout-login.loginbackgroundimage'.$count.' {'; @@ -762,8 +762,8 @@ function theme_boost_union_get_additionalresources_templatecontext() { // Iterate over the files and fill the templatecontext of the file list. $filesforcontext = []; foreach ($files as $af) { - $urlpersistent = new moodle_url('/pluginfile.php/1/theme_boost_union/additionalresources/0/'.$af->get_filename()); - $urlrevisioned = new moodle_url('/pluginfile.php/1/theme_boost_union/additionalresources/'.theme_get_revision(). + $urlpersistent = new core\url('/pluginfile.php/1/theme_boost_union/additionalresources/0/'.$af->get_filename()); + $urlrevisioned = new core\url('/pluginfile.php/1/theme_boost_union/additionalresources/'.theme_get_revision(). '/'.$af->get_filename()); $filesforcontext[] = ['filename' => $af->get_filename(), 'filetype' => $af->get_mimetype(), @@ -821,7 +821,7 @@ function theme_boost_union_get_customfonts_templatecontext() { } // Otherwise, fill the templatecontext of the file list. - $urlpersistent = new moodle_url('/pluginfile.php/1/theme_boost_union/customfonts/0/'.$filename); + $urlpersistent = new core\url('/pluginfile.php/1/theme_boost_union/customfonts/0/'.$filename); $filesforcontext[] = ['filename' => $filename, 'fileurlpersistent' => $urlpersistent->out(), ]; } @@ -1027,7 +1027,7 @@ function theme_boost_union_add_flavourcss_to_page() { $flavour = theme_boost_union_get_flavour_which_applies(); if ($flavour != null) { // Build the flavour CSS file URL. - $flavourcssurl = new moodle_url('/theme/boost_union/flavours/styles.php', + $flavourcssurl = new core\url('/theme/boost_union/flavours/styles.php', ['id' => $flavour->id, 'rev' => theme_get_revision()]); // Add the CSS file to the page. @@ -1075,7 +1075,7 @@ function theme_boost_union_get_course_header_image_url() { $file = reset($files); // Build and return the image URL. - return moodle_url::make_pluginfile_url($file->get_contextid(), $file->get_component(), $file->get_filearea(), + return core\url::make_pluginfile_url($file->get_contextid(), $file->get_component(), $file->get_filearea(), $file->get_itemid(), $file->get_filepath(), $file->get_filename()); } @@ -1099,7 +1099,7 @@ function theme_boost_union_set_mobilecss_url() { // This parameter isn't the theme revision as the theme cache is not cleared when this setting is stored. // It is just the time when the setting is saved. // This is the best we can do to make the Mobile app load the new styles when needed. - $mobilescssurl = new moodle_url('/theme/boost_union/mobile/styles.php', ['rev' => time()]); + $mobilescssurl = new core\url('/theme/boost_union/mobile/styles.php', ['rev' => time()]); // Set the $CFG->mobilecssurl setting. set_config('mobilecssurl', $mobilescssurl->out()); @@ -1892,7 +1892,7 @@ function theme_boost_union_get_touchicons_html_for_page() { // If the file exists (i.e. it has been uploaded). if ($file->exists == true) { // Build the file URL. - $fileurl = new moodle_url('/pluginfile.php/1/theme_boost_union/touchiconsios/' . + $fileurl = new core\url('/pluginfile.php/1/theme_boost_union/touchiconsios/' . theme_get_revision().'/'.$file->filename); // Compose and append the HTML tag. @@ -1991,7 +1991,7 @@ function($favourite) { if ($course->visible || $canviewhiddencourses) { $coursesfortemplate[] = [ - 'url' => new \moodle_url('/course/view.php', ['id' => $course->id]), + 'url' => new \core\url('/course/view.php', ['id' => $course->id]), 'fullname' => $course->fullname, 'visible' => $course->visible == 1, ]; diff --git a/locallogin.php b/locallogin.php index c9992b5c4fc..62716ea36b0 100644 --- a/locallogin.php +++ b/locallogin.php @@ -49,7 +49,7 @@ // If the local login is not disabled, we just show a short friendly warning page and are done. if ($config->loginlocalloginenable != THEME_BOOST_UNION_SETTING_SELECT_NO) { echo $OUTPUT->header(); - $loginurl = new moodle_url('/login/index.php'); + $loginurl = new core\url('/login/index.php'); $notification = new \core\output\notification( get_string('loginlocalloginlocalnotdisabled', 'theme_boost_union', ['url' => $loginurl]), \core\output\notification::NOTIFY_INFO); @@ -73,7 +73,7 @@ // Prepare the local login form. $templatecontext = []; -$templatecontext['loginurl'] = new moodle_url('/login/index.php'); +$templatecontext['loginurl'] = new core\url('/login/index.php'); $templatecontext['logintoken'] = \core\session\manager::get_login_token(); // Output the local login form. diff --git a/renderers.php b/renderers.php index a9f6079f7ab..2fb61b5de56 100644 --- a/renderers.php +++ b/renderers.php @@ -46,7 +46,7 @@ public function h5p_alter_styles(&$styles, $libraries, $embedtype) { global $CFG; // Build the H5P CSS file URL. - $h5pcssurl = new moodle_url('/theme/boost_union/h5p/styles.php'); + $h5pcssurl = new core\url('/theme/boost_union/h5p/styles.php'); // Add the CSS file path and a version (to support browser caching) to H5P. $styles[] = (object) [ @@ -59,14 +59,14 @@ public function h5p_alter_styles(&$styles, $libraries, $embedtype) { // If H5P interactive videos are installed. if (isset($libraries['H5P.InteractiveVideo']) && $libraries['H5P.InteractiveVideo']['majorVersion'] == '1') { // Adding H5PEditor css file. - $h5peditoravurl = new moodle_url('/local/och5pcore/lib/style/H5PEditor.AV.css'); + $h5peditoravurl = new core\url('/local/och5pcore/lib/style/H5PEditor.AV.css'); $styles[] = (object) [ 'path' => $h5peditoravurl->out(), 'version' => '?ver='.theme_get_revision(), ]; // Adding opencast font css file. - $ocfontsurl = new moodle_url('/local/och5pcore/lib/style/oc-fonts.css'); + $ocfontsurl = new core\url('/local/och5pcore/lib/style/oc-fonts.css'); $styles[] = (object) [ 'path' => $ocfontsurl->out(), 'version' => '?ver='.theme_get_revision(), @@ -90,14 +90,14 @@ public function h5p_alter_scripts(&$scripts, $libraries, $embedtype) { // If H5P interactive videos are installed. if (isset($libraries['H5P.InteractiveVideo']) && $libraries['H5P.InteractiveVideo']['majorVersion'] == '1') { // Adding LTI related script into scripts array. - $h5prunltiurl = new moodle_url('/local/och5pcore/lib/js/H5PRunLTI.js'); + $h5prunltiurl = new core\url('/local/och5pcore/lib/js/H5PRunLTI.js'); $scripts[] = (object) [ 'path' => $h5prunltiurl->out(), 'version' => '?ver='.theme_get_revision(), ]; // Adding editor script to scripts array. - $h5peditoravurl = new moodle_url('/local/och5pcore/lib/js/H5PEditor.AV.js'); + $h5peditoravurl = new core\url('/local/och5pcore/lib/js/H5PEditor.AV.js'); $scripts[] = (object) [ 'path' => $h5peditoravurl->out(), 'version' => '?ver='.theme_get_revision(), @@ -135,7 +135,7 @@ public function hvp_alter_styles(&$styles, $libraries, $embedtype) { global $CFG; // Build the H5P CSS file URL. - $h5pcssurl = new moodle_url('/theme/boost_union/h5p/styles.php'); + $h5pcssurl = new core\url('/theme/boost_union/h5p/styles.php'); // Add the CSS file path and a version (to support browser caching) to H5P. $styles[] = (object)[ @@ -148,14 +148,14 @@ public function hvp_alter_styles(&$styles, $libraries, $embedtype) { // If H5P interactive videos are installed. if (isset($libraries['H5P.InteractiveVideo']) && $libraries['H5P.InteractiveVideo']['majorVersion'] == '1') { // Adding H5PEditor css file. - $h5peditoravurl = new moodle_url('/local/och5p/lib/style/H5PEditor.AV.css'); + $h5peditoravurl = new core\url('/local/och5p/lib/style/H5PEditor.AV.css'); $styles[] = (object) [ 'path' => $h5peditoravurl->out(), 'version' => '?ver='.theme_get_revision(), ]; // Adding opencast font css file. - $ocfontsurl = new moodle_url('/local/och5p/lib/style/oc-fonts.css'); + $ocfontsurl = new core\url('/local/och5p/lib/style/oc-fonts.css'); $styles[] = (object) [ 'path' => $ocfontsurl->out(), 'version' => '?ver='.theme_get_revision(), @@ -179,14 +179,14 @@ public function hvp_alter_scripts(&$scripts, $libraries, $embedtype) { // If H5P interactive videos are installed. if (isset($libraries['H5P.InteractiveVideo']) && $libraries['H5P.InteractiveVideo']['majorVersion'] == '1') { // Adding LTI related script into scripts array. - $h5prunltiurl = new moodle_url('/local/och5p/lib/js/H5PRunLTI.js'); + $h5prunltiurl = new core\url('/local/och5p/lib/js/H5PRunLTI.js'); $scripts[] = (object) [ 'path' => $h5prunltiurl->out(), 'version' => '?ver='.theme_get_revision(), ]; // Adding editor script to scripts array. - $h5peditoravurl = new moodle_url('/local/och5p/lib/js/H5PEditor.AV.js'); + $h5peditoravurl = new core\url('/local/och5p/lib/js/H5PEditor.AV.js'); $scripts[] = (object) [ 'path' => $h5peditoravurl->out(), 'version' => '?ver='.theme_get_revision(), diff --git a/settings.php b/settings.php index 199cafeb3a2..7772d97f7bf 100644 --- a/settings.php +++ b/settings.php @@ -45,9 +45,9 @@ // settings and which is automatically linked from the theme selector page. // To avoid that there appears a broken "Boost Union" settings page, we redirect the user to a settings // overview page if he opens this page. - $mainsettingspageurl = new moodle_url('/admin/settings.php', ['section' => 'themesettingboost_union']); + $mainsettingspageurl = new core\url('/admin/settings.php', ['section' => 'themesettingboost_union']); if ($ADMIN->fulltree && $PAGE->has_set_url() && $PAGE->url->compare($mainsettingspageurl)) { - redirect(new moodle_url('/theme/boost_union/settings_overview.php')); + redirect(new core\url('/theme/boost_union/settings_overview.php')); } // Create custom admin settings category. @@ -60,7 +60,7 @@ // (and allow users with the theme/boost_union:configure capability to access it). $overviewpage = new admin_externalpage('theme_boost_union_overview', get_string('settingsoverview', 'theme_boost_union', null, true), - new moodle_url('/theme/boost_union/settings_overview.php'), + new core\url('/theme/boost_union/settings_overview.php'), 'theme/boost_union:configure'); $ADMIN->add('theme_boost_union', $overviewpage); @@ -96,7 +96,7 @@ // (and allow users with the theme/boost_union:configure capability to access it). $flavourspage = new admin_externalpage('theme_boost_union_flavours', get_string('configtitleflavours', 'theme_boost_union', null, true), - new moodle_url('/theme/boost_union/flavours/overview.php'), + new core\url('/theme/boost_union/flavours/overview.php'), 'theme/boost_union:configure'); $ADMIN->add('theme_boost_union', $flavourspage); @@ -104,7 +104,7 @@ // (and allow users with the theme/boost_union:configure capability to access it). $smartmenuspage = new admin_externalpage('theme_boost_union_smartmenus', get_string('smartmenus', 'theme_boost_union', null, true), - new moodle_url('/theme/boost_union/smartmenus/menus.php'), + new core\url('/theme/boost_union/smartmenus/menus.php'), 'theme/boost_union:configure'); $ADMIN->add('theme_boost_union', $smartmenuspage); } @@ -138,7 +138,7 @@ // Create theme presets heading. $name = 'theme_boost_union/presetheading'; - $preseturl = new moodle_url('/admin/settings.php', ['section' => 'themesettingboost'], 'theme_boost_general'); + $preseturl = new core\url('/admin/settings.php', ['section' => 'themesettingboost'], 'theme_boost_general'); $title = get_string('presetheading', 'theme_boost_union', null, true); $description = get_string('presetheading_desc', 'theme_boost_union', null, true).'
'. // We would love to use $OUTPUT->single_button($preseturl, ...) here, but this results in the fact @@ -183,7 +183,7 @@ // Create external SCSS heading. $name = 'theme_boost_union/extscssheading'; $title = get_string('extscssheading', 'theme_boost_union', null, true); - $taskurl = new moodle_url('/admin/tool/task/scheduledtasks.php', + $taskurl = new core\url('/admin/tool/task/scheduledtasks.php', ['action' => 'edit', 'task' => 'theme_boost_union\task\purge_cache']); $description = get_string('extscssheading_desc', 'theme_boost_union', null, true).'

'. get_string('extscssheading_instr', 'theme_boost_union', null, true). @@ -370,7 +370,7 @@ // Create logos heading. $name = 'theme_boost_union/logosheading'; $title = get_string('logosheading', 'theme_boost_union', null, true); - $notificationurl = new moodle_url('/admin/settings.php', ['section' => 'logos']); + $notificationurl = new core\url('/admin/settings.php', ['section' => 'logos']); $notification = new \core\output\notification(get_string('logosheading_desc', 'theme_boost_union', $notificationurl->out()), \core\output\notification::NOTIFY_INFO); $notification->set_show_closebutton(false); @@ -399,7 +399,7 @@ // Create favicon heading. $name = 'theme_boost_union/faviconheading'; $title = get_string('faviconheading', 'theme_boost_union', null, true); - $notificationurl = new moodle_url('/admin/settings.php', ['section' => 'logos']); + $notificationurl = new core\url('/admin/settings.php', ['section' => 'logos']); $notification = new \core\output\notification(get_string('faviconheading_desc', 'theme_boost_union', $notificationurl->out()), \core\output\notification::NOTIFY_INFO); $notification->set_show_closebutton(false); @@ -765,7 +765,7 @@ // Setting: Local login. $name = 'theme_boost_union/loginlocalloginenable'; $title = get_string('loginlocalloginenablesetting', 'theme_boost_union', null, true); - $localloginurl = new moodle_url('/theme/boost_union/locallogin.php'); + $localloginurl = new core\url('/theme/boost_union/locallogin.php'); $description = get_string('loginlocalloginenablesetting_desc', 'theme_boost_union', null, true).'

'. get_string('loginlocalloginenablesetting_note', 'theme_boost_union', ['url' => $localloginurl], true); $setting = new admin_setting_configselect($name, $title, $description, THEME_BOOST_UNION_SETTING_SELECT_YES, $yesnooption); @@ -1060,7 +1060,7 @@ $title = ''; $description = '

'.get_string('emailbrandinginstruction', 'theme_boost_union', null, true).'

'; $description .= '

'.get_string('emailbrandinginstruction0', 'theme_boost_union', null, true).'

'; - $emailbrandinginstructionli1url = new moodle_url('/admin/tool/customlang/index.php', ['lng' => $CFG->lang]); + $emailbrandinginstructionli1url = new core\url('/admin/tool/customlang/index.php', ['lng' => $CFG->lang]); $description .= '