From: konrad Date: Sun, 9 Aug 2009 15:38:20 +0000 (+0000) Subject: getallevents works again X-Git-Url: http://git.silmor.de/gitweb/?a=commitdiff_plain;h=ecbdf43d27551be92866423724d04315d4ad2e44;p=web%2Fkonrad%2Fsmoke.git getallevents works again git-svn-id: https://silmor.de/svn/softmagic/smoke/trunk@326 6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33 --- diff --git a/src/event.cpp b/src/event.cpp index fe1a8a6..e81f4a6 100644 --- a/src/event.cpp +++ b/src/event.cpp @@ -33,7 +33,7 @@ QRegExp MEvent::priceRegExp()const QString MEvent::priceString()const { - qint64 dp=defaultprice(); + qint64 dp=/*defaultprice()*/0; QString ret=QString::number(dp/100); ret+=QCoreApplication::translate("MEvent",".","price decimal dot"); ret+=QString::number((dp/10)%10); diff --git a/src/event.h b/src/event.h index c684946..e5b9f7b 100644 --- a/src/event.h +++ b/src/event.h @@ -57,7 +57,7 @@ class MEvent:public MOEvent void setdefaultprice(QString); //inherit alternative definition - inline void setdefaultprice(qint64 p){MOEvent::setdefaultprice(p);} + inline void setdefaultprice(qint64 p){/*MOEvent::setdefaultprice(p);*/} /**returns whether the event is valid. an event can be invalid if it is uninitialized (negative ID) or the server request failed*/ //bool isValid()const{return m_valid;} diff --git a/src/eventedit.cpp b/src/eventedit.cpp index 3c4b663..2b73b75 100644 --- a/src/eventedit.cpp +++ b/src/eventedit.cpp @@ -68,7 +68,7 @@ MEventEditor::MEventEditor(QWidget*w,qint64 id) gl->addWidget(lab=new QLabel(tr("Artist:")),++lctr,0); lab->setAlignment(Qt::AlignRight|Qt::AlignVCenter); gl->addWidget(artist=new QLineEdit,lctr,1); - artist->setText(event.artist()); + artist->setText(event.artist().value().name()); gl->addWidget(lab=new QLabel(tr("Description:")),++lctr,0); lab->setAlignment(Qt::AlignRight|Qt::AlignVCenter); @@ -113,10 +113,10 @@ MEventEditor::MEventEditor(QWidget*w,qint64 id) price->setText(event.priceString()); gl->addWidget(cancelcheck=new QCheckBox(tr("Event Cancelled:")),++lctr,0); - cancelcheck->setChecked(event.cancelled()); + cancelcheck->setChecked(event.iscancelled()); cancelcheck->setEnabled(false); gl->addWidget(cancelreason=new QLineEdit,lctr,1); - cancelreason->setEnabled(event.cancelled()); + cancelreason->setEnabled(event.iscancelled()); cancelreason->setText(event.cancelreason()); connect(cancelcheck,SIGNAL(toggled(bool)),cancelreason,SLOT(setEnabled(bool))); @@ -137,10 +137,10 @@ void MEventEditor::writeBack() event.settitle(title->text()); event.setstart(starttime->dateTime().toTime_t()); event.setend(endtime->dateTime().toTime_t()); - event.setartist(artist->text()); +// event.setartist(artist->text()); event.setroom(room->text()); event.setdefaultprice(price->text()); - event.setcancelled(cancelcheck->isChecked()); + event.setiscancelled(cancelcheck->isChecked()); event.setcancelreason(cancelreason->text()); event.setdescription(description->toPlainText()); event.setcapacity(capacity->value()); diff --git a/src/eventsummary.cpp b/src/eventsummary.cpp index ba5206c..70caf5a 100644 --- a/src/eventsummary.cpp +++ b/src/eventsummary.cpp @@ -49,7 +49,7 @@ MEventSummary::MEventSummary(QWidget*par,qint64 eid) gl->addWidget(new QLabel(tr("Title:")),rc,0); gl->addWidget(new QLabel(event.title()),rc,1); gl->addWidget(new QLabel(tr("Artist:")),++rc,0); - gl->addWidget(new QLabel(event.artist()),rc,1); + gl->addWidget(new QLabel(event.artist().value().name()),rc,1); gl->addWidget(new QLabel(tr("Start:")),++rc,0); gl->addWidget(new QLabel(event.startTimeString()),rc,1); gl->addWidget(new QLabel(tr("Capacity:")),++rc,0); @@ -212,7 +212,7 @@ void MEventSummary::getVariable(QString varname,MOdtRenderer::VarType&av,QVarian value=event.title().value(); else if(varname=="ARTIST") - value=event.artist().value(); + value=event.artist().value().name().value(); else if(varname=="ROOM") value=event.room().value(); @@ -266,7 +266,7 @@ void MEventSummary::getVariable(QString varname,MOdtRenderer::VarType&av,QVarian av=MOdtRenderer::IntVar; }else if(varname=="EVENTPRICE"){ - value=event.defaultprice().value(); + value=/*event.defaultprice().value()*/(int)1; av=MOdtRenderer::MoneyVar; } } diff --git a/src/orderwin.cpp b/src/orderwin.cpp index 945b9e5..04e4d91 100644 --- a/src/orderwin.cpp +++ b/src/orderwin.cpp @@ -540,7 +540,7 @@ void MOrderWindow::getLoopVariable(QString loopname,int it,QString vn,MOdtRender }else if(vn=="ID")value=tickets[it].ticketid().value();else if(vn=="TITLE")value=tickets[it].event().title().value();else - if(vn=="ARTIST")value=tickets[it].event().artist().value();else + if(vn=="ARTIST")value=tickets[it].event().artist().value().name().value();else if(vn=="DATE"){ value=tickets[it].event().start().value(); av=MOdtRenderer::DateVar; @@ -567,7 +567,7 @@ void MOrderWindow::getLoopVariable(QString loopname,int it,QString vn,MOdtRender av=MOdtRenderer::MoneyVar; }else if(vn=="TITLE")value=tickets[it].proto.event().title().value();else - if(vn=="ARTIST")value=tickets[it].proto.event().artist().value();else + if(vn=="ARTIST")value=tickets[it].proto.event().artist().value().name().value();else if(vn=="DATE"){ value=tickets[it].proto.event().start().value(); av=MOdtRenderer::DateVar; diff --git a/src/ticketrender.cpp b/src/ticketrender.cpp index 5fb3db8..8e5b9d4 100644 --- a/src/ticketrender.cpp +++ b/src/ticketrender.cpp @@ -527,7 +527,7 @@ QString MTicketLabel::getVariable(QString var)const if(var=="DATETIME")return tick.event().startTimeString(); if(var=="ROOM")return tick.event().room(); if(var=="TITLE")return tick.event().title(); - if(var=="ARTIST")return tick.event().artist(); + if(var=="ARTIST")return tick.event().artist().value().name(); return ""; } diff --git a/src/wbase/nullable.h b/src/wbase/nullable.h index 3b90ed3..ec11c9d 100644 --- a/src/wbase/nullable.h +++ b/src/wbase/nullable.h @@ -17,7 +17,7 @@ templateclass Nullable { public: - Nullable(){isnull=true;} + Nullable(){isnull=true;elem=T();} Nullable(const T&t){isnull=false;elem=t;} Nullable(const Nullable&t){isnull=t.isnull;elem=t.elem;} diff --git a/wob/event.wolf b/wob/event.wolf index 615584d..dd11253 100644 --- a/wob/event.wolf +++ b/wob/event.wolf @@ -42,7 +42,7 @@ - + @@ -68,14 +68,29 @@ + + + + + + + + + + + + + + + - + - + @@ -91,8 +106,8 @@ - - + + diff --git a/woc/phpout.cpp b/woc/phpout.cpp index dd55d22..2de7e4a 100644 --- a/woc/phpout.cpp +++ b/woc/phpout.cpp @@ -268,6 +268,9 @@ void WocPHPServerOut::newClass(const WocClass&cls) QString code="class "+cna+" extends "+cls.serverBaseClass()+"{\n\n"; tf.write(code.toAscii()); + //property declaration and constructor + tf.write(classConstruct(cls).toAscii()); + //enums tf.write(classEnums(cls).toAscii()); @@ -291,6 +294,23 @@ void WocPHPServerOut::newClass(const WocClass&cls) tf.close(); } +QString WocPHPServerOut::classConstruct(const WocClass&cls) +{ + QString code; + QStringList k=cls.propertyNames(); + for(int i=0;i >map=cls.mapping(k[i]); for(int j=0;j"+map[j].first+";\n"; + code+="\t$data->prop_"+map[j].second+"=$table->"+map[j].first+";\n"; } - code+="\treturn new WO"+cls.name()+"($data);\n}\n"; + code+="\treturn $data;\n}\n"; code+="static public function fromTableArray"+k[i]+"(array $table){\n\t$ret=array();\n"; code+="\tfor($i=0;$isetAttribute(\""+prop+"\",$this->getstr_"+prop+"());\n"; + return code+"\t$root->setAttribute(\""+prop+"\",$this->getstr_"+prop+"());\n"; //is it an element? if(cls.propertyIsElement(prop)) - return "\t$root->appendChild($xml->createElement(\""+prop+"\",xq($this->getstr_"+prop+"())));\n"; + return code+"\t$root->appendChild($xml->createElement(\""+prop+"\",xq($this->getstr_"+prop+"())));\n"; //is it a class? if(cls.propertyIsObject(prop)) - return "\t$root->appendChild($this->get_"+prop+"()->toXml($xml,\""+prop+"\"));\n"; + return code+"$root->appendChild($p->toXml($xml,\""+prop+"\"));\n"; //anything else? qDebug("Warning: end of WocPHPServerOut::propertyToXml - this code should not be reachable."); return "//internal generator error!\n"; @@ -684,12 +707,12 @@ void WocPHPServerOut::newTransaction(const WocTransaction&trn) case WocTransaction::Checked: code+="\t/*security check: authenticated and authorized*/\n"; code+="\t"+m_authinit+";\n"; - code+="\tif(!"+m_isauth+"||!"+QString(m_hasrole).replace("%","\""+trn.name()+"\"")+")notAuthenticated();\n"; + code+="\tif(!"+m_isauth+"||!"+QString(m_hasrole).replace("%","\""+trn.name()+"\"")+")$this->notAuthenticated();\n"; break; case WocTransaction::Auth: code+="\t/*security check: authenticated*/\n"; code+="\t"+m_authinit+";\n"; - code+="\tif(!"+m_isauth+")notAuthenticated();\n"; + code+="\tif(!"+m_isauth+")$this->notAuthenticated();\n"; break; default: code+="\t/*no security check, open function*/\n"; @@ -699,7 +722,7 @@ void WocPHPServerOut::newTransaction(const WocTransaction&trn) //parse low level XML code+="\t/*low level XML parsing*/\n"; code+="\tglobal $HTTP_RAW_POST_DATA;\n\tif(isset($HTTP_RAW_POST_DATA))$txt=$HTTP_RAW_POST_DATA;else $txt=\"\";\n"; - code+="\t$xml=new DOMDocument;\n\tif(!$xml->loadXML($txt))xmlParserError();\n"; + code+="\t$xml=new DOMDocument;\n\tif(!$xml->loadXML($txt))$this->xmlParserError();\n"; code+="\t$root=$xml->documentElement;\n"; //parse inputs @@ -708,7 +731,7 @@ void WocPHPServerOut::newTransaction(const WocTransaction&trn) //call if(trn.hasCall("php")){ code+="\t/*call actual functionality:*/\n"; - code+="\ttry{"+trn.callFunction("php")+"}catch(Exception $e){handleException($e);}\n"; + code+="\ttry{"+trn.callFunction("php")+"}catch(Exception $e){$this->handleException($e);}\n"; }else{ code+="\t/*normally here would be the PHP call, but it is missing from the config*/\n"; qDebug("Warning: transaction %s does not have a PHP call!",trn.name().toAscii().data()); @@ -815,7 +838,7 @@ QString WocPHPServerOut::trnInput(const WocTransaction&trn) } } } - code+="\t}catch(Exception $e){handleException($e);}\n"; + code+="\t}catch(Exception $e){$this->handleException($e);}\n"; code+="\t/*end of input parsing*/\n"; return code; } @@ -855,7 +878,7 @@ QString WocPHPServerOut::trnOutput(const WocTransaction&trn) code+="\t\t$xml->appendChild($root);\n"; code+="\t\theader(\"X-WobResponse-Status: Ok\");\n"; code+="\t\tprint($xml->saveXml());\n"; - code+="\t}catch(Exception $e){handleException($e);}\n"; + code+="\t}catch(Exception $e){$this->handleException($e);}\n"; code+="\t/*end of output*/\n"; return code; } diff --git a/woc/phpout.h b/woc/phpout.h index 8fea498..b3dba00 100644 --- a/woc/phpout.h +++ b/woc/phpout.h @@ -38,6 +38,8 @@ class WocPHPServerOut:public WocOutput /**helper: generates PHP code to transform a class property to XML*/ QString propertyToXml(const WocClass&,QString); + /**helper: generate class constructor*/ + QString classConstruct(const WocClass&); /**helper: generate class internal enums*/ QString classEnums(const WocClass&); /**helper: generate class internal props*/ diff --git a/www/inc/wbase/object.php b/www/inc/wbase/object.php index 946fb82..4e27b1e 100644 --- a/www/inc/wbase/object.php +++ b/www/inc/wbase/object.php @@ -10,9 +10,7 @@ // class WObject { - protected $data; - - protected function __construct($d){$this->data=$d;} + protected function __construct(){} };