From ace9c57b1c50709bbe8085e9cf99161a4c574be2 Mon Sep 17 00:00:00 2001 From: wei <> Date: Sun, 28 Jan 2007 01:22:37 +0000 Subject: Fixed TActiveListBox bug. Add more meta for active record. Fix TCallback docs. --- .../Data/ActiveRecord/Vendor/TMysqlColumnMetaData.php | 12 +++++++++++- .../ActiveRecord/Vendor/TMysqlMetaDataInspector.php | 2 +- .../Data/ActiveRecord/Vendor/TPgsqlColumnMetaData.php | 12 +++++++++++- .../ActiveRecord/Vendor/TPgsqlMetaDataInspector.php | 2 +- .../Data/ActiveRecord/Vendor/TSqliteColumnMetaData.php | 12 +++++++++++- .../ActiveRecord/Vendor/TSqliteMetaDataInspector.php | 2 +- framework/Web/UI/ActiveControls/TActiveListBox.php | 4 ++++ framework/Web/UI/ActiveControls/TBaseActiveControl.php | 17 ++++++++++++++++- framework/Web/UI/ActiveControls/TCallback.php | 3 ++- framework/Web/UI/TPage.php | 2 +- 10 files changed, 59 insertions(+), 9 deletions(-) (limited to 'framework') diff --git a/framework/Data/ActiveRecord/Vendor/TMysqlColumnMetaData.php b/framework/Data/ActiveRecord/Vendor/TMysqlColumnMetaData.php index e7e7ceb8..d659851f 100644 --- a/framework/Data/ActiveRecord/Vendor/TMysqlColumnMetaData.php +++ b/framework/Data/ActiveRecord/Vendor/TMysqlColumnMetaData.php @@ -25,6 +25,7 @@ class TMysqlColumnMetaData extends TComponent private $_autoIncrement; private $_default; private $_notNull=true; + private $_property; private $_isPrimary=null; @@ -38,8 +39,9 @@ class TMysqlColumnMetaData extends TComponent * @param string serial name. * @param string default value. */ - public function __construct($name,$type,$notNull,$autoIncrement,$default,$primary) + public function __construct($property, $name,$type,$notNull,$autoIncrement,$default,$primary) { + $this->_property=$property; $this->_name=$name; $this->_type=$type; $this->_notNull=$notNull; @@ -56,6 +58,14 @@ class TMysqlColumnMetaData extends TComponent return $this->_name; } + /** + * @return string column name, used as active record property name + */ + public function getProperty() + { + return $this->_property; + } + public function getPHPType() { switch(strtolower($this->_type)) diff --git a/framework/Data/ActiveRecord/Vendor/TMysqlMetaDataInspector.php b/framework/Data/ActiveRecord/Vendor/TMysqlMetaDataInspector.php index dcbf6ada..5e438e37 100644 --- a/framework/Data/ActiveRecord/Vendor/TMysqlMetaDataInspector.php +++ b/framework/Data/ActiveRecord/Vendor/TMysqlMetaDataInspector.php @@ -51,7 +51,7 @@ class TMysqlMetaDataInspector extends TDbMetaDataInspector $autoIncrement=is_int(strpos(strtolower($col['Extra']), 'auto_increment')); $default = $col['Default']; $primaryKey = $col['Key']==='PRI'; - return new TMysqlColumnMetaData($name,$type,$notNull,$autoIncrement,$default,$primaryKey); + return new TMysqlColumnMetaData($col['Field'],$name,$type,$notNull,$autoIncrement,$default,$primaryKey); } /** diff --git a/framework/Data/ActiveRecord/Vendor/TPgsqlColumnMetaData.php b/framework/Data/ActiveRecord/Vendor/TPgsqlColumnMetaData.php index 1e799aac..a51c435d 100644 --- a/framework/Data/ActiveRecord/Vendor/TPgsqlColumnMetaData.php +++ b/framework/Data/ActiveRecord/Vendor/TPgsqlColumnMetaData.php @@ -26,6 +26,7 @@ class TPgsqlColumnMetaData extends TComponent private $_default; private $_length; private $_notNull=true; + private $_property; private $_isPrimary=null; @@ -39,8 +40,9 @@ class TPgsqlColumnMetaData extends TComponent * @param string serial name. * @param string default value. */ - public function __construct($name,$type,$length,$notNull,$serial,$default) + public function __construct($property,$name,$type,$length,$notNull,$serial,$default) { + $this->_property=$property; $this->_name=$name; $this->_type=$type; $this->_length=$length; @@ -57,6 +59,14 @@ class TPgsqlColumnMetaData extends TComponent return $this->_name; } + /** + * @return string column name, used as active record property name + */ + public function getProperty() + { + return $this->_property; + } + public function getPHPType() { switch(strtolower($this->_type)) diff --git a/framework/Data/ActiveRecord/Vendor/TPgsqlMetaDataInspector.php b/framework/Data/ActiveRecord/Vendor/TPgsqlMetaDataInspector.php index 910b826e..6f787942 100644 --- a/framework/Data/ActiveRecord/Vendor/TPgsqlMetaDataInspector.php +++ b/framework/Data/ActiveRecord/Vendor/TPgsqlMetaDataInspector.php @@ -150,7 +150,7 @@ EOD; $notNull = $col['attnotnull']; $serial = $col['attisserial'] ? $schema.'.'.$this->getSerialName($col['adsrc']) : null; $default = $serial === null && $col['atthasdef'] ? $col['adsrc'] : null; - return new TPgsqlColumnMetaData($name,$type,$length,$notNull,$serial,$default); + return new TPgsqlColumnMetaData($col['attname'],$name,$type,$length,$notNull,$serial,$default); } /** diff --git a/framework/Data/ActiveRecord/Vendor/TSqliteColumnMetaData.php b/framework/Data/ActiveRecord/Vendor/TSqliteColumnMetaData.php index abb50caf..92315a1a 100644 --- a/framework/Data/ActiveRecord/Vendor/TSqliteColumnMetaData.php +++ b/framework/Data/ActiveRecord/Vendor/TSqliteColumnMetaData.php @@ -28,9 +28,11 @@ class TSqliteColumnMetaData extends TComponent private $_autoIncrement; private $_default; private $_primary=false; + private $_property; - public function __construct($name,$type,$notNull,$autoIncrement,$default,$primary) + public function __construct($property,$name,$type,$notNull,$autoIncrement,$default,$primary) { + $this->_property=$property; $this->_name=$name; $this->_type=$type; $this->_notNull=$notNull; @@ -54,6 +56,14 @@ class TSqliteColumnMetaData extends TComponent } } + /** + * @return string column name, used as active record property name + */ + public function getProperty() + { + return $this->_property; + } + /** * @return string quoted column name. */ diff --git a/framework/Data/ActiveRecord/Vendor/TSqliteMetaDataInspector.php b/framework/Data/ActiveRecord/Vendor/TSqliteMetaDataInspector.php index 29bc3b8a..3621c666 100644 --- a/framework/Data/ActiveRecord/Vendor/TSqliteMetaDataInspector.php +++ b/framework/Data/ActiveRecord/Vendor/TSqliteMetaDataInspector.php @@ -73,7 +73,7 @@ class TSqliteMetaDataInspector extends TDbMetaDataInspector $primary = $col['pk']==='1'; $autoIncrement = strtolower($type)==='integer' && $primary; $default = $col['dflt_value']; - return new TSqliteColumnMetaData($name,$type,$notNull,$autoIncrement,$default,$primary); + return new TSqliteColumnMetaData($col['name'],$name,$type,$notNull,$autoIncrement,$default,$primary); } /** diff --git a/framework/Web/UI/ActiveControls/TActiveListBox.php b/framework/Web/UI/ActiveControls/TActiveListBox.php index 21816961..97b28ac7 100644 --- a/framework/Web/UI/ActiveControls/TActiveListBox.php +++ b/framework/Web/UI/ActiveControls/TActiveListBox.php @@ -127,6 +127,10 @@ class TActiveListBox extends TListBox implements IActiveControl, ICallbackEventH { parent::onPreRender($param); $this->getAdapter()->updateListItems(); + $multiple = $this->getIsMultiSelect(); + $id = $this->getUniqueID(); $multi_id = $id.'[]'; + if($multiple) + $this->getPage()->registerPostDataLoader($multi_id); } } diff --git a/framework/Web/UI/ActiveControls/TBaseActiveControl.php b/framework/Web/UI/ActiveControls/TBaseActiveControl.php index 000e896f..ebd9d168 100644 --- a/framework/Web/UI/ActiveControls/TBaseActiveControl.php +++ b/framework/Web/UI/ActiveControls/TBaseActiveControl.php @@ -360,10 +360,17 @@ class TBaseActiveCallbackControl extends TBaseActiveControl * request for this control call the dispatch() method on the * request instance. Example code in javascript * - * request = <%= $this->mycallback->ActiveControl->Javascript %>; + * var request = <%= $this->mycallback->ActiveControl->Javascript %>; * request.setParameter('hello'); * request.dispatch(); //make the callback request. * + * + * Alternatively, + * + * //dispatches immediately + * Prado.Callback("<%= $this->mycallback->UniqueID %>", + * $this->mycallback->ActiveControl->JsCallbackOptions); + * * @return string javascript client-side callback request object (javascript * code) */ @@ -372,6 +379,14 @@ class TBaseActiveCallbackControl extends TBaseActiveControl $client = $this->getPage()->getClientScript(); return $client->getCallbackReference($this->getControl(),$this->getClientSideOptions()); } + + /** + * @param string callback requestion options as javascript code. + */ + public function getJsCallbackOptions() + { + return TJavascript::encode($this->getClientSideOptions()); + } } ?> \ No newline at end of file diff --git a/framework/Web/UI/ActiveControls/TCallback.php b/framework/Web/UI/ActiveControls/TCallback.php index 60bdaf10..47d36d54 100644 --- a/framework/Web/UI/ActiveControls/TCallback.php +++ b/framework/Web/UI/ActiveControls/TCallback.php @@ -29,7 +29,8 @@ Prado::using('System.Web.UI.ActiveControls.TActiveControlAdapter'); * *
Click Me!
diff --git a/framework/Web/UI/TPage.php b/framework/Web/UI/TPage.php index 53c9b03f..96ac6d36 100644 --- a/framework/Web/UI/TPage.php +++ b/framework/Web/UI/TPage.php @@ -846,7 +846,7 @@ class TPage extends TTemplateControl if($control->loadPostData($key,$postData)) $this->_controlsPostDataChanged[]=$control; } - else if($control instanceof IPostBackEventHandler && + else if($control instanceof IPostBackEventHandler && empty($this->_postData[self::FIELD_POSTBACK_TARGET])) { $this->_postData->add(self::FIELD_POSTBACK_TARGET,$key); // not calling setPostBackEventTarget() because the control may be removed later -- cgit v1.2.3