From: konrad Date: Sat, 3 Jul 2010 18:43:18 +0000 (+0000) Subject: fix some more warnings X-Git-Url: http://git.silmor.de/gitweb/?a=commitdiff_plain;h=8f6f33fc2a37644bc5f2e42f97781f496c5706a5;p=web%2Fkonrad%2Fsmoke.git fix some more warnings 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 --- diff --git a/wob/cart.wolf b/wob/cart.wolf index 09a1eb1..7d2f4e6 100644 --- a/wob/cart.wolf +++ b/wob/cart.wolf @@ -21,8 +21,9 @@ + - + @@ -80,6 +81,7 @@ + The cart as used from the remote (non-web) system, this is a transaction object, it has no equivalent inside the database. The cart has been processed successfully diff --git a/www/inc/classes/autoload.php b/www/inc/classes/autoload.php index 432e853..eb3c80d 100644 --- a/www/inc/classes/autoload.php +++ b/www/inc/classes/autoload.php @@ -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 index 5cc9ebc..0000000 --- a/www/inc/classes/error.php +++ /dev/null @@ -1,74 +0,0 @@ - -// +---------------------------------------------------------------------- -// | -// | 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 diff --git a/www/inc/global_variables.php b/www/inc/global_variables.php index 0a5d5f4..760ff01 100644 --- a/www/inc/global_variables.php +++ b/www/inc/global_variables.php @@ -14,6 +14,5 @@ define("COOKIE_WEBSESSION", "ms_websession"); define("COOKIE_LANGUAGE", "ms_lang"); $lang = LanguageManager::singleton(); -$error = ErrorManager::singleton(); ?> diff --git a/www/inc/machine/session.php b/www/inc/machine/session.php index 0e0777a..4a3df97 100644 --- a/www/inc/machine/session.php +++ b/www/inc/machine/session.php @@ -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;$iselect("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(); diff --git a/www/inc/rendering/event_listing.php b/www/inc/rendering/event_listing.php index 17303ba..ec39adc 100644 --- a/www/inc/rendering/event_listing.php +++ b/www/inc/rendering/event_listing.php @@ -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 diff --git a/www/inc/rendering/submit.php b/www/inc/rendering/submit.php index a80fe41..eb0c5f2 100644 --- a/www/inc/rendering/submit.php +++ b/www/inc/rendering/submit.php @@ -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)); diff --git a/www/inc/wext/event.php b/www/inc/wext/event.php index 33274ee..b2e4a35 100644 --- a/www/inc/wext/event.php +++ b/www/inc/wext/event.php @@ -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 diff --git a/www/index.php b/www/index.php index cee78d8..a40fd26 100644 --- a/www/index.php +++ b/www/index.php @@ -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; diff --git a/www/template/en/eventdetails.html b/www/template/en/eventdetails.html index 75e5c4d..adb425e 100644 --- a/www/template/en/eventdetails.html +++ b/www/template/en/eventdetails.html @@ -1,53 +1,30 @@ -

Veranstaltungsdetails

-
-
+{# Example Template for MagicSmoke + ================================ + this one is called to create the event detail/order page +#} -@EVENTDETAILS@ +{% extends 'layout.html' %} -#set:EVENT: -
-
- -
@EVENTNAME@
-
-
- -
@ARTIST@
-
-
- -
@PLACE@
-
-
- -
@DATE@
-
-
- -
@TIME@
-
-
- -
@DESCRIPTION@
-
-
- -
@PRICE@ €
-
-
- - -
-
-#endset +{% block title %}{{event.name}}{% endblock %} -
- -
- +{% block page %} -#if:ERROR==true -@ERRORAREA@ -#endif +

{{event.name}}

+ {{event.date}} {{event.time}}, {{event.place}}
+ Artist: {{event.artist}}
+ {{event.description}}
+
+
+ + {% for price in event.prices %} + + + {% endfor %}
Price:Amount:
{{price.price}} ({{price.categoryname}})

+ + - \ No newline at end of file +{% endblock %}