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/events.php | 45 +++++++++++++++++++++++++++++++++------------ 1 file changed, 33 insertions(+), 12 deletions(-) (limited to 'utils/events.php') diff --git a/utils/events.php b/utils/events.php index 27ec873..2257e33 100644 --- a/utils/events.php +++ b/utils/events.php @@ -10,16 +10,17 @@ class Event { public function show() { - echo "
\n"; - echo "
" . + $str = "
\n"; + $str .= "
" . htmlspecialchars_decode($this->title, ENT_QUOTES) . "
\n"; - echo "
" . date("D M jS Y", $this->time) . "
\n"; - echo "
" . + $str .= "
" . date("D M jS Y", $this->time) . "
\n"; + $str .= "
" . htmlspecialchars_decode($this->description, ENT_QUOTES) . "
\n"; if($this->flyer) { - echo " \"flyer\"flyer . "\"/>\n"; + $str .= " \"flyer\"flyer . "\"/>\n"; } - echo "
\n"; + $str .= "
\n"; + return $str; } public function Event($title, $time, $description, $flyer = "") @@ -36,8 +37,24 @@ class Events { private $file; private $events = array(); + public function run($module) + { + switch($module) { + case "events_coming": + return $this->showcoming(-1); + break; + + case "events_old": + default: + return $this->showold(-1); + break; + } + } + public function showcoming($number) { + $str = ""; + $foundany = false; // Key sort @@ -49,17 +66,20 @@ class Events { foreach($this->events as $event) { if($event->time >= time()) { $foundany = true; - $event->show(); + $str .= $event->show(); $number--; } - if(!$number) return; + if(!$number) return $str; } - if($foundany == false) echo "No shows available at the moment."; + if($foundany == false) return "No shows available at the moment."; + return $str; } public function showold($number) { + $str = ""; + // Key sort krsort($this->events); @@ -68,11 +88,12 @@ class Events { foreach($this->events as $event) { if($event->time <= time()) { - $event->show(); + $str .= $event->show(); $number--; } - if(!$number) return; + if(!$number) return $str; } + return $str; } public function add($event) { @@ -122,7 +143,7 @@ class Events { public function Events($file) { $this->file = $file; - $this->read(); + if(file_exists($file)) $this->read(); } } -- cgit v1.2.3