Skip to content

Commit f3cf545

Browse files
committed
Change Moodle class names (MDL-81918)
1 parent d095941 commit f3cf545

17 files changed

Lines changed: 119 additions & 81 deletions

classes/coursecontentheaderfooter.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,23 @@
2424
*/
2525
namespace format_multitopic;
2626

27+
use core\output\html_writer;
28+
use core\output\renderable;
29+
use core\url;
30+
2731
/**
2832
* Course content header/footer: Back to course button.
2933
*
3034
* @copyright 2019 James Calder and Otago Polytechnic
3135
* @copyright based on work by 2009 Tim Hunt
3236
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
3337
*/
34-
class coursecontentheaderfooter implements \renderable {
38+
class coursecontentheaderfooter implements renderable {
3539
// See https://docs.moodle.org/dev/Course_formats#Additional_footer_or_header_on_any_page_inside_the_course .
3640

3741
/** @var int -1 for header, 1 for footer */
3842
private $pos;
39-
/** @var \moodle_url URL for relevant course section */
43+
/** @var url URL for relevant course section */
4044
private $sectionurl;
4145

4246
/**
@@ -78,7 +82,7 @@ public function output(): string {
7882
if ($this->sectionurl) {
7983
$strback = get_string_manager()->string_exists('back_to_course', 'format_multitopic') ?
8084
get_string('back_to_course', 'format_multitopic') : get_string('back');
81-
$o .= \html_writer::tag(
85+
$o .= html_writer::tag(
8286
'a',
8387
$OUTPUT->pix_icon('t/left', '') . ' ' . $strback,
8488
['href' => $this->sectionurl]
@@ -89,9 +93,9 @@ public function output(): string {
8993
// Horizontal rule to separate header/footer from page content.
9094
if ($o) {
9195
if ($this->pos < 0) {
92-
$o = $o . \html_writer::empty_tag('hr');
96+
$o = $o . html_writer::empty_tag('hr');
9397
} else if ($this->pos > 0) {
94-
$o = \html_writer::empty_tag('hr') . $o;
98+
$o = html_writer::empty_tag('hr') . $o;
9599
}
96100
}
97101

classes/courseformat/sectionactions.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
namespace format_multitopic\courseformat;
1818

1919
use stdClass;
20+
use core\exception\moodle_exception;
2021
use core_courseformat\local\sectionactions as base_sectionactions;
2122

2223
/**
@@ -95,7 +96,7 @@ public function fmt_create_from_object(stdClass $fields, bool $skipcheck = false
9596
!empty($fields->component) ? 2 : 1
9697
);
9798
$sectionrecord->section = $movednews[$sectionrecord->id]->section;
98-
} catch (\moodle_exception $e) {
99+
} catch (moodle_exception $e) {
99100
$DB->delete_records('course_sections', ['id' => $sectionrecord->id]);
100101
throw $e;
101102
}

classes/courseformat/stateactions.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
require_once(__DIR__ . '/../../locallib.php');
2222

23+
use core\exception\moodle_exception;
2324
use format_multitopic;
2425

2526
/**
@@ -57,7 +58,7 @@ public function fmt_section_move_before(
5758
): void {
5859
// Validate target elements.
5960
if (!$targetsectionid) {
60-
throw new \moodle_exception("Action fmt_section_move_before requires targetsectionid");
61+
throw new moodle_exception("Action fmt_section_move_before requires targetsectionid");
6162
}
6263

6364
$this->validate_sections($course, $ids, __FUNCTION__);
@@ -135,7 +136,7 @@ public function section_move_after(
135136
): void {
136137
// Validate target elements.
137138
if (!$targetsectionid) {
138-
throw new \moodle_exception("Action section_move_after requires targetsectionid");
139+
throw new moodle_exception("Action section_move_after requires targetsectionid");
139140
}
140141

141142
$this->validate_sections($course, $ids, __FUNCTION__);
@@ -213,7 +214,7 @@ public function fmt_section_move_into(
213214
): void {
214215
// Validate target elements.
215216
if (!$targetsectionid) {
216-
throw new \moodle_exception("Action section_move_into requires targetsectionid");
217+
throw new moodle_exception("Action section_move_into requires targetsectionid");
217218
}
218219

219220
$this->validate_sections($course, $ids, __FUNCTION__);

classes/courseheader.php

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,20 @@
2323
*/
2424
namespace format_multitopic;
2525

26+
use core\output\html_writer;
27+
use core\output\renderable;
28+
use core\url;
29+
2630
/**
2731
* Course header: A banner with the course title and a slice of the course image.
2832
*
2933
* @copyright 2019 James Calder and Otago Polytechnic
3034
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
3135
*/
32-
class courseheader implements \renderable {
36+
class courseheader implements renderable {
3337
// See https://docs.moodle.org/dev/Course_formats#Additional_footer_or_header_on_any_page_inside_the_course .
3438

35-
/** @var \moodle_url|null course image URL */
39+
/** @var url|null course image URL */
3640
private $imageurl;
3741
/** @var string|null course image name */
3842
private $imagename;
@@ -72,7 +76,7 @@ public function __construct(\stdClass $course) {
7276
$filename = $file->get_filename();
7377
$filenameextpos = strrpos($filename, '.');
7478
if ($filenameextpos) {
75-
$url = \moodle_url::make_file_url(
79+
$url = url::make_file_url(
7680
'/pluginfile.php',
7781
'/' . $file->get_contextid() . '/course/overviewfiles' . $file->get_filepath() . $filename
7882
);
@@ -94,22 +98,22 @@ public function output(): string {
9498

9599
// Output the banner.
96100
// NOTE: Changes here need to be reflected in _course_edit.js .
97-
$o = \html_writer::start_tag('div', [
101+
$o = html_writer::start_tag('div', [
98102
'id' => 'course-header-banner',
99103
'style' => "background-image: url('{$this->imageurl}'); "
100104
. "background-position: center {$this->bannerslice}%;",
101105
]);
102-
$o .= \html_writer::tag('div', $this->coursename, [
106+
$o .= html_writer::tag('div', $this->coursename, [
103107
'id' => 'course-header-banner-text',
104108
'class' => 'h2',
105109
]);
106-
$o .= \html_writer::end_tag('div');
110+
$o .= html_writer::end_tag('div');
107111

108112
// Output the attribution.
109-
$o .= \html_writer::start_tag('p', ['id' => 'course-header-banner_attribution',
113+
$o .= html_writer::start_tag('p', ['id' => 'course-header-banner_attribution',
110114
'style' => 'visibility: ' . ($this->imageurl ? 'visible' : 'hidden') . ';', ]);
111115
$o .= format_multitopic_image_attribution($this->imagename, $this->authorwithurl, $this->licencecode);
112-
$o .= \html_writer::end_tag('p');
116+
$o .= html_writer::end_tag('p');
113117

114118
return $o;
115119
}

classes/output/courseformat/content.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,9 @@
2525

2626
namespace format_multitopic\output\courseformat;
2727

28+
use core\exception\moodle_exception;
29+
use core\output\renderer_base;
2830
use core_courseformat\output\local\content as content_base;
29-
use renderer_base;
3031

3132
/**
3233
* Base class to render a course format.
@@ -43,7 +44,7 @@ class content extends content_base {
4344
* @param renderer_base $output typically, the renderer that's calling this function
4445
* @return \stdClass data context for a mustache template
4546
*/
46-
public function export_for_template(\renderer_base $output) {
47+
public function export_for_template(renderer_base $output) {
4748
global $CFG;
4849
global $PAGE;
4950

@@ -101,7 +102,7 @@ public function export_for_template(\renderer_base $output) {
101102
) {
102103
// This section doesn't exist or is not available for the user.
103104
// We actually already check this in course/view.php but just in case exit from this function as well.
104-
throw new \moodle_exception(
105+
throw new moodle_exception(
105106
'unknowncoursesection',
106107
'error',
107108
course_get_url($course),

classes/output/courseformat/content/addsection.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525

2626
namespace format_multitopic\output\courseformat\content;
2727

28+
use core\output\renderer_base;
29+
use core\url;
2830
use core_courseformat\output\local\content\addsection as addsection_base;
2931
use core_courseformat\base as course_format;
3032
use section_info;
@@ -66,12 +68,12 @@ public function __construct(course_format $format, ?section_info $targetsection
6668
* Note to course format developers: inserting sections in the other positions should check both
6769
* capabilities 'moodle/course:update' and 'moodle/course:movesections'.
6870
*
69-
* @param \renderer_base $output typically, the renderer that's calling this function
71+
* @param renderer_base $output typically, the renderer that's calling this function
7072
* @param int $lastsection the last section number
7173
* @param int $maxsections the maximum number of sections (deprecated since Moodle 5.1)
7274
* @return stdClass data context for a mustache template
7375
*/
74-
protected function get_add_section_data(\renderer_base $output, int $lastsection, int $maxsections = 0): stdClass {
76+
protected function get_add_section_data(renderer_base $output, int $lastsection, int $maxsections = 0): stdClass {
7577
$format = $this->format;
7678
$course = $format->get_course();
7779
$data = parent::get_add_section_data($output, $lastsection, $maxsections);
@@ -84,7 +86,7 @@ protected function get_add_section_data(\renderer_base $output, int $lastsection
8486
'courseid' => $course->id, // CHANGED.
8587
'insertlevel' => FORMAT_MULTITOPIC_SECTION_LEVEL_TOPIC,
8688
'sesskey' => sesskey(),
87-
'returnurl' => new \moodle_url(
89+
'returnurl' => new url(
8890
"/course/view.php?id={$course->id}"
8991
. (($format->get_sectionid() != $format->fmtrootsectionid) ?
9092
"&sectionid={$format->get_sectionid()}" : "")
@@ -96,7 +98,7 @@ protected function get_add_section_data(\renderer_base $output, int $lastsection
9698
$params['insertparentid'] = $format->get_sectionid();
9799
}
98100

99-
$data->addsections->url = new \moodle_url('/course/format/multitopic/_course_changenumsections.php', $params);
101+
$data->addsections->url = new url('/course/format/multitopic/_course_changenumsections.php', $params);
100102
$data->addsections->title = $addstring;
101103

102104
return $data;

classes/output/courseformat/content/section.php

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
namespace format_multitopic\output\courseformat\content;
2727

28+
use core\output\renderer_base;
2829
use core_courseformat\output\local\content\section as section_base;
2930
use core_courseformat\base as course_format;
3031

@@ -57,10 +58,10 @@ public function __construct(course_format $format, \section_info $section) {
5758
/**
5859
* Export this data so it can be used as the context for a mustache template.
5960
*
60-
* @param \renderer_base $output typically, the renderer that's calling this function
61+
* @param renderer_base $output typically, the renderer that's calling this function
6162
* @return \stdClass data context for a mustache template
6263
*/
63-
public function export_for_template(\renderer_base $output): \stdClass {
64+
public function export_for_template(renderer_base $output): \stdClass {
6465
$format = $this->format;
6566

6667
$data = parent::export_for_template($output);
@@ -84,10 +85,10 @@ public function export_for_template(\renderer_base $output): \stdClass {
8485
* Add the section header to the data structure.
8586
*
8687
* @param \stdClass $data the current cm data reference
87-
* @param \renderer_base $output typically, the renderer that's calling this function
88+
* @param renderer_base $output typically, the renderer that's calling this function
8889
* @return bool if the cm has name data
8990
*/
90-
protected function add_header_data(\stdClass &$data, \renderer_base $output): bool {
91+
protected function add_header_data(\stdClass &$data, renderer_base $output): bool {
9192
$result = parent::add_header_data($data, $output);
9293
if (!$result || !empty($this->section->component)) {
9394
return $result;
@@ -104,10 +105,10 @@ protected function add_header_data(\stdClass &$data, \renderer_base $output): bo
104105
* Add the section cm list to the data structure.
105106
*
106107
* @param \stdClass $data the current cm data reference
107-
* @param \renderer_base $output typically, the renderer that's calling this function
108+
* @param renderer_base $output typically, the renderer that's calling this function
108109
* @return bool if the cm has name data
109110
*/
110-
protected function add_cm_data(\stdClass &$data, \renderer_base $output): bool {
111+
protected function add_cm_data(\stdClass &$data, renderer_base $output): bool {
111112
$result = false;
112113

113114
$section = $this->section;
@@ -135,10 +136,10 @@ protected function add_cm_data(\stdClass &$data, \renderer_base $output): bool {
135136
* Add the section editor attributes to the data structure.
136137
*
137138
* @param \stdClass $data the current cm data reference
138-
* @param \renderer_base $output typically, the renderer that's calling this function
139+
* @param renderer_base $output typically, the renderer that's calling this function
139140
* @return bool if the cm has name data
140141
*/
141-
protected function add_editor_data(\stdClass &$data, \renderer_base $output): bool {
142+
protected function add_editor_data(\stdClass &$data, renderer_base $output): bool {
142143
$result = parent::add_editor_data($data, $output);
143144

144145
if (!empty($this->section->component) || !$result) {
@@ -157,10 +158,10 @@ protected function add_editor_data(\stdClass &$data, \renderer_base $output): bo
157158
*
158159
* @param \stdClass $data the current cm data reference
159160
* @param bool[] $haspartials the result of loading partial data elements
160-
* @param \renderer_base $output typically, the renderer that's calling this function
161+
* @param renderer_base $output typically, the renderer that's calling this function
161162
* @return bool if the cm has name data
162163
*/
163-
protected function add_format_data(\stdClass &$data, array $haspartials, \renderer_base $output): bool {
164+
protected function add_format_data(\stdClass &$data, array $haspartials, renderer_base $output): bool {
164165
$section = $this->section;
165166

166167
$result = parent::add_format_data($data, $haspartials, $output);

classes/output/courseformat/content/section/header.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
namespace format_multitopic\output\courseformat\content\section;
2727

28+
use core\output\renderer_base;
2829
use core_courseformat\output\local\content\section\header as header_base;
2930

3031
/**
@@ -53,10 +54,10 @@ public function __construct(\format_multitopic $format, \section_info $section)
5354
/**
5455
* Export this data so it can be used as the context for a mustache template.
5556
*
56-
* @param \renderer_base $output typically, the renderer that's calling this function
57+
* @param renderer_base $output typically, the renderer that's calling this function
5758
* @return \stdClass data context for a mustache template
5859
*/
59-
public function export_for_template(\renderer_base $output): \stdClass {
60+
public function export_for_template(renderer_base $output): \stdClass {
6061
$format = $this->format;
6162
$section = $this->section;
6263
$sectionextra = $this->fmtsectionextra;

classes/output/courseformat/content/section/summary.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
namespace format_multitopic\output\courseformat\content\section;
2828

2929
use context_course;
30+
use core\output\html_writer;
31+
use core\url;
3032
use core_courseformat\output\local\content\section\summary as summary_base;
3133

3234
/**
@@ -67,7 +69,7 @@ public function format_summary_text(): string {
6769
$filename = $file->get_filename();
6870
$filenameextpos = strrpos($filename, '.');
6971
if ((substr($filename, 0, 4) == 'goi_') && $filenameextpos) {
70-
$imageurl = \moodle_url::make_file_url(
72+
$imageurl = url::make_file_url(
7173
'/pluginfile.php',
7274
"/{$file->get_contextid()}/course/section/{$section->id}{$file->get_filepath()}{$filename}"
7375
);
@@ -82,12 +84,12 @@ public function format_summary_text(): string {
8284

8385
// Output section image, if any.
8486
if (isset($imageurl)) {
85-
$o .= \html_writer::start_tag('div', ['class' => 'section_image_holder']);
86-
$o .= \html_writer::empty_tag('img', ['src' => $imageurl]);
87-
$o .= \html_writer::start_tag('p');
87+
$o .= html_writer::start_tag('div', ['class' => 'section_image_holder']);
88+
$o .= html_writer::empty_tag('img', ['src' => $imageurl]);
89+
$o .= html_writer::start_tag('p');
8890
$o .= \format_multitopic_image_attribution($imagename, $authorwithurl, $licencecode);
89-
$o .= \html_writer::end_tag('p');
90-
$o .= \html_writer::end_tag('div');
91+
$o .= html_writer::end_tag('p');
92+
$o .= html_writer::end_tag('div');
9193
}
9294
// END ADDED.
9395

classes/output/courseformat/content/sectionnavigation.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
namespace format_multitopic\output\courseformat\content;
2626

27+
use core\output\renderer_base;
2728
use core_courseformat\output\local\content\sectionnavigation as sectionnavigation_base;
2829
use core_courseformat\base as course_format;
2930
use stdClass;
@@ -60,10 +61,10 @@ public function __construct(course_format $format, $section) {
6061
/**
6162
* Export this data so it can be used as the context for a mustache template.
6263
*
63-
* @param \renderer_base $output typically, the renderer that's calling this function
64+
* @param renderer_base $output typically, the renderer that's calling this function
6465
* @return stdClass data context for a mustache template
6566
*/
66-
public function export_for_template(\renderer_base $output): stdClass {
67+
public function export_for_template(renderer_base $output): stdClass {
6768

6869
if ($this->data !== null) {
6970
return $this->data;

0 commit comments

Comments
 (0)