1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
|
<?php
/**
* TSqliteScaffoldInput class file.
*
* @link http://www.pradosoft.com/
* @copyright Copyright © 2005-2014 PradoSoft
* @license http://www.pradosoft.com/license/
* @package Prado\Data\ActiveRecord\Scaffold\InputBuilder
*/
namespace Prado\Data\ActiveRecord\Scaffold\InputBuilder;
use Prado\Prado;
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);
}
}
|