]> git.nbdom.net Git - nb.git/commitdiff
fix ml regexp replace by is(xtml)
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Wed, 21 Dec 2016 23:29:38 +0000 (23:29 +0000)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Wed, 21 Dec 2016 23:29:38 +0000 (23:29 +0000)
lib/php/page.php

index 9d93c2e281bcc53c6ea47e9a97cee9adbbd56531..7b6c26ed03e898017fe1b0083bdbf1e894f3b84f 100644 (file)
@@ -188,10 +188,8 @@ class Page extends nb {
    * Return html code for a tag
    */
   public static function tag($tag,$content='',$attrs='') {
-    #bye('zaza');
     static $is_html = null;
-    if ($is_html === null) $is_html = preg_match('/ml$/',self::content_type()) ? true : false;
-    #bye((int)$is_html);
+    if ($is_html === null) $is_html = self::is('xtml') ? true : false;
     
     # Extract attrs from tag
     if (preg_match('/^([\w-]+)\s+(.*?)$/',$tag,$m)) {
@@ -280,7 +278,7 @@ class Page extends nb {
   static function debug($debug,$level=0) {
 
     if (is_array($debug) or is_object($debug)) $debug = print_r($debug,true);
-    if (preg_match('/ml$/',self::$content_type)) {
+    if (self::is('xtml')) {
       #echo "<!-- $debug -->";
       echo "<pre class=\"ui-state-highlight debug\">".htmlentities($debug)."</pre>".NB_EOL;
 
@@ -299,6 +297,7 @@ class Page extends nb {
     $this->headers(); 
 
     if (preg_match('/html$/',self::$content_type)) {
+    #if (self::is('html')) {
 
       echo $this->doctype(); 
 
@@ -319,7 +318,7 @@ class Page extends nb {
     if ( empty($this->title) and !empty($title) ) $this->title = join($this->sep,$title);
     if ( empty($this->h1) and !empty($html) ) $this->h1 = join($this->sep,$html);
     if ( empty($this->h1) and !empty($this->title) ) $this->h1 = $this->title;
-    if (preg_match('/ml$/',self::$content_type)) {
+    if (self::is('xtml')) {
 
       echo $this->head(); 
 
@@ -338,7 +337,7 @@ class Page extends nb {
 
   public static function end() {
 
-    if (preg_match('/ml$/',self::$content_type)) {
+    if (self::is('xtml')) {
       self::tag_end();
       echo '</body>' . NB_EOL;
       if (preg_match('/html$/',self::$content_type)) echo '</html>' . NB_EOL;
@@ -475,6 +474,7 @@ class Page extends nb {
     if ($is == 'xhtml') return preg_match('/xhtml$/',self::$content_type);
     if ($is == 'html') return preg_match('/html$/',self::$content_type);
     if ($is == 'xml') return preg_match('/xml$/',self::$content_type);
+    if ($is == 'xtml') return preg_match('/(x|ht)ml$/',self::$content_type);
     if ($is == 'text') return preg_match('/^text\//',self::$content_type);
     die("Db->is(): unknow argument '$is'. Accepted values are xhtml, html, xml");
   }
@@ -541,8 +541,10 @@ class Page extends nb {
     # Pretty h2
     $phpinfo =  preg_replace_callback ('@(<h2>(?:<[^>]+>)?)([^<]+)@',function($m){return $m[1].prettyText($m[2]);},$phpinfo);
 
-    if ($text) return $phpinfo;
+# NB 21.12.16     if ($text) return $phpinfo;
     if (!preg_match_all('@(<h2.*?</table>)@s',$phpinfo,$m)) return '';
+    #bye($m[0]);
+    if ($text) return strip_tags(join("\n",$m[0]));
     return join("\n",$m[0]);
   }