]> git.nbdom.net Git - nb.git/commitdiff
www/dbq/dbq.php
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Sun, 28 Jan 2018 04:16:13 +0000 (04:16 +0000)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Sun, 28 Jan 2018 04:16:13 +0000 (04:16 +0000)
lib/php/functions.php
lib/php/nb.php
www/dbq/dbq.php
www/dbq/html/default.js

index 9737a503bcb2d41f6950c3072543d73f70d5c775..cf620df50215a4418d6e1addd2f08c0e3321cfd8 100644 (file)
@@ -1,6 +1,7 @@
 <?php
 require_once(realpath(dirname(__FILE__).'/nb.php'));
 if (!defined('EOL')) define('EOL',NB_EOL);
+function prettyText($text) { return Nb::prettyText($text); }
 /*
 Vim:
 
@@ -11,7 +12,7 @@ s/^define(\([^,]\+\)/if (!defined(\1)) define(\1/
 */
 
 function file_write($file,$data,$mode='w') {
-  return nb::file_write($file,$data,$mode);
+  return Nb::file_write($file,$data,$mode);
 
   if (!$ftmp = fopen($file,$mode)) {
     bye("file_write(): Cant open $file in mode $mode");
@@ -51,7 +52,7 @@ function ar_map($return,$array,$as_hash=false) {
 }
 
 function txt2md($txt) {
-# NB 28.11.16: TODO rename as nb::md2html 
+# NB 28.11.16: TODO rename as Nb::md2html 
   global $_txt2md;
   if ($_txt2md === null) {
     require_once(NB_ROOT.'/lib/php/parsedown/Parsedown.php');
@@ -61,7 +62,7 @@ function txt2md($txt) {
 }
 
 function bye($msg='__bye__',$backtrace_deep=0) {
-  return nb::bye($msg,$backtrace_deep);
+  return Nb::bye($msg,$backtrace_deep);
 }
 
 function warn ($msg) {
@@ -69,7 +70,7 @@ function warn ($msg) {
 }
 
 function err($msg='__err__',$preff='err',$backtrace_deep=0) {
-  return nb::err($msg,$preff,$backtrace_deep);
+  return Nb::err($msg,$preff,$backtrace_deep);
 }
 
 # NB 15.11.17 function err($msg='__err__',$preff='err',$backtrace_deep=0) {
@@ -78,8 +79,8 @@ function err($msg='__err__',$preff='err',$backtrace_deep=0) {
 # NB 15.11.17 
 # NB 15.11.17   if ($msg !== '__err__' and $backtrace_deep !== false) {
 # NB 15.11.17     $msg = trim($preff_msg.$msg).' '
-# NB 15.11.17       .nb::debug_backtrace_msg(1+$backtrace_deep,NULL,$preff_msg)
-# NB 15.11.17       #.nb::debug_backtrace_msg(1+$backtrace_deep,NULL)
+# NB 15.11.17       .Nb::debug_backtrace_msg(1+$backtrace_deep,NULL,$preff_msg)
+# NB 15.11.17       #.Nb::debug_backtrace_msg(1+$backtrace_deep,NULL)
 # NB 15.11.17     ;
 # NB 15.11.17 
 # NB 15.11.17   } else { 
@@ -87,8 +88,8 @@ function err($msg='__err__',$preff='err',$backtrace_deep=0) {
 # NB 15.11.17 
 # NB 15.11.17   }
 # NB 15.11.17 
-# NB 15.11.17   #nb::msg( !nb::php_cli()
-# NB 15.11.17   nb::msg( nb::client_header('Accept','ml')
+# NB 15.11.17   #Nb::msg( !Nb::php_cli()
+# NB 15.11.17   Nb::msg( Nb::client_header('Accept','ml')
 # NB 15.11.17     ? '<pre'
 # NB 15.11.17         .' class="err'. ( ($preff and $preff!='err') ? " $preff" : '' ).'"'
 # NB 15.11.17       .'>'.$msg.'</pre>'.NB_EOL
@@ -98,15 +99,15 @@ function err($msg='__err__',$preff='err',$backtrace_deep=0) {
 # NB 15.11.17 }
 
 function debug($msg,$level=0) {
-  return nb::debug($msg,$level);
+  return Nb::debug($msg,$level);
 }
 
 # NB 15.11.17 function debug($msg,$level=0) {
-# NB 15.11.17   if ($level and $level>nb::p('debug')) return;
+# NB 15.11.17   if ($level and $level>Nb::p('debug')) return;
 # NB 15.11.17   #$msg = is_scalar($msg) ? $msg : print_r($msg,true);
 # NB 15.11.17   $msg = is_scalar($msg) ? $msg : print_r($msg,true);
 # NB 15.11.17 
-# NB 15.11.17   if (nb::client_header('Accept','ml')) {
+# NB 15.11.17   if (Nb::client_header('Accept','ml')) {
 # NB 15.11.17     $msg = '<pre class="debug">'
 # NB 15.11.17       .(isset($_SERVER['HTTP_HOST']) ? htmlentities($msg) : $msg)
 # NB 15.11.17       #.(isset($_SERVER['HTTP_HOST']) ? htmlspecialchars($msg) : $msg)
@@ -116,21 +117,10 @@ function debug($msg,$level=0) {
 # NB 15.11.17     $msg = "DEBUG: $msg\n";
 # NB 15.11.17 
 # NB 15.11.17   }
-# NB 15.11.17   nb::msg($msg);
+# NB 15.11.17   Nb::msg($msg);
 # NB 15.11.17 
 # NB 15.11.17 }
 
-function prettyText($text) {
-  $replace = array(
-    '/(\w)(,)(\w)/' => '$1$2 $3',
-    '/_/' => ' ',
-    '/[^\w,]+/' => ' ',
-  );
-  return ucwords(
-    preg_replace(array_keys($replace),array_values($replace),$text)
-  );
-}
-
 function rtf2txt($rtf) {
        $cmd="unrtf --text";
   return cmd2str($cmd,$rtf);
@@ -184,7 +174,7 @@ function cmd2str($cmd,$write=null) {
 
 }
 
-function argv2request($args=null) { return nb::argv2request($args); }
+function argv2request($args=null) { return Nb::argv2request($args); }
 
 function html_select_array($data,$opt=[]) {
 
index f7ce4fcc882e63162e5c2217d086d30bf4804e4c..af9ed5be1d219a6fce0d8bba1d11525e310479d2 100644 (file)
@@ -225,9 +225,17 @@ class NB {
         * Does what it says
         */
        public static function prettyText($text) {
-               return prettyText($text);
+       $exps = array(
+       '/(\w)(,)(\w)/' => '$1$2 $3',
+       '/_/' => ' ',
+       '/[^\w,=]+/' => ' ',
+       );
+       return ucwords(
+       preg_replace(array_keys($exps),array_values($exps),$text)
+       );
        }
 
+
 # NB 19.01.18  public static function mime2ext($mime) {
 # NB 19.01.18          require_once(NB_ROOT.'/lib/php/mime.php');
 # NB 19.01.18          return Mime::ext($mime);
index 2c5dea850c7785611486769a466e30cbbfe484d7..a94e299f8b3302d079e6969c5d1c196a77012925 100644 (file)
@@ -285,6 +285,7 @@ class DbQ extends nb {
                        $this->page->body_class = ''
                                .(empty($this->params['db']) ? '' : ' db-'.$this->params['db'])
                                .(empty($this->params['table']) ? '' : ' table-'.$this->params['table'])
+                               .( (empty($this->db) or empty($this->table)) ? '' : ' h1-to-select' )
                                .(empty($this->params['action']) ? ' action-'.self::PARAM_DB_DEFAULT : ' action-'.($this->params['action'] == 'add' ? 'vi' : $this->params['action']))
 
                        ;
index 351d694eb623abbe5a2a58b3335837c110f20eab..71ef3f13670d4cd0db8801093ab736e9dc5fc2d8 100644 (file)
@@ -133,9 +133,8 @@ document.addEventListener("DOMContentLoaded", function() {
                document.querySelector("th.delete").appendChild(a);
        }
 
-       if (document.querySelector("body.action-ls")) document.querySelectorAll("body > h1 a.db, body > h1 a.table").forEach(function(e) {
+       if (document.querySelector("body.h1-to-select")) document.querySelectorAll("body > h1 a.db, body > h1 a.table").forEach(function(e) {
                var base = window._dbq[e.className+'.base'].replace(/\/[^\/]+$/,'');
-               //if (base == '') base = '/';
                var url = base + (base == '' ? '/ls' : '') + '.json';
                console.log(url);
                var fields = e.className == 'db' ? ['id','id'] : ['name','name'];