diff options
Diffstat (limited to 'framework/Data')
7 files changed, 750 insertions, 707 deletions
diff --git a/framework/Data/ActiveRecord/Scaffold/InputBuilder/TIbmScaffoldInput.php b/framework/Data/ActiveRecord/Scaffold/InputBuilder/TIbmScaffoldInput.php index 2c315468..f0e2b215 100644 --- a/framework/Data/ActiveRecord/Scaffold/InputBuilder/TIbmScaffoldInput.php +++ b/framework/Data/ActiveRecord/Scaffold/InputBuilder/TIbmScaffoldInput.php @@ -1,51 +1,52 @@ -<?php
-/**
- * TIbmScaffoldInput class file.
- *
- * @author Cesar Ramos <cramos[at]gmail[dot]com>
- * @link http://www.pradosoft.com/
- * @copyright Copyright © 2005-2007 PradoSoft
- * @license http://www.pradosoft.com/license/
- */
-Prado::using('System.Data.ActiveRecord.Scaffold.InputBuilder.TScaffoldInputCommon');
-
-class TIbmScaffoldInput extends TScaffoldInputCommon
-{
- protected function createControl($container, $column, $record)
- {
- switch(strtolower($column->getDbType()))
- {
- case 'date':
- return $this->createDateControl($container, $column, $record);
- case 'time':
- return $this->createTimeControl($container, $column, $record);
- case 'timestamp':
- return $this->createDateTimeControl($container, $column, $record);
- case 'smallint': case 'integer': case 'bigint':
- return $this->createIntegerControl($container, $column, $record);
- case 'decimal': case 'numeric': case 'real': case 'float': case 'double':
- return $this->createFloatControl($container, $column, $record);
- case 'char': case 'varchar':
- return $this->createMultiLineControl($container, $column, $record);
- default:
- return $this->createDefaultControl($container,$column, $record);
- }
- }
-
- protected function getControlValue($container, $column, $record)
- {
- switch(strtolower($column->getDbType()))
- {
- case 'date':
- return $container->findControl(self::DEFAULT_ID)->getDate();
- case 'time':
- return $this->getTimeValue($container, $column, $record);
- case 'timestamp':
- return $this->getDateTimeValue($container, $column, $record);
- default:
- return $this->getDefaultControlValue($container,$column, $record);
- }
- }
-}
-
+<?php +/** + * TIbmScaffoldInput class file. + * + * @author Cesar Ramos <cramos[at]gmail[dot]com> + * @link http://www.pradosoft.com/ + * @copyright Copyright © 2005-2007 PradoSoft + * @license http://www.pradosoft.com/license/ + * @package System.Data.ActiveReecord.Scaffold.InputBuilder + */ +Prado::using('System.Data.ActiveRecord.Scaffold.InputBuilder.TScaffoldInputCommon'); + +class TIbmScaffoldInput extends TScaffoldInputCommon +{ + protected function createControl($container, $column, $record) + { + switch(strtolower($column->getDbType())) + { + case 'date': + return $this->createDateControl($container, $column, $record); + case 'time': + return $this->createTimeControl($container, $column, $record); + case 'timestamp': + return $this->createDateTimeControl($container, $column, $record); + case 'smallint': case 'integer': case 'bigint': + return $this->createIntegerControl($container, $column, $record); + case 'decimal': case 'numeric': case 'real': case 'float': case 'double': + return $this->createFloatControl($container, $column, $record); + case 'char': case 'varchar': + return $this->createMultiLineControl($container, $column, $record); + default: + return $this->createDefaultControl($container,$column, $record); + } + } + + protected function getControlValue($container, $column, $record) + { + switch(strtolower($column->getDbType())) + { + case 'date': + return $container->findControl(self::DEFAULT_ID)->getDate(); + case 'time': + return $this->getTimeValue($container, $column, $record); + case 'timestamp': + return $this->getDateTimeValue($container, $column, $record); + default: + return $this->getDefaultControlValue($container,$column, $record); + } + } +} + ?>
\ No newline at end of file diff --git a/framework/Data/ActiveRecord/Scaffold/InputBuilder/TMssqlScaffoldInput.php b/framework/Data/ActiveRecord/Scaffold/InputBuilder/TMssqlScaffoldInput.php index 2f06368e..297b76f1 100644 --- a/framework/Data/ActiveRecord/Scaffold/InputBuilder/TMssqlScaffoldInput.php +++ b/framework/Data/ActiveRecord/Scaffold/InputBuilder/TMssqlScaffoldInput.php @@ -1,47 +1,54 @@ -<?php
-
-Prado::using('System.Data.ActiveRecord.Scaffold.InputBuilder.TScaffoldInputCommon');
-
-class TMssqlScaffoldInput extends TScaffoldInputCommon
-{
- protected function createControl($container, $column, $record)
- {
- switch(strtolower($column->getDbType()))
- {
- case 'bit':
- return $this->createBooleanControl($container, $column, $record);
- case 'text':
- return $this->createMultiLineControl($container, $column, $record);
- case 'smallint': case 'int': case 'bigint': case 'tinyint':
- return $this->createIntegerControl($container, $column, $record);
- case 'decimal': case 'float': case 'money': case 'numeric': case 'real': case 'smallmoney':
- return $this->createFloatControl($container, $column, $record);
- case 'datetime': case 'smalldatetime':
- return $this->createDateTimeControl($container, $column, $record);
- default:
- $control = $this->createDefaultControl($container,$column, $record);
- if($column->getIsExcluded())
- $control->setEnabled(false);
- return $control;
- }
- }
-
- protected function getControlValue($container, $column, $record)
- {
- switch(strtolower($column->getDbType()))
- {
- case 'boolean':
- return $container->findControl(self::DEFAULT_ID)->getChecked();
- case 'datetime': case 'smalldatetime':
- return $this->getDateTimeValue($container,$column, $record);
- default:
- $value = $this->getDefaultControlValue($container,$column, $record);
- if(trim($value)==='' && $column->getAllowNull())
- return null;
- else
- return $value;
- }
- }
-}
-
+<?php +/** + * TMssqlScaffoldInput class file. + * + * @link http://www.pradosoft.com/ + * @copyright Copyright © 2005-2007 PradoSoft + * @license http://www.pradosoft.com/license/ + * @package System.Data.ActiveReecord.Scaffold.InputBuilder + */ +Prado::using('System.Data.ActiveRecord.Scaffold.InputBuilder.TScaffoldInputCommon'); + +class TMssqlScaffoldInput extends TScaffoldInputCommon +{ + protected function createControl($container, $column, $record) + { + switch(strtolower($column->getDbType())) + { + case 'bit': + return $this->createBooleanControl($container, $column, $record); + case 'text': + return $this->createMultiLineControl($container, $column, $record); + case 'smallint': case 'int': case 'bigint': case 'tinyint': + return $this->createIntegerControl($container, $column, $record); + case 'decimal': case 'float': case 'money': case 'numeric': case 'real': case 'smallmoney': + return $this->createFloatControl($container, $column, $record); + case 'datetime': case 'smalldatetime': + return $this->createDateTimeControl($container, $column, $record); + default: + $control = $this->createDefaultControl($container,$column, $record); + if($column->getIsExcluded()) + $control->setEnabled(false); + return $control; + } + } + + protected function getControlValue($container, $column, $record) + { + switch(strtolower($column->getDbType())) + { + case 'boolean': + return $container->findControl(self::DEFAULT_ID)->getChecked(); + case 'datetime': case 'smalldatetime': + return $this->getDateTimeValue($container,$column, $record); + default: + $value = $this->getDefaultControlValue($container,$column, $record); + if(trim($value)==='' && $column->getAllowNull()) + return null; + else + return $value; + } + } +} + ?>
\ No newline at end of file diff --git a/framework/Data/ActiveRecord/Scaffold/InputBuilder/TMysqlScaffoldInput.php b/framework/Data/ActiveRecord/Scaffold/InputBuilder/TMysqlScaffoldInput.php index 42f8cead..ceae6c38 100644 --- a/framework/Data/ActiveRecord/Scaffold/InputBuilder/TMysqlScaffoldInput.php +++ b/framework/Data/ActiveRecord/Scaffold/InputBuilder/TMysqlScaffoldInput.php @@ -1,77 +1,84 @@ -<?php
-
-Prado::using('System.Data.ActiveRecord.Scaffold.InputBuilder.TScaffoldInputCommon');
-
-class TMysqlScaffoldInput extends TScaffoldInputCommon
-{
- protected function createControl($container, $column, $record)
- {
- $dbtype = trim(str_replace(array('unsigned', 'zerofill'),array('','',),strtolower($column->getDbType())));
- switch($dbtype)
- {
- case 'date':
- return $this->createDateControl($container, $column, $record);
- case 'blob': case 'tinyblob': case 'mediumblob': case 'longblob':
- case 'text': case 'tinytext': case 'mediumtext': case 'longtext':
- return $this->createMultiLineControl($container, $column, $record);
- case 'year':
- return $this->createYearControl($container, $column, $record);
- case 'int': case 'integer': case 'tinyint': case 'smallint': case 'mediumint': case 'bigint':
- return $this->createIntegerControl($container, $column, $record);
- case 'decimal': case 'double': case 'float':
- return $this->createFloatControl($container, $column, $record);
- case 'time' :
- return $this->createTimeControl($container, $column, $record);
- case 'datetime': case 'timestamp':
- return $this->createDateTimeControl($container, $column, $record);
- case 'set':
- return $this->createSetControl($container, $column, $record);
- case 'enum':
- return $this->createEnumControl($container, $column, $record);
- default:
- return $this->createDefaultControl($container, $column, $record);
- }
- }
-
- protected function getControlValue($container, $column, $record)
- {
- $dbtype = trim(str_replace(array('unsigned', 'zerofill'),array('','',),strtolower($column->getDbType())));
- switch($dbtype)
- {
- case 'date':
- return $container->findControl(self::DEFAULT_ID)->getDate();
- case 'year':
- return $container->findControl(self::DEFAULT_ID)->getSelectedValue();
- case 'time':
- return $this->getTimeValue($container, $column, $record);
- case 'datetime': case 'timestamp':
- return $this->getDateTimeValue($container,$column, $record);
- case 'tinyint':
- return $this->getIntBooleanValue($container,$column, $record);
- case 'set':
- return $this->getSetValue($container, $column, $record);
- case 'enum':
- return $this->getEnumValue($container, $column, $record);
- default:
- return $this->getDefaultControlValue($container,$column, $record);
- }
- }
-
- protected function createIntegerControl($container, $column, $record)
- {
- if($column->getColumnSize()==1)
- return $this->createBooleanControl($container, $column, $record);
- else
- parent::createIntegerControl($container, $column, $record);
- }
-
- protected function getIntBooleanValue($container,$column, $record)
- {
- if($column->getColumnSize()==1)
- return (int)$container->findControl(self::DEFAULT_ID)->getChecked();
- else
- return $this->getDefaultControlValue($container,$column, $record);
- }
-}
-
+<?php +/** + * TMysqlScaffoldInput class file. + * + * @link http://www.pradosoft.com/ + * @copyright Copyright © 2005-2007 PradoSoft + * @license http://www.pradosoft.com/license/ + * @package System.Data.ActiveReecord.Scaffold.InputBuilder + */ +Prado::using('System.Data.ActiveRecord.Scaffold.InputBuilder.TScaffoldInputCommon'); + +class TMysqlScaffoldInput extends TScaffoldInputCommon +{ + protected function createControl($container, $column, $record) + { + $dbtype = trim(str_replace(array('unsigned', 'zerofill'),array('','',),strtolower($column->getDbType()))); + switch($dbtype) + { + case 'date': + return $this->createDateControl($container, $column, $record); + case 'blob': case 'tinyblob': case 'mediumblob': case 'longblob': + case 'text': case 'tinytext': case 'mediumtext': case 'longtext': + return $this->createMultiLineControl($container, $column, $record); + case 'year': + return $this->createYearControl($container, $column, $record); + case 'int': case 'integer': case 'tinyint': case 'smallint': case 'mediumint': case 'bigint': + return $this->createIntegerControl($container, $column, $record); + case 'decimal': case 'double': case 'float': + return $this->createFloatControl($container, $column, $record); + case 'time' : + return $this->createTimeControl($container, $column, $record); + case 'datetime': case 'timestamp': + return $this->createDateTimeControl($container, $column, $record); + case 'set': + return $this->createSetControl($container, $column, $record); + case 'enum': + return $this->createEnumControl($container, $column, $record); + default: + return $this->createDefaultControl($container, $column, $record); + } + } + + protected function getControlValue($container, $column, $record) + { + $dbtype = trim(str_replace(array('unsigned', 'zerofill'),array('','',),strtolower($column->getDbType()))); + switch($dbtype) + { + case 'date': + return $container->findControl(self::DEFAULT_ID)->getDate(); + case 'year': + return $container->findControl(self::DEFAULT_ID)->getSelectedValue(); + case 'time': + return $this->getTimeValue($container, $column, $record); + case 'datetime': case 'timestamp': + return $this->getDateTimeValue($container,$column, $record); + case 'tinyint': + return $this->getIntBooleanValue($container,$column, $record); + case 'set': + return $this->getSetValue($container, $column, $record); + case 'enum': + return $this->getEnumValue($container, $column, $record); + default: + return $this->getDefaultControlValue($container,$column, $record); + } + } + + protected function createIntegerControl($container, $column, $record) + { + if($column->getColumnSize()==1) + return $this->createBooleanControl($container, $column, $record); + else + parent::createIntegerControl($container, $column, $record); + } + + protected function getIntBooleanValue($container,$column, $record) + { + if($column->getColumnSize()==1) + return (int)$container->findControl(self::DEFAULT_ID)->getChecked(); + else + return $this->getDefaultControlValue($container,$column, $record); + } +} + ?>
\ No newline at end of file diff --git a/framework/Data/ActiveRecord/Scaffold/InputBuilder/TPgsqlScaffoldInput.php b/framework/Data/ActiveRecord/Scaffold/InputBuilder/TPgsqlScaffoldInput.php index a024c73b..04a5c334 100644 --- a/framework/Data/ActiveRecord/Scaffold/InputBuilder/TPgsqlScaffoldInput.php +++ b/framework/Data/ActiveRecord/Scaffold/InputBuilder/TPgsqlScaffoldInput.php @@ -1,48 +1,55 @@ -<?php
-
-Prado::using('System.Data.ActiveRecord.Scaffold.InputBuilder.TScaffoldInputCommon');
-
-class TPgsqlScaffoldInput extends TScaffoldInputCommon
-{
- protected function createControl($container, $column, $record)
- {
- switch(strtolower($column->getDbType()))
- {
- case 'boolean':
- return $this->createBooleanControl($container, $column, $record);
- case 'date':
- return $this->createDateControl($container, $column, $record);
- case 'text':
- return $this->createMultiLineControl($container, $column, $record);
- case 'smallint': case 'integer': case 'bigint':
- return $this->createIntegerControl($container, $column, $record);
- case 'decimal': case 'numeric': case 'real': case 'double precision':
- return $this->createFloatControl($container, $column, $record);
- case 'time without time zone' :
- return $this->createTimeControl($container, $column, $record);
- case 'timestamp without time zone':
- return $this->createDateTimeControl($container, $column, $record);
- default:
- return $this->createDefaultControl($container,$column, $record);
- }
- }
-
- protected function getControlValue($container, $column, $record)
- {
- switch(strtolower($column->getDbType()))
- {
- case 'boolean':
- return $container->findControl(self::DEFAULT_ID)->getChecked();
- case 'date':
- return $container->findControl(self::DEFAULT_ID)->getDate();
- case 'time without time zone':
- return $this->getTimeValue($container, $column, $record);
- case 'timestamp without time zone':
- return $this->getDateTimeValue($container,$column, $record);
- default:
- return $this->getDefaultControlValue($container,$column, $record);
- }
- }
-}
-
+<?php +/** + * TPgsqlScaffoldInput class file. + * + * @link http://www.pradosoft.com/ + * @copyright Copyright © 2005-2007 PradoSoft + * @license http://www.pradosoft.com/license/ + * @package System.Data.ActiveReecord.Scaffold.InputBuilder + */ +Prado::using('System.Data.ActiveRecord.Scaffold.InputBuilder.TScaffoldInputCommon'); + +class TPgsqlScaffoldInput extends TScaffoldInputCommon +{ + protected function createControl($container, $column, $record) + { + switch(strtolower($column->getDbType())) + { + case 'boolean': + return $this->createBooleanControl($container, $column, $record); + case 'date': + return $this->createDateControl($container, $column, $record); + case 'text': + return $this->createMultiLineControl($container, $column, $record); + case 'smallint': case 'integer': case 'bigint': + return $this->createIntegerControl($container, $column, $record); + case 'decimal': case 'numeric': case 'real': case 'double precision': + return $this->createFloatControl($container, $column, $record); + case 'time without time zone' : + return $this->createTimeControl($container, $column, $record); + case 'timestamp without time zone': + return $this->createDateTimeControl($container, $column, $record); + default: + return $this->createDefaultControl($container,$column, $record); + } + } + + protected function getControlValue($container, $column, $record) + { + switch(strtolower($column->getDbType())) + { + case 'boolean': + return $container->findControl(self::DEFAULT_ID)->getChecked(); + case 'date': + return $container->findControl(self::DEFAULT_ID)->getDate(); + case 'time without time zone': + return $this->getTimeValue($container, $column, $record); + case 'timestamp without time zone': + return $this->getDateTimeValue($container,$column, $record); + default: + return $this->getDefaultControlValue($container,$column, $record); + } + } +} + ?>
\ No newline at end of file diff --git a/framework/Data/ActiveRecord/Scaffold/InputBuilder/TScaffoldInputBase.php b/framework/Data/ActiveRecord/Scaffold/InputBuilder/TScaffoldInputBase.php index f9ca9180..1df0910b 100644 --- a/framework/Data/ActiveRecord/Scaffold/InputBuilder/TScaffoldInputBase.php +++ b/framework/Data/ActiveRecord/Scaffold/InputBuilder/TScaffoldInputBase.php @@ -1,97 +1,104 @@ -<?php
-
-class TScaffoldInputBase
-{
- const DEFAULT_ID = 'scaffold_input';
- private $_parent;
-
- protected function getParent()
- {
- return $this->_parent;
- }
-
- public static function createInputBuilder($record)
- {
- $record->getDbConnection()->setActive(true); //must be connected before retrieving driver name!
- $driver = $record->getDbConnection()->getDriverName();
- switch(strtolower($driver))
- {
- case 'sqlite': //sqlite 3
- case 'sqlite2': //sqlite 2
- require_once(dirname(__FILE__).'/TSqliteScaffoldInput.php');
- return new TSqliteScaffoldInput($conn);
- case 'mysqli':
- case 'mysql':
- require_once(dirname(__FILE__).'/TMysqlScaffoldInput.php');
- return new TMysqlScaffoldInput($conn);
- case 'pgsql':
- require_once(dirname(__FILE__).'/TPgsqlScaffoldInput.php');
- return new TPgsqlScaffoldInput($conn);
- case 'mssql':
- require_once(dirname(__FILE__).'/TMssqlScaffoldInput.php');
- return new TMssqlScaffoldInput($conn);
- case 'ibm':
- require_once(dirname(__FILE__).'/TIbmScaffoldInput.php');
- return new TIbmScaffoldInput($conn);
- default:
- throw new TConfigurationException(
- 'scaffold_invalid_database_driver',$driver);
- }
- }
-
- public function createScaffoldInput($parent, $item, $column, $record)
- {
- $this->_parent=$parent;
- $item->setCustomData($column->getColumnId());
- $this->createControl($item->_input, $column, $record);
- if($item->_input->findControl(self::DEFAULT_ID))
- $this->createControlLabel($item->_label, $column, $record);
- }
-
- protected function createControlLabel($label, $column, $record)
- {
- $fieldname = ucwords(str_replace('_', ' ', $column->getColumnId())).':';
- $label->setText($fieldname);
- $label->setForControl(self::DEFAULT_ID);
- }
-
- public function loadScaffoldInput($parent, $item, $column, $record)
- {
- $this->_parent=$parent;
- if($this->getIsEnabled($column, $record))
- {
- $prop = $column->getColumnId();
- $record->{$prop} = $this->getControlValue($item->_input, $column, $record);
- }
- }
-
- protected function getIsEnabled($column, $record)
- {
- return !($this->getParent()->getRecordPk() !== null
- && $column->getIsPrimaryKey() || $column->hasSequence());
- }
-
- protected function getRecordPropertyValue($column, $record)
- {
- $value = $record->{$column->getColumnId()};
- if($column->getDefaultValue()!==TDbTableColumn::UNDEFINED_VALUE && $value===null)
- return $column->getDefaultValue();
- else
- return $value;
- }
-
- protected function setRecordPropertyValue($item, $record, $input)
- {
- $record->{$item->getCustomData()} = $input->getText();
- }
-
- protected function createControl($container, $column, $record)
- {
- }
-
- protected function getControlValue($container, $column, $record)
- {
- }
-}
-
+<?php +/** + * TScaffoldInputBase class file. + * + * @link http://www.pradosoft.com/ + * @copyright Copyright © 2005-2007 PradoSoft + * @license http://www.pradosoft.com/license/ + * @package System.Data.ActiveReecord.Scaffold.InputBuilder + */ +class TScaffoldInputBase +{ + const DEFAULT_ID = 'scaffold_input'; + private $_parent; + + protected function getParent() + { + return $this->_parent; + } + + public static function createInputBuilder($record) + { + $record->getDbConnection()->setActive(true); //must be connected before retrieving driver name! + $driver = $record->getDbConnection()->getDriverName(); + switch(strtolower($driver)) + { + case 'sqlite': //sqlite 3 + case 'sqlite2': //sqlite 2 + require_once(dirname(__FILE__).'/TSqliteScaffoldInput.php'); + return new TSqliteScaffoldInput($conn); + case 'mysqli': + case 'mysql': + require_once(dirname(__FILE__).'/TMysqlScaffoldInput.php'); + return new TMysqlScaffoldInput($conn); + case 'pgsql': + require_once(dirname(__FILE__).'/TPgsqlScaffoldInput.php'); + return new TPgsqlScaffoldInput($conn); + case 'mssql': + require_once(dirname(__FILE__).'/TMssqlScaffoldInput.php'); + return new TMssqlScaffoldInput($conn); + case 'ibm': + require_once(dirname(__FILE__).'/TIbmScaffoldInput.php'); + return new TIbmScaffoldInput($conn); + default: + throw new TConfigurationException( + 'scaffold_invalid_database_driver',$driver); + } + } + + public function createScaffoldInput($parent, $item, $column, $record) + { + $this->_parent=$parent; + $item->setCustomData($column->getColumnId()); + $this->createControl($item->_input, $column, $record); + if($item->_input->findControl(self::DEFAULT_ID)) + $this->createControlLabel($item->_label, $column, $record); + } + + protected function createControlLabel($label, $column, $record) + { + $fieldname = ucwords(str_replace('_', ' ', $column->getColumnId())).':'; + $label->setText($fieldname); + $label->setForControl(self::DEFAULT_ID); + } + + public function loadScaffoldInput($parent, $item, $column, $record) + { + $this->_parent=$parent; + if($this->getIsEnabled($column, $record)) + { + $prop = $column->getColumnId(); + $record->{$prop} = $this->getControlValue($item->_input, $column, $record); + } + } + + protected function getIsEnabled($column, $record) + { + return !($this->getParent()->getRecordPk() !== null + && $column->getIsPrimaryKey() || $column->hasSequence()); + } + + protected function getRecordPropertyValue($column, $record) + { + $value = $record->{$column->getColumnId()}; + if($column->getDefaultValue()!==TDbTableColumn::UNDEFINED_VALUE && $value===null) + return $column->getDefaultValue(); + else + return $value; + } + + protected function setRecordPropertyValue($item, $record, $input) + { + $record->{$item->getCustomData()} = $input->getText(); + } + + protected function createControl($container, $column, $record) + { + } + + protected function getControlValue($container, $column, $record) + { + } +} + ?>
\ No newline at end of file diff --git a/framework/Data/ActiveRecord/Scaffold/InputBuilder/TScaffoldInputCommon.php b/framework/Data/ActiveRecord/Scaffold/InputBuilder/TScaffoldInputCommon.php index 84c381f0..e36ca954 100644 --- a/framework/Data/ActiveRecord/Scaffold/InputBuilder/TScaffoldInputCommon.php +++ b/framework/Data/ActiveRecord/Scaffold/InputBuilder/TScaffoldInputCommon.php @@ -1,301 +1,308 @@ -<?php
-
-class TScaffoldInputCommon extends TScaffoldInputBase
-{
- protected function setDefaultProperty($container, $control, $column, $record)
- {
- $control->setID(self::DEFAULT_ID);
- $control->setEnabled($this->getIsEnabled($column, $record));
- $container->Controls[] = $control;
- }
-
- protected function setNotNullProperty($container, $control, $column, $record)
- {
- $this->setDefaultProperty($container, $control, $column, $record);
- if(!$column->getAllowNull() && !$column->hasSequence())
- $this->createRequiredValidator($container, $column, $record);
- }
-
- protected function createBooleanControl($container, $column, $record)
- {
- $value = $this->getRecordPropertyValue($column, $record);
- $control = new TCheckBox();
- $control->setChecked(TPropertyValue::ensureBoolean($value));
- $control->setCssClass('boolean-checkbox');
- $this->setDefaultProperty($container, $control, $column, $record);
- return $control;
- }
-
- protected function createDefaultControl($container, $column, $record)
- {
- $value = $this->getRecordPropertyValue($column, $record);
- $control = new TTextBox();
- $control->setText($value);
- $control->setCssClass('default-textbox scaffold_input');
- if(($len=$column->getColumnSize())!==null)
- $control->setMaxLength($len);
- $this->setNotNullProperty($container, $control, $column, $record);
- return $control;
- }
-
- protected function getDefaultControlValue($container,$column, $record)
- {
- $control = $container->findControl(self::DEFAULT_ID);
- if($control instanceof TCheckBox)
- return $control->getChecked();
- else if($control instanceof TControl)
- return $control->getText();
- }
-
- protected function createMultiLineControl($container, $column, $record)
- {
- $value = $this->getRecordPropertyValue($column, $record);
- $control = new TTextBox();
- $control->setText($value);
- $control->setTextMode(TTextBoxMode::MultiLine);
- $control->setCssClass('multiline-textbox scaffold_input');
- $this->setNotNullProperty($container, $control, $column, $record);
- return $control;
- }
-
- protected function createYearControl($container, $column, $record)
- {
- $value = $this->getRecordPropertyValue($column, $record);
- $control = new TDropDownList();
- $years = array();
- $current = intval(@date('Y'));
- $from = $current-10; $to=$current+10;
- for($i = $from; $i <= $to; $i++)
- $years[$i] = $i;
- $control->setDataSource($years);
- $control->setSelectedValue(empty($value) ? $current : $value);
- $control->setCssClass('year-dropdown');
- $this->setNotNullProperty($container, $control, $column, $record);
- return $control;
- }
-
- protected function createIntegerControl($container, $column, $record)
- {
- $control = $this->createDefaultControl($container, $column, $record);
- $val = $this->createTypeValidator($container, $column, $record);
- $val->setDataType(TValidationDataType::Integer);
- $val->setErrorMessage('Please entery an integer.');
- return $control;
- }
-
- protected function createFloatControl($container, $column, $record)
- {
- $control = $this->createDefaultControl($container, $column, $record);
- $val = $this->createTypeValidator($container, $column, $record);
- $val->setDataType(TValidationDataType::Float);
- $val->setErrorMessage('Please entery a decimal number.');
- if(($max= $column->getMaxiumNumericConstraint())!==null)
- {
- $val = $this->createRangeValidator($container,$column,$record);
- $val->setDataType(TValidationDataType::Float);
- $val->setMaxValue($max);
- $val->setStrictComparison(true);
- $val->setErrorMessage('Please entery a decimal number strictly less than '.$max.'.');
- }
- return $control;
- }
-
- protected function createRequiredValidator($container, $column, $record)
- {
- $val = new TRequiredFieldValidator();
- $val->setErrorMessage('*');
- $val->setControlCssClass('required-input');
- $val->setCssClass('required');
- $val->setControlToValidate(self::DEFAULT_ID);
- $val->setValidationGroup($this->getParent()->getValidationGroup());
- $val->setDisplay(TValidatorDisplayStyle::Dynamic);
- $container->Controls[] = $val;
- return $val;
- }
-
- protected function createTypeValidator($container, $column, $record)
- {
- $val = new TDataTypeValidator();
- $val->setControlCssClass('required-input2');
- $val->setCssClass('required');
- $val->setControlToValidate(self::DEFAULT_ID);
- $val->setValidationGroup($this->getParent()->getValidationGroup());
- $val->setDisplay(TValidatorDisplayStyle::Dynamic);
- $container->Controls[] = $val;
- return $val;
- }
-
- protected function createRangeValidator($container, $column, $record)
- {
- $val = new TRangeValidator();
- $val->setControlCssClass('required-input3');
- $val->setCssClass('required');
- $val->setControlToValidate(self::DEFAULT_ID);
- $val->setValidationGroup($this->getParent()->getValidationGroup());
- $val->setDisplay(TValidatorDisplayStyle::Dynamic);
- $container->Controls[] = $val;
- return $val;
- }
-
- protected function createTimeControl($container, $column, $record)
- {
- $value = $this->getRecordPropertyValue($column, $record);
- $hours=array();
- for($i=0;$i<24;$i++) $hours[] = str_pad($i,2,'0',STR_PAD_LEFT);
- $mins=array();
- for($i=0;$i<60;$i++) $mins[] = str_pad($i,2,'0',STR_PAD_LEFT);
- $hour = intval(@date('H'));
- $min = intval(@date('i'));
- $sec = intval(@date('s'));
- if(!empty($value))
- {
- $match=array();
- if(preg_match('/(\d+):(\d+):?(\d+)?/', $value, $match))
- {
- $hour = $match[1];
- $min = $match[2];
- if(isset($match[3]))
- $sec=$match[3];
- }
- }
-
- $hcontrol = new TDropDownList();
- $hcontrol->setDataSource($hours);
- $hcontrol->setID(self::DEFAULT_ID);
- $hcontrol->dataBind();
- $hcontrol->setSelectedValue(intval($hour));
- $container->Controls[] = $hcontrol;
- $container->Controls[] = ' : ';
-
- $mcontrol = new TDropDownList();
- $mcontrol->setDataSource($mins);
- $mcontrol->dataBind();
- $mcontrol->setID('scaffold_time_min');
- $mcontrol->setSelectedValue(intval($min));
- $container->Controls[] = $mcontrol;
- $container->Controls[] = ' : ';
-
- $scontrol = new TDropDownList();
- $scontrol->setDataSource($mins);
- $scontrol->dataBind();
- $scontrol->setID('scaffold_time_sec');
- $scontrol->setSelectedValue(intval($sec));
- $container->Controls[] = $scontrol;
-
- return array($hcontrol,$mcontrol,$scontrol);
- }
-
-
- protected function createDateControl($container, $column, $record)
- {
- $value = $this->getRecordPropertyValue($column, $record);
- $control = new TDatePicker();
- $control->setFromYear(1900);
- $control->setInputMode(TDatePickerInputMode::DropDownList);
- $control->setDateFormat('yyyy-MM-dd');
- if(!empty($value))
- $control->setDate(substr($value,0,10));
- $control->setCssClass('date-dropdown');
- $this->setNotNullProperty($container, $control, $column, $record);
- return $control;
- }
-
- protected function createDateTimeControl($container, $column, $record)
- {
- $value = $this->getRecordPropertyValue($column, $record);
- $control = $this->createDateControl($container, $column, $record);
- $container->Controls[] = ' @ ';
- $time = $this->createTimeControl($container, $column, $record);
- if(!empty($value))
- {
- $match=array();
- if(preg_match('/(\d+):(\d+):?(\d+)?/', substr($value, 11), $match))
- {
- $time[0]->setSelectedValue(intval($match[1]));
- $time[1]->setSelectedValue(intval($match[2]));
- if(isset($match[3]))
- $time[2]->setSelectedValue(intval($match[3]));
- }
- }
- $time[0]->setID('scaffold_time_hour');
- return array($control, $time[0], $time[1], $time[2]);
- }
-
- protected function getDateTimeValue($container, $column, $record)
- {
- $date = $container->findControl(self::DEFAULT_ID)->getDate();
- $hour = $container->findControl('scaffold_time_hour')->getSelectedValue();
- $mins = $container->findControl('scaffold_time_min')->getSelectedValue();
- $secs = $container->findControl('scaffold_time_sec')->getSelectedValue();
- return "{$date} {$hour}:{$mins}:{$secs}";
- }
-
- protected function getTimeValue($container, $column, $record)
- {
- $hour = $container->findControl(self::DEFAULT_ID)->getSelectedValue();
- $mins = $container->findControl('scaffold_time_min')->getSelectedValue();
- $secs = $container->findControl('scaffold_time_sec')->getSelectedValue();
- return "{$hour}:{$mins}:{$secs}";
- }
-
- protected function createSetControl($container, $column, $record)
- {
- $value = $this->getRecordPropertyValue($column, $record);
- $selectedValues = preg_split('/\s*,\s*/', $value);
- $control = new TCheckBoxList();
- $values = $column->getDbTypeValues();
- $control->setDataSource($values);
- $control->dataBind();
- $control->setSelectedIndices($this->getMatchingIndices($values,$selectedValues));
- $control->setID(self::DEFAULT_ID);
- $control->setCssClass('set-checkboxes');
- $this->setNotNullProperty($container, $control, $column, $record);
- return $control;
- }
-
- protected function getMatchingIndices($checks, $values)
- {
- $index=array();
- for($i=0, $k=count($checks); $i<$k; $i++)
- {
- if(in_array($checks[$i], $values))
- $index[] = $i;
- }
- return $index;
- }
-
- protected function createEnumControl($container, $column, $record)
- {
- $value = $this->getRecordPropertyValue($column, $record);
- $selectedValues = preg_split('/\s*,\s*/', $value);
- $control = new TRadioButtonList();
- $values = $column->getDbTypeValues();
- $control->setDataSource($values);
- $control->dataBind();
- $index = $this->getMatchingIndices($values,$selectedValues);
- if(count($index) > 0)
- $control->setSelectedIndex($index[0]);
- $control->setID(self::DEFAULT_ID);
- $control->setCssClass('enum-radio-buttons');
- $this->setNotNullProperty($container, $control, $column, $record);
- return $control;
- }
-
- protected function getSetValue($container, $column, $record)
- {
- $value=array();
- foreach($container->findControl(self::DEFAULT_ID)->getItems() as $item)
- {
- if($item->getSelected())
- $value[] = $item->getText();
- }
- return implode(',', $value);
- }
-
- protected function getEnumValue($container, $column, $record)
- {
- return $container->findControl(self::DEFAULT_ID)->getSelectedItem()->getText();
- }
-}
-
+<?php +/** + * TScaffoldInputCommon class file. + * + * @link http://www.pradosoft.com/ + * @copyright Copyright © 2005-2007 PradoSoft + * @license http://www.pradosoft.com/license/ + * @package System.Data.ActiveReecord.Scaffold.InputBuilder + */ +class TScaffoldInputCommon extends TScaffoldInputBase +{ + protected function setDefaultProperty($container, $control, $column, $record) + { + $control->setID(self::DEFAULT_ID); + $control->setEnabled($this->getIsEnabled($column, $record)); + $container->Controls[] = $control; + } + + protected function setNotNullProperty($container, $control, $column, $record) + { + $this->setDefaultProperty($container, $control, $column, $record); + if(!$column->getAllowNull() && !$column->hasSequence()) + $this->createRequiredValidator($container, $column, $record); + } + + protected function createBooleanControl($container, $column, $record) + { + $value = $this->getRecordPropertyValue($column, $record); + $control = new TCheckBox(); + $control->setChecked(TPropertyValue::ensureBoolean($value)); + $control->setCssClass('boolean-checkbox'); + $this->setDefaultProperty($container, $control, $column, $record); + return $control; + } + + protected function createDefaultControl($container, $column, $record) + { + $value = $this->getRecordPropertyValue($column, $record); + $control = new TTextBox(); + $control->setText($value); + $control->setCssClass('default-textbox scaffold_input'); + if(($len=$column->getColumnSize())!==null) + $control->setMaxLength($len); + $this->setNotNullProperty($container, $control, $column, $record); + return $control; + } + + protected function getDefaultControlValue($container,$column, $record) + { + $control = $container->findControl(self::DEFAULT_ID); + if($control instanceof TCheckBox) + return $control->getChecked(); + else if($control instanceof TControl) + return $control->getText(); + } + + protected function createMultiLineControl($container, $column, $record) + { + $value = $this->getRecordPropertyValue($column, $record); + $control = new TTextBox(); + $control->setText($value); + $control->setTextMode(TTextBoxMode::MultiLine); + $control->setCssClass('multiline-textbox scaffold_input'); + $this->setNotNullProperty($container, $control, $column, $record); + return $control; + } + + protected function createYearControl($container, $column, $record) + { + $value = $this->getRecordPropertyValue($column, $record); + $control = new TDropDownList(); + $years = array(); + $current = intval(@date('Y')); + $from = $current-10; $to=$current+10; + for($i = $from; $i <= $to; $i++) + $years[$i] = $i; + $control->setDataSource($years); + $control->setSelectedValue(empty($value) ? $current : $value); + $control->setCssClass('year-dropdown'); + $this->setNotNullProperty($container, $control, $column, $record); + return $control; + } + + protected function createIntegerControl($container, $column, $record) + { + $control = $this->createDefaultControl($container, $column, $record); + $val = $this->createTypeValidator($container, $column, $record); + $val->setDataType(TValidationDataType::Integer); + $val->setErrorMessage('Please entery an integer.'); + return $control; + } + + protected function createFloatControl($container, $column, $record) + { + $control = $this->createDefaultControl($container, $column, $record); + $val = $this->createTypeValidator($container, $column, $record); + $val->setDataType(TValidationDataType::Float); + $val->setErrorMessage('Please entery a decimal number.'); + if(($max= $column->getMaxiumNumericConstraint())!==null) + { + $val = $this->createRangeValidator($container,$column,$record); + $val->setDataType(TValidationDataType::Float); + $val->setMaxValue($max); + $val->setStrictComparison(true); + $val->setErrorMessage('Please entery a decimal number strictly less than '.$max.'.'); + } + return $control; + } + + protected function createRequiredValidator($container, $column, $record) + { + $val = new TRequiredFieldValidator(); + $val->setErrorMessage('*'); + $val->setControlCssClass('required-input'); + $val->setCssClass('required'); + $val->setControlToValidate(self::DEFAULT_ID); + $val->setValidationGroup($this->getParent()->getValidationGroup()); + $val->setDisplay(TValidatorDisplayStyle::Dynamic); + $container->Controls[] = $val; + return $val; + } + + protected function createTypeValidator($container, $column, $record) + { + $val = new TDataTypeValidator(); + $val->setControlCssClass('required-input2'); + $val->setCssClass('required'); + $val->setControlToValidate(self::DEFAULT_ID); + $val->setValidationGroup($this->getParent()->getValidationGroup()); + $val->setDisplay(TValidatorDisplayStyle::Dynamic); + $container->Controls[] = $val; + return $val; + } + + protected function createRangeValidator($container, $column, $record) + { + $val = new TRangeValidator(); + $val->setControlCssClass('required-input3'); + $val->setCssClass('required'); + $val->setControlToValidate(self::DEFAULT_ID); + $val->setValidationGroup($this->getParent()->getValidationGroup()); + $val->setDisplay(TValidatorDisplayStyle::Dynamic); + $container->Controls[] = $val; + return $val; + } + + protected function createTimeControl($container, $column, $record) + { + $value = $this->getRecordPropertyValue($column, $record); + $hours=array(); + for($i=0;$i<24;$i++) $hours[] = str_pad($i,2,'0',STR_PAD_LEFT); + $mins=array(); + for($i=0;$i<60;$i++) $mins[] = str_pad($i,2,'0',STR_PAD_LEFT); + $hour = intval(@date('H')); + $min = intval(@date('i')); + $sec = intval(@date('s')); + if(!empty($value)) + { + $match=array(); + if(preg_match('/(\d+):(\d+):?(\d+)?/', $value, $match)) + { + $hour = $match[1]; + $min = $match[2]; + if(isset($match[3])) + $sec=$match[3]; + } + } + + $hcontrol = new TDropDownList(); + $hcontrol->setDataSource($hours); + $hcontrol->setID(self::DEFAULT_ID); + $hcontrol->dataBind(); + $hcontrol->setSelectedValue(intval($hour)); + $container->Controls[] = $hcontrol; + $container->Controls[] = ' : '; + + $mcontrol = new TDropDownList(); + $mcontrol->setDataSource($mins); + $mcontrol->dataBind(); + $mcontrol->setID('scaffold_time_min'); + $mcontrol->setSelectedValue(intval($min)); + $container->Controls[] = $mcontrol; + $container->Controls[] = ' : '; + + $scontrol = new TDropDownList(); + $scontrol->setDataSource($mins); + $scontrol->dataBind(); + $scontrol->setID('scaffold_time_sec'); + $scontrol->setSelectedValue(intval($sec)); + $container->Controls[] = $scontrol; + + return array($hcontrol,$mcontrol,$scontrol); + } + + + protected function createDateControl($container, $column, $record) + { + $value = $this->getRecordPropertyValue($column, $record); + $control = new TDatePicker(); + $control->setFromYear(1900); + $control->setInputMode(TDatePickerInputMode::DropDownList); + $control->setDateFormat('yyyy-MM-dd'); + if(!empty($value)) + $control->setDate(substr($value,0,10)); + $control->setCssClass('date-dropdown'); + $this->setNotNullProperty($container, $control, $column, $record); + return $control; + } + + protected function createDateTimeControl($container, $column, $record) + { + $value = $this->getRecordPropertyValue($column, $record); + $control = $this->createDateControl($container, $column, $record); + $container->Controls[] = ' @ '; + $time = $this->createTimeControl($container, $column, $record); + if(!empty($value)) + { + $match=array(); + if(preg_match('/(\d+):(\d+):?(\d+)?/', substr($value, 11), $match)) + { + $time[0]->setSelectedValue(intval($match[1])); + $time[1]->setSelectedValue(intval($match[2])); + if(isset($match[3])) + $time[2]->setSelectedValue(intval($match[3])); + } + } + $time[0]->setID('scaffold_time_hour'); + return array($control, $time[0], $time[1], $time[2]); + } + + protected function getDateTimeValue($container, $column, $record) + { + $date = $container->findControl(self::DEFAULT_ID)->getDate(); + $hour = $container->findControl('scaffold_time_hour')->getSelectedValue(); + $mins = $container->findControl('scaffold_time_min')->getSelectedValue(); + $secs = $container->findControl('scaffold_time_sec')->getSelectedValue(); + return "{$date} {$hour}:{$mins}:{$secs}"; + } + + protected function getTimeValue($container, $column, $record) + { + $hour = $container->findControl(self::DEFAULT_ID)->getSelectedValue(); + $mins = $container->findControl('scaffold_time_min')->getSelectedValue(); + $secs = $container->findControl('scaffold_time_sec')->getSelectedValue(); + return "{$hour}:{$mins}:{$secs}"; + } + + protected function createSetControl($container, $column, $record) + { + $value = $this->getRecordPropertyValue($column, $record); + $selectedValues = preg_split('/\s*,\s*/', $value); + $control = new TCheckBoxList(); + $values = $column->getDbTypeValues(); + $control->setDataSource($values); + $control->dataBind(); + $control->setSelectedIndices($this->getMatchingIndices($values,$selectedValues)); + $control->setID(self::DEFAULT_ID); + $control->setCssClass('set-checkboxes'); + $this->setNotNullProperty($container, $control, $column, $record); + return $control; + } + + protected function getMatchingIndices($checks, $values) + { + $index=array(); + for($i=0, $k=count($checks); $i<$k; $i++) + { + if(in_array($checks[$i], $values)) + $index[] = $i; + } + return $index; + } + + protected function createEnumControl($container, $column, $record) + { + $value = $this->getRecordPropertyValue($column, $record); + $selectedValues = preg_split('/\s*,\s*/', $value); + $control = new TRadioButtonList(); + $values = $column->getDbTypeValues(); + $control->setDataSource($values); + $control->dataBind(); + $index = $this->getMatchingIndices($values,$selectedValues); + if(count($index) > 0) + $control->setSelectedIndex($index[0]); + $control->setID(self::DEFAULT_ID); + $control->setCssClass('enum-radio-buttons'); + $this->setNotNullProperty($container, $control, $column, $record); + return $control; + } + + protected function getSetValue($container, $column, $record) + { + $value=array(); + foreach($container->findControl(self::DEFAULT_ID)->getItems() as $item) + { + if($item->getSelected()) + $value[] = $item->getText(); + } + return implode(',', $value); + } + + protected function getEnumValue($container, $column, $record) + { + return $container->findControl(self::DEFAULT_ID)->getSelectedItem()->getText(); + } +} + ?>
\ No newline at end of file diff --git a/framework/Data/ActiveRecord/Scaffold/InputBuilder/TSqliteScaffoldInput.php b/framework/Data/ActiveRecord/Scaffold/InputBuilder/TSqliteScaffoldInput.php index a61da1f3..6a26305d 100644 --- a/framework/Data/ActiveRecord/Scaffold/InputBuilder/TSqliteScaffoldInput.php +++ b/framework/Data/ActiveRecord/Scaffold/InputBuilder/TSqliteScaffoldInput.php @@ -1,93 +1,100 @@ -<?php
-
-Prado::using('System.Data.ActiveRecord.Scaffold.InputBuilder.TScaffoldInputCommon');
-
-class TSqliteScaffoldInput extends TScaffoldInputCommon
-{
- protected function createControl($container, $column, $record)
- {
- switch(strtolower($column->getDbType()))
- {
- case 'boolean':
- return $this->createBooleanControl($container, $column, $record);
- case 'date':
- return $this->createDateControl($container, $column, $record);
- case 'blob': case 'tinyblob': case 'mediumblob': case 'longblob':
- case 'text': case 'tinytext': case 'mediumtext': case 'longtext':
- return $this->createMultiLineControl($container, $column, $record);
- case 'year':
- return $this->createYearControl($container, $column, $record);
- case 'int': case 'integer': case 'tinyint': case 'smallint': case 'mediumint': case 'bigint':
- return $this->createIntegerControl($container, $column, $record);
- case 'decimal': case 'double': case 'float':
- return $this->createFloatControl($container, $column, $record);
- case 'time' :
- return $this->createTimeControl($container, $column, $record);
- case 'datetime': case 'timestamp':
- return $this->createDateTimeControl($container, $column, $record);
- default:
- return $this->createDefaultControl($container,$column, $record);
- }
- }
-
- protected function getControlValue($container, $column, $record)
- {
- switch(strtolower($column->getDbType()))
- {
- case 'boolean':
- return $container->findControl(self::DEFAULT_ID)->getChecked();
- case 'date':
- return $container->findControl(self::DEFAULT_ID)->getDate();
- case 'year':
- return $container->findControl(self::DEFAULT_ID)->getSelectedValue();
- case 'time':
- return $this->getTimeValue($container, $column, $record);
- case 'datetime': case 'timestamp':
- return $this->getDateTimeValue($container,$column, $record);
- default:
- return $this->getDefaultControlValue($container,$column, $record);
- }
- }
-
- protected function createDateControl($container, $column, $record)
- {
- $control = parent::createDateControl($container, $column, $record);
- $value = $this->getRecordPropertyValue($column, $record);
- if(!empty($value) && preg_match('/timestamp/i', $column->getDbType()))
- $control->setTimestamp(intval($value));
- return $control;
- }
-
- protected function createDateTimeControl($container, $column, $record)
- {
- $value = $this->getRecordPropertyValue($column, $record);
- $time = parent::createDateTimeControl($container, $column, $record);
- if(!empty($value) && preg_match('/timestamp/i', $column->getDbType()))
- {
- $s = Prado::createComponent('System.Util.TDateTimeStamp');
- $date = $s->getDate(intval($value));
- $time[1]->setSelectedValue($date['hours']);
- $time[2]->setSelectedValue($date['minutes']);
- $time[3]->setSelectedValue($date['seconds']);
- }
- return $time;
- }
-
- protected function getDateTimeValue($container, $column, $record)
- {
- if(preg_match('/timestamp/i', $column->getDbType()))
- {
- $time = $container->findControl(self::DEFAULT_ID)->getTimestamp();
- $s = Prado::createComponent('System.Util.TDateTimeStamp');
- $date = $s->getDate($time);
- $hour = $container->findControl('scaffold_time_hour')->getSelectedValue();
- $mins = $container->findControl('scaffold_time_min')->getSelectedValue();
- $secs = $container->findControl('scaffold_time_sec')->getSelectedValue();
- return $s->getTimeStamp($hour,$mins,$secs,$date['mon'],$date['mday'],$date['year']);
- }
- else
- return parent::getDateTimeValue($container, $column, $record);
- }
-}
-
+<?php +/** + * TSqliteScaffoldInput class file. + * + * @link http://www.pradosoft.com/ + * @copyright Copyright © 2005-2007 PradoSoft + * @license http://www.pradosoft.com/license/ + * @package System.Data.ActiveReecord.Scaffold.InputBuilder + */ +Prado::using('System.Data.ActiveRecord.Scaffold.InputBuilder.TScaffoldInputCommon'); + +class TSqliteScaffoldInput extends TScaffoldInputCommon +{ + protected function createControl($container, $column, $record) + { + switch(strtolower($column->getDbType())) + { + case 'boolean': + return $this->createBooleanControl($container, $column, $record); + case 'date': + return $this->createDateControl($container, $column, $record); + case 'blob': case 'tinyblob': case 'mediumblob': case 'longblob': + case 'text': case 'tinytext': case 'mediumtext': case 'longtext': + return $this->createMultiLineControl($container, $column, $record); + case 'year': + return $this->createYearControl($container, $column, $record); + case 'int': case 'integer': case 'tinyint': case 'smallint': case 'mediumint': case 'bigint': + return $this->createIntegerControl($container, $column, $record); + case 'decimal': case 'double': case 'float': + return $this->createFloatControl($container, $column, $record); + case 'time' : + return $this->createTimeControl($container, $column, $record); + case 'datetime': case 'timestamp': + return $this->createDateTimeControl($container, $column, $record); + default: + return $this->createDefaultControl($container,$column, $record); + } + } + + protected function getControlValue($container, $column, $record) + { + switch(strtolower($column->getDbType())) + { + case 'boolean': + return $container->findControl(self::DEFAULT_ID)->getChecked(); + case 'date': + return $container->findControl(self::DEFAULT_ID)->getDate(); + case 'year': + return $container->findControl(self::DEFAULT_ID)->getSelectedValue(); + case 'time': + return $this->getTimeValue($container, $column, $record); + case 'datetime': case 'timestamp': + return $this->getDateTimeValue($container,$column, $record); + default: + return $this->getDefaultControlValue($container,$column, $record); + } + } + + protected function createDateControl($container, $column, $record) + { + $control = parent::createDateControl($container, $column, $record); + $value = $this->getRecordPropertyValue($column, $record); + if(!empty($value) && preg_match('/timestamp/i', $column->getDbType())) + $control->setTimestamp(intval($value)); + return $control; + } + + protected function createDateTimeControl($container, $column, $record) + { + $value = $this->getRecordPropertyValue($column, $record); + $time = parent::createDateTimeControl($container, $column, $record); + if(!empty($value) && preg_match('/timestamp/i', $column->getDbType())) + { + $s = Prado::createComponent('System.Util.TDateTimeStamp'); + $date = $s->getDate(intval($value)); + $time[1]->setSelectedValue($date['hours']); + $time[2]->setSelectedValue($date['minutes']); + $time[3]->setSelectedValue($date['seconds']); + } + return $time; + } + + protected function getDateTimeValue($container, $column, $record) + { + if(preg_match('/timestamp/i', $column->getDbType())) + { + $time = $container->findControl(self::DEFAULT_ID)->getTimestamp(); + $s = Prado::createComponent('System.Util.TDateTimeStamp'); + $date = $s->getDate($time); + $hour = $container->findControl('scaffold_time_hour')->getSelectedValue(); + $mins = $container->findControl('scaffold_time_min')->getSelectedValue(); + $secs = $container->findControl('scaffold_time_sec')->getSelectedValue(); + return $s->getTimeStamp($hour,$mins,$secs,$date['mon'],$date['mday'],$date['year']); + } + else + return parent::getDateTimeValue($container, $column, $record); + } +} + ?>
\ No newline at end of file |