From 1c311cc4487a82278b382b84efa6daa86919347a Mon Sep 17 00:00:00 2001 From: Hannes Magnusson Date: Thu, 26 Dec 2013 15:16:51 -0800 Subject: [PATCH] Add a "headsup" bar when we add new news entries --- conferences/index.php | 1 + include/header.inc | 3 +++ include/layout.inc | 23 +++++++++++++++++++++++ index.php | 2 ++ styles/theme-medium.css | 14 ++++++++++++++ 5 files changed, 43 insertions(+) diff --git a/conferences/index.php b/conferences/index.php index afe354691..0fc5b8903 100644 --- a/conferences/index.php +++ b/conferences/index.php @@ -5,6 +5,7 @@ include_once $_SERVER['DOCUMENT_ROOT'] . '/include/prepend.inc'; include_once $_SERVER['DOCUMENT_ROOT'] . '/include/pregen-news.inc'; +mirror_setcookie("LAST_NEWS", $_SERVER["REQUEST_TIME"], 60*60*24*365); site_header("PHP Conferences around the world", array( 'headtags' => '', 'current' => 'community', diff --git a/include/header.inc b/include/header.inc index e8f45fbad..64546764d 100755 --- a/include/header.inc +++ b/include/header.inc @@ -94,6 +94,9 @@ if ($config["cache"]) {
+ +
+ diff --git a/include/layout.inc b/include/layout.inc index 812e21daf..1717d06b3 100644 --- a/include/layout.inc +++ b/include/layout.inc @@ -521,10 +521,14 @@ function site_header($title = '', $config = array()) 'classes' => '', 'layout_span' => 9, "cache" => false, + "headsup" => "", ); + $config = array_merge($defaults, $config); + + $config["headsup"] = get_news_changes(); $lang = language_convert($config["lang"]); $curr = $config["current"]; $classes = $config['classes']; @@ -546,6 +550,25 @@ function site_footer($config = array()) require dirname(__FILE__) . "/footer.inc"; } +function get_news_changes() +{ + include dirname(__FILE__) . "/pregen-news.inc"; + $date = date_create($NEWS_ENTRIES[0]["updated"]); + if (isset($_COOKIE["LAST_NEWS"]) && $_COOKIE["LAST_NEWS"] >= $date->getTimestamp()) { + return false; + } + if ($_SERVER["BASE_PAGE"] == "index.php") { + return false; + } + + $date->modify("+1 week"); + if ($date->getTimestamp() > $_SERVER["REQUEST_TIME"]) { + $link = substr($NEWS_ENTRIES[0]["link"][0]["href"], 14); // Strip http://php.net + $title = $NEWS_ENTRIES[0]["title"]; + return "{$title}"; + } +} + function news_toc($sections = null) { include dirname(__FILE__) . "/pregen-news.inc"; $items = array( diff --git a/index.php b/index.php index 966684522..fdf46ebea 100644 --- a/index.php +++ b/index.php @@ -39,6 +39,8 @@ include_once 'include/pregen-confs.inc'; include_once 'include/pregen-news.inc'; include_once 'include/version.inc'; +mirror_setcookie("LAST_NEWS", $_SERVER["REQUEST_TIME"], 60*60*24*365); + $content = "
"; $releasenews = 0; diff --git a/styles/theme-medium.css b/styles/theme-medium.css index 42d6db10d..76f7291dc 100755 --- a/styles/theme-medium.css +++ b/styles/theme-medium.css @@ -475,5 +475,19 @@ div.elephpants img:focus { position: relative; } +.headsup { + padding:.25em 0; + height:1.5em; + border-bottom:.125em solid #696; + background-color: #9c9; + color:#fff; +} + +.headsup, +.headsup a { + margin: 0 auto; + text-align: center; + color: #fff; +} // vim: set ts=2 sw=2 et: