summaryrefslogtreecommitdiff
path: root/utils/modules/events.php
diff options
context:
space:
mode:
Diffstat (limited to 'utils/modules/events.php')
-rw-r--r--utils/modules/events.php53
1 files changed, 39 insertions, 14 deletions
diff --git a/utils/modules/events.php b/utils/modules/events.php
index be11dcf..3bccce6 100644
--- a/utils/modules/events.php
+++ b/utils/modules/events.php
@@ -21,23 +21,22 @@ class Event {
fwrite($fp, "</event>\n");
}
- public function show()
+ public function show($eventpage)
{
- global $ICONS_DIR, $EVENT_PAGE;
- $icons = new Icons($ICONS_DIR."/");
- $icon = $icons->icons[$this->flyer];
-
$content = Markdown(htmlspecialchars_decode($this->description));
$str = "<div class=\"event\">\n";
$str .= " <div class=\"event_time\">" . date("D M jS Y", $this->time) . "</div>\n";
$str .= " <div class=\"event_title\">\n";
- $str .= " <a href=\"?page=".$EVENT_PAGE."&amp;eventid=".$this->time."\">".
+ $str .= " <a href=\"?page=".$eventpage."&amp;eventid=".$this->time."\">".
htmlspecialchars_decode($this->title, ENT_QUOTES) . "</a>\n";
$str .= "</div>\n";
$str .= " <div class=\"event_description\">" . $content . "</div>\n";
/*
if($this->flyer) {
+ global $ICONS_DIR;
+ $icons = new Icons($ICONS_DIR."/");
+ $icon = $icons->icons[$this->flyer];
$str .= " <img class=\"event_flyer\" alt=\"flyer\" src=\"".$icon->prefix.$icon->file."\"/>\n";
}
*/
@@ -58,12 +57,32 @@ class Events {
private $file;
private $events = array();
+ public $eventpage;
// Admin config
public $admin_title = "Events";
public $admin_submodules = array("Add Event" => "add",
"Edit Event" => "edit",
- "Delete Event" => "delete");
+ "Delete Event" => "delete",
+ "Config" => "config");
+
+ public function admin_config($action, $vars)
+ {
+ switch($action) {
+ case "update":
+ $this->eventpage = $vars["eventpage"];
+ // echo "The title has now been changed to \"". $this->value("title") . "\"";
+ $this->write();
+ break;
+
+ default:
+ $form = new Form("update");
+ $form->addWidget(new LineEdit("Event page:", "eventpage", $this->eventpage));
+ $form->addWidget(new Button("Update"));
+ $form->render();
+ break;
+ }
+ }
public function admin_add($action, $vars)
{
@@ -83,7 +102,7 @@ class Events {
$vars["description"], $vars["icon"]);
echo "<div class=\"preview\">\n";
echo "<div class=\"content\">\n";
- echo $event->show();
+ echo $event->show($this->eventpage);
echo "</div>\n";
echo "</div>\n";
echo "<p>Looking ok?</p>";
@@ -134,7 +153,7 @@ class Events {
$vars["description"], $vars["icon"]);
echo "<div class=\"preview\">\n";
echo "<div class=\"content\">\n";
- echo $event->show();
+ echo $event->show($this->eventpage);
echo "</div>\n";
echo "</div>\n";
echo "<p>Looking ok?</p>";
@@ -227,6 +246,9 @@ class Events {
public function admin($sub, $action, $vars)
{
switch($sub) {
+ case "config":
+ $this->admin_config($action, $vars);
+ break;
case "add":
$this->admin_add($action, $vars);
break;
@@ -269,7 +291,7 @@ class Events {
if($single == true) {
if($eventid && $this->events[$eventid]) {
- $str .= $this->events[$eventid]->show();
+ $str .= $this->events[$eventid]->show($this->eventpage);
} else {
$str .= "<strong>No such show!</strong>\n";
}
@@ -308,7 +330,7 @@ class Events {
foreach($this->events as $event) {
$foundany = true;
- $str .= $event->show();
+ $str .= $event->show($this->eventpage);
$number--;
if(!$number) return $str;
}
@@ -332,7 +354,7 @@ class Events {
foreach($this->events as $event) {
if($event->time >= time()) {
$foundany = true;
- $str .= $event->show();
+ $str .= $event->show($this->eventpage);
$number--;
}
if(!$number) return $str;
@@ -354,7 +376,7 @@ class Events {
foreach($this->events as $event) {
if($event->time <= time()) {
- $str .= $event->show();
+ $str .= $event->show($this->eventpage);
$number--;
}
if(!$number) return $str;
@@ -373,7 +395,7 @@ class Events {
$fp = fopen($this->file, "w");
fwrite($fp, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
- fwrite($fp, "<events>\n");
+ fwrite($fp, "<events eventpage=\"".xmlenc($this->eventpage)."\">\n");
foreach($this->events as $event) {
$event->write($fp);
}
@@ -389,6 +411,9 @@ class Events {
$dom->load($this->file);
$params = $dom->getElementsByTagName('event');
+ $events = $dom->documentElement;
+ $this->eventpage = $events->getAttribute('eventpage');
+
foreach ($params as $param) {
$event = new Event($param->getAttribute('title'),
$param->getAttribute('time'),