]> git.nbdom.net Git - nb.git/commitdiff
EOL
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Wed, 16 Mar 2016 00:19:17 +0000 (00:19 +0000)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Wed, 16 Mar 2016 00:19:17 +0000 (00:19 +0000)
lib/php/benchmark.php
lib/php/config.php
lib/php/db.php
lib/php/db/field.php
lib/php/db/table.php
lib/php/functions.php
lib/php/nb.php
lib/php/out.php
lib/php/page.php

index 8807c8e084cc82e480f257fd8d7ed5a61d03176a..deea73a1dabe1a43043c8486446d63dbea73a269 100755 (executable)
@@ -23,7 +23,7 @@ function __f2($ar) { return; foreach ($ar as $v) { 1; } }
 $array = array_fill(0,100000,"a");
 #if (function_exists('__f1')) { function _f1() { __f1($array); } nb::benchmark('_f1'); }
 #if (function_exists('__f2')) { function _f2() { __f2($array); } nb::benchmark('_f2'); }
-function _f1() { $html = ''; } nb::benchmark('_f1');
+function _f1() { echo null; } nb::benchmark('_f1');
 function _f2() { echo ''; } nb::benchmark('_f2');
 
 nb::benchmark(); exit;
index c385af96b3e8dc65b9ead788c7e60121671efda2..aa762d462b9e0ee88f1863b26712dcef9a814f0c 100644 (file)
@@ -16,6 +16,8 @@ ini_set('include_path',''
        .rtrim(':'.ini_get('include_path'),':')
 );
 
+#define('NB_EOL','');
+#define('NB_PROD',true);
 require_once('nb.php');
 if (nb::php_cli()) argv2request();
 ?>
index 0a0a1dbf545e584647738d0a7c0476611e27e81f..e7a9be79b3ce1d05dfa819afaef5a262b2001e07 100644 (file)
@@ -361,7 +361,7 @@ EOF;
 
   function html_menu($table=null) {
 
-    $r = '<form class="db menu" method="get" action="?">'.PHP_EOL;
+    $r = '<form class="db menu" method="get" action="?">'.NB_EOL;
 
     // Criterias
     if (!empty($table)) {
@@ -450,7 +450,7 @@ EOF;
     ///
     // Bye
     ///
-    $r .= '</form>'.PHP_EOL;
+    $r .= '</form>'.NB_EOL;
     return $r;
   }
 
@@ -465,12 +465,12 @@ EOF;
     #if (preg_match('/yaml|yml/',$f)) bye($this->yaml_encode($this->object2array($this->fields())));
     $mime = $this->print_header($f);
 
-    #echo $row.PHP_EOL;
+    #echo $row.NB_EOL;
     #bye($f); return true;
-    if ($f == 'json') { echo json_encode($row).PHP_EOL; }
+    if ($f == 'json') { echo json_encode($row).NB_EOL; }
     #elseif ($f == 'csv' and is_array($row)) { echo join("\n",$row)."\n"; }
     #elseif ($f == 'csv') { echo join("\t",nb::ar_map('json_encode($a)',$row))."\n"; }
-    #elseif ($f == 'csv') { echo json_encode($row).PHP_EOL; }
+    #elseif ($f == 'csv') { echo json_encode($row).NB_EOL; }
     elseif ($f == 'csv') {
       #if (is_object($data)) echo "$data\n";
       #$isHash = array_values($row) !== $row;
@@ -519,7 +519,7 @@ EOF;
 # NB 06.03.16         }
         #else echo join("\t",array_values($v))."\n";
       }
-      #echo json_encode($row).PHP_EOL;
+      #echo json_encode($row).NB_EOL;
       if ($type === 2) {
         echo "\n";
       }
@@ -527,8 +527,8 @@ EOF;
     elseif (preg_match('/yaml|yml/',$f)) { echo $this->yaml_encode($row); }
     elseif (preg_match('/php|var_export/',$f)) { echo var_export($row,true); }
     elseif (preg_match('/var_dump/',$f)) { echo var_dump($row,true); }
-    elseif (is_scalar($row)) { echo($row.PHP_EOL); }
-    //else { echo($row.PHP_EOL); }
+    elseif (is_scalar($row)) { echo($row.NB_EOL); }
+    //else { echo($row.NB_EOL); }
     else{ echo var_export($row,true); }
 
     return true;
index 12abc17ebc60783ff2637f53ff3ead65ed6afdf9..64cc34477b3b0bd789a5badd0411e0f3b66282f6 100644 (file)
@@ -39,7 +39,7 @@ class field {
         ? '<span class="extra" id="'.$this->name.'">'.$this->out($value).'</span>'
         : '<input name="'.$this->name.'" id="'.$this->name.'" value="'.$value.'" type="text"/>'
       )
-    .'</div>'.PHP_EOL;
+    .'</div>'.NB_EOL;
 
   }
 
index 764a77f9bdacba2fbbf78a9ab113bc9ba04c7095..5c39aaef862b9d87c2e0153c22cdee02b810edb1 100644 (file)
@@ -15,8 +15,7 @@ if (false and empty($_SERVER['DOCUMENT_ROOT'])) {
   #print_r($Table->sql());
 }
 
-define('TABLE_EOL',defined(NB_EOL) ? NB_EOL : PHP_EOL);
-define('TABLE_INDENT',TABLE_EOL ? "\t" : "");
+define('TABLE_INDENT',NB_EOL ? "\t" : "");
 define('TABLE_CSV_SEP',nb::p('sep') ? nb::p('sep') : "\t");
 if (!defined('DB_HTML_EDIT')) define('DB_HTML_EDIT','Edit');
 if (!defined('DB_HTML_DELETE')) define('DB_HTML_DELETE','Delete');
@@ -338,8 +337,8 @@ FROM pg_catalog.pg_attribute a WHERE a.attrelid = (SELECT c.oid FROM pg_catalog.
     $st = $this->db->conn->prepare($sql);
     $st->execute();
 
-    echo '<form class="db edit" method="post" action="?">'.TABLE_EOL;
-    echo '<div class="fields">'.TABLE_EOL;
+    echo '<form class="db edit" method="post" action="?">'.NB_EOL;
+    echo '<div class="fields">'.NB_EOL;
     $count = 0;
     if ( $add or ($row = $st->fetch(PDO::FETCH_ASSOC, PDO::FETCH_ORI_NEXT))) {
       $count ++;
@@ -353,20 +352,20 @@ FROM pg_catalog.pg_attribute a WHERE a.attrelid = (SELECT c.oid FROM pg_catalog.
       }
 
     }
-    echo '</div>'.TABLE_EOL;
+    echo '</div>'.NB_EOL;
 
     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"/>'
-      .'</div>'.TABLE_EOL
+      .'</div>'.NB_EOL
       .'<input type="hidden" name="table" value="'.$this->name.'"/>'
       .'<input type="hidden" name="action" value="update"/>'
       .'<input type="hidden" name="db" value="'.$this->p('db').'"/>'
       .'<input type="hidden" name="debug" value="'.$this->p('debug').'"/>'
       .'<input type="hidden" name="referer" value="'.urlencode(@$_SERVER['HTTP_REFERER']).'"/>'
-    .'</form>'.TABLE_EOL;
+    .'</form>'.NB_EOL;
 
   }
 
@@ -719,7 +718,7 @@ FROM pg_catalog.pg_attribute a WHERE a.attrelid = (SELECT c.oid FROM pg_catalog.
 
             echo '<div class="nav bottom">'
               .$this->nav($opt['count'],$opt['tot'],$opt['limit'])
-             .'</div>'.TABLE_EOL
+             .'</div>'.NB_EOL
             ;
            }
         }
@@ -761,11 +760,11 @@ FROM pg_catalog.pg_attribute a WHERE a.attrelid = (SELECT c.oid FROM pg_catalog.
   -----------------------------------------------------------------*/
   public function rows_begin_json() {
     $this->_row_json = null;
-    return '['.TABLE_EOL;
+    return '['.NB_EOL;
     return ''
       #."// database: ".$this->db->name."\n"
       #."// table: $this->name\n"
-    .'['.TABLE_EOL;
+    .'['.NB_EOL;
   }
 
   public function rows_rec_json(&$row) {
@@ -773,14 +772,14 @@ FROM pg_catalog.pg_attribute a WHERE a.attrelid = (SELECT c.oid FROM pg_catalog.
       $json = '';
       $this->_row_json = true;
     } else {
-      $json = ','.TABLE_EOL;
+      $json = ','.NB_EOL;
     }
     return $json . json_encode($row);
   }
 
   public function rows_end_json() {
     unset($this->_row_json);
-    return TABLE_EOL.']'.TABLE_EOL;
+    return NB_EOL.']'.NB_EOL;
   }
 
   /*-----------------------------------------------------------------
@@ -795,28 +794,28 @@ FROM pg_catalog.pg_attribute a WHERE a.attrelid = (SELECT c.oid FROM pg_catalog.
   -----------------------------------------------------------------*/
   public function rows_begin_xml() {
     return ''
-      .'<?xml version="1.0" encoding="utf-8"?>'.TABLE_EOL #<?
-      #.'<database name="'.$this->db->name.'" table="'.$this->name.'" type="'.$this->db->type.'">'.TABLE_EOL
-      .'<rows name="'.$this->name.'" database="'.$this->db->name.'" database-type="'.$this->db->type.'">'.TABLE_EOL
+      .'<?xml version="1.0" encoding="utf-8"?>'.NB_EOL #<?
+      #.'<database name="'.$this->db->name.'" table="'.$this->name.'" type="'.$this->db->type.'">'.NB_EOL
+      .'<rows name="'.$this->name.'" database="'.$this->db->name.'" database-type="'.$this->db->type.'">'.NB_EOL
     ;
   }
 
   public function rows_rec_xml(&$row) {
     $xml = '';
-    $xml .= TABLE_INDENT."<row>".TABLE_EOL;
+    $xml .= TABLE_INDENT."<row>".NB_EOL;
     foreach ($row as $k=>$v) {
       if ($v !== '') $xml .= ''
         . TABLE_INDENT.TABLE_INDENT."<".$k.">"
         .'<![CDATA['.$v.']]>'
         . '</'.$k.'>'
-      . TABLE_EOL;
+      . NB_EOL;
     }
-    $xml .= TABLE_INDENT."</row>".TABLE_EOL;
+    $xml .= TABLE_INDENT."</row>".NB_EOL;
     return $xml;
   }
 
   public function rows_end_xml() {
-    return '</rows>'.TABLE_EOL;
+    return '</rows>'.NB_EOL;
   }
 
   /*-----------------------------------------------------------------
@@ -843,55 +842,55 @@ FROM pg_catalog.pg_attribute a WHERE a.attrelid = (SELECT c.oid FROM pg_catalog.
 
     $html = '';
 
-    #$html .= '<table data-role="table" class="ui-responsive rows '.$this->name.'">'.TABLE_EOL;
-    $html .= '<table class="rows '.$this->name.'">'.TABLE_EOL;
-    #if (!empty($opt)) $html .= '<caption>' . $this->nav($opt['count'],$opt['tot'],$opt['limit']) . '</caption>' .TABLE_EOL;
+    #$html .= '<table data-role="table" class="ui-responsive rows '.$this->name.'">'.NB_EOL;
+    $html .= '<table class="rows '.$this->name.'">'.NB_EOL;
+    #if (!empty($opt)) $html .= '<caption>' . $this->nav($opt['count'],$opt['tot'],$opt['limit']) . '</caption>' .NB_EOL;
 
     if ($this->p('header')!=="0") {
-      $html .= '<thead>'.TABLE_EOL.'<tr class="head">'.TABLE_EOL;
+      $html .= '<thead>'.NB_EOL.'<tr class="head">'.NB_EOL;
 
-      if ($this->p('buttons')!=='0' and DB_HTML_EDIT) $html .= '<th class="edit"></th>'.TABLE_EOL;
+      if ($this->p('buttons')!=='0' and DB_HTML_EDIT) $html .= '<th class="edit"></th>'.NB_EOL;
 
       foreach (array_keys($fields) as $f) {
-        #$html .= '<th class="'.$f.'">'.($this->p('buttons')==='0' ? $f : $this->url_sort($f)).'</th>'.TABLE_EOL;
-        $html .= '<th class="'.$f.'">'.($this->p('buttons')==='0' ? $this->prettyText($f) : $this->url_sort($f)).'</th>'.TABLE_EOL;
+        #$html .= '<th class="'.$f.'">'.($this->p('buttons')==='0' ? $f : $this->url_sort($f)).'</th>'.NB_EOL;
+        $html .= '<th class="'.$f.'">'.($this->p('buttons')==='0' ? $this->prettyText($f) : $this->url_sort($f)).'</th>'.NB_EOL;
       }
-      if ($this->p('buttons')!=='0' and DB_HTML_DELETE) $html .= '<th class="delete"></th>'.TABLE_EOL;
-      $html .= '</tr>'.TABLE_EOL.'</thead>'.TABLE_EOL;
+      if ($this->p('buttons')!=='0' and DB_HTML_DELETE) $html .= '<th class="delete"></th>'.NB_EOL;
+      $html .= '</tr>'.NB_EOL.'</thead>'.NB_EOL;
     }
 
-    $html .= '<tbody>'.TABLE_EOL;
+    $html .= '<tbody>'.NB_EOL;
     return $html;
   }
 
   public function rows_rec_table(&$row) {
 
-    $html = '<tr class="row">'.TABLE_EOL;
+    $html = '<tr class="row">'.NB_EOL;
 
     if ($this->p('buttons')!=='0') $html .=
       '<td class="action"><a class="edit button" href="'
         .$this->url_keys($row,'action=edit')
-      .'">'.DB_HTML_EDIT.'</a></td>'.TABLE_EOL;
+      .'">'.DB_HTML_EDIT.'</a></td>'.NB_EOL;
 
     foreach ($row as $k => $v) {
       if (isset($this->extras[$k])) $k .= " extra";
-      $html .= '<td class="'.$k.'">'.$v.'</td>'.TABLE_EOL;
+      $html .= '<td class="'.$k.'">'.$v.'</td>'.NB_EOL;
     }
 
     if ($this->p('buttons')!=='0') $html .=
       '<td class="action"><a class="delete button" href="'
         .$this->url_keys($row,'action=delete')
-      .'">'.DB_HTML_DELETE.'</a></td>'.TABLE_EOL;
+      .'">'.DB_HTML_DELETE.'</a></td>'.NB_EOL;
 
-    $html .= '</tr>'.TABLE_EOL;
+    $html .= '</tr>'.NB_EOL;
 
     return $html;
   }
 
   public function rows_end_table($opt=array()) {
     $html = '';
-    $html .= '</tbody>'.TABLE_EOL;
-    $html .= '</table>'.TABLE_EOL;
+    $html .= '</tbody>'.NB_EOL;
+    $html .= '</table>'.NB_EOL;
     return $html;
   }
 
@@ -899,30 +898,30 @@ FROM pg_catalog.pg_attribute a WHERE a.attrelid = (SELECT c.oid FROM pg_catalog.
     Html Div
   -----------------------------------------------------------------*/
   public function rows_begin_div() {
-    return '<div class="rows '.$this->name.'">'.TABLE_EOL;
+    return '<div class="rows '.$this->name.'">'.NB_EOL;
   }
 
   public function rows_rec_div(&$row) {
 
     $html = '';
 
-    $html .= '<ul class="row">'.TABLE_EOL;
+    $html .= '<ul class="row">'.NB_EOL;
 
     if ($this->p('buttons')!=='0') {
-      $html .= '<li class="buttons">'.TABLE_EOL;
-      $html .= '<a class="edit button" href="'.$this->url_keys($row,'action=edit').'">'.DB_HTML_EDIT.'</a>'.TABLE_EOL;
-      $html .= '<a class="delete button" href="'.$this->url_keys($row,'action=delete').'">'.DB_HTML_DELETE.'</a>'.TABLE_EOL;
-      $html .= '</li>'.TABLE_EOL;
+      $html .= '<li class="buttons">'.NB_EOL;
+      $html .= '<a class="edit button" href="'.$this->url_keys($row,'action=edit').'">'.DB_HTML_EDIT.'</a>'.NB_EOL;
+      $html .= '<a class="delete button" href="'.$this->url_keys($row,'action=delete').'">'.DB_HTML_DELETE.'</a>'.NB_EOL;
+      $html .= '</li>'.NB_EOL;
     }
 
     foreach ($row as $k => $v) {
       $html .= '<li>'
         .( $k == '0' ? '' : '<label>'.prettyText($k).'</label>')
         .'<span class="'.$k.'">'.$v.'</span>'
-        .'</li>'.TABLE_EOL;
+        .'</li>'.NB_EOL;
     }
 
-    $html .= '</ul>'.TABLE_EOL;
+    $html .= '</ul>'.NB_EOL;
 
     return $html;
   }
@@ -952,7 +951,7 @@ FROM pg_catalog.pg_attribute a WHERE a.attrelid = (SELECT c.oid FROM pg_catalog.
     ;
 
     if (!($query = $this->db->conn->prepare($sql))) {
-      err('PDO::errorInfo(): ' .join(' ', $this->db->conn->errorInfo()) .TABLE_EOL);
+      err('PDO::errorInfo(): ' .join(' ', $this->db->conn->errorInfo()) .NB_EOL);
       return false;
     }
 
@@ -960,7 +959,7 @@ FROM pg_catalog.pg_attribute a WHERE a.attrelid = (SELECT c.oid FROM pg_catalog.
 
 #debug(array($sql,$values));
     if (!($execute = $query->execute())) {
-      err('PDO::errorInfo(): ' .join(' ', $this->db->conn->errorInfo()) .TABLE_EOL);
+      err('PDO::errorInfo(): ' .join(' ', $this->db->conn->errorInfo()) .NB_EOL);
       return false;
     }
 
@@ -1010,7 +1009,7 @@ FROM pg_catalog.pg_attribute a WHERE a.attrelid = (SELECT c.oid FROM pg_catalog.
     $this->debug($sql,1);
 
     if (!($query = $this->db->conn->prepare($sql))) {
-      err('PDO::errorInfo(): ' .join(' ', $this->db->conn->errorInfo()) .TABLE_EOL);
+      err('PDO::errorInfo(): ' .join(' ', $this->db->conn->errorInfo()) .NB_EOL);
       return false;
     }
      
@@ -1025,7 +1024,7 @@ FROM pg_catalog.pg_attribute a WHERE a.attrelid = (SELECT c.oid FROM pg_catalog.
     #return $sql;
     #bye($sql);
     if (!($execute = $query->execute())) {
-      err('PDO::errorInfo(): ' .join(' ', $this->db->conn->errorInfo()) .TABLE_EOL);
+      err('PDO::errorInfo(): ' .join(' ', $this->db->conn->errorInfo()) .NB_EOL);
       return false;
     }
 
@@ -1118,7 +1117,7 @@ FROM pg_catalog.pg_attribute a WHERE a.attrelid = (SELECT c.oid FROM pg_catalog.
 
       $replace = array();
       foreach ($this->replace as $k=>$v) { $replace[] = "$k.$v"; }
-      $html .= '<span id="db-table-replace" style="display:none">'.join(' ',$replace).'</span>'.TABLE_EOL;
+      $html .= '<span id="db-table-replace" style="display:none">'.join(' ',$replace).'</span>'.NB_EOL;
 
     }
 
index 26576cf707dcf0e0bb8990a5f3b85078b43d20cd..904a475e3cc336db5b0957fd4f157715dab68fa1 100644 (file)
@@ -112,7 +112,7 @@ function err($msg,$preff='err',$backtrace_deep=0) {
   nb::msg( preg_match('/ml/i',nb::get_header('Content-type'))
     ? '<pre class="'.($preff and $preff!='err' ? 'err ': '').$preff.'">'.$msg.'</pre>'
     : strtoupper($preff).": $msg"
-  ).PHP_EOL;
+  ).NB_EOL;
 
   return false;
 }
@@ -125,7 +125,7 @@ function debug($msg,$level=0) {
     $msg = '<pre class="debug">'
       .(isset($_SERVER['HTTP_HOST']) ? htmlentities($msg) : $msg)
 # NB 16.12.15       .(isset($_SERVER['HTTP_HOST']) ? htmlspecialchars($msg) : $msg)
-    .'</pre>'.PHP_EOL;
+    .'</pre>'.NB_EOL;
 
   } else {
     $msg = "DEBUG: $msg\n";
@@ -203,13 +203,13 @@ function html_select_array($data,$opt=array()) {
   $html = '<select';
   if (!empty($opt['html'])) $html .= ' '.preg_replace('/^\s+/','',$opt['html']);
   if (!empty($opt['readonly'])) $html.=' disabled="disabled"';
-  $html .= '>'.PHP_EOL;
+  $html .= '>'.NB_EOL;
 
   if (!empty($opt['blank'])) {
     if (empty($opt['blank_lib'])) $opt['blank_lib'] = $opt['blank'];
     $html .= '<option value="'.$opt['blank_val'].'"'.(strcmp((string)$opt['selected'],$opt['blank_val']) == 0 ?' selected="selected"':'').'>';
     $html .= $opt['blank_lib'];
-    $html .= '</option>'.PHP_EOL;
+    $html .= '</option>'.NB_EOL;
   }
 
   foreach ($data as $d) {
@@ -226,11 +226,11 @@ function html_select_array($data,$opt=array()) {
 
     $html .= '<option value="'.$val.'"'
       .( ($opt['selected']!==NULL and strcmp((string)$opt['selected'],$val)===0) ?' selected="selected"':'')
-    .'>'.$lib.'</option>'.PHP_EOL;
+    .'>'.$lib.'</option>'.NB_EOL;
 
   }
 
-  $html .= '</select>'.PHP_EOL;
+  $html .= '</select>'.NB_EOL;
 
   return $html;
 
index 1eefc13979c5721d47efd45d64bab6028f06745b..c746897ebd747e9bc241733769ab840454f9f367 100644 (file)
@@ -1,6 +1,10 @@
 <?php
-define('NB_ROOT',realpath(dirname(__FILE__).'/../..'));
-define('NB_EOL',"\n");
+if (!defined('NB_ROOT')) define('NB_ROOT',realpath(dirname(__FILE__).'/../..'));
+#die($_REQUEST['prod']);
+#if (!defined('NB_EOL')) define('NB_EOL',empty($_REQUEST['prod']) ? "\n" : '');
+if (!defined('NB_EOL')) define('NB_EOL',defined('NB_PROD') ? '' : "\n");
+#if (!defined('NB_EOL')) define('NB_EOL',"\n");
+if (!defined('EOL')) define('EOL',NB_EOL);
 require_once(dirname(__FILE__).'/functions.php');
 #print_r(self::p());
 class nb {
index 4416d52ba91ecdb60c365bc8afb967a7cec70037..7ed6c9b808edc81f5b4c1f96467cfdbb4d350013 100644 (file)
@@ -1,12 +1,10 @@
 <?php
 require_once('nb.php');
-#define('OUT_EOL','');
-define('OUT_EOL',defined('NB_EOL') ? NB_EOL : "\n");
-# NB 07.03.16 define('OUT_BRACKET1','['.OUT_EOL);
+# NB 07.03.16 define('OUT_BRACKET1','['.NB_EOL);
 # NB 07.03.16 define('OUT_BRACKET2',']');
-# NB 07.03.16 define('OUT_BRACE1','{'.OUT_EOL);
+# NB 07.03.16 define('OUT_BRACE1','{'.NB_EOL);
 # NB 07.03.16 define('OUT_BRACE2','}');
-# NB 07.03.16 define('OUT_COMA',','.OUT_EOL);
+# NB 07.03.16 define('OUT_COMA',','.NB_EOL);
 
 class Out extends Nb {
 
@@ -20,14 +18,14 @@ class Out extends Nb {
         'function' => 'out_csv',
       ),
       'center' => array(
-        'enclose' => array("<center>".OUT_EOL,"</center>".PHP_EOL),
+        'enclose' => array("<center>".NB_EOL,"</center>".NB_EOL),
         'tag_enclose' => 'div',
         'tag' => 'label',
         'function' => 'out_tag',
         'head' => 'out_tag_head',
       ),
       'table' => array(
-        'enclose' => array("<table>".OUT_EOL,"</table>".PHP_EOL),
+        'enclose' => array("<table>".NB_EOL,"</table>".NB_EOL),
         'tag_enclose' => 'tr',
         'tag_head' => 'th',
         'tag' => 'td',
@@ -35,7 +33,7 @@ class Out extends Nb {
         'head' => 'out_tag_head',
       ),
       'xml' => array(
-        'enclose' => array('<?xml version="1.0" encoding="utf-8"?>'.OUT_EOL."<rows>".OUT_EOL,"</rows>".PHP_EOL),
+        'enclose' => array('<?xml version="1.0" encoding="utf-8"?>'.NB_EOL."<rows>".NB_EOL,"</rows>".NB_EOL),
         'function' => 'out_xml',
       ),
       'yaml' => array(
@@ -43,9 +41,9 @@ class Out extends Nb {
         'function' => 'out_yaml',
       ),
       'json' => array(
-        'enclose' => array('['.OUT_EOL,OUT_EOL.']'),
+        'enclose' => array('['.NB_EOL,NB_EOL.']'),
         'function.ext' => 'json_encode',
-        'eol' => OUT_EOL,
+        'eol' => NB_EOL,
         'rec' => ',',
       ),
     );
@@ -180,7 +178,7 @@ function out_tag_head(&$data,$o) {
 
 function out_tag(&$row,$o) {
 #var_dump($row); return '';
-  if (isset($o['tag_enclose'])) echo (OUT_EOL ? '  ' : '').'<'.$o['tag_enclose'].'>'.PHP_EOL;
+  if (isset($o['tag_enclose'])) echo (NB_EOL ? '  ' : '').'<'.$o['tag_enclose'].'>'.NB_EOL;
 
   foreach ($row as $k => $v) {
     #if (!is_scalar($v)) continue;
@@ -192,29 +190,29 @@ function out_tag(&$row,$o) {
       $class = '';
     }
     echo ''
-      .(OUT_EOL ? '    ' : '')
+      .(NB_EOL ? '    ' : '')
       #.(isset($o['tag_enclose']) ? '<'.$o['tag_enclose'].'>' : '')
       ."<$k$class>$v</$k>"
       #.(isset($o['tag_enclose']) ? '</'.$o['tag_enclose'].'>' : '')
-      .OUT_EOL
+      .NB_EOL
     ;
   }
 
-  if (isset($o['tag_enclose'])) echo (OUT_EOL ? '  ' : '').'</'.$o['tag_enclose'].'>'.PHP_EOL;
+  if (isset($o['tag_enclose'])) echo (NB_EOL ? '  ' : '').'</'.$o['tag_enclose'].'>'.NB_EOL;
 }
 
 function out_xml(&$row,$o) {
-  echo (OUT_EOL ? '  ' : '')."<row>".OUT_EOL;
+  echo (NB_EOL ? '  ' : '')."<row>".NB_EOL;
   foreach ($row as $k => $v) {
-    echo (OUT_EOL ? '    ' : '')."<$k><![CDATA[$v]]></$k>".OUT_EOL;
+    echo (NB_EOL ? '    ' : '')."<$k><![CDATA[$v]]></$k>".NB_EOL;
   }
-  echo (OUT_EOL ? '  ' : '')."</row>".OUT_EOL;
+  echo (NB_EOL ? '  ' : '')."</row>".NB_EOL;
 }
 
 # < Functions
 /****************************************************************************/
 
-#die("A OUT_EOL B \n");
+#die("A NB_EOL B \n");
 if (empty($argv) or $argv[1] != 'test') return true;
 $data = array(
   'a' => 1,
index 4a356a73b957c0eb773a6914809205731cce6e11..a3aac561f7647e1f370fee164e1d3394038cefdc 100644 (file)
@@ -163,7 +163,7 @@ class Page extends nb {
         . "</$tag>"
       ;
     }
-    return join(PHP_EOL,$tags);
+    return join(NB_EOL,$tags);
     return ''
       . '<' . $tag
         . ($attrs ? " $attrs" : "")
@@ -178,7 +178,7 @@ class Page extends nb {
     if (is_array($debug) or is_object($debug)) $debug = print_r($debug,true);
     if (preg_match('/ml$/',$this->content_type)) {
       #echo "<!-- $debug -->";
-      echo "<pre class=\"ui-state-highlight debug\">".htmlentities($debug)."</pre>".PHP_EOL;
+      echo "<pre class=\"ui-state-highlight debug\">".htmlentities($debug)."</pre>".NB_EOL;
 
     } else {
       echo "DEBUG: $debug\n";
@@ -200,11 +200,11 @@ class Page extends nb {
       echo $this->doctype(); 
 
       if (!$this->lang) {
-        echo '<html> '.PHP_EOL;
+        echo '<html> '.NB_EOL;
       } elseif ($this->html5) {
-        echo '<html lang="'.$this->lang.'"> '.PHP_EOL;
+        echo '<html lang="'.$this->lang.'"> '.NB_EOL;
       } else {
-        echo '<html xmlns="http://www.w3.org/1999/xhtml" lang="'.$this->lang.'" xml:lang="'.$this->lang.'">'.PHP_EOL;
+        echo '<html xmlns="http://www.w3.org/1999/xhtml" lang="'.$this->lang.'" xml:lang="'.$this->lang.'">'.NB_EOL;
       }
 
     }
@@ -217,10 +217,10 @@ class Page extends nb {
       echo '<body'
         .(empty($this->body_class) ? '' : ' class="'.trim($this->body_class).'"')
         .(empty($this->body_id)    ? '' : ' id="'.trim($this->body_id).'"')
-      .'>' . PHP_EOL;
+      .'>' . NB_EOL;
 
-      if     ($this->h1)    echo $this->tag('h1',$this->h1).PHP_EOL;
-      elseif ($this->title) echo $this->tag('h1',$this->title).PHP_EOL;
+      if     ($this->h1)    echo $this->tag('h1',$this->h1).NB_EOL;
+      elseif ($this->title) echo $this->tag('h1',$this->title).NB_EOL;
     }
 
     return true;
@@ -230,8 +230,8 @@ class Page extends nb {
   function end() {
 
     if (preg_match('/ml$/',$this->content_type)) {
-      echo '</body>' . PHP_EOL;
-      echo '</html>' . PHP_EOL;
+      echo '</body>' . NB_EOL;
+      echo '</html>' . NB_EOL;
     }
 
   }
@@ -273,16 +273,16 @@ class Page extends nb {
     $doctype = '';
 
     if (preg_match('/frame/',$content_type)) {
-      $doctype = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">'.PHP_EOL;
+      $doctype = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">'.NB_EOL;
     } elseif (preg_match('/xhtml/',$content_type)) {
-      $doctype = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">'.PHP_EOL;
+      $doctype = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">'.NB_EOL;
     } elseif (preg_match('/xml/',$content_type)) {
-      $doctype = '<?xml version="1.0" encoding="'.strtoupper($this->charset).'"?>'.PHP_EOL; //<?
+      $doctype = '<?xml version="1.0" encoding="'.strtoupper($this->charset).'"?>'.NB_EOL; //<?
     } elseif ($this->html5) {
       # See: http://www.w3.org/TR/html-markup/elements.html
       $doctype = '<!DOCTYPE html>'; 
     } else {
-      $doctype = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">'.PHP_EOL;
+      $doctype = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">'.NB_EOL;
     }
 
     return $doctype;
@@ -291,42 +291,42 @@ class Page extends nb {
   function head() {
     $head = '';
 
-    #$head .= '</head>'.PHP_EOL; return $head;
+    #$head .= '</head>'.NB_EOL; return $head;
 
-    if ($this->title) $head .= $this->tag('title',$this->title) . PHP_EOL;
+    if ($this->title) $head .= $this->tag('title',$this->title) . NB_EOL;
 
     if (preg_match('/tml$/',$this->content_type)) {
 
-      if ($this->charset) $head .= '<meta http-equiv="Content-Type" content="text/html; charset='.$this->charset.'" />'.PHP_EOL;
+      if ($this->charset) $head .= '<meta http-equiv="Content-Type" content="text/html; charset='.$this->charset.'" />'.NB_EOL;
 
-      $head .= '<meta name="viewport" content="width=device-width, initial-scale=1" />'.PHP_EOL;
+      $head .= '<meta name="viewport" content="width=device-width, initial-scale=1" />'.NB_EOL;
 
       foreach ($this->to_array($this->css) as $v) {
-        $head .= '<link type="text/css" rel="stylesheet" href="' . $v . '" />'.PHP_EOL;
+        $head .= '<link type="text/css" rel="stylesheet" href="' . $v . '" />'.NB_EOL;
       }
 
       if ($this->css_code) $head .=  ''
-        . '<style type="text/css"><!-- ' . PHP_EOL
+        . '<style type="text/css"><!-- ' . NB_EOL
         . $this->css_code
-        . ' --></style>' . PHP_EOL
+        . ' --></style>' . NB_EOL
       ;
 
       foreach ($this->to_array($this->js) as $v) {
-        $head .= '<script src="' . $v . '" type="text/javascript"></script>' . PHP_EOL;
+        $head .= '<script src="' . $v . '" type="text/javascript"></script>' . NB_EOL;
       }
       if ($this->js_code) $head .=  ''
-        . '<script type="text/javascript"><!-- ' . PHP_EOL
+        . '<script type="text/javascript"><!-- ' . NB_EOL
         . trim($this->js_code)."\n"
-        . ' --></script>' . PHP_EOL
+        . ' --></script>' . NB_EOL
       ;
 
 
     }
 
-    foreach ($this->to_array($this->head) as $h) $head .= $h.PHP_EOL;
+    foreach ($this->to_array($this->head) as $h) $head .= $h.NB_EOL;
 
     if ($head) {
-      $head = '<head>'.PHP_EOL.$head.'</head>'.PHP_EOL;
+      $head = '<head>'.NB_EOL.$head.'</head>'.NB_EOL;
     }
 
     return $head;