From 64cb76436b0e92048f4ee5f6a9b04f86f0afa0eb Mon Sep 17 00:00:00 2001 From: aB0t Date: Wed, 26 Jul 2023 19:53:35 +0200 Subject: [PATCH] Stable release of v2.0.3 Fixed getBible/support#2 so that the view value does not result into Undefined. Fixed getBible/support#3 so that empty translations and translations without the selected books better manage the mismatching query. --- CHANGELOG.md | 7 ++- README.md | 14 ++--- admin/README.txt | 14 ++--- admin/sql/updates/mysql/2.0.2.sql | 1 + getbible.xml | 4 +- script.php | 2 +- site/language/en-GB/en-GB.com_getbible.ini | 1 + site/models/app.php | 62 +++++++++++++++++++--- site/router.php | 18 ++++--- update_server.xml | 18 +++++++ 10 files changed, 107 insertions(+), 34 deletions(-) create mode 100644 admin/sql/updates/mysql/2.0.2.sql diff --git a/CHANGELOG.md b/CHANGELOG.md index 8543a9b..36dc13a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,4 +12,9 @@ # v2.0.2 -- Adds missing Marked JS file \ No newline at end of file +- Adds missing Marked JS file + +# v2.0.3 + +- Fixed getBible/support#2 so that the view value does not result into Undefined. +- Fixed getBible/support#3 so that empty translations and translations without the selected books better manage the mismatching query. \ No newline at end of file diff --git a/README.md b/README.md index fbdd2b4..5ed717b 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Get Bible (2.0.2) +# Get Bible (2.0.3) ![Get Bible image](https://git.vdm.dev/getBible/joomla-component/raw/branch/master/admin/assets/images/vdm-component.jpg "GetBible") @@ -19,7 +19,7 @@ In essence, The Bible for Joomla is designed to transform how the Word of God is + *Name*: [Get Bible](https://getbible.net) + *First Build*: 3rd December, 2015 + *Last Build*: 26th July, 2023 -+ *Version*: 2.0.2 ++ *Version*: 2.0.3 + *Copyright*: Copyright (C) 2015. All Rights Reserved + *License*: GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html @@ -31,19 +31,19 @@ due to [Automated Component Builder](https://www.joomlacomponentbuilder.com)) > (if creating a folder and file took **5 seconds** and writing one line of code took **10 seconds**, > never making one mistake or taking any coffee break.) -+ *Line count*: **189871** -+ *File count*: **1662** ++ *Line count*: **189942** ++ *File count*: **1663** + *Folder count*: **161** -**349 Hours** or **44 Eight Hour Days** (the actual time the author spent) +**350 Hours** or **44 Eight Hour Days** (the actual time the author spent) > (with the following break down: -> **debugging @132hours** = codingtime / 4; +> **debugging @133hours** = codingtime / 4; > **planning @76hours** = codingtime / 7; > **mapping @53hours** = codingtime / 10; > **office @88hours** = codingtime / 6;) -**879 Hours** or **110 Eight Hour Days** +**880 Hours** or **110 Eight Hour Days** (a total of the realistic time frame for this project) > (if creating a folder and file took **5 seconds** and writing one line of code took **10 seconds**, diff --git a/admin/README.txt b/admin/README.txt index fbdd2b4..5ed717b 100644 --- a/admin/README.txt +++ b/admin/README.txt @@ -1,4 +1,4 @@ -# Get Bible (2.0.2) +# Get Bible (2.0.3) ![Get Bible image](https://git.vdm.dev/getBible/joomla-component/raw/branch/master/admin/assets/images/vdm-component.jpg "GetBible") @@ -19,7 +19,7 @@ In essence, The Bible for Joomla is designed to transform how the Word of God is + *Name*: [Get Bible](https://getbible.net) + *First Build*: 3rd December, 2015 + *Last Build*: 26th July, 2023 -+ *Version*: 2.0.2 ++ *Version*: 2.0.3 + *Copyright*: Copyright (C) 2015. All Rights Reserved + *License*: GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html @@ -31,19 +31,19 @@ due to [Automated Component Builder](https://www.joomlacomponentbuilder.com)) > (if creating a folder and file took **5 seconds** and writing one line of code took **10 seconds**, > never making one mistake or taking any coffee break.) -+ *Line count*: **189871** -+ *File count*: **1662** ++ *Line count*: **189942** ++ *File count*: **1663** + *Folder count*: **161** -**349 Hours** or **44 Eight Hour Days** (the actual time the author spent) +**350 Hours** or **44 Eight Hour Days** (the actual time the author spent) > (with the following break down: -> **debugging @132hours** = codingtime / 4; +> **debugging @133hours** = codingtime / 4; > **planning @76hours** = codingtime / 7; > **mapping @53hours** = codingtime / 10; > **office @88hours** = codingtime / 6;) -**879 Hours** or **110 Eight Hour Days** +**880 Hours** or **110 Eight Hour Days** (a total of the realistic time frame for this project) > (if creating a folder and file took **5 seconds** and writing one line of code took **10 seconds**, diff --git a/admin/sql/updates/mysql/2.0.2.sql b/admin/sql/updates/mysql/2.0.2.sql new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/admin/sql/updates/mysql/2.0.2.sql @@ -0,0 +1 @@ + diff --git a/getbible.xml b/getbible.xml index d14f2f7..f74459a 100644 --- a/getbible.xml +++ b/getbible.xml @@ -7,9 +7,9 @@ https://getbible.net Copyright (C) 2015. All Rights Reserved GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html - 2.0.2 + 2.0.3 Get Bible (v.2.0.2) +

Get Bible (v.2.0.3)

Welcome to the next level of scripture engagement - The Bible for Joomla! Our purpose is to bring the Word of God to every person, in their native language, entirely free. This isn't just a typical extension; it's a groundbreaking tool developed to span language divides and deliver a rich, customizable Bible study experience to users worldwide. diff --git a/script.php b/script.php index 8d64572..603aee2 100644 --- a/script.php +++ b/script.php @@ -1539,7 +1539,7 @@ class com_getbibleInstallerScript echo ' -

Upgrade to Version 2.0.2 Was Successful! Let us know if anything is not working as expected.

'; +

Upgrade to Version 2.0.3 Was Successful! Let us know if anything is not working as expected.

'; // Set db if not set already. if (!isset($db)) diff --git a/site/language/en-GB/en-GB.com_getbible.ini b/site/language/en-GB/en-GB.com_getbible.ini index 3d8ad6c..12d4163 100644 --- a/site/language/en-GB/en-GB.com_getbible.ini +++ b/site/language/en-GB/en-GB.com_getbible.ini @@ -199,6 +199,7 @@ COM_GETBIBLE_VERSE="Verse" COM_GETBIBLE_VERSES="Verses" COM_GETBIBLE_VERSE_NUMBER="Verse Number" COM_GETBIBLE_VIEW_ALL_VERSES_TAGGED="View all verses tagged." +COM_GETBIBLE_WERE_SORRY_THE_TRANSLATION_YOU_SELECTED_DOES_NOT_INCLUDE_THE_BOOK_YOU_WERE_IN_PREVIOUSLY_HOWEVER_WE_HAVE_LOCATED_BSB_WHICH_MIGHT_BE_OF_INTEREST_TO_YOU="We're sorry, the translation you selected does not include the book you were in previously. However, we have located %s which might be of interest to you." COM_GETBIBLE_WE_CURRENTLY_HAVE_BSB_VERSES_STORED_IN_THE_DATABASE_FOR_THIS_PARTICULAR_TRANSLATION="We currently have %s verses stored in the database for this particular translation." COM_GETBIBLE_WHAT_IS_THIS_HASH_ALL_ABOUT_CLICK_HERE_TO_READ_MORE="What is this Hash all about? Click here to read more..." COM_GETBIBLE_WITHOUT_SELECTING_THE_CORRECT_FAVOURITE_VERSE_YOU_CANT_PERFORM_THE_INITIAL_ACTION="Without selecting the correct favourite verse, you can't perform the initial action." diff --git a/site/models/app.php b/site/models/app.php index e9306fd..79626bc 100644 --- a/site/models/app.php +++ b/site/models/app.php @@ -104,10 +104,10 @@ class GetbibleModelApp extends ItemModel } // we get all the Scripture Details - $this->translation = $this->input->getString('t') ?? $this->input->getString('version') ?? $this->input->getString('translation', 'kjv') ; - $this->book = $this->input->getInt('b') ?? $this->input->getInt('book'); - $this->chapter = $this->input->getInt('c') ?? $this->input->getInt('chapter', 1); - $this->verses = $this->input->getString('v') ?? $this->input->getString('verses'); + $this->translation = $this->input->getString('translation') ?? $this->input->getString('t', 'kjv'); + $this->book = $this->input->getInt('book') ?? $this->input->getInt('b'); + $this->chapter = $this->input->getInt('chapter') ?? $this->input->getInt('c', 1); + $this->verses = $this->input->getString('verses') ?? $this->input->getString('verse') ?? $this->input->getString('v'); $pk = 0; // try the ref string @@ -155,15 +155,31 @@ class GetbibleModelApp extends ItemModel // we load the queried chapter if (!Factory::_('GetBible.Watcher')->api($this->translation, $this->book, $this->chapter)) { - $this->book = Factory::_('GetBible.Watcher')->getNextBook($this->translation, $this->book); + $book = Factory::_('GetBible.Watcher')->getNextBook($this->translation, $this->book); $this->chapter = 1; $this->verses = null; // so we try to load this one last time - if (!Factory::_('GetBible.Watcher')->api($this->translation, $this->book, $this->chapter)) + if (empty($book) || !Factory::_('GetBible.Watcher')->api($this->translation, $book, $this->chapter)) { return false; } + + // we found another book + $this->book = $book; + + // since we could not find the book we where looking for, we redirect to what we found + $app = JFactory::getApplication(); + + // get the book name + $name = $this->getBookName($this->book, $this->translation) ?? $book; + + // we state this obvious result to the user + $app->enqueueMessage(JText::sprintf("COM_GETBIBLE_WERE_SORRY_THE_TRANSLATION_YOU_SELECTED_DOES_NOT_INCLUDE_THE_BOOK_YOU_WERE_IN_PREVIOUSLY_HOWEVER_WE_HAVE_LOCATED_BSB_WHICH_MIGHT_BE_OF_INTEREST_TO_YOU", $name), 'warning'); + + $app->redirect(JRoute::_('index.php?option=com_getbible&view=app&t=' . $this->translation . '&ref=' . $name)); + + return false; } // [or] we load the next chapter @@ -681,7 +697,7 @@ class GetbibleModelApp extends ItemModel $chapter = 1; // make sure its loaded - if ($book === null || !Factory::_('GetBible.Watcher')->api($this->translation, $book, $chapter)) + if (empty($book) || !Factory::_('GetBible.Watcher')->api($this->translation, $book, $chapter)) { return false; } @@ -802,7 +818,7 @@ class GetbibleModelApp extends ItemModel $book = Factory::_('GetBible.Watcher')->getPreviousBook($this->translation, $this->book); // make sure its loaded - if ($book === null || !Factory::_('GetBible.Watcher')->api($this->translation, $book, 1)) + if (empty($book) || !Factory::_('GetBible.Watcher')->api($this->translation, $book, 1)) { return false; } @@ -1646,6 +1662,36 @@ class GetbibleModelApp extends ItemModel return $items; } + /** + * Get the book name + * + * @param int $book The book number + * + * @return string|null The book name on success + */ + protected function getBookName(int $book, string $translation): ?string + { + // Get a db connection. + $db = JFactory::getDbo(); + + // Create a new query object. + $query = $db->getQuery(true); + + // Get from #__getbible_book as a + $query->select($db->quoteName( + array('a.name'), + array('name'))); + $query->from($db->quoteName('#__getbible_book', 'a')); + + $query->where('a.abbreviation = ' . $db->quote($translation)); + $query->where('a.nr = ' . $book); + + // Reset the query using our newly populated query object. + $db->setQuery($query); + + return $db->loadResult(); + } + /** * Method to add html span tag to each word in each verse * diff --git a/site/router.php b/site/router.php index 4acfeca..92c104d 100644 --- a/site/router.php +++ b/site/router.php @@ -38,8 +38,9 @@ class GetbibleRouter extends JComponentRouterBase public function build(&$query) { $segments = []; + $view = $query['view'] ?? 'app'; - if ($query['view'] === 'search') + if ($view === 'search') { $segments[0] = 'search'; $segments[1] = $query['t'] ?? $query['version'] ?? $query['translation'] ?? 'kjv'; @@ -112,7 +113,7 @@ class GetbibleRouter extends JComponentRouterBase $segments[3] = $query['search'] ?? $query['s'] ?? ''; } - elseif ($query['view'] === 'openai') + elseif ($view === 'openai') { $segments[0] = 'openai'; $segments[1] = $query['guid'] ?? ''; @@ -132,13 +133,13 @@ class GetbibleRouter extends JComponentRouterBase unset($segments[6]); } } - elseif ($query['view'] === 'api') + elseif ($view === 'api') { $segments[0] = 'api'; $segments[1] = $query['t'] ?? $query['version'] ?? $query['translation'] ?? 'kjv'; $segments[2] = $query['get'] ?? ''; } - elseif ($query['view'] === 'tag') + elseif ($view === 'tag') { $segments[0] = 'tag'; $segments[1] = $query['t'] ?? $query['version'] ?? $query['translation'] ?? 'kjv'; @@ -154,15 +155,13 @@ class GetbibleRouter extends JComponentRouterBase $segments[0] = $query['t'] ?? $query['version'] ?? $query['translation'] ?? 'kjv'; $segments[1] = $query['ref'] ?? $query['b'] ?? $query['book'] ?? ''; - $chapter = isset($query['chapter']) ? $query['chapter'] : ''; - $chapter = isset($query['c']) ? $query['c'] : $chapter; + $chapter = $query['chapter'] ?? $query['c'] ?? ''; if (strlen($chapter) && is_numeric($chapter)) { $segments[2] = $chapter; } - $verse = isset($query['verse']) ? $query['verse'] : ''; - $verse = isset($query['v']) ? $query['v'] : $verse; + $verse = $query['verse'] ?? $query['v'] ?? ''; if (strlen($verse)) { $segments[3] = $verse; @@ -296,6 +295,7 @@ class GetbibleRouter extends JComponentRouterBase if ($book_name !== null && $book_number > 0) { $vars['ref'] = $book_name; + $vars['book'] = $book_number; $key++; $chapter_number = $this->getChapter($vars, $key, $segments); @@ -392,6 +392,7 @@ class GetbibleRouter extends JComponentRouterBase if (!empty($value) && is_numeric($value) && $value > 0) { $vars['ref'] .= ' ' . $value; + $vars['chapter'] = $value; $key++; return (int) $value; @@ -416,6 +417,7 @@ class GetbibleRouter extends JComponentRouterBase if (!empty($value) && (is_numeric($value) || strpos($value, '-') !== false)) { $vars['ref'] .= ':' . $value; + $vars['verse'] = $value; $key++; return true; diff --git a/update_server.xml b/update_server.xml index fecc768..1627c21 100644 --- a/update_server.xml +++ b/update_server.xml @@ -35,4 +35,22 @@ https://getbible.net + + Get Bible + The Bible for Joomla + pkg_getbible + package + site + 2.0.3 + https://getbible.net + + https://git.vdm.dev/api/v1/repos/getBible/joomla-pkg/archive/v2.0.3.zip + + + stable + + Llewellyn van der Merwe + https://getbible.net + + \ No newline at end of file