From 8f1d51764bf6bcac9df1a0488f483084c2c0f668 Mon Sep 17 00:00:00 2001 From: Emidio Reggiani Date: Wed, 14 Jan 2026 09:11:32 +0100 Subject: [PATCH] Local lables in themes, comments functions improvements. --- lang/en_US.ini | 2 -- system/admin/admin.php | 10 +++++++--- system/admin/views/comments.html.php | 4 ++-- system/includes/comments.php | 24 +++++++++++++++++++----- system/includes/dispatch.php | 7 +++++++ 5 files changed, 35 insertions(+), 12 deletions(-) diff --git a/lang/en_US.ini b/lang/en_US.ini index fa73426..e495c40 100644 --- a/lang/en_US.ini +++ b/lang/en_US.ini @@ -428,5 +428,3 @@ sysmsg_subscribe_success = "Your will receive now new comment notifications on t sysmsg_subscribe_fail = "Something went wrong during subscription verification process." sysmsg_unsubscribe_success = "You have successfully unsubscribed from notification emails." sysmsg_unsubscribe_fail = "Something wrong during unsubscription process" -codebtn_copy = "Copy" -codebtn_copied = "Copied!" diff --git a/system/admin/admin.php b/system/admin/admin.php index 07e6847..1e4a09f 100644 --- a/system/admin/admin.php +++ b/system/admin/admin.php @@ -2025,6 +2025,13 @@ function delete_comments($mdfile) { // regardless if file is content .md file or comments .json file function get_url_from_file($file) { + // Ensure config is loaded - if not loads it + $config_loaded = config('permalink.type'); + if (!$config_loaded) { + if (file_exists('config/config.ini')) { + config('source', 'config/config.ini'); + } + } // Normalize path separators (Windows/Linux)) $file = str_replace('\\', '/', $file); @@ -2096,9 +2103,6 @@ function get_url_from_file($file) // return site_url() . $slug; } - - - // Check if it's a blog post: {username}/blog/{category}/{type}/[scheduled/]{date}_{tags}_{slug}.md if (count($parts) >= 5 && $parts[1] == 'blog') { $filename_parts = explode('_', pathinfo($basename, PATHINFO_FILENAME)); diff --git a/system/admin/views/comments.html.php b/system/admin/views/comments.html.php index 148ce1f..e90f2fe 100644 --- a/system/admin/views/comments.html.php +++ b/system/admin/views/comments.html.php @@ -61,8 +61,8 @@ - - + + diff --git a/system/includes/comments.php b/system/includes/comments.php index c8262ea..e691d64 100644 --- a/system/includes/comments.php +++ b/system/includes/comments.php @@ -213,9 +213,6 @@ function get_comments_file_from_url($url) { } - - - /** * Get all comments for a post/page * @@ -283,11 +280,12 @@ function getAllComments($page = null, $perpage = null) $allComments = array(); - foreach ($files as $file) { $comments = getComments('', $file, true); + $url = get_url_from_file($file); foreach ($comments as $comment) { $comment['file'] = $file; + $comment['url'] = $url; $allComments[] = $comment; } } @@ -308,6 +306,22 @@ function getAllComments($page = null, $perpage = null) return $allComments; } + +function getPublishedComments($limit = 5) +{ + $comments = array(); + $counter = 0; + $allComments = getAllComments(); + foreach ($allComments as $comment) { + if ($comment['published'] == 1) { + $comments[] = $comment; + } + if (count($comments) >= $limit) break; + } + return $comments; +} + + /** * Generate unique comment ID * @@ -702,7 +716,7 @@ function commentPublish($file, $commentId) if ($comment['id'] === $commentId) { $comment['published'] = true; $updated = true; - + $url = get_url_from_file($file); // Send notifications only to subscribers when publishing (admin already saw it in moderation) diff --git a/system/includes/dispatch.php b/system/includes/dispatch.php index dab3f3f..41318e6 100644 --- a/system/includes/dispatch.php +++ b/system/includes/dispatch.php @@ -90,6 +90,13 @@ function i18n($key, $value = null) $_i18n = parse_ini_file($value, true); else $_i18n = parse_ini_file('lang/en_US.ini', true); + $theme_path = parse_url(theme_path(), PHP_URL_PATH); + $theme_lang_file = $_SERVER['DOCUMENT_ROOT'] . $theme_path . 'lang/en_US.ini'; + $_i18n_local = array(); + if (file_exists($theme_lang_file)) { + $_i18n_local = parse_ini_file($theme_lang_file, true); + } + $_i18n = array_replace($_i18n, $_i18n_local); } elseif ($value == null) return (isset($_i18n[$key]) ? $_i18n[$key] : $key); else