From 282780a398ea686585d8133175346eeb7a24ca7b Mon Sep 17 00:00:00 2001 From: Nicolas Boisselier Date: Tue, 27 Sep 2016 16:07:49 +0200 Subject: [PATCH] function out::row_end obsolete --- lib/php/db/table.php | 2 +- lib/php/out.php | 39 ++++++++++++++++++++++++++------------- 2 files changed, 27 insertions(+), 14 deletions(-) diff --git a/lib/php/db/table.php b/lib/php/db/table.php index c92f6033..a4ab8112 100644 --- a/lib/php/db/table.php +++ b/lib/php/db/table.php @@ -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 diff --git a/lib/php/out.php b/lib/php/out.php index 762d19d7..de4d9895 100644 --- a/lib/php/out.php +++ b/lib/php/out.php @@ -36,9 +36,13 @@ Class Out extends Nb { ), 'php' => array( +# NB 27.09.16 'enclose' => [ +# NB 27.09.16 ''.NB_EOL +# NB 27.09.16 ], 'enclose' => [ - ''.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; -- 2.47.3