From 86d950111dba74a6fbd8feda6d5997e69bd0fafd Mon Sep 17 00:00:00 2001 From: Nicolas Boisselier Date: Wed, 21 Dec 2016 23:29:38 +0000 Subject: [PATCH] fix ml regexp replace by is(xtml) --- lib/php/page.php | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/lib/php/page.php b/lib/php/page.php index 9d93c2e2..7b6c26ed 100644 --- a/lib/php/page.php +++ b/lib/php/page.php @@ -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 ""; echo "
".htmlentities($debug)."
".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 '' . NB_EOL; if (preg_match('/html$/',self::$content_type)) echo '' . 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 ('@(

(?:<[^>]+>)?)([^<]+)@',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('@()@s',$phpinfo,$m)) return ''; + #bye($m[0]); + if ($text) return strip_tags(join("\n",$m[0])); return join("\n",$m[0]); } -- 2.47.3