From c29fa08c41c2774f2e4c4b3aa0dfa7a0ade86e7c Mon Sep 17 00:00:00 2001 From: xue <> Date: Mon, 2 Apr 2007 01:26:38 +0000 Subject: fixed the issue that Event handler specified via subproperty in template does not work --- HISTORY | 1 + framework/TComponent.php | 12 +++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/HISTORY b/HISTORY index 0607aa9f..8638442c 100644 --- a/HISTORY +++ b/HISTORY @@ -6,6 +6,7 @@ BUG: Ticket#505 - cultureInfo::getEnglishName does not return an arrary (Wei) BUG: Ticket#508 - CultureInfo class: PHP Notice because of missing static declaration (Wei) BUG: Ticket#558 - TRadionButtonList generates a empty onclick attribute (Qiang) BUG: Ticket#573 - NumberFormat Bug (Wei) +BUG: Event handler specified via subproperty in template does not work (Qiang) ENH: Ticket#367 - Change default extension for XLIFF files (Wei, changed to support .xlf extension). ENH: Upgraded javascript library Prototype to version 1.5.0 (Wei) ENH: Upgraded javascript library Scriptaculous to version 1.7.0 (Wei) diff --git a/framework/TComponent.php b/framework/TComponent.php index 54fe7ec7..79732290 100644 --- a/framework/TComponent.php +++ b/framework/TComponent.php @@ -345,7 +345,17 @@ class TComponent { if(is_string($handler)) { - call_user_func($handler,$sender,$param); + if(($pos=strrpos($handler,'.'))!==false) + { + $object=$this->getSubProperty(substr($handler,0,$pos)); + $method=substr($handler,$pos+1); + if(method_exists($object,$method)) + $object->$method($sender,$param); + else + throw new TInvalidDataValueException('component_eventhandler_invalid',get_class($this),$name); + } + else + call_user_func($handler,$sender,$param); } else if(is_callable($handler,true)) { -- cgit v1.2.3