diff --git a/blocks/classes/output/block_contents.php b/blocks/classes/output/block_contents.php index a18800bbe1b..aeb12971102 100644 --- a/blocks/classes/output/block_contents.php +++ b/blocks/classes/output/block_contents.php @@ -14,6 +14,8 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . +namespace core_block\output; + /** * This class represents how a block appears on a page. * @@ -32,7 +34,6 @@ * @category output */ class block_contents { - /** Used when the block cannot be collapsed **/ const NOT_HIDEABLE = 0; @@ -159,3 +160,8 @@ class block_contents { return isset($this->attributes['data-block']) && $this->attributes['data-block'] == '_fake'; } } + +// Alias this class to the old name. +// This file will be autoloaded by the legacyclasses autoload system. +// In future all uses of this class will be corrected and the legacy references will be removed. +class_alias(block_contents::class, \block_contents::class); diff --git a/blocks/classes/output/block_move_target.php b/blocks/classes/output/block_move_target.php index c0312747b8b..d698ac21c7d 100644 --- a/blocks/classes/output/block_move_target.php +++ b/blocks/classes/output/block_move_target.php @@ -14,6 +14,10 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . +namespace core_block\output; + +use moodle_url; + /** * This class represents a target for where a block can go when it is being moved. * @@ -28,17 +32,19 @@ * @category output */ class block_move_target { - /** - * @var moodle_url Move url - */ - public $url; - - /** - * Constructor + * Constructor. + * * @param moodle_url $url */ - public function __construct(moodle_url $url) { - $this->url = $url; + public function __construct( + /** @var moodle_url Move url */ + public moodle_url $url, + ) { } } + +// Alias this class to the old name. +// This file will be autoloaded by the legacyclasses autoload system. +// In future all uses of this class will be corrected and the legacy references will be removed. +class_alias(block_move_target::class, \block_move_target::class); diff --git a/lib/classes/output/action_link.php b/lib/classes/output/action_link.php index ae006adfe27..bb094108d05 100644 --- a/lib/classes/output/action_link.php +++ b/lib/classes/output/action_link.php @@ -14,6 +14,12 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . +namespace core\output; + +use core\output\actions\component_action; +use moodle_url; +use stdClass; + /** * Data structure describing html link with special action attached. * @@ -24,7 +30,6 @@ * @category output */ class action_link implements renderable { - /** * @var moodle_url Href url */ @@ -154,3 +159,8 @@ class action_link implements renderable { return $data; } } + +// Alias this class to the old name. +// This file will be autoloaded by the legacyclasses autoload system. +// In future all uses of this class will be corrected and the legacy references will be removed. +class_alias(action_link::class, \action_link::class); diff --git a/lib/classes/output/action_menu.php b/lib/classes/output/action_menu.php index 2906f1c86fa..1bbdeb22cc2 100644 --- a/lib/classes/output/action_menu.php +++ b/lib/classes/output/action_menu.php @@ -14,7 +14,15 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . +namespace core\output; + +use core\exception\coding_exception; use core\output\local\action_menu\subpanel; +use core\output\action_menu\link as action_menu_link; +use core\output\action_menu\filler as action_menu_filler; +use lang_string; +use moodle_page; +use stdClass; /** * An action menu. @@ -29,7 +37,6 @@ use core\output\local\action_menu\subpanel; * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class action_menu implements renderable, templatable { - /** * Top right alignment. */ @@ -664,3 +671,8 @@ class action_menu implements renderable, templatable { return $secondary; } } + +// Alias this class to the old name. +// This file will be autoloaded by the legacyclasses autoload system. +// In future all uses of this class will be corrected and the legacy references will be removed. +class_alias(action_menu::class, \action_menu::class); diff --git a/lib/classes/output/action_menu/filler.php b/lib/classes/output/action_menu/filler.php index 2a2fe9a0d00..1d8863ebb87 100644 --- a/lib/classes/output/action_menu/filler.php +++ b/lib/classes/output/action_menu/filler.php @@ -14,6 +14,12 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . +namespace core\output\action_menu; + +use core\output\action_link; +use core\output\html_writer; +use core\output\renderable; + /** * An action menu filler * @@ -22,8 +28,7 @@ * @copyright 2013 Andrew Nicols * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -class action_menu_filler extends action_link implements renderable { - +class filler extends action_link implements renderable { /** * True if this is a primary action. False if not. * @var bool @@ -37,3 +42,8 @@ class action_menu_filler extends action_link implements renderable { $this->attributes['id'] = html_writer::random_id('action_link'); } } + +// Alias this class to the old name. +// This file will be autoloaded by the legacyclasses autoload system. +// In future all uses of this class will be corrected and the legacy references will be removed. +class_alias(filler::class, \action_menu_filler::class); diff --git a/lib/classes/output/action_menu/link.php b/lib/classes/output/action_menu/link.php index d91abd646bc..af440be5ec3 100644 --- a/lib/classes/output/action_menu/link.php +++ b/lib/classes/output/action_menu/link.php @@ -14,6 +14,16 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . +namespace core\output\action_menu; + +use core\output\action_menu; +use core\output\action_link; +use core\output\pix_icon; +use core\output\renderable; +use core\output\renderer_base; +use moodle_url; +use stdClass; + /** * An action menu action * @@ -22,7 +32,7 @@ * @copyright 2013 Sam Hemelryk * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -class action_menu_link extends action_link implements renderable { +class link extends action_link implements renderable { /** * True if this is a primary action. False if not. @@ -104,3 +114,8 @@ class action_menu_link extends action_link implements renderable { return $data; } } + +// Alias this class to the old name. +// This file will be autoloaded by the legacyclasses autoload system. +// In future all uses of this class will be corrected and the legacy references will be removed. +class_alias(link::class, \action_menu_link::class); diff --git a/lib/classes/output/action_menu/link_primary.php b/lib/classes/output/action_menu/link_primary.php index 7359fbe4d61..3a251d93023 100644 --- a/lib/classes/output/action_menu/link_primary.php +++ b/lib/classes/output/action_menu/link_primary.php @@ -14,6 +14,11 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . +namespace core\output\action_menu; + +use core\output\pix_icon; +use moodle_url; + /** * A primary action menu action * @@ -22,7 +27,7 @@ * @copyright 2013 Sam Hemelryk * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -class action_menu_link_primary extends action_menu_link { +class link_primary extends link { /** * Constructs the object. * @@ -35,3 +40,8 @@ class action_menu_link_primary extends action_menu_link { parent::__construct($url, $icon, $text, true, $attributes); } } + +// Alias this class to the old name. +// This file will be autoloaded by the legacyclasses autoload system. +// In future all uses of this class will be corrected and the legacy references will be removed. +class_alias(link_primary::class, \action_menu_link_primary::class); diff --git a/lib/classes/output/action_menu/link_secondary.php b/lib/classes/output/action_menu/link_secondary.php index 45780a1f9ea..5f71598ac15 100644 --- a/lib/classes/output/action_menu/link_secondary.php +++ b/lib/classes/output/action_menu/link_secondary.php @@ -14,6 +14,11 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . +namespace core\output\action_menu; + +use core\output\pix_icon; +use moodle_url; + /** * A secondary action menu action * @@ -22,7 +27,7 @@ * @copyright 2013 Sam Hemelryk * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -class action_menu_link_secondary extends action_menu_link { +class link_secondary extends link { /** * Constructs the object. * @@ -35,3 +40,8 @@ class action_menu_link_secondary extends action_menu_link { parent::__construct($url, $icon, $text, false, $attributes); } } + +// Alias this class to the old name. +// This file will be autoloaded by the legacyclasses autoload system. +// In future all uses of this class will be corrected and the legacy references will be removed. +class_alias(link_secondary::class, \action_menu_link_secondary::class); diff --git a/lib/classes/output/actions/component_action.php b/lib/classes/output/actions/component_action.php index 72bb07c0480..39b73c218f6 100644 --- a/lib/classes/output/actions/component_action.php +++ b/lib/classes/output/actions/component_action.php @@ -14,6 +14,13 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . +namespace core\output\actions; + +use core\exception\coding_exception; +use core\output\renderer_base; +use core\output\templatable; +use stdClass; + /** * Helper class used by other components that involve an action on the page (URL or JS). * @@ -77,3 +84,8 @@ class component_action implements templatable { ]; } } + +// Alias this class to the old name. +// This file will be autoloaded by the legacyclasses autoload system. +// In future all uses of this class will be corrected and the legacy references will be removed. +class_alias(component_action::class, \component_action::class); diff --git a/lib/classes/output/actions/confirm_action.php b/lib/classes/output/actions/confirm_action.php index 5ce5b5bfed7..e49d80b3963 100644 --- a/lib/classes/output/actions/confirm_action.php +++ b/lib/classes/output/actions/confirm_action.php @@ -14,6 +14,8 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . +namespace core\output\actions; + /** * Confirm action * @@ -45,3 +47,8 @@ class confirm_action extends component_action { 'continuelabel' => $continuelabel, 'cancellabel' => $cancellabel)); } } + +// Alias this class to the old name. +// This file will be autoloaded by the legacyclasses autoload system. +// In future all uses of this class will be corrected and the legacy references will be removed. +class_alias(confirm_action::class, \confirm_action::class); diff --git a/lib/classes/output/actions/popup_action.php b/lib/classes/output/actions/popup_action.php index 4c0bdc49c4e..bf1d20af3a6 100644 --- a/lib/classes/output/actions/popup_action.php +++ b/lib/classes/output/actions/popup_action.php @@ -13,6 +13,12 @@ // // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . + +namespace core\output\actions; + +use core\exception\coding_exception; +use moodle_url; + /** * Component action for a popup window. * @@ -62,7 +68,9 @@ class popup_action extends component_action { if ($name) { $_name = $name; if (($_name = preg_replace("/\s/", '_', $_name)) != $name) { - throw new coding_exception('The $name of a popup window shouldn\'t contain spaces - string modified. '. $name .' changed to '. $_name); + throw new coding_exception( + 'The $name of a popup window shouldn\'t contain spaces - string modified. ' . $name . ' changed to ' . $_name, + ); $name = $_name; } } else { @@ -104,3 +112,8 @@ class popup_action extends component_action { return $jsoptions; } } + +// Alias this class to the old name. +// This file will be autoloaded by the legacyclasses autoload system. +// In future all uses of this class will be corrected and the legacy references will be removed. +class_alias(popup_action::class, \popup_action::class); diff --git a/lib/classes/output/activity_header.php b/lib/classes/output/activity_header.php index b2fa9522db1..10c4b7f0c24 100644 --- a/lib/classes/output/activity_header.php +++ b/lib/classes/output/activity_header.php @@ -17,8 +17,6 @@ namespace core\output; use moodle_page; -use renderer_base; -use url_select; /** * Data structure representing standard components displayed on the activity header. @@ -31,7 +29,7 @@ use url_select; * @package core * @category output */ -class activity_header implements \renderable, \templatable { +class activity_header implements renderable, templatable { /** @var moodle_page $page The current page we are looking at */ protected $page; /** @var string $title The title to be displayed in the header. Defaults to activityrecord name. */ diff --git a/lib/classes/output/checkbox_toggleall.php b/lib/classes/output/checkbox_toggleall.php index 5a900b89101..3484de91015 100644 --- a/lib/classes/output/checkbox_toggleall.php +++ b/lib/classes/output/checkbox_toggleall.php @@ -23,12 +23,8 @@ */ namespace core\output; -defined('MOODLE_INTERNAL') || die(); -use renderable; -use renderer_base; use stdClass; -use templatable; /** * The checkbox-toggleall renderable class. @@ -38,7 +34,6 @@ use templatable; * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class checkbox_toggleall implements renderable, templatable { - /** @var string The name of the group of checkboxes to be toggled. */ protected $togglegroup; diff --git a/lib/classes/output/choicelist.php b/lib/classes/output/choicelist.php index e01d949badb..57d9bdc71ee 100644 --- a/lib/classes/output/choicelist.php +++ b/lib/classes/output/choicelist.php @@ -16,10 +16,6 @@ namespace core\output; -use renderable; -use renderer_base; -use core\output\named_templatable; - /** * A generic user choice output class. * @@ -30,8 +26,7 @@ use core\output\named_templatable; * @copyright 2023 Ferran Recio * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -class choicelist implements renderable, named_templatable { - +class choicelist implements named_templatable, renderable { /** @var object[] The user choices. */ protected $options = []; diff --git a/lib/classes/output/chooser.php b/lib/classes/output/chooser.php index d63831fe4d0..268e4285c43 100644 --- a/lib/classes/output/chooser.php +++ b/lib/classes/output/chooser.php @@ -23,14 +23,10 @@ */ namespace core\output; -defined('MOODLE_INTERNAL') || die(); use lang_string; use moodle_url; -use renderer_base; -use renderable; use stdClass; -use templatable; /** * The chooser renderable class. diff --git a/lib/classes/output/chooser_item.php b/lib/classes/output/chooser_item.php index d6392c52b96..e1a7e99281a 100644 --- a/lib/classes/output/chooser_item.php +++ b/lib/classes/output/chooser_item.php @@ -24,13 +24,9 @@ namespace core\output; -use coding_exception; -use context; -use pix_icon; -use renderer_base; -use renderable; +use core\exception\coding_exception; +use core\context; use stdClass; -use templatable; /** * The chooser_item renderable class. diff --git a/lib/classes/output/chooser_section.php b/lib/classes/output/chooser_section.php index ec2f270c33f..ed071058cc0 100644 --- a/lib/classes/output/chooser_section.php +++ b/lib/classes/output/chooser_section.php @@ -23,13 +23,9 @@ */ namespace core\output; -defined('MOODLE_INTERNAL') || die(); use lang_string; -use renderer_base; -use renderable; use stdClass; -use templatable; /** * The chooser_section renderable class. diff --git a/lib/classes/output/comboboxsearch.php b/lib/classes/output/comboboxsearch.php index 0f9a1802533..b8ec7ea8b79 100644 --- a/lib/classes/output/comboboxsearch.php +++ b/lib/classes/output/comboboxsearch.php @@ -16,10 +16,7 @@ namespace core\output; -use moodle_exception; -use renderable; -use renderer_base; -use templatable; +use core\exception\moodle_exception; /** * Renderable class for the comboboxsearch. diff --git a/lib/classes/output/context_header.php b/lib/classes/output/context_header.php index e1c02d8614c..fc6a056118f 100644 --- a/lib/classes/output/context_header.php +++ b/lib/classes/output/context_header.php @@ -14,6 +14,8 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . +namespace core\output; + /** * Renderable for the main page header. * @@ -24,7 +26,7 @@ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class context_header implements renderable, templatable { - /** +/** * @var string $heading Main heading. */ public $heading; @@ -145,3 +147,8 @@ class context_header implements renderable, templatable { ]; } } + +// Alias this class to the old name. +// This file will be autoloaded by the legacyclasses autoload system. +// In future all uses of this class will be corrected and the legacy references will be removed. +class_alias(context_header::class, \context_header::class); diff --git a/lib/classes/output/core_renderer.php b/lib/classes/output/core_renderer.php index df1de09d584..038ef4a7c5d 100644 --- a/lib/classes/output/core_renderer.php +++ b/lib/classes/output/core_renderer.php @@ -14,7 +14,24 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . +namespace core\output; + +use breadcrumb_navigation_node; +use cm_info; +use core_block\output\block_contents; +use core_block\output\block_move_target; +use core_completion\cm_completion_details; +use core\context; +use core_course\output\activity_information; +use core_tag\output\taglist; +use core_text; +use core_useragent; +use core\check\check as check_check; +use core\check\result as check_result; +use core\context\system as context_system; +use core\context\course as context_course; use core\di; +use core\exception\coding_exception; use core\hook\manager as hook_manager; use core\hook\output\after_standard_main_region_html_generation; use core\hook\output\before_footer_html_generation; @@ -22,8 +39,21 @@ use core\hook\output\before_html_attributes; use core\hook\output\before_http_headers; use core\hook\output\before_standard_footer_html_generation; use core\hook\output\before_standard_top_of_body_html_generation; -use core_completion\cm_completion_details; -use core_course\output\activity_information; +use core\output\action_menu\link as action_menu_link; +use core\output\action_menu\link_primary as action_menu_link_primary; +use core\output\actions\component_action; +use core\output\actions\popup_action; +use core\output\action_menu\filler as action_menu_filler; +use core\plugin_manager; +use core\output\action_menu\link_secondary as action_menu_link_secondary; +use moodleform; +use moodle_page; +use moodle_url; +use navigation_node; +use rating; +use rating_manager; +use stdClass; +use HTML_QuickForm_element; /** * The standard implementation of the core_renderer interface. @@ -753,8 +783,14 @@ class core_renderer extends renderer_base { * @return string The HTML to display to the user before dying, may contain * meta refresh, javascript refresh, and may have set header redirects */ - public function redirect_message($encodedurl, $message, $delay, $debugdisableredirect, - $messagetype = \core\output\notification::NOTIFY_INFO) { + + public function redirect_message( + $encodedurl, + $message, + $delay, + $debugdisableredirect, + $messagetype = notification::NOTIFY_INFO, + ) { global $CFG; $url = str_replace('&', '&', $encodedurl); @@ -1178,7 +1214,7 @@ class core_renderer extends renderer_base { * @return string The lang menu HTML or empty string */ public function lang_menu() { - $languagemenu = new \core\output\language_menu($this->page); + $languagemenu = new language_menu($this->page); $data = $languagemenu->export_for_single_select($this); if ($data) { return $this->render_from_template('core/single_select', $data); @@ -1258,12 +1294,12 @@ class core_renderer extends renderer_base { /** * Renders a full check API result including summary and details * - * @param core\check\check $check the check that was run to get details from - * @param core\check\result $result the result of a check + * @param check_check $check the check that was run to get details from + * @param check_result $result the result of a check * @param bool $includedetails if true, details are included as well * @return string rendered html */ - protected function render_check_full_result(core\check\check $check, core\check\result $result, bool $includedetails): string { + protected function render_check_full_result(check_check $check, check_result $result, bool $includedetails): string { // Initially render just badge itself. $renderedresult = $this->render_from_template($result->get_template_name(), $result->export_for_template($this)); @@ -1272,17 +1308,17 @@ class core_renderer extends renderer_base { // Wrap in notificaiton. $notificationmap = [ - \core\check\result::NA => \core\output\notification::NOTIFY_INFO, - \core\check\result::OK => \core\output\notification::NOTIFY_SUCCESS, - \core\check\result::INFO => \core\output\notification::NOTIFY_INFO, - \core\check\result::UNKNOWN => \core\output\notification::NOTIFY_WARNING, - \core\check\result::WARNING => \core\output\notification::NOTIFY_WARNING, - \core\check\result::ERROR => \core\output\notification::NOTIFY_ERROR, - \core\check\result::CRITICAL => \core\output\notification::NOTIFY_ERROR, + check_result::NA => notification::NOTIFY_INFO, + check_result::OK => notification::NOTIFY_SUCCESS, + check_result::INFO => notification::NOTIFY_INFO, + check_result::UNKNOWN => notification::NOTIFY_WARNING, + check_result::WARNING => notification::NOTIFY_WARNING, + check_result::ERROR => notification::NOTIFY_ERROR, + check_result::CRITICAL => notification::NOTIFY_ERROR, ]; // Get type, or default to error. - $notificationtype = $notificationmap[$result->get_status()] ?? \core\output\notification::NOTIFY_ERROR; + $notificationtype = $notificationmap[$result->get_status()] ?? notification::NOTIFY_ERROR; $renderedresult = $this->notification($renderedresult, $notificationtype, false); // If adding details, add on new line. @@ -1299,32 +1335,32 @@ class core_renderer extends renderer_base { /** * Renders a full check API result including summary and details * - * @param core\check\check $check the check that was run to get details from - * @param core\check\result $result the result of a check + * @param check_check $check the check that was run to get details from + * @param check_result $result the result of a check * @param bool $includedetails if details should be included * @return string HTML fragment */ - public function check_full_result(core\check\check $check, core\check\result $result, bool $includedetails = false) { + public function check_full_result(check_check $check, check_result $result, bool $includedetails = false) { return $this->render_check_full_result($check, $result, $includedetails); } /** * Renders a Check API result * - * @param core\check\result $result + * @param check_result $result * @return string HTML fragment */ - protected function render_check_result(core\check\result $result) { + protected function render_check_result(check_result $result) { return $this->render_from_template($result->get_template_name(), $result->export_for_template($this)); } /** * Renders a Check API result * - * @param core\check\result $result + * @param check_result $result * @return string HTML fragment */ - public function check_result(core\check\result $result) { + public function check_result(check_result $result) { return $this->render_check_result($result); } @@ -1721,10 +1757,9 @@ class core_renderer extends renderer_base { * @param array $params Extra params sent to the download page * @return string HTML fragment */ - public function download_dataformat_selector($label, $base, $name = 'dataformat', $params = array()) { - - $formats = core_plugin_manager::instance()->get_plugins_of_type('dataformat'); - $options = array(); + public function download_dataformat_selector($label, $base, $name = 'dataformat', $params = []) { + $formats = plugin_manager::instance()->get_plugins_of_type('dataformat'); + $options = []; foreach ($formats as $format) { if ($format->is_enabled()) { $options[] = array( @@ -1841,7 +1876,7 @@ class core_renderer extends renderer_base { * @return string HTML fragment */ protected function render_image_icon(image_icon $icon) { - $system = \core\output\icon_system::instance(\core\output\icon_system::STANDARD); + $system = icon_system::instance(icon_system::STANDARD); return $system->render_pix_icon($this, $icon); } @@ -1869,7 +1904,7 @@ class core_renderer extends renderer_base { * @return string HTML fragment */ protected function render_pix_icon(pix_icon $icon) { - $system = \core\output\icon_system::instance(); + $system = icon_system::instance(); return $system->render_pix_icon($this, $icon); } @@ -1880,7 +1915,7 @@ class core_renderer extends renderer_base { * @return string HTML fragment */ protected function render_pix_emoticon(pix_emoticon $emoticon) { - $system = \core\output\icon_system::instance(\core\output\icon_system::STANDARD); + $system = icon_system::instance(icon_system::STANDARD); return $system->render_pix_icon($this, $emoticon); } @@ -2556,26 +2591,26 @@ EOD; * Note: \core\notification::add() may be more suitable for your usage. * * @param string $message The message to print out. - * @param ?string $type The type of notification. See constants on \core\output\notification. + * @param ?string $type The type of notification. See constants on notification. * @param bool $closebutton Whether to show a close icon to remove the notification (default true). * @return string the HTML to output. */ public function notification($message, $type = null, $closebutton = true) { $typemappings = [ // Valid types. - 'success' => \core\output\notification::NOTIFY_SUCCESS, - 'info' => \core\output\notification::NOTIFY_INFO, - 'warning' => \core\output\notification::NOTIFY_WARNING, - 'error' => \core\output\notification::NOTIFY_ERROR, + 'success' => notification::NOTIFY_SUCCESS, + 'info' => notification::NOTIFY_INFO, + 'warning' => notification::NOTIFY_WARNING, + 'error' => notification::NOTIFY_ERROR, // Legacy types mapped to current types. - 'notifyproblem' => \core\output\notification::NOTIFY_ERROR, - 'notifytiny' => \core\output\notification::NOTIFY_ERROR, - 'notifyerror' => \core\output\notification::NOTIFY_ERROR, - 'notifysuccess' => \core\output\notification::NOTIFY_SUCCESS, - 'notifymessage' => \core\output\notification::NOTIFY_INFO, - 'notifyredirect' => \core\output\notification::NOTIFY_INFO, - 'redirectmessage' => \core\output\notification::NOTIFY_INFO, + 'notifyproblem' => notification::NOTIFY_ERROR, + 'notifytiny' => notification::NOTIFY_ERROR, + 'notifyerror' => notification::NOTIFY_ERROR, + 'notifysuccess' => notification::NOTIFY_SUCCESS, + 'notifymessage' => notification::NOTIFY_INFO, + 'notifyredirect' => notification::NOTIFY_INFO, + 'redirectmessage' => notification::NOTIFY_INFO, ]; $extraclasses = []; @@ -2604,7 +2639,7 @@ EOD; } } - $notification = new \core\output\notification($message, $type, $closebutton); + $notification = new notification($message, $type, $closebutton); if (count($extraclasses)) { $notification->set_extra_classes($extraclasses); } @@ -2649,10 +2684,10 @@ EOD; * Render a notification (that is, a status message about something that has * just happened). * - * @param \core\output\notification $notification the notification to print out + * @param notification $notification the notification to print out * @return string the HTML to output. */ - protected function render_notification(\core\output\notification $notification) { + protected function render_notification(notification $notification) { return $this->render_from_template($notification->get_template_name(), $notification->export_for_template($this)); } @@ -3843,7 +3878,7 @@ EOD; * @return bool */ public function has_communication_links(): bool { - if (during_initial_install() || !core_communication\api::is_available()) { + if (during_initial_install() || !\core_communication\api::is_available()) { return false; } return !empty($this->communication_link()); @@ -4358,17 +4393,17 @@ EOD; */ public function tag_list($tags, $label = null, $classes = '', $limit = 10, $pagecontext = null, $accesshidelabel = false) { - $list = new \core_tag\output\taglist($tags, $label, $classes, $limit, $pagecontext, $accesshidelabel); + $list = new taglist($tags, $label, $classes, $limit, $pagecontext, $accesshidelabel); return $this->render_from_template('core_tag/taglist', $list->export_for_template($this)); } /** * Renders element for inline editing of any value * - * @param \core\output\inplace_editable $element + * @param inplace_editable $element * @return string */ - public function render_inplace_editable(\core\output\inplace_editable $element) { + public function render_inplace_editable(inplace_editable $element) { return $this->render_from_template('core/inplace_editable', $element->export_for_template($this)); } @@ -4458,7 +4493,7 @@ EOD; try { // We call this to generate a file not found exception if there is no template. // We don't want to call export_for_template if there is no template. - core\output\mustache_template_finder::get_template_filepath($templatename); + mustache_template_finder::get_template_filepath($templatename); if ($element instanceof templatable) { $elementcontext = $element->export_for_template($this); @@ -4505,7 +4540,7 @@ EOD; ); return $this->render_from_template($templatename, $context); } - } catch (Exception $e) { + } catch (\Exception $e) { // No template for this element. return false; } @@ -4593,10 +4628,10 @@ EOD; /** * Renders element for a toggle-all checkbox. * - * @param \core\output\checkbox_toggleall $element + * @param checkbox_toggleall $element * @return string */ - public function render_checkbox_toggleall(\core\output\checkbox_toggleall $element) { + public function render_checkbox_toggleall(checkbox_toggleall $element) { return $this->render_from_template($element->get_template(), $element->export_for_template($this)); } @@ -4608,7 +4643,7 @@ EOD; * @return string */ public function render_participants_tertiary_nav(object $course, ?string $renderedbuttons = null) { - $actionbar = new \core\output\participants_action_bar($course, $this->page, $renderedbuttons); + $actionbar = new participants_action_bar($course, $this->page, $renderedbuttons); $content = $this->render_from_template('core_course/participants_actionbar', $actionbar->export_for_template($this)); return $content ?: ""; } @@ -4763,3 +4798,7 @@ EOD; return $output; } } +// Alias this class to the old name. +// This file will be autoloaded by the legacyclasses autoload system. +// In future all uses of this class will be corrected and the legacy references will be removed. +class_alias(core_renderer::class, \core_renderer::class); diff --git a/lib/classes/output/core_renderer_ajax.php b/lib/classes/output/core_renderer_ajax.php index 61e0ac12912..a70a42b2ed1 100644 --- a/lib/classes/output/core_renderer_ajax.php +++ b/lib/classes/output/core_renderer_ajax.php @@ -14,6 +14,12 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . +namespace core\output; + +use core_useragent; +use moodle_url; +use stdClass; + /** * A renderer that generates output for ajax scripts. * @@ -27,7 +33,6 @@ * @category output */ class core_renderer_ajax extends core_renderer { - /** * Returns a template fragment representing a fatal error. * @@ -88,14 +93,19 @@ class core_renderer_ajax extends core_renderer { * @param string $messagetype The type of notification to show the message in. * See constants on \core\output\notification. */ - public function redirect_message($encodedurl, $message, $delay, $debugdisableredirect, - $messagetype = \core\output\notification::NOTIFY_INFO) {} + public function redirect_message( + $encodedurl, + $message, + $delay, + $debugdisableredirect, + $messagetype = notification::NOTIFY_INFO, + ) {} /** * Prepares the start of an AJAX output. */ public function header() { - // unfortunately YUI iframe upload does not support application/json + // Unfortunately YUI iframe upload does not support application/json. if (!empty($_FILES)) { @header('Content-type: text/plain; charset=utf-8'); if (!core_useragent::supports_json_contenttype()) { @@ -132,3 +142,8 @@ class core_renderer_ajax extends core_renderer { */ public function heading($text, $level = 2, $classes = 'main', $id = null) {} } + +// Alias this class to the old name. +// This file will be autoloaded by the legacyclasses autoload system. +// In future all uses of this class will be corrected and the legacy references will be removed. +class_alias(core_renderer_ajax::class, \core_renderer_ajax::class); diff --git a/lib/classes/output/core_renderer_cli.php b/lib/classes/output/core_renderer_cli.php index 21b0bb113eb..1de38c598a1 100644 --- a/lib/classes/output/core_renderer_cli.php +++ b/lib/classes/output/core_renderer_cli.php @@ -14,6 +14,11 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . +namespace core\output; + +use core_text; +use core\check\result as check_result; + /** * A renderer that generates output for command-line scripts. * @@ -26,7 +31,6 @@ * @category output */ class core_renderer_cli extends core_renderer { - /** * @var array $progressmaximums stores the largest percentage for a progress bar. * @return string ascii fragment @@ -48,20 +52,20 @@ class core_renderer_cli extends core_renderer { * To aid in CLI consistency this status is NOT translated and the visual * width is always exactly 10 chars. * - * @param core\check\result $result + * @param check_result $result * @return string HTML fragment */ - protected function render_check_result(core\check\result $result) { + protected function render_check_result(check_result $result) { $status = $result->get_status(); $labels = [ - core\check\result::NA => ' ' . cli_ansi_format('' ) . ' NA ', - core\check\result::OK => ' ' . cli_ansi_format('') . ' OK ', - core\check\result::INFO => ' ' . cli_ansi_format('' ) . ' INFO ', - core\check\result::UNKNOWN => ' ' . cli_ansi_format('' ) . ' UNKNOWN ', - core\check\result::WARNING => ' ' . cli_ansi_format('') . ' WARNING ', - core\check\result::ERROR => ' ' . cli_ansi_format('') . ' ERROR ', - core\check\result::CRITICAL => '' . cli_ansi_format('') . ' CRITICAL ', + check_result::NA => ' ' . cli_ansi_format('' ) . ' NA ', + check_result::OK => ' ' . cli_ansi_format('') . ' OK ', + check_result::INFO => ' ' . cli_ansi_format('' ) . ' INFO ', + check_result::UNKNOWN => ' ' . cli_ansi_format('' ) . ' UNKNOWN ', + check_result::WARNING => ' ' . cli_ansi_format('') . ' WARNING ', + check_result::ERROR => ' ' . cli_ansi_format('') . ' ERROR ', + check_result::CRITICAL => '' . cli_ansi_format('') . ' CRITICAL ', ]; $string = $labels[$status] . cli_ansi_format(''); return $string; @@ -70,10 +74,10 @@ class core_renderer_cli extends core_renderer { /** * Renders a Check API result * - * @param core\check\result $result + * @param check_result $result * @return string fragment */ - public function check_result(core\check\result $result) { + public function check_result(check_result $result) { return $this->render_check_result($result); } @@ -235,16 +239,22 @@ class core_renderer_cli extends core_renderer { * There is no footer for a cli request, however we must override the * footer method to prevent the default footer. */ - public function footer() {} + public function footer() { + } /** * Render a notification (that is, a status message about something that has * just happened). * - * @param \core\output\notification $notification the notification to print out + * @param notification $notification the notification to print out * @return string plain text output */ - public function render_notification(\core\output\notification $notification) { + public function render_notification(notification $notification) { return $this->notification($notification->get_message(), $notification->get_message_type()); } } + +// Alias this class to the old name. +// This file will be autoloaded by the legacyclasses autoload system. +// In future all uses of this class will be corrected and the legacy references will be removed. +class_alias(core_renderer_cli::class, \core_renderer_cli::class); diff --git a/lib/classes/output/core_renderer_maintenance.php b/lib/classes/output/core_renderer_maintenance.php index 641922cb368..1aee2863dc0 100644 --- a/lib/classes/output/core_renderer_maintenance.php +++ b/lib/classes/output/core_renderer_maintenance.php @@ -14,6 +14,14 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . +namespace core\output; + +use core_block\output\block_contents; +use core\exception\coding_exception; +use moodle_page; +use moodle_url; +use stdClass; + /** * The maintenance renderer. * @@ -227,3 +235,8 @@ class core_renderer_maintenance extends core_renderer { return ''; } } + +// Alias this class to the old name. +// This file will be autoloaded by the legacyclasses autoload system. +// In future all uses of this class will be corrected and the legacy references will be removed. +class_alias(core_renderer_maintenance::class, \core_renderer_maintenance::class); diff --git a/lib/classes/output/custom_menu.php b/lib/classes/output/custom_menu.php index 1ed34eea659..67ab20ee60d 100644 --- a/lib/classes/output/custom_menu.php +++ b/lib/classes/output/custom_menu.php @@ -14,6 +14,11 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . +namespace core\output; + +use core\exception\moodle_exception; +use moodle_url; + /** * Custom menu class * @@ -31,7 +36,6 @@ * @category output */ class custom_menu extends custom_menu_item { - /** * @var string The language we should render for, null disables multilang support. */ @@ -177,3 +181,8 @@ class custom_menu extends custom_menu_item { return ($itema > $itemb) ? +1 : -1; } } + +// Alias this class to the old name. +// This file will be autoloaded by the legacyclasses autoload system. +// In future all uses of this class will be corrected and the legacy references will be removed. +class_alias(custom_menu::class, \custom_menu::class); diff --git a/lib/classes/output/custom_menu_item.php b/lib/classes/output/custom_menu_item.php index 560cf2a3ec6..314cfeebeb8 100644 --- a/lib/classes/output/custom_menu_item.php +++ b/lib/classes/output/custom_menu_item.php @@ -14,6 +14,12 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . +namespace core\output; + +use core\context\system as context_system; +use moodle_url; +use stdClass; + /** * Custom menu item * @@ -259,3 +265,8 @@ class custom_menu_item implements renderable, templatable { return $context; } } + +// Alias this class to the old name. +// This file will be autoloaded by the legacyclasses autoload system. +// In future all uses of this class will be corrected and the legacy references will be removed. +class_alias(custom_menu_item::class, \custom_menu_item::class); diff --git a/lib/classes/output/datafilter.php b/lib/classes/output/datafilter.php index ea28136d45b..04973ef3d93 100644 --- a/lib/classes/output/datafilter.php +++ b/lib/classes/output/datafilter.php @@ -16,10 +16,8 @@ namespace core\output; -use context; -use renderable; +use core\context; use stdClass; -use templatable; /** * The filter renderable class. diff --git a/lib/classes/output/dynamic_tabs.php b/lib/classes/output/dynamic_tabs.php index c2592bb8134..1dbb26df2e6 100644 --- a/lib/classes/output/dynamic_tabs.php +++ b/lib/classes/output/dynamic_tabs.php @@ -19,8 +19,6 @@ declare(strict_types=1); namespace core\output; use core\output\dynamic_tabs\base; -use renderer_base; -use templatable; /** * Class dynamic tabs diff --git a/lib/classes/output/dynamic_tabs/base.php b/lib/classes/output/dynamic_tabs/base.php index 2396ee645ec..477b73587ec 100644 --- a/lib/classes/output/dynamic_tabs/base.php +++ b/lib/classes/output/dynamic_tabs/base.php @@ -18,8 +18,8 @@ declare(strict_types=1); namespace core\output\dynamic_tabs; -use moodle_exception; -use templatable; +use core\exception\moodle_exception; +use core\output\templatable; /** * Class tab_base diff --git a/lib/classes/output/file_picker.php b/lib/classes/output/file_picker.php index 785b0d9a69f..783e29fe71c 100644 --- a/lib/classes/output/file_picker.php +++ b/lib/classes/output/file_picker.php @@ -14,6 +14,12 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . +namespace core\output; + +use core\context\user as context_user; +use moodle_url; +use stdClass; + /** * Data structure representing a file picker. * @@ -24,7 +30,6 @@ * @category output */ class file_picker implements renderable { - /** * @var stdClass An object containing options for the file picker */ @@ -91,3 +96,8 @@ class file_picker implements renderable { } } } + +// Alias this class to the old name. +// This file will be autoloaded by the legacyclasses autoload system. +// In future all uses of this class will be corrected and the legacy references will be removed. +class_alias(file_picker::class, \file_picker::class); diff --git a/lib/classes/output/help_icon.php b/lib/classes/output/help_icon.php index 9fee559cad5..6c36b1cf918 100644 --- a/lib/classes/output/help_icon.php +++ b/lib/classes/output/help_icon.php @@ -14,6 +14,11 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . +namespace core\output; + +use moodle_url; +use stdClass; + /** * Data structure representing a help icon. * @@ -24,7 +29,6 @@ * @category output */ class help_icon implements renderable, templatable { - /** * @var string lang pack identifier (without the "_help" suffix), * both get_string($identifier, $component) and get_string($identifier.'_help', $component) @@ -116,3 +120,8 @@ class help_icon implements renderable, templatable { return $data; } } + +// Alias this class to the old name. +// This file will be autoloaded by the legacyclasses autoload system. +// In future all uses of this class will be corrected and the legacy references will be removed. +class_alias(help_icon::class, \help_icon::class); diff --git a/lib/classes/output/html_writer.php b/lib/classes/output/html_writer.php index 9d595335d32..3f00022d876 100644 --- a/lib/classes/output/html_writer.php +++ b/lib/classes/output/html_writer.php @@ -14,6 +14,15 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . +namespace core\output; + +use core\exception\coding_exception; +use core_table\output\html_table; +use core_table\output\html_table_cell; +use core_table\output\html_table_row; +use core_text; +use moodle_url; + /** * Simple html output class * @@ -24,7 +33,6 @@ * @category output */ class html_writer { - /** * Outputs a tag with attributes and contents * @@ -434,11 +442,11 @@ class html_writer { * @return string */ public static function alist(array $items, array $attributes = null, $tag = 'ul') { - $output = html_writer::start_tag($tag, $attributes)."\n"; + $output = self::start_tag($tag, $attributes)."\n"; foreach ($items as $item) { - $output .= html_writer::tag('li', $item)."\n"; + $output .= self::tag('li', $item)."\n"; } - $output .= html_writer::end_tag($tag); + $output .= self::end_tag($tag); return $output; } @@ -553,7 +561,7 @@ class html_writer { 'cellpadding' => $table->cellpadding, 'cellspacing' => $table->cellspacing, )); - $output = html_writer::start_tag('table', $attributes) . "\n"; + $output = self::start_tag('table', $attributes) . "\n"; $countcols = 0; @@ -563,7 +571,7 @@ class html_writer { if ($table->captionhide) { $captionattributes['class'] = 'accesshide'; } - $output .= html_writer::tag( + $output .= self::tag( 'caption', $table->caption, $captionattributes @@ -573,8 +581,8 @@ class html_writer { if (!empty($table->head)) { $countcols = count($table->head); - $output .= html_writer::start_tag('thead', array()) . "\n"; - $output .= html_writer::start_tag('tr', array()) . "\n"; + $output .= self::start_tag('thead', array()) . "\n"; + $output .= self::start_tag('tr', array()) . "\n"; $keys = array_keys($table->head); $lastkey = end($keys); @@ -618,28 +626,28 @@ class html_writer { $attributes['scope'] = !empty($heading->scope) ? $heading->scope : 'col'; } - $output .= html_writer::tag($tagtype, $heading->text, $attributes) . "\n"; + $output .= self::tag($tagtype, $heading->text, $attributes) . "\n"; } - $output .= html_writer::end_tag('tr') . "\n"; - $output .= html_writer::end_tag('thead') . "\n"; + $output .= self::end_tag('tr') . "\n"; + $output .= self::end_tag('thead') . "\n"; if (empty($table->data)) { // For valid XHTML strict every table must contain either a valid tr // or a valid tbody... both of which must contain a valid td - $output .= html_writer::start_tag('tbody', array('class' => 'empty')); - $output .= html_writer::tag('tr', html_writer::tag('td', '', array('colspan'=>count($table->head)))); - $output .= html_writer::end_tag('tbody'); + $output .= self::start_tag('tbody', array('class' => 'empty')); + $output .= self::tag('tr', self::tag('td', '', array('colspan'=>count($table->head)))); + $output .= self::end_tag('tbody'); } } if (!empty($table->data)) { $keys = array_keys($table->data); $lastrowkey = end($keys); - $output .= html_writer::start_tag('tbody', array()); + $output .= self::start_tag('tbody', array()); foreach ($table->data as $key => $row) { if (($row === 'hr') && ($countcols)) { - $output .= html_writer::tag('td', html_writer::tag('div', '', array('class' => 'tabledivider')), array('colspan' => $countcols)); + $output .= self::tag('td', self::tag('div', '', array('class' => 'tabledivider')), array('colspan' => $countcols)); } else { // Convert array rows to html_table_rows and cell strings to html_table_cell objects if (!($row instanceof html_table_row)) { @@ -668,7 +676,7 @@ class html_writer { 'id' => $row->id, 'style' => $row->style, )); - $output .= html_writer::start_tag('tr', $trattributes) . "\n"; + $output .= self::start_tag('tr', $trattributes) . "\n"; $keys2 = array_keys($row->cells); $lastkey = end($keys2); @@ -715,14 +723,14 @@ class html_writer { if ($cell->header === true) { $tagtype = 'th'; } - $output .= html_writer::tag($tagtype, $cell->text, $tdattributes) . "\n"; + $output .= self::tag($tagtype, $cell->text, $tdattributes) . "\n"; } } - $output .= html_writer::end_tag('tr') . "\n"; + $output .= self::end_tag('tr') . "\n"; } - $output .= html_writer::end_tag('tbody') . "\n"; + $output .= self::end_tag('tbody') . "\n"; } - $output .= html_writer::end_tag('table') . "\n"; + $output .= self::end_tag('table') . "\n"; if ($table->responsive) { return self::div($output, 'table-responsive'); @@ -868,3 +876,8 @@ class html_writer { return self::end_tag('span'); } } + +// Alias this class to the old name. +// This file will be autoloaded by the legacyclasses autoload system. +// In future all uses of this class will be corrected and the legacy references will be removed. +class_alias(html_writer::class, \html_writer::class); diff --git a/lib/classes/output/icon_system.php b/lib/classes/output/icon_system.php index d690bc6272f..c9f6b5a1488 100644 --- a/lib/classes/output/icon_system.php +++ b/lib/classes/output/icon_system.php @@ -14,22 +14,8 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . -/** - * Contains class \core\output\icon_system - * - * @package core - * @category output - * @copyright 2016 Damyon Wiese - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ - namespace core\output; -use renderer_base; -use pix_icon; - -defined('MOODLE_INTERNAL') || die(); - /** * Class allowing different systems for mapping and rendering icons. * diff --git a/lib/classes/output/icon_system_fontawesome.php b/lib/classes/output/icon_system_fontawesome.php index 767949bd803..0b9053a2590 100644 --- a/lib/classes/output/icon_system_fontawesome.php +++ b/lib/classes/output/icon_system_fontawesome.php @@ -14,22 +14,8 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . -/** - * Contains class \core\output\icon_system - * - * @package core - * @category output - * @copyright 2016 Damyon Wiese - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ - namespace core\output; -use renderer_base; -use pix_icon; - -defined('MOODLE_INTERNAL') || die(); - /** * Class allowing different systems for mapping and rendering icons. * diff --git a/lib/classes/output/icon_system_standard.php b/lib/classes/output/icon_system_standard.php index c9a2f77e18d..cc0d1500915 100644 --- a/lib/classes/output/icon_system_standard.php +++ b/lib/classes/output/icon_system_standard.php @@ -14,22 +14,8 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . -/** - * Contains class \core\output\icon_system_standard - * - * @package core - * @category output - * @copyright 2016 Damyon Wiese - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ - namespace core\output; -use renderer_base; -use pix_icon; - -defined('MOODLE_INTERNAL') || die(); - /** * Standard icon rendering. No mapping - img tags used. * @@ -39,7 +25,6 @@ defined('MOODLE_INTERNAL') || die(); * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class icon_system_standard extends icon_system { - public function render_pix_icon(renderer_base $output, pix_icon $icon) { $data = $icon->export_for_template($output); return $output->render_from_template('core/pix_icon', $data); @@ -50,4 +35,3 @@ class icon_system_standard extends icon_system { } } - diff --git a/lib/classes/output/image_icon.php b/lib/classes/output/image_icon.php index 805b655d1b6..76e6bce00c4 100644 --- a/lib/classes/output/image_icon.php +++ b/lib/classes/output/image_icon.php @@ -14,6 +14,8 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . +namespace core\output; + /** * Data structure representing an activity icon. * @@ -25,3 +27,8 @@ */ class image_icon extends pix_icon { } + +// Alias this class to the old name. +// This file will be autoloaded by the legacyclasses autoload system. +// In future all uses of this class will be corrected and the legacy references will be removed. +class_alias(image_icon::class, \image_icon::class); diff --git a/lib/classes/output/initials_bar.php b/lib/classes/output/initials_bar.php index e7c48a903ac..453b843d245 100644 --- a/lib/classes/output/initials_bar.php +++ b/lib/classes/output/initials_bar.php @@ -14,6 +14,11 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . +namespace core\output; + +use moodle_url; +use stdClass; + /** * Component representing initials bar. * @@ -24,7 +29,6 @@ * @category output */ class initials_bar implements renderable, templatable { - /** * @var string Currently selected letter. */ @@ -146,3 +150,8 @@ class initials_bar implements renderable, templatable { return $data; } } + +// Alias this class to the old name. +// This file will be autoloaded by the legacyclasses autoload system. +// In future all uses of this class will be corrected and the legacy references will be removed. +class_alias(initials_bar::class, \initials_bar::class); diff --git a/lib/classes/output/inplace_editable.php b/lib/classes/output/inplace_editable.php index 2488fa085d8..6c94c474418 100644 --- a/lib/classes/output/inplace_editable.php +++ b/lib/classes/output/inplace_editable.php @@ -14,21 +14,9 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . -/** - * Contains class \core\output\inplace_editable - * - * @package core - * @category output - * @copyright 2016 Marina Glancy - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ - namespace core\output; -use templatable; -use renderable; use lang_string; -use pix_icon; /** * Class allowing to quick edit a title inline @@ -53,7 +41,6 @@ use pix_icon; * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class inplace_editable implements templatable, renderable { - /** * @var string component responsible for diplsying/updating */ diff --git a/lib/classes/output/js_writer.php b/lib/classes/output/js_writer.php index 348fb79c0e4..a98d078b980 100644 --- a/lib/classes/output/js_writer.php +++ b/lib/classes/output/js_writer.php @@ -14,6 +14,8 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . +namespace core\output; + /** * Simple javascript output class * @@ -24,7 +26,6 @@ * @category output */ class js_writer { - /** * Returns javascript code calling the function * @@ -145,3 +146,8 @@ class js_writer { return $output . ");\n"; } } + +// Alias this class to the old name. +// This file will be autoloaded by the legacyclasses autoload system. +// In future all uses of this class will be corrected and the legacy references will be removed. +class_alias(js_writer::class, \js_writer::class); diff --git a/lib/classes/output/language_menu.php b/lib/classes/output/language_menu.php index b6a0fbc63e0..c45ed734478 100644 --- a/lib/classes/output/language_menu.php +++ b/lib/classes/output/language_menu.php @@ -33,7 +33,7 @@ namespace core\output; * @copyright 2021 Adrian Greeve * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -class language_menu implements \renderable, \templatable { +class language_menu implements renderable, templatable { /** @var \moodle_page $page the moodle page that the languague menu belongs to */ protected $page; diff --git a/lib/classes/output/local/action_menu/subpanel.php b/lib/classes/output/local/action_menu/subpanel.php index cfcca6d6bb1..d0a92624c3a 100644 --- a/lib/classes/output/local/action_menu/subpanel.php +++ b/lib/classes/output/local/action_menu/subpanel.php @@ -16,9 +16,9 @@ namespace core\output\local\action_menu; -use action_link; -use pix_icon; -use renderable; +use core\output\action_link; +use core\output\pix_icon; +use core\output\renderable; use stdClass; /** diff --git a/lib/classes/output/local/dropdown/dialog.php b/lib/classes/output/local/dropdown/dialog.php index 5ba38521979..cf0a20b0cd4 100644 --- a/lib/classes/output/local/dropdown/dialog.php +++ b/lib/classes/output/local/dropdown/dialog.php @@ -17,7 +17,7 @@ namespace core\output\local\dropdown; use core\output\named_templatable; -use renderable; +use core\output\renderable; /** * Class to render a dropdown dialog element. diff --git a/lib/classes/output/mustache_clean_string_helper.php b/lib/classes/output/mustache_clean_string_helper.php index 144cd62e2a5..a067490ca18 100644 --- a/lib/classes/output/mustache_clean_string_helper.php +++ b/lib/classes/output/mustache_clean_string_helper.php @@ -14,15 +14,6 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . -/** - * Mustache helper to load strings from string_manager and perform HTML escaping on them. - * - * @package core - * @category output - * @copyright 2021 Shamim Rezaie - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ - namespace core\output; use Mustache_LambdaHelper; @@ -30,6 +21,7 @@ use Mustache_LambdaHelper; /** * This class will load language strings in a template. * + * @package core * @copyright 2021 Shamim Rezaie * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @since 4.0 diff --git a/lib/classes/output/mustache_engine.php b/lib/classes/output/mustache_engine.php index ada43c20c77..60a7933e74e 100644 --- a/lib/classes/output/mustache_engine.php +++ b/lib/classes/output/mustache_engine.php @@ -68,7 +68,7 @@ class mustache_engine extends \Mustache_Engine { /** * Get the current set of Mustache helpers. * - * @see Mustache_Engine::setHelpers + * @see \Mustache_Engine::setHelpers * * @return \Mustache_HelperCollection */ diff --git a/lib/classes/output/mustache_filesystem_loader.php b/lib/classes/output/mustache_filesystem_loader.php index 7cfdc2143bf..84266836b8c 100644 --- a/lib/classes/output/mustache_filesystem_loader.php +++ b/lib/classes/output/mustache_filesystem_loader.php @@ -14,22 +14,12 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . -/** - * Perform some custom name mapping for template file names (strip leading component/). - * - * @package core - * @category output - * @copyright 2015 Damyon Wiese - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ - namespace core\output; -use coding_exception; - /** * Perform some custom name mapping for template file names. * + * @package core * @copyright 2015 Damyon Wiese * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @since 2.9 diff --git a/lib/classes/output/mustache_helper_collection.php b/lib/classes/output/mustache_helper_collection.php index e2f7b332eb9..2a6f33213a7 100644 --- a/lib/classes/output/mustache_helper_collection.php +++ b/lib/classes/output/mustache_helper_collection.php @@ -14,18 +14,12 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . -/** - * Custom Moodle helper collection for mustache. - * - * @copyright 2019 Ryan Wyllie - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ - namespace core\output; /** * Custom Moodle helper collection for mustache. * + * @package core * @copyright 2019 Ryan Wyllie * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ diff --git a/lib/classes/output/mustache_javascript_helper.php b/lib/classes/output/mustache_javascript_helper.php index 173860d088a..cf163b67a64 100644 --- a/lib/classes/output/mustache_javascript_helper.php +++ b/lib/classes/output/mustache_javascript_helper.php @@ -19,6 +19,7 @@ namespace core\output; /** * Store a list of JS calls to insert at the end of the page. * + * @package core * @copyright 2015 Damyon Wiese * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @since 2.9 diff --git a/lib/classes/output/mustache_pix_helper.php b/lib/classes/output/mustache_pix_helper.php index 9bc374d1414..1942f97e8f9 100644 --- a/lib/classes/output/mustache_pix_helper.php +++ b/lib/classes/output/mustache_pix_helper.php @@ -14,29 +14,18 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . -/** - * Mustache helper render pix icons. - * - * @package core - * @category output - * @copyright 2015 Damyon Wiese - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ - namespace core\output; use Mustache_LambdaHelper; -use renderer_base; /** * This class will call pix_icon with the section content. * + * @package core * @copyright 2015 Damyon Wiese * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - * @since 2.9 */ class mustache_pix_helper { - /** @var renderer_base $renderer A reference to the renderer in use */ private $renderer; @@ -80,4 +69,3 @@ class mustache_pix_helper { return trim($this->renderer->pix_icon($key, $text, $component)); } } - diff --git a/lib/classes/output/mustache_shorten_text_helper.php b/lib/classes/output/mustache_shorten_text_helper.php index 8a470647903..510ca472117 100644 --- a/lib/classes/output/mustache_shorten_text_helper.php +++ b/lib/classes/output/mustache_shorten_text_helper.php @@ -14,25 +14,14 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . -/** - * Mustache helper shorten text. - * - * @package core - * @category output - * @copyright 2017 Ryan Wyllie - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ - namespace core\output; -defined('MOODLE_INTERNAL') || die(); - use Mustache_LambdaHelper; -use renderer_base; /** * This class will call shorten_text with the section content. * + * @package core * @copyright 2017 Ryan Wyllie * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ @@ -62,4 +51,3 @@ class mustache_shorten_text_helper { return shorten_text($text, $length); } } - diff --git a/lib/classes/output/mustache_string_helper.php b/lib/classes/output/mustache_string_helper.php index 0241be53059..f0d78c24d93 100644 --- a/lib/classes/output/mustache_string_helper.php +++ b/lib/classes/output/mustache_string_helper.php @@ -14,15 +14,6 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . -/** - * Mustache helper to load strings from string_manager. - * - * @package core - * @category output - * @copyright 2015 Damyon Wiese - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ - namespace core\output; use Mustache_LambdaHelper; diff --git a/lib/classes/output/mustache_template_finder.php b/lib/classes/output/mustache_template_finder.php index 263725833e3..babc77d1e8d 100644 --- a/lib/classes/output/mustache_template_finder.php +++ b/lib/classes/output/mustache_template_finder.php @@ -14,21 +14,11 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . -/** - * List the valid locations to search for a template with a given name. - * - * @package core - * @category output - * @copyright 2015 Damyon Wiese - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ - namespace core\output; -use coding_exception; -use moodle_exception; +use core\exception\coding_exception; +use core\exception\moodle_exception; use core_component; -use theme_config; /** * Get information about valid locations for mustache templates. @@ -38,7 +28,6 @@ use theme_config; * @since 2.9 */ class mustache_template_finder { - /** * Helper function for getting a list of valid template directories for a specific component. * diff --git a/lib/classes/output/mustache_template_source_loader.php b/lib/classes/output/mustache_template_source_loader.php index b71dc4f5c63..9c054a38643 100644 --- a/lib/classes/output/mustache_template_source_loader.php +++ b/lib/classes/output/mustache_template_source_loader.php @@ -14,19 +14,8 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . -/** - * Load template source strings. - * - * @package core - * @category output - * @copyright 2018 Ryan Wyllie - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ - namespace core\output; -defined('MOODLE_INTERNAL') || die(); - use \Mustache_Tokenizer; /** diff --git a/lib/classes/output/mustache_user_date_helper.php b/lib/classes/output/mustache_user_date_helper.php index 8f02aee3256..5ff809a1f1f 100644 --- a/lib/classes/output/mustache_user_date_helper.php +++ b/lib/classes/output/mustache_user_date_helper.php @@ -14,19 +14,8 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . -/** - * Mustache helper that will convert a timestamp to a date string. - * - * @package core - * @category output - * @copyright 2017 Ryan Wyllie - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ - namespace core\output; -defined('MOODLE_INTERNAL') || die(); - use Mustache_LambdaHelper; /** @@ -36,7 +25,6 @@ use Mustache_LambdaHelper; * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class mustache_user_date_helper { - /** * Read a timestamp and format from the string. * diff --git a/lib/classes/output/named_templatable.php b/lib/classes/output/named_templatable.php index 2404e509c95..c9373b70ac9 100644 --- a/lib/classes/output/named_templatable.php +++ b/lib/classes/output/named_templatable.php @@ -16,8 +16,6 @@ namespace core\output; -use templatable; - /** * A subset of templatable which provides the name of the template to use. * @@ -26,12 +24,11 @@ use templatable; * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ interface named_templatable extends templatable { - /** * Get the name of the template to use for this templatable. * - * @param \renderer_base $renderer The renderer requesting the template name + * @param renderer_base $renderer The renderer requesting the template name * @return string */ - public function get_template_name(\renderer_base $renderer): string; + public function get_template_name(renderer_base $renderer): string; } diff --git a/lib/classes/output/notification.php b/lib/classes/output/notification.php index b15ef759761..ba74371a730 100644 --- a/lib/classes/output/notification.php +++ b/lib/classes/output/notification.php @@ -33,7 +33,7 @@ namespace core\output; * @package core * @category output */ -class notification implements \renderable, \templatable { +class notification implements renderable, templatable { /** * A notification of level 'success'. diff --git a/lib/classes/output/paging_bar.php b/lib/classes/output/paging_bar.php index bc6a47c632c..0d204731dc6 100644 --- a/lib/classes/output/paging_bar.php +++ b/lib/classes/output/paging_bar.php @@ -14,6 +14,13 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . +namespace core\output; + +use core\exception\coding_exception; +use moodle_page; +use moodle_url; +use stdClass; + /** * Component representing a paging bar. * @@ -24,7 +31,6 @@ * @category output */ class paging_bar implements renderable, templatable { - /** * @var int The maximum number of pagelinks to display. */ @@ -253,3 +259,8 @@ class paging_bar implements renderable, templatable { return $data; } } + +// Alias this class to the old name. +// This file will be autoloaded by the legacyclasses autoload system. +// In future all uses of this class will be corrected and the legacy references will be removed. +class_alias(paging_bar::class, \paging_bar::class); diff --git a/lib/classes/output/participants_action_bar.php b/lib/classes/output/participants_action_bar.php index 4195649e8a8..9ddb022a934 100644 --- a/lib/classes/output/participants_action_bar.php +++ b/lib/classes/output/participants_action_bar.php @@ -16,7 +16,7 @@ namespace core\output; -use context_course; +use core\context\course as context_course; use moodle_page; use navigation_node; use moodle_url; @@ -28,7 +28,7 @@ use moodle_url; * @copyright 2021 Peter Dias * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -class participants_action_bar implements \renderable { +class participants_action_bar implements renderable { /** @var object $course The course we are dealing with. */ private $course; /** @var moodle_page $page The current page. */ diff --git a/lib/classes/output/pix_emoticon.php b/lib/classes/output/pix_emoticon.php index 5740c729f25..000092cb596 100644 --- a/lib/classes/output/pix_emoticon.php +++ b/lib/classes/output/pix_emoticon.php @@ -14,6 +14,8 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . +namespace core\output; + /** * Data structure representing an emoticon image * @@ -38,3 +40,8 @@ class pix_emoticon extends pix_icon implements renderable { parent::__construct($pix, $alt, $component, $attributes); } } + +// Alias this class to the old name. +// This file will be autoloaded by the legacyclasses autoload system. +// In future all uses of this class will be corrected and the legacy references will be removed. +class_alias(pix_emoticon::class, \pix_emoticon::class); diff --git a/lib/classes/output/pix_icon.php b/lib/classes/output/pix_icon.php index 0106e7c0d52..1ceaaebb585 100644 --- a/lib/classes/output/pix_icon.php +++ b/lib/classes/output/pix_icon.php @@ -14,6 +14,8 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . +namespace core\output; + /** * Data structure representing an icon. * @@ -141,3 +143,8 @@ class pix_icon implements renderable, templatable { ]; } } + +// Alias this class to the old name. +// This file will be autoloaded by the legacyclasses autoload system. +// In future all uses of this class will be corrected and the legacy references will be removed. +class_alias(pix_icon::class, \pix_icon::class); diff --git a/lib/classes/output/pix_icon_font.php b/lib/classes/output/pix_icon_font.php index 280853de86a..dce04f61462 100644 --- a/lib/classes/output/pix_icon_font.php +++ b/lib/classes/output/pix_icon_font.php @@ -14,6 +14,8 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . +namespace core\output; + /** * Data structure representing an icon font. * @@ -23,7 +25,6 @@ * @category output */ class pix_icon_font implements templatable { - /** * @var pix_icon $pixicon The original icon. */ @@ -49,7 +50,7 @@ class pix_icon_font implements templatable { $this->pixicon = $pixicon; $this->mapped = false; - $iconsystem = \core\output\icon_system::instance(); + $iconsystem = icon_system::instance(); $this->key = $iconsystem->remap_icon_name($pixicon->pix, $pixicon->component); if (!empty($this->key)) { @@ -91,3 +92,8 @@ class pix_icon_font implements templatable { return $data; } } + +// Alias this class to the old name. +// This file will be autoloaded by the legacyclasses autoload system. +// In future all uses of this class will be corrected and the legacy references will be removed. +class_alias(pix_icon_font::class, \pix_icon_font::class); diff --git a/lib/classes/output/pix_icon_fontawesome.php b/lib/classes/output/pix_icon_fontawesome.php index 8cab6924e5c..77f15233d8a 100644 --- a/lib/classes/output/pix_icon_fontawesome.php +++ b/lib/classes/output/pix_icon_fontawesome.php @@ -14,6 +14,8 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . +namespace core\output; + /** * Data structure representing an icon subtype. * @@ -24,3 +26,8 @@ */ class pix_icon_fontawesome extends pix_icon_font { } + +// Alias this class to the old name. +// This file will be autoloaded by the legacyclasses autoload system. +// In future all uses of this class will be corrected and the legacy references will be removed. +class_alias(pix_icon_fontawesome::class, \pix_icon_fontawesome::class); diff --git a/lib/classes/output/plugin_renderer_base.php b/lib/classes/output/plugin_renderer_base.php index 922d867a867..df6b94df22d 100644 --- a/lib/classes/output/plugin_renderer_base.php +++ b/lib/classes/output/plugin_renderer_base.php @@ -14,6 +14,11 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . +namespace core\output; + +use core\exception\coding_exception; +use moodle_page; + /** * Basis for all plugin renderers. * @@ -24,7 +29,6 @@ * @category output */ class plugin_renderer_base extends renderer_base { - /** * @var renderer_base|core_renderer A reference to the current renderer. * The renderer provided here will be determined by the page but will in 90% @@ -129,3 +133,8 @@ class plugin_renderer_base extends renderer_base { } } } + +// Alias this class to the old name. +// This file will be autoloaded by the legacyclasses autoload system. +// In future all uses of this class will be corrected and the legacy references will be removed. +class_alias(plugin_renderer_base::class, \plugin_renderer_base::class); diff --git a/lib/classes/output/preferences_group.php b/lib/classes/output/preferences_group.php index bc8a5d0d7a7..4ab98a1d821 100644 --- a/lib/classes/output/preferences_group.php +++ b/lib/classes/output/preferences_group.php @@ -14,6 +14,8 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . +namespace core\output; + /** * Represents a group of preferences page link. * @@ -45,3 +47,8 @@ class preferences_group implements renderable { $this->nodes = $nodes; } } + +// Alias this class to the old name. +// This file will be autoloaded by the legacyclasses autoload system. +// In future all uses of this class will be corrected and the legacy references will be removed. +class_alias(preferences_group::class, \preferences_group::class); diff --git a/lib/classes/output/preferences_groups.php b/lib/classes/output/preferences_groups.php index 6bdcf936fb0..3b40bb4baa8 100644 --- a/lib/classes/output/preferences_groups.php +++ b/lib/classes/output/preferences_groups.php @@ -14,6 +14,8 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . +namespace core\output; + /** * Represents a set of preferences groups. * @@ -37,3 +39,8 @@ class preferences_groups implements renderable { $this->groups = $groups; } } + +// Alias this class to the old name. +// This file will be autoloaded by the legacyclasses autoload system. +// In future all uses of this class will be corrected and the legacy references will be removed. +class_alias(preferences_groups::class, \preferences_groups::class); diff --git a/lib/classes/output/progress_bar.php b/lib/classes/output/progress_bar.php index a674ec87d28..b0b3476777c 100644 --- a/lib/classes/output/progress_bar.php +++ b/lib/classes/output/progress_bar.php @@ -14,6 +14,10 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . +namespace core\output; + +use core\exception\coding_exception; + /** * Progress bar class. * @@ -202,3 +206,8 @@ class progress_bar implements renderable, templatable { ]; } } + +// Alias this class to the old name. +// This file will be autoloaded by the legacyclasses autoload system. +// In future all uses of this class will be corrected and the legacy references will be removed. +class_alias(progress_bar::class, \progress_bar::class); diff --git a/lib/classes/output/renderable.php b/lib/classes/output/renderable.php index 7c1a065146b..d9a3263dbc6 100644 --- a/lib/classes/output/renderable.php +++ b/lib/classes/output/renderable.php @@ -14,6 +14,8 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . +namespace core\output; + /** * Interface marking other classes as suitable for renderer_base::render() * @@ -24,3 +26,8 @@ interface renderable { // intentionally empty } + +// Alias this class to the old name. +// This file will be autoloaded by the legacyclasses autoload system. +// In future all uses of this class will be corrected and the legacy references will be removed. +class_alias(renderable::class, \renderable::class); diff --git a/lib/classes/output/renderer_base.php b/lib/classes/output/renderer_base.php index c33c12bfafe..faef3897910 100644 --- a/lib/classes/output/renderer_base.php +++ b/lib/classes/output/renderer_base.php @@ -14,7 +14,15 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . -use core\output\named_templatable; +namespace core\output; + +use core\context\system as context_system; +use core\exception\moodle_exception; +use core\exception\coding_exception; +use core\output\actions\component_action; +use moodle_page; +use moodle_url; +use Mustache_Exception_UnknownTemplateException; /** * Simple base class for Moodle renderers. @@ -46,7 +54,7 @@ class renderer_base { protected $target; /** - * @var Mustache_Engine $mustache The mustache template compiler + * @var \Mustache_Engine The mustache template compiler */ private $mustache; @@ -59,7 +67,7 @@ class renderer_base { * Return an instance of the mustache class. * * @since 2.9 - * @return Mustache_Engine + * @return \Mustache_Engine */ protected function get_mustache() { global $CFG; @@ -84,14 +92,14 @@ class renderer_base { } } - $loader = new \core\output\mustache_filesystem_loader(); - $stringhelper = new \core\output\mustache_string_helper(); - $cleanstringhelper = new \core\output\mustache_clean_string_helper(); - $quotehelper = new \core\output\mustache_quote_helper(); - $jshelper = new \core\output\mustache_javascript_helper($this->page); - $pixhelper = new \core\output\mustache_pix_helper($this); - $shortentexthelper = new \core\output\mustache_shorten_text_helper(); - $userdatehelper = new \core\output\mustache_user_date_helper(); + $loader = new mustache_filesystem_loader(); + $stringhelper = new mustache_string_helper(); + $cleanstringhelper = new mustache_clean_string_helper(); + $quotehelper = new mustache_quote_helper(); + $jshelper = new mustache_javascript_helper($this->page); + $pixhelper = new mustache_pix_helper($this); + $shortentexthelper = new mustache_shorten_text_helper(); + $userdatehelper = new mustache_user_date_helper(); // We only expose the variables that are exposed to JS templates. $safeconfig = $this->page->requires->get_config_for_javascript($this->page, $this); @@ -106,12 +114,12 @@ class renderer_base { 'userdate' => array($userdatehelper, 'transform'), ); - $this->mustache = new \core\output\mustache_engine(array( + $this->mustache = new mustache_engine(array( 'cache' => $cachedir, 'escape' => 's', 'loader' => $loader, 'helpers' => $helpers, - 'pragmas' => [Mustache_Engine::PRAGMA_BLOCKS], + 'pragmas' => [\Mustache_Engine::PRAGMA_BLOCKS], // Don't allow the JavaScript helper to be executed from within another // helper. If it's allowed it can be used by users to inject malicious // JS into the page. @@ -168,7 +176,7 @@ class renderer_base { // but will be different from template to template. This is useful for // e.g. aria attributes that only work with id attributes and must be // unique in a page. - $mustache->addHelper('uniqid', new \core\output\mustache_uniqid_helper()); + $mustache->addHelper('uniqid', new mustache_uniqid_helper()); if (isset($this->templatecache[$templatename])) { $template = $this->templatecache[$templatename]; } else { @@ -404,3 +412,8 @@ class renderer_base { return $this->page; } } + +// Alias this class to the old name. +// This file will be autoloaded by the legacyclasses autoload system. +// In future all uses of this class will be corrected and the legacy references will be removed. +class_alias(renderer_base::class, \renderer_base::class); diff --git a/lib/classes/output/renderer_factory/renderer_factory_base.php b/lib/classes/output/renderer_factory/renderer_factory_base.php index 73367d34bf0..16009bd8cab 100644 --- a/lib/classes/output/renderer_factory/renderer_factory_base.php +++ b/lib/classes/output/renderer_factory/renderer_factory_base.php @@ -14,6 +14,12 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . +namespace core\output\renderer_factory; + +use core_component; +use core\exception\coding_exception; +use core\output\theme_config; + /** * This is a base class to help you implement the renderer_factory interface. * @@ -29,19 +35,16 @@ * @package core * @category output */ -abstract class renderer_factory_base implements renderer_factory { - /** - * @var theme_config The theme we belong to. - */ - protected $theme; - +abstract class renderer_factory_base implements renderer_factory_interface { /** * Constructor. * * @param theme_config $theme the theme we belong to. */ - public function __construct(theme_config $theme) { - $this->theme = $theme; + public function __construct( + /** @var theme_config The theme we belong to */ + protected theme_config $theme, + ) { } /** @@ -195,3 +198,8 @@ abstract class renderer_factory_base implements renderer_factory { return $classnames; } } + +// Alias this class to the old name. +// This file will be autoloaded by the legacyclasses autoload system. +// In future all uses of this class will be corrected and the legacy references will be removed. +class_alias(renderer_factory_base::class, \renderer_factory_base::class); diff --git a/lib/classes/output/renderer_factory/renderer_factory_interface.php b/lib/classes/output/renderer_factory/renderer_factory_interface.php index 0b4631443ba..9707182c517 100644 --- a/lib/classes/output/renderer_factory/renderer_factory_interface.php +++ b/lib/classes/output/renderer_factory/renderer_factory_interface.php @@ -14,6 +14,11 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . +namespace core\output\renderer_factory; + +use moodle_page; +use core\output\renderer_base; + /** * A renderer factory is just responsible for creating an appropriate renderer * for any given part of Moodle. @@ -30,8 +35,7 @@ * @package core * @category output */ -interface renderer_factory { - +interface renderer_factory_interface { /** * Return the renderer for a particular part of Moodle. * @@ -59,3 +63,8 @@ interface renderer_factory { */ public function get_renderer(moodle_page $page, $component, $subtype=null, $target=null); } + +// Alias this class to the old name. +// This file will be autoloaded by the legacyclasses autoload system. +// In future all uses of this class will be corrected and the legacy references will be removed. +class_alias(renderer_factory_interface::class, \renderer_factory::class); diff --git a/lib/classes/output/renderer_factory/standard_renderer_factory.php b/lib/classes/output/renderer_factory/standard_renderer_factory.php index 4256dd11563..ac2651d992a 100644 --- a/lib/classes/output/renderer_factory/standard_renderer_factory.php +++ b/lib/classes/output/renderer_factory/standard_renderer_factory.php @@ -14,6 +14,12 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . +namespace core\output\renderer_factory; + +use core\exception\coding_exception; +use core\output\renderer_base; +use moodle_page; + /** * This is the default renderer factory for Moodle. * @@ -26,7 +32,6 @@ * @category output */ class standard_renderer_factory extends renderer_factory_base { - /** * Implement the subclass method * @@ -78,3 +83,8 @@ class standard_renderer_factory extends renderer_factory_base { return new $classname($page, $target); } } + +// Alias this class to the old name. +// This file will be autoloaded by the legacyclasses autoload system. +// In future all uses of this class will be corrected and the legacy references will be removed. +class_alias(standard_renderer_factory::class, \standard_renderer_factory::class); diff --git a/lib/classes/output/renderer_factory/theme_overridden_renderer_factory.php b/lib/classes/output/renderer_factory/theme_overridden_renderer_factory.php index 81487f1e6c6..3e7cc10bfac 100644 --- a/lib/classes/output/renderer_factory/theme_overridden_renderer_factory.php +++ b/lib/classes/output/renderer_factory/theme_overridden_renderer_factory.php @@ -14,6 +14,13 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . +namespace core\output\renderer_factory; + +use core\exception\coding_exception; +use core\output\renderer_base; +use core\output\theme_config; +use moodle_page; + /** * This is renderer factory allows themes to override the standard renderers using php code. * @@ -116,3 +123,8 @@ class theme_overridden_renderer_factory extends renderer_factory_base { throw new coding_exception('Request for an unknown renderer ' . $component . ', ' . $subtype . ', ' . $target); } } + +// Alias this class to the old name. +// This file will be autoloaded by the legacyclasses autoload system. +// In future all uses of this class will be corrected and the legacy references will be removed. +class_alias(theme_overridden_renderer_factory::class, \theme_overridden_renderer_factory::class); diff --git a/lib/classes/output/requirements/fragment_requirements_manager.php b/lib/classes/output/requirements/fragment_requirements_manager.php index 840d3b55f2f..9a71fe77f59 100644 --- a/lib/classes/output/requirements/fragment_requirements_manager.php +++ b/lib/classes/output/requirements/fragment_requirements_manager.php @@ -14,6 +14,11 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . +namespace core\output\requirements; + +use html_writer; +use js_writer; + /** * This requirements manager captures the appropriate html for creating a fragment to * be inserted elsewhere. @@ -54,7 +59,6 @@ class fragment_requirements_manager extends page_requirements_manager { return $output; } - /** * Generate any HTML that needs to go at the end of the page. * @@ -116,3 +120,8 @@ class fragment_requirements_manager extends page_requirements_manager { return $output; } } + +// Alias this class to the old name. +// This file will be autoloaded by the legacyclasses autoload system. +// In future all uses of this class will be corrected and the legacy references will be removed. +class_alias(fragment_requirements_manager::class, \fragment_requirements_manager::class); diff --git a/lib/classes/output/requirements/page_requirements_manager.php b/lib/classes/output/requirements/page_requirements_manager.php index 5e68103dfd5..f19999b558e 100644 --- a/lib/classes/output/requirements/page_requirements_manager.php +++ b/lib/classes/output/requirements/page_requirements_manager.php @@ -14,6 +14,20 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . +namespace core\output\requirements; + +use core_component; +use core\context\course as context_course; +use core\exception\coding_exception; +use core\output\core_renderer; +use core\output\js_writer; +use core\output\html_writer; +use core\output\renderer_base; +use lang_string; +use moodle_page; +use moodle_url; +use stdClass; + /** * This class tracks all the things that are needed by the current page. * @@ -45,7 +59,6 @@ * @category output */ class page_requirements_manager { - /** * @var array List of string available from JS */ @@ -131,7 +144,7 @@ class page_requirements_manager { protected $yui3loader; /** - * @var YUI_config default YUI loader configuration + * @var yui default YUI loader configuration */ protected $YUI_config; @@ -165,7 +178,7 @@ class page_requirements_manager { $sep = empty($CFG->yuislasharguments) ? '?' : '/'; $this->yui3loader = new stdClass(); - $this->YUI_config = new YUI_config(); + $this->YUI_config = new yui(); // Set up some loader options. $this->yui3loader->local_base = $CFG->wwwroot . '/lib/yuilib/'. $CFG->yui3version . '/'; @@ -1812,3 +1825,8 @@ EOF; return $this->onetimeitemsoutput[$thing] = true; } } + +// Alias this class to the old name. +// This file will be autoloaded by the legacyclasses autoload system. +// In future all uses of this class will be corrected and the legacy references will be removed. +class_alias(page_requirements_manager::class, \page_requirements_manager::class); diff --git a/lib/classes/output/requirements/yui.php b/lib/classes/output/requirements/yui.php index 272753aa4fe..367177fc80b 100644 --- a/lib/classes/output/requirements/yui.php +++ b/lib/classes/output/requirements/yui.php @@ -14,6 +14,14 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . +namespace core\output\requirements; + +use cache; +use core_component; +use core_minify; +use core\exception\coding_exception; +use DirectoryIterator; + /** * This class represents the YUI configuration. * @@ -23,7 +31,7 @@ * @package core * @category output */ -class YUI_config { +class yui { /** * These settings must be public so that when the object is converted to json they are exposed. * Note: Some of these are camelCase because YUI uses camelCase variable names. @@ -349,3 +357,8 @@ class YUI_config { } } } + +// Alias this class to the old name. +// This file will be autoloaded by the legacyclasses autoload system. +// In future all uses of this class will be corrected and the legacy references will be removed. +class_alias(yui::class, \YUI_config::class); diff --git a/lib/classes/output/select_menu.php b/lib/classes/output/select_menu.php index eb487911d17..ee512815299 100644 --- a/lib/classes/output/select_menu.php +++ b/lib/classes/output/select_menu.php @@ -18,8 +18,6 @@ declare(strict_types=1); namespace core\output; -use renderer_base; - /** * A single-select combobox widget that is functionally similar to an HTML select element. * @@ -28,7 +26,7 @@ use renderer_base; * @copyright 2022 Shamim Rezaie * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -class select_menu implements \renderable, \templatable { +class select_menu implements renderable, templatable { /** @var array List of options. */ protected $options; diff --git a/lib/classes/output/single_button.php b/lib/classes/output/single_button.php index 83de95439b3..c2dbfb607de 100644 --- a/lib/classes/output/single_button.php +++ b/lib/classes/output/single_button.php @@ -14,6 +14,13 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . +namespace core\output; + +use core\output\actions\confirm_action; +use core\output\actions\component_action; +use moodle_url; +use stdClass; + /** * Data structure representing a simple form with only one button. * @@ -24,7 +31,6 @@ * @category output */ class single_button implements renderable { - /** * Possible button types. From boostrap. */ @@ -264,3 +270,8 @@ class single_button implements renderable { return $data; } } + +// Alias this class to the old name. +// This file will be autoloaded by the legacyclasses autoload system. +// In future all uses of this class will be corrected and the legacy references will be removed. +class_alias(single_button::class, \single_button::class); diff --git a/lib/classes/output/single_select.php b/lib/classes/output/single_select.php index 4645e7bd8b7..6e7954eab42 100644 --- a/lib/classes/output/single_select.php +++ b/lib/classes/output/single_select.php @@ -14,6 +14,13 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . +namespace core\output; + +use core\exception\coding_exception; +use core\output\actions\component_action; +use moodle_url; +use stdClass; + /** * Simple form with just one select field that gets submitted automatically. * @@ -287,3 +294,8 @@ class single_select implements renderable, templatable { return $data; } } + +// Alias this class to the old name. +// This file will be autoloaded by the legacyclasses autoload system. +// In future all uses of this class will be corrected and the legacy references will be removed. +class_alias(single_select::class, \single_select::class); diff --git a/lib/classes/output/sticky_footer.php b/lib/classes/output/sticky_footer.php index a007c2b060e..fdb88d57251 100644 --- a/lib/classes/output/sticky_footer.php +++ b/lib/classes/output/sticky_footer.php @@ -16,8 +16,6 @@ namespace core\output; -use renderable; - /** * Class to render a sticky footer element. * diff --git a/lib/classes/output/tabobject.php b/lib/classes/output/tabobject.php index 305d5b30a75..7d7fa865833 100644 --- a/lib/classes/output/tabobject.php +++ b/lib/classes/output/tabobject.php @@ -14,6 +14,10 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . +namespace core\output; + +use moodle_url; + /** * Stores one tab * @@ -138,3 +142,8 @@ class tabobject implements renderable, templatable { } } + +// Alias this class to the old name. +// This file will be autoloaded by the legacyclasses autoload system. +// In future all uses of this class will be corrected and the legacy references will be removed. +class_alias(tabobject::class, \tabobject::class); diff --git a/lib/classes/output/tabtree.php b/lib/classes/output/tabtree.php index ca31e32ea7e..62a58a25694 100644 --- a/lib/classes/output/tabtree.php +++ b/lib/classes/output/tabtree.php @@ -14,6 +14,8 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . +namespace core\output; + /** * Stores tabs list * @@ -70,7 +72,7 @@ class tabtree extends tabobject { * Export for template. * * @param renderer_base $output Renderer. - * @return object + * @return \stdClass */ public function export_for_template(renderer_base $output) { $tabs = []; @@ -89,3 +91,8 @@ class tabtree extends tabobject { ]; } } + +// Alias this class to the old name. +// This file will be autoloaded by the legacyclasses autoload system. +// In future all uses of this class will be corrected and the legacy references will be removed. +class_alias(tabtree::class, \tabtree::class); diff --git a/lib/classes/output/templatable.php b/lib/classes/output/templatable.php index 8a05b61e43e..007335e697f 100644 --- a/lib/classes/output/templatable.php +++ b/lib/classes/output/templatable.php @@ -14,16 +14,18 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . +namespace core\output; + /** * Interface marking other classes having the ability to export their data for use by templates. * * @copyright 2015 Damyon Wiese + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @package core * @category output * @since 2.9 */ interface templatable { - /** * Function to export the renderer data in a format that is suitable for a * mustache template. This means: @@ -31,7 +33,12 @@ interface templatable { * 2. Any additional info that is required for the template is pre-calculated (e.g. capability checks). * * @param renderer_base $output Used to do a final render of any components that need to be rendered for export. - * @return stdClass|array + * @return \stdClass|array */ public function export_for_template(renderer_base $output); } + +// Alias this class to the old name. +// This file will be autoloaded by the legacyclasses autoload system. +// In future all uses of this class will be corrected and the legacy references will be removed. +class_alias(templatable::class, \templatable::class); diff --git a/lib/classes/output/theme_config.php b/lib/classes/output/theme_config.php index d162a454fea..4edc1b65697 100644 --- a/lib/classes/output/theme_config.php +++ b/lib/classes/output/theme_config.php @@ -14,6 +14,25 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . +namespace core\output; + +use cache; +use cache_store; +use core_component; +use core_cssparser; +use core_minify; +use core_php_time_limit; +use core_rtlcss; +use core_scss; +use core_useragent; +use core\context\system as context_system; +use core\exception\coding_exception; +use core\output\renderer_factory\standard_renderer_factory; +use dml_exception; +use moodle_page; +use moodle_url; +use stdClass; + /** * This class represents the configuration variables of a Moodle theme. * @@ -172,7 +191,7 @@ class theme_config { * your own custom renderers in a lib.php file in this theme (or the parent theme). * */ - public $rendererfactory = 'standard_renderer_factory'; + public $rendererfactory = standard_renderer_factory::class; /** * @var string Function to do custom CSS post-processing. @@ -424,23 +443,23 @@ class theme_config { $settings = new stdClass(); } - if ($config = theme_config::find_theme_config($themename, $settings)) { - return new theme_config($config); + if ($config = self::find_theme_config($themename, $settings)) { + return new self($config); - } else if ($themename == theme_config::DEFAULT_THEME) { - throw new coding_exception('Default theme '.theme_config::DEFAULT_THEME.' not available or broken!'); + } else if ($themename == self::DEFAULT_THEME) { + throw new coding_exception('Default theme '.self::DEFAULT_THEME.' not available or broken!'); - } else if ($config = theme_config::find_theme_config($CFG->theme, $settings)) { + } else if ($config = self::find_theme_config($CFG->theme, $settings)) { debugging('This page should be using theme ' . $themename . ' which cannot be initialised. Falling back to the site theme ' . $CFG->theme, DEBUG_NORMAL); - return new theme_config($config); + return new self($config); } else { // bad luck, the requested theme has some problems - admin see details in theme config debugging('This page should be using theme ' . $themename . ' which cannot be initialised. Nor can the site theme ' . $CFG->theme . - '. Falling back to ' . theme_config::DEFAULT_THEME, DEBUG_NORMAL); - return new theme_config(theme_config::find_theme_config(theme_config::DEFAULT_THEME, $settings)); + '. Falling back to ' . self::DEFAULT_THEME, DEBUG_NORMAL); + return new self(self::find_theme_config(self::DEFAULT_THEME, $settings)); } } @@ -496,7 +515,7 @@ class theme_config { // verify all parents and load configs and renderers foreach ($this->parents as $parent) { - if (!$parent_config = theme_config::find_theme_config($parent, $this->settings)) { + if (!$parent_config = self::find_theme_config($parent, $this->settings)) { // this is not good - better exclude faulty parents continue; } @@ -1286,15 +1305,15 @@ class theme_config { // Getting all the candidate functions. $system = false; - if (isset($this->iconsystem) && \core\output\icon_system::is_valid_system($this->iconsystem)) { + if (isset($this->iconsystem) && icon_system::is_valid_system($this->iconsystem)) { return $this->iconsystem; } foreach ($this->parent_configs as $parent_config) { - if (isset($parent_config->iconsystem) && \core\output\icon_system::is_valid_system($parent_config->iconsystem)) { + if (isset($parent_config->iconsystem) && icon_system::is_valid_system($parent_config->iconsystem)) { return $parent_config->iconsystem; } } - return \core\output\icon_system::STANDARD; + return icon_system::STANDARD; } /** @@ -1386,7 +1405,7 @@ class theme_config { // We collect the SCSS property until we've found one. if (empty($scss) && !empty($config->scss)) { $candidate = is_string($config->scss) ? "{$path}/{$config->scss}.scss" : $config->scss; - if ($candidate instanceof Closure) { + if ($candidate instanceof \Closure) { $scss = $candidate; } else if (is_string($candidate) && is_readable($candidate)) { $scss = $candidate; @@ -2060,7 +2079,7 @@ class theme_config { // We have to use the variable name $THEME (upper case) because that // is what is used in theme config.php files. - if (!$dir = theme_config::find_theme_location($themename)) { + if (!$dir = self::find_theme_location($themename)) { return null; } @@ -2081,7 +2100,7 @@ class theme_config { if ($parentscheck) { // Find all parent theme configs. foreach ($THEME->parents as $parent) { - $parentconfig = theme_config::find_theme_config($parent, $settings, false); + $parentconfig = self::find_theme_config($parent, $settings, false); if (empty($parentconfig)) { return null; } @@ -2310,3 +2329,7 @@ class theme_config { } } +// Alias this class to the old name. +// This file will be autoloaded by the legacyclasses autoload system. +// In future all uses of this class will be corrected and the legacy references will be removed. +class_alias(theme_config::class, \theme_config::class); diff --git a/lib/classes/output/url_select.php b/lib/classes/output/url_select.php index 9051e83d0a4..0f043fa0815 100644 --- a/lib/classes/output/url_select.php +++ b/lib/classes/output/url_select.php @@ -14,6 +14,12 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . +namespace core\output; + +use core\exception\coding_exception; +use moodle_url; +use stdClass; + /** * Simple URL selection widget description. * @@ -280,3 +286,8 @@ class url_select implements renderable, templatable { return $data; } } + +// Alias this class to the old name. +// This file will be autoloaded by the legacyclasses autoload system. +// In future all uses of this class will be corrected and the legacy references will be removed. +class_alias(url_select::class, \url_select::class); diff --git a/lib/classes/output/user_picture.php b/lib/classes/output/user_picture.php index d278e4d2c10..a7947b6430c 100644 --- a/lib/classes/output/user_picture.php +++ b/lib/classes/output/user_picture.php @@ -14,6 +14,13 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . +namespace core\output; + +use core\context\user as context_user; +use moodle_page; +use moodle_url; +use stdClass; + /** * Data structure representing a user picture. * @@ -33,7 +40,7 @@ class user_picture implements renderable { /** * @var int The course id. Used when constructing the link to the user's * profile, page course id used if not specified. - */ + */ public $courseid; /** @@ -300,3 +307,8 @@ class user_picture implements renderable { return $defaulturl; } } + +// Alias this class to the old name. +// This file will be autoloaded by the legacyclasses autoload system. +// In future all uses of this class will be corrected and the legacy references will be removed. +class_alias(user_picture::class, \user_picture::class); diff --git a/lib/classes/output/xhtml_container_stack.php b/lib/classes/output/xhtml_container_stack.php index 193b90ab36b..64e7192397b 100644 --- a/lib/classes/output/xhtml_container_stack.php +++ b/lib/classes/output/xhtml_container_stack.php @@ -14,6 +14,10 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . +namespace core\output; + +use stdClass; + /** * This class keeps track of which HTML tags are currently open. * @@ -62,7 +66,7 @@ class xhtml_container_stack { * @param string $closehtml The HTML required to close the container. */ public function push($type, $closehtml) { - $container = new stdClass; + $container = new stdClass(); $container->type = $type; $container->closehtml = $closehtml; if ($this->isdebugging) { @@ -151,3 +155,8 @@ class xhtml_container_stack { return '
    ' . implode("\n", $this->log) . '
'; } } + +// Alias this class to the old name. +// This file will be autoloaded by the legacyclasses autoload system. +// In future all uses of this class will be corrected and the legacy references will be removed. +class_alias(xhtml_container_stack::class, \xhtml_container_stack::class); diff --git a/lib/pagelib.php b/lib/pagelib.php index 169e0354a15..1c4d0019509 100644 --- a/lib/pagelib.php +++ b/lib/pagelib.php @@ -31,6 +31,7 @@ use core\navigation\views\primary; use core\navigation\views\secondary; use core\navigation\output\primary as primaryoutput; use core\output\activity_header; +use core\output\xhtml_container_stack; /** * $PAGE is a central store of information about the current page we are diff --git a/lib/table/classes/base_export_format.php b/lib/table/classes/base_export_format.php index 40abfc8b22f..22b29fd89db 100644 --- a/lib/table/classes/base_export_format.php +++ b/lib/table/classes/base_export_format.php @@ -14,6 +14,10 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . +namespace core_table; + +use flexible_table; + defined('MOODLE_INTERNAL') || die(); global $CFG; @@ -21,11 +25,13 @@ global $CFG; require_once("{$CFG->libdir}/tablelib.php"); /** + * The table base export format. + * * @package moodlecore * @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com} * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -class table_default_export_format_parent { +class base_export_format { /** * @var flexible_table or child class reference pointing to table class * object from which to export data. @@ -93,3 +99,8 @@ class table_default_export_format_parent { return array_map([$this, 'format_text'], $row); } } + +// Alias this class to the old name. +// This file will be autoloaded by the legacyclasses autoload system. +// In future all uses of this class will be corrected and the legacy references will be removed. +class_alias(base_export_format::class, \table_default_export_format_parent::class); diff --git a/lib/table/classes/dataformat_export_format.php b/lib/table/classes/dataformat_export_format.php index aca76e07342..4d2922728cf 100644 --- a/lib/table/classes/dataformat_export_format.php +++ b/lib/table/classes/dataformat_export_format.php @@ -14,6 +14,10 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . +namespace core_table; + +use core\exception\coding_exception; + defined('MOODLE_INTERNAL') || die(); global $CFG; @@ -30,8 +34,7 @@ use core\dataformat; * @copyright 2016 Brendan Heywood (brendan@catalyst-au.net) * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -class table_dataformat_export_format extends table_default_export_format_parent { - +class dataformat_export_format extends base_export_format { /** @var \core\dataformat\base $dataformat */ protected $dataformat; @@ -146,3 +149,8 @@ class table_dataformat_export_format extends table_default_export_format_parent exit(); } } + +// Alias this class to the old name. +// This file will be autoloaded by the legacyclasses autoload system. +// In future all uses of this class will be corrected and the legacy references will be removed. +class_alias(dataformat_export_format::class, \table_dataformat_export_format::class); diff --git a/lib/table/classes/flexible_table.php b/lib/table/classes/flexible_table.php index cf683e47023..3950b5770ce 100644 --- a/lib/table/classes/flexible_table.php +++ b/lib/table/classes/flexible_table.php @@ -14,7 +14,16 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . +namespace core_table; + +use core\context; use core_table\local\filter\filterset; +use core\exception\coding_exception; +use core\output\renderable; +use html_writer; +use moodle_url; +use paging_bar; +use stdClass; defined('MOODLE_INTERNAL') || die(); @@ -128,7 +137,7 @@ class flexible_table { */ var $started_output = false; - /** @var table_dataformat_export_format */ + /** @var dataformat_export_format */ var $exportclass = null; /** @@ -209,8 +218,8 @@ class flexible_table { /** * Get, and optionally set, the export class. - * @param table_dataformat_export_format $exportclass (optional) if passed, set the table to use this export class. - * @return table_dataformat_export_format the export class in use (after any set). + * @param dataformat_export_format $exportclass (optional) if passed, set the table to use this export class. + * @return dataformat_export_format the export class in use (after any set). */ function export_class_instance($exportclass = null) { if (!is_null($exportclass)) { @@ -218,7 +227,7 @@ class flexible_table { $this->exportclass = $exportclass; $this->exportclass->table = $this; } else if (is_null($this->exportclass) && !empty($this->download)) { - $this->exportclass = new table_dataformat_export_format($this, $this->download); + $this->exportclass = new dataformat_export_format($this, $this->download); if (!$this->exportclass->document_started()) { $this->exportclass->start_document($this->filename, $this->sheettitle); } @@ -1735,7 +1744,7 @@ class flexible_table { * @return string */ protected function get_dynamic_table_html_start(): string { - if (is_a($this, \core_table\dynamic::class)) { + if (is_a($this, dynamic::class)) { $sortdata = array_map(function($sortby, $sortorder) { return [ 'sortby' => $sortby, @@ -1773,7 +1782,7 @@ class flexible_table { protected function get_dynamic_table_html_end(): string { global $PAGE; - if (is_a($this, \core_table\dynamic::class)) { + if (is_a($this, dynamic::class)) { $output = ''; $perpageurl = new moodle_url($PAGE->url); @@ -1948,7 +1957,7 @@ class flexible_table { public function get_context(): context { global $PAGE; - if (is_a($this, \core_table\dynamic::class)) { + if (is_a($this, dynamic::class)) { throw new coding_exception('The get_context function must be defined for a dynamic table'); } @@ -1990,8 +1999,12 @@ class flexible_table { * Attempt to guess the base URL. */ public function guess_base_url(): void { - if (is_a($this, \core_table\dynamic::class)) { + if (is_a($this, dynamic::class)) { throw new coding_exception('The guess_base_url function must be defined for a dynamic table'); } } } +// Alias this class to the old name. +// This file will be autoloaded by the legacyclasses autoload system. +// In future all uses of this class will be corrected and the legacy references will be removed. +class_alias(flexible_table::class, \flexible_table::class); diff --git a/lib/table/classes/output/html_table.php b/lib/table/classes/output/html_table.php index 86cc3a3b4e2..c04ef01bc7e 100644 --- a/lib/table/classes/output/html_table.php +++ b/lib/table/classes/output/html_table.php @@ -14,6 +14,8 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . +namespace core_table\output; + /** * Holds all the information required to render a by {@link core_renderer::table()} * @@ -205,3 +207,8 @@ class html_table { $this->attributes['class'] = ''; } } + +// Alias this class to the old name. +// This file will be autoloaded by the legacyclasses autoload system. +// In future all uses of this class will be corrected and the legacy references will be removed. +class_alias(html_table::class, \html_table::class); diff --git a/lib/table/classes/output/html_table_cell.php b/lib/table/classes/output/html_table_cell.php index bc4c8ab31fb..038fb27ad50 100644 --- a/lib/table/classes/output/html_table_cell.php +++ b/lib/table/classes/output/html_table_cell.php @@ -14,6 +14,8 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . +namespace core_table\output; + /** * Component representing a table cell. * @@ -24,7 +26,6 @@ * @category output */ class html_table_cell { - /** * @var string Value to use for the id attribute of the cell. */ @@ -80,3 +81,8 @@ class html_table_cell { $this->attributes['class'] = ''; } } + +// Alias this class to the old name. +// This file will be autoloaded by the legacyclasses autoload system. +// In future all uses of this class will be corrected and the legacy references will be removed. +class_alias(html_table_cell::class, \html_table_cell::class); diff --git a/lib/table/classes/output/html_table_row.php b/lib/table/classes/output/html_table_row.php index 8a0a366bd17..6b92c0a5486 100644 --- a/lib/table/classes/output/html_table_row.php +++ b/lib/table/classes/output/html_table_row.php @@ -14,6 +14,8 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . +namespace core_table\output; + /** * Component representing a table row. * @@ -24,7 +26,6 @@ * @category output */ class html_table_row { - /** * @var string Value to use for the id attribute of the row. */ @@ -61,3 +62,8 @@ class html_table_row { } } } + +// Alias this class to the old name. +// This file will be autoloaded by the legacyclasses autoload system. +// In future all uses of this class will be corrected and the legacy references will be removed. +class_alias(html_table_row::class, \html_table_row::class); diff --git a/lib/table/classes/sql_table.php b/lib/table/classes/sql_table.php index 21771010c68..00e26153535 100644 --- a/lib/table/classes/sql_table.php +++ b/lib/table/classes/sql_table.php @@ -14,6 +14,12 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . +namespace core_table; + +use flexible_table; +use moodle_recordset; +use stdClass; + defined('MOODLE_INTERNAL') || die(); global $CFG; @@ -27,8 +33,7 @@ require_once("{$CFG->libdir}/tablelib.php"); * @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com} * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -class table_sql extends flexible_table { - +class sql_table extends flexible_table { public $countsql = NULL; public $countparams = NULL; /** @@ -203,3 +208,8 @@ class table_sql extends flexible_table { $this->finish_output(); } } + +// Alias this class to the old name. +// This file will be autoloaded by the legacyclasses autoload system. +// In future all uses of this class will be corrected and the legacy references will be removed. +class_alias(sql_table::class, \table_sql::class); diff --git a/lib/tests/tablelib_test.php b/lib/table/tests/tablelib_test.php similarity index 99% rename from lib/tests/tablelib_test.php rename to lib/table/tests/tablelib_test.php index 1325a5dc5d2..922a341ec07 100644 --- a/lib/tests/tablelib_test.php +++ b/lib/table/tests/tablelib_test.php @@ -14,9 +14,8 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . -namespace core; +namespace core_table; -use flexible_table; use testable_flexible_table; defined('MOODLE_INTERNAL') || die(); @@ -28,7 +27,7 @@ require_once($CFG->libdir . '/tests/fixtures/testable_flexible_table.php'); /** * Test some of tablelib. * - * @package core + * @package core_table * @category test * @copyright 2013 Damyon Wiese * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later diff --git a/lib/tests/xhtml_container_stack_test.php b/lib/tests/output/xhtml_container_stack_test.php similarity index 95% rename from lib/tests/xhtml_container_stack_test.php rename to lib/tests/output/xhtml_container_stack_test.php index 4827ba34407..756674af763 100644 --- a/lib/tests/xhtml_container_stack_test.php +++ b/lib/tests/output/xhtml_container_stack_test.php @@ -14,14 +14,7 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . -namespace core; - -use xhtml_container_stack; - -defined('MOODLE_INTERNAL') || die(); - -global $CFG; -require_once($CFG->libdir . '/outputlib.php'); +namespace core\output; /** * Unit tests for the xhtml_container_stack class. @@ -32,8 +25,9 @@ require_once($CFG->libdir . '/outputlib.php'); * @category test * @copyright 2009 Tim Hunt * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * @covers \core\output\xhtml_container_stacks */ -class xhtml_container_stack_test extends \advanced_testcase { +final class xhtml_container_stack_test extends \advanced_testcase { public function test_push_then_pop(): void { // Set up. $stack = new xhtml_container_stack(); diff --git a/lib/tests/outputcomponents_test.php b/lib/tests/outputcomponents_test.php index 444351e9f79..15af70b24c9 100644 --- a/lib/tests/outputcomponents_test.php +++ b/lib/tests/outputcomponents_test.php @@ -25,7 +25,7 @@ use single_button; use single_select; use theme_config; use url_select; -use user_picture; +use core\output\user_picture; /** * Unit tests for lib/outputcomponents.php.