From: Nicolas Boisselier Date: Wed, 21 Dec 2016 15:06:42 +0000 (+0000) Subject: dbq X-Git-Url: https://git.nbdom.net/?a=commitdiff_plain;h=1339cb33ef229007c614154b681d5377c42b8a8a;p=nb.git dbq --- diff --git a/lib/php/db.php b/lib/php/db.php index 3f614c1b..0155b62c 100644 --- a/lib/php/db.php +++ b/lib/php/db.php @@ -620,6 +620,7 @@ class Db extends nb { $rows = self::array_fill_assoc($rows); usort($rows,function($a,$b) { return strcmp($a['name'],$b['name']); }); + return $rows; } diff --git a/lib/php/db/table.php b/lib/php/db/table.php index 7ee5614d..ed292cfb 100644 --- a/lib/php/db/table.php +++ b/lib/php/db/table.php @@ -1775,7 +1775,7 @@ Class Table extends nb { $r .= '
'; // Hiddens - #if ($this->show_hidden_params) + if ($this->show_hidden_params) $r .= ''#.print_r(self::$params,true) .self::form_hidden(['db','table','format','limit','download']) // Embed for no html format (rent) diff --git a/lib/php/nb.php b/lib/php/nb.php index a0b151de..4cb85e89 100644 --- a/lib/php/nb.php +++ b/lib/php/nb.php @@ -838,28 +838,27 @@ class NB { public static function client_content_type($default='') { $v = explode(',', self::client_header('Accept')); return ( ($v and $v[0] != '*/*') ? $v[0] : $default ); -# NB 19.12.16 $headers = self::client_header(); -# NB 19.12.16 if (0 -# NB 19.12.16 or !isset($headers['Accept']) -# NB 19.12.16 or $headers['Accept'] == '*/*' -# NB 19.12.16 ) return ''; -# NB 19.12.16 $v = explode(',', $headers['Accept']); -# NB 19.12.16 return $v ? $v[0] : ''; } - public static function array_fill_assoc($rows) { - $keys = []; - - foreach($rows as $k=>$v) { - $keys = array_merge_recursive(array_keys($v),$keys); + public static function array_fill_assoc($rows,$keys=null) { + if ($keys === null) { + $keys = []; + foreach(array_reverse($rows) as $v) { + foreach ($v as $k=>$vv) $keys[$k] = 1; + } + $keys = array_keys($keys); } + # NB 21.12.16: to keep order we need a new array + $new = []; foreach($rows as $k=>$v) { foreach ($keys as $key) { - if (empty($v[$key])) $rows[$k][$key] = ''; + $new[$k][$key] = isset($v[$key]) ? $v[$key] : ''; + if (!isset($v[$key])) $rows[$k][$key] = ''; } } + return $new; return $rows; } diff --git a/www/dbq/dbq.php b/www/dbq/dbq.php index 78e7aa21..c5e6d56f 100644 --- a/www/dbq/dbq.php +++ b/www/dbq/dbq.php @@ -162,16 +162,51 @@ function form_clean(form) { e.value = "" } } +function form_submit_clean(f) { + var i = 0; + var url = ""; + var action = f.getAttribute("action"); + var method = f.getAttribute("method"); + if (method != "get") return true; + + //if (typeof(action) == "undefined") action = ""; + + for(i=0;ipage->is('html')) { - #debug($this->page->content_type()); - } $opt = ($this->page->is('html') and ($this->perm >= self::VIEW) and $this->table->type() != 'sql' @@ -283,7 +315,6 @@ document.addEventListener("DOMContentLoaded", function() { '', ]), 'row_parse_pre' => function(&$r){ - $GLOBALS['dbq_args'] = urlencode( join(self::PARAM_ARGS_SEP,$this->table->fields_keys_values($r)) ); }, 'row_parse_post' => function(&$r){