flash_message(str) function and support in themes
This commit is contained in:
parent
a38aaba328
commit
37b3dd60b6
6 changed files with 53 additions and 0 deletions
|
@ -687,6 +687,19 @@ function set_prefixed_cookie($name, $value, $time, $path) {
|
||||||
setcookie($full_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.
|
* Figure out the path to the shimmie install directory.
|
||||||
*
|
*
|
||||||
|
|
|
@ -191,6 +191,13 @@ class Layout {
|
||||||
$withleft = "noleft";
|
$withleft = "noleft";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$flash = get_prefixed_cookie("flash_message");
|
||||||
|
$flash_html = "";
|
||||||
|
if($flash) {
|
||||||
|
$flash_html = "<b id='flash'>".nl2br(html_escape($flash))." <a href='#' onclick=\"\$('#flash').hide(); return false;\">[X]</a></b>";
|
||||||
|
set_prefixed_cookie("flash_message", "", -1, "/");
|
||||||
|
}
|
||||||
|
|
||||||
print <<<EOD
|
print <<<EOD
|
||||||
<!doctype html>
|
<!doctype html>
|
||||||
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7" lang="en"> <![endif]-->
|
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7" lang="en"> <![endif]-->
|
||||||
|
@ -217,6 +224,7 @@ $header_html
|
||||||
$sub_block_html
|
$sub_block_html
|
||||||
$left
|
$left
|
||||||
<article class="$withleft">
|
<article class="$withleft">
|
||||||
|
$flash_html
|
||||||
$main_block_html
|
$main_block_html
|
||||||
</article>
|
</article>
|
||||||
<footer><em>
|
<footer><em>
|
||||||
|
|
|
@ -49,6 +49,13 @@ class Layout {
|
||||||
$wrapper = ' style="height: 3em; overflow: auto;"';
|
$wrapper = ' style="height: 3em; overflow: auto;"';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$flash = get_prefixed_cookie("flash_message");
|
||||||
|
$flash_html = "";
|
||||||
|
if($flash) {
|
||||||
|
$flash_html = "<b id='flash'>".nl2br(html_escape($flash))." <a href='#' onclick=\"\$('#flash').hide(); return false;\">[X]</a></b>";
|
||||||
|
set_prefixed_cookie("flash_message", "", -1, "/");
|
||||||
|
}
|
||||||
|
|
||||||
print <<<EOD
|
print <<<EOD
|
||||||
<!doctype html>
|
<!doctype html>
|
||||||
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7" lang="en"> <![endif]-->
|
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7" lang="en"> <![endif]-->
|
||||||
|
@ -69,6 +76,7 @@ $header_html
|
||||||
$left_block_html
|
$left_block_html
|
||||||
</nav>
|
</nav>
|
||||||
<article>
|
<article>
|
||||||
|
$flash_html
|
||||||
$main_block_html
|
$main_block_html
|
||||||
</article>
|
</article>
|
||||||
<footer>
|
<footer>
|
||||||
|
|
|
@ -55,6 +55,13 @@ class Layout {
|
||||||
$withleft = "";
|
$withleft = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$flash = get_prefixed_cookie("flash_message");
|
||||||
|
$flash_html = "";
|
||||||
|
if($flash) {
|
||||||
|
$flash_html = "<b id='flash'>".nl2br(html_escape($flash))." <a href='#' onclick=\"\$('#flash').hide(); return false;\">[X]</a></b>";
|
||||||
|
set_prefixed_cookie("flash_message", "", -1, "/");
|
||||||
|
}
|
||||||
|
|
||||||
print <<<EOD
|
print <<<EOD
|
||||||
<!doctype html>
|
<!doctype html>
|
||||||
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7" lang="en"> <![endif]-->
|
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7" lang="en"> <![endif]-->
|
||||||
|
@ -75,6 +82,7 @@ $header_html
|
||||||
</header>
|
</header>
|
||||||
$left
|
$left
|
||||||
<article class="$withleft">
|
<article class="$withleft">
|
||||||
|
$flash_html
|
||||||
$main_block_html
|
$main_block_html
|
||||||
</article>
|
</article>
|
||||||
<footer>
|
<footer>
|
||||||
|
|
|
@ -159,6 +159,13 @@ class Layout {
|
||||||
$main_block_html = "<article>$main_block_html</article>";
|
$main_block_html = "<article>$main_block_html</article>";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$flash = get_prefixed_cookie("flash_message");
|
||||||
|
$flash_html = "";
|
||||||
|
if($flash) {
|
||||||
|
$flash_html = "<b id='flash'>".nl2br(html_escape($flash))." <a href='#' onclick=\"\$('#flash').hide(); return false;\">[X]</a></b>";
|
||||||
|
set_prefixed_cookie("flash_message", "", -1, "/");
|
||||||
|
}
|
||||||
|
|
||||||
print <<<EOD
|
print <<<EOD
|
||||||
<!doctype html>
|
<!doctype html>
|
||||||
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7" lang="en"> <![endif]-->
|
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7" lang="en"> <![endif]-->
|
||||||
|
@ -177,6 +184,7 @@ class Layout {
|
||||||
$sub_block_html
|
$sub_block_html
|
||||||
</header>
|
</header>
|
||||||
$left_block_html
|
$left_block_html
|
||||||
|
$flash_html
|
||||||
$main_block_html
|
$main_block_html
|
||||||
<footer>
|
<footer>
|
||||||
Images © their respective owners,
|
Images © their respective owners,
|
||||||
|
|
|
@ -55,6 +55,13 @@ class Layout {
|
||||||
$wrapper = ' style="height: 3em; overflow: auto;"';
|
$wrapper = ' style="height: 3em; overflow: auto;"';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$flash = get_prefixed_cookie("flash_message");
|
||||||
|
$flash_html = "";
|
||||||
|
if($flash) {
|
||||||
|
$flash_html = "<b id='flash'>".nl2br(html_escape($flash))." <a href='#' onclick=\"\$('#flash').hide(); return false;\">[X]</a></b>";
|
||||||
|
set_prefixed_cookie("flash_message", "", -1, "/");
|
||||||
|
}
|
||||||
|
|
||||||
print <<<EOD
|
print <<<EOD
|
||||||
<!doctype html>
|
<!doctype html>
|
||||||
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7" lang="en"> <![endif]-->
|
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7" lang="en"> <![endif]-->
|
||||||
|
@ -83,6 +90,7 @@ $header_html
|
||||||
$left_block_html
|
$left_block_html
|
||||||
</nav>
|
</nav>
|
||||||
<article>
|
<article>
|
||||||
|
$flash_html
|
||||||
$main_block_html
|
$main_block_html
|
||||||
</article>
|
</article>
|
||||||
<footer>
|
<footer>
|
||||||
|
|
Reference in a new issue