From ea7f24b53a043aa8df2f99552f7fc55210689af4 Mon Sep 17 00:00:00 2001 From: Diego Najar Date: Thu, 15 Feb 2018 20:08:00 +0100 Subject: [PATCH] Reading time improves --- bl-kernel/admin/views/content.php | 3 +-- bl-kernel/page.class.php | 8 +++++++- bl-languages/en.json | 5 ++++- bl-themes/blogx/php/home.php | 2 +- bl-themes/blogx/php/page.php | 2 +- 5 files changed, 14 insertions(+), 6 deletions(-) diff --git a/bl-kernel/admin/views/content.php b/bl-kernel/admin/views/content.php index 384bd95f..617db95e 100644 --- a/bl-kernel/admin/views/content.php +++ b/bl-kernel/admin/views/content.php @@ -65,8 +65,7 @@ function table($status, $icon='arrow-circle-o-down') { echo ''.$friendlyURL.''; echo ''; - foreach ($page->children() as $childKey) { - $child = buildPage($childKey); + foreach ($page->children() as $child) { if ($child->published()) { echo ' diff --git a/bl-kernel/page.class.php b/bl-kernel/page.class.php index b260c58f..fd3e4a2c 100644 --- a/bl-kernel/page.class.php +++ b/bl-kernel/page.class.php @@ -487,13 +487,19 @@ class Page { // Returns the amount of minutes takes to read the page public function readingTime() { + global $Language; + $words = $this->content(true); $words = strip_tags($words); $words = str_word_count($words); $average = $words / 200; $minutes = round($average); - return $minutes; + if ($minutes>0) { + return $minutes.' '.$Language->get('minutes'); + } + + return '~1 '.$Language->get('minute'); } // Returns relative time (e.g. "1 minute ago") diff --git a/bl-languages/en.json b/bl-languages/en.json index 6a99dd65..d59bdfd3 100644 --- a/bl-languages/en.json +++ b/bl-languages/en.json @@ -280,5 +280,8 @@ "plugins-position": "Plugin position", "plugins-position-changed": "Plugin position changed", "drag-and-drop-to-set-the-position-of-the-plugin": "Drag and Drop to set the position of the plugins", - "change-the-position-of-the-plugins": "Change the position of the plugins" + "change-the-position-of-the-plugins": "Change the position of the plugins", + "reading-time": "Reading time", + "minutes": "minutes", + "minute": "minute" } diff --git a/bl-themes/blogx/php/home.php b/bl-themes/blogx/php/home.php index 6b51dc02..53b1a839 100644 --- a/bl-themes/blogx/php/home.php +++ b/bl-themes/blogx/php/home.php @@ -15,7 +15,7 @@ -
date(); ?>
+
date(); ?> - get('Reading time') . ': ' . $page->readingTime() . $Language->get('minutes') ?>
contentBreak(); ?> diff --git a/bl-themes/blogx/php/page.php b/bl-themes/blogx/php/page.php index 08972c8a..350afdda 100644 --- a/bl-themes/blogx/php/page.php +++ b/bl-themes/blogx/php/page.php @@ -14,7 +14,7 @@ static()): ?> -
date(); ?>
+
date(); ?> - get('Reading time') . ': ' . $page->readingTime() ?>