]> git.nbdom.net Git - nb.git/commitdiff
fix
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Thu, 7 Apr 2016 11:24:49 +0000 (12:24 +0100)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Thu, 7 Apr 2016 11:24:49 +0000 (12:24 +0100)
lib/php/db.php
lib/php/db/table.php
lib/php/out.php

index 58a44594e24e16fbf2b9ef424d390d97c8865393..41b6bebdad27fa8fb36f65afd93d5f6fd9029550 100644 (file)
@@ -133,7 +133,7 @@ class Db extends nb {
     if (empty($this->pdo)) return false;
 
     # Type
-    if (!$this->type(null)) $this->bye("unknow type = `".$this->type."`");
+    if (!$this->type(null)) $this->bye("Unknow type = `".$this->type."`");
 
     # Connect
     if ($this->type('use_path') and !is_readable($this->name)) {
@@ -146,7 +146,7 @@ class Db extends nb {
       #if (isset($this->pdo_error)) $this->conn->setAttribute($this->pdo_error[0], $this->pdo_error[1]);
 
     } catch (PDOException $e) {
-      throw new CustomException('Connection failed: ' . $e->getMessage(), (int)$e->getCode( ));
+      throw new Exception('Connection failed: ' . $e->getMessage(), (int)$e->getCode( ));
       self::bye('Connection failed: ' . $e->getMessage());
 
     }
index d56fe26d0e15462804a2bcaedb2d1cbc87f6096f..920452c3c023dc68a5ef74b3ba625212eb93fdc4 100644 (file)
@@ -227,7 +227,7 @@ Class Table extends nb {
   }
 
   public function fields_keys(&$others=array()) {
-    
+
     $fields_keys = array();
 
     foreach ($this->fields() as $name => $f) {
@@ -247,7 +247,7 @@ Class Table extends nb {
     foreach (array_diff(self::$params,$ignore) as $p) {
       if ($v=self::p($p)) {
         if (self::p('debug')) $h .= "<label>$p</label>";
-        $h .= '<input type="'.(self::p('debug')?'text':'hidden').'" name="'.$p.'" value="'.$v.'"/>';
+        $h .= '<input type="'.(self::p('debug')?'text':'hidden').'" name="'.$p.'" value="'.$v.'"/>'.NB_EOL;
       }
     }
     return $h;
@@ -384,21 +384,6 @@ Class Table extends nb {
       $next = 999999;
     }
 
-  /*
-    if ($prev>=0) $html .= '<li class="prev"><a href="'.$this->url_list('limit',preg_replace('/^0,/','',"$prev,$y")).'">&lt;&lt;</a></li>';
-
-    $html .= '<li class="count">'.($tot ? ($x+1) : 0).' - '.( $count<($x+$y) ? $count : ($x+$y) ).' / '.$tot.' results</li>';
-
-    if ($next<$tot) $html .= '<li class="prev"><a href="'.$this->url_list('limit',"$next,$y").'">&gt;&gt;</a></li>';
-
-    if ($html) $html = ''
-      .'<nav>'.NB_EOL
-      .'<li>'.NB_EOL
-      .$html
-      .'</li>'.NB_EOL
-      .'</nav>'.NB_EOL
-    ;
-  */
     if ($prev>=0) $html .= '<span class="prev"><a href="'.$this->url_list('limit',preg_replace('/^0,/','',"$prev,$y")).'">&lt;&lt;</a></span>&nbsp;';
 
     $html .= '<span class="count">'.($tot ? ($x+1) : 0).' - '.( $count<($x+$y) ? $count : ($x+$y) ).' / '.$tot.' results</span>';
@@ -602,13 +587,12 @@ Class Table extends nb {
 
     if ($opt['is_html'] and !$this->p('action') and !$this->p('inc')) {
       echo $this->html_menu();
-
-    } elseif ($opt['is_html'] and !$this->p('inc')) {
-      echo $this->form_hidden();
-
     }
 
-    if ($opt['is_html']) echo '<div class="results">'.NB_EOL;
+    if ($opt['is_html']) {
+       echo '<div class="results">'.NB_EOL;
+       if (!$this->p('inc')) echo $this->form_hidden();
+    }
 
     # Use the module out when format unknow
     $out_conf = null;
@@ -695,10 +679,10 @@ Class Table extends nb {
         $query = $this->db()->conn->query($select_count[1]);
 
       } elseif ($where) {
-        $debug = "Table.rows(): Using $sql_count";
         $sql_count = $sql;
         $sql_count = preg_replace('/ (ORDER|LIMIT) .*?$/s','',$sql_count);
         $sql_count = preg_replace('/^SELECT .*FROM/s','SELECT count(*) FROM ',$sql_count);
+        $debug = "Table.rows(): Using $sql_count";
         $query = $this->db()->conn->query($sql_count);
 
       } else {
index fd0fc32155d6b35cab902510eaba15827b235b29..b8f597c9cbb32ef11d4c8c81cfec8d6085fd3a7e 100644 (file)
@@ -379,6 +379,8 @@ function out_tag(&$row,&$o) {
 
   foreach ($row as $k => $v) {
 
+    $v = out::escape($v);
+
     # Inside tag, ex: label
     if (isset($o['tag_key'])) {
       $v = '<'.$o['tag_key'].'>'.$k.'</'.preg_replace('/ .*$/','',$o['tag_key']).'>'.$v;
@@ -387,12 +389,11 @@ function out_tag(&$row,&$o) {
     # Tag = o[tag] or key
     if (isset($o['tag'])) {
       $class = is_numeric($k) ? '' : ' class="'.$k.'"';
-      $k = $o['tag']; 
+      $k = $o['tag'];
     } else {
       $class = '';
     }
 
-    $v = out::escape($v);
     echo ''
       .(NB_EOL ? '    ' : '')
       ."<$k$class>$v</$k>"