From dfaab46ef228b3b50c76e969094e14bc805c8ae4 Mon Sep 17 00:00:00 2001 From: aB0t Date: Thu, 7 Mar 2024 18:23:34 +0200 Subject: [PATCH] Stable release of v4.0.7 Fix missing token variable in ajax call. --- CHANGELOG.md | 20 +- GetbibleInstallerScript.php | 2 +- README.md | 28 +- admin/README.txt | 28 +- admin/sql/install.mysql.utf8.sql | 2 +- .../updates/mysql/{5.0.0.sql => 4.0.0.sql} | 0 .../updates/mysql/{5.0.1.sql => 4.0.1.sql} | 0 .../updates/mysql/{5.0.2.sql => 4.0.2.sql} | 0 .../updates/mysql/{5.0.3.sql => 4.0.3.sql} | 0 .../updates/mysql/{5.0.4.sql => 4.0.4.sql} | 0 .../updates/mysql/{5.0.5.sql => 4.0.5.sql} | 0 .../updates/mysql/{5.0.6.sql => 4.0.6.sql} | 0 .../src/Controller/TranslationsController.php | 2 +- admin/src/Model/GetbibleModel.php | 1 - getbible.xml | 8 +- .../src/Utilities/Component/Helper.php | 10 +- site/src/Model/OpenaiModel.php | 6 +- site/src/Service/Router.php | 763 +----------------- site/tmpl/app/default_getbiblebooks.php | 4 +- site/tmpl/app/default_getbiblechapters.php | 4 +- .../tmpl/app/default_getbibletranslations.php | 6 +- update_server.xml | 48 +- 22 files changed, 99 insertions(+), 833 deletions(-) rename admin/sql/updates/mysql/{5.0.0.sql => 4.0.0.sql} (100%) rename admin/sql/updates/mysql/{5.0.1.sql => 4.0.1.sql} (100%) rename admin/sql/updates/mysql/{5.0.2.sql => 4.0.2.sql} (100%) rename admin/sql/updates/mysql/{5.0.3.sql => 4.0.3.sql} (100%) rename admin/sql/updates/mysql/{5.0.4.sql => 4.0.4.sql} (100%) rename admin/sql/updates/mysql/{5.0.5.sql => 4.0.5.sql} (100%) rename admin/sql/updates/mysql/{5.0.6.sql => 4.0.6.sql} (100%) diff --git a/CHANGELOG.md b/CHANGELOG.md index bca9eca..07a7ff7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,36 +1,36 @@ -# v5.0.7 +# v4.0.7 - Fix missing token variable in ajax call -# v5.0.6 +# v4.0.6 - Fix an Ajax input typo. -# v5.0.5 +# v4.0.5 - Add option to target MySQL 8+ with the search regex. -# v5.0.4 +# v4.0.4 - Fix the spl_autoload_register function to load all the needed namespace. That was remove in the last update (sorry). -# v5.0.3 +# v4.0.3 - Fix canDelete to correctly use published. - Add default 1 to version field to make sure the versioning feature works as expected. -# v5.0.2 +# v4.0.2 - Fix Daily Light Deprecated code. - Fix Daily Scripture Deprecated code. -# v5.0.1 +# v4.0.1 -- First stable back-end and front-end release towards Joomla 4 and 5 +- First stable back-end and front-end release towards Joomla 4 -# v5.0.0 +# v4.0.0 -- Moved to Joomla 4 and 5 +- Moved to Joomla 4 # v3.0.5 diff --git a/GetbibleInstallerScript.php b/GetbibleInstallerScript.php index e65eece..a884487 100644 --- a/GetbibleInstallerScript.php +++ b/GetbibleInstallerScript.php @@ -755,7 +755,7 @@ class Com_GetbibleInstallerScript implements InstallerScriptInterface echo '
-

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

'; +

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

'; // Add/Update component in the action logs extensions table. $this->setActionLogsExtensions(); diff --git a/README.md b/README.md index c9000ed..12d51d6 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Get Bible (5.0.7) +# Get Bible (4.0.7) ![Get Bible image](https://git.vdm.dev/getBible/joomla-component/raw/branch/5.0/admin/assets/images/vdm-component.jpg "GetBible") @@ -18,38 +18,38 @@ In essence, The Bible for Joomla is designed to transform how the Word of God is + *Author*: [Llewellyn van der Merwe](mailto:joomla@vdm.io) + *Name*: [Get Bible](https://getbible.net) + *First Build*: 3rd December, 2015 -+ *Last Build*: 4th March, 2024 -+ *Version*: 5.0.7 ++ *Last Build*: 7th March, 2024 ++ *Version*: 4.0.7 + *Copyright*: Copyright (C) 2015. All Rights Reserved + *License*: GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html ## Build Time -**579 Hours** or **72 Eight Hour Days** (actual time the author saved - +**571 Hours** or **71 Eight Hour Days** (actual time the author saved - 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*: **207531** -+ *File count*: **1725** -+ *Folder count*: **189** ++ *Line count*: **204547** ++ *File count*: **1694** ++ *Folder count*: **174** -**382 Hours** or **48 Eight Hour Days** (the actual time the author spent) +**376 Hours** or **47 Eight Hour Days** (the actual time the author spent) > (with the following break down: -> **debugging @145hours** = codingtime / 4; -> **planning @83hours** = codingtime / 7; -> **mapping @58hours** = codingtime / 10; -> **office @97hours** = codingtime / 6;) +> **debugging @143hours** = codingtime / 4; +> **planning @82hours** = codingtime / 7; +> **mapping @57hours** = codingtime / 10; +> **office @95hours** = codingtime / 6;) -**961 Hours** or **120 Eight Hour Days** +**947 Hours** or **118 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**, > with the normal everyday realities at the office, that includes the component planning, mapping & debugging.) -Project duration: **24 weeks** or **5 months** +Project duration: **23.6 weeks** or **4.9 months** > This **component** was build with a Joomla [Automated Component Builder](https://www.joomlacomponentbuilder.com). > Developed by [Llewellyn van der Merwe](mailto:joomla@vdm.io) diff --git a/admin/README.txt b/admin/README.txt index c9000ed..12d51d6 100644 --- a/admin/README.txt +++ b/admin/README.txt @@ -1,4 +1,4 @@ -# Get Bible (5.0.7) +# Get Bible (4.0.7) ![Get Bible image](https://git.vdm.dev/getBible/joomla-component/raw/branch/5.0/admin/assets/images/vdm-component.jpg "GetBible") @@ -18,38 +18,38 @@ In essence, The Bible for Joomla is designed to transform how the Word of God is + *Author*: [Llewellyn van der Merwe](mailto:joomla@vdm.io) + *Name*: [Get Bible](https://getbible.net) + *First Build*: 3rd December, 2015 -+ *Last Build*: 4th March, 2024 -+ *Version*: 5.0.7 ++ *Last Build*: 7th March, 2024 ++ *Version*: 4.0.7 + *Copyright*: Copyright (C) 2015. All Rights Reserved + *License*: GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html ## Build Time -**579 Hours** or **72 Eight Hour Days** (actual time the author saved - +**571 Hours** or **71 Eight Hour Days** (actual time the author saved - 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*: **207531** -+ *File count*: **1725** -+ *Folder count*: **189** ++ *Line count*: **204547** ++ *File count*: **1694** ++ *Folder count*: **174** -**382 Hours** or **48 Eight Hour Days** (the actual time the author spent) +**376 Hours** or **47 Eight Hour Days** (the actual time the author spent) > (with the following break down: -> **debugging @145hours** = codingtime / 4; -> **planning @83hours** = codingtime / 7; -> **mapping @58hours** = codingtime / 10; -> **office @97hours** = codingtime / 6;) +> **debugging @143hours** = codingtime / 4; +> **planning @82hours** = codingtime / 7; +> **mapping @57hours** = codingtime / 10; +> **office @95hours** = codingtime / 6;) -**961 Hours** or **120 Eight Hour Days** +**947 Hours** or **118 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**, > with the normal everyday realities at the office, that includes the component planning, mapping & debugging.) -Project duration: **24 weeks** or **5 months** +Project duration: **23.6 weeks** or **4.9 months** > This **component** was build with a Joomla [Automated Component Builder](https://www.joomlacomponentbuilder.com). > Developed by [Llewellyn van der Merwe](mailto:joomla@vdm.io) diff --git a/admin/sql/install.mysql.utf8.sql b/admin/sql/install.mysql.utf8.sql index 7d11d90..12bc0d7 100644 --- a/admin/sql/install.mysql.utf8.sql +++ b/admin/sql/install.mysql.utf8.sql @@ -287,7 +287,7 @@ CREATE TABLE IF NOT EXISTS `#__getbible_tag` ( `id` INT(11) NOT NULL AUTO_INCREMENT, `asset_id` INT(10) unsigned NOT NULL DEFAULT 0 COMMENT 'FK to the #__assets table.', `access` TINYINT(1) NOT NULL DEFAULT 0, - `description` TEXT NOT NULL, + `description` TEXT NULL, `guid` VARCHAR(36) NOT NULL DEFAULT '', `linker` VARCHAR(36) NOT NULL DEFAULT '', `name` VARCHAR(255) NOT NULL DEFAULT '', diff --git a/admin/sql/updates/mysql/5.0.0.sql b/admin/sql/updates/mysql/4.0.0.sql similarity index 100% rename from admin/sql/updates/mysql/5.0.0.sql rename to admin/sql/updates/mysql/4.0.0.sql diff --git a/admin/sql/updates/mysql/5.0.1.sql b/admin/sql/updates/mysql/4.0.1.sql similarity index 100% rename from admin/sql/updates/mysql/5.0.1.sql rename to admin/sql/updates/mysql/4.0.1.sql diff --git a/admin/sql/updates/mysql/5.0.2.sql b/admin/sql/updates/mysql/4.0.2.sql similarity index 100% rename from admin/sql/updates/mysql/5.0.2.sql rename to admin/sql/updates/mysql/4.0.2.sql diff --git a/admin/sql/updates/mysql/5.0.3.sql b/admin/sql/updates/mysql/4.0.3.sql similarity index 100% rename from admin/sql/updates/mysql/5.0.3.sql rename to admin/sql/updates/mysql/4.0.3.sql diff --git a/admin/sql/updates/mysql/5.0.4.sql b/admin/sql/updates/mysql/4.0.4.sql similarity index 100% rename from admin/sql/updates/mysql/5.0.4.sql rename to admin/sql/updates/mysql/4.0.4.sql diff --git a/admin/sql/updates/mysql/5.0.5.sql b/admin/sql/updates/mysql/4.0.5.sql similarity index 100% rename from admin/sql/updates/mysql/5.0.5.sql rename to admin/sql/updates/mysql/4.0.5.sql diff --git a/admin/sql/updates/mysql/5.0.6.sql b/admin/sql/updates/mysql/4.0.6.sql similarity index 100% rename from admin/sql/updates/mysql/5.0.6.sql rename to admin/sql/updates/mysql/4.0.6.sql diff --git a/admin/src/Controller/TranslationsController.php b/admin/src/Controller/TranslationsController.php index 6b6648b..5bf94ec 100644 --- a/admin/src/Controller/TranslationsController.php +++ b/admin/src/Controller/TranslationsController.php @@ -83,7 +83,7 @@ class TranslationsController extends AdminController { // Redirect to the list screen with error. $message = Text::_('COM_GETBIBLE_YOU_DO_NOT_HAVE_PERMISSION_TO_UPDATE_THE_BOOK_NAMES_PLEASE_CONTACT_YOUR_SYSTEM_ADMINISTRATOR_FOR_MORE_HELP'); - $this->setRedirect(JRoute::_('index.php?option=com_getbible&view=translations', false), $message, 'error'); + $this->setRedirect(\JRoute::_('index.php?option=com_getbible&view=translations', false), $message, 'error'); return; } // Redirect to the list screen with error. diff --git a/admin/src/Model/GetbibleModel.php b/admin/src/Model/GetbibleModel.php index b70e35c..01f0f0e 100644 --- a/admin/src/Model/GetbibleModel.php +++ b/admin/src/Model/GetbibleModel.php @@ -31,7 +31,6 @@ use Joomla\CMS\User\User; use Joomla\Utilities\ArrayHelper; use Joomla\Input\Input; use TrueChristianChurch\Component\Getbible\Administrator\Helper\GetbibleHelper; -use Joomla\Registry\Registry; use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; use VDM\Joomla\Utilities\StringHelper; diff --git a/getbible.xml b/getbible.xml index 84a4641..8926b25 100644 --- a/getbible.xml +++ b/getbible.xml @@ -1,15 +1,15 @@ COM_GETBIBLE - 4th March, 2024 + 7th March, 2024 Llewellyn van der Merwe joomla@vdm.io https://getbible.net Copyright (C) 2015. All Rights Reserved GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html - 5.0.7 + 4.0.7 Get Bible (v.5.0.7) +

Get Bible (v.4.0.7)

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. @@ -111,6 +111,6 @@ In essence, The Bible for Joomla is designed to transform how the Word of God is - https://git.vdm.dev/getBible/joomla-component/raw/branch/5.0/update_server.xml + https://git.vdm.dev/getBible/joomla-component/raw/branch/4.x/update_server.xml \ No newline at end of file diff --git a/libraries/jcb_powers/VDM.Joomla/src/Utilities/Component/Helper.php b/libraries/jcb_powers/VDM.Joomla/src/Utilities/Component/Helper.php index b2ae824..5660a49 100644 --- a/libraries/jcb_powers/VDM.Joomla/src/Utilities/Component/Helper.php +++ b/libraries/jcb_powers/VDM.Joomla/src/Utilities/Component/Helper.php @@ -79,12 +79,12 @@ abstract class Helper /** * Set the component option * - * @param string $option The option + * @param string|null $option The option * * @return void * @since 3.2.0 */ - public static function setOption(string $option): void + public static function setOption(?string $option): void { self::$option = $option; } @@ -97,7 +97,7 @@ abstract class Helper * @return string|null A component option * @since 3.0.11 */ - public static function getOption(string $default = 'empty'): ?string + public static function getOption(?string $default = 'empty'): ?string { if (empty(self::$option)) { @@ -160,7 +160,7 @@ abstract class Helper * * @since 3.0.11 */ - public static function get(string $option = null, string $default = null): ?string + public static function get(?string $option = null, ?string $default = null): ?string { // check that we have an option // and get the code name from it @@ -260,7 +260,7 @@ abstract class Helper * * @since 3.0.11 */ - public static function methodExists(string $method, string $option = null): bool + public static function methodExists(string $method, ?string $option = null): bool { // get the helper class return ($helper = self::get($option, null)) !== null && diff --git a/site/src/Model/OpenaiModel.php b/site/src/Model/OpenaiModel.php index 095babb..cdd0faf 100644 --- a/site/src/Model/OpenaiModel.php +++ b/site/src/Model/OpenaiModel.php @@ -220,7 +220,7 @@ class OpenaiModel extends ItemModel $app = Factory::getApplication(); // If no data is found redirect to default page and show warning. $app->enqueueMessage('The Open AI feature has not been activated. Please contact the system administrator of this website to resolve this.', 'error'); - $app->redirect(JRoute::_('index.php?option=com_getbible&view=app')); + $app->redirect(\JRoute::_('index.php?option=com_getbible&view=app')); return false; } // validate that we have a valid prompt and we have a book, chapter and verse @@ -229,7 +229,7 @@ class OpenaiModel extends ItemModel $app = Factory::getApplication(); // If no data is found redirect to default page and show warning. $app->enqueueMessage('There has been an error!', 'error'); - $app->redirect(JRoute::_('index.php?option=com_getbible&view=app')); + $app->redirect(\JRoute::_('index.php?option=com_getbible&view=app')); return false; } // validate that we have the correct translation @@ -238,7 +238,7 @@ class OpenaiModel extends ItemModel $app = Factory::getApplication(); // If no data is found redirect to default page and show warning. $app->enqueueMessage('There has been an error: mismatch!', 'error'); - $app->redirect(JRoute::_('index.php?option=com_getbible&view=app')); + $app->redirect(\JRoute::_('index.php?option=com_getbible&view=app')); return false; } diff --git a/site/src/Service/Router.php b/site/src/Service/Router.php index d82dc4c..74c27cf 100644 --- a/site/src/Service/Router.php +++ b/site/src/Service/Router.php @@ -31,8 +31,6 @@ use Joomla\Database\DatabaseInterface; use Joomla\Database\ParameterType; use Joomla\Registry\Registry; use TrueChristianChurch\Component\Getbible\Administrator\Helper\GetbibleHelper; -use VDM\Joomla\Utilities\Component\Helper; -use VDM\Joomla\Utilities\GetHelper; // No direct access to this file \defined('_JEXEC') or die; @@ -105,21 +103,21 @@ class Router extends RouterView $this->params = ComponentHelper::getParams('com_getbible'); $this->noIDs = (bool) $this->params->get('sef_ids', false); - Helper::setOption('com_getbible'); - $this->defaultTranslation = $this->params->get('default_translation', 'kjv'); - - // Define views and register them - $appView = new RouterViewConfiguration('app'); - $this->registerView($appView); - - $searchView = new RouterViewConfiguration('search'); - $this->registerView($searchView); - - $tagView = new RouterViewConfiguration('tag'); - $this->registerView($tagView); - - $openaiView = new RouterViewConfiguration('openai'); - $this->registerView($openaiView); + // Add the (app:view) router configuration + $app = new RouterViewConfiguration('app'); + $this->registerView($app); + + // Add the (tag:view) router configuration + $tag = new RouterViewConfiguration('tag'); + $this->registerView($tag); + + // Add the (search:view) router configuration + $search = new RouterViewConfiguration('search'); + $this->registerView($search); + + // Add the (openai:view) router configuration + $openai = new RouterViewConfiguration('openai'); + $this->registerView($openai); parent::__construct($app, $menu); @@ -127,735 +125,4 @@ class Router extends RouterView $this->attachRule(new StandardRules($this)); $this->attachRule(new NomenuRules($this)); } - - /** - * The default translation - * - * @var string|null - * @since 3.3 - */ - private ?string $defaultTranslation = null; - - /** - * Build the route for the com_getbible component - * - * @param array &$query An array of URL arguments - * - * @return array The URL arguments to use to assemble the subsequent URL. - * @since 3.3 - */ - public function build(&$query) - { - $segments = []; - $view = $query['view'] ?? 'app'; - - if ($view === 'search') - { - $segments[0] = 'search'; - $segments[1] = $query['t'] ?? $query['version'] ?? $query['translation'] ?? $this->defaultTranslation; - - $criteria = $query['criteria'] ?? null; - if ($criteria === null) - { - $word = $query['words'] ?? 1; - $match = $query['match'] ?? 2; - $case = $query['case'] ?? 1; - $target = $query['target'] ?? 1000; - - $criteria = "{$word}-{$match}-{$case}-{$target}"; - } - - if (strpos($criteria, '-') !== false) - { - $word = $this->criteriaString( - $criteria, 0, - [ - 'allwords' => 'allwords', - 'anywords' => 'anywords', - 'exactwords' => 'exactwords', - 1 => 'allwords', - 2 => 'anywords', - 3 => 'exactwords' - ], 'allwords'); - - $match = $this->criteriaString( - $criteria, 1, - [ - 'exactmatch' => 'exactmatch', - 'partialmatch' => 'partialmatch', - 1 => 'exactmatch', - 2 => 'partialmatch' - ], 'partialmatch'); - - $case = $this->criteriaString( - $criteria, 2, - [ - 'caseinsensitive' => 'caseinsensitive', - 'casesensitive' => 'casesensitive', - 1 => 'caseinsensitive', - 2 => 'casesensitive' - ], 'caseinsensitive'); - - $target = $this->criteriaString( - $criteria, 3, - [ - 'allbooks' => 'allbooks', - 'oldtestament' => 'oldtestament', - 'newtestament' => 'newtestament', - 1000 => 'allbooks', - 2000 => 'oldtestament', - 3000 => 'newtestament', - 4000 => 'booknames' - ], 'allbooks'); - - if ($target === 'booknames') - { - $target = $this->criteriaBook($criteria, 3); - } - - $segments[2] = "{$word}-{$match}-{$case}-{$target}"; - } - else - { - $segments[2] = 'allwords-partialmatch-caseinsensitive-allbooks'; - } - - $segments[3] = $query['search'] ?? $query['s'] ?? ''; - } - elseif ($view === 'openai') - { - $segments[0] = 'openai'; - $segments[1] = $query['guid'] ?? ''; - $segments[2] = $query['t'] ?? $query['version'] ?? $query['translation'] ?? $this->defaultTranslation; - $segments[3] = $query['book'] ?? ''; - $segments[4] = $query['chapter'] ?? ''; - $segments[5] = $query['verse'] ?? ''; - $segments[6] = $query['words'] ?? ''; - - // remove what is not there - if (empty($segments[5])) - { - unset($segments[5]); - } - if (empty($segments[6])) - { - unset($segments[6]); - } - } - elseif ($view === 'api') - { - $segments[0] = 'api'; - $segments[1] = $query['t'] ?? $query['version'] ?? $query['translation'] ?? $this->defaultTranslation; - $segments[2] = $query['get'] ?? ''; - } - elseif ($view === 'tag') - { - $segments[0] = 'tag'; - $segments[1] = $query['t'] ?? $query['version'] ?? $query['translation'] ?? $this->defaultTranslation; - $segments[2] = $query['guid'] ?? ''; - if (!empty($query['guid']) && ($tag_name = GetHelper::var('tag', $query['guid'], 'guid', 'name')) !== null) - { - $tag_name = preg_replace('/[^\p{L}\p{N}\s]/u', '', $tag_name); - $segments[3] = urlencode($tag_name); - } - } - else - { - $segments[0] = $query['t'] ?? $query['translation'] ?? $this->defaultTranslation; - $book = $query['ref'] ?? $query['b'] ?? $query['book'] ?? ''; - if (is_numeric($book) && $book > 0) - { - $book = $this->getBookName((int) $book, $segments[0]); - } - $segments[1] = $book; - - $chapter = $query['chapter'] ?? $query['c'] ?? ''; - if (strlen($chapter) && is_numeric($chapter)) - { - $segments[2] = $chapter; - } - - $verse = $query['verse'] ?? $query['v'] ?? ''; - if (strlen($verse)) - { - $segments[3] = $verse; - } - } - - // remove all values used - unset($query['view']); - unset($query['ref']); - unset($query['t']); - unset($query['version']); - unset($query['translation']); - unset($query['b']); - unset($query['book']); - unset($query['target_book']); - unset($query['c']); - unset($query['chapter']); - unset($query['verse']); - unset($query['v']); - unset($query['criteria']); - unset($query['words']); - unset($query['match']); - unset($query['case']); - unset($query['target']); - unset($query['search']); - unset($query['guid']); - - return $segments; - } - - /** - * Parse the segments of a URL. - * - * @param array &$segments The segments of the URL to parse. - * - * @return array The URL attributes to be used by the application. - * @since 3.3 - */ - public function parse(&$segments) - { - $vars = []; - $vars['view'] = 'app'; - - $key = 0; - $vars['t'] = $segments[$key] ?? ''; - - // if first value is a valid translation, we are on the app page - if ($this->validTranslation($vars['t'])) - { - $key++; - $this->setAppVars($vars, $key, $segments); - } - // if the first value is search we are on the search page - elseif ($vars['t'] === 'search') - { - $key++; - $this->setSearchVars($vars, $key, $segments); - } - // if the first api is search we are on the api page - elseif ($vars['t'] === 'api') - { - $vars['view'] = 'api'; - - // set the translation - $key++; - $this->setTranslation($vars, $key, $segments); - - $vars['ref'] = $segments[$key] ?? ''; - } - // if the first api is search we are on the api page - elseif ($vars['t'] === 'api') - { - $vars['view'] = 'api'; - - // set the translation - $key++; - $this->setTranslation($vars, $key, $segments); - - $vars['ref'] = $segments[$key] ?? ''; - } - // if the first openai is search we are on the openai page - elseif ($vars['t'] === 'openai') - { - $vars['view'] = 'openai'; - - // set the AI guid - $key++; - $vars['guid'] = $segments[$key] ?? ''; - - // set the translation - $key++; - $this->setTranslation($vars, $key, $segments); - - // set the targets - $vars['book'] = $segments[$key] ?? ''; - $key++; - $vars['chapter'] = $segments[$key] ?? ''; - $key++; - $vars['verse'] = $segments[$key] ?? ''; - $key++; - $vars['words'] = $segments[$key] ?? ''; - } - // if the first tag is search we are on the tag page - elseif ($vars['t'] === 'tag') - { - $vars['view'] = 'tag'; - - // set the translation - $key++; - $this->setTranslation($vars, $key, $segments); - - // set the Tag guid - $vars['guid'] = $segments[$key] ?? ''; - } - // if the first tag is none of the above, we are probably on the app page - else - { - $vars['t'] = $this->defaultTranslation; - $this->setAppVars($vars, $key, $segments); - } - - // always clear the segment (crazy right) - $segments = []; - - return $vars; - } - - /** - * Set the app variables - * - * @param array $vars The active variables found - * @param int $key The active key state of the segment array pointer - * @param array $segments The URL segments - * - * @return void - * @since 3.3 - */ - protected function setAppVars(array &$vars, int &$key, array $segments): void - { - $value = $segments[$key] ?? null; - - $book_number = 0; - $book_name = $this->getBook($value, $book_number, $vars['t']); - - if ($book_name !== null && $book_number > 0) - { - $vars['ref'] = $book_name; - $vars['book'] = $book_number; - $key++; - - $chapter_number = $this->getChapter($vars, $key, $segments); - $has_verses = $this->getVerses($vars, $key, $segments); - } - - $this->checkAndRedirectApiCall( - $vars, - $key, - $segments, - $book_number ?? null, - $chapter_number ?? null, - $has_verses ?? false - ); - } - - /** - * Set the Search Variables - * - * @param array $vars The active variables found - * @param int $key The active key state of the segment array pointer - * @param array $segments The URL segments - * - * @return void - * @since 3.3 - */ - protected function setSearchVars(array &$vars, int &$key, array $segments): void - { - $vars['view'] = 'search'; - - // set the translation - $this->setTranslation($vars, $key, $segments); - - // set the criteria for the search - $this->setSearchCriteria($vars, $key, $segments); - - // get the search value - $vars['search'] = $segments[$key] ?? ''; - - // check if this is an API call - if (!empty($vars['search'])) - { - $key++; - - $api_call = $segments[$key] ?? 'not_api_call'; - if ($api_call === 'get_bible.json') - { - echo '

';
-				var_dump('We have an API call!');
-				var_dump($vars);
-				exit;
-			}
-		}
-	}
-
-	/**
-	 * Retrieve book based on the value provided
-	 *
-	 * @param   mixed         $value
-	 * @param   int          &$bookNumber
-	 * @param   string|null   $translation    The book translation.
-	 *
-	 * @return  string|null
-	 * @since   3.3
-	 */
-	private function getBook($value, int &$bookNumber, ?string $translation = null): ?string
-	{
-		if (is_numeric($value))
-		{
-			$bookNumber = $value;
-
-			return $this->getBookName((int) $value, $translation);
-		}
-		elseif (!empty($value) && ($bookNumber = $this->getBookNumber($value)) !== null)
-		{
-			return $value;
-		}
-
-		return null;
-	}
-
-	/**
-	 * Retrieve chapter from the segments
-	 *
-	 * @param   array  &$vars
-	 * @param   int    &$key
-	 * @param   array  $segments
-	 *
-	 * @return  int|null
-	 * @since   3.3
-	 */
-	private function getChapter(array &$vars, int &$key, array $segments): ?int
-	{
-		$value = $segments[$key] ?? null;
-		if (!empty($value) && is_numeric($value) && $value > 0)
-		{
-			$vars['ref'] .= ' ' . $value;
-			$vars['chapter'] = $value;
-			$key++;
-
-			return (int) $value;
-		}
-
-		return null;
-	}
-
-	/**
-	 * Retrieve verses from the segments
-	 *
-	 * @param   array  &$vars
-	 * @param   int    &$key
-	 * @param   array  $segments
-	 *
-	 * @return  bool
-	 * @since   3.3
-	 */
-	private function getVerses(array &$vars, int &$key, array $segments): bool
-	{
-		$value = $segments[$key] ?? null;
-		if (!empty($value) && (is_numeric($value) || strpos($value, '-') !== false))
-		{
-			$vars['ref'] .= ':' . $value;
-			$vars['verse'] = $value;
-			$key++;
-
-			return true;
-		}
-
-		return false;
-	}
-
-	/**
-	 * Check if the request is an API call and redirect if necessary
-	 *
-	 * @param   array     $vars
-	 * @param   int       &$key
-	 * @param   array     $segments
-	 * @param   int|null  $bookNumber
-	 * @param   int|null  $chapterNumber
-	 * @param   bool      $hasVerses
-	 *
-	 * @return  void
-	 * @since   3.3
-	 */
-	private function checkAndRedirectApiCall(
-		array $vars, int $key, array $segments,
-		?int $bookNumber, ?int $chapterNumber, bool $hasVerses): void
-	{
-		$apiCall = $segments[$key] ?? 'not_api_call';
-		if ($apiCall === 'get_bible.json')
-		{
-			if ($hasVerses)
-			{
-				header("Location: https://query.getbible.net/v2/{$vars['t']}/{$vars['ref']}");
-				exit;
-			}
-			elseif (!empty($bookNumber) && !empty($chapterNumber))
-			{
-				header("Location: https://api.getbible.net/v2/{$vars['t']}/$bookNumber/$chapterNumber.json");
-				exit;
-			}
-			elseif (!empty($bookNumber))
-			{
-				header("Location: https://api.getbible.net/v2/{$vars['t']}/$bookNumber.json");
-				exit;
-			}
-			else
-			{
-				header("Location: https://api.getbible.net/v2/{$vars['t']}.json");
-				exit;
-			}
-		}
-	}
-
-	/**
-	 * Set The Translation
-	 *
-	 * @param   array  $vars     The active variables found
-	 * @param   int    $key      The active key state of the segment array pointer
-	 * @param   array  $segments The URL segments
-	 *
-	 * @return  void
-	 * @since   3.3
-	 */
-	private function setTranslation(array &$vars, int &$key, array $segments): void
-	{
-		$vars['t'] = $segments[$key] ?? $this->defaultTranslation;
-
-		if ($this->validTranslation($vars['t']))
-		{
-			$key++;
-		}
-		else
-		{
-			$vars['t'] = $this->defaultTranslation;
-		}
-	}
-
-	/**
-	 * Set The Search Criteria
-	 *
-	 * @param   array  $vars     The active variables found
-	 * @param   int    $key      The active key state of the segment array pointer
-	 * @param   array  $segments The URL segments
-	 *
-	 * @return  void
-	 * @since   3.3
-	 */
-	private function setSearchCriteria(array &$vars, int &$key, array $segments): void
-	{
-		// set the criteria values
-		$criteria = $segments[$key] ?? null;
-		if ($criteria === null || strpos($criteria , '-') === false)
-		{
-			// the default is greedy
-			$criteria = 'allwords-partialmatch-caseinsensitive-allbooks';
-		}
-		else
-		{
-			$key++;
-		}
-
-		/**
-		 * > words (0)
-		 * 1 = allwords, 2 = anywords, 3 = exactwords
-		 */
-		$vars['words'] = $this->criteria(
-			$criteria, 0,
-			[
-				'allwords' => 1,
-				'anywords' => 2,
-				'exactwords' => 3,
-				1 => 1, 2 => 2, 3 => 3
-			], 1);
-
-		/**
-		 * > match (1)
-		 * 1 = exactmatch, 2 = partialmatch
-		 */
-		$vars['match'] = $this->criteria(
-			$criteria, 1,
-			[
-				'exactmatch' => 1,
-				'partialmatch' => 2,
-				1 => 1, 2 => 2
-			], 2);
-
-		/**
-		 * > case (2)
-		 * 1 = caseinsensitive, 2 = casesensitive
-		 */
-		$vars['case'] = $this->criteria(
-			$criteria, 2,
-			[
-				'caseinsensitive' => 1,
-				'casesensitive' => 2,
-				1 => 1, 2 => 2
-			], 1);
-
-		/**
-		 * > target (3)
-		 * 1000 = all, 2000 = old, 3000 = new, 4000 = book_name
-		 */
-		$vars['target'] = $this->criteria(
-			$criteria, 3,
-			[
-				'allbooks' => 1000,
-				'oldtestament' => 2000,
-				'newtestament' => 3000,
-				1000 => 1000, 2000 => 2000, 3000 => 3000
-			], 4000);
-
-		/**
-		 * When we have 4000 we need to get the book name
-		 */
-		if ($vars['target'] == 4000)
-		{
-			$vars['target_book'] = $this->criteriaBook($criteria, 3);
-
-			if ($vars['target_book'] === null)
-			{
-				$vars['target'] = 1000;
-			}
-		}
-	}
-
-	/**
-	 * Get the int value of the criteria string
-	 *
-	 * @param   string  $value     The criteria string.
-	 * @param   int     $position  The criteria position.
-	 * @param   array   $criteria  The criteria target.
-	 * @param   int     $default   The criteria default.
-	 *
-	 * @return  int  The int value of the targeted criteria.
-	 * @since   3.3
-	 */
-	private function criteria(string $value, int $position, array $criteria, int $default): int
-	{
-		if (strpos($value, '-') !== false)
-		{
-			$array = explode('-', $value);
-			if (isset($array[$position]) && isset($criteria[$array[$position]]))
-			{
-				return $criteria[$array[$position]];
-			}
-		}
-
-		return $default;
-	}
-
-	/**
-	 * Get the book value from the criteria string
-	 *
-	 * @param   string  $value     The criteria string.
-	 * @param   int     $position  The criteria position.
-	 *
-	 * @return  mixed  the book value
-	 * @since   3.3
-	 */
-	private function criteriaBook(string $value, int $position)
-	{
-		if (strpos($value, '-') !== false)
-		{
-			$array = explode('-', $value);
-			if (isset($array[$position]))
-			{
-				return $array[$position];
-			}
-		}
-
-		return null;
-	}
-
-	/**
-	 * Get the string value of the criteria int
-	 *
-	 * @param   string  $value     The criteria string.
-	 * @param   int     $position  The criteria position.
-	 * @param   array   $criteria  The criteria target.
-	 * @param   int     $default   The criteria default.
-	 *
-	 * @return  string  The string value of the targeted criteria.
-	 * @since   3.3
-	 */
-	private function criteriaString(string $value, int $position, array $criteria, string $default): string
-	{
-		if (strpos($value, '-') !== false)
-		{
-			$array = explode('-', $value);
-			if (isset($array[$position]) && isset($criteria[$array[$position]]))
-			{
-				return $criteria[$array[$position]];
-			}
-		}
-
-		return $default;
-	}
-
-	/**
-	 * Get a Book number
-	 *
-	 * @param   string  $value   The book name.
-	 *
-	 * @return  int|null  The book number
-	 * @since   3.3
-	 */
-	private function getBookNumber(string $name): ?int
-	{
-		if (($number = GetHelper::var('book', $name, 'name', 'nr')) !== null
-			&& $number > 0)
-		{
-			return $number;
-		}
-
-		return null;
-	}
-
-	/**
-	 * Get a Book name
-	 *
-	 * @param   int           $value          The book number.
-	 * @param   string|null   $translation    The book translation.
-	 *
-	 * @return  string|null  The book name
-	 * @since   3.3
-	 */
-	private function getBookName(int $value, ?string $translation = null): ?string
-	{
-		if (!empty($translation) && is_numeric($value) && $value > 0)
-		{
-			// Create a new query object.
-			$query = $this->db->getQuery(true);
-			$query->select($this->db->quoteName('name'));
-			$query->from($this->db->quoteName('#__getbible_book'));
-			$query->where($this->db->quoteName('nr') . ' = '. (int) $value);
-			$query->where($this->db->quoteName('abbreviation') . ' = ' . $this->db->quote((string) $translation));
-			$this->db->setQuery($query);
-			$this->db->execute();
-			if ($this->db->getNumRows())
-			{
-				return $this->db->loadResult();
-			}
-		}
-
-		if (($name = GetHelper::var('book', $value, 'nr', 'name')) !== null)
-		{
-			return $name;
-		}
-
-		return null;
-	}
-
-	/**
-	 * Validate if this is a active translation
-	 *
-	 * @param   string  $value     The criteria string.
-	 *
-	 * @return  bool  True if its a valid translation
-	 * @since   3.3
-	 */
-	private function validTranslation(string $value): bool
-	{
-		if (strlen($value) > 0)
-		{
-			if (($published = GetHelper::var('translation', $value, 'abbreviation', 'published')) !== null
-				&& $published == 1)
-			{
-				return true;
-			}
-		}
-
-		return false;
-	}
 }
diff --git a/site/tmpl/app/default_getbiblebooks.php b/site/tmpl/app/default_getbiblebooks.php
index 209286c..5d260ee 100644
--- a/site/tmpl/app/default_getbiblebooks.php
+++ b/site/tmpl/app/default_getbiblebooks.php
@@ -28,11 +28,11 @@ defined('_JEXEC') or die;
 		
nr !== $this->chapter->book_nr): ?> - + name; ?> - + name; ?> diff --git a/site/tmpl/app/default_getbiblechapters.php b/site/tmpl/app/default_getbiblechapters.php index 41893b0..74b8a63 100644 --- a/site/tmpl/app/default_getbiblechapters.php +++ b/site/tmpl/app/default_getbiblechapters.php @@ -28,11 +28,11 @@ defined('_JEXEC') or die;
chapter !== $this->chapter->chapter): ?> - + chapter; ?> - + chapter; ?> diff --git a/site/tmpl/app/default_getbibletranslations.php b/site/tmpl/app/default_getbibletranslations.php index 76e0fa5..5c99851 100644 --- a/site/tmpl/app/default_getbibletranslations.php +++ b/site/tmpl/app/default_getbibletranslations.php @@ -24,7 +24,7 @@ defined('_JEXEC') or die; ?> defaultTranslation)): ?> - + defaultTranslation->translation; ?> (defaultTranslation->abbreviation; ?>) @@ -39,11 +39,11 @@ defined('_JEXEC') or die;
abbreviation !== $this->chapter->abbreviation): ?> - + translation; ?> (abbreviation; ?>) - + translation; ?> (abbreviation; ?>) diff --git a/update_server.xml b/update_server.xml index c80d7b9..566857b 100644 --- a/update_server.xml +++ b/update_server.xml @@ -23,17 +23,17 @@ pkg_getbible package site - 5.0.0 + 4.0.0 https://getbible.net - https://git.vdm.dev/api/v1/repos/getBible/joomla-pkg/archive/v5.0.0.zip + https://git.vdm.dev/api/v1/repos/getBible/joomla-pkg/archive/v4.0.7.zip beta Llewellyn van der Merwe https://getbible.net - + Get Bible @@ -41,17 +41,17 @@ pkg_getbible package site - 5.0.1 + 4.0.1 https://getbible.net - https://git.vdm.dev/api/v1/repos/getBible/joomla-pkg/archive/v5.0.1.zip + https://git.vdm.dev/api/v1/repos/getBible/joomla-pkg/archive/v4.0.7.zip stable Llewellyn van der Merwe https://getbible.net - + Get Bible @@ -59,17 +59,17 @@ pkg_getbible package site - 5.0.2 + 4.0.2 https://getbible.net - https://git.vdm.dev/api/v1/repos/getBible/joomla-pkg/archive/v5.0.2.zip + https://git.vdm.dev/api/v1/repos/getBible/joomla-pkg/archive/v4.0.7.zip stable Llewellyn van der Merwe https://getbible.net - + Get Bible @@ -77,17 +77,17 @@ pkg_getbible package site - 5.0.3 + 4.0.3 https://getbible.net - https://git.vdm.dev/api/v1/repos/getBible/joomla-pkg/archive/v5.0.3.zip + https://git.vdm.dev/api/v1/repos/getBible/joomla-pkg/archive/v4.0.7.zip stable Llewellyn van der Merwe https://getbible.net - + Get Bible @@ -95,17 +95,17 @@ pkg_getbible package site - 5.0.4 + 4.0.4 https://getbible.net - https://git.vdm.dev/api/v1/repos/getBible/joomla-pkg/archive/v5.0.4.zip + https://git.vdm.dev/api/v1/repos/getBible/joomla-pkg/archive/v4.0.7.zip stable Llewellyn van der Merwe https://getbible.net - + Get Bible @@ -113,17 +113,17 @@ pkg_getbible package site - 5.0.5 + 4.0.5 https://getbible.net - https://git.vdm.dev/api/v1/repos/getBible/joomla-pkg/archive/v5.0.5.zip + https://git.vdm.dev/api/v1/repos/getBible/joomla-pkg/archive/v4.0.7.zip stable Llewellyn van der Merwe https://getbible.net - + Get Bible @@ -131,17 +131,17 @@ pkg_getbible package site - 5.0.6 + 4.0.6 https://getbible.net - https://git.vdm.dev/api/v1/repos/getBible/joomla-pkg/archive/v5.0.6.zip + https://git.vdm.dev/api/v1/repos/getBible/joomla-pkg/archive/v4.0.7.zip stable Llewellyn van der Merwe https://getbible.net - + Get Bible @@ -149,16 +149,16 @@ pkg_getbible package site - 5.0.7 + 4.0.7 https://getbible.net - https://git.vdm.dev/api/v1/repos/getBible/joomla-pkg/archive/v5.0.7.zip + https://git.vdm.dev/api/v1/repos/getBible/joomla-pkg/archive/v4.0.7.zip stable Llewellyn van der Merwe https://getbible.net - + \ No newline at end of file