com web/php: Add a "headsup" bar when we add new news entries: conferences/index.php include/header.inc include/layout.inc index.php
styles/theme-medium.css
| From: | Hannes Magnusson | Date: | Thu, 26 Dec 2013 23:16:51 +0000 |
| Subject: | com web/php: Add a "headsup" bar when we add new news entries: conferences/index.php include/header.inc include/layout.inc index.php styles/theme-medium.css |
||
| Groups: | php.webmaster | ||
| Request: | Send a blank email to php-webmaster+get-17792@lists.php.net to get a copy of this message | ||
Commit: 1c311cc4487a82278b382b84efa6daa86919347a
Author: Hannes Magnusson <bjori@mongodb.com> Thu, 26 Dec 2013 15:16:51 -0800
Parents: c1ac5f072244091f55022a80dc62d49e6fecff04
Branches: master
Link: http://git.php.net/?p=web/php.git;a=commitdiff;h=1c311cc4487a82278b382b84efa6daa86919347a
Log:
Add a "headsup" bar when we add new news entries
Changed paths:
M conferences/index.php
M include/header.inc
M include/layout.inc
M index.php
M styles/theme-medium.css
Diff:
diff --git a/conferences/index.php b/conferences/index.php
index afe3546..0fc5b89 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' => '<link rel="alternate"
type="application/atom+xml" title="PHP: Conference announcements"
href="' . $MYSITE . 'feed.atom" />',
'current' => 'community',
diff --git a/include/header.inc b/include/header.inc
index e8f45fb..6454676 100755
--- a/include/header.inc
+++ b/include/header.inc
@@ -94,6 +94,9 @@ if ($config["cache"]) {
</div>
<div id="flash-message"></div>
</nav>
+<?php if (!empty($config["headsup"])): ?>
+<div class="headsup"><?php echo $config["headsup"]?></div>
+<?php endif ?>
<nav id="trick"><div><?php doc_toc("en")
?></div></nav>
<?php if (!empty($config['breadcrumbs'])): ?>
diff --git a/include/layout.inc b/include/layout.inc
index 812e21d..1717d06 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 "<a href='{$link}'>{$title}</a>";
+ }
+}
+
function news_toc($sections = null) {
include dirname(__FILE__) . "/pregen-news.inc";
$items = array(
diff --git a/index.php b/index.php
index 9666845..fdf46eb 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 = "<div class='home-content'>";
$releasenews = 0;
diff --git a/styles/theme-medium.css b/styles/theme-medium.css
index 42d6db1..76f7291 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: