]> git.nbdom.net Git - nb.git/commitdiff
fix bug page title and h1
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Tue, 6 Dec 2016 20:59:40 +0000 (20:59 +0000)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Tue, 6 Dec 2016 20:59:40 +0000 (20:59 +0000)
lib/php/page.php

index f3251ae95a038ec928256074e174179365b56d5d..305cd65cf28b1ef8aff06440c4034d2e0f3466ae 100644 (file)
@@ -69,9 +69,11 @@ class Page extends nb {
     if (!$this->content_type()) $this->content_type($this->client_content_type());
 
     // Nav
+    $links = [];
     if (isset($opt['nav'])) {
-      list($title,$nav) = self::nav_parse($opt['nav']);
-      if ( empty($this->h1) ) $this->h1 = join($this->sep,$nav);
+      list($title,$html) = self::nav_parse($opt['nav']);
+      if ( empty($this->h1) ) $this->h1 = join($this->sep,$html);
+      if ( empty($this->title) ) $this->title = join($this->sep,$title);
       unset($opt['nav']);
     }
 # NB 06.12.16     if ( empty($this->title) ) $this->title = !empty($title) ? join($this->sep,$title) : $this->filename2title();
@@ -90,7 +92,8 @@ class Page extends nb {
     parent::__construct($opt);
 
     // Defaults
-    if ( empty($this->title) ) $this->title = !empty($nav) ? join($this->sep,$nav) : $this->filename2title();
+    if (empty($this->title)) $this->title = $this->filename2title();
+    if ( empty($this->h1) and ! empty($this->title)) $this->h1 = $this->title;
 
     // Call / Print
     if (!empty($this->call)) $this->call($this->call);
@@ -473,6 +476,7 @@ class Page extends nb {
 
   public static function nav_parse($array) {
     #$v = &$sep;
+    $hash = [];
     foreach ($array as $k => $v) {
       if ($v === '' or $v === null or empty($v[0])) {
         continue;
@@ -481,25 +485,25 @@ class Page extends nb {
       if (is_array($v)) {
 
         if (count($v)==3) {
-          $title[] = $v[0];
-          $nav[] = empty($v[2]) ? $v[1] : self::tag('a',$v[1],'href="'.$v[2].'"');
+          $text = $v[0];
+          $html = empty($v[2]) ? $v[1] : self::tag('a',$v[1],'href="'.$v[2].'"');
         } else {
-          $title[] = $v[0];
-          $nav[] = empty($v[1]) ? $v[0] : self::tag('a',$v[0],'href="'.$v[1].'"');
+          $text = $v[0];
+          $html = empty($v[1]) ? $v[0] : self::tag('a',$v[0],'href="'.$v[1].'"');
         }
 
       } else {
-        $title[] = $v;
-        $nav[] = self::tag('span',$v);
+        $text = $v;
+        $html = self::tag('span',$v);
 
       }
 
+      $title[] = $text;
+      $nav[] = $html;
+      $hash[$text] = $html;
+
     }
-    return [$title,$nav];
-    return [
-      'title' => $title,
-      'title' => $title,
-    ];
+    return [$title,$nav,$hash];
   }
 
   public static function phpinfo() {