diff options
author | floam <floam@edf5b092-35ff-0310-97b2-ce42778d08ea> | 2006-03-04 21:54:02 +0000 |
---|---|---|
committer | floam <floam@edf5b092-35ff-0310-97b2-ce42778d08ea> | 2006-03-04 21:54:02 +0000 |
commit | 6aada11343cfef3db5a40f202e3ac96836e0e8d7 (patch) | |
tree | 74c9f168c0323fd770a42b84a76a8b157e9ea1ae /web/include/news.php | |
parent | a92b52b7ff3df60c0b6f118daf9338604a5f5889 (diff) | |
download | ioquake3-aero-6aada11343cfef3db5a40f202e3ac96836e0e8d7.tar.gz ioquake3-aero-6aada11343cfef3db5a40f202e3ac96836e0e8d7.zip |
It works!
git-svn-id: svn://svn.icculus.org/quake3/trunk@621 edf5b092-35ff-0310-97b2-ce42778d08ea
Diffstat (limited to 'web/include/news.php')
-rw-r--r-- | web/include/news.php | 46 |
1 files changed, 20 insertions, 26 deletions
diff --git a/web/include/news.php b/web/include/news.php index 92949b1..fe1a2c8 100644 --- a/web/include/news.php +++ b/web/include/news.php @@ -2,24 +2,25 @@ require("/webspace/icculus.org/news/IcculusNews.php"); $id = $_GET['id']; -if (empty($_GET['news_index'])) { $news_index = 0; } +if (empty($_GET['news_index'])) + $news_index = false; +else + $news_index = $_GET['news_index']; $news_queue = 2; -$news_item_count = 5; +$news_item_max = 5; if ($err = news_login($sock, 'localhost', 263, NULL, NULL, $news_queue)) $err = "Failed to log in: $err"; else { - if (isset($id)) - { - $digestarray[] = array( 'id' => $id ); - } - - else if ($err = news_digest($sock, $digestarray, false, $news_item_count)) + if ($err = news_digest($sock, $digestarray, $news_index, $news_item_max)) { $err = "Failed to get news digest: $err"; } - + + $current_post = 0; + $news_item_count = count($digestarray); + if (!isset($err)) { foreach($digestarray as $digestItem) @@ -29,24 +30,17 @@ else $err = "Failed to grab news item: $err"; break; } - echo "<h3>" . $item['title'] . "-" . $item['postdate'] . "</h3>\n<p>" . $item['text'] . "</p>"; - } - - $post_count = count($digestarray); - - if ($news_index != 0) - { - $ncount = ($news_index - $news_item_count); - if ($ncount == 0) { unset($ncount); } - echo "<a class=\"floater right\" href=\"?page=news&news_index=" . $ncount . "\">Newer→</a>"; + echo "<h3>" . $item['title'] . " - <em>" . date("F j, Y", strtotime($item['postdate'])) . "</em></h3>\n<p>" . $item['text'] . "</p>"; + if ($current_post++ == $news_item_count - 1) + $lastid = $digestItem['id']; + } } - if ($post_count == $news_item_count) { - $ncount = ($news_index + $news_item_count); - if ($ncount == 0) { unset($ncount); } - echo "<a class=\"floater left\" href=\"?page=news&news_index=" . $ncount . "\">←Older</a>"; -} - - } + echo "<p>"; + if ($news_item_count == $news_item_max) + echo "<a class=\"left\" href=\"?page=news&news_index=$lastid\">←Backpedal</a>"; + if ($news_index != false) + echo "<a class=\"right\" href=\"?page=news\">To Newest→</a>"; + echo "</p>"; } news_logout($sock); |