From 42c62cb041a2b2b95c9cda0c20fcf70334fd244c Mon Sep 17 00:00:00 2001 From: deva Date: Tue, 1 Nov 2011 09:32:21 +0000 Subject: Rewl og krat... needs cleaning up - after port to GIT. --- forum/utils/events.php | 79 ++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 63 insertions(+), 16 deletions(-) (limited to 'forum/utils/events.php') diff --git a/forum/utils/events.php b/forum/utils/events.php index 9f521b8..2f46f14 100644 --- a/forum/utils/events.php +++ b/forum/utils/events.php @@ -8,31 +8,62 @@ class Event { public $starttime; public $duration; public $description; + public $concert; public $user; public function show() { - global $users, $date, $client_is_mobile_device; + global $users, $GLOBALS, $client_is_mobile_device; - $user = $users->getUser($this->user); + $str = ""; - echo "
\n"; - echo "
". $this->title . "\n"; - // echo " Edit\n"; - echo "
\n"; - echo "
" . date("G:i", $this->starttime) . " - " . - date("G:i", $this->starttime + $this->duration) . "
\n"; + $user = $users->getUser($this->user); + $str .= "
concert == "true") $str .= " concert"; + $str .= "\">\n"; + $str .= "
". $this->title . "\n"; + // $str .= " Edit\n"; + $str .= "
\n"; + $str .= "
" . date("G:i", $this->starttime) . + " - " . date("G:i", $this->starttime + $this->duration) . "
\n"; if(!$client_is_mobile_device) { - echo "
". $this->description . "
\n"; + $str .= "
". $this->description . + "
\n"; } else { - echo "
". $this->description . "
\n"; + $str .= "
" . + $this->description . "
\n"; } - echo "
By: ".$user->name . "
\n"; - // echo " Edit"; - echo "
\n"; + $str .= "
By: ".$user->name . "
\n"; + + $datestr = ""; + if(isset($GLOBALS['date'])) $datestr = "&date=". $GLOBALS['date']; + + $str .= " Delete"; + $str .= "
\n"; + + return $str; + } + + public function show_simple() + { + global $users, $GLOBALS, $client_is_mobile_device; + + $str = ""; + + $str .= "
\n"; + $str .= " " . date("D d M Y", $this->starttime) . "\n"; + $str .= " ". $this->title . "\n"; + $str .= " \n"; + $str .= " " . date("G:i", $this->starttime) . + " - " . date("G:i", $this->starttime + $this->duration) . "\n"; + $str .= "
\n"; + + return $str; } - public function Event($eid, $title, $starttime, $duration, $description, $user) + public function Event($eid, $title, $concert, $starttime, $duration, + $description, $user) { $this->eid = $eid; $this->title = $title; @@ -40,6 +71,7 @@ class Event { $this->duration = $duration; $this->description = $description; $this->user = $user; + $this->concert = $concert; } } @@ -53,6 +85,13 @@ class Events { $this->events[$key] = $event; } + public function delete($eid) { + if(isset($this->events[$eid])) { + unset($this->events[$eid]); + echo "DELETE"; + } + } + public function write() { $fp = fopen($this->file, "w"); @@ -68,6 +107,11 @@ class Events { htmlspecialchars($event->eid, ENT_QUOTES, "UTF-8") . "\"\n"); fwrite($fp, " title=\"" . htmlspecialchars($event->title, ENT_QUOTES, "UTF-8") . "\"\n"); + + if($event->concert == "true") $concert = "true"; + else $concert = "false"; + fwrite($fp, " concert=\"" . $concert . "\"\n"); + fwrite($fp, " starttime=\"" . htmlspecialchars($event->starttime, ENT_QUOTES, "UTF-8") . "\"\n"); fwrite($fp, " duration=\"" . @@ -90,7 +134,7 @@ class Events { unset($this->members[$id]); // $this->write(); } else { - echo "

ERROR: User! ".$id." does not exist!

\n"; + $str .= "

ERROR: User! ".$id." does not exist!

\n"; return false; } return true; @@ -99,10 +143,12 @@ class Events { public function show($starttime, $endtime) { + $str = ""; foreach($this->events as $event) { if($event->starttime > $starttime && $event->starttime < $endtime) - $event->show(); + $str .= $event->show(); } + return $str; } public function getEvent($eid) @@ -121,6 +167,7 @@ class Events { foreach ($events as $e) { $event = new Event($e->getAttribute('eid'), $e->getAttribute('title'), + $e->getAttribute('concert') == "true", $e->getAttribute('starttime'), $e->getAttribute('duration'), $e->getAttribute('description'), -- cgit v1.2.3