]> git.nbdom.net Git - nb.git/commitdiff
function out::row_end obsolete
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Tue, 27 Sep 2016 14:07:49 +0000 (16:07 +0200)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Tue, 27 Sep 2016 14:07:49 +0000 (16:07 +0200)
lib/php/db/table.php
lib/php/out.php

index c92f60337929d54bc58ad5143daafaec6dbad32e..a4ab811238d613da6d0831a3dc2f53abd01eba55 100644 (file)
@@ -816,7 +816,7 @@ Class Table extends nb {
       #
       # Close previous
       #
-      if ($out_conf and $count !== 1) out::row_end($out_conf);
+# NB 27.09.16       if ($out_conf and $count !== 1) out::row_end($out_conf);
 
       #
       # Preffix
index 762d19d7ab0054c141f636da95ce7abd5206d234..de4d98956422abf54076adad8bb6223a6f6b2446 100644 (file)
@@ -36,9 +36,13 @@ Class Out extends Nb {
       ),
 
       'php' => array(
+# NB 27.09.16         'enclose' => [
+# NB 27.09.16            '<?php'.(NB_EOL ? NB_EOL:' ') . '$VAR = array('.NB_EOL
+# NB 27.09.16           ,NB_EOL.');' . (NB_EOL ? NB_EOL:' ').'?'.'>'.NB_EOL
+# NB 27.09.16         ],
         'enclose' => [
-           '<?php'.(NB_EOL ? NB_EOL:' ') . '$VAR = array('.NB_EOL
-          ,NB_EOL.');' . (NB_EOL ? NB_EOL:' ').'?'.'>'.NB_EOL
+           '<?php'.(NB_EOL ? NB_EOL:' ') . '$VAR = array('
+          ,');' . (NB_EOL ? NB_EOL:' ').'?'.'>'.NB_EOL
         ],
         'eol' => self::p('eol',NB_EOL),
         'rec' => ',',
@@ -120,7 +124,8 @@ Class Out extends Nb {
       ],
 
       'json' => array(
-        'enclose' => array('['.NB_EOL,NB_EOL.']'),
+        #'enclose' => array('['.NB_EOL,NB_EOL.']'),
+        'enclose' => array('[',']'),
         'row' => function(&$o,&$row) { return json_encode($row); },
         'eol' => self::p('eol',NB_EOL),
         'rec' => ',',
@@ -214,6 +219,7 @@ Class Out extends Nb {
 
   public static function head(&$o,$head,$data=[]) {
     $o['header'] = (self::p('header')==='0') ? false : true;
+    $o['out_count'] = 0;
 
     # Format $head
     if ($head !== false) {
@@ -251,27 +257,34 @@ Class Out extends Nb {
       #or !isset($o['head'])
     ) return;
 
-    self::type_call('head',$o,$head) . empty($o['eol']) ? '' : $o['eol'];
+    if (self::type_call('head',$o,$head)) $o['out_count']++;
+    if (isset($o['eol'])) echo $o['eol'];
     return $head;
 
   }
 
   public static function row(&$o,&$row) {
 
-    if (self::type_call('row',$o,$row)) return true;
+    if ($o['out_count'] and isset($o['rec'])) echo $o['rec'];
+    if (self::type_call('row',$o,$row)) {
+      $ret = true;
 
     # Assume html/xml tag style
-    if (isset($o['tag'])) {
-      return out_tag($o,$row);
-    }
+    } elseif (isset($o['tag'])) {
+      $ret = out_tag($o,$row);
+    } else {
 
-    # txt
-    return self::row_txt($o,$row);
+      # txt
+      $ret = self::row_txt($o,$row);
+    }
 
-    return true;
+    if (isset($o['eol'])) echo $o['eol'];
+    $o['out_count']++;
+    return $ret;
   }
 
   public static function row_end($o) {
+    bye('OBSOLETE');
     if (isset($o['rec'])) echo $o['rec'];
     if (isset($o['eol'])) echo $o['eol'];
   }
@@ -280,6 +293,7 @@ Class Out extends Nb {
     #if (isset($o['end'])) echo $o['end']($o);
     self::type_call('end',$o);
     if (isset($o['enclose'])) echo $o['enclose'][1];
+    unset($o['out_count']);
   }
 
   public static function rows_get($type,$data,$head=array()) {
@@ -329,7 +343,7 @@ Class Out extends Nb {
 
       }
 
-      if ($count>0) self::row_end($conf);
+# NB 27.09.16       if ($count>0) self::row_end($conf);
       $count++;
       self::row($conf,$row);
 
@@ -459,7 +473,6 @@ Class Out extends Nb {
 // Tag
 //
 function out_tag_head($o,&$data) {
-  #if (isset($o['tag_key'])) return ''; # No header, field will be in rows - NB 24.03.16
   if (isset($o['tag_head'])) $o['tag'] = $o['tag_head'];
   $row = out::ar_first($data);
   if (!out::is_hash($row)) $row = $data;