@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | protected function getRecordPropertyValues($record) |
59 | 59 | { |
60 | 60 | $data = []; |
61 | - foreach ($this->getTableInfo()->getColumns() as $name => $column) { |
|
61 | + foreach($this->getTableInfo()->getColumns() as $name => $column) { |
|
62 | 62 | $data[] = $record->getColumnValue($name); |
63 | 63 | } |
64 | 64 | return $data; |
@@ -71,8 +71,8 @@ discard block |
||
71 | 71 | protected function getRecordPkValues($record) |
72 | 72 | { |
73 | 73 | $data = []; |
74 | - foreach ($this->getTableInfo()->getColumns() as $name => $column) { |
|
75 | - if ($column->getIsPrimaryKey()) { |
|
74 | + foreach($this->getTableInfo()->getColumns() as $name => $column) { |
|
75 | + if($column->getIsPrimaryKey()) { |
|
76 | 76 | $data[] = $record->getColumnValue($name); |
77 | 77 | } |
78 | 78 | } |
@@ -124,10 +124,10 @@ discard block |
||
124 | 124 | */ |
125 | 125 | protected function getRecordObject($pk = null) |
126 | 126 | { |
127 | - if ($this->_record === null) { |
|
128 | - if ($pk !== null) { |
|
127 | + if($this->_record === null) { |
|
128 | + if($pk !== null) { |
|
129 | 129 | $this->_record = $this->getRecordFinder()->findByPk($pk); |
130 | - if ($this->_record === null) { |
|
130 | + if($this->_record === null) { |
|
131 | 131 | throw new TConfigurationException( |
132 | 132 | 'scaffold_invalid_record_pk', |
133 | 133 | $this->getRecordClass(), |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | } |
137 | 137 | } else { |
138 | 138 | $class = $this->getRecordClass(); |
139 | - if ($class !== null) { |
|
139 | + if($class !== null) { |
|
140 | 140 | $this->_record = Prado::createComponent($class); |
141 | 141 | } else { |
142 | 142 | throw new TConfigurationException( |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | public function onPreRender($param) |
205 | 205 | { |
206 | 206 | parent::onPreRender($param); |
207 | - if ($this->getEnableDefaultStyle()) { |
|
207 | + if($this->getEnableDefaultStyle()) { |
|
208 | 208 | $url = $this->publishAsset($this->getDefaultStyle() . '.css'); |
209 | 209 | $this->getPage()->getClientScript()->registerStyleSheetFile($url, $url); |
210 | 210 | } |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | */ |
64 | 64 | public function onLoad($param) |
65 | 65 | { |
66 | - if ($this->getVisible()) { |
|
66 | + if($this->getVisible()) { |
|
67 | 67 | $this->initializeEditForm(); |
68 | 68 | } |
69 | 69 | } |
@@ -117,12 +117,12 @@ discard block |
||
117 | 117 | { |
118 | 118 | $record = $this->getCurrentRecord(); |
119 | 119 | $classPath = $this->getEditRenderer(); |
120 | - if ($classPath === '') { |
|
120 | + if($classPath === '') { |
|
121 | 121 | $columns = $this->getTableInfo()->getColumns(); |
122 | 122 | $this->getInputRepeater()->setDataSource($columns); |
123 | 123 | $this->getInputRepeater()->dataBind(); |
124 | 124 | } else { |
125 | - if ($this->_editRenderer === null) { |
|
125 | + if($this->_editRenderer === null) { |
|
126 | 126 | $this->createEditRenderer($record, $classPath); |
127 | 127 | } else { |
128 | 128 | $this->_editRenderer->setData($record); |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | protected function createEditRenderer($record, $classPath) |
141 | 141 | { |
142 | 142 | $this->_editRenderer = Prado::createComponent($classPath); |
143 | - if ($this->_editRenderer instanceof IScaffoldEditRenderer) { |
|
143 | + if($this->_editRenderer instanceof IScaffoldEditRenderer) { |
|
144 | 144 | $index = $this->getControls()->remove($this->getInputRepeater()); |
145 | 145 | $this->getControls()->insertAt($index, $this->_editRenderer); |
146 | 146 | $this->_editRenderer->setData($record); |
@@ -159,10 +159,10 @@ discard block |
||
159 | 159 | protected function createRepeaterEditItem($sender, $param) |
160 | 160 | { |
161 | 161 | $type = $param->getItem()->getItemType(); |
162 | - if ($type == TListItemType::Item || $type == TListItemType::AlternatingItem) { |
|
162 | + if($type == TListItemType::Item || $type == TListItemType::AlternatingItem) { |
|
163 | 163 | $item = $param->getItem(); |
164 | 164 | $column = $item->getData(); |
165 | - if ($column === null) { |
|
165 | + if($column === null) { |
|
166 | 166 | return; |
167 | 167 | } |
168 | 168 | |
@@ -178,7 +178,7 @@ discard block |
||
178 | 178 | */ |
179 | 179 | public function bubbleEvent($sender, $param) |
180 | 180 | { |
181 | - switch (strtolower($param->getCommandName())) { |
|
181 | + switch(strtolower($param->getCommandName())) { |
|
182 | 182 | case 'save': |
183 | 183 | return $this->doSave() ? false : true; |
184 | 184 | case 'clear': |
@@ -196,12 +196,12 @@ discard block |
||
196 | 196 | */ |
197 | 197 | protected function doSave() |
198 | 198 | { |
199 | - if ($this->getPage()->getIsValid()) { |
|
199 | + if($this->getPage()->getIsValid()) { |
|
200 | 200 | $record = $this->getCurrentRecord(); |
201 | - if ($this->_editRenderer === null) { |
|
201 | + if($this->_editRenderer === null) { |
|
202 | 202 | $table = $this->getTableInfo(); |
203 | 203 | $builder = $this->getScaffoldInputBuilder($record); |
204 | - foreach ($this->getInputRepeater()->getItems() as $item) { |
|
204 | + foreach($this->getInputRepeater()->getItems() as $item) { |
|
205 | 205 | $column = $table->getColumn($item->getCustomData()); |
206 | 206 | $builder->loadScaffoldInput($this, $item, $column, $record); |
207 | 207 | } |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | } |
211 | 211 | $record->save(); |
212 | 212 | return true; |
213 | - } elseif ($this->_editRenderer !== null) { |
|
213 | + } elseif($this->_editRenderer !== null) { |
|
214 | 214 | //preserve the form data. |
215 | 215 | $this->_editRenderer->updateRecord($this->getCurrentRecord()); |
216 | 216 | } |
@@ -263,7 +263,7 @@ discard block |
||
263 | 263 | { |
264 | 264 | static $_builders = []; |
265 | 265 | $class = get_class($record); |
266 | - if (!isset($_builders[$class])) { |
|
266 | + if(!isset($_builders[$class])) { |
|
267 | 267 | $_builders[$class] = TScaffoldInputBase::createInputBuilder($record); |
268 | 268 | } |
269 | 269 | return $_builders[$class]; |
@@ -64,11 +64,11 @@ discard block |
||
64 | 64 | $table = $this->getTableInfo(); |
65 | 65 | $sorts = ['Sort By', str_repeat('-', 15)]; |
66 | 66 | $headers = []; |
67 | - foreach ($table->getColumns() as $name => $colum) { |
|
67 | + foreach($table->getColumns() as $name => $colum) { |
|
68 | 68 | $fname = ucwords(str_replace('_', ' ', $name)); |
69 | 69 | $sorts[$name . ' ASC'] = $fname . ' Ascending'; |
70 | 70 | $sorts[$name . ' DESC'] = $fname . ' Descending'; |
71 | - $headers[] = $fname ; |
|
71 | + $headers[] = $fname; |
|
72 | 72 | } |
73 | 73 | $this->_sort->setDataSource($sorts); |
74 | 74 | $this->_sort->dataBind(); |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | public function onPreRender($param) |
83 | 83 | { |
84 | 84 | parent::onPreRender($param); |
85 | - if (!$this->getPage()->getIsPostBack() || $this->getViewState('CurrentClass') != $this->getRecordClass()) { |
|
85 | + if(!$this->getPage()->getIsPostBack() || $this->getViewState('CurrentClass') != $this->getRecordClass()) { |
|
86 | 86 | $this->initializeSort(); |
87 | 87 | $this->setViewState('CurrentClass', $this->getRecordClass()); |
88 | 88 | } |
@@ -110,18 +110,18 @@ discard block |
||
110 | 110 | $total = $this->_list->getVirtualItemCount(); |
111 | 111 | $limit = $this->_list->getPageSize(); |
112 | 112 | $offset = $this->_list->getCurrentPageIndex() * $limit; |
113 | - if ($offset + $limit > $total) { |
|
113 | + if($offset + $limit > $total) { |
|
114 | 114 | $limit = $total - $offset; |
115 | 115 | } |
116 | 116 | $criteria = new TActiveRecordCriteria($this->getSearchCondition(), $this->getSearchParameters()); |
117 | - if ($limit > 0) { |
|
117 | + if($limit > 0) { |
|
118 | 118 | $criteria->setLimit($limit); |
119 | - if ($offset <= $total) { |
|
119 | + if($offset <= $total) { |
|
120 | 120 | $criteria->setOffset($offset); |
121 | 121 | } |
122 | 122 | } |
123 | 123 | $order = explode(' ', $this->_sort->getSelectedValue(), 2); |
124 | - if (is_array($order) && count($order) === 2) { |
|
124 | + if(is_array($order) && count($order) === 2) { |
|
125 | 125 | $criteria->OrdersBy[$order[0]] = $order[1]; |
126 | 126 | } |
127 | 127 | return $criteria; |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | */ |
165 | 165 | public function bubbleEvent($sender, $param) |
166 | 166 | { |
167 | - switch (strtolower($param->getCommandName())) { |
|
167 | + switch(strtolower($param->getCommandName())) { |
|
168 | 168 | case 'delete': |
169 | 169 | return $this->deleteRecord($sender, $param); |
170 | 170 | case 'edit': |
@@ -179,8 +179,8 @@ discard block |
||
179 | 179 | */ |
180 | 180 | protected function initializeEdit($sender, $param) |
181 | 181 | { |
182 | - if (($ctrl = $this->getEditViewControl()) !== null) { |
|
183 | - if ($param instanceof TRepeaterCommandEventParameter) { |
|
182 | + if(($ctrl = $this->getEditViewControl()) !== null) { |
|
183 | + if($param instanceof TRepeaterCommandEventParameter) { |
|
184 | 184 | $pk = $param->getItem()->getCustomData(); |
185 | 185 | $ctrl->setRecordPk($pk); |
186 | 186 | $ctrl->initializeEditForm(); |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | */ |
194 | 194 | protected function deleteRecord($sender, $param) |
195 | 195 | { |
196 | - if ($param instanceof TRepeaterCommandEventParameter) { |
|
196 | + if($param instanceof TRepeaterCommandEventParameter) { |
|
197 | 197 | $pk = $param->getItem()->getCustomData(); |
198 | 198 | $this->getRecordFinder()->deleteByPk($pk); |
199 | 199 | } |
@@ -205,9 +205,9 @@ discard block |
||
205 | 205 | protected function listItemCreated($sender, $param) |
206 | 206 | { |
207 | 207 | $item = $param->getItem(); |
208 | - if ($item instanceof IItemDataRenderer) { |
|
208 | + if($item instanceof IItemDataRenderer) { |
|
209 | 209 | $type = $item->getItemType(); |
210 | - if ($type == TListItemType::Item || $type == TListItemType::AlternatingItem) { |
|
210 | + if($type == TListItemType::Item || $type == TListItemType::AlternatingItem) { |
|
211 | 211 | $this->populateField($sender, $param); |
212 | 212 | } |
213 | 213 | } |
@@ -220,9 +220,9 @@ discard block |
||
220 | 220 | protected function populateField($sender, $param) |
221 | 221 | { |
222 | 222 | $item = $param->getItem(); |
223 | - if (($data = $item->getData()) !== null) { |
|
223 | + if(($data = $item->getData()) !== null) { |
|
224 | 224 | $item->setCustomData($this->getRecordPkValues($data)); |
225 | - if (($prop = $item->findControl('_properties')) !== null) { |
|
225 | + if(($prop = $item->findControl('_properties')) !== null) { |
|
226 | 226 | $item->_properties->setDataSource($this->getRecordPropertyValues($data)); |
227 | 227 | $item->_properties->dataBind(); |
228 | 228 | } |
@@ -294,9 +294,9 @@ discard block |
||
294 | 294 | */ |
295 | 295 | protected function getEditViewControl() |
296 | 296 | { |
297 | - if (($id = $this->getEditViewID()) !== null) { |
|
297 | + if(($id = $this->getEditViewID()) !== null) { |
|
298 | 298 | $ctrl = $this->getParent()->findControl($id); |
299 | - if ($ctrl === null) { |
|
299 | + if($ctrl === null) { |
|
300 | 300 | throw new TConfigurationException('scaffold_unable_to_find_edit_view', $id); |
301 | 301 | } |
302 | 302 | return $ctrl; |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | { |
17 | 17 | protected function createControl($container, $column, $record) |
18 | 18 | { |
19 | - switch (strtolower($column->getDbType())) { |
|
19 | + switch(strtolower($column->getDbType())) { |
|
20 | 20 | case 'bit': |
21 | 21 | return $this->createBooleanControl($container, $column, $record); |
22 | 22 | case 'text': |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | return $this->createDateTimeControl($container, $column, $record); |
30 | 30 | default: |
31 | 31 | $control = $this->createDefaultControl($container, $column, $record); |
32 | - if ($column->getIsExcluded()) { |
|
32 | + if($column->getIsExcluded()) { |
|
33 | 33 | $control->setEnabled(false); |
34 | 34 | } |
35 | 35 | return $control; |
@@ -38,14 +38,14 @@ discard block |
||
38 | 38 | |
39 | 39 | protected function getControlValue($container, $column, $record) |
40 | 40 | { |
41 | - switch (strtolower($column->getDbType())) { |
|
41 | + switch(strtolower($column->getDbType())) { |
|
42 | 42 | case 'boolean': |
43 | 43 | return $container->findControl(self::DEFAULT_ID)->getChecked(); |
44 | 44 | case 'datetime': case 'smalldatetime': |
45 | 45 | return $this->getDateTimeValue($container, $column, $record); |
46 | 46 | default: |
47 | 47 | $value = $this->getDefaultControlValue($container, $column, $record); |
48 | - if (trim($value) === '' && $column->getAllowNull()) { |
|
48 | + if(trim($value) === '' && $column->getAllowNull()) { |
|
49 | 49 | return null; |
50 | 50 | } else { |
51 | 51 | return $value; |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | { |
28 | 28 | $record->getDbConnection()->setActive(true); //must be connected before retrieving driver name! |
29 | 29 | $driver = $record->getDbConnection()->getDriverName(); |
30 | - switch (strtolower($driver)) { |
|
30 | + switch(strtolower($driver)) { |
|
31 | 31 | case 'sqlite': //sqlite 3 |
32 | 32 | case 'sqlite2': //sqlite 2 |
33 | 33 | require_once(dirname(__FILE__) . '/TSqliteScaffoldInput.php'); |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | $this->_parent = $parent; |
59 | 59 | $item->setCustomData($column->getColumnId()); |
60 | 60 | $this->createControl($item->_input, $column, $record); |
61 | - if ($item->_input->findControl(self::DEFAULT_ID)) { |
|
61 | + if($item->_input->findControl(self::DEFAULT_ID)) { |
|
62 | 62 | $this->createControlLabel($item->_label, $column, $record); |
63 | 63 | } |
64 | 64 | } |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | public function loadScaffoldInput($parent, $item, $column, $record) |
74 | 74 | { |
75 | 75 | $this->_parent = $parent; |
76 | - if ($this->getIsEnabled($column, $record)) { |
|
76 | + if($this->getIsEnabled($column, $record)) { |
|
77 | 77 | $prop = $column->getColumnId(); |
78 | 78 | $record->setColumnValue($prop, $this->getControlValue($item->_input, $column, $record)); |
79 | 79 | } |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | protected function getRecordPropertyValue($column, $record) |
89 | 89 | { |
90 | 90 | $value = $record->getColumnValue($column->getColumnId()); |
91 | - if ($column->getDefaultValue() !== TDbTableColumn::UNDEFINED_VALUE && $value === null) { |
|
91 | + if($column->getDefaultValue() !== TDbTableColumn::UNDEFINED_VALUE && $value === null) { |
|
92 | 92 | return $column->getDefaultValue(); |
93 | 93 | } else { |
94 | 94 | return $value; |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | { |
18 | 18 | protected function createControl($container, $column, $record) |
19 | 19 | { |
20 | - switch (strtolower($column->getDbType())) { |
|
20 | + switch(strtolower($column->getDbType())) { |
|
21 | 21 | case 'date': |
22 | 22 | return $this->createDateControl($container, $column, $record); |
23 | 23 | case 'time': |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | |
38 | 38 | protected function getControlValue($container, $column, $record) |
39 | 39 | { |
40 | - switch (strtolower($column->getDbType())) { |
|
40 | + switch(strtolower($column->getDbType())) { |
|
41 | 41 | case 'date': |
42 | 42 | return $container->findControl(self::DEFAULT_ID)->getDate(); |
43 | 43 | case 'time': |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | { |
17 | 17 | protected function createControl($container, $column, $record) |
18 | 18 | { |
19 | - switch (strtolower($column->getDbType())) { |
|
19 | + switch(strtolower($column->getDbType())) { |
|
20 | 20 | case 'boolean': |
21 | 21 | return $this->createBooleanControl($container, $column, $record); |
22 | 22 | case 'date': |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | |
39 | 39 | protected function getControlValue($container, $column, $record) |
40 | 40 | { |
41 | - switch (strtolower($column->getDbType())) { |
|
41 | + switch(strtolower($column->getDbType())) { |
|
42 | 42 | case 'boolean': |
43 | 43 | return $container->findControl(self::DEFAULT_ID)->getChecked(); |
44 | 44 | case 'date': |
@@ -16,8 +16,8 @@ discard block |
||
16 | 16 | { |
17 | 17 | protected function createControl($container, $column, $record) |
18 | 18 | { |
19 | - $dbtype = trim(str_replace(['unsigned', 'zerofill'], ['','',], strtolower($column->getDbType()))); |
|
20 | - switch ($dbtype) { |
|
19 | + $dbtype = trim(str_replace(['unsigned', 'zerofill'], ['', '', ], strtolower($column->getDbType()))); |
|
20 | + switch($dbtype) { |
|
21 | 21 | case 'date': |
22 | 22 | return $this->createDateControl($container, $column, $record); |
23 | 23 | case 'blob': case 'tinyblob': case 'mediumblob': case 'longblob': |
@@ -44,8 +44,8 @@ discard block |
||
44 | 44 | |
45 | 45 | protected function getControlValue($container, $column, $record) |
46 | 46 | { |
47 | - $dbtype = trim(str_replace(['unsigned', 'zerofill'], ['','',], strtolower($column->getDbType()))); |
|
48 | - switch ($dbtype) { |
|
47 | + $dbtype = trim(str_replace(['unsigned', 'zerofill'], ['', '', ], strtolower($column->getDbType()))); |
|
48 | + switch($dbtype) { |
|
49 | 49 | case 'date': |
50 | 50 | return $container->findControl(self::DEFAULT_ID)->getDate(); |
51 | 51 | case 'year': |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | |
68 | 68 | protected function createIntegerControl($container, $column, $record) |
69 | 69 | { |
70 | - if ($column->getColumnSize() == 1) { |
|
70 | + if($column->getColumnSize() == 1) { |
|
71 | 71 | return $this->createBooleanControl($container, $column, $record); |
72 | 72 | } else { |
73 | 73 | parent::createIntegerControl($container, $column, $record); |
@@ -76,8 +76,8 @@ discard block |
||
76 | 76 | |
77 | 77 | protected function getIntBooleanValue($container, $column, $record) |
78 | 78 | { |
79 | - if ($column->getColumnSize() == 1) { |
|
80 | - return (int)$container->findControl(self::DEFAULT_ID)->getChecked(); |
|
79 | + if($column->getColumnSize() == 1) { |
|
80 | + return (int) $container->findControl(self::DEFAULT_ID)->getChecked(); |
|
81 | 81 | } else { |
82 | 82 | return $this->getDefaultControlValue($container, $column, $record); |
83 | 83 | } |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | { |
17 | 17 | protected function createControl($container, $column, $record) |
18 | 18 | { |
19 | - switch (strtolower($column->getDbType())) { |
|
19 | + switch(strtolower($column->getDbType())) { |
|
20 | 20 | case 'boolean': |
21 | 21 | return $this->createBooleanControl($container, $column, $record); |
22 | 22 | case 'date': |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | |
42 | 42 | protected function getControlValue($container, $column, $record) |
43 | 43 | { |
44 | - switch (strtolower($column->getDbType())) { |
|
44 | + switch(strtolower($column->getDbType())) { |
|
45 | 45 | case 'boolean': |
46 | 46 | return $container->findControl(self::DEFAULT_ID)->getChecked(); |
47 | 47 | case 'date': |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | { |
62 | 62 | $control = parent::createDateControl($container, $column, $record); |
63 | 63 | $value = $this->getRecordPropertyValue($column, $record); |
64 | - if (!empty($value) && preg_match('/timestamp/i', $column->getDbType())) { |
|
64 | + if(!empty($value) && preg_match('/timestamp/i', $column->getDbType())) { |
|
65 | 65 | $control->setTimestamp(intval($value)); |
66 | 66 | } |
67 | 67 | return $control; |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | { |
72 | 72 | $value = $this->getRecordPropertyValue($column, $record); |
73 | 73 | $time = parent::createDateTimeControl($container, $column, $record); |
74 | - if (!empty($value) && preg_match('/timestamp/i', $column->getDbType())) { |
|
74 | + if(!empty($value) && preg_match('/timestamp/i', $column->getDbType())) { |
|
75 | 75 | $dt = new \DateTime; |
76 | 76 | $dt->setTimestamp(intval($value)); |
77 | 77 | $time[1]->setSelectedValue($dt->format('G')); |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | |
84 | 84 | protected function getDateTimeValue($container, $column, $record) |
85 | 85 | { |
86 | - if (preg_match('/timestamp/i', $column->getDbType())) { |
|
86 | + if(preg_match('/timestamp/i', $column->getDbType())) { |
|
87 | 87 | $time = $container->findControl(self::DEFAULT_ID)->getTimestamp(); |
88 | 88 | $dt = new \DateTime; |
89 | 89 | $dt->setTimestamp($time); |