From c2ed24a7c761943670cb45c399f7b0a10d0ccea5 Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Tue, 21 Jan 2025 21:49:52 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20(themes):=20add=20an=20API=20to=20g?= =?UTF-8?q?et=20a=20title=20page?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bl-kernel/authors.class.php | 3 +- bl-kernel/helpers/theme.class.php | 49 +++++++++++++++++++++++++++++++ bl-themes/popeye/php/home.php | 4 +++ 3 files changed, 55 insertions(+), 1 deletion(-) diff --git a/bl-kernel/authors.class.php b/bl-kernel/authors.class.php index 1a384c3e..fc6263a7 100644 --- a/bl-kernel/authors.class.php +++ b/bl-kernel/authors.class.php @@ -23,7 +23,8 @@ class Authors extends dbList { if (isset($authorsIndex[$authorName])) { array_push($authorsIndex[$authorName]['list'], $pageKey); } else { - $authorsIndex[$authorName]['name'] = $authorName; + $user = new User($pageFields['username']); + $authorsIndex[$authorName]['name'] = $user->displayName(); $authorsIndex[$authorName]['list'] = array($pageKey); } } diff --git a/bl-kernel/helpers/theme.class.php b/bl-kernel/helpers/theme.class.php index 6ee8dcd0..1d97d393 100644 --- a/bl-kernel/helpers/theme.class.php +++ b/bl-kernel/helpers/theme.class.php @@ -91,6 +91,55 @@ class Theme return DOMAIN_ADMIN; } + public static function locationTitle() + { + global $url; + global $site; + global $tags; + global $archives; + global $authors; + global $categories; + global $WHERE_AM_I; + global $page; + + if ($WHERE_AM_I == 'page') { + return $page->title(); + } elseif ($WHERE_AM_I == 'tag') { + try { + $tagKey = $url->slug(); + $tag = new Tag($tagKey); + return $tag->name(); + } catch (Exception $e) { + // Tag doesn't exist + } + } elseif ($WHERE_AM_I == 'category') { + try { + $categoryKey = $url->slug(); + $category = new Category($categoryKey); + return $category->name(); + } catch (Exception $e) { + // Category doesn't exist + } + } elseif ($WHERE_AM_I == 'archive') { + try { + $archiveKey = $url->slug(); + return Date::prettyArchiveDate($archiveKey); + } catch (Exception $e) { + // Archive doesn't exist + } + } elseif ($WHERE_AM_I == 'author') { + try { + $authorKey = $url->slug(); + $user = new User($authorKey); + return $user->displayName(); + } catch (Exception $e) { + // Author doesn't exist + } + } + + return null; + } + public static function metaTags($tag) { if ($tag == 'title') { diff --git a/bl-themes/popeye/php/home.php b/bl-themes/popeye/php/home.php index d07a8fcf..ac51274c 100644 --- a/bl-themes/popeye/php/home.php +++ b/bl-themes/popeye/php/home.php @@ -47,6 +47,10 @@ + +

+ +