diff options
author | deva <deva> | 2008-10-24 10:20:04 +0000 |
---|---|---|
committer | deva <deva> | 2008-10-24 10:20:04 +0000 |
commit | 96b8bc5ff5882f33114137d6b07db32e17b8ad87 (patch) | |
tree | 24ee6be2390627fc005b0e2ec12829c0fc5aef47 /utils/news.php | |
parent | 9bca27c9342bd4f34bed77dd3eb8c51dd686cdf1 (diff) |
Did a lot of work on the page and module systems.
Diffstat (limited to 'utils/news.php')
-rw-r--r-- | utils/news.php | 36 |
1 files changed, 26 insertions, 10 deletions
diff --git a/utils/news.php b/utils/news.php index 809e8dc..0493804 100644 --- a/utils/news.php +++ b/utils/news.php @@ -10,13 +10,14 @@ class NewsEntry { public function show() { - echo "<div class=\"news_entry\">\n"; - echo " <div class=\"news_title\">" . + $str = "<div class=\"news_entry\">\n"; + $str .= " <div class=\"news_title\">" . htmlspecialchars_decode($this->title, ENT_QUOTES) . "</div>\n"; - echo " <div class=\"news_time\">" . date("D M jS Y G:i", $this->time) . "</div>\n"; - echo " <div class=\"news_description\">" . + $str .= " <div class=\"news_time\">" . date("D M jS Y G:i", $this->time) . "</div>\n"; + $str .= " <div class=\"news_description\">" . htmlspecialchars_decode($this->description, ENT_QUOTES) . "</div>\n"; - echo "</div>\n"; + $str .= "</div>\n"; + return $str; } public function NewsEntry($title, $time, $category, $description) @@ -33,18 +34,34 @@ class News { private $file; private $news = array(); + public function run($module) + { + global $show; + + switch($module) { + case "news": + default: + if($show == "all") return $this->show(-1, "all"); + else return $this->show(-1, "main"); + break; + } + } + public function show($number, $category) { + $str = ""; + // If number is -1 show all shows. if($number == -1) $number = 100000; - + foreach($this->news as $newsentry) { if($newsentry->category == $category || $category == "all") { - $newsentry->show(); + $str .= $newsentry->show(); $number--; } - if(!$number) return; + if(!$number) return $str; } + return $str; } public function add($newsentry) { @@ -74,7 +91,6 @@ class News { private function read() { - $dom = new DomDocument; $dom->preserveWhiteSpace = FALSE; $dom->load($this->file); @@ -95,7 +111,7 @@ class News { public function News($file) { $this->file = $file; - $this->read(); + if(file_exists($file)) $this->read(); } } |