]> git.nbdom.net Git - nb.git/commitdiff
Fix bug no title when link on all nav
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Sat, 26 Mar 2016 21:38:27 +0000 (21:38 +0000)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Sat, 26 Mar 2016 21:38:27 +0000 (21:38 +0000)
lib/php/page.php

index 7ab03d11477dc6dead1865a02172ba1e2c1089c5..0df3e42dc075a45d70b1754ed23bd058b1631fb0 100644 (file)
@@ -157,9 +157,19 @@ class Page extends nb {
     return htmlspecialchars($v,$replace_flags,$charset);
   }
 
-# NB 04.08.15   function tag($content='',$tag,$attrs='') {
   function tag($tag,$content='',$attrs='') {
     
+    # Extract attrs from tag
+    if (preg_match('/^([\w-]+)\s+(.*?)$/',$tag,$m)) {
+      $tag = $m[1];
+      $attrs = trim($attrs.' '.$m[2]);
+    }
+
+    if ($content===null) {
+      $this->end_tag($tag);
+      return '<' . $tag . ($attrs ? " $attrs" : "") . '>';
+    }
+
     if (!is_array($content)) $content = array($content);
     $tags = array();
 
@@ -240,9 +250,22 @@ class Page extends nb {
 
   }
 
+  function end_tag($tag=null) {
+    static $tags = array();
+    if ($tag !== null) return array_unshift($tags,$tag);
+    foreach ($tags as $t) echo "</$t>".NB_EOL;
+    $tags = array();
+    return false;
+    return join('',self::ar_map('',$tags));
+    if ($tag === null) return $tags;
+    array_unshift($tags,$tag);
+  }
+
   function end() {
 
     if (preg_match('/ml$/',$this->content_type)) {
+      #foreach ($this->end_tag() as $t) echo "</$t>".NB_EOL;
+      $this->end_tag();
       echo '</body>' . NB_EOL;
       echo '</html>' . NB_EOL;
     }