summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--htdocs/admin.css124
-rw-r--r--htdocs/index.php30
-rw-r--r--pages/admin.php89
-rw-r--r--utils/forms.php119
-rw-r--r--utils/login.php5
-rw-r--r--utils/modules.php20
-rw-r--r--utils/modules/events.php296
-rw-r--r--utils/modules/news.php255
8 files changed, 633 insertions, 305 deletions
diff --git a/htdocs/admin.css b/htdocs/admin.css
new file mode 100644
index 0000000..86d0d49
--- /dev/null
+++ b/htdocs/admin.css
@@ -0,0 +1,124 @@
+/*** Admin ***/
+
+.admin {
+ text-align: center;
+ position: absolute;
+ top: 10%;
+ left: 10%;
+ right: 10%;
+ width: 80%;
+ height: 500px;
+ border: solid #0000ff 3px;
+ background: url(gfx/transparent.png) repeat;
+ color: #000;
+}
+
+.admin .menu {
+ background-image: none;
+ border-bottom: solid blue 1px;
+ width: 100%;
+ height: 30px;
+ padding-top: 0px;
+ padding-left: 0px;
+}
+
+.admin .submenu {
+ border-bottom: solid blue 1px;
+}
+
+.admin .header {
+ background-image: none;
+ text-align: center;
+ font-size: 16px;
+ font-weight: bold;
+ border: 0px;
+ border-bottom: solid #0000ff 3px;
+}
+
+.admin .logout {
+ text-align: right;
+}
+
+.admin .preview {
+ text-align: left;
+ border: solid green 1px;
+ padding: 20px 20px 20px 20px;
+ margin: 20px 60px 20px 60px;
+}
+
+.IGNOREadmin h2 {
+ text-align: center;
+}
+
+.IGNOREadmin_menu {
+ margin-top: 4px;
+ border-top: solid #930104 1px;
+ border-left: solid #930104 1px;
+ border-right: solid #930104 1px;
+ padding-right: 2px;
+ float: left;
+}
+
+.IGNOREadmin_menu_entry {
+ text-align: center;
+ background: url(gfx/chicken.jpg) repeat;
+ border: solid #930104 1px;
+ color: #cc7f00;
+ padding: 1px;
+ margin: 3px 0px 3px 3px;
+ width: 67px;
+ float: left;
+ text-decoration: none;
+}
+
+.IGNOREadmin_menu_entry_active {
+ text-align: center;
+ background: url(gfx/chicken.jpg) repeat;
+ border-top: solid #930104 1px;
+ border-left: solid #930104 1px;
+ border-right: solid #930104 1px;
+ color: #ffaf00;
+ font-weight: bold;
+ padding: 2px 2px 6px 2px;
+ margin: 1px -1px 0px 2px;
+ width: 67px;
+ float: left;
+ text-decoration: none;
+}
+
+.IGNOREadmin_form {
+ padding: 4px;
+ border: solid #930104 1px;
+ min-height: 300px;
+ clear:both;
+}
+
+.IGNOREadmin_form input {
+ margin: 1px;
+ padding: 0px;
+ background: #000;
+ border: solid #930104 1px;
+ color: #6f6f6f;
+ width: 150px;
+}
+
+.IGNOREadmin_form select {
+ background: #000;
+ border: solid #930104 1px;
+ color: #6f6f6f;
+ width: 150px;
+}
+
+.IGNOREadmin_form textarea {
+ background: #000;
+ border: solid #930104 1px;
+ color: #6f6f6f;
+ width: 500px;
+ margin-bottom: 4px;
+}
+
+.IGNOREadmin_form button {
+ background: url(gfx/chicken.jpg) repeat;
+ border: solid #930104 1px;
+ color: #ff9f00;
+}
diff --git a/htdocs/index.php b/htdocs/index.php
index f374113..6ce08d8 100644
--- a/htdocs/index.php
+++ b/htdocs/index.php
@@ -6,6 +6,10 @@ header("Content-Type: text/html; charset=UTF-8");
include_once($UTIL_DIR . "/login.php");
if($page == "admin") checklogin();
+
+include_once($UTIL_DIR . "/pages.php");
+
+$pages = new Pages($DATA_DIR . "/pages.xml");
?>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
@@ -20,7 +24,8 @@ if($page == "admin") checklogin();
<link href="/favicon.ico" rel="shortcut icon"/>
<link rel="stylesheet" type="text/css" href="style.css" media="screen"/>
<link rel="stylesheet" type="text/css" href="handheld.css" media="handheld"/>
-<script type="text/javascript" src="external.js">js"></script>
+<link rel="stylesheet" type="text/css" href="admin.css" media="screen"/>
+<script type="text/javascript" src="external.js"></script>
</head>
<body>
<div style="display: none;">
@@ -79,6 +84,15 @@ if($page == "admin") checklogin();
<?php
include_once("config.php");
+if($page == "admin") {
+ include($PAGE_DIR."/admin.php");
+} else {
+ if($page) $p = $pages->getPage($page);
+ else $p = $pages->getPage($DEFAULT_PAGE);
+ if($p) $p->show();
+}
+
+/*
switch($page) {
case "news": include($PAGE_DIR."/news.php"); break;
case "shop": include($PAGE_DIR."/shop.php"); break;
@@ -104,23 +118,23 @@ case "cancel": include($PAGE_DIR."/cancel.php"); break;
// Default
default: include($PAGE_DIR."/news.php"); break;
}
+*/
?>
</div>
<div class="column" <?php if(strstr($_SERVER['HTTP_USER_AGENT'], "MSIE 6.0"))
echo "style=\"width: 249px;\"";
?>>
<?php
- include $PAGE_DIR."/column.php"
+$p = $pages->getPage("column");
+if($p) $p->show();
?>
</div>
</div>
<div class="footer">
- Hosted by <a href="http://www.aasimon.org">Aasimon.org</a>.
- Design and DIE logo by <a href="mailto:elsenator@gmail.com">Lars Bisballe Jensen</a>.
- Artwork by <a href="http://tonysandoval.deviantart.com">Tony Sandoval</a>.
- Copyright&copy;2007 <a href="http://www.executionroom.com">DIE</a>.
- This site is valid <a href="http://validator.w3.org/check?uri=referer">XHTML1.1</a>
- and <a href="http://jigsaw.w3.org/css-validator/check/referer">CSS2.0</a>
+<?php
+$p = $pages->getPage("footer");
+if($p) $p->show();
+?>
</div>
</div>
<?php if(strstr($_SERVER['HTTP_USER_AGENT'], "MSIE 6.0")) echo "</td></tr></table></center>"; ?>
diff --git a/pages/admin.php b/pages/admin.php
index 5305ae2..3f924c7 100644
--- a/pages/admin.php
+++ b/pages/admin.php
@@ -1,3 +1,5 @@
+<div class="admin">
+ <div class="header">Admin</div>
<?php
if($loggedin == true) {
?>
@@ -7,66 +9,44 @@ if($loggedin == true) {
else $UID = $HTTP_COOKIE_VARS["UserID"];
$user = $users->findUser($UID);
?>
-<div class="header">
- <div class="header_admin">
- <div class="header_text">Admin</div>
- </div>
-</div>
<div class="logout">
<a href="?page=admin&amp;action=logout">Logout <em><?php echo $UID;?></em></a>
</div>
-<div class="admin_menu">
-<?php if($user->events == "on") {?>
- <a class="admin_menu_entry<?php if($module == "events") echo "_active" ?>"
- href="?page=admin&amp;module=events">Events</a>
-<?php }?>
-<?php if($user->news == "on") {?>
- <a class="admin_menu_entry<?php if($module == "news") echo "_active" ?>"
- href="?page=admin&amp;module=news">News</a>
-<?php }?>
-<?php if($user->gallery == "on") {?>
- <a class="admin_menu_entry<?php if($module == "gallery") echo "_active" ?>"
- href="?page=admin&amp;module=gallery">Gallery</a>
-<?php }?>
-<?php if($user->guestbook == "on") {?>
- <a class="admin_menu_entry<?php if($module == "guestbook") echo "_active" ?>"
- href="?page=admin&amp;module=guestbook">Guestbook</a>
-<?php }?>
-<?php if($user->newsletter == "on") {?>
- <a class="admin_menu_entry<?php if($module == "newsletter") echo "_active" ?>"
- href="?page=admin&amp;module=newsletter">Newsletter</a>
-<?php }?>
-<?php if($user->pressrelease == "on") {?>
- <a class="admin_menu_entry<?php if($module == "pressrelease") echo "_active" ?>"
- href="?page=admin&amp;module=pressrelease">Press</a>
-<?php }?>
-<?php if($user->user == "on") {?>
- <a class="admin_menu_entry<?php if($module == "user") echo "_active" ?>"
- href="?page=admin&amp;module=user">Password</a>
-<?php }?>
-<?php if($user->users == "on") {?>
- <a class="admin_menu_entry<?php if($module == "users") echo "_active" ?>"
- href="?page=admin&amp;module=users">Users</a>
-<?php }?>
+<div class="menu">
+<?php
+include_once($UTIL_DIR . "/modules.php");
+
+foreach($modules as $modulename => $module) {
+ if($m == $modulename) $admin_module = $module;
+ echo "<div class=\"entry\"><a href=\"?page=admin&amp;m=$modulename\">$module->admin_title</a></div>\n";
+}
+?>
</div>
-<div class="admin_form">
+<div class="submenu">
<?php
- if($user->events == "on" && $module == "events") include($UTIL_DIR."/admin_events.php");
- if($user->news == "on" && $module == "news") include($UTIL_DIR."/admin_news.php");
- if($user->gallery == "on" && $module == "gallery") include($UTIL_DIR."/admin_gallery.php");
- if($user->guestbook == "on" && $module == "guestbook") include($UTIL_DIR."/admin_guestbook.php");
- if($user->newsletter == "on" && $module == "newsletter") include($UTIL_DIR."/admin_newsletter.php");
- if($user->pressrelease == "on" && $module == "pressrelease") include($UTIL_DIR."/admin_pressrelease.php");
- if($user->user == "on" && $module == "user") include($UTIL_DIR."/admin_user.php");
- if($user->users == "on" && $module == "users") include($UTIL_DIR."/admin_users.php");
- if($module == "") {
- echo "Welcome <em>". $UID ."</em>. Please select administration module.";
- }
- echo "</div>\n";
-} else {
+if($admin_module) {
+ foreach($admin_module->admin_submodules as $submodulename => $submodule) {
+ if($s == $submodule) {
+ $admin_submodule = $s;
+ $admin_submodule_name = $submodulename;
+ }
+ echo "<div class=\"subentry\"><a href=\"?page=admin&amp;m=$m&amp;s=$submodule\">$submodulename</a></div>\n";
+ }
+}
?>
-<div class="admin_form">
-<div class="small_header">Login</div>
+</div>
+<div class="form">
+<?php
+if($admin_submodule) {
+ echo "<div class=\"submodule_header\">$admin_submodule_name</div>\n";
+ $admin_module->admin($admin_submodule, $a, $vars);
+}
+?>
+</div>
+<?php
+} else { // logged in?
+?>
+<div class="form">
<form action="?page=admin&amp;action=login" method="post">
<p>UserID: <input name="userid"/></p>
<p>Password: <input name="password" type="password"/></p>
@@ -76,3 +56,4 @@ if($loggedin == true) {
<?php
}
?>
+</div>
diff --git a/utils/forms.php b/utils/forms.php
new file mode 100644
index 0000000..4383d0a
--- /dev/null
+++ b/utils/forms.php
@@ -0,0 +1,119 @@
+<?php
+
+function beginform($action)
+{
+ global $m, $s;
+?>
+<form method="post" action="?page=admin&amp;m=<?php echo $m; ?>&amp;s=<?php echo $s; ?>&amp;a=<?php echo $action; ?>">
+<?php
+}
+
+function endform()
+{
+?>
+</form>
+<?php
+}
+
+function button($label)
+{
+?>
+ <div class="input">
+ <div class="label"></div>
+ <div class="widget"><button type="submit"><?php echo $label; ?></button></div>
+ </div>
+<?php
+}
+
+function lineedit($label, $name, $value = "")
+{
+?>
+ <div class="input">
+ <div class="label"><?php echo $label; ?></div>
+ <div class="widget"><input name="<?php echo "vars[".$name."]"; ?>" value="<?php echo $value; ?>"/></div>
+ </div>
+<?php
+}
+
+function hidden($values)
+{
+ foreach($values as $key => $value) {
+?>
+ <input type="hidden" name="<?php echo "vars[".$key."]"; ?>" value="<?php echo $value; ?>"/>
+<?php
+ }
+}
+
+function textedit($label, $name, $value = "")
+{
+?>
+ <div class="input">
+ <div class="label"><?php echo $label; ?></div>
+ <div class="widget"><textarea name="<?php echo "vars[".$name."]"; ?>"><?php echo $value; ?></textarea></div>
+ </div>
+<?php
+}
+
+function datetimeedit($label, $name, $timestamp = 0)
+{
+ if($timestamp == 0) $timestamp = time();
+
+ $second = date('s',$timestamp);
+ $minute = date('i',$timestamp);
+ $hour = date('G',$timestamp);
+ $day = date('d',$timestamp);
+ $month = date('m',$timestamp);
+ $year = date('Y',$timestamp);
+?>
+ <div class="input">
+ <div class="label"><?php echo $label; ?></div>
+ <div class="widget">
+ <input style="width: 40px;" name="<?php echo "vars[".$name."_year]"; ?>" value="<?php echo $year; ?>"/>
+ /
+ <input style="width: 20px;" name="<?php echo "vars[".$name."_month]"; ?>" value="<?php echo $month; ?>"/>
+ /
+ <input style="width: 20px;" name="<?php echo "vars[".$name."_day]"; ?>" value="<?php echo $day; ?>"/>
+ -
+ <input style="width: 20px;" name="<?php echo "vars[".$name."_hour]"; ?>" value="<?php echo $hour; ?>"/>
+ :
+ <input style="width: 20px;" name="<?php echo "vars[".$name."_minute]"; ?>" value="<?php echo $minute; ?>"/>
+ :
+ <input style="width: 20px;" name="<?php echo "vars[".$name."_second]"; ?>" value="<?php echo $second; ?>"/>
+ </div>
+ </div>
+<?php
+}
+function totimestamp($t, $name)
+{
+ $timestring = sprintf("%d", $t[$name."_year"]) ."/".
+ sprintf("%d", $t[$name."_month"]) ."/".
+ sprintf("%d", $t[$name."_day"]) ." ".
+ sprintf("%d", $t[$name."_hour"]) .":".
+ sprintf("%02d", $t[$name."_minute"]).":".
+ sprintf("%02d", $t[$name."_second"]);
+
+ echo $timestring;
+
+ return strtotime($timestring);
+}
+
+function combobox($label, $name, $value, $values)
+{
+?>
+ <div class="input">
+ <div class="label"><?php echo $label; ?></div>
+ <div class="widget">
+ <select name="<?php echo "vars[".$name."]"; ?>">
+<?php
+
+ foreach($values as $k => $v) {
+ if($v != $value) echo " <option value=\"$v\">$k</option>\n";
+ else echo " <option value=\"$v\" selected>$k</option>\n";
+ }
+?>
+ </select>
+ </div>
+ </div>
+<?php
+}
+?>
diff --git a/utils/login.php b/utils/login.php
index 950476e..88ba53a 100644
--- a/utils/login.php
+++ b/utils/login.php
@@ -13,6 +13,7 @@ function checklogin()
global $loggedin;
global $action;
global $DATA_DIR;
+ global $ADMIN_TIMEOUT;
$users = new Users($DATA_DIR . "/users.xml");
@@ -25,8 +26,8 @@ function checklogin()
} else {
_log("Wrong password", $userid);
}
- setcookie("UserID", $userid, time()+600); // expire in 10 minutes
- setcookie("Password", $password, time()+600); // expire in 10 minutes
+ setcookie("UserID", $userid, time()+$ADMIN_TIMEOUT);
+ setcookie("Password", $password, time()+$ADMIN_TIMEOUT);
return;
} else {
_log("Failed", $userid);
diff --git a/utils/modules.php b/utils/modules.php
index 62e64d3..4c34228 100644
--- a/utils/modules.php
+++ b/utils/modules.php
@@ -1,17 +1,15 @@
<?php
-$MODULES_DIR = $UTIL_DIR . "/modules";
-
-// Module includes
-include_once($MODULES_DIR . "/news.php");
-include_once($MODULES_DIR . "/events.php");
-
$modules = array();
-$newsmodule = new News($DATA_DIR . "/news.xml");
-$eventsmodule = new Events($DATA_DIR . "/events.xml");
-
-$modules["news"] = $newsmodule;
-$modules["events"] = $eventsmodule;
+/**
+ * Iterate all defined modules, and load them into the global array.
+ * FIXME: Make this lazy (load on demand)
+ */
+foreach($MODULES as $modulename) {
+ include_once($MODULES_DIR . "/" . $modulename . ".php");
+ $module = call_user_func($modulename . "_init");
+ $modules[$modulename] = $module;
+}
?>
diff --git a/utils/modules/events.php b/utils/modules/events.php
index 339102e..efba697 100644
--- a/utils/modules/events.php
+++ b/utils/modules/events.php
@@ -1,153 +1,177 @@
<?php
-
include_once($UTIL_DIR . "/convert.php");
class Event {
- public $title;
- public $time;
- public $description;
- public $flyer;
-
- public function show()
- {
- $str = "<div class=\"event\">\n";
- $str .= " <div class=\"event_title\">" .
- htmlspecialchars_decode($this->title, ENT_QUOTES) . "</div>\n";
- $str .= " <div class=\"event_time\">" . date("D M jS Y", $this->time) . "</div>\n";
- $str .= " <div class=\"event_description\">" .
- htmlspecialchars_decode($this->description, ENT_QUOTES) . "</div>\n";
- if($this->flyer) {
- $str .= " <img class=\"event_flyer\" alt=\"flyer\" src=\"gfx/flyers/" . $this->flyer . "\"/>\n";
- }
- $str .= "</div>\n";
- return $str;
- }
-
- public function Event($title, $time, $description, $flyer = "")
- {
- $this->title = $title;
- $this->time = $time;
- $this->description = $description;
- $this->flyer = $flyer;
- }
+ public $title;
+ public $time;
+ public $description;
+ public $flyer;
+
+ public function show()
+ {
+ $str = "<div class=\"event\">\n";
+ $str .= " <div class=\"event_title\">" .
+ htmlspecialchars_decode($this->title, ENT_QUOTES) . "</div>\n";
+ $str .= " <div class=\"event_time\">" . date("D M jS Y", $this->time) . "</div>\n";
+ $str .= " <div class=\"event_description\">" .
+ htmlspecialchars_decode($this->description, ENT_QUOTES) . "</div>\n";
+ if($this->flyer) {
+ $str .= " <img class=\"event_flyer\" alt=\"flyer\" src=\"gfx/flyers/" . $this->flyer . "\"/>\n";
+ }
+ $str .= "</div>\n";
+ return $str;
+ }
+
+ public function Event($title, $time, $description, $flyer = "")
+ {
+ $this->title = $title;
+ $this->time = $time;
+ $this->description = $description;
+ $this->flyer = $flyer;
+ }
}
class Events {
- private $file;
- private $events = array();
-
- public function run($params)
- {
- foreach($params as $param) {
- switch($param) {
- case "coming":
- return $this->showcoming(-1);
- break;
-
- case "old":
- default:
- return $this->showold(-1);
- break;
- }
- }
- }
-
- public function showcoming($number)
- {
- $str = "";
-
- $foundany = false;
-
- // Key sort
- ksort($this->events);
-
- // If number is -1 show all shows.
- if($number == -1) $number = 100000;
+ private $file;
+ private $events = array();
+
+ // Admin config
+ public $admin_title = "Events";
+ public $admin_submodules = array("New Event" => "new",
+ "Edit Event" => "edit",
+ "Delete Event" => "delete");
+
+ public function admin($sub, $action, $vars)
+ {
+ switch($sub) {
+ case "new":
+ echo "New";
+ break;
+ case "edit":
+ echo "Edit";
+ break;
+ case "delete":
+ echo "Delete";
+ break;
+ }
+ }
+
+ public function run($params)
+ {
+ foreach($params as $param) {
+ switch($param) {
+ case "coming":
+ return $this->showcoming(-1);
+ break;
+
+ case "old":
+ default:
+ return $this->showold(-1);
+ break;
+ }
+ }
+ }
+
+ public function showcoming($number)
+ {
+ $str = "";
+
+ $foundany = false;
+
+ // Key sort
+ ksort($this->events);
+
+ // If number is -1 show all shows.
+ if($number == -1) $number = 100000;
- foreach($this->events as $event) {
- if($event->time >= time()) {
- $foundany = true;
- $str .= $event->show();
- $number--;
- }
- if(!$number) return $str;
- }
-
- if($foundany == false) return "No shows available at the moment.";
- return $str;
- }
-
- public function showold($number)
- {
- $str = "";
-
- // Key sort
- krsort($this->events);
-
- // If number is -1 show all shows.
- if($number == -1) $number = 100000;
-
- foreach($this->events as $event) {
- if($event->time <= time()) {
- $str .= $event->show();
- $number--;
- }
- if(!$number) return $str;
- }
- return $str;
- }
+ foreach($this->events as $event) {
+ if($event->time >= time()) {
+ $foundany = true;
+ $str .= $event->show();
+ $number--;
+ }
+ if(!$number) return $str;
+ }
+
+ if($foundany == false) return "No shows available at the moment.";
+ return $str;
+ }
+
+ public function showold($number)
+ {
+ $str = "";
+
+ // Key sort
+ krsort($this->events);
+
+ // If number is -1 show all shows.
+ if($number == -1) $number = 100000;
+
+ foreach($this->events as $event) {
+ if($event->time <= time()) {
+ $str .= $event->show();
+ $number--;
+ }
+ if(!$number) return $str;
+ }
+ return $str;
+ }
- public function add($event) {
- $key = $event->time;
- // array_push($this->events, $event);
- $this->events[$key] = $event;
- }
+ public function add($event) {
+ $key = $event->time;
+ // array_push($this->events, $event);
+ $this->events[$key] = $event;
+ }
- public function write()
- {
- $fp = fopen($this->file, "w");
- fwrite($fp, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
-
- fwrite($fp, "<events>\n");
- foreach($this->events as $event) {
- fwrite($fp, " <event title=\"" .
- htmlspecialchars($event->title, ENT_QUOTES, "UTF-8") . "\"\n");
- fwrite($fp, " time=\"" . $event->time . "\"\n");
- fwrite($fp, " description=\"" .
- htmlspecialchars($event->description, ENT_QUOTES, "UTF-8") . "\"\n");
- fwrite($fp, " flyer=\"" . $event->flyer . "\">\n");
- fwrite($fp, " </event>\n");
- }
- fwrite($fp, "</events>\n");
-
- fclose($fp);
- }
+ public function write()
+ {
+ $fp = fopen($this->file, "w");
+ fwrite($fp, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
+
+ fwrite($fp, "<events>\n");
+ foreach($this->events as $event) {
+ fwrite($fp, " <event title=\"" .
+ htmlspecialchars($event->title, ENT_QUOTES, "UTF-8") . "\"\n");
+ fwrite($fp, " time=\"" . $event->time . "\"\n");
+ fwrite($fp, " description=\"" .
+ htmlspecialchars($event->description, ENT_QUOTES, "UTF-8") . "\"\n");
+ fwrite($fp, " flyer=\"" . $event->flyer . "\">\n");
+ fwrite($fp, " </event>\n");
+ }
+ fwrite($fp, "</events>\n");
+
+ fclose($fp);
+ }
- private function read()
- {
-
- $dom = new DomDocument;
- $dom->preserveWhiteSpace = FALSE;
- $dom->load($this->file);
- $params = $dom->getElementsByTagName('event');
-
- foreach ($params as $param) {
- $event = new Event($param->getAttribute('title'),
- $param->getAttribute('time'),
- $param->getAttribute('description'),
- $param->getAttribute('flyer'));
- $this->add($event);
- }
-
- }
+ private function read()
+ {
+ $dom = new DomDocument;
+ $dom->preserveWhiteSpace = FALSE;
+ $dom->load($this->file);
+ $params = $dom->getElementsByTagName('event');
+
+ foreach ($params as $param) {
+ $event = new Event($param->getAttribute('title'),
+ $param->getAttribute('time'),
+ $param->getAttribute('description'),
+ $param->getAttribute('flyer'));
+ $this->add($event);
+ }
+ }
+
+ public function Events($file)
+ {
+ $this->file = $file;
+ if(file_exists($file)) $this->read();
+ }
- public function Events($file)
- {
- $this->file = $file;
- if(file_exists($file)) $this->read();
- }
+}
+function events_init()
+{
+ global $DATA_DIR;
+ return new Events($DATA_DIR . "/events.xml");
}
?>
diff --git a/utils/modules/news.php b/utils/modules/news.php
index 22de6a0..2505ffb 100644
--- a/utils/modules/news.php
+++ b/utils/modules/news.php
@@ -1,119 +1,186 @@
<?php
include_once($UTIL_DIR . "/convert.php");
+include_once($UTIL_DIR . "/forms.php");
class NewsEntry {
- public $title;
- public $time;
- public $description;
- public $category;
-
- public function show()
- {
- $str = "<div class=\"news_entry\">\n";
- $str .= " <div class=\"news_title\">" .
- htmlspecialchars_decode($this->title, ENT_QUOTES) . "</div>\n";
- $str .= " <div class=\"news_time\">" . date("D M jS Y G:i", $this->time) . "</div>\n";
- $str .= " <div class=\"news_description\">" .
- htmlspecialchars_decode($this->description, ENT_QUOTES) . "</div>\n";
- $str .= "</div>\n";
- return $str;
- }
-
- public function NewsEntry($title, $time, $category, $description)
- {
- $this->title = $title;
- $this->time = $time;
- $this->category = $category;
- $this->description = $description;
- }
+ public $title;
+ public $time;
+ public $description;
+ public $category;
+
+ public function show()
+ {
+ $str = "<div class=\"news_entry\">\n";
+ $str .= " <div class=\"news_title\">" .
+ htmlspecialchars_decode($this->title, ENT_QUOTES) . "</div>\n";
+ $str .= " <div class=\"news_time\">" . date("D M jS Y G:i", $this->time) . "</div>\n";
+ $str .= " <div class=\"news_description\">" .
+ htmlspecialchars_decode($this->description, ENT_QUOTES) . "</div>\n";
+ $str .= "</div>\n";
+ return $str;
+ }
+
+ public function NewsEntry($title, $time, $category, $description)
+ {
+ $this->title = $title;
+ $this->time = $time;
+ $this->category = $category;
+ $this->description = $description;
+ }
}
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") {
+ private $file;
+ private $news = array();
+
+ // Admin config
+ public $admin_title = "News";
+ public $admin_submodules = array("New Newsentry" => "new",
+ "Edit Newsentry" => "edit",
+ "Delete Newsentry" => "delete");
+
+ public function admin($sub, $action, $vars)
+ {
+ switch($sub) {
+ case "new":
+ switch($action) {
+ case "add":
+ $n = new NewsEntry($vars["title"], totimestamp($vars, "time"), $vars["category"], $vars["description"]);
+ $this->add($n);
+ $this->write();
+ break;
+
+ case "preview":
+ $n = new NewsEntry($vars["title"], totimestamp($vars, "time"), $vars["category"], $vars["description"]);
+ echo "<div class=\"preview\">\n";
+ echo "<div class=\"content\">\n";
+ echo $n->show();
+ echo "</div>\n";
+ echo "</div>\n";
+ echo "<p>Looking ok?</p>";
+ beginform("add");
+ hidden($vars);
+ button("yes");
+ endform();
+ beginform("retry");
+ hidden($vars);
+ button("no");
+ endform();
+ break;
+
+ case "retry":
+ $title = $vars["title"];
+ $time = totimestamp($vars, "time");
+ $category = $vars["category"];
+ $description = $vars["description"];
+ default:
+ beginform("preview");
+ lineedit("Title", "title", $title);
+ datetimeedit("Time", "time", $time);
+ combobox("Category", "category", $category, array("Main" => "main", "Site" => "site"));
+ textedit("Description", "description", $description);
+ button("Post news");
+ endform();
+ break;
+ }
+ break;
+
+ case "edit":
+ echo "Edit";
+ break;
+ case "delete":
+ echo "Delete";
+ break;
+ }
+ }
+
+ 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") {
$str .= $newsentry->show();
$number--;
- }
- if(!$number) return $str;
- }
- return $str;
- }
-
- public function add($newsentry) {
- $key = $newsentry->time;
- $this->news[$key] = $newsentry;
- }
+ }
+ if(!$number) return $str;
+ }
+ return $str;
+ }
+
+ public function add($newsentry) {
+ $key = $newsentry->time;
+ $this->news[$key] = $newsentry;
+ }
- public function write()
- {
- $fp = fopen($this->file, "w");
- fwrite($fp, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
-
- fwrite($fp, "<news>\n");
- foreach($this->news as $newsentry) {
- fwrite($fp, " <newsentry title=\"" .
+ public function write()
+ {
+ $fp = fopen($this->file, "w");
+ fwrite($fp, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
+
+ fwrite($fp, "<news>\n");
+ foreach($this->news as $newsentry) {
+ fwrite($fp, " <newsentry title=\"" .
htmlspecialchars($newsentry->title, ENT_QUOTES, "UTF-8") . "\"\n");
- fwrite($fp, " time=\"" . $newsentry->time . "\"\n");
- fwrite($fp, " category=\"" . $newsentry->category . "\"\n");
- fwrite($fp, " description=\"" .
+ fwrite($fp, " time=\"" . $newsentry->time . "\"\n");
+ fwrite($fp, " category=\"" . $newsentry->category . "\"\n");
+ fwrite($fp, " description=\"" .
htmlspecialchars($newsentry->description, ENT_QUOTES, "UTF-8") . "\">\n");
- fwrite($fp, " </newsentry>\n");
- }
- fwrite($fp, "</news>\n");
+ fwrite($fp, " </newsentry>\n");
+ }
+ fwrite($fp, "</news>\n");
- fclose($fp);
- }
+ fclose($fp);
+ }
- private function read()
- {
- $dom = new DomDocument;
- $dom->preserveWhiteSpace = FALSE;
- $dom->load($this->file);
- $params = $dom->getElementsByTagName('newsentry');
-
- foreach ($params as $param) {
- $newsentry = new NewsEntry($param->getAttribute('title'),
+ private function read()
+ {
+ $dom = new DomDocument;
+ $dom->preserveWhiteSpace = FALSE;
+ $dom->load($this->file);
+ $params = $dom->getElementsByTagName('newsentry');
+
+ foreach ($params as $param) {
+ $newsentry = new NewsEntry($param->getAttribute('title'),
$param->getAttribute('time'),
$param->getAttribute('category'),
$param->getAttribute('description'));
- $this->add($newsentry);
- }
+ $this->add($newsentry);
+ }
- // Key sort
- krsort($this->news);
- }
+ // Key sort
+ krsort($this->news);
+ }
- public function News($file)
- {
- $this->file = $file;
- if(file_exists($file)) $this->read();
- }
+ public function News($file)
+ {
+ $this->file = $file;
+ if(file_exists($file)) $this->read();
+ }
}
+function news_init()
+{
+ global $DATA_DIR;
+ return new News($DATA_DIR . "/news.xml");
+}
?>