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) {
$str .= "
". $this->description .
"
\n";
} else {
$str .= "
" .
$this->description . "
\n";
}
$str .= "
By: ".$user->name . "
\n";
$datestr = "";
if(isset($GLOBALS['date'])) $datestr = "&date=". $GLOBALS['date'];
$str .= "
eid . "&action=delete\">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, $concert, $starttime, $duration,
$description, $user)
{
$this->eid = $eid;
$this->title = $title;
$this->starttime = $starttime;
$this->duration = $duration;
$this->description = $description;
$this->user = $user;
$this->concert = $concert;
}
}
class Events {
private $file;
public $events = array();
public function add($event) {
$key = $event->eid;
$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");
$block = TRUE;
flock($fp, LOCK_EX, $block); // do an exclusive lock
fwrite($fp, "\n");
fwrite($fp, "\n");
foreach($this->events as $event) {
fwrite($fp, " 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=\"" .
htmlspecialchars($event->duration, ENT_QUOTES, "UTF-8") . "\"\n");
fwrite($fp, " description=\"" .
htmlspecialchars($event->description, ENT_QUOTES, "UTF-8") . "\"\n");
fwrite($fp, " user=\"" .
htmlspecialchars($event->user, ENT_QUOTES, "UTF-8") . "\">\n");
fwrite($fp, " \n");
}
fwrite($fp, "\n");
fclose($fp);
}
/*
public function deleteForumUser($id)
{
if($this->members[$id]) {
unset($this->members[$id]);
// $this->write();
} else {
$str .= "ERROR: User! ".$id." does not exist!
\n";
return false;
}
return true;
}
*/
public function show($starttime, $endtime)
{
$str = "";
foreach($this->events as $event) {
if($event->starttime > $starttime && $event->starttime < $endtime)
$str .= $event->show();
}
return $str;
}
public function getEvent($eid)
{
$event = $this->events[$eid];
return $event;
}
private function read()
{
$dom = new DomDocument;
$dom->preserveWhiteSpace = FALSE;
$dom->load($this->file);
$events = $dom->getElementsByTagName('event');
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'),
$e->getAttribute('user'));
$this->add($event);
}
}
public function Events($file)
{
$this->file = $file;
if(file_exists($file)) $this->read();
}
}
?>