From 37b3dd60b69c86709e33992cf49aafba7749d680 Mon Sep 17 00:00:00 2001 From: Shish Date: Sat, 9 Jun 2012 17:00:25 +0100 Subject: [PATCH] flash_message(str) function and support in themes --- core/util.inc.php | 13 +++++++++++++ themes/danbooru/layout.class.php | 8 ++++++++ themes/default/layout.class.php | 8 ++++++++ themes/futaba/layout.class.php | 8 ++++++++ themes/lite/layout.class.php | 8 ++++++++ themes/warm/layout.class.php | 8 ++++++++ 6 files changed, 53 insertions(+) diff --git a/core/util.inc.php b/core/util.inc.php index 4bf59033..7168d610 100644 --- a/core/util.inc.php +++ b/core/util.inc.php @@ -687,6 +687,19 @@ function set_prefixed_cookie($name, $value, $time, $path) { setcookie($full_name, $value, $time, $path); } +/** + * Set (or extend) a flash-message cookie + */ +function flash_message(/*string*/ $text) { + $current = get_prefixed_cookie("flash_message"); + if($current) { + $text = $current . "\n" . $text; + } + # the message should be viewed pretty much immediately, + # so 60s timeout should be more than enough + set_prefixed_cookie("flash_message", $text, time()+60, "/"); +} + /** * Figure out the path to the shimmie install directory. * diff --git a/themes/danbooru/layout.class.php b/themes/danbooru/layout.class.php index bf9763f2..ee760130 100644 --- a/themes/danbooru/layout.class.php +++ b/themes/danbooru/layout.class.php @@ -191,6 +191,13 @@ class Layout { $withleft = "noleft"; } + $flash = get_prefixed_cookie("flash_message"); + $flash_html = ""; + if($flash) { + $flash_html = "".nl2br(html_escape($flash))." [X]"; + set_prefixed_cookie("flash_message", "", -1, "/"); + } + print << @@ -217,6 +224,7 @@ $header_html $sub_block_html $left
+ $flash_html $main_block_html