From e33d3df6290412c5ab3e6813d4b414d994bb98dc Mon Sep 17 00:00:00 2001 From: Hannes Magnusson Date: Tue, 18 Mar 2008 14:26:30 +0000 Subject: [PATCH] - Simplify the "news system" - Initial implementation of the hAtom microformat --- archive/2008.php | 7 +---- archive/2008.xml | 6 ++-- conferences/index.php | 2 +- include/layout.inc | 67 ++++++++++++++++++++++++++++++++++--------- index.php | 2 +- styles/site.css | 2 +- 6 files changed, 61 insertions(+), 25 deletions(-) diff --git a/archive/2008.php b/archive/2008.php index 01d1c6b58..9e5b4e4a5 100644 --- a/archive/2008.php +++ b/archive/2008.php @@ -16,13 +16,8 @@ site_header("News Archive - 2008");
strtotime($b["date"]) ? -1 : 1); -} -$news = array_merge($NEWS_ENTRIES["frontpage"], $NEWS_ENTRIES["conferences"]); -uasort($news, "date_sort"); -print_news($news, 2008); +print_news($NEWS_ENTRIES, array("conferences", "cfp", "frontpage"), 50); /* %s/\(.*\)<\/a>//g */ site_footer(); diff --git a/archive/2008.xml b/archive/2008.xml index 20781a42e..a3b95a8ca 100644 --- a/archive/2008.xml +++ b/archive/2008.xml @@ -21,7 +21,7 @@ 2008-05-24 phptek_2008.png -
+
php|tek 2008: Chicago

The publishers of php|architect Magazine are proud to announce the php|tek 2008 conference in Chicago, Illinois, USA. @@ -46,7 +46,7 @@ For the past two years, php|architect's spring conference has sold out weeks 2008-03-16 conference_php_quebec.gif -

+
2008 PHP Quebec Conference & Job Fair

The PHP Quebec team is pleased to present the sixth edition of the http://conf.phpquebec.com phplondon2008.png -

+

February 29th (Leap Year Day). phplondon.org announce their third annual community conference to be held at Inmarsat, Old Street, London.

diff --git a/conferences/index.php b/conferences/index.php index 0d9820161..848f71806 100644 --- a/conferences/index.php +++ b/conferences/index.php @@ -22,7 +22,7 @@ unset($RSIDEBAR_DATA); site_header("PHP Conferences around the world", array("layout_workaround" => $layout_workaround, 'headtags' => '')); -print_news($NEWS_ENTRIES["conferences"], false, true); +print_news($NEWS_ENTRIES, array("conferences", "cfp"), 10); site_footer( array("atom" => "/feed.atom") // Add a link to the feed diff --git a/include/layout.inc b/include/layout.inc index 87dfe71bd..7191a4a5f 100644 --- a/include/layout.inc +++ b/include/layout.inc @@ -375,9 +375,13 @@ function print_image($file, $alt = FALSE, $align = FALSE, $extras = FALSE, // Shortcut to usual news image printing (right floating // image from the news dir with an alt and an URL) -function news_image($URL, $image, $alt) +function news_image($URL, $image, $alt, $print = true) { - echo "" . make_image("news/$image", $alt, "right") . ""; + $str = "" . make_image("news/$image", $alt, "right") . ""; + if ($print) { + echo $str; + } + return $str; } // Return HTML code for a submit button image @@ -646,24 +650,60 @@ function news_archive_sidebar() } // Print news -function print_news($news, $year = false, $event = false) { +function print_news($news, $dog, $max = 5) { + $count = 0; foreach($news as $item) { - if ($year && $year != date("Y", strtotime($item["date"]))) { + $vevent = ""; + $ok = false; + + // Only print entries in the provided s/dog/cat/ egory + // If its a conference, use the hCalendar container + foreach($item["category"] as $category) { + if (in_array($category["term"], (array)$dog)) { + $ok = true; + ++$count; + } + if ($category["term"] === "conferences") { + $vevent = " vevent"; + } + } + if ($count > $max) { + break; + } + if ($ok === false) { continue; } + $image = ""; - if($item["image"]) { - $image = news_image($item["image"]["link"], $item["image"]["image"], $item["image"]["title"]); + if(isset($item["newsImage"])) { + $image = news_image($item["newsImage"]["link"], $item["newsImage"]["content"], $item["newsImage"]["title"], false); } - $vevent = ""; - if ($event) { - $vevent = " vevent"; + + //$id = parse_url($item["id"], PHP_URL_FRAGMENT); 5.1.2 + $id = parse_url($item["id"]); + $id = $id["fragment"]; + + // Find the permlink + foreach($item["link"] as $link) { + if ($link["rel"] === "via") { + $permlink = $link["href"]; + break; + } } + if (!isset($permlink)) { + $permlink = "#" .$id; + } + + $newsdate = date("d-M-Y", strtotime($item["updated"])); + echo <<< EOT -
- $image -

{$item["title"]}

- {$item["content"]} +
+
{$image}
+

{$item["title"]}

+
+ [{$newsdate}] + {$item["content"]} +

@@ -672,3 +712,4 @@ EOT; } } /* vim: set et ts=4 sw=4 ft=php: : */ + diff --git a/index.php b/index.php index 256418c21..ed42cc111 100644 --- a/index.php +++ b/index.php @@ -245,7 +245,7 @@ if (is_array($CONF_TEASER) && count($CONF_TEASER)) { /* Where the h*ll did all the news go? * See archives/2007.xml */ -print_news($NEWS_ENTRIES["frontpage"]); +print_news($NEWS_ENTRIES, "frontpage"); ?>

News Archive

diff --git a/styles/site.css b/styles/site.css index d24727500..c735306a5 100644 --- a/styles/site.css +++ b/styles/site.css @@ -162,7 +162,7 @@ hr { } div.newsItem .newsdate { float:left; - padding-right: 10px; + margin-right: 10px; } div.indent {