From ec41f13012ca7c8ca67e1c1992368a5dee2a9624 Mon Sep 17 00:00:00 2001 From: xue <> Date: Thu, 17 Nov 2005 22:41:18 +0000 Subject: --- framework/Exceptions/messages.en | 7 +++++++ framework/TComponent.php | 22 ++++++++++++---------- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/framework/Exceptions/messages.en b/framework/Exceptions/messages.en index f1f6c9ad..136fe3df 100644 --- a/framework/Exceptions/messages.en +++ b/framework/Exceptions/messages.en @@ -1,4 +1,11 @@ component_property_undefined = Component property '%s.%s' is not defined. +component_property_readonly = Component property '%s.%s' is read-only. +component_event_undefined = Component event '%s.%s' is not defined. +component_eventhandler_invalid = Component event '%s.%s' is attached with an invalid event handler. +component_expression_invalid = Component '%s' is evaluating an invalid expression '%s' : %s. +component_statements_invalid = Component '%s' is evaluating invalid PHP statements '%s' : %s. + +propertyvalue_enumvalue_invalid = Value '%s' is a not valid enumeration value (%s). application_configfile_inexistent = Application configuration file "%s" does not exist. application_module_existing = Application module "%s" cannot be registered twice. diff --git a/framework/TComponent.php b/framework/TComponent.php index b91afb2d..3934bfdc 100644 --- a/framework/TComponent.php +++ b/framework/TComponent.php @@ -1,6 +1,6 @@ * @link http://www.pradosoft.com/ @@ -355,7 +355,7 @@ class TComponent } } else - throw new TInvalidDataValueException('component_event_handler_invalid',$handler); + throw new TInvalidDataValueException('component_eventhandler_invalid',get_class($this),$name); } } else if(!$this->hasEvent($name)) @@ -377,7 +377,7 @@ class TComponent } catch(Exception $e) { - throw new TInvalidOperationException('component_expression_invalid',$expression,$e->getMessage()); + throw new TInvalidOperationException('component_expression_invalid',get_class($this),$expression,$e->getMessage()); } } @@ -400,7 +400,7 @@ class TComponent } catch(Exception $e) { - throw new TInvalidOperationException('component_statements_invalid',$statements,$e->getMessage()); + throw new TInvalidOperationException('component_statements_invalid',get_class($this),$statements,$e->getMessage()); } } } @@ -427,7 +427,9 @@ class TComponent * string 'false' (case-insensitive) will be converted to false. * - integer * - float - * - array + * - array: string starting with '(' and ending with ')' will be considered as + * as an array expression and will be evaluated. Otherwise, an array + * with the value to be ensured is returned. * - object * - enum: enumerable type, represented by an array of strings. * @@ -494,24 +496,24 @@ class TPropertyValue * in the form (a,b,c) then an array consisting of each of the elements * will be returned. If the value is a string and it is not in this form * then an array consisting of just the string will be returned. If the value - * is not a string then + * is not a string then * @param mixed the value to be converted. * @return array */ public static function ensureArray($value) { - if(is_string($value)) + if(is_string($value)) { $trimmed = trim($value); $len = strlen($value); - if ($len >= 2 && $trimmed[0] == '(' && $trimmed[$len-1] == ')') + if ($len >= 2 && $trimmed[0] == '(' && $trimmed[$len-1] == ')') { eval('$array=array'.$trimmed.';'); return $array; } else return $len>0?array($value):array(); - } + } else return (array)$value; } @@ -539,7 +541,7 @@ class TPropertyValue if(($index=array_search($value,$enum))!==false) return $enum[$index]; else - throw new TInvalidDataValueException('propertyvalue_enumvalue_invalid',$value,implode(',',$enum)); + throw new TInvalidDataValueException('propertyvalue_enumvalue_invalid',$value,implode(' | ',$enum)); } } -- cgit v1.2.3