2023-07-26 09:09:42 +00:00
|
|
|
<?php
|
|
|
|
/*----------------------------------------------------------------------------------| io.vdm.dev |----/
|
|
|
|
Vast Development Method
|
|
|
|
/-------------------------------------------------------------------------------------------------------/
|
|
|
|
|
|
|
|
@package getBible.net
|
|
|
|
|
|
|
|
@created 3rd December, 2015
|
|
|
|
@author Llewellyn van der Merwe <https://getbible.net>
|
|
|
|
@git Get Bible <https://git.vdm.dev/getBible>
|
|
|
|
@github Get Bible <https://github.com/getBible>
|
|
|
|
@support Get Bible <https://git.vdm.dev/getBible/support>
|
|
|
|
@copyright Copyright (C) 2015. All Rights Reserved
|
|
|
|
@license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html
|
|
|
|
|
|
|
|
/------------------------------------------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
// No direct access to this file
|
|
|
|
defined('_JEXEC') or die('Restricted access');
|
|
|
|
|
2024-01-22 08:48:28 +00:00
|
|
|
use Joomla\CMS\Factory;
|
|
|
|
use Joomla\CMS\Language\Text;
|
|
|
|
use Joomla\CMS\Uri\Uri;
|
|
|
|
use Joomla\CMS\Session\Session;
|
|
|
|
use Joomla\CMS\HTML\HTMLHelper as Html;
|
|
|
|
use Joomla\CMS\Component\ComponentHelper;
|
2023-07-26 09:09:42 +00:00
|
|
|
use Joomla\CMS\MVC\Model\ListModel;
|
2024-01-22 08:48:28 +00:00
|
|
|
use Joomla\CMS\Plugin\PluginHelper;
|
2023-07-26 09:09:42 +00:00
|
|
|
use Joomla\Utilities\ArrayHelper;
|
|
|
|
use Joomla\Registry\Registry;
|
2024-01-22 08:48:28 +00:00
|
|
|
use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper;
|
|
|
|
use VDM\Joomla\Utilities\StringHelper;
|
2023-07-26 09:09:42 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Getbible List Model
|
|
|
|
*/
|
|
|
|
class GetbibleModelGetbible extends ListModel
|
|
|
|
{
|
|
|
|
public function getIcons()
|
|
|
|
{
|
|
|
|
// load user for access menus
|
2024-01-22 08:48:28 +00:00
|
|
|
$user = Factory::getUser();
|
2023-07-26 09:09:42 +00:00
|
|
|
// reset icon array
|
2024-01-22 08:48:28 +00:00
|
|
|
$icons = [];
|
2023-07-26 09:09:42 +00:00
|
|
|
// view groups array
|
|
|
|
$viewGroups = array(
|
|
|
|
'main' => array('png.linkers', 'png.notes', 'png.tagged_verses', 'png.prompts', 'png.open_ai_responses', 'png.tags', 'png.translations', 'png.books', 'png.chapters', 'png.verses')
|
|
|
|
);
|
|
|
|
// view access array
|
2023-11-09 06:11:41 +00:00
|
|
|
$viewAccess = [
|
2023-07-26 09:09:42 +00:00
|
|
|
'linker.create' => 'linker.create',
|
|
|
|
'linkers.access' => 'linker.access',
|
|
|
|
'linker.access' => 'linker.access',
|
|
|
|
'linkers.submenu' => 'linker.submenu',
|
|
|
|
'linkers.dashboard_list' => 'linker.dashboard_list',
|
|
|
|
'note.create' => 'note.create',
|
|
|
|
'notes.access' => 'note.access',
|
|
|
|
'note.access' => 'note.access',
|
|
|
|
'notes.submenu' => 'note.submenu',
|
|
|
|
'notes.dashboard_list' => 'note.dashboard_list',
|
|
|
|
'tagged_verse.create' => 'tagged_verse.create',
|
|
|
|
'tagged_verses.access' => 'tagged_verse.access',
|
|
|
|
'tagged_verse.access' => 'tagged_verse.access',
|
|
|
|
'tagged_verses.submenu' => 'tagged_verse.submenu',
|
|
|
|
'tagged_verses.dashboard_list' => 'tagged_verse.dashboard_list',
|
|
|
|
'prompt.create' => 'prompt.create',
|
|
|
|
'prompts.access' => 'prompt.access',
|
|
|
|
'prompt.access' => 'prompt.access',
|
|
|
|
'prompts.submenu' => 'prompt.submenu',
|
|
|
|
'prompts.dashboard_list' => 'prompt.dashboard_list',
|
|
|
|
'open_ai_response.create' => 'open_ai_response.create',
|
|
|
|
'open_ai_responses.access' => 'open_ai_response.access',
|
|
|
|
'open_ai_response.access' => 'open_ai_response.access',
|
|
|
|
'open_ai_responses.submenu' => 'open_ai_response.submenu',
|
|
|
|
'open_ai_responses.dashboard_list' => 'open_ai_response.dashboard_list',
|
|
|
|
'open_ai_message.create' => 'open_ai_message.create',
|
|
|
|
'open_ai_messages.access' => 'open_ai_message.access',
|
|
|
|
'open_ai_message.access' => 'open_ai_message.access',
|
|
|
|
'password.create' => 'password.create',
|
|
|
|
'passwords.access' => 'password.access',
|
|
|
|
'password.access' => 'password.access',
|
|
|
|
'tag.create' => 'tag.create',
|
|
|
|
'tags.access' => 'tag.access',
|
|
|
|
'tag.access' => 'tag.access',
|
|
|
|
'tags.submenu' => 'tag.submenu',
|
|
|
|
'tags.dashboard_list' => 'tag.dashboard_list',
|
|
|
|
'translation.create' => 'translation.create',
|
|
|
|
'translations.access' => 'translation.access',
|
|
|
|
'translation.access' => 'translation.access',
|
|
|
|
'translations.submenu' => 'translation.submenu',
|
|
|
|
'translations.dashboard_list' => 'translation.dashboard_list',
|
|
|
|
'book.create' => 'book.create',
|
|
|
|
'books.access' => 'book.access',
|
|
|
|
'book.access' => 'book.access',
|
|
|
|
'books.submenu' => 'book.submenu',
|
|
|
|
'books.dashboard_list' => 'book.dashboard_list',
|
|
|
|
'chapter.create' => 'chapter.create',
|
|
|
|
'chapters.access' => 'chapter.access',
|
|
|
|
'chapter.access' => 'chapter.access',
|
|
|
|
'chapters.submenu' => 'chapter.submenu',
|
|
|
|
'chapters.dashboard_list' => 'chapter.dashboard_list',
|
|
|
|
'verse.create' => 'verse.create',
|
|
|
|
'verses.access' => 'verse.access',
|
|
|
|
'verse.access' => 'verse.access',
|
|
|
|
'verses.submenu' => 'verse.submenu',
|
2023-11-09 06:11:41 +00:00
|
|
|
'verses.dashboard_list' => 'verse.dashboard_list',
|
|
|
|
];
|
2023-07-26 09:09:42 +00:00
|
|
|
// loop over the $views
|
|
|
|
foreach($viewGroups as $group => $views)
|
|
|
|
{
|
|
|
|
$i = 0;
|
2024-01-22 08:48:28 +00:00
|
|
|
if (UtilitiesArrayHelper::check($views))
|
2023-07-26 09:09:42 +00:00
|
|
|
{
|
|
|
|
foreach($views as $view)
|
|
|
|
{
|
|
|
|
$add = false;
|
|
|
|
// external views (links)
|
|
|
|
if (strpos($view,'||') !== false)
|
|
|
|
{
|
|
|
|
$dwd = explode('||', $view);
|
|
|
|
if (count($dwd) == 3)
|
|
|
|
{
|
|
|
|
list($type, $name, $url) = $dwd;
|
2024-01-22 08:48:28 +00:00
|
|
|
$viewName = $name;
|
|
|
|
$alt = $name;
|
|
|
|
$url = $url;
|
|
|
|
$image = $name . '.' . $type;
|
|
|
|
$name = 'COM_GETBIBLE_DASHBOARD_' . StringHelper::safe($name,'U');
|
2023-07-26 09:09:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
// internal views
|
|
|
|
elseif (strpos($view,'.') !== false)
|
|
|
|
{
|
|
|
|
$dwd = explode('.', $view);
|
|
|
|
if (count($dwd) == 3)
|
|
|
|
{
|
|
|
|
list($type, $name, $action) = $dwd;
|
|
|
|
}
|
|
|
|
elseif (count($dwd) == 2)
|
|
|
|
{
|
|
|
|
list($type, $name) = $dwd;
|
|
|
|
$action = false;
|
|
|
|
}
|
|
|
|
if ($action)
|
|
|
|
{
|
|
|
|
$viewName = $name;
|
|
|
|
switch($action)
|
|
|
|
{
|
|
|
|
case 'add':
|
2024-01-22 08:48:28 +00:00
|
|
|
$url = 'index.php?option=com_getbible&view=' . $name . '&layout=edit';
|
|
|
|
$image = $name . '_' . $action. '.' . $type;
|
|
|
|
$alt = $name . ' ' . $action;
|
|
|
|
$name = 'COM_GETBIBLE_DASHBOARD_'.StringHelper::safe($name,'U').'_ADD';
|
|
|
|
$add = true;
|
2023-07-26 09:09:42 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
// check for new convention (more stable)
|
|
|
|
if (strpos($action, '_qpo0O0oqp_') !== false)
|
|
|
|
{
|
|
|
|
list($action, $extension) = (array) explode('_qpo0O0oqp_', $action);
|
|
|
|
$extension = str_replace('_po0O0oq_', '.', $extension);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$extension = 'com_getbible.' . $name;
|
|
|
|
}
|
2024-01-22 08:48:28 +00:00
|
|
|
$url = 'index.php?option=com_categories&view=categories&extension=' . $extension;
|
|
|
|
$image = $name . '_' . $action . '.' . $type;
|
|
|
|
$alt = $viewName . ' ' . $action;
|
|
|
|
$name = 'COM_GETBIBLE_DASHBOARD_' . StringHelper::safe($name,'U') . '_' . StringHelper::safe($action,'U');
|
2023-07-26 09:09:42 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2024-01-22 08:48:28 +00:00
|
|
|
$viewName = $name;
|
|
|
|
$alt = $name;
|
|
|
|
$url = 'index.php?option=com_getbible&view=' . $name;
|
|
|
|
$image = $name . '.' . $type;
|
|
|
|
$name = 'COM_GETBIBLE_DASHBOARD_' . StringHelper::safe($name,'U');
|
|
|
|
$hover = false;
|
2023-07-26 09:09:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2024-01-22 08:48:28 +00:00
|
|
|
$viewName = $view;
|
|
|
|
$alt = $view;
|
|
|
|
$url = 'index.php?option=com_getbible&view=' . $view;
|
|
|
|
$image = $view . '.png';
|
|
|
|
$name = ucwords($view).'<br /><br />';
|
|
|
|
$hover = false;
|
2023-07-26 09:09:42 +00:00
|
|
|
}
|
|
|
|
// first make sure the view access is set
|
2024-01-22 08:48:28 +00:00
|
|
|
if (UtilitiesArrayHelper::check($viewAccess))
|
2023-07-26 09:09:42 +00:00
|
|
|
{
|
|
|
|
// setup some defaults
|
|
|
|
$dashboard_add = false;
|
|
|
|
$dashboard_list = false;
|
|
|
|
$accessTo = '';
|
|
|
|
$accessAdd = '';
|
|
|
|
// access checking start
|
2024-01-22 08:48:28 +00:00
|
|
|
$accessCreate = (isset($viewAccess[$viewName.'.create'])) ? StringHelper::check($viewAccess[$viewName.'.create']):false;
|
|
|
|
$accessAccess = (isset($viewAccess[$viewName.'.access'])) ? StringHelper::check($viewAccess[$viewName.'.access']):false;
|
2023-07-26 09:09:42 +00:00
|
|
|
// set main controllers
|
2024-01-22 08:48:28 +00:00
|
|
|
$accessDashboard_add = (isset($viewAccess[$viewName.'.dashboard_add'])) ? StringHelper::check($viewAccess[$viewName.'.dashboard_add']):false;
|
|
|
|
$accessDashboard_list = (isset($viewAccess[$viewName.'.dashboard_list'])) ? StringHelper::check($viewAccess[$viewName.'.dashboard_list']):false;
|
2023-07-26 09:09:42 +00:00
|
|
|
// check for adding access
|
|
|
|
if ($add && $accessCreate)
|
|
|
|
{
|
|
|
|
$accessAdd = $viewAccess[$viewName.'.create'];
|
|
|
|
}
|
|
|
|
elseif ($add)
|
|
|
|
{
|
|
|
|
$accessAdd = 'core.create';
|
|
|
|
}
|
|
|
|
// check if access to view is set
|
|
|
|
if ($accessAccess)
|
|
|
|
{
|
|
|
|
$accessTo = $viewAccess[$viewName.'.access'];
|
|
|
|
}
|
|
|
|
// set main access controllers
|
|
|
|
if ($accessDashboard_add)
|
|
|
|
{
|
2024-01-22 08:48:28 +00:00
|
|
|
$dashboard_add = $user->authorise($viewAccess[$viewName.'.dashboard_add'], 'com_getbible');
|
2023-07-26 09:09:42 +00:00
|
|
|
}
|
|
|
|
if ($accessDashboard_list)
|
|
|
|
{
|
|
|
|
$dashboard_list = $user->authorise($viewAccess[$viewName.'.dashboard_list'], 'com_getbible');
|
|
|
|
}
|
2024-01-22 08:48:28 +00:00
|
|
|
if (StringHelper::check($accessAdd) && StringHelper::check($accessTo))
|
2023-07-26 09:09:42 +00:00
|
|
|
{
|
|
|
|
// check access
|
|
|
|
if($user->authorise($accessAdd, 'com_getbible') && $user->authorise($accessTo, 'com_getbible') && $dashboard_add)
|
|
|
|
{
|
2024-01-22 08:48:28 +00:00
|
|
|
$icons[$group][$i] = new StdClass;
|
|
|
|
$icons[$group][$i]->url = $url;
|
|
|
|
$icons[$group][$i]->name = $name;
|
|
|
|
$icons[$group][$i]->image = $image;
|
|
|
|
$icons[$group][$i]->alt = $alt;
|
2023-07-26 09:09:42 +00:00
|
|
|
}
|
|
|
|
}
|
2024-01-22 08:48:28 +00:00
|
|
|
elseif (StringHelper::check($accessTo))
|
2023-07-26 09:09:42 +00:00
|
|
|
{
|
|
|
|
// check access
|
|
|
|
if($user->authorise($accessTo, 'com_getbible') && $dashboard_list)
|
|
|
|
{
|
2024-01-22 08:48:28 +00:00
|
|
|
$icons[$group][$i] = new StdClass;
|
|
|
|
$icons[$group][$i]->url = $url;
|
|
|
|
$icons[$group][$i]->name = $name;
|
|
|
|
$icons[$group][$i]->image = $image;
|
|
|
|
$icons[$group][$i]->alt = $alt;
|
2023-07-26 09:09:42 +00:00
|
|
|
}
|
|
|
|
}
|
2024-01-22 08:48:28 +00:00
|
|
|
elseif (StringHelper::check($accessAdd))
|
2023-07-26 09:09:42 +00:00
|
|
|
{
|
|
|
|
// check access
|
|
|
|
if($user->authorise($accessAdd, 'com_getbible') && $dashboard_add)
|
|
|
|
{
|
2024-01-22 08:48:28 +00:00
|
|
|
$icons[$group][$i] = new StdClass;
|
|
|
|
$icons[$group][$i]->url = $url;
|
|
|
|
$icons[$group][$i]->name = $name;
|
|
|
|
$icons[$group][$i]->image = $image;
|
|
|
|
$icons[$group][$i]->alt = $alt;
|
2023-07-26 09:09:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2024-01-22 08:48:28 +00:00
|
|
|
$icons[$group][$i] = new StdClass;
|
|
|
|
$icons[$group][$i]->url = $url;
|
|
|
|
$icons[$group][$i]->name = $name;
|
|
|
|
$icons[$group][$i]->image = $image;
|
|
|
|
$icons[$group][$i]->alt = $alt;
|
2023-07-26 09:09:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2024-01-22 08:48:28 +00:00
|
|
|
$icons[$group][$i] = new StdClass;
|
|
|
|
$icons[$group][$i]->url = $url;
|
|
|
|
$icons[$group][$i]->name = $name;
|
|
|
|
$icons[$group][$i]->image = $image;
|
|
|
|
$icons[$group][$i]->alt = $alt;
|
2023-07-26 09:09:42 +00:00
|
|
|
}
|
|
|
|
$i++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$icons[$group][$i] = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $icons;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function getWiki()
|
|
|
|
{
|
|
|
|
// the call URL
|
2024-01-22 08:48:28 +00:00
|
|
|
$call_url = Uri::base() . 'index.php?option=com_getbible&task=ajax.getWiki&format=json&raw=true&' . Session::getFormToken() . '=1&name=Home';
|
|
|
|
$document = Factory::getDocument();
|
2023-07-26 09:09:42 +00:00
|
|
|
$document->addScriptDeclaration('
|
|
|
|
function getWikiPage(){
|
|
|
|
fetch("' . $call_url . '").then((response) => {
|
|
|
|
if (response.ok) {
|
|
|
|
return response.json();
|
|
|
|
}
|
|
|
|
}).then((result) => {
|
|
|
|
if (typeof result.page !== "undefined") {
|
2024-01-22 08:48:28 +00:00
|
|
|
document.getElementById("wiki-md").innerHTML = marked.parse(result.page);
|
2023-07-26 09:09:42 +00:00
|
|
|
} else if (typeof result.error !== "undefined") {
|
|
|
|
document.getElementById("wiki-md-error").innerHTML = result.error
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
setTimeout(getWikiPage, 1000);');
|
|
|
|
|
2024-01-22 08:48:28 +00:00
|
|
|
return '<div id="wiki-md"><small>'.Text::_('COM_GETBIBLE_THE_WIKI_IS_LOADING').'.<span class="loading-dots">.</span></small></div><div id="wiki-md-error" style="color: red"></div>';
|
2023-07-26 09:09:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function getNoticeboard()
|
|
|
|
{
|
|
|
|
// get the document to load the scripts
|
2024-01-22 08:48:28 +00:00
|
|
|
$document = Factory::getDocument();
|
|
|
|
Html::_('script', "media/com_getbible/js/marked.js", ['version' => 'auto']);
|
2023-07-26 09:09:42 +00:00
|
|
|
$document->addScriptDeclaration('
|
2024-01-22 08:48:28 +00:00
|
|
|
var token = "' . Session::getFormToken() . '";
|
2023-07-26 09:09:42 +00:00
|
|
|
var noticeboard = "https://vdm.bz/getbible-noticeboard-md";
|
2024-01-22 08:48:28 +00:00
|
|
|
document.addEventListener("DOMContentLoaded", function() {
|
|
|
|
fetch(noticeboard)
|
|
|
|
.then(response => {
|
|
|
|
if (!response.ok) {
|
|
|
|
throw new Error("Network response was not ok");
|
|
|
|
}
|
|
|
|
return response.text();
|
|
|
|
})
|
|
|
|
.then(board => {
|
2023-07-26 09:09:42 +00:00
|
|
|
if (board.length > 5) {
|
2024-01-22 08:48:28 +00:00
|
|
|
document.getElementById("noticeboard-md").innerHTML = marked.parse(board);
|
|
|
|
getIS(1, board)
|
|
|
|
.then(result => {
|
|
|
|
if (result) {
|
|
|
|
document.querySelectorAll("#cpanel_tabTabs a").forEach(link => {
|
|
|
|
if (link.href.includes("#vast_development_method") || link.href.includes("#notice_board")) {
|
|
|
|
var textVDM = link.textContent;
|
|
|
|
link.innerHTML = "<span class=\"label label-important vdm-new-notice\">1</span> " + textVDM;
|
|
|
|
link.id = "vdm-new-notice";
|
|
|
|
document.getElementById("vdm-new-notice").addEventListener("click", () => {
|
|
|
|
getIS(2, board)
|
|
|
|
.then(result => {
|
|
|
|
if (result) {
|
|
|
|
document.querySelectorAll(".vdm-new-notice").forEach(element => {
|
|
|
|
element.style.opacity = 0;
|
|
|
|
});
|
2023-07-26 09:09:42 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
} else {
|
2024-01-22 08:48:28 +00:00
|
|
|
document.getElementById("noticeboard-md").innerHTML = "'.Text::_('COM_GETBIBLE_ALL_IS_GOOD_PLEASE_CHECK_AGAIN_LATER').'.";
|
2023-07-26 09:09:42 +00:00
|
|
|
}
|
|
|
|
})
|
2024-01-22 08:48:28 +00:00
|
|
|
.catch(error => {
|
|
|
|
console.error("There was an error!", error);
|
|
|
|
document.getElementById("noticeboard-md").innerHTML = "'.Text::_('COM_GETBIBLE_ALL_IS_GOOD_PLEASE_CHECK_AGAIN_LATER').'.";
|
2023-07-26 09:09:42 +00:00
|
|
|
});
|
|
|
|
});
|
2024-01-22 08:48:28 +00:00
|
|
|
|
2023-07-26 09:09:42 +00:00
|
|
|
// to check is READ/NEW
|
2024-01-22 08:48:28 +00:00
|
|
|
function getIS(type, notice) {
|
|
|
|
let getUrl = "";
|
|
|
|
if (type === 1) {
|
|
|
|
getUrl = "index.php?option=com_getbible&task=ajax.isNew&format=json&raw=true";
|
|
|
|
} else if (type === 2) {
|
|
|
|
getUrl = "index.php?option=com_getbible&task=ajax.isRead&format=json&raw=true";
|
2023-07-26 09:09:42 +00:00
|
|
|
}
|
2024-01-22 08:48:28 +00:00
|
|
|
let request = new URLSearchParams();
|
|
|
|
if (token.length > 0 && notice.length) {
|
|
|
|
request.append(token, "1");
|
|
|
|
request.append("notice", notice);
|
|
|
|
}
|
|
|
|
return fetch(getUrl, {
|
|
|
|
method: "POST",
|
|
|
|
headers: {
|
|
|
|
"Content-Type": "application/x-www-form-urlencoded;charset=UTF-8"
|
|
|
|
},
|
|
|
|
body: request
|
|
|
|
}).then(response => response.json());
|
2023-07-26 09:09:42 +00:00
|
|
|
}
|
|
|
|
|
2024-01-22 08:48:28 +00:00
|
|
|
document.addEventListener("DOMContentLoaded", function() {
|
|
|
|
document.querySelectorAll(".loading-dots").forEach(function(loading_dots) {
|
|
|
|
let x = 0;
|
|
|
|
let intervalId = setInterval(function() {
|
|
|
|
if (!loading_dots.classList.contains("loading-dots")) {
|
|
|
|
clearInterval(intervalId);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
let dots = ".".repeat(x % 8);
|
|
|
|
loading_dots.textContent = dots;
|
|
|
|
x++;
|
|
|
|
}, 500);
|
|
|
|
});
|
2023-07-26 09:09:42 +00:00
|
|
|
});');
|
|
|
|
|
2024-01-22 08:48:28 +00:00
|
|
|
return '<div id="noticeboard-md">'.Text::_('COM_GETBIBLE_THE_NOTICE_BOARD_IS_LOADING').'.<span class="loading-dots">.</span></small></div>';
|
2023-07-26 09:09:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public function getReadme()
|
|
|
|
{
|
2024-01-22 08:48:28 +00:00
|
|
|
$document = Factory::getDocument();
|
2023-07-26 09:09:42 +00:00
|
|
|
$document->addScriptDeclaration('
|
2024-01-22 08:48:28 +00:00
|
|
|
var getreadme = "'. Uri::root() . 'administrator/components/com_getbible/README.txt";
|
|
|
|
document.addEventListener("DOMContentLoaded", function () {
|
|
|
|
fetch(getreadme)
|
|
|
|
.then(response => {
|
|
|
|
if (!response.ok) {
|
|
|
|
throw new Error("Network response was not ok");
|
|
|
|
}
|
|
|
|
return response.text();
|
|
|
|
})
|
|
|
|
.then(readme => {
|
|
|
|
document.getElementById("readme-md").innerHTML = marked.parse(readme);
|
2023-07-26 09:09:42 +00:00
|
|
|
})
|
2024-01-22 08:48:28 +00:00
|
|
|
.catch(error => {
|
|
|
|
console.error("There has been a problem with your fetch operation:", error);
|
|
|
|
document.getElementById("readme-md").innerHTML = "'.Text::_('COM_GETBIBLE_PLEASE_CHECK_AGAIN_LATER').'.";
|
2023-07-26 09:09:42 +00:00
|
|
|
});
|
|
|
|
});');
|
|
|
|
|
2024-01-22 08:48:28 +00:00
|
|
|
return '<div id="readme-md"><small>'.Text::_('COM_GETBIBLE_THE_README_IS_LOADING').'.<span class="loading-dots">.</span></small></div>';
|
2023-07-26 09:09:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* get Current Version Bay adding JavaScript to the Page
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
* @since 2.3.0
|
|
|
|
*/
|
|
|
|
public function getVersion()
|
|
|
|
{
|
|
|
|
// the call URL
|
2024-01-22 08:48:28 +00:00
|
|
|
$call_url = Uri::base() . 'index.php?option=com_getbible&task=ajax.getVersion&format=json&raw=true&' . Session::getFormToken() . '=1&version=1';
|
|
|
|
$document = Factory::getDocument();
|
2023-07-26 09:09:42 +00:00
|
|
|
$document->addScriptDeclaration('
|
|
|
|
function getComponentVersionStatus() {
|
|
|
|
fetch("' . $call_url . '").then((response) => {
|
|
|
|
if (response.ok) {
|
|
|
|
return response.json();
|
|
|
|
}
|
|
|
|
}).then((result) => {
|
|
|
|
if (typeof result.notice !== "undefined") {
|
|
|
|
document.getElementById("component-update-notice").innerHTML = result.notice;
|
|
|
|
} else if (typeof result.error !== "undefined") {
|
|
|
|
document.getElementById("component-update-notice").innerHTML = result.error;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
setTimeout(getComponentVersionStatus, 800);');
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|