update 2023-07-04 07:26:00
This commit is contained in:
parent
87814d74f2
commit
c298dbff03
90
README.md
90
README.md
@ -1,89 +1 @@
|
||||
```
|
||||
███████╗██╗ ██╗██████╗ ███████╗██████╗
|
||||
██╔════╝██║ ██║██╔══██╗██╔════╝██╔══██╗
|
||||
███████╗██║ ██║██████╔╝█████╗ ██████╔╝
|
||||
╚════██║██║ ██║██╔═══╝ ██╔══╝ ██╔══██╗
|
||||
███████║╚██████╔╝██║ ███████╗██║ ██║
|
||||
╚══════╝ ╚═════╝ ╚═╝ ╚══════╝╚═╝ ╚═╝
|
||||
██████╗ ██████╗ ██╗ ██╗███████╗██████╗ ███████╗
|
||||
██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗██╔════╝
|
||||
██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝███████╗
|
||||
██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗╚════██║
|
||||
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║███████║
|
||||
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝╚══════╝
|
||||
```
|
||||
|
||||
### What is JCB Super Powers?
|
||||
The Joomla Component Builder (JCB) Super Power features are designed to enhance JCB's functionality and streamline the development process. These Super Powers enable developers to efficiently manage and share their custom powers across multiple JCB instances through repositories hosted on [https://git.vdm.dev/[username]/[repository-name]](https://git.vdm.dev). JCB Super Powers are managed using a combination of layers, events, tasks, methods, switches, and algorithms, which work together to provide powerful customization and extensibility options. More details on JCB Super Powers can be found in the [Super Powers Documentation](https://git.vdm.dev/joomla/super-powers/wiki).
|
||||
|
||||
In summary, JCB Super Powers offer a flexible and efficient way to manage and share functionalities between JCB instances. By utilizing a sophisticated system of layers, events, tasks, methods, switches, and algorithms, developers can seamlessly integrate JCB core powers and their custom powers. For more information on how to work with JCB Super Powers, refer to the [Super Powers User Guide](https://git.vdm.dev/joomla/super-powers/wiki).
|
||||
|
||||
### What can I find here?
|
||||
This repository contains an index (see below) of all the approved powers within the JCB GUI. During the compilation of a component, these powers are automatically added to the repository, ensuring a well-organized and accessible collection of functionalities.
|
||||
|
||||
# Index of powers
|
||||
|
||||
- **Namespace**: [VDM\Joomla\GetBible](#vdm-joomla-getbible)
|
||||
|
||||
- **abstract class Factory** | [Details](src/11892cfa-374e-4e3f-b0bc-531871c822d9) | [Code](src/11892cfa-374e-4e3f-b0bc-531871c822d9/code.php) | [Settings](src/11892cfa-374e-4e3f-b0bc-531871c822d9/settings.json) | Super__11892cfa_374e_4e3f_b0bc_531871c822d9__Power
|
||||
- **abstract class Openai** | [Details](src/f722bb8b-d377-4425-b1e4-2fe1734a3664) | [Code](src/f722bb8b-d377-4425-b1e4-2fe1734a3664/code.php) | [Settings](src/f722bb8b-d377-4425-b1e4-2fe1734a3664/settings.json) | Super__f722bb8b_d377_4425_b1e4_2fe1734a3664__Power
|
||||
- **final class DailyScripture** | [Details](src/90f2ee7a-c041-4316-ad54-af4f97fa3003) | [Code](src/90f2ee7a-c041-4316-ad54-af4f97fa3003/code.php) | [Settings](src/90f2ee7a-c041-4316-ad54-af4f97fa3003/settings.json) | Super__90f2ee7a_c041_4316_ad54_af4f97fa3003__Power
|
||||
- **final class Search** | [Details](src/8336e3c4-f11b-41bc-a2b1-976f99442a84) | [Code](src/8336e3c4-f11b-41bc-a2b1-976f99442a84/code.php) | [Settings](src/8336e3c4-f11b-41bc-a2b1-976f99442a84/settings.json) | Super__8336e3c4_f11b_41bc_a2b1_976f99442a84__Power
|
||||
- **final class Watcher** | [Details](src/f815fb33-f721-48a5-a84e-53f1986e8881) | [Code](src/f815fb33-f721-48a5-a84e-53f1986e8881/code.php) | [Settings](src/f815fb33-f721-48a5-a84e-53f1986e8881/settings.json) | Super__f815fb33_f721_48a5_a84e_53f1986e8881__Power
|
||||
- **class Config** | [Details](src/71075f03-4e77-4fc0-840a-ef55fd9260b2) | [Code](src/71075f03-4e77-4fc0-840a-ef55fd9260b2/code.php) | [Settings](src/71075f03-4e77-4fc0-840a-ef55fd9260b2/settings.json) | Super__71075f03_4e77_4fc0_840a_ef55fd9260b2__Power
|
||||
- **class Table** | [Details](src/ff8d5fdb-2d1f-4178-bd18-a43b8efd1068) | [Code](src/ff8d5fdb-2d1f-4178-bd18-a43b8efd1068/code.php) | [Settings](src/ff8d5fdb-2d1f-4178-bd18-a43b8efd1068/settings.json) | Super__ff8d5fdb_2d1f_4178_bd18_a43b8efd1068__Power
|
||||
- **Namespace**: [VDM\Joomla\GetBible\Abstraction](#vdm-joomla-getbible-abstraction)
|
||||
|
||||
- **abstract class Api** | [Details](src/7b490e63-8d1f-46de-a0c4-154272fd5d7f) | [Code](src/7b490e63-8d1f-46de-a0c4-154272fd5d7f/code.php) | [Settings](src/7b490e63-8d1f-46de-a0c4-154272fd5d7f/settings.json) | Super__7b490e63_8d1f_46de_a0c4_154272fd5d7f__Power
|
||||
- **Namespace**: [VDM\Joomla\GetBible\Api](#vdm-joomla-getbible-api)
|
||||
|
||||
- **final class Books** | [Details](src/491c91ce-6355-40d3-bbbd-622473c6c026) | [Code](src/491c91ce-6355-40d3-bbbd-622473c6c026/code.php) | [Settings](src/491c91ce-6355-40d3-bbbd-622473c6c026/settings.json) | Super__491c91ce_6355_40d3_bbbd_622473c6c026__Power
|
||||
- **final class Chapters** | [Details](src/a752e4b2-9b5e-4188-8d33-3799c46d5119) | [Code](src/a752e4b2-9b5e-4188-8d33-3799c46d5119/code.php) | [Settings](src/a752e4b2-9b5e-4188-8d33-3799c46d5119/settings.json) | Super__a752e4b2_9b5e_4188_8d33_3799c46d5119__Power
|
||||
- **final class Translations** | [Details](src/be0cae8b-4b78-4f59-b97b-9e31ee6f52e0) | [Code](src/be0cae8b-4b78-4f59-b97b-9e31ee6f52e0/code.php) | [Settings](src/be0cae8b-4b78-4f59-b97b-9e31ee6f52e0/settings.json) | Super__be0cae8b_4b78_4f59_b97b_9e31ee6f52e0__Power
|
||||
- **final class Verses** | [Details](src/afa508bf-78f8-4616-97cc-f2809584c086) | [Code](src/afa508bf-78f8-4616-97cc-f2809584c086/code.php) | [Settings](src/afa508bf-78f8-4616-97cc-f2809584c086/settings.json) | Super__afa508bf_78f8_4616_97cc_f2809584c086__Power
|
||||
- **Namespace**: [VDM\Joomla\GetBible\Database](#vdm-joomla-getbible-database)
|
||||
|
||||
- **final class Insert** | [Details](src/a07d90f6-6ff2-40a1-99c1-0f2cf33c9adf) | [Code](src/a07d90f6-6ff2-40a1-99c1-0f2cf33c9adf/code.php) | [Settings](src/a07d90f6-6ff2-40a1-99c1-0f2cf33c9adf/settings.json) | Super__a07d90f6_6ff2_40a1_99c1_0f2cf33c9adf__Power
|
||||
- **final class Load** | [Details](src/c03b9c61-17d3-4774-a335-783903719f83) | [Code](src/c03b9c61-17d3-4774-a335-783903719f83/code.php) | [Settings](src/c03b9c61-17d3-4774-a335-783903719f83/settings.json) | Super__c03b9c61_17d3_4774_a335_783903719f83__Power
|
||||
- **final class Update** | [Details](src/d7a5f0c6-de60-4d31-b3e4-5d668a8f7d2e) | [Code](src/d7a5f0c6-de60-4d31-b3e4-5d668a8f7d2e/code.php) | [Settings](src/d7a5f0c6-de60-4d31-b3e4-5d668a8f7d2e/settings.json) | Super__d7a5f0c6_de60_4d31_b3e4_5d668a8f7d2e__Power
|
||||
- **Namespace**: [VDM\Joomla\GetBible\Model](#vdm-joomla-getbible-model)
|
||||
|
||||
- **final class Load** | [Details](src/b1bd2b4f-dede-44ad-86e9-2a595a0a9ca0) | [Code](src/b1bd2b4f-dede-44ad-86e9-2a595a0a9ca0/code.php) | [Settings](src/b1bd2b4f-dede-44ad-86e9-2a595a0a9ca0/settings.json) | Super__b1bd2b4f_dede_44ad_86e9_2a595a0a9ca0__Power
|
||||
- **final class Upsert** | [Details](src/91b37bd7-b314-48be-91cf-434ec823bd80) | [Code](src/91b37bd7-b314-48be-91cf-434ec823bd80/code.php) | [Settings](src/91b37bd7-b314-48be-91cf-434ec823bd80/settings.json) | Super__91b37bd7_b314_48be_91cf_434ec823bd80__Power
|
||||
- **Namespace**: [VDM\Joomla\GetBible\Service](#vdm-joomla-getbible-service)
|
||||
|
||||
- **class Api** | [Details](src/b32eea04-6b9c-469d-94db-35d610686cf1) | [Code](src/b32eea04-6b9c-469d-94db-35d610686cf1/code.php) | [Settings](src/b32eea04-6b9c-469d-94db-35d610686cf1/settings.json) | Super__b32eea04_6b9c_469d_94db_35d610686cf1__Power
|
||||
- **class App** | [Details](src/56465044-94ed-4e00-b6db-160c67163df8) | [Code](src/56465044-94ed-4e00-b6db-160c67163df8/code.php) | [Settings](src/56465044-94ed-4e00-b6db-160c67163df8/settings.json) | Super__56465044_94ed_4e00_b6db_160c67163df8__Power
|
||||
- **class Database** | [Details](src/51bb0397-fa7c-4f7a-a4c5-1f95fdacad38) | [Code](src/51bb0397-fa7c-4f7a-a4c5-1f95fdacad38/code.php) | [Settings](src/51bb0397-fa7c-4f7a-a4c5-1f95fdacad38/settings.json) | Super__51bb0397_fa7c_4f7a_a4c5_1f95fdacad38__Power
|
||||
- **class Model** | [Details](src/116eb429-bc51-4d14-b9aa-7145c86a29d1) | [Code](src/116eb429-bc51-4d14-b9aa-7145c86a29d1/code.php) | [Settings](src/116eb429-bc51-4d14-b9aa-7145c86a29d1/settings.json) | Super__116eb429_bc51_4d14_b9aa_7145c86a29d1__Power
|
||||
- **class Openai** | [Details](src/ac5c7679-dd6e-4817-8e48-489e521122f1) | [Code](src/ac5c7679-dd6e-4817-8e48-489e521122f1/code.php) | [Settings](src/ac5c7679-dd6e-4817-8e48-489e521122f1/settings.json) | Super__ac5c7679_dd6e_4817_8e48_489e521122f1__Power
|
||||
- **class Utilities** | [Details](src/b89d74ef-c71c-4a58-8455-5dbdfe94027a) | [Code](src/b89d74ef-c71c-4a58-8455-5dbdfe94027a/code.php) | [Settings](src/b89d74ef-c71c-4a58-8455-5dbdfe94027a/settings.json) | Super__b89d74ef_c71c_4a58_8455_5dbdfe94027a__Power
|
||||
- **Namespace**: [VDM\Joomla\GetBible\Utilities](#vdm-joomla-getbible-utilities)
|
||||
|
||||
- **final class Http** | [Details](src/b8c66089-735e-4081-825c-8fe36b28e4a6) | [Code](src/b8c66089-735e-4081-825c-8fe36b28e4a6/code.php) | [Settings](src/b8c66089-735e-4081-825c-8fe36b28e4a6/settings.json) | Super__b8c66089_735e_4081_825c_8fe36b28e4a6__Power
|
||||
- **final class Response** | [Details](src/c99e85a0-d120-4f25-bcbf-0940dd7b773b) | [Code](src/c99e85a0-d120-4f25-bcbf-0940dd7b773b/code.php) | [Settings](src/c99e85a0-d120-4f25-bcbf-0940dd7b773b/settings.json) | Super__c99e85a0_d120_4f25_bcbf_0940dd7b773b__Power
|
||||
- **final class Uri** | [Details](src/fc9ab6f0-c31b-4077-bb1c-2dcddd36f6bb) | [Code](src/fc9ab6f0-c31b-4077-bb1c-2dcddd36f6bb/code.php) | [Settings](src/fc9ab6f0-c31b-4077-bb1c-2dcddd36f6bb/settings.json) | Super__fc9ab6f0_c31b_4077_bb1c_2dcddd36f6bb__Power
|
||||
|
||||
---
|
||||
```
|
||||
██╗ ██████╗ ██████╗ ███╗ ███╗██╗ █████╗
|
||||
██║██╔═══██╗██╔═══██╗████╗ ████║██║ ██╔══██╗
|
||||
██║██║ ██║██║ ██║██╔████╔██║██║ ███████║
|
||||
██ ██║██║ ██║██║ ██║██║╚██╔╝██║██║ ██╔══██║
|
||||
╚█████╔╝╚██████╔╝╚██████╔╝██║ ╚═╝ ██║███████╗██║ ██║
|
||||
╚════╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
|
||||
██████╗ ██████╗ ███╗ ███╗██████╗ ██████╗ ███╗ ██╗███████╗███╗ ██╗████████╗
|
||||
██╔════╝██╔═══██╗████╗ ████║██╔══██╗██╔═══██╗████╗ ██║██╔════╝████╗ ██║╚══██╔══╝
|
||||
██║ ██║ ██║██╔████╔██║██████╔╝██║ ██║██╔██╗ ██║█████╗ ██╔██╗ ██║ ██║
|
||||
██║ ██║ ██║██║╚██╔╝██║██╔═══╝ ██║ ██║██║╚██╗██║██╔══╝ ██║╚██╗██║ ██║
|
||||
╚██████╗╚██████╔╝██║ ╚═╝ ██║██║ ╚██████╔╝██║ ╚████║███████╗██║ ╚████║ ██║
|
||||
╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═════╝ ╚═╝ ╚═══╝╚══════╝╚═╝ ╚═══╝ ╚═╝
|
||||
██████╗ ██╗ ██╗██╗██╗ ██████╗ ███████╗██████╗
|
||||
██╔══██╗██║ ██║██║██║ ██╔══██╗██╔════╝██╔══██╗
|
||||
██████╔╝██║ ██║██║██║ ██║ ██║█████╗ ██████╔╝
|
||||
██╔══██╗██║ ██║██║██║ ██║ ██║██╔══╝ ██╔══██╗
|
||||
██████╔╝╚██████╔╝██║███████╗██████╔╝███████╗██║ ██║
|
||||
╚═════╝ ╚═════╝ ╚═╝╚══════╝╚═════╝ ╚══════╝╚═╝ ╚═╝
|
||||
```
|
||||
> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder)
|
||||
|
||||
###POWERREADME###
|
@ -1,53 +1 @@
|
||||
```
|
||||
██████╗ ██████╗ ██╗ ██╗███████╗██████╗
|
||||
██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗
|
||||
██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝
|
||||
██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗
|
||||
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
|
||||
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
|
||||
```
|
||||
# class Model (Details)
|
||||
> namespace: **VDM\Joomla\GetBible\Service**
|
||||
```uml
|
||||
@startuml
|
||||
class Model #Gold {
|
||||
+ register(Container $container) : void
|
||||
+ getUpsert(Container $container) : Upsert
|
||||
+ getLoad(Container $container) : Load
|
||||
}
|
||||
|
||||
note right of Model::register
|
||||
Registers the service provider with a DI container.
|
||||
|
||||
since: 2.0.1
|
||||
return: void
|
||||
end note
|
||||
|
||||
note right of Model::getUpsert
|
||||
Get the Upsert class
|
||||
|
||||
since: 2.0.1
|
||||
return: Upsert
|
||||
end note
|
||||
|
||||
note right of Model::getLoad
|
||||
Get the Load class
|
||||
|
||||
since: 2.0.1
|
||||
return: Load
|
||||
end note
|
||||
|
||||
@enduml
|
||||
```
|
||||
|
||||
---
|
||||
```
|
||||
██╗ ██████╗██████╗
|
||||
██║██╔════╝██╔══██╗
|
||||
██║██║ ██████╔╝
|
||||
██ ██║██║ ██╔══██╗
|
||||
╚█████╔╝╚██████╗██████╔╝
|
||||
╚════╝ ╚═════╝╚═════╝
|
||||
```
|
||||
> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder)
|
||||
|
||||
###POWERREADME###
|
@ -9,69 +9,4 @@
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\GetBible\Service;
|
||||
|
||||
|
||||
use Joomla\DI\Container;
|
||||
use Joomla\DI\ServiceProviderInterface;
|
||||
use VDM\Joomla\GetBible\Model\Upsert;
|
||||
use VDM\Joomla\GetBible\Model\Load;
|
||||
|
||||
|
||||
/**
|
||||
* The GetBible Model Service
|
||||
*
|
||||
* @since 2.0.1
|
||||
*/
|
||||
class Model implements ServiceProviderInterface
|
||||
{
|
||||
/**
|
||||
* Registers the service provider with a DI container.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return void
|
||||
* @since 2.0.1
|
||||
*/
|
||||
public function register(Container $container)
|
||||
{
|
||||
$container->alias(Upsert::class, 'GetBible.Model.Upsert')
|
||||
->share('GetBible.Model.Upsert', [$this, 'getUpsert'], true);
|
||||
|
||||
$container->alias(Load::class, 'GetBible.Model.Load')
|
||||
->share('GetBible.Model.Load', [$this, 'getLoad'], true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Upsert class
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Upsert
|
||||
* @since 2.0.1
|
||||
*/
|
||||
public function getUpsert(Container $container): Upsert
|
||||
{
|
||||
return new Upsert(
|
||||
$container->get('GetBible.Config'),
|
||||
$container->get('GetBible.Table')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Load class
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Load
|
||||
* @since 2.0.1
|
||||
*/
|
||||
public function getLoad(Container $container): Load
|
||||
{
|
||||
return new Load(
|
||||
$container->get('GetBible.Config'),
|
||||
$container->get('GetBible.Table')
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
###POWERCODE###
|
||||
|
@ -1,48 +1 @@
|
||||
/**
|
||||
* Registers the service provider with a DI container.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return void
|
||||
* @since 2.0.1
|
||||
*/
|
||||
public function register(Container $container)
|
||||
{
|
||||
$container->alias(Upsert::class, 'GetBible.Model.Upsert')
|
||||
->share('GetBible.Model.Upsert', [$this, 'getUpsert'], true);
|
||||
|
||||
$container->alias(Load::class, 'GetBible.Model.Load')
|
||||
->share('GetBible.Model.Load', [$this, 'getLoad'], true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Upsert class
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Upsert
|
||||
* @since 2.0.1
|
||||
*/
|
||||
public function getUpsert(Container $container): Upsert
|
||||
{
|
||||
return new Upsert(
|
||||
$container->get('GetBible.Config'),
|
||||
$container->get('GetBible.Table')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Load class
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Load
|
||||
* @since 2.0.1
|
||||
*/
|
||||
public function getLoad(Container $container): Load
|
||||
{
|
||||
return new Load(
|
||||
$container->get('GetBible.Config'),
|
||||
$container->get('GetBible.Table')
|
||||
);
|
||||
}
|
||||
###CODEPOWER###
|
@ -1,30 +1 @@
|
||||
{
|
||||
"add_head": "1",
|
||||
"add_licensing_template": "2",
|
||||
"extends": "0",
|
||||
"guid": "116eb429-bc51-4d14-b9aa-7145c86a29d1",
|
||||
"implements": [
|
||||
"-1"
|
||||
],
|
||||
"load_selection": null,
|
||||
"name": "Model",
|
||||
"power_version": "1.0.0",
|
||||
"system_name": "Joomla.GetBible.Service.Model",
|
||||
"type": "class",
|
||||
"use_selection": {
|
||||
"use_selection0": {
|
||||
"use": "91b37bd7-b314-48be-91cf-434ec823bd80",
|
||||
"as": "default"
|
||||
},
|
||||
"use_selection1": {
|
||||
"use": "b1bd2b4f-dede-44ad-86e9-2a595a0a9ca0",
|
||||
"as": "default"
|
||||
}
|
||||
},
|
||||
"namespace": "VDM\\Joomla\\GetBible\\Service.Model",
|
||||
"description": "The GetBible Model Service\r\n\r\n@since 2.0.1",
|
||||
"implements_custom": "ServiceProviderInterface",
|
||||
"licensing_template": "\/**\r\n * @package GetBible\r\n *\r\n * @created 30th May, 2023\r\n * @author Llewellyn van der Merwe <https:\/\/dev.vdm.io>\r\n * @git GetBible <https:\/\/git.vdm.dev\/getBible>\r\n * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.\r\n * @license GNU General Public License version 2 or later; see LICENSE.txt\r\n *\/\r\n",
|
||||
"head": "use Joomla\\DI\\Container;\r\nuse Joomla\\DI\\ServiceProviderInterface;",
|
||||
"composer": ""
|
||||
}
|
||||
###POWERLINKER###
|
@ -1,54 +1 @@
|
||||
```
|
||||
██████╗ ██████╗ ██╗ ██╗███████╗██████╗
|
||||
██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗
|
||||
██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝
|
||||
██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗
|
||||
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
|
||||
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
|
||||
```
|
||||
# abstract class Factory (Details)
|
||||
> namespace: **VDM\Joomla\GetBible**
|
||||
```uml
|
||||
@startuml
|
||||
abstract Factory #Orange {
|
||||
# static $container
|
||||
+ {static} _(string $key) : Mixed
|
||||
+ {static} getContainer() : Container
|
||||
# {static} createContainer() : Container
|
||||
}
|
||||
|
||||
note right of Factory::_
|
||||
Get any class from the package container
|
||||
|
||||
since: 2.0.1
|
||||
return: Mixed
|
||||
end note
|
||||
|
||||
note right of Factory::getContainer
|
||||
Get the global package container
|
||||
|
||||
since: 2.0.1
|
||||
return: Container
|
||||
end note
|
||||
|
||||
note right of Factory::createContainer
|
||||
Create a container object
|
||||
|
||||
since: 2.0.1
|
||||
return: Container
|
||||
end note
|
||||
|
||||
@enduml
|
||||
```
|
||||
|
||||
---
|
||||
```
|
||||
██╗ ██████╗██████╗
|
||||
██║██╔════╝██╔══██╗
|
||||
██║██║ ██████╔╝
|
||||
██ ██║██║ ██╔══██╗
|
||||
╚█████╔╝╚██████╗██████╔╝
|
||||
╚════╝ ╚═════╝╚═════╝
|
||||
```
|
||||
> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder)
|
||||
|
||||
###POWERREADME###
|
@ -9,76 +9,4 @@
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\GetBible;
|
||||
|
||||
|
||||
use Joomla\DI\Container;
|
||||
use VDM\Joomla\GetBible\Service\Api;
|
||||
use VDM\Joomla\GetBible\Service\Utilities;
|
||||
use VDM\Joomla\GetBible\Service\App;
|
||||
use VDM\Joomla\GetBible\Service\Model;
|
||||
use VDM\Joomla\GetBible\Service\Database;
|
||||
use VDM\Joomla\Interfaces\FactoryInterface;
|
||||
|
||||
|
||||
/**
|
||||
* GetBible Factory
|
||||
*
|
||||
* @since 2.0.1
|
||||
*/
|
||||
abstract class Factory implements FactoryInterface
|
||||
{
|
||||
/**
|
||||
* Global Package Container
|
||||
*
|
||||
* @var Container
|
||||
* @since 2.0.1
|
||||
**/
|
||||
protected static $container = null;
|
||||
|
||||
/**
|
||||
* Get any class from the package container
|
||||
*
|
||||
* @param string $key The container class key
|
||||
*
|
||||
* @return Mixed
|
||||
* @since 2.0.1
|
||||
*/
|
||||
public static function _($key)
|
||||
{
|
||||
return self::getContainer()->get($key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the global package container
|
||||
*
|
||||
* @return Container
|
||||
* @since 2.0.1
|
||||
*/
|
||||
public static function getContainer(): Container
|
||||
{
|
||||
if (!self::$container)
|
||||
{
|
||||
self::$container = self::createContainer();
|
||||
}
|
||||
|
||||
return self::$container;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a container object
|
||||
*
|
||||
* @return Container
|
||||
* @since 2.0.1
|
||||
*/
|
||||
protected static function createContainer(): Container
|
||||
{
|
||||
return (new Container())
|
||||
->registerServiceProvider(new Utilities())
|
||||
->registerServiceProvider(new Api())
|
||||
->registerServiceProvider(new App())
|
||||
->registerServiceProvider(new Model())
|
||||
->registerServiceProvider(new Database());
|
||||
}
|
||||
}
|
||||
|
||||
###POWERCODE###
|
||||
|
@ -1,52 +1 @@
|
||||
/**
|
||||
* Global Package Container
|
||||
*
|
||||
* @var Container
|
||||
* @since 2.0.1
|
||||
**/
|
||||
protected static $container = null;
|
||||
|
||||
/**
|
||||
* Get any class from the package container
|
||||
*
|
||||
* @param string $key The container class key
|
||||
*
|
||||
* @return Mixed
|
||||
* @since 2.0.1
|
||||
*/
|
||||
public static function _($key)
|
||||
{
|
||||
return self::getContainer()->get($key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the global package container
|
||||
*
|
||||
* @return Container
|
||||
* @since 2.0.1
|
||||
*/
|
||||
public static function getContainer(): Container
|
||||
{
|
||||
if (!self::$container)
|
||||
{
|
||||
self::$container = self::createContainer();
|
||||
}
|
||||
|
||||
return self::$container;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a container object
|
||||
*
|
||||
* @return Container
|
||||
* @since 2.0.1
|
||||
*/
|
||||
protected static function createContainer(): Container
|
||||
{
|
||||
return (new Container())
|
||||
->registerServiceProvider(new Utilities())
|
||||
->registerServiceProvider(new Api())
|
||||
->registerServiceProvider(new App())
|
||||
->registerServiceProvider(new Model())
|
||||
->registerServiceProvider(new Database());
|
||||
}
|
||||
###CODEPOWER###
|
@ -1,41 +1 @@
|
||||
{
|
||||
"add_head": "1",
|
||||
"add_licensing_template": "2",
|
||||
"extends": "0",
|
||||
"guid": "11892cfa-374e-4e3f-b0bc-531871c822d9",
|
||||
"implements": [
|
||||
"caf33c5d-858c-4f9a-894f-ab302ec5445a"
|
||||
],
|
||||
"load_selection": null,
|
||||
"name": "Factory",
|
||||
"power_version": "1.0.0",
|
||||
"system_name": "GetBible.Factory",
|
||||
"type": "abstract class",
|
||||
"use_selection": {
|
||||
"use_selection0": {
|
||||
"use": "b32eea04-6b9c-469d-94db-35d610686cf1",
|
||||
"as": "default"
|
||||
},
|
||||
"use_selection1": {
|
||||
"use": "b89d74ef-c71c-4a58-8455-5dbdfe94027a",
|
||||
"as": "default"
|
||||
},
|
||||
"use_selection2": {
|
||||
"use": "56465044-94ed-4e00-b6db-160c67163df8",
|
||||
"as": "default"
|
||||
},
|
||||
"use_selection3": {
|
||||
"use": "116eb429-bc51-4d14-b9aa-7145c86a29d1",
|
||||
"as": "default"
|
||||
},
|
||||
"use_selection4": {
|
||||
"use": "51bb0397-fa7c-4f7a-a4c5-1f95fdacad38",
|
||||
"as": "default"
|
||||
}
|
||||
},
|
||||
"namespace": "VDM\\Joomla\\GetBible\\Factory",
|
||||
"description": "GetBible Factory\r\n\r\n@since 2.0.1",
|
||||
"licensing_template": "\/**\r\n * @package GetBible\r\n *\r\n * @created 30th May, 2023\r\n * @author Llewellyn van der Merwe <https:\/\/dev.vdm.io>\r\n * @git GetBible <https:\/\/git.vdm.dev\/getBible>\r\n * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.\r\n * @license GNU General Public License version 2 or later; see LICENSE.txt\r\n *\/\r\n",
|
||||
"head": "use Joomla\\DI\\Container;",
|
||||
"composer": ""
|
||||
}
|
||||
###POWERLINKER###
|
@ -1,61 +1 @@
|
||||
```
|
||||
██████╗ ██████╗ ██╗ ██╗███████╗██████╗
|
||||
██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗
|
||||
██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝
|
||||
██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗
|
||||
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
|
||||
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
|
||||
```
|
||||
# final class Books (Details)
|
||||
> namespace: **VDM\Joomla\GetBible\Api**
|
||||
```uml
|
||||
@startuml
|
||||
class Books << (F,LightGreen) >> #Green {
|
||||
+ get(string $translation = 'kjv') : ?object
|
||||
+ list(string $translation = 'kjv') : ?object
|
||||
+ checksum(string $translation = 'kjv') : ?object
|
||||
+ sha(string $translation, int $book) : ?string
|
||||
}
|
||||
|
||||
note right of Books::get
|
||||
Get the books in a translation
|
||||
|
||||
since: 2.0.1
|
||||
return: ?object
|
||||
end note
|
||||
|
||||
note right of Books::list
|
||||
List the books in a translation
|
||||
|
||||
since: 2.0.1
|
||||
return: ?object
|
||||
end note
|
||||
|
||||
note right of Books::checksum
|
||||
List the books checksums in a translation
|
||||
|
||||
since: 2.0.1
|
||||
return: ?object
|
||||
end note
|
||||
|
||||
note right of Books::sha
|
||||
Get the book's checksums in a translation
|
||||
|
||||
since: 2.0.1
|
||||
return: ?string
|
||||
end note
|
||||
|
||||
@enduml
|
||||
```
|
||||
|
||||
---
|
||||
```
|
||||
██╗ ██████╗██████╗
|
||||
██║██╔════╝██╔══██╗
|
||||
██║██║ ██████╔╝
|
||||
██ ██║██║ ██╔══██╗
|
||||
╚█████╔╝╚██████╗██████╔╝
|
||||
╚════╝ ╚═════╝╚═════╝
|
||||
```
|
||||
> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder)
|
||||
|
||||
###POWERREADME###
|
@ -9,88 +9,4 @@
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\GetBible\Api;
|
||||
|
||||
|
||||
use VDM\Joomla\GetBible\Abstraction\Api;
|
||||
|
||||
|
||||
/**
|
||||
* The GetBible Books
|
||||
*
|
||||
* @since 2.0.1
|
||||
*/
|
||||
final class Books extends Api
|
||||
{
|
||||
/**
|
||||
* Get the books in a translation
|
||||
*
|
||||
* @param string $translation The translation.
|
||||
*
|
||||
* @return object|null The response object or null if an error occurs.
|
||||
* @since 2.0.1
|
||||
*/
|
||||
public function get(string $translation = 'kjv'): ?object
|
||||
{
|
||||
return $this->response->get(
|
||||
$this->http->get(
|
||||
$this->uri->get($translation . '.json')
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* List the books in a translation
|
||||
*
|
||||
* @param string $translation The translation.
|
||||
*
|
||||
* @return object|null The response object or null if an error occurs.
|
||||
* @since 2.0.1
|
||||
*/
|
||||
public function list(string $translation = 'kjv'): ?object
|
||||
{
|
||||
return $this->response->get(
|
||||
$this->http->get(
|
||||
$this->uri->get($translation . '/books.json')
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* List the books checksums in a translation
|
||||
*
|
||||
* @param string $translation The translation.
|
||||
*
|
||||
* @return object|null The response object or null if an error occurs.
|
||||
* @since 2.0.1
|
||||
*/
|
||||
public function checksum(string $translation = 'kjv'): ?object
|
||||
{
|
||||
return $this->response->get(
|
||||
$this->http->get(
|
||||
$this->uri->get($translation . '/checksum.json')
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the book's checksums in a translation
|
||||
*
|
||||
* @param string $translation The translation.
|
||||
* @param int $book The book number.
|
||||
*
|
||||
* @return string|null The response checksums or null if an error occurs.
|
||||
* @since 2.0.1
|
||||
*/
|
||||
public function sha(string $translation, int $book): ?string
|
||||
{
|
||||
return trim(
|
||||
$this->response->get(
|
||||
$this->http->get(
|
||||
$this->uri->get($translation . '/' . $book . '.sha')
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
###POWERCODE###
|
||||
|
@ -1,70 +1 @@
|
||||
/**
|
||||
* Get the books in a translation
|
||||
*
|
||||
* @param string $translation The translation.
|
||||
*
|
||||
* @return object|null The response object or null if an error occurs.
|
||||
* @since 2.0.1
|
||||
*/
|
||||
public function get(string $translation = 'kjv'): ?object
|
||||
{
|
||||
return $this->response->get(
|
||||
$this->http->get(
|
||||
$this->uri->get($translation . '.json')
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* List the books in a translation
|
||||
*
|
||||
* @param string $translation The translation.
|
||||
*
|
||||
* @return object|null The response object or null if an error occurs.
|
||||
* @since 2.0.1
|
||||
*/
|
||||
public function list(string $translation = 'kjv'): ?object
|
||||
{
|
||||
return $this->response->get(
|
||||
$this->http->get(
|
||||
$this->uri->get($translation . '/books.json')
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* List the books checksums in a translation
|
||||
*
|
||||
* @param string $translation The translation.
|
||||
*
|
||||
* @return object|null The response object or null if an error occurs.
|
||||
* @since 2.0.1
|
||||
*/
|
||||
public function checksum(string $translation = 'kjv'): ?object
|
||||
{
|
||||
return $this->response->get(
|
||||
$this->http->get(
|
||||
$this->uri->get($translation . '/checksum.json')
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the book's checksums in a translation
|
||||
*
|
||||
* @param string $translation The translation.
|
||||
* @param int $book The book number.
|
||||
*
|
||||
* @return string|null The response checksums or null if an error occurs.
|
||||
* @since 2.0.1
|
||||
*/
|
||||
public function sha(string $translation, int $book): ?string
|
||||
{
|
||||
return trim(
|
||||
$this->response->get(
|
||||
$this->http->get(
|
||||
$this->uri->get($translation . '/' . $book . '.sha')
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
###CODEPOWER###
|
@ -1,18 +1 @@
|
||||
{
|
||||
"add_head": "0",
|
||||
"add_licensing_template": "2",
|
||||
"extends": "7b490e63-8d1f-46de-a0c4-154272fd5d7f",
|
||||
"guid": "491c91ce-6355-40d3-bbbd-622473c6c026",
|
||||
"implements": null,
|
||||
"load_selection": null,
|
||||
"name": "Books",
|
||||
"power_version": "1.0.0",
|
||||
"system_name": "Joomla.GetBible.Api.Books",
|
||||
"type": "final class",
|
||||
"use_selection": null,
|
||||
"namespace": "VDM\\Joomla\\GetBible\\Api.Books",
|
||||
"description": "The GetBible Books\r\n\r\n@since 2.0.1",
|
||||
"licensing_template": "\/**\r\n * @package GetBible\r\n *\r\n * @created 30th May, 2023\r\n * @author Llewellyn van der Merwe <https:\/\/dev.vdm.io>\r\n * @git GetBible <https:\/\/git.vdm.dev\/getBible>\r\n * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.\r\n * @license GNU General Public License version 2 or later; see LICENSE.txt\r\n *\/\r\n",
|
||||
"head": "",
|
||||
"composer": ""
|
||||
}
|
||||
###POWERLINKER###
|
@ -1,85 +1 @@
|
||||
```
|
||||
██████╗ ██████╗ ██╗ ██╗███████╗██████╗
|
||||
██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗
|
||||
██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝
|
||||
██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗
|
||||
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
|
||||
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
|
||||
```
|
||||
# class Database (Details)
|
||||
> namespace: **VDM\Joomla\GetBible\Service**
|
||||
```uml
|
||||
@startuml
|
||||
class Database #Gold {
|
||||
+ register(Container $container) : void
|
||||
+ getBaseUpdate(Container $container) : BaseUpdate
|
||||
+ getBaseInsert(Container $container) : BaseInsert
|
||||
+ getBaseLoad(Container $container) : BaseLoad
|
||||
+ getInsert(Container $container) : Insert
|
||||
+ getUpdate(Container $container) : Update
|
||||
+ getLoad(Container $container) : Load
|
||||
}
|
||||
|
||||
note right of Database::register
|
||||
Registers the service provider with a DI container.
|
||||
|
||||
since: 2.0.1
|
||||
return: void
|
||||
end note
|
||||
|
||||
note right of Database::getBaseUpdate
|
||||
Get the BaseUpdate class
|
||||
|
||||
since: 2.0.1
|
||||
return: BaseUpdate
|
||||
end note
|
||||
|
||||
note right of Database::getBaseInsert
|
||||
Get the BaseInsert class
|
||||
|
||||
since: 2.0.1
|
||||
return: BaseInsert
|
||||
end note
|
||||
|
||||
note right of Database::getBaseLoad
|
||||
Get the BaseLoad class
|
||||
|
||||
since: 2.0.1
|
||||
return: BaseLoad
|
||||
end note
|
||||
|
||||
note right of Database::getInsert
|
||||
Get the Insert class
|
||||
|
||||
since: 2.0.1
|
||||
return: Insert
|
||||
end note
|
||||
|
||||
note right of Database::getUpdate
|
||||
Get the Update class
|
||||
|
||||
since: 2.0.1
|
||||
return: Update
|
||||
end note
|
||||
|
||||
note right of Database::getLoad
|
||||
Get the Table class
|
||||
|
||||
since: 2.0.1
|
||||
return: Load
|
||||
end note
|
||||
|
||||
@enduml
|
||||
```
|
||||
|
||||
---
|
||||
```
|
||||
██╗ ██████╗██████╗
|
||||
██║██╔════╝██╔══██╗
|
||||
██║██║ ██████╔╝
|
||||
██ ██║██║ ██╔══██╗
|
||||
╚█████╔╝╚██████╗██████╔╝
|
||||
╚════╝ ╚═════╝╚═════╝
|
||||
```
|
||||
> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder)
|
||||
|
||||
###POWERREADME###
|
@ -9,141 +9,4 @@
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\GetBible\Service;
|
||||
|
||||
|
||||
use Joomla\DI\Container;
|
||||
use Joomla\DI\ServiceProviderInterface;
|
||||
use VDM\Joomla\Database\Insert as BaseInsert;
|
||||
use VDM\Joomla\Database\Update as BaseUpdate;
|
||||
use VDM\Joomla\Database\Load as BaseLoad;
|
||||
use VDM\Joomla\GetBible\Database\Insert;
|
||||
use VDM\Joomla\GetBible\Database\Load;
|
||||
use VDM\Joomla\GetBible\Database\Update;
|
||||
|
||||
|
||||
/**
|
||||
* The GetBible Database Service
|
||||
*
|
||||
* @since 2.0.1
|
||||
*/
|
||||
class Database implements ServiceProviderInterface
|
||||
{
|
||||
/**
|
||||
* Registers the service provider with a DI container.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return void
|
||||
* @since 2.0.1
|
||||
*/
|
||||
public function register(Container $container)
|
||||
{
|
||||
$container->alias(BaseInsert::class, 'DB.Insert')
|
||||
->share('DB.Insert', [$this, 'getBaseInsert'], true);
|
||||
|
||||
$container->alias(BaseUpdate::class, 'DB.Update')
|
||||
->share('DB.Update', [$this, 'getBaseUpdate'], true);
|
||||
|
||||
$container->alias(BaseLoad::class, 'DB.Load')
|
||||
->share('DB.Load', [$this, 'getBaseLoad'], true);
|
||||
|
||||
$container->alias(Insert::class, 'GetBible.Insert')
|
||||
->share('GetBible.Insert', [$this, 'getInsert'], true);
|
||||
|
||||
$container->alias(Update::class, 'GetBible.Update')
|
||||
->share('GetBible.Update', [$this, 'getUpdate'], true);
|
||||
|
||||
$container->alias(Load::class, 'GetBible.Load')
|
||||
->share('GetBible.Load', [$this, 'getLoad'], true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the BaseUpdate class
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return BaseUpdate
|
||||
* @since 2.0.1
|
||||
*/
|
||||
public function getBaseUpdate(Container $container): BaseUpdate
|
||||
{
|
||||
return new BaseUpdate();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the BaseInsert class
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return BaseInsert
|
||||
* @since 2.0.1
|
||||
*/
|
||||
public function getBaseInsert(Container $container): BaseInsert
|
||||
{
|
||||
return new BaseInsert();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the BaseLoad class
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return BaseLoad
|
||||
* @since 2.0.1
|
||||
*/
|
||||
public function getBaseLoad(Container $container): BaseLoad
|
||||
{
|
||||
return new BaseLoad();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Insert class
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Insert
|
||||
* @since 2.0.1
|
||||
*/
|
||||
public function getInsert(Container $container): Insert
|
||||
{
|
||||
return new Insert(
|
||||
$container->get('GetBible.Model.Upsert'),
|
||||
$container->get('DB.Insert')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Update class
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Update
|
||||
* @since 2.0.1
|
||||
*/
|
||||
public function getUpdate(Container $container): Update
|
||||
{
|
||||
return new Update(
|
||||
$container->get('GetBible.Model.Upsert'),
|
||||
$container->get('DB.Update')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Table class
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Load
|
||||
* @since 2.0.1
|
||||
*/
|
||||
public function getLoad(Container $container): Load
|
||||
{
|
||||
return new Load(
|
||||
$container->get('GetBible.Table'),
|
||||
$container->get('GetBible.Model.Load'),
|
||||
$container->get('DB.Load')
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
###POWERCODE###
|
||||
|
@ -1,116 +1 @@
|
||||
/**
|
||||
* Registers the service provider with a DI container.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return void
|
||||
* @since 2.0.1
|
||||
*/
|
||||
public function register(Container $container)
|
||||
{
|
||||
$container->alias(BaseInsert::class, 'DB.Insert')
|
||||
->share('DB.Insert', [$this, 'getBaseInsert'], true);
|
||||
|
||||
$container->alias(BaseUpdate::class, 'DB.Update')
|
||||
->share('DB.Update', [$this, 'getBaseUpdate'], true);
|
||||
|
||||
$container->alias(BaseLoad::class, 'DB.Load')
|
||||
->share('DB.Load', [$this, 'getBaseLoad'], true);
|
||||
|
||||
$container->alias(Insert::class, 'GetBible.Insert')
|
||||
->share('GetBible.Insert', [$this, 'getInsert'], true);
|
||||
|
||||
$container->alias(Update::class, 'GetBible.Update')
|
||||
->share('GetBible.Update', [$this, 'getUpdate'], true);
|
||||
|
||||
$container->alias(Load::class, 'GetBible.Load')
|
||||
->share('GetBible.Load', [$this, 'getLoad'], true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the BaseUpdate class
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return BaseUpdate
|
||||
* @since 2.0.1
|
||||
*/
|
||||
public function getBaseUpdate(Container $container): BaseUpdate
|
||||
{
|
||||
return new BaseUpdate();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the BaseInsert class
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return BaseInsert
|
||||
* @since 2.0.1
|
||||
*/
|
||||
public function getBaseInsert(Container $container): BaseInsert
|
||||
{
|
||||
return new BaseInsert();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the BaseLoad class
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return BaseLoad
|
||||
* @since 2.0.1
|
||||
*/
|
||||
public function getBaseLoad(Container $container): BaseLoad
|
||||
{
|
||||
return new BaseLoad();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Insert class
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Insert
|
||||
* @since 2.0.1
|
||||
*/
|
||||
public function getInsert(Container $container): Insert
|
||||
{
|
||||
return new Insert(
|
||||
$container->get('GetBible.Model.Upsert'),
|
||||
$container->get('DB.Insert')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Update class
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Update
|
||||
* @since 2.0.1
|
||||
*/
|
||||
public function getUpdate(Container $container): Update
|
||||
{
|
||||
return new Update(
|
||||
$container->get('GetBible.Model.Upsert'),
|
||||
$container->get('DB.Update')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Table class
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Load
|
||||
* @since 2.0.1
|
||||
*/
|
||||
public function getLoad(Container $container): Load
|
||||
{
|
||||
return new Load(
|
||||
$container->get('GetBible.Table'),
|
||||
$container->get('GetBible.Model.Load'),
|
||||
$container->get('DB.Load')
|
||||
);
|
||||
}
|
||||
###CODEPOWER###
|
@ -1,46 +1 @@
|
||||
{
|
||||
"add_head": "1",
|
||||
"add_licensing_template": "2",
|
||||
"extends": "0",
|
||||
"guid": "51bb0397-fa7c-4f7a-a4c5-1f95fdacad38",
|
||||
"implements": [
|
||||
"-1"
|
||||
],
|
||||
"load_selection": null,
|
||||
"name": "Database",
|
||||
"power_version": "1.0.0",
|
||||
"system_name": "Joomla.GetBible.Service.Database",
|
||||
"type": "class",
|
||||
"use_selection": {
|
||||
"use_selection0": {
|
||||
"use": "524eb8f6-38d4-47dc-92ad-98b94e099ac0",
|
||||
"as": "BaseInsert"
|
||||
},
|
||||
"use_selection1": {
|
||||
"use": "cce56585-58b0-4f72-a92c-e2635ea52d83",
|
||||
"as": "BaseUpdate"
|
||||
},
|
||||
"use_selection2": {
|
||||
"use": "06f8eada-d59b-441c-b287-0aea1793da5a",
|
||||
"as": "BaseLoad"
|
||||
},
|
||||
"use_selection3": {
|
||||
"use": "a07d90f6-6ff2-40a1-99c1-0f2cf33c9adf",
|
||||
"as": "default"
|
||||
},
|
||||
"use_selection4": {
|
||||
"use": "c03b9c61-17d3-4774-a335-783903719f83",
|
||||
"as": "default"
|
||||
},
|
||||
"use_selection5": {
|
||||
"use": "d7a5f0c6-de60-4d31-b3e4-5d668a8f7d2e",
|
||||
"as": "default"
|
||||
}
|
||||
},
|
||||
"namespace": "VDM\\Joomla\\GetBible\\Service.Database",
|
||||
"description": "The GetBible Database Service\r\n\r\n@since 2.0.1",
|
||||
"implements_custom": "ServiceProviderInterface",
|
||||
"licensing_template": "\/**\r\n * @package GetBible\r\n *\r\n * @created 30th May, 2023\r\n * @author Llewellyn van der Merwe <https:\/\/dev.vdm.io>\r\n * @git GetBible <https:\/\/git.vdm.dev\/getBible>\r\n * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.\r\n * @license GNU General Public License version 2 or later; see LICENSE.txt\r\n *\/\r\n",
|
||||
"head": "use Joomla\\DI\\Container;\r\nuse Joomla\\DI\\ServiceProviderInterface;",
|
||||
"composer": ""
|
||||
}
|
||||
###POWERLINKER###
|
@ -1,77 +1 @@
|
||||
```
|
||||
██████╗ ██████╗ ██╗ ██╗███████╗██████╗
|
||||
██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗
|
||||
██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝
|
||||
██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗
|
||||
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
|
||||
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
|
||||
```
|
||||
# class App (Details)
|
||||
> namespace: **VDM\Joomla\GetBible\Service**
|
||||
```uml
|
||||
@startuml
|
||||
class App #Gold {
|
||||
+ register(Container $container) : void
|
||||
+ getConfig(Container $container) : Config
|
||||
+ getTable(Container $container) : Table
|
||||
+ getDailyScripture(Container $container) : DailyScripture
|
||||
+ getSearch(Container $container) : Search
|
||||
+ getWatcher(Container $container) : Watcher
|
||||
}
|
||||
|
||||
note right of App::register
|
||||
Registers the service provider with a DI container.
|
||||
|
||||
since: 2.0.1
|
||||
return: void
|
||||
end note
|
||||
|
||||
note right of App::getConfig
|
||||
Get the Config class
|
||||
|
||||
since: 2.0.1
|
||||
return: Config
|
||||
end note
|
||||
|
||||
note right of App::getTable
|
||||
Get the Table class
|
||||
|
||||
since: 2.0.1
|
||||
return: Table
|
||||
end note
|
||||
|
||||
note right of App::getDailyScripture
|
||||
Get the Daily Scripture class
|
||||
|
||||
since: 2.0.1
|
||||
return: DailyScripture
|
||||
end note
|
||||
|
||||
note right of App::getSearch
|
||||
Get the Search class
|
||||
|
||||
since: 2.0.1
|
||||
return: Search
|
||||
end note
|
||||
|
||||
note right of App::getWatcher
|
||||
Get the Watcher class
|
||||
|
||||
since: 2.0.1
|
||||
return: Watcher
|
||||
end note
|
||||
|
||||
@enduml
|
||||
```
|
||||
|
||||
---
|
||||
```
|
||||
██╗ ██████╗██████╗
|
||||
██║██╔════╝██╔══██╗
|
||||
██║██║ ██████╔╝
|
||||
██ ██║██║ ██╔══██╗
|
||||
╚█████╔╝╚██████╗██████╔╝
|
||||
╚════╝ ╚═════╝╚═════╝
|
||||
```
|
||||
> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder)
|
||||
|
||||
###POWERREADME###
|
@ -9,126 +9,4 @@
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\GetBible\Service;
|
||||
|
||||
|
||||
use Joomla\DI\Container;
|
||||
use Joomla\DI\ServiceProviderInterface;
|
||||
use VDM\Joomla\GetBible\Config;
|
||||
use VDM\Joomla\GetBible\Table;
|
||||
use VDM\Joomla\GetBible\DailyScripture;
|
||||
use VDM\Joomla\GetBible\Search;
|
||||
use VDM\Joomla\GetBible\Watcher;
|
||||
|
||||
|
||||
/**
|
||||
* The GetBible App Service
|
||||
*
|
||||
* @since 2.0.1
|
||||
*/
|
||||
class App implements ServiceProviderInterface
|
||||
{
|
||||
/**
|
||||
* Registers the service provider with a DI container.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return void
|
||||
* @since 2.0.1
|
||||
*/
|
||||
public function register(Container $container)
|
||||
{
|
||||
$container->alias(Config::class, 'GetBible.Config')
|
||||
->share('GetBible.Config', [$this, 'getConfig'], true);
|
||||
|
||||
$container->alias(Table::class, 'GetBible.Table')
|
||||
->share('GetBible.Table', [$this, 'getTable'], true);
|
||||
|
||||
$container->alias(DailyScripture::class, 'DailyScripture')
|
||||
->share('DailyScripture', [$this, 'getDailyScripture'], true);
|
||||
|
||||
$container->alias(Search::class, 'GetBible.Search')
|
||||
->share('GetBible.Search', [$this, 'getSearch'], true);
|
||||
|
||||
$container->alias(Watcher::class, 'GetBible.Watcher')
|
||||
->share('GetBible.Watcher', [$this, 'getWatcher'], true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Config class
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Config
|
||||
* @since 2.0.1
|
||||
*/
|
||||
public function getConfig(Container $container): Config
|
||||
{
|
||||
return new Config();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Table class
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Table
|
||||
* @since 2.0.1
|
||||
*/
|
||||
public function getTable(Container $container): Table
|
||||
{
|
||||
return new Table();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Daily Scripture class
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return DailyScripture
|
||||
* @since 2.0.1
|
||||
*/
|
||||
public function getDailyScripture(Container $container): DailyScripture
|
||||
{
|
||||
return new DailyScripture(
|
||||
$container->get('GetBible.Config'),
|
||||
$container->get('GetBible.Utilities.Http'),
|
||||
$container->get('GetBible.Load')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Search class
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Search
|
||||
* @since 2.0.1
|
||||
*/
|
||||
public function getSearch(Container $container): Search
|
||||
{
|
||||
return new Search();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Watcher class
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Watcher
|
||||
* @since 2.0.1
|
||||
*/
|
||||
public function getWatcher(Container $container): Watcher
|
||||
{
|
||||
return new Watcher(
|
||||
$container->get('GetBible.Load'),
|
||||
$container->get('GetBible.Insert'),
|
||||
$container->get('GetBible.Update'),
|
||||
$container->get('GetBible.Api.Translations'),
|
||||
$container->get('GetBible.Api.Books'),
|
||||
$container->get('GetBible.Api.Chapters'),
|
||||
$container->get('GetBible.Api.Verses')
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
###POWERCODE###
|
||||
|
@ -1,102 +1 @@
|
||||
/**
|
||||
* Registers the service provider with a DI container.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return void
|
||||
* @since 2.0.1
|
||||
*/
|
||||
public function register(Container $container)
|
||||
{
|
||||
$container->alias(Config::class, 'GetBible.Config')
|
||||
->share('GetBible.Config', [$this, 'getConfig'], true);
|
||||
|
||||
$container->alias(Table::class, 'GetBible.Table')
|
||||
->share('GetBible.Table', [$this, 'getTable'], true);
|
||||
|
||||
$container->alias(DailyScripture::class, 'DailyScripture')
|
||||
->share('DailyScripture', [$this, 'getDailyScripture'], true);
|
||||
|
||||
$container->alias(Search::class, 'GetBible.Search')
|
||||
->share('GetBible.Search', [$this, 'getSearch'], true);
|
||||
|
||||
$container->alias(Watcher::class, 'GetBible.Watcher')
|
||||
->share('GetBible.Watcher', [$this, 'getWatcher'], true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Config class
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Config
|
||||
* @since 2.0.1
|
||||
*/
|
||||
public function getConfig(Container $container): Config
|
||||
{
|
||||
return new Config();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Table class
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Table
|
||||
* @since 2.0.1
|
||||
*/
|
||||
public function getTable(Container $container): Table
|
||||
{
|
||||
return new Table();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Daily Scripture class
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return DailyScripture
|
||||
* @since 2.0.1
|
||||
*/
|
||||
public function getDailyScripture(Container $container): DailyScripture
|
||||
{
|
||||
return new DailyScripture(
|
||||
$container->get('GetBible.Config'),
|
||||
$container->get('GetBible.Utilities.Http'),
|
||||
$container->get('GetBible.Load')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Search class
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Search
|
||||
* @since 2.0.1
|
||||
*/
|
||||
public function getSearch(Container $container): Search
|
||||
{
|
||||
return new Search();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Watcher class
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Watcher
|
||||
* @since 2.0.1
|
||||
*/
|
||||
public function getWatcher(Container $container): Watcher
|
||||
{
|
||||
return new Watcher(
|
||||
$container->get('GetBible.Load'),
|
||||
$container->get('GetBible.Insert'),
|
||||
$container->get('GetBible.Update'),
|
||||
$container->get('GetBible.Api.Translations'),
|
||||
$container->get('GetBible.Api.Books'),
|
||||
$container->get('GetBible.Api.Chapters'),
|
||||
$container->get('GetBible.Api.Verses')
|
||||
);
|
||||
}
|
||||
###CODEPOWER###
|
@ -1,42 +1 @@
|
||||
{
|
||||
"add_head": "1",
|
||||
"add_licensing_template": "2",
|
||||
"extends": "0",
|
||||
"guid": "56465044-94ed-4e00-b6db-160c67163df8",
|
||||
"implements": [
|
||||
"-1"
|
||||
],
|
||||
"load_selection": null,
|
||||
"name": "App",
|
||||
"power_version": "1.0.0",
|
||||
"system_name": "Joomla.GetBible.Service.App",
|
||||
"type": "class",
|
||||
"use_selection": {
|
||||
"use_selection0": {
|
||||
"use": "71075f03-4e77-4fc0-840a-ef55fd9260b2",
|
||||
"as": "default"
|
||||
},
|
||||
"use_selection1": {
|
||||
"use": "ff8d5fdb-2d1f-4178-bd18-a43b8efd1068",
|
||||
"as": "default"
|
||||
},
|
||||
"use_selection2": {
|
||||
"use": "90f2ee7a-c041-4316-ad54-af4f97fa3003",
|
||||
"as": "default"
|
||||
},
|
||||
"use_selection3": {
|
||||
"use": "8336e3c4-f11b-41bc-a2b1-976f99442a84",
|
||||
"as": "default"
|
||||
},
|
||||
"use_selection4": {
|
||||
"use": "f815fb33-f721-48a5-a84e-53f1986e8881",
|
||||
"as": "default"
|
||||
}
|
||||
},
|
||||
"namespace": "VDM\\Joomla\\GetBible\\Service.App",
|
||||
"description": "The GetBible App Service\r\n\r\n@since 2.0.1",
|
||||
"implements_custom": "ServiceProviderInterface",
|
||||
"licensing_template": "\/**\r\n * @package GetBible\r\n *\r\n * @created 30th May, 2023\r\n * @author Llewellyn van der Merwe <https:\/\/dev.vdm.io>\r\n * @git GetBible <https:\/\/git.vdm.dev\/getBible>\r\n * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.\r\n * @license GNU General Public License version 2 or later; see LICENSE.txt\r\n *\/\r\n",
|
||||
"head": "use Joomla\\DI\\Container;\r\nuse Joomla\\DI\\ServiceProviderInterface;",
|
||||
"composer": ""
|
||||
}
|
||||
###POWERLINKER###
|
@ -1,69 +1 @@
|
||||
```
|
||||
██████╗ ██████╗ ██╗ ██╗███████╗██████╗
|
||||
██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗
|
||||
██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝
|
||||
██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗
|
||||
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
|
||||
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
|
||||
```
|
||||
# class Config (Details)
|
||||
> namespace: **VDM\Joomla\GetBible**
|
||||
```uml
|
||||
@startuml
|
||||
class Config #Gold {
|
||||
# getEndpoint() : ?string
|
||||
# getSchema() : ?string
|
||||
# getDomain() : ?string
|
||||
# getVersion() : ?string
|
||||
# getDailyscriptureurl() : ?string
|
||||
}
|
||||
|
||||
note right of Config::getEndpoint
|
||||
get Bible API url
|
||||
|
||||
since: 2.0.1
|
||||
return: ?string
|
||||
end note
|
||||
|
||||
note right of Config::getSchema
|
||||
get Bible API Schema
|
||||
|
||||
since: 2.0.1
|
||||
return: ?string
|
||||
end note
|
||||
|
||||
note right of Config::getDomain
|
||||
get Bible API domain
|
||||
|
||||
since: 2.0.1
|
||||
return: ?string
|
||||
end note
|
||||
|
||||
note right of Config::getVersion
|
||||
get Bible version
|
||||
|
||||
since: 2.0.1
|
||||
return: ?string
|
||||
end note
|
||||
|
||||
note right of Config::getDailyscriptureurl
|
||||
get Daily Scripture URL
|
||||
|
||||
since: 2.0.1
|
||||
return: ?string
|
||||
end note
|
||||
|
||||
@enduml
|
||||
```
|
||||
|
||||
---
|
||||
```
|
||||
██╗ ██████╗██████╗
|
||||
██║██╔════╝██╔══██╗
|
||||
██║██║ ██████╔╝
|
||||
██ ██║██║ ██╔══██╗
|
||||
╚█████╔╝╚██████╗██████╔╝
|
||||
╚════╝ ╚═════╝╚═════╝
|
||||
```
|
||||
> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder)
|
||||
|
||||
###POWERREADME###
|
@ -9,73 +9,4 @@
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\GetBible;
|
||||
|
||||
|
||||
use VDM\Joomla\Utilities\GetHelper;
|
||||
use VDM\Joomla\Abstraction\BaseConfig;
|
||||
|
||||
|
||||
/**
|
||||
* GetBible Configurations
|
||||
*
|
||||
* @since 2.0.1
|
||||
*/
|
||||
class Config extends BaseConfig
|
||||
{
|
||||
/**
|
||||
* get Bible API url
|
||||
*
|
||||
* @return string The API Endpoint
|
||||
* @since 2.0.1
|
||||
*/
|
||||
protected function getEndpoint(): ?string
|
||||
{
|
||||
return $this->schema . '://' . $this->domain . '/' . $this->version . '/';
|
||||
}
|
||||
|
||||
/**
|
||||
* get Bible API Schema
|
||||
*
|
||||
* @return string The Get Bible Schema
|
||||
* @since 2.0.1
|
||||
*/
|
||||
protected function getSchema(): ?string
|
||||
{
|
||||
return 'https';
|
||||
}
|
||||
|
||||
/**
|
||||
* get Bible API domain
|
||||
*
|
||||
* @return string The Get Bible Domain
|
||||
* @since 2.0.1
|
||||
*/
|
||||
protected function getDomain(): ?string
|
||||
{
|
||||
return 'api.getbible.net';
|
||||
}
|
||||
|
||||
/**
|
||||
* get Bible version
|
||||
*
|
||||
* @return string The Get Bible Version
|
||||
* @since 2.0.1
|
||||
*/
|
||||
protected function getVersion(): ?string
|
||||
{
|
||||
return 'v2';
|
||||
}
|
||||
|
||||
/**
|
||||
* get Daily Scripture URL
|
||||
*
|
||||
* @return string The Get Daily Scripture URL
|
||||
* @since 2.0.1
|
||||
*/
|
||||
protected function getDailyscriptureurl(): ?string
|
||||
{
|
||||
return 'https://raw.githubusercontent.com/trueChristian/daily-scripture/master/README.today';
|
||||
}
|
||||
}
|
||||
|
||||
###POWERCODE###
|
||||
|
@ -1,54 +1 @@
|
||||
/**
|
||||
* get Bible API url
|
||||
*
|
||||
* @return string The API Endpoint
|
||||
* @since 2.0.1
|
||||
*/
|
||||
protected function getEndpoint(): ?string
|
||||
{
|
||||
return $this->schema . '://' . $this->domain . '/' . $this->version . '/';
|
||||
}
|
||||
|
||||
/**
|
||||
* get Bible API Schema
|
||||
*
|
||||
* @return string The Get Bible Schema
|
||||
* @since 2.0.1
|
||||
*/
|
||||
protected function getSchema(): ?string
|
||||
{
|
||||
return 'https';
|
||||
}
|
||||
|
||||
/**
|
||||
* get Bible API domain
|
||||
*
|
||||
* @return string The Get Bible Domain
|
||||
* @since 2.0.1
|
||||
*/
|
||||
protected function getDomain(): ?string
|
||||
{
|
||||
return 'api.getbible.net';
|
||||
}
|
||||
|
||||
/**
|
||||
* get Bible version
|
||||
*
|
||||
* @return string The Get Bible Version
|
||||
* @since 2.0.1
|
||||
*/
|
||||
protected function getVersion(): ?string
|
||||
{
|
||||
return 'v2';
|
||||
}
|
||||
|
||||
/**
|
||||
* get Daily Scripture URL
|
||||
*
|
||||
* @return string The Get Daily Scripture URL
|
||||
* @since 2.0.1
|
||||
*/
|
||||
protected function getDailyscriptureurl(): ?string
|
||||
{
|
||||
return 'https://raw.githubusercontent.com/trueChristian/daily-scripture/master/README.today';
|
||||
}
|
||||
###CODEPOWER###
|
@ -1,23 +1 @@
|
||||
{
|
||||
"add_head": "0",
|
||||
"add_licensing_template": "2",
|
||||
"extends": "ffbd4e1f-a342-4080-ab7d-1de3741bf319",
|
||||
"guid": "71075f03-4e77-4fc0-840a-ef55fd9260b2",
|
||||
"implements": null,
|
||||
"load_selection": null,
|
||||
"name": "Config",
|
||||
"power_version": "1.0.0",
|
||||
"system_name": "JCB.GetBible.Config",
|
||||
"type": "class",
|
||||
"use_selection": {
|
||||
"use_selection0": {
|
||||
"use": "db87c339-5bb6-4291-a7ef-2c48ea1b06bc",
|
||||
"as": "default"
|
||||
}
|
||||
},
|
||||
"namespace": "VDM\\Joomla\\GetBible\\Config",
|
||||
"description": "GetBible Configurations\r\n\r\n@since 2.0.1",
|
||||
"licensing_template": "\/**\r\n * @package GetBible\r\n *\r\n * @created 30th May, 2023\r\n * @author Llewellyn van der Merwe <https:\/\/dev.vdm.io>\r\n * @git GetBible <https:\/\/git.vdm.dev\/getBible>\r\n * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.\r\n * @license GNU General Public License version 2 or later; see LICENSE.txt\r\n *\/\r\n",
|
||||
"head": "",
|
||||
"composer": ""
|
||||
}
|
||||
###POWERLINKER###
|
@ -1,44 +1 @@
|
||||
```
|
||||
██████╗ ██████╗ ██╗ ██╗███████╗██████╗
|
||||
██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗
|
||||
██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝
|
||||
██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗
|
||||
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
|
||||
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
|
||||
```
|
||||
# abstract class Api (Details)
|
||||
> namespace: **VDM\Joomla\GetBible\Abstraction**
|
||||
```uml
|
||||
@startuml
|
||||
abstract Api #Orange {
|
||||
# Http $http
|
||||
# Uri $uri
|
||||
# Response $response
|
||||
+ __construct(Http $http, Uri $uri, ...)
|
||||
}
|
||||
|
||||
note right of Api::__construct
|
||||
Constructor.
|
||||
|
||||
since: 2.0.1
|
||||
|
||||
arguments:
|
||||
Http $http
|
||||
Uri $uri
|
||||
Response $response
|
||||
end note
|
||||
|
||||
@enduml
|
||||
```
|
||||
|
||||
---
|
||||
```
|
||||
██╗ ██████╗██████╗
|
||||
██║██╔════╝██╔══██╗
|
||||
██║██║ ██████╔╝
|
||||
██ ██║██║ ██╔══██╗
|
||||
╚█████╔╝╚██████╗██████╔╝
|
||||
╚════╝ ╚═════╝╚═════╝
|
||||
```
|
||||
> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder)
|
||||
|
||||
###POWERREADME###
|
@ -9,59 +9,4 @@
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\GetBible\Abstraction;
|
||||
|
||||
|
||||
use VDM\Joomla\GetBible\Utilities\Http;
|
||||
use VDM\Joomla\GetBible\Utilities\Uri;
|
||||
use VDM\Joomla\GetBible\Utilities\Response;
|
||||
|
||||
|
||||
/**
|
||||
* The GetBible Api
|
||||
*
|
||||
* @since 2.0.1
|
||||
*/
|
||||
abstract class Api
|
||||
{
|
||||
/**
|
||||
* The Http class
|
||||
*
|
||||
* @var Http
|
||||
* @since 2.0.1
|
||||
*/
|
||||
protected Http $http;
|
||||
|
||||
/**
|
||||
* The Uri class
|
||||
*
|
||||
* @var Uri
|
||||
* @since 2.0.1
|
||||
*/
|
||||
protected Uri $uri;
|
||||
|
||||
/**
|
||||
* The Response class
|
||||
*
|
||||
* @var Response
|
||||
* @since 2.0.1
|
||||
*/
|
||||
protected Response $response;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param Http $http The http class.
|
||||
* @param Uri $uri The uri class.
|
||||
* @param Response $response The response class.
|
||||
*
|
||||
* @since 2.0.1
|
||||
**/
|
||||
public function __construct(Http $http, Uri $uri, Response $response)
|
||||
{
|
||||
$this->http = $http;
|
||||
$this->uri = $uri;
|
||||
$this->response = $response;
|
||||
}
|
||||
}
|
||||
|
||||
###POWERCODE###
|
||||
|
@ -1,39 +1 @@
|
||||
/**
|
||||
* The Http class
|
||||
*
|
||||
* @var Http
|
||||
* @since 2.0.1
|
||||
*/
|
||||
protected Http $http;
|
||||
|
||||
/**
|
||||
* The Uri class
|
||||
*
|
||||
* @var Uri
|
||||
* @since 2.0.1
|
||||
*/
|
||||
protected Uri $uri;
|
||||
|
||||
/**
|
||||
* The Response class
|
||||
*
|
||||
* @var Response
|
||||
* @since 2.0.1
|
||||
*/
|
||||
protected Response $response;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param Http $http The http class.
|
||||
* @param Uri $uri The uri class.
|
||||
* @param Response $response The response class.
|
||||
*
|
||||
* @since 2.0.1
|
||||
**/
|
||||
public function __construct(Http $http, Uri $uri, Response $response)
|
||||
{
|
||||
$this->http = $http;
|
||||
$this->uri = $uri;
|
||||
$this->response = $response;
|
||||
}
|
||||
###CODEPOWER###
|
@ -1,31 +1 @@
|
||||
{
|
||||
"add_head": "0",
|
||||
"add_licensing_template": "2",
|
||||
"extends": "0",
|
||||
"guid": "7b490e63-8d1f-46de-a0c4-154272fd5d7f",
|
||||
"implements": null,
|
||||
"load_selection": null,
|
||||
"name": "Api",
|
||||
"power_version": "1.0.0",
|
||||
"system_name": "Joomla.GetBible.Abstraction.Api",
|
||||
"type": "abstract class",
|
||||
"use_selection": {
|
||||
"use_selection0": {
|
||||
"use": "b8c66089-735e-4081-825c-8fe36b28e4a6",
|
||||
"as": "default"
|
||||
},
|
||||
"use_selection1": {
|
||||
"use": "fc9ab6f0-c31b-4077-bb1c-2dcddd36f6bb",
|
||||
"as": "default"
|
||||
},
|
||||
"use_selection2": {
|
||||
"use": "c99e85a0-d120-4f25-bcbf-0940dd7b773b",
|
||||
"as": "default"
|
||||
}
|
||||
},
|
||||
"namespace": "VDM\\Joomla\\GetBible\\Abstraction.Api",
|
||||
"description": "The GetBible Api\r\n\r\n@since 2.0.1",
|
||||
"licensing_template": "\/**\r\n * @package GetBible\r\n *\r\n * @created 30th May, 2023\r\n * @author Llewellyn van der Merwe <https:\/\/dev.vdm.io>\r\n * @git GetBible <https:\/\/git.vdm.dev\/getBible>\r\n * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.\r\n * @license GNU General Public License version 2 or later; see LICENSE.txt\r\n *\/\r\n",
|
||||
"head": "",
|
||||
"composer": ""
|
||||
}
|
||||
###POWERLINKER###
|
@ -1,21 +1 @@
|
||||
```
|
||||
██████╗ ██████╗ ██╗ ██╗███████╗██████╗
|
||||
██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗
|
||||
██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝
|
||||
██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗
|
||||
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
|
||||
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
|
||||
```
|
||||
> Error adding class diagram
|
||||
|
||||
---
|
||||
```
|
||||
██╗ ██████╗██████╗
|
||||
██║██╔════╝██╔══██╗
|
||||
██║██║ ██████╔╝
|
||||
██ ██║██║ ██╔══██╗
|
||||
╚█████╔╝╚██████╗██████╔╝
|
||||
╚════╝ ╚═════╝╚═════╝
|
||||
```
|
||||
> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder)
|
||||
|
||||
###POWERREADME###
|
@ -9,15 +9,4 @@
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\GetBible;
|
||||
|
||||
|
||||
/**
|
||||
* The GetBible Search
|
||||
*
|
||||
* @since 2.0.1
|
||||
*/
|
||||
final class Search
|
||||
{
|
||||
}
|
||||
|
||||
###POWERCODE###
|
||||
|
@ -1,18 +1 @@
|
||||
{
|
||||
"add_head": "0",
|
||||
"add_licensing_template": "2",
|
||||
"extends": "0",
|
||||
"guid": "8336e3c4-f11b-41bc-a2b1-976f99442a84",
|
||||
"implements": null,
|
||||
"load_selection": null,
|
||||
"name": "Search",
|
||||
"power_version": "1.0.0",
|
||||
"system_name": "Joomla.GetBible.Search",
|
||||
"type": "final class",
|
||||
"use_selection": null,
|
||||
"namespace": "VDM\\Joomla\\GetBible\\Search",
|
||||
"description": "The GetBible Search\r\n\r\n@since 2.0.1",
|
||||
"licensing_template": "\/**\r\n * @package GetBible\r\n *\r\n * @created 30th May, 2023\r\n * @author Llewellyn van der Merwe <https:\/\/dev.vdm.io>\r\n * @git GetBible <https:\/\/git.vdm.dev\/getBible>\r\n * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.\r\n * @license GNU General Public License version 2 or later; see LICENSE.txt\r\n *\/\r\n",
|
||||
"head": "",
|
||||
"composer": ""
|
||||
}
|
||||
###POWERLINKER###
|
@ -1,118 +1 @@
|
||||
```
|
||||
██████╗ ██████╗ ██╗ ██╗███████╗██████╗
|
||||
██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗
|
||||
██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝
|
||||
██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗
|
||||
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
|
||||
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
|
||||
```
|
||||
# final class DailyScripture (Details)
|
||||
> namespace: **VDM\Joomla\GetBible**
|
||||
```uml
|
||||
@startuml
|
||||
class DailyScripture << (F,LightGreen) >> #Green {
|
||||
# ?int $book
|
||||
# ?int $chapter
|
||||
# ?string $verses
|
||||
# ?string $reference
|
||||
# Load $load
|
||||
+ __construct(Config $config, Http $http, ...)
|
||||
+ load(string $reference)
|
||||
+ book() : ?int
|
||||
+ chapter() : ?int
|
||||
+ verses() : ?string
|
||||
- parse(string $reference)
|
||||
- extract(string $reference) : ?string
|
||||
- replace(string $reference, string $name, ...) : string
|
||||
- mb_str_replace(string $search, string $replace, ...) : string
|
||||
}
|
||||
|
||||
note right of DailyScripture::__construct
|
||||
Constructor
|
||||
|
||||
since: 2.0.1
|
||||
|
||||
arguments:
|
||||
Config $config
|
||||
Http $http
|
||||
Load $load
|
||||
end note
|
||||
|
||||
note left of DailyScripture::load
|
||||
An option to load another reference
|
||||
|
||||
since: 2.0.1
|
||||
end note
|
||||
|
||||
note right of DailyScripture::book
|
||||
Get the book number from the reference
|
||||
|
||||
since: 2.0.1
|
||||
return: ?int
|
||||
end note
|
||||
|
||||
note left of DailyScripture::chapter
|
||||
Get the chapter from the reference
|
||||
|
||||
since: 2.0.1
|
||||
return: ?int
|
||||
end note
|
||||
|
||||
note right of DailyScripture::verses
|
||||
Get the verses from the reference
|
||||
|
||||
since: 2.0.1
|
||||
return: ?string
|
||||
end note
|
||||
|
||||
note left of DailyScripture::parse
|
||||
Parse the scriptural reference
|
||||
|
||||
since: 2.0.1
|
||||
end note
|
||||
|
||||
note right of DailyScripture::extract
|
||||
Extract the book name from the reference
|
||||
|
||||
since: 2.0.1
|
||||
return: ?string
|
||||
end note
|
||||
|
||||
note left of DailyScripture::replace
|
||||
Replace the book name with a number in the reference
|
||||
|
||||
since: 2.0.1
|
||||
return: string
|
||||
|
||||
arguments:
|
||||
string $reference
|
||||
string $name
|
||||
int $number
|
||||
end note
|
||||
|
||||
note right of DailyScripture::mb_str_replace
|
||||
Build in str_replace that will work with all languages
|
||||
|
||||
since: 2.0.1
|
||||
return: string
|
||||
|
||||
arguments:
|
||||
string $search
|
||||
string $replace
|
||||
string $subject
|
||||
end note
|
||||
|
||||
@enduml
|
||||
```
|
||||
|
||||
---
|
||||
```
|
||||
██╗ ██████╗██████╗
|
||||
██║██╔════╝██╔══██╗
|
||||
██║██║ ██████╔╝
|
||||
██ ██║██║ ██╔══██╗
|
||||
╚█████╔╝╚██████╗██████╔╝
|
||||
╚════╝ ╚═════╝╚═════╝
|
||||
```
|
||||
> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder)
|
||||
|
||||
###POWERREADME###
|
@ -9,216 +9,4 @@
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\GetBible;
|
||||
|
||||
|
||||
use VDM\Joomla\GetBible\Config;
|
||||
use VDM\Joomla\GetBible\Utilities\Http;
|
||||
use VDM\Joomla\GetBible\Database\Load;
|
||||
|
||||
|
||||
/**
|
||||
* The GetBible Daily Scripture
|
||||
*
|
||||
* @since 2.0.1
|
||||
*/
|
||||
final class DailyScripture
|
||||
{
|
||||
/**
|
||||
* The book number
|
||||
*
|
||||
* @var string|null
|
||||
* @since 2.0.1
|
||||
*/
|
||||
protected ?int $book = null;
|
||||
|
||||
/**
|
||||
* The chapter number
|
||||
*
|
||||
* @var int|null
|
||||
* @since 2.0.1
|
||||
*/
|
||||
protected ?int $chapter = null;
|
||||
|
||||
/**
|
||||
* The verses string
|
||||
*
|
||||
* @var string|null
|
||||
* @since 2.0.1
|
||||
*/
|
||||
protected ?string $verses = null;
|
||||
|
||||
/**
|
||||
* The reference string
|
||||
*
|
||||
* @var string|null
|
||||
* @since 2.0.1
|
||||
*/
|
||||
protected ?string $reference = null;
|
||||
|
||||
/**
|
||||
* The load object
|
||||
*
|
||||
* @var Load
|
||||
* @since 2.0.1
|
||||
*/
|
||||
protected Load $load;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param Config $config The config object.
|
||||
* @param Http $http The http object.
|
||||
* @param Load $load The load object.
|
||||
*
|
||||
* @since 2.0.1
|
||||
*/
|
||||
public function __construct(Config $config, Http $http, Load $load)
|
||||
{
|
||||
$response = $http->get($config->daily_scripture_url);
|
||||
|
||||
// make sure we got the correct response
|
||||
if ($response->code == 200 && isset($response->body) && is_string($response->body))
|
||||
{
|
||||
$this->reference = $response->body;
|
||||
|
||||
$this->parse($this->reference);
|
||||
}
|
||||
|
||||
$this->load = $load;
|
||||
}
|
||||
|
||||
/**
|
||||
* An option to load another reference
|
||||
*
|
||||
* @param string $reference The scriptural reference.
|
||||
*
|
||||
* @since 2.0.1
|
||||
*/
|
||||
public function load(string $reference)
|
||||
{
|
||||
// convert book name to book number
|
||||
if (($name = $this->extract($reference)) !== null)
|
||||
{
|
||||
if (($number = $this->load->value(
|
||||
['name' => $name], 'nr', 'book')) === null)
|
||||
{
|
||||
// the book number could not be found
|
||||
return;
|
||||
}
|
||||
|
||||
$reference = $this->replace($reference, $name, $number);
|
||||
}
|
||||
|
||||
$this->parse($reference);
|
||||
|
||||
if ($this->book === null)
|
||||
{
|
||||
$this->parse($this->reference);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the book number from the reference
|
||||
*
|
||||
* @return int|null Book number
|
||||
* @since 2.0.1
|
||||
*/
|
||||
public function book(): ?int
|
||||
{
|
||||
return $this->book;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the chapter from the reference
|
||||
*
|
||||
* @return int|null Chapter number
|
||||
* @since 2.0.1
|
||||
*/
|
||||
public function chapter(): ?int
|
||||
{
|
||||
return $this->chapter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the verses from the reference
|
||||
*
|
||||
* @return string|null Verses
|
||||
* @since 2.0.1
|
||||
*/
|
||||
public function verses(): ?string
|
||||
{
|
||||
return $this->verses;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse the scriptural reference
|
||||
*
|
||||
* @param string $reference The scriptural reference.
|
||||
*
|
||||
* @since 2.0.1
|
||||
*/
|
||||
private function parse(string $reference)
|
||||
{
|
||||
$parts = explode(' ', $reference);
|
||||
|
||||
$this->book = (isset($parts[0]) && is_numeric($parts[0])) ? intval($parts[0]) : null;
|
||||
$chapterVerses = isset($parts[1]) ? explode(':', $parts[1]) : [null, null];
|
||||
|
||||
$this->chapter = (isset($chapterVerses[0]) && is_numeric($chapterVerses[0])) ? intval($chapterVerses[0]) : null;
|
||||
$this->verses = isset($chapterVerses[1]) ? trim($chapterVerses[1]) : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract the book name from the reference
|
||||
*
|
||||
* @return string|null Book name
|
||||
* @since 2.0.1
|
||||
*/
|
||||
private function extract(string $reference): ?string
|
||||
{
|
||||
// Use regex to match and remove chapter:verse and their variations (if they exist) from the end of the string
|
||||
// This new regex considers Unicode word boundaries
|
||||
$bookName = preg_replace('/\b\d+(:(\d+([,-]\d+)*)?\b)*$/u', '', $reference);
|
||||
|
||||
// If there's no match or the remaining string is empty or numeric, return null
|
||||
// The is_numeric check has been adjusted to work for Unicode strings
|
||||
if (mb_strlen(trim($bookName)) === 0 || preg_match('/^\d+$/u', $bookName))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return trim($bookName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Replace the book name with a number in the reference
|
||||
*
|
||||
* @param string $reference Original reference
|
||||
* @param string $name Book name
|
||||
* @param int $number Book number
|
||||
*
|
||||
* @return string New reference with the book number instead of the name
|
||||
* @since 2.0.1
|
||||
*/
|
||||
private function replace(string $reference, string $name, int $number): string
|
||||
{
|
||||
return $this->mb_str_replace($name, "$number", $reference);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build in str_replace that will work with all languages
|
||||
*
|
||||
* @param string $search The search phrase/word
|
||||
* @param string $replace The replace phrase/word
|
||||
* @param string $subject The string to update
|
||||
*
|
||||
* @return string New updated string
|
||||
* @since 2.0.1
|
||||
*/
|
||||
private function mb_str_replace(string $search, string $replace, string $subject): string
|
||||
{
|
||||
return mb_ereg_replace(preg_quote($search), $replace, $subject);
|
||||
}
|
||||
}
|
||||
|
||||
###POWERCODE###
|
||||
|
@ -1,196 +1 @@
|
||||
/**
|
||||
* The book number
|
||||
*
|
||||
* @var string|null
|
||||
* @since 2.0.1
|
||||
*/
|
||||
protected ?int $book = null;
|
||||
|
||||
/**
|
||||
* The chapter number
|
||||
*
|
||||
* @var int|null
|
||||
* @since 2.0.1
|
||||
*/
|
||||
protected ?int $chapter = null;
|
||||
|
||||
/**
|
||||
* The verses string
|
||||
*
|
||||
* @var string|null
|
||||
* @since 2.0.1
|
||||
*/
|
||||
protected ?string $verses = null;
|
||||
|
||||
/**
|
||||
* The reference string
|
||||
*
|
||||
* @var string|null
|
||||
* @since 2.0.1
|
||||
*/
|
||||
protected ?string $reference = null;
|
||||
|
||||
/**
|
||||
* The load object
|
||||
*
|
||||
* @var Load
|
||||
* @since 2.0.1
|
||||
*/
|
||||
protected Load $load;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param Config $config The config object.
|
||||
* @param Http $http The http object.
|
||||
* @param Load $load The load object.
|
||||
*
|
||||
* @since 2.0.1
|
||||
*/
|
||||
public function __construct(Config $config, Http $http, Load $load)
|
||||
{
|
||||
$response = $http->get($config->daily_scripture_url);
|
||||
|
||||
// make sure we got the correct response
|
||||
if ($response->code == 200 && isset($response->body) && is_string($response->body))
|
||||
{
|
||||
$this->reference = $response->body;
|
||||
|
||||
$this->parse($this->reference);
|
||||
}
|
||||
|
||||
$this->load = $load;
|
||||
}
|
||||
|
||||
/**
|
||||
* An option to load another reference
|
||||
*
|
||||
* @param string $reference The scriptural reference.
|
||||
*
|
||||
* @since 2.0.1
|
||||
*/
|
||||
public function load(string $reference)
|
||||
{
|
||||
// convert book name to book number
|
||||
if (($name = $this->extract($reference)) !== null)
|
||||
{
|
||||
if (($number = $this->load->value(
|
||||
['name' => $name], 'nr', 'book')) === null)
|
||||
{
|
||||
// the book number could not be found
|
||||
return;
|
||||
}
|
||||
|
||||
$reference = $this->replace($reference, $name, $number);
|
||||
}
|
||||
|
||||
$this->parse($reference);
|
||||
|
||||
if ($this->book === null)
|
||||
{
|
||||
$this->parse($this->reference);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the book number from the reference
|
||||
*
|
||||
* @return int|null Book number
|
||||
* @since 2.0.1
|
||||
*/
|
||||
public function book(): ?int
|
||||
{
|
||||
return $this->book;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the chapter from the reference
|
||||
*
|
||||
* @return int|null Chapter number
|
||||
* @since 2.0.1
|
||||
*/
|
||||
public function chapter(): ?int
|
||||
{
|
||||
return $this->chapter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the verses from the reference
|
||||
*
|
||||
* @return string|null Verses
|
||||
* @since 2.0.1
|
||||
*/
|
||||
public function verses(): ?string
|
||||
{
|
||||
return $this->verses;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse the scriptural reference
|
||||
*
|
||||
* @param string $reference The scriptural reference.
|
||||
*
|
||||
* @since 2.0.1
|
||||
*/
|
||||
private function parse(string $reference)
|
||||
{
|
||||
$parts = explode(' ', $reference);
|
||||
|
||||
$this->book = (isset($parts[0]) && is_numeric($parts[0])) ? intval($parts[0]) : null;
|
||||
$chapterVerses = isset($parts[1]) ? explode(':', $parts[1]) : [null, null];
|
||||
|
||||
$this->chapter = (isset($chapterVerses[0]) && is_numeric($chapterVerses[0])) ? intval($chapterVerses[0]) : null;
|
||||
$this->verses = isset($chapterVerses[1]) ? trim($chapterVerses[1]) : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract the book name from the reference
|
||||
*
|
||||
* @return string|null Book name
|
||||
* @since 2.0.1
|
||||
*/
|
||||
private function extract(string $reference): ?string
|
||||
{
|
||||
// Use regex to match and remove chapter:verse and their variations (if they exist) from the end of the string
|
||||
// This new regex considers Unicode word boundaries
|
||||
$bookName = preg_replace('/\b\d+(:(\d+([,-]\d+)*)?\b)*$/u', '', $reference);
|
||||
|
||||
// If there's no match or the remaining string is empty or numeric, return null
|
||||
// The is_numeric check has been adjusted to work for Unicode strings
|
||||
if (mb_strlen(trim($bookName)) === 0 || preg_match('/^\d+$/u', $bookName))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return trim($bookName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Replace the book name with a number in the reference
|
||||
*
|
||||
* @param string $reference Original reference
|
||||
* @param string $name Book name
|
||||
* @param int $number Book number
|
||||
*
|
||||
* @return string New reference with the book number instead of the name
|
||||
* @since 2.0.1
|
||||
*/
|
||||
private function replace(string $reference, string $name, int $number): string
|
||||
{
|
||||
return $this->mb_str_replace($name, "$number", $reference);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build in str_replace that will work with all languages
|
||||
*
|
||||
* @param string $search The search phrase/word
|
||||
* @param string $replace The replace phrase/word
|
||||
* @param string $subject The string to update
|
||||
*
|
||||
* @return string New updated string
|
||||
* @since 2.0.1
|
||||
*/
|
||||
private function mb_str_replace(string $search, string $replace, string $subject): string
|
||||
{
|
||||
return mb_ereg_replace(preg_quote($search), $replace, $subject);
|
||||
}
|
||||
###CODEPOWER###
|
@ -1,31 +1 @@
|
||||
{
|
||||
"add_head": "0",
|
||||
"add_licensing_template": "2",
|
||||
"extends": "0",
|
||||
"guid": "90f2ee7a-c041-4316-ad54-af4f97fa3003",
|
||||
"implements": null,
|
||||
"load_selection": null,
|
||||
"name": "DailyScripture",
|
||||
"power_version": "1.0.0",
|
||||
"system_name": "Joomla.GetBible.DailyScripture",
|
||||
"type": "final class",
|
||||
"use_selection": {
|
||||
"use_selection0": {
|
||||
"use": "71075f03-4e77-4fc0-840a-ef55fd9260b2",
|
||||
"as": "default"
|
||||
},
|
||||
"use_selection1": {
|
||||
"use": "b8c66089-735e-4081-825c-8fe36b28e4a6",
|
||||
"as": "default"
|
||||
},
|
||||
"use_selection2": {
|
||||
"use": "c03b9c61-17d3-4774-a335-783903719f83",
|
||||
"as": "default"
|
||||
}
|
||||
},
|
||||
"namespace": "VDM\\Joomla\\GetBible\\DailyScripture",
|
||||
"description": "The GetBible Daily Scripture\r\n\r\n@since 2.0.1",
|
||||
"licensing_template": "\/**\r\n * @package GetBible\r\n *\r\n * @created 30th May, 2023\r\n * @author Llewellyn van der Merwe <https:\/\/dev.vdm.io>\r\n * @git GetBible <https:\/\/git.vdm.dev\/getBible>\r\n * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.\r\n * @license GNU General Public License version 2 or later; see LICENSE.txt\r\n *\/\r\n",
|
||||
"head": "",
|
||||
"composer": ""
|
||||
}
|
||||
###POWERLINKER###
|
@ -1,93 +1 @@
|
||||
```
|
||||
██████╗ ██████╗ ██╗ ██╗███████╗██████╗
|
||||
██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗
|
||||
██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝
|
||||
██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗
|
||||
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
|
||||
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
|
||||
```
|
||||
# final class Upsert (Details)
|
||||
> namespace: **VDM\Joomla\GetBible\Model**
|
||||
```uml
|
||||
@startuml
|
||||
class Upsert << (F,LightGreen) >> #Green {
|
||||
# Config $config
|
||||
+ __construct(Config $config, Table $table)
|
||||
+ value(mixed $value, string $field, ...) : mixed
|
||||
# validateBefore(mixed $value, ?string $field = null, ...) : bool
|
||||
# validateAfter(mixed $value, ?string $field = null, ...) : bool
|
||||
# getTable() : string
|
||||
+ modelDistributionHistory(mixed $value) : mixed
|
||||
}
|
||||
|
||||
note right of Upsert::__construct
|
||||
Constructor
|
||||
|
||||
since: 2.0.1
|
||||
end note
|
||||
|
||||
note right of Upsert::value
|
||||
Model the value
|
||||
Example: $this->value(value, 'field_key', 'table_name');
|
||||
|
||||
since: 2.0.1
|
||||
return: mixed
|
||||
|
||||
arguments:
|
||||
mixed $value
|
||||
string $field
|
||||
?string $table = null
|
||||
end note
|
||||
|
||||
note right of Upsert::validateBefore
|
||||
Validate before the value is modelled
|
||||
|
||||
since: 2.0.1
|
||||
return: bool
|
||||
|
||||
arguments:
|
||||
mixed $value
|
||||
?string $field = null
|
||||
?string $table = null
|
||||
end note
|
||||
|
||||
note right of Upsert::validateAfter
|
||||
Validate after the value is modelled
|
||||
|
||||
since: 2.0.1
|
||||
return: bool
|
||||
|
||||
arguments:
|
||||
mixed $value
|
||||
?string $field = null
|
||||
?string $table = null
|
||||
end note
|
||||
|
||||
note right of Upsert::getTable
|
||||
Get the current active table
|
||||
|
||||
since: 2.0.1
|
||||
return: string
|
||||
end note
|
||||
|
||||
note right of Upsert::modelDistributionHistory
|
||||
Model Distribution History
|
||||
|
||||
since: 2.0.1
|
||||
return: mixed
|
||||
end note
|
||||
|
||||
@enduml
|
||||
```
|
||||
|
||||
---
|
||||
```
|
||||
██╗ ██████╗██████╗
|
||||
██║██╔════╝██╔══██╗
|
||||
██║██║ ██████╔╝
|
||||
██ ██║██║ ██╔══██╗
|
||||
╚█████╔╝╚██████╗██████╔╝
|
||||
╚════╝ ╚═════╝╚═════╝
|
||||
```
|
||||
> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder)
|
||||
|
||||
###POWERREADME###
|
@ -9,151 +9,4 @@
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\GetBible\Model;
|
||||
|
||||
|
||||
use VDM\Joomla\GetBible\Config;
|
||||
use VDM\Joomla\GetBible\Table;
|
||||
use VDM\Joomla\Utilities\ObjectHelper;
|
||||
use VDM\Joomla\Interfaces\ModelInterface;
|
||||
use VDM\Joomla\Abstraction\Model;
|
||||
|
||||
|
||||
/**
|
||||
* The GetBible Model for both Update and Insert
|
||||
*
|
||||
* @since 2.0.1
|
||||
*/
|
||||
final class Upsert extends Model implements ModelInterface
|
||||
{
|
||||
/**
|
||||
* GetBible Config
|
||||
*
|
||||
* @var Config
|
||||
* @since 2.0.1
|
||||
*/
|
||||
protected Config $config;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param Config $config The getBible config object.
|
||||
* @param Table $table The getBible table object.
|
||||
*
|
||||
* @since 2.0.1
|
||||
*/
|
||||
public function __construct(Config $config, Table $table)
|
||||
{
|
||||
parent::__construct($table);
|
||||
|
||||
$this->config = $config;
|
||||
}
|
||||
|
||||
/**
|
||||
* Model the value
|
||||
* Example: $this->value(value, 'field_key', 'table_name');
|
||||
*
|
||||
* @param mixed $value The value to model
|
||||
* @param string $field The field key
|
||||
* @param string|null $table The table
|
||||
*
|
||||
* @return mixed
|
||||
* @since 2.0.1
|
||||
*/
|
||||
public function value($value, string $field, ?string $table = null)
|
||||
{
|
||||
// set the table name
|
||||
if (empty($table))
|
||||
{
|
||||
$table = $this->getTable();
|
||||
}
|
||||
|
||||
// check if this is a valid table
|
||||
if (($store = $this->table->get($table, $field, 'store')) !== null)
|
||||
{
|
||||
// Model Distribution History
|
||||
if ($table === 'translation' && $field === 'distribution_history')
|
||||
{
|
||||
$value = $this->modelDistributionHistory($value);
|
||||
}
|
||||
|
||||
// open the value based on the store method
|
||||
switch($store)
|
||||
{
|
||||
case 'json':
|
||||
$value = json_encode($value, JSON_FORCE_OBJECT);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate before the value is modelled
|
||||
*
|
||||
* @param mixed $value The field value
|
||||
* @param string|null $field The field key
|
||||
* @param string|null $table The table
|
||||
*
|
||||
* @return bool
|
||||
* @since 2.0.1
|
||||
*/
|
||||
protected function validateBefore(&$value, ?string $field = null, ?string $table = null): bool
|
||||
{
|
||||
// add all values
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate after the value is modelled
|
||||
*
|
||||
* @param mixed $value The field value
|
||||
* @param string|null $field The field key
|
||||
* @param string|null $table The table
|
||||
*
|
||||
* @return bool
|
||||
* @since 2.0.1
|
||||
*/
|
||||
protected function validateAfter(&$value, ?string $field = null, ?string $table = null): bool
|
||||
{
|
||||
// add all values
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current active table
|
||||
*
|
||||
* @return string
|
||||
* @since 2.0.1
|
||||
*/
|
||||
protected function getTable(): string
|
||||
{
|
||||
return $this->config->table_name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Model Distribution History
|
||||
*
|
||||
* @param mixed $value The value to model
|
||||
*
|
||||
* @return mixed
|
||||
* @since 2.0.1
|
||||
*/
|
||||
public function modelDistributionHistory($value)
|
||||
{
|
||||
if (ObjectHelper::check($value))
|
||||
{
|
||||
$n = 0;
|
||||
$bucket = [];
|
||||
foreach ($value as $version => $description)
|
||||
{
|
||||
$bucket["distribution_history$n"] = ['version' => $version, 'description' => $description];
|
||||
$n++;
|
||||
}
|
||||
return $bucket;
|
||||
}
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
###POWERCODE###
|
||||
|
@ -1,129 +1 @@
|
||||
/**
|
||||
* GetBible Config
|
||||
*
|
||||
* @var Config
|
||||
* @since 2.0.1
|
||||
*/
|
||||
protected Config $config;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param Config $config The getBible config object.
|
||||
* @param Table $table The getBible table object.
|
||||
*
|
||||
* @since 2.0.1
|
||||
*/
|
||||
public function __construct(Config $config, Table $table)
|
||||
{
|
||||
parent::__construct($table);
|
||||
|
||||
$this->config = $config;
|
||||
}
|
||||
|
||||
/**
|
||||
* Model the value
|
||||
* Example: $this->value(value, 'field_key', 'table_name');
|
||||
*
|
||||
* @param mixed $value The value to model
|
||||
* @param string $field The field key
|
||||
* @param string|null $table The table
|
||||
*
|
||||
* @return mixed
|
||||
* @since 2.0.1
|
||||
*/
|
||||
public function value($value, string $field, ?string $table = null)
|
||||
{
|
||||
// set the table name
|
||||
if (empty($table))
|
||||
{
|
||||
$table = $this->getTable();
|
||||
}
|
||||
|
||||
// check if this is a valid table
|
||||
if (($store = $this->table->get($table, $field, 'store')) !== null)
|
||||
{
|
||||
// Model Distribution History
|
||||
if ($table === 'translation' && $field === 'distribution_history')
|
||||
{
|
||||
$value = $this->modelDistributionHistory($value);
|
||||
}
|
||||
|
||||
// open the value based on the store method
|
||||
switch($store)
|
||||
{
|
||||
case 'json':
|
||||
$value = json_encode($value, JSON_FORCE_OBJECT);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate before the value is modelled
|
||||
*
|
||||
* @param mixed $value The field value
|
||||
* @param string|null $field The field key
|
||||
* @param string|null $table The table
|
||||
*
|
||||
* @return bool
|
||||
* @since 2.0.1
|
||||
*/
|
||||
protected function validateBefore(&$value, ?string $field = null, ?string $table = null): bool
|
||||
{
|
||||
// add all values
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate after the value is modelled
|
||||
*
|
||||
* @param mixed $value The field value
|
||||
* @param string|null $field The field key
|
||||
* @param string|null $table The table
|
||||
*
|
||||
* @return bool
|
||||
* @since 2.0.1
|
||||
*/
|
||||
protected function validateAfter(&$value, ?string $field = null, ?string $table = null): bool
|
||||
{
|
||||
// add all values
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current active table
|
||||
*
|
||||
* @return string
|
||||
* @since 2.0.1
|
||||
*/
|
||||
protected function getTable(): string
|
||||
{
|
||||
return $this->config->table_name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Model Distribution History
|
||||
*
|
||||
* @param mixed $value The value to model
|
||||
*
|
||||
* @return mixed
|
||||
* @since 2.0.1
|
||||
*/
|
||||
public function modelDistributionHistory($value)
|
||||
{
|
||||
if (ObjectHelper::check($value))
|
||||
{
|
||||
$n = 0;
|
||||
$bucket = [];
|
||||
foreach ($value as $version => $description)
|
||||
{
|
||||
$bucket["distribution_history$n"] = ['version' => $version, 'description' => $description];
|
||||
$n++;
|
||||
}
|
||||
return $bucket;
|
||||
}
|
||||
return '';
|
||||
}
|
||||
###CODEPOWER###
|
@ -1,33 +1 @@
|
||||
{
|
||||
"add_head": "0",
|
||||
"add_licensing_template": "2",
|
||||
"extends": "584747d1-3a86-453d-b7a3-a2219de8d777",
|
||||
"guid": "91b37bd7-b314-48be-91cf-434ec823bd80",
|
||||
"implements": [
|
||||
"8aef58c1-3f70-4bd4-b9e4-3f29fcd41cff"
|
||||
],
|
||||
"load_selection": null,
|
||||
"name": "Upsert",
|
||||
"power_version": "1.0.0",
|
||||
"system_name": "Joomla.GetBible.Model.Upsert",
|
||||
"type": "final class",
|
||||
"use_selection": {
|
||||
"use_selection0": {
|
||||
"use": "71075f03-4e77-4fc0-840a-ef55fd9260b2",
|
||||
"as": "default"
|
||||
},
|
||||
"use_selection1": {
|
||||
"use": "ff8d5fdb-2d1f-4178-bd18-a43b8efd1068",
|
||||
"as": "default"
|
||||
},
|
||||
"use_selection4": {
|
||||
"use": "91004529-94a9-4590-b842-e7c6b624ecf5",
|
||||
"as": "default"
|
||||
}
|
||||
},
|
||||
"namespace": "VDM\\Joomla\\GetBible\\Model.Upsert",
|
||||
"description": "The GetBible Model for both Update and Insert\r\n\r\n@since 2.0.1",
|
||||
"licensing_template": "\/**\r\n * @package GetBible\r\n *\r\n * @created 30th May, 2023\r\n * @author Llewellyn van der Merwe <https:\/\/dev.vdm.io>\r\n * @git GetBible <https:\/\/git.vdm.dev\/getBible>\r\n * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.\r\n * @license GNU General Public License version 2 or later; see LICENSE.txt\r\n *\/\r\n",
|
||||
"head": "",
|
||||
"composer": ""
|
||||
}
|
||||
###POWERLINKER###
|
@ -1,88 +1 @@
|
||||
```
|
||||
██████╗ ██████╗ ██╗ ██╗███████╗██████╗
|
||||
██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗
|
||||
██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝
|
||||
██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗
|
||||
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
|
||||
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
|
||||
```
|
||||
# final class Insert (Details)
|
||||
> namespace: **VDM\Joomla\GetBible\Database**
|
||||
```uml
|
||||
@startuml
|
||||
class Insert << (F,LightGreen) >> #Green {
|
||||
# Model $model
|
||||
# Database $database
|
||||
+ __construct(Model $model, Database $database)
|
||||
+ value(mixed $value, string $field, ...) : bool
|
||||
+ row(array $item, string $table) : bool
|
||||
+ rows(?array $items, string $table) : bool
|
||||
+ item(object $item, string $table) : bool
|
||||
+ items(?array $items, string $table) : bool
|
||||
}
|
||||
|
||||
note right of Insert::__construct
|
||||
Constructor
|
||||
|
||||
since: 2.0.1
|
||||
end note
|
||||
|
||||
note right of Insert::value
|
||||
Insert a value to a given table
|
||||
Example: $this->value(Value, 'value_key', 'table_name');
|
||||
|
||||
since: 2.0.1
|
||||
return: bool
|
||||
|
||||
arguments:
|
||||
mixed $value
|
||||
string $field
|
||||
string $table
|
||||
end note
|
||||
|
||||
note right of Insert::row
|
||||
Insert single row with multiple values to a given table
|
||||
Example: $this->item(Array, 'table_name');
|
||||
|
||||
since: 2.0.1
|
||||
return: bool
|
||||
end note
|
||||
|
||||
note right of Insert::rows
|
||||
Insert multiple rows to a given table
|
||||
Example: $this->items(Array, 'table_name');
|
||||
|
||||
since: 2.0.1
|
||||
return: bool
|
||||
end note
|
||||
|
||||
note right of Insert::item
|
||||
Insert single item with multiple values to a given table
|
||||
Example: $this->item(Object, 'table_name');
|
||||
|
||||
since: 2.0.1
|
||||
return: bool
|
||||
end note
|
||||
|
||||
note right of Insert::items
|
||||
Insert multiple items to a given table
|
||||
Example: $this->items(Array, 'table_name');
|
||||
|
||||
since: 2.0.1
|
||||
return: bool
|
||||
end note
|
||||
|
||||
@enduml
|
||||
```
|
||||
|
||||
---
|
||||
```
|
||||
██╗ ██████╗██████╗
|
||||
██║██╔════╝██╔══██╗
|
||||
██║██║ ██████╔╝
|
||||
██ ██║██║ ██╔══██╗
|
||||
╚█████╔╝╚██████╗██████╔╝
|
||||
╚════╝ ╚═════╝╚═════╝
|
||||
```
|
||||
> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder)
|
||||
|
||||
###POWERREADME###
|
@ -9,153 +9,4 @@
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\GetBible\Database;
|
||||
|
||||
|
||||
use VDM\Joomla\GetBible\Model\Upsert as Model;
|
||||
use VDM\Joomla\Database\Insert as Database;
|
||||
|
||||
|
||||
/**
|
||||
* GetBible Database Insert
|
||||
*
|
||||
* @since 2.0.1
|
||||
*/
|
||||
final class Insert
|
||||
{
|
||||
/**
|
||||
* Model
|
||||
*
|
||||
* @var Model
|
||||
* @since 2.0.1
|
||||
*/
|
||||
protected Model $model;
|
||||
|
||||
/**
|
||||
* Database
|
||||
*
|
||||
* @var Database
|
||||
* @since 2.0.1
|
||||
*/
|
||||
protected Database $database;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param Model $model The set model object.
|
||||
* @param Database $database The insert database object.
|
||||
*
|
||||
* @since 2.0.1
|
||||
*/
|
||||
public function __construct(Model $model, Database $database)
|
||||
{
|
||||
$this->model = $model;
|
||||
$this->database = $database;
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert a value to a given table
|
||||
* Example: $this->value(Value, 'value_key', 'table_name');
|
||||
*
|
||||
* @param mixed $value The field value
|
||||
* @param string $field The field key
|
||||
* @param string $table Target table
|
||||
*
|
||||
* @return bool
|
||||
* @since 2.0.1
|
||||
*/
|
||||
public function value($value, string $field, string $table): bool
|
||||
{
|
||||
// build the array
|
||||
$item = [];
|
||||
$item[$field] = $value;
|
||||
|
||||
// Insert the column of this table
|
||||
return $this->row($item, $table);
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert single row with multiple values to a given table
|
||||
* Example: $this->item(Array, 'table_name');
|
||||
*
|
||||
* @param array $item The item to save
|
||||
* @param string $table Target table
|
||||
*
|
||||
* @return bool
|
||||
* @since 2.0.1
|
||||
*/
|
||||
public function row(array $item, string $table): bool
|
||||
{
|
||||
// check if object could be modelled
|
||||
if (($item = $this->model->row($item, $table)) !== null)
|
||||
{
|
||||
// Insert the column of this table
|
||||
return $this->database->row($item, $table);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert multiple rows to a given table
|
||||
* Example: $this->items(Array, 'table_name');
|
||||
*
|
||||
* @param array|null $items The items updated in database (array of arrays)
|
||||
* @param string $table Target table
|
||||
*
|
||||
* @return bool
|
||||
* @since 2.0.1
|
||||
*/
|
||||
public function rows(?array $items, string $table): bool
|
||||
{
|
||||
// check if object could be modelled
|
||||
if (($items = $this->model->rows($items, $table)) !== null)
|
||||
{
|
||||
// Insert the column of this table
|
||||
return $this->database->rows($items, $table);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert single item with multiple values to a given table
|
||||
* Example: $this->item(Object, 'table_name');
|
||||
*
|
||||
* @param object $item The item to save
|
||||
* @param string $table Target table
|
||||
*
|
||||
* @return bool
|
||||
* @since 2.0.1
|
||||
*/
|
||||
public function item(object $item, string $table): bool
|
||||
{
|
||||
// check if object could be modelled
|
||||
if (($item = $this->model->item($item, $table)) !== null)
|
||||
{
|
||||
// Insert the column of this table.
|
||||
return $this->database->item($item, $table);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert multiple items to a given table
|
||||
* Example: $this->items(Array, 'table_name');
|
||||
*
|
||||
* @param array|null $items The items updated in database (array of objects)
|
||||
* @param string $table Target table
|
||||
*
|
||||
* @return bool
|
||||
* @since 2.0.1
|
||||
*/
|
||||
public function items(?array $items, string $table): bool
|
||||
{
|
||||
// check if object could be modelled
|
||||
if (($items = $this->model->items($items, $table)) !== null)
|
||||
{
|
||||
// Insert the column of this table.
|
||||
return $this->database->items($items, $table);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
###POWERCODE###
|
||||
|
@ -1,134 +1 @@
|
||||
/**
|
||||
* Model
|
||||
*
|
||||
* @var Model
|
||||
* @since 2.0.1
|
||||
*/
|
||||
protected Model $model;
|
||||
|
||||
/**
|
||||
* Database
|
||||
*
|
||||
* @var Database
|
||||
* @since 2.0.1
|
||||
*/
|
||||
protected Database $database;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param Model $model The set model object.
|
||||
* @param Database $database The insert database object.
|
||||
*
|
||||
* @since 2.0.1
|
||||
*/
|
||||
public function __construct(Model $model, Database $database)
|
||||
{
|
||||
$this->model = $model;
|
||||
$this->database = $database;
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert a value to a given table
|
||||
* Example: $this->value(Value, 'value_key', 'table_name');
|
||||
*
|
||||
* @param mixed $value The field value
|
||||
* @param string $field The field key
|
||||
* @param string $table Target table
|
||||
*
|
||||
* @return bool
|
||||
* @since 2.0.1
|
||||
*/
|
||||
public function value($value, string $field, string $table): bool
|
||||
{
|
||||
// build the array
|
||||
$item = [];
|
||||
$item[$field] = $value;
|
||||
|
||||
// Insert the column of this table
|
||||
return $this->row($item, $table);
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert single row with multiple values to a given table
|
||||
* Example: $this->item(Array, 'table_name');
|
||||
*
|
||||
* @param array $item The item to save
|
||||
* @param string $table Target table
|
||||
*
|
||||
* @return bool
|
||||
* @since 2.0.1
|
||||
*/
|
||||
public function row(array $item, string $table): bool
|
||||
{
|
||||
// check if object could be modelled
|
||||
if (($item = $this->model->row($item, $table)) !== null)
|
||||
{
|
||||
// Insert the column of this table
|
||||
return $this->database->row($item, $table);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert multiple rows to a given table
|
||||
* Example: $this->items(Array, 'table_name');
|
||||
*
|
||||
* @param array|null $items The items updated in database (array of arrays)
|
||||
* @param string $table Target table
|
||||
*
|
||||
* @return bool
|
||||
* @since 2.0.1
|
||||
*/
|
||||
public function rows(?array $items, string $table): bool
|
||||
{
|
||||
// check if object could be modelled
|
||||
if (($items = $this->model->rows($items, $table)) !== null)
|
||||
{
|
||||
// Insert the column of this table
|
||||
return $this->database->rows($items, $table);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert single item with multiple values to a given table
|
||||
* Example: $this->item(Object, 'table_name');
|
||||
*
|
||||
* @param object $item The item to save
|
||||
* @param string $table Target table
|
||||
*
|
||||
* @return bool
|
||||
* @since 2.0.1
|
||||
*/
|
||||
public function item(object $item, string $table): bool
|
||||
{
|
||||
// check if object could be modelled
|
||||
if (($item = $this->model->item($item, $table)) !== null)
|
||||
{
|
||||
// Insert the column of this table.
|
||||
return $this->database->item($item, $table);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert multiple items to a given table
|
||||
* Example: $this->items(Array, 'table_name');
|
||||
*
|
||||
* @param array|null $items The items updated in database (array of objects)
|
||||
* @param string $table Target table
|
||||
*
|
||||
* @return bool
|
||||
* @since 2.0.1
|
||||
*/
|
||||
public function items(?array $items, string $table): bool
|
||||
{
|
||||
// check if object could be modelled
|
||||
if (($items = $this->model->items($items, $table)) !== null)
|
||||
{
|
||||
// Insert the column of this table.
|
||||
return $this->database->items($items, $table);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
###CODEPOWER###
|
@ -1,27 +1 @@
|
||||
{
|
||||
"add_head": "0",
|
||||
"add_licensing_template": "2",
|
||||
"extends": "0",
|
||||
"guid": "a07d90f6-6ff2-40a1-99c1-0f2cf33c9adf",
|
||||
"implements": null,
|
||||
"load_selection": null,
|
||||
"name": "Insert",
|
||||
"power_version": "1.0.0",
|
||||
"system_name": "Joomla.GetBible.Database.Insert",
|
||||
"type": "final class",
|
||||
"use_selection": {
|
||||
"use_selection0": {
|
||||
"use": "91b37bd7-b314-48be-91cf-434ec823bd80",
|
||||
"as": "Model"
|
||||
},
|
||||
"use_selection1": {
|
||||
"use": "524eb8f6-38d4-47dc-92ad-98b94e099ac0",
|
||||
"as": "Database"
|
||||
}
|
||||
},
|
||||
"namespace": "VDM\\Joomla\\GetBible\\Database.Insert",
|
||||
"description": "GetBible Database Insert\r\n\r\n@since 2.0.1",
|
||||
"licensing_template": "\/**\r\n * @package GetBible\r\n *\r\n * @created 30th May, 2023\r\n * @author Llewellyn van der Merwe <https:\/\/dev.vdm.io>\r\n * @git GetBible <https:\/\/git.vdm.dev\/getBible>\r\n * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.\r\n * @license GNU General Public License version 2 or later; see LICENSE.txt\r\n *\/\r\n",
|
||||
"head": "",
|
||||
"composer": ""
|
||||
}
|
||||
###POWERLINKER###
|
@ -1,66 +1 @@
|
||||
```
|
||||
██████╗ ██████╗ ██╗ ██╗███████╗██████╗
|
||||
██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗
|
||||
██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝
|
||||
██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗
|
||||
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
|
||||
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
|
||||
```
|
||||
# final class Chapters (Details)
|
||||
> namespace: **VDM\Joomla\GetBible\Api**
|
||||
```uml
|
||||
@startuml
|
||||
class Chapters << (F,LightGreen) >> #Green {
|
||||
+ get(string $translation, int $book) : ?object
|
||||
+ list(string $translation, int $book) : ?object
|
||||
+ checksum(string $translation, int $book) : ?object
|
||||
+ sha(string $translation, int $book, ...) : ?string
|
||||
}
|
||||
|
||||
note right of Chapters::get
|
||||
Get the chapters in a book in a translation
|
||||
|
||||
since: 2.0.1
|
||||
return: ?object
|
||||
end note
|
||||
|
||||
note right of Chapters::list
|
||||
List the chapters of a book in a translation
|
||||
|
||||
since: 2.0.1
|
||||
return: ?object
|
||||
end note
|
||||
|
||||
note right of Chapters::checksum
|
||||
List the chapters checksums of a book in a translation
|
||||
|
||||
since: 2.0.1
|
||||
return: ?object
|
||||
end note
|
||||
|
||||
note right of Chapters::sha
|
||||
Get the chapter's checksums of a book in a translation
|
||||
|
||||
since: 2.0.1
|
||||
return: ?string
|
||||
|
||||
arguments:
|
||||
string $translation
|
||||
int $book
|
||||
int $chapter
|
||||
end note
|
||||
|
||||
@enduml
|
||||
```
|
||||
|
||||
---
|
||||
```
|
||||
██╗ ██████╗██████╗
|
||||
██║██╔════╝██╔══██╗
|
||||
██║██║ ██████╔╝
|
||||
██ ██║██║ ██╔══██╗
|
||||
╚█████╔╝╚██████╗██████╔╝
|
||||
╚════╝ ╚═════╝╚═════╝
|
||||
```
|
||||
> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder)
|
||||
|
||||
###POWERREADME###
|
@ -9,92 +9,4 @@
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\GetBible\Api;
|
||||
|
||||
|
||||
use VDM\Joomla\GetBible\Abstraction\Api;
|
||||
|
||||
|
||||
/**
|
||||
* The GetBible Book Chapters
|
||||
*
|
||||
* @since 2.0.1
|
||||
*/
|
||||
final class Chapters extends Api
|
||||
{
|
||||
/**
|
||||
* Get the chapters in a book in a translation
|
||||
*
|
||||
* @param string $translation The translation.
|
||||
* @param int $book The book number.
|
||||
*
|
||||
* @return object|null The response object or null if an error occurs.
|
||||
* @since 2.0.1
|
||||
*/
|
||||
public function get(string $translation, int $book): ?object
|
||||
{
|
||||
return $this->response->get(
|
||||
$this->http->get(
|
||||
$this->uri->get($translation . '/' . $book . '.json')
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* List the chapters of a book in a translation
|
||||
*
|
||||
* @param string $translation The translation.
|
||||
* @param int $book The book number.
|
||||
*
|
||||
* @return object|null The response object or null if an error occurs.
|
||||
* @since 2.0.1
|
||||
*/
|
||||
public function list( string $translation, int $book): ?object
|
||||
{
|
||||
return $this->response->get(
|
||||
$this->http->get(
|
||||
$this->uri->get($translation . '/' . $book . '/chapters.json')
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* List the chapters checksums of a book in a translation
|
||||
*
|
||||
* @param string $translation The translation.
|
||||
* @param int $book The book number.
|
||||
*
|
||||
* @return object|null The response object or null if an error occurs.
|
||||
* @since 2.0.1
|
||||
*/
|
||||
public function checksum(string $translation, int $book): ?object
|
||||
{
|
||||
return $this->response->get(
|
||||
$this->http->get(
|
||||
$this->uri->get($translation . '/' . $book . '/checksum.json')
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the chapter's checksums of a book in a translation
|
||||
*
|
||||
* @param string $translation The translation.
|
||||
* @param int $book The book number.
|
||||
* @param int $chapter The chapter number.
|
||||
*
|
||||
* @return string|null The response checksum or null if an error occurs.
|
||||
* @since 2.0.1
|
||||
*/
|
||||
public function sha(string $translation, int $book, int $chapter): ?string
|
||||
{
|
||||
return trim(
|
||||
$this->response->get(
|
||||
$this->http->get(
|
||||
$this->uri->get($translation . '/' . $book . '/' . $chapter . '.sha')
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
###POWERCODE###
|
||||
|
@ -1,74 +1 @@
|
||||
/**
|
||||
* Get the chapters in a book in a translation
|
||||
*
|
||||
* @param string $translation The translation.
|
||||
* @param int $book The book number.
|
||||
*
|
||||
* @return object|null The response object or null if an error occurs.
|
||||
* @since 2.0.1
|
||||
*/
|
||||
public function get(string $translation, int $book): ?object
|
||||
{
|
||||
return $this->response->get(
|
||||
$this->http->get(
|
||||
$this->uri->get($translation . '/' . $book . '.json')
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* List the chapters of a book in a translation
|
||||
*
|
||||
* @param string $translation The translation.
|
||||
* @param int $book The book number.
|
||||
*
|
||||
* @return object|null The response object or null if an error occurs.
|
||||
* @since 2.0.1
|
||||
*/
|
||||
public function list( string $translation, int $book): ?object
|
||||
{
|
||||
return $this->response->get(
|
||||
$this->http->get(
|
||||
$this->uri->get($translation . '/' . $book . '/chapters.json')
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* List the chapters checksums of a book in a translation
|
||||
*
|
||||
* @param string $translation The translation.
|
||||
* @param int $book The book number.
|
||||
*
|
||||
* @return object|null The response object or null if an error occurs.
|
||||
* @since 2.0.1
|
||||
*/
|
||||
public function checksum(string $translation, int $book): ?object
|
||||
{
|
||||
return $this->response->get(
|
||||
$this->http->get(
|
||||
$this->uri->get($translation . '/' . $book . '/checksum.json')
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the chapter's checksums of a book in a translation
|
||||
*
|
||||
* @param string $translation The translation.
|
||||
* @param int $book The book number.
|
||||
* @param int $chapter The chapter number.
|
||||
*
|
||||
* @return string|null The response checksum or null if an error occurs.
|
||||
* @since 2.0.1
|
||||
*/
|
||||
public function sha(string $translation, int $book, int $chapter): ?string
|
||||
{
|
||||
return trim(
|
||||
$this->response->get(
|
||||
$this->http->get(
|
||||
$this->uri->get($translation . '/' . $book . '/' . $chapter . '.sha')
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
###CODEPOWER###
|
@ -1,18 +1 @@
|
||||
{
|
||||
"add_head": "0",
|
||||
"add_licensing_template": "2",
|
||||
"extends": "7b490e63-8d1f-46de-a0c4-154272fd5d7f",
|
||||
"guid": "a752e4b2-9b5e-4188-8d33-3799c46d5119",
|
||||
"implements": null,
|
||||
"load_selection": null,
|
||||
"name": "Chapters",
|
||||
"power_version": "1.0.0",
|
||||
"system_name": "Joomla.GetBible.Api.Chapters",
|
||||
"type": "final class",
|
||||
"use_selection": null,
|
||||
"namespace": "VDM\\Joomla\\GetBible\\Api.Chapters",
|
||||
"description": "The GetBible Book Chapters\r\n\r\n@since 2.0.1",
|
||||
"licensing_template": "\/**\r\n * @package GetBible\r\n *\r\n * @created 30th May, 2023\r\n * @author Llewellyn van der Merwe <https:\/\/dev.vdm.io>\r\n * @git GetBible <https:\/\/git.vdm.dev\/getBible>\r\n * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.\r\n * @license GNU General Public License version 2 or later; see LICENSE.txt\r\n *\/\r\n",
|
||||
"head": "",
|
||||
"composer": ""
|
||||
}
|
||||
###POWERLINKER###
|
@ -1,69 +1 @@
|
||||
```
|
||||
██████╗ ██████╗ ██╗ ██╗███████╗██████╗
|
||||
██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗
|
||||
██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝
|
||||
██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗
|
||||
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
|
||||
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
|
||||
```
|
||||
# class Openai (Details)
|
||||
> namespace: **VDM\Joomla\GetBible\Service**
|
||||
```uml
|
||||
@startuml
|
||||
class Openai #Gold {
|
||||
+ register(Container $container) : void
|
||||
+ getChat(Container $container) : Chat
|
||||
+ getCompletions(Container $container) : Completions
|
||||
+ getModels(Container $container) : Models
|
||||
+ getModerate(Container $container) : Moderate
|
||||
}
|
||||
|
||||
note right of Openai::register
|
||||
Registers the service provider with a DI container.
|
||||
|
||||
since: 3.2.0
|
||||
return: void
|
||||
end note
|
||||
|
||||
note right of Openai::getChat
|
||||
Get the Chat class
|
||||
|
||||
since: 3.2.0
|
||||
return: Chat
|
||||
end note
|
||||
|
||||
note right of Openai::getCompletions
|
||||
Get the Completions class
|
||||
|
||||
since: 3.2.0
|
||||
return: Completions
|
||||
end note
|
||||
|
||||
note right of Openai::getModels
|
||||
Get the Models class
|
||||
|
||||
since: 3.2.0
|
||||
return: Models
|
||||
end note
|
||||
|
||||
note right of Openai::getModerate
|
||||
Get the Moderate class
|
||||
|
||||
since: 3.2.0
|
||||
return: Moderate
|
||||
end note
|
||||
|
||||
@enduml
|
||||
```
|
||||
|
||||
---
|
||||
```
|
||||
██╗ ██████╗██████╗
|
||||
██║██╔════╝██╔══██╗
|
||||
██║██║ ██████╔╝
|
||||
██ ██║██║ ██╔══██╗
|
||||
╚█████╔╝╚██████╗██████╔╝
|
||||
╚════╝ ╚═════╝╚═════╝
|
||||
```
|
||||
> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder)
|
||||
|
||||
###POWERREADME###
|
@ -9,114 +9,4 @@
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\GetBible\Service;
|
||||
|
||||
|
||||
use Joomla\DI\Container;
|
||||
use Joomla\DI\ServiceProviderInterface;
|
||||
use VDM\Joomla\Openai\Chat;
|
||||
use VDM\Joomla\Openai\Completions;
|
||||
use VDM\Joomla\Openai\Models;
|
||||
use VDM\Joomla\Openai\Moderate;
|
||||
|
||||
|
||||
/**
|
||||
* The Openai Api Service
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Openai implements ServiceProviderInterface
|
||||
{
|
||||
/**
|
||||
* Registers the service provider with a DI container.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return void
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function register(Container $container)
|
||||
{
|
||||
|
||||
$container->alias(Chat::class, 'Openai.Chat')
|
||||
->share('Openai.Chat', [$this, 'getChat'], true);
|
||||
|
||||
$container->alias(Completions::class, 'Openai.Completions')
|
||||
->share('Openai.Completions', [$this, 'getCompletions'], true);
|
||||
|
||||
$container->alias(Models::class, 'Openai.Models')
|
||||
->share('Openai.Models', [$this, 'getModels'], true);
|
||||
|
||||
$container->alias(Moderate::class, 'Openai.Moderate')
|
||||
->share('Openai.Moderate', [$this, 'getModerate'], true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Chat class
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Chat
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function getChat(Container $container): Chat
|
||||
{
|
||||
return new Chat(
|
||||
$container->get('Openai.Utilities.Http'),
|
||||
$container->get('Openai.Utilities.Uri'),
|
||||
$container->get('Openai.Utilities.Response')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Completions class
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Completions
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function getCompletions(Container $container): Completions
|
||||
{
|
||||
return new Completions(
|
||||
$container->get('Openai.Utilities.Http'),
|
||||
$container->get('Openai.Utilities.Uri'),
|
||||
$container->get('Openai.Utilities.Response')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Models class
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Models
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function getModels(Container $container): Models
|
||||
{
|
||||
return new Models(
|
||||
$container->get('Openai.Utilities.Http'),
|
||||
$container->get('Openai.Utilities.Uri'),
|
||||
$container->get('Openai.Utilities.Response')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Moderate class
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Moderate
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function getModerate(Container $container): Moderate
|
||||
{
|
||||
return new Moderate(
|
||||
$container->get('Openai.Utilities.Http'),
|
||||
$container->get('Openai.Utilities.Uri'),
|
||||
$container->get('Openai.Utilities.Response')
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
###POWERCODE###
|
||||
|
@ -1,91 +1 @@
|
||||
/**
|
||||
* Registers the service provider with a DI container.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return void
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function register(Container $container)
|
||||
{
|
||||
|
||||
$container->alias(Chat::class, 'Openai.Chat')
|
||||
->share('Openai.Chat', [$this, 'getChat'], true);
|
||||
|
||||
$container->alias(Completions::class, 'Openai.Completions')
|
||||
->share('Openai.Completions', [$this, 'getCompletions'], true);
|
||||
|
||||
$container->alias(Models::class, 'Openai.Models')
|
||||
->share('Openai.Models', [$this, 'getModels'], true);
|
||||
|
||||
$container->alias(Moderate::class, 'Openai.Moderate')
|
||||
->share('Openai.Moderate', [$this, 'getModerate'], true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Chat class
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Chat
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function getChat(Container $container): Chat
|
||||
{
|
||||
return new Chat(
|
||||
$container->get('Openai.Utilities.Http'),
|
||||
$container->get('Openai.Utilities.Uri'),
|
||||
$container->get('Openai.Utilities.Response')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Completions class
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Completions
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function getCompletions(Container $container): Completions
|
||||
{
|
||||
return new Completions(
|
||||
$container->get('Openai.Utilities.Http'),
|
||||
$container->get('Openai.Utilities.Uri'),
|
||||
$container->get('Openai.Utilities.Response')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Models class
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Models
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function getModels(Container $container): Models
|
||||
{
|
||||
return new Models(
|
||||
$container->get('Openai.Utilities.Http'),
|
||||
$container->get('Openai.Utilities.Uri'),
|
||||
$container->get('Openai.Utilities.Response')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Moderate class
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Moderate
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function getModerate(Container $container): Moderate
|
||||
{
|
||||
return new Moderate(
|
||||
$container->get('Openai.Utilities.Http'),
|
||||
$container->get('Openai.Utilities.Uri'),
|
||||
$container->get('Openai.Utilities.Response')
|
||||
);
|
||||
}
|
||||
###CODEPOWER###
|
@ -1,38 +1 @@
|
||||
{
|
||||
"add_head": "1",
|
||||
"add_licensing_template": "2",
|
||||
"extends": "0",
|
||||
"guid": "ac5c7679-dd6e-4817-8e48-489e521122f1",
|
||||
"implements": [
|
||||
"-1"
|
||||
],
|
||||
"load_selection": null,
|
||||
"name": "Openai",
|
||||
"power_version": "1.0.0",
|
||||
"system_name": "Joomla.GetBible.Service.Openai",
|
||||
"type": "class",
|
||||
"use_selection": {
|
||||
"use_selection0": {
|
||||
"use": "c54c92da-2dd7-4136-81c9-1785f2fa0af5",
|
||||
"as": "default"
|
||||
},
|
||||
"use_selection1": {
|
||||
"use": "796cca70-2577-4f8f-9a05-ac37db1f2f02",
|
||||
"as": "default"
|
||||
},
|
||||
"use_selection2": {
|
||||
"use": "08abd2df-1406-4939-a1a6-94d2fce3f043",
|
||||
"as": "default"
|
||||
},
|
||||
"use_selection3": {
|
||||
"use": "34f2c249-64a7-4229-9592-77e58f6e994f",
|
||||
"as": "default"
|
||||
}
|
||||
},
|
||||
"namespace": "VDM\\Joomla\\GetBible\\Service.Openai",
|
||||
"description": "The Openai Api Service\r\n\r\n@since 3.2.0",
|
||||
"implements_custom": "ServiceProviderInterface",
|
||||
"licensing_template": "\/**\r\n * @package GetBible\r\n *\r\n * @created 30th May, 2023\r\n * @author Llewellyn van der Merwe <https:\/\/dev.vdm.io>\r\n * @git GetBible <https:\/\/git.vdm.dev\/getBible>\r\n * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.\r\n * @license GNU General Public License version 2 or later; see LICENSE.txt\r\n *\/\r\n",
|
||||
"head": "use Joomla\\DI\\Container;\r\nuse Joomla\\DI\\ServiceProviderInterface;",
|
||||
"composer": ""
|
||||
}
|
||||
###POWERLINKER###
|
@ -1,42 +1 @@
|
||||
```
|
||||
██████╗ ██████╗ ██╗ ██╗███████╗██████╗
|
||||
██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗
|
||||
██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝
|
||||
██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗
|
||||
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
|
||||
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
|
||||
```
|
||||
# final class Verses (Details)
|
||||
> namespace: **VDM\Joomla\GetBible\Api**
|
||||
```uml
|
||||
@startuml
|
||||
class Verses << (F,LightGreen) >> #Green {
|
||||
+ get(string $translation, int $book, ...) : ?object
|
||||
}
|
||||
|
||||
note right of Verses::get
|
||||
Get the verses of chapter in a book in a translation
|
||||
|
||||
since: 2.0.1
|
||||
return: ?object
|
||||
|
||||
arguments:
|
||||
string $translation
|
||||
int $book
|
||||
int $chapter
|
||||
end note
|
||||
|
||||
@enduml
|
||||
```
|
||||
|
||||
---
|
||||
```
|
||||
██╗ ██████╗██████╗
|
||||
██║██╔════╝██╔══██╗
|
||||
██║██║ ██████╔╝
|
||||
██ ██║██║ ██╔══██╗
|
||||
╚█████╔╝╚██████╗██████╔╝
|
||||
╚════╝ ╚═════╝╚═════╝
|
||||
```
|
||||
> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder)
|
||||
|
||||
###POWERREADME###
|
@ -9,36 +9,4 @@
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\GetBible\Api;
|
||||
|
||||
|
||||
use VDM\Joomla\GetBible\Abstraction\Api;
|
||||
|
||||
|
||||
/**
|
||||
* The GetBible Book Chapter Verses
|
||||
*
|
||||
* @since 2.0.1
|
||||
*/
|
||||
final class Verses extends Api
|
||||
{
|
||||
/**
|
||||
* Get the verses of chapter in a book in a translation
|
||||
*
|
||||
* @param string $translation The translation.
|
||||
* @param int $book The book number.
|
||||
* @param int $chapter The chapter number.
|
||||
*
|
||||
* @return object|null The response object or null if an error occurs.
|
||||
* @since 2.0.1
|
||||
*/
|
||||
public function get(string $translation, int $book, int $chapter): ?object
|
||||
{
|
||||
return $this->response->get(
|
||||
$this->http->get(
|
||||
$this->uri->get($translation . '/' . $book . '/' . $chapter . '.json')
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
###POWERCODE###
|
||||
|
@ -1,18 +1 @@
|
||||
/**
|
||||
* Get the verses of chapter in a book in a translation
|
||||
*
|
||||
* @param string $translation The translation.
|
||||
* @param int $book The book number.
|
||||
* @param int $chapter The chapter number.
|
||||
*
|
||||
* @return object|null The response object or null if an error occurs.
|
||||
* @since 2.0.1
|
||||
*/
|
||||
public function get(string $translation, int $book, int $chapter): ?object
|
||||
{
|
||||
return $this->response->get(
|
||||
$this->http->get(
|
||||
$this->uri->get($translation . '/' . $book . '/' . $chapter . '.json')
|
||||
)
|
||||
);
|
||||
}
|
||||
###CODEPOWER###
|
@ -1,18 +1 @@
|
||||
{
|
||||
"add_head": "0",
|
||||
"add_licensing_template": "2",
|
||||
"extends": "7b490e63-8d1f-46de-a0c4-154272fd5d7f",
|
||||
"guid": "afa508bf-78f8-4616-97cc-f2809584c086",
|
||||
"implements": null,
|
||||
"load_selection": null,
|
||||
"name": "Verses",
|
||||
"power_version": "1.0.0",
|
||||
"system_name": "Joomla.GetBible.Api.Verses",
|
||||
"type": "final class",
|
||||
"use_selection": null,
|
||||
"namespace": "VDM\\Joomla\\GetBible\\Api.Verses",
|
||||
"description": "The GetBible Book Chapter Verses\r\n\r\n@since 2.0.1",
|
||||
"licensing_template": "\/**\r\n * @package GetBible\r\n *\r\n * @created 30th May, 2023\r\n * @author Llewellyn van der Merwe <https:\/\/dev.vdm.io>\r\n * @git GetBible <https:\/\/git.vdm.dev\/getBible>\r\n * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.\r\n * @license GNU General Public License version 2 or later; see LICENSE.txt\r\n *\/\r\n",
|
||||
"head": "",
|
||||
"composer": ""
|
||||
}
|
||||
###POWERLINKER###
|
@ -1,93 +1 @@
|
||||
```
|
||||
██████╗ ██████╗ ██╗ ██╗███████╗██████╗
|
||||
██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗
|
||||
██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝
|
||||
██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗
|
||||
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
|
||||
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
|
||||
```
|
||||
# final class Load (Details)
|
||||
> namespace: **VDM\Joomla\GetBible\Model**
|
||||
```uml
|
||||
@startuml
|
||||
class Load << (F,LightGreen) >> #Green {
|
||||
# Config $config
|
||||
+ __construct(Config $config, Table $table)
|
||||
+ value(mixed $value, string $field, ...) : mixed
|
||||
# validateBefore(mixed $value, ?string $field = null, ...) : bool
|
||||
# validateAfter(mixed $value, ?string $field = null, ...) : bool
|
||||
# getTable() : string
|
||||
+ modelDistributionHistory(mixed $value) : mixed
|
||||
}
|
||||
|
||||
note right of Load::__construct
|
||||
Constructor
|
||||
|
||||
since: 2.0.1
|
||||
end note
|
||||
|
||||
note right of Load::value
|
||||
Model the value
|
||||
Example: $this->value(value, 'field_key', 'table_name');
|
||||
|
||||
since: 2.0.1
|
||||
return: mixed
|
||||
|
||||
arguments:
|
||||
mixed $value
|
||||
string $field
|
||||
?string $table = null
|
||||
end note
|
||||
|
||||
note right of Load::validateBefore
|
||||
Validate before the value is modelled
|
||||
|
||||
since: 2.0.1
|
||||
return: bool
|
||||
|
||||
arguments:
|
||||
mixed $value
|
||||
?string $field = null
|
||||
?string $table = null
|
||||
end note
|
||||
|
||||
note right of Load::validateAfter
|
||||
Validate after the value is modelled
|
||||
|
||||
since: 2.0.1
|
||||
return: bool
|
||||
|
||||
arguments:
|
||||
mixed $value
|
||||
?string $field = null
|
||||
?string $table = null
|
||||
end note
|
||||
|
||||
note right of Load::getTable
|
||||
Get the current active table
|
||||
|
||||
since: 2.0.1
|
||||
return: string
|
||||
end note
|
||||
|
||||
note right of Load::modelDistributionHistory
|
||||
Model Distribution History
|
||||
|
||||
since: 2.0.1
|
||||
return: mixed
|
||||
end note
|
||||
|
||||
@enduml
|
||||
```
|
||||
|
||||
---
|
||||
```
|
||||
██╗ ██████╗██████╗
|
||||
██║██╔════╝██╔══██╗
|
||||
██║██║ ██████╔╝
|
||||
██ ██║██║ ██╔══██╗
|
||||
╚█████╔╝╚██████╗██████╔╝
|
||||
╚════╝ ╚═════╝╚═════╝
|
||||
```
|
||||
> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder)
|
||||
|
||||
###POWERREADME###
|
@ -9,152 +9,4 @@
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\GetBible\Model;
|
||||
|
||||
|
||||
use VDM\Joomla\GetBible\Config;
|
||||
use VDM\Joomla\GetBible\Table;
|
||||
use VDM\Joomla\Utilities\StringHelper;
|
||||
use VDM\Joomla\Utilities\ArrayHelper;
|
||||
use VDM\Joomla\Utilities\ObjectHelper;
|
||||
use VDM\Joomla\Interfaces\ModelInterface;
|
||||
use VDM\Joomla\Abstraction\Model;
|
||||
|
||||
|
||||
/**
|
||||
* The GetBible Model to Load
|
||||
*
|
||||
* @since 2.0.1
|
||||
*/
|
||||
final class Load extends Model implements ModelInterface
|
||||
{
|
||||
/**
|
||||
* GetBible Config
|
||||
*
|
||||
* @var Config
|
||||
* @since 2.0.1
|
||||
*/
|
||||
protected Config $config;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param Config $config The getBible config object.
|
||||
* @param Table $table The getBible table object.
|
||||
*
|
||||
* @since 2.0.1
|
||||
*/
|
||||
public function __construct(Config $config, Table $table)
|
||||
{
|
||||
parent::__construct($table);
|
||||
|
||||
$this->config = $config;
|
||||
}
|
||||
|
||||
/**
|
||||
* Model the value
|
||||
* Example: $this->value(value, 'field_key', 'table_name');
|
||||
*
|
||||
* @param mixed $value The value to model
|
||||
* @param string $field The field key
|
||||
* @param string|null $table The table
|
||||
*
|
||||
* @return mixed
|
||||
* @since 2.0.1
|
||||
*/
|
||||
public function value($value, string $field, ?string $table = null)
|
||||
{
|
||||
// set the table name
|
||||
if (empty($table))
|
||||
{
|
||||
$table = $this->getTable();
|
||||
}
|
||||
|
||||
// check if this is a valid table
|
||||
if (($store = $this->table->get($table, $field, 'store')) !== null)
|
||||
{
|
||||
// open the value based on the store method
|
||||
switch($store)
|
||||
{
|
||||
case 'json':
|
||||
$value = json_decode($value);
|
||||
break;
|
||||
}
|
||||
|
||||
// Model Distribution History
|
||||
if ($table === 'translation' && $field === 'distribution_history')
|
||||
{
|
||||
$value = $this->modelDistributionHistory($value);
|
||||
}
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate before the value is modelled
|
||||
*
|
||||
* @param mixed $value The field value
|
||||
* @param string|null $field The field key
|
||||
* @param string|null $table The table
|
||||
*
|
||||
* @return bool
|
||||
* @since 2.0.1
|
||||
*/
|
||||
protected function validateBefore(&$value, ?string $field = null, ?string $table = null): bool
|
||||
{
|
||||
// only strings or numbers allowed
|
||||
if (StringHelper::check($value) || is_numeric($value))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
// remove empty values
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate after the value is modelled
|
||||
*
|
||||
* @param mixed $value The field value
|
||||
* @param string|null $field The field key
|
||||
* @param string|null $table The table
|
||||
*
|
||||
* @return bool
|
||||
* @since 2.0.1
|
||||
*/
|
||||
protected function validateAfter(&$value, ?string $field = null, ?string $table = null): bool
|
||||
{
|
||||
// check values
|
||||
if (StringHelper::check($value) || ArrayHelper::check($value, true) || ObjectHelper::check($value) || is_numeric($value))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
// remove empty values
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current active table
|
||||
*
|
||||
* @return string
|
||||
* @since 2.0.1
|
||||
*/
|
||||
protected function getTable(): string
|
||||
{
|
||||
return $this->config->table_name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Model Distribution History
|
||||
*
|
||||
* @param mixed $value The value to model
|
||||
*
|
||||
* @return mixed
|
||||
* @since 2.0.1
|
||||
*/
|
||||
public function modelDistributionHistory($value)
|
||||
{
|
||||
return $value;
|
||||
}
|
||||
}
|
||||
|
||||
###POWERCODE###
|
||||
|
@ -1,128 +1 @@
|
||||
/**
|
||||
* GetBible Config
|
||||
*
|
||||
* @var Config
|
||||
* @since 2.0.1
|
||||
*/
|
||||
protected Config $config;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param Config $config The getBible config object.
|
||||
* @param Table $table The getBible table object.
|
||||
*
|
||||
* @since 2.0.1
|
||||
*/
|
||||
public function __construct(Config $config, Table $table)
|
||||
{
|
||||
parent::__construct($table);
|
||||
|
||||
$this->config = $config;
|
||||
}
|
||||
|
||||
/**
|
||||
* Model the value
|
||||
* Example: $this->value(value, 'field_key', 'table_name');
|
||||
*
|
||||
* @param mixed $value The value to model
|
||||
* @param string $field The field key
|
||||
* @param string|null $table The table
|
||||
*
|
||||
* @return mixed
|
||||
* @since 2.0.1
|
||||
*/
|
||||
public function value($value, string $field, ?string $table = null)
|
||||
{
|
||||
// set the table name
|
||||
if (empty($table))
|
||||
{
|
||||
$table = $this->getTable();
|
||||
}
|
||||
|
||||
// check if this is a valid table
|
||||
if (($store = $this->table->get($table, $field, 'store')) !== null)
|
||||
{
|
||||
// open the value based on the store method
|
||||
switch($store)
|
||||
{
|
||||
case 'json':
|
||||
$value = json_decode($value);
|
||||
break;
|
||||
}
|
||||
|
||||
// Model Distribution History
|
||||
if ($table === 'translation' && $field === 'distribution_history')
|
||||
{
|
||||
$value = $this->modelDistributionHistory($value);
|
||||
}
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate before the value is modelled
|
||||
*
|
||||
* @param mixed $value The field value
|
||||
* @param string|null $field The field key
|
||||
* @param string|null $table The table
|
||||
*
|
||||
* @return bool
|
||||
* @since 2.0.1
|
||||
*/
|
||||
protected function validateBefore(&$value, ?string $field = null, ?string $table = null): bool
|
||||
{
|
||||
// only strings or numbers allowed
|
||||
if (StringHelper::check($value) || is_numeric($value))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
// remove empty values
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate after the value is modelled
|
||||
*
|
||||
* @param mixed $value The field value
|
||||
* @param string|null $field The field key
|
||||
* @param string|null $table The table
|
||||
*
|
||||
* @return bool
|
||||
* @since 2.0.1
|
||||
*/
|
||||
protected function validateAfter(&$value, ?string $field = null, ?string $table = null): bool
|
||||
{
|
||||
// check values
|
||||
if (StringHelper::check($value) || ArrayHelper::check($value, true) || ObjectHelper::check($value) || is_numeric($value))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
// remove empty values
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current active table
|
||||
*
|
||||
* @return string
|
||||
* @since 2.0.1
|
||||
*/
|
||||
protected function getTable(): string
|
||||
{
|
||||
return $this->config->table_name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Model Distribution History
|
||||
*
|
||||
* @param mixed $value The value to model
|
||||
*
|
||||
* @return mixed
|
||||
* @since 2.0.1
|
||||
*/
|
||||
public function modelDistributionHistory($value)
|
||||
{
|
||||
return $value;
|
||||
}
|
||||
###CODEPOWER###
|
@ -1,41 +1 @@
|
||||
{
|
||||
"add_head": "0",
|
||||
"add_licensing_template": "2",
|
||||
"extends": "584747d1-3a86-453d-b7a3-a2219de8d777",
|
||||
"guid": "b1bd2b4f-dede-44ad-86e9-2a595a0a9ca0",
|
||||
"implements": [
|
||||
"8aef58c1-3f70-4bd4-b9e4-3f29fcd41cff"
|
||||
],
|
||||
"load_selection": null,
|
||||
"name": "Load",
|
||||
"power_version": "1.0.0",
|
||||
"system_name": "Joomla.GetBible.Model.Load",
|
||||
"type": "final class",
|
||||
"use_selection": {
|
||||
"use_selection0": {
|
||||
"use": "71075f03-4e77-4fc0-840a-ef55fd9260b2",
|
||||
"as": "default"
|
||||
},
|
||||
"use_selection1": {
|
||||
"use": "ff8d5fdb-2d1f-4178-bd18-a43b8efd1068",
|
||||
"as": "default"
|
||||
},
|
||||
"use_selection2": {
|
||||
"use": "1f28cb53-60d9-4db1-b517-3c7dc6b429ef",
|
||||
"as": "default"
|
||||
},
|
||||
"use_selection3": {
|
||||
"use": "0a59c65c-9daf-4bc9-baf4-e063ff9e6a8a",
|
||||
"as": "default"
|
||||
},
|
||||
"use_selection4": {
|
||||
"use": "91004529-94a9-4590-b842-e7c6b624ecf5",
|
||||
"as": "default"
|
||||
}
|
||||
},
|
||||
"namespace": "VDM\\Joomla\\GetBible\\Model.Load",
|
||||
"description": "The GetBible Model to Load\r\n\r\n@since 2.0.1",
|
||||
"licensing_template": "\/**\r\n * @package GetBible\r\n *\r\n * @created 30th May, 2023\r\n * @author Llewellyn van der Merwe <https:\/\/dev.vdm.io>\r\n * @git GetBible <https:\/\/git.vdm.dev\/getBible>\r\n * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.\r\n * @license GNU General Public License version 2 or later; see LICENSE.txt\r\n *\/\r\n",
|
||||
"head": "",
|
||||
"composer": ""
|
||||
}
|
||||
###POWERLINKER###
|
@ -1,69 +1 @@
|
||||
```
|
||||
██████╗ ██████╗ ██╗ ██╗███████╗██████╗
|
||||
██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗
|
||||
██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝
|
||||
██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗
|
||||
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
|
||||
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
|
||||
```
|
||||
# class Api (Details)
|
||||
> namespace: **VDM\Joomla\GetBible\Service**
|
||||
```uml
|
||||
@startuml
|
||||
class Api #Gold {
|
||||
+ register(Container $container) : void
|
||||
+ getTranslations(Container $container) : Translations
|
||||
+ getBooks(Container $container) : Books
|
||||
+ getChapters(Container $container) : Chapters
|
||||
+ getVerses(Container $container) : Verses
|
||||
}
|
||||
|
||||
note right of Api::register
|
||||
Registers the service provider with a DI container.
|
||||
|
||||
since: 2.0.1
|
||||
return: void
|
||||
end note
|
||||
|
||||
note right of Api::getTranslations
|
||||
Get the Translations class
|
||||
|
||||
since: 3.2.0
|
||||
return: Translations
|
||||
end note
|
||||
|
||||
note right of Api::getBooks
|
||||
Get the Books class
|
||||
|
||||
since: 3.2.0
|
||||
return: Books
|
||||
end note
|
||||
|
||||
note right of Api::getChapters
|
||||
Get the Chapters class
|
||||
|
||||
since: 3.2.0
|
||||
return: Chapters
|
||||
end note
|
||||
|
||||
note right of Api::getVerses
|
||||
Get the Verses class
|
||||
|
||||
since: 3.2.0
|
||||
return: Verses
|
||||
end note
|
||||
|
||||
@enduml
|
||||
```
|
||||
|
||||
---
|
||||
```
|
||||
██╗ ██████╗██████╗
|
||||
██║██╔════╝██╔══██╗
|
||||
██║██║ ██████╔╝
|
||||
██ ██║██║ ██╔══██╗
|
||||
╚█████╔╝╚██████╗██████╔╝
|
||||
╚════╝ ╚═════╝╚═════╝
|
||||
```
|
||||
> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder)
|
||||
|
||||
###POWERREADME###
|
@ -9,113 +9,4 @@
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\GetBible\Service;
|
||||
|
||||
|
||||
use Joomla\DI\Container;
|
||||
use Joomla\DI\ServiceProviderInterface;
|
||||
use VDM\Joomla\GetBible\Api\Translations;
|
||||
use VDM\Joomla\GetBible\Api\Books;
|
||||
use VDM\Joomla\GetBible\Api\Chapters;
|
||||
use VDM\Joomla\GetBible\Api\Verses;
|
||||
|
||||
|
||||
/**
|
||||
* The GetBible Api Service
|
||||
*
|
||||
* @since 2.0.1
|
||||
*/
|
||||
class Api implements ServiceProviderInterface
|
||||
{
|
||||
/**
|
||||
* Registers the service provider with a DI container.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return void
|
||||
* @since 2.0.1
|
||||
*/
|
||||
public function register(Container $container)
|
||||
{
|
||||
$container->alias(Translations::class, 'GetBible.Api.Translations')
|
||||
->share('GetBible.Api.Translations', [$this, 'getTranslations'], true);
|
||||
|
||||
$container->alias(Books::class, 'GetBible.Api.Books')
|
||||
->share('GetBible.Api.Books', [$this, 'getBooks'], true);
|
||||
|
||||
$container->alias(Chapters::class, 'GetBible.Api.Chapters')
|
||||
->share('GetBible.Api.Chapters', [$this, 'getChapters'], true);
|
||||
|
||||
$container->alias(Verses::class, 'GetBible.Api.Verses')
|
||||
->share('GetBible.Api.Verses', [$this, 'getVerses'], true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Translations class
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Translations
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function getTranslations(Container $container): Translations
|
||||
{
|
||||
return new Translations(
|
||||
$container->get('GetBible.Utilities.Http'),
|
||||
$container->get('GetBible.Utilities.Uri'),
|
||||
$container->get('GetBible.Utilities.Response')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Books class
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Books
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function getBooks(Container $container): Books
|
||||
{
|
||||
return new Books(
|
||||
$container->get('GetBible.Utilities.Http'),
|
||||
$container->get('GetBible.Utilities.Uri'),
|
||||
$container->get('GetBible.Utilities.Response')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Chapters class
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Chapters
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function getChapters(Container $container): Chapters
|
||||
{
|
||||
return new Chapters(
|
||||
$container->get('GetBible.Utilities.Http'),
|
||||
$container->get('GetBible.Utilities.Uri'),
|
||||
$container->get('GetBible.Utilities.Response')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Verses class
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Verses
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function getVerses(Container $container): Verses
|
||||
{
|
||||
return new Verses(
|
||||
$container->get('GetBible.Utilities.Http'),
|
||||
$container->get('GetBible.Utilities.Uri'),
|
||||
$container->get('GetBible.Utilities.Response')
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
###POWERCODE###
|
||||
|
@ -1,90 +1 @@
|
||||
/**
|
||||
* Registers the service provider with a DI container.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return void
|
||||
* @since 2.0.1
|
||||
*/
|
||||
public function register(Container $container)
|
||||
{
|
||||
$container->alias(Translations::class, 'GetBible.Api.Translations')
|
||||
->share('GetBible.Api.Translations', [$this, 'getTranslations'], true);
|
||||
|
||||
$container->alias(Books::class, 'GetBible.Api.Books')
|
||||
->share('GetBible.Api.Books', [$this, 'getBooks'], true);
|
||||
|
||||
$container->alias(Chapters::class, 'GetBible.Api.Chapters')
|
||||
->share('GetBible.Api.Chapters', [$this, 'getChapters'], true);
|
||||
|
||||
$container->alias(Verses::class, 'GetBible.Api.Verses')
|
||||
->share('GetBible.Api.Verses', [$this, 'getVerses'], true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Translations class
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Translations
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function getTranslations(Container $container): Translations
|
||||
{
|
||||
return new Translations(
|
||||
$container->get('GetBible.Utilities.Http'),
|
||||
$container->get('GetBible.Utilities.Uri'),
|
||||
$container->get('GetBible.Utilities.Response')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Books class
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Books
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function getBooks(Container $container): Books
|
||||
{
|
||||
return new Books(
|
||||
$container->get('GetBible.Utilities.Http'),
|
||||
$container->get('GetBible.Utilities.Uri'),
|
||||
$container->get('GetBible.Utilities.Response')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Chapters class
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Chapters
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function getChapters(Container $container): Chapters
|
||||
{
|
||||
return new Chapters(
|
||||
$container->get('GetBible.Utilities.Http'),
|
||||
$container->get('GetBible.Utilities.Uri'),
|
||||
$container->get('GetBible.Utilities.Response')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Verses class
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Verses
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function getVerses(Container $container): Verses
|
||||
{
|
||||
return new Verses(
|
||||
$container->get('GetBible.Utilities.Http'),
|
||||
$container->get('GetBible.Utilities.Uri'),
|
||||
$container->get('GetBible.Utilities.Response')
|
||||
);
|
||||
}
|
||||
###CODEPOWER###
|
@ -1,38 +1 @@
|
||||
{
|
||||
"add_head": "1",
|
||||
"add_licensing_template": "2",
|
||||
"extends": "0",
|
||||
"guid": "b32eea04-6b9c-469d-94db-35d610686cf1",
|
||||
"implements": [
|
||||
"-1"
|
||||
],
|
||||
"load_selection": null,
|
||||
"name": "Api",
|
||||
"power_version": "1.0.0",
|
||||
"system_name": "Joomla.GetBible.Service.Api",
|
||||
"type": "class",
|
||||
"use_selection": {
|
||||
"use_selection0": {
|
||||
"use": "be0cae8b-4b78-4f59-b97b-9e31ee6f52e0",
|
||||
"as": "default"
|
||||
},
|
||||
"use_selection1": {
|
||||
"use": "491c91ce-6355-40d3-bbbd-622473c6c026",
|
||||
"as": "default"
|
||||
},
|
||||
"use_selection2": {
|
||||
"use": "a752e4b2-9b5e-4188-8d33-3799c46d5119",
|
||||
"as": "default"
|
||||
},
|
||||
"use_selection3": {
|
||||
"use": "afa508bf-78f8-4616-97cc-f2809584c086",
|
||||
"as": "default"
|
||||
}
|
||||
},
|
||||
"namespace": "VDM\\Joomla\\GetBible\\Service.Api",
|
||||
"description": "The GetBible Api Service\r\n\r\n@since 2.0.1",
|
||||
"implements_custom": "ServiceProviderInterface",
|
||||
"licensing_template": "\/**\r\n * @package GetBible\r\n *\r\n * @created 30th May, 2023\r\n * @author Llewellyn van der Merwe <https:\/\/dev.vdm.io>\r\n * @git GetBible <https:\/\/git.vdm.dev\/getBible>\r\n * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.\r\n * @license GNU General Public License version 2 or later; see LICENSE.txt\r\n *\/\r\n",
|
||||
"head": "use Joomla\\DI\\Container;\r\nuse Joomla\\DI\\ServiceProviderInterface;",
|
||||
"composer": ""
|
||||
}
|
||||
###POWERLINKER###
|
@ -1,61 +1 @@
|
||||
```
|
||||
██████╗ ██████╗ ██╗ ██╗███████╗██████╗
|
||||
██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗
|
||||
██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝
|
||||
██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗
|
||||
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
|
||||
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
|
||||
```
|
||||
# class Utilities (Details)
|
||||
> namespace: **VDM\Joomla\GetBible\Service**
|
||||
```uml
|
||||
@startuml
|
||||
class Utilities #Gold {
|
||||
+ register(Container $container) : void
|
||||
+ getUri(Container $container) : Uri
|
||||
+ getResponse(Container $container) : Response
|
||||
+ getHttp(Container $container) : Http
|
||||
}
|
||||
|
||||
note right of Utilities::register
|
||||
Registers the service provider with a DI container.
|
||||
|
||||
since: 3.2.0
|
||||
return: void
|
||||
end note
|
||||
|
||||
note right of Utilities::getUri
|
||||
Get the Uri class
|
||||
|
||||
since: 3.2.0
|
||||
return: Uri
|
||||
end note
|
||||
|
||||
note right of Utilities::getResponse
|
||||
Get the Response class
|
||||
|
||||
since: 3.2.0
|
||||
return: Response
|
||||
end note
|
||||
|
||||
note right of Utilities::getHttp
|
||||
Get the Http class
|
||||
|
||||
since: 3.2.0
|
||||
return: Http
|
||||
end note
|
||||
|
||||
@enduml
|
||||
```
|
||||
|
||||
---
|
||||
```
|
||||
██╗ ██████╗██████╗
|
||||
██║██╔════╝██╔══██╗
|
||||
██║██║ ██████╔╝
|
||||
██ ██║██║ ██╔══██╗
|
||||
╚█████╔╝╚██████╗██████╔╝
|
||||
╚════╝ ╚═════╝╚═════╝
|
||||
```
|
||||
> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder)
|
||||
|
||||
###POWERREADME###
|
@ -9,82 +9,4 @@
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\GetBible\Service;
|
||||
|
||||
|
||||
use Joomla\DI\Container;
|
||||
use Joomla\DI\ServiceProviderInterface;
|
||||
use VDM\Joomla\GetBible\Utilities\Uri;
|
||||
use VDM\Joomla\GetBible\Utilities\Response;
|
||||
use VDM\Joomla\GetBible\Utilities\Http;
|
||||
|
||||
|
||||
/**
|
||||
* The GetBible Utilities Service
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Utilities implements ServiceProviderInterface
|
||||
{
|
||||
/**
|
||||
* Registers the service provider with a DI container.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return void
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function register(Container $container)
|
||||
{
|
||||
$container->alias(Uri::class, 'GetBible.Utilities.Uri')
|
||||
->share('GetBible.Utilities.Uri', [$this, 'getUri'], true);
|
||||
|
||||
$container->alias(Response::class, 'GetBible.Utilities.Response')
|
||||
->share('GetBible.Utilities.Response', [$this, 'getResponse'], true);
|
||||
|
||||
$container->alias(Http::class, 'GetBible.Utilities.Http')
|
||||
->share('GetBible.Utilities.Http', [$this, 'getHttp'], true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Uri class
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Uri
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function getUri(Container $container): Uri
|
||||
{
|
||||
return new Uri(
|
||||
$container->get('GetBible.Config')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Response class
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Response
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function getResponse(Container $container): Response
|
||||
{
|
||||
return new Response();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Http class
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Http
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function getHttp(Container $container): Http
|
||||
{
|
||||
return new Http();
|
||||
}
|
||||
}
|
||||
|
||||
###POWERCODE###
|
||||
|
@ -1,60 +1 @@
|
||||
/**
|
||||
* Registers the service provider with a DI container.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return void
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function register(Container $container)
|
||||
{
|
||||
$container->alias(Uri::class, 'GetBible.Utilities.Uri')
|
||||
->share('GetBible.Utilities.Uri', [$this, 'getUri'], true);
|
||||
|
||||
$container->alias(Response::class, 'GetBible.Utilities.Response')
|
||||
->share('GetBible.Utilities.Response', [$this, 'getResponse'], true);
|
||||
|
||||
$container->alias(Http::class, 'GetBible.Utilities.Http')
|
||||
->share('GetBible.Utilities.Http', [$this, 'getHttp'], true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Uri class
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Uri
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function getUri(Container $container): Uri
|
||||
{
|
||||
return new Uri(
|
||||
$container->get('GetBible.Config')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Response class
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Response
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function getResponse(Container $container): Response
|
||||
{
|
||||
return new Response();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Http class
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Http
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function getHttp(Container $container): Http
|
||||
{
|
||||
return new Http();
|
||||
}
|
||||
###CODEPOWER###
|
@ -1,34 +1 @@
|
||||
{
|
||||
"add_head": "1",
|
||||
"add_licensing_template": "2",
|
||||
"extends": "0",
|
||||
"guid": "b89d74ef-c71c-4a58-8455-5dbdfe94027a",
|
||||
"implements": [
|
||||
"-1"
|
||||
],
|
||||
"load_selection": null,
|
||||
"name": "Utilities",
|
||||
"power_version": "1.0.0",
|
||||
"system_name": "Joomla.GetBible.Service.Utilities",
|
||||
"type": "class",
|
||||
"use_selection": {
|
||||
"use_selection0": {
|
||||
"use": "fc9ab6f0-c31b-4077-bb1c-2dcddd36f6bb",
|
||||
"as": "default"
|
||||
},
|
||||
"use_selection1": {
|
||||
"use": "c99e85a0-d120-4f25-bcbf-0940dd7b773b",
|
||||
"as": "default"
|
||||
},
|
||||
"use_selection2": {
|
||||
"use": "b8c66089-735e-4081-825c-8fe36b28e4a6",
|
||||
"as": "default"
|
||||
}
|
||||
},
|
||||
"namespace": "VDM\\Joomla\\GetBible\\Service.Utilities",
|
||||
"description": "The GetBible Utilities Service\r\n\r\n@since 3.2.0",
|
||||
"implements_custom": "ServiceProviderInterface",
|
||||
"licensing_template": "\/**\r\n * @package GetBible\r\n *\r\n * @created 30th May, 2023\r\n * @author Llewellyn van der Merwe <https:\/\/dev.vdm.io>\r\n * @git GetBible <https:\/\/git.vdm.dev\/getBible>\r\n * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.\r\n * @license GNU General Public License version 2 or later; see LICENSE.txt\r\n *\/\r\n",
|
||||
"head": "use Joomla\\DI\\Container;\r\nuse Joomla\\DI\\ServiceProviderInterface;",
|
||||
"composer": ""
|
||||
}
|
||||
###POWERLINKER###
|
@ -1,36 +1 @@
|
||||
```
|
||||
██████╗ ██████╗ ██╗ ██╗███████╗██████╗
|
||||
██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗
|
||||
██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝
|
||||
██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗
|
||||
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
|
||||
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
|
||||
```
|
||||
# final class Http (Details)
|
||||
> namespace: **VDM\Joomla\GetBible\Utilities**
|
||||
```uml
|
||||
@startuml
|
||||
class Http << (F,LightGreen) >> #Green {
|
||||
+ __construct()
|
||||
}
|
||||
|
||||
note right of Http::__construct
|
||||
Constructor.
|
||||
|
||||
since: 2.0.1
|
||||
end note
|
||||
|
||||
@enduml
|
||||
```
|
||||
|
||||
---
|
||||
```
|
||||
██╗ ██████╗██████╗
|
||||
██║██╔════╝██╔══██╗
|
||||
██║██║ ██████╔╝
|
||||
██ ██║██║ ██╔══██╗
|
||||
╚█████╔╝╚██████╗██████╔╝
|
||||
╚════╝ ╚═════╝╚═════╝
|
||||
```
|
||||
> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder)
|
||||
|
||||
###POWERREADME###
|
@ -9,40 +9,4 @@
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\GetBible\Utilities;
|
||||
|
||||
|
||||
use Joomla\CMS\Http\Http as JoomlaHttp;
|
||||
use Joomla\Registry\Registry;
|
||||
|
||||
|
||||
/**
|
||||
* The GetBible Http
|
||||
*
|
||||
* @since 2.0.1
|
||||
*/
|
||||
final class Http extends JoomlaHttp
|
||||
{
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @since 2.0.1
|
||||
* @throws \InvalidArgumentException
|
||||
**/
|
||||
public function __construct()
|
||||
{
|
||||
// setup config
|
||||
$config = [
|
||||
'userAgent' => 'JoomlaGetBible/2.0',
|
||||
'headers' => [
|
||||
'Content-Type' => 'application/json'
|
||||
]
|
||||
];
|
||||
|
||||
$options = new Registry($config);
|
||||
|
||||
// run parent constructor
|
||||
parent::__construct($options);
|
||||
}
|
||||
}
|
||||
|
||||
###POWERCODE###
|
||||
|
@ -1,21 +1 @@
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @since 2.0.1
|
||||
* @throws \InvalidArgumentException
|
||||
**/
|
||||
public function __construct()
|
||||
{
|
||||
// setup config
|
||||
$config = [
|
||||
'userAgent' => 'JoomlaGetBible/2.0',
|
||||
'headers' => [
|
||||
'Content-Type' => 'application/json'
|
||||
]
|
||||
];
|
||||
|
||||
$options = new Registry($config);
|
||||
|
||||
// run parent constructor
|
||||
parent::__construct($options);
|
||||
}
|
||||
###CODEPOWER###
|
@ -1,19 +1 @@
|
||||
{
|
||||
"add_head": "1",
|
||||
"add_licensing_template": "2",
|
||||
"extends": "-1",
|
||||
"guid": "b8c66089-735e-4081-825c-8fe36b28e4a6",
|
||||
"implements": null,
|
||||
"load_selection": null,
|
||||
"name": "Http",
|
||||
"power_version": "1.0.0",
|
||||
"system_name": "Joomla.GetBible.Utilities.Http",
|
||||
"type": "final class",
|
||||
"use_selection": null,
|
||||
"namespace": "VDM\\Joomla\\GetBible\\Utilities.Http",
|
||||
"description": "The GetBible Http\r\n\r\n@since 2.0.1",
|
||||
"extends_custom": "JoomlaHttp",
|
||||
"licensing_template": "\/**\r\n * @package GetBible\r\n *\r\n * @created 30th May, 2023\r\n * @author Llewellyn van der Merwe <https:\/\/dev.vdm.io>\r\n * @git GetBible <https:\/\/git.vdm.dev\/getBible>\r\n * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.\r\n * @license GNU General Public License version 2 or later; see LICENSE.txt\r\n *\/\r\n",
|
||||
"head": "use Joomla\\CMS\\Http\\Http as JoomlaHttp;\r\nuse Joomla\\Registry\\Registry;",
|
||||
"composer": ""
|
||||
}
|
||||
###POWERLINKER###
|
@ -1,53 +1 @@
|
||||
```
|
||||
██████╗ ██████╗ ██╗ ██╗███████╗██████╗
|
||||
██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗
|
||||
██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝
|
||||
██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗
|
||||
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
|
||||
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
|
||||
```
|
||||
# final class Translations (Details)
|
||||
> namespace: **VDM\Joomla\GetBible\Api**
|
||||
```uml
|
||||
@startuml
|
||||
class Translations << (F,LightGreen) >> #Green {
|
||||
+ list() : ?object
|
||||
+ checksum() : ?object
|
||||
+ sha(string $translation = 'kjv') : ?string
|
||||
}
|
||||
|
||||
note right of Translations::list
|
||||
List the translations
|
||||
|
||||
since: 2.0.1
|
||||
return: ?object
|
||||
end note
|
||||
|
||||
note right of Translations::checksum
|
||||
List the translations checksums
|
||||
|
||||
since: 2.0.1
|
||||
return: ?object
|
||||
end note
|
||||
|
||||
note right of Translations::sha
|
||||
Get the translation's checksums
|
||||
|
||||
since: 2.0.1
|
||||
return: ?string
|
||||
end note
|
||||
|
||||
@enduml
|
||||
```
|
||||
|
||||
---
|
||||
```
|
||||
██╗ ██████╗██████╗
|
||||
██║██╔════╝██╔══██╗
|
||||
██║██║ ██████╔╝
|
||||
██ ██║██║ ██╔══██╗
|
||||
╚█████╔╝╚██████╗██████╔╝
|
||||
╚════╝ ╚═════╝╚═════╝
|
||||
```
|
||||
> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder)
|
||||
|
||||
###POWERREADME###
|
@ -9,66 +9,4 @@
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\GetBible\Api;
|
||||
|
||||
|
||||
use VDM\Joomla\GetBible\Abstraction\Api;
|
||||
|
||||
|
||||
/**
|
||||
* The GetBible Translations
|
||||
*
|
||||
* @since 2.0.1
|
||||
*/
|
||||
final class Translations extends Api
|
||||
{
|
||||
/**
|
||||
* List the translations
|
||||
*
|
||||
* @return object|null The response object or null if an error occurs.
|
||||
* @since 2.0.1
|
||||
*/
|
||||
public function list(): ?object
|
||||
{
|
||||
return $this->response->get(
|
||||
$this->http->get(
|
||||
$this->uri->get('translations.json')
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* List the translations checksums
|
||||
*
|
||||
* @return object|null The response object or null if an error occurs.
|
||||
* @since 2.0.1
|
||||
*/
|
||||
public function checksum(): ?object
|
||||
{
|
||||
return $this->response->get(
|
||||
$this->http->get(
|
||||
$this->uri->get('checksum.json')
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the translation's checksums
|
||||
*
|
||||
* @param string $translation The translation.
|
||||
*
|
||||
* @return string|null The response checksum or null if an error occurs.
|
||||
* @since 2.0.1
|
||||
*/
|
||||
public function sha(string $translation = 'kjv'): ?string
|
||||
{
|
||||
return trim(
|
||||
$this->response->get(
|
||||
$this->http->get(
|
||||
$this->uri->get($translation . '.sha')
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
###POWERCODE###
|
||||
|
@ -1,48 +1 @@
|
||||
/**
|
||||
* List the translations
|
||||
*
|
||||
* @return object|null The response object or null if an error occurs.
|
||||
* @since 2.0.1
|
||||
*/
|
||||
public function list(): ?object
|
||||
{
|
||||
return $this->response->get(
|
||||
$this->http->get(
|
||||
$this->uri->get('translations.json')
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* List the translations checksums
|
||||
*
|
||||
* @return object|null The response object or null if an error occurs.
|
||||
* @since 2.0.1
|
||||
*/
|
||||
public function checksum(): ?object
|
||||
{
|
||||
return $this->response->get(
|
||||
$this->http->get(
|
||||
$this->uri->get('checksum.json')
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the translation's checksums
|
||||
*
|
||||
* @param string $translation The translation.
|
||||
*
|
||||
* @return string|null The response checksum or null if an error occurs.
|
||||
* @since 2.0.1
|
||||
*/
|
||||
public function sha(string $translation = 'kjv'): ?string
|
||||
{
|
||||
return trim(
|
||||
$this->response->get(
|
||||
$this->http->get(
|
||||
$this->uri->get($translation . '.sha')
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
###CODEPOWER###
|
@ -1,18 +1 @@
|
||||
{
|
||||
"add_head": "0",
|
||||
"add_licensing_template": "2",
|
||||
"extends": "7b490e63-8d1f-46de-a0c4-154272fd5d7f",
|
||||
"guid": "be0cae8b-4b78-4f59-b97b-9e31ee6f52e0",
|
||||
"implements": null,
|
||||
"load_selection": null,
|
||||
"name": "Translations",
|
||||
"power_version": "1.0.0",
|
||||
"system_name": "Joomla.GetBible.Api.Translations",
|
||||
"type": "final class",
|
||||
"use_selection": null,
|
||||
"namespace": "VDM\\Joomla\\GetBible\\Api.Translations",
|
||||
"description": "The GetBible Translations\r\n\r\n@since 2.0.1",
|
||||
"licensing_template": "\/**\r\n * @package GetBible\r\n *\r\n * @created 30th May, 2023\r\n * @author Llewellyn van der Merwe <https:\/\/dev.vdm.io>\r\n * @git GetBible <https:\/\/git.vdm.dev\/getBible>\r\n * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.\r\n * @license GNU General Public License version 2 or later; see LICENSE.txt\r\n *\/\r\n",
|
||||
"head": "",
|
||||
"composer": ""
|
||||
}
|
||||
###POWERLINKER###
|
@ -1,133 +1 @@
|
||||
```
|
||||
██████╗ ██████╗ ██╗ ██╗███████╗██████╗
|
||||
██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗
|
||||
██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝
|
||||
██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗
|
||||
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
|
||||
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
|
||||
```
|
||||
# final class Load (Details)
|
||||
> namespace: **VDM\Joomla\GetBible\Database**
|
||||
```uml
|
||||
@startuml
|
||||
class Load << (F,LightGreen) >> #Green {
|
||||
# Table $table
|
||||
# Model $model
|
||||
# Database $load
|
||||
+ __construct(Table $table, Model $model, ...)
|
||||
+ value(array $keys, string $field, ...) : mixed
|
||||
+ max(array $keys, string $field, ...) : mixed
|
||||
+ item(array $keys, string $table) : ?object
|
||||
+ items(array $keys, string $table) : ?array
|
||||
- prefix(array $keys) : array
|
||||
}
|
||||
|
||||
note right of Load::__construct
|
||||
Constructor
|
||||
|
||||
since: 2.0.1
|
||||
|
||||
arguments:
|
||||
Table $table
|
||||
Model $model
|
||||
Database $load
|
||||
end note
|
||||
|
||||
note right of Load::value
|
||||
Get a value from a given table
|
||||
Example: $this->value(
|
||||
[
|
||||
'abbreviation' => 'kjv',
|
||||
'book_nr' => 62,
|
||||
'chapter' => 3,
|
||||
'verse' => 16
|
||||
], 'value_key', 'table_name'
|
||||
);
|
||||
|
||||
since: 2.0.1
|
||||
return: mixed
|
||||
|
||||
arguments:
|
||||
array $keys
|
||||
string $field
|
||||
string $table
|
||||
end note
|
||||
|
||||
note right of Load::max
|
||||
Get the max value from a given table
|
||||
Example: $this->value(
|
||||
[
|
||||
'abbreviation' => 'kjv',
|
||||
'book_nr' => 62,
|
||||
'chapter' => 3,
|
||||
'verse' => 16
|
||||
], 'value_key', 'table_name'
|
||||
);
|
||||
|
||||
since: 2.0.1
|
||||
return: mixed
|
||||
|
||||
arguments:
|
||||
array $keys
|
||||
string $field
|
||||
string $table
|
||||
end note
|
||||
|
||||
note right of Load::item
|
||||
Get values from a given table
|
||||
Example: $this->item(
|
||||
[
|
||||
'abbriviation' => 'kjv',
|
||||
'book_nr' => 62,
|
||||
'chapter' => 3,
|
||||
'verse' => 16
|
||||
], 'table_name'
|
||||
);
|
||||
|
||||
since: 2.0.1
|
||||
return: ?object
|
||||
end note
|
||||
|
||||
note right of Load::items
|
||||
Get values from a given table
|
||||
Example: $this->items(
|
||||
[
|
||||
'abbriviation' => [
|
||||
'operator' => 'IN',
|
||||
'value' => ['kjv', 'aov']
|
||||
],
|
||||
'book_nr' => 62,
|
||||
'chapter' => 3,
|
||||
'verse' => [
|
||||
'operator' => 'IN',
|
||||
'value' => [16, 17, 18]
|
||||
]
|
||||
], 'table_name'
|
||||
);
|
||||
Example: $this->items($ids, 'table_name');
|
||||
|
||||
since: 2.0.1
|
||||
return: ?array
|
||||
end note
|
||||
|
||||
note right of Load::prefix
|
||||
Add prefix to the keys
|
||||
|
||||
since: 2.0.1
|
||||
return: array
|
||||
end note
|
||||
|
||||
@enduml
|
||||
```
|
||||
|
||||
---
|
||||
```
|
||||
██╗ ██████╗██████╗
|
||||
██║██╔════╝██╔══██╗
|
||||
██║██║ ██████╔╝
|
||||
██ ██║██║ ██╔══██╗
|
||||
╚█████╔╝╚██████╗██████╔╝
|
||||
╚════╝ ╚═════╝╚═════╝
|
||||
```
|
||||
> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder)
|
||||
|
||||
###POWERREADME###
|
@ -9,227 +9,4 @@
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\GetBible\Database;
|
||||
|
||||
|
||||
use VDM\Joomla\GetBible\Table;
|
||||
use VDM\Joomla\GetBible\Model\Load as Model;
|
||||
use VDM\Joomla\Database\Load as Database;
|
||||
|
||||
|
||||
/**
|
||||
* GetBible Database Load
|
||||
*
|
||||
* @since 2.0.1
|
||||
*/
|
||||
final class Load
|
||||
{
|
||||
/**
|
||||
* Search Table
|
||||
*
|
||||
* @var Table
|
||||
* @since 2.0.1
|
||||
*/
|
||||
protected Table $table;
|
||||
|
||||
/**
|
||||
* Model Load
|
||||
*
|
||||
* @var Model
|
||||
* @since 2.0.1
|
||||
*/
|
||||
protected Model $model;
|
||||
|
||||
/**
|
||||
* Database Load
|
||||
*
|
||||
* @var Database
|
||||
* @since 2.0.1
|
||||
*/
|
||||
protected Database $load;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param Table $table The core table object.
|
||||
* @param Model $model The model object.
|
||||
* @param Database $load The database object.
|
||||
*
|
||||
* @since 2.0.1
|
||||
*/
|
||||
public function __construct(Table $table, Model $model, Database $load)
|
||||
{
|
||||
$this->table = $table;
|
||||
$this->model = $model;
|
||||
$this->load = $load;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a value from a given table
|
||||
* Example: $this->value(
|
||||
* [
|
||||
* 'abbreviation' => 'kjv',
|
||||
* 'book_nr' => 62,
|
||||
* 'chapter' => 3,
|
||||
* 'verse' => 16
|
||||
* ], 'value_key', 'table_name'
|
||||
* );
|
||||
*
|
||||
* @param array $keys The item keys
|
||||
* @param string $field The field key
|
||||
* @param string $table The table
|
||||
*
|
||||
* @return mixed
|
||||
* @since 2.0.1
|
||||
*/
|
||||
public function value(array $keys, string $field, string $table)
|
||||
{
|
||||
// check if this is a valid table
|
||||
if ($this->table->exist($table, $field))
|
||||
{
|
||||
return $this->model->value(
|
||||
$this->load->value(
|
||||
["a.${field}" => $field],
|
||||
['a' => $table],
|
||||
$this->prefix($keys)
|
||||
),
|
||||
$field,
|
||||
$table
|
||||
);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the max value from a given table
|
||||
* Example: $this->value(
|
||||
* [
|
||||
* 'abbreviation' => 'kjv',
|
||||
* 'book_nr' => 62,
|
||||
* 'chapter' => 3,
|
||||
* 'verse' => 16
|
||||
* ], 'value_key', 'table_name'
|
||||
* );
|
||||
*
|
||||
* @param array $keys The item keys
|
||||
* @param string $field The field key
|
||||
* @param string $table The table
|
||||
*
|
||||
* @return mixed
|
||||
* @since 2.0.1
|
||||
*/
|
||||
public function max(array $keys, string $field, string $table)
|
||||
{
|
||||
// check if this is a valid table
|
||||
if ($this->table->exist($table, $field))
|
||||
{
|
||||
return $this->model->value(
|
||||
$this->load->value(
|
||||
["all" => "MAX(`$field`)"],
|
||||
['a' => $table],
|
||||
$this->prefix($keys)
|
||||
),
|
||||
$field,
|
||||
$table
|
||||
);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get values from a given table
|
||||
* Example: $this->item(
|
||||
* [
|
||||
* 'abbriviation' => 'kjv',
|
||||
* 'book_nr' => 62,
|
||||
* 'chapter' => 3,
|
||||
* 'verse' => 16
|
||||
* ], 'table_name'
|
||||
* );
|
||||
*
|
||||
* @param array $keys The item keys
|
||||
* @param string $table The table
|
||||
*
|
||||
* @return object|null
|
||||
* @since 2.0.1
|
||||
*/
|
||||
public function item(array $keys, string $table): ?object
|
||||
{
|
||||
// check if this is a valid table
|
||||
if ($this->table->exist($table))
|
||||
{
|
||||
return $this->model->item(
|
||||
$this->load->item(
|
||||
['all' => 'a.*'],
|
||||
['a' => $table],
|
||||
$this->prefix($keys)
|
||||
),
|
||||
$table
|
||||
);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get values from a given table
|
||||
* Example: $this->items(
|
||||
* [
|
||||
* 'abbriviation' => [
|
||||
* 'operator' => 'IN',
|
||||
* 'value' => ['kjv', 'aov']
|
||||
* ],
|
||||
* 'book_nr' => 62,
|
||||
* 'chapter' => 3,
|
||||
* 'verse' => [
|
||||
* 'operator' => 'IN',
|
||||
* 'value' => [16, 17, 18]
|
||||
* ]
|
||||
* ], 'table_name'
|
||||
* );
|
||||
* Example: $this->items($ids, 'table_name');
|
||||
*
|
||||
* @param array $keys The item keys
|
||||
* @param string $table The table
|
||||
*
|
||||
* @return array|null
|
||||
* @since 2.0.1
|
||||
*/
|
||||
public function items(array $keys, string $table): ?array
|
||||
{
|
||||
// check if this is a valid table
|
||||
if ($this->table->exist($table))
|
||||
{
|
||||
return $this->model->items(
|
||||
$this->load->items(
|
||||
['all' => 'a.*'], ['a' => $table], $this->prefix($keys)
|
||||
),
|
||||
$table
|
||||
);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add prefix to the keys
|
||||
*
|
||||
* @param array $keys The query keys
|
||||
*
|
||||
* @return array
|
||||
* @since 2.0.1
|
||||
*/
|
||||
private function prefix(array &$keys): array
|
||||
{
|
||||
// update the key values
|
||||
$bucket = [];
|
||||
foreach ($keys as $k => $v)
|
||||
{
|
||||
$bucket['a.' . $k] = $v;
|
||||
}
|
||||
return $bucket;
|
||||
}
|
||||
}
|
||||
|
||||
###POWERCODE###
|
||||
|
@ -1,207 +1 @@
|
||||
/**
|
||||
* Search Table
|
||||
*
|
||||
* @var Table
|
||||
* @since 2.0.1
|
||||
*/
|
||||
protected Table $table;
|
||||
|
||||
/**
|
||||
* Model Load
|
||||
*
|
||||
* @var Model
|
||||
* @since 2.0.1
|
||||
*/
|
||||
protected Model $model;
|
||||
|
||||
/**
|
||||
* Database Load
|
||||
*
|
||||
* @var Database
|
||||
* @since 2.0.1
|
||||
*/
|
||||
protected Database $load;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param Table $table The core table object.
|
||||
* @param Model $model The model object.
|
||||
* @param Database $load The database object.
|
||||
*
|
||||
* @since 2.0.1
|
||||
*/
|
||||
public function __construct(Table $table, Model $model, Database $load)
|
||||
{
|
||||
$this->table = $table;
|
||||
$this->model = $model;
|
||||
$this->load = $load;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a value from a given table
|
||||
* Example: $this->value(
|
||||
* [
|
||||
* 'abbreviation' => 'kjv',
|
||||
* 'book_nr' => 62,
|
||||
* 'chapter' => 3,
|
||||
* 'verse' => 16
|
||||
* ], 'value_key', 'table_name'
|
||||
* );
|
||||
*
|
||||
* @param array $keys The item keys
|
||||
* @param string $field The field key
|
||||
* @param string $table The table
|
||||
*
|
||||
* @return mixed
|
||||
* @since 2.0.1
|
||||
*/
|
||||
public function value(array $keys, string $field, string $table)
|
||||
{
|
||||
// check if this is a valid table
|
||||
if ($this->table->exist($table, $field))
|
||||
{
|
||||
return $this->model->value(
|
||||
$this->load->value(
|
||||
["a.${field}" => $field],
|
||||
['a' => $table],
|
||||
$this->prefix($keys)
|
||||
),
|
||||
$field,
|
||||
$table
|
||||
);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the max value from a given table
|
||||
* Example: $this->value(
|
||||
* [
|
||||
* 'abbreviation' => 'kjv',
|
||||
* 'book_nr' => 62,
|
||||
* 'chapter' => 3,
|
||||
* 'verse' => 16
|
||||
* ], 'value_key', 'table_name'
|
||||
* );
|
||||
*
|
||||
* @param array $keys The item keys
|
||||
* @param string $field The field key
|
||||
* @param string $table The table
|
||||
*
|
||||
* @return mixed
|
||||
* @since 2.0.1
|
||||
*/
|
||||
public function max(array $keys, string $field, string $table)
|
||||
{
|
||||
// check if this is a valid table
|
||||
if ($this->table->exist($table, $field))
|
||||
{
|
||||
return $this->model->value(
|
||||
$this->load->value(
|
||||
["all" => "MAX(`$field`)"],
|
||||
['a' => $table],
|
||||
$this->prefix($keys)
|
||||
),
|
||||
$field,
|
||||
$table
|
||||
);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get values from a given table
|
||||
* Example: $this->item(
|
||||
* [
|
||||
* 'abbriviation' => 'kjv',
|
||||
* 'book_nr' => 62,
|
||||
* 'chapter' => 3,
|
||||
* 'verse' => 16
|
||||
* ], 'table_name'
|
||||
* );
|
||||
*
|
||||
* @param array $keys The item keys
|
||||
* @param string $table The table
|
||||
*
|
||||
* @return object|null
|
||||
* @since 2.0.1
|
||||
*/
|
||||
public function item(array $keys, string $table): ?object
|
||||
{
|
||||
// check if this is a valid table
|
||||
if ($this->table->exist($table))
|
||||
{
|
||||
return $this->model->item(
|
||||
$this->load->item(
|
||||
['all' => 'a.*'],
|
||||
['a' => $table],
|
||||
$this->prefix($keys)
|
||||
),
|
||||
$table
|
||||
);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get values from a given table
|
||||
* Example: $this->items(
|
||||
* [
|
||||
* 'abbriviation' => [
|
||||
* 'operator' => 'IN',
|
||||
* 'value' => ['kjv', 'aov']
|
||||
* ],
|
||||
* 'book_nr' => 62,
|
||||
* 'chapter' => 3,
|
||||
* 'verse' => [
|
||||
* 'operator' => 'IN',
|
||||
* 'value' => [16, 17, 18]
|
||||
* ]
|
||||
* ], 'table_name'
|
||||
* );
|
||||
* Example: $this->items($ids, 'table_name');
|
||||
*
|
||||
* @param array $keys The item keys
|
||||
* @param string $table The table
|
||||
*
|
||||
* @return array|null
|
||||
* @since 2.0.1
|
||||
*/
|
||||
public function items(array $keys, string $table): ?array
|
||||
{
|
||||
// check if this is a valid table
|
||||
if ($this->table->exist($table))
|
||||
{
|
||||
return $this->model->items(
|
||||
$this->load->items(
|
||||
['all' => 'a.*'], ['a' => $table], $this->prefix($keys)
|
||||
),
|
||||
$table
|
||||
);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add prefix to the keys
|
||||
*
|
||||
* @param array $keys The query keys
|
||||
*
|
||||
* @return array
|
||||
* @since 2.0.1
|
||||
*/
|
||||
private function prefix(array &$keys): array
|
||||
{
|
||||
// update the key values
|
||||
$bucket = [];
|
||||
foreach ($keys as $k => $v)
|
||||
{
|
||||
$bucket['a.' . $k] = $v;
|
||||
}
|
||||
return $bucket;
|
||||
}
|
||||
###CODEPOWER###
|
@ -1,31 +1 @@
|
||||
{
|
||||
"add_head": "0",
|
||||
"add_licensing_template": "2",
|
||||
"extends": "0",
|
||||
"guid": "c03b9c61-17d3-4774-a335-783903719f83",
|
||||
"implements": null,
|
||||
"load_selection": null,
|
||||
"name": "Load",
|
||||
"power_version": "1.0.0",
|
||||
"system_name": "Joomla.GetBible.Database.Load",
|
||||
"type": "final class",
|
||||
"use_selection": {
|
||||
"use_selection0": {
|
||||
"use": "ff8d5fdb-2d1f-4178-bd18-a43b8efd1068",
|
||||
"as": "default"
|
||||
},
|
||||
"use_selection1": {
|
||||
"use": "b1bd2b4f-dede-44ad-86e9-2a595a0a9ca0",
|
||||
"as": "Model"
|
||||
},
|
||||
"use_selection2": {
|
||||
"use": "06f8eada-d59b-441c-b287-0aea1793da5a",
|
||||
"as": "Database"
|
||||
}
|
||||
},
|
||||
"namespace": "VDM\\Joomla\\GetBible\\Database.Load",
|
||||
"description": "GetBible Database Load\r\n\r\n@since 2.0.1",
|
||||
"licensing_template": "\/**\r\n * @package GetBible\r\n *\r\n * @created 30th May, 2023\r\n * @author Llewellyn van der Merwe <https:\/\/dev.vdm.io>\r\n * @git GetBible <https:\/\/git.vdm.dev\/getBible>\r\n * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.\r\n * @license GNU General Public License version 2 or later; see LICENSE.txt\r\n *\/\r\n",
|
||||
"head": "",
|
||||
"composer": ""
|
||||
}
|
||||
###POWERLINKER###
|
@ -1,58 +1 @@
|
||||
```
|
||||
██████╗ ██████╗ ██╗ ██╗███████╗██████╗
|
||||
██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗
|
||||
██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝
|
||||
██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗
|
||||
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
|
||||
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
|
||||
```
|
||||
# final class Response (Details)
|
||||
> namespace: **VDM\Joomla\GetBible\Utilities**
|
||||
```uml
|
||||
@startuml
|
||||
class Response << (F,LightGreen) >> #Green {
|
||||
+ get(JoomlaResponse $response, int $expectedCode = 200, ...) : mixed
|
||||
# getBody(JoomlaResponse $response, mixed $default = null) : mixed
|
||||
# error(JoomlaResponse $response) : string
|
||||
}
|
||||
|
||||
note right of Response::get
|
||||
Process the response and decode it.
|
||||
|
||||
since: 2.0.1
|
||||
return: mixed
|
||||
|
||||
arguments:
|
||||
JoomlaResponse $response
|
||||
int $expectedCode = 200
|
||||
mixed $default = null
|
||||
end note
|
||||
|
||||
note right of Response::getBody
|
||||
Return the body from the response
|
||||
|
||||
since: 2.0.1
|
||||
return: mixed
|
||||
end note
|
||||
|
||||
note right of Response::error
|
||||
Get the error message from the GetBible API response
|
||||
|
||||
since: 2.0.1
|
||||
return: string
|
||||
end note
|
||||
|
||||
@enduml
|
||||
```
|
||||
|
||||
---
|
||||
```
|
||||
██╗ ██████╗██████╗
|
||||
██║██╔════╝██╔══██╗
|
||||
██║██║ ██████╔╝
|
||||
██ ██║██║ ██╔══██╗
|
||||
╚█████╔╝╚██████╗██████╔╝
|
||||
╚════╝ ╚═════╝╚═════╝
|
||||
```
|
||||
> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder)
|
||||
|
||||
###POWERREADME###
|
@ -9,115 +9,4 @@
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\GetBible\Utilities;
|
||||
|
||||
|
||||
use Joomla\CMS\Http\Response as JoomlaResponse;
|
||||
use VDM\Joomla\Utilities\JsonHelper;
|
||||
use VDM\Joomla\Utilities\StringHelper;
|
||||
|
||||
|
||||
/**
|
||||
* The GetBible Response
|
||||
*
|
||||
* @since 2.0.1
|
||||
*/
|
||||
final class Response
|
||||
{
|
||||
/**
|
||||
* Process the response and decode it.
|
||||
*
|
||||
* @param JoomlaResponse $response The response.
|
||||
* @param integer $expectedCode The expected "good" code.
|
||||
* @param mixed $default The default if body not have length
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @since 2.0.1
|
||||
* @throws \DomainException
|
||||
**/
|
||||
public function get(JoomlaResponse $response, int $expectedCode = 200, $default = null)
|
||||
{
|
||||
// Validate the response code.
|
||||
if ($response->code != $expectedCode)
|
||||
{
|
||||
// Decode the error response and throw an exception.
|
||||
$message = $this->error($response);
|
||||
|
||||
// Throw an exception with the GetBible error message and code.
|
||||
throw new \DomainException($message, $response->code);
|
||||
}
|
||||
|
||||
return $this->getBody($response, $default);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the body from the response
|
||||
*
|
||||
* @param JoomlaResponse $response The response.
|
||||
* @param mixed $default The default if body not have length
|
||||
*
|
||||
* @return mixed
|
||||
* @since 2.0.1
|
||||
**/
|
||||
protected function getBody(JoomlaResponse $response, $default = null)
|
||||
{
|
||||
// check that we have a body
|
||||
if (isset($response->body) && StringHelper::check($response->body))
|
||||
{
|
||||
// if it's JSON, decode it
|
||||
if (JsonHelper::check($response->body))
|
||||
{
|
||||
return json_decode((string) $response->body);
|
||||
}
|
||||
|
||||
// if it's XML, convert it to an object
|
||||
libxml_use_internal_errors(true);
|
||||
$xml = simplexml_load_string($response->body);
|
||||
if ($xml !== false)
|
||||
{
|
||||
return $xml;
|
||||
}
|
||||
|
||||
// if it's neither JSON nor XML, return as is
|
||||
return $response->body;
|
||||
}
|
||||
|
||||
return $default;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the error message from the GetBible API response
|
||||
*
|
||||
* @param JoomlaResponse $response The response.
|
||||
*
|
||||
* @return string
|
||||
* @since 2.0.1
|
||||
**/
|
||||
protected function error(JoomlaResponse $response): string
|
||||
{
|
||||
// do we have a json string
|
||||
if (isset($response->body) && JsonHelper::check($response->body))
|
||||
{
|
||||
$error = json_decode($response->body);
|
||||
}
|
||||
else
|
||||
{
|
||||
return 'Invalid or empty response body.';
|
||||
}
|
||||
|
||||
// check if GetBible returned an error object
|
||||
if (isset($error->Error))
|
||||
{
|
||||
// error object found, extract message and code
|
||||
$errorMessage = isset($error->Error->Message) ? $error->Error->Message : 'Unknown error.';
|
||||
$errorCode = isset($error->Error->Code) ? $error->Error->Code : 'Unknown error code.';
|
||||
|
||||
// return formatted error message
|
||||
return 'Wasabi Error: ' . $errorMessage . ' Code: ' . $errorCode;
|
||||
}
|
||||
|
||||
return 'No error information found in response.';
|
||||
}
|
||||
}
|
||||
|
||||
###POWERCODE###
|
||||
|
@ -1,95 +1 @@
|
||||
/**
|
||||
* Process the response and decode it.
|
||||
*
|
||||
* @param JoomlaResponse $response The response.
|
||||
* @param integer $expectedCode The expected "good" code.
|
||||
* @param mixed $default The default if body not have length
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @since 2.0.1
|
||||
* @throws \DomainException
|
||||
**/
|
||||
public function get(JoomlaResponse $response, int $expectedCode = 200, $default = null)
|
||||
{
|
||||
// Validate the response code.
|
||||
if ($response->code != $expectedCode)
|
||||
{
|
||||
// Decode the error response and throw an exception.
|
||||
$message = $this->error($response);
|
||||
|
||||
// Throw an exception with the GetBible error message and code.
|
||||
throw new \DomainException($message, $response->code);
|
||||
}
|
||||
|
||||
return $this->getBody($response, $default);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the body from the response
|
||||
*
|
||||
* @param JoomlaResponse $response The response.
|
||||
* @param mixed $default The default if body not have length
|
||||
*
|
||||
* @return mixed
|
||||
* @since 2.0.1
|
||||
**/
|
||||
protected function getBody(JoomlaResponse $response, $default = null)
|
||||
{
|
||||
// check that we have a body
|
||||
if (isset($response->body) && StringHelper::check($response->body))
|
||||
{
|
||||
// if it's JSON, decode it
|
||||
if (JsonHelper::check($response->body))
|
||||
{
|
||||
return json_decode((string) $response->body);
|
||||
}
|
||||
|
||||
// if it's XML, convert it to an object
|
||||
libxml_use_internal_errors(true);
|
||||
$xml = simplexml_load_string($response->body);
|
||||
if ($xml !== false)
|
||||
{
|
||||
return $xml;
|
||||
}
|
||||
|
||||
// if it's neither JSON nor XML, return as is
|
||||
return $response->body;
|
||||
}
|
||||
|
||||
return $default;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the error message from the GetBible API response
|
||||
*
|
||||
* @param JoomlaResponse $response The response.
|
||||
*
|
||||
* @return string
|
||||
* @since 2.0.1
|
||||
**/
|
||||
protected function error(JoomlaResponse $response): string
|
||||
{
|
||||
// do we have a json string
|
||||
if (isset($response->body) && JsonHelper::check($response->body))
|
||||
{
|
||||
$error = json_decode($response->body);
|
||||
}
|
||||
else
|
||||
{
|
||||
return 'Invalid or empty response body.';
|
||||
}
|
||||
|
||||
// check if GetBible returned an error object
|
||||
if (isset($error->Error))
|
||||
{
|
||||
// error object found, extract message and code
|
||||
$errorMessage = isset($error->Error->Message) ? $error->Error->Message : 'Unknown error.';
|
||||
$errorCode = isset($error->Error->Code) ? $error->Error->Code : 'Unknown error code.';
|
||||
|
||||
// return formatted error message
|
||||
return 'Wasabi Error: ' . $errorMessage . ' Code: ' . $errorCode;
|
||||
}
|
||||
|
||||
return 'No error information found in response.';
|
||||
}
|
||||
###CODEPOWER###
|
@ -1,27 +1 @@
|
||||
{
|
||||
"add_head": "1",
|
||||
"add_licensing_template": "2",
|
||||
"extends": "0",
|
||||
"guid": "c99e85a0-d120-4f25-bcbf-0940dd7b773b",
|
||||
"implements": null,
|
||||
"load_selection": null,
|
||||
"name": "Response",
|
||||
"power_version": "1.0.0",
|
||||
"system_name": "Joomla.GetBible.Utilities.Response",
|
||||
"type": "final class",
|
||||
"use_selection": {
|
||||
"use_selection0": {
|
||||
"use": "4b225c51-d293-48e4-b3f6-5136cf5c3f18",
|
||||
"as": "default"
|
||||
},
|
||||
"use_selection1": {
|
||||
"use": "1f28cb53-60d9-4db1-b517-3c7dc6b429ef",
|
||||
"as": "default"
|
||||
}
|
||||
},
|
||||
"namespace": "VDM\\Joomla\\GetBible\\Utilities.Response",
|
||||
"description": "The GetBible Response\r\n\r\n@since 2.0.1",
|
||||
"licensing_template": "\/**\r\n * @package GetBible\r\n *\r\n * @created 30th May, 2023\r\n * @author Llewellyn van der Merwe <https:\/\/dev.vdm.io>\r\n * @git GetBible <https:\/\/git.vdm.dev\/getBible>\r\n * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.\r\n * @license GNU General Public License version 2 or later; see LICENSE.txt\r\n *\/\r\n",
|
||||
"head": "use Joomla\\CMS\\Http\\Response as JoomlaResponse;",
|
||||
"composer": ""
|
||||
}
|
||||
###POWERLINKER###
|
@ -1,110 +1 @@
|
||||
```
|
||||
██████╗ ██████╗ ██╗ ██╗███████╗██████╗
|
||||
██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗
|
||||
██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝
|
||||
██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗
|
||||
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
|
||||
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
|
||||
```
|
||||
# final class Update (Details)
|
||||
> namespace: **VDM\Joomla\GetBible\Database**
|
||||
```uml
|
||||
@startuml
|
||||
class Update << (F,LightGreen) >> #Green {
|
||||
# Model $model
|
||||
# Database $database
|
||||
+ __construct(Model $model, Database $database)
|
||||
+ value(mixed $value, string $field, ...) : bool
|
||||
+ row(array $item, string $key, ...) : bool
|
||||
+ rows(?array $items, string $key, ...) : bool
|
||||
+ item(object $item, string $key, ...) : bool
|
||||
+ items(?array $items, string $key, ...) : bool
|
||||
}
|
||||
|
||||
note right of Update::__construct
|
||||
Constructor
|
||||
|
||||
since: 2.0.1
|
||||
end note
|
||||
|
||||
note right of Update::value
|
||||
Update a value to a given table
|
||||
Example: $this->value(Value, 'value_key', 'id', 'table_name');
|
||||
|
||||
since: 2.0.1
|
||||
return: bool
|
||||
|
||||
arguments:
|
||||
mixed $value
|
||||
string $field
|
||||
string $keyValue
|
||||
string $key
|
||||
string $table
|
||||
end note
|
||||
|
||||
note right of Update::row
|
||||
Update single row with multiple values to a given table
|
||||
Example: $this->item(Array, 'id', 'table_name');
|
||||
|
||||
since: 2.0.1
|
||||
return: bool
|
||||
|
||||
arguments:
|
||||
array $item
|
||||
string $key
|
||||
string $table
|
||||
end note
|
||||
|
||||
note right of Update::rows
|
||||
Update multiple rows to a given table
|
||||
Example: $this->items(Array, 'id', 'table_name');
|
||||
|
||||
since: 2.0.1
|
||||
return: bool
|
||||
|
||||
arguments:
|
||||
?array $items
|
||||
string $key
|
||||
string $table
|
||||
end note
|
||||
|
||||
note right of Update::item
|
||||
Update single item with multiple values to a given table
|
||||
Example: $this->item(Object, 'id', 'table_name');
|
||||
|
||||
since: 2.0.1
|
||||
return: bool
|
||||
|
||||
arguments:
|
||||
object $item
|
||||
string $key
|
||||
string $table
|
||||
end note
|
||||
|
||||
note right of Update::items
|
||||
Update multiple items to a given table
|
||||
Example: $this->items(Array, 'id', 'table_name');
|
||||
|
||||
since: 2.0.1
|
||||
return: bool
|
||||
|
||||
arguments:
|
||||
?array $items
|
||||
string $key
|
||||
string $table
|
||||
end note
|
||||
|
||||
@enduml
|
||||
```
|
||||
|
||||
---
|
||||
```
|
||||
██╗ ██████╗██████╗
|
||||
██║██╔════╝██╔══██╗
|
||||
██║██║ ██████╔╝
|
||||
██ ██║██║ ██╔══██╗
|
||||
╚█████╔╝╚██████╗██████╔╝
|
||||
╚════╝ ╚═════╝╚═════╝
|
||||
```
|
||||
> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder)
|
||||
|
||||
###POWERREADME###
|
@ -9,160 +9,4 @@
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\GetBible\Database;
|
||||
|
||||
|
||||
use VDM\Joomla\GetBible\Model\Upsert as Model;
|
||||
use VDM\Joomla\Database\Update as Database;
|
||||
|
||||
|
||||
/**
|
||||
* The GetBible Database Update
|
||||
*
|
||||
* @since 2.0.1
|
||||
*/
|
||||
final class Update
|
||||
{
|
||||
/**
|
||||
* Model
|
||||
*
|
||||
* @var Model
|
||||
* @since 2.0.1
|
||||
*/
|
||||
protected Model $model;
|
||||
|
||||
/**
|
||||
* Database
|
||||
*
|
||||
* @var Database
|
||||
* @since 2.0.1
|
||||
*/
|
||||
protected Database $database;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param Model $model The set model object.
|
||||
* @param Database $database The update database object.
|
||||
*
|
||||
* @since 2.0.1
|
||||
*/
|
||||
public function __construct(Model $model, Database $database)
|
||||
{
|
||||
$this->model = $model;
|
||||
$this->database = $database;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update a value to a given table
|
||||
* Example: $this->value(Value, 'value_key', 'id', 'table_name');
|
||||
*
|
||||
* @param mixed $value The field value
|
||||
* @param string $field The field key
|
||||
* @param string $keyValue The key value
|
||||
* @param string $key The key name
|
||||
* @param string $table Target table
|
||||
*
|
||||
* @return bool
|
||||
* @since 2.0.1
|
||||
*/
|
||||
public function value($value, string $field, string $keyValue, string $key, string $table): bool
|
||||
{
|
||||
// build the array
|
||||
$item = [];
|
||||
$item[$key] = $keyValue;
|
||||
$item[$field] = $value;
|
||||
|
||||
// Update the column of this table using guid as the primary key.
|
||||
return $this->row($item, $key, $table);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update single row with multiple values to a given table
|
||||
* Example: $this->item(Array, 'id', 'table_name');
|
||||
*
|
||||
* @param array $item The item to save
|
||||
* @param string $key The key name
|
||||
* @param string $table Target table
|
||||
*
|
||||
* @return bool
|
||||
* @since 2.0.1
|
||||
*/
|
||||
public function row(array $item, string $key, string $table): bool
|
||||
{
|
||||
// check if object could be modelled
|
||||
if (($item = $this->model->row($item, $table)) !== null)
|
||||
{
|
||||
// Update the column of this table using $key as the primary key.
|
||||
return $this->database->row($item, $key, $table);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update multiple rows to a given table
|
||||
* Example: $this->items(Array, 'id', 'table_name');
|
||||
*
|
||||
* @param array|null $items The items updated in database (array of arrays)
|
||||
* @param string $key The key name
|
||||
* @param string $table Target table
|
||||
*
|
||||
* @return bool
|
||||
* @since 2.0.1
|
||||
*/
|
||||
public function rows(?array $items, string $key, string $table): bool
|
||||
{
|
||||
// check if object could be modelled
|
||||
if (($items = $this->model->rows($items, $table)) !== null)
|
||||
{
|
||||
// Update the column of this table using $key as the primary key.
|
||||
return $this->database->rows($items, $key, $table);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update single item with multiple values to a given table
|
||||
* Example: $this->item(Object, 'id', 'table_name');
|
||||
*
|
||||
* @param object $item The item to save
|
||||
* @param string $key The key name
|
||||
* @param string $table Target table
|
||||
*
|
||||
* @return bool
|
||||
* @since 2.0.1
|
||||
*/
|
||||
public function item(object $item, string $key, string $table): bool
|
||||
{
|
||||
// check if object could be modelled
|
||||
if (($item = $this->model->item($item, $table)) !== null)
|
||||
{
|
||||
// Update the column of this table using $key as the primary key.
|
||||
return $this->database->item($item, $key, $table);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update multiple items to a given table
|
||||
* Example: $this->items(Array, 'id', 'table_name');
|
||||
*
|
||||
* @param array|null $items The items updated in database (array of objects)
|
||||
* @param string $key The key name
|
||||
* @param string $table Target table
|
||||
*
|
||||
* @return bool
|
||||
* @since 2.0.1
|
||||
*/
|
||||
public function items(?array $items, string $key, string $table): bool
|
||||
{
|
||||
// check if object could be modelled
|
||||
if (($items = $this->model->items($items, $table)) !== null)
|
||||
{
|
||||
// Update the column of this table using $key as the primary key.
|
||||
return $this->database->items($items, $key, $table);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
###POWERCODE###
|
||||
|
@ -1,141 +1 @@
|
||||
/**
|
||||
* Model
|
||||
*
|
||||
* @var Model
|
||||
* @since 2.0.1
|
||||
*/
|
||||
protected Model $model;
|
||||
|
||||
/**
|
||||
* Database
|
||||
*
|
||||
* @var Database
|
||||
* @since 2.0.1
|
||||
*/
|
||||
protected Database $database;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param Model $model The set model object.
|
||||
* @param Database $database The update database object.
|
||||
*
|
||||
* @since 2.0.1
|
||||
*/
|
||||
public function __construct(Model $model, Database $database)
|
||||
{
|
||||
$this->model = $model;
|
||||
$this->database = $database;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update a value to a given table
|
||||
* Example: $this->value(Value, 'value_key', 'id', 'table_name');
|
||||
*
|
||||
* @param mixed $value The field value
|
||||
* @param string $field The field key
|
||||
* @param string $keyValue The key value
|
||||
* @param string $key The key name
|
||||
* @param string $table Target table
|
||||
*
|
||||
* @return bool
|
||||
* @since 2.0.1
|
||||
*/
|
||||
public function value($value, string $field, string $keyValue, string $key, string $table): bool
|
||||
{
|
||||
// build the array
|
||||
$item = [];
|
||||
$item[$key] = $keyValue;
|
||||
$item[$field] = $value;
|
||||
|
||||
// Update the column of this table using guid as the primary key.
|
||||
return $this->row($item, $key, $table);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update single row with multiple values to a given table
|
||||
* Example: $this->item(Array, 'id', 'table_name');
|
||||
*
|
||||
* @param array $item The item to save
|
||||
* @param string $key The key name
|
||||
* @param string $table Target table
|
||||
*
|
||||
* @return bool
|
||||
* @since 2.0.1
|
||||
*/
|
||||
public function row(array $item, string $key, string $table): bool
|
||||
{
|
||||
// check if object could be modelled
|
||||
if (($item = $this->model->row($item, $table)) !== null)
|
||||
{
|
||||
// Update the column of this table using $key as the primary key.
|
||||
return $this->database->row($item, $key, $table);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update multiple rows to a given table
|
||||
* Example: $this->items(Array, 'id', 'table_name');
|
||||
*
|
||||
* @param array|null $items The items updated in database (array of arrays)
|
||||
* @param string $key The key name
|
||||
* @param string $table Target table
|
||||
*
|
||||
* @return bool
|
||||
* @since 2.0.1
|
||||
*/
|
||||
public function rows(?array $items, string $key, string $table): bool
|
||||
{
|
||||
// check if object could be modelled
|
||||
if (($items = $this->model->rows($items, $table)) !== null)
|
||||
{
|
||||
// Update the column of this table using $key as the primary key.
|
||||
return $this->database->rows($items, $key, $table);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update single item with multiple values to a given table
|
||||
* Example: $this->item(Object, 'id', 'table_name');
|
||||
*
|
||||
* @param object $item The item to save
|
||||
* @param string $key The key name
|
||||
* @param string $table Target table
|
||||
*
|
||||
* @return bool
|
||||
* @since 2.0.1
|
||||
*/
|
||||
public function item(object $item, string $key, string $table): bool
|
||||
{
|
||||
// check if object could be modelled
|
||||
if (($item = $this->model->item($item, $table)) !== null)
|
||||
{
|
||||
// Update the column of this table using $key as the primary key.
|
||||
return $this->database->item($item, $key, $table);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update multiple items to a given table
|
||||
* Example: $this->items(Array, 'id', 'table_name');
|
||||
*
|
||||
* @param array|null $items The items updated in database (array of objects)
|
||||
* @param string $key The key name
|
||||
* @param string $table Target table
|
||||
*
|
||||
* @return bool
|
||||
* @since 2.0.1
|
||||
*/
|
||||
public function items(?array $items, string $key, string $table): bool
|
||||
{
|
||||
// check if object could be modelled
|
||||
if (($items = $this->model->items($items, $table)) !== null)
|
||||
{
|
||||
// Update the column of this table using $key as the primary key.
|
||||
return $this->database->items($items, $key, $table);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
###CODEPOWER###
|
@ -1,27 +1 @@
|
||||
{
|
||||
"add_head": "0",
|
||||
"add_licensing_template": "2",
|
||||
"extends": "0",
|
||||
"guid": "d7a5f0c6-de60-4d31-b3e4-5d668a8f7d2e",
|
||||
"implements": null,
|
||||
"load_selection": null,
|
||||
"name": "Update",
|
||||
"power_version": "1.0.0",
|
||||
"system_name": "Joomla.GetBible.Database.Update",
|
||||
"type": "final class",
|
||||
"use_selection": {
|
||||
"use_selection0": {
|
||||
"use": "91b37bd7-b314-48be-91cf-434ec823bd80",
|
||||
"as": "Model"
|
||||
},
|
||||
"use_selection1": {
|
||||
"use": "cce56585-58b0-4f72-a92c-e2635ea52d83",
|
||||
"as": "Database"
|
||||
}
|
||||
},
|
||||
"namespace": "VDM\\Joomla\\GetBible\\Database.Update",
|
||||
"description": "The GetBible Database Update\r\n\r\n@since 2.0.1",
|
||||
"licensing_template": "\/**\r\n * @package GetBible\r\n *\r\n * @created 30th May, 2023\r\n * @author Llewellyn van der Merwe <https:\/\/dev.vdm.io>\r\n * @git GetBible <https:\/\/git.vdm.dev\/getBible>\r\n * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.\r\n * @license GNU General Public License version 2 or later; see LICENSE.txt\r\n *\/\r\n",
|
||||
"head": "",
|
||||
"composer": ""
|
||||
}
|
||||
###POWERLINKER###
|
@ -1,54 +1 @@
|
||||
```
|
||||
██████╗ ██████╗ ██╗ ██╗███████╗██████╗
|
||||
██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗
|
||||
██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝
|
||||
██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗
|
||||
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
|
||||
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
|
||||
```
|
||||
# abstract class Openai (Details)
|
||||
> namespace: **VDM\Joomla\GetBible**
|
||||
```uml
|
||||
@startuml
|
||||
abstract Openai #Orange {
|
||||
# static $container
|
||||
+ {static} _(string $key) : Mixed
|
||||
+ {static} getContainer() : Container
|
||||
# {static} createContainer() : Container
|
||||
}
|
||||
|
||||
note right of Openai::_
|
||||
Get any class from the package container
|
||||
|
||||
since: 3.2.0
|
||||
return: Mixed
|
||||
end note
|
||||
|
||||
note right of Openai::getContainer
|
||||
Get the global package container
|
||||
|
||||
since: 3.2.0
|
||||
return: Container
|
||||
end note
|
||||
|
||||
note right of Openai::createContainer
|
||||
Create a container object
|
||||
|
||||
since: 3.2.0
|
||||
return: Container
|
||||
end note
|
||||
|
||||
@enduml
|
||||
```
|
||||
|
||||
---
|
||||
```
|
||||
██╗ ██████╗██████╗
|
||||
██║██╔════╝██╔══██╗
|
||||
██║██║ ██████╔╝
|
||||
██ ██║██║ ██╔══██╗
|
||||
╚█████╔╝╚██████╗██████╔╝
|
||||
╚════╝ ╚═════╝╚═════╝
|
||||
```
|
||||
> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder)
|
||||
|
||||
###POWERREADME###
|
@ -9,70 +9,4 @@
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\GetBible;
|
||||
|
||||
|
||||
use Joomla\DI\Container;
|
||||
use VDM\Joomla\GetBible\Service\Openai as Api;
|
||||
use VDM\Joomla\Openai\Service\Utilities;
|
||||
use VDM\Joomla\Interfaces\FactoryInterface;
|
||||
|
||||
|
||||
/**
|
||||
* Openai Factory
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
abstract class Openai implements FactoryInterface
|
||||
{
|
||||
/**
|
||||
* Global Package Container
|
||||
*
|
||||
* @var Container
|
||||
* @since 3.2.0
|
||||
**/
|
||||
protected static $container = null;
|
||||
|
||||
/**
|
||||
* Get any class from the package container
|
||||
*
|
||||
* @param string $key The container class key
|
||||
*
|
||||
* @return Mixed
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public static function _($key)
|
||||
{
|
||||
return self::getContainer()->get($key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the global package container
|
||||
*
|
||||
* @return Container
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public static function getContainer(): Container
|
||||
{
|
||||
if (!self::$container)
|
||||
{
|
||||
self::$container = self::createContainer();
|
||||
}
|
||||
|
||||
return self::$container;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a container object
|
||||
*
|
||||
* @return Container
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected static function createContainer(): Container
|
||||
{
|
||||
return (new Container())
|
||||
->registerServiceProvider(new Utilities())
|
||||
->registerServiceProvider(new Api());
|
||||
}
|
||||
}
|
||||
|
||||
###POWERCODE###
|
||||
|
@ -1,49 +1 @@
|
||||
/**
|
||||
* Global Package Container
|
||||
*
|
||||
* @var Container
|
||||
* @since 3.2.0
|
||||
**/
|
||||
protected static $container = null;
|
||||
|
||||
/**
|
||||
* Get any class from the package container
|
||||
*
|
||||
* @param string $key The container class key
|
||||
*
|
||||
* @return Mixed
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public static function _($key)
|
||||
{
|
||||
return self::getContainer()->get($key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the global package container
|
||||
*
|
||||
* @return Container
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public static function getContainer(): Container
|
||||
{
|
||||
if (!self::$container)
|
||||
{
|
||||
self::$container = self::createContainer();
|
||||
}
|
||||
|
||||
return self::$container;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a container object
|
||||
*
|
||||
* @return Container
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected static function createContainer(): Container
|
||||
{
|
||||
return (new Container())
|
||||
->registerServiceProvider(new Utilities())
|
||||
->registerServiceProvider(new Api());
|
||||
}
|
||||
###CODEPOWER###
|
@ -1,29 +1 @@
|
||||
{
|
||||
"add_head": "1",
|
||||
"add_licensing_template": "2",
|
||||
"extends": "0",
|
||||
"guid": "f722bb8b-d377-4425-b1e4-2fe1734a3664",
|
||||
"implements": [
|
||||
"caf33c5d-858c-4f9a-894f-ab302ec5445a"
|
||||
],
|
||||
"load_selection": null,
|
||||
"name": "Openai",
|
||||
"power_version": "1.0.0",
|
||||
"system_name": "GetBible.Openai",
|
||||
"type": "abstract class",
|
||||
"use_selection": {
|
||||
"use_selection0": {
|
||||
"use": "ac5c7679-dd6e-4817-8e48-489e521122f1",
|
||||
"as": "Api"
|
||||
},
|
||||
"use_selection1": {
|
||||
"use": "07858e1f-5698-4227-8941-03dc93557938",
|
||||
"as": "default"
|
||||
}
|
||||
},
|
||||
"namespace": "VDM\\Joomla\\GetBible\\Openai",
|
||||
"description": "Openai Factory\r\n\r\n@since 3.2.0",
|
||||
"licensing_template": "\/**\r\n * @package GetBible\r\n *\r\n * @created 30th May, 2023\r\n * @author Llewellyn van der Merwe <https:\/\/dev.vdm.io>\r\n * @git GetBible <https:\/\/git.vdm.dev\/getBible>\r\n * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.\r\n * @license GNU General Public License version 2 or later; see LICENSE.txt\r\n *\/\r\n",
|
||||
"head": "use Joomla\\DI\\Container;",
|
||||
"composer": ""
|
||||
}
|
||||
###POWERLINKER###
|
@ -1,225 +1 @@
|
||||
```
|
||||
██████╗ ██████╗ ██╗ ██╗███████╗██████╗
|
||||
██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗
|
||||
██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝
|
||||
██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗
|
||||
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
|
||||
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
|
||||
```
|
||||
# final class Watcher (Details)
|
||||
> namespace: **VDM\Joomla\GetBible**
|
||||
```uml
|
||||
@startuml
|
||||
class Watcher << (F,LightGreen) >> #Green {
|
||||
# Load $load
|
||||
# Insert $insert
|
||||
# Update $update
|
||||
# Translations $translations
|
||||
# Books $books
|
||||
# Chapters $chapters
|
||||
# Verses $verses
|
||||
# bool $fresh
|
||||
# string $today
|
||||
# ?object $verse
|
||||
+ __construct(Load $load, Insert $insert, ...)
|
||||
+ isNew() : bool
|
||||
+ api(string $translation, int $book, ...) : bool
|
||||
+ getNextChapter(string $translation, int $book, ...) : ?int
|
||||
+ getPreviousChapter(int $chapter, bool $force = false) : ?int
|
||||
+ getLastChapter(string $translation, int $book) : ?int
|
||||
+ getNextBook(string $translation, int $book, ...) : ?int
|
||||
+ getPreviousBook(string $translation, int $book, ...) : ?int
|
||||
- translation(string $translation) : ?string
|
||||
- book(string $translation, int $book) : ?string
|
||||
- chapter(string $translation, int $book, ...) : ?string
|
||||
- verses(string $translation, int $book, ...) : bool
|
||||
- update(string $translation, int $book, ...) : bool
|
||||
- getVerse(int $number, array $verses) : ?object
|
||||
- updateHash(string $translation, int $book, ...) : bool
|
||||
- hold() : bool
|
||||
- bump() : bool
|
||||
}
|
||||
|
||||
note right of Watcher::__construct
|
||||
Constructor
|
||||
|
||||
since: 2.0.1
|
||||
|
||||
arguments:
|
||||
Load $load
|
||||
Insert $insert
|
||||
Update $update
|
||||
Translations $translations
|
||||
Books $books
|
||||
Chapters $chapters
|
||||
Verses $verses
|
||||
end note
|
||||
|
||||
note left of Watcher::isNew
|
||||
The see if new chapters was installed, and therefore new
|
||||
|
||||
since: 2.0.1
|
||||
return: bool
|
||||
end note
|
||||
|
||||
note right of Watcher::api
|
||||
Watching that the local Database and API is in sync
|
||||
|
||||
since: 2.0.1
|
||||
return: bool
|
||||
|
||||
arguments:
|
||||
string $translation
|
||||
int $book
|
||||
int $chapter
|
||||
end note
|
||||
|
||||
note left of Watcher::getNextChapter
|
||||
Get the next chapter
|
||||
|
||||
since: 2.0.1
|
||||
return: ?int
|
||||
|
||||
arguments:
|
||||
string $translation
|
||||
int $book
|
||||
int $chapter
|
||||
bool $force = false
|
||||
end note
|
||||
|
||||
note right of Watcher::getPreviousChapter
|
||||
Get the previous chapter
|
||||
|
||||
since: 2.0.1
|
||||
return: ?int
|
||||
end note
|
||||
|
||||
note left of Watcher::getLastChapter
|
||||
Get the last chapter of a book
|
||||
|
||||
since: 2.0.1
|
||||
return: ?int
|
||||
end note
|
||||
|
||||
note right of Watcher::getNextBook
|
||||
Get the next book
|
||||
|
||||
since: 2.0.1
|
||||
return: ?int
|
||||
|
||||
arguments:
|
||||
string $translation
|
||||
int $book
|
||||
int $try
|
||||
end note
|
||||
|
||||
note left of Watcher::getPreviousBook
|
||||
Get the previous book
|
||||
|
||||
since: 2.0.1
|
||||
return: ?int
|
||||
|
||||
arguments:
|
||||
string $translation
|
||||
int $book
|
||||
int $try
|
||||
end note
|
||||
|
||||
note right of Watcher::translation
|
||||
Get Translation Hash Value
|
||||
|
||||
since: 2.0.1
|
||||
return: ?string
|
||||
end note
|
||||
|
||||
note left of Watcher::book
|
||||
Get Book Hash Value
|
||||
|
||||
since: 2.0.1
|
||||
return: ?string
|
||||
end note
|
||||
|
||||
note right of Watcher::chapter
|
||||
Get Chapter Hash Value
|
||||
|
||||
since: 2.0.1
|
||||
return: ?string
|
||||
|
||||
arguments:
|
||||
string $translation
|
||||
int $book
|
||||
int $chapter
|
||||
end note
|
||||
|
||||
note left of Watcher::verses
|
||||
Load verses if not in local database
|
||||
|
||||
since: 2.0.1
|
||||
return: bool
|
||||
|
||||
arguments:
|
||||
string $translation
|
||||
int $book
|
||||
int $chapter
|
||||
end note
|
||||
|
||||
note right of Watcher::update
|
||||
Trigger the update of the verses of a translation-book-chapter
|
||||
|
||||
since: 2.0.1
|
||||
return: bool
|
||||
|
||||
arguments:
|
||||
string $translation
|
||||
int $book
|
||||
int $chapter
|
||||
end note
|
||||
|
||||
note left of Watcher::getVerse
|
||||
Get a verse text from the API array of verses
|
||||
|
||||
since: 2.0.1
|
||||
return: ?object
|
||||
end note
|
||||
|
||||
note right of Watcher::updateHash
|
||||
Trigger the update of a chapter hash value
|
||||
|
||||
since: 2.0.1
|
||||
return: bool
|
||||
|
||||
arguments:
|
||||
string $translation
|
||||
int $book
|
||||
int $chapter
|
||||
string $hash
|
||||
end note
|
||||
|
||||
note left of Watcher::hold
|
||||
Check if its time to match the API hash
|
||||
|
||||
since: 2.0.1
|
||||
return: bool
|
||||
end note
|
||||
|
||||
note right of Watcher::bump
|
||||
Bump the checking time
|
||||
|
||||
since: 2.0.1
|
||||
return: bool
|
||||
end note
|
||||
|
||||
@enduml
|
||||
```
|
||||
|
||||
---
|
||||
```
|
||||
██╗ ██████╗██████╗
|
||||
██║██╔════╝██╔══██╗
|
||||
██║██║ ██████╔╝
|
||||
██ ██║██║ ██╔══██╗
|
||||
╚█████╔╝╚██████╗██████╔╝
|
||||
╚════╝ ╚═════╝╚═════╝
|
||||
```
|
||||
> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder)
|
||||
|
||||
###POWERREADME###
|
@ -9,650 +9,4 @@
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\GetBible;
|
||||
|
||||
|
||||
use Joomla\CMS\Date\Date;
|
||||
use VDM\Joomla\GetBible\Database\Load;
|
||||
use VDM\Joomla\GetBible\Database\Insert;
|
||||
use VDM\Joomla\GetBible\Database\Update;
|
||||
use VDM\Joomla\GetBible\Api\Translations;
|
||||
use VDM\Joomla\GetBible\Api\Books;
|
||||
use VDM\Joomla\GetBible\Api\Chapters;
|
||||
use VDM\Joomla\GetBible\Api\Verses;
|
||||
|
||||
|
||||
/**
|
||||
* The GetBible Watcher
|
||||
*
|
||||
* @since 2.0.1
|
||||
*/
|
||||
final class Watcher
|
||||
{
|
||||
/**
|
||||
* The Load class
|
||||
*
|
||||
* @var Load
|
||||
* @since 2.0.1
|
||||
*/
|
||||
protected Load $load;
|
||||
|
||||
/**
|
||||
* The Insert class
|
||||
*
|
||||
* @var Insert
|
||||
* @since 2.0.1
|
||||
*/
|
||||
protected Insert $insert;
|
||||
|
||||
/**
|
||||
* The Update class
|
||||
*
|
||||
* @var Update
|
||||
* @since 2.0.1
|
||||
*/
|
||||
protected Update $update;
|
||||
|
||||
/**
|
||||
* The Translations class
|
||||
*
|
||||
* @var Translations
|
||||
* @since 2.0.1
|
||||
*/
|
||||
protected Translations $translations;
|
||||
|
||||
/**
|
||||
* The Books class
|
||||
*
|
||||
* @var Books
|
||||
* @since 2.0.1
|
||||
*/
|
||||
protected Books $books;
|
||||
|
||||
/**
|
||||
* The Chapters class
|
||||
*
|
||||
* @var Chapters
|
||||
* @since 2.0.1
|
||||
*/
|
||||
protected Chapters $chapters;
|
||||
|
||||
/**
|
||||
* The Verses class
|
||||
*
|
||||
* @var Verses
|
||||
* @since 2.0.1
|
||||
*/
|
||||
protected Verses $verses;
|
||||
|
||||
/**
|
||||
* The fresh load switch
|
||||
*
|
||||
* @var bool
|
||||
* @since 2.0.1
|
||||
*/
|
||||
protected bool $fresh = false;
|
||||
|
||||
/**
|
||||
* The sql date of today
|
||||
*
|
||||
* @var string
|
||||
* @since 2.0.1
|
||||
*/
|
||||
protected string $today;
|
||||
|
||||
/**
|
||||
* The target verse
|
||||
*
|
||||
* @var object|null
|
||||
* @since 2.0.1
|
||||
*/
|
||||
protected ?object $verse;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param Load $load The load object.
|
||||
* @param Insert $insert The insert object.
|
||||
* @param Update $update The update object.
|
||||
* @param Translations $translations The translations API object.
|
||||
* @param Books $books The books API object.
|
||||
* @param Chapters $chapters The chapters API object.
|
||||
* @param Verses $verses The verses API object.
|
||||
*
|
||||
* @since 2.0.1
|
||||
*/
|
||||
public function __construct(
|
||||
Load $load,
|
||||
Insert $insert,
|
||||
Update $update,
|
||||
Translations $translations,
|
||||
Books $books,
|
||||
Chapters $chapters,
|
||||
Verses $verses)
|
||||
{
|
||||
$this->load = $load;
|
||||
$this->insert = $insert;
|
||||
$this->update = $update;
|
||||
$this->translations = $translations;
|
||||
$this->books = $books;
|
||||
$this->chapters = $chapters;
|
||||
$this->verses = $verses;
|
||||
|
||||
// just in-case we set a date
|
||||
$this->today = (new Date())->toSql();
|
||||
}
|
||||
|
||||
/**
|
||||
* The see if new chapters was installed, and therefore new
|
||||
*
|
||||
* @return bool true if is new
|
||||
* @since 2.0.1
|
||||
*/
|
||||
public function isNew(): bool
|
||||
{
|
||||
return $this->fresh;
|
||||
}
|
||||
|
||||
/**
|
||||
* Watching that the local Database and API is in sync
|
||||
*
|
||||
* @param string $translation The translation.
|
||||
* @param int $book The book number.
|
||||
* @param int $chapter The chapter number.
|
||||
*
|
||||
* @return bool True on success
|
||||
* @since 2.0.1
|
||||
*/
|
||||
public function api(string $translation, int $book, int $chapter): bool
|
||||
{
|
||||
// does the translation exist
|
||||
if ($this->translation($translation) === null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// does the book exist
|
||||
if ($this->book($translation, $book) === null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// does the chapter exist, and get hash value
|
||||
if (($hash = $this->chapter($translation, $book, $chapter)) === null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// load the verses if not found
|
||||
if ($this->verses($translation, $book, $chapter))
|
||||
{
|
||||
if ($this->isNew() || $this->hold())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// get API chapter hash value
|
||||
$api_hash = $this->chapters->sha($translation, $book, $chapter);
|
||||
|
||||
// confirm chapter hash has not changed
|
||||
if (hash_equals($hash, $api_hash))
|
||||
{
|
||||
return $this->bump();
|
||||
}
|
||||
|
||||
if ($this->update($translation, $book, $chapter))
|
||||
{
|
||||
// now update the hash of this chapter
|
||||
return $this->updateHash($translation, $book, $chapter, $api_hash);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the next chapter
|
||||
*
|
||||
* @param string $translation The translation.
|
||||
* @param int $book The book number.
|
||||
* @param int $chapter The chapter number.
|
||||
* @param bool $force The switch to force the getting.
|
||||
*
|
||||
* @return int|null Number if there is a next, else null
|
||||
* @since 2.0.1
|
||||
*/
|
||||
public function getNextChapter(string $translation, int $book, int $chapter, bool $force = false): ?int
|
||||
{
|
||||
// we load the next chapter
|
||||
$next = $chapter + 1;
|
||||
// check if this books has this next chapter
|
||||
if (($force || !$this->isNew()) && $this->load->value(
|
||||
['abbreviation' => $translation, 'book_nr' => $book, 'chapter' => $next],
|
||||
'sha', 'chapter'
|
||||
))
|
||||
{
|
||||
return $next;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the previous chapter
|
||||
*
|
||||
* @param int $chapter The chapter number.
|
||||
* @param bool $force The switch to force the getting.
|
||||
*
|
||||
* @return int|null Number if there is a previous, else null
|
||||
* @since 2.0.1
|
||||
*/
|
||||
public function getPreviousChapter(int $chapter, bool $force = false): ?int
|
||||
{
|
||||
// we load the previous chapter
|
||||
$previous = $chapter - 1;
|
||||
if (($force || !$this->isNew()) && $previous > 0)
|
||||
{
|
||||
return $previous;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the last chapter of a book
|
||||
*
|
||||
* @param string $translation The translation.
|
||||
* @param int $book The book number.
|
||||
*
|
||||
* @return int|null Number if there is a previous, else null
|
||||
* @since 2.0.1
|
||||
*/
|
||||
public function getLastChapter(string $translation, int $book): ?int
|
||||
{
|
||||
// we load the last chapter
|
||||
return $this->load->max(
|
||||
['abbreviation' => $translation, 'book_nr' => $book],
|
||||
'chapter', 'chapter'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the next book
|
||||
*
|
||||
* @param string $translation The translation.
|
||||
* @param int $book The book number.
|
||||
* @param int $try The number of tries
|
||||
*
|
||||
* @return int|null Number if there is a next, else null
|
||||
* @since 2.0.1
|
||||
*/
|
||||
public function getNextBook(string $translation, int $book, int $try = 0): ?int
|
||||
{
|
||||
// we load the next chapter
|
||||
$next = $book + 1;
|
||||
|
||||
// if we already looked over 66
|
||||
if ($next >= 67)
|
||||
{
|
||||
$next = 1;
|
||||
}
|
||||
|
||||
// check if this book exist
|
||||
if ($this->load->value(
|
||||
['abbreviation' => $translation, 'nr' => $next],
|
||||
'sha', 'book'
|
||||
))
|
||||
{
|
||||
return $next;
|
||||
}
|
||||
|
||||
$try++;
|
||||
|
||||
// could not be found :(
|
||||
if ($try >= 65)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return $this->getNextBook($translation, $next, $try);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the previous book
|
||||
*
|
||||
* @param string $translation The translation.
|
||||
* @param int $book The book number.
|
||||
* @param int $try The number of tries
|
||||
*
|
||||
* @return int|null Number if there is a previous, else null
|
||||
* @since 2.0.1
|
||||
*/
|
||||
public function getPreviousBook(string $translation, int $book, int $try = 0): ?int
|
||||
{
|
||||
// we load the previous book
|
||||
$previous = $book - 1;
|
||||
|
||||
// if we already looked over 66
|
||||
if ($previous <= 0)
|
||||
{
|
||||
$previous = 66;
|
||||
}
|
||||
|
||||
// check if this book exist
|
||||
if ($this->load->value(
|
||||
['abbreviation' => $translation, 'nr' => $previous],
|
||||
'sha', 'book'
|
||||
))
|
||||
{
|
||||
return $previous;
|
||||
}
|
||||
|
||||
$try++;
|
||||
|
||||
// could not be found :(
|
||||
if ($try >= 65)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return $this->getPreviousBook($translation, $previous, $try);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Translation Hash Value
|
||||
*
|
||||
* @param string $translation The translation.
|
||||
*
|
||||
* @return string|null The sha of the translation
|
||||
* @since 2.0.1
|
||||
*/
|
||||
private function translation(string $translation): ?string
|
||||
{
|
||||
// check local value
|
||||
if (($translation_sha = $this->load->value(['abbreviation' => $translation], 'sha', 'translation')) !== null)
|
||||
{
|
||||
return $translation_sha;
|
||||
}
|
||||
|
||||
// get all the translations
|
||||
$translations = $this->translations->list();
|
||||
|
||||
// check return data
|
||||
if (!isset($translations->{$translation}) || !isset($translations->{$translation}->sha))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
// add them to the database
|
||||
$this->insert->items((array) $translations, 'translation');
|
||||
|
||||
return $translations->{$translation}->sha;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Book Hash Value
|
||||
*
|
||||
* @param string $translation The translation.
|
||||
* @param int $book The book number.
|
||||
*
|
||||
* @return string|null The sha of the book
|
||||
* @since 2.0.1
|
||||
*/
|
||||
private function book(string $translation, int $book): ?string
|
||||
{
|
||||
// check local value
|
||||
if (($book_sha = $this->load->value(['abbreviation' => $translation, 'nr' => $book], 'sha', 'book')) !== null)
|
||||
{
|
||||
return $book_sha;
|
||||
}
|
||||
|
||||
// get all the books
|
||||
$books = $this->books->list($translation);
|
||||
|
||||
// check return data
|
||||
if (!isset($books->{$book}) || !isset($books->{$book}->sha))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
// add them to the database
|
||||
$this->insert->items((array) $books, 'book');
|
||||
|
||||
return $books->{$book}->sha;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Chapter Hash Value
|
||||
*
|
||||
* @param string $translation The translation.
|
||||
* @param int $book The book number.
|
||||
* @param int $chapter The chapter number.
|
||||
*
|
||||
* @return string|null The sha of the chapter
|
||||
* @since 2.0.1
|
||||
*/
|
||||
private function chapter(string $translation, int $book, int $chapter): ?string
|
||||
{
|
||||
// check local value
|
||||
if (($chapter_sha = $this->load->value(
|
||||
['abbreviation' => $translation, 'book_nr' => $book, 'chapter' => $chapter],
|
||||
'sha', 'chapter'
|
||||
)) !== null)
|
||||
{
|
||||
return $chapter_sha;
|
||||
}
|
||||
|
||||
// get all the books
|
||||
$chapters = $this->chapters->list($translation, $book);
|
||||
|
||||
// check return data
|
||||
if (!isset($chapters->{$chapter}) || !isset($chapters->{$chapter}->sha))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
// add them to the database
|
||||
$this->insert->items((array) $chapters, 'chapter');
|
||||
|
||||
return $chapters->{$chapter}->sha;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load verses if not in local database
|
||||
*
|
||||
* @param string $translation The translation.
|
||||
* @param int $book The book number.
|
||||
* @param int $chapter The chapter number.
|
||||
*
|
||||
* @return bool True if in local database
|
||||
* @since 2.0.1
|
||||
*/
|
||||
private function verses(string $translation, int $book, int $chapter): bool
|
||||
{
|
||||
// check local value
|
||||
if (($this->verse = $this->load->item(
|
||||
['abbreviation' => $translation, 'book_nr' => $book, 'chapter' => $chapter, 'verse' => 1],
|
||||
'verse'
|
||||
)) !== null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// get all the verses
|
||||
if (($verses = $this->verses->get($translation, $book, $chapter)) === null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// dynamic update all verse objects
|
||||
$insert = ['book_nr' => $book, 'abbreviation' => $translation];
|
||||
array_walk($verses->verses, function ($item, $key) use ($insert) {
|
||||
foreach ($insert as $k => $v) { $item->$k = $v; }
|
||||
});
|
||||
|
||||
$this->fresh = true;
|
||||
|
||||
// add them to the database
|
||||
return $this->insert->items((array) $verses->verses, 'verse');
|
||||
}
|
||||
|
||||
/**
|
||||
* Trigger the update of the verses of a translation-book-chapter
|
||||
*
|
||||
* @param string $translation The translation.
|
||||
* @param int $book The book number.
|
||||
* @param int $chapter The chapter number.
|
||||
*
|
||||
* @return bool True if update was a success
|
||||
* @since 2.0.1
|
||||
*/
|
||||
private function update(string $translation, int $book, int $chapter): bool
|
||||
{
|
||||
// load all the verses from the local database
|
||||
if (($verses = $this->load->items(
|
||||
['abbreviation' => $translation, 'book_nr' => $book, 'chapter' => $chapter],
|
||||
'verse'
|
||||
)) !== null)
|
||||
{
|
||||
// get verses from the API
|
||||
if (($api = $this->verses->get($translation, $book, $chapter)) === null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
$update = [];
|
||||
$insert = [];
|
||||
|
||||
// dynamic update all verse objects
|
||||
foreach ($api->verses as $verse)
|
||||
{
|
||||
// check if the verse exist
|
||||
if (($object = $this->getVerse((int) $verse->verse, $verses)) !== null)
|
||||
{
|
||||
$verse->id = $object->id;
|
||||
$verse->created = $this->today;
|
||||
$update[] = $verse;
|
||||
}
|
||||
else
|
||||
{
|
||||
$insert[] = $verse;
|
||||
}
|
||||
}
|
||||
|
||||
// check if we have values to insert
|
||||
if ($insert !== [])
|
||||
{
|
||||
$this->insert->items($insert, 'verse');
|
||||
}
|
||||
|
||||
// update the local verses
|
||||
if ($update !== [] && $this->update->items($update, 'id', 'verse'))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a verse text from the API array of verses
|
||||
*
|
||||
* @param int $number The verse number.
|
||||
* @param array $verses The api verses
|
||||
*
|
||||
* @return object|null The verse string
|
||||
* @since 2.0.1
|
||||
*/
|
||||
private function getVerse(int $number, array &$verses): ?object
|
||||
{
|
||||
foreach ($verses as $verse)
|
||||
{
|
||||
if ($verse->verse === $number)
|
||||
{
|
||||
return $verse;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Trigger the update of a chapter hash value
|
||||
*
|
||||
* @param string $translation The translation.
|
||||
* @param int $book The book number.
|
||||
* @param int $chapter The chapter number.
|
||||
* @param string $hash The API chapter hash value.
|
||||
*
|
||||
* @return bool True if update was a success
|
||||
* @since 2.0.1
|
||||
*/
|
||||
private function updateHash(string $translation, int $book, int $chapter, string $hash): bool
|
||||
{
|
||||
// load the chapter
|
||||
if (($item = $this->load->item(
|
||||
['abbreviation' => $translation, 'book_nr' => $book, 'chapter' => $chapter],
|
||||
'chapter'
|
||||
)) !== null)
|
||||
{
|
||||
$update = [];
|
||||
$update['id'] = $item->id;
|
||||
$update['sha'] = $hash;
|
||||
$update['created'] = $this->today;
|
||||
|
||||
// update the local chapter
|
||||
return $this->update->row($update, 'id', 'chapter');
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if its time to match the API hash
|
||||
*
|
||||
* @return bool false if its time to check for an update
|
||||
* @since 2.0.1
|
||||
*/
|
||||
private function hold(): bool
|
||||
{
|
||||
// Create DateTime objects from the strings
|
||||
try {
|
||||
$today = new \DateTime($this->today);
|
||||
$created = new \DateTime($this->verse->created);
|
||||
} catch (\Exception $e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Calculate the difference
|
||||
$interval = $today->diff($created);
|
||||
|
||||
// Check if the interval is more than 1 month
|
||||
if ($interval->m >= 1 || $interval->y >= 1)
|
||||
{
|
||||
return false; // More than a month, it's time to check for an update
|
||||
}
|
||||
else
|
||||
{
|
||||
return true; // Within the last month, hold off on the update check
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Bump the checking time
|
||||
*
|
||||
* @return bool true when the update was a success
|
||||
* @since 2.0.1
|
||||
*/
|
||||
private function bump(): bool
|
||||
{
|
||||
$update = [];
|
||||
$update['id'] = $this->verse->id;
|
||||
$update['created'] = $this->today;
|
||||
|
||||
// update the local verse
|
||||
return $this->update->row($update, 'id', 'verse');
|
||||
}
|
||||
}
|
||||
|
||||
###POWERCODE###
|
||||
|
@ -1,625 +1 @@
|
||||
/**
|
||||
* The Load class
|
||||
*
|
||||
* @var Load
|
||||
* @since 2.0.1
|
||||
*/
|
||||
protected Load $load;
|
||||
|
||||
/**
|
||||
* The Insert class
|
||||
*
|
||||
* @var Insert
|
||||
* @since 2.0.1
|
||||
*/
|
||||
protected Insert $insert;
|
||||
|
||||
/**
|
||||
* The Update class
|
||||
*
|
||||
* @var Update
|
||||
* @since 2.0.1
|
||||
*/
|
||||
protected Update $update;
|
||||
|
||||
/**
|
||||
* The Translations class
|
||||
*
|
||||
* @var Translations
|
||||
* @since 2.0.1
|
||||
*/
|
||||
protected Translations $translations;
|
||||
|
||||
/**
|
||||
* The Books class
|
||||
*
|
||||
* @var Books
|
||||
* @since 2.0.1
|
||||
*/
|
||||
protected Books $books;
|
||||
|
||||
/**
|
||||
* The Chapters class
|
||||
*
|
||||
* @var Chapters
|
||||
* @since 2.0.1
|
||||
*/
|
||||
protected Chapters $chapters;
|
||||
|
||||
/**
|
||||
* The Verses class
|
||||
*
|
||||
* @var Verses
|
||||
* @since 2.0.1
|
||||
*/
|
||||
protected Verses $verses;
|
||||
|
||||
/**
|
||||
* The fresh load switch
|
||||
*
|
||||
* @var bool
|
||||
* @since 2.0.1
|
||||
*/
|
||||
protected bool $fresh = false;
|
||||
|
||||
/**
|
||||
* The sql date of today
|
||||
*
|
||||
* @var string
|
||||
* @since 2.0.1
|
||||
*/
|
||||
protected string $today;
|
||||
|
||||
/**
|
||||
* The target verse
|
||||
*
|
||||
* @var object|null
|
||||
* @since 2.0.1
|
||||
*/
|
||||
protected ?object $verse;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param Load $load The load object.
|
||||
* @param Insert $insert The insert object.
|
||||
* @param Update $update The update object.
|
||||
* @param Translations $translations The translations API object.
|
||||
* @param Books $books The books API object.
|
||||
* @param Chapters $chapters The chapters API object.
|
||||
* @param Verses $verses The verses API object.
|
||||
*
|
||||
* @since 2.0.1
|
||||
*/
|
||||
public function __construct(
|
||||
Load $load,
|
||||
Insert $insert,
|
||||
Update $update,
|
||||
Translations $translations,
|
||||
Books $books,
|
||||
Chapters $chapters,
|
||||
Verses $verses)
|
||||
{
|
||||
$this->load = $load;
|
||||
$this->insert = $insert;
|
||||
$this->update = $update;
|
||||
$this->translations = $translations;
|
||||
$this->books = $books;
|
||||
$this->chapters = $chapters;
|
||||
$this->verses = $verses;
|
||||
|
||||
// just in-case we set a date
|
||||
$this->today = (new Date())->toSql();
|
||||
}
|
||||
|
||||
/**
|
||||
* The see if new chapters was installed, and therefore new
|
||||
*
|
||||
* @return bool true if is new
|
||||
* @since 2.0.1
|
||||
*/
|
||||
public function isNew(): bool
|
||||
{
|
||||
return $this->fresh;
|
||||
}
|
||||
|
||||
/**
|
||||
* Watching that the local Database and API is in sync
|
||||
*
|
||||
* @param string $translation The translation.
|
||||
* @param int $book The book number.
|
||||
* @param int $chapter The chapter number.
|
||||
*
|
||||
* @return bool True on success
|
||||
* @since 2.0.1
|
||||
*/
|
||||
public function api(string $translation, int $book, int $chapter): bool
|
||||
{
|
||||
// does the translation exist
|
||||
if ($this->translation($translation) === null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// does the book exist
|
||||
if ($this->book($translation, $book) === null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// does the chapter exist, and get hash value
|
||||
if (($hash = $this->chapter($translation, $book, $chapter)) === null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// load the verses if not found
|
||||
if ($this->verses($translation, $book, $chapter))
|
||||
{
|
||||
if ($this->isNew() || $this->hold())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// get API chapter hash value
|
||||
$api_hash = $this->chapters->sha($translation, $book, $chapter);
|
||||
|
||||
// confirm chapter hash has not changed
|
||||
if (hash_equals($hash, $api_hash))
|
||||
{
|
||||
return $this->bump();
|
||||
}
|
||||
|
||||
if ($this->update($translation, $book, $chapter))
|
||||
{
|
||||
// now update the hash of this chapter
|
||||
return $this->updateHash($translation, $book, $chapter, $api_hash);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the next chapter
|
||||
*
|
||||
* @param string $translation The translation.
|
||||
* @param int $book The book number.
|
||||
* @param int $chapter The chapter number.
|
||||
* @param bool $force The switch to force the getting.
|
||||
*
|
||||
* @return int|null Number if there is a next, else null
|
||||
* @since 2.0.1
|
||||
*/
|
||||
public function getNextChapter(string $translation, int $book, int $chapter, bool $force = false): ?int
|
||||
{
|
||||
// we load the next chapter
|
||||
$next = $chapter + 1;
|
||||
// check if this books has this next chapter
|
||||
if (($force || !$this->isNew()) && $this->load->value(
|
||||
['abbreviation' => $translation, 'book_nr' => $book, 'chapter' => $next],
|
||||
'sha', 'chapter'
|
||||
))
|
||||
{
|
||||
return $next;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the previous chapter
|
||||
*
|
||||
* @param int $chapter The chapter number.
|
||||
* @param bool $force The switch to force the getting.
|
||||
*
|
||||
* @return int|null Number if there is a previous, else null
|
||||
* @since 2.0.1
|
||||
*/
|
||||
public function getPreviousChapter(int $chapter, bool $force = false): ?int
|
||||
{
|
||||
// we load the previous chapter
|
||||
$previous = $chapter - 1;
|
||||
if (($force || !$this->isNew()) && $previous > 0)
|
||||
{
|
||||
return $previous;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the last chapter of a book
|
||||
*
|
||||
* @param string $translation The translation.
|
||||
* @param int $book The book number.
|
||||
*
|
||||
* @return int|null Number if there is a previous, else null
|
||||
* @since 2.0.1
|
||||
*/
|
||||
public function getLastChapter(string $translation, int $book): ?int
|
||||
{
|
||||
// we load the last chapter
|
||||
return $this->load->max(
|
||||
['abbreviation' => $translation, 'book_nr' => $book],
|
||||
'chapter', 'chapter'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the next book
|
||||
*
|
||||
* @param string $translation The translation.
|
||||
* @param int $book The book number.
|
||||
* @param int $try The number of tries
|
||||
*
|
||||
* @return int|null Number if there is a next, else null
|
||||
* @since 2.0.1
|
||||
*/
|
||||
public function getNextBook(string $translation, int $book, int $try = 0): ?int
|
||||
{
|
||||
// we load the next chapter
|
||||
$next = $book + 1;
|
||||
|
||||
// if we already looked over 66
|
||||
if ($next >= 67)
|
||||
{
|
||||
$next = 1;
|
||||
}
|
||||
|
||||
// check if this book exist
|
||||
if ($this->load->value(
|
||||
['abbreviation' => $translation, 'nr' => $next],
|
||||
'sha', 'book'
|
||||
))
|
||||
{
|
||||
return $next;
|
||||
}
|
||||
|
||||
$try++;
|
||||
|
||||
// could not be found :(
|
||||
if ($try >= 65)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return $this->getNextBook($translation, $next, $try);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the previous book
|
||||
*
|
||||
* @param string $translation The translation.
|
||||
* @param int $book The book number.
|
||||
* @param int $try The number of tries
|
||||
*
|
||||
* @return int|null Number if there is a previous, else null
|
||||
* @since 2.0.1
|
||||
*/
|
||||
public function getPreviousBook(string $translation, int $book, int $try = 0): ?int
|
||||
{
|
||||
// we load the previous book
|
||||
$previous = $book - 1;
|
||||
|
||||
// if we already looked over 66
|
||||
if ($previous <= 0)
|
||||
{
|
||||
$previous = 66;
|
||||
}
|
||||
|
||||
// check if this book exist
|
||||
if ($this->load->value(
|
||||
['abbreviation' => $translation, 'nr' => $previous],
|
||||
'sha', 'book'
|
||||
))
|
||||
{
|
||||
return $previous;
|
||||
}
|
||||
|
||||
$try++;
|
||||
|
||||
// could not be found :(
|
||||
if ($try >= 65)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return $this->getPreviousBook($translation, $previous, $try);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Translation Hash Value
|
||||
*
|
||||
* @param string $translation The translation.
|
||||
*
|
||||
* @return string|null The sha of the translation
|
||||
* @since 2.0.1
|
||||
*/
|
||||
private function translation(string $translation): ?string
|
||||
{
|
||||
// check local value
|
||||
if (($translation_sha = $this->load->value(['abbreviation' => $translation], 'sha', 'translation')) !== null)
|
||||
{
|
||||
return $translation_sha;
|
||||
}
|
||||
|
||||
// get all the translations
|
||||
$translations = $this->translations->list();
|
||||
|
||||
// check return data
|
||||
if (!isset($translations->{$translation}) || !isset($translations->{$translation}->sha))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
// add them to the database
|
||||
$this->insert->items((array) $translations, 'translation');
|
||||
|
||||
return $translations->{$translation}->sha;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Book Hash Value
|
||||
*
|
||||
* @param string $translation The translation.
|
||||
* @param int $book The book number.
|
||||
*
|
||||
* @return string|null The sha of the book
|
||||
* @since 2.0.1
|
||||
*/
|
||||
private function book(string $translation, int $book): ?string
|
||||
{
|
||||
// check local value
|
||||
if (($book_sha = $this->load->value(['abbreviation' => $translation, 'nr' => $book], 'sha', 'book')) !== null)
|
||||
{
|
||||
return $book_sha;
|
||||
}
|
||||
|
||||
// get all the books
|
||||
$books = $this->books->list($translation);
|
||||
|
||||
// check return data
|
||||
if (!isset($books->{$book}) || !isset($books->{$book}->sha))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
// add them to the database
|
||||
$this->insert->items((array) $books, 'book');
|
||||
|
||||
return $books->{$book}->sha;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Chapter Hash Value
|
||||
*
|
||||
* @param string $translation The translation.
|
||||
* @param int $book The book number.
|
||||
* @param int $chapter The chapter number.
|
||||
*
|
||||
* @return string|null The sha of the chapter
|
||||
* @since 2.0.1
|
||||
*/
|
||||
private function chapter(string $translation, int $book, int $chapter): ?string
|
||||
{
|
||||
// check local value
|
||||
if (($chapter_sha = $this->load->value(
|
||||
['abbreviation' => $translation, 'book_nr' => $book, 'chapter' => $chapter],
|
||||
'sha', 'chapter'
|
||||
)) !== null)
|
||||
{
|
||||
return $chapter_sha;
|
||||
}
|
||||
|
||||
// get all the books
|
||||
$chapters = $this->chapters->list($translation, $book);
|
||||
|
||||
// check return data
|
||||
if (!isset($chapters->{$chapter}) || !isset($chapters->{$chapter}->sha))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
// add them to the database
|
||||
$this->insert->items((array) $chapters, 'chapter');
|
||||
|
||||
return $chapters->{$chapter}->sha;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load verses if not in local database
|
||||
*
|
||||
* @param string $translation The translation.
|
||||
* @param int $book The book number.
|
||||
* @param int $chapter The chapter number.
|
||||
*
|
||||
* @return bool True if in local database
|
||||
* @since 2.0.1
|
||||
*/
|
||||
private function verses(string $translation, int $book, int $chapter): bool
|
||||
{
|
||||
// check local value
|
||||
if (($this->verse = $this->load->item(
|
||||
['abbreviation' => $translation, 'book_nr' => $book, 'chapter' => $chapter, 'verse' => 1],
|
||||
'verse'
|
||||
)) !== null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// get all the verses
|
||||
if (($verses = $this->verses->get($translation, $book, $chapter)) === null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// dynamic update all verse objects
|
||||
$insert = ['book_nr' => $book, 'abbreviation' => $translation];
|
||||
array_walk($verses->verses, function ($item, $key) use ($insert) {
|
||||
foreach ($insert as $k => $v) { $item->$k = $v; }
|
||||
});
|
||||
|
||||
$this->fresh = true;
|
||||
|
||||
// add them to the database
|
||||
return $this->insert->items((array) $verses->verses, 'verse');
|
||||
}
|
||||
|
||||
/**
|
||||
* Trigger the update of the verses of a translation-book-chapter
|
||||
*
|
||||
* @param string $translation The translation.
|
||||
* @param int $book The book number.
|
||||
* @param int $chapter The chapter number.
|
||||
*
|
||||
* @return bool True if update was a success
|
||||
* @since 2.0.1
|
||||
*/
|
||||
private function update(string $translation, int $book, int $chapter): bool
|
||||
{
|
||||
// load all the verses from the local database
|
||||
if (($verses = $this->load->items(
|
||||
['abbreviation' => $translation, 'book_nr' => $book, 'chapter' => $chapter],
|
||||
'verse'
|
||||
)) !== null)
|
||||
{
|
||||
// get verses from the API
|
||||
if (($api = $this->verses->get($translation, $book, $chapter)) === null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
$update = [];
|
||||
$insert = [];
|
||||
|
||||
// dynamic update all verse objects
|
||||
foreach ($api->verses as $verse)
|
||||
{
|
||||
// check if the verse exist
|
||||
if (($object = $this->getVerse((int) $verse->verse, $verses)) !== null)
|
||||
{
|
||||
$verse->id = $object->id;
|
||||
$verse->created = $this->today;
|
||||
$update[] = $verse;
|
||||
}
|
||||
else
|
||||
{
|
||||
$insert[] = $verse;
|
||||
}
|
||||
}
|
||||
|
||||
// check if we have values to insert
|
||||
if ($insert !== [])
|
||||
{
|
||||
$this->insert->items($insert, 'verse');
|
||||
}
|
||||
|
||||
// update the local verses
|
||||
if ($update !== [] && $this->update->items($update, 'id', 'verse'))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a verse text from the API array of verses
|
||||
*
|
||||
* @param int $number The verse number.
|
||||
* @param array $verses The api verses
|
||||
*
|
||||
* @return object|null The verse string
|
||||
* @since 2.0.1
|
||||
*/
|
||||
private function getVerse(int $number, array &$verses): ?object
|
||||
{
|
||||
foreach ($verses as $verse)
|
||||
{
|
||||
if ($verse->verse === $number)
|
||||
{
|
||||
return $verse;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Trigger the update of a chapter hash value
|
||||
*
|
||||
* @param string $translation The translation.
|
||||
* @param int $book The book number.
|
||||
* @param int $chapter The chapter number.
|
||||
* @param string $hash The API chapter hash value.
|
||||
*
|
||||
* @return bool True if update was a success
|
||||
* @since 2.0.1
|
||||
*/
|
||||
private function updateHash(string $translation, int $book, int $chapter, string $hash): bool
|
||||
{
|
||||
// load the chapter
|
||||
if (($item = $this->load->item(
|
||||
['abbreviation' => $translation, 'book_nr' => $book, 'chapter' => $chapter],
|
||||
'chapter'
|
||||
)) !== null)
|
||||
{
|
||||
$update = [];
|
||||
$update['id'] = $item->id;
|
||||
$update['sha'] = $hash;
|
||||
$update['created'] = $this->today;
|
||||
|
||||
// update the local chapter
|
||||
return $this->update->row($update, 'id', 'chapter');
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if its time to match the API hash
|
||||
*
|
||||
* @return bool false if its time to check for an update
|
||||
* @since 2.0.1
|
||||
*/
|
||||
private function hold(): bool
|
||||
{
|
||||
// Create DateTime objects from the strings
|
||||
try {
|
||||
$today = new \DateTime($this->today);
|
||||
$created = new \DateTime($this->verse->created);
|
||||
} catch (\Exception $e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Calculate the difference
|
||||
$interval = $today->diff($created);
|
||||
|
||||
// Check if the interval is more than 1 month
|
||||
if ($interval->m >= 1 || $interval->y >= 1)
|
||||
{
|
||||
return false; // More than a month, it's time to check for an update
|
||||
}
|
||||
else
|
||||
{
|
||||
return true; // Within the last month, hold off on the update check
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Bump the checking time
|
||||
*
|
||||
* @return bool true when the update was a success
|
||||
* @since 2.0.1
|
||||
*/
|
||||
private function bump(): bool
|
||||
{
|
||||
$update = [];
|
||||
$update['id'] = $this->verse->id;
|
||||
$update['created'] = $this->today;
|
||||
|
||||
// update the local verse
|
||||
return $this->update->row($update, 'id', 'verse');
|
||||
}
|
||||
###CODEPOWER###
|
@ -1,47 +1 @@
|
||||
{
|
||||
"add_head": "1",
|
||||
"add_licensing_template": "2",
|
||||
"extends": "0",
|
||||
"guid": "f815fb33-f721-48a5-a84e-53f1986e8881",
|
||||
"implements": null,
|
||||
"load_selection": null,
|
||||
"name": "Watcher",
|
||||
"power_version": "1.0.0",
|
||||
"system_name": "Joomla.GetBible.Watcher",
|
||||
"type": "final class",
|
||||
"use_selection": {
|
||||
"use_selection0": {
|
||||
"use": "c03b9c61-17d3-4774-a335-783903719f83",
|
||||
"as": "default"
|
||||
},
|
||||
"use_selection1": {
|
||||
"use": "a07d90f6-6ff2-40a1-99c1-0f2cf33c9adf",
|
||||
"as": "default"
|
||||
},
|
||||
"use_selection2": {
|
||||
"use": "d7a5f0c6-de60-4d31-b3e4-5d668a8f7d2e",
|
||||
"as": "default"
|
||||
},
|
||||
"use_selection3": {
|
||||
"use": "be0cae8b-4b78-4f59-b97b-9e31ee6f52e0",
|
||||
"as": "default"
|
||||
},
|
||||
"use_selection4": {
|
||||
"use": "491c91ce-6355-40d3-bbbd-622473c6c026",
|
||||
"as": "default"
|
||||
},
|
||||
"use_selection5": {
|
||||
"use": "a752e4b2-9b5e-4188-8d33-3799c46d5119",
|
||||
"as": "default"
|
||||
},
|
||||
"use_selection6": {
|
||||
"use": "afa508bf-78f8-4616-97cc-f2809584c086",
|
||||
"as": "default"
|
||||
}
|
||||
},
|
||||
"namespace": "VDM\\Joomla\\GetBible\\Watcher",
|
||||
"description": "The GetBible Watcher\r\n\r\n@since 2.0.1",
|
||||
"licensing_template": "\/**\r\n * @package GetBible\r\n *\r\n * @created 30th May, 2023\r\n * @author Llewellyn van der Merwe <https:\/\/dev.vdm.io>\r\n * @git GetBible <https:\/\/git.vdm.dev\/getBible>\r\n * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.\r\n * @license GNU General Public License version 2 or later; see LICENSE.txt\r\n *\/\r\n",
|
||||
"head": "use Joomla\\CMS\\Date\\Date;",
|
||||
"composer": ""
|
||||
}
|
||||
###POWERLINKER###
|
@ -1,45 +1 @@
|
||||
```
|
||||
██████╗ ██████╗ ██╗ ██╗███████╗██████╗
|
||||
██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗
|
||||
██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝
|
||||
██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗
|
||||
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
|
||||
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
|
||||
```
|
||||
# final class Uri (Details)
|
||||
> namespace: **VDM\Joomla\GetBible\Utilities**
|
||||
```uml
|
||||
@startuml
|
||||
class Uri << (F,LightGreen) >> #Green {
|
||||
# Config $config
|
||||
+ __construct(Config $config)
|
||||
+ get(string $path) : JoomlaUri
|
||||
}
|
||||
|
||||
note right of Uri::__construct
|
||||
Constructor
|
||||
|
||||
since: 2.0.1
|
||||
end note
|
||||
|
||||
note right of Uri::get
|
||||
Method to build and return a full request URL for the request.
|
||||
|
||||
since: 2.0.1
|
||||
return: JoomlaUri
|
||||
end note
|
||||
|
||||
@enduml
|
||||
```
|
||||
|
||||
---
|
||||
```
|
||||
██╗ ██████╗██████╗
|
||||
██║██╔════╝██╔══██╗
|
||||
██║██║ ██████╔╝
|
||||
██ ██║██║ ██╔══██╗
|
||||
╚█████╔╝╚██████╗██████╔╝
|
||||
╚════╝ ╚═════╝╚═════╝
|
||||
```
|
||||
> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder)
|
||||
|
||||
###POWERREADME###
|
@ -9,55 +9,4 @@
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\GetBible\Utilities;
|
||||
|
||||
|
||||
use Joomla\Uri\Uri as JoomlaUri;
|
||||
use VDM\Joomla\GetBible\Config;
|
||||
|
||||
|
||||
/**
|
||||
* The GetBible Uri
|
||||
*
|
||||
* @since 2.0.1
|
||||
*/
|
||||
final class Uri
|
||||
{
|
||||
/**
|
||||
* The Config class
|
||||
*
|
||||
* @var Config
|
||||
* @since 2.0.1
|
||||
*/
|
||||
protected Config $config;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param Config $config The config class.
|
||||
*
|
||||
* @since 2.0.1
|
||||
**/
|
||||
public function __construct(Config $config)
|
||||
{
|
||||
// set the API config
|
||||
$this->config = $config;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to build and return a full request URL for the request.
|
||||
*
|
||||
* @param string $path URL to inflect
|
||||
*
|
||||
* @return JoomlaUri
|
||||
* @since 2.0.1
|
||||
**/
|
||||
public function get(string $path): JoomlaUri
|
||||
{
|
||||
// Get a new Uri object focusing the api url and given path.
|
||||
$uri = new JoomlaUri($this->config->endpoint . $path);
|
||||
|
||||
return $uri;
|
||||
}
|
||||
}
|
||||
|
||||
###POWERCODE###
|
||||
|
@ -1,36 +1 @@
|
||||
/**
|
||||
* The Config class
|
||||
*
|
||||
* @var Config
|
||||
* @since 2.0.1
|
||||
*/
|
||||
protected Config $config;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param Config $config The config class.
|
||||
*
|
||||
* @since 2.0.1
|
||||
**/
|
||||
public function __construct(Config $config)
|
||||
{
|
||||
// set the API config
|
||||
$this->config = $config;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to build and return a full request URL for the request.
|
||||
*
|
||||
* @param string $path URL to inflect
|
||||
*
|
||||
* @return JoomlaUri
|
||||
* @since 2.0.1
|
||||
**/
|
||||
public function get(string $path): JoomlaUri
|
||||
{
|
||||
// Get a new Uri object focusing the api url and given path.
|
||||
$uri = new JoomlaUri($this->config->endpoint . $path);
|
||||
|
||||
return $uri;
|
||||
}
|
||||
###CODEPOWER###
|
@ -1,23 +1 @@
|
||||
{
|
||||
"add_head": "1",
|
||||
"add_licensing_template": "2",
|
||||
"extends": "0",
|
||||
"guid": "fc9ab6f0-c31b-4077-bb1c-2dcddd36f6bb",
|
||||
"implements": null,
|
||||
"load_selection": null,
|
||||
"name": "Uri",
|
||||
"power_version": "1.0.0",
|
||||
"system_name": "Joomla.GetBible.Utilities.Uri",
|
||||
"type": "final class",
|
||||
"use_selection": {
|
||||
"use_selection0": {
|
||||
"use": "71075f03-4e77-4fc0-840a-ef55fd9260b2",
|
||||
"as": "default"
|
||||
}
|
||||
},
|
||||
"namespace": "VDM\\Joomla\\GetBible\\Utilities.Uri",
|
||||
"description": "The GetBible Uri\r\n\r\n@since 2.0.1",
|
||||
"licensing_template": "\/**\r\n * @package GetBible\r\n *\r\n * @created 30th May, 2023\r\n * @author Llewellyn van der Merwe <https:\/\/dev.vdm.io>\r\n * @git GetBible <https:\/\/git.vdm.dev\/getBible>\r\n * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.\r\n * @license GNU General Public License version 2 or later; see LICENSE.txt\r\n *\/\r\n",
|
||||
"head": "use Joomla\\Uri\\Uri as JoomlaUri;",
|
||||
"composer": ""
|
||||
}
|
||||
###POWERLINKER###
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user