Refactor code formatting and improve readability in gdb.min.php and grid.php; update cache sizes in ftp-kr.sync.cache.json

This commit is contained in:
2024-11-10 21:08:30 +01:00
parent 4acdddcabf
commit 35f6ff9bbb
3 changed files with 30 additions and 37 deletions

View File

@@ -47,20 +47,20 @@
"layout": { "layout": {
"style.css": { "style.css": {
"type": "-", "type": "-",
"size": 14963, "size": 15759,
"lmtime": 1731233991810, "lmtime": 1731246911854,
"modified": false "modified": false
}, },
"style.css.map": { "style.css.map": {
"type": "-", "type": "-",
"size": 26778, "size": 28396,
"lmtime": 1731233991810, "lmtime": 1731246911854,
"modified": false "modified": false
}, },
"style.scss": { "style.scss": {
"type": "-", "type": "-",
"size": 18665, "size": 19740,
"lmtime": 1731233991666, "lmtime": 1731246911704,
"modified": false "modified": false
} }
}, },
@@ -82,8 +82,8 @@
}, },
"main-view.php": { "main-view.php": {
"type": "-", "type": "-",
"size": 14418, "size": 14294,
"lmtime": 1731233950425, "lmtime": 1731246739957,
"modified": false "modified": false
}, },
"operation-edit.php": { "operation-edit.php": {

View File

@@ -3,7 +3,7 @@
* Medoo database framework * Medoo database framework
* http://medoo.in * http://medoo.in
* Version 0.9.7 * Version 0.9.7
* *
* Copyright 2014, Angel Lai * Copyright 2014, Angel Lai
* Released under the MIT license * Released under the MIT license
*/ */
@@ -33,7 +33,7 @@ class gdb
protected $option = array(); protected $option = array();
// Variable // Variable
protected $logs = array(); protected $logs = array();
public function __construct($options = null) public function __construct($options = null)
@@ -131,7 +131,7 @@ class gdb
} }
$this->pdo = new PDO( $this->pdo = new PDO(
$dsn, $dsn,
$this->username, $this->username,
$this->password, $this->password,
$this->option $this->option
@@ -199,7 +199,10 @@ class gdb
} }
} }
return implode($stack, ','); if ( is_array( $stack ) )
return implode( ',', $stack );
else
return $stack;
} }
protected function array_quote($array) protected function array_quote($array)
@@ -318,11 +321,11 @@ class gdb
} }
$value = '%' . $value . '%'; $value = '%' . $value . '%';
$wheres[] = $column . ' LIKE ' . $this->fn_quote($key, $value); $wheres[] = $column . ' LIKE ' . $this->fn_quote($key, $value);
} }
} }
if (in_array($operator, array('>', '>=', '<', '<='))) if (in_array($operator, array('>', '>=', '<', '<=')))
{ {
if (is_numeric($value)) if (is_numeric($value))
@@ -719,7 +722,7 @@ class gdb
} }
} }
$this->exec('INSERT INTO "' . $table . '" (' . implode(', ', $columns) . ') VALUES (' . implode($values, ', ') . ')'); $this->exec('INSERT INTO "' . $table . '" (' . implode(', ', $columns) . ') VALUES (' . implode(', ',$values) . ')');
$lastId[] = $this->pdo->lastInsertId(); $lastId[] = $this->pdo->lastInsertId();
} }
@@ -829,13 +832,13 @@ class gdb
} }
$where['LIMIT'] = 1; $where['LIMIT'] = 1;
$data = $this->query($this->select_context($table, $join, $column, $where))->fetchAll(PDO::FETCH_ASSOC); $data = $this->query($this->select_context($table, $join, $column, $where))->fetchAll(PDO::FETCH_ASSOC);
if (isset($data[0])) if (isset($data[0]))
{ {
$column = $where == null ? $join : $column; $column = $where == null ? $join : $column;
if (is_string($column) && $column != '*') if (is_string($column) && $column != '*')
{ {
return $data[ 0 ][ $column ]; return $data[ 0 ][ $column ];

View File

@@ -36,8 +36,6 @@ class grid
public $sql = null; public $sql = null;
public $sql_count = null; public $sql_count = null;
public $context_menu = true;
public $include_plugins = true; public $include_plugins = true;
public $gdb_opt = array( public $gdb_opt = array(
@@ -80,8 +78,9 @@ class grid
$this -> name ? $g_table = $this -> name : $g_table = $this -> table; $this -> name ? $g_table = $this -> name : $g_table = $this -> table;
if ( is_array( $_SESSION ) ) foreach ( $_SESSION as $key => $val ) if ( is_array( $_SESSION ) ) foreach ( $_SESSION as $key => $val )
{ {
if ( $key != 'g' . $g_table and @get_class( $val ) == '__PHP_Incomplete_Class' ) if ($key != 'g' . $g_table && is_object($val) && get_class($val) == '__PHP_Incomplete_Class') {
unset( $_SESSION[ $key ] ); unset($_SESSION[$key]);
}
} }
} }
} }
@@ -124,10 +123,9 @@ class grid
$this -> hidden_columns = $results['hidden_columns']; $this -> hidden_columns = $results['hidden_columns'];
(int)$_SESSION[ 'g' . $g_table . 'cp' ] ? $this -> cp = (int)$_SESSION[ 'g' . $g_table . 'cp' ] : $this -> cp = 1;
if ( !empty( $_SESSION[ 'g' . $g_table . 'order' ] ) )
$this -> order = $_SESSION[ 'g' . $g_table . 'order' ]; (int)$_SESSION[ 'g' . $g_table . 'cp' ] ? $this -> cp = (int)$_SESSION[ 'g' . $g_table . 'cp' ] : $this -> cp = 1;
$_SESSION[ 'g' . $g_table ] = $this; $_SESSION[ 'g' . $g_table ] = $this;
@@ -147,7 +145,7 @@ class grid
'server' => $this -> gdb_opt['server'], 'server' => $this -> gdb_opt['server'],
'username' => $this -> gdb_opt['username'], 'username' => $this -> gdb_opt['username'],
'password' => $this -> gdb_opt['password'], 'password' => $this -> gdb_opt['password'],
'port' => $this -> gdb_opt['port'], 'port' => isset( $this -> gdb_opt['port'] ) ? $this -> gdb_opt['port'] : 3306,
'charset' => 'utf8' 'charset' => 'utf8'
] ); ] );
} }
@@ -156,8 +154,6 @@ class grid
{ {
if ( is_array( $this -> src ) ) if ( is_array( $this -> src ) )
$results = $this -> getDataSrc(); $results = $this -> getDataSrc();
else if ( isset( $this -> sql ) and isset( $this -> sql_count ) )
$results = $this -> get_data_sql();
else else
$results = $this -> getData( true ); $results = $this -> getData( true );
@@ -183,7 +179,7 @@ class grid
{ {
/* podmiana na wartości tablicy */ /* podmiana na wartości tablicy */
if ( is_array( $column['replace']['array'] ) ) if ( is_array( $column['replace']['array'] ) )
$array_row[] = strip_tags( $this -> convertString( $column['replace']['array'][ $row[ $column['db'] ] ], $row ) ); $array_row[] = $this -> convertString( $column['replace']['array'][ $row[ $column['db'] ] ], $row );
else if ( $column['replace']['sql'] ) else if ( $column['replace']['sql'] )
{ {
@@ -386,14 +382,7 @@ class grid
$where['AND'] = array_merge( $where['AND'], [ $key . '[~]' => $val['value'] ] ); $where['AND'] = array_merge( $where['AND'], [ $key . '[~]' => $val['value'] ] );
if ( $val['type'] == 'equal' ) if ( $val['type'] == 'equal' )
{ $where['AND'] = array_merge( $where['AND'], [ $key => $val['value'] ] );
if ( $val['value'] == 'isnull' )
$where['AND'] = array_merge( $where['AND'], [ $key => null ] );
elseif ( $val['value'] == 'isnotnull' )
$where['AND'] = array_merge( $where['AND'], [ $key . '[!]' => null ] );
else
$where['AND'] = array_merge( $where['AND'], [ $key => $val['value'] ] );
}
if ( $val['type'] == 'date_range' ) if ( $val['type'] == 'date_range' )
{ {
@@ -448,6 +437,7 @@ class grid
public function getDataSummary() public function getDataSummary()
{ {
$summary = [];
$where = self::getWhereCondition(); $where = self::getWhereCondition();
if ( is_array( $this -> summary ) ) foreach ( $this -> summary as $key ) if ( is_array( $this -> summary ) ) foreach ( $this -> summary as $key )
@@ -522,7 +512,7 @@ class grid
public function saveElement( $values ) public function saveElement( $values )
{ {
if ( !$values[ $this -> id ] ) if ( !isset( $values[ $this -> id ] ) or !$values[ $this -> id ] )
{ {
unset( $values[ $this -> id ] ); unset( $values[ $this -> id ] );
return $this -> connectToDb() -> insert( $this -> table, $values ); return $this -> connectToDb() -> insert( $this -> table, $values );