),
'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' => ',',
],
'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' => ',',
public static function head(&$o,$head,$data=[]) {
$o['header'] = (self::p('header')==='0') ? false : true;
+ $o['out_count'] = 0;
# Format $head
if ($head !== false) {
#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'];
}
#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()) {
}
- if ($count>0) self::row_end($conf);
+# NB 27.09.16 if ($count>0) self::row_end($conf);
$count++;
self::row($conf,$row);
// 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;