Stable release of v3.0.3

Add option to target mysql 8+ with the search regex.
This commit is contained in:
Robot 2024-02-18 23:54:30 +02:00
parent b26ab90cf1
commit 057c38f16f
Signed by: Robot
GPG Key ID: 14DECD44E7E1BB95
24 changed files with 114 additions and 30 deletions

View File

@ -1,3 +1,7 @@
# v3.0.3
- Add option to target mysql 8+ with the search regex.
# v3.0.2
- More namespace updates.

View File

@ -1,4 +1,4 @@
# Get Bible (3.0.2)
# Get Bible (3.0.3)
![Get Bible image](https://git.vdm.dev/getBible/joomla-component/raw/branch/master/admin/assets/images/vdm-component.jpg "GetBible")
@ -18,8 +18,8 @@ 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*: 10th February, 2024
+ *Version*: 3.0.2
+ *Last Build*: 18th February, 2024
+ *Version*: 3.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,8 +31,8 @@ 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*: **201645**
+ *File count*: **1714**
+ *Line count*: **201717**
+ *File count*: **1715**
+ *Folder count*: **150**
**371 Hours** or **47 Eight Hour Days** (the actual time the author spent)

View File

@ -1,4 +1,4 @@
# Get Bible (3.0.2)
# Get Bible (3.0.3)
![Get Bible image](https://git.vdm.dev/getBible/joomla-component/raw/branch/master/admin/assets/images/vdm-component.jpg "GetBible")
@ -18,8 +18,8 @@ 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*: 10th February, 2024
+ *Version*: 3.0.2
+ *Last Build*: 18th February, 2024
+ *Version*: 3.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,8 +31,8 @@ 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*: **201645**
+ *File count*: **1714**
+ *Line count*: **201717**
+ *File count*: **1715**
+ *Folder count*: **150**
**371 Hours** or **47 Eight Hour Days** (the actual time the author spent)

View File

@ -0,0 +1 @@

View File

@ -51,7 +51,7 @@ $componentParams = $this->params; // will be removed just use $this->params inst
<?php echo LayoutHelper::render('book.details_above', $this); ?>
<div class="form-horizontal">
<?php echo Html::_('bootstrap.startTabSet', 'bookTab', array('active' => 'details')); ?>
<?php echo Html::_('bootstrap.startTabSet', 'bookTab', ['active' => 'details', 'recall' => true]); ?>
<?php echo Html::_('bootstrap.addTab', 'bookTab', 'details', Text::_('COM_GETBIBLE_BOOK_DETAILS', true)); ?>
<div class="row-fluid form-horizontal-desktop">

View File

@ -51,7 +51,7 @@ $componentParams = $this->params; // will be removed just use $this->params inst
<?php echo LayoutHelper::render('chapter.details_above', $this); ?>
<div class="form-horizontal">
<?php echo Html::_('bootstrap.startTabSet', 'chapterTab', array('active' => 'details')); ?>
<?php echo Html::_('bootstrap.startTabSet', 'chapterTab', ['active' => 'details', 'recall' => true]); ?>
<?php echo Html::_('bootstrap.addTab', 'chapterTab', 'details', Text::_('COM_GETBIBLE_CHAPTER_DETAILS', true)); ?>
<div class="row-fluid form-horizontal-desktop">

View File

@ -51,7 +51,7 @@ $componentParams = $this->params; // will be removed just use $this->params inst
<?php echo LayoutHelper::render('linker.details_above', $this); ?>
<div class="form-horizontal">
<?php echo Html::_('bootstrap.startTabSet', 'linkerTab', array('active' => 'details')); ?>
<?php echo Html::_('bootstrap.startTabSet', 'linkerTab', ['active' => 'details', 'recall' => true]); ?>
<?php echo Html::_('bootstrap.addTab', 'linkerTab', 'details', Text::_('COM_GETBIBLE_LINKER_DETAILS', true)); ?>
<div class="row-fluid form-horizontal-desktop">

View File

@ -51,7 +51,7 @@ $componentParams = $this->params; // will be removed just use $this->params inst
<?php echo LayoutHelper::render('note.details_above', $this); ?>
<div class="form-horizontal">
<?php echo Html::_('bootstrap.startTabSet', 'noteTab', array('active' => 'details')); ?>
<?php echo Html::_('bootstrap.startTabSet', 'noteTab', ['active' => 'details', 'recall' => true]); ?>
<?php echo Html::_('bootstrap.addTab', 'noteTab', 'details', Text::_('COM_GETBIBLE_NOTE_DETAILS', true)); ?>
<div class="row-fluid form-horizontal-desktop">

View File

@ -51,7 +51,7 @@ $componentParams = $this->params; // will be removed just use $this->params inst
<?php echo LayoutHelper::render('open_ai_message.message_above', $this); ?>
<div class="form-horizontal">
<?php echo Html::_('bootstrap.startTabSet', 'open_ai_messageTab', array('active' => 'message')); ?>
<?php echo Html::_('bootstrap.startTabSet', 'open_ai_messageTab', ['active' => 'message', 'recall' => true]); ?>
<?php echo Html::_('bootstrap.addTab', 'open_ai_messageTab', 'message', Text::_('COM_GETBIBLE_OPEN_AI_MESSAGE_MESSAGE', true)); ?>
<div class="row-fluid form-horizontal-desktop">

View File

@ -51,7 +51,7 @@ $componentParams = $this->params; // will be removed just use $this->params inst
<?php echo LayoutHelper::render('open_ai_response.details_above', $this); ?>
<div class="form-horizontal">
<?php echo Html::_('bootstrap.startTabSet', 'open_ai_responseTab', array('active' => 'details')); ?>
<?php echo Html::_('bootstrap.startTabSet', 'open_ai_responseTab', ['active' => 'details', 'recall' => true]); ?>
<?php echo Html::_('bootstrap.addTab', 'open_ai_responseTab', 'details', Text::_('COM_GETBIBLE_OPEN_AI_RESPONSE_DETAILS', true)); ?>
<div class="row-fluid form-horizontal-desktop">

View File

@ -51,7 +51,7 @@ $componentParams = $this->params; // will be removed just use $this->params inst
<?php echo LayoutHelper::render('password.details_above', $this); ?>
<div class="form-horizontal">
<?php echo Html::_('bootstrap.startTabSet', 'passwordTab', array('active' => 'details')); ?>
<?php echo Html::_('bootstrap.startTabSet', 'passwordTab', ['active' => 'details', 'recall' => true]); ?>
<?php echo Html::_('bootstrap.addTab', 'passwordTab', 'details', Text::_('COM_GETBIBLE_PASSWORD_DETAILS', true)); ?>
<div class="row-fluid form-horizontal-desktop">

View File

@ -51,7 +51,7 @@ $componentParams = $this->params; // will be removed just use $this->params inst
<?php echo LayoutHelper::render('prompt.prompt_above', $this); ?>
<div class="form-horizontal">
<?php echo Html::_('bootstrap.startTabSet', 'promptTab', array('active' => 'prompt')); ?>
<?php echo Html::_('bootstrap.startTabSet', 'promptTab', ['active' => 'prompt', 'recall' => true]); ?>
<?php echo Html::_('bootstrap.addTab', 'promptTab', 'prompt', Text::_('COM_GETBIBLE_PROMPT_PROMPT', true)); ?>
<div class="row-fluid form-horizontal-desktop">

View File

@ -51,7 +51,7 @@ $componentParams = $this->params; // will be removed just use $this->params inst
<?php echo LayoutHelper::render('tag.details_above', $this); ?>
<div class="form-horizontal">
<?php echo Html::_('bootstrap.startTabSet', 'tagTab', array('active' => 'details')); ?>
<?php echo Html::_('bootstrap.startTabSet', 'tagTab', ['active' => 'details', 'recall' => true]); ?>
<?php echo Html::_('bootstrap.addTab', 'tagTab', 'details', Text::_('COM_GETBIBLE_TAG_DETAILS', true)); ?>
<div class="row-fluid form-horizontal-desktop">

View File

@ -51,7 +51,7 @@ $componentParams = $this->params; // will be removed just use $this->params inst
<?php echo LayoutHelper::render('tagged_verse.details_above', $this); ?>
<div class="form-horizontal">
<?php echo Html::_('bootstrap.startTabSet', 'tagged_verseTab', array('active' => 'details')); ?>
<?php echo Html::_('bootstrap.startTabSet', 'tagged_verseTab', ['active' => 'details', 'recall' => true]); ?>
<?php echo Html::_('bootstrap.addTab', 'tagged_verseTab', 'details', Text::_('COM_GETBIBLE_TAGGED_VERSE_DETAILS', true)); ?>
<div class="row-fluid form-horizontal-desktop">

View File

@ -51,7 +51,7 @@ $componentParams = $this->params; // will be removed just use $this->params inst
<?php echo LayoutHelper::render('translation.details_above', $this); ?>
<div class="form-horizontal">
<?php echo Html::_('bootstrap.startTabSet', 'translationTab', array('active' => 'details')); ?>
<?php echo Html::_('bootstrap.startTabSet', 'translationTab', ['active' => 'details', 'recall' => true]); ?>
<?php echo Html::_('bootstrap.addTab', 'translationTab', 'details', Text::_('COM_GETBIBLE_TRANSLATION_DETAILS', true)); ?>
<div class="row-fluid form-horizontal-desktop">

View File

@ -51,7 +51,7 @@ $componentParams = $this->params; // will be removed just use $this->params inst
<?php echo LayoutHelper::render('verse.details_above', $this); ?>
<div class="form-horizontal">
<?php echo Html::_('bootstrap.startTabSet', 'verseTab', array('active' => 'details')); ?>
<?php echo Html::_('bootstrap.startTabSet', 'verseTab', ['active' => 'details', 'recall' => true]); ?>
<?php echo Html::_('bootstrap.addTab', 'verseTab', 'details', Text::_('COM_GETBIBLE_VERSE_DETAILS', true)); ?>
<div class="row-fluid form-horizontal-desktop">

View File

@ -1,15 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<extension type="component" version="3.10" method="upgrade">
<name>COM_GETBIBLE</name>
<creationDate>10th February, 2024</creationDate>
<creationDate>18th February, 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>3.0.2</version>
<version>3.0.3</version>
<description><![CDATA[
<h1>Get Bible (v.3.0.2)</h1>
<h1>Get Bible (v.3.0.3)</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.

View File

@ -1546,7 +1546,7 @@ class Com_GetbibleInstallerScript
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 3.0.2 Was Successful! Let us know if anything is not working as expected.</h3></div>';
<h3>Upgrade to Version 3.0.3 Was Successful! Let us know if anything is not working as expected.</h3></div>';
// Set db if not set already.
if (!isset($db))

View File

@ -397,6 +397,14 @@ class GetbibleModelSearch extends ListModel
$conditions = [];
$case = $this->case == 2 ? 'BINARY' : ' ';
// Determine the database type and version
$db_type = $this->getDatabaseType($db); // Implement this method based on your environment
$use_modern_regex = $db_type === 'mysql' && $this->isModernMySQL($db); // Implement isModernMySQL to detect MySQL 8+
// Adjust REGEXP syntax based on the database type and version
$word_boundary_start = $use_modern_regex ? '\\b' : '[[:<:]]';
$word_boundary_end = $use_modern_regex ? '\\b' : '[[:>:]]';
// 2 = ANY WORDS
if($this->words == 2)
{
@ -436,11 +444,12 @@ class GetbibleModelSearch extends ListModel
{
if ($i == 0)
{
$condition .= $db->quote('[[:<:]]' . $db->escape($word, true). '[[:>:]]');
$condition .= $db->quote($word_boundary_start . $db->escape($word, true). $word_boundary_end);
}
else
{
$condition .= ' OR ' . $case . ' a.text REGEXP '. $db->quote('[[:<:]]' . $db->escape($word, true) . '[[:>:]]');
$condition .= ' OR ' . $case . ' a.text REGEXP '.
$db->quote($word_boundary_start . $db->escape($word, true) . $word_boundary_end);
}
$i++;
}
@ -470,7 +479,8 @@ class GetbibleModelSearch extends ListModel
{
// 1 = exact match
// For exact phrase, escape and quote the entire phrase and use REGEXP to match it exactly
$search = $case . ' a.text REGEXP ' . $db->quote('[[:<:]]' . $db->escape($this->search, true) . '[[:>:]]');
$search = $case . ' a.text REGEXP ' .
$db->quote($word_boundary_start . $db->escape($this->search, true) . $word_boundary_end);
$conditions[] = '(' . $search . ')';
}
}
@ -498,7 +508,8 @@ class GetbibleModelSearch extends ListModel
{
if ($this->hasLength($word))
{
$search = $case . ' a.text REGEXP '. $db->quote('[[:<:]]' . $db->escape($word, true) . '[[:>:]]');
$search = $case . ' a.text REGEXP '.
$db->quote($word_boundary_start . $db->escape($word, true) . $word_boundary_end);
$conditions[] = '( ' . $search . ')';
}
}
@ -662,5 +673,51 @@ class GetbibleModelSearch extends ListModel
protected function hasLength(string $word): bool
{
return GetBibleFactory::_('GetBible.Utilities.String')->hasLength($word);
}
/**
* Determines whether the database is MySQL or MariaDB.
*
* This function executes a query to fetch the version comment from the database.
* MariaDB includes its name in the version comment, allowing us to distinguish between MySQL and MariaDB.
*
* @param \JDatabaseDriver $db The database driver object from Joomla.
*
* @return string Returns 'mysql' for MySQL, 'mariadb' for MariaDB, or 'unknown' for other or undetectable types.
*/
protected function getDatabaseType($db): string
{
try {
// Attempt to get the version comment from the database
$versionComment = $db->setQuery("SELECT VERSION()")->loadResult();
if (strpos(strtolower($versionComment), 'mariadb') !== false) {
return 'mariadb';
} else {
return 'mysql'; // Assuming MySQL if MariaDB is not detected
}
} catch (\Exception $e) {
// Handle exceptions or fallback for other databases
return 'unknown';
}
}
/**
* Checks if the MySQL version is 8.0 or higher.
*
* This function queries the database version directly and compares it against 8.0
* to determine if modern MySQL features, such as enhanced regular expression syntax, can be used.
* It's specifically designed for MySQL and does not apply to MariaDB or other databases.
*
* @param \JDatabaseDriver $db The database driver object.
*
* @return bool Returns true if the MySQL version is 8.0 or higher, false otherwise.
*/
protected function isModernMySQL($db): bool
{
// Query the database for its version
$version = $db->getVersion();
// Compare the version to determine if it's modern MySQL
return version_compare($version, '8.0', '>=');
}
}

View File

@ -21,6 +21,7 @@ defined('_JEXEC') or die('Restricted access');
use Joomla\CMS\Factory;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Router\Route;
use Joomla\CMS\HTML\HTMLHelper as Html;
?>
<?php if ($this->item): ?>

View File

@ -21,6 +21,7 @@ defined('_JEXEC') or die('Restricted access');
use Joomla\CMS\Factory;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Router\Route;
use Joomla\CMS\HTML\HTMLHelper as Html;
?>
<?php if ($this->item): ?>

View File

@ -21,6 +21,7 @@ defined('_JEXEC') or die('Restricted access');
use Joomla\CMS\Factory;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Router\Route;
use Joomla\CMS\HTML\HTMLHelper as Html;
?>
<?php if ($this->params->get('activate_search') == 1): ?>

View File

@ -21,6 +21,7 @@ defined('_JEXEC') or die('Restricted access');
use Joomla\CMS\Factory;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Router\Route;
use Joomla\CMS\HTML\HTMLHelper as Html;
?>
<?php if ($this->params->get('activate_tags') == 1): ?>

View File

@ -593,4 +593,22 @@
<maintainerurl>https://getbible.net</maintainerurl>
<targetplatform name="joomla" version="3.*"/>
</update>
<update>
<name>Get Bible</name>
<description>The Bible for Joomla</description>
<element>pkg_getbible</element>
<type>package</type>
<client>site</client>
<version>3.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/v3.0.3.zip</downloadurl>
</downloads>
<tags>
<tag>stable</tag>
</tags>
<maintainer>Llewellyn van der Merwe</maintainer>
<maintainerurl>https://getbible.net</maintainerurl>
<targetplatform name="joomla" version="3.*"/>
</update>
</updates>