.ms_AlignRight {text-align: right;}\r
.ms_Bold {font-weight: bold;}\r
\r
-.ms_ButtonArea {margin-top: 10px}
\ No newline at end of file
+.ms_ButtonArea {margin-top: 10px}\r
+\r
+.ms_Error {color: red; margin-top: 20px;}
\ No newline at end of file
// see the documentation on how to make settings
//Template directory
-$template="./template/de/";
+$template="./template/";
///////////
--- /dev/null
+<?php
+// +----------------------------------------------------------------------
+// | PHP Source
+// +----------------------------------------------------------------------
+// | Copyright (C) 2007 by Peter keller <peter@silmor.de>
+// +----------------------------------------------------------------------
+// |
+// | Copyright: See COPYING file that comes with this distribution
+// +----------------------------------------------------------------------
+//
+
+class ErrorManager
+{
+ private $errorMessages;
+
+ public function __construct()
+ {
+ $this->errorMessages = array();
+ }
+
+ /** add new error message */
+ public function add($message)
+ {
+ $this->errorMessages[] = $message;
+ }
+
+ /** get all error messages in an array */
+ public function getAll()
+ {
+ return $this->errorMessages;
+ }
+
+ /** get all error messages formatted */
+ public function getAllFormatted()
+ {
+ $p = new Parser("definition.html");
+ $messages = "";
+
+ foreach ($this->errorMessages as $message)
+ {
+ $errorTmpl = $p->getVar("ERROR");
+ $p->setVar("MESSAGE", $message);
+ $messages .= $p->parse($errorTmpl);
+ }
+ return $messages;
+ }
+
+ /** returns true if errors exist */
+ public function exists()
+ {
+ if (count($this->errorMessages) > 0) {
+ return true;
+ }
+ else {
+ return false;
+ }
+ }
+}
+?>
\ No newline at end of file
function createEventDetails()
{
global $parser;
- global $_GET;
-
+ global $error;
+
if (isset($_GET["event"])) {
$eventID = $_GET["event"];
}
$p->setVars($event->getParserData());
$details = $p->parse($eventTmpl);
$p->setVar("EVENTDETAILS",$details);
- $p->setVar("fieldAMOUNT", "<input type='text' id='ms_textfield_amount' name='ms_amount' size='2' maxlength='2'/>");
+ $p->setVar("fieldAMOUNT", "ms_amount");
$p->setVar("buttonSAVE", "ms_save");
+
+ // set error message
+ if ($error->exists()) {
+ $p->setVar("ERROR", "true");
+ $p->setVar("ERRORMESSAGE", $error->getAllFormatted());
+ }
// create page
$parser->setVAR("PAGE", $p->parseFile("eventdetails.html"));
--- /dev/null
+<?php
+// +----------------------------------------------------------------------
+// | PHP Source
+// +----------------------------------------------------------------------
+// | Copyright (C) 2007 by Peter keller <peter@silmor.de>
+// +----------------------------------------------------------------------
+// |
+// | Copyright: See COPYING file that comes with this distribution
+// +----------------------------------------------------------------------
+//
+
+class LanguageManager
+{
+ private $COOKIE_NAME = "ms_lang";
+ private $lang;
+
+ /** constructor */
+ public function __construct()
+ {
+ global $template;
+
+ // check if cookie is set
+ if (isset($_COOKIE[$this->COOKIE_NAME])) {
+ $this->lang = $_COOKIE[$this->COOKIE_NAME];
+ } else {
+ $this->lang = substr($_SERVER[HTTP_ACCEPT_LANGUAGE],0,2);
+ }
+
+ $dir = $template.$this->lang."/";
+
+ if (is_dir($dir)) {
+ // if language folder exists
+ $template = $dir;
+ } else {
+ // set default value
+ $template .= "de/";
+ }
+ }
+
+ /** set language */
+ public function setLanguage($language)
+ {
+ $this->lang = $language;
+ setcookie($this->COOKIE_NAME, $language, 0);
+ }
+
+ /** get date in current language */
+ public function getDate($date)
+ {
+
+ }
+
+ /** get time in current language */
+ public function getTime($time)
+ {
+
+ }
+
+ /** get price in current language */
+ public function getPrice($price)
+ {
+
+ }
+}
+
+?>
{
global $_SERVER;
$this->vars["SCRIPT"]=$_SERVER[SCRIPT_NAME];
+ $this->vars["FULLURL"]=$_SERVER[REQUEST_URI];
if($fname!="")
$this->parseFile($fname);
}
--- /dev/null
+<?php
+// +----------------------------------------------------------------------
+// | PHP Source
+// +----------------------------------------------------------------------
+// | Copyright (C) 2007 by Peter keller <peter@silmor.de>
+// +----------------------------------------------------------------------
+// |
+// | Copyright: See COPYING file that comes with this distribution
+// +----------------------------------------------------------------------
+//
+
+/** adds an event to the cart */
+function addEventToCart()
+{
+ global $error;
+
+ if (isset($_POST["ms_save"])) {
+ if (empty($_POST["ms_amount"])) {
+ $error->add("Bitte geben Sie eine Kartenmenge an!");
+ return;
+ } else {
+ // TODO: add to cart
+ Header("Location: index.php");
+ }
+ }
+}
+?>
//basics
include('inc/loader.php');
include('inc/loader_nonadmin.php');
+include('inc/parser.php');
+include('inc/error.php');
+include('inc/language_manager.php');
+
+//include
+include('inc/submit.php');
+
//include display scripts
include('inc/event_listing.php');
-include('inc/parser.php');
//set common basics
$mode="index";
if(isset($_GET["mode"])){
$mode=$_GET["mode"];
}
-$parser=new Parser();
+
+$parser = new Parser();
+$error = new ErrorManager();
+$lang = new LanguageManager();
//get page template and process it
switch($mode){
- case "reserve":
- createreservation();
- break;
case "eventDetails":
+ addEventToCart();
createEventDetails();
break;
default:
--- /dev/null
+#set:ERROR:
+<div>
+@MESSAGE@
+</div>
+#endset
\ No newline at end of file
<h1>Veranstaltungsdetails</h1>
<div id="ms_form">
-<form action="." method="POST">
+<form action="@FULLURL@" method="POST">
@EVENTDETAILS@
</div>
<div class="ms_FormRow">
<label for="ms_textfield_amount">Kartenanzahl:</label>
-@fieldAMOUNT@
+<input type="text" id="ms_textfield_amount" name="@fieldAMOUNT@" size="2" maxlength="2"/>
</div>
</fieldset>
#endset
<div class="ms_ButtonArea">
-<input type="button" id="ms_button_save" name="@buttonSAVE@" value="In den Warenkorb" />
+<input type="submit" id="ms_button_save" name="@buttonSAVE@" value="In den Warenkorb" />
</div>
</form>
+
+#if:ERROR==true
+<div class="ms_ErrorArea">
+@ERRORMESSAGE@
+</div>
+#endif
+
</div>
\ No newline at end of file
<a href="@SCRIPT@?mode=info&event=@ID@">Info</a>
<a href="@SCRIPT@?mode=eventDetails&event=@ID@">Bestellen</a>
</p>
-#endset
\ No newline at end of file
+#endset