@@ -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 |
@@ -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 |
@@ -120,11 +120,11 @@ discard block |
||
120 | 120 | } |
121 | 121 | } |
122 | 122 | |
123 | - /** |
|
124 | - * Clears all existing selections on the client side. |
|
125 | - */ |
|
126 | - public function clearSelection() |
|
127 | - { |
|
123 | + /** |
|
124 | + * Clears all existing selections on the client side. |
|
125 | + */ |
|
126 | + public function clearSelection() |
|
127 | + { |
|
128 | 128 | if($this->canUpdateClientSide()) |
129 | 129 | { |
130 | 130 | $this->updateListItems(); |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | $this->getPage()->getCallbackClient()->select($this->getControl(), 'Clear'); |
138 | 138 | } |
139 | 139 | } |
140 | - } |
|
140 | + } |
|
141 | 141 | |
142 | 142 | /** |
143 | 143 | * Update the client-side list options. |
@@ -78,8 +78,8 @@ |
||
78 | 78 | } |
79 | 79 | |
80 | 80 | /** |
81 | - * Publish the ajax script |
|
82 | - */ |
|
81 | + * Publish the ajax script |
|
82 | + */ |
|
83 | 83 | public function onPreRender($param) |
84 | 84 | { |
85 | 85 | parent::onPreRender($param); |
@@ -173,15 +173,15 @@ |
||
173 | 173 | { |
174 | 174 | if(($forControl=$this->getForControl())==='') |
175 | 175 | throw new TConfigurationException('keyboard_forcontrol_required'); |
176 | - if(($target=$this->findControl($forControl))===null) |
|
177 | - throw new TConfigurationException('keyboard_forcontrol_invalid',$forControl); |
|
176 | + if(($target=$this->findControl($forControl))===null) |
|
177 | + throw new TConfigurationException('keyboard_forcontrol_invalid',$forControl); |
|
178 | 178 | |
179 | - $options['ID'] = $this->getClientID(); |
|
180 | - $options['ForControl'] = $target->getClientID(); |
|
181 | - $options['AutoHide'] = $this->getAutoHide(); |
|
182 | - $options['CssClass'] = $this->getKeyboardCssClass(); |
|
179 | + $options['ID'] = $this->getClientID(); |
|
180 | + $options['ForControl'] = $target->getClientID(); |
|
181 | + $options['AutoHide'] = $this->getAutoHide(); |
|
182 | + $options['CssClass'] = $this->getKeyboardCssClass(); |
|
183 | 183 | |
184 | - return $options; |
|
184 | + return $options; |
|
185 | 185 | } |
186 | 186 | } |
187 | 187 |
@@ -101,7 +101,7 @@ |
||
101 | 101 | |
102 | 102 | /** |
103 | 103 | * Sets the horizontal alignment of the contents within the panel. |
104 | - * Valid values include 'NotSet', 'Justify', 'Left', 'Right', 'Center' |
|
104 | + * Valid values include 'NotSet', 'Justify', 'Left', 'Right', 'Center' |
|
105 | 105 | * @param string the horizontal alignment |
106 | 106 | */ |
107 | 107 | public function setHorizontalAlign($value) |
@@ -68,9 +68,9 @@ discard block |
||
68 | 68 | } |
69 | 69 | |
70 | 70 | /** |
71 | - * Creates a new callback control, sets the adapter to |
|
72 | - * TActiveControlAdapter. |
|
73 | - */ |
|
71 | + * Creates a new callback control, sets the adapter to |
|
72 | + * TActiveControlAdapter. |
|
73 | + */ |
|
74 | 74 | public function __construct() { |
75 | 75 | parent::__construct(); |
76 | 76 | $this->setAdapter(new TActiveControlAdapter($this)); |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | * @param string $value container tag |
112 | 112 | */ |
113 | 113 | public function setSurroundingTag($value) { |
114 | - $this->_surroundingTag=TPropertyValue::ensureString($value); |
|
114 | + $this->_surroundingTag=TPropertyValue::ensureString($value); |
|
115 | 115 | } |
116 | 116 | |
117 | 117 | /** |