From 3fec45442e19989aec1a28c7d5d90ec523933bd9 Mon Sep 17 00:00:00 2001 From: Thomas Nilsen Date: Sat, 24 Nov 2018 21:13:57 +0100 Subject: [PATCH] Added warning/success alert render function --- classes/constellation.php | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/classes/constellation.php b/classes/constellation.php index d977cf9..c4fc58e 100644 --- a/classes/constellation.php +++ b/classes/constellation.php @@ -156,6 +156,40 @@ class Constellation "incidents" => $array ]; } -} + + + function render_warning($header, $message, $show_link = false, $url = null, $link_text = null) + { + $this->render_alert('alert-warning', $header, $message, $show_link, $url, $link_text); + } + function render_success($header, $message, $show_link = false, $url = null, $link_text = null) + { + $this->render_alert('alert-success', $header, $message, $show_link, $url, $link_text); + } + + /** + * Renders an alert on screen with an optional button to return to a given URL + * @param string alert_type - Type of warning to render alert-danger, alert-warning, alert-success etc + * @param string header - Title of warning + * @param string message - Message to display + * @param boolean show_link - True if button is to be displayed + * @param string url - URL for button + * @param string link_txt - Text for button + * @return void + */ + function render_alert($alert_type, $header, $message, $show_link = false, $url = null, $link_text = null) + { + echo '

+
'; + if ( $show_link ) { + echo '
'.$link_text.'
'; + } + + } +} $constellation = new Constellation(); \ No newline at end of file