From b9a02584dcd25c09b0aa763b3d74f41010859f80 Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Sun, 19 Jan 2025 16:47:21 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20(settings):=20allow=20to=20modify?= =?UTF-8?q?=20the=20author/archive=20URI?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bl-kernel/admin/views/settings.php | 18 ++++++++++++++++++ bl-kernel/helpers/theme.class.php | 19 +++++++++++++++++++ bl-kernel/site.class.php | 12 ++++++++++++ 3 files changed, 49 insertions(+) diff --git a/bl-kernel/admin/views/settings.php b/bl-kernel/admin/views/settings.php index 48fa9233..db6bb836 100644 --- a/bl-kernel/admin/views/settings.php +++ b/bl-kernel/admin/views/settings.php @@ -298,6 +298,24 @@ echo Bootstrap::formInputHidden(array( 'tip' => DOMAIN_CATEGORIES )); + echo Bootstrap::formInputText(array( + 'name' => 'uriArchive', + 'label' => $L->g('Archive'), + 'value' => $site->uriFilters('archive'), + 'class' => '', + 'placeholder' => '', + 'tip' => DOMAIN_ARCHIVES + )); + + echo Bootstrap::formInputText(array( + 'name' => 'uriAuthor', + 'label' => $L->g('Authors'), + 'value' => $site->uriFilters('author'), + 'class' => '', + 'placeholder' => '', + 'tip' => DOMAIN_AUTHORS + )); + echo Bootstrap::formInputText(array( 'name' => 'uriBlog', 'label' => $L->g('Blog'), diff --git a/bl-kernel/helpers/theme.class.php b/bl-kernel/helpers/theme.class.php index 4e6118fa..6ee8dcd0 100644 --- a/bl-kernel/helpers/theme.class.php +++ b/bl-kernel/helpers/theme.class.php @@ -105,6 +105,8 @@ class Theme global $url; global $site; global $tags; + global $archives; + global $authors; global $categories; global $WHERE_AM_I; global $page; @@ -131,6 +133,23 @@ class Theme } catch (Exception $e) { // Category doesn't exist } + } elseif ($WHERE_AM_I == 'archive') { + try { + $archiveKey = $url->slug(); + $format = $site->titleFormatArchive(); + $format = Text::replace('{{archive-name}}', Date::prettyArchiveDate($archiveKey), $format); + } catch (Exception $e) { + // Archive doesn't exist + } + } elseif ($WHERE_AM_I == 'author') { + try { + $authorKey = $url->slug(); + $user = new User($authorKey); + $format = $site->titleFormatAuthor(); + $format = Text::replace('{{author-name}}', $user->displayName(), $format); + } catch (Exception $e) { + // Author doesn't exist + } } else { $format = $site->titleFormatHomepage(); } diff --git a/bl-kernel/site.class.php b/bl-kernel/site.class.php index 989b775b..a62c69aa 100644 --- a/bl-kernel/site.class.php +++ b/bl-kernel/site.class.php @@ -45,6 +45,8 @@ class Site extends dbJSON 'titleFormatPages' => '{{page-title}} | {{site-title}}', 'titleFormatCategory' => '{{category-name}} | {{site-title}}', 'titleFormatTag' => '{{tag-name}} | {{site-title}}', + 'titleFormatAuthor' => '{{author-name}} | {{site-title}}', + 'titleFormatArchive' => '{{archive-name}} | {{site-title}}', 'imageRestrict' => true, 'imageRelativeToAbsolute' => false, 'thumbnailWidth' => 400, // px @@ -322,6 +324,16 @@ class Site extends dbJSON return $this->getField('titleFormatTag'); } + public function titleFormatArchive() + { + return $this->getField('titleFormatArchive'); + } + + public function titleFormatAuthor() + { + return $this->getField('titleFormatAuthor'); + } + // Returns the absolute URL of the site logo // If you set $absolute=false returns only the filename public function logo($absolute = true)