Stable release of v4.0.7

Fix missing token variable in ajax call.
This commit is contained in:
Robot 2024-03-07 18:23:34 +02:00
parent db9339b641
commit dfaab46ef2
Signed by: Robot
GPG Key ID: 14DECD44E7E1BB95
22 changed files with 99 additions and 833 deletions

View File

@ -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

View File

@ -755,7 +755,7 @@ class Com_GetbibleInstallerScript implements InstallerScriptInterface
echo '<div style="background-color: #fff;" class="alert alert-info"><a target="_blank" href="https://getbible.net" title="Get Bible">
<img src="components/com_getbible/assets/images/vdm-component.jpg"/>
</a>
<h3>Upgrade to Version 5.0.7 Was Successful! Let us know if anything is not working as expected.</h3></div>';
<h3>Upgrade to Version 4.0.7 Was Successful! Let us know if anything is not working as expected.</h3></div>';
// Add/Update component in the action logs extensions table.
$this->setActionLogsExtensions();

View File

@ -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)

View File

@ -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)

View File

@ -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 '',

View File

@ -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.

View File

@ -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;

View File

@ -1,15 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<extension type="component" version="4.0" method="upgrade">
<name>COM_GETBIBLE</name>
<creationDate>4th March, 2024</creationDate>
<creationDate>7th March, 2024</creationDate>
<author>Llewellyn van der Merwe</author>
<authorEmail>joomla@vdm.io</authorEmail>
<authorUrl>https://getbible.net</authorUrl>
<copyright>Copyright (C) 2015. All Rights Reserved</copyright>
<license>GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html</license>
<version>5.0.7</version>
<version>4.0.7</version>
<description><![CDATA[
<h1>Get Bible (v.5.0.7)</h1>
<h1>Get Bible (v.4.0.7)</h1>
<div style="clear: both;"></div>
<p>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
</administration>
<updateservers>
<server type="extension" enabled="1" element="com_getbible" name="Get Bible">https://git.vdm.dev/getBible/joomla-component/raw/branch/5.0/update_server.xml</server>
<server type="extension" enabled="1" element="com_getbible" name="Get Bible">https://git.vdm.dev/getBible/joomla-component/raw/branch/4.x/update_server.xml</server>
</updateservers>
</extension>

View File

@ -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 &&

View File

@ -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;
}

View File

@ -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 '<pre>';
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;
}
}

View File

@ -28,11 +28,11 @@ defined('_JEXEC') or die;
<div>
<div class="uk-card">
<?php if ($book->nr !== $this->chapter->book_nr): ?>
<a class="uk-button uk-button-default" href="<?php echo JRoute::_('index.php?option=com_getbible&view=app&t=' . $book->abbreviation . '&ref=' . $book->name . '&c=1&tab=chapters'); ?>">
<a class="uk-button uk-button-default" href="<?php echo \JRoute::_('index.php?option=com_getbible&view=app&t=' . $book->abbreviation . '&ref=' . $book->name . '&c=1&tab=chapters'); ?>">
<?php echo $book->name; ?>
</a>
<?php else: ?>
<a class="uk-button uk-button-default uk-active" href="<?php echo JRoute::_('index.php?option=com_getbible&view=app&t=' . $book->abbreviation . '&ref=' . $book->name . '&c=' . $this->chapter->chapter); ?>">
<a class="uk-button uk-button-default uk-active" href="<?php echo \JRoute::_('index.php?option=com_getbible&view=app&t=' . $book->abbreviation . '&ref=' . $book->name . '&c=' . $this->chapter->chapter); ?>">
<?php echo $book->name; ?>
</a>
<?php endif; ?>

View File

@ -28,11 +28,11 @@ defined('_JEXEC') or die;
<div>
<div class="uk-card">
<?php if ($chapter->chapter !== $this->chapter->chapter): ?>
<a class="uk-button uk-button-default" href="<?php echo JRoute::_('index.php?option=com_getbible&view=app&t=' . $chapter->abbreviation . '&ref=' . $chapter->book_name . '&c=' . $chapter->chapter); ?>">
<a class="uk-button uk-button-default" href="<?php echo \JRoute::_('index.php?option=com_getbible&view=app&t=' . $chapter->abbreviation . '&ref=' . $chapter->book_name . '&c=' . $chapter->chapter); ?>">
<?php echo $chapter->chapter; ?>
</a>
<?php else: ?>
<a class="uk-button uk-button-default uk-active" href="<?php echo JRoute::_('index.php?option=com_getbible&view=app&t=' . $chapter->abbreviation . '&ref=' . $chapter->book_name . '&c=' . $chapter->chapter); ?>">
<a class="uk-button uk-button-default uk-active" href="<?php echo \JRoute::_('index.php?option=com_getbible&view=app&t=' . $chapter->abbreviation . '&ref=' . $chapter->book_name . '&c=' . $chapter->chapter); ?>">
<?php echo $chapter->chapter; ?>
</a>
<?php endif; ?>

View File

@ -24,7 +24,7 @@ defined('_JEXEC') or die;
?>
<?php if (!empty($this->defaultTranslation)): ?>
<a class="uk-button uk-button-default uk-button-small uk-width-1-1" href="<?php echo JRoute::_('index.php?option=com_getbible&view=app&t=' . $this->defaultTranslation->abbreviation . '&b=' . $this->chapter->book_nr . '&c=' . $this->chapter->chapter); ?>">
<a class="uk-button uk-button-default uk-button-small uk-width-1-1" href="<?php echo \JRoute::_('index.php?option=com_getbible&view=app&t=' . $this->defaultTranslation->abbreviation . '&b=' . $this->chapter->book_nr . '&c=' . $this->chapter->chapter); ?>">
<?php echo $this->defaultTranslation->translation; ?> (<?php echo $this->defaultTranslation->abbreviation; ?>)
</a>
<?php endif; ?>
@ -39,11 +39,11 @@ defined('_JEXEC') or die;
<div class="uk-accordion-content">
<?php foreach ($translations as $translation): ?>
<?php if ($translation->abbreviation !== $this->chapter->abbreviation): ?>
<a class="uk-button uk-button-default uk-button-small uk-width-1-1 uk-margin-small-bottom" href="<?php echo JRoute::_('index.php?option=com_getbible&view=app&t=' . $translation->abbreviation . '&b=' . $this->chapter->book_nr . '&c=' . $this->chapter->chapter); ?>">
<a class="uk-button uk-button-default uk-button-small uk-width-1-1 uk-margin-small-bottom" href="<?php echo \JRoute::_('index.php?option=com_getbible&view=app&t=' . $translation->abbreviation . '&b=' . $this->chapter->book_nr . '&c=' . $this->chapter->chapter); ?>">
<?php echo $translation->translation; ?> (<?php echo $translation->abbreviation; ?>)
</a>
<?php else: ?>
<a class="uk-button uk-button-default uk-button-small uk-active uk-width-1-1 uk-margin-small-bottom" href="<?php echo JRoute::_('index.php?option=com_getbible&view=app&t=' . $translation->abbreviation . '&b=' . $this->chapter->book_nr . '&c=' . $this->chapter->chapter); ?>">
<a class="uk-button uk-button-default uk-button-small uk-active uk-width-1-1 uk-margin-small-bottom" href="<?php echo \JRoute::_('index.php?option=com_getbible&view=app&t=' . $translation->abbreviation . '&b=' . $this->chapter->book_nr . '&c=' . $this->chapter->chapter); ?>">
<?php echo $translation->translation; ?> (<?php echo $translation->abbreviation; ?>)
</a>
<?php endif; ?>

View File

@ -23,17 +23,17 @@
<element>pkg_getbible</element>
<type>package</type>
<client>site</client>
<version>5.0.0</version>
<version>4.0.0</version>
<infourl title="Get Bible!">https://getbible.net</infourl>
<downloads>
<downloadurl type="full" format="zip">https://git.vdm.dev/api/v1/repos/getBible/joomla-pkg/archive/v5.0.0.zip</downloadurl>
<downloadurl type="full" format="zip">https://git.vdm.dev/api/v1/repos/getBible/joomla-pkg/archive/v4.0.7.zip</downloadurl>
</downloads>
<tags>
<tag>beta</tag>
</tags>
<maintainer>Llewellyn van der Merwe</maintainer>
<maintainerurl>https://getbible.net</maintainerurl>
<targetplatform name="joomla" version="4\.[01234]|5\.0"/>
<targetplatform name="joomla" version="4\.[01234]"/>
</update>
<update>
<name>Get Bible</name>
@ -41,17 +41,17 @@
<element>pkg_getbible</element>
<type>package</type>
<client>site</client>
<version>5.0.1</version>
<version>4.0.1</version>
<infourl title="Get Bible!">https://getbible.net</infourl>
<downloads>
<downloadurl type="full" format="zip">https://git.vdm.dev/api/v1/repos/getBible/joomla-pkg/archive/v5.0.1.zip</downloadurl>
<downloadurl type="full" format="zip">https://git.vdm.dev/api/v1/repos/getBible/joomla-pkg/archive/v4.0.7.zip</downloadurl>
</downloads>
<tags>
<tag>stable</tag>
</tags>
<maintainer>Llewellyn van der Merwe</maintainer>
<maintainerurl>https://getbible.net</maintainerurl>
<targetplatform name="joomla" version="4\.[01234]|5\.0"/>
<targetplatform name="joomla" version="4\.[01234]"/>
</update>
<update>
<name>Get Bible</name>
@ -59,17 +59,17 @@
<element>pkg_getbible</element>
<type>package</type>
<client>site</client>
<version>5.0.2</version>
<version>4.0.2</version>
<infourl title="Get Bible!">https://getbible.net</infourl>
<downloads>
<downloadurl type="full" format="zip">https://git.vdm.dev/api/v1/repos/getBible/joomla-pkg/archive/v5.0.2.zip</downloadurl>
<downloadurl type="full" format="zip">https://git.vdm.dev/api/v1/repos/getBible/joomla-pkg/archive/v4.0.7.zip</downloadurl>
</downloads>
<tags>
<tag>stable</tag>
</tags>
<maintainer>Llewellyn van der Merwe</maintainer>
<maintainerurl>https://getbible.net</maintainerurl>
<targetplatform name="joomla" version="4\.[01234]|5\.0"/>
<targetplatform name="joomla" version="4\.[01234]"/>
</update>
<update>
<name>Get Bible</name>
@ -77,17 +77,17 @@
<element>pkg_getbible</element>
<type>package</type>
<client>site</client>
<version>5.0.3</version>
<version>4.0.3</version>
<infourl title="Get Bible!">https://getbible.net</infourl>
<downloads>
<downloadurl type="full" format="zip">https://git.vdm.dev/api/v1/repos/getBible/joomla-pkg/archive/v5.0.3.zip</downloadurl>
<downloadurl type="full" format="zip">https://git.vdm.dev/api/v1/repos/getBible/joomla-pkg/archive/v4.0.7.zip</downloadurl>
</downloads>
<tags>
<tag>stable</tag>
</tags>
<maintainer>Llewellyn van der Merwe</maintainer>
<maintainerurl>https://getbible.net</maintainerurl>
<targetplatform name="joomla" version="4\.[01234]|5\.0"/>
<targetplatform name="joomla" version="4\.[01234]"/>
</update>
<update>
<name>Get Bible</name>
@ -95,17 +95,17 @@
<element>pkg_getbible</element>
<type>package</type>
<client>site</client>
<version>5.0.4</version>
<version>4.0.4</version>
<infourl title="Get Bible!">https://getbible.net</infourl>
<downloads>
<downloadurl type="full" format="zip">https://git.vdm.dev/api/v1/repos/getBible/joomla-pkg/archive/v5.0.4.zip</downloadurl>
<downloadurl type="full" format="zip">https://git.vdm.dev/api/v1/repos/getBible/joomla-pkg/archive/v4.0.7.zip</downloadurl>
</downloads>
<tags>
<tag>stable</tag>
</tags>
<maintainer>Llewellyn van der Merwe</maintainer>
<maintainerurl>https://getbible.net</maintainerurl>
<targetplatform name="joomla" version="4\.[01234]|5\.0"/>
<targetplatform name="joomla" version="4\.[01234]"/>
</update>
<update>
<name>Get Bible</name>
@ -113,17 +113,17 @@
<element>pkg_getbible</element>
<type>package</type>
<client>site</client>
<version>5.0.5</version>
<version>4.0.5</version>
<infourl title="Get Bible!">https://getbible.net</infourl>
<downloads>
<downloadurl type="full" format="zip">https://git.vdm.dev/api/v1/repos/getBible/joomla-pkg/archive/v5.0.5.zip</downloadurl>
<downloadurl type="full" format="zip">https://git.vdm.dev/api/v1/repos/getBible/joomla-pkg/archive/v4.0.7.zip</downloadurl>
</downloads>
<tags>
<tag>stable</tag>
</tags>
<maintainer>Llewellyn van der Merwe</maintainer>
<maintainerurl>https://getbible.net</maintainerurl>
<targetplatform name="joomla" version="4\.[01234]|5\.0"/>
<targetplatform name="joomla" version="4\.[01234]"/>
</update>
<update>
<name>Get Bible</name>
@ -131,17 +131,17 @@
<element>pkg_getbible</element>
<type>package</type>
<client>site</client>
<version>5.0.6</version>
<version>4.0.6</version>
<infourl title="Get Bible!">https://getbible.net</infourl>
<downloads>
<downloadurl type="full" format="zip">https://git.vdm.dev/api/v1/repos/getBible/joomla-pkg/archive/v5.0.6.zip</downloadurl>
<downloadurl type="full" format="zip">https://git.vdm.dev/api/v1/repos/getBible/joomla-pkg/archive/v4.0.7.zip</downloadurl>
</downloads>
<tags>
<tag>stable</tag>
</tags>
<maintainer>Llewellyn van der Merwe</maintainer>
<maintainerurl>https://getbible.net</maintainerurl>
<targetplatform name="joomla" version="4\.[01234]|5\.0"/>
<targetplatform name="joomla" version="4\.[01234]"/>
</update>
<update>
<name>Get Bible</name>
@ -149,16 +149,16 @@
<element>pkg_getbible</element>
<type>package</type>
<client>site</client>
<version>5.0.7</version>
<version>4.0.7</version>
<infourl title="Get Bible!">https://getbible.net</infourl>
<downloads>
<downloadurl type="full" format="zip">https://git.vdm.dev/api/v1/repos/getBible/joomla-pkg/archive/v5.0.7.zip</downloadurl>
<downloadurl type="full" format="zip">https://git.vdm.dev/api/v1/repos/getBible/joomla-pkg/archive/v4.0.7.zip</downloadurl>
</downloads>
<tags>
<tag>stable</tag>
</tags>
<maintainer>Llewellyn van der Merwe</maintainer>
<maintainerurl>https://getbible.net</maintainerurl>
<targetplatform name="joomla" version="4\.[01234]|5\.0"/>
<targetplatform name="joomla" version="4\.[01234]"/>
</update>
</updates>