From: konrad Date: Sat, 10 Jul 2010 05:14:27 +0000 (+0000) Subject: link TZ lib X-Git-Url: http://git.silmor.de/gitweb/?a=commitdiff_plain;h=793d81435cdc3652e450675a497a793de92fa61c;p=web%2Fkonrad%2Fsmoke.git link TZ lib remove TZ transition stuff from GetLanguage - client is expected to have a local TZDB git-svn-id: https://silmor.de/svn/softmagic/smoke/trunk@552 6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33 --- diff --git a/src/libs.pri b/src/libs.pri index 9dbd1cf..56c723c 100644 --- a/src/libs.pri +++ b/src/libs.pri @@ -1,4 +1,4 @@ # Libraries for Magic Smoke by (c) Konrad Rosenbaum, 2007-2010 -LIBS += -L../zip -lzip -L../pack/qtbase -lqwbase -INCLUDEPATH += ../zip ../pack/qtbase +LIBS += -L../zip -lzip -L../pack/qtbase -lqwbase -L../tzone -ltzdata +INCLUDEPATH += ../zip ../pack/qtbase ../tzone diff --git a/src/misc/misc.cpp b/src/misc/misc.cpp index 65551cc..6206874 100644 --- a/src/misc/misc.cpp +++ b/src/misc/misc.cpp @@ -622,7 +622,7 @@ qint64 MLocalFormat::localTime2unix(QDateTime ) const //TODO!! } -void MLocalFormat::setTimeZone(QString olsenname, QList< MOTimeTransition > transitions) +void MLocalFormat::setTimeZone(QString olsenname) { //TODO!! } diff --git a/src/misc/misc.h b/src/misc/misc.h index b7a7b41..673e294 100644 --- a/src/misc/misc.h +++ b/src/misc/misc.h @@ -128,7 +128,7 @@ class MLocalFormat /**overrides the local time zone \param olsenname the name of the local timezone in olsen notation, eg. "Europe/Berlin" \param transitions a list of time transitions, if missing the system attempts to locate the transition DB itself*/ - virtual void setTimeZone(QString olsenname,QList transitions=QList()); + virtual void setTimeZone(QString olsenname); /**overrides the formatting to be non-localized, numbers use decimal dot and no thousand separator, no currency symbol and "-" as negative sign; otherwise things stay the same; this is a helper for the shortcut methods like cent2str*/ virtual void setNonLocalized(); diff --git a/wob/classes/basics.wolf b/wob/classes/basics.wolf index 35a2826..6da4cb5 100644 --- a/wob/classes/basics.wolf +++ b/wob/classes/basics.wolf @@ -14,13 +14,13 @@ - + Transport class for server formatting settings. This is used by both UIs to format numbers, dates, money, etc. The XML version of it is stored in the template directory, distributed between main and language dependent directory. @@ -41,6 +41,6 @@ The currency used One or two characters: for negative money values the first one is placed in front of the money value and the second one behind the money value Olsen database time zone name - list of all precalculated transitions in this timezone, how far into the future calculations go depends on the server, usually at the moment till 2037 + diff --git a/wob/transact/basics.wolf b/wob/transact/basics.wolf index 128fe6f..2932c4f 100644 --- a/wob/transact/basics.wolf +++ b/wob/transact/basics.wolf @@ -17,7 +17,7 @@ - This transaction returns basic language and formatting settings from the server - it must be used before the client displays any times or monetary values, even if it does not indend to translate any strings. + This transaction returns basic language and formatting settings from the server - it must be used before the client displays any times or monetary values, even if it does not indend to translate any strings. If the transaction fails on the first attempt (eg. because the language could not be found), the client MUST repeat the request with "C" as language to retrieve formatting rules - "C" as language MUST succeed on the server, regardless of any other settings. The language that the client wants to use, use "C" for no translation wanted. The translation file format that the client supports: either "ts" for Qt translation XML source files, or "qm" for translated binary Qt translation files. diff --git a/www/inc/machine/translation.php b/www/inc/machine/translation.php index 53545bc..a1718d9 100644 --- a/www/inc/machine/translation.php +++ b/www/inc/machine/translation.php @@ -19,9 +19,9 @@ class Translation $nlst=explode("_",trim($trans->getlanguage())); //set format object if(count($nlst)>0) - $trans->setformats(new ServerFormat($nlst[0])); + $trans->setformats(new WOServerFormat($nlst[0])); else - $trans->setformats(new ServerFormat(); + $trans->setformats(new WOServerFormat()); //if this is "C", abort parsing and return if(strtolower(trim($trans->getlanguage()))=="c") return; @@ -31,7 +31,7 @@ class Translation $trans->abortWithError(translate("Translation","Format must be either 'ts' or 'qm'.")); //does the syntax match? foreach($nlst as $nm) - if(!ereg("^[a-zA-Z]{1,3}$",$nm)) + if(!preg_match("/^[a-zA-Z]{1,3}$/",$nm)) $trans->abortWithError(translate("Translation","Language invalid.")); //find the longest match for language for($i=count($nlst);$i>0;$i--){ diff --git a/www/inc/wext/format.php b/www/inc/wext/format.php index 092cd56..3458db3 100644 --- a/www/inc/wext/format.php +++ b/www/inc/wext/format.php @@ -19,7 +19,7 @@ class WOServerFormat extends WOServerFormatAbstract parent::__construct(); global $template; $this->loadConfig($template."/format.cfg"); - if($lang!="") + if($lang!="" && preg_match('/^[a-zA-Z0-9_-]+$/',$lang)) $this->loadConfig($template."/".$lang."/format.cfg"); } @@ -57,27 +57,11 @@ class WOServerFormat extends WOServerFormatAbstract case "moneydecimals":$this->setmoneydecimals($val);break; case "currencysymbol":$this->setcurrencysymbol($val);break; case "moneynegative":$this->setmoneynegative($val);break; - case "timezone":$this->settimezone($val);$this->loadtimezone();break; + case "timezone":$this->settimezone($val);break; default: die("Unknown keyword in format config $file line ".($num+1));break; } } } - - /** \internal helper for loadConfig to initialize timezone transitions*/ - protected function loadtimezone() - { - $dtz=new DateTimeZone($this->prop_timezone); - $tr=array(); - foreach($dtz->getTransitions() as $tran){ - $t=new WOTimeTransition; - $t->setts($tran["ts"]); - $t->setoffset($tran["offset"]); - $t->setabbr($tran["abbr"]); - $t->setisdst($tran["isdst"]); - $tr[]=$t; - } - $this->prop_TZtransitions=$tr; - } } ?> \ No newline at end of file