From b3ceed048bb533a00bbea542f7c12b49c8c83d9b Mon Sep 17 00:00:00 2001 From: wei <> Date: Sat, 17 Jun 2006 01:55:05 +0000 Subject: Update changes to active controls, add FT tests for active controls, add comments. --- .../Web/UI/ActiveControls/TBaseActiveControl.php | 49 +++++++++++++++++----- 1 file changed, 38 insertions(+), 11 deletions(-) (limited to 'framework/Web/UI/ActiveControls/TBaseActiveControl.php') diff --git a/framework/Web/UI/ActiveControls/TBaseActiveControl.php b/framework/Web/UI/ActiveControls/TBaseActiveControl.php index 13d953c8..71d50a67 100644 --- a/framework/Web/UI/ActiveControls/TBaseActiveControl.php +++ b/framework/Web/UI/ActiveControls/TBaseActiveControl.php @@ -10,6 +10,8 @@ * @package System.Web.UI.ActiveControls */ +Prado::using('System.Web.UI.ActiveControls.TCallbackClientSideOptions'); + /** * TBaseActiveControl class provided additional basic property for every * active control. An instance of TBaseActiveControl or its decendent @@ -163,42 +165,66 @@ class TBaseActiveCallbackControl extends TBaseActiveControl } return $client; } + + /** + * Sets the client side options. Can only be set when client side is null. + * @param TCallbackClientSideOptions client side options. + */ + public function setClientSide($client) + { + if(is_null($this->getOption('ClientSide'))) + $this->setOption('ClientSide', $client); + else + throw new TConfigurationException( + 'active_controls_client_side_exists', $this->getControl()->getID()); + } /** * @return TCallbackClientSideOptions callback client-side options. */ protected function createClientSideOptions() { - if(($id=$this->getCallbackOptionID())!=='' - && ($control=$this->getControl()->findControl($id))!==null) - { - if($control instanceof TCallbackOptions) - return $control->getClientSide(); - } return new TCallbackClientSideOptions; } /** - * Sets the ID of a TCallbackOptions component to duplicate the client-side + * Sets default callback options. Takes the ID of a TCallbackOptions + * component to duplicate the client-side * options for this control. The {@link getClientSide ClientSide} * subproperties has precendent over the CallbackOptions property. * @param string ID of a TCallbackOptions control from which ClientSide * options are cloned. */ - public function setCallbackOptionID($value) + public function setCallbackOptions($value) { $this->setOption('CallbackOptions', $value, ''); } /** * @return string ID of a TCallbackOptions control from which ClientSide - * options are cloned. + * options are duplicated. */ - public function getCallbackOptionID() + public function getCallbackOptions() { return $this->getOption('CallbackOptions', ''); } + /** + * Returns an array of default callback client-side options. The default options + * are obtained from the client-side options of a TCallbackOptions control with + * ID specified by {@link setCallbackOptionsID CallbackOptionsID}. + * @return array list of default callback client-side options. + */ + protected function getDefaultClientSideOptions() + { + if(($id=$this->getCallbackOptions())!=='' + && ($control=$this->getControl()->findControl($id))!==null + && $control instanceof TCallbackOptions) + return $control->getClientSide()->getOptions()->toArray(); + else + return array(); + } + /** * @return boolean whether callback event trigger by this button will cause * input validation, default is true @@ -255,7 +281,8 @@ class TBaseActiveCallbackControl extends TBaseActiveControl */ protected function getClientSideOptions() { - $options = $this->getClientSide()->getOptions()->toArray(); + $default = $this->getDefaultClientSideOptions(); + $options = array_merge($default,$this->getClientSide()->getOptions()->toArray()); $validate = $this->getCausesValidation(); $options['CausesValidation']= $validate ? '' : false; $options['ValidationGroup']=$this->getValidationGroup(); -- cgit v1.2.3