From dd0e16acf3e71272f5b61bb1c1478bb27df4bae4 Mon Sep 17 00:00:00 2001 From: danpros Date: Sun, 3 Mar 2024 07:59:29 +0700 Subject: [PATCH 1/5] Cleaning up --- system/admin/admin.php | 12 ++++++++---- system/includes/functions.php | 32 ++++++++++++++++++++------------ themes/blog/main.html.php | 8 +++++--- themes/clean/main.html.php | 3 ++- themes/doks/main.html.php | 4 ++-- themes/doks/profile.html.php | 6 +++--- themes/logs/main.html.php | 4 ++-- themes/readable/main.html.php | 4 ++-- themes/twentyfifteen/main.html.php | 3 ++- themes/twentysixteen/main.html.php | 3 ++- 10 files changed, 48 insertions(+), 31 deletions(-) diff --git a/system/admin/admin.php b/system/admin/admin.php index 4ab4347..2543fed 100644 --- a/system/admin/admin.php +++ b/system/admin/admin.php @@ -1010,7 +1010,9 @@ function find_draft_page($static = null) $tmp = array(); - if (config('views.counter') == 'true') { + $counter = config('views.counter'); + + if ($counter == 'true') { $viewsFile = "content/data/views.json"; if (file_exists($viewsFile)) { $views = json_decode(file_get_contents($viewsFile), true); @@ -1052,7 +1054,7 @@ function find_draft_page($static = null) // Get the contents and convert it to HTML $post->body = MarkdownExtra::defaultTransform(remove_html_comments($content)); - if (config('views.counter') == 'true') { + if ($counter == 'true') { $post->views = get_views('page_' . $post->slug, $post->file, $views); } else { $post->views = null; @@ -1078,7 +1080,9 @@ function find_draft_subpage($static = null, $sub_static = null) $tmp = array(); - if (config('views.counter') == 'true') { + $counter = config('views.counter'); + + if ($counter == 'true') { $viewsFile = "content/data/views.json"; if (file_exists($viewsFile)) { $views = json_decode(file_get_contents($viewsFile), true); @@ -1129,7 +1133,7 @@ function find_draft_subpage($static = null, $sub_static = null) // Get the contents and convert it to HTML $post->body = MarkdownExtra::defaultTransform(remove_html_comments($content)); - if (config('views.counter') == 'true') { + if ($counter == 'true') { $post->views = get_views('subpage_' . $post->parentSlug .'.'. $post->slug, $post->file, $views); } else { $post->views = null; diff --git a/system/includes/functions.php b/system/includes/functions.php index 25dc827..62e4425 100644 --- a/system/includes/functions.php +++ b/system/includes/functions.php @@ -394,8 +394,12 @@ function get_posts($posts, $page = 1, $perpage = 0) $posts = array_slice($posts, ($page - 1) * $perpage, $perpage); $cList = category_list(true); - - if (config('views.counter') == 'true') { + + $auto = config('toc.automatic'); + $counter = config('views.counter'); + $caption = config('fig.captions'); + + if ($counter == 'true') { $viewsFile = "content/data/views.json"; if (file_exists($viewsFile)) { $views = json_decode(file_get_contents($viewsFile), true); @@ -535,18 +539,17 @@ function get_posts($posts, $page = 1, $perpage = 0) if (isset($toc['1'])) { $post->body = insert_toc('post-' . $post->date, $toc['0'], $toc['1']); } else { - $auto = config('toc.automatic'); if ($auto === 'true') { $post->body = automatic_toc($post->body, 'post-' . $post->date); } } // Convert image tags to figures - if (config('fig.captions') == 'true') { + if ($caption == 'true') { $post->body = preg_replace( '/

()<\/p>/', '

$1
$2
', $post->body ); } - if (config('views.counter') == 'true') { + if ($counter == 'true') { $post->views = get_views('post_' . $post->slug, $post->file, $views); } else { $post->views = null; @@ -565,8 +568,11 @@ function get_pages($pages, $page = 1, $perpage = 0) } $tmp = array(); + + $auto = config('toc.automatic'); + $counter = config('views.counter'); - if (config('views.counter') == 'true') { + if ($counter == 'true') { $viewsFile = "content/data/views.json"; if (file_exists($viewsFile)) { $views = json_decode(file_get_contents($viewsFile), true); @@ -616,13 +622,12 @@ function get_pages($pages, $page = 1, $perpage = 0) if (isset($toc['1'])) { $post->body = insert_toc('page-' . $post->slug, $toc['0'], $toc['1']); } else { - $auto = config('toc.automatic'); if ($auto === 'true') { $post->body = automatic_toc($post->body, 'page-' . $post->slug); } } - if (config('views.counter') == 'true') { + if ($counter == 'true') { $post->views = get_views('page_' . $post->slug, $post->file, $views); } else { $post->views = null; @@ -642,8 +647,11 @@ function get_subpages($sub_pages, $page = 1, $perpage = 0) } $tmp = array(); + + $auto = config('toc.automatic'); + $counter = config('views.counter'); - if (config('views.counter') == 'true') { + if ($counter == 'true') { $viewsFile = "content/data/views.json"; if (file_exists($viewsFile)) { $views = json_decode(file_get_contents($viewsFile), true); @@ -703,13 +711,12 @@ function get_subpages($sub_pages, $page = 1, $perpage = 0) if (isset($toc['1'])) { $post->body = insert_toc('subpage-' . $post->slug, $toc['0'], $toc['1']); } else { - $auto = config('toc.automatic'); if ($auto === 'true') { $post->body = automatic_toc($post->body, 'subpage-' . $post->slug); } } - if (config('views.counter') == 'true') { + if ($counter == 'true') { $post->views = get_views('subpage_' . $post->parentSlug .'.'. $post->slug, $post->file, $views); } else { $post->views = null; @@ -2210,6 +2217,7 @@ function get_teaser($string, $url = null, $char = null) { $teaserType = config('teaser.type'); $more = config('read.more'); + $behave = config('teaser.behave'); if(empty($more)) { $more = 'Read more'; @@ -2231,7 +2239,7 @@ function get_teaser($string, $url = null, $char = null) return $string; } } else { - if (config('teaser.behave') === 'check') { + if ($behave === 'check') { $readMore = explode('', $string); if (isset($readMore['1'])) { $string = shorten($readMore[0]); diff --git a/themes/blog/main.html.php b/themes/blog/main.html.php index b5fb8f4..2618ba6 100644 --- a/themes/blog/main.html.php +++ b/themes/blog/main.html.php @@ -17,6 +17,7 @@ +
@@ -61,11 +62,12 @@

- body, $p->url) ?> + body, $p->url);?> + [...]
- - + +
+
@@ -52,7 +53,7 @@
body) ?> body, $p->url) ?> - + [...]
diff --git a/themes/doks/main.html.php b/themes/doks/main.html.php index a6442d0..329c038 100644 --- a/themes/doks/main.html.php +++ b/themes/doks/main.html.php @@ -61,7 +61,7 @@ - + body);?>
@@ -101,7 +101,7 @@
body, $post->url); ?> - + [...]

diff --git a/themes/doks/profile.html.php b/themes/doks/profile.html.php index d6ddf28..54bddf3 100644 --- a/themes/doks/profile.html.php +++ b/themes/doks/profile.html.php @@ -7,7 +7,7 @@

about;?>
- + body);?> @@ -17,7 +17,7 @@ image)) {?> <?php echo $post->title;?> - + <?php echo $post->title;?> @@ -48,7 +48,7 @@
body, $post->url); ?> - + [...]

diff --git a/themes/logs/main.html.php b/themes/logs/main.html.php index 26ee850..c610320 100644 --- a/themes/logs/main.html.php +++ b/themes/logs/main.html.php @@ -10,6 +10,7 @@ +

@@ -50,9 +51,8 @@
- body) ?> body, $p->url) ?> - + [...]
diff --git a/themes/readable/main.html.php b/themes/readable/main.html.php index d11539f..e2fc855 100644 --- a/themes/readable/main.html.php +++ b/themes/readable/main.html.php @@ -10,6 +10,7 @@ +
@@ -50,9 +51,8 @@
- body) ?> body, $p->url) ?> - + [...]
diff --git a/themes/twentyfifteen/main.html.php b/themes/twentyfifteen/main.html.php index 3249b6e..29652b3 100644 --- a/themes/twentyfifteen/main.html.php +++ b/themes/twentyfifteen/main.html.php @@ -30,6 +30,7 @@

Type: title);?>

+
image)):?> @@ -63,7 +64,7 @@
body, $p->url); ?> - + [...]