From: Nicolas Boisselier Date: Thu, 8 Sep 2016 11:07:27 +0000 (+0100) Subject: fix bugs X-Git-Url: https://git.nbdom.net/?a=commitdiff_plain;h=424df570278b091721146400a486b5cd284fc051;p=nb.git fix bugs --- diff --git a/etc/dbs/ui.php b/etc/dbs/ui.php index a698b6b7..69bbef08 100644 --- a/etc/dbs/ui.php +++ b/etc/dbs/ui.php @@ -165,6 +165,8 @@ $CONF['_ui'] = array( ); $CONF['ui'] = array( '_import' => array('_ui'), + 'order' => (preg_match('/^(dev|isp|ist)/',php_uname('n')) ? 1 : null), + #'order' => 1, ); $CONF['ui-pgsql'] = array( 'host' => 'ui.semantico.net', diff --git a/lib/php/db.php b/lib/php/db.php index 21512d3b..78d5be66 100644 --- a/lib/php/db.php +++ b/lib/php/db.php @@ -961,10 +961,12 @@ class Db extends nb { $dbs = []; $name = self::p('name',''); $type = self::p('type',''); + $has_order = false; foreach ($this->conf as $id => $attr) { $attr['_no_connect'] = true; $attr['id'] = $id; + if (isset($attr['id'])) $has_order = true; $d = new Db($attr); $db = []; @@ -978,6 +980,7 @@ class Db extends nb { $dbs[] = $db; } + if ($has_order) foreach ($dbs as $i=>$db) if (!isset($db['order'])) $dbs[$i]['order'] = ''; return $dbs; } diff --git a/lib/php/db/page.php b/lib/php/db/page.php index 027e452f..bb2916ea 100644 --- a/lib/php/db/page.php +++ b/lib/php/db/page.php @@ -6,7 +6,8 @@ require_once(dirname(__FILE__).'/../page.php'); $Page = new Page([ #'title' => 'Test', - 'content_type' => ((Page::php_cli() and !Page::p('web') )? 'text/plain' : 'text/html'), + 'content_type' => Page::content_type_and_set_format(), + #'content_type' => ((Page::php_cli() and !Page::p('web') )? 'text/plain' : 'text/html'), 'call' => array( 'begin', ['out', "Hello World !!!\n"], @@ -23,10 +24,14 @@ $Page = new Page([ #bye($type); $page->pdef('format','csv'); } + #echo Page::p('db')."\n"; return; +#echo 'zaza'; return; if ($page->action()) 1; else require_once(dirname(__FILE__).'/index.php'); #else if (!empty($page->db)) $page->db->action($page->db->p('action'),empty($Table) ? null : $Table); }, +/* +*/ #array('out', print_r($_SERVER,true)), 'end', ), diff --git a/lib/php/nb.php b/lib/php/nb.php index ca5abe8e..d71a3fa8 100644 --- a/lib/php/nb.php +++ b/lib/php/nb.php @@ -248,7 +248,6 @@ class NB { } $new_argv = array(); - for ($i=1;$i diff --git a/lib/php/page.php b/lib/php/page.php index fe470cf4..44a4de13 100644 --- a/lib/php/page.php +++ b/lib/php/page.php @@ -55,6 +55,7 @@ class Page extends nb { if (isset($opt['content_type'])) $this->content_type($opt['content_type']); #elseif($this->php_cli()) $this->content_type('text/html'); unset($opt['content_type']); + if (!$this->content_type()) $this->content_type($this->client_content_type()); // Statics foreach ([ @@ -68,7 +69,7 @@ class Page extends nb { // Opt parent::__construct($opt); - + // Defaults if ( empty($this->title) ) $this->title = !empty($title) ? join($this->sep,$title) : $this->filename2title(); if ( empty($this->h1) ) $this->h1 = !empty($nav) ? join($this->sep,$nav) : $this->title; @@ -304,20 +305,6 @@ class Page extends nb { } - /* - * Function client_content_type - * Return the head Accept from the client - */ - public static function client_content_type() { - $headers = getallheaders(); - if (0 - or !isset($headers['Accept']) - or $headers['Accept'] == '*/*' - ) return ''; - $v = explode(',', $headers['Accept']); - return $v ? $v[0] : ''; - } - public static function headers_no_cache() { $ts = gmdate("D, d M Y H:i:s") . " GMT"; header("Expires: $ts"); @@ -425,10 +412,6 @@ class Page extends nb { return preg_replace('/\?.*$/','',$_SERVER['REQUEST_URI']); } - public static function files_concat($files) { - - } - public static function nav_parse($array) { #$v = &$sep; foreach ($array as $k => $v) { @@ -538,5 +521,20 @@ class Page extends nb { return self::$content_type; } + public static function content_type_and_set_format() { + $format = self::p('format'); + $content_type = self::p('content_type'); + + if (!$format and $content_type) { + self::p('format',self::mime2ext($content_type)); + } elseif (!$format and ($client_type = self::client_content_type())) { + self::p('format',self::mime2ext($client_type)); + } + + if (!$content_type and $format) $content_type = self::ext2mime($format); + if (!$content_type and self::php_cli()) $content_type = 'text/plain'; + if ($content_type) return $content_type; + } + } return; # < Class ?>