From 09d5cfadc5c120ce523ea06751baca05bf9e3012 Mon Sep 17 00:00:00 2001 From: Sam Hemelryk Date: Fri, 11 Apr 2014 10:20:09 +1200 Subject: [PATCH] MDL-44729 theme_bootstrapbase: override the maintenance renderer This patch overrides the maintenance renderer in the bootstrapbase theme in order to override the notification method in the same way we override the core renderer notification method. This ensures now that clean is standard that notifications during maintenance tasks (install, upgrade etc) look pretty. --- .../bootstrapbase/renderers/core_renderer.php | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/theme/bootstrapbase/renderers/core_renderer.php b/theme/bootstrapbase/renderers/core_renderer.php index 7f0663dfd68..318f3849442 100644 --- a/theme/bootstrapbase/renderers/core_renderer.php +++ b/theme/bootstrapbase/renderers/core_renderer.php @@ -221,3 +221,48 @@ class theme_bootstrapbase_core_renderer extends core_renderer { } } } + +/** + * Overridden core maintenance renderer. + * + * This renderer gets used instead of the standard core_renderer during maintenance + * tasks such as installation and upgrade. + * We override it in order to style those scenarios consistently with the regular + * bootstrap look and feel. + * + * @package theme_bootstrapbase + * @copyright 2014 Sam Hemelryk + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +class theme_bootstrapbase_core_renderer_maintenance extends core_renderer_maintenance { + /** + * Renders notifications for maintenance scripts. + * + * We need to override this method in the same way we do for the core_renderer maintenance method + * found above. + * Please note this isn't required of every function, only functions used during maintenance. + * In this case notification is used to print errors and we want pretty errors. + * + * @param string $message + * @param string $classes + * @return string + */ + public function notification($message, $classes = 'notifyproblem') { + $message = clean_text($message); + $type = ''; + + if (($classes == 'notifyproblem') || ($classes == 'notifytiny')) { + $type = 'alert alert-error'; + } + if ($classes == 'notifysuccess') { + $type = 'alert alert-success'; + } + if ($classes == 'notifymessage') { + $type = 'alert alert-info'; + } + if ($classes == 'redirectmessage') { + $type = 'alert alert-block alert-info'; + } + return "
$message
"; + } +}