From 7f7442db5731572788a12086158e81aee28d3dac Mon Sep 17 00:00:00 2001 From: Nicolas Boisselier Date: Mon, 15 Aug 2016 12:36:14 +0200 Subject: [PATCH] dbs order --- etc/dbs.yaml | 14 +++++--------- lib/php/db.php | 15 ++++++++++++--- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/etc/dbs.yaml b/etc/dbs.yaml index eecf9fbf..16eeb8ad 100644 --- a/etc/dbs.yaml +++ b/etc/dbs.yaml @@ -16,12 +16,14 @@ rt: title: 'RT' izi: - title: Mysql Izi - host: sql.izideal.vpn + title: Izi Admin + host: admin.izideal.vpn default_table: process user: izideal name: izi type: mysql + _import: + - _izi tables: site: replace: @@ -33,13 +35,7 @@ izi-sql: _import: - izi -izi: - title: Mysql Izi Master - host: admin.izideal.vpn - _import: - - izi - -izidev: +izi-dev: host: big.cascais.loc title: Mysql Izi on Big #user: nico diff --git a/lib/php/db.php b/lib/php/db.php index a863fe07..4ed9fb3b 100644 --- a/lib/php/db.php +++ b/lib/php/db.php @@ -416,7 +416,7 @@ class Db extends nb { } elseif ($action == 'db.dbs' or $action == 'dbs') { if (true or self::p('hash') or self::p('all')) { - $fields = ['id','name','title','type','host']; + $fields = ['id','name','title','type','host','order']; $dbs = []; $name = self::p('name',''); $type = self::p('type',''); @@ -505,11 +505,20 @@ class Db extends nb { foreach ($h as $db=>$o) { if (preg_match('/^_/',$db)) unset($h[$db]); } # Add missing name - foreach ($h as $db=>$o) { if (empty($o['name'])) $h[$db]['name'] = $db; } + foreach ($h as $db=>$o) { + if (empty($o['name'])) $h[$db]['name'] = $db; + if (empty($o['id'])) $h[$db]['id'] = $db; + } # Sort - uasort($h,create_function('$a,$b','$a_=isset($a["order"])?$a["order"]:-1;$b_=isset($b["order"])?$b["order"]:-1; return($b_-$a_);')); + uasort($h,function($a,$b){ + if (empty($a["order"]) and empty($b["order"])) return strcmp($a['id'],$b['id']); + $a_ = isset($a["order"]) ? $a["order"] : -1; + $b_ = isset($b["order"]) ? $b["order"] : -1; + return($b_-$a_); + }); + if (!$h) return false; if ($first !== false) $first = self::ar_first($h); return $h; -- 2.47.3