| 1 |
lars |
1 |
<?php
|
|
|
2 |
/**
|
|
|
3 |
* TMysqlScaffoldInput class file.
|
|
|
4 |
*
|
|
|
5 |
* @link http://www.pradosoft.com/
|
|
|
6 |
* @copyright Copyright © 2005-2008 PradoSoft
|
|
|
7 |
* @license http://www.pradosoft.com/license/
|
|
|
8 |
* @package System.Data.ActiveReecord.Scaffold.InputBuilder
|
|
|
9 |
*/
|
|
|
10 |
Prado::using('System.Data.ActiveRecord.Scaffold.InputBuilder.TScaffoldInputCommon');
|
|
|
11 |
|
|
|
12 |
class TMysqlScaffoldInput extends TScaffoldInputCommon
|
|
|
13 |
{
|
|
|
14 |
protected function createControl($container, $column, $record)
|
|
|
15 |
{
|
|
|
16 |
$dbtype = trim(str_replace(array('unsigned', 'zerofill'),array('','',),strtolower($column->getDbType())));
|
|
|
17 |
switch($dbtype)
|
|
|
18 |
{
|
|
|
19 |
case 'date':
|
|
|
20 |
return $this->createDateControl($container, $column, $record);
|
|
|
21 |
case 'blob': case 'tinyblob': case 'mediumblob': case 'longblob':
|
|
|
22 |
case 'text': case 'tinytext': case 'mediumtext': case 'longtext':
|
|
|
23 |
return $this->createMultiLineControl($container, $column, $record);
|
|
|
24 |
case 'year':
|
|
|
25 |
return $this->createYearControl($container, $column, $record);
|
|
|
26 |
case 'int': case 'integer': case 'tinyint': case 'smallint': case 'mediumint': case 'bigint':
|
|
|
27 |
return $this->createIntegerControl($container, $column, $record);
|
|
|
28 |
case 'decimal': case 'double': case 'float':
|
|
|
29 |
return $this->createFloatControl($container, $column, $record);
|
|
|
30 |
case 'time' :
|
|
|
31 |
return $this->createTimeControl($container, $column, $record);
|
|
|
32 |
case 'datetime': case 'timestamp':
|
|
|
33 |
return $this->createDateTimeControl($container, $column, $record);
|
|
|
34 |
case 'set':
|
|
|
35 |
return $this->createSetControl($container, $column, $record);
|
|
|
36 |
case 'enum':
|
|
|
37 |
return $this->createEnumControl($container, $column, $record);
|
|
|
38 |
default:
|
|
|
39 |
return $this->createDefaultControl($container, $column, $record);
|
|
|
40 |
}
|
|
|
41 |
}
|
|
|
42 |
|
|
|
43 |
protected function getControlValue($container, $column, $record)
|
|
|
44 |
{
|
|
|
45 |
$dbtype = trim(str_replace(array('unsigned', 'zerofill'),array('','',),strtolower($column->getDbType())));
|
|
|
46 |
switch($dbtype)
|
|
|
47 |
{
|
|
|
48 |
case 'date':
|
|
|
49 |
return $container->findControl(self::DEFAULT_ID)->getDate();
|
|
|
50 |
case 'year':
|
|
|
51 |
return $container->findControl(self::DEFAULT_ID)->getSelectedValue();
|
|
|
52 |
case 'time':
|
|
|
53 |
return $this->getTimeValue($container, $column, $record);
|
|
|
54 |
case 'datetime': case 'timestamp':
|
|
|
55 |
return $this->getDateTimeValue($container,$column, $record);
|
|
|
56 |
case 'tinyint':
|
|
|
57 |
return $this->getIntBooleanValue($container,$column, $record);
|
|
|
58 |
case 'set':
|
|
|
59 |
return $this->getSetValue($container, $column, $record);
|
|
|
60 |
case 'enum':
|
|
|
61 |
return $this->getEnumValue($container, $column, $record);
|
|
|
62 |
default:
|
|
|
63 |
return $this->getDefaultControlValue($container,$column, $record);
|
|
|
64 |
}
|
|
|
65 |
}
|
|
|
66 |
|
|
|
67 |
protected function createIntegerControl($container, $column, $record)
|
|
|
68 |
{
|
|
|
69 |
if($column->getColumnSize()==1)
|
|
|
70 |
return $this->createBooleanControl($container, $column, $record);
|
|
|
71 |
else
|
|
|
72 |
parent::createIntegerControl($container, $column, $record);
|
|
|
73 |
}
|
|
|
74 |
|
|
|
75 |
protected function getIntBooleanValue($container,$column, $record)
|
|
|
76 |
{
|
|
|
77 |
if($column->getColumnSize()==1)
|
|
|
78 |
return (int)$container->findControl(self::DEFAULT_ID)->getChecked();
|
|
|
79 |
else
|
|
|
80 |
return $this->getDefaultControlValue($container,$column, $record);
|
|
|
81 |
}
|
|
|
82 |
}
|
|
|
83 |
|