]> git.nbdom.net Git - nb.git/commitdiff
lib/php/db/field.php
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Fri, 14 Sep 2018 18:48:19 +0000 (19:48 +0100)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Fri, 14 Sep 2018 18:48:19 +0000 (19:48 +0100)
lib/php/db/field.php
lib/php/db/table.php

index 75776d7fba1db83be8169bcea45f3c443bf7d8bf..94184c7ff69184d16403a148f5f1fcd91436b49e 100644 (file)
@@ -73,7 +73,6 @@ class field extends nb {
     # See: http://www.w3schools.com/html/html_form_input_types.asp
     if (stripos($this->name,'password') !== false) return 'password" autocomplete="off';
     if ($this->numeric() !== false) return 'number" step="any';
-    if ($this->autoincrement) return 'text" readonly="readonly';
     return 'text';
     # Html5 only
     if (stripos($this->name,'mail') !== false) return 'email'; # no safari
@@ -104,9 +103,9 @@ class field extends nb {
     #$t1 = $t2 = '';
 
     return $t1
-      .'Yes <input type="radio" class="yes" name="'.$this->preffix.$this->name.'" value="1"'.$s_yes.'>'
+      .'Yes <input type="radio" class="yes form-control" name="'.$this->preffix.$this->name.'" value="1"'.$s_yes.'>'
       .' | '
-      .'No <input type="radio" class="no" name="'.$this->preffix.$this->name.'" value="0"'.$s_no.'>'
+      .'No <input type="radio" class="no form-control" name="'.$this->preffix.$this->name.'" value="0"'.$s_no.'>'
       #.'<input type="text" id="'.$this->name.'" style="display:none" value="'.($s_yes ? 1 : 0).'">'
     .$t2;
 
@@ -156,6 +155,10 @@ class field extends nb {
        $h .= '<'.$tag
                .' name="'.$this->preffix.$this->name . ($multi ? '[]' : '') . '"'
                .( ($size and $tag != 'textarea') ? ' size="'.$size.'"' : '')
+                                       .' class="form-control"'
+                                       .' placeholder="'.htmlspecialchars(prettyText($this->name)).'"'
+                       . ($this->autoincrement ? ' readonly="readonly"' : '')
+                       . ($this->null ? '' : ' required="required"')
                .($tag == 'textarea' ? '>'.$value.'</textarea>' : ' type="'.$type.'" value="'.htmlspecialchars($value).'" />')
        ;
 
index c27ee99d9e001292026ff5966f6d739c2ba111a6..4da49e768862c8fcfab849bd15f14db087a0e81c 100644 (file)
@@ -634,9 +634,9 @@ Class Table extends nb {
 
                echo ''
                        .'<div class="db buttons">'
-                       .( empty($_SERVER['HTTP_REFERER']) ? '' : '<input type="button" onclick="document.location=document.referrer" value="Cancel" />')
-                       .'<input type="reset" />'
-                       .'<input type="submit" />'
+                       .( empty($_SERVER['HTTP_REFERER']) ? '' : '<input type="button btn btn-danger" onclick="document.location=document.referrer" value="Cancel" />')
+                       .'<input class="btn btn-warning" type="reset" />'
+                       .'<input class="btn btn-success" type="submit" />'
                        .'</div>'.NB_EOL
                ;
 
@@ -2159,7 +2159,7 @@ Class Table extends nb {
        public function html_menu($opt=[]) {
                if (isset($opt['html_menu']) and !$opt['html_menu']) return '';
 
-               $buttons = '<input type="submit" class="button button-small" value="Go"/>';
+               $buttons = '<input type="submit" class="button button-small bnt bnt-primary" value="Go"/>';
                if (!empty($opt['buttons'])) $buttons = $opt['buttons'];
 
                $r = '<form class="menu list-group-item" id="db-table-html-menu-form" method="get" action="'.$this->request_uri().'">'.NB_EOL;
@@ -2173,75 +2173,75 @@ Class Table extends nb {
                //
                $options = (bool)($this->p('table-menu-options')!=='0');
                if ($options) {
-
-                       $r .= '<div class="options">';
+                       $option_html = '';
 
                        // Tables - see default.js if you change class
                        $tables = array_keys($this->db()->tables());
                        if (count($tables)>1) {
-                               $r .= '<span class="label">';
-                               $r .= '<label for="table">Tables</label>'.html_select_array($tables,[
-                                       'html'       => 'class="table" name="table" id="table"',
+                               $option_html .= '<span class="label">';
+                               $option_html .= '<label for="table">Tables</label>'.html_select_array($tables,[
+                                       'html'       => 'class="table form-control" name="table" id="table"',
                                        'selected'   => $this->name,
                                        'prettyText' => true,
                                        'sort'       => 'natcasesort',
                                ]);
-                               $r .= '</span>';
+                               $option_html .= '</span>';
                        }
 
                        // Dbs - see default.js if you change class
                        if (!empty($this->db()->dbs) and count($this->db()->dbs)>1) {
-                               $r .= '<span class="label">';
-                               $r .= '<label for="db">Db</label>'.html_select_array($this->db()->dbs,[
-                                       'html'       => 'class="dbs" id="db" name="db" onchange="document.location=\''.preg_replace('/\?.*$/','',$_SERVER['REQUEST_URI']).'?db=\'+this.value"',
+                               $option_html .= '<span class="label">';
+                               $option_html .= '<label for="db">Db</label>'.html_select_array($this->db()->dbs,[
+                                       'html'       => 'class="dbs form-control" id="db" name="db" onchange="document.location=\''.preg_replace('/\?.*$/','',$_SERVER['REQUEST_URI']).'?db=\'+this.value"',
                                        'selected'   => $this->db()->name,
                                        'prettyText' => true,
                                        'sort' => 'natcasesort',
                                ]);
-                               $r .= '</span>';
+                               $option_html .= '</span>';
                        }
 
                        // Format
-                       $r .= '<span class="label">';
+                       $option_html .= '<span class="label">';
                        #debug($this->db()->formats);
-                       $r .= '<label for="format">Format</label>'.html_select_array($this->db()->formats,[
-                               'html'       => 'class="format" name="format" id="format"',
+                       $option_html .= '<label for="format">Format</label>'.html_select_array($this->db()->formats,[
+                               'html'       => 'class="format form-control" name="format" id="format"',
                                'selected'   => $this->db()->format,
                                'prettyText' => true,
 # NB 26.12.16         'sort'       => 'natcasesort',
                        ]);
-                       $r .= '</span>';
+                       $option_html .= '</span>';
 
                        // Limit
                        if (!empty($this->db()->limits) and count($this->db()->limits)>1) {
-                               $r .= '<span class="label">';
-                               $r .= '<label for="limit">Limit</label>'.html_select_array($this->db()->limits,[
-                                       'html'       => 'class="limit" name="limit" id="limit"',
+                               $option_html .= '<span class="label">';
+                               $option_html .= '<label for="limit">Limit</label>'.html_select_array($this->db()->limits,[
+                                       'html'       => 'class="limit form-control" name="limit" id="limit"',
                                        'selected'   => $this->p('limit'),
                                        'prettyText' => true,
                                        'sort' => 'sort',
                                        'default_value' => $this->db()->limits[0],
                                ]);
-                               $r .= '</span>';
+                               $option_html .= '</span>';
                        }
 
                        // Submit
-                       $r .= $buttons;
+                       $option_html .= $buttons;
 
                        // Order By
                        /*
-                       $r .= '<span class="label">';
-                       $r .= '<label for="limit">OrderBy</label>'.html_select_array(array_keys($this->fields()),[
-                               'html'       => 'class="orderby" name="orderby" id="orderby"',
+                       $option_html .= '<span class="label">';
+                       $option_html .= '<label for="limit">OrderBy</label>'.html_select_array(array_keys($this->fields()),[
+                               'html'       => 'class="orderby form-control" name="orderby" id="orderby"',
                                'selected'   => $this->p('orderby'),
                                'prettyText' => true,
                        ]);
-                       $r .= '</span>';
+                       $option_html .= '</span>';
                        */
 
                        $form_hidden_ignore = ['db','table','format','limit'];#,'download'];
 
-                       $r .= '</div>'; # < Options
+                       if ($option_html) $r .= '<div class="options">' . $option_html . '</div>';
+
 
                } else { # // Options
                        $form_hidden_ignore = ['limit'];
@@ -2271,7 +2271,7 @@ Class Table extends nb {
                        $r .= ''
                                .'<span class="label '.$k.'">'
                                . '<label>'.prettyText($k).'</label>'
-                               . '<input type="text" id="'.$k.'" name="'.$this->ppreff().$k.'" value="'.$v.'" />'
+                               . '<input class="form-control" type="text" id="'.$k.'" name="'.$this->ppreff().$k.'" value="'.$v.'" />'
                                .'</span>'
                        ;