From 13ef18b37b46898d1fd93238774a1d15b9ecf46a Mon Sep 17 00:00:00 2001 From: xue <> Date: Tue, 18 Jul 2006 20:13:59 +0000 Subject: Fixed #287. --- HISTORY | 1 + UPGRADE | 4 ++++ framework/Web/UI/TControl.php | 32 +++++++++++++++++++++----------- 3 files changed, 26 insertions(+), 11 deletions(-) diff --git a/HISTORY b/HISTORY index 1cfcadb1..e32f7185 100644 --- a/HISTORY +++ b/HISTORY @@ -8,6 +8,7 @@ ENH: Ticket#220 - TClientScripts method to import custom javascript files (Wei) ENH: Ticket#225 - TRadioButton::getRadioButtonsInGroup() added (Wei) ENH: Ticket#223 - Use TRequiredFieldValidator for TRadioButtons with GroupName property (Wei) ENH: Ticket#277 - Added TControl.CustomData property (Qiang) +ENH: Ticket#287 - TControl::broadcastEvent() may raise events now (Qiang) NEW: Added TStyleSheet (Wei) Version 3.0.2 July 2, 2006 diff --git a/UPGRADE b/UPGRADE index c4df2888..ae0fcf6b 100644 --- a/UPGRADE +++ b/UPGRADE @@ -16,6 +16,10 @@ for both A and B. Upgrading from v3.0.2 --------------------- +- The signature of TControl::broadcastEvent() is changed from + broadcastEvent($sender,TBroadCastEventParameter $param) to + broadcastEvent($name,$sender,$param). + This makes the call to broadcastEvent() to be consistent with raiseEvent(). Upgrading from v3.0.1 --------------------- diff --git a/framework/Web/UI/TControl.php b/framework/Web/UI/TControl.php index ff4a85ea..01c57795 100644 --- a/framework/Web/UI/TControl.php +++ b/framework/Web/UI/TControl.php @@ -1368,30 +1368,40 @@ class TControl extends TApplicationComponent implements IRenderable, IBindable return false; } + /** * Broadcasts an event. * The event will be sent to all controls on the current page hierarchy. - * If this control is not on a page, the event will be sent to all its - * child controls recursively. - * Controls implementing {@link IBroadcastEventReceiver} will get a chance - * to respond to the event. - * @param TControl sender of the event - * @param TBroadcastEventParameter event parameter + * If a control defines the event, the event will be raised for the control. + * If a control implements {@link IBroadcastEventReceiver}, its + * {@link IBroadcastEventReceiver::broadcastEventReceived broadcastEventReceived()} method will + * be invoked which gives the control a chance to respond to the event. + * For example, when broadcasting event 'OnClick', all controls having 'OnClick' + * event will have this event raised, and all controls implementing + * {@link IBroadcastEventReceiver} will also have its + * {@link IBroadcastEventReceiver::broadcastEventReceived broadcastEventReceived()} + * invoked. + * @param string name of the broadcast event + * @param TControl sender of this event + * @param TEventParameter event parameter */ - protected function broadcastEvent($sender,TBroadCastEventParameter $param) + protected function broadcastEvent($name,$sender,$param) { - $origin=(($page=$this->getPage())===null)?$this:$page; - $origin->broadcastEventInternal($sender,$param); + $rootControl=(($page=$this->getPage())===null)?$this:$page; + $rootControl->broadcastEventInternal($name,$sender,new TBroadcastEventParameter($name,$param)); } /** * Recursively broadcasts an event. * This method should only be used by framework developers. + * @param string name of the broadcast event * @param TControl sender of the event * @param TBroadcastEventParameter event parameter */ - final protected function broadcastEventInternal($sender,$param) + final protected function broadcastEventInternal($name,$sender,$param) { + if($this->hasEvent($name)) + $this->raiseEvent($name,$sender,$param->getParameter()); if($this instanceof IBroadcastEventReceiver) $this->broadcastEventReceived($sender,$param); if($this->getHasControls()) @@ -1399,7 +1409,7 @@ class TControl extends TApplicationComponent implements IRenderable, IBindable foreach($this->_rf[self::RF_CONTROLS] as $control) { if($control instanceof TControl) - $control->broadcastEventInternal($sender,$param); + $control->broadcastEventInternal($name,$sender,$param); } } } -- cgit v1.2.3