Release of v2.0.23

This commit is contained in:
Robot 2023-09-07 07:51:44 +02:00
parent 0a434aa6f0
commit 19bdf15fee
Signed by: Robot
GPG Key ID: 14DECD44E7E1BB95
48 changed files with 999 additions and 1269 deletions

View File

@ -1,3 +1,113 @@
# v2.0.23
- Refactored all core helper functions to make use of New classes
- Adds open ai meta data to page
- Other JCB fixes
# v2.0.22
- Fixed search redirect bug
# v2.0.21
- Adds Tags meta data to tag pages
- Adds option to share a tag
- Improve the URL creation, and return URL feature for search and tag pages
# v2.0.20
- First step to resolve getBible/support#8 so that the selection works on mobile browsers.
- Fixed the scrolling for mobiles.
# v2.0.19
- Adds metadata to each Bible page to resolve getBible/support#6
- Adds option to force chapter hash checking.
# v2.0.18
- Adds bottom module position on tag, search, ai and app pages.
- Fixed JavaScript Database Manager some more.
# v2.0.17
- Adds brut-force protection
# v2.0.16
- Fixed JavaScript Database Manager
# v2.0.15
- Adds new session option
- Adds make public switches to back-end
# v2.0.14
- Adds install mysql commands for faster queries on large systems.
- Fixes mobile layout on settings active session tab.
- Making correction to tag descriptions.
# v2.0.13
- Fix tag issues
- Adds Footable to back-end
- Fix chapter issue of app page
- Moves translations tab
# v2.0.12
- Fixes Links to Translations (to use their own book names)
# v2.0.11
- Adds better translation selection by Language
# v2.0.9
- Adds create tags on front-end.
- Adds update tags on front-end.
- Adds delete of tags on front-end.
- Improves verse view in note, and tag modal.
- Other bug fixes.
# v2.0.8
- Adds easy option to update book names in the back-end.
- Adds easy option to sync translations details in the back-end.
# v2.0.7
- Adds force update option
- Improves the book name display on Bible page
# v2.0.6
- Adds updating watchers for book names, and translation details.
- Adds edit option to owned tags
- Better session management that allows sharing sessions.
- Few bug fixes
# v2.0.5
- Adds list of default system tags
- Adds linker session manager
- Adds option to share sessions
# v2.0.4
- Added the option to set the default Translation.
- Fixed sharing of a verse, so its auto selected when verse number is clicked.
# v2.0.3
- Fixed getBible/support#2 so that the view value does not result into Undefined.
- Fixed getBible/support#3 so that empty translations and translations without the selected books better manage the mismatching query.
# v2.0.2
- Adds missing Marked JS file
# v2.0.1
- New System Architecture as to how Scripture is added
@ -8,108 +118,4 @@
- New Tagging system
- New Notes system
- New Search system
- Integration with OpenAI
# v2.0.2
- Adds missing Marked JS file
# v2.0.3
- Fixed getBible/support#2 so that the view value does not result into Undefined.
- Fixed getBible/support#3 so that empty translations and translations without the selected books better manage the mismatching query.
# v2.0.4
- Added the option to set the default Translation.
- Fixed sharing of a verse, so its auto selected when verse number is clicked.
# v2.0.5
- Adds list of default system tags
- Adds linker session manager
- Adds option to share sessions
# v2.0.6
- Adds updating watchers for book names, and translation details.
- Adds edit option to owned tags
- Better session management that allows sharing sessions.
- Few bug fixes
# v2.0.7
- Adds force update option
- Improves the book name display on Bible page
# v2.0.8
- Adds easy option to update book names in the back-end.
- Adds easy option to sync translations details in the back-end.
# v2.0.9
- Adds create tags on front-end.
- Adds update tags on front-end.
- Adds delete of tags on front-end.
- Improves verse view in note, and tag modal.
- Other bug fixes.
# v2.0.11
- Adds better translation selection by Language
# v2.0.12
- Fixes Links to Translations (to use their own book names)
# v2.0.13
- Fix tag issues
- Adds Footable to back-end
- Fix chapter issue of app page
- Moves translations tab
# v2.0.14
- Adds install mysql commands for faster queries on large systems.
- Fixes mobile layout on settings active session tab.
- Making correction to tag descriptions.
# v2.0.15
- Adds new session option
- Adds make public switches to back-end
# v2.0.16
- Fixed JavaScript Database Manager
# v2.0.17
- Adds brut-force protection
# v2.0.18
- Adds bottom module position on tag, search, ai and app pages.
- Fixed JavaScript Database Manager some more.
# v2.0.19
- Adds metadata to each Bible page to resolve getBible/support#6
- Adds option to force chapter hash checking.
# v2.0.20
- First step to resolve getBible/support#8 so that the selection works on mobile browsers.
- Fixed the scrolling for mobiles.
# v2.0.21
- Adds Tags meta data to tag pages
- Adds option to share a tag
- Improve the URL creation, and return URL feature for search and tag pages
# v2.0.22
- Fixed search redirect bug
- Integration with OpenAI

View File

@ -1,4 +1,4 @@
# Get Bible (2.0.22)
# Get Bible (2.0.23)
![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*: 21st August, 2023
+ *Version*: 2.0.22
+ *Last Build*: 7th September, 2023
+ *Version*: 2.0.23
+ *Copyright*: Copyright (C) 2015. All Rights Reserved
+ *License*: GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html
@ -31,11 +31,11 @@ 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*: **199334**
+ *File count*: **1722**
+ *Line count*: **199088**
+ *File count*: **1723**
+ *Folder count*: **163**
**367 Hours** or **45 Eight Hour Days** (the actual time the author spent)
**366 Hours** or **45 Eight Hour Days** (the actual time the author spent)
> (with the following break down:
> **debugging @139hours** = codingtime / 4;
@ -43,7 +43,7 @@ due to [Automated Component Builder](https://www.joomlacomponentbuilder.com))
> **mapping @56hours** = codingtime / 10;
> **office @93hours** = codingtime / 6;)
**923 Hours** or **115 Eight Hour Days**
**922 Hours** or **115 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**,

View File

@ -1,4 +1,4 @@
# Get Bible (2.0.22)
# Get Bible (2.0.23)
![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*: 21st August, 2023
+ *Version*: 2.0.22
+ *Last Build*: 7th September, 2023
+ *Version*: 2.0.23
+ *Copyright*: Copyright (C) 2015. All Rights Reserved
+ *License*: GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html
@ -31,11 +31,11 @@ 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*: **199334**
+ *File count*: **1722**
+ *Line count*: **199088**
+ *File count*: **1723**
+ *Folder count*: **163**
**367 Hours** or **45 Eight Hour Days** (the actual time the author spent)
**366 Hours** or **45 Eight Hour Days** (the actual time the author spent)
> (with the following break down:
> **debugging @139hours** = codingtime / 4;
@ -43,7 +43,7 @@ due to [Automated Component Builder](https://www.joomlacomponentbuilder.com))
> **mapping @56hours** = codingtime / 10;
> **office @93hours** = codingtime / 6;)
**923 Hours** or **115 Eight Hour Days**
**922 Hours** or **115 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**,

View File

@ -68,7 +68,7 @@ class GetbibleControllerBook extends FormController
return false;
}
// In the absense of better information, revert to the component permissions.
// In the absence of better information, revert to the component permissions.
return $user->authorise('book.create', $this->option);
}
@ -91,7 +91,7 @@ class GetbibleControllerBook extends FormController
// Access check.
$access = ($user->authorise('book.access', 'com_getbible.book.' . (int) $recordId) && $user->authorise('book.access', 'com_getbible'));
$access = ($user->authorise('book.access', 'com_getbible.book.' . (int) $recordId) && $user->authorise('book.access', 'com_getbible'));
if (!$access)
{
return false;

View File

@ -68,7 +68,7 @@ class GetbibleControllerChapter extends FormController
return false;
}
// In the absense of better information, revert to the component permissions.
// In the absence of better information, revert to the component permissions.
return $user->authorise('chapter.create', $this->option);
}
@ -91,7 +91,7 @@ class GetbibleControllerChapter extends FormController
// Access check.
$access = ($user->authorise('chapter.access', 'com_getbible.chapter.' . (int) $recordId) && $user->authorise('chapter.access', 'com_getbible'));
$access = ($user->authorise('chapter.access', 'com_getbible.chapter.' . (int) $recordId) && $user->authorise('chapter.access', 'com_getbible'));
if (!$access)
{
return false;

View File

@ -68,7 +68,7 @@ class GetbibleControllerLinker extends FormController
return false;
}
// In the absense of better information, revert to the component permissions.
// In the absence of better information, revert to the component permissions.
return $user->authorise('linker.create', $this->option);
}
@ -91,7 +91,7 @@ class GetbibleControllerLinker extends FormController
// Access check.
$access = ($user->authorise('linker.access', 'com_getbible.linker.' . (int) $recordId) && $user->authorise('linker.access', 'com_getbible'));
$access = ($user->authorise('linker.access', 'com_getbible.linker.' . (int) $recordId) && $user->authorise('linker.access', 'com_getbible'));
if (!$access)
{
return false;

View File

@ -68,7 +68,7 @@ class GetbibleControllerNote extends FormController
return false;
}
// In the absense of better information, revert to the component permissions.
// In the absence of better information, revert to the component permissions.
return $user->authorise('note.create', $this->option);
}
@ -91,7 +91,7 @@ class GetbibleControllerNote extends FormController
// Access check.
$access = ($user->authorise('note.access', 'com_getbible.note.' . (int) $recordId) && $user->authorise('note.access', 'com_getbible'));
$access = ($user->authorise('note.access', 'com_getbible.note.' . (int) $recordId) && $user->authorise('note.access', 'com_getbible'));
if (!$access)
{
return false;

View File

@ -68,7 +68,7 @@ class GetbibleControllerOpen_ai_message extends FormController
return false;
}
// In the absense of better information, revert to the component permissions.
// In the absence of better information, revert to the component permissions.
return $user->authorise('open_ai_message.create', $this->option);
}
@ -91,7 +91,7 @@ class GetbibleControllerOpen_ai_message extends FormController
// Access check.
$access = ($user->authorise('open_ai_message.access', 'com_getbible.open_ai_message.' . (int) $recordId) && $user->authorise('open_ai_message.access', 'com_getbible'));
$access = ($user->authorise('open_ai_message.access', 'com_getbible.open_ai_message.' . (int) $recordId) && $user->authorise('open_ai_message.access', 'com_getbible'));
if (!$access)
{
return false;

View File

@ -68,7 +68,7 @@ class GetbibleControllerOpen_ai_response extends FormController
return false;
}
// In the absense of better information, revert to the component permissions.
// In the absence of better information, revert to the component permissions.
return $user->authorise('open_ai_response.create', $this->option);
}
@ -91,7 +91,7 @@ class GetbibleControllerOpen_ai_response extends FormController
// Access check.
$access = ($user->authorise('open_ai_response.access', 'com_getbible.open_ai_response.' . (int) $recordId) && $user->authorise('open_ai_response.access', 'com_getbible'));
$access = ($user->authorise('open_ai_response.access', 'com_getbible.open_ai_response.' . (int) $recordId) && $user->authorise('open_ai_response.access', 'com_getbible'));
if (!$access)
{
return false;

View File

@ -68,7 +68,7 @@ class GetbibleControllerPassword extends FormController
return false;
}
// In the absense of better information, revert to the component permissions.
// In the absence of better information, revert to the component permissions.
return $user->authorise('password.create', $this->option);
}
@ -91,7 +91,7 @@ class GetbibleControllerPassword extends FormController
// Access check.
$access = ($user->authorise('password.access', 'com_getbible.password.' . (int) $recordId) && $user->authorise('password.access', 'com_getbible'));
$access = ($user->authorise('password.access', 'com_getbible.password.' . (int) $recordId) && $user->authorise('password.access', 'com_getbible'));
if (!$access)
{
return false;

View File

@ -68,7 +68,7 @@ class GetbibleControllerPrompt extends FormController
return false;
}
// In the absense of better information, revert to the component permissions.
// In the absence of better information, revert to the component permissions.
return $user->authorise('prompt.create', $this->option);
}
@ -91,7 +91,7 @@ class GetbibleControllerPrompt extends FormController
// Access check.
$access = ($user->authorise('prompt.access', 'com_getbible.prompt.' . (int) $recordId) && $user->authorise('prompt.access', 'com_getbible'));
$access = ($user->authorise('prompt.access', 'com_getbible.prompt.' . (int) $recordId) && $user->authorise('prompt.access', 'com_getbible'));
if (!$access)
{
return false;

View File

@ -68,7 +68,7 @@ class GetbibleControllerTag extends FormController
return false;
}
// In the absense of better information, revert to the component permissions.
// In the absence of better information, revert to the component permissions.
return $user->authorise('tag.create', $this->option);
}
@ -91,7 +91,7 @@ class GetbibleControllerTag extends FormController
// Access check.
$access = ($user->authorise('tag.access', 'com_getbible.tag.' . (int) $recordId) && $user->authorise('tag.access', 'com_getbible'));
$access = ($user->authorise('tag.access', 'com_getbible.tag.' . (int) $recordId) && $user->authorise('tag.access', 'com_getbible'));
if (!$access)
{
return false;

View File

@ -68,7 +68,7 @@ class GetbibleControllerTagged_verse extends FormController
return false;
}
// In the absense of better information, revert to the component permissions.
// In the absence of better information, revert to the component permissions.
return $user->authorise('tagged_verse.create', $this->option);
}
@ -91,7 +91,7 @@ class GetbibleControllerTagged_verse extends FormController
// Access check.
$access = ($user->authorise('tagged_verse.access', 'com_getbible.tagged_verse.' . (int) $recordId) && $user->authorise('tagged_verse.access', 'com_getbible'));
$access = ($user->authorise('tagged_verse.access', 'com_getbible.tagged_verse.' . (int) $recordId) && $user->authorise('tagged_verse.access', 'com_getbible'));
if (!$access)
{
return false;

View File

@ -68,7 +68,7 @@ class GetbibleControllerTranslation extends FormController
return false;
}
// In the absense of better information, revert to the component permissions.
// In the absence of better information, revert to the component permissions.
return $user->authorise('translation.create', $this->option);
}
@ -91,7 +91,7 @@ class GetbibleControllerTranslation extends FormController
// Access check.
$access = ($user->authorise('translation.access', 'com_getbible.translation.' . (int) $recordId) && $user->authorise('translation.access', 'com_getbible'));
$access = ($user->authorise('translation.access', 'com_getbible.translation.' . (int) $recordId) && $user->authorise('translation.access', 'com_getbible'));
if (!$access)
{
return false;

View File

@ -68,7 +68,7 @@ class GetbibleControllerVerse extends FormController
return false;
}
// In the absense of better information, revert to the component permissions.
// In the absence of better information, revert to the component permissions.
return $user->authorise('verse.create', $this->option);
}
@ -91,7 +91,7 @@ class GetbibleControllerVerse extends FormController
// Access check.
$access = ($user->authorise('verse.access', 'com_getbible.verse.' . (int) $recordId) && $user->authorise('verse.access', 'com_getbible'));
$access = ($user->authorise('verse.access', 'com_getbible.verse.' . (int) $recordId) && $user->authorise('verse.access', 'com_getbible'));
if (!$access)
{
return false;

View File

@ -70,6 +70,12 @@ use Joomla\Registry\Registry;
use Joomla\String\StringHelper;
use Joomla\Utilities\ArrayHelper;
use VDM\Joomla\GetBible\Factory;
use VDM\Joomla\Utilities\StringHelper as UtilitiesStringHelper;
use VDM\Joomla\Utilities\ObjectHelper;
use VDM\Joomla\Utilities\GetHelper;
use VDM\Joomla\Utilities\JsonHelper;
use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper;
use VDM\Joomla\Componentbuilder\Utilities\FormHelper;
/**
* Getbible component helper.
@ -78,14 +84,14 @@ abstract class GetbibleHelper
{
/**
* Composer Switch
*
*
* @var array
*/
protected static $composer = array();
/**
* The Main Active Language
*
*
* @var string
*/
public static $langTag;
@ -122,7 +128,7 @@ abstract class GetbibleHelper
if (!isset(self::$composer[$target]))
{
// get the function name
$functionName = self::safeString('compose' . $target);
$functionName = UtilitiesStringHelper::safe('compose' . $target);
// check if method exist
if (method_exists(__CLASS__, $functionName))
{
@ -144,7 +150,7 @@ abstract class GetbibleHelper
/**
* Joomla version object
*/
*/
protected static $JVersion;
/**
@ -153,7 +159,7 @@ abstract class GetbibleHelper
public static function jVersion()
{
// check if set
if (!self::checkObject(self::$JVersion))
if (!ObjectHelper::check(self::$JVersion))
{
self::$JVersion = new JVersion();
}
@ -191,8 +197,8 @@ abstract class GetbibleHelper
$link_front = '';
$link_back = '';
}
$contributors[$nr]['title'] = self::htmlEscape($params->get("titleContributor".$nr));
$contributors[$nr]['name'] = $link_front.self::htmlEscape($params->get("nameContributor".$nr)).$link_back;
$contributors[$nr]['title'] = UtilitiesStringHelper::html($params->get("titleContributor".$nr));
$contributors[$nr]['name'] = $link_front.UtilitiesStringHelper::html($params->get("nameContributor".$nr)).$link_back;
}
}
return $contributors;
@ -258,7 +264,7 @@ abstract class GetbibleHelper
}
/**
* Get a Variable
* Get a Variable
*
* @param string $table The table from which to get the variable
* @param string $where The value where
@ -268,46 +274,18 @@ abstract class GetbibleHelper
* @param string $main The component in which the table is found
*
* @return mix string/int/float
*
* @deprecated 3.3 Use GetHelper::var(...);
*/
public static function getVar($table, $where = null, $whereString = 'user', $what = 'id', $operator = '=', $main = 'getbible')
{
if(!$where)
{
$where = JFactory::getUser()->id;
}
// Get a db connection.
$db = JFactory::getDbo();
// Create a new query object.
$query = $db->getQuery(true);
$query->select($db->quoteName(array($what)));
if (empty($table))
{
$query->from($db->quoteName('#__'.$main));
}
else
{
$query->from($db->quoteName('#__'.$main.'_'.$table));
}
if (is_numeric($where))
{
$query->where($db->quoteName($whereString) . ' '.$operator.' '.(int) $where);
}
elseif (is_string($where))
{
$query->where($db->quoteName($whereString) . ' '.$operator.' '. $db->quote((string)$where));
}
else
{
return false;
}
$db->setQuery($query);
$db->execute();
if ($db->getNumRows())
{
return $db->loadResult();
}
return false;
return GetHelper::var(
$table,
$where,
$whereString,
$what,
$operator,
$main
);
}
/**
@ -322,110 +300,38 @@ abstract class GetbibleHelper
* @param bool $unique The switch to return a unique array
*
* @return array
*
* @deprecated 3.3 Use GetHelper::vars(...);
*/
public static function getVars($table, $where = null, $whereString = 'user', $what = 'id', $operator = 'IN', $main = 'getbible', $unique = true)
{
if(!$where)
{
$where = JFactory::getUser()->id;
}
if (!self::checkArray($where) && $where > 0)
{
$where = array($where);
}
if (self::checkArray($where))
{
// prep main <-- why? well if $main='' is empty then $table can be categories or users
if (self::checkString($main))
{
$main = '_'.ltrim($main, '_');
}
// Get a db connection.
$db = JFactory::getDbo();
// Create a new query object.
$query = $db->getQuery(true);
$query->select($db->quoteName(array($what)));
if (empty($table))
{
$query->from($db->quoteName('#__'.$main));
}
else
{
$query->from($db->quoteName('#_'.$main.'_'.$table));
}
// add strings to array search
if ('IN_STRINGS' === $operator || 'NOT IN_STRINGS' === $operator)
{
$query->where($db->quoteName($whereString) . ' ' . str_replace('_STRINGS', '', $operator) . ' ("' . implode('","',$where) . '")');
}
else
{
$query->where($db->quoteName($whereString) . ' ' . $operator . ' (' . implode(',',$where) . ')');
}
$db->setQuery($query);
$db->execute();
if ($db->getNumRows())
{
if ($unique)
{
return array_unique($db->loadColumn());
}
return $db->loadColumn();
}
}
return false;
return GetHelper::vars(
$table,
$where,
$whereString,
$what,
$operator,
$main,
$unique
);
}
/**
* Convert a json object to a string
*
* @input string $value The json string to convert
*
* @returns a string
* @deprecated 3.3 Use JsonHelper::string(...);
*/
public static function jsonToString($value, $sperator = ", ", $table = null, $id = 'id', $name = 'name')
{
// do some table foot work
$external = false;
if (strpos($table, '#__') !== false)
{
$external = true;
$table = str_replace('#__', '', $table);
}
// check if string is JSON
$result = json_decode($value, true);
if (json_last_error() === JSON_ERROR_NONE)
{
// is JSON
if (self::checkArray($result))
{
if (self::checkString($table))
{
$names = array();
foreach ($result as $val)
{
if ($external)
{
if ($_name = self::getVar(null, $val, $id, $name, '=', $table))
{
$names[] = $_name;
}
}
else
{
if ($_name = self::getVar($table, $val, $id, $name))
{
$names[] = $_name;
}
}
}
if (self::checkArray($names))
{
return (string) implode($sperator,$names);
}
}
return (string) implode($sperator,$result);
}
return (string) json_decode($value);
}
return $value;
return JsonHelper::string(
$value,
$sperator,
$table,
$id,
$name
);
}
public static function isPublished($id,$type)
@ -478,12 +384,12 @@ abstract class GetbibleHelper
* @param object $user The user whose permissions we are loading
*
* @return object The JObject of permission/authorised actions
*
*
*/
public static function getActions($view, &$record = null, $views = null, $target = null, $component = 'getbible', $user = 'null')
{
// load the user if not given
if (!self::checkObject($user))
if (!ObjectHelper::check($user))
{
// get the user object
$user = JFactory::getUser();
@ -491,10 +397,10 @@ abstract class GetbibleHelper
// load the JObject
$result = new JObject;
// make view name safe (just incase)
$view = self::safeString($view);
if (self::checkString($views))
$view = UtilitiesStringHelper::safe($view);
if (UtilitiesStringHelper::check($views))
{
$views = self::safeString($views);
$views = UtilitiesStringHelper::safe($views);
}
// get all actions from component
$actions = JAccess::getActionsFromFile(
@ -507,9 +413,9 @@ abstract class GetbibleHelper
return $result;
}
// get created by if not found
if (self::checkObject($record) && !isset($record->created_by) && isset($record->id))
if (ObjectHelper::check($record) && !isset($record->created_by) && isset($record->id))
{
$record->created_by = self::getVar($view, $record->id, 'id', 'created_by', '=', $component);
$record->created_by = GetHelper::var($view, $record->id, 'id', 'created_by', '=', $component);
}
// set actions only set in component settings
$componentActions = array('core.admin', 'core.manage', 'core.options', 'core.export');
@ -518,12 +424,12 @@ abstract class GetbibleHelper
if ($target)
{
// convert to an array
if (self::checkString($target))
if (UtilitiesStringHelper::check($target))
{
$target = array($target);
}
// check if we are good to go
if (self::checkArray($target))
if (UtilitiesArrayHelper::check($target))
{
$checkTarget = true;
}
@ -544,7 +450,7 @@ abstract class GetbibleHelper
// set area
$area = 'comp';
// check if the record has an ID and the action is item related (not a component action)
if (self::checkObject($record) && isset($record->id) && $record->id > 0 && !in_array($action->name, $componentActions) &&
if (ObjectHelper::check($record) && isset($record->id) && $record->id > 0 && !in_array($action->name, $componentActions) &&
(strpos($action->name, 'core.') !== false || strpos($action->name, $view . '.') !== false))
{
// we are in item
@ -577,7 +483,7 @@ abstract class GetbibleHelper
}
}
}
elseif (self::checkString($views) && isset($record->catid) && $record->catid > 0)
elseif (UtilitiesStringHelper::check($views) && isset($record->catid) && $record->catid > 0)
{
// we are in item
$area = 'category';
@ -649,7 +555,7 @@ abstract class GetbibleHelper
* @param array $targets The array of target actions
*
* @return boolean true if action should be filtered out
*
*
*/
protected static function filterActions(&$view, &$action, &$targets)
{
@ -671,13 +577,13 @@ abstract class GetbibleHelper
public static function getModel($name, $path = JPATH_COMPONENT_ADMINISTRATOR, $Component = 'Getbible', $config = array())
{
// fix the name
$name = self::safeString($name);
$name = UtilitiesStringHelper::safe($name);
// full path to models
$fullPathModels = $path . '/models';
// load the model file
JModelLegacy::addIncludePath($fullPathModels, $Component . 'Model');
// make sure the table path is loaded
if (!isset($config['table_path']) || !self::checkString($config['table_path']))
if (!isset($config['table_path']) || !UtilitiesStringHelper::check($config['table_path']))
{
// This is the JCB default path to tables in Joomla 3.x
$config['table_path'] = JPATH_ADMINISTRATOR . '/components/com_' . strtolower($Component) . '/tables';
@ -720,7 +626,7 @@ abstract class GetbibleHelper
{
$parent = JTable::getInstance('Asset');
$parent->loadByName('com_getbible');
$parentId = $parent->id;
$name = 'com_getbible.'.$table.'.'.$id;
$title = '';
@ -840,35 +746,12 @@ abstract class GetbibleHelper
* @param SimpleXMLElement $xml The XML element reference in which to inject a comment
* @param mixed $node A SimpleXMLElement node to append to the XML element reference, or a stdClass object containing a comment attribute to be injected before the XML node and a fieldXML attribute containing a SimpleXMLElement
*
* @return null
*
* @return void
* @deprecated 3.3 Use FormHelper::append($xml, $node);
*/
public static function xmlAppend(&$xml, $node)
{
if (!$node)
{
// element was not returned
return;
}
switch (get_class($node))
{
case 'stdClass':
if (property_exists($node, 'comment'))
{
self::xmlComment($xml, $node->comment);
}
if (property_exists($node, 'fieldXML'))
{
self::xmlAppend($xml, $node->fieldXML);
}
break;
case 'SimpleXMLElement':
$domXML = dom_import_simplexml($xml);
$domNode = dom_import_simplexml($node);
$domXML->appendChild($domXML->ownerDocument->importNode($domNode, true));
$xml = simplexml_import_dom($domXML);
break;
}
FormHelper::append($xml, $node);
}
/**
@ -877,16 +760,12 @@ abstract class GetbibleHelper
* @param SimpleXMLElement $xml The XML element reference in which to inject a comment
* @param string $comment The comment to inject
*
* @return null
*
* @return void
* @deprecated 3.3 Use FormHelper::comment($xml, $comment);
*/
public static function xmlComment(&$xml, $comment)
{
$domXML = dom_import_simplexml($xml);
$domComment = new DOMComment($comment);
$nodeTarget = $domXML->ownerDocument->importNode($domComment, true);
$domXML->appendChild($nodeTarget);
$xml = simplexml_import_dom($domXML);
FormHelper::comment($xml, $comment);
}
/**
@ -896,14 +775,11 @@ abstract class GetbibleHelper
* @param array $attributes The attributes to apply to the XML element
*
* @return null
*
* @deprecated 3.3 Use FormHelper::attributes($xml, $attributes);
*/
public static function xmlAddAttributes(&$xml, $attributes = array())
{
foreach ($attributes as $key => $value)
{
$xml->addAttribute($key, $value);
}
FormHelper::attributes($xml, $attributes);
}
/**
@ -913,16 +789,11 @@ abstract class GetbibleHelper
* @param array $options The options to apply to the XML element
*
* @return void
*
* @deprecated 3.3 Use FormHelper::options($xml, $options);
*/
public static function xmlAddOptions(&$xml, $options = array())
{
foreach ($options as $key => $value)
{
$addOption = $xml->addChild('option');
$addOption->addAttribute('value', $key);
$addOption[] = $value;
}
FormHelper::options($xml, $options);
}
/**
@ -933,28 +804,11 @@ abstract class GetbibleHelper
* @param array $options The options to apply to the XML element
*
* @return object
*
* @deprecated 3.3 Use FormHelper::field($attributes, $default, $options);
*/
public static function getFieldObject(&$attributes, $default = '', $options = null)
{
// make sure we have attributes and a type value
if (self::checkArray($attributes) && isset($attributes['type']))
{
// make sure the form helper class is loaded
if (!method_exists('JFormHelper', 'loadFieldType'))
{
jimport('joomla.form.form');
}
// get field type
$field = JFormHelper::loadFieldType($attributes['type'], true);
// get field xml
$XML = self::getFieldXML($attributes, $options);
// setup the field
$field->setup($XML, $default);
// return the field object
return $field;
}
return false;
return FormHelper::field($attributes, $default, $options);
}
/**
@ -964,27 +818,11 @@ abstract class GetbibleHelper
* @param array $options The options to apply to the XML element
*
* @return object
*
* @deprecated 3.3 Use FormHelper::xml($attributes, $options);
*/
public static function getFieldXML(&$attributes, $options = null)
{
// make sure we have attributes and a type value
if (self::checkArray($attributes))
{
// start field xml
$XML = new SimpleXMLElement('<field/>');
// load the attributes
self::xmlAddAttributes($XML, $attributes);
// check if we have options
if (self::checkArray($options))
{
// load the options
self::xmlAddOptions($XML, $options);
}
// return the field xml
return $XML;
}
return false;
return FormHelper::xml($attributes, $options);
}
/**
@ -1008,17 +846,17 @@ abstract class GetbibleHelper
// button attributes
$buttonAttributes = array(
'type' => 'radio',
'name' => isset($args[0]) ? self::htmlEscape($args[0]) : 'bool_button',
'label' => isset($args[0]) ? self::safeString(self::htmlEscape($args[0]), 'Ww') : 'Bool Button', // not seen anyway
'name' => isset($args[0]) ? UtilitiesStringHelper::html($args[0]) : 'bool_button',
'label' => isset($args[0]) ? UtilitiesStringHelper::safe(UtilitiesStringHelper::html($args[0]), 'Ww') : 'Bool Button', // not seen anyway
'class' => 'btn-group',
'filter' => 'INT',
'default' => isset($args[2]) ? (int) $args[2] : 0);
// set the button options
$buttonOptions = array(
'1' => isset($args[3]) ? self::htmlEscape($args[3]) : 'JYES',
'0' => isset($args[4]) ? self::htmlEscape($args[4]) : 'JNO');
'1' => isset($args[3]) ? UtilitiesStringHelper::html($args[3]) : 'JYES',
'0' => isset($args[4]) ? UtilitiesStringHelper::html($args[4]) : 'JNO');
// return the input
return self::getFieldObject($buttonAttributes, $buttonAttributes['default'], $buttonOptions)->input;
return FormHelper::field($buttonAttributes, $buttonAttributes['default'], $buttonOptions)->input;
}
/**
@ -1027,15 +865,11 @@ abstract class GetbibleHelper
* @input string The json string to check
*
* @returns bool true on success
* @deprecated 3.3 Use JsonHelper::check($string);
*/
public static function checkJson($string)
{
if (self::checkString($string))
{
json_decode($string);
return (json_last_error() === JSON_ERROR_NONE);
}
return false;
return JsonHelper::check($string);
}
/**
@ -1044,14 +878,11 @@ abstract class GetbibleHelper
* @input object The object to check
*
* @returns bool true on success
* @deprecated 3.3 Use ObjectHelper::check($object);
*/
public static function checkObject($object)
{
if (isset($object) && is_object($object))
{
return count((array)$object) > 0;
}
return false;
return ObjectHelper::check($object);
}
/**
@ -1060,26 +891,11 @@ abstract class GetbibleHelper
* @input array The array to check
*
* @returns bool/int number of items in array on success
* @deprecated 3.3 Use UtilitiesArrayHelper::check($array, $removeEmptyString);
*/
public static function checkArray($array, $removeEmptyString = false)
{
if (isset($array) && is_array($array) && ($nr = count((array)$array)) > 0)
{
// also make sure the empty strings are removed
if ($removeEmptyString)
{
foreach ($array as $key => $string)
{
if (empty($string))
{
unset($array[$key]);
}
}
return self::checkArray($array, false);
}
return $nr;
}
return false;
return UtilitiesArrayHelper::check($array, $removeEmptyString);
}
/**
@ -1088,14 +904,11 @@ abstract class GetbibleHelper
* @input string The string to check
*
* @returns bool true on success
* @deprecated 3.3 Use UtilitiesStringHelper::check($string);
*/
public static function checkString($string)
{
if (isset($string) && is_string($string) && strlen($string) > 0)
{
return true;
}
return false;
return UtilitiesStringHelper::check($string);
}
/**
@ -1107,7 +920,7 @@ abstract class GetbibleHelper
public static function isConnected()
{
// If example.com is down, then probably the whole internet is down, since IANA maintains the domain. Right?
$connected = @fsockopen("www.example.com", 80);
$connected = @fsockopen("www.example.com", 80);
// website, port (try 80 or 443)
if ($connected)
{
@ -1129,22 +942,11 @@ abstract class GetbibleHelper
* @input array The arrays you would like to merge
*
* @returns array on success
* @deprecated 3.3 Use UtilitiesArrayHelper::merge($arrays);
*/
public static function mergeArrays($arrays)
{
if(self::checkArray($arrays))
{
$arrayBuket = array();
foreach ($arrays as $array)
{
if (self::checkArray($array))
{
$arrayBuket = array_merge($arrayBuket, $array);
}
}
return $arrayBuket;
}
return false;
return UtilitiesArrayHelper::merge($arrays);
}
// typo sorry!
@ -1159,39 +961,11 @@ abstract class GetbibleHelper
* @input string The you would like to shorten
*
* @returns string on success
* @deprecated 3.3 Use UtilitiesStringHelper::shorten(...);
*/
public static function shorten($string, $length = 40, $addTip = true)
{
if (self::checkString($string))
{
$initial = strlen($string);
$words = preg_split('/([\s\n\r]+)/', $string, null, PREG_SPLIT_DELIM_CAPTURE);
$words_count = count((array)$words);
$word_length = 0;
$last_word = 0;
for (; $last_word < $words_count; ++$last_word)
{
$word_length += strlen($words[$last_word]);
if ($word_length > $length)
{
break;
}
}
$newString = implode(array_slice($words, 0, $last_word));
$final = strlen($newString);
if ($initial != $final && $addTip)
{
$title = self::shorten($string, 400 , false);
return '<span class="hasTip" title="'.$title.'" style="cursor:help">'.trim($newString).'...</span>';
}
elseif ($initial != $final && !$addTip)
{
return trim($newString).'...';
}
}
return $string;
return UtilitiesStringHelper::shorten($string, $length, $addTip);
}
/**
@ -1200,157 +974,61 @@ abstract class GetbibleHelper
* @input string The you would like to make safe
*
* @returns string on success
* @deprecated 3.3 Use UtilitiesStringHelper::safe(...);
*/
public static function safeString($string, $type = 'L', $spacer = '_', $replaceNumbers = true, $keepOnlyCharacters = true)
{
if ($replaceNumbers === true)
{
// remove all numbers and replace with english text version (works well only up to millions)
$string = self::replaceNumbers($string);
}
// 0nly continue if we have a string
if (self::checkString($string))
{
// create file name without the extention that is safe
if ($type === 'filename')
{
// make sure VDM is not in the string
$string = str_replace('VDM', 'vDm', $string);
// Remove anything which isn't a word, whitespace, number
// or any of the following caracters -_()
// If you don't need to handle multi-byte characters
// you can use preg_replace rather than mb_ereg_replace
// Thanks @Łukasz Rysiak!
// $string = mb_ereg_replace("([^\w\s\d\-_\(\)])", '', $string);
$string = preg_replace("([^\w\s\d\-_\(\)])", '', $string);
// http://stackoverflow.com/a/2021729/1429677
return preg_replace('/\s+/', ' ', $string);
}
// remove all other characters
$string = trim($string);
$string = preg_replace('/'.$spacer.'+/', ' ', $string);
$string = preg_replace('/\s+/', ' ', $string);
// Transliterate string
$string = self::transliterate($string);
// remove all and keep only characters
if ($keepOnlyCharacters)
{
$string = preg_replace("/[^A-Za-z ]/", '', $string);
}
// keep both numbers and characters
else
{
$string = preg_replace("/[^A-Za-z0-9 ]/", '', $string);
}
// select final adaptations
if ($type === 'L' || $type === 'strtolower')
{
// replace white space with underscore
$string = preg_replace('/\s+/', $spacer, $string);
// default is to return lower
return strtolower($string);
}
elseif ($type === 'W')
{
// return a string with all first letter of each word uppercase(no undersocre)
return ucwords(strtolower($string));
}
elseif ($type === 'w' || $type === 'word')
{
// return a string with all lowercase(no undersocre)
return strtolower($string);
}
elseif ($type === 'Ww' || $type === 'Word')
{
// return a string with first letter of the first word uppercase and all the rest lowercase(no undersocre)
return ucfirst(strtolower($string));
}
elseif ($type === 'WW' || $type === 'WORD')
{
// return a string with all the uppercase(no undersocre)
return strtoupper($string);
}
elseif ($type === 'U' || $type === 'strtoupper')
{
// replace white space with underscore
$string = preg_replace('/\s+/', $spacer, $string);
// return all upper
return strtoupper($string);
}
elseif ($type === 'F' || $type === 'ucfirst')
{
// replace white space with underscore
$string = preg_replace('/\s+/', $spacer, $string);
// return with first caracter to upper
return ucfirst(strtolower($string));
}
elseif ($type === 'cA' || $type === 'cAmel' || $type === 'camelcase')
{
// convert all words to first letter uppercase
$string = ucwords(strtolower($string));
// remove white space
$string = preg_replace('/\s+/', '', $string);
// now return first letter lowercase
return lcfirst($string);
}
// return string
return $string;
}
// not a string
return '';
return UtilitiesStringHelper::safe(
$string,
$type,
$spacer,
$replaceNumbers,
$keepOnlyCharacters
);
}
/**
* Convert none English strings to code usable string
*
* @input an string
*
* @returns a string
* @deprecated 3.3 Use UtilitiesStringHelper::transliterate($string);
*/
public static function transliterate($string)
{
// set tag only once
if (!self::checkString(self::$langTag))
{
// get global value
self::$langTag = JComponentHelper::getParams('com_getbible')->get('language', 'en-GB');
}
// Transliterate on the language requested
$lang = Language::getInstance(self::$langTag);
return $lang->transliterate($string);
return UtilitiesStringHelper::transliterate($string);
}
/**
* make sure a string is HTML save
*
* @input an html string
*
* @returns a string
* @deprecated 3.3 Use UtilitiesStringHelper::html(...);
*/
public static function htmlEscape($var, $charset = 'UTF-8', $shorten = false, $length = 40)
{
if (self::checkString($var))
{
$filter = new JFilterInput();
$string = $filter->clean(html_entity_decode(htmlentities($var, ENT_COMPAT, $charset)), 'HTML');
if ($shorten)
{
return self::shorten($string,$length);
}
return $string;
}
else
{
return '';
}
return UtilitiesStringHelper::html(
$var,
$charset,
$shorten,
$length
);
}
/**
* Convert all int in a string to an English word string
*
* @input an string with numbers
*
* @returns a string
* @deprecated 3.3 Use UtilitiesStringHelper::numbers($string);
*/
public static function replaceNumbers($string)
{
// set numbers array
$numbers = array();
// first get all numbers
preg_match_all('!\d+!', $string, $numbers);
// check if we have any numbers
if (isset($numbers[0]) && self::checkArray($numbers[0]))
{
foreach ($numbers[0] as $number)
{
$searchReplace[$number] = self::numberToString((int)$number);
}
// now replace numbers in string
$string = str_replace(array_keys($searchReplace), array_values($searchReplace),$string);
// check if we missed any, strange if we did.
return self::replaceNumbers($string);
}
// return the string with no numbers remaining.
return $string;
return UtilitiesStringHelper::numbers($string);
}
/**
@ -1359,107 +1037,21 @@ abstract class GetbibleHelper
*
* @input an int
* @returns a string
* @deprecated 3.3 Use UtilitiesStringHelper::number($x);
*/
public static function numberToString($x)
{
$nwords = array( "zero", "one", "two", "three", "four", "five", "six", "seven",
"eight", "nine", "ten", "eleven", "twelve", "thirteen",
"fourteen", "fifteen", "sixteen", "seventeen", "eighteen",
"nineteen", "twenty", 30 => "thirty", 40 => "forty",
50 => "fifty", 60 => "sixty", 70 => "seventy", 80 => "eighty",
90 => "ninety" );
if(!is_numeric($x))
{
$w = $x;
}
elseif(fmod($x, 1) != 0)
{
$w = $x;
}
else
{
if($x < 0)
{
$w = 'minus ';
$x = -$x;
}
else
{
$w = '';
// ... now $x is a non-negative integer.
}
if($x < 21) // 0 to 20
{
$w .= $nwords[$x];
}
elseif($x < 100) // 21 to 99
{
$w .= $nwords[10 * floor($x/10)];
$r = fmod($x, 10);
if($r > 0)
{
$w .= ' '. $nwords[$r];
}
}
elseif($x < 1000) // 100 to 999
{
$w .= $nwords[floor($x/100)] .' hundred';
$r = fmod($x, 100);
if($r > 0)
{
$w .= ' and '. self::numberToString($r);
}
}
elseif($x < 1000000) // 1000 to 999999
{
$w .= self::numberToString(floor($x/1000)) .' thousand';
$r = fmod($x, 1000);
if($r > 0)
{
$w .= ' ';
if($r < 100)
{
$w .= 'and ';
}
$w .= self::numberToString($r);
}
}
else // millions
{
$w .= self::numberToString(floor($x/1000000)) .' million';
$r = fmod($x, 1000000);
if($r > 0)
{
$w .= ' ';
if($r < 100)
{
$w .= 'and ';
}
$w .= self::numberToString($r);
}
}
}
return $w;
return UtilitiesStringHelper::number($x);
}
/**
* Random Key
*
* @returns a string
* @deprecated 3.3 Use UtilitiesStringHelper::random($size);
*/
public static function randomkey($size)
{
$bag = "abcefghijknopqrstuwxyzABCDDEFGHIJKLLMMNOPQRSTUVVWXYZabcddefghijkllmmnopqrstuvvwxyzABCEFGHIJKNOPQRSTUWXYZ";
$key = array();
$bagsize = strlen($bag) - 1;
for ($i = 0; $i < $size; $i++)
{
$get = rand(0, $bagsize);
$key[] = $bag[$get];
}
return implode($key);
return UtilitiesStringHelper::random($size);
}
}

View File

@ -351,7 +351,7 @@ class GetbibleModelBook extends AdminModel
return false;
}
}
// In the absense of better information, revert to the component permissions.
// In the absence of better information, revert to the component permissions.
return $user->authorise('book.edit.state', 'com_getbible');
}

View File

@ -369,7 +369,7 @@ class GetbibleModelChapter extends AdminModel
return false;
}
}
// In the absense of better information, revert to the component permissions.
// In the absence of better information, revert to the component permissions.
return $user->authorise('chapter.edit.state', 'com_getbible');
}

View File

@ -711,7 +711,7 @@ class GetbibleModelLinker extends AdminModel
return false;
}
}
// In the absense of better information, revert to the component permissions.
// In the absence of better information, revert to the component permissions.
return $user->authorise('linker.edit.state', 'com_getbible');
}

View File

@ -405,7 +405,7 @@ class GetbibleModelNote extends AdminModel
return false;
}
}
// In the absense of better information, revert to the component permissions.
// In the absence of better information, revert to the component permissions.
return $user->authorise('note.edit.state', 'com_getbible');
}

View File

@ -410,7 +410,7 @@ class GetbibleModelOpen_ai_message extends AdminModel
return false;
}
}
// In the absense of better information, revert to the component permissions.
// In the absence of better information, revert to the component permissions.
return $user->authorise('open_ai_message.edit.state', 'com_getbible');
}

View File

@ -858,7 +858,7 @@ class GetbibleModelOpen_ai_response extends AdminModel
return false;
}
}
// In the absense of better information, revert to the component permissions.
// In the absence of better information, revert to the component permissions.
return $user->authorise('open_ai_response.edit.state', 'com_getbible');
}

View File

@ -390,7 +390,7 @@ class GetbibleModelPassword extends AdminModel
return false;
}
}
// In the absense of better information, revert to the component permissions.
// In the absence of better information, revert to the component permissions.
return $user->authorise('password.edit.state', 'com_getbible');
}

View File

@ -766,7 +766,7 @@ class GetbibleModelPrompt extends AdminModel
return false;
}
}
// In the absense of better information, revert to the component permissions.
// In the absence of better information, revert to the component permissions.
return $user->authorise('prompt.edit.state', 'com_getbible');
}

View File

@ -369,7 +369,7 @@ class GetbibleModelTag extends AdminModel
return false;
}
}
// In the absense of better information, revert to the component permissions.
// In the absence of better information, revert to the component permissions.
return $user->authorise('tag.edit.state', 'com_getbible');
}

View File

@ -423,7 +423,7 @@ class GetbibleModelTagged_verse extends AdminModel
return false;
}
}
// In the absense of better information, revert to the component permissions.
// In the absence of better information, revert to the component permissions.
return $user->authorise('tagged_verse.edit.state', 'com_getbible');
}

View File

@ -598,7 +598,7 @@ class GetbibleModelTranslation extends AdminModel
return false;
}
}
// In the absense of better information, revert to the component permissions.
// In the absence of better information, revert to the component permissions.
return $user->authorise('translation.edit.state', 'com_getbible');
}

View File

@ -389,7 +389,7 @@ class GetbibleModelVerse extends AdminModel
return false;
}
}
// In the absense of better information, revert to the component permissions.
// In the absence of better information, revert to the component permissions.
return $user->authorise('verse.edit.state', 'com_getbible');
}

View File

@ -0,0 +1 @@

View File

@ -58,7 +58,7 @@ class GetbibleViewBooks extends HtmlView
$this->canState = $this->canDo->get('book.edit.state');
$this->canCreate = $this->canDo->get('book.create');
$this->canDelete = $this->canDo->get('book.delete');
$this->canBatch = $this->canDo->get('core.batch');
$this->canBatch = ($this->canDo->get('book.batch') && $this->canDo->get('core.batch'));
// We don't need toolbar in the modal window.
if ($this->getLayout() !== 'modal')

View File

@ -58,7 +58,7 @@ class GetbibleViewChapters extends HtmlView
$this->canState = $this->canDo->get('chapter.edit.state');
$this->canCreate = $this->canDo->get('chapter.create');
$this->canDelete = $this->canDo->get('chapter.delete');
$this->canBatch = $this->canDo->get('core.batch');
$this->canBatch = ($this->canDo->get('chapter.batch') && $this->canDo->get('core.batch'));
// We don't need toolbar in the modal window.
if ($this->getLayout() !== 'modal')

View File

@ -58,7 +58,7 @@ class GetbibleViewLinkers extends HtmlView
$this->canState = $this->canDo->get('linker.edit.state');
$this->canCreate = $this->canDo->get('linker.create');
$this->canDelete = $this->canDo->get('linker.delete');
$this->canBatch = $this->canDo->get('core.batch');
$this->canBatch = ($this->canDo->get('linker.batch') && $this->canDo->get('core.batch'));
// We don't need toolbar in the modal window.
if ($this->getLayout() !== 'modal')

View File

@ -58,7 +58,7 @@ class GetbibleViewNotes extends HtmlView
$this->canState = $this->canDo->get('note.edit.state');
$this->canCreate = $this->canDo->get('note.create');
$this->canDelete = $this->canDo->get('note.delete');
$this->canBatch = $this->canDo->get('core.batch');
$this->canBatch = ($this->canDo->get('note.batch') && $this->canDo->get('core.batch'));
// We don't need toolbar in the modal window.
if ($this->getLayout() !== 'modal')

View File

@ -58,7 +58,7 @@ class GetbibleViewOpen_ai_messages extends HtmlView
$this->canState = $this->canDo->get('open_ai_message.edit.state');
$this->canCreate = $this->canDo->get('open_ai_message.create');
$this->canDelete = $this->canDo->get('open_ai_message.delete');
$this->canBatch = $this->canDo->get('core.batch');
$this->canBatch = ($this->canDo->get('open_ai_message.batch') && $this->canDo->get('core.batch'));
// We don't need toolbar in the modal window.
if ($this->getLayout() !== 'modal')

View File

@ -58,7 +58,7 @@ class GetbibleViewOpen_ai_responses extends HtmlView
$this->canState = $this->canDo->get('open_ai_response.edit.state');
$this->canCreate = $this->canDo->get('open_ai_response.create');
$this->canDelete = $this->canDo->get('open_ai_response.delete');
$this->canBatch = $this->canDo->get('core.batch');
$this->canBatch = ($this->canDo->get('open_ai_response.batch') && $this->canDo->get('core.batch'));
// We don't need toolbar in the modal window.
if ($this->getLayout() !== 'modal')

View File

@ -58,7 +58,7 @@ class GetbibleViewPasswords extends HtmlView
$this->canState = $this->canDo->get('password.edit.state');
$this->canCreate = $this->canDo->get('password.create');
$this->canDelete = $this->canDo->get('password.delete');
$this->canBatch = $this->canDo->get('core.batch');
$this->canBatch = ($this->canDo->get('password.batch') && $this->canDo->get('core.batch'));
// We don't need toolbar in the modal window.
if ($this->getLayout() !== 'modal')

View File

@ -58,7 +58,7 @@ class GetbibleViewPrompts extends HtmlView
$this->canState = $this->canDo->get('prompt.edit.state');
$this->canCreate = $this->canDo->get('prompt.create');
$this->canDelete = $this->canDo->get('prompt.delete');
$this->canBatch = $this->canDo->get('core.batch');
$this->canBatch = ($this->canDo->get('prompt.batch') && $this->canDo->get('core.batch'));
// We don't need toolbar in the modal window.
if ($this->getLayout() !== 'modal')

View File

@ -58,7 +58,7 @@ class GetbibleViewTagged_verses extends HtmlView
$this->canState = $this->canDo->get('tagged_verse.edit.state');
$this->canCreate = $this->canDo->get('tagged_verse.create');
$this->canDelete = $this->canDo->get('tagged_verse.delete');
$this->canBatch = $this->canDo->get('core.batch');
$this->canBatch = ($this->canDo->get('tagged_verse.batch') && $this->canDo->get('core.batch'));
// We don't need toolbar in the modal window.
if ($this->getLayout() !== 'modal')

View File

@ -58,7 +58,7 @@ class GetbibleViewTags extends HtmlView
$this->canState = $this->canDo->get('tag.edit.state');
$this->canCreate = $this->canDo->get('tag.create');
$this->canDelete = $this->canDo->get('tag.delete');
$this->canBatch = $this->canDo->get('core.batch');
$this->canBatch = ($this->canDo->get('tag.batch') && $this->canDo->get('core.batch'));
// We don't need toolbar in the modal window.
if ($this->getLayout() !== 'modal')

View File

@ -58,7 +58,7 @@ class GetbibleViewTranslations extends HtmlView
$this->canState = $this->canDo->get('translation.edit.state');
$this->canCreate = $this->canDo->get('translation.create');
$this->canDelete = $this->canDo->get('translation.delete');
$this->canBatch = $this->canDo->get('core.batch');
$this->canBatch = ($this->canDo->get('translation.batch') && $this->canDo->get('core.batch'));
// We don't need toolbar in the modal window.
if ($this->getLayout() !== 'modal')

View File

@ -58,7 +58,7 @@ class GetbibleViewVerses extends HtmlView
$this->canState = $this->canDo->get('verse.edit.state');
$this->canCreate = $this->canDo->get('verse.create');
$this->canDelete = $this->canDo->get('verse.delete');
$this->canBatch = $this->canDo->get('core.batch');
$this->canBatch = ($this->canDo->get('verse.batch') && $this->canDo->get('core.batch'));
// We don't need toolbar in the modal window.
if ($this->getLayout() !== 'modal')

View File

@ -1,15 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<extension type="component" version="4" method="upgrade">
<name>COM_GETBIBLE</name>
<creationDate>21st August, 2023</creationDate>
<creationDate>7th September, 2023</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>2.0.22</version>
<version>2.0.23</version>
<description><![CDATA[
<h1>Get Bible (v.2.0.22)</h1>
<h1>Get Bible (v.2.0.23)</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

@ -236,7 +236,7 @@ final class Engineer
$choice->message->open_ai_response = $open_ai_response;
$choice->message->source = 2; // open AI as source
$choice->message->index = $choice->index;
$choice->message->name = 'getBible-Open-AI';
$choice->message->name = 'Open-AI';
$choice->message->published = $state;
$this->messages[] = $choice->message;

View File

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

View File

@ -70,6 +70,12 @@ use Joomla\Registry\Registry;
use Joomla\String\StringHelper;
use Joomla\Utilities\ArrayHelper;
use VDM\Joomla\GetBible\Factory;
use VDM\Joomla\Utilities\StringHelper as UtilitiesStringHelper;
use VDM\Joomla\Utilities\JsonHelper;
use VDM\Joomla\Utilities\ObjectHelper;
use VDM\Joomla\Componentbuilder\Utilities\FormHelper;
use VDM\Joomla\Utilities\GetHelper;
use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper;
/**
* Getbible component helper
@ -78,14 +84,14 @@ abstract class GetbibleHelper
{
/**
* Composer Switch
*
*
* @var array
*/
protected static $composer = array();
/**
* The Main Active Language
*
*
* @var string
*/
public static $langTag;
@ -122,7 +128,7 @@ abstract class GetbibleHelper
if (!isset(self::$composer[$target]))
{
// get the function name
$functionName = self::safeString('compose' . $target);
$functionName = UtilitiesStringHelper::safe('compose' . $target);
// check if method exist
if (method_exists(__CLASS__, $functionName))
{
@ -134,54 +140,22 @@ abstract class GetbibleHelper
}
/**
* Convert it into a string
* Convert a json object to a string
*
* @input string $value The json string to convert
*
* @returns a string
* @deprecated 3.3 Use JsonHelper::string(...);
*/
public static function jsonToString($value, $sperator = ", ", $table = null, $id = 'id', $name = 'name')
{
// do some table foot work
$external = false;
if (strpos($table, '#__') !== false)
{
$external = true;
$table = str_replace('#__', '', $table);
}
// check if string is JSON
$result = json_decode($value, true);
if (json_last_error() === JSON_ERROR_NONE)
{
// is JSON
if (self::checkArray($result))
{
if (self::checkString($table))
{
$names = array();
foreach ($result as $val)
{
if ($external)
{
if ($_name = self::getVar(null, $val, $id, $name, '=', $table))
{
$names[] = $_name;
}
}
else
{
if ($_name = self::getVar($table, $val, $id, $name))
{
$names[] = $_name;
}
}
}
if (self::checkArray($names))
{
return (string) implode($sperator,$names);
}
}
return (string) implode($sperator,$result);
}
return (string) json_decode($value);
}
return $value;
return JsonHelper::string(
$value,
$sperator,
$table,
$id,
$name
);
}
/**
@ -195,7 +169,7 @@ abstract class GetbibleHelper
/**
* Joomla version object
*/
*/
protected static $JVersion;
/**
@ -204,7 +178,7 @@ abstract class GetbibleHelper
public static function jVersion()
{
// check if set
if (!self::checkObject(self::$JVersion))
if (!ObjectHelper::check(self::$JVersion))
{
self::$JVersion = new JVersion();
}
@ -242,8 +216,8 @@ abstract class GetbibleHelper
$link_front = '';
$link_back = '';
}
$contributors[$nr]['title'] = self::htmlEscape($params->get("titleContributor".$nr));
$contributors[$nr]['name'] = $link_front.self::htmlEscape($params->get("nameContributor".$nr)).$link_back;
$contributors[$nr]['title'] = UtilitiesStringHelper::html($params->get("titleContributor".$nr));
$contributors[$nr]['name'] = $link_front.UtilitiesStringHelper::html($params->get("nameContributor".$nr)).$link_back;
}
}
return $contributors;
@ -263,13 +237,13 @@ abstract class GetbibleHelper
public static function getModel($name, $path = JPATH_COMPONENT_SITE, $Component = 'Getbible', $config = array())
{
// fix the name
$name = self::safeString($name);
$name = UtilitiesStringHelper::safe($name);
// full path to models
$fullPathModels = $path . '/models';
// load the model file
JModelLegacy::addIncludePath($fullPathModels, $Component . 'Model');
// make sure the table path is loaded
if (!isset($config['table_path']) || !self::checkString($config['table_path']))
if (!isset($config['table_path']) || !UtilitiesStringHelper::check($config['table_path']))
{
// This is the JCB default path to tables in Joomla 3.x
$config['table_path'] = JPATH_ADMINISTRATOR . '/components/com_' . strtolower($Component) . '/tables';
@ -312,7 +286,7 @@ abstract class GetbibleHelper
{
$parent = JTable::getInstance('Asset');
$parent->loadByName('com_getbible');
$parentId = $parent->id;
$name = 'com_getbible.'.$table.'.'.$id;
$title = '';
@ -432,35 +406,12 @@ abstract class GetbibleHelper
* @param SimpleXMLElement $xml The XML element reference in which to inject a comment
* @param mixed $node A SimpleXMLElement node to append to the XML element reference, or a stdClass object containing a comment attribute to be injected before the XML node and a fieldXML attribute containing a SimpleXMLElement
*
* @return null
*
* @return void
* @deprecated 3.3 Use FormHelper::append($xml, $node);
*/
public static function xmlAppend(&$xml, $node)
{
if (!$node)
{
// element was not returned
return;
}
switch (get_class($node))
{
case 'stdClass':
if (property_exists($node, 'comment'))
{
self::xmlComment($xml, $node->comment);
}
if (property_exists($node, 'fieldXML'))
{
self::xmlAppend($xml, $node->fieldXML);
}
break;
case 'SimpleXMLElement':
$domXML = dom_import_simplexml($xml);
$domNode = dom_import_simplexml($node);
$domXML->appendChild($domXML->ownerDocument->importNode($domNode, true));
$xml = simplexml_import_dom($domXML);
break;
}
FormHelper::append($xml, $node);
}
/**
@ -469,16 +420,12 @@ abstract class GetbibleHelper
* @param SimpleXMLElement $xml The XML element reference in which to inject a comment
* @param string $comment The comment to inject
*
* @return null
*
* @return void
* @deprecated 3.3 Use FormHelper::comment($xml, $comment);
*/
public static function xmlComment(&$xml, $comment)
{
$domXML = dom_import_simplexml($xml);
$domComment = new DOMComment($comment);
$nodeTarget = $domXML->ownerDocument->importNode($domComment, true);
$domXML->appendChild($nodeTarget);
$xml = simplexml_import_dom($domXML);
FormHelper::comment($xml, $comment);
}
/**
@ -488,14 +435,11 @@ abstract class GetbibleHelper
* @param array $attributes The attributes to apply to the XML element
*
* @return null
*
* @deprecated 3.3 Use FormHelper::attributes($xml, $attributes);
*/
public static function xmlAddAttributes(&$xml, $attributes = array())
{
foreach ($attributes as $key => $value)
{
$xml->addAttribute($key, $value);
}
FormHelper::attributes($xml, $attributes);
}
/**
@ -505,16 +449,11 @@ abstract class GetbibleHelper
* @param array $options The options to apply to the XML element
*
* @return void
*
* @deprecated 3.3 Use FormHelper::options($xml, $options);
*/
public static function xmlAddOptions(&$xml, $options = array())
{
foreach ($options as $key => $value)
{
$addOption = $xml->addChild('option');
$addOption->addAttribute('value', $key);
$addOption[] = $value;
}
FormHelper::options($xml, $options);
}
/**
@ -525,28 +464,11 @@ abstract class GetbibleHelper
* @param array $options The options to apply to the XML element
*
* @return object
*
* @deprecated 3.3 Use FormHelper::field($attributes, $default, $options);
*/
public static function getFieldObject(&$attributes, $default = '', $options = null)
{
// make sure we have attributes and a type value
if (self::checkArray($attributes) && isset($attributes['type']))
{
// make sure the form helper class is loaded
if (!method_exists('JFormHelper', 'loadFieldType'))
{
jimport('joomla.form.form');
}
// get field type
$field = JFormHelper::loadFieldType($attributes['type'], true);
// get field xml
$XML = self::getFieldXML($attributes, $options);
// setup the field
$field->setup($XML, $default);
// return the field object
return $field;
}
return false;
return FormHelper::field($attributes, $default, $options);
}
/**
@ -556,27 +478,11 @@ abstract class GetbibleHelper
* @param array $options The options to apply to the XML element
*
* @return object
*
* @deprecated 3.3 Use FormHelper::xml($attributes, $options);
*/
public static function getFieldXML(&$attributes, $options = null)
{
// make sure we have attributes and a type value
if (self::checkArray($attributes))
{
// start field xml
$XML = new SimpleXMLElement('<field/>');
// load the attributes
self::xmlAddAttributes($XML, $attributes);
// check if we have options
if (self::checkArray($options))
{
// load the options
self::xmlAddOptions($XML, $options);
}
// return the field xml
return $XML;
}
return false;
return FormHelper::xml($attributes, $options);
}
/**
@ -600,21 +506,21 @@ abstract class GetbibleHelper
// button attributes
$buttonAttributes = array(
'type' => 'radio',
'name' => isset($args[0]) ? self::htmlEscape($args[0]) : 'bool_button',
'label' => isset($args[0]) ? self::safeString(self::htmlEscape($args[0]), 'Ww') : 'Bool Button', // not seen anyway
'name' => isset($args[0]) ? UtilitiesStringHelper::html($args[0]) : 'bool_button',
'label' => isset($args[0]) ? UtilitiesStringHelper::safe(UtilitiesStringHelper::html($args[0]), 'Ww') : 'Bool Button', // not seen anyway
'class' => 'btn-group',
'filter' => 'INT',
'default' => isset($args[2]) ? (int) $args[2] : 0);
// set the button options
$buttonOptions = array(
'1' => isset($args[3]) ? self::htmlEscape($args[3]) : 'JYES',
'0' => isset($args[4]) ? self::htmlEscape($args[4]) : 'JNO');
'1' => isset($args[3]) ? UtilitiesStringHelper::html($args[3]) : 'JYES',
'0' => isset($args[4]) ? UtilitiesStringHelper::html($args[4]) : 'JNO');
// return the input
return self::getFieldObject($buttonAttributes, $buttonAttributes['default'], $buttonOptions)->input;
return FormHelper::field($buttonAttributes, $buttonAttributes['default'], $buttonOptions)->input;
}
/**
* Get a variable
* Get a variable
*
* @param string $table The table from which to get the variable
* @param string $where The value where
@ -624,46 +530,18 @@ abstract class GetbibleHelper
* @param string $main The component in which the table is found
*
* @return mix string/int/float
*
* @deprecated 3.3 Use GetHelper::var(...);
*/
public static function getVar($table, $where = null, $whereString = 'user', $what = 'id', $operator = '=', $main = 'getbible')
{
if(!$where)
{
$where = JFactory::getUser()->id;
}
// Get a db connection.
$db = JFactory::getDbo();
// Create a new query object.
$query = $db->getQuery(true);
$query->select($db->quoteName(array($what)));
if (empty($table))
{
$query->from($db->quoteName('#__'.$main));
}
else
{
$query->from($db->quoteName('#__'.$main.'_'.$table));
}
if (is_numeric($where))
{
$query->where($db->quoteName($whereString) . ' '.$operator.' '.(int) $where);
}
elseif (is_string($where))
{
$query->where($db->quoteName($whereString) . ' '.$operator.' '. $db->quote((string)$where));
}
else
{
return false;
}
$db->setQuery($query);
$db->execute();
if ($db->getNumRows())
{
return $db->loadResult();
}
return false;
return GetHelper::var(
$table,
$where,
$whereString,
$what,
$operator,
$main
);
}
/**
@ -678,63 +556,20 @@ abstract class GetbibleHelper
* @param bool $unique The switch to return a unique array
*
* @return array
*
* @deprecated 3.3 Use GetHelper::vars(...);
*/
public static function getVars($table, $where = null, $whereString = 'user', $what = 'id', $operator = 'IN', $main = 'getbible', $unique = true)
{
if(!$where)
{
$where = JFactory::getUser()->id;
}
if (!self::checkArray($where) && $where > 0)
{
$where = array($where);
}
if (self::checkArray($where))
{
// prep main <-- why? well if $main='' is empty then $table can be categories or users
if (self::checkString($main))
{
$main = '_'.ltrim($main, '_');
}
// Get a db connection.
$db = JFactory::getDbo();
// Create a new query object.
$query = $db->getQuery(true);
$query->select($db->quoteName(array($what)));
if (empty($table))
{
$query->from($db->quoteName('#__'.$main));
}
else
{
$query->from($db->quoteName('#_'.$main.'_'.$table));
}
// add strings to array search
if ('IN_STRINGS' === $operator || 'NOT IN_STRINGS' === $operator)
{
$query->where($db->quoteName($whereString) . ' ' . str_replace('_STRINGS', '', $operator) . ' ("' . implode('","',$where) . '")');
}
else
{
$query->where($db->quoteName($whereString) . ' ' . $operator . ' (' . implode(',',$where) . ')');
}
$db->setQuery($query);
$db->execute();
if ($db->getNumRows())
{
if ($unique)
{
return array_unique($db->loadColumn());
}
return $db->loadColumn();
}
}
return false;
}
return GetHelper::vars(
$table,
$where,
$whereString,
$what,
$operator,
$main,
$unique
);
}
public static function isPublished($id,$type)
{
@ -786,12 +621,12 @@ abstract class GetbibleHelper
* @param object $user The user whose permissions we are loading
*
* @return object The JObject of permission/authorised actions
*
*
*/
public static function getActions($view, &$record = null, $views = null, $target = null, $component = 'getbible', $user = 'null')
{
// load the user if not given
if (!self::checkObject($user))
if (!ObjectHelper::check($user))
{
// get the user object
$user = JFactory::getUser();
@ -799,10 +634,10 @@ abstract class GetbibleHelper
// load the JObject
$result = new JObject;
// make view name safe (just incase)
$view = self::safeString($view);
if (self::checkString($views))
$view = UtilitiesStringHelper::safe($view);
if (UtilitiesStringHelper::check($views))
{
$views = self::safeString($views);
$views = UtilitiesStringHelper::safe($views);
}
// get all actions from component
$actions = JAccess::getActionsFromFile(
@ -815,9 +650,9 @@ abstract class GetbibleHelper
return $result;
}
// get created by if not found
if (self::checkObject($record) && !isset($record->created_by) && isset($record->id))
if (ObjectHelper::check($record) && !isset($record->created_by) && isset($record->id))
{
$record->created_by = self::getVar($view, $record->id, 'id', 'created_by', '=', $component);
$record->created_by = GetHelper::var($view, $record->id, 'id', 'created_by', '=', $component);
}
// set actions only set in component settings
$componentActions = array('core.admin', 'core.manage', 'core.options', 'core.export');
@ -826,12 +661,12 @@ abstract class GetbibleHelper
if ($target)
{
// convert to an array
if (self::checkString($target))
if (UtilitiesStringHelper::check($target))
{
$target = array($target);
}
// check if we are good to go
if (self::checkArray($target))
if (UtilitiesArrayHelper::check($target))
{
$checkTarget = true;
}
@ -852,7 +687,7 @@ abstract class GetbibleHelper
// set area
$area = 'comp';
// check if the record has an ID and the action is item related (not a component action)
if (self::checkObject($record) && isset($record->id) && $record->id > 0 && !in_array($action->name, $componentActions) &&
if (ObjectHelper::check($record) && isset($record->id) && $record->id > 0 && !in_array($action->name, $componentActions) &&
(strpos($action->name, 'core.') !== false || strpos($action->name, $view . '.') !== false))
{
// we are in item
@ -885,7 +720,7 @@ abstract class GetbibleHelper
}
}
}
elseif (self::checkString($views) && isset($record->catid) && $record->catid > 0)
elseif (UtilitiesStringHelper::check($views) && isset($record->catid) && $record->catid > 0)
{
// we are in item
$area = 'category';
@ -957,7 +792,7 @@ abstract class GetbibleHelper
* @param array $targets The array of target actions
*
* @return boolean true if action should be filtered out
*
*
*/
protected static function filterActions(&$view, &$action, &$targets)
{
@ -979,15 +814,11 @@ abstract class GetbibleHelper
* @input string The json string to check
*
* @returns bool true on success
* @deprecated 3.3 Use JsonHelper::check($string);
*/
public static function checkJson($string)
{
if (self::checkString($string))
{
json_decode($string);
return (json_last_error() === JSON_ERROR_NONE);
}
return false;
return JsonHelper::check($string);
}
/**
@ -996,14 +827,11 @@ abstract class GetbibleHelper
* @input object The object to check
*
* @returns bool true on success
* @deprecated 3.3 Use ObjectHelper::check($object);
*/
public static function checkObject($object)
{
if (isset($object) && is_object($object))
{
return count((array)$object) > 0;
}
return false;
return ObjectHelper::check($object);
}
/**
@ -1012,26 +840,11 @@ abstract class GetbibleHelper
* @input array The array to check
*
* @returns bool/int number of items in array on success
* @deprecated 3.3 Use UtilitiesArrayHelper::check($array, $removeEmptyString);
*/
public static function checkArray($array, $removeEmptyString = false)
{
if (isset($array) && is_array($array) && ($nr = count((array)$array)) > 0)
{
// also make sure the empty strings are removed
if ($removeEmptyString)
{
foreach ($array as $key => $string)
{
if (empty($string))
{
unset($array[$key]);
}
}
return self::checkArray($array, false);
}
return $nr;
}
return false;
return UtilitiesArrayHelper::check($array, $removeEmptyString);
}
/**
@ -1040,14 +853,11 @@ abstract class GetbibleHelper
* @input string The string to check
*
* @returns bool true on success
* @deprecated 3.3 Use UtilitiesStringHelper::check($string);
*/
public static function checkString($string)
{
if (isset($string) && is_string($string) && strlen($string) > 0)
{
return true;
}
return false;
return UtilitiesStringHelper::check($string);
}
/**
@ -1059,7 +869,7 @@ abstract class GetbibleHelper
public static function isConnected()
{
// If example.com is down, then probably the whole internet is down, since IANA maintains the domain. Right?
$connected = @fsockopen("www.example.com", 80);
$connected = @fsockopen("www.example.com", 80);
// website, port (try 80 or 443)
if ($connected)
{
@ -1081,22 +891,11 @@ abstract class GetbibleHelper
* @input array The arrays you would like to merge
*
* @returns array on success
* @deprecated 3.3 Use UtilitiesArrayHelper::merge($arrays);
*/
public static function mergeArrays($arrays)
{
if(self::checkArray($arrays))
{
$arrayBuket = array();
foreach ($arrays as $array)
{
if (self::checkArray($array))
{
$arrayBuket = array_merge($arrayBuket, $array);
}
}
return $arrayBuket;
}
return false;
return UtilitiesArrayHelper::merge($arrays);
}
// typo sorry!
@ -1111,39 +910,11 @@ abstract class GetbibleHelper
* @input string The you would like to shorten
*
* @returns string on success
* @deprecated 3.3 Use UtilitiesStringHelper::shorten(...);
*/
public static function shorten($string, $length = 40, $addTip = true)
{
if (self::checkString($string))
{
$initial = strlen($string);
$words = preg_split('/([\s\n\r]+)/', $string, null, PREG_SPLIT_DELIM_CAPTURE);
$words_count = count((array)$words);
$word_length = 0;
$last_word = 0;
for (; $last_word < $words_count; ++$last_word)
{
$word_length += strlen($words[$last_word]);
if ($word_length > $length)
{
break;
}
}
$newString = implode(array_slice($words, 0, $last_word));
$final = strlen($newString);
if ($initial != $final && $addTip)
{
$title = self::shorten($string, 400 , false);
return '<span class="hasTip" title="'.$title.'" style="cursor:help">'.trim($newString).'...</span>';
}
elseif ($initial != $final && !$addTip)
{
return trim($newString).'...';
}
}
return $string;
return UtilitiesStringHelper::shorten($string, $length, $addTip);
}
/**
@ -1152,157 +923,61 @@ abstract class GetbibleHelper
* @input string The you would like to make safe
*
* @returns string on success
* @deprecated 3.3 Use UtilitiesStringHelper::safe(...);
*/
public static function safeString($string, $type = 'L', $spacer = '_', $replaceNumbers = true, $keepOnlyCharacters = true)
{
if ($replaceNumbers === true)
{
// remove all numbers and replace with english text version (works well only up to millions)
$string = self::replaceNumbers($string);
}
// 0nly continue if we have a string
if (self::checkString($string))
{
// create file name without the extention that is safe
if ($type === 'filename')
{
// make sure VDM is not in the string
$string = str_replace('VDM', 'vDm', $string);
// Remove anything which isn't a word, whitespace, number
// or any of the following caracters -_()
// If you don't need to handle multi-byte characters
// you can use preg_replace rather than mb_ereg_replace
// Thanks @Łukasz Rysiak!
// $string = mb_ereg_replace("([^\w\s\d\-_\(\)])", '', $string);
$string = preg_replace("([^\w\s\d\-_\(\)])", '', $string);
// http://stackoverflow.com/a/2021729/1429677
return preg_replace('/\s+/', ' ', $string);
}
// remove all other characters
$string = trim($string);
$string = preg_replace('/'.$spacer.'+/', ' ', $string);
$string = preg_replace('/\s+/', ' ', $string);
// Transliterate string
$string = self::transliterate($string);
// remove all and keep only characters
if ($keepOnlyCharacters)
{
$string = preg_replace("/[^A-Za-z ]/", '', $string);
}
// keep both numbers and characters
else
{
$string = preg_replace("/[^A-Za-z0-9 ]/", '', $string);
}
// select final adaptations
if ($type === 'L' || $type === 'strtolower')
{
// replace white space with underscore
$string = preg_replace('/\s+/', $spacer, $string);
// default is to return lower
return strtolower($string);
}
elseif ($type === 'W')
{
// return a string with all first letter of each word uppercase(no undersocre)
return ucwords(strtolower($string));
}
elseif ($type === 'w' || $type === 'word')
{
// return a string with all lowercase(no undersocre)
return strtolower($string);
}
elseif ($type === 'Ww' || $type === 'Word')
{
// return a string with first letter of the first word uppercase and all the rest lowercase(no undersocre)
return ucfirst(strtolower($string));
}
elseif ($type === 'WW' || $type === 'WORD')
{
// return a string with all the uppercase(no undersocre)
return strtoupper($string);
}
elseif ($type === 'U' || $type === 'strtoupper')
{
// replace white space with underscore
$string = preg_replace('/\s+/', $spacer, $string);
// return all upper
return strtoupper($string);
}
elseif ($type === 'F' || $type === 'ucfirst')
{
// replace white space with underscore
$string = preg_replace('/\s+/', $spacer, $string);
// return with first caracter to upper
return ucfirst(strtolower($string));
}
elseif ($type === 'cA' || $type === 'cAmel' || $type === 'camelcase')
{
// convert all words to first letter uppercase
$string = ucwords(strtolower($string));
// remove white space
$string = preg_replace('/\s+/', '', $string);
// now return first letter lowercase
return lcfirst($string);
}
// return string
return $string;
}
// not a string
return '';
return UtilitiesStringHelper::safe(
$string,
$type,
$spacer,
$replaceNumbers,
$keepOnlyCharacters
);
}
/**
* Convert none English strings to code usable string
*
* @input an string
*
* @returns a string
* @deprecated 3.3 Use UtilitiesStringHelper::transliterate($string);
*/
public static function transliterate($string)
{
// set tag only once
if (!self::checkString(self::$langTag))
{
// get global value
self::$langTag = JComponentHelper::getParams('com_getbible')->get('language', 'en-GB');
}
// Transliterate on the language requested
$lang = Language::getInstance(self::$langTag);
return $lang->transliterate($string);
return UtilitiesStringHelper::transliterate($string);
}
/**
* make sure a string is HTML save
*
* @input an html string
*
* @returns a string
* @deprecated 3.3 Use UtilitiesStringHelper::html(...);
*/
public static function htmlEscape($var, $charset = 'UTF-8', $shorten = false, $length = 40)
{
if (self::checkString($var))
{
$filter = new JFilterInput();
$string = $filter->clean(html_entity_decode(htmlentities($var, ENT_COMPAT, $charset)), 'HTML');
if ($shorten)
{
return self::shorten($string,$length);
}
return $string;
}
else
{
return '';
}
return UtilitiesStringHelper::html(
$var,
$charset,
$shorten,
$length
);
}
/**
* Convert all int in a string to an English word string
*
* @input an string with numbers
*
* @returns a string
* @deprecated 3.3 Use UtilitiesStringHelper::numbers($string);
*/
public static function replaceNumbers($string)
{
// set numbers array
$numbers = array();
// first get all numbers
preg_match_all('!\d+!', $string, $numbers);
// check if we have any numbers
if (isset($numbers[0]) && self::checkArray($numbers[0]))
{
foreach ($numbers[0] as $number)
{
$searchReplace[$number] = self::numberToString((int)$number);
}
// now replace numbers in string
$string = str_replace(array_keys($searchReplace), array_values($searchReplace),$string);
// check if we missed any, strange if we did.
return self::replaceNumbers($string);
}
// return the string with no numbers remaining.
return $string;
return UtilitiesStringHelper::numbers($string);
}
/**
@ -1311,107 +986,21 @@ abstract class GetbibleHelper
*
* @input an int
* @returns a string
* @deprecated 3.3 Use UtilitiesStringHelper::number($x);
*/
public static function numberToString($x)
{
$nwords = array( "zero", "one", "two", "three", "four", "five", "six", "seven",
"eight", "nine", "ten", "eleven", "twelve", "thirteen",
"fourteen", "fifteen", "sixteen", "seventeen", "eighteen",
"nineteen", "twenty", 30 => "thirty", 40 => "forty",
50 => "fifty", 60 => "sixty", 70 => "seventy", 80 => "eighty",
90 => "ninety" );
if(!is_numeric($x))
{
$w = $x;
}
elseif(fmod($x, 1) != 0)
{
$w = $x;
}
else
{
if($x < 0)
{
$w = 'minus ';
$x = -$x;
}
else
{
$w = '';
// ... now $x is a non-negative integer.
}
if($x < 21) // 0 to 20
{
$w .= $nwords[$x];
}
elseif($x < 100) // 21 to 99
{
$w .= $nwords[10 * floor($x/10)];
$r = fmod($x, 10);
if($r > 0)
{
$w .= ' '. $nwords[$r];
}
}
elseif($x < 1000) // 100 to 999
{
$w .= $nwords[floor($x/100)] .' hundred';
$r = fmod($x, 100);
if($r > 0)
{
$w .= ' and '. self::numberToString($r);
}
}
elseif($x < 1000000) // 1000 to 999999
{
$w .= self::numberToString(floor($x/1000)) .' thousand';
$r = fmod($x, 1000);
if($r > 0)
{
$w .= ' ';
if($r < 100)
{
$w .= 'and ';
}
$w .= self::numberToString($r);
}
}
else // millions
{
$w .= self::numberToString(floor($x/1000000)) .' million';
$r = fmod($x, 1000000);
if($r > 0)
{
$w .= ' ';
if($r < 100)
{
$w .= 'and ';
}
$w .= self::numberToString($r);
}
}
}
return $w;
return UtilitiesStringHelper::number($x);
}
/**
* Random Key
*
* @returns a string
* @deprecated 3.3 Use UtilitiesStringHelper::random($size);
*/
public static function randomkey($size)
{
$bag = "abcefghijknopqrstuwxyzABCDDEFGHIJKLLMMNOPQRSTUVVWXYZabcddefghijkllmmnopqrstuvvwxyzABCEFGHIJKNOPQRSTUWXYZ";
$key = array();
$bagsize = strlen($bag) - 1;
for ($i = 0; $i < $size; $i++)
{
$get = rand(0, $bagsize);
$key[] = $bag[$get];
}
return implode($key);
return UtilitiesStringHelper::random($size);
}
}

View File

@ -115,7 +115,11 @@ COM_GETBIBLE_ONCE_YOU_HAVE_COMPLETED_THE_INSTALLATION_OF_ALL_DESIRED_BIBLE_TRANS
COM_GETBIBLE_OPEN="Open"
COM_GETBIBLE_OPENAI="Openai"
COM_GETBIBLE_OPENAI_DESC="Open AI"
COM_GETBIBLE_OPEN_AI="Open AI"
COM_GETBIBLE_OPEN_AI_RESPOND_TO_PROMPT_ABOUT_S_IN_S="Open AI respond to prompt about, %s, in %s"
COM_GETBIBLE_OPEN_AI_RESPONSE="Open AI Response"
COM_GETBIBLE_OPEN_AI_S_IN_S_S="Open AI: %s in %s - %s"
COM_GETBIBLE_OPEN_AI_S_S_BIBLE_S_S_SCRIPTURE_RESEARCH_GETBIBLE="Open AI, %s, %s Bible, %s, %s, scripture research, getBible"
COM_GETBIBLE_OPEN_AN_ISSUE="Open an Issue"
COM_GETBIBLE_OPEN_TAG="Open Tag"
COM_GETBIBLE_PARAGRAPH="Paragraph"

View File

@ -40,7 +40,9 @@ class GetbibleViewOpenai extends HtmlView
$this->translation = $this->get('Translation');
// remove from page (in case debug mode is on)
$this->params->set('openai_token', null);
$this->params->set('gitea_token', null);
$this->params->set('gitea_token', null);
// set meta
$this->setMetaData();
// Set the toolbar
$this->addToolBar();
@ -57,6 +59,524 @@ class GetbibleViewOpenai extends HtmlView
parent::display($tpl);
}
/**
* Set the page metadata
*
* @return void
* @since 2.0.1
*/
protected function setMetaData()
{
if (empty($this->item))
{
return;
}
// set the page title
$title = JText::sprintf('COM_GETBIBLE_OPEN_AI_S_IN_S_S',
$this->getSelectedWord(),
$this->translation->translation,
$this->params->get('page_title', '')
);
$this->document->setTitle($title);
$url = $this->getCanonicalUrl();
// set the Generator
$this->document->setGenerator('getBible! - Open AI - Open Source Bible App.');
// set the metadata values
$description = JText::sprintf('COM_GETBIBLE_OPEN_AI_RESPOND_TO_PROMPT_ABOUT_S_IN_S',
$this->getSelectedWord(),
$this->translation->translation
);
$this->document->setDescription($description);
$this->document->setMetadata('keywords', JText::sprintf('COM_GETBIBLE_OPEN_AI_S_S_BIBLE_S_S_SCRIPTURE_RESEARCH_GETBIBLE',
$this->getSelectedWord(),
$this->translation->translation,
$this->translation->abbreviation,
$this->translation->language
));
$this->document->setMetaData('author', JText::_('COM_GETBIBLE_OPEN_AI'));
// set canonical URL
$this->document->addHeadLink($url, 'canonical');
// OG:Title
$this->document->setMetadata('og:title', $title, 'property');
// OG:Description
$this->document->setMetadata('og:description', $description, 'property');
// OG:Image
// $this->document->setMetadata('og:image', 'YOUR_IMAGE_URL_HERE', 'property');
// OG:URL
$this->document->setMetadata('og:url', $url, 'property');
// OG:Type
$this->document->setMetadata('og:type', 'website', 'property');
// Twitter Card Type
$this->document->setMetadata('twitter:card', 'summary');
// Twitter Title
$this->document->setMetadata('twitter:title', $title);
// Twitter Description
$this->document->setMetadata('twitter:description', $description);
// Twitter Image
// $this->document->setMetadata('twitter:image', 'YOUR_IMAGE_URL_HERE');
// Twitter Site (Your website's Twitter handle)
// $this->document->setMetadata('twitter:site', '@YourTwitterHandle');
// Twitter Creator (Author's Twitter handle or your website's Twitter handle)
// $this->document->setMetadata('twitter:creator', '@AuthorTwitterHandle');
}
/**
* Get the canonical url
*
* @return string
* @since 2.0.1
*/
public function getCanonicalUrl(): string
{
if (empty($this->url_canonical))
{
$this->setCanonicalUrl();
}
return $this->url_canonical ?? $this->getBaseUrl();
}
/**
* Get the Bible url
*
* @return string
* @since 2.0.1
*/
public function getBibleUrl(): string
{
if (empty($this->url_bible))
{
$this->setBibleUrl();
}
return $this->url_bible;
}
/**
* Get the base url
*
* @return string
* @since 2.0.1
*/
public function getBaseUrl(): string
{
if (empty($this->url_base))
{
$this->setBaseUrl();
}
return $this->url_base ?? '';
}
/**
* Get the AI url
*
* @return string
* @since 2.0.1
*/
public function getAiUrl(): string
{
if (empty($this->url_ai))
{
$this->setAiUrl();
}
return $this->url_ai ?? '';
}
/**
* Get the AJAX url
*
* @return string
* @since 2.0.1
*/
public function getAjaxUrl(): string
{
if (empty($this->url_ajax))
{
$this->setAjaxUrl();
}
return $this->url_ajax ?? '';
}
/**
* Get the return url value
*
* @return string|null
* @since 2.0.1
*/
public function getReturnUrl(): ?string
{
if (empty($this->url_return))
{
$this->setReturnUrl();
}
return $this->url_return ?? null;
}
/**
* Get the return url value
*
* @return string
* @since 2.0.1
*/
public function getReturnUrlValue(): string
{
if (empty($this->url_return_value))
{
$this->setReturnUrl();
}
if (!empty($this->url_return_value))
{
return '&bibleurl=' . $this->url_return_value;
}
return '';
}
/**
* Get the return url book value
*
* @return int
* @since 2.0.1
*/
public function getReturnUrlBook(): int
{
if (empty($this->url_return_query))
{
$this->setReturnUrl();
}
return (int) $this->url_return_query['book'] ?? 0;
}
/**
* Get the return url chapter value
*
* @return int
* @since 2.0.1
*/
public function getReturnUrlChapter(): int
{
if (empty($this->url_return_query))
{
$this->setReturnUrl();
}
return (int) $this->url_return_query['chapter'] ?? 0;
}
/**
* Get the last prompt
*
* @return object|null
* @since 2.0.1
*/
public function getPrompt(): ?object
{
if (empty($this->prompt))
{
$this->setPrompt();
}
return $this->prompt ?? null;
}
/**
* Get the selected word
*
* @return string
* @since 2.0.1
*/
public function getSelectedWord(): string
{
if (empty($this->selected_word))
{
$this->setSelectedWord();
}
return $this->selected_word ?? '';
}
/**
* Get the word number/s
*
* @return string
* @since 2.0.1
*/
public function getWord(): string
{
if (empty($this->word))
{
$this->setWord();
}
return $this->word ?? '';
}
/**
* Get the verse number/s
*
* @return string
* @since 2.0.1
*/
public function getVerse(): string
{
if (empty($this->verse))
{
$this->setVerse();
}
return $this->verse ?? '';
}
/**
* Get the chapter number/s
*
* @return string
* @since 2.0.1
*/
public function getChapter(): string
{
if (empty($this->chapter))
{
$this->setChapter();
}
return $this->chapter ?? '';
}
/**
* Get the book number/s
*
* @return string
* @since 2.0.1
*/
public function getBook(): string
{
if (empty($this->book))
{
$this->setBook();
}
return $this->book ?? '';
}
/**
* Get the prompt guid
*
* @return string
* @since 2.0.1
*/
public function getGuid(): string
{
if (empty($this->prompt_guid))
{
$this->setGuid();
}
return $this->prompt_guid ?? '';
}
/**
* Set the return URL if it's provided and internal.
*
* @return void
* @since 2.0.1
*/
protected function setReturnUrl(): void
{
$encodedUrl = $this->input->get('bibleurl', null, 'base64');
if ($encodedUrl === null)
{
return;
}
$decodedUrl = base64_decode($encodedUrl);
$uri = JUri::getInstance($decodedUrl);
$router = JRouter::getInstance('site');
$this->url_return_value = $encodedUrl;
$this->url_return = $decodedUrl;
$this->url_return_query = $router->parse($uri);
}
/**
* Set the prompt guid
*
* @return void
* @since 2.0.1
*/
protected function setGuid()
{
$prompt = $this->getPrompt();
$this->prompt_guid = $prompt->prompt ?? '';
}
/**
* Set the book number/s
*
* @return void
* @since 2.0.1
*/
protected function setBook()
{
$prompt = $this->getPrompt();
$this->book = $prompt->book ?? '';
}
/**
* Set the chapter number/s
*
* @return void
* @since 2.0.1
*/
protected function setChapter()
{
$prompt = $this->getPrompt();
$this->chapter = $prompt->chapter ?? '';
}
/**
* Set the verse number/s
*
* @return void
* @since 2.0.1
*/
protected function setVerse()
{
$prompt = $this->getPrompt();
$this->verse = $prompt->verse ?? '';
}
/**
* Set the word number/s
*
* @return void
* @since 2.0.1
*/
protected function setWord()
{
$prompt = $this->getPrompt();
$this->word = $prompt->word ?? '';
}
/**
* Set the selected word
*
* @return void
* @since 2.0.1
*/
public function setSelectedWord()
{
$prompt = $this->getPrompt();
$this->selected_word = $prompt->selected_word ?? '';
}
/**
* Set the last prompt
*
* @return void
* @since 2.0.1
*/
protected function setPrompt()
{
// Check if the 'item' property or its first element is empty.
if (empty($this->item) || empty($this->item[0]))
{
return;
}
// Set the last item from the 'item' array as the prompt.
$this->prompt = end($this->item);
// Reset the internal pointer of the array to ensure consistent behaviour elsewhere.
reset($this->item);
}
/**
* Set the base url
*
* @return void
* @since 2.0.1
*/
protected function setBaseUrl()
{
$this->url_base = JUri::base();
}
/**
* Set the AJAX url
*
* @return void
* @since 2.0.1
*/
protected function setAjaxUrl()
{
$this->url_ajax = $this->getBaseUrl() . 'index.php?option=com_getbible&format=json&raw=true&' . JSession::getFormToken() . '=1&task=ajax.';
}
/**
* Set the Bible url
*
* @return void
* @since 2.0.1
*/
protected function setBibleUrl()
{
$this->url_bible = $this->getReturnUrl() ?? JRoute::_('index.php?option=com_getbible&view=app&Itemid=' . $this->params->get('app_menu', 0) . '&t=' . $this->translation->abbreviation);
}
/**
* Set the AI url
*
* @return void
* @since 2.0.1
*/
protected function setAiUrl()
{
// set the current search URL
$this->url_ai = JRoute::_('index.php?option=com_getbible&view=openai&t=' . $this->translation->abbreviation .
'&Itemid=' . $this->params->get('app_menu', 0) .
$this->getReturnUrlValue() .
'&guid=' . $this->getGuid() .
'&book=' . $this->getBook() .
'&chapter=' . $this->getChapter() .
'&verse=' . $this->getVerse() .
'&words=' . $this->getWord());
}
/**
* Set the canonical url
*
* @return void
* @since 2.0.1
*/
protected function setCanonicalUrl()
{
// set the current search URL
$this->url_canonical = trim($this->getBaseUrl(), '/') .
JRoute::_('index.php?option=com_getbible&view=openai&Itemid=' . $this->params->get('app_menu', 0) .
'&t=' . $this->translation->abbreviation .
'&guid=' . $this->getGuid() .
'&book=' . $this->getBook() .
'&chapter=' . $this->getChapter() .
'&verse=' . $this->getVerse() .
'&words=' . $this->getWord());
}
/**
* Prepares the document
*/

View File

@ -377,4 +377,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>2.0.23</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/v2.0.23.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>