From: Nicolas Boisselier Date: Tue, 6 Dec 2016 20:59:40 +0000 (+0000) Subject: fix bug page title and h1 X-Git-Url: https://git.nbdom.net/?a=commitdiff_plain;h=57214789be42b65d4de3cda33b2a06f84c29da58;p=nb.git fix bug page title and h1 --- diff --git a/lib/php/page.php b/lib/php/page.php index f3251ae9..305cd65c 100644 --- a/lib/php/page.php +++ b/lib/php/page.php @@ -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() {