@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | // <editor-fold defaultstate="collapsed" desc="Page Generation"> |
50 | 50 | public function generate($tableName, $viewType) |
51 | 51 | { |
52 | - switch ($viewType) |
|
52 | + switch($viewType) |
|
53 | 53 | { |
54 | 54 | default: |
55 | 55 | case self::LIST_TYPE: |
@@ -90,21 +90,21 @@ discard block |
||
90 | 90 | { |
91 | 91 | $code = ""; |
92 | 92 | $tableInfo = $this->_dbMetaData->getTableInfo($tableName); |
93 | - switch ($type) |
|
93 | + switch($type) |
|
94 | 94 | { |
95 | 95 | case self::LIST_TYPE: |
96 | 96 | break; |
97 | 97 | case self::ADD_TYPE: |
98 | - foreach ($tableInfo->getColumns() as $colField => $colMetadata) |
|
98 | + foreach($tableInfo->getColumns() as $colField => $colMetadata) |
|
99 | 99 | { |
100 | - if (!$colMetadata->IsPrimaryKey && !$colMetadata->IsForeignKey) |
|
100 | + if(!$colMetadata->IsPrimaryKey && !$colMetadata->IsForeignKey) |
|
101 | 101 | { |
102 | 102 | $code .= $this->generateControl($colMetadata); |
103 | 103 | $code .= $this->generateValidators($colMetadata); |
104 | 104 | $code .= "\n"; |
105 | 105 | } |
106 | 106 | } |
107 | - foreach ($tableInfo->getForeignKeys() as $colField => $colMetadata) |
|
107 | + foreach($tableInfo->getForeignKeys() as $colField => $colMetadata) |
|
108 | 108 | { |
109 | 109 | $colField = $this->eq($colMetadata["table"]); |
110 | 110 | $code .= "\t<com:TTextBox ID=$colField />\n"; |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | private function generateControl($colMetadata) |
123 | 123 | { |
124 | 124 | $controlType = "TTextBox"; |
125 | - switch ($colMetadata->DbType) |
|
125 | + switch($colMetadata->DbType) |
|
126 | 126 | { |
127 | 127 | |
128 | 128 | } |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | { |
135 | 135 | $controlId = $colMetadata->ColumnId; |
136 | 136 | $code = ""; |
137 | - if (!$colMetadata->AllowNull) |
|
137 | + if(!$colMetadata->AllowNull) |
|
138 | 138 | { |
139 | 139 | $code .= "\t<com:TRequiredFieldValidator ControlToValidate=$controlId ValidationGroup=\"addGroup\" Text=\"Field $controlId is required.\" Display=\"Dynamic\" />\n"; |
140 | 140 | } |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | |
34 | 34 | public function __construct() |
35 | 35 | { |
36 | - if (!class_exists("TActiveRecordManager", false)) |
|
36 | + if(!class_exists("TActiveRecordManager", false)) |
|
37 | 37 | throw new Exception("You need to enable the ActiveRecord module in your application configuration file."); |
38 | 38 | $ar_manager = TActiveRecordManager::getInstance(); |
39 | 39 | $_conn = $ar_manager->getDbConnection(); |
@@ -44,16 +44,16 @@ discard block |
||
44 | 44 | public function setOpFile($op_file_namespace) |
45 | 45 | { |
46 | 46 | $op_file = Prado::getPathOfNamespace($op_file_namespace); |
47 | - if (empty($op_file)) |
|
47 | + if(empty($op_file)) |
|
48 | 48 | throw new Exception("You need to fix your output folder namespace."); |
49 | - if (!is_dir($op_file)) |
|
49 | + if(!is_dir($op_file)) |
|
50 | 50 | mkdir($op_file, 0777, true); |
51 | 51 | $this->_opFile = $op_file; |
52 | 52 | } |
53 | 53 | |
54 | 54 | public function renderAllTablesInformation() |
55 | 55 | { |
56 | - foreach ($this->getAllTableNames() as $table_name) |
|
56 | + foreach($this->getAllTableNames() as $table_name) |
|
57 | 57 | { |
58 | 58 | echo $table_name . "<br>"; |
59 | 59 | $tableInfo = $this->_dbMetaData->getTableInfo($table_name); |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | { |
69 | 69 | $tableNames = $this->_dbMetaData->findTableNames(); |
70 | 70 | $index = array_search('pradocache', $tableNames); |
71 | - if ($index) |
|
71 | + if($index) |
|
72 | 72 | array_splice($tableNames, $index, 1); |
73 | 73 | return $tableNames; |
74 | 74 | } |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | |
24 | 24 | public function generate($sender) |
25 | 25 | { |
26 | - if ($this->IsValid) |
|
26 | + if($this->IsValid) |
|
27 | 27 | { |
28 | 28 | $tableName = $this->table_name->Text; |
29 | 29 | $outputFolderNs = $this->output_folder->Text; |
@@ -37,10 +37,10 @@ discard block |
||
37 | 37 | $ar_generator->setClasPrefix($classPrefix); |
38 | 38 | $ar_generator->setClassSufix($classSuffix); |
39 | 39 | |
40 | - if ($this->build_rel->Checked) |
|
40 | + if($this->build_rel->Checked) |
|
41 | 41 | $ar_generator->buildRelations(); |
42 | 42 | |
43 | - if ($tableName != "*") |
|
43 | + if($tableName != "*") |
|
44 | 44 | $ar_generator->generate($tableName); |
45 | 45 | else |
46 | 46 | $ar_generator->generateAll(); |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | private function startVisual() |
31 | 31 | { |
32 | 32 | $scf_generator = new TWsatScaffoldingGenerator(); |
33 | - foreach ($scf_generator->getAllTableNames() as $tableName) |
|
33 | + foreach($scf_generator->getAllTableNames() as $tableName) |
|
34 | 34 | { |
35 | 35 | $dynChb = new TCheckBox(); |
36 | 36 | $dynChb->ID = "cb_$tableName"; |
@@ -48,13 +48,13 @@ discard block |
||
48 | 48 | */ |
49 | 49 | public function generate($sender) |
50 | 50 | { |
51 | - if ($this->IsValid) |
|
51 | + if($this->IsValid) |
|
52 | 52 | { |
53 | 53 | try |
54 | 54 | { |
55 | 55 | $scf_generator = new TWsatScaffoldingGenerator(); |
56 | 56 | $scf_generator->setOpFile($this->output_folder->Text); |
57 | - foreach ($scf_generator->getAllTableNames() as $tableName) |
|
57 | + foreach($scf_generator->getAllTableNames() as $tableName) |
|
58 | 58 | { |
59 | 59 | $id = "cb_$tableName"; |
60 | 60 | $obj = $this->tableNames->findControl($id); |
@@ -65,13 +65,13 @@ discard block |
||
65 | 65 | |
66 | 66 | public function generateAll() |
67 | 67 | { |
68 | - foreach ($this->getAllTableNames() as $tableName) |
|
68 | + foreach($this->getAllTableNames() as $tableName) |
|
69 | 69 | { |
70 | 70 | $tableInfo = $this->_dbMetaData->getTableInfo($tableName); |
71 | - if (!empty($this->_relations)) |
|
71 | + if(!empty($this->_relations)) |
|
72 | 72 | { |
73 | 73 | // Cancel generation of M-M relationships middle table |
74 | - if (count($tableInfo->getPrimaryKeys()) === 2 && count($tableInfo->getColumns()) === 2)//M-M relationships |
|
74 | + if(count($tableInfo->getPrimaryKeys()) === 2 && count($tableInfo->getColumns()) === 2)//M-M relationships |
|
75 | 75 | continue; |
76 | 76 | } |
77 | 77 | $this->_commonGenerate($tableName, $tableInfo); |
@@ -81,13 +81,13 @@ discard block |
||
81 | 81 | public function buildRelations() |
82 | 82 | { |
83 | 83 | $this->_relations = []; |
84 | - foreach ($this->getAllTableNames() as $table_name) |
|
84 | + foreach($this->getAllTableNames() as $table_name) |
|
85 | 85 | { |
86 | 86 | $tableInfo = $this->_dbMetaData->getTableInfo($table_name); |
87 | 87 | $pks = $tableInfo->getPrimaryKeys(); |
88 | 88 | $fks = $tableInfo->getForeignKeys(); |
89 | 89 | |
90 | - if (count($pks) === 2 && count($tableInfo->getColumns()) === 2)//M-M relationships |
|
90 | + if(count($pks) === 2 && count($tableInfo->getColumns()) === 2)//M-M relationships |
|
91 | 91 | { |
92 | 92 | $table_name_mm = $fks[0]["table"]; |
93 | 93 | $table_name_mm2 = $fks[1]["table"]; |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | ]; |
108 | 108 | continue; |
109 | 109 | } |
110 | - foreach ($fks as $fk_data)//1-M relationships |
|
110 | + foreach($fks as $fk_data)//1-M relationships |
|
111 | 111 | { |
112 | 112 | $owner_table = $fk_data["table"]; |
113 | 113 | $slave_table = $table_name; |
@@ -136,12 +136,12 @@ discard block |
||
136 | 136 | |
137 | 137 | private function _commonGenerate($tableName, $tableInfo) |
138 | 138 | { |
139 | - if (count($tableInfo->getColumns()) === 0) |
|
139 | + if(count($tableInfo->getColumns()) === 0) |
|
140 | 140 | throw new Exception("Unable to find table or view $tableName in " . $this->_dbMetaData->getDbConnection()->getConnectionString() . "."); |
141 | 141 | else |
142 | 142 | { |
143 | 143 | $properties = []; |
144 | - foreach ($tableInfo->getColumns() as $field => $metadata) |
|
144 | + foreach($tableInfo->getColumns() as $field => $metadata) |
|
145 | 145 | $properties[] = $this->generateProperty($field, $metadata); |
146 | 146 | $toString = $this->_buildSmartToString($tableInfo); |
147 | 147 | } |
@@ -175,11 +175,11 @@ discard block |
||
175 | 175 | |
176 | 176 | private function _renderRelations($tablename) |
177 | 177 | { |
178 | - if (!isset($this->_relations[$tablename])) |
|
178 | + if(!isset($this->_relations[$tablename])) |
|
179 | 179 | return ""; |
180 | 180 | |
181 | 181 | $code = "\tpublic static \$RELATIONS = array ("; |
182 | - foreach ($this->_relations[$tablename] as $rel_data) |
|
182 | + foreach($this->_relations[$tablename] as $rel_data) |
|
183 | 183 | $code .= "\n\t\t'" . $rel_data["prop_name"] . "' => array(" . $rel_data["rel_type"] . ", '" . $rel_data["ref_class_name"] . "', '" . $rel_data["prop_ref"] . "'),"; |
184 | 184 | |
185 | 185 | $code = substr($code, 0, -1); |
@@ -193,11 +193,11 @@ discard block |
||
193 | 193 | $property = "throw new THttpException(500, 'Not implemented yet.');"; |
194 | 194 | try |
195 | 195 | { |
196 | - foreach ($tableInfo->getColumns() as $column) |
|
196 | + foreach($tableInfo->getColumns() as $column) |
|
197 | 197 | { |
198 | - if (isset($column->IsPrimaryKey) && $column->IsPrimaryKey) |
|
198 | + if(isset($column->IsPrimaryKey) && $column->IsPrimaryKey) |
|
199 | 199 | $property = str_replace($this->uqChars, "", $column->ColumnName); |
200 | - elseif ($column->PdoType == PDO::PARAM_STR && $column->DBType != "date") |
|
200 | + elseif($column->PdoType == PDO::PARAM_STR && $column->DBType != "date") |
|
201 | 201 | { |
202 | 202 | $property = str_replace($this->uqChars, "", $column->ColumnName); |
203 | 203 | break; |
@@ -306,7 +306,7 @@ discard block |
||
306 | 306 | // generates unique ID by hashing the runtime path |
307 | 307 | $this->_uniqueID = md5($this->_runtimePath); |
308 | 308 | $this->_parameters = new \Prado\Collections\TMap; |
309 | - $this->_services = [$this->getPageServiceID() => ['TPageService',[],null]]; |
|
309 | + $this->_services = [$this->getPageServiceID() => ['TPageService', [], null]]; |
|
310 | 310 | |
311 | 311 | Prado::setPathOfAlias('Application', $this->_basePath); |
312 | 312 | } |
@@ -384,7 +384,7 @@ discard block |
||
384 | 384 | $this->_step++; |
385 | 385 | } |
386 | 386 | } |
387 | - catch(\Exception $e) |
|
387 | + catch (\Exception $e) |
|
388 | 388 | { |
389 | 389 | $this->onError($e); |
390 | 390 | } |
@@ -419,7 +419,7 @@ discard block |
||
419 | 419 | */ |
420 | 420 | public function getGlobalState($key, $defaultValue = null) |
421 | 421 | { |
422 | - return isset($this->_globals[$key])?$this->_globals[$key]:$defaultValue; |
|
422 | + return isset($this->_globals[$key]) ? $this->_globals[$key] : $defaultValue; |
|
423 | 423 | } |
424 | 424 | |
425 | 425 | /** |
@@ -948,7 +948,7 @@ discard block |
||
948 | 948 | // keep the key to avoid reuse of the old module id |
949 | 949 | $this->_lazyModules[$id] = null; |
950 | 950 | |
951 | - return [$module,$configElement]; |
|
951 | + return [$module, $configElement]; |
|
952 | 952 | } |
953 | 953 | /** |
954 | 954 | * Applies an application configuration. |
@@ -974,7 +974,7 @@ discard block |
||
974 | 974 | } |
975 | 975 | |
976 | 976 | if(empty($this->_services)) |
977 | - $this->_services = [$this->getPageServiceID() => ['Prado\Web\Services\TPageService',[],null]]; |
|
977 | + $this->_services = [$this->getPageServiceID() => ['Prado\Web\Services\TPageService', [], null]]; |
|
978 | 978 | |
979 | 979 | // load parameters |
980 | 980 | foreach($config->getParameters() as $id => $parameter) |
@@ -1238,7 +1238,7 @@ discard block |
||
1238 | 1238 | public function onEndRequest() |
1239 | 1239 | { |
1240 | 1240 | $this->flushOutput(false); // flush all remaining content in the buffer |
1241 | - $this->saveGlobals(); // save global state |
|
1241 | + $this->saveGlobals(); // save global state |
|
1242 | 1242 | $this->raiseEvent('OnEndRequest', $this, null); |
1243 | 1243 | } |
1244 | 1244 | } |
@@ -46,7 +46,7 @@ |
||
46 | 46 | array_shift($args); |
47 | 47 | $n = count($args); |
48 | 48 | $tokens = []; |
49 | - for($i = 0;$i < $n;++$i) |
|
49 | + for($i = 0; $i < $n; ++$i) |
|
50 | 50 | $tokens['{' . $i . '}'] = TPropertyValue::ensureString($args[$i]); |
51 | 51 | parent::__construct(strtr($errorMessage, $tokens)); |
52 | 52 | } |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | array_shift($args); |
56 | 56 | $n = count($args); |
57 | 57 | $tokens = []; |
58 | - for($i = 0;$i < $n;++$i) |
|
58 | + for($i = 0; $i < $n; ++$i) |
|
59 | 59 | $tokens['{' . $i . '}'] = TPropertyValue::ensureString($args[$i]); |
60 | 60 | parent::__construct(strtr($errorMessage, $tokens)); |
61 | 61 | } |
@@ -70,13 +70,13 @@ discard block |
||
70 | 70 | $msgFile = $this->getErrorMessageFile(); |
71 | 71 | |
72 | 72 | // Cache messages |
73 | - if (!isset(self::$_messageCache[$msgFile])) |
|
73 | + if(!isset(self::$_messageCache[$msgFile])) |
|
74 | 74 | { |
75 | 75 | if(($entries = @file($msgFile)) !== false) |
76 | 76 | { |
77 | 77 | foreach($entries as $entry) |
78 | 78 | { |
79 | - list($code, $message) = array_merge(explode('=', $entry, 2), [ '' ]); |
|
79 | + list($code, $message) = array_merge(explode('=', $entry, 2), ['']); |
|
80 | 80 | self::$_messageCache[$msgFile][trim($code)] = trim($message); |
81 | 81 | } |
82 | 82 | } |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | |
196 | 196 | $content = $this->getErrorTemplate($statusCode, $exception); |
197 | 197 | |
198 | - $serverAdmin = isset($_SERVER['SERVER_ADMIN'])?$_SERVER['SERVER_ADMIN']:''; |
|
198 | + $serverAdmin = isset($_SERVER['SERVER_ADMIN']) ? $_SERVER['SERVER_ADMIN'] : ''; |
|
199 | 199 | |
200 | 200 | $isDebug = $this->getApplication()->getMode() === TApplicationMode::Debug; |
201 | 201 | |
@@ -262,7 +262,7 @@ discard block |
||
262 | 262 | if($exception instanceof TTemplateException) |
263 | 263 | { |
264 | 264 | $fileName = $exception->getTemplateFile(); |
265 | - $lines = empty($fileName)?explode("\n", $exception->getTemplateSource()):@file($fileName); |
|
265 | + $lines = empty($fileName) ?explode("\n", $exception->getTemplateSource()) : @file($fileName); |
|
266 | 266 | $source = $this->getSourceCode($lines, $exception->getLineNumber()); |
267 | 267 | if($fileName === '') |
268 | 268 | $fileName = '---embedded template---'; |
@@ -425,11 +425,11 @@ discard block |
||
425 | 425 | |
426 | 426 | private function getSourceCode($lines, $errorLine) |
427 | 427 | { |
428 | - $beginLine = $errorLine - self::SOURCE_LINES >= 0?$errorLine - self::SOURCE_LINES:0; |
|
429 | - $endLine = $errorLine + self::SOURCE_LINES <= count($lines)?$errorLine + self::SOURCE_LINES:count($lines); |
|
428 | + $beginLine = $errorLine - self::SOURCE_LINES >= 0 ? $errorLine - self::SOURCE_LINES : 0; |
|
429 | + $endLine = $errorLine + self::SOURCE_LINES <= count($lines) ? $errorLine + self::SOURCE_LINES : count($lines); |
|
430 | 430 | |
431 | 431 | $source = ''; |
432 | - for($i = $beginLine;$i < $endLine;++$i) |
|
432 | + for($i = $beginLine; $i < $endLine; ++$i) |
|
433 | 433 | { |
434 | 434 | if($i === $errorLine - 1) |
435 | 435 | { |
@@ -443,7 +443,7 @@ discard block |
||
443 | 443 | } |
444 | 444 | |
445 | 445 | private function addLink($message) { |
446 | - if (null !== ($class = $this->getErrorClassNameSpace($message))) { |
|
446 | + if(null !== ($class = $this->getErrorClassNameSpace($message))) { |
|
447 | 447 | return str_replace($class['name'], '<a href="' . $class['url'] . '" target="_blank">' . $class['name'] . '</a>', $message); |
448 | 448 | } |
449 | 449 | return $message; |
@@ -452,7 +452,7 @@ discard block |
||
452 | 452 | private function getErrorClassNameSpace($message) { |
453 | 453 | $matches = []; |
454 | 454 | preg_match('/\b(T[A-Z]\w+)\b/', $message, $matches); |
455 | - if (is_array($matches) && count($matches) > 0) { |
|
455 | + if(is_array($matches) && count($matches) > 0) { |
|
456 | 456 | $class = $matches[0]; |
457 | 457 | try { |
458 | 458 | $function = new \ReflectionClass($class); |