From 96b8bc5ff5882f33114137d6b07db32e17b8ad87 Mon Sep 17 00:00:00 2001 From: deva Date: Fri, 24 Oct 2008 10:20:04 +0000 Subject: Did a lot of work on the page and module systems. --- utils/news.php | 36 ++++++++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 10 deletions(-) (limited to 'utils/news.php') 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 "
\n"; - echo "
" . + $str = "
\n"; + $str .= "
" . htmlspecialchars_decode($this->title, ENT_QUOTES) . "
\n"; - echo "
" . date("D M jS Y G:i", $this->time) . "
\n"; - echo "
" . + $str .= "
" . date("D M jS Y G:i", $this->time) . "
\n"; + $str .= "
" . htmlspecialchars_decode($this->description, ENT_QUOTES) . "
\n"; - echo "
\n"; + $str .= "
\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(); } } -- cgit v1.2.3