From: Nicolas Boisselier Date: Mon, 6 Jul 2015 13:55:57 +0000 (+0100) Subject: config dir X-Git-Url: https://git.nbdom.net/?a=commitdiff_plain;h=66cda149c91a76c3c28cfef22418acb130e69745;p=nb.git config dir --- diff --git a/lib/php/db.php b/lib/php/db.php index a6b2b3a5..ed912d18 100644 --- a/lib/php/db.php +++ b/lib/php/db.php @@ -238,7 +238,11 @@ EOF; } function pset($name,$value) { - return $_REQUEST[$name] = $value; + if ($value === null) { + unset ($_REQUEST[$name]); + return null; + } + return ($_REQUEST[$name] = $value); } /* @@ -290,55 +294,6 @@ class table { return $this->fields(); } - /* - * Function db.page - * - * print any pages according to params - * - * @param (array) - */ - function page($Page,$param=null) { - if ($param === null) $param = $this->p(); - elseif (!is_array($param)) $param = array('name' => $param); - - foreach (array( - 'action' => 'list', - ) as $k => $v) { - } - - $Page->title = prettyText($this->name); - - #if ($Page->is('html')) $this->form_criterias(); - - if ($this->p('format')) $this->print_header($this->p('format')); - if ($this->p('format')) { - $this->rows(array('format' => $this->p('format'))); - return 0; - } - - #die($Page->content_type); - $Page->begin(); - echo '
'.PHP_EOL; - echo '
'.PHP_EOL; - #$Page->debug($this->tables()); - - - echo $this->html_menu(); - - /* - Rows - */ - if (@$this) $this->rows(array( - 'format' => $this->p('format'), - )); - - // END - echo '
'.PHP_EOL; - #$Page->out($Db->query2v("SELECT 1")); - $Page->end(); - return 0; - } - /* * Function db.fields * @@ -795,7 +750,7 @@ FROM pg_catalog.pg_attribute a WHERE a.attrelid = (SELECT c.oid FROM pg_catalog. $st = $this->db->conn->prepare($sql); $st->execute(); - $format = ''.(isset($opt['format']) ? $opt['format'] : 'table'); + $format = (!empty($opt['format']) ? $opt['format'] : 'table'); if (!@$opt['is_html']) $opt['is_html'] = preg_match('/^(table)$/',$format) ? true : false; if ($opt['is_html']) echo ''.PHP_EOL; diff --git a/lib/php/functions.php b/lib/php/functions.php index 9dea64b3..3b8d287e 100644 --- a/lib/php/functions.php +++ b/lib/php/functions.php @@ -62,6 +62,8 @@ function ls_dir($path,$recurse=false,$exp='') { } +function ar_first($ar) { return $ar[0]; } + function ar_map($return,$array,$as_hash=false) { $map = array_map(create_function('$a',"return($return);"),$array); diff --git a/lib/php/page.php b/lib/php/page.php index 995bbd6e..85b9b571 100644 --- a/lib/php/page.php +++ b/lib/php/page.php @@ -83,8 +83,9 @@ class Page { } function filename2title() { - $str = preg_replace(',^.*?([^/]+)(\/?.*)?$,','\1',$_SERVER['REQUEST_URI']); - if ($str == '/') $str = preg_replace('@^.*?([^/\.]+)(/index)?(\..*?)$@','\1',$_SERVER['SCRIPT_NAME']); + $str = ''; + if (isset($_SERVER['REQUEST_URI'])) $str = preg_replace(',^.*?([^/]+)(\/?.*)?$,','\1',$_SERVER['REQUEST_URI']); + if ($str == '' or $str == '/') $str = preg_replace('@^.*?([^/\.]+)(/index)?(\..*?)$@','\1',$_SERVER['SCRIPT_NAME']); $str = preg_replace('@[\'_-]+$@',' ',$str); return mb_strtoupper(mb_substr($str,0,1)).mb_strtolower(mb_substr($str,1,mb_strlen($str))); }