From 03dbe16b7762cc1a9e57df4e9e34bc04f46bb57f Mon Sep 17 00:00:00 2001 From: wei <> Date: Tue, 3 Apr 2007 01:38:15 +0000 Subject: update js onclick handler context for controls with js counterpart. --- framework/Data/ActiveRecord/TActiveRecord.php | 2 +- .../Data/ActiveRecord/TActiveRecordCriteria.php | 24 ++++++++++++++++++++++ .../Data/ActiveRecord/TActiveRecordGateway.php | 2 ++ .../Vendor/TSqliteMetaDataInspector.php | 4 ++-- .../Data/SqlMap/Statements/TCachingStatement.php | 6 +++--- framework/Web/Javascripts/js/compressed/prado.js | 2 +- framework/Web/Javascripts/js/debug/prado.js | 2 +- .../Web/Javascripts/prado/controls/controls.js | 2 +- 8 files changed, 35 insertions(+), 9 deletions(-) (limited to 'framework') diff --git a/framework/Data/ActiveRecord/TActiveRecord.php b/framework/Data/ActiveRecord/TActiveRecord.php index 109ae9a6..54aef3f3 100644 --- a/framework/Data/ActiveRecord/TActiveRecord.php +++ b/framework/Data/ActiveRecord/TActiveRecord.php @@ -520,7 +520,7 @@ abstract class TActiveRecord extends TComponent $search = implode('|', $meta->getColumnNames()); $regexp = '/('.$search.')(and|_and_|or|_or_)?/i'; $matches = array(); - if(!preg_match_all($regexp, strtolower($condition), $matches,PREG_SET_ORDER)) + if(!preg_match_all($regexp, $condition, $matches,PREG_SET_ORDER)) { throw new TActiveRecordException('ar_mismatch_column_names', $method, implode(', ', $meta->getColumnNames()), $meta->getTableName()); diff --git a/framework/Data/ActiveRecord/TActiveRecordCriteria.php b/framework/Data/ActiveRecord/TActiveRecordCriteria.php index 533ff50a..134632e8 100644 --- a/framework/Data/ActiveRecord/TActiveRecordCriteria.php +++ b/framework/Data/ActiveRecord/TActiveRecordCriteria.php @@ -149,6 +149,30 @@ class TActiveRecordCriteria extends TComponent $this->_offset=$value; } + /** + * This method is invoked before the object is deleted from the database. + * The method raises 'OnDelete' event. + * If you override this method, be sure to call the parent implementation + * so that the event handlers can be invoked. + * @param TActiveRecordEventParameter event parameter to be passed to the event handlers + */ + public function onDelete($param) + { + $this->raiseEvent('OnDelete', $this, $param); + } + + /** + * This method is invoked before any select query is executed on the database. + * The method raises 'OnSelect' event. + * If you override this method, be sure to call the parent implementation + * so that the event handlers can be invoked. + * @param TActiveRecordEventParameter event parameter to be passed to the event handlers + */ + public function onSelect($param) + { + $this->raiseEvent('OnSelect', $this, $param); + } + /** * @return string string representation of the criteria. Useful for debugging. */ diff --git a/framework/Data/ActiveRecord/TActiveRecordGateway.php b/framework/Data/ActiveRecord/TActiveRecordGateway.php index f9cc5bbd..be9731c5 100644 --- a/framework/Data/ActiveRecord/TActiveRecordGateway.php +++ b/framework/Data/ActiveRecord/TActiveRecordGateway.php @@ -300,6 +300,8 @@ class TActiveRecordGateway extends TComponent $param = new TActiveRecordGatewayEventParameter($type,$command,$record,$data); $manager = $record->getRecordManager(); $event = 'on'.$type; + if($data instanceof TActiveRecordCriteria) + $data->{$event}($param); $manager->{$event}($param); } } diff --git a/framework/Data/ActiveRecord/Vendor/TSqliteMetaDataInspector.php b/framework/Data/ActiveRecord/Vendor/TSqliteMetaDataInspector.php index 1d4599a8..94f0bb72 100644 --- a/framework/Data/ActiveRecord/Vendor/TSqliteMetaDataInspector.php +++ b/framework/Data/ActiveRecord/Vendor/TSqliteMetaDataInspector.php @@ -55,7 +55,7 @@ class TSqliteMetaDataInspector extends TDbMetaDataInspector $command->prepare(); $cols = array(); foreach($command->query() as $col) - $cols[strtolower($col['name'])] = $this->getColumnMetaData($col); + $cols[$col['name']] = $this->getColumnMetaData($col); return $cols; } @@ -73,7 +73,7 @@ class TSqliteMetaDataInspector extends TDbMetaDataInspector $primary = $col['pk']==='1'; $autoIncrement = strtolower($type)==='integer' && $primary; $default = $col['dflt_value']; - return new TSqliteColumnMetaData(strtolower($col['name']),$name,$type, + return new TSqliteColumnMetaData($col['name'],$name,$type, $notNull,$autoIncrement,$default,$primary); } diff --git a/framework/Data/SqlMap/Statements/TCachingStatement.php b/framework/Data/SqlMap/Statements/TCachingStatement.php index 7d0c0824..051a8ec3 100644 --- a/framework/Data/SqlMap/Statements/TCachingStatement.php +++ b/framework/Data/SqlMap/Statements/TCachingStatement.php @@ -45,7 +45,7 @@ class TCachingStatement implements IMappedStatement public function executeQueryForMap($connection, $parameter,$keyProperty, $valueProperty=null, $delegate=null) { $sql = $this->createCommand($connection, $parameter); - $key = $this->getCacheKey(array($sql, $keyProperty, $valueProperty)); + $key = $this->getCacheKey(array(clone($sql), $keyProperty, $valueProperty)); $map = $this->getStatement()->getCache()->get($key); if(is_null($map)) { @@ -69,7 +69,7 @@ class TCachingStatement implements IMappedStatement public function executeQueryForList($connection, $parameter, $result=null, $skip=-1, $max=-1, $delegate=null) { $sql = $this->createCommand($connection, $parameter); - $key = $this->getCacheKey(array($sql, $skip, $max)); + $key = $this->getCacheKey(array(clone($sql), $parameter, $skip, $max)); $list = $this->getStatement()->getCache()->get($key); if(is_null($list)) { @@ -83,7 +83,7 @@ class TCachingStatement implements IMappedStatement public function executeQueryForObject($connection, $parameter, $result=null) { $sql = $this->createCommand($connection, $parameter); - $key = $this->getCacheKey($sql); + $key = $this->getCacheKey(array(clone($sql), $parameter)); $object = $this->getStatement()->getCache()->get($key); if(is_null($object)) { diff --git a/framework/Web/Javascripts/js/compressed/prado.js b/framework/Web/Javascripts/js/compressed/prado.js index 55651927..7c2c3ea6 100644 --- a/framework/Web/Javascripts/js/compressed/prado.js +++ b/framework/Web/Javascripts/js/compressed/prado.js @@ -462,7 +462,7 @@ var newdate=new Date(year,month-1,date,0,0,0);return newdate;}});Prado.WebUI=Cla {if(this.onInit) this.onInit(options);}},onInit:function(options) {if(typeof(this.element.onclick)=="function") -{this._elementOnClick=this.element.onclick;this.element.onclick=null;} +{this._elementOnClick=this.element.onclick.bind(this.element);;this.element.onclick=null;} Event.observe(this.element,"click",this.elementClicked.bindEvent(this,options));},elementClicked:function(event,options) {var src=Event.element(event);var doPostBack=true;var onclicked=null;if(this._elementOnClick) {var onclicked=this._elementOnClick(event);if(typeof(onclicked)=="boolean") diff --git a/framework/Web/Javascripts/js/debug/prado.js b/framework/Web/Javascripts/js/debug/prado.js index d1a04f4f..03c271af 100644 --- a/framework/Web/Javascripts/js/debug/prado.js +++ b/framework/Web/Javascripts/js/debug/prado.js @@ -4447,7 +4447,7 @@ Prado.WebUI.PostBackControl.prototype = { if(typeof(this.element.onclick)=="function") { - this._elementOnClick = this.element.onclick; + this._elementOnClick = this.element.onclick.bind(this.element);; this.element.onclick = null; } Event.observe(this.element, "click", this.elementClicked.bindEvent(this,options)); diff --git a/framework/Web/Javascripts/prado/controls/controls.js b/framework/Web/Javascripts/prado/controls/controls.js index 64fb1a30..ff40b0e8 100644 --- a/framework/Web/Javascripts/prado/controls/controls.js +++ b/framework/Web/Javascripts/prado/controls/controls.js @@ -20,7 +20,7 @@ Prado.WebUI.PostBackControl.prototype = { if(typeof(this.element.onclick)=="function") { - this._elementOnClick = this.element.onclick; + this._elementOnClick = this.element.onclick.bind(this.element); this.element.onclick = null; } Event.observe(this.element, "click", this.elementClicked.bindEvent(this,options)); -- cgit v1.2.3