fix some more warnings
authorkonrad <konrad@6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33>
Sat, 3 Jul 2010 18:43:18 +0000 (18:43 +0000)
committerkonrad <konrad@6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33>
Sat, 3 Jul 2010 18:43:18 +0000 (18:43 +0000)
remove old web error class
new form for event details

git-svn-id: https://silmor.de/svn/softmagic/smoke/trunk@514 6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33

wob/cart.wolf
www/inc/classes/autoload.php
www/inc/classes/error.php [deleted file]
www/inc/global_variables.php
www/inc/machine/session.php
www/inc/rendering/event_listing.php
www/inc/rendering/submit.php
www/inc/wext/event.php
www/index.php
www/template/en/eventdetails.html

index 09a1eb1..7d2f4e6 100644 (file)
@@ -21,8 +21,9 @@
                <Column name="cartid" type="string:32" notnull="yes" foreignkey="cart:cartid" primarykey="yes"/>
                <!--tickets in the cart-->
                <Column name="eventid" type="int32" notnull="yes" foreignkey="event:eventid" primarykey="yes"/>
+               <Column name="pricecategoryid" type="int32" foreignkey="pricecategory:pricecategoryid" primarykey="yes"/>
                <Column name="amount" type="int32" notnull="yes"/>
-               <Column name="seating" type="string:32" null="yes"/>
+               <!-- Column name="seating" type="string:32" null="yes"/ -->
        </Table>
        <Table name="cart_voucher">
                <Column name="cvid" type="seq64" primarykey="yes"/>
@@ -80,6 +81,7 @@
        <Class name="CartItem"/>
        
        <Class name="CartOrder">
+               <Doc>The cart as used from the remote (non-web) system, this is a transaction object, it has no equivalent inside the database.</Doc>
                <Abstract lang="php"/>
                <Enum name="ValidationState">
                        <Value name="Ok">The cart has been processed successfully</Value>
index 432e853..eb3c80d 100644 (file)
@@ -13,5 +13,4 @@
 wob_autoclass('LanguageManager','./inc/classes/language_manager.php');
 wob_autoclass('ConfigManager','./inc/classes/config_manager.php');
 wob_autoclass('Websession','./inc/classes/websession.php');
-wob_autoclass('ErrorManager','./inc/classes/error.php');
 ?>
\ No newline at end of file
diff --git a/www/inc/classes/error.php b/www/inc/classes/error.php
deleted file mode 100644 (file)
index 5cc9ebc..0000000
+++ /dev/null
@@ -1,74 +0,0 @@
-<?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;
-       private static $instance;
-       
-       private function __construct()
-       {
-               $this->errorMessages = array(); 
-       }
-       
-       /** returns the instance of the Error Manager */
-       public static function singleton()
-       {
-               if(!self::$instance) {
-                       self::$instance = new ErrorManager();
-               }
-
-               return self::$instance;
-       }
-       
-       /** 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);
-               }
-               
-               $errorArea = $p->getVar("ERRORAREA");
-               $p->setVar("ERRORMESSAGES", $messages);
-               
-               return $p->parse($errorArea);
-       }
-       
-       /** returns true if errors exist */
-       public function exists()
-       {
-               if (count($this->errorMessages) > 0) {
-                       return true;
-               }
-               else {
-                       return false;
-               }
-       }
-}
-?>
\ No newline at end of file
index 0a5d5f4..760ff01 100644 (file)
@@ -14,6 +14,5 @@ define("COOKIE_WEBSESSION", "ms_websession");
 define("COOKIE_LANGUAGE", "ms_lang");
 
 $lang = LanguageManager::singleton();
-$error = ErrorManager::singleton();
 
 ?>
index 0e0777a..4a3df97 100644 (file)
@@ -38,7 +38,7 @@ class Session
                        $this->sessid=$sid;
                        $this->user=$res[0]["uname"];
                        $this->initRights();
-                       $this->initFlags($res[0]["flags"]);
+                       $this->initFlags();
                }
                $session=$this;
        }
@@ -80,10 +80,15 @@ class Session
        }
        
        /**internal: retrieve and remember the flags of this user*/
-       protected function initFlags($flg)
+       protected function initFlags()
        {
                global $db;
-               $this->flags=explode(" ",$flg);
+               #user flags
+               $this->flags=array();
+               $res=$db->select("user","uname,flags","uname=".$db->escapeString($this->user));
+               if(count($res)>0)
+                       $this->flags=explode(" ",$res[0]['flags']);
+               #role flags
                $res=$db->select("userrole","role","uname=".$db->escapeString($this->user));
                for($i=0;$i<count($res);$i++){
                        $res2=$db->select("role","flags","rolename=".$db->escapeString($res[$i][0]));
@@ -156,7 +161,6 @@ class Session
                
                //create session and return
                //get random bits
-               randseed($rand);
                $sid=getRandom(128);
                //try to create entry
                $db->beginTransaction();
index 17303ba..ec39adc 100644 (file)
@@ -40,40 +40,26 @@ public static function createEventList()
 /** creates the details of an event */
 public static function createEventDetails()
 {
-       global $parser;
+       global $twig,$session,$basevars;
        
-       $error = ErrorManager::singleton();
-
        if (isset($_GET["event"])) {
                $eventID = $_GET["event"]+0;
        }
 
-       $p = new Parser("eventdetails.html");
-       $eventTmpl = $p->getVar("EVENT");
-       
+       $p = $twig->loadTemplate("eventdetails.html");
+
        // check if event exists
-       $event = new Event($eventID);
-       if (!$event->exists())
-       {
-               redirectHome(array());
-               return;
-       }
-       
+       $trn=WTrGetEvent::execute($eventID);
+       $event = $trn->resultevent();
+       if(!is_a($event,"WoEvent"))
+               throw new Exception("Unknown Event");
+
        // set event details
-       $p->setVars($event->getParserData());
-       $details = $p->parse($eventTmpl);
-       $p->setVar("EVENTDETAILS",$details);
-       $p->setVar("fieldAMOUNT", "ms_amount");
-       $p->setVar("buttonSAVE", "ms_save");
+       $list=$basevars;
+       $list['event']=$event->getParserData();
        
-       // set error message
-       if ($error->exists()) {
-               $p->setVar("ERROR", "true");
-               $p->setVar("ERRORAREA", $error->getAllFormatted());
-       }
-
        // create page
-       $parser->setVAR("PAGE", $p->parseFile("eventdetails.html"));
+       return $p->render($list);
 }
 
 //end of class
index a80fe41..eb0c5f2 100644 (file)
@@ -21,7 +21,7 @@ if (isset($_POST["ms_goToOrder"])) {
 /** adds an event to the cart */ 
 function addEventToCart()
 {
-       $error = ErrorManager::singleton();
+//     $error = ErrorManager::singleton();
 
        if (isset($_POST["ms_save"])) {
                $event = new Event(($_GET["event"]+0));
index 33274ee..b2e4a35 100644 (file)
@@ -234,7 +234,7 @@ class WOEvent extends WOEventAbstract
        /**returns the data in an array suitable for the web-page-renderer*/
        public function getParserData()
        {
-               global $session;
+               global $session,$basevars;
                $lang = LanguageManager::singleton();
                $ret=array(
                        "date"=>$lang->getDate($this->getstart()),
@@ -256,8 +256,13 @@ class WOEvent extends WOEventAbstract
                                "price"=>$lang->getPrice($price->getprice()),
                                "pricecents"=>$price->getprice(),
                                "categoryid"=>$price->getpricecategoryid(),
-                               "categoryname"=>$price->getpricecategory()->getname()
+                               "categoryname"=>$price->getpricecategory()->getname(),
                                //TODO: get max tickets, current amount, amount free
+                               "maxtickets"=>$price->getmaxavailable(),
+                               "ticketsblock"=>$price->getamountticketsblock(),
+                               "ticketsavailable"=>($price->getmaxavailable()-$price->getamountticketsblock()),
+                               //little helper for forms
+                               "amountinputfield"=>($basevars['inputnames']['amountTickets']."[".$price->getpricecategoryid()."]"),
                        );
                }
                //return result
index cee78d8..a40fd26 100644 (file)
@@ -15,10 +15,6 @@ include("inc/rendering/autoload.php");
 //include process script (TODO: rework to be autoloaded)
 include('inc/rendering/submit.php');
 
-//include display scripts (TODO: move to autoloading)
-include('inc/rendering/cart_listing.php');
-include('inc/rendering/order_listing.php');
-
 //set common basics
 $mode="index";
 if(isset($_GET["mode"])){
@@ -38,12 +34,17 @@ foreach($twigextensions as $te)$twig->addExtension($te);
 $basevars['script']['root']=$_SERVER['SCRIPT_NAME'];
 $basevars['script']['this']=$_SERVER['REQUEST_URI'];
 $basevars['script']['eventDetails']=$_SERVER['SCRIPT_NAME']."?mode=eventDetails&event=";
-$basevars['script']['cart']=$_SERVER['SCRIPT_NAME']."?mode=cart";
-$basevars['script']['orderLogin']=$_SERVER['SCRIPT_NAME']."?mode=orderLogin";
-$basevars['script']['customerRegistration']=$_SERVER['SCRIPT_NAME']."?mode=customerRegistration";
-$basevars['script']['orderOverview']=$_SERVER['SCRIPT_NAME']."?mode=orderOverview";
-$basevars['script']['editShippingAddress']=$_SERVER['SCRIPT_NAME']."?mode=editShippingAddress";
-$basevars['script']['editOrderComments']=$_SERVER['SCRIPT_NAME']."?mode=editOrderComments";
+$basevars['script']['eventOrder']=$_SERVER['SCRIPT_NAME']."?mode=eventOrder&event=";
+//$basevars['script']['cart']=$_SERVER['SCRIPT_NAME']."?mode=cart";
+//$basevars['script']['orderLogin']=$_SERVER['SCRIPT_NAME']."?mode=orderLogin";
+//$basevars['script']['customerRegistration']=$_SERVER['SCRIPT_NAME']."?mode=customerRegistration";
+//$basevars['script']['orderOverview']=$_SERVER['SCRIPT_NAME']."?mode=orderOverview";
+//$basevars['script']['editShippingAddress']=$_SERVER['SCRIPT_NAME']."?mode=editShippingAddress";
+//$basevars['script']['editOrderComments']=$_SERVER['SCRIPT_NAME']."?mode=editOrderComments";
+// form elements
+$basevars['inputnames']['amountTickets']="amountTickets";
+$basevars['inputnames']['event']="event";
+$basevars['inputnames']['mode']="mode";
 
 //strings that are used to compose the overall layout
 $page="(internal error: no page text yet)";
@@ -52,10 +53,11 @@ try{
        //get page template and process it
        switch($mode){
                case "eventDetails":
-                       addEventToCart();
-                       EventRender::createEventDetails();
+                       $page=EventRender::createEventDetails();
                        break;
-               case "cart":
+               case "eventOrder":
+                       $page=
+/*             case "cart":
                        deleteEventFromCart();
                        changeTicketAmountInCart();
                        createCartOverview();
@@ -79,7 +81,7 @@ try{
                case "editOrderComments":
                        saveOrderComments();
                        editOrderComments();
-                       break;
+                       break;*/
                default:
                        $page=EventRender::createEventList();
                        break;
index 75e5c4d..adb425e 100644 (file)
@@ -1,53 +1,30 @@
-<h1>Veranstaltungsdetails</h1>
-<div id="ms_form">
-<form action="@FULLURL@" method="POST">
+{# Example Template for MagicSmoke
+   ================================
+   this one is called to create the event detail/order page
+#}
 
-@EVENTDETAILS@
+{% extends 'layout.html' %}
 
-#set:EVENT:
-<fieldset class="ms_Form">
-<div class="ms_FormRow">
-<label for="ms_text_event">Veranstaltung:</label>
-<div id="ms_text_event">@EVENTNAME@</div>
-</div>
-<div class="ms_FormRow">
-<label for="ms_text_artist">K&uuml;nstler:</label>
-<div id="ms_text_artist">@ARTIST@</div>
-</div>
-<div class="ms_FormRow">
-<label for="ms_text_place">Ort:</label>
-<div id="ms_text_place">@PLACE@</div>
-</div>
-<div class="ms_FormRow">
-<label for="ms_text_date">Datum:</label>
-<div id="ms_text_date">@DATE@</div>
-</div>
-<div class="ms_FormRow">
-<label for="ms_text_time">Uhrzeit:</label>
-<div id="ms_text_time">@TIME@</div>
-</div>
-<div class="ms_FormRow">
-<label for="ms_text_information">Information:</label>
-<div id="ms_text_information">@DESCRIPTION@</div>
-</div>
-<div class="ms_FormRow">
-<label for="ms_text_price">Kartenpreis:</label>
-<div id="ms_text_price">@PRICE@ &euro;</div>
-</div>
-<div class="ms_FormRow">
-<label for="ms_textfield_amount">Kartenanzahl:</label>
-<input type="text" id="ms_textfield_amount" name="@fieldAMOUNT@" size="2" maxlength="2" value="1"/>
-</div>
-</fieldset>
-#endset
+{% block title %}{{event.name}}{% endblock %}
 
-<div class="ms_ButtonArea">
-<input type="submit" id="ms_button_save" name="@buttonSAVE@" value="In den Warenkorb" />
-</div>
-</form>
+{% block page %}
 
-#if:ERROR==true
-@ERRORAREA@
-#endif
+  <h2>{{event.name}}</h2>
+  {{event.date}} {{event.time}}, {{event.place}}<br/>
+  Artist: {{event.artist}}<br/>
+  {{event.description}}<br/>
+  <form action="{{script.eventOrder}}{{event.ID}}" method="GET">
+  <table>
+  <tr><td>Price:</td><td>Amount:</td></tr>
+  {% for price in event.prices %}
+   <tr><td>{{price.price}} ({{price.categoryname}})</td>
+   <td><select name="{{price.amountinputfield}}">
+    {% for i in 0 .. price.ticketsavailable %}
+      <option>{{i}}</option>
+    {% endfor %}
+    </select></td></tr>
+  {% endfor %}</table><br/>
+  <input type="submit" value="add to cart" />
+  </form>
 
-</div>
\ No newline at end of file
+{% endblock %}