@@ -100,10 +100,10 @@ |
||
| 100 | 100 | protected function createComponentFilterForm() |
| 101 | 101 | { |
| 102 | 102 | $form = $this->driver->formManager()->filterForm($this->translator, $this->columns, $this->filter, $this->sorting, $this->onPage); |
| 103 | - $form->doRedirect[] = function ($onPage, $filter, $sorting) { |
|
| 103 | + $form->doRedirect[] = function($onPage, $filter, $sorting) { |
|
| 104 | 104 | $this->redirect('Item:default', $this->driver->type(), $this->database, $this->type, $this->table, 1, $onPage, $filter, $sorting); |
| 105 | 105 | }; |
| 106 | - $form->doReset[] = function () { |
|
| 106 | + $form->doReset[] = function() { |
|
| 107 | 107 | $this->redirect('Item:default', $this->driver->type(), $this->database, $this->type, $this->table); |
| 108 | 108 | }; |
| 109 | 109 | return $form; |
@@ -44,7 +44,7 @@ |
||
| 44 | 44 | 'svg' => 'image/svg+xml', |
| 45 | 45 | 'otf' => 'application/x-font-opentype', |
| 46 | 46 | ]; |
| 47 | - $path = __DIR__ . '/../../www/' . $file; |
|
| 47 | + $path = __DIR__.'/../../www/'.$file; |
|
| 48 | 48 | $extension = pathinfo($path, PATHINFO_EXTENSION); |
| 49 | 49 | $contentType = isset($contentTypes[$extension]) ? $contentTypes[$extension] : 'text/plain'; |
| 50 | 50 | $httpResponse->setContentType($contentType); |
@@ -50,7 +50,7 @@ |
||
| 50 | 50 | return $message; |
| 51 | 51 | } |
| 52 | 52 | foreach ($params as $key => $value) { |
| 53 | - $message = str_replace('%' . $key . '%', $value, $message); |
|
| 53 | + $message = str_replace('%'.$key.'%', $value, $message); |
|
| 54 | 54 | } |
| 55 | 55 | return $message; |
| 56 | 56 | } |
@@ -49,7 +49,7 @@ |
||
| 49 | 49 | $tableForm->addFieldsToForm($form); |
| 50 | 50 | $form->addSubmit('save', 'Save'); |
| 51 | 51 | $form->onSuccess[] = [$tableForm, 'submit']; |
| 52 | - $form->onSuccess[] = function () { |
|
| 52 | + $form->onSuccess[] = function() { |
|
| 53 | 53 | $this->presenter->redirect('Table:default', $this->driver->type(), $this->database); |
| 54 | 54 | }; |
| 55 | 55 | return $form; |
@@ -34,7 +34,7 @@ |
||
| 34 | 34 | |
| 35 | 35 | public function name() |
| 36 | 36 | { |
| 37 | - return $this->type() . '.name'; |
|
| 37 | + return $this->type().'.name'; |
|
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | /** |
@@ -64,7 +64,7 @@ |
||
| 64 | 64 | return $count; |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | - $stats = $this->connection->getExtendedStats('cachedump', (int)$table); |
|
| 67 | + $stats = $this->connection->getExtendedStats('cachedump', (int) $table); |
|
| 68 | 68 | $keys = isset($stats[$this->database]) ? $stats[$this->database] : []; |
| 69 | 69 | return count($keys); |
| 70 | 70 | } |
@@ -69,29 +69,29 @@ |
||
| 69 | 69 | |
| 70 | 70 | public function submit(Form $form, ArrayHash $values) |
| 71 | 71 | { |
| 72 | - $values = (array)$values; |
|
| 73 | - $keys = array_map(function ($key) { |
|
| 74 | - return '`' . $key . '`'; |
|
| 72 | + $values = (array) $values; |
|
| 73 | + $keys = array_map(function($key) { |
|
| 74 | + return '`'.$key.'`'; |
|
| 75 | 75 | }, array_keys($values)); |
| 76 | - $vals = array_map(function ($key) { |
|
| 77 | - return ':' . $key; |
|
| 76 | + $vals = array_map(function($key) { |
|
| 77 | + return ':'.$key; |
|
| 78 | 78 | }, array_keys($values)); |
| 79 | 79 | if ($this->item) { |
| 80 | - $query = 'UPDATE `' . $this->table . '` SET '; |
|
| 80 | + $query = 'UPDATE `'.$this->table.'` SET '; |
|
| 81 | 81 | $set = []; |
| 82 | 82 | foreach ($values as $key => $value) { |
| 83 | - $set[] = '`' . $key . '` = :' . $key; |
|
| 83 | + $set[] = '`'.$key.'` = :'.$key; |
|
| 84 | 84 | } |
| 85 | 85 | $query .= implode(', ', $set); |
| 86 | 86 | $primaryColumns = $this->dataManager->getPrimaryColumns($this->type, $this->table); |
| 87 | - $query .= ' WHERE md5(concat(' . implode(', "|", ', $primaryColumns) . ')) = "' . $this->item . '"'; |
|
| 87 | + $query .= ' WHERE md5(concat('.implode(', "|", ', $primaryColumns).')) = "'.$this->item.'"'; |
|
| 88 | 88 | } else { |
| 89 | - $query = sprintf('INSERT INTO `' . $this->table . '` %s VALUES %s', '(' . implode(', ', $keys) . ')', '(' . implode(', ', $vals) . ')'); |
|
| 89 | + $query = sprintf('INSERT INTO `'.$this->table.'` %s VALUES %s', '('.implode(', ', $keys).')', '('.implode(', ', $vals).')'); |
|
| 90 | 90 | } |
| 91 | 91 | $statement = $this->pdo->prepare($query); |
| 92 | 92 | foreach ($values as $key => $value) { |
| 93 | 93 | $value = $value === '' && $this->columns[$key]['Null'] ? null : $value; |
| 94 | - $statement->bindValue(':' . $key, $value); |
|
| 94 | + $statement->bindValue(':'.$key, $value); |
|
| 95 | 95 | } |
| 96 | 96 | $ret = $statement->execute(); |
| 97 | 97 | if (!$ret) { |
@@ -47,14 +47,14 @@ |
||
| 47 | 47 | public function submit(Form $form, ArrayHash $values) |
| 48 | 48 | { |
| 49 | 49 | if ($this->database) { |
| 50 | - $query = 'ALTER DATABASE ' . $this->database; |
|
| 50 | + $query = 'ALTER DATABASE '.$this->database; |
|
| 51 | 51 | } else { |
| 52 | - $query = 'CREATE DATABASE ' . $values['name']; |
|
| 52 | + $query = 'CREATE DATABASE '.$values['name']; |
|
| 53 | 53 | } |
| 54 | 54 | if ($values['charset']) { |
| 55 | - $query .= ' CHARACTER SET ' . $values['charset']; |
|
| 55 | + $query .= ' CHARACTER SET '.$values['charset']; |
|
| 56 | 56 | if ($values['collation']) { |
| 57 | - $query .= ' COLLATE ' . $values['collation']; |
|
| 57 | + $query .= ' COLLATE '.$values['collation']; |
|
| 58 | 58 | } |
| 59 | 59 | } |
| 60 | 60 | |
@@ -102,17 +102,17 @@ discard block |
||
| 102 | 102 | |
| 103 | 103 | public function itemsCount($type, $table, array $filter = []) |
| 104 | 104 | { |
| 105 | - $query = 'SELECT count(*) FROM `' . $table . '`' . $this->createWhere($filter); |
|
| 105 | + $query = 'SELECT count(*) FROM `'.$table.'`'.$this->createWhere($filter); |
|
| 106 | 106 | return $this->connection->query($query)->fetch(PDO::FETCH_COLUMN); |
| 107 | 107 | } |
| 108 | 108 | |
| 109 | 109 | public function items($type, $table, $page, $onPage, array $filter = [], array $sorting = []) |
| 110 | 110 | { |
| 111 | 111 | $primaryColumns = $this->getPrimaryColumns($type, $table); |
| 112 | - $query = 'SELECT * FROM `' . $table . '`'; |
|
| 112 | + $query = 'SELECT * FROM `'.$table.'`'; |
|
| 113 | 113 | $query .= $this->createWhere($filter); |
| 114 | 114 | $query .= $this->createOrderBy($sorting); |
| 115 | - $query .= ' LIMIT ' . (($page - 1) * $onPage) . ', ' . $onPage; |
|
| 115 | + $query .= ' LIMIT '.(($page - 1) * $onPage).', '.$onPage; |
|
| 116 | 116 | $items = []; |
| 117 | 117 | foreach ($this->connection->query($query)->fetchAll(PDO::FETCH_ASSOC) as $item) { |
| 118 | 118 | $pk = []; |
@@ -153,9 +153,9 @@ discard block |
||
| 153 | 153 | foreach ($filterPart as $key => $filterSettings) { |
| 154 | 154 | foreach ($filterSettings as $operator => $value) { |
| 155 | 155 | if (!isset($operatorsMap[$operator])) { |
| 156 | - throw new OperatorNotSupportedException('Operator "' . $operator . '" is not supported.'); |
|
| 156 | + throw new OperatorNotSupportedException('Operator "'.$operator.'" is not supported.'); |
|
| 157 | 157 | } |
| 158 | - $whereParts[] = "`$key`" . sprintf($operatorsMap[$operator], $value); |
|
| 158 | + $whereParts[] = "`$key`".sprintf($operatorsMap[$operator], $value); |
|
| 159 | 159 | } |
| 160 | 160 | } |
| 161 | 161 | } |
@@ -183,7 +183,7 @@ discard block |
||
| 183 | 183 | public function loadItem($type, $table, $item) |
| 184 | 184 | { |
| 185 | 185 | $primaryColumns = $this->getPrimaryColumns($type, $table); |
| 186 | - $query = 'SELECT * FROM `' . $table . '` WHERE md5(concat(' . implode(', "|", ', $primaryColumns) . ')) = "' . $item . '"'; |
|
| 186 | + $query = 'SELECT * FROM `'.$table.'` WHERE md5(concat('.implode(', "|", ', $primaryColumns).')) = "'.$item.'"'; |
|
| 187 | 187 | return $this->connection->query($query)->fetch(PDO::FETCH_ASSOC); |
| 188 | 188 | } |
| 189 | 189 | |
@@ -191,32 +191,32 @@ discard block |
||
| 191 | 191 | { |
| 192 | 192 | $primaryColumns = $this->getPrimaryColumns($type, $table); |
| 193 | 193 | |
| 194 | - $query = 'DELETE FROM `' . $table . '` WHERE md5(concat(' . implode(', "|", ', $primaryColumns) . ')) = "' . $item . '"'; |
|
| 194 | + $query = 'DELETE FROM `'.$table.'` WHERE md5(concat('.implode(', "|", ', $primaryColumns).')) = "'.$item.'"'; |
|
| 195 | 195 | return $this->connection->query($query); |
| 196 | 196 | } |
| 197 | 197 | |
| 198 | 198 | public function deleteTable($type, $table) |
| 199 | 199 | { |
| 200 | 200 | if ($type === MySqlDriver::TYPE_TABLE) { |
| 201 | - $query = 'DROP TABLE `' . $table . '`'; |
|
| 201 | + $query = 'DROP TABLE `'.$table.'`'; |
|
| 202 | 202 | } elseif ($type === MySqlDriver::TYPE_VIEW) { |
| 203 | - $query = 'DROP VIEW `' . $table . '`'; |
|
| 203 | + $query = 'DROP VIEW `'.$table.'`'; |
|
| 204 | 204 | } else { |
| 205 | - throw new InvalidArgumentException('Type "' . $type . '" is not supported'); |
|
| 205 | + throw new InvalidArgumentException('Type "'.$type.'" is not supported'); |
|
| 206 | 206 | } |
| 207 | 207 | return $this->connection->query($query); |
| 208 | 208 | } |
| 209 | 209 | |
| 210 | 210 | public function deleteDatabase($database) |
| 211 | 211 | { |
| 212 | - $query = 'DROP DATABASE `' . $database . '`'; |
|
| 212 | + $query = 'DROP DATABASE `'.$database.'`'; |
|
| 213 | 213 | return $this->connection->query($query); |
| 214 | 214 | } |
| 215 | 215 | |
| 216 | 216 | public function selectDatabase($database) |
| 217 | 217 | { |
| 218 | 218 | $this->database = $database; |
| 219 | - $this->connection->query('USE `' . $database . '`'); |
|
| 219 | + $this->connection->query('USE `'.$database.'`'); |
|
| 220 | 220 | } |
| 221 | 221 | |
| 222 | 222 | public function getPrimaryColumns($type, $table) |
@@ -238,7 +238,7 @@ discard block |
||
| 238 | 238 | public function getColumns($type, $table) |
| 239 | 239 | { |
| 240 | 240 | if ($this->columns === null) { |
| 241 | - $columns = $this->connection->query('SHOW FULL COLUMNS FROM `' . $table .'`')->fetchAll(PDO::FETCH_ASSOC); |
|
| 241 | + $columns = $this->connection->query('SHOW FULL COLUMNS FROM `'.$table.'`')->fetchAll(PDO::FETCH_ASSOC); |
|
| 242 | 242 | $keys = []; |
| 243 | 243 | foreach ($this->connection->query("SELECT * FROM information_schema.KEY_COLUMN_USAGE WHERE TABLE_SCHEMA = '{$this->database}' AND TABLE_NAME = '$table'")->fetchAll(PDO::FETCH_ASSOC) as $key) { |
| 244 | 244 | $keys[$key['COLUMN_NAME']] = $key; |
@@ -254,7 +254,7 @@ discard block |
||
| 254 | 254 | |
| 255 | 255 | public function execute($commands) |
| 256 | 256 | { |
| 257 | - $queries = array_filter(array_map('trim', explode(';', $commands)), function ($query) { |
|
| 257 | + $queries = array_filter(array_map('trim', explode(';', $commands)), function($query) { |
|
| 258 | 258 | return $query; |
| 259 | 259 | }); |
| 260 | 260 | $results = []; |