@@ -218,14 +218,14 @@ discard block |
||
| 218 | 218 | $target .= '<b>' . $this->util->html($foreignKey->schema) . '</b>.'; |
| 219 | 219 | } |
| 220 | 220 | $target = $this->util->html($foreignKey->table) . |
| 221 | - '(' . implode(', ', array_map(function ($key) { |
|
| 221 | + '(' . implode(', ', array_map(function($key) { |
|
| 222 | 222 | return $this->util->html($key); |
| 223 | 223 | }, $foreignKey->target)) . ')'; |
| 224 | 224 | $details[] = [ |
| 225 | 225 | 'name' => $this->util->html($name), |
| 226 | 226 | 'source' => '<i>' . implode( |
| 227 | 227 | '</i>, <i>', |
| 228 | - array_map(function ($key) { |
|
| 228 | + array_map(function($key) { |
|
| 229 | 229 | return $this->util->html($key); |
| 230 | 230 | }, $foreignKey->source) |
| 231 | 231 | ) . '</i>', |
@@ -369,7 +369,7 @@ discard block |
||
| 369 | 369 | private function makeTableAttrs(array $values, string $table = '') |
| 370 | 370 | { |
| 371 | 371 | // From create.inc.php |
| 372 | - $values['fields'] = (array)$values['fields']; |
|
| 372 | + $values['fields'] = (array) $values['fields']; |
|
| 373 | 373 | if ($values['autoIncrementCol']) { |
| 374 | 374 | $values['fields'][$values['autoIncrementCol']]['autoIncrement'] = true; |
| 375 | 375 | } |
@@ -141,8 +141,7 @@ |
||
| 141 | 141 | { |
| 142 | 142 | $foreignKey = $this->foreignKeys[$field->type] ?? null; |
| 143 | 143 | //! Can collide with user defined type |
| 144 | - $typeField = ($foreignKey === null ? $field : |
|
| 145 | - TableFieldEntity::make($this->referencableTables[$foreignKey])); |
|
| 144 | + $typeField = ($foreignKey === null ? $field : TableFieldEntity::make($this->referencableTables[$foreignKey])); |
|
| 146 | 145 | $processedField = $this->util->processField($field, $typeField); |
| 147 | 146 | $origField = $this->fields[$this->fieldName] ?? null; |
| 148 | 147 | if ($this->fieldName === '') { |
@@ -1,16 +1,16 @@ |
||
| 1 | 1 | <form id="<?php echo $this->formId ?>"> |
| 2 | -<?php foreach($this->fields as $name => $field): ?> |
|
| 2 | +<?php foreach ($this->fields as $name => $field): ?> |
|
| 3 | 3 | <div class="form-group row"> |
| 4 | 4 | <div class="col-md-3"> |
| 5 | 5 | <label title="<?php echo $field['type'] ?>"><?php echo $field['name'] ?></label> |
| 6 | 6 | </div> |
| 7 | 7 | <div class="col-md-2"> |
| 8 | -<?php if($field['functions']['type'] === 'name'): ?> |
|
| 8 | +<?php if ($field['functions']['type'] === 'name'): ?> |
|
| 9 | 9 | <label class=""><?php echo $field['functions']['name'] ?></label> |
| 10 | -<?php elseif($field['functions']['type'] === 'select'): ?> |
|
| 10 | +<?php elseif ($field['functions']['type'] === 'select'): ?> |
|
| 11 | 11 | <select name="<?php echo $field['functions']['name'] ?>" class="form-control"> |
| 12 | -<?php foreach($field['functions']['options'] as $function): ?> |
|
| 13 | - <option <?php if($function === $field['functions']['selected']): ?>selected<?php |
|
| 12 | +<?php foreach ($field['functions']['options'] as $function): ?> |
|
| 13 | + <option <?php if ($function === $field['functions']['selected']): ?>selected<?php |
|
| 14 | 14 | endif ?>><?php echo $function ?></option> |
| 15 | 15 | <?php endforeach ?> |
| 16 | 16 | </select> |
@@ -1,16 +1,16 @@ |
||
| 1 | 1 | <form class="form-horizontal" role="form" id="<?php echo $this->formId ?>"> |
| 2 | -<?php foreach($this->fields as $name => $field): ?> |
|
| 2 | +<?php foreach ($this->fields as $name => $field): ?> |
|
| 3 | 3 | <div class="form-group"> |
| 4 | 4 | <div class="col-md-3"> |
| 5 | 5 | <label title="<?php echo $field['type'] ?>"><?php echo $field['name'] ?></label> |
| 6 | 6 | </div> |
| 7 | 7 | <div class="col-md-2"> |
| 8 | -<?php if($field['functions']['type'] === 'name'): ?> |
|
| 8 | +<?php if ($field['functions']['type'] === 'name'): ?> |
|
| 9 | 9 | <label class=""><?php echo $field['functions']['name'] ?></label> |
| 10 | -<?php elseif($field['functions']['type'] === 'select'): ?> |
|
| 10 | +<?php elseif ($field['functions']['type'] === 'select'): ?> |
|
| 11 | 11 | <select name="<?php echo $field['functions']['name'] ?>" class="form-control"> |
| 12 | -<?php foreach($field['functions']['options'] as $function): ?> |
|
| 13 | - <option <?php if($function === $field['functions']['selected']): ?>selected<?php |
|
| 12 | +<?php foreach ($field['functions']['options'] as $function): ?> |
|
| 13 | + <option <?php if ($function === $field['functions']['selected']): ?>selected<?php |
|
| 14 | 14 | endif ?>><?php echo $function ?></option> |
| 15 | 15 | <?php endforeach ?> |
| 16 | 16 | </select> |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | 'text' => '<i>' . $this->trans->lang('original') . '</i>']; |
| 70 | 70 | } |
| 71 | 71 | if ($field->null) { |
| 72 | - $values[] = ['value' => '', 'checked' => $value === null && !$select, 'text' => '<i>NULL</i>']; |
|
| 72 | + $values[] = ['value' => '', 'checked' => $value === null && !$select, 'text' => '<i>NULL</i>']; |
|
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | // From functions.inc.php (function enum_input()) |
@@ -80,8 +80,7 @@ discard block |
||
| 80 | 80 | preg_match_all("~'((?:[^']|'')*)'~", $field->fullType, $matches); |
| 81 | 81 | foreach ($matches[1] as $i => $val) { |
| 82 | 82 | $val = stripcslashes(str_replace("''", "'", $val)); |
| 83 | - $checked = (is_int($value) ? $value == $i + 1 : |
|
| 84 | - (is_array($value) ? in_array($i+1, $value) : $value === $val)); |
|
| 83 | + $checked = (is_int($value) ? $value == $i + 1 : (is_array($value) ? in_array($i + 1, $value) : $value === $val)); |
|
| 85 | 84 | $values[] = ['value' => $i + 1, 'checked' => $checked, 'text' => $this->util->html($val)]; |
| 86 | 85 | } |
| 87 | 86 | |
@@ -419,8 +419,7 @@ discard block |
||
| 419 | 419 | } |
| 420 | 420 | $enumLength = $this->driver->enumLength(); |
| 421 | 421 | return (\preg_match("~^\\s*\\(?\\s*$enumLength(?:\\s*,\\s*$enumLength)*+\\s*\\)?\\s*\$~", $length) && |
| 422 | - \preg_match_all("~$enumLength~", $length, $matches) ? '(' . \implode(',', $matches[0]) . ')' : |
|
| 423 | - \preg_replace('~^[0-9].*~', '(\0)', \preg_replace('~[^-0-9,+()[\]]~', '', $length)) |
|
| 422 | + \preg_match_all("~$enumLength~", $length, $matches) ? '(' . \implode(',', $matches[0]) . ')' : \preg_replace('~^[0-9].*~', '(\0)', \preg_replace('~[^-0-9,+()[\]]~', '', $length)) |
|
| 424 | 423 | ); |
| 425 | 424 | } |
| 426 | 425 | |
@@ -607,7 +606,7 @@ discard block |
||
| 607 | 606 | $expressions = []; |
| 608 | 607 | foreach ($indexes as $i => $index) { |
| 609 | 608 | if ($index->type == 'FULLTEXT' && $this->input->values['fulltext'][$i] != '') { |
| 610 | - $columns = \array_map(function ($column) { |
|
| 609 | + $columns = \array_map(function($column) { |
|
| 611 | 610 | return $this->driver->escapeId($column); |
| 612 | 611 | }, $index->columns); |
| 613 | 612 | $expressions[] = 'MATCH (' . \implode(', ', $columns) . ') AGAINST (' . |
@@ -722,8 +721,7 @@ discard block |
||
| 722 | 721 | */ |
| 723 | 722 | private function _selectValue($value, string $link, string $type, $original): string |
| 724 | 723 | { |
| 725 | - $clause = ($value === null ? '<i>NULL</i>' : |
|
| 726 | - (\preg_match('~char|binary|boolean~', $type) && !\preg_match('~var~', $type) ? |
|
| 724 | + $clause = ($value === null ? '<i>NULL</i>' : (\preg_match('~char|binary|boolean~', $type) && !\preg_match('~var~', $type) ? |
|
| 727 | 725 | "<code>$value</code>" : $value)); |
| 728 | 726 | if (\preg_match('~blob|bytea|raw|file~', $type) && !$this->isUtf8($value)) { |
| 729 | 727 | $clause = '<i>' . $this->trans->lang('%d byte(s)', \strlen($original)) . '</i>'; |
@@ -285,8 +285,7 @@ discard block |
||
| 285 | 285 | $row[$key] = '"' . str_replace('"', '""', $val) . '"'; |
| 286 | 286 | } |
| 287 | 287 | } |
| 288 | - $separator = $this->options['format'] == 'csv' ? ',' : |
|
| 289 | - ($this->options['format'] == 'tsv' ? "\t" : ';'); |
|
| 288 | + $separator = $this->options['format'] == 'csv' ? ',' : ($this->options['format'] == 'tsv' ? "\t" : ';'); |
|
| 290 | 289 | $this->queries[] = implode($separator, $row); |
| 291 | 290 | } |
| 292 | 291 | |
@@ -395,7 +394,7 @@ discard block |
||
| 395 | 394 | } else { |
| 396 | 395 | if (!$this->insert) { |
| 397 | 396 | $this->insert = 'INSERT INTO ' . $this->driver->table($table) . ' (' . |
| 398 | - implode(', ', array_map(function ($key) { |
|
| 397 | + implode(', ', array_map(function($key) { |
|
| 399 | 398 | return $this->driver->escapeId($key); |
| 400 | 399 | }, $keys)) . ') VALUES'; |
| 401 | 400 | } |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | if ($row === null) { |
| 122 | 122 | return !$update && $field->autoIncrement ? "" : (isset($queryOptions["select"]) ? false : $default); |
| 123 | 123 | } |
| 124 | - if ($row[$name] != "" && $this->driver->jush() == "sql" && preg_match("~enum|set~", $field->type) ) { |
|
| 124 | + if ($row[$name] != "" && $this->driver->jush() == "sql" && preg_match("~enum|set~", $field->type)) { |
|
| 125 | 125 | return is_array($row[$name]) ? array_sum($row[$name]) : +$row[$name]; |
| 126 | 126 | } |
| 127 | 127 | return is_bool($row[$name]) ? +$row[$name] : $row[$name]; |
@@ -141,7 +141,7 @@ discard block |
||
| 141 | 141 | return "SQL"; |
| 142 | 142 | } |
| 143 | 143 | if ($queryOptions["save"]) { |
| 144 | - return (string)$queryOptions["function"][$name]; |
|
| 144 | + return (string) $queryOptions["function"][$name]; |
|
| 145 | 145 | } |
| 146 | 146 | if ($update && preg_match('~^CURRENT_TIMESTAMP~i', $field->onUpdate)) { |
| 147 | 147 | return 'now'; |
@@ -158,7 +158,7 @@ discard block |
||
| 158 | 158 | */ |
| 159 | 159 | public function insertItem(string $table, array $queryOptions): array |
| 160 | 160 | { |
| 161 | - list($fields, ,) = $this->getFields($table, $queryOptions); |
|
| 161 | + list($fields,,) = $this->getFields($table, $queryOptions); |
|
| 162 | 162 | |
| 163 | 163 | // From edit.inc.php |
| 164 | 164 | $values = []; |
@@ -188,7 +188,7 @@ discard block |
||
| 188 | 188 | */ |
| 189 | 189 | public function updateItem(string $table, array $queryOptions): array |
| 190 | 190 | { |
| 191 | - list($fields, $where, ) = $this->getFields($table, $queryOptions); |
|
| 191 | + list($fields, $where,) = $this->getFields($table, $queryOptions); |
|
| 192 | 192 | |
| 193 | 193 | // From edit.inc.php |
| 194 | 194 | $indexes = $this->driver->indexes($table); |