@@ -33,7 +33,7 @@ |
||
| 33 | 33 | $tables = []; |
| 34 | 34 | } |
| 35 | 35 | $this->template->tables = $tables; |
| 36 | - $this->template->setFile(__DIR__ . '/default.latte'); |
|
| 36 | + $this->template->setFile(__DIR__.'/default.latte'); |
|
| 37 | 37 | $this->template->render(); |
| 38 | 38 | } |
| 39 | 39 | } |
@@ -33,7 +33,7 @@ |
||
| 33 | 33 | $this->template->type = $this->type; |
| 34 | 34 | $this->template->table = $this->table; |
| 35 | 35 | $this->template->item = $this->item; |
| 36 | - $this->template->setFile(__DIR__ . '/default.latte'); |
|
| 36 | + $this->template->setFile(__DIR__.'/default.latte'); |
|
| 37 | 37 | $this->template->render(); |
| 38 | 38 | } |
| 39 | 39 | } |
@@ -18,6 +18,10 @@ |
||
| 18 | 18 | |
| 19 | 19 | private $item; |
| 20 | 20 | |
| 21 | + /** |
|
| 22 | + * @param string|null $driver |
|
| 23 | + * @param string|null $databaseName |
|
| 24 | + */ |
|
| 21 | 25 | public function __construct($driver, $database, $databaseName, $type, $table, $item) |
| 22 | 26 | { |
| 23 | 27 | parent::__construct(); |
@@ -1,5 +1,5 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -$container = require __DIR__ . '/../app/bootstrap.php'; |
|
| 3 | +$container = require __DIR__.'/../app/bootstrap.php'; |
|
| 4 | 4 | |
| 5 | 5 | $container->getService('application')->run(); |
@@ -5,30 +5,30 @@ |
||
| 5 | 5 | use RadekDostal\NetteComponents\DateTimePicker\TbDatePicker; |
| 6 | 6 | use RadekDostal\NetteComponents\DateTimePicker\TbDateTimePicker; |
| 7 | 7 | |
| 8 | -require __DIR__ . '/../vendor/autoload.php'; |
|
| 8 | +require __DIR__.'/../vendor/autoload.php'; |
|
| 9 | 9 | |
| 10 | 10 | umask(0); |
| 11 | 11 | |
| 12 | 12 | $configurator = new Configurator(); |
| 13 | 13 | |
| 14 | 14 | $host = filter_input(INPUT_SERVER, 'HTTP_HOST'); |
| 15 | -$debug = (bool)preg_match('/localhost|devel/', $host); |
|
| 15 | +$debug = (bool) preg_match('/localhost|devel/', $host); |
|
| 16 | 16 | |
| 17 | 17 | $configurator->setDebugMode($debug); |
| 18 | -$configurator->enableDebugger(__DIR__ . '/../log'); |
|
| 19 | -$configurator->setTempDirectory(__DIR__ . '/../temp'); |
|
| 18 | +$configurator->enableDebugger(__DIR__.'/../log'); |
|
| 19 | +$configurator->setTempDirectory(__DIR__.'/../temp'); |
|
| 20 | 20 | |
| 21 | -$configurator->addConfig(__DIR__ . '/config/config.neon'); |
|
| 21 | +$configurator->addConfig(__DIR__.'/config/config.neon'); |
|
| 22 | 22 | $container = $configurator->createContainer(); |
| 23 | 23 | |
| 24 | -Form::extensionMethod('addDatePicker', function (Form $form, $name, $label, $maxLength = null) { |
|
| 24 | +Form::extensionMethod('addDatePicker', function(Form $form, $name, $label, $maxLength = null) { |
|
| 25 | 25 | $datePicker = new TbDatePicker($label, $maxLength); |
| 26 | 26 | $datePicker->setFormat('Y-m-d'); |
| 27 | 27 | $datePicker->setAttribute('class', 'datepicker'); |
| 28 | 28 | return $form[$name] = $datePicker; |
| 29 | 29 | }); |
| 30 | 30 | |
| 31 | -Form::extensionMethod('addDateTimePicker', function (Form $form, $name, $label, $maxLength = null) { |
|
| 31 | +Form::extensionMethod('addDateTimePicker', function(Form $form, $name, $label, $maxLength = null) { |
|
| 32 | 32 | $dateTimePicker = new TbDateTimePicker($label, $maxLength); |
| 33 | 33 | $dateTimePicker->setFormat('Y-m-d H:i:s'); |
| 34 | 34 | $dateTimePicker->setAttribute('class', 'datetimepicker'); |
@@ -12,7 +12,7 @@ discard block |
||
| 12 | 12 | |
| 13 | 13 | foreach ($data as $key => $row) { |
| 14 | 14 | foreach ($row as $column => $value) { |
| 15 | - $col = '__' . $column . '__'; |
|
| 15 | + $col = '__'.$column.'__'; |
|
| 16 | 16 | if (!isset($$col)) { |
| 17 | 17 | $$col = []; |
| 18 | 18 | } |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | $args = []; |
| 24 | 24 | foreach ($sorting as $sort) { |
| 25 | 25 | foreach ($sort as $key => $direction) { |
| 26 | - $col = '__' . $key . '__'; |
|
| 26 | + $col = '__'.$key.'__'; |
|
| 27 | 27 | if (!isset($$col)) { |
| 28 | 28 | continue; |
| 29 | 29 | } |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | public function load($lang) |
| 18 | 18 | { |
| 19 | 19 | $translations = []; |
| 20 | - $dir = $this->localizationDirectory . '/' . $lang; |
|
| 20 | + $dir = $this->localizationDirectory.'/'.$lang; |
|
| 21 | 21 | if (!file_exists($dir)) { |
| 22 | 22 | return $translations; |
| 23 | 23 | } |
@@ -36,13 +36,13 @@ discard block |
||
| 36 | 36 | } |
| 37 | 37 | foreach ($subnode as $key => $value) { |
| 38 | 38 | if (is_array($value)) { |
| 39 | - $nodePath = $path ? $path . '.' . $key : $key; |
|
| 39 | + $nodePath = $path ? $path.'.'.$key : $key; |
|
| 40 | 40 | $this->flatten($messages, $value, $nodePath); |
| 41 | 41 | if ($path === null) { |
| 42 | 42 | unset($messages[$key]); |
| 43 | 43 | } |
| 44 | 44 | } elseif ($path !== null) { |
| 45 | - $messages[$path . '.' . $key] = $value; |
|
| 45 | + $messages[$path.'.'.$key] = $value; |
|
| 46 | 46 | } |
| 47 | 47 | } |
| 48 | 48 | } |
@@ -21,28 +21,28 @@ |
||
| 21 | 21 | public function formatSize($number) |
| 22 | 22 | { |
| 23 | 23 | if ($number < 1024) { |
| 24 | - return $this->formatNumber($number) . ' B'; |
|
| 24 | + return $this->formatNumber($number).' B'; |
|
| 25 | 25 | } |
| 26 | 26 | if ($number < pow(1024, 2)) { |
| 27 | - return $this->formatNumber($number / 1024, 1) . ' kB'; |
|
| 27 | + return $this->formatNumber($number / 1024, 1).' kB'; |
|
| 28 | 28 | } |
| 29 | 29 | if ($number < pow(1024, 3)) { |
| 30 | - return $this->formatNumber($number / pow(1024, 2), 1) . ' MB'; |
|
| 30 | + return $this->formatNumber($number / pow(1024, 2), 1).' MB'; |
|
| 31 | 31 | } |
| 32 | 32 | if ($number < pow(1024, 4)) { |
| 33 | - return $this->formatNumber($number / pow(1024, 3), 1) . ' GB'; |
|
| 33 | + return $this->formatNumber($number / pow(1024, 3), 1).' GB'; |
|
| 34 | 34 | } |
| 35 | - return $this->formatNumber($number / pow(1024, 4), 1) . ' TB'; |
|
| 35 | + return $this->formatNumber($number / pow(1024, 4), 1).' TB'; |
|
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | public function formatTime($number) |
| 39 | 39 | { |
| 40 | 40 | if ($number < 60) { |
| 41 | - return $number . ' s'; |
|
| 41 | + return $number.' s'; |
|
| 42 | 42 | } |
| 43 | 43 | if ($number < 3600) { |
| 44 | 44 | return date('i:s', $number); |
| 45 | 45 | } |
| 46 | - return floor($number / 3600) . date('\h i\m s\s', $number); |
|
| 46 | + return floor($number / 3600).date('\h i\m s\s', $number); |
|
| 47 | 47 | } |
| 48 | 48 | } |
@@ -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 | 80 | $query = sprintf('UPDATE `%s` SET ', $this->table); |
| 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 | 87 | $query .= sprintf(' WHERE md5(concat(%s)) = "%s"', implode(', "|", ', $primaryColumns), $this->item); |
| 88 | 88 | } else { |
| 89 | - $query = sprintf('INSERT INTO `%s` %s VALUES %s', $this->table, '(' . implode(', ', $keys) . ')', '(' . implode(', ', $vals) . ')'); |
|
| 89 | + $query = sprintf('INSERT INTO `%s` %s VALUES %s', $this->table, '('.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) { |
@@ -23,6 +23,10 @@ |
||
| 23 | 23 | |
| 24 | 24 | private $columns = []; |
| 25 | 25 | |
| 26 | + /** |
|
| 27 | + * @param string $type |
|
| 28 | + * @param string $table |
|
| 29 | + */ |
|
| 26 | 30 | public function __construct(PDO $pdo, MySqlDataManager $dataManager, $type, $table, $item) |
| 27 | 31 | { |
| 28 | 32 | $this->pdo = $pdo; |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | |
| 99 | 99 | public function itemsCount($type, $table, array $filter = []) |
| 100 | 100 | { |
| 101 | - $query = sprintf('SELECT count(*) FROM `%s`', $table) . $this->createWhere($filter); |
|
| 101 | + $query = sprintf('SELECT count(*) FROM `%s`', $table).$this->createWhere($filter); |
|
| 102 | 102 | return $this->connection->query($query)->fetch(PDO::FETCH_COLUMN); |
| 103 | 103 | } |
| 104 | 104 | |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | $query = sprintf('SELECT * FROM `%s`', $table); |
| 109 | 109 | $query .= $this->createWhere($filter); |
| 110 | 110 | $query .= $this->createOrderBy($sorting); |
| 111 | - $query .= ' LIMIT ' . (($page - 1) * $onPage) . ', ' . $onPage; |
|
| 111 | + $query .= ' LIMIT '.(($page - 1) * $onPage).', '.$onPage; |
|
| 112 | 112 | $items = []; |
| 113 | 113 | foreach ($this->connection->query($query)->fetchAll(PDO::FETCH_ASSOC) as $item) { |
| 114 | 114 | $pk = []; |
@@ -149,9 +149,9 @@ discard block |
||
| 149 | 149 | foreach ($filterPart as $key => $filterSettings) { |
| 150 | 150 | foreach ($filterSettings as $operator => $value) { |
| 151 | 151 | if (!isset($operatorsMap[$operator])) { |
| 152 | - throw new OperatorNotSupportedException('Operator "' . $operator . '" is not supported.'); |
|
| 152 | + throw new OperatorNotSupportedException('Operator "'.$operator.'" is not supported.'); |
|
| 153 | 153 | } |
| 154 | - $whereParts[] = "`$key` " . sprintf($operatorsMap[$operator], $value); |
|
| 154 | + $whereParts[] = "`$key` ".sprintf($operatorsMap[$operator], $value); |
|
| 155 | 155 | } |
| 156 | 156 | } |
| 157 | 157 | } |
@@ -197,7 +197,7 @@ discard block |
||
| 197 | 197 | } elseif ($type === MySqlDriver::TYPE_VIEW) { |
| 198 | 198 | $query = sprintf('DROP VIEW `%s`', $table); |
| 199 | 199 | } else { |
| 200 | - throw new InvalidArgumentException('Type "' . $type . '" is not supported'); |
|
| 200 | + throw new InvalidArgumentException('Type "'.$type.'" is not supported'); |
|
| 201 | 201 | } |
| 202 | 202 | return $this->connection->query($query); |
| 203 | 203 | } |
@@ -250,7 +250,7 @@ discard block |
||
| 250 | 250 | |
| 251 | 251 | public function execute($commands) |
| 252 | 252 | { |
| 253 | - $queries = array_filter(array_map('trim', explode(';', $commands)), function ($query) { |
|
| 253 | + $queries = array_filter(array_map('trim', explode(';', $commands)), function($query) { |
|
| 254 | 254 | return $query; |
| 255 | 255 | }); |
| 256 | 256 | $results = []; |