@@ -14,59 +14,59 @@ |
||
14 | 14 | class TWsatScaffolding extends TPage |
15 | 15 | { |
16 | 16 | |
17 | - public function onInit($param) |
|
18 | - { |
|
19 | - parent::onInit($param); |
|
20 | - $this->startVisual(); |
|
21 | - } |
|
17 | + public function onInit($param) |
|
18 | + { |
|
19 | + parent::onInit($param); |
|
20 | + $this->startVisual(); |
|
21 | + } |
|
22 | 22 | |
23 | - private function startVisual() |
|
24 | - { |
|
25 | - $scf_generator = new TWsatScaffoldingGenerator(); |
|
26 | - foreach ($scf_generator->getAllTableNames() as $tableName) |
|
27 | - { |
|
28 | - $dynChb = new TCheckBox(); |
|
29 | - $dynChb->ID = "cb_$tableName"; |
|
30 | - $dynChb->Text = ucfirst($tableName); |
|
31 | - $dynChb->Checked = true; |
|
32 | - $this->registerObject("cb_$tableName", $dynChb); |
|
33 | - $this->tableNames->getControls()->add($dynChb); |
|
34 | - $this->tableNames->getControls()->add("</br>"); |
|
35 | - } |
|
36 | - } |
|
23 | + private function startVisual() |
|
24 | + { |
|
25 | + $scf_generator = new TWsatScaffoldingGenerator(); |
|
26 | + foreach ($scf_generator->getAllTableNames() as $tableName) |
|
27 | + { |
|
28 | + $dynChb = new TCheckBox(); |
|
29 | + $dynChb->ID = "cb_$tableName"; |
|
30 | + $dynChb->Text = ucfirst($tableName); |
|
31 | + $dynChb->Checked = true; |
|
32 | + $this->registerObject("cb_$tableName", $dynChb); |
|
33 | + $this->tableNames->getControls()->add($dynChb); |
|
34 | + $this->tableNames->getControls()->add("</br>"); |
|
35 | + } |
|
36 | + } |
|
37 | 37 | |
38 | - /** |
|
39 | - * Generate Scaffolding code for selected tables |
|
40 | - * @param type $sender |
|
41 | - */ |
|
42 | - public function generate($sender) |
|
43 | - { |
|
44 | - if ($this->IsValid) |
|
45 | - { |
|
46 | - try |
|
47 | - { |
|
48 | - $scf_generator = new TWsatScaffoldingGenerator(); |
|
49 | - $scf_generator->setOpFile($this->output_folder->Text); |
|
50 | - foreach ($scf_generator->getAllTableNames() as $tableName) |
|
51 | - { |
|
52 | - $id = "cb_$tableName"; |
|
53 | - $obj = $this->tableNames->findControl($id); |
|
54 | - if($obj!==null && $obj->Checked) |
|
55 | - { |
|
56 | - $scf_generator->generateCRUD($tableName); |
|
57 | - } |
|
58 | - } |
|
38 | + /** |
|
39 | + * Generate Scaffolding code for selected tables |
|
40 | + * @param type $sender |
|
41 | + */ |
|
42 | + public function generate($sender) |
|
43 | + { |
|
44 | + if ($this->IsValid) |
|
45 | + { |
|
46 | + try |
|
47 | + { |
|
48 | + $scf_generator = new TWsatScaffoldingGenerator(); |
|
49 | + $scf_generator->setOpFile($this->output_folder->Text); |
|
50 | + foreach ($scf_generator->getAllTableNames() as $tableName) |
|
51 | + { |
|
52 | + $id = "cb_$tableName"; |
|
53 | + $obj = $this->tableNames->findControl($id); |
|
54 | + if($obj!==null && $obj->Checked) |
|
55 | + { |
|
56 | + $scf_generator->generateCRUD($tableName); |
|
57 | + } |
|
58 | + } |
|
59 | 59 | |
60 | - $this->feedback_panel->CssClass = "green_panel"; |
|
61 | - $this->generation_msg->Text = "The code has been generated successfully."; |
|
62 | - } catch (Exception $ex) |
|
63 | - { |
|
64 | - $this->feedback_panel->CssClass = "red_panel"; |
|
65 | - $this->generation_msg->Text = $ex->getMessage(); |
|
66 | - } |
|
67 | - $this->feedback_panel->Visible = true; |
|
68 | - } |
|
60 | + $this->feedback_panel->CssClass = "green_panel"; |
|
61 | + $this->generation_msg->Text = "The code has been generated successfully."; |
|
62 | + } catch (Exception $ex) |
|
63 | + { |
|
64 | + $this->feedback_panel->CssClass = "red_panel"; |
|
65 | + $this->generation_msg->Text = $ex->getMessage(); |
|
66 | + } |
|
67 | + $this->feedback_panel->Visible = true; |
|
68 | + } |
|
69 | 69 | |
70 | - // $scf_generator->renderAllTablesInformation(); |
|
71 | - } |
|
70 | + // $scf_generator->renderAllTablesInformation(); |
|
71 | + } |
|
72 | 72 | } |
73 | 73 | \ No newline at end of file |
@@ -14,44 +14,44 @@ |
||
14 | 14 | class TWsatGenerateAR extends TPage |
15 | 15 | { |
16 | 16 | |
17 | - public function generate($sender) |
|
18 | - { |
|
19 | - if ($this->IsValid) |
|
20 | - { |
|
21 | - $tableName = $this->table_name->Text; |
|
22 | - $outputFolderNs = $this->output_folder->Text; |
|
23 | - $classPrefix = $this->class_prefix->Text; |
|
24 | - $classSuffix = $this->class_suffix->Text; |
|
25 | - |
|
26 | - try |
|
27 | - { |
|
28 | - $ar_generator = new TWsatARGenerator(); |
|
29 | - $ar_generator->setOpFile($outputFolderNs); |
|
30 | - $ar_generator->setClasPrefix($classPrefix); |
|
31 | - $ar_generator->setClassSufix($classSuffix); |
|
32 | - |
|
33 | - if ($this->build_rel->Checked) |
|
34 | - $ar_generator->buildRelations(); |
|
35 | - |
|
36 | - if ($tableName != "*") |
|
37 | - $ar_generator->generate($tableName); |
|
38 | - else |
|
39 | - $ar_generator->generateAll(); |
|
40 | - |
|
41 | - $this->feedback_panel->CssClass = "green_panel"; |
|
42 | - $this->generation_msg->Text = "The code has been generated successfully."; |
|
43 | - } catch (Exception $ex) |
|
44 | - { |
|
45 | - $this->feedback_panel->CssClass = "red_panel"; |
|
46 | - $this->generation_msg->Text = $ex->getMessage(); |
|
47 | - } |
|
48 | - $this->feedback_panel->Visible = true; |
|
49 | - } |
|
50 | - } |
|
51 | - |
|
52 | - public function preview($sender) |
|
53 | - { |
|
54 | - throw new THttpException(500, "Not implemented yet."); |
|
55 | - } |
|
17 | + public function generate($sender) |
|
18 | + { |
|
19 | + if ($this->IsValid) |
|
20 | + { |
|
21 | + $tableName = $this->table_name->Text; |
|
22 | + $outputFolderNs = $this->output_folder->Text; |
|
23 | + $classPrefix = $this->class_prefix->Text; |
|
24 | + $classSuffix = $this->class_suffix->Text; |
|
25 | + |
|
26 | + try |
|
27 | + { |
|
28 | + $ar_generator = new TWsatARGenerator(); |
|
29 | + $ar_generator->setOpFile($outputFolderNs); |
|
30 | + $ar_generator->setClasPrefix($classPrefix); |
|
31 | + $ar_generator->setClassSufix($classSuffix); |
|
32 | + |
|
33 | + if ($this->build_rel->Checked) |
|
34 | + $ar_generator->buildRelations(); |
|
35 | + |
|
36 | + if ($tableName != "*") |
|
37 | + $ar_generator->generate($tableName); |
|
38 | + else |
|
39 | + $ar_generator->generateAll(); |
|
40 | + |
|
41 | + $this->feedback_panel->CssClass = "green_panel"; |
|
42 | + $this->generation_msg->Text = "The code has been generated successfully."; |
|
43 | + } catch (Exception $ex) |
|
44 | + { |
|
45 | + $this->feedback_panel->CssClass = "red_panel"; |
|
46 | + $this->generation_msg->Text = $ex->getMessage(); |
|
47 | + } |
|
48 | + $this->feedback_panel->Visible = true; |
|
49 | + } |
|
50 | + } |
|
51 | + |
|
52 | + public function preview($sender) |
|
53 | + { |
|
54 | + throw new THttpException(500, "Not implemented yet."); |
|
55 | + } |
|
56 | 56 | |
57 | 57 | } |
58 | 58 | \ No newline at end of file |
@@ -8,29 +8,29 @@ |
||
8 | 8 | class TWsatLayout extends TTemplateControl |
9 | 9 | { |
10 | 10 | |
11 | - public function onLoad($param) |
|
12 | - { |
|
13 | - parent::onLoad($param); |
|
14 | - $this->validateSecurity(); |
|
15 | - } |
|
11 | + public function onLoad($param) |
|
12 | + { |
|
13 | + parent::onLoad($param); |
|
14 | + $this->validateSecurity(); |
|
15 | + } |
|
16 | 16 | |
17 | - private function validateSecurity() |
|
18 | - { |
|
19 | - if ($this->Session["wsat_password"] !== $this->getService()->getPassword()) |
|
20 | - { |
|
21 | - if (!$this->getPage() instanceof TWsatLogin) |
|
22 | - { |
|
23 | - $url = $this->Service->constructUrl('TWsatLogin'); |
|
24 | - $this->Response->redirect($url); |
|
25 | - } |
|
26 | - } |
|
27 | - } |
|
17 | + private function validateSecurity() |
|
18 | + { |
|
19 | + if ($this->Session["wsat_password"] !== $this->getService()->getPassword()) |
|
20 | + { |
|
21 | + if (!$this->getPage() instanceof TWsatLogin) |
|
22 | + { |
|
23 | + $url = $this->Service->constructUrl('TWsatLogin'); |
|
24 | + $this->Response->redirect($url); |
|
25 | + } |
|
26 | + } |
|
27 | + } |
|
28 | 28 | |
29 | - public function logout() |
|
30 | - { |
|
31 | - $this->Session["wsat_password"] = ""; |
|
32 | - $url = $this->Service->constructUrl('TWsatLogin'); |
|
33 | - $this->Response->redirect($url); |
|
34 | - } |
|
29 | + public function logout() |
|
30 | + { |
|
31 | + $this->Session["wsat_password"] = ""; |
|
32 | + $url = $this->Service->constructUrl('TWsatLogin'); |
|
33 | + $this->Response->redirect($url); |
|
34 | + } |
|
35 | 35 | |
36 | 36 | } |
37 | 37 | \ No newline at end of file |
@@ -12,21 +12,21 @@ |
||
12 | 12 | class TWsatLogin extends TPage |
13 | 13 | { |
14 | 14 | |
15 | - public function login() |
|
16 | - { |
|
17 | - if ($this->IsValid) |
|
18 | - { |
|
19 | - $this->Session["wsat_password"] = $this->getService()->getPassword(); |
|
20 | - $url = $this->Service->constructUrl('TWsatHome'); |
|
21 | - $this->Response->redirect($url); |
|
22 | - } |
|
23 | - } |
|
15 | + public function login() |
|
16 | + { |
|
17 | + if ($this->IsValid) |
|
18 | + { |
|
19 | + $this->Session["wsat_password"] = $this->getService()->getPassword(); |
|
20 | + $url = $this->Service->constructUrl('TWsatHome'); |
|
21 | + $this->Response->redirect($url); |
|
22 | + } |
|
23 | + } |
|
24 | 24 | |
25 | - public function validatePassword($sender, $param) |
|
26 | - { |
|
27 | - $config_pass = $this->Service->Password; |
|
28 | - $user_pass = $this->password->Text; |
|
29 | - $param->IsValid = $user_pass === $config_pass; |
|
30 | - } |
|
25 | + public function validatePassword($sender, $param) |
|
26 | + { |
|
27 | + $config_pass = $this->Service->Password; |
|
28 | + $user_pass = $this->password->Text; |
|
29 | + $param->IsValid = $user_pass === $config_pass; |
|
30 | + } |
|
31 | 31 | |
32 | 32 | } |
33 | 33 | \ No newline at end of file |
@@ -14,206 +14,206 @@ discard block |
||
14 | 14 | class TWsatARGenerator extends TWsatBaseGenerator |
15 | 15 | { |
16 | 16 | |
17 | - /** |
|
18 | - * Class name prefix |
|
19 | - */ |
|
20 | - private $_clasPrefix; |
|
21 | - |
|
22 | - /** |
|
23 | - * Class name sufix |
|
24 | - */ |
|
25 | - private $_classSufix; |
|
26 | - |
|
27 | - /** |
|
28 | - * all table relations array |
|
29 | - */ |
|
30 | - private $_relations; |
|
31 | - |
|
32 | - /** |
|
33 | - * unquote chars |
|
34 | - * @var array |
|
35 | - */ |
|
36 | - private $uqChars = array('[', ']', '"', '`', "'"); |
|
37 | - |
|
38 | - function __construct() |
|
39 | - { |
|
40 | - parent::__construct(); |
|
41 | - } |
|
42 | - |
|
43 | - public function setClasPrefix($_clas_prefix) |
|
44 | - { |
|
45 | - $this->_clasPrefix = $_clas_prefix; |
|
46 | - } |
|
47 | - |
|
48 | - public function setClassSufix($_clas_sufix) |
|
49 | - { |
|
50 | - $this->_classSufix = $_clas_sufix; |
|
51 | - } |
|
17 | + /** |
|
18 | + * Class name prefix |
|
19 | + */ |
|
20 | + private $_clasPrefix; |
|
21 | + |
|
22 | + /** |
|
23 | + * Class name sufix |
|
24 | + */ |
|
25 | + private $_classSufix; |
|
26 | + |
|
27 | + /** |
|
28 | + * all table relations array |
|
29 | + */ |
|
30 | + private $_relations; |
|
31 | + |
|
32 | + /** |
|
33 | + * unquote chars |
|
34 | + * @var array |
|
35 | + */ |
|
36 | + private $uqChars = array('[', ']', '"', '`', "'"); |
|
37 | + |
|
38 | + function __construct() |
|
39 | + { |
|
40 | + parent::__construct(); |
|
41 | + } |
|
42 | + |
|
43 | + public function setClasPrefix($_clas_prefix) |
|
44 | + { |
|
45 | + $this->_clasPrefix = $_clas_prefix; |
|
46 | + } |
|
47 | + |
|
48 | + public function setClassSufix($_clas_sufix) |
|
49 | + { |
|
50 | + $this->_classSufix = $_clas_sufix; |
|
51 | + } |
|
52 | 52 | |
53 | 53 | //----------------------------------------------------------------------------- |
54 | - // <editor-fold defaultstate="collapsed" desc="Main APIs"> |
|
55 | - public function generate($tableName) |
|
56 | - { |
|
57 | - $tableInfo = $this->_dbMetaData->getTableInfo($tableName); |
|
58 | - $this->_commonGenerate($tableName, $tableInfo); |
|
59 | - } |
|
60 | - |
|
61 | - public function generateAll() |
|
62 | - { |
|
63 | - foreach ($this->getAllTableNames() as $tableName) |
|
64 | - { |
|
65 | - $tableInfo = $this->_dbMetaData->getTableInfo($tableName); |
|
66 | - if (!empty($this->_relations)) |
|
67 | - { |
|
68 | - // Cancel generation of M-M relationships middle table |
|
69 | - if (count($tableInfo->getPrimaryKeys()) === 2 && count($tableInfo->getColumns()) === 2)//M-M relationships |
|
70 | - continue; |
|
71 | - } |
|
72 | - $this->_commonGenerate($tableName, $tableInfo); |
|
73 | - } |
|
74 | - } |
|
75 | - |
|
76 | - public function buildRelations() |
|
77 | - { |
|
78 | - $this->_relations = array(); |
|
79 | - foreach ($this->getAllTableNames() as $table_name) |
|
80 | - { |
|
81 | - $tableInfo = $this->_dbMetaData->getTableInfo($table_name); |
|
82 | - $pks = $tableInfo->getPrimaryKeys(); |
|
83 | - $fks = $tableInfo->getForeignKeys(); |
|
84 | - |
|
85 | - if (count($pks) === 2 && count($tableInfo->getColumns()) === 2)//M-M relationships |
|
86 | - { |
|
87 | - $table_name_mm = $fks[0]["table"]; |
|
88 | - $table_name_mm2 = $fks[1]["table"]; |
|
89 | - |
|
90 | - $this->_relations[$table_name_mm][] = array( |
|
91 | - "prop_name" => strtolower($table_name_mm2), |
|
92 | - "rel_type" => "self::MANY_TO_MANY", |
|
93 | - "ref_class_name" => $this->_getProperClassName($table_name_mm2), |
|
94 | - "prop_ref" => $table_name |
|
95 | - ); |
|
96 | - |
|
97 | - $this->_relations[$table_name_mm2][] = array( |
|
98 | - "prop_name" => strtolower($table_name_mm), |
|
99 | - "rel_type" => "self::MANY_TO_MANY", |
|
100 | - "ref_class_name" => $this->_getProperClassName($table_name_mm), |
|
101 | - "prop_ref" => $table_name |
|
102 | - ); |
|
103 | - continue; |
|
104 | - } |
|
105 | - foreach ($fks as $fk_data)//1-M relationships |
|
106 | - { |
|
107 | - $owner_table = $fk_data["table"]; |
|
108 | - $slave_table = $table_name; |
|
109 | - $fk_prop = key($fk_data["keys"]); |
|
110 | - |
|
111 | - $this->_relations[$owner_table][] = array( |
|
112 | - "prop_name" => strtolower($slave_table), |
|
113 | - "rel_type" => "self::HAS_MANY", |
|
114 | - "ref_class_name" => $this->_getProperClassName($slave_table), |
|
115 | - "prop_ref" => $fk_prop |
|
116 | - ); |
|
117 | - |
|
118 | - $this->_relations[$slave_table][] = array( |
|
119 | - "prop_name" => strtolower($owner_table), |
|
120 | - "rel_type" => "self::BELONGS_TO", |
|
121 | - "ref_class_name" => $this->_getProperClassName($owner_table), |
|
122 | - "prop_ref" => $fk_prop |
|
123 | - ); |
|
124 | - } |
|
125 | - } |
|
126 | - } |
|
54 | + // <editor-fold defaultstate="collapsed" desc="Main APIs"> |
|
55 | + public function generate($tableName) |
|
56 | + { |
|
57 | + $tableInfo = $this->_dbMetaData->getTableInfo($tableName); |
|
58 | + $this->_commonGenerate($tableName, $tableInfo); |
|
59 | + } |
|
60 | + |
|
61 | + public function generateAll() |
|
62 | + { |
|
63 | + foreach ($this->getAllTableNames() as $tableName) |
|
64 | + { |
|
65 | + $tableInfo = $this->_dbMetaData->getTableInfo($tableName); |
|
66 | + if (!empty($this->_relations)) |
|
67 | + { |
|
68 | + // Cancel generation of M-M relationships middle table |
|
69 | + if (count($tableInfo->getPrimaryKeys()) === 2 && count($tableInfo->getColumns()) === 2)//M-M relationships |
|
70 | + continue; |
|
71 | + } |
|
72 | + $this->_commonGenerate($tableName, $tableInfo); |
|
73 | + } |
|
74 | + } |
|
75 | + |
|
76 | + public function buildRelations() |
|
77 | + { |
|
78 | + $this->_relations = array(); |
|
79 | + foreach ($this->getAllTableNames() as $table_name) |
|
80 | + { |
|
81 | + $tableInfo = $this->_dbMetaData->getTableInfo($table_name); |
|
82 | + $pks = $tableInfo->getPrimaryKeys(); |
|
83 | + $fks = $tableInfo->getForeignKeys(); |
|
84 | + |
|
85 | + if (count($pks) === 2 && count($tableInfo->getColumns()) === 2)//M-M relationships |
|
86 | + { |
|
87 | + $table_name_mm = $fks[0]["table"]; |
|
88 | + $table_name_mm2 = $fks[1]["table"]; |
|
89 | + |
|
90 | + $this->_relations[$table_name_mm][] = array( |
|
91 | + "prop_name" => strtolower($table_name_mm2), |
|
92 | + "rel_type" => "self::MANY_TO_MANY", |
|
93 | + "ref_class_name" => $this->_getProperClassName($table_name_mm2), |
|
94 | + "prop_ref" => $table_name |
|
95 | + ); |
|
96 | + |
|
97 | + $this->_relations[$table_name_mm2][] = array( |
|
98 | + "prop_name" => strtolower($table_name_mm), |
|
99 | + "rel_type" => "self::MANY_TO_MANY", |
|
100 | + "ref_class_name" => $this->_getProperClassName($table_name_mm), |
|
101 | + "prop_ref" => $table_name |
|
102 | + ); |
|
103 | + continue; |
|
104 | + } |
|
105 | + foreach ($fks as $fk_data)//1-M relationships |
|
106 | + { |
|
107 | + $owner_table = $fk_data["table"]; |
|
108 | + $slave_table = $table_name; |
|
109 | + $fk_prop = key($fk_data["keys"]); |
|
110 | + |
|
111 | + $this->_relations[$owner_table][] = array( |
|
112 | + "prop_name" => strtolower($slave_table), |
|
113 | + "rel_type" => "self::HAS_MANY", |
|
114 | + "ref_class_name" => $this->_getProperClassName($slave_table), |
|
115 | + "prop_ref" => $fk_prop |
|
116 | + ); |
|
117 | + |
|
118 | + $this->_relations[$slave_table][] = array( |
|
119 | + "prop_name" => strtolower($owner_table), |
|
120 | + "rel_type" => "self::BELONGS_TO", |
|
121 | + "ref_class_name" => $this->_getProperClassName($owner_table), |
|
122 | + "prop_ref" => $fk_prop |
|
123 | + ); |
|
124 | + } |
|
125 | + } |
|
126 | + } |
|
127 | 127 | |
128 | 128 | // </editor-fold> |
129 | 129 | //----------------------------------------------------------------------------- |
130 | - // <editor-fold defaultstate="collapsed" desc="Common Methods"> |
|
131 | - |
|
132 | - private function _commonGenerate($tableName, $tableInfo) |
|
133 | - { |
|
134 | - if (count($tableInfo->getColumns()) === 0) |
|
135 | - throw new Exception("Unable to find table or view $tableName in " . $this->_dbMetaData->getDbConnection()->getConnectionString() . "."); |
|
136 | - else |
|
137 | - { |
|
138 | - $properties = array(); |
|
139 | - foreach ($tableInfo->getColumns() as $field => $metadata) |
|
140 | - $properties[] = $this->generateProperty($field, $metadata); |
|
141 | - $toString = $this->_buildSmartToString($tableInfo); |
|
142 | - } |
|
143 | - |
|
144 | - $clasName = $this->_getProperClassName($tableName); |
|
145 | - $class = $this->generateClass($properties, $tableName, $clasName, $toString); |
|
146 | - $output = $this->_opFile . DIRECTORY_SEPARATOR . $clasName . ".php"; |
|
147 | - file_put_contents($output, $class); |
|
148 | - } |
|
149 | - |
|
150 | - private function _getProperClassName($tableName) |
|
151 | - { |
|
152 | - $table_name_words = str_replace("_", " ", strtolower($tableName)); |
|
153 | - $final_conversion = str_replace(" ", "", ucwords($table_name_words)); |
|
154 | - return $this->_clasPrefix . $final_conversion . $this->_classSufix; |
|
155 | - } |
|
130 | + // <editor-fold defaultstate="collapsed" desc="Common Methods"> |
|
131 | + |
|
132 | + private function _commonGenerate($tableName, $tableInfo) |
|
133 | + { |
|
134 | + if (count($tableInfo->getColumns()) === 0) |
|
135 | + throw new Exception("Unable to find table or view $tableName in " . $this->_dbMetaData->getDbConnection()->getConnectionString() . "."); |
|
136 | + else |
|
137 | + { |
|
138 | + $properties = array(); |
|
139 | + foreach ($tableInfo->getColumns() as $field => $metadata) |
|
140 | + $properties[] = $this->generateProperty($field, $metadata); |
|
141 | + $toString = $this->_buildSmartToString($tableInfo); |
|
142 | + } |
|
143 | + |
|
144 | + $clasName = $this->_getProperClassName($tableName); |
|
145 | + $class = $this->generateClass($properties, $tableName, $clasName, $toString); |
|
146 | + $output = $this->_opFile . DIRECTORY_SEPARATOR . $clasName . ".php"; |
|
147 | + file_put_contents($output, $class); |
|
148 | + } |
|
149 | + |
|
150 | + private function _getProperClassName($tableName) |
|
151 | + { |
|
152 | + $table_name_words = str_replace("_", " ", strtolower($tableName)); |
|
153 | + $final_conversion = str_replace(" ", "", ucwords($table_name_words)); |
|
154 | + return $this->_clasPrefix . $final_conversion . $this->_classSufix; |
|
155 | + } |
|
156 | 156 | |
157 | 157 | //----------------------------------------------------------------------------- |
158 | 158 | |
159 | - protected function generateProperty($field, $metadata) |
|
160 | - { |
|
161 | - $prop = ''; |
|
162 | - $name = '$' . $field; |
|
163 | - |
|
164 | - /* TODO use in version 2.0 */ |
|
165 | - // $type = $column->getPHPType(); |
|
166 | - |
|
167 | - $prop .= "\tpublic $name;"; |
|
168 | - return $prop; |
|
169 | - } |
|
170 | - |
|
171 | - private function _renderRelations($tablename) |
|
172 | - { |
|
173 | - if (!isset($this->_relations[$tablename])) |
|
174 | - return ""; |
|
175 | - |
|
176 | - $code = "\tpublic static \$RELATIONS = array ("; |
|
177 | - foreach ($this->_relations[$tablename] as $rel_data) |
|
178 | - $code .= "\n\t\t'" . $rel_data["prop_name"] . "' => array(" . $rel_data["rel_type"] . ", '" . $rel_data["ref_class_name"] . "', '" . $rel_data["prop_ref"] . "'),"; |
|
179 | - |
|
180 | - $code = substr($code, 0, -1); |
|
181 | - $code .= "\n\t);"; |
|
182 | - return $code; |
|
183 | - } |
|
184 | - |
|
185 | - private function _buildSmartToString($tableInfo) |
|
186 | - { |
|
187 | - $code = "\tpublic function __toString() {"; |
|
188 | - $property = "throw new THttpException(500, 'Not implemented yet.');"; |
|
189 | - try |
|
190 | - { |
|
191 | - foreach ($tableInfo->getColumns() as $column) |
|
192 | - { |
|
193 | - if (isset($column->IsPrimaryKey) && $column->IsPrimaryKey) |
|
194 | - $property = str_replace($this->uqChars, "", $column->ColumnName); |
|
195 | - elseif ($column->PdoType == PDO::PARAM_STR && $column->DBType != "date") |
|
196 | - { |
|
197 | - $property = str_replace($this->uqChars, "", $column->ColumnName); |
|
198 | - break; |
|
199 | - } |
|
200 | - } |
|
201 | - } catch (Exception $ex) |
|
202 | - { |
|
203 | - Prado::trace($ex->getMessage()); |
|
204 | - } |
|
205 | - $code .= "\n\t\treturn \$this->$property;"; |
|
206 | - $code .= "\n\t}"; |
|
207 | - return $code; |
|
208 | - } |
|
209 | - |
|
210 | - protected function generateClass($properties, $tablename, $classname, $toString) |
|
211 | - { |
|
212 | - $props = implode("\n", $properties); |
|
213 | - $relations = $this->_renderRelations($tablename); |
|
214 | - $date = date('Y-m-d h:i:s'); |
|
215 | - $env_user = getenv("username"); |
|
216 | - return <<<EOD |
|
159 | + protected function generateProperty($field, $metadata) |
|
160 | + { |
|
161 | + $prop = ''; |
|
162 | + $name = '$' . $field; |
|
163 | + |
|
164 | + /* TODO use in version 2.0 */ |
|
165 | + // $type = $column->getPHPType(); |
|
166 | + |
|
167 | + $prop .= "\tpublic $name;"; |
|
168 | + return $prop; |
|
169 | + } |
|
170 | + |
|
171 | + private function _renderRelations($tablename) |
|
172 | + { |
|
173 | + if (!isset($this->_relations[$tablename])) |
|
174 | + return ""; |
|
175 | + |
|
176 | + $code = "\tpublic static \$RELATIONS = array ("; |
|
177 | + foreach ($this->_relations[$tablename] as $rel_data) |
|
178 | + $code .= "\n\t\t'" . $rel_data["prop_name"] . "' => array(" . $rel_data["rel_type"] . ", '" . $rel_data["ref_class_name"] . "', '" . $rel_data["prop_ref"] . "'),"; |
|
179 | + |
|
180 | + $code = substr($code, 0, -1); |
|
181 | + $code .= "\n\t);"; |
|
182 | + return $code; |
|
183 | + } |
|
184 | + |
|
185 | + private function _buildSmartToString($tableInfo) |
|
186 | + { |
|
187 | + $code = "\tpublic function __toString() {"; |
|
188 | + $property = "throw new THttpException(500, 'Not implemented yet.');"; |
|
189 | + try |
|
190 | + { |
|
191 | + foreach ($tableInfo->getColumns() as $column) |
|
192 | + { |
|
193 | + if (isset($column->IsPrimaryKey) && $column->IsPrimaryKey) |
|
194 | + $property = str_replace($this->uqChars, "", $column->ColumnName); |
|
195 | + elseif ($column->PdoType == PDO::PARAM_STR && $column->DBType != "date") |
|
196 | + { |
|
197 | + $property = str_replace($this->uqChars, "", $column->ColumnName); |
|
198 | + break; |
|
199 | + } |
|
200 | + } |
|
201 | + } catch (Exception $ex) |
|
202 | + { |
|
203 | + Prado::trace($ex->getMessage()); |
|
204 | + } |
|
205 | + $code .= "\n\t\treturn \$this->$property;"; |
|
206 | + $code .= "\n\t}"; |
|
207 | + return $code; |
|
208 | + } |
|
209 | + |
|
210 | + protected function generateClass($properties, $tablename, $classname, $toString) |
|
211 | + { |
|
212 | + $props = implode("\n", $properties); |
|
213 | + $relations = $this->_renderRelations($tablename); |
|
214 | + $date = date('Y-m-d h:i:s'); |
|
215 | + $env_user = getenv("username"); |
|
216 | + return <<<EOD |
|
217 | 217 | <?php |
218 | 218 | /** |
219 | 219 | * Auto generated by PRADO - WSAT on $date. |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | $toString |
235 | 235 | } |
236 | 236 | EOD; |
237 | - } |
|
237 | + } |
|
238 | 238 | |
239 | 239 | // </editor-fold> |
240 | 240 | } |
241 | 241 | \ No newline at end of file |
@@ -62,31 +62,31 @@ |
||
62 | 62 | class_exists("DOMDocument",false), |
63 | 63 | 'DOM extension check', |
64 | 64 | 'DOM extension required'), |
65 | - array( |
|
66 | - true, |
|
67 | - extension_loaded("SPL"), |
|
68 | - 'SPL extension check', |
|
69 | - 'SPL extension required'), |
|
70 | - array( |
|
71 | - true, |
|
72 | - extension_loaded("CType"), |
|
73 | - 'CType extension check', |
|
74 | - 'CType extension required'), |
|
75 | - array( |
|
76 | - true, |
|
77 | - extension_loaded("pcre"), |
|
78 | - 'PCRE extension check', |
|
79 | - 'PCRE extension required'), |
|
80 | - array( |
|
81 | - true, |
|
82 | - extension_loaded("json"), |
|
83 | - 'JSON extension check', |
|
84 | - 'JSON extension required'), |
|
85 | - array( |
|
86 | - false, |
|
87 | - class_exists("PDO",false), |
|
88 | - 'PDO extension check', |
|
89 | - 'PDO extension optional'), |
|
65 | + array( |
|
66 | + true, |
|
67 | + extension_loaded("SPL"), |
|
68 | + 'SPL extension check', |
|
69 | + 'SPL extension required'), |
|
70 | + array( |
|
71 | + true, |
|
72 | + extension_loaded("CType"), |
|
73 | + 'CType extension check', |
|
74 | + 'CType extension required'), |
|
75 | + array( |
|
76 | + true, |
|
77 | + extension_loaded("pcre"), |
|
78 | + 'PCRE extension check', |
|
79 | + 'PCRE extension required'), |
|
80 | + array( |
|
81 | + true, |
|
82 | + extension_loaded("json"), |
|
83 | + 'JSON extension check', |
|
84 | + 'JSON extension required'), |
|
85 | + array( |
|
86 | + false, |
|
87 | + class_exists("PDO",false), |
|
88 | + 'PDO extension check', |
|
89 | + 'PDO extension optional'), |
|
90 | 90 | array( |
91 | 91 | false, |
92 | 92 | function_exists("iconv"), |
@@ -740,89 +740,89 @@ discard block |
||
740 | 740 | */ |
741 | 741 | class PradoCommandLineActiveRecordGenAll extends PradoCommandLineAction { |
742 | 742 | |
743 | - protected $action = 'generateAll'; |
|
744 | - protected $parameters = array('output'); |
|
745 | - protected $optional = array('directory', 'soap', 'overwrite', 'prefix', 'postfix'); |
|
746 | - protected $description = "Generate Active Record skeleton for all Tables to <output> file using application.xml in [directory]. May also generate [soap] properties.\nGenerated Classes are named like the Table with optional [Prefix] and/or [Postfix]. [Overwrite] is used to overwrite existing Files."; |
|
747 | - private $_soap = false; |
|
748 | - private $_prefix = ''; |
|
749 | - private $_postfix = ''; |
|
750 | - private $_overwrite = false; |
|
751 | - |
|
752 | - public function performAction($args) { |
|
753 | - $app_dir = count($args) > 2 ? $this->getAppDir($args[2]) : $this->getAppDir(); |
|
754 | - $this->_soap = count($args) > 3 ? ($args[3] == "soap" || $args[3] == "true" ? true : false) : false; |
|
755 | - $this->_overwrite = count($args) > 4 ? ($args[4] == "overwrite" || $args[4] == "true" ? true : false) : false; |
|
756 | - $this->_prefix = count($args) > 5 ? $args[5] : ''; |
|
757 | - $this->_postfix = count($args) > 6 ? $args[6] : ''; |
|
758 | - |
|
759 | - if ($app_dir !== false) { |
|
760 | - $config = $this->getActiveRecordConfig($app_dir); |
|
761 | - |
|
762 | - $manager = TActiveRecordManager::getInstance(); |
|
763 | - $con = $manager->getDbConnection(); |
|
764 | - $con->Active = true; |
|
765 | - $command = $con->createCommand("Show Tables"); |
|
766 | - $dataReader = $command->query(); |
|
767 | - $dataReader->bindColumn(1, $table); |
|
768 | - $generator = new PHP_Shell_Extensions_ActiveRecord(); |
|
769 | - $tables = array(); |
|
770 | - while ($dataReader->read() !== false) { |
|
771 | - $tables[] = $table; |
|
772 | - } |
|
773 | - $con->Active = False; |
|
774 | - foreach ($tables as $key => $table) { |
|
775 | - $output = $args[1] . "." . $this->_prefix . ucfirst($table) . $this->_postfix; |
|
776 | - if ($config !== false && $output !== false) { |
|
777 | - $generator->generate("generate " . $table . " " . $output . " " . $this->_soap . " " . $this->_overwrite); |
|
778 | - } |
|
779 | - } |
|
780 | - } |
|
781 | - return true; |
|
782 | - } |
|
783 | - |
|
784 | - protected function getAppDir($dir=".") { |
|
785 | - if (is_dir($dir)) |
|
786 | - return realpath($dir); |
|
787 | - if (false !== ($app_dir = realpath($dir . '/protected/')) && is_dir($app_dir)) |
|
788 | - return $app_dir; |
|
789 | - echo '** Unable to find directory "' . $dir . "\".\n"; |
|
790 | - return false; |
|
791 | - } |
|
792 | - |
|
793 | - protected function getXmlFile($app_dir) { |
|
794 | - if (false !== ($xml = realpath($app_dir . '/application.xml')) && is_file($xml)) |
|
795 | - return $xml; |
|
796 | - if (false !== ($xml = realpath($app_dir . '/protected/application.xml')) && is_file($xml)) |
|
797 | - return $xml; |
|
798 | - echo '** Unable to find application.xml in ' . $app_dir . "\n"; |
|
799 | - return false; |
|
800 | - } |
|
801 | - |
|
802 | - protected function getActiveRecordConfig($app_dir) { |
|
803 | - if (false === ($xml = $this->getXmlFile($app_dir))) |
|
804 | - return false; |
|
805 | - if (false !== ($app = $this->initializePradoApplication($app_dir))) { |
|
806 | - Prado::using('System.Data.ActiveRecord.TActiveRecordConfig'); |
|
807 | - foreach ($app->getModules() as $module) |
|
808 | - if ($module instanceof TActiveRecordConfig) |
|
809 | - return $module; |
|
810 | - echo '** Unable to find TActiveRecordConfig module in ' . $xml . "\n"; |
|
811 | - } |
|
812 | - return false; |
|
813 | - } |
|
814 | - |
|
815 | - protected function getOutputFile($app_dir, $namespace) { |
|
816 | - if (is_file($namespace) && strpos($namespace, $app_dir) === 0) |
|
817 | - return $namespace; |
|
818 | - $file = Prado::getPathOfNamespace($namespace, ""); |
|
819 | - if ($file !== null && false !== ($path = realpath(dirname($file))) && is_dir($path)) { |
|
820 | - if (strpos($path, $app_dir) === 0) |
|
821 | - return $file; |
|
822 | - } |
|
823 | - echo '** Output file ' . $file . ' must be within directory ' . $app_dir . "\n"; |
|
824 | - return false; |
|
825 | - } |
|
743 | + protected $action = 'generateAll'; |
|
744 | + protected $parameters = array('output'); |
|
745 | + protected $optional = array('directory', 'soap', 'overwrite', 'prefix', 'postfix'); |
|
746 | + protected $description = "Generate Active Record skeleton for all Tables to <output> file using application.xml in [directory]. May also generate [soap] properties.\nGenerated Classes are named like the Table with optional [Prefix] and/or [Postfix]. [Overwrite] is used to overwrite existing Files."; |
|
747 | + private $_soap = false; |
|
748 | + private $_prefix = ''; |
|
749 | + private $_postfix = ''; |
|
750 | + private $_overwrite = false; |
|
751 | + |
|
752 | + public function performAction($args) { |
|
753 | + $app_dir = count($args) > 2 ? $this->getAppDir($args[2]) : $this->getAppDir(); |
|
754 | + $this->_soap = count($args) > 3 ? ($args[3] == "soap" || $args[3] == "true" ? true : false) : false; |
|
755 | + $this->_overwrite = count($args) > 4 ? ($args[4] == "overwrite" || $args[4] == "true" ? true : false) : false; |
|
756 | + $this->_prefix = count($args) > 5 ? $args[5] : ''; |
|
757 | + $this->_postfix = count($args) > 6 ? $args[6] : ''; |
|
758 | + |
|
759 | + if ($app_dir !== false) { |
|
760 | + $config = $this->getActiveRecordConfig($app_dir); |
|
761 | + |
|
762 | + $manager = TActiveRecordManager::getInstance(); |
|
763 | + $con = $manager->getDbConnection(); |
|
764 | + $con->Active = true; |
|
765 | + $command = $con->createCommand("Show Tables"); |
|
766 | + $dataReader = $command->query(); |
|
767 | + $dataReader->bindColumn(1, $table); |
|
768 | + $generator = new PHP_Shell_Extensions_ActiveRecord(); |
|
769 | + $tables = array(); |
|
770 | + while ($dataReader->read() !== false) { |
|
771 | + $tables[] = $table; |
|
772 | + } |
|
773 | + $con->Active = False; |
|
774 | + foreach ($tables as $key => $table) { |
|
775 | + $output = $args[1] . "." . $this->_prefix . ucfirst($table) . $this->_postfix; |
|
776 | + if ($config !== false && $output !== false) { |
|
777 | + $generator->generate("generate " . $table . " " . $output . " " . $this->_soap . " " . $this->_overwrite); |
|
778 | + } |
|
779 | + } |
|
780 | + } |
|
781 | + return true; |
|
782 | + } |
|
783 | + |
|
784 | + protected function getAppDir($dir=".") { |
|
785 | + if (is_dir($dir)) |
|
786 | + return realpath($dir); |
|
787 | + if (false !== ($app_dir = realpath($dir . '/protected/')) && is_dir($app_dir)) |
|
788 | + return $app_dir; |
|
789 | + echo '** Unable to find directory "' . $dir . "\".\n"; |
|
790 | + return false; |
|
791 | + } |
|
792 | + |
|
793 | + protected function getXmlFile($app_dir) { |
|
794 | + if (false !== ($xml = realpath($app_dir . '/application.xml')) && is_file($xml)) |
|
795 | + return $xml; |
|
796 | + if (false !== ($xml = realpath($app_dir . '/protected/application.xml')) && is_file($xml)) |
|
797 | + return $xml; |
|
798 | + echo '** Unable to find application.xml in ' . $app_dir . "\n"; |
|
799 | + return false; |
|
800 | + } |
|
801 | + |
|
802 | + protected function getActiveRecordConfig($app_dir) { |
|
803 | + if (false === ($xml = $this->getXmlFile($app_dir))) |
|
804 | + return false; |
|
805 | + if (false !== ($app = $this->initializePradoApplication($app_dir))) { |
|
806 | + Prado::using('System.Data.ActiveRecord.TActiveRecordConfig'); |
|
807 | + foreach ($app->getModules() as $module) |
|
808 | + if ($module instanceof TActiveRecordConfig) |
|
809 | + return $module; |
|
810 | + echo '** Unable to find TActiveRecordConfig module in ' . $xml . "\n"; |
|
811 | + } |
|
812 | + return false; |
|
813 | + } |
|
814 | + |
|
815 | + protected function getOutputFile($app_dir, $namespace) { |
|
816 | + if (is_file($namespace) && strpos($namespace, $app_dir) === 0) |
|
817 | + return $namespace; |
|
818 | + $file = Prado::getPathOfNamespace($namespace, ""); |
|
819 | + if ($file !== null && false !== ($path = realpath(dirname($file))) && is_dir($path)) { |
|
820 | + if (strpos($path, $app_dir) === 0) |
|
821 | + return $file; |
|
822 | + } |
|
823 | + echo '** Output file ' . $file . ' must be within directory ' . $app_dir . "\n"; |
|
824 | + return false; |
|
825 | + } |
|
826 | 826 | |
827 | 827 | } |
828 | 828 | |
@@ -830,20 +830,20 @@ discard block |
||
830 | 830 | if(class_exists('PHP_Shell_Commands', false)) |
831 | 831 | { |
832 | 832 | class PHP_Shell_Extensions_ActiveRecord implements PHP_Shell_Extension { |
833 | - public function register() |
|
834 | - { |
|
833 | + public function register() |
|
834 | + { |
|
835 | 835 | |
836 | - $cmd = PHP_Shell_Commands::getInstance(); |
|
836 | + $cmd = PHP_Shell_Commands::getInstance(); |
|
837 | 837 | if(Prado::getApplication() !== null) |
838 | 838 | { |
839 | - $cmd->registerCommand('#^generate#', $this, 'generate', 'generate <table> <output> [soap]', |
|
840 | - 'Generate Active Record skeleton for <table> to <output> file using'.PHP_EOL. |
|
841 | - ' application.xml in [directory]. May also generate [soap] properties.'); |
|
839 | + $cmd->registerCommand('#^generate#', $this, 'generate', 'generate <table> <output> [soap]', |
|
840 | + 'Generate Active Record skeleton for <table> to <output> file using'.PHP_EOL. |
|
841 | + ' application.xml in [directory]. May also generate [soap] properties.'); |
|
842 | 842 | } |
843 | - } |
|
843 | + } |
|
844 | 844 | |
845 | - public function generate($l) |
|
846 | - { |
|
845 | + public function generate($l) |
|
846 | + { |
|
847 | 847 | $input = explode(" ", trim($l)); |
848 | 848 | if(count($input) > 2) |
849 | 849 | { |
@@ -860,12 +860,12 @@ discard block |
||
860 | 860 | { |
861 | 861 | echo "\n Usage: generate table_name Application.pages.RecordClassName\n"; |
862 | 862 | } |
863 | - } |
|
863 | + } |
|
864 | 864 | } |
865 | 865 | |
866 | 866 | $__shell_exts = PHP_Shell_Extensions::getInstance(); |
867 | 867 | $__shell_exts->registerExtensions(array( |
868 | - "active-record" => new PHP_Shell_Extensions_ActiveRecord)); /* the :set command */ |
|
868 | + "active-record" => new PHP_Shell_Extensions_ActiveRecord)); /* the :set command */ |
|
869 | 869 | |
870 | 870 | include_once(realpath(dirname(dirname(__FILE__))).'/framework/3rdParty/PhpShell/php-shell-cmd.php'); |
871 | 871 | } |
@@ -4203,10 +4203,10 @@ discard block |
||
4203 | 4203 | { |
4204 | 4204 | $value=TPropertyValue::ensureEnum($value,'THttpSessionCookieMode'); |
4205 | 4205 | if($value===THttpSessionCookieMode::None) |
4206 | - { |
|
4206 | + { |
|
4207 | 4207 | ini_set('session.use_cookies','0'); |
4208 | 4208 | ini_set('session.use_only_cookies','0'); |
4209 | - } |
|
4209 | + } |
|
4210 | 4210 | else if($value===THttpSessionCookieMode::Allow) |
4211 | 4211 | { |
4212 | 4212 | ini_set('session.use_cookies','1'); |
@@ -6805,77 +6805,77 @@ discard block |
||
6805 | 6805 | throw new TConfigurationException('templatecontrol_mastercontrol_required',get_class($this)); |
6806 | 6806 | parent::initRecursive($namingContainer); |
6807 | 6807 | } |
6808 | - public function tryToUpdateView($arObj, $throwExceptions = false) |
|
6809 | - { |
|
6810 | - $objAttrs = get_class_vars(get_class($arObj)); |
|
6811 | - foreach (array_keys($objAttrs) as $key) |
|
6812 | - { |
|
6813 | - try |
|
6814 | - { |
|
6815 | - if ($key != "RELATIONS") |
|
6816 | - { |
|
6817 | - $control = $this->{$key}; |
|
6818 | - if ($control instanceof TTextBox) |
|
6819 | - $control->Text = $arObj->{$key}; |
|
6820 | - elseif ($control instanceof TCheckBox) |
|
6821 | - $control->Checked = (boolean) $arObj->{$key}; |
|
6822 | - elseif ($control instanceof TDatePicker) |
|
6823 | - $control->Date = $arObj->{$key}; |
|
6824 | - } |
|
6825 | - else |
|
6826 | - { |
|
6827 | - foreach ($objAttrs["RELATIONS"] as $relKey => $relValues) |
|
6828 | - { |
|
6829 | - $relControl = $this->{$relKey}; |
|
6830 | - switch ($relValues[0]) |
|
6831 | - { |
|
6832 | - case TActiveRecord::BELONGS_TO: |
|
6833 | - case TActiveRecord::HAS_ONE: |
|
6834 | - $relControl->Text = $arObj->{$relKey}; |
|
6835 | - break; |
|
6836 | - case TActiveRecord::HAS_MANY: |
|
6837 | - if ($relControl instanceof TListControl) |
|
6838 | - { |
|
6839 | - $relControl->DataSource = $arObj->{$relKey}; |
|
6840 | - $relControl->dataBind(); |
|
6841 | - } |
|
6842 | - break; |
|
6843 | - } |
|
6844 | - } |
|
6845 | - break; |
|
6846 | - } |
|
6847 | - } |
|
6848 | - catch (Exception $ex) |
|
6849 | - { |
|
6850 | - if ($throwExceptions) |
|
6851 | - throw $ex; |
|
6852 | - } |
|
6853 | - } |
|
6854 | - } |
|
6855 | - public function tryToUpdateAR($arObj, $throwExceptions = false) |
|
6856 | - { |
|
6857 | - $objAttrs = get_class_vars(get_class($arObj)); |
|
6858 | - foreach (array_keys($objAttrs) as $key) |
|
6859 | - { |
|
6860 | - try |
|
6861 | - { |
|
6862 | - if ($key == "RELATIONS") |
|
6863 | - break; |
|
6864 | - $control = $this->{$key}; |
|
6865 | - if ($control instanceof TTextBox) |
|
6866 | - $arObj->{$key} = $control->Text; |
|
6867 | - elseif ($control instanceof TCheckBox) |
|
6868 | - $arObj->{$key} = $control->Checked; |
|
6869 | - elseif ($control instanceof TDatePicker) |
|
6870 | - $arObj->{$key} = $control->Date; |
|
6871 | - } |
|
6872 | - catch (Exception $ex) |
|
6873 | - { |
|
6874 | - if ($throwExceptions) |
|
6875 | - throw $ex; |
|
6876 | - } |
|
6877 | - } |
|
6878 | - } |
|
6808 | + public function tryToUpdateView($arObj, $throwExceptions = false) |
|
6809 | + { |
|
6810 | + $objAttrs = get_class_vars(get_class($arObj)); |
|
6811 | + foreach (array_keys($objAttrs) as $key) |
|
6812 | + { |
|
6813 | + try |
|
6814 | + { |
|
6815 | + if ($key != "RELATIONS") |
|
6816 | + { |
|
6817 | + $control = $this->{$key}; |
|
6818 | + if ($control instanceof TTextBox) |
|
6819 | + $control->Text = $arObj->{$key}; |
|
6820 | + elseif ($control instanceof TCheckBox) |
|
6821 | + $control->Checked = (boolean) $arObj->{$key}; |
|
6822 | + elseif ($control instanceof TDatePicker) |
|
6823 | + $control->Date = $arObj->{$key}; |
|
6824 | + } |
|
6825 | + else |
|
6826 | + { |
|
6827 | + foreach ($objAttrs["RELATIONS"] as $relKey => $relValues) |
|
6828 | + { |
|
6829 | + $relControl = $this->{$relKey}; |
|
6830 | + switch ($relValues[0]) |
|
6831 | + { |
|
6832 | + case TActiveRecord::BELONGS_TO: |
|
6833 | + case TActiveRecord::HAS_ONE: |
|
6834 | + $relControl->Text = $arObj->{$relKey}; |
|
6835 | + break; |
|
6836 | + case TActiveRecord::HAS_MANY: |
|
6837 | + if ($relControl instanceof TListControl) |
|
6838 | + { |
|
6839 | + $relControl->DataSource = $arObj->{$relKey}; |
|
6840 | + $relControl->dataBind(); |
|
6841 | + } |
|
6842 | + break; |
|
6843 | + } |
|
6844 | + } |
|
6845 | + break; |
|
6846 | + } |
|
6847 | + } |
|
6848 | + catch (Exception $ex) |
|
6849 | + { |
|
6850 | + if ($throwExceptions) |
|
6851 | + throw $ex; |
|
6852 | + } |
|
6853 | + } |
|
6854 | + } |
|
6855 | + public function tryToUpdateAR($arObj, $throwExceptions = false) |
|
6856 | + { |
|
6857 | + $objAttrs = get_class_vars(get_class($arObj)); |
|
6858 | + foreach (array_keys($objAttrs) as $key) |
|
6859 | + { |
|
6860 | + try |
|
6861 | + { |
|
6862 | + if ($key == "RELATIONS") |
|
6863 | + break; |
|
6864 | + $control = $this->{$key}; |
|
6865 | + if ($control instanceof TTextBox) |
|
6866 | + $arObj->{$key} = $control->Text; |
|
6867 | + elseif ($control instanceof TCheckBox) |
|
6868 | + $arObj->{$key} = $control->Checked; |
|
6869 | + elseif ($control instanceof TDatePicker) |
|
6870 | + $arObj->{$key} = $control->Date; |
|
6871 | + } |
|
6872 | + catch (Exception $ex) |
|
6873 | + { |
|
6874 | + if ($throwExceptions) |
|
6875 | + throw $ex; |
|
6876 | + } |
|
6877 | + } |
|
6878 | + } |
|
6879 | 6879 | } |
6880 | 6880 | class TForm extends TControl |
6881 | 6881 | { |
@@ -7536,13 +7536,13 @@ discard block |
||
7536 | 7536 | { |
7537 | 7537 | Prado::using('System.Web.UI.ActiveControls.TActivePageAdapter'); |
7538 | 7538 | $this->setAdapter(new TActivePageAdapter($this)); |
7539 | - $callbackEventParameter = $this->getRequest()->itemAt(TPage::FIELD_CALLBACK_PARAMETER); |
|
7540 | - if(strlen($callbackEventParameter) > 0) |
|
7541 | - $this->_postData[TPage::FIELD_CALLBACK_PARAMETER]=TJavaScript::jsonDecode((string)$callbackEventParameter); |
|
7542 | - if (($g=$this->getApplication()->getGlobalization(false))!==null && |
|
7543 | - strtoupper($enc=$g->getCharset())!='UTF-8') |
|
7544 | - foreach ($this->_postData as $k=>$v) |
|
7545 | - $this->_postData[$k]=self::decodeUTF8($v, $enc); |
|
7539 | + $callbackEventParameter = $this->getRequest()->itemAt(TPage::FIELD_CALLBACK_PARAMETER); |
|
7540 | + if(strlen($callbackEventParameter) > 0) |
|
7541 | + $this->_postData[TPage::FIELD_CALLBACK_PARAMETER]=TJavaScript::jsonDecode((string)$callbackEventParameter); |
|
7542 | + if (($g=$this->getApplication()->getGlobalization(false))!==null && |
|
7543 | + strtoupper($enc=$g->getCharset())!='UTF-8') |
|
7544 | + foreach ($this->_postData as $k=>$v) |
|
7545 | + $this->_postData[$k]=self::decodeUTF8($v, $enc); |
|
7546 | 7546 | $this->onPreInit(null); |
7547 | 7547 | $this->initRecursive(); |
7548 | 7548 | $this->onInitComplete(null); |
@@ -9127,15 +9127,15 @@ discard block |
||
9127 | 9127 | $component=new ReflectionClass('TComponent'); |
9128 | 9128 | $behaviors=$component->getStaticProperties(); |
9129 | 9129 | if(!isset($behaviors['_um'])) |
9130 | - return false; |
|
9130 | + return false; |
|
9131 | 9131 | foreach($behaviors['_um'] as $name=>$list) |
9132 | 9132 | { |
9133 | - if(strtolower($class->getShortName())!==$name && !$class->isSubclassOf($name)) continue; |
|
9134 | - foreach($list as $param) |
|
9135 | - { |
|
9136 | - if(method_exists($param->getBehavior(),$method)) |
|
9137 | - return true; |
|
9138 | - } |
|
9133 | + if(strtolower($class->getShortName())!==$name && !$class->isSubclassOf($name)) continue; |
|
9134 | + foreach($list as $param) |
|
9135 | + { |
|
9136 | + if(method_exists($param->getBehavior(),$method)) |
|
9137 | + return true; |
|
9138 | + } |
|
9139 | 9139 | } |
9140 | 9140 | return false; |
9141 | 9141 | } |
@@ -1,13 +1,13 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * TJuiProgressbar class file. |
|
4 | - * |
|
5 | - * @author Fabio Bas <ctrlaltca[at]gmail[dot]com> |
|
6 | - * @link https://github.com/pradosoft/prado |
|
7 | - * @copyright Copyright © 2013-2015 PradoSoft |
|
8 | - * @license https://github.com/pradosoft/prado/blob/master/COPYRIGHT |
|
9 | - * @package System.Web.UI.JuiControls |
|
10 | - */ |
|
3 | + * TJuiProgressbar class file. |
|
4 | + * |
|
5 | + * @author Fabio Bas <ctrlaltca[at]gmail[dot]com> |
|
6 | + * @link https://github.com/pradosoft/prado |
|
7 | + * @copyright Copyright © 2013-2015 PradoSoft |
|
8 | + * @license https://github.com/pradosoft/prado/blob/master/COPYRIGHT |
|
9 | + * @package System.Web.UI.JuiControls |
|
10 | + */ |
|
11 | 11 | |
12 | 12 | Prado::using('System.Web.UI.JuiControls.TJuiControlAdapter'); |
13 | 13 | Prado::using('System.Web.UI.ActiveControls.TActivePanel'); |