From c94983dc698bef34084e4c45e1ac898de4664f13 Mon Sep 17 00:00:00 2001 From: Nicolas Boisselier Date: Wed, 20 Jun 2018 13:36:20 +0100 Subject: [PATCH] www/dbq/dbq.php --- lib/php/db/table.php | 6 +++--- www/dbq/dbq.php | 48 ++++++++++++++++++-------------------------- 2 files changed, 23 insertions(+), 31 deletions(-) diff --git a/lib/php/db/table.php b/lib/php/db/table.php index 3bbb5996..319c7273 100644 --- a/lib/php/db/table.php +++ b/lib/php/db/table.php @@ -505,8 +505,6 @@ Class Table extends nb { $params = self::params2hash(self::$params); } - #debug([$params,array_diff($params,$ignore)]); -# NB 07.01.18 foreach (array_diff($params,$ignore) as $k=>$v) { foreach ($params as $k=>$v) { if (!empty($ignore) and in_array($k,$ignore)) continue; if (isset($v) or $k=='action') { @@ -1203,7 +1201,9 @@ Class Table extends nb { $out_conf = array_merge($opt,$out_conf); # Function name should be format - $this->db()->out->type($format); self::$params += array_values($this->db()->out->types()); + $this->db()->out->type($format); +# NB 20.06.18 Why ????? +# NB 20.06.18 self::$params += array_values($this->db()->out->types()); if (empty($out_conf['enclose'])) $out_conf['enclose'] = ['','']; debug('Using out module!',3); diff --git a/www/dbq/dbq.php b/www/dbq/dbq.php index 63f83c4a..9dbcc67a 100644 --- a/www/dbq/dbq.php +++ b/www/dbq/dbq.php @@ -183,7 +183,7 @@ class DbQ extends nb { if ($limit !== false) return $limit; if ($limit = $this->p('limit')) return $limit; - if ($this->page->is('html')) return ($limit = $this->default_limit); + if ($this->is_html) return ($limit = $this->default_limit); } @@ -358,7 +358,7 @@ class DbQ extends nb { $bottom[] = 'Database: '.preg_replace(array_keys($r),$r,$this->db->pdo); } - if ($bottom and $this->page->is('html')) echo $this->page->tag('div class="block bottom"',join('
'.NB_EOL,$bottom)); + if ($bottom and $this->is_html) echo $this->page->tag('div class="block bottom"',join('
'.NB_EOL,$bottom)); $this->page->end(); } @@ -396,21 +396,22 @@ class DbQ extends nb { # NB 11.06.18 return $this->db; } else { - // Re use - if (!empty($this->db)) return $this->db; - require_once(NB_ROOT.'/lib/php/db.php'); + // Re use + if (!empty($this->db)) return $this->db; + require_once(NB_ROOT.'/lib/php/db.php'); - // Load confs - if (empty($DB_CONFS)) { - require_once(NB_ROOT.'/lib/php/db/config.php'); - } else { - #debug($DB_CONFS); - $DB_CONFS = Db::conf_load($DB_CONFS); - } + // Load confs + if (empty($DB_CONFS)) { + require_once(NB_ROOT.'/lib/php/db/config.php'); + } else { + #debug($DB_CONFS); + $DB_CONFS = Db::conf_load($DB_CONFS); + } - $this->db = new Db(['conf'=>$DB_CONFS]); + $this->db = new Db(['conf'=>$DB_CONFS]); } + $this->db->is_html = $this->is_html; $this->db->html_base = $this->base; #$this->db->base = ($this->base ? $this->base : '/').$this->db->id; $this->db->base = $this->base . ($this->db->id ? '/' . $this->db->id : ''); @@ -507,12 +508,14 @@ class DbQ extends nb { } private function table_rows($fct=null) { - $this->db->limit = $this->limit(); $ropt = [ #'html_menu' => empty($this->_nopage), # NB 07.06.18 'is_html' => empty($this->_nopage), - 'is_html' => $this->page->is('html'), +# NB 20.06.18 'is_html' => $this->is_html, + 'is_html' => ($this->is_html and empty($this->_nopage)), ]; + $this->db->is_html = $ropt['is_html']; + $this->db->limit = $ropt['is_html'] ? $this->limit() : null; if (!empty($this->_nopage)) { $this->table->show_url_sort = false; } @@ -520,7 +523,7 @@ class DbQ extends nb { $this->row_parse_pre(); $this->row_parse_post(); - $opt = ($this->page->is('html') + $opt = ($this->is_html and $this->table_rw() and empty($this->_nopage) ) ? [ @@ -612,13 +615,9 @@ class DbQ extends nb { # NB 08.12.17 if ($this->format() == 'tmpl') { #bye($param); if (preg_match("/^(.*)\.(tmpl)$/",$this->params['table'],$m)) { -#bye($this->params['table']); $this->params['table'] = $m[1]; $param['idtemplate'] = $this->format(); $this->format('template'); -# NB 08.12.17 } else { -# NB 08.12.17 $this->error("Template id is missing"); -# NB 08.12.17 } } if (!in_array($this->params['table'],array_keys($this->db->tables()))) { @@ -633,7 +632,6 @@ class DbQ extends nb { $this->table = $this->db->table(array_merge([ 'name' => $this->params['table'], 'db' => $this->db, - 'db' => $this->db, 'show_hidden_params' => true, 'show_buttons' => false, 'show_header' => $this->is_html, @@ -978,17 +976,11 @@ EOF; if (empty($this->ext)) $this->ext = $format; $this->method_post_accept_decode(); $this->is_html = strpos($content_type,'html') ? true : false; - $this->db->is_html = $this->is_html; } public function phpinfo_rows() { - $txt = $this->page->is('html') ? 0 : 1; - - if (0 and !$this->page->is('html')) { - return $this->page->phpinfo(); - #return $this->page($this->page->phpinfo($txt)); - } + $txt = $this->is_html ? 0 : 1; $rows = []; $row = []; -- 2.47.3