1
0
mirror of https://github.com/php/web-php.git synced 2026-03-23 23:02:13 +01:00

- Simplify the "news system"

- Initial implementation of the hAtom microformat
This commit is contained in:
Hannes Magnusson
2008-03-18 14:26:30 +00:00
parent d9c1e6c784
commit e33d3df629
6 changed files with 61 additions and 25 deletions

View File

@@ -16,13 +16,8 @@ site_header("News Archive - 2008");
<hr />
<?php
function date_sort($a, $b) {
return $a["date"] == $b["date"] ? 0 : (strtotime($a["date"]) > 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 href="\(.*\)"><img src="\/images\/news\/\(.*\)" alt="\(.*\)" width.*><\/a>/<?php news_image("\1", "\2", "\3"); ?>/g */
site_footer();

View File

@@ -21,7 +21,7 @@
<php:finalTeaserDate>2008-05-24</php:finalTeaserDate>
<php:newsImage link="http://tek.phparch.com/" title="php|tek 2008: Chicago">phptek_2008.png</php:newsImage>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml" class="description">
<div xmlns="http://www.w3.org/1999/xhtml">
<a href="http://tek.phparch.com/" class="url">php|tek 2008: Chicago</a>
<p>
The publishers of <a href="http://www.phparch.com/">php|architect Magazine</a> 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 <em>weeks
<php:finalTeaserDate>2008-03-16</php:finalTeaserDate>
<php:newsImage link="http://conf.phpquebec.com/en/conf2008/" title="PHP Québec conference 2008">conference_php_quebec.gif</php:newsImage>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml" class="description">
<div xmlns="http://www.w3.org/1999/xhtml">
<a href="http://conf.phpquebec.com/">2008 PHP Quebec Conference &amp; Job Fair</a>
<p>
The PHP Quebec team is pleased to present the sixth edition of the <a
@@ -78,7 +78,7 @@ visit the website: <a href="http://conf.phpquebec.com">http://conf.phpquebec.com
<php:newsImage xmlns="http://php.net/ns/news" link="http://www.phpconference.co.uk/" title="PHP London Conference 08">phplondon2008.png</php:newsImage>
<link href="http://www.phpconference.co.uk/" rel="via" type="text/html"/>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml" class="description">
<div xmlns="http://www.w3.org/1999/xhtml">
<p><abbr class="dtstart" title="2008-02-29">February 29th</abbr> (Leap Year Day). phplondon.org announce their third
annual <a href="http://www.phpconference.co.uk" alt="phplondon.org community conference" class="url">community conference</a>
to be held at Inmarsat, Old Street, London.</p>

View File

@@ -22,7 +22,7 @@ unset($RSIDEBAR_DATA);
site_header("PHP Conferences around the world", array("layout_workaround" => $layout_workaround, 'headtags' => '<link rel="alternate" type="application/atom+xml" title="PHP: Conference announcements" href="' . $MYSITE . 'feed.atom" />'));
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

View File

@@ -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 "<a href=\"$URL\">" . make_image("news/$image", $alt, "right") . "</a>";
$str = "<a href=\"$URL\">" . make_image("news/$image", $alt, "right") . "</a>";
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
<div class="newsItem$vevent">
$image
<a name="{$item["fragment"]}" id="{$item["fragment"]}"><h1 class="summary">{$item["title"]}</h1></a>
{$item["content"]}
<div class="newsItem hentry{$vevent}">
<div class="newsImage">{$image}</div>
<h1 class="summary entry-title"><a name="{$id}" id="{$id}" href="{$permlink}" rel="bookmark" class="bookmark">{$item["title"]}</a></h1>
<div class="entry-content description">
<abbr class="updated newsdate" title="{$item["updated"]}">[{$newsdate}]</abbr>
{$item["content"]}
</div>
</div>
<hr />
@@ -672,3 +712,4 @@ EOT;
}
}
/* vim: set et ts=4 sw=4 ft=php: : */

View File

@@ -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");
?>
<p class="center"><a href="/archive/index.php">News Archive</a></p>

View File

@@ -162,7 +162,7 @@ hr {
}
div.newsItem .newsdate {
float:left;
padding-right: 10px;
margin-right: 10px;
}
div.indent {