From 6b8420b10e6b2009f9eae52b9871b6f0b65190bb Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Sun, 19 Jan 2025 10:54:16 +0100 Subject: [PATCH 01/25] =?UTF-8?q?=F0=9F=97=83=EF=B8=8F=20add=20an=20author?= =?UTF-8?q?=20database=20for=20pages?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bl-kernel/authors.class.php | 37 ++++++++++++++++++++++++++++ bl-kernel/functions.php | 11 +++++++++ bl-plugins/remote-content/plugin.php | 1 + 3 files changed, 49 insertions(+) create mode 100644 bl-kernel/authors.class.php diff --git a/bl-kernel/authors.class.php b/bl-kernel/authors.class.php new file mode 100644 index 00000000..1a384c3e --- /dev/null +++ b/bl-kernel/authors.class.php @@ -0,0 +1,37 @@ +countItems($key); + } + + public function reindex() + { + global $pages; + $db = $pages->getDB($onlyKeys=false); + $authorsIndex = array(); + foreach ($db as $pageKey=>$pageFields) { + if (in_array($pageFields['type'], $GLOBALS['DB_TAGS_TYPES'])) { + $authorName = $pageFields['username']; + if (isset($authorsIndex[$authorName])) { + array_push($authorsIndex[$authorName]['list'], $pageKey); + } else { + $authorsIndex[$authorName]['name'] = $authorName; + $authorsIndex[$authorName]['list'] = array($pageKey); + } + } + } + + $this->db = $authorsIndex; + $this->sortAlphanumeric(); + return $this->save(); + } + +} \ No newline at end of file diff --git a/bl-kernel/functions.php b/bl-kernel/functions.php index 77711d40..e57337d5 100644 --- a/bl-kernel/functions.php +++ b/bl-kernel/functions.php @@ -16,6 +16,14 @@ function reindexTags() return $tags->reindex(); } +// Re-index database of authors +// If you create/edit/remove a page is necessary regenerate the database of authors +function reindexAuthors() +{ + global $authors; + return $authors->reindex(); +} + // Generate the page 404 Not found function buildErrorPage() { @@ -341,6 +349,7 @@ function createPage($args) reindexCategories(); reindexTags(); + reindexAuthors(); // Add to syslog $syslog->add(array( @@ -392,6 +401,7 @@ function editPage($args) reindexCategories(); reindexTags(); + reindexAuthors(); // Add to syslog $syslog->add(array( @@ -417,6 +427,7 @@ function deletePage($key) reindexCategories(); reindexTags(); + reindexAuthors(); // Add to syslog $syslog->add(array( diff --git a/bl-plugins/remote-content/plugin.php b/bl-plugins/remote-content/plugin.php index 98d9259b..2f301493 100644 --- a/bl-plugins/remote-content/plugin.php +++ b/bl-plugins/remote-content/plugin.php @@ -154,6 +154,7 @@ EOF; Theme::plugins('afterPageCreate'); reindexCategories(); reindexTags(); + reindexAuthors(); } return true; -- 2.39.5 From 79ff2bc74d85e76c8c5ff1bf9fb378bcf96ed528 Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Sun, 19 Jan 2025 11:22:30 +0100 Subject: [PATCH 02/25] =?UTF-8?q?=E2=9C=A8=20(pages):=20allow=20to=20show?= =?UTF-8?q?=20pages=20by=20author?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bl-kernel/boot/init.php | 7 +++++++ bl-kernel/boot/rules/69.pages.php | 4 ++++ bl-kernel/functions.php | 15 ++++++++++++++- bl-kernel/site.class.php | 2 ++ 4 files changed, 27 insertions(+), 1 deletion(-) diff --git a/bl-kernel/boot/init.php b/bl-kernel/boot/init.php index 74ae925d..4177f3e3 100644 --- a/bl-kernel/boot/init.php +++ b/bl-kernel/boot/init.php @@ -66,6 +66,7 @@ define('DB_PAGES', PATH_DATABASES . 'pages.php'); define('DB_SITE', PATH_DATABASES . 'site.php'); define('DB_CATEGORIES', PATH_DATABASES . 'categories.php'); define('DB_TAGS', PATH_DATABASES . 'tags.php'); +define('DB_AUTHORS', PATH_DATABASES . 'authors.php'); define('DB_SYSLOG', PATH_DATABASES . 'syslog.php'); define('DB_USERS', PATH_DATABASES . 'users.php'); define('DB_SECURITY', PATH_DATABASES . 'security.php'); @@ -88,6 +89,7 @@ include(PATH_ABSTRACT . 'plugin.class.php'); include(PATH_KERNEL . 'pages.class.php'); include(PATH_KERNEL . 'users.class.php'); include(PATH_KERNEL . 'tags.class.php'); +include(PATH_KERNEL . 'authors.class.php'); include(PATH_KERNEL . 'language.class.php'); include(PATH_KERNEL . 'site.class.php'); include(PATH_KERNEL . 'categories.class.php'); @@ -126,6 +128,7 @@ include(PATH_HELPERS . 'cookie.class.php'); $pages = new Pages(); $users = new Users(); $tags = new Tags(); +$authors = new Authors(); $categories = new Categories(); $site = new Site(); $url = new Url(); @@ -191,6 +194,9 @@ define('TAG_URI_FILTER', $url->filters('tag')); // Category URI filter define('CATEGORY_URI_FILTER', $url->filters('category')); +// Author URI filter +define('AUTHOR_URI_FILTER', $url->filters('author')); + // Page URI filter define('PAGE_URI_FILTER', $url->filters('page')); @@ -247,6 +253,7 @@ define('DOMAIN_ADMIN', DOMAIN_BASE . ADMIN_URI_FILTER . '/'); define('DOMAIN_TAGS', Text::addSlashes(DOMAIN_BASE . TAG_URI_FILTER, false, true)); define('DOMAIN_CATEGORIES', Text::addSlashes(DOMAIN_BASE . CATEGORY_URI_FILTER, false, true)); define('DOMAIN_PAGES', Text::addSlashes(DOMAIN_BASE . PAGE_URI_FILTER, false, true)); +define('DOMAIN_AUTHORS', Text::addSlashes(DOMAIN_BASE . AUTHOR_URI_FILTER, false, true)); $ADMIN_CONTROLLER = ''; $ADMIN_VIEW = ''; diff --git a/bl-kernel/boot/rules/69.pages.php b/bl-kernel/boot/rules/69.pages.php index 3c8ce2b9..76398e9d 100644 --- a/bl-kernel/boot/rules/69.pages.php +++ b/bl-kernel/boot/rules/69.pages.php @@ -71,6 +71,10 @@ elseif ($url->whereAmI()==='tag') { elseif ($url->whereAmI()==='category') { $content = buildPagesByCategory(); } +// Build content by author +elseif ($url->whereAmI()==='author') { + $content = buildPagesByAuthor(); +} // Build content for the homepage elseif ( ($url->whereAmI()==='home') || ($url->whereAmI()==='blog') ) { $content = buildPagesForHome(); diff --git a/bl-kernel/functions.php b/bl-kernel/functions.php index e57337d5..bf07b9cc 100644 --- a/bl-kernel/functions.php +++ b/bl-kernel/functions.php @@ -92,16 +92,26 @@ function buildPagesByTag() return buildPagesFor('tag', false, $tagKey); } +// This function is only used from the rule 69.pages.php, DO NOT use this function! +function buildPagesByAuthor() +{ + global $url; + + $authorKey = $url->slug(); + return buildPagesFor('author', false, false, $authorKey); +} + // This function is only used from the rule 69.pages.php, DO NOT use this function! // Generate the global variables $content / $content, defined on 69.pages.php // This function is use for buildPagesForHome(), buildPagesByCategory(), buildPagesByTag() -function buildPagesFor($for, $categoryKey = false, $tagKey = false) +function buildPagesFor($for, $categoryKey = false, $tagKey = false, $authorKey = false) { global $pages; global $categories; global $tags; global $site; global $url; + global $authors; // Get the page number from URL $pageNumber = $url->pageNumber(); @@ -122,6 +132,9 @@ function buildPagesFor($for, $categoryKey = false, $tagKey = false) } elseif ($for == 'tag') { $numberOfItems = $site->itemsPerPage(); $list = $tags->getList($tagKey, $pageNumber, $numberOfItems); + } elseif ($for == 'author') { + $numberOfItems = $site->itemsPerPage(); + $list = $authors->getList($authorKey, $pageNumber, $numberOfItems); } // There are not items, invalid tag, invalid category, out of range, etc... diff --git a/bl-kernel/site.class.php b/bl-kernel/site.class.php index 3d65535d..d44fe0a7 100644 --- a/bl-kernel/site.class.php +++ b/bl-kernel/site.class.php @@ -19,6 +19,7 @@ class Site extends dbJSON 'uriTag' => '/tag/', 'uriCategory' => '/category/', 'uriBlog' => '/blog/', + 'uriAuthor' => '/author/', 'url' => '', 'emailFrom' => '', 'dateFormat' => 'F j, Y', @@ -99,6 +100,7 @@ class Site extends dbJSON $filters['page'] = $this->getField('uriPage'); $filters['tag'] = $this->getField('uriTag'); $filters['category'] = $this->getField('uriCategory'); + $filters['author'] = $this->getField('uriAuthor'); if ($this->getField('uriBlog')) { $filters['blog'] = $this->getField('uriBlog'); -- 2.39.5 From e1f77f2eacecefc119810b3dcf0de1b53b1ccbb1 Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Sun, 19 Jan 2025 11:22:46 +0100 Subject: [PATCH 03/25] =?UTF-8?q?=F0=9F=90=9B=20(login):=20some=20visual?= =?UTF-8?q?=20fixes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bl-kernel/admin/views/login.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bl-kernel/admin/views/login.php b/bl-kernel/admin/views/login.php index e9b78089..21812037 100644 --- a/bl-kernel/admin/views/login.php +++ b/bl-kernel/admin/views/login.php @@ -11,13 +11,13 @@ echo Bootstrap::formInputHidden(array( echo '
- +
'; echo '
- +
'; @@ -34,4 +34,4 @@ echo ' echo ''; -echo '

' . $L->g('Powered by Koblog') . '

'; +echo '

' . $L->g('Powered by Koblog') . '

'; -- 2.39.5 From a5805a1f3f815c73648acd04991db277e598911c Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Sun, 19 Jan 2025 11:38:07 +0100 Subject: [PATCH 04/25] =?UTF-8?q?=F0=9F=97=83=EF=B8=8F=20add=20an=20archiv?= =?UTF-8?q?e=20database=20for=20pages?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Show pages by dates (monthly or yearly) --- bl-kernel/archives.class.php | 49 ++++++++++++++++++++++++++++ bl-kernel/boot/init.php | 3 ++ bl-kernel/functions.php | 11 +++++++ bl-plugins/remote-content/plugin.php | 1 + 4 files changed, 64 insertions(+) create mode 100644 bl-kernel/archives.class.php diff --git a/bl-kernel/archives.class.php b/bl-kernel/archives.class.php new file mode 100644 index 00000000..314ab678 --- /dev/null +++ b/bl-kernel/archives.class.php @@ -0,0 +1,49 @@ +countItems($key); + } + + public function reindex() + { + global $pages; + $db = $pages->getDB($onlyKeys=false); + $archiveIndex = array(); + foreach ($db as $pageKey=>$pageFields) { + if (in_array($pageFields['type'], $GLOBALS['DB_TAGS_TYPES'])) { + $date = $pageFields['date']; + $year = mb_substr($date, 0, 4); + $month = mb_substr($date, 0, 7); + + // Index by years + if (isset($archiveIndex[$year])) { + array_push($archiveIndex[$year]['list'], $pageKey); + } else { + $archiveIndex[$year]['name'] = $year; + $archiveIndex[$year]['list'] = array($pageKey); + } + + // Index by month + if (isset($archiveIndex[$month])) { + array_push($archiveIndex[$month]['list'], $pageKey); + } else { + $archiveIndex[$month]['name'] = $month; + $archiveIndex[$month]['list'] = array($pageKey); + } + } + } + + $this->db = $archiveIndex; + $this->sortAlphanumeric(); + return $this->save(); + } + +} \ No newline at end of file diff --git a/bl-kernel/boot/init.php b/bl-kernel/boot/init.php index 4177f3e3..ee779727 100644 --- a/bl-kernel/boot/init.php +++ b/bl-kernel/boot/init.php @@ -67,6 +67,7 @@ define('DB_SITE', PATH_DATABASES . 'site.php'); define('DB_CATEGORIES', PATH_DATABASES . 'categories.php'); define('DB_TAGS', PATH_DATABASES . 'tags.php'); define('DB_AUTHORS', PATH_DATABASES . 'authors.php'); +define('DB_ARCHIVES', PATH_DATABASES . 'archives.php'); define('DB_SYSLOG', PATH_DATABASES . 'syslog.php'); define('DB_USERS', PATH_DATABASES . 'users.php'); define('DB_SECURITY', PATH_DATABASES . 'security.php'); @@ -90,6 +91,7 @@ include(PATH_KERNEL . 'pages.class.php'); include(PATH_KERNEL . 'users.class.php'); include(PATH_KERNEL . 'tags.class.php'); include(PATH_KERNEL . 'authors.class.php'); +include(PATH_KERNEL . 'archives.class.php'); include(PATH_KERNEL . 'language.class.php'); include(PATH_KERNEL . 'site.class.php'); include(PATH_KERNEL . 'categories.class.php'); @@ -129,6 +131,7 @@ $pages = new Pages(); $users = new Users(); $tags = new Tags(); $authors = new Authors(); +$archives = new Archives(); $categories = new Categories(); $site = new Site(); $url = new Url(); diff --git a/bl-kernel/functions.php b/bl-kernel/functions.php index bf07b9cc..c6cee4db 100644 --- a/bl-kernel/functions.php +++ b/bl-kernel/functions.php @@ -24,6 +24,14 @@ function reindexAuthors() return $authors->reindex(); } +// Re-index database of archives +// If you create/edit/remove a page is necessary regenerate the database of archives +function reindexArchives() +{ + global $archives; + return $archives->reindex(); +} + // Generate the page 404 Not found function buildErrorPage() { @@ -363,6 +371,7 @@ function createPage($args) reindexCategories(); reindexTags(); reindexAuthors(); + reindexArchives(); // Add to syslog $syslog->add(array( @@ -415,6 +424,7 @@ function editPage($args) reindexCategories(); reindexTags(); reindexAuthors(); + reindexArchives(); // Add to syslog $syslog->add(array( @@ -441,6 +451,7 @@ function deletePage($key) reindexCategories(); reindexTags(); reindexAuthors(); + reindexArchives(); // Add to syslog $syslog->add(array( diff --git a/bl-plugins/remote-content/plugin.php b/bl-plugins/remote-content/plugin.php index 2f301493..4c05aa7d 100644 --- a/bl-plugins/remote-content/plugin.php +++ b/bl-plugins/remote-content/plugin.php @@ -155,6 +155,7 @@ EOF; reindexCategories(); reindexTags(); reindexAuthors(); + reindexArchives(); } return true; -- 2.39.5 From ac507092d887a2e525064f438d7570efcccef666 Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Sun, 19 Jan 2025 12:51:35 +0100 Subject: [PATCH 05/25] =?UTF-8?q?=E2=9C=A8=20(pages):=20show=20pages=20by?= =?UTF-8?q?=20dates?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bl-kernel/boot/init.php | 4 ++++ bl-kernel/boot/rules/69.pages.php | 4 ++++ bl-kernel/functions.php | 15 ++++++++++++++- bl-kernel/site.class.php | 2 ++ 4 files changed, 24 insertions(+), 1 deletion(-) diff --git a/bl-kernel/boot/init.php b/bl-kernel/boot/init.php index ee779727..1243e0b3 100644 --- a/bl-kernel/boot/init.php +++ b/bl-kernel/boot/init.php @@ -200,6 +200,9 @@ define('CATEGORY_URI_FILTER', $url->filters('category')); // Author URI filter define('AUTHOR_URI_FILTER', $url->filters('author')); +// Archive URI filter +define('ARCHIVE_URI_FILTER', $url->filters('archive')); + // Page URI filter define('PAGE_URI_FILTER', $url->filters('page')); @@ -257,6 +260,7 @@ define('DOMAIN_TAGS', Text::addSlashes(DOMAIN_BASE . TAG_URI_FILTER, false, tr define('DOMAIN_CATEGORIES', Text::addSlashes(DOMAIN_BASE . CATEGORY_URI_FILTER, false, true)); define('DOMAIN_PAGES', Text::addSlashes(DOMAIN_BASE . PAGE_URI_FILTER, false, true)); define('DOMAIN_AUTHORS', Text::addSlashes(DOMAIN_BASE . AUTHOR_URI_FILTER, false, true)); +define('DOMAIN_ARCHIVES', Text::addSlashes(DOMAIN_BASE . ARCHIVE_URI_FILTER, false, true)); $ADMIN_CONTROLLER = ''; $ADMIN_VIEW = ''; diff --git a/bl-kernel/boot/rules/69.pages.php b/bl-kernel/boot/rules/69.pages.php index 76398e9d..321dd401 100644 --- a/bl-kernel/boot/rules/69.pages.php +++ b/bl-kernel/boot/rules/69.pages.php @@ -75,6 +75,10 @@ elseif ($url->whereAmI()==='category') { elseif ($url->whereAmI()==='author') { $content = buildPagesByAuthor(); } +// Build content by author +elseif ($url->whereAmI()==='archive') { + $content = buildPagesByArchive(); +} // Build content for the homepage elseif ( ($url->whereAmI()==='home') || ($url->whereAmI()==='blog') ) { $content = buildPagesForHome(); diff --git a/bl-kernel/functions.php b/bl-kernel/functions.php index c6cee4db..3e4db37e 100644 --- a/bl-kernel/functions.php +++ b/bl-kernel/functions.php @@ -109,10 +109,19 @@ function buildPagesByAuthor() return buildPagesFor('author', false, false, $authorKey); } +// This function is only used from the rule 69.pages.php, DO NOT use this function! +function buildPagesByArchive() +{ + global $url; + + $archiveKey = $url->slug(); + return buildPagesFor('archive', false, false, false, $archiveKey); +} + // This function is only used from the rule 69.pages.php, DO NOT use this function! // Generate the global variables $content / $content, defined on 69.pages.php // This function is use for buildPagesForHome(), buildPagesByCategory(), buildPagesByTag() -function buildPagesFor($for, $categoryKey = false, $tagKey = false, $authorKey = false) +function buildPagesFor($for, $categoryKey = false, $tagKey = false, $authorKey = false, $archiveKey = false) { global $pages; global $categories; @@ -120,6 +129,7 @@ function buildPagesFor($for, $categoryKey = false, $tagKey = false, $authorKey = global $site; global $url; global $authors; + global $archives; // Get the page number from URL $pageNumber = $url->pageNumber(); @@ -143,6 +153,9 @@ function buildPagesFor($for, $categoryKey = false, $tagKey = false, $authorKey = } elseif ($for == 'author') { $numberOfItems = $site->itemsPerPage(); $list = $authors->getList($authorKey, $pageNumber, $numberOfItems); + } elseif ($for == 'archive') { + $numberOfItems = $site->itemsPerPage(); + $list = $archives->getList($archiveKey, $pageNumber, $numberOfItems); } // There are not items, invalid tag, invalid category, out of range, etc... diff --git a/bl-kernel/site.class.php b/bl-kernel/site.class.php index d44fe0a7..989b775b 100644 --- a/bl-kernel/site.class.php +++ b/bl-kernel/site.class.php @@ -20,6 +20,7 @@ class Site extends dbJSON 'uriCategory' => '/category/', 'uriBlog' => '/blog/', 'uriAuthor' => '/author/', + 'uriArchive' => '/archive/', 'url' => '', 'emailFrom' => '', 'dateFormat' => 'F j, Y', @@ -101,6 +102,7 @@ class Site extends dbJSON $filters['tag'] = $this->getField('uriTag'); $filters['category'] = $this->getField('uriCategory'); $filters['author'] = $this->getField('uriAuthor'); + $filters['archive'] = $this->getField(field: 'uriArchive'); if ($this->getField('uriBlog')) { $filters['blog'] = $this->getField('uriBlog'); -- 2.39.5 From 617bbf49f7df50a212600f72e3b0eff6913c0823 Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Sun, 19 Jan 2025 13:01:57 +0100 Subject: [PATCH 06/25] =?UTF-8?q?=E2=9C=A8=20(user):=20add=20a=20way=20to?= =?UTF-8?q?=20get=20the=20author=20URI?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bl-kernel/user.class.php | 4 ++++ bl-themes/popeye/php/page.php | 6 +++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/bl-kernel/user.class.php b/bl-kernel/user.class.php index c3c3e139..07b0962a 100644 --- a/bl-kernel/user.class.php +++ b/bl-kernel/user.class.php @@ -75,6 +75,10 @@ class User } } + public function authorUri() { + return DOMAIN_AUTHORS . $this->username(); + } + public function displayNameMode() { return $this->getValue('displayNameMode'); diff --git a/bl-themes/popeye/php/page.php b/bl-themes/popeye/php/page.php index bea31fc8..baeace17 100644 --- a/bl-themes/popeye/php/page.php +++ b/bl-themes/popeye/php/page.php @@ -8,13 +8,13 @@ isStatic() && !$url->notFound()) : ?>
- date() ?> + date() ?> - readingTime() . ' ' . $L->get('minutes') . ' ' . $L->g('read') ?> + readingTime() . ' ' . $L->get('minutes') . ' ' . $L->g('read') ?> - user('displayName') ?> + user('displayName') ?>
-- 2.39.5 From 21787c8203c8825ba0ac7ece724867eef4dae870 Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Sun, 19 Jan 2025 13:03:32 +0100 Subject: [PATCH 07/25] =?UTF-8?q?=F0=9F=90=9B=20(author):=20reindex=20auth?= =?UTF-8?q?ors=20on=20user=20change?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bl-kernel/functions.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/bl-kernel/functions.php b/bl-kernel/functions.php index 3e4db37e..0547985d 100644 --- a/bl-kernel/functions.php +++ b/bl-kernel/functions.php @@ -490,6 +490,8 @@ function editUser($args) 'notes' => $args['username'] )); + reindexAuthors(); + return true; } @@ -523,6 +525,8 @@ function disableUser($args) 'notes' => $username )); + reindexAuthors(); + return true; } @@ -567,6 +571,8 @@ function deleteUser($args) 'notes' => $username )); + reindexAuthors(); + return true; } -- 2.39.5 From 34fd8b57ff36d96fae9936b461f91eb83638deaf Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Sun, 19 Jan 2025 16:46:45 +0100 Subject: [PATCH 08/25] =?UTF-8?q?=E2=9C=A8=20(date):=20add=20a=20tool=20to?= =?UTF-8?q?=20pretty=20print=20archive=20dates?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bl-kernel/helpers/date.class.php | 33 ++++++++++++++++++++++++++++++++ bl-languages/fr_FR.json | 1 + 2 files changed, 34 insertions(+) diff --git a/bl-kernel/helpers/date.class.php b/bl-kernel/helpers/date.class.php index 843905a8..6886ea43 100644 --- a/bl-kernel/helpers/date.class.php +++ b/bl-kernel/helpers/date.class.php @@ -2,6 +2,21 @@ class Date { + private const MONTHS = [ + "01" => "January", + "02" => "February", + "03" => "March", + "04" => "April", + "05" => "May", + "06" => "June", + "07" => "July", + "08" => "August", + "09" => "September", + "10" => "October", + "11" => "November", + "12" => "December" + ]; + // Returns string with the date translated // Example: $date = 'Mon, 27th March' > 'Lun, 27th Marzo' public static function translate($date) @@ -127,4 +142,22 @@ class Date { return $tmp; } + + private static function getMonthName($month) { + return isset(self::MONTHS[$month]) ? self::MONTHS[$month] : null; + } + + public static function prettyArchiveDate($date) { + global $L; + $explodedDate = explode("-", $date); + try { + if (sizeof($explodedDate) > 2) { + return $date; + } else { + return self::translate(self::getMonthName($explodedDate[1])." ".$explodedDate[0]); + } + } catch (Exception $e) { + return $L->g("Invalid Date"); + } + } } diff --git a/bl-languages/fr_FR.json b/bl-languages/fr_FR.json index 5230dfa6..72192ee8 100644 --- a/bl-languages/fr_FR.json +++ b/bl-languages/fr_FR.json @@ -166,6 +166,7 @@ "current-format": "Format actuel", "version": "Version", "author": "Auteur", + "authors": "Auteurs", "activate": "Activer", "deactivate": "Désactiver", "edit-category": "Modifier la catégorie", -- 2.39.5 From b9a02584dcd25c09b0aa763b3d74f41010859f80 Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Sun, 19 Jan 2025 16:47:21 +0100 Subject: [PATCH 09/25] =?UTF-8?q?=E2=9C=A8=20(settings):=20allow=20to=20mo?= =?UTF-8?q?dify=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) -- 2.39.5 From c2ed24a7c761943670cb45c399f7b0a10d0ccea5 Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Tue, 21 Jan 2025 21:49:52 +0100 Subject: [PATCH 10/25] =?UTF-8?q?=E2=9C=A8=20(themes):=20add=20an=20API=20?= =?UTF-8?q?to=20get=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 @@ + +

+ +
-- 2.39.5 From e8cebf6c103832bffee171782dcbd5d7ae8c8703 Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Thu, 23 Jan 2025 22:41:26 +0100 Subject: [PATCH 11/25] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20=F0=9F=92=A5=20(page?= =?UTF-8?q?s):=20use=20the=20"article"=20type=20instead=20of=20published?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It makes more sense to use the type of page you have for the type, and it prepare published to be a state instead of a type --- bl-kernel/admin/views/edit-content.php | 4 ++-- bl-kernel/admin/views/new-content.php | 6 +++--- bl-kernel/ajax/get-published.php | 2 +- bl-kernel/boot/admin.php | 1 + bl-kernel/boot/init.php | 3 +++ bl-kernel/boot/rules/50.updaters.php | 15 ++++++++++++++ bl-kernel/boot/site.php | 1 + bl-kernel/boot/variables.php | 2 +- bl-kernel/categories.class.php | 2 +- bl-kernel/functions.php | 2 +- bl-kernel/helpers/updater.class.php | 20 +++++++++++++++++++ bl-kernel/pages.class.php | 27 ++++++++++++++------------ bl-kernel/pagex.class.php | 9 ++++++++- bl-kernel/site.class.php | 6 ++++++ bl-plugins/api/plugin.php | 2 +- bl-plugins/disqus/plugin.php | 2 +- install.php | 2 +- 17 files changed, 81 insertions(+), 25 deletions(-) create mode 100644 bl-kernel/boot/rules/50.updaters.php create mode 100644 bl-kernel/helpers/updater.class.php diff --git a/bl-kernel/admin/views/edit-content.php b/bl-kernel/admin/views/edit-content.php index b0715c04..2055eb70 100644 --- a/bl-kernel/admin/views/edit-content.php +++ b/bl-kernel/admin/views/edit-content.php @@ -21,7 +21,7 @@ echo Bootstrap::formInputHidden(array( 'value' => $page->uuid() )); -// Type = published, draft, sticky, static +// Type = article, draft, sticky, static echo Bootstrap::formInputHidden(array( 'name' => 'type', 'value' => $page->type() @@ -210,7 +210,7 @@ echo Bootstrap::formInputHidden(array( 'label' => $L->g('Type'), 'selected' => $page->type(), 'options' => array( - 'published' => '- ' . $L->g('Default') . ' -', + 'article' => '- ' . $L->g('Default') . ' -', 'sticky' => $L->g('Sticky'), 'static' => $L->g('Static') ), diff --git a/bl-kernel/admin/views/new-content.php b/bl-kernel/admin/views/new-content.php index 7aa4b2f2..42b23158 100644 --- a/bl-kernel/admin/views/new-content.php +++ b/bl-kernel/admin/views/new-content.php @@ -21,10 +21,10 @@ echo Bootstrap::formInputHidden(array( 'value' => $uuid )); -// Type = published, draft, sticky, static +// Type = article, draft, sticky, static echo Bootstrap::formInputHidden(array( 'name' => 'type', - 'value' => 'published' + 'value' => 'article' )); // Cover image @@ -191,7 +191,7 @@ echo Bootstrap::formInputHidden(array( 'label' => $L->g('Type'), 'selected' => '', 'options' => array( - 'published' => '- ' . $L->g('Default') . ' -', + 'article' => '- ' . $L->g('Default') . ' -', 'sticky' => $L->g('Sticky'), 'static' => $L->g('Static') ), diff --git a/bl-kernel/ajax/get-published.php b/bl-kernel/ajax/get-published.php index 881c6738..3608ee05 100644 --- a/bl-kernel/ajax/get-published.php +++ b/bl-kernel/ajax/get-published.php @@ -28,7 +28,7 @@ foreach ($pagesKey as $pageKey) { $page = new Page($pageKey); if ($page->isParent() || !$checkIsParent) { // Check page status - if ($page->published() || $page->sticky() || $page->isStatic()) { + if ($page->article() || $page->sticky() || $page->isStatic()) { // Check if the query contains in the title $lowerTitle = Text::lowercase($page->title()); if (Text::stringContains($lowerTitle, $query)) { diff --git a/bl-kernel/boot/admin.php b/bl-kernel/boot/admin.php index 81768cc9..faf1b965 100644 --- a/bl-kernel/boot/admin.php +++ b/bl-kernel/boot/admin.php @@ -57,6 +57,7 @@ if ($layout['slug']==='ajax') { else { // Boot rules + include(PATH_RULES.'50.updaters.php'); include(PATH_RULES.'69.pages.php'); include(PATH_RULES.'99.header.php'); include(PATH_RULES.'99.paginator.php'); diff --git a/bl-kernel/boot/init.php b/bl-kernel/boot/init.php index 1243e0b3..0f35b018 100644 --- a/bl-kernel/boot/init.php +++ b/bl-kernel/boot/init.php @@ -126,6 +126,9 @@ include(PATH_HELPERS . 'tcp.class.php'); include(PATH_HELPERS . 'dom.class.php'); include(PATH_HELPERS . 'cookie.class.php'); +// Updaters +include(PATH_HELPERS . 'updater.class.php'); + // Objects $pages = new Pages(); $users = new Users(); diff --git a/bl-kernel/boot/rules/50.updaters.php b/bl-kernel/boot/rules/50.updaters.php new file mode 100644 index 00000000..f53026e7 --- /dev/null +++ b/bl-kernel/boot/rules/50.updaters.php @@ -0,0 +1,15 @@ +databaseVersion() < 2) { + KoblogUpdater::upgradeArticlesToPageTypes(); +} \ No newline at end of file diff --git a/bl-kernel/boot/site.php b/bl-kernel/boot/site.php index 34046523..b63e6c88 100644 --- a/bl-kernel/boot/site.php +++ b/bl-kernel/boot/site.php @@ -7,6 +7,7 @@ include(PATH_RULES.'60.plugins.php'); Theme::plugins('beforeAll'); // Load rules +include(PATH_RULES.'50.updaters.php'); include(PATH_RULES.'60.router.php'); include(PATH_RULES.'69.pages.php'); include(PATH_RULES.'99.header.php'); diff --git a/bl-kernel/boot/variables.php b/bl-kernel/boot/variables.php index 3425cd85..fbc3c915 100644 --- a/bl-kernel/boot/variables.php +++ b/bl-kernel/boot/variables.php @@ -104,7 +104,7 @@ define('MEDIA_MANAGER_SORT_BY_DATE', true); // Constant arrays using define are not allowed in PHP 5.6 or earlier // Type of pages included in the tag database -$GLOBALS['DB_TAGS_TYPES'] = array('published','static','sticky'); +$GLOBALS['DB_TAGS_TYPES'] = array('article','static','sticky'); // Allowed image extensions $GLOBALS['ALLOWED_IMG_EXTENSION'] = array('gif', 'png', 'jpg', 'jpeg', 'svg', 'webp'); diff --git a/bl-kernel/categories.class.php b/bl-kernel/categories.class.php index 17b8c87b..b0c1178b 100644 --- a/bl-kernel/categories.class.php +++ b/bl-kernel/categories.class.php @@ -28,7 +28,7 @@ class Categories extends dbList { $categoryKey = $pageFields['category']; if (isset($this->db[$categoryKey]['list'])) { if ( - ($db[$pageKey]['type']=='published') || + ($db[$pageKey]['type']=='article') || ($db[$pageKey]['type']=='sticky') || ($db[$pageKey]['type']=='static') ) { diff --git a/bl-kernel/functions.php b/bl-kernel/functions.php index 0547985d..d4825c47 100644 --- a/bl-kernel/functions.php +++ b/bl-kernel/functions.php @@ -168,7 +168,7 @@ function buildPagesFor($for, $categoryKey = false, $tagKey = false, $authorKey = foreach ($list as $pageKey) { try { $page = new Page($pageKey); - if (($page->type() == 'published') || + if (($page->type() == 'article') || ($page->type() == 'sticky') || ($page->type() == 'static') ) { diff --git a/bl-kernel/helpers/updater.class.php b/bl-kernel/helpers/updater.class.php new file mode 100644 index 00000000..65ff80b9 --- /dev/null +++ b/bl-kernel/helpers/updater.class.php @@ -0,0 +1,20 @@ + +db as $key => $fields) { + if ($fields['type'] === "published") { + $pages->db[$key]['type'] = "article"; + } else { + //$pages->db[$key]['sticky'] = false; // Not really important for static + } + } + + return $pages->save(); + } + +} \ No newline at end of file diff --git a/bl-kernel/pages.class.php b/bl-kernel/pages.class.php index bac2e2fb..5bf0a8f3 100644 --- a/bl-kernel/pages.class.php +++ b/bl-kernel/pages.class.php @@ -9,7 +9,7 @@ class Pages extends dbJSON 'description' => '', 'username' => '', 'tags' => array(), - 'type' => 'published', // published, static, draft, sticky, scheduled, autosave + 'type' => 'article', // article, static, draft, sticky, scheduled, autosave 'date' => '', 'dateModified' => '', 'position' => 0, @@ -129,7 +129,7 @@ class Pages extends dbJSON } // Schedule page - if (($row['date'] > Date::current(DB_DATE_FORMAT)) && ($row['type'] == 'published')) { + if (($row['date'] > Date::current(DB_DATE_FORMAT)) && ($row['type'] == 'article')) { $row['type'] = 'scheduled'; } @@ -244,7 +244,8 @@ class Pages extends dbJSON $row['dateModified'] = Date::current(DB_DATE_FORMAT); // Schedule page - if (($row['date'] > Date::current(DB_DATE_FORMAT)) && ($row['type'] == 'published')) { + // TODO: will use the state then + if (($row['date'] > Date::current(DB_DATE_FORMAT)) && ($row['type'] == 'article')) { $row['type'] = 'scheduled'; } @@ -395,14 +396,14 @@ class Pages extends dbJSON return $tmp; } - // Returns a database with published pages + // Returns a database with published articles // $onlyKeys = true; Returns only the pages keys // $onlyKeys = false; Returns part of the database, I do not recommend use this public function getPublishedDB($onlyKeys = true) { $tmp = $this->db; foreach ($tmp as $key => $fields) { - if ($fields['type'] != 'published') { + if ($fields['type'] != 'article') { unset($tmp[$key]); } } @@ -504,12 +505,13 @@ class Pages extends dbJSON // Returns the next page key of the current page key public function nextPageKey($currentKey) { - if ($this->db[$currentKey]['type'] == 'published') { + if ($this->db[$currentKey]['type'] == 'article') { $keys = array_keys($this->db); $position = array_search($currentKey, $keys) - 1; if (isset($keys[$position])) { $nextKey = $keys[$position]; - if ($this->db[$nextKey]['type'] == 'published') { + // TODO: make it check pages from the same type instead + if ($this->db[$nextKey]['type'] == 'article') { return $nextKey; } } @@ -520,12 +522,13 @@ class Pages extends dbJSON // Returns the previous page key of the current page key public function previousPageKey($currentKey) { - if ($this->db[$currentKey]['type'] == 'published') { + if ($this->db[$currentKey]['type'] == 'article') { $keys = array_keys($this->db); $position = array_search($currentKey, $keys) + 1; if (isset($keys[$position])) { $prevKey = $keys[$position]; - if ($this->db[$prevKey]['type'] == 'published') { + // TODO: make it check pages from the same type instead + if ($this->db[$prevKey]['type'] == 'article') { return $prevKey; } } @@ -542,7 +545,7 @@ class Pages extends dbJSON { $list = array(); foreach ($this->db as $key => $fields) { - if ($published && $fields['type'] == 'published') { + if ($published && $fields['type'] == 'article') { array_push($list, $key); } elseif ($static && $fields['type'] == 'static') { array_push($list, $key); @@ -719,10 +722,10 @@ class Pages extends dbJSON foreach ($this->db as $pageKey => $fields) { if ($fields['type'] == 'scheduled') { if ($fields['date'] <= $currentDate) { - $this->db[$pageKey]['type'] = 'published'; + $this->db[$pageKey]['type'] = 'article'; $saveDatabase = true; } - } elseif (($fields['type'] == 'published') && (ORDER_BY == 'date')) { + } elseif (($fields['type'] == 'article') && (ORDER_BY == 'date')) { break; } } diff --git a/bl-kernel/pagex.class.php b/bl-kernel/pagex.class.php index 81bee954..7c127658 100644 --- a/bl-kernel/pagex.class.php +++ b/bl-kernel/pagex.class.php @@ -360,7 +360,14 @@ class Page // (boolean) Returns TRUE if the page is published, FALSE otherwise public function published() { - return ($this->getValue('type') === 'published'); + // TODO: will use then the state + return ($this->getValue('type') === 'article'); + } + + // (boolean) Returns TRUE if the page is an article, FALSE otherwise + public function article() + { + return ($this->getValue('type') === 'article'); } // (boolean) Returns TRUE if the page is scheduled, FALSE otherwise diff --git a/bl-kernel/site.class.php b/bl-kernel/site.class.php index a62c69aa..c33eefb7 100644 --- a/bl-kernel/site.class.php +++ b/bl-kernel/site.class.php @@ -477,4 +477,10 @@ class Site extends dbJSON $customFields = Sanitize::htmlDecode($this->getField('customFields')); return json_decode($customFields, true); } + + // Returns the custom fields as array + public function databaseVersion() + { + return 1; + } } diff --git a/bl-plugins/api/plugin.php b/bl-plugins/api/plugin.php index 2e175cdc..4d33bc46 100644 --- a/bl-plugins/api/plugin.php +++ b/bl-plugins/api/plugin.php @@ -352,7 +352,7 @@ class pluginAPI extends Plugin global $pages; // Parameters and the default values - $published = (isset($args['published']) ? $args['published'] == 'true' : true); + $published = (isset($args['article']) ? $args['article'] == 'true' : true); $static = (isset($args['static']) ? $args['static'] == 'true' : false); $draft = (isset($args['draft']) ? $args['draft'] == 'true' : false); $sticky = (isset($args['sticky']) ? $args['sticky'] == 'true' : false); diff --git a/bl-plugins/disqus/plugin.php b/bl-plugins/disqus/plugin.php index 9045eb75..71e825f8 100644 --- a/bl-plugins/disqus/plugin.php +++ b/bl-plugins/disqus/plugin.php @@ -62,7 +62,7 @@ class pluginDisqus extends Plugin if ($WHERE_AM_I === 'page') { global $page; - if ($page->published() && $this->getValue('enablePages')) { + if ($page->article() && $this->getValue('enablePages')) { return $this->javascript(); } if ($page->isStatic() && $this->getValue('enableStatic')) { diff --git a/install.php b/install.php index cc9a2a86..ced49f0b 100644 --- a/install.php +++ b/install.php @@ -334,7 +334,7 @@ function install($adminPassword, $timezone) 'description' => '', 'username' => 'admin', 'tags' => array(), - 'type' => (($slug == 'example-page-4-slug') ? 'static' : 'published'), + 'type' => (($slug == 'example-page-4-slug') ? 'static' : 'article'), 'date' => $nextDate, 'dateModified' => '', 'allowComments' => true, -- 2.39.5 From 05f3e6fc93a5912a882b91a2e6e9966c40c8b78c Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Thu, 23 Jan 2025 23:12:26 +0100 Subject: [PATCH 12/25] =?UTF-8?q?=F0=9F=9A=B8=20(content):=20Use=20a=20dra?= =?UTF-8?q?ft=20button=20instead=20of=20the=20current=20system?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bl-kernel/admin/views/edit-content.php | 28 +++------------- bl-kernel/admin/views/new-content.php | 44 ++++++++++++-------------- 2 files changed, 25 insertions(+), 47 deletions(-) diff --git a/bl-kernel/admin/views/edit-content.php b/bl-kernel/admin/views/edit-content.php index 2055eb70..a4c0d3b6 100644 --- a/bl-kernel/admin/views/edit-content.php +++ b/bl-kernel/admin/views/edit-content.php @@ -51,7 +51,7 @@ echo Bootstrap::formInputHidden(array(
- draft() ? $L->g('Draft') : $L->g('Publish')) ?> + scheduled()) : ?>
p('scheduled') ?>: date(SCHEDULED_DATE_FORMAT) ?>
@@ -59,8 +59,8 @@ echo Bootstrap::formInputHidden(array(
- - + +
@@ -484,19 +484,6 @@ foreach ($customFields as $field => $options) { }; } - // Button switch - $("#jsswitchButton").on("click", function() { - if ($(this).data("switch") == "publish") { - $(this).html('p('Draft') ?>'); - $(this).data("switch", "draft"); - $(this).attr('class', "ms-2 btn-outline-secondary btn"); - } else { - $(this).html('p('Publish') ?>'); - $(this).data("switch", "publish"); - $(this).attr('class', "ms-2 btn-outline-success btn"); - } - }); - // Button preview $("#jsbuttonPreview").on("click", function() { var uuid = $("#jsuuid").val(); @@ -511,13 +498,8 @@ foreach ($customFields as $field => $options) { // Button Save $("#jsbuttonSave").on("click", function() { - // If the switch is setted to "published", get the value from the selector - if ($("#jsswitchButton").data("switch") == "publish") { - var value = $("#jstypeSelector option:selected").val(); - $("#jstype").val(value); - } else { - $("#jstype").val("draft"); - } + var value = $("#jstypeSelector option:selected").val(); + $("#jstype").val(value); // Get the content $("#jscontent").val(editorGetContent()); diff --git a/bl-kernel/admin/views/new-content.php b/bl-kernel/admin/views/new-content.php index 42b23158..144d56a6 100644 --- a/bl-kernel/admin/views/new-content.php +++ b/bl-kernel/admin/views/new-content.php @@ -44,11 +44,11 @@ echo Bootstrap::formInputHidden(array(
- p('Publish') ?> +
- +
@@ -439,19 +439,6 @@ foreach ($customFields as $field => $options) { }; } - // Button switch - $("#jsswitchButton").on("click", function() { - if ($(this).data("switch") == "publish") { - $(this).html('p('Draft') ?>'); - $(this).data("switch", "draft"); - $(this).attr('class', "ms-2 btn-outline-secondary btn"); - } else { - $(this).html('p('Publish') ?>'); - $(this).data("switch", "publish"); - $(this).attr('class', "ms-2 btn-outline-success btn"); - } - }); - // Button preview $("#jsbuttonPreview").on("click", function() { var uuid = $("#jsuuid").val(); @@ -467,15 +454,24 @@ foreach ($customFields as $field => $options) { $("#jsbuttonSave").on("click", function() { let actionParameters = ''; - // If the switch is setted to "published", get the value from the selector - if ($("#jsbuttonSwitch").data("switch") == "publish") { - var value = $("#jstypeSelector option:selected").val(); - $("#jstype").val(value); - actionParameters = '#' + value; - } else { - $("#jstype").val("draft"); - actionParameters = '#draft'; - } + var value = $("#jstypeSelector option:selected").val(); + $("#jstype").val(value); + actionParameters = '#' + value; + + // Get the content + $("#jscontent").val(editorGetContent()); + + // Submit the form + $("#jsform").attr('action', actionParameters); + $("#jsform").submit(); + }); + + // Button Draft + $("#jsbuttonDraft").on("click", function() { + let actionParameters = ''; + + $("#jstype").val("draft"); + actionParameters = '#draft'; // Get the content $("#jscontent").val(editorGetContent()); -- 2.39.5 From 23de39ece80608c995591b3dd5b9fde9af018a41 Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Fri, 24 Jan 2025 19:57:49 +0100 Subject: [PATCH 13/25] =?UTF-8?q?=F0=9F=92=84=20(content):=20fix=20the=20s?= =?UTF-8?q?chduled=20badge?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bl-kernel/admin/views/content.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bl-kernel/admin/views/content.php b/bl-kernel/admin/views/content.php index 26f4f64d..c9247117 100644 --- a/bl-kernel/admin/views/content.php +++ b/bl-kernel/admin/views/content.php @@ -200,7 +200,7 @@ function table($type) {