4
0

update 2023-09-25 16:33:07

This commit is contained in:
Robot 2023-09-25 16:33:07 +02:00
parent 5c43e15baa
commit 381102cbe1
Signed by: Robot
GPG Key ID: 14DECD44E7E1BB95
213 changed files with 213 additions and 25589 deletions

127
README.md
View File

@ -1,126 +1 @@
``` ###POWERREADME###
███████╗██╗ ██╗██████╗ ███████╗██████╗
██╔════╝██║ ██║██╔══██╗██╔════╝██╔══██╗
███████╗██║ ██║██████╔╝█████╗ ██████╔╝
╚════██║██║ ██║██╔═══╝ ██╔══╝ ██╔══██╗
███████║╚██████╔╝██║ ███████╗██║ ██║
╚══════╝ ╚═════╝ ╚═╝ ╚══════╝╚═╝ ╚═╝
██████╗ ██████╗ ██╗ ██╗███████╗██████╗ ███████╗
██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗██╔════╝
██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝███████╗
██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗╚════██║
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║███████║
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝╚══════╝
```
### 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 AI** | [Details](src/f3757646-bc63-4f11-98c1-a2663180ab5e) | [Code](src/f3757646-bc63-4f11-98c1-a2663180ab5e/code.php) | [Settings](src/f3757646-bc63-4f11-98c1-a2663180ab5e/settings.json) | Super__f3757646_bc63_4f11_98c1_a2663180ab5e__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 Linker** | [Details](src/36ab759f-7b42-4465-9c17-56ba1dd05f90) | [Code](src/36ab759f-7b42-4465-9c17-56ba1dd05f90/code.php) | [Settings](src/36ab759f-7b42-4465-9c17-56ba1dd05f90/settings.json) | Super__36ab759f_7b42_4465_9c17_56ba1dd05f90__Power
- **final class Loader** | [Details](src/fb5683e2-67ec-413d-96fa-8465fd2f511c) | [Code](src/fb5683e2-67ec-413d-96fa-8465fd2f511c/code.php) | [Settings](src/fb5683e2-67ec-413d-96fa-8465fd2f511c/settings.json) | Super__fb5683e2_67ec_413d_96fa_8465fd2f511c__Power
- **final class Note** | [Details](src/ebda6bd8-95b9-468b-a521-974205146018) | [Code](src/ebda6bd8-95b9-468b-a521-974205146018/code.php) | [Settings](src/ebda6bd8-95b9-468b-a521-974205146018/settings.json) | Super__ebda6bd8_95b9_468b_a521_974205146018__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 Tag** | [Details](src/67f91b8b-7b48-4dbb-bbd5-7945c174622a) | [Code](src/67f91b8b-7b48-4dbb-bbd5-7945c174622a/code.php) | [Settings](src/67f91b8b-7b48-4dbb-bbd5-7945c174622a/settings.json) | Super__67f91b8b_7b48_4dbb_bbd5_7945c174622a__Power
- **final class Tagged** | [Details](src/2315a1c5-bcf6-401a-8d11-60f4d6d12dbb) | [Code](src/2315a1c5-bcf6-401a-8d11-60f4d6d12dbb/code.php) | [Settings](src/2315a1c5-bcf6-401a-8d11-60f4d6d12dbb/settings.json) | Super__2315a1c5_bcf6_401a_8d11_60f4d6d12dbb__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\AI](#vdm-joomla-getbible-ai)
- **final class Engineer** | [Details](src/ed16a9c4-e026-4d16-be60-81892ce7c6a9) | [Code](src/ed16a9c4-e026-4d16-be60-81892ce7c6a9/code.php) | [Settings](src/ed16a9c4-e026-4d16-be60-81892ce7c6a9/settings.json) | Super__ed16a9c4_e026_4d16_be60_81892ce7c6a9__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
- **abstract class Watcher** | [Details](src/37e36c41-16a7-4c5d-972c-99acad5fd0b1) | [Code](src/37e36c41-16a7-4c5d-972c-99acad5fd0b1/code.php) | [Settings](src/37e36c41-16a7-4c5d-972c-99acad5fd0b1/settings.json) | Super__37e36c41_16a7_4c5d_972c_99acad5fd0b1__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\Data](#vdm-joomla-getbible-data)
- **final class Book** | [Details](src/fa776320-65f8-4198-a517-58cd94b3b7b7) | [Code](src/fa776320-65f8-4198-a517-58cd94b3b7b7/code.php) | [Settings](src/fa776320-65f8-4198-a517-58cd94b3b7b7/settings.json) | Super__fa776320_65f8_4198_a517_58cd94b3b7b7__Power
- **final class Chapter** | [Details](src/4a4c786d-51f4-421a-aa61-262dfd071880) | [Code](src/4a4c786d-51f4-421a-aa61-262dfd071880/code.php) | [Settings](src/4a4c786d-51f4-421a-aa61-262dfd071880/settings.json) | Super__4a4c786d_51f4_421a_aa61_262dfd071880__Power
- **final class Placeholders** | [Details](src/ba2151c0-8ffa-4a07-ba6e-93f135a3e9d5) | [Code](src/ba2151c0-8ffa-4a07-ba6e-93f135a3e9d5/code.php) | [Settings](src/ba2151c0-8ffa-4a07-ba6e-93f135a3e9d5/settings.json) | Super__ba2151c0_8ffa_4a07_ba6e_93f135a3e9d5__Power
- **final class Prompt** | [Details](src/3f785d63-a592-463d-9f5f-b2b5a8edd561) | [Code](src/3f785d63-a592-463d-9f5f-b2b5a8edd561/code.php) | [Settings](src/3f785d63-a592-463d-9f5f-b2b5a8edd561/settings.json) | Super__3f785d63_a592_463d_9f5f_b2b5a8edd561__Power
- **final class Response** | [Details](src/44c15b17-e096-47c0-8769-42ea9b692cb2) | [Code](src/44c15b17-e096-47c0-8769-42ea9b692cb2/code.php) | [Settings](src/44c15b17-e096-47c0-8769-42ea9b692cb2/settings.json) | Super__44c15b17_e096_47c0_8769_42ea9b692cb2__Power
- **final class Scripture** | [Details](src/17d87374-2953-4d6c-9fdd-4220d6ad1564) | [Code](src/17d87374-2953-4d6c-9fdd-4220d6ad1564/code.php) | [Settings](src/17d87374-2953-4d6c-9fdd-4220d6ad1564/settings.json) | Super__17d87374_2953_4d6c_9fdd_4220d6ad1564__Power
- **final class Translation** | [Details](src/c4098e1a-46dd-4d60-9277-b3668a09edc8) | [Code](src/c4098e1a-46dd-4d60-9277-b3668a09edc8/code.php) | [Settings](src/c4098e1a-46dd-4d60-9277-b3668a09edc8/settings.json) | Super__c4098e1a_46dd_4d60_9277_b3668a09edc8__Power
- **final class Verse** | [Details](src/e3798c7e-aae1-4e38-ba78-6018ce94630b) | [Code](src/e3798c7e-aae1-4e38-ba78-6018ce94630b/code.php) | [Settings](src/e3798c7e-aae1-4e38-ba78-6018ce94630b/settings.json) | Super__e3798c7e_aae1_4e38_ba78_6018ce94630b__Power
- **final class Word** | [Details](src/899551ac-943e-4f81-becd-7e15c41f1081) | [Code](src/899551ac-943e-4f81-becd-7e15c41f1081/code.php) | [Settings](src/899551ac-943e-4f81-becd-7e15c41f1081/settings.json) | Super__899551ac_943e_4f81_becd_7e15c41f1081__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\Openai](#vdm-joomla-getbible-openai)
- **class Config** | [Details](src/3af7864b-f1f3-491e-b16f-0504f890086d) | [Code](src/3af7864b-f1f3-491e-b16f-0504f890086d/code.php) | [Settings](src/3af7864b-f1f3-491e-b16f-0504f890086d/settings.json) | Super__3af7864b_f1f3_491e_b16f_0504f890086d__Power
- **Namespace**: [VDM\Joomla\GetBible\Service](#vdm-joomla-getbible-service)
- **class AI** | [Details](src/b2c9493f-692b-426b-af22-c6865f76c2bb) | [Code](src/b2c9493f-692b-426b-af22-c6865f76c2bb/code.php) | [Settings](src/b2c9493f-692b-426b-af22-c6865f76c2bb/settings.json) | Super__b2c9493f_692b_426b_af22_c6865f76c2bb__Power
- **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 Data** | [Details](src/3439e63b-d8f1-42ce-a765-60d56b1fbe21) | [Code](src/3439e63b-d8f1-42ce-a765-60d56b1fbe21/code.php) | [Settings](src/3439e63b-d8f1-42ce-a765-60d56b1fbe21/settings.json) | Super__3439e63b_d8f1_42ce_a765_60d56b1fbe21__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
- **class Watcher** | [Details](src/c5077cd8-b042-4295-99cf-3a5ba2af7dce) | [Code](src/c5077cd8-b042-4295-99cf-3a5ba2af7dce/code.php) | [Settings](src/c5077cd8-b042-4295-99cf-3a5ba2af7dce/settings.json) | Super__c5077cd8_b042_4295_99cf_3a5ba2af7dce__Power
- **Namespace**: [VDM\Joomla\GetBible\Tagged](#vdm-joomla-getbible-tagged)
- **final class Paragraphs** | [Details](src/4cfff1bc-02b3-4c52-9e6e-7ceefb505a32) | [Code](src/4cfff1bc-02b3-4c52-9e6e-7ceefb505a32/code.php) | [Settings](src/4cfff1bc-02b3-4c52-9e6e-7ceefb505a32/settings.json) | Super__4cfff1bc_02b3_4c52_9e6e_7ceefb505a32__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 SessionHelper** | [Details](src/84e84cd1-c938-4559-8414-d5692db4118e) | [Code](src/84e84cd1-c938-4559-8414-d5692db4118e/code.php) | [Settings](src/84e84cd1-c938-4559-8414-d5692db4118e/settings.json) | Super__84e84cd1_c938_4559_8414_d5692db4118e__Power
- **final class StringHelper** | [Details](src/a5b32737-207d-4cf6-b8ae-ee815612c3a0) | [Code](src/a5b32737-207d-4cf6-b8ae-ee815612c3a0/code.php) | [Settings](src/a5b32737-207d-4cf6-b8ae-ee815612c3a0/settings.json) | Super__a5b32737_207d_4cf6_b8ae_ee815612c3a0__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
- **Namespace**: [VDM\Joomla\GetBible\Watcher](#vdm-joomla-getbible-watcher)
- **final class Book** | [Details](src/c2a8a5fa-8e7f-443a-86d7-a8c1e4cdfa98) | [Code](src/c2a8a5fa-8e7f-443a-86d7-a8c1e4cdfa98/code.php) | [Settings](src/c2a8a5fa-8e7f-443a-86d7-a8c1e4cdfa98/settings.json) | Super__c2a8a5fa_8e7f_443a_86d7_a8c1e4cdfa98__Power
- **final class Chapter** | [Details](src/07d3888a-5f35-4ba7-977f-fb2f5cf99061) | [Code](src/07d3888a-5f35-4ba7-977f-fb2f5cf99061/code.php) | [Settings](src/07d3888a-5f35-4ba7-977f-fb2f5cf99061/settings.json) | Super__07d3888a_5f35_4ba7_977f_fb2f5cf99061__Power
- **final class Translation** | [Details](src/7d592acd-f031-4d0f-b667-584c88ae0495) | [Code](src/7d592acd-f031-4d0f-b667-584c88ae0495/code.php) | [Settings](src/7d592acd-f031-4d0f-b667-584c88ae0495/settings.json) | Super__7d592acd_f031_4d0f_b667_584c88ae0495__Power
---
```
██╗ ██████╗ ██████╗ ███╗ ███╗██╗ █████╗
██║██╔═══██╗██╔═══██╗████╗ ████║██║ ██╔══██╗
██║██║ ██║██║ ██║██╔████╔██║██║ ███████║
██ ██║██║ ██║██║ ██║██║╚██╔╝██║██║ ██╔══██║
╚█████╔╝╚██████╔╝╚██████╔╝██║ ╚═╝ ██║███████╗██║ ██║
╚════╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
██████╗ ██████╗ ███╗ ███╗██████╗ ██████╗ ███╗ ██╗███████╗███╗ ██╗████████╗
██╔════╝██╔═══██╗████╗ ████║██╔══██╗██╔═══██╗████╗ ██║██╔════╝████╗ ██║╚══██╔══╝
██║ ██║ ██║██╔████╔██║██████╔╝██║ ██║██╔██╗ ██║█████╗ ██╔██╗ ██║ ██║
██║ ██║ ██║██║╚██╔╝██║██╔═══╝ ██║ ██║██║╚██╗██║██╔══╝ ██║╚██╗██║ ██║
╚██████╗╚██████╔╝██║ ╚═╝ ██║██║ ╚██████╔╝██║ ╚████║███████╗██║ ╚████║ ██║
╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═════╝ ╚═╝ ╚═══╝╚══════╝╚═╝ ╚═══╝ ╚═╝
██████╗ ██╗ ██╗██╗██╗ ██████╗ ███████╗██████╗
██╔══██╗██║ ██║██║██║ ██╔══██╗██╔════╝██╔══██╗
██████╔╝██║ ██║██║██║ ██║ ██║█████╗ ██████╔╝
██╔══██╗██║ ██║██║██║ ██║ ██║██╔══╝ ██╔══██╗
██████╔╝╚██████╔╝██║███████╗██████╔╝███████╗██║ ██║
╚═════╝ ╚═════╝ ╚═╝╚══════╝╚═════╝ ╚══════╝╚═╝ ╚═╝
```
> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder)

View File

@ -1,134 +1 @@
``` ###POWERREADME###
██████╗ ██████╗ ██╗ ██╗███████╗██████╗
██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗
██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝
██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
```
# final class Chapter (Details)
> namespace: **VDM\Joomla\GetBible\Watcher**
```uml
@startuml
class Chapter << (F,LightGreen) >> #Green {
# Chapters $chapters
# Verses $verses
+ __construct(Load $load, Insert $insert, ...)
+ sync(string $translation, int $book, ...) : bool
+ names(array $books) : bool
+ force(array $books) : bool
- chapter(string $translation, int $book, ...) : bool
- chapters(string $translation, int $book, ...) : bool
- verses(string $translation, int $book, ...) : bool
- update(string $translation, int $book, ...) : bool
- hash(string $hash) : bool
}
note right of Chapter::__construct
Constructor
since: 2.0.1
arguments:
Load $load
Insert $insert
Update $update
Chapters $chapters
Verses $verses
end note
note left of Chapter::sync
Sync the target being watched
since: 2.0.1
return: bool
arguments:
string $translation
int $book
int $chapter
end note
note right of Chapter::names
Update translation book chapter names
since: 2.0.1
return: bool
end note
note left of Chapter::force
Force book chapter sync
since: 2.0.1
return: bool
end note
note right of Chapter::chapter
Load the chapter numbers
since: 2.0.1
return: bool
arguments:
string $translation
int $book
int $chapter
end note
note left of Chapter::chapters
Trigger the update of the chapters of a translation-book
since: 2.0.1
return: bool
arguments:
string $translation
int $book
bool $updateHash = false
end note
note right of Chapter::verses
Load verses
since: 2.0.1
return: bool
arguments:
string $translation
int $book
int $chapter
end note
note left of Chapter::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 right of Chapter::hash
Trigger the update of a chapter hash value
since: 2.0.1
return: bool
end note
@enduml
```
---
```
██╗ ██████╗██████╗
██║██╔════╝██╔══██╗
██║██║ ██████╔╝
██ ██║██║ ██╔══██╗
╚█████╔╝╚██████╗██████╔╝
╚════╝ ╚═════╝╚═════╝
```
> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder)

View File

@ -9,423 +9,4 @@
* @license GNU General Public License version 2 or later; see LICENSE.txt * @license GNU General Public License version 2 or later; see LICENSE.txt
*/ */
namespace VDM\Joomla\GetBible\Watcher; ###POWERCODE###
use VDM\Joomla\GetBible\Database\Load;
use VDM\Joomla\GetBible\Database\Insert;
use VDM\Joomla\GetBible\Database\Update;
use VDM\Joomla\GetBible\Api\Chapters;
use VDM\Joomla\GetBible\Api\Verses;
use VDM\Joomla\GetBible\Abstraction\Watcher;
/**
* The GetBible Chapter Watcher
*
* @since 2.0.1
*/
final class Chapter extends Watcher
{
/**
* The Chapters class
*
* @var Chapters
* @since 2.0.1
*/
protected Chapters $chapters;
/**
* The Verses class
*
* @var Verses
* @since 2.0.1
*/
protected Verses $verses;
/**
* Constructor
*
* @param Load $load The load object.
* @param Insert $insert The insert object.
* @param Update $update The update 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,
Chapters $chapters,
Verses $verses)
{
// load the parent constructor
parent::__construct($load, $insert, $update);
$this->chapters = $chapters;
$this->verses = $verses;
// set the table
$this->table = 'chapter';
}
/**
* Sync the target being watched
*
* @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 sync(string $translation, int $book, int $chapter): bool
{
// load the target if not found
if ($this->chapter($translation, $book, $chapter)
&& $this->verses($translation, $book, $chapter))
{
if ($this->isNew() || $this->hold())
{
return true;
}
// get API hash value
$hash = $this->chapters->sha($translation, $book, $chapter);
// confirm hash has not changed
if (hash_equals($hash, $this->target->sha))
{
return $this->bump();
}
if ($this->update($translation, $book, $chapter)
&& $this->hash($hash))
{
return true;
}
}
return false;
}
/**
* Update translation book chapter names
*
* @param array $books The books ids.
*
* @return bool True on success
* @since 2.0.1
*/
public function names(array $books): bool
{
foreach ($books as $book)
{
if (($_book = $this->load->item(['id' => $book], 'book')) === null)
{
return false;
}
if (!$this->chapters($_book->abbreviation, $_book->nr))
{
return false;
}
}
return true;
}
/**
* Force book chapter sync
*
* @param array $books The books ids.
*
* @return bool True on success
* @since 2.0.1
*/
public function force(array $books): bool
{
foreach ($books as $book)
{
if (($_book = $this->load->item(['id' => $book], 'book')) === null)
{
return false;
}
if (($chapters = $this->load->items(
['abbreviation' => $_book->abbreviation, 'book_nr' => $_book->nr],
'chapter'
)) !== null)
{
foreach ($chapters as $chapter)
{
$this->update->row([
'id' => $chapter->id,
'created' => $this->past
], 'id', 'chapter');
}
}
}
return true;
}
/**
* Load the chapter numbers
*
* @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
*/
private function chapter(string $translation, int $book, int $chapter): bool
{
// check local value
if (($this->target = $this->load->item(
['abbreviation' => $translation, 'book_nr' => $book, 'chapter' => $chapter],
'chapter'
)) !== null)
{
return true;
}
// get all the books
$chapters = $this->chapters->list($translation, $book);
// check return data
if (!isset($chapters->{$chapter}) || !isset($chapters->{$chapter}->sha))
{
return false;
}
// add them to the database
$this->insert->items((array) $chapters, 'chapter');
// check local value
if (($this->target = $this->load->item(
['abbreviation' => $translation, 'book_nr' => $book, 'chapter' => $chapter],
'chapter'
)) !== null)
{
return true;
}
return false;
}
/**
* Trigger the update of the chapters of a translation-book
*
* @param string $translation The translation.
* @param int $book The book number.
* @param bool $updateHash The switch to update the hash.
*
* @return bool True if update was a success
* @since 2.0.1
*/
private function chapters(string $translation, int $book, bool $updateHash = false): bool
{
// load all the verses from the local database
$inserted = false;
// get verses from the API
if (($api = $this->chapters->list($translation, $book)) === null)
{
return false;
}
if (($chapters = $this->load->items(
['abbreviation' => $translation, 'book_nr' => $book],
'chapter'
)) !== null)
{
$update = [];
$insert = [];
$match = ['key' => 'book_nr', 'value' => ''];
// dynamic update all verse objects
foreach ($api as $chapter)
{
// hash must only update/set if
// verses are also updated/set
if (!$updateHash)
{
unset($chapter->sha);
}
// check if the verse exist
$match['value'] = (string) $chapter->book_nr;
if (($object = $this->getTarget($match, $chapters)) !== null)
{
$chapter->id = $object->id;
$chapter->modified = $this->today;
$update[] = $chapter;
}
else
{
$insert[] = $chapter;
}
}
// check if we have values to insert
if ($insert !== [])
{
$inserted = $this->insert->items($insert, 'chapter');
}
// update the local chapters
if ($update !== [] && $this->update->items($update, 'id', 'chapter'))
{
return true;
}
}
else
{
$inserted = $this->insert->items((array) $api, 'chapter');
}
return $inserted;
}
/**
* Load verses
*
* @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 (($text = $this->load->value(
['abbreviation' => $translation, 'book_nr' => $book, 'chapter' => $chapter, 'verse' => 1],
'text', '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; }
});
// add them to the database
$this->fresh = $this->insert->items((array) $verses->verses, 'verse');
return true;
}
/**
* 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
$inserted = false;
// get verses from the API
if (($api = $this->verses->get($translation, $book, $chapter)) === null)
{
return false;
}
if (($verses = $this->load->items(
['abbreviation' => $translation, 'book_nr' => $book, 'chapter' => $chapter],
'verse'
)) !== null)
{
$update = [];
$insert = [];
$match = ['key' => 'verse', 'value' => ''];
// dynamic update all verse objects
foreach ($api->verses as $verse)
{
// check if the verse exist
$match['value'] = (string) $verse->verse;
if ($verses !== null && ($object = $this->getTarget($match, $verses)) !== null)
{
$verse->id = $object->id;
$verse->modified = $this->today;
$update[] = $verse;
}
else
{
$insert[] = $verse;
}
}
// check if we have values to insert
if ($insert !== [])
{
$_insert = ['book_nr' => $book, 'abbreviation' => $translation];
array_walk($insert, function ($item, $key) use ($_insert) {
foreach ($_insert as $k => $v) { $item->$k = $v; }
});
$inserted = $this->insert->items($insert, 'verse');
}
// update the local verses
if ($update !== [] && $this->update->items($update, 'id', 'verse'))
{
return true;
}
}
else
{
$insert = ['book_nr' => $book, 'abbreviation' => $translation];
array_walk($api->verses, function ($item, $key) use ($insert) {
foreach ($insert as $k => $v) { $item->$k = $v; }
});
$inserted = $this->insert->items((array) $api->verses, 'verse');
}
return $inserted;
}
/**
* Trigger the update of a chapter hash value
*
* @param string $hash The API chapter hash value.
*
* @return bool True if update was a success
* @since 2.0.1
*/
private function hash(string $hash): bool
{
// load the chapter
$update = [];
$update['id'] = $this->target->id;
$update['sha'] = $hash;
$update['created'] = $this->today;
// update the local chapter
return $this->update->row($update, 'id', 'chapter');
}
}

View File

@ -1,400 +1 @@
/** ###CODEPOWER###
* The Chapters class
*
* @var Chapters
* @since 2.0.1
*/
protected Chapters $chapters;
/**
* The Verses class
*
* @var Verses
* @since 2.0.1
*/
protected Verses $verses;
/**
* Constructor
*
* @param Load $load The load object.
* @param Insert $insert The insert object.
* @param Update $update The update 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,
Chapters $chapters,
Verses $verses)
{
// load the parent constructor
parent::__construct($load, $insert, $update);
$this->chapters = $chapters;
$this->verses = $verses;
// set the table
$this->table = 'chapter';
}
/**
* Sync the target being watched
*
* @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 sync(string $translation, int $book, int $chapter): bool
{
// load the target if not found
if ($this->chapter($translation, $book, $chapter)
&& $this->verses($translation, $book, $chapter))
{
if ($this->isNew() || $this->hold())
{
return true;
}
// get API hash value
$hash = $this->chapters->sha($translation, $book, $chapter);
// confirm hash has not changed
if (hash_equals($hash, $this->target->sha))
{
return $this->bump();
}
if ($this->update($translation, $book, $chapter)
&& $this->hash($hash))
{
return true;
}
}
return false;
}
/**
* Update translation book chapter names
*
* @param array $books The books ids.
*
* @return bool True on success
* @since 2.0.1
*/
public function names(array $books): bool
{
foreach ($books as $book)
{
if (($_book = $this->load->item(['id' => $book], 'book')) === null)
{
return false;
}
if (!$this->chapters($_book->abbreviation, $_book->nr))
{
return false;
}
}
return true;
}
/**
* Force book chapter sync
*
* @param array $books The books ids.
*
* @return bool True on success
* @since 2.0.1
*/
public function force(array $books): bool
{
foreach ($books as $book)
{
if (($_book = $this->load->item(['id' => $book], 'book')) === null)
{
return false;
}
if (($chapters = $this->load->items(
['abbreviation' => $_book->abbreviation, 'book_nr' => $_book->nr],
'chapter'
)) !== null)
{
foreach ($chapters as $chapter)
{
$this->update->row([
'id' => $chapter->id,
'created' => $this->past
], 'id', 'chapter');
}
}
}
return true;
}
/**
* Load the chapter numbers
*
* @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
*/
private function chapter(string $translation, int $book, int $chapter): bool
{
// check local value
if (($this->target = $this->load->item(
['abbreviation' => $translation, 'book_nr' => $book, 'chapter' => $chapter],
'chapter'
)) !== null)
{
return true;
}
// get all the books
$chapters = $this->chapters->list($translation, $book);
// check return data
if (!isset($chapters->{$chapter}) || !isset($chapters->{$chapter}->sha))
{
return false;
}
// add them to the database
$this->insert->items((array) $chapters, 'chapter');
// check local value
if (($this->target = $this->load->item(
['abbreviation' => $translation, 'book_nr' => $book, 'chapter' => $chapter],
'chapter'
)) !== null)
{
return true;
}
return false;
}
/**
* Trigger the update of the chapters of a translation-book
*
* @param string $translation The translation.
* @param int $book The book number.
* @param bool $updateHash The switch to update the hash.
*
* @return bool True if update was a success
* @since 2.0.1
*/
private function chapters(string $translation, int $book, bool $updateHash = false): bool
{
// load all the verses from the local database
$inserted = false;
// get verses from the API
if (($api = $this->chapters->list($translation, $book)) === null)
{
return false;
}
if (($chapters = $this->load->items(
['abbreviation' => $translation, 'book_nr' => $book],
'chapter'
)) !== null)
{
$update = [];
$insert = [];
$match = ['key' => 'book_nr', 'value' => ''];
// dynamic update all verse objects
foreach ($api as $chapter)
{
// hash must only update/set if
// verses are also updated/set
if (!$updateHash)
{
unset($chapter->sha);
}
// check if the verse exist
$match['value'] = (string) $chapter->book_nr;
if (($object = $this->getTarget($match, $chapters)) !== null)
{
$chapter->id = $object->id;
$chapter->modified = $this->today;
$update[] = $chapter;
}
else
{
$insert[] = $chapter;
}
}
// check if we have values to insert
if ($insert !== [])
{
$inserted = $this->insert->items($insert, 'chapter');
}
// update the local chapters
if ($update !== [] && $this->update->items($update, 'id', 'chapter'))
{
return true;
}
}
else
{
$inserted = $this->insert->items((array) $api, 'chapter');
}
return $inserted;
}
/**
* Load verses
*
* @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 (($text = $this->load->value(
['abbreviation' => $translation, 'book_nr' => $book, 'chapter' => $chapter, 'verse' => 1],
'text', '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; }
});
// add them to the database
$this->fresh = $this->insert->items((array) $verses->verses, 'verse');
return true;
}
/**
* 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
$inserted = false;
// get verses from the API
if (($api = $this->verses->get($translation, $book, $chapter)) === null)
{
return false;
}
if (($verses = $this->load->items(
['abbreviation' => $translation, 'book_nr' => $book, 'chapter' => $chapter],
'verse'
)) !== null)
{
$update = [];
$insert = [];
$match = ['key' => 'verse', 'value' => ''];
// dynamic update all verse objects
foreach ($api->verses as $verse)
{
// check if the verse exist
$match['value'] = (string) $verse->verse;
if ($verses !== null && ($object = $this->getTarget($match, $verses)) !== null)
{
$verse->id = $object->id;
$verse->modified = $this->today;
$update[] = $verse;
}
else
{
$insert[] = $verse;
}
}
// check if we have values to insert
if ($insert !== [])
{
$_insert = ['book_nr' => $book, 'abbreviation' => $translation];
array_walk($insert, function ($item, $key) use ($_insert) {
foreach ($_insert as $k => $v) { $item->$k = $v; }
});
$inserted = $this->insert->items($insert, 'verse');
}
// update the local verses
if ($update !== [] && $this->update->items($update, 'id', 'verse'))
{
return true;
}
}
else
{
$insert = ['book_nr' => $book, 'abbreviation' => $translation];
array_walk($api->verses, function ($item, $key) use ($insert) {
foreach ($insert as $k => $v) { $item->$k = $v; }
});
$inserted = $this->insert->items((array) $api->verses, 'verse');
}
return $inserted;
}
/**
* Trigger the update of a chapter hash value
*
* @param string $hash The API chapter hash value.
*
* @return bool True if update was a success
* @since 2.0.1
*/
private function hash(string $hash): bool
{
// load the chapter
$update = [];
$update['id'] = $this->target->id;
$update['sha'] = $hash;
$update['created'] = $this->today;
// update the local chapter
return $this->update->row($update, 'id', 'chapter');
}

View File

@ -1,39 +1 @@
{ ###POWERLINKER###
"add_head": "0",
"add_licensing_template": "2",
"extends": "37e36c41-16a7-4c5d-972c-99acad5fd0b1",
"guid": "07d3888a-5f35-4ba7-977f-fb2f5cf99061",
"implements": null,
"load_selection": null,
"name": "Chapter",
"power_version": "1.0.0",
"system_name": "Joomla.GetBible.Watcher.Chapter",
"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": "a752e4b2-9b5e-4188-8d33-3799c46d5119",
"as": "default"
},
"use_selection4": {
"use": "afa508bf-78f8-4616-97cc-f2809584c086",
"as": "default"
}
},
"namespace": "VDM\\Joomla\\GetBible\\Watcher.Chapter",
"description": "The GetBible Chapter 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": "",
"composer": ""
}

View File

@ -1,53 +1 @@
``` ###POWERREADME###
██████╗ ██████╗ ██╗ ██╗███████╗██████╗
██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗
██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝
██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
```
# 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)

View File

@ -9,69 +9,4 @@
* @license GNU General Public License version 2 or later; see LICENSE.txt * @license GNU General Public License version 2 or later; see LICENSE.txt
*/ */
namespace VDM\Joomla\GetBible\Service; ###POWERCODE###
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')
);
}
}

View File

@ -1,48 +1 @@
/** ###CODEPOWER###
* 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')
);
}

View File

@ -1,30 +1 @@
{ ###POWERLINKER###
"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": ""
}

View File

@ -1,54 +1 @@
``` ###POWERREADME###
██████╗ ██████╗ ██╗ ██╗███████╗██████╗
██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗
██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝
██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
```
# 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)

View File

@ -9,78 +9,4 @@
* @license GNU General Public License version 2 or later; see LICENSE.txt * @license GNU General Public License version 2 or later; see LICENSE.txt
*/ */
namespace VDM\Joomla\GetBible; ###POWERCODE###
use Joomla\DI\Container;
use VDM\Joomla\GetBible\Service\Api;
use VDM\Joomla\GetBible\Service\Utilities;
use VDM\Joomla\GetBible\Service\Watcher;
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 Watcher())
->registerServiceProvider(new App())
->registerServiceProvider(new Model())
->registerServiceProvider(new Database());
}
}

View File

@ -1,53 +1 @@
/** ###CODEPOWER###
* 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 Watcher())
->registerServiceProvider(new App())
->registerServiceProvider(new Model())
->registerServiceProvider(new Database());
}

View File

@ -1,45 +1 @@
{ ###POWERLINKER###
"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_selection5": {
"use": "c5077cd8-b042-4295-99cf-3a5ba2af7dce",
"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": ""
}

View File

@ -1,65 +1 @@
``` ###POWERREADME###
██████╗ ██████╗ ██╗ ██╗███████╗██████╗
██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗
██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝
██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
```
# final class Scripture (Details)
> namespace: **VDM\Joomla\GetBible\Data**
```uml
@startuml
class Scripture << (F,LightGreen) >> #Green {
# Translation $translation
# Book $book
# Chapter $chapter
# Verse $verse
# Word $word
# ?object $scripture
+ __construct(Translation $translation, Book $book, ...)
+ get(string $key, mixed $default = null) : mixed
- getScripture() : object
}
note right of Scripture::__construct
Constructor
since: 2.0.1
arguments:
Translation $translation
Book $book
Chapter $chapter
Verse $verse
Word $word
end note
note right of Scripture::get
Get the Open AI response
since: 2.0.1
return: mixed
end note
note right of Scripture::getScripture
Get all related scripture values
since: 2.0.1
return: object
end note
@enduml
```
---
```
██╗ ██████╗██████╗
██║██╔════╝██╔══██╗
██║██║ ██████╔╝
██ ██║██║ ██╔══██╗
╚█████╔╝╚██████╗██████╔╝
╚════╝ ╚═════╝╚═════╝
```
> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder)

View File

@ -9,146 +9,4 @@
* @license GNU General Public License version 2 or later; see LICENSE.txt * @license GNU General Public License version 2 or later; see LICENSE.txt
*/ */
namespace VDM\Joomla\GetBible\Data; ###POWERCODE###
use VDM\Joomla\GetBible\Data\Translation;
use VDM\Joomla\GetBible\Data\Book;
use VDM\Joomla\GetBible\Data\Chapter;
use VDM\Joomla\GetBible\Data\Verse;
use VDM\Joomla\GetBible\Data\Word;
/**
* The GetBible Scripture
*
* @since 2.0.1
*/
final class Scripture
{
/**
* The Translation class
*
* @var Translation
* @since 2.0.1
*/
protected Translation $translation;
/**
* The Book class
*
* @var Book
* @since 2.0.1
*/
protected Book $book;
/**
* The Chapter class
*
* @var Chapter
* @since 2.0.1
*/
protected Chapter $chapter;
/**
* The Verse class
*
* @var Verse
* @since 2.0.1
*/
protected Verse $verse;
/**
* The Word class
*
* @var Word
* @since 2.0.1
*/
protected Word $word;
/**
* The Scripture object
*
* @var object
* @since 2.0.1
*/
protected ?object $scripture;
/**
* Constructor
*
* @param Translation $translation The translation object.
* @param Book $book The book object.
* @param Chapter $chapter The chapter object.
* @param Verse $verse The verse object.
* @param Word $word The word object.
*
* @since 2.0.1
*/
public function __construct(
Translation $translation,
Book $book,
Chapter $chapter,
Verse $verse,
Word $word)
{
$this->translation = $translation;
$this->book = $book;
$this->chapter = $chapter;
$this->verse = $verse;
$this->word = $word;
}
/**
* Get the Open AI response
*
* @param string $key The value key.
* @param mixed $default The default value.
*
* @return mixed Scripture Values
* @since 2.0.1
*/
public function get(string $key, $default = null)
{
if (empty($this->scripture))
{
$this->scripture = $this->getScripture();
}
return $this->scripture->{$key} ?? $default;
}
/**
* Get all related scripture values
*
* @return object Object of Scripture Values
* @since 2.0.1
*/
private function getScripture(): object
{
/**
* do not change these keys !!!
* this is an easy mapping
* so called bad practice
* that we use to simplify
* access to these values
*/
return (object) [
'translation_name' => $this->translation->getName(),
'translation_language' => $this->translation->getLanguage(),
'translation_lcsh' => $this->translation->getLcsh(),
'translation_abbreviation' => $this->translation->getAbbreviation(),
'book_number' => $this->book->getNumber(),
'book_name' => $this->book->getName(),
'chapter_number' => $this->chapter->getNumber(),
'chapter_name' => $this->chapter->getName(),
'chapter_text' => $this->chapter->getText(),
'verse_number' => $this->verse->getNumber(),
'verse_name' => $this->verse->getName(),
'verse_text' => $this->verse->getText(),
'selected_word_number' => $this->word->getNumber(),
'selected_word_text' => $this->word->getText()
];
}
}

View File

@ -1,124 +1 @@
/** ###CODEPOWER###
* The Translation class
*
* @var Translation
* @since 2.0.1
*/
protected Translation $translation;
/**
* The Book class
*
* @var Book
* @since 2.0.1
*/
protected Book $book;
/**
* The Chapter class
*
* @var Chapter
* @since 2.0.1
*/
protected Chapter $chapter;
/**
* The Verse class
*
* @var Verse
* @since 2.0.1
*/
protected Verse $verse;
/**
* The Word class
*
* @var Word
* @since 2.0.1
*/
protected Word $word;
/**
* The Scripture object
*
* @var object
* @since 2.0.1
*/
protected ?object $scripture;
/**
* Constructor
*
* @param Translation $translation The translation object.
* @param Book $book The book object.
* @param Chapter $chapter The chapter object.
* @param Verse $verse The verse object.
* @param Word $word The word object.
*
* @since 2.0.1
*/
public function __construct(
Translation $translation,
Book $book,
Chapter $chapter,
Verse $verse,
Word $word)
{
$this->translation = $translation;
$this->book = $book;
$this->chapter = $chapter;
$this->verse = $verse;
$this->word = $word;
}
/**
* Get the Open AI response
*
* @param string $key The value key.
* @param mixed $default The default value.
*
* @return mixed Scripture Values
* @since 2.0.1
*/
public function get(string $key, $default = null)
{
if (empty($this->scripture))
{
$this->scripture = $this->getScripture();
}
return $this->scripture->{$key} ?? $default;
}
/**
* Get all related scripture values
*
* @return object Object of Scripture Values
* @since 2.0.1
*/
private function getScripture(): object
{
/**
* do not change these keys !!!
* this is an easy mapping
* so called bad practice
* that we use to simplify
* access to these values
*/
return (object) [
'translation_name' => $this->translation->getName(),
'translation_language' => $this->translation->getLanguage(),
'translation_lcsh' => $this->translation->getLcsh(),
'translation_abbreviation' => $this->translation->getAbbreviation(),
'book_number' => $this->book->getNumber(),
'book_name' => $this->book->getName(),
'chapter_number' => $this->chapter->getNumber(),
'chapter_name' => $this->chapter->getName(),
'chapter_text' => $this->chapter->getText(),
'verse_number' => $this->verse->getNumber(),
'verse_name' => $this->verse->getName(),
'verse_text' => $this->verse->getText(),
'selected_word_number' => $this->word->getNumber(),
'selected_word_text' => $this->word->getText()
];
}

View File

@ -1,39 +1 @@
{ ###POWERLINKER###
"add_head": "0",
"add_licensing_template": "2",
"extends": "0",
"guid": "17d87374-2953-4d6c-9fdd-4220d6ad1564",
"implements": null,
"load_selection": null,
"name": "Scripture",
"power_version": "1.0.0",
"system_name": "Joomla.GetBible.Data.Scripture",
"type": "final class",
"use_selection": {
"use_selection0": {
"use": "c4098e1a-46dd-4d60-9277-b3668a09edc8",
"as": "default"
},
"use_selection1": {
"use": "fa776320-65f8-4198-a517-58cd94b3b7b7",
"as": "default"
},
"use_selection2": {
"use": "4a4c786d-51f4-421a-aa61-262dfd071880",
"as": "default"
},
"use_selection3": {
"use": "e3798c7e-aae1-4e38-ba78-6018ce94630b",
"as": "default"
},
"use_selection4": {
"use": "899551ac-943e-4f81-becd-7e15c41f1081",
"as": "default"
}
},
"namespace": "VDM\\Joomla\\GetBible\\Data.Scripture",
"description": "The GetBible 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": ""
}

View File

@ -1,125 +1 @@
``` ###POWERREADME###
██████╗ ██████╗ ██╗ ██╗███████╗██████╗
██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗
██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝
██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
```
# final class Tagged (Details)
> namespace: **VDM\Joomla\GetBible**
```uml
@startuml
class Tagged << (F,LightGreen) >> #Green {
# Load $load
# Insert $insert
# Update $update
# Linker $linker
# Registry $params
# CMSApplication $app
+ __construct(Load $load, Insert $insert, ...)
+ set(string $translation, int $book, ...) : ?array
+ delete(string $tagged) : ?array
- getByGuid(string $guid) : ?object
- get(string $linker, int $book, ...) : ?object
- create(string $linker, string $translation, ...) : bool
- createForLinker(string $linker, object $tagged, ...) : bool
}
note right of Tagged::__construct
Constructor
since: 2.0.1
arguments:
Load $load
Insert $insert
Update $update
Linker $linker
?Registry $params = null
?CMSApplication $app = null
end note
note right of Tagged::set
Set a tagged verse
since: 2.0.1
return: ?array
arguments:
string $translation
int $book
int $chapter
int $verse
string $tag
end note
note right of Tagged::delete
Delete a tagged verse
since: 2.0.1
return: ?array
end note
note right of Tagged::getByGuid
Get a tagged verse
since: 2.0.1
return: ?object
end note
note right of Tagged::get
Get a tagged verse
since: 2.0.1
return: ?object
arguments:
string $linker
int $book
int $chapter
int $verse
string $tag
end note
note right of Tagged::create
Create a Tagged verse
since: 2.0.1
return: bool
arguments:
string $linker
string $translation
int $book
int $chapter
int $verse
string $tag
end note
note right of Tagged::createForLinker
Create a Tagged verse for a linker using a system tagged verse
since: 2.0.1
return: bool
arguments:
string $linker
object $tagged
int $published = -2
end note
@enduml
```
---
```
██╗ ██████╗██████╗
██║██╔════╝██╔══██╗
██║██║ ██████╔╝
██ ██║██║ ██╔══██╗
╚█████╔╝╚██████╗██████╔╝
╚════╝ ╚═════╝╚═════╝
```
> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder)

View File

@ -9,356 +9,4 @@
* @license GNU General Public License version 2 or later; see LICENSE.txt * @license GNU General Public License version 2 or later; see LICENSE.txt
*/ */
namespace VDM\Joomla\GetBible; ###POWERCODE###
use Joomla\Registry\Registry;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Application\CMSApplication;
use Joomla\CMS\Factory;
use VDM\Joomla\GetBible\Database\Load;
use VDM\Joomla\GetBible\Database\Insert;
use VDM\Joomla\GetBible\Database\Update;
use VDM\Joomla\GetBible\Linker;
use VDM\Joomla\Utilities\GuidHelper;
use VDM\Joomla\Utilities\Component\Helper;
/**
* The GetBible Tagged
*
* @since 2.0.1
*/
final class Tagged
{
/**
* 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 Linker class
*
* @var Linker
* @since 2.0.1
*/
protected Linker $linker;
/**
* The Registry class
*
* @var Registry
* @since 2.0.1
*/
protected Registry $params;
/**
* Application object.
*
* @var CMSApplication
* @since 3.2.0
**/
protected CMSApplication $app;
/**
* Constructor
*
* @param Load $load The load object.
* @param Insert $insert The insert object.
* @param Update $update The update object.
* @param Linker $linker The linker object.
* @param Registry|null $params The params object.
* @param CMSApplication|null $app The app object.
*
* @since 2.0.1
*/
public function __construct(
Load $load,
Insert $insert,
Update $update,
Linker $linker,
?Registry $params = null,
?CMSApplication $app = null)
{
$this->load = $load;
$this->insert = $insert;
$this->update = $update;
$this->linker = $linker;
$this->params = $params ?: Helper::getParams('com_getbible');
$this->app = $app ?: Factory::getApplication();
}
/**
* Set a tagged verse
*
* @param string $translation The translation in which the note is made
* @param int $book The book in which the note is made
* @param int $chapter The chapter in which the note is made
* @param int $verse The verse where the note is made
* @param string $tag The tag being added
*
* @return array|null Array of the tagged values on success
* @since 2.0.1
**/
public function set(
string $translation,
int $book,
int $chapter,
int $verse,
string $tag
): ?array
{
// make sure the linker has access
if (($linker = $this->linker->get()) === null)
{
return [
'error' => Text::_("COM_GETBIBLE_WITHOUT_SELECTING_THE_CORRECT_FAVOURITE_VERSEBR_YOU_CANT_PERFORM_THE_INITIAL_ACTION"),
'access_required' => true
];
}
// make sure the tag is active
if (($published = GuidHelper::item($tag, 'tag', 'a.published', 'getbible')) === null
|| $published != 1)
{
return [
'error' => Text::_('COM_GETBIBLE_THE_TAG_SELECTED_IS_NOT_ACTIVE_PLEASE_SELECT_AN_ACTIVE_TAG')
];
}
// get tagged verse if it exist
if (($tagged = $this->get($linker, $book, $chapter, $verse, $tag)) !== null)
{
// publish if not published
if ($tagged->published != 1 && !$this->update->value(1, 'published', $tagged->id, 'id', 'tagged_verse'))
{
return [
'error' => Text::_('COM_GETBIBLE_TAGGED_VERSE_ALREADY_EXIST_BUT_COULD_NOT_BE_REACTIVATED')
];
}
$tagged->published = 1;
$tagged->success = Text::_('COM_GETBIBLE_THE_VERSE_WAS_SUCCESSFULLY_TAGGED');
return (array) $tagged;
}
// create a new tagged verse
elseif ($this->create($linker, $translation, $book, $chapter, $verse, $tag)
&& ($tagged = $this->get($linker, $book, $chapter, $verse, $tag)) !== null)
{
$tagged->success = Text::_('COM_GETBIBLE_THE_VERSE_WAS_SUCCESSFULLY_TAGGED');
return (array) $tagged;
}
return null;
}
/**
* Delete a tagged verse
*
* @param string $tagged The tagged verse GUID value
*
* @return array|null True on success
* @since 2.0.1
**/
public function delete(
string $tagged
): ?array
{
// make sure the linker has access
if (($linker = $this->linker->get()) === null)
{
return [
'error' => Text::_("COM_GETBIBLE_WITHOUT_SELECTING_THE_CORRECT_FAVOURITE_VERSEBR_YOU_CANT_PERFORM_THE_INITIAL_ACTION"),
'access_required' => true
];
}
// make sure the linker has access to delete this tag
if (($id = $this->load->value(['linker' => $linker, 'guid' => $tagged], 'id', 'tagged_verse')) !== null && $id > 0
&& $this->update->value(-2, 'published', $id, 'id', 'tagged_verse'))
{
return [
'success' => Text::_('COM_GETBIBLE_THE_TAG_WAS_SUCCESSFULLY_REMOVED_FROM_THE_VERSE')
];
}
// lets check if this is a systems tag
if (($_tagged = $this->getByGuid($tagged)) !== null && $_tagged->access == 1)
{
if ($this->params->get('allow_untagging') == 1
&& $this->createForLinker($linker, $_tagged, -2))
{
return [
'success' => Text::_('COM_GETBIBLE_THE_TAG_WAS_SUCCESSFULLY_REMOVED_FROM_THE_VERSE')
];
}
return [
'notice' => Text::sprintf("COM_GETBIBLE_THIS_IS_A_GLOBAL_TAG_SET_BY_US_AT_BSB_FOR_YOUR_CONVENIENCE_WE_HOLD_THE_PRIVILEGE_TO_MODIFY_THESE_TAGS_IF_YOU_BELIEVE_ITS_SET_IN_ERROR_KINDLY_INFORM_US", $this->app->get('sitename'))
];
}
return [
'error' => Text::_('COM_GETBIBLE_THIS_TAG_COULD_NOT_BE_REMOVED')
];
}
/**
* Get a tagged verse
*
* @param string $guid The tagged verse GUID value
*
* @return object|null Object of the tagged verse values on success
* @since 2.0.1
**/
private function getByGuid(string $guid): ?object
{
// get tagged verse if it exist
if (($tagged = $this->load->item(['guid' => $guid], 'tagged_verse')) !== null)
{
return $tagged;
}
return null;
}
/**
* Get a tagged verse
*
* @param string $linker The linker GUID value
* @param int $book The book in which the note is made
* @param int $chapter The chapter in which the note is made
* @param int $verse The verse where the note is made
* @param string $tag The tag being added
*
* @return object|null Object of the tagged verse values on success
* @since 2.0.1
**/
private function get(
string $linker,
int $book,
int $chapter,
int $verse,
string $tag
): ?object
{
// get tagged verse if it exist
if (($tagged = $this->load->item([
'linker' => $linker,
'book_nr' => $book,
'chapter' => $chapter,
'verse' => $verse,
'tag' => $tag
], 'tagged_verse')) !== null)
{
$tagged->name = $this->load->value([
'guid' => $tag
], 'name', 'tag');
$tagged->description = $this->load->value([
'guid' => $tag
], 'description', 'tag');
return $tagged;
}
return null;
}
/**
* Create a Tagged verse
*
* @param string $linker The linker GUID value
* @param string $translation The translation in which the note is made
* @param int $book The book in which the note is made
* @param int $chapter The chapter in which the note is made
* @param int $verse The verse where the note is made
* @param string $tag The tag being added
*
* @return bool True on success
* @since 2.0.1
**/
private function create(
string $linker,
string $translation,
int $book,
int $chapter,
int $verse,
string $tag
): bool
{
$guid = (string) GuidHelper::get();
while (!GuidHelper::valid($guid, 'tagged_verse', 0, 'getbible'))
{
// must always be set
$guid = (string) GuidHelper::get();
}
return $this->insert->row([
'tag' => $tag,
'access' => 0,
'linker' => $linker,
'abbreviation' => $translation,
'book_nr' => $book,
'chapter' => $chapter,
'verse' => $verse,
'guid' => $guid
], 'tagged_verse');
}
/**
* Create a Tagged verse for a linker using a system tagged verse
*
* @param string $linker The linker GUID value
* @param object $tagged The system tagged verse
* @param int $published The new tagged verse state [default trashed = -2]
*
* @return bool True on success
* @since 2.0.1
**/
private function createForLinker(
string $linker,
object $tagged,
int $published = -2
): bool
{
$guid = (string) GuidHelper::get();
while (!GuidHelper::valid($guid, 'tagged_verse', 0, 'getbible'))
{
// must always be set
$guid = (string) GuidHelper::get();
}
return $this->insert->row([
'tag' => $tagged->tag,
'access' => 0,
'linker' => $linker,
'abbreviation' => $tagged->abbreviation,
'book_nr' => $tagged->book_nr,
'chapter' => $tagged->chapter,
'verse' => $tagged->verse,
'guid' => $guid,
'published' => $published
], 'tagged_verse');
}
}

View File

@ -1,329 +1 @@
/** ###CODEPOWER###
* 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 Linker class
*
* @var Linker
* @since 2.0.1
*/
protected Linker $linker;
/**
* The Registry class
*
* @var Registry
* @since 2.0.1
*/
protected Registry $params;
/**
* Application object.
*
* @var CMSApplication
* @since 3.2.0
**/
protected CMSApplication $app;
/**
* Constructor
*
* @param Load $load The load object.
* @param Insert $insert The insert object.
* @param Update $update The update object.
* @param Linker $linker The linker object.
* @param Registry|null $params The params object.
* @param CMSApplication|null $app The app object.
*
* @since 2.0.1
*/
public function __construct(
Load $load,
Insert $insert,
Update $update,
Linker $linker,
?Registry $params = null,
?CMSApplication $app = null)
{
$this->load = $load;
$this->insert = $insert;
$this->update = $update;
$this->linker = $linker;
$this->params = $params ?: Helper::getParams('com_[[[component]]]');
$this->app = $app ?: Factory::getApplication();
}
/**
* Set a tagged verse
*
* @param string $translation The translation in which the note is made
* @param int $book The book in which the note is made
* @param int $chapter The chapter in which the note is made
* @param int $verse The verse where the note is made
* @param string $tag The tag being added
*
* @return array|null Array of the tagged values on success
* @since 2.0.1
**/
public function set(
string $translation,
int $book,
int $chapter,
int $verse,
string $tag
): ?array
{
// make sure the linker has access
if (($linker = $this->linker->get()) === null)
{
return [
'error' => Text::_("Without selecting the correct favourite verse,<br />you can't perform the initial action."),
'access_required' => true
];
}
// make sure the tag is active
if (($published = GuidHelper::item($tag, 'tag', 'a.published', '[[[component]]]')) === null
|| $published != 1)
{
return [
'error' => Text::_('The tag selected is not active, please select an active tag.')
];
}
// get tagged verse if it exist
if (($tagged = $this->get($linker, $book, $chapter, $verse, $tag)) !== null)
{
// publish if not published
if ($tagged->published != 1 && !$this->update->value(1, 'published', $tagged->id, 'id', 'tagged_verse'))
{
return [
'error' => Text::_('Tagged verse already exist, but could not be reactivated.')
];
}
$tagged->published = 1;
$tagged->success = Text::_('The verse was successfully tagged.');
return (array) $tagged;
}
// create a new tagged verse
elseif ($this->create($linker, $translation, $book, $chapter, $verse, $tag)
&& ($tagged = $this->get($linker, $book, $chapter, $verse, $tag)) !== null)
{
$tagged->success = Text::_('The verse was successfully tagged.');
return (array) $tagged;
}
return null;
}
/**
* Delete a tagged verse
*
* @param string $tagged The tagged verse GUID value
*
* @return array|null True on success
* @since 2.0.1
**/
public function delete(
string $tagged
): ?array
{
// make sure the linker has access
if (($linker = $this->linker->get()) === null)
{
return [
'error' => Text::_("Without selecting the correct favourite verse,<br />you can't perform the initial action."),
'access_required' => true
];
}
// make sure the linker has access to delete this tag
if (($id = $this->load->value(['linker' => $linker, 'guid' => $tagged], 'id', 'tagged_verse')) !== null && $id > 0
&& $this->update->value(-2, 'published', $id, 'id', 'tagged_verse'))
{
return [
'success' => Text::_('The tag was successfully removed from the verse.')
];
}
// lets check if this is a systems tag
if (($_tagged = $this->getByGuid($tagged)) !== null && $_tagged->access == 1)
{
if ($this->params->get('allow_untagging') == 1
&& $this->createForLinker($linker, $_tagged, -2))
{
return [
'success' => Text::_('The tag was successfully removed from the verse.')
];
}
return [
'notice' => Text::sprintf("This is a global tag, set by us at <b>%s</b> for your convenience. We hold the privilege to modify these tags. If you believe it's set in error, kindly inform us.", $this->app->get('sitename'))
];
}
return [
'error' => Text::_('This tag could not be removed.')
];
}
/**
* Get a tagged verse
*
* @param string $guid The tagged verse GUID value
*
* @return object|null Object of the tagged verse values on success
* @since 2.0.1
**/
private function getByGuid(string $guid): ?object
{
// get tagged verse if it exist
if (($tagged = $this->load->item(['guid' => $guid], 'tagged_verse')) !== null)
{
return $tagged;
}
return null;
}
/**
* Get a tagged verse
*
* @param string $linker The linker GUID value
* @param int $book The book in which the note is made
* @param int $chapter The chapter in which the note is made
* @param int $verse The verse where the note is made
* @param string $tag The tag being added
*
* @return object|null Object of the tagged verse values on success
* @since 2.0.1
**/
private function get(
string $linker,
int $book,
int $chapter,
int $verse,
string $tag
): ?object
{
// get tagged verse if it exist
if (($tagged = $this->load->item([
'linker' => $linker,
'book_nr' => $book,
'chapter' => $chapter,
'verse' => $verse,
'tag' => $tag
], 'tagged_verse')) !== null)
{
$tagged->name = $this->load->value([
'guid' => $tag
], 'name', 'tag');
$tagged->description = $this->load->value([
'guid' => $tag
], 'description', 'tag');
return $tagged;
}
return null;
}
/**
* Create a Tagged verse
*
* @param string $linker The linker GUID value
* @param string $translation The translation in which the note is made
* @param int $book The book in which the note is made
* @param int $chapter The chapter in which the note is made
* @param int $verse The verse where the note is made
* @param string $tag The tag being added
*
* @return bool True on success
* @since 2.0.1
**/
private function create(
string $linker,
string $translation,
int $book,
int $chapter,
int $verse,
string $tag
): bool
{
$guid = (string) GuidHelper::get();
while (!GuidHelper::valid($guid, 'tagged_verse', 0, '[[[component]]]'))
{
// must always be set
$guid = (string) GuidHelper::get();
}
return $this->insert->row([
'tag' => $tag,
'access' => 0,
'linker' => $linker,
'abbreviation' => $translation,
'book_nr' => $book,
'chapter' => $chapter,
'verse' => $verse,
'guid' => $guid
], 'tagged_verse');
}
/**
* Create a Tagged verse for a linker using a system tagged verse
*
* @param string $linker The linker GUID value
* @param object $tagged The system tagged verse
* @param int $published The new tagged verse state [default trashed = -2]
*
* @return bool True on success
* @since 2.0.1
**/
private function createForLinker(
string $linker,
object $tagged,
int $published = -2
): bool
{
$guid = (string) GuidHelper::get();
while (!GuidHelper::valid($guid, 'tagged_verse', 0, '[[[component]]]'))
{
// must always be set
$guid = (string) GuidHelper::get();
}
return $this->insert->row([
'tag' => $tagged->tag,
'access' => 0,
'linker' => $linker,
'abbreviation' => $tagged->abbreviation,
'book_nr' => $tagged->book_nr,
'chapter' => $tagged->chapter,
'verse' => $tagged->verse,
'guid' => $guid,
'published' => $published
], 'tagged_verse');
}

View File

@ -1,43 +1 @@
{ ###POWERLINKER###
"add_head": "1",
"add_licensing_template": "2",
"extends": "0",
"guid": "2315a1c5-bcf6-401a-8d11-60f4d6d12dbb",
"implements": null,
"load_selection": null,
"name": "Tagged",
"power_version": "1.0.0",
"system_name": "Joomla.GetBible.Tagged",
"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": "36ab759f-7b42-4465-9c17-56ba1dd05f90",
"as": "default"
},
"use_selection4": {
"use": "9c513baf-b279-43fd-ae29-a585c8cbc4f0",
"as": "default"
},
"use_selection5": {
"use": "640b5352-fb09-425f-a26e-cd44eda03f15",
"as": "default"
}
},
"namespace": "VDM\\Joomla\\GetBible\\Tagged",
"description": "The GetBible Tagged\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\\Registry\\Registry;\r\nuse Joomla\\CMS\\Language\\Text;\r\nuse Joomla\\CMS\\Application\\CMSApplication;\r\nuse Joomla\\CMS\\Factory;",
"composer": ""
}

View File

@ -1,133 +1 @@
``` ###POWERREADME###
██████╗ ██████╗ ██╗ ██╗███████╗██████╗
██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗
██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝
██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
```
# class Data (Details)
> namespace: **VDM\Joomla\GetBible\Service**
```uml
@startuml
class Data #Gold {
+ register(Container $container) : void
+ getConfig(Container $container) : Config
+ getTable(Container $container) : Table
+ getString(Container $container) : StringHelper
+ getPrompt(Container $container) : Prompt
+ getScripture(Container $container) : Scripture
+ getTranslation(Container $container) : Translation
+ getBook(Container $container) : Book
+ getChapter(Container $container) : Chapter
+ getVerse(Container $container) : Verse
+ getWord(Container $container) : Word
+ getPlaceholders(Container $container) : Placeholders
+ getResponse(Container $container) : Response
}
note right of Data::register
Registers the service provider with a DI container.
since: 3.2.0
return: void
end note
note left of Data::getConfig
Get the Config class
since: 2.0.1
return: Config
end note
note right of Data::getTable
Get the Table class
since: 2.0.1
return: Table
end note
note left of Data::getString
Get the String Helper class
since: 3.2.0
return: StringHelper
end note
note right of Data::getPrompt
Get the Prompt class
since: 3.2.0
return: Prompt
end note
note left of Data::getScripture
Get the Scripture class
since: 3.2.0
return: Scripture
end note
note right of Data::getTranslation
Get the Translation class
since: 3.2.0
return: Translation
end note
note left of Data::getBook
Get the Book class
since: 3.2.0
return: Book
end note
note right of Data::getChapter
Get the Chapter class
since: 3.2.0
return: Chapter
end note
note left of Data::getVerse
Get the Verse class
since: 3.2.0
return: Verse
end note
note right of Data::getWord
Get the Word class
since: 3.2.0
return: Word
end note
note left of Data::getPlaceholders
Get the Placeholders class
since: 3.2.0
return: Placeholders
end note
note right of Data::getResponse
Get the Response class
since: 3.2.0
return: Response
end note
@enduml
```
---
```
██╗ ██████╗██████╗
██║██╔════╝██╔══██╗
██║██║ ██████╔╝
██ ██║██║ ██╔══██╗
╚█████╔╝╚██████╗██████╔╝
╚════╝ ╚═════╝╚═════╝
```
> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder)

View File

@ -9,268 +9,4 @@
* @license GNU General Public License version 2 or later; see LICENSE.txt * @license GNU General Public License version 2 or later; see LICENSE.txt
*/ */
namespace VDM\Joomla\GetBible\Service; ###POWERCODE###
use Joomla\DI\Container;
use Joomla\DI\ServiceProviderInterface;
use VDM\Joomla\GetBible\Openai\Config;
use VDM\Joomla\GetBible\Table;
use VDM\Joomla\GetBible\Utilities\StringHelper;
use VDM\Joomla\GetBible\Data\Scripture;
use VDM\Joomla\GetBible\Data\Translation;
use VDM\Joomla\GetBible\Data\Book;
use VDM\Joomla\GetBible\Data\Chapter;
use VDM\Joomla\GetBible\Data\Verse;
use VDM\Joomla\GetBible\Data\Word;
use VDM\Joomla\GetBible\Data\Prompt;
use VDM\Joomla\GetBible\Data\Placeholders;
use VDM\Joomla\GetBible\Data\Response;
/**
* The GetBible Data Service
*
* @since 3.2.0
*/
class Data 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(Config::class, 'GetBible.Config')
->share('GetBible.Config', [$this, 'getConfig'], true);
$container->alias(Table::class, 'GetBible.Table')
->share('GetBible.Table', [$this, 'getTable'], true);
$container->alias(StringHelper::class, 'GetBible.Utilities.String')
->share('GetBible.Utilities.String', [$this, 'getString'], true);
$container->alias(Prompt::class, 'GetBible.Prompt')
->share('GetBible.Prompt', [$this, 'getPrompt'], true);
$container->alias(Scripture::class, 'GetBible.Scripture')
->share('GetBible.Scripture', [$this, 'getScripture'], true);
$container->alias(Translation::class, 'GetBible.Translation')
->share('GetBible.Translation', [$this, 'getTranslation'], true);
$container->alias(Book::class, 'GetBible.Book')
->share('GetBible.Book', [$this, 'getBook'], true);
$container->alias(Chapter::class, 'GetBible.Chapter')
->share('GetBible.Chapter', [$this, 'getChapter'], true);
$container->alias(Verse::class, 'GetBible.Verse')
->share('GetBible.Verse', [$this, 'getVerse'], true);
$container->alias(Word::class, 'GetBible.Word')
->share('GetBible.Word', [$this, 'getWord'], true);
$container->alias(Placeholders::class, 'GetBible.Placeholders')
->share('GetBible.Placeholders', [$this, 'getPlaceholders'], true);
$container->alias(Response::class, 'GetBible.Response')
->share('GetBible.Response', [$this, 'getResponse'], 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 String Helper class
*
* @param Container $container The DI container.
*
* @return StringHelper
* @since 3.2.0
*/
public function getString(Container $container): StringHelper
{
return new StringHelper();
}
/**
* Get the Prompt class
*
* @param Container $container The DI container.
*
* @return Prompt
* @since 3.2.0
*/
public function getPrompt(Container $container): Prompt
{
return new Prompt(
$container->get('GetBible.Load'),
$container->get('GetBible.Config')
);
}
/**
* Get the Scripture class
*
* @param Container $container The DI container.
*
* @return Scripture
* @since 3.2.0
*/
public function getScripture(Container $container): Scripture
{
return new Scripture(
$container->get('GetBible.Translation'),
$container->get('GetBible.Book'),
$container->get('GetBible.Chapter'),
$container->get('GetBible.Verse'),
$container->get('GetBible.Word'),
);
}
/**
* Get the Translation class
*
* @param Container $container The DI container.
*
* @return Translation
* @since 3.2.0
*/
public function getTranslation(Container $container): Translation
{
return new Translation(
$container->get('GetBible.Load'),
$container->get('GetBible.Config')
);
}
/**
* Get the Book class
*
* @param Container $container The DI container.
*
* @return Book
* @since 3.2.0
*/
public function getBook(Container $container): Book
{
return new Book(
$container->get('GetBible.Load'),
$container->get('GetBible.Config')
);
}
/**
* Get the Chapter class
*
* @param Container $container The DI container.
*
* @return Chapter
* @since 3.2.0
*/
public function getChapter(Container $container): Chapter
{
return new Chapter(
$container->get('GetBible.Load'),
$container->get('GetBible.Config')
);
}
/**
* Get the Verse class
*
* @param Container $container The DI container.
*
* @return Verse
* @since 3.2.0
*/
public function getVerse(Container $container): Verse
{
return new Verse(
$container->get('GetBible.Chapter'),
$container->get('GetBible.Config'),
$container->get('GetBible.Prompt'),
$container->get('GetBible.Utilities.String')
);
}
/**
* Get the Word class
*
* @param Container $container The DI container.
*
* @return Word
* @since 3.2.0
*/
public function getWord(Container $container): Word
{
return new Word(
$container->get('GetBible.Verse'),
$container->get('GetBible.Config'),
$container->get('GetBible.Prompt')
);
}
/**
* Get the Placeholders class
*
* @param Container $container The DI container.
*
* @return Placeholders
* @since 3.2.0
*/
public function getPlaceholders(Container $container): Placeholders
{
return new Placeholders(
$container->get('GetBible.Scripture'),
$container->get('GetBible.Prompt')
);
}
/**
* 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(
$container->get('GetBible.Scripture'),
$container->get('GetBible.Prompt'),
$container->get('GetBible.Load'),
$container->get('GetBible.Config')
);
}
}

View File

@ -1,237 +1 @@
/** ###CODEPOWER###
* 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(Config::class, 'GetBible.Config')
->share('GetBible.Config', [$this, 'getConfig'], true);
$container->alias(Table::class, 'GetBible.Table')
->share('GetBible.Table', [$this, 'getTable'], true);
$container->alias(StringHelper::class, 'GetBible.Utilities.String')
->share('GetBible.Utilities.String', [$this, 'getString'], true);
$container->alias(Prompt::class, 'GetBible.Prompt')
->share('GetBible.Prompt', [$this, 'getPrompt'], true);
$container->alias(Scripture::class, 'GetBible.Scripture')
->share('GetBible.Scripture', [$this, 'getScripture'], true);
$container->alias(Translation::class, 'GetBible.Translation')
->share('GetBible.Translation', [$this, 'getTranslation'], true);
$container->alias(Book::class, 'GetBible.Book')
->share('GetBible.Book', [$this, 'getBook'], true);
$container->alias(Chapter::class, 'GetBible.Chapter')
->share('GetBible.Chapter', [$this, 'getChapter'], true);
$container->alias(Verse::class, 'GetBible.Verse')
->share('GetBible.Verse', [$this, 'getVerse'], true);
$container->alias(Word::class, 'GetBible.Word')
->share('GetBible.Word', [$this, 'getWord'], true);
$container->alias(Placeholders::class, 'GetBible.Placeholders')
->share('GetBible.Placeholders', [$this, 'getPlaceholders'], true);
$container->alias(Response::class, 'GetBible.Response')
->share('GetBible.Response', [$this, 'getResponse'], 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 String Helper class
*
* @param Container $container The DI container.
*
* @return StringHelper
* @since 3.2.0
*/
public function getString(Container $container): StringHelper
{
return new StringHelper();
}
/**
* Get the Prompt class
*
* @param Container $container The DI container.
*
* @return Prompt
* @since 3.2.0
*/
public function getPrompt(Container $container): Prompt
{
return new Prompt(
$container->get('GetBible.Load'),
$container->get('GetBible.Config')
);
}
/**
* Get the Scripture class
*
* @param Container $container The DI container.
*
* @return Scripture
* @since 3.2.0
*/
public function getScripture(Container $container): Scripture
{
return new Scripture(
$container->get('GetBible.Translation'),
$container->get('GetBible.Book'),
$container->get('GetBible.Chapter'),
$container->get('GetBible.Verse'),
$container->get('GetBible.Word'),
);
}
/**
* Get the Translation class
*
* @param Container $container The DI container.
*
* @return Translation
* @since 3.2.0
*/
public function getTranslation(Container $container): Translation
{
return new Translation(
$container->get('GetBible.Load'),
$container->get('GetBible.Config')
);
}
/**
* Get the Book class
*
* @param Container $container The DI container.
*
* @return Book
* @since 3.2.0
*/
public function getBook(Container $container): Book
{
return new Book(
$container->get('GetBible.Load'),
$container->get('GetBible.Config')
);
}
/**
* Get the Chapter class
*
* @param Container $container The DI container.
*
* @return Chapter
* @since 3.2.0
*/
public function getChapter(Container $container): Chapter
{
return new Chapter(
$container->get('GetBible.Load'),
$container->get('GetBible.Config')
);
}
/**
* Get the Verse class
*
* @param Container $container The DI container.
*
* @return Verse
* @since 3.2.0
*/
public function getVerse(Container $container): Verse
{
return new Verse(
$container->get('GetBible.Chapter'),
$container->get('GetBible.Config'),
$container->get('GetBible.Prompt'),
$container->get('GetBible.Utilities.String')
);
}
/**
* Get the Word class
*
* @param Container $container The DI container.
*
* @return Word
* @since 3.2.0
*/
public function getWord(Container $container): Word
{
return new Word(
$container->get('GetBible.Verse'),
$container->get('GetBible.Config'),
$container->get('GetBible.Prompt')
);
}
/**
* Get the Placeholders class
*
* @param Container $container The DI container.
*
* @return Placeholders
* @since 3.2.0
*/
public function getPlaceholders(Container $container): Placeholders
{
return new Placeholders(
$container->get('GetBible.Scripture'),
$container->get('GetBible.Prompt')
);
}
/**
* 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(
$container->get('GetBible.Scripture'),
$container->get('GetBible.Prompt'),
$container->get('GetBible.Load'),
$container->get('GetBible.Config')
);
}

View File

@ -1,70 +1 @@
{ ###POWERLINKER###
"add_head": "1",
"add_licensing_template": "2",
"extends": "0",
"guid": "3439e63b-d8f1-42ce-a765-60d56b1fbe21",
"implements": [
"-1"
],
"load_selection": null,
"name": "Data",
"power_version": "1.0.0",
"system_name": "Joomla.GetBible.Service.Data",
"type": "class",
"use_selection": {
"use_selection0": {
"use": "3af7864b-f1f3-491e-b16f-0504f890086d",
"as": "default"
},
"use_selection1": {
"use": "ff8d5fdb-2d1f-4178-bd18-a43b8efd1068",
"as": "default"
},
"use_selection2": {
"use": "a5b32737-207d-4cf6-b8ae-ee815612c3a0",
"as": "default"
},
"use_selection11": {
"use": "17d87374-2953-4d6c-9fdd-4220d6ad1564",
"as": "default"
},
"use_selection3": {
"use": "c4098e1a-46dd-4d60-9277-b3668a09edc8",
"as": "default"
},
"use_selection4": {
"use": "fa776320-65f8-4198-a517-58cd94b3b7b7",
"as": "default"
},
"use_selection5": {
"use": "4a4c786d-51f4-421a-aa61-262dfd071880",
"as": "default"
},
"use_selection6": {
"use": "e3798c7e-aae1-4e38-ba78-6018ce94630b",
"as": "default"
},
"use_selection7": {
"use": "899551ac-943e-4f81-becd-7e15c41f1081",
"as": "default"
},
"use_selection8": {
"use": "3f785d63-a592-463d-9f5f-b2b5a8edd561",
"as": "default"
},
"use_selection9": {
"use": "ba2151c0-8ffa-4a07-ba6e-93f135a3e9d5",
"as": "default"
},
"use_selection10": {
"use": "44c15b17-e096-47c0-8769-42ea9b692cb2",
"as": "default"
}
},
"namespace": "VDM\\Joomla\\GetBible\\Service.Data",
"description": "The GetBible Data 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": ""
}

View File

@ -1,204 +1 @@
``` ###POWERREADME###
██████╗ ██████╗ ██╗ ██╗███████╗██████╗
██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗
██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝
██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
```
# final class Linker (Details)
> namespace: **VDM\Joomla\GetBible**
```uml
@startuml
class Linker << (F,LightGreen) >> #Green {
# Load $load
# Insert $insert
# Update $update
# Session $session
# bool $trigger
+ __construct(Load $load, Insert $insert, ...)
+ share() : bool
+ get() : ?string
+ getNew() : string
+ active(bool $setup = true) : ?string
+ activeDetails(bool $setup = true) : ?array
+ valid(string $linker) : bool
+ authenticated(string $linker) : array
+ trigger(string $linker) : bool
+ set(string $linker) : bool
+ revokeSession(string $linker) : ?array
+ setName(string $name) : ?array
+ access(string $linker, string $pass, ...) : ?array
+ revoke(string $linker) : ?array
- hasAccess(string $linker, string $pass) : bool
- getPassGuid(string $linker, string $pass) : ?string
- getPassword(string $linker, string $pass) : ?object
- setLinker(string $linker) : bool
- setPassword(string $linker, string $pass) : bool
- getGuid(string $table) : string
}
note right of Linker::__construct
Constructor
since: 2.0.1
arguments:
Load $load
Insert $insert
Update $update
Session $session
end note
note left of Linker::share
The Share His Word Trigger
since: 2.0.1
return: bool
end note
note right of Linker::get
Get Linker that has Access
since: 2.0.1
return: ?string
end note
note left of Linker::getNew
Get GUID of a new Linker
since: 2.0.1
return: string
end note
note right of Linker::active
Get active Linker
since: 2.0.1
return: ?string
end note
note left of Linker::activeDetails
Get active Linker details
since: 2.0.1
return: ?array
end note
note right of Linker::valid
Check if a Linker is valid active linker
since: 2.0.1
return: bool
end note
note left of Linker::authenticated
Check if the linker is authenticated
since: 2.0.1
return: array
end note
note right of Linker::trigger
The Share His Word Trigger
since: 2.0.1
return: bool
end note
note left of Linker::set
Set Active Linker
since: 2.0.1
return: bool
end note
note right of Linker::revokeSession
Revoke Linker Session
since: 2.0.1
return: ?array
end note
note left of Linker::setName
Set a linker name
since: 2.0.1
return: ?array
end note
note right of Linker::access
Set Access
since: 2.0.1
return: ?array
arguments:
string $linker
string $pass
?string $oldPass
end note
note left of Linker::revoke
Revoke Access
since: 2.0.1
return: ?array
end note
note right of Linker::hasAccess
Has Access
since: 2.0.1
return: bool
end note
note left of Linker::getPassGuid
Get Password GUID
since: 2.0.1
return: ?string
end note
note right of Linker::getPassword
Get Password
since: 2.0.1
return: ?object
end note
note left of Linker::setLinker
Set Linker
since: 2.0.1
return: bool
end note
note right of Linker::setPassword
Set Password
since: 2.0.1
return: bool
end note
note left of Linker::getGuid
Get a GUID
since: 2.0.1
return: string
end note
@enduml
```
---
```
██╗ ██████╗██████╗
██║██╔════╝██╔══██╗
██║██║ ██████╔╝
██ ██║██║ ██╔══██╗
╚█████╔╝╚██████╗██████╔╝
╚════╝ ╚═════╝╚═════╝
```
> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder)

View File

@ -9,610 +9,4 @@
* @license GNU General Public License version 2 or later; see LICENSE.txt * @license GNU General Public License version 2 or later; see LICENSE.txt
*/ */
namespace VDM\Joomla\GetBible; ###POWERCODE###
use Joomla\CMS\User\UserHelper;
use Joomla\CMS\Language\Text;
use VDM\Joomla\GetBible\Database\Load;
use VDM\Joomla\GetBible\Database\Insert;
use VDM\Joomla\GetBible\Database\Update;
use VDM\Joomla\GetBible\Utilities\SessionHelper as Session;
use VDM\Joomla\Utilities\GuidHelper;
/**
* The GetBible Linker
*
* @since 2.0.1
*/
final class Linker
{
/**
* 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 Session class
*
* @var Session
* @since 2.0.1
*/
protected Session $session;
/**
* The Share His Word Trigger
*
* @var bool
* @since 2.0.1
*/
protected bool $trigger = false;
/**
* Constructor
*
* @param Load $load The load object.
* @param Insert $insert The insert object.
* @param Update $update The update object.
* @param Session $session The session object.
*
* @since 2.0.1
*/
public function __construct(
Load $load,
Insert $insert,
Update $update,
Session $session)
{
$this->load = $load;
$this->insert = $insert;
$this->update = $update;
$this->session = $session;
}
/**
* The Share His Word Trigger
*
* @return bool True on success
* @since 2.0.1
**/
public function share(): bool
{
return $this->trigger;
}
/**
* Get Linker that has Access
*
* @return string|null Linker GUID that has access
* @since 2.0.1
**/
public function get(): ?string
{
if (($linker = $this->session->get('getbible_active_linker_guid', null)) === null)
{
return null;
}
if (($access = $this->session->get("getbible_active_{$linker}", null)) === null
|| $access !== 'valid_access')
{
return null;
}
return $linker;
}
/**
* Get GUID of a new Linker
*
* @return string|null Linker GUID that is new
* @since 2.0.1
**/
public function getNew(): string
{
return $this->getGuid('linker');
}
/**
* Get active Linker
*
* @param bool $setup The setup switch
*
* @return string|null Linker GUID that has access
* @since 2.0.1
**/
public function active(bool $setup = true): ?string
{
if (($linker = $this->session->get('getbible_active_linker_guid', null)) !== null)
{
return $linker;
}
if ($setup)
{
$guid = $this->getGuid('linker');
$this->session->set('getbible_active_linker_guid', $guid);
return $guid;
}
return null;
}
/**
* Get active Linker details
*
* @param bool $setup The setup switch
*
* @return array|null Linker details
* @since 2.0.1
**/
public function activeDetails(bool $setup = true): ?array
{
if (($linker = $this->active($setup)) !== null)
{
// check if this is a valid linker (already set)
if (($name = $this->load->value(
['guid' => $linker, 'published' => 1],
'name', 'linker'
)) !== null)
{
return ['guid' => $linker, 'name' => $name, 'share' => $this->share()];
}
return ['guid' => $linker, 'name' => null, 'share' => null];
}
return null;
}
/**
* Check if a Linker is valid active linker
*
* @param string $linker The linker GUID value
*
* @return bool True if active valid linker
* @since 2.0.1
**/
public function valid(string $linker): bool
{
// is only valid if this linker has an active password
if (GuidHelper::valid($linker) && ($password_name = $this->load->value(
['linker' => $linker, 'published' => 1],
'name', 'password'
)) !== null)
{
return true;
}
return false;
}
/**
* Check if the linker is authenticated
*
* @param string $linker The linker GUID value
*
* @return array Linker authenticated message
* @since 2.0.1
**/
public function authenticated(string $linker): array
{
if (($access = $this->session->get("getbible_active_{$linker}", null)) === null
|| $access !== 'valid_access')
{
return ['error' => Text::_('COM_GETBIBLE_SESSION_NOT_ACTIVE')];
}
// get current session
$current = $this->session->get('getbible_active_linker_guid', null);
if (strcasecmp($linker, $current) == 0)
{
return ['success' => Text::_('COM_GETBIBLE_SESSION_ACTIVE'), 'status' => true];
}
return ['success' => Text::_('COM_GETBIBLE_SESSION_ACTIVE'), 'status' => false];
}
/**
* The Share His Word Trigger
*
* @param string $linker The linker GUID value
*
* @return bool True on success
* @since 2.0.1
**/
public function trigger(string $linker): bool
{
if (!$this->set($linker))
{
return false;
}
$this->trigger = true;
return true;
}
/**
* Set Active Linker
*
* @param string $linker The linker GUID value
*
* @return bool True on success
* @since 2.0.1
**/
public function set(string $linker): bool
{
if (!GuidHelper::valid($linker))
{
return false;
}
$this->session->set('getbible_active_linker_guid', $linker);
return true;
}
/**
* Revoke Linker Session
*
* @param string $linker The linker GUID value
*
* @return array|null The success or error details
* @since 2.0.1
**/
public function revokeSession(string $linker): ?array
{
// linker not valid GUID
if (!GuidHelper::valid($linker))
{
// hmm we can log this
return [
'error' => Text::_('COM_GETBIBLE_ACCESS_REVOKED')
];
}
if (($access = $this->session->get('getbible_active_linker_guid', null)) === null
|| $access !== $linker)
{
// hmm we can log this
return [
'success' => Text::_('COM_GETBIBLE_ACCESS_REVOKED')
];
}
$this->session->set('getbible_active_linker_guid', null);
return [
'success' => Text::_('COM_GETBIBLE_ACCESS_REVOKED')
];
}
/**
* Set a linker name
*
* @param string $name The linker name
*
* @return array|null Array on success
* @since 2.0.1
**/
public function setName(string $name): ?array
{
// make sure the linker has access
if (($linker = $this->get()) === null)
{
return [
'error' => Text::_("COM_GETBIBLE_WITHOUT_SELECTING_THE_CORRECT_FAVOURITE_VERSEBR_YOU_CANT_PERFORM_THE_INITIAL_ACTION"),
'access_required' => true
];
}
// set the name of this linker
if (!$this->update->value($name, 'name', $linker, 'guid', 'linker'))
{
return [
'error' => Text::_('COM_GETBIBLE_THE_NAME_COULD_NOT_BE_UPDATED')
];
}
return [
'guid' => $linker,
'name' => $name,
'success' => Text::_('COM_GETBIBLE_THE_NAME_HAS_BEEN_UPDATED')
];
}
/**
* Set Access
*
* @param string $linker The linker GUID value
* @param string $pass The linker pass value
* @param string|null $oldPass The linker old pass value
*
* @return array|null The success or error details
* @since 2.0.1
**/
public function access(string $linker, string $pass, ?string $oldPass): ?array
{
// trim all empty space
$pass = trim($pass);
// password to short
if (strlen($pass) <= 3)
{
return [
'error' => Text::_('COM_GETBIBLE_PASSWORD_TO_SHORT_USE_A_LONGER_PASSWORD')
];
}
// linker not valid GUID
elseif (!GuidHelper::valid($linker))
{
return [
'error' => Text::_('COM_GETBIBLE_INVALID_SESSION_KEY_VALUE')
];
}
// get trying attempt counter
$attempt = $this->session->get("getbible_attempt_{$linker}", 1);
if ($attempt >= 11)
{
return [
'error' => Text::_('COM_GETBIBLE_YOU_HAVE_BEEN_BLOCKED_YOU_WILL_NEED_TO_WAIT_ONE_DAY_BEFORE_TRYING_AGAIN_OR_CONTACT_SUPPORT')
];
}
// we log this, only 10 allowed
$attempt++;
$this->session->set("getbible_attempt_{$linker}", $attempt);
// get linker
if (($_linker = $this->load->item(['guid' => $linker],'linker')) !== null)
{
// publish the linker if needed
if ($_linker->published != 1 && $this->update->value(1, 'published', $_linker->id, 'id', 'linker'))
{
return [
'error' => Text::_('COM_GETBIBLE_ACCESS_ALREADY_EXIST_BUT_COULD_NOT_BE_REACTIVATED')
];
}
if (!empty($oldPass))
{
$oldPass = trim($oldPass);
if (($guid = $this->getPassGuid($linker, $oldPass)) === null)
{
return [
'error' => Text::_('COM_GETBIBLE_INCORRECT_FAVOURITE_VERSE_SELECTED')
];
}
if (!$this->setPassword($linker, $pass))
{
return [
'error' => Text::_('COM_GETBIBLE_FAVOURITE_VERSE_COULD_NOT_BE_CHANGED')
];
}
// unpublished the old pass word only if new password was set
$this->update->value(-2, 'published', $guid, 'guid', 'password');
}
elseif (!$this->hasAccess($linker, $pass))
{
return [
'error' => Text::_('COM_GETBIBLE_INCORRECT_FAVOURITE_VERSE_SELECTED')
];
}
}
elseif (!$this->setLinker($linker))
{
return [
'error' => Text::_('COM_GETBIBLE_SESSION_KEY_COULD_NOT_BE_STORED')
];
}
elseif (!$this->setPassword($linker, $pass))
{
return [
'error' => Text::_('COM_GETBIBLE_FAVOURITE_VERSE_COULD_NOT_BE_STORED')
];
}
elseif (($_linker = $this->load->item(['guid' => $linker],'linker')) === null)
{
return null;
}
$_linker->published = 1;
$_linker->success = Text::_('COM_GETBIBLE_FAVOURITE_VERSE_SUCCESSFULLY_SET');
// add to session
$this->session->set('getbible_active_linker_guid', $linker);
$this->session->set("getbible_active_{$linker}", 'valid_access');
$this->session->set("getbible_attempt_{$linker}", 1);
return (array) $_linker;
}
/**
* Revoke Access
*
* @param string $linker The linker GUID value
*
* @return array|null The success or error details
* @since 2.0.1
**/
public function revoke(string $linker): ?array
{
// linker not valid GUID
if (!GuidHelper::valid($linker))
{
// hmm we can log this
return [
'success' => Text::_('COM_GETBIBLE_ACCESS_REVOKED')
];
}
if (($access = $this->session->get("getbible_active_{$linker}", null)) === null
|| $access !== 'valid_access')
{
// hmm we can log this
return [
'success' => Text::_('COM_GETBIBLE_ACCESS_REVOKED')
];
}
$this->session->set("getbible_active_{$linker}", null);
return [
'success' => Text::_('COM_GETBIBLE_ACCESS_REVOKED')
];
}
/**
* Has Access
*
* @param string $linker The linker GUID value
* @param string $pass The linker pass value
*
* @return bool True on success
* @since 2.0.1
**/
private function hasAccess(string $linker, string $pass): bool
{
if (($password = $this->getPassword($linker, $pass)) !== null)
{
return true;
}
return false;
}
/**
* Get Password GUID
*
* @param string $linker The linker GUID value
* @param string $pass The linker pass value
*
* @return string|null The GUID on success
* @since 2.0.1
**/
private function getPassGuid(string $linker, string $pass): ?string
{
if (($password = $this->getPassword($linker, $pass)) !== null)
{
return $password->guid;
}
return null;
}
/**
* Get Password
*
* @param string $linker The linker GUID value
* @param string $pass The linker pass value
*
* @return object|null The GUID on success
* @since 2.0.1
**/
private function getPassword(string $linker, string $pass): ?object
{
if (strlen($pass) > 3 && ($passwords = $this->load->items(
['linker' => $linker, 'published' => 1],
'password'
)) !== null)
{
foreach ($passwords as $password)
{
if (UserHelper::verifyPassword($pass, $password->password))
{
return $password;
}
}
}
return null;
}
/**
* Set Linker
*
* @param string $linker The linker GUID value
*
* @return bool True on success
* @since 2.0.1
**/
private function setLinker(string $linker): bool
{
return $this->insert->row([
'name' => 'Default-Name',
'guid' => $linker
], 'linker');
}
/**
* Set Password
*
* @param string $linker The linker GUID value
* @param string $pass The linker pass value
*
* @return bool True on success
* @since 2.0.1
**/
private function setPassword(string $linker, string $pass): bool
{
if (strlen($pass) <= 3)
{
return false;
}
return $this->insert->row([
'name' => 'Favourite-Verse',
'linker' => $linker,
'password' => UserHelper::hashPassword($pass),
'guid' => $this->getGuid('password')
], 'password');
}
/**
* Get a GUID
*
* @param string $table The table its for
*
* @return string The GUID value
* @since 2.0.1
**/
private function getGuid(string $table): string
{
$guid = (string) GuidHelper::get();
while (!GuidHelper::valid($guid, $table, 0, 'getbible'))
{
// must always be set
$guid = (string) GuidHelper::get();
}
return $guid;
}
}

View File

@ -1,586 +1 @@
/** ###CODEPOWER###
* 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 Session class
*
* @var Session
* @since 2.0.1
*/
protected Session $session;
/**
* The Share His Word Trigger
*
* @var bool
* @since 2.0.1
*/
protected bool $trigger = false;
/**
* Constructor
*
* @param Load $load The load object.
* @param Insert $insert The insert object.
* @param Update $update The update object.
* @param Session $session The session object.
*
* @since 2.0.1
*/
public function __construct(
Load $load,
Insert $insert,
Update $update,
Session $session)
{
$this->load = $load;
$this->insert = $insert;
$this->update = $update;
$this->session = $session;
}
/**
* The Share His Word Trigger
*
* @return bool True on success
* @since 2.0.1
**/
public function share(): bool
{
return $this->trigger;
}
/**
* Get Linker that has Access
*
* @return string|null Linker GUID that has access
* @since 2.0.1
**/
public function get(): ?string
{
if (($linker = $this->session->get('getbible_active_linker_guid', null)) === null)
{
return null;
}
if (($access = $this->session->get("getbible_active_{$linker}", null)) === null
|| $access !== 'valid_access')
{
return null;
}
return $linker;
}
/**
* Get GUID of a new Linker
*
* @return string|null Linker GUID that is new
* @since 2.0.1
**/
public function getNew(): string
{
return $this->getGuid('linker');
}
/**
* Get active Linker
*
* @param bool $setup The setup switch
*
* @return string|null Linker GUID that has access
* @since 2.0.1
**/
public function active(bool $setup = true): ?string
{
if (($linker = $this->session->get('getbible_active_linker_guid', null)) !== null)
{
return $linker;
}
if ($setup)
{
$guid = $this->getGuid('linker');
$this->session->set('getbible_active_linker_guid', $guid);
return $guid;
}
return null;
}
/**
* Get active Linker details
*
* @param bool $setup The setup switch
*
* @return array|null Linker details
* @since 2.0.1
**/
public function activeDetails(bool $setup = true): ?array
{
if (($linker = $this->active($setup)) !== null)
{
// check if this is a valid linker (already set)
if (($name = $this->load->value(
['guid' => $linker, 'published' => 1],
'name', 'linker'
)) !== null)
{
return ['guid' => $linker, 'name' => $name, 'share' => $this->share()];
}
return ['guid' => $linker, 'name' => null, 'share' => null];
}
return null;
}
/**
* Check if a Linker is valid active linker
*
* @param string $linker The linker GUID value
*
* @return bool True if active valid linker
* @since 2.0.1
**/
public function valid(string $linker): bool
{
// is only valid if this linker has an active password
if (GuidHelper::valid($linker) && ($password_name = $this->load->value(
['linker' => $linker, 'published' => 1],
'name', 'password'
)) !== null)
{
return true;
}
return false;
}
/**
* Check if the linker is authenticated
*
* @param string $linker The linker GUID value
*
* @return array Linker authenticated message
* @since 2.0.1
**/
public function authenticated(string $linker): array
{
if (($access = $this->session->get("getbible_active_{$linker}", null)) === null
|| $access !== 'valid_access')
{
return ['error' => Text::_('Session not active.')];
}
// get current session
$current = $this->session->get('getbible_active_linker_guid', null);
if (strcasecmp($linker, $current) == 0)
{
return ['success' => Text::_('Session active.'), 'status' => true];
}
return ['success' => Text::_('Session active.'), 'status' => false];
}
/**
* The Share His Word Trigger
*
* @param string $linker The linker GUID value
*
* @return bool True on success
* @since 2.0.1
**/
public function trigger(string $linker): bool
{
if (!$this->set($linker))
{
return false;
}
$this->trigger = true;
return true;
}
/**
* Set Active Linker
*
* @param string $linker The linker GUID value
*
* @return bool True on success
* @since 2.0.1
**/
public function set(string $linker): bool
{
if (!GuidHelper::valid($linker))
{
return false;
}
$this->session->set('getbible_active_linker_guid', $linker);
return true;
}
/**
* Revoke Linker Session
*
* @param string $linker The linker GUID value
*
* @return array|null The success or error details
* @since 2.0.1
**/
public function revokeSession(string $linker): ?array
{
// linker not valid GUID
if (!GuidHelper::valid($linker))
{
// hmm we can log this
return [
'error' => Text::_('Access revoked.')
];
}
if (($access = $this->session->get('getbible_active_linker_guid', null)) === null
|| $access !== $linker)
{
// hmm we can log this
return [
'success' => Text::_('Access revoked.')
];
}
$this->session->set('getbible_active_linker_guid', null);
return [
'success' => Text::_('Access revoked.')
];
}
/**
* Set a linker name
*
* @param string $name The linker name
*
* @return array|null Array on success
* @since 2.0.1
**/
public function setName(string $name): ?array
{
// make sure the linker has access
if (($linker = $this->get()) === null)
{
return [
'error' => Text::_("Without selecting the correct favourite verse,<br />you can't perform the initial action."),
'access_required' => true
];
}
// set the name of this linker
if (!$this->update->value($name, 'name', $linker, 'guid', 'linker'))
{
return [
'error' => Text::_('The name could not be updated.')
];
}
return [
'guid' => $linker,
'name' => $name,
'success' => Text::_('The name has been updated.')
];
}
/**
* Set Access
*
* @param string $linker The linker GUID value
* @param string $pass The linker pass value
* @param string|null $oldPass The linker old pass value
*
* @return array|null The success or error details
* @since 2.0.1
**/
public function access(string $linker, string $pass, ?string $oldPass): ?array
{
// trim all empty space
$pass = trim($pass);
// password to short
if (strlen($pass) <= 3)
{
return [
'error' => Text::_('Password to short, use a longer password.')
];
}
// linker not valid GUID
elseif (!GuidHelper::valid($linker))
{
return [
'error' => Text::_('Invalid session key value.')
];
}
// get trying attempt counter
$attempt = $this->session->get("getbible_attempt_{$linker}", 1);
if ($attempt >= 11)
{
return [
'error' => Text::_('You have been blocked, you will need to wait one day before trying again, or contact support.')
];
}
// we log this, only 10 allowed
$attempt++;
$this->session->set("getbible_attempt_{$linker}", $attempt);
// get linker
if (($_linker = $this->load->item(['guid' => $linker],'linker')) !== null)
{
// publish the linker if needed
if ($_linker->published != 1 && $this->update->value(1, 'published', $_linker->id, 'id', 'linker'))
{
return [
'error' => Text::_('Access already exist, but could not be reactivated.')
];
}
if (!empty($oldPass))
{
$oldPass = trim($oldPass);
if (($guid = $this->getPassGuid($linker, $oldPass)) === null)
{
return [
'error' => Text::_('Incorrect favourite verse selected.')
];
}
if (!$this->setPassword($linker, $pass))
{
return [
'error' => Text::_('Favourite verse could not be changed.')
];
}
// unpublished the old pass word only if new password was set
$this->update->value(-2, 'published', $guid, 'guid', 'password');
}
elseif (!$this->hasAccess($linker, $pass))
{
return [
'error' => Text::_('Incorrect favourite verse selected.')
];
}
}
elseif (!$this->setLinker($linker))
{
return [
'error' => Text::_('Session key could not be stored.')
];
}
elseif (!$this->setPassword($linker, $pass))
{
return [
'error' => Text::_('Favourite verse could not be stored.')
];
}
elseif (($_linker = $this->load->item(['guid' => $linker],'linker')) === null)
{
return null;
}
$_linker->published = 1;
$_linker->success = Text::_('Favourite verse successfully set.');
// add to session
$this->session->set('getbible_active_linker_guid', $linker);
$this->session->set("getbible_active_{$linker}", 'valid_access');
$this->session->set("getbible_attempt_{$linker}", 1);
return (array) $_linker;
}
/**
* Revoke Access
*
* @param string $linker The linker GUID value
*
* @return array|null The success or error details
* @since 2.0.1
**/
public function revoke(string $linker): ?array
{
// linker not valid GUID
if (!GuidHelper::valid($linker))
{
// hmm we can log this
return [
'success' => Text::_('Access revoked.')
];
}
if (($access = $this->session->get("getbible_active_{$linker}", null)) === null
|| $access !== 'valid_access')
{
// hmm we can log this
return [
'success' => Text::_('Access revoked.')
];
}
$this->session->set("getbible_active_{$linker}", null);
return [
'success' => Text::_('Access revoked.')
];
}
/**
* Has Access
*
* @param string $linker The linker GUID value
* @param string $pass The linker pass value
*
* @return bool True on success
* @since 2.0.1
**/
private function hasAccess(string $linker, string $pass): bool
{
if (($password = $this->getPassword($linker, $pass)) !== null)
{
return true;
}
return false;
}
/**
* Get Password GUID
*
* @param string $linker The linker GUID value
* @param string $pass The linker pass value
*
* @return string|null The GUID on success
* @since 2.0.1
**/
private function getPassGuid(string $linker, string $pass): ?string
{
if (($password = $this->getPassword($linker, $pass)) !== null)
{
return $password->guid;
}
return null;
}
/**
* Get Password
*
* @param string $linker The linker GUID value
* @param string $pass The linker pass value
*
* @return object|null The GUID on success
* @since 2.0.1
**/
private function getPassword(string $linker, string $pass): ?object
{
if (strlen($pass) > 3 && ($passwords = $this->load->items(
['linker' => $linker, 'published' => 1],
'password'
)) !== null)
{
foreach ($passwords as $password)
{
if (UserHelper::verifyPassword($pass, $password->password))
{
return $password;
}
}
}
return null;
}
/**
* Set Linker
*
* @param string $linker The linker GUID value
*
* @return bool True on success
* @since 2.0.1
**/
private function setLinker(string $linker): bool
{
return $this->insert->row([
'name' => 'Default-Name',
'guid' => $linker
], 'linker');
}
/**
* Set Password
*
* @param string $linker The linker GUID value
* @param string $pass The linker pass value
*
* @return bool True on success
* @since 2.0.1
**/
private function setPassword(string $linker, string $pass): bool
{
if (strlen($pass) <= 3)
{
return false;
}
return $this->insert->row([
'name' => 'Favourite-Verse',
'linker' => $linker,
'password' => UserHelper::hashPassword($pass),
'guid' => $this->getGuid('password')
], 'password');
}
/**
* Get a GUID
*
* @param string $table The table its for
*
* @return string The GUID value
* @since 2.0.1
**/
private function getGuid(string $table): string
{
$guid = (string) GuidHelper::get();
while (!GuidHelper::valid($guid, $table, 0, '[[[component]]]'))
{
// must always be set
$guid = (string) GuidHelper::get();
}
return $guid;
}

View File

@ -1,39 +1 @@
{ ###POWERLINKER###
"add_head": "1",
"add_licensing_template": "2",
"extends": "0",
"guid": "36ab759f-7b42-4465-9c17-56ba1dd05f90",
"implements": null,
"load_selection": null,
"name": "Linker",
"power_version": "1.0.0",
"system_name": "Joomla.GetBible.Linker",
"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": "84e84cd1-c938-4559-8414-d5692db4118e",
"as": "Session"
},
"use_selection4": {
"use": "9c513baf-b279-43fd-ae29-a585c8cbc4f0",
"as": "default"
}
},
"namespace": "VDM\\Joomla\\GetBible\\Linker",
"description": "The GetBible Linker\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\\User\\UserHelper;\r\nuse Joomla\\CMS\\Language\\Text;",
"composer": ""
}

View File

@ -1,90 +1 @@
``` ###POWERREADME###
██████╗ ██████╗ ██╗ ██╗███████╗██████╗
██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗
██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝
██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
```
# abstract class Watcher (Details)
> namespace: **VDM\Joomla\GetBible\Abstraction**
```uml
@startuml
abstract Watcher #Orange {
# Load $load
# Insert $insert
# Update $update
# bool $fresh
# bool $force
# ?object $target
# string $today
# string $past
# string $table
+ __construct(Load $load, Insert $insert, ...)
+ forceUpdate() : void
+ isNew() : bool
# hold() : bool
# bump() : bool
# getTarget(array $match, array $local) : ?object
}
note right of Watcher::__construct
Constructor
since: 2.0.1
arguments:
Load $load
Insert $insert
Update $update
end note
note right of Watcher::forceUpdate
The switch to force a local update
since: 2.0.1
return: void
end note
note right of Watcher::isNew
The see if new target is newly installed
since: 2.0.1
return: bool
end note
note right 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
note right of Watcher::getTarget
Get local targeted object
since: 2.0.1
return: ?object
end note
@enduml
```
---
```
██╗ ██████╗██████╗
██║██╔════╝██╔══██╗
██║██║ ██████╔╝
██ ██║██║ ██╔══██╗
╚█████╔╝╚██████╗██████╔╝
╚════╝ ╚═════╝╚═════╝
```
> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder)

View File

@ -9,212 +9,4 @@
* @license GNU General Public License version 2 or later; see LICENSE.txt * @license GNU General Public License version 2 or later; see LICENSE.txt
*/ */
namespace VDM\Joomla\GetBible\Abstraction; ###POWERCODE###
use Joomla\CMS\Date\Date;
use VDM\Joomla\GetBible\Database\Load;
use VDM\Joomla\GetBible\Database\Insert;
use VDM\Joomla\GetBible\Database\Update;
/**
* The GetBible Watcher
*
* @since 2.0.1
*/
abstract 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 fresh load switch
*
* @var bool
* @since 2.0.1
*/
protected bool $fresh = false;
/**
* The force update
*
* @var bool
* @since 2.0.1
*/
protected bool $force = false;
/**
* The target
*
* @var object|null
* @since 2.0.1
*/
protected ?object $target;
/**
* The today's date
*
* @var string
* @since 2.0.1
*/
protected string $today;
/**
* The two months in the past date
*
* @var string
* @since 2.0.1
*/
protected string $past;
/**
* The target table
*
* @var string
* @since 2.0.1
*/
protected string $table;
/**
* Constructor
*
* @param Load $load The load object.
* @param Insert $insert The insert object.
* @param Update $update The update object.
*
* @since 2.0.1
*/
public function __construct(
Load $load,
Insert $insert,
Update $update)
{
$this->load = $load;
$this->insert = $insert;
$this->update = $update;
// just in-case we set some dates
$this->today = (new Date())->toSql();
$this->past = (new Date())->modify('-2 months')->toSql();
}
/**
* The switch to force a local update
*
* @return void
* @since 2.0.1
*/
public function forceUpdate(): void
{
$this->force = true;
}
/**
* The see if new target is newly installed
*
* @return bool true if is new
* @since 2.0.1
*/
public function isNew(): bool
{
return $this->fresh;
}
/**
* Check if its time to match the API hash
*
* @return bool false if its time to check for an update
* @since 2.0.1
*/
protected function hold(): bool
{
// if we are being forced
if ($this->force)
{
return false; // we no longer hold, but force an update
}
// Create DateTime objects from the strings
try {
$today = new \DateTime($this->today);
$created = new \DateTime($this->target->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
*/
protected function bump(): bool
{
$update = [];
$update['id'] = $this->target->id;
$update['created'] = $this->today;
// update the local verse
return $this->update->row($update, 'id', $this->table);
}
/**
* Get local targeted object
*
* @param array $match The [key, value].
* @param array $local The local values.
*
* @return object|null The found value
* @since 2.0.1
*/
protected function getTarget(array $match, array &$local): ?object
{
foreach ($local as $_value)
{
if ($_value->{$match['key']} === $match['value'])
{
return $_value;
}
}
return null;
}
}

View File

@ -1,191 +1 @@
/** ###CODEPOWER###
* 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 fresh load switch
*
* @var bool
* @since 2.0.1
*/
protected bool $fresh = false;
/**
* The force update
*
* @var bool
* @since 2.0.1
*/
protected bool $force = false;
/**
* The target
*
* @var object|null
* @since 2.0.1
*/
protected ?object $target;
/**
* The today's date
*
* @var string
* @since 2.0.1
*/
protected string $today;
/**
* The two months in the past date
*
* @var string
* @since 2.0.1
*/
protected string $past;
/**
* The target table
*
* @var string
* @since 2.0.1
*/
protected string $table;
/**
* Constructor
*
* @param Load $load The load object.
* @param Insert $insert The insert object.
* @param Update $update The update object.
*
* @since 2.0.1
*/
public function __construct(
Load $load,
Insert $insert,
Update $update)
{
$this->load = $load;
$this->insert = $insert;
$this->update = $update;
// just in-case we set some dates
$this->today = (new Date())->toSql();
$this->past = (new Date())->modify('-2 months')->toSql();
}
/**
* The switch to force a local update
*
* @return void
* @since 2.0.1
*/
public function forceUpdate(): void
{
$this->force = true;
}
/**
* The see if new target is newly installed
*
* @return bool true if is new
* @since 2.0.1
*/
public function isNew(): bool
{
return $this->fresh;
}
/**
* Check if its time to match the API hash
*
* @return bool false if its time to check for an update
* @since 2.0.1
*/
protected function hold(): bool
{
// if we are being forced
if ($this->force)
{
return false; // we no longer hold, but force an update
}
// Create DateTime objects from the strings
try {
$today = new \DateTime($this->today);
$created = new \DateTime($this->target->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
*/
protected function bump(): bool
{
$update = [];
$update['id'] = $this->target->id;
$update['created'] = $this->today;
// update the local verse
return $this->update->row($update, 'id', $this->table);
}
/**
* Get local targeted object
*
* @param array $match The [key, value].
* @param array $local The local values.
*
* @return object|null The found value
* @since 2.0.1
*/
protected function getTarget(array $match, array &$local): ?object
{
foreach ($local as $_value)
{
if ($_value->{$match['key']} === $match['value'])
{
return $_value;
}
}
return null;
}

View File

@ -1,31 +1 @@
{ ###POWERLINKER###
"add_head": "1",
"add_licensing_template": "2",
"extends": "0",
"guid": "37e36c41-16a7-4c5d-972c-99acad5fd0b1",
"implements": null,
"load_selection": null,
"name": "Watcher",
"power_version": "1.0.0",
"system_name": "Joomla.GetBible.Abstraction.Watcher",
"type": "abstract 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"
}
},
"namespace": "VDM\\Joomla\\GetBible\\Abstraction.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": ""
}

View File

@ -1,174 +1 @@
``` ###POWERREADME###
██████╗ ██████╗ ██╗ ██╗███████╗██████╗
██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗
██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝
██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
```
# class Config (Details)
> namespace: **VDM\Joomla\GetBible\Openai**
```uml
@startuml
class Config #Gold {
# Input $input
# JoomlaRegistry $params
+ __construct(?Input $input = null, ?JoomlaRegistry $params = null)
# getPrompt() : ?string
# getTranslation() : ?string
# getBook() : ?int
# getChapter() : ?int
# getVerse() : ?string
# getWords() : ?string
# getEnableopenai() : bool
# getEnableopenaiorg() : bool
# getToken() : ?string
# getOrgToken() : ?string
# getModel() : ?string
# getMaxtokens() : ?int
# getTemperature() : ?float
# getTopp() : ?float
# getN() : ?int
# getPresencepenalty() : ?float
# getFrequencypenalty() : ?float
}
note right of Config::__construct
Constructor
since: 3.2.0
end note
note left of Config::getPrompt
get Prompt GUID
since: 2.0.1
return: ?string
end note
note right of Config::getTranslation
get Translation Abbreviation
since: 2.0.1
return: ?string
end note
note left of Config::getBook
get Book Number
since: 2.0.1
return: ?int
end note
note right of Config::getChapter
get Chapter Number
since: 2.0.1
return: ?int
end note
note left of Config::getVerse
get Verse Number/s
since: 2.0.1
return: ?string
end note
note right of Config::getWords
get Words Number/s
since: 2.0.1
return: ?string
end note
note left of Config::getEnableopenai
get Enable Open AI
since: 2.0.1
return: bool
end note
note right of Config::getEnableopenaiorg
get Enable Open AI Organisation
since: 2.0.1
return: bool
end note
note left of Config::getToken
get User Token
since: 2.0.1
return: ?string
end note
note right of Config::getOrgToken
get Org Token
since: 2.0.1
return: ?string
end note
note left of Config::getModel
get Open AI Model name
since: 2.0.1
return: ?string
end note
note right of Config::getMaxtokens
get Max Tokens
since: 2.0.1
return: ?int
end note
note left of Config::getTemperature
get Temperature
since: 2.0.1
return: ?float
end note
note right of Config::getTopp
get Top P
since: 2.0.1
return: ?float
end note
note left of Config::getN
get N (number of results)
since: 2.0.1
return: ?int
end note
note right of Config::getPresencepenalty
get Presence Penalty
since: 2.0.1
return: ?float
end note
note left of Config::getFrequencypenalty
get Frequency Penalty
since: 2.0.1
return: ?float
end note
@enduml
```
---
```
██╗ ██████╗██████╗
██║██╔════╝██╔══██╗
██║██║ ██████╔╝
██ ██║██║ ██╔══██╗
╚█████╔╝╚██████╗██████╔╝
╚════╝ ╚═════╝╚═════╝
```
> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder)

View File

@ -9,297 +9,4 @@
* @license GNU General Public License version 2 or later; see LICENSE.txt * @license GNU General Public License version 2 or later; see LICENSE.txt
*/ */
namespace VDM\Joomla\GetBible\Openai; ###POWERCODE###
use Joomla\CMS\Factory as JoomlaFactory;
use Joomla\Registry\Registry as JoomlaRegistry;
use Joomla\Input\Input;
use VDM\Joomla\Utilities\Component\Helper;
use VDM\Joomla\Abstraction\BaseConfig;
/**
* GetBible Openai Configurations
*
* @since 2.0.1
*/
class Config extends BaseConfig
{
/**
* Hold a JInput object for easier access to the input variables.
*
* @var Input
* @since 3.2.0
*/
protected Input $input;
/**
* The Params
*
* @var JoomlaRegistry
* @since 3.2.0
*/
protected JoomlaRegistry $params;
/**
* Constructor
*
* @param Input|null $input Input
* @param JoomlaRegistry|null $params The component parameters
*
* @throws \Exception
* @since 3.2.0
*/
public function __construct(?Input $input = null, ?JoomlaRegistry $params = null)
{
$this->input = $input ?: JoomlaFactory::getApplication()->input;
$this->params = $params ?: Helper::getParams('com_getbible');
// run parent constructor
parent::__construct();
}
/**
* get Prompt GUID
*
* @return string|null The translation abbreviation
* @since 2.0.1
*/
protected function getPrompt(): ?string
{
return $this->input->getString('guid');
}
/**
* get Translation Abbreviation
*
* @return string|null The translation abbreviation
* @since 2.0.1
*/
protected function getTranslation(): ?string
{
return $this->input->getString('t') ?? $this->input->getString('version') ?? $this->input->getString('translation');
}
/**
* get Book Number
*
* @return int|null The book number
* @since 2.0.1
*/
protected function getBook(): ?int
{
return $this->input->getInt('book');
}
/**
* get Chapter Number
*
* @return int|null The chapter number
* @since 2.0.1
*/
protected function getChapter(): ?int
{
return $this->input->getInt('chapter');
}
/**
* get Verse Number/s
*
* @return string|null The verse number/s
* @since 2.0.1
*/
protected function getVerse(): ?string
{
return $this->input->getString('verse');
}
/**
* get Words Number/s
*
* @return string|null The word number/s
* @since 2.0.1
*/
protected function getWords(): ?string
{
return $this->input->getString('words');
}
/**
* get Enable Open AI
*
* @return bool The switch to enable open AI
* @since 2.0.1
*/
protected function getEnableopenai(): bool
{
if ($this->params->get('enable_open_ai', 0) == 1)
{
return true;
}
return false;
}
/**
* get Enable Open AI Organisation
*
* @return bool The switch to enable open AI Organisation
* @since 2.0.1
*/
protected function getEnableopenaiorg(): bool
{
if ($this->params->get('enable_open_ai_org', 0) == 1)
{
return true;
}
return false;
}
/**
* get User Token
*
* @return string|null The token
* @since 2.0.1
*/
protected function getToken(): ?string
{
if (!$this->enable_open_ai)
{
return null;
}
return $this->params->get('openai_token');
}
/**
* get Org Token
*
* @return string|null The org token
* @since 2.0.1
*/
protected function getOrgToken(): ?string
{
if (!$this->enable_open_ai || !$this->enable_open_ai_org)
{
return null;
}
return $this->params->get('openai_org_token');
}
/**
* get Open AI Model name
*
* @return string|null The model name
* @since 2.0.1
*/
protected function getModel(): ?string
{
if (!$this->enable_open_ai)
{die;
return null;
}
return $this->params->get('openai_model');
}
/**
* get Max Tokens
*
* @return int|null The max tokens
* @since 2.0.1
*/
protected function getMaxtokens(): ?int
{
if (!$this->enable_open_ai)
{
return null;
}
return (int) $this->params->get('openai_max_tokens', 300);
}
/**
* get Temperature
*
* @return float|null The temperature
* @since 2.0.1
*/
protected function getTemperature(): ?float
{
if (!$this->enable_open_ai)
{
return null;
}
return (float) $this->params->get('openai_temperature', 1);
}
/**
* get Top P
*
* @return float|null The top p
* @since 2.0.1
*/
protected function getTopp(): ?float
{
if (!$this->enable_open_ai)
{
return null;
}
return (float) $this->params->get('openai_top_p', 1);
}
/**
* get N (number of results)
*
* @return int|null The number of results
* @since 2.0.1
*/
protected function getN(): ?int
{
if (!$this->enable_open_ai)
{
return null;
}
return (int) $this->params->get('openai_n', 1);
}
/**
* get Presence Penalty
*
* @return float|null The presence penalty
* @since 2.0.1
*/
protected function getPresencepenalty(): ?float
{
if (!$this->enable_open_ai)
{
return null;
}
return (float) $this->params->get('openai_presence_penalty', 0);
}
/**
* get Frequency Penalty
*
* @return float|null The frequency penalty
* @since 2.0.1
*/
protected function getFrequencypenalty(): ?float
{
if (!$this->enable_open_ai)
{
return null;
}
return (float) $this->params->get('openai_frequency_penalty', 0);
}
}

View File

@ -1,275 +1 @@
/** ###CODEPOWER###
* Hold a JInput object for easier access to the input variables.
*
* @var Input
* @since 3.2.0
*/
protected Input $input;
/**
* The Params
*
* @var JoomlaRegistry
* @since 3.2.0
*/
protected JoomlaRegistry $params;
/**
* Constructor
*
* @param Input|null $input Input
* @param JoomlaRegistry|null $params The component parameters
*
* @throws \Exception
* @since 3.2.0
*/
public function __construct(?Input $input = null, ?JoomlaRegistry $params = null)
{
$this->input = $input ?: JoomlaFactory::getApplication()->input;
$this->params = $params ?: Helper::getParams('com_[[[component]]]');
// run parent constructor
parent::__construct();
}
/**
* get Prompt GUID
*
* @return string|null The translation abbreviation
* @since 2.0.1
*/
protected function getPrompt(): ?string
{
return $this->input->getString('guid');
}
/**
* get Translation Abbreviation
*
* @return string|null The translation abbreviation
* @since 2.0.1
*/
protected function getTranslation(): ?string
{
return $this->input->getString('t') ?? $this->input->getString('version') ?? $this->input->getString('translation');
}
/**
* get Book Number
*
* @return int|null The book number
* @since 2.0.1
*/
protected function getBook(): ?int
{
return $this->input->getInt('book');
}
/**
* get Chapter Number
*
* @return int|null The chapter number
* @since 2.0.1
*/
protected function getChapter(): ?int
{
return $this->input->getInt('chapter');
}
/**
* get Verse Number/s
*
* @return string|null The verse number/s
* @since 2.0.1
*/
protected function getVerse(): ?string
{
return $this->input->getString('verse');
}
/**
* get Words Number/s
*
* @return string|null The word number/s
* @since 2.0.1
*/
protected function getWords(): ?string
{
return $this->input->getString('words');
}
/**
* get Enable Open AI
*
* @return bool The switch to enable open AI
* @since 2.0.1
*/
protected function getEnableopenai(): bool
{
if ($this->params->get('enable_open_ai', 0) == 1)
{
return true;
}
return false;
}
/**
* get Enable Open AI Organisation
*
* @return bool The switch to enable open AI Organisation
* @since 2.0.1
*/
protected function getEnableopenaiorg(): bool
{
if ($this->params->get('enable_open_ai_org', 0) == 1)
{
return true;
}
return false;
}
/**
* get User Token
*
* @return string|null The token
* @since 2.0.1
*/
protected function getToken(): ?string
{
if (!$this->enable_open_ai)
{
return null;
}
return $this->params->get('openai_token');
}
/**
* get Org Token
*
* @return string|null The org token
* @since 2.0.1
*/
protected function getOrgToken(): ?string
{
if (!$this->enable_open_ai || !$this->enable_open_ai_org)
{
return null;
}
return $this->params->get('openai_org_token');
}
/**
* get Open AI Model name
*
* @return string|null The model name
* @since 2.0.1
*/
protected function getModel(): ?string
{
if (!$this->enable_open_ai)
{die;
return null;
}
return $this->params->get('openai_model');
}
/**
* get Max Tokens
*
* @return int|null The max tokens
* @since 2.0.1
*/
protected function getMaxtokens(): ?int
{
if (!$this->enable_open_ai)
{
return null;
}
return (int) $this->params->get('openai_max_tokens', 300);
}
/**
* get Temperature
*
* @return float|null The temperature
* @since 2.0.1
*/
protected function getTemperature(): ?float
{
if (!$this->enable_open_ai)
{
return null;
}
return (float) $this->params->get('openai_temperature', 1);
}
/**
* get Top P
*
* @return float|null The top p
* @since 2.0.1
*/
protected function getTopp(): ?float
{
if (!$this->enable_open_ai)
{
return null;
}
return (float) $this->params->get('openai_top_p', 1);
}
/**
* get N (number of results)
*
* @return int|null The number of results
* @since 2.0.1
*/
protected function getN(): ?int
{
if (!$this->enable_open_ai)
{
return null;
}
return (int) $this->params->get('openai_n', 1);
}
/**
* get Presence Penalty
*
* @return float|null The presence penalty
* @since 2.0.1
*/
protected function getPresencepenalty(): ?float
{
if (!$this->enable_open_ai)
{
return null;
}
return (float) $this->params->get('openai_presence_penalty', 0);
}
/**
* get Frequency Penalty
*
* @return float|null The frequency penalty
* @since 2.0.1
*/
protected function getFrequencypenalty(): ?float
{
if (!$this->enable_open_ai)
{
return null;
}
return (float) $this->params->get('openai_frequency_penalty', 0);
}

View File

@ -1,23 +1 @@
{ ###POWERLINKER###
"add_head": "1",
"add_licensing_template": "2",
"extends": "ffbd4e1f-a342-4080-ab7d-1de3741bf319",
"guid": "3af7864b-f1f3-491e-b16f-0504f890086d",
"implements": null,
"load_selection": null,
"name": "Config",
"power_version": "1.0.0",
"system_name": "JCB.GetBible.Openai.Config",
"type": "class",
"use_selection": {
"use_selection0": {
"use": "640b5352-fb09-425f-a26e-cd44eda03f15",
"as": "default"
}
},
"namespace": "VDM\\Joomla\\GetBible\\Openai.Config",
"description": "GetBible Openai 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": "use Joomla\\CMS\\Factory as JoomlaFactory;\r\nuse Joomla\\Registry\\Registry as JoomlaRegistry;\r\nuse Joomla\\Input\\Input;",
"composer": ""
}

View File

@ -1,159 +1 @@
``` ###POWERREADME###
██████╗ ██████╗ ██╗ ██╗███████╗██████╗
██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗
██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝
██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
```
# final class Prompt (Details)
> namespace: **VDM\Joomla\GetBible\Data**
```uml
@startuml
class Prompt << (F,LightGreen) >> #Green {
# Load $load
# Config $config
# array $prompts
+ __construct(Load $load, Config $config)
+ getGuid() : string
+ getToken() : ?string
+ getOrgToken() : ?string
+ getModel() : ?string
+ getMaxTokens() : ?int
+ getTemperature() : ?float
+ getTopP() : ?float
+ getN() : ?int
+ getPresencePenalty() : ?float
+ getFrequencyPenalty() : ?float
+ getIntegration() : ?int
+ getCacheBehaviour() : ?int
+ getCacheCapacity() : int
+ getMessages() : ?array
# get() : ?object
}
note right of Prompt::__construct
Constructor
since: 2.0.1
end note
note left of Prompt::getGuid
Get prompt guid
since: 2.0.1
return: string
end note
note right of Prompt::getToken
Get open ai token
since: 2.0.1
return: ?string
end note
note left of Prompt::getOrgToken
Get open ai organisation token
since: 2.0.1
return: ?string
end note
note right of Prompt::getModel
Get open ai model name
since: 2.0.1
return: ?string
end note
note left of Prompt::getMaxTokens
Get the max tokens
since: 2.0.1
return: ?int
end note
note right of Prompt::getTemperature
Get the temperature
since: 2.0.1
return: ?float
end note
note left of Prompt::getTopP
Get the top p
since: 2.0.1
return: ?float
end note
note right of Prompt::getN
Get the number of results
since: 2.0.1
return: ?int
end note
note left of Prompt::getPresencePenalty
Get presence penalty
since: 2.0.1
return: ?float
end note
note right of Prompt::getFrequencyPenalty
Get frequency penalty
since: 2.0.1
return: ?float
end note
note left of Prompt::getIntegration
Get the integration
since: 2.0.1
return: ?int
end note
note right of Prompt::getCacheBehaviour
Get the cache behaviour
since: 2.0.1
return: ?int
end note
note left of Prompt::getCacheCapacity
Get the cache capacity
since: 2.0.1
return: int
end note
note right of Prompt::getMessages
Get the prompt messages
since: 2.0.1
return: ?array
end note
note left of Prompt::get
Get the prompt
since: 2.0.1
return: ?object
end note
@enduml
```
---
```
██╗ ██████╗██████╗
██║██╔════╝██╔══██╗
██║██║ ██████╔╝
██ ██║██║ ██╔══██╗
╚█████╔╝╚██████╗██████╔╝
╚════╝ ╚═════╝╚═════╝
```
> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder)

View File

@ -9,319 +9,4 @@
* @license GNU General Public License version 2 or later; see LICENSE.txt * @license GNU General Public License version 2 or later; see LICENSE.txt
*/ */
namespace VDM\Joomla\GetBible\Data; ###POWERCODE###
use VDM\Joomla\GetBible\Database\Load;
use VDM\Joomla\GetBible\Openai\Config;
/**
* The GetBible Prompt Data
*
* @since 2.0.1
*/
final class Prompt
{
/**
* The Load class
*
* @var Load
* @since 2.0.1
*/
protected Load $load;
/**
* The Config class
*
* @var Config
* @since 2.0.1
*/
protected Config $config;
/**
* The prompts
*
* @var array
* @since 2.0.1
*/
protected array $prompts = [];
/**
* Constructor
*
* @param Load $load The load object.
* @param Config $config The config object.
*
* @since 2.0.1
*/
public function __construct(Load $load, Config $config)
{
$this->load = $load;
$this->config = $config;
}
/**
* Get prompt guid
*
* @return string The global unique id
* @since 2.0.1
*/
public function getGuid(): string
{
$prompt = $this->get();
return $prompt ? $prompt->guid ?? '' : '';
}
/**
* Get open ai token
*
* @return string|null The token
* @since 2.0.1
*/
public function getToken(): ?string
{
$default = $this->config->get('token');
$prompt = $this->get();
if (!$prompt || !isset($prompt->token_override) ||
$prompt->token_override != 1)
{
return $default;
}
return $prompt->token ?? $default;
}
/**
* Get open ai organisation token
*
* @return string|null The token
* @since 2.0.1
*/
public function getOrgToken(): ?string
{
$default = $this->config->get('org_token');
$prompt = $this->get();
if (!$prompt || !isset($prompt->ai_org_token_override) ||
$prompt->ai_org_token_override != 1)
{
return $default;
}
return $prompt->org_token ?? $default;
}
/**
* Get open ai model name
*
* @return string|null The model name
* @since 2.0.1
*/
public function getModel(): ?string
{
$default = $this->config->get('model');
$prompt = $this->get();
return $prompt ? $prompt->model ?? $default : $default;
}
/**
* Get the max tokens
*
* @return int|null The max tokens
* @since 2.0.1
*/
public function getMaxTokens(): ?int
{
$default = $this->config->get('max_tokens');
$prompt = $this->get();
if (!$prompt || !isset($prompt->max_tokens_override) ||
$prompt->max_tokens_override != 1)
{
return $default;
}
return $prompt->max_tokens ?? $default;
}
/**
* Get the temperature
*
* @return float|null The temperature
* @since 2.0.1
*/
public function getTemperature(): ?float
{
$default = $this->config->get('temperature');
$prompt = $this->get();
if (!$prompt || !isset($prompt->temperature_override) ||
$prompt->temperature_override != 1)
{
return $default;
}
return $prompt->temperature ?? $default;
}
/**
* Get the top p
*
* @return float|null The top p
* @since 2.0.1
*/
public function getTopP(): ?float
{
$default = $this->config->get('top_p');
$prompt = $this->get();
if (!$prompt || !isset($prompt->top_p_override) ||
$prompt->top_p_override != 1)
{
return $default;
}
return $prompt->top_p ?? $default;
}
/**
* Get the number of results
*
* @return int|null The number of results
* @since 2.0.1
*/
public function getN(): ?int
{
$default = $this->config->get('n');
$prompt = $this->get();
if (!$prompt || !isset($prompt->n_override) ||
$prompt->n_override != 1)
{
return $default;
}
return $prompt->n ?? $default;
}
/**
* Get presence penalty
*
* @return float|null The presence penalty
* @since 2.0.1
*/
public function getPresencePenalty(): ?float
{
$default = $this->config->get('presence_penalty');
$prompt = $this->get();
if (!$prompt || !isset($prompt->presence_penalty_override) ||
$prompt->presence_penalty_override != 1)
{
return $default;
}
return $prompt->presence_penalty ?? $default;
}
/**
* Get frequency penalty
*
* @return float|null The frequency penalty
* @since 2.0.1
*/
public function getFrequencyPenalty(): ?float
{
$default = $this->config->get('frequency_penalty');
$prompt = $this->get();
if (!$prompt || !isset($prompt->frequency_penalty_override) ||
$prompt->frequency_penalty_override != 1)
{
return $default;
}
return $prompt->frequency_penalty ?? $default;
}
/**
* Get the integration
*
* @return int|null 1 = Word-Based, 2 = Verse-Based, 3 = Selection-Based
* @since 2.0.1
*/
public function getIntegration(): ?int
{
$prompt = $this->get();
return $prompt ? $prompt->integration ?? null : null;
}
/**
* Get the cache behaviour
*
* @return int|null 0 = Persistently, 2 = Basic, 3 = Advanced
* @since 2.0.1
*/
public function getCacheBehaviour(): ?int
{
$prompt = $this->get();
return $prompt ? $prompt->cache_behaviour ?? null : null;
}
/**
* Get the cache capacity
*
* @return int The number to cache
* @since 2.0.1
*/
public function getCacheCapacity(): int
{
$prompt = $this->get();
return $prompt ? $prompt->cache_capacity ?? 1 : 1;
}
/**
* Get the prompt messages
*
* @return array|null The array of massage
* @since 2.0.1
*/
public function getMessages(): ?array
{
$prompt = $this->get();
return $prompt ? $prompt->messages ?? null : null;
}
/**
* Get the prompt
*
* @return object|null True on success
* @since 2.0.1
*/
protected function get(): ?object
{
// get from cache if not found
$guid = $this->config->get('prompt');
if (empty($guid))
{
return null;
}
if (!isset($this->prompts[$guid]))
{
$this->prompts[$guid] = $this->load->item(['guid' => $guid, 'published' => 1], 'prompt');
if ($this->prompts[$guid] && isset($this->prompts[$guid]->messages) && is_object($this->prompts[$guid]->messages))
{
$this->prompts[$guid]->messages = array_values((array) $this->prompts[$guid]->messages);
}
}
return $this->prompts[$guid];
}
}

View File

@ -1,300 +1 @@
/** ###CODEPOWER###
* The Load class
*
* @var Load
* @since 2.0.1
*/
protected Load $load;
/**
* The Config class
*
* @var Config
* @since 2.0.1
*/
protected Config $config;
/**
* The prompts
*
* @var array
* @since 2.0.1
*/
protected array $prompts = [];
/**
* Constructor
*
* @param Load $load The load object.
* @param Config $config The config object.
*
* @since 2.0.1
*/
public function __construct(Load $load, Config $config)
{
$this->load = $load;
$this->config = $config;
}
/**
* Get prompt guid
*
* @return string The global unique id
* @since 2.0.1
*/
public function getGuid(): string
{
$prompt = $this->get();
return $prompt ? $prompt->guid ?? '' : '';
}
/**
* Get open ai token
*
* @return string|null The token
* @since 2.0.1
*/
public function getToken(): ?string
{
$default = $this->config->get('token');
$prompt = $this->get();
if (!$prompt || !isset($prompt->token_override) ||
$prompt->token_override != 1)
{
return $default;
}
return $prompt->token ?? $default;
}
/**
* Get open ai organisation token
*
* @return string|null The token
* @since 2.0.1
*/
public function getOrgToken(): ?string
{
$default = $this->config->get('org_token');
$prompt = $this->get();
if (!$prompt || !isset($prompt->ai_org_token_override) ||
$prompt->ai_org_token_override != 1)
{
return $default;
}
return $prompt->org_token ?? $default;
}
/**
* Get open ai model name
*
* @return string|null The model name
* @since 2.0.1
*/
public function getModel(): ?string
{
$default = $this->config->get('model');
$prompt = $this->get();
return $prompt ? $prompt->model ?? $default : $default;
}
/**
* Get the max tokens
*
* @return int|null The max tokens
* @since 2.0.1
*/
public function getMaxTokens(): ?int
{
$default = $this->config->get('max_tokens');
$prompt = $this->get();
if (!$prompt || !isset($prompt->max_tokens_override) ||
$prompt->max_tokens_override != 1)
{
return $default;
}
return $prompt->max_tokens ?? $default;
}
/**
* Get the temperature
*
* @return float|null The temperature
* @since 2.0.1
*/
public function getTemperature(): ?float
{
$default = $this->config->get('temperature');
$prompt = $this->get();
if (!$prompt || !isset($prompt->temperature_override) ||
$prompt->temperature_override != 1)
{
return $default;
}
return $prompt->temperature ?? $default;
}
/**
* Get the top p
*
* @return float|null The top p
* @since 2.0.1
*/
public function getTopP(): ?float
{
$default = $this->config->get('top_p');
$prompt = $this->get();
if (!$prompt || !isset($prompt->top_p_override) ||
$prompt->top_p_override != 1)
{
return $default;
}
return $prompt->top_p ?? $default;
}
/**
* Get the number of results
*
* @return int|null The number of results
* @since 2.0.1
*/
public function getN(): ?int
{
$default = $this->config->get('n');
$prompt = $this->get();
if (!$prompt || !isset($prompt->n_override) ||
$prompt->n_override != 1)
{
return $default;
}
return $prompt->n ?? $default;
}
/**
* Get presence penalty
*
* @return float|null The presence penalty
* @since 2.0.1
*/
public function getPresencePenalty(): ?float
{
$default = $this->config->get('presence_penalty');
$prompt = $this->get();
if (!$prompt || !isset($prompt->presence_penalty_override) ||
$prompt->presence_penalty_override != 1)
{
return $default;
}
return $prompt->presence_penalty ?? $default;
}
/**
* Get frequency penalty
*
* @return float|null The frequency penalty
* @since 2.0.1
*/
public function getFrequencyPenalty(): ?float
{
$default = $this->config->get('frequency_penalty');
$prompt = $this->get();
if (!$prompt || !isset($prompt->frequency_penalty_override) ||
$prompt->frequency_penalty_override != 1)
{
return $default;
}
return $prompt->frequency_penalty ?? $default;
}
/**
* Get the integration
*
* @return int|null 1 = Word-Based, 2 = Verse-Based, 3 = Selection-Based
* @since 2.0.1
*/
public function getIntegration(): ?int
{
$prompt = $this->get();
return $prompt ? $prompt->integration ?? null : null;
}
/**
* Get the cache behaviour
*
* @return int|null 0 = Persistently, 2 = Basic, 3 = Advanced
* @since 2.0.1
*/
public function getCacheBehaviour(): ?int
{
$prompt = $this->get();
return $prompt ? $prompt->cache_behaviour ?? null : null;
}
/**
* Get the cache capacity
*
* @return int The number to cache
* @since 2.0.1
*/
public function getCacheCapacity(): int
{
$prompt = $this->get();
return $prompt ? $prompt->cache_capacity ?? 1 : 1;
}
/**
* Get the prompt messages
*
* @return array|null The array of massage
* @since 2.0.1
*/
public function getMessages(): ?array
{
$prompt = $this->get();
return $prompt ? $prompt->messages ?? null : null;
}
/**
* Get the prompt
*
* @return object|null True on success
* @since 2.0.1
*/
protected function get(): ?object
{
// get from cache if not found
$guid = $this->config->get('prompt');
if (empty($guid))
{
return null;
}
if (!isset($this->prompts[$guid]))
{
$this->prompts[$guid] = $this->load->item(['guid' => $guid, 'published' => 1], 'prompt');
if ($this->prompts[$guid] && isset($this->prompts[$guid]->messages) && is_object($this->prompts[$guid]->messages))
{
$this->prompts[$guid]->messages = array_values((array) $this->prompts[$guid]->messages);
}
}
return $this->prompts[$guid];
}

View File

@ -1,27 +1 @@
{ ###POWERLINKER###
"add_head": "0",
"add_licensing_template": "2",
"extends": "0",
"guid": "3f785d63-a592-463d-9f5f-b2b5a8edd561",
"implements": null,
"load_selection": null,
"name": "Prompt",
"power_version": "1.0.0",
"system_name": "Joomla.GetBible.Data.Prompt",
"type": "final class",
"use_selection": {
"use_selection0": {
"use": "c03b9c61-17d3-4774-a335-783903719f83",
"as": "default"
},
"use_selection1": {
"use": "3af7864b-f1f3-491e-b16f-0504f890086d",
"as": "default"
}
},
"namespace": "VDM\\Joomla\\GetBible\\Data.Prompt",
"description": "The GetBible Prompt Data\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": ""
}

View File

@ -1,72 +1 @@
``` ###POWERREADME###
██████╗ ██████╗ ██╗ ██╗███████╗██████╗
██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗
██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝
██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
```
# final class Response (Details)
> namespace: **VDM\Joomla\GetBible\Data**
```uml
@startuml
class Response << (F,LightGreen) >> #Green {
# Scripture $scripture
# Prompt $prompt
# Load $load
# Config $config
# array $responses
# int $total
+ __construct(Scripture $scripture, Prompt $prompt, ...)
+ get() : ?array
+ isEnough() : bool
+ getTotal() : int
}
note right of Response::__construct
Constructor
since: 2.0.1
arguments:
Scripture $scripture
Prompt $prompt
Load $load
Config $config
end note
note right of Response::get
Get the responses
since: 2.0.1
return: ?array
end note
note right of Response::isEnough
is there enough response messages
since: 2.0.1
return: bool
end note
note right of Response::getTotal
Get the total responses in cache
since: 2.0.1
return: int
end note
@enduml
```
---
```
██╗ ██████╗██████╗
██║██╔════╝██╔══██╗
██║██║ ██████╔╝
██ ██║██║ ██╔══██╗
╚█████╔╝╚██████╗██████╔╝
╚════╝ ╚═════╝╚═════╝
```
> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder)

View File

@ -9,192 +9,4 @@
* @license GNU General Public License version 2 or later; see LICENSE.txt * @license GNU General Public License version 2 or later; see LICENSE.txt
*/ */
namespace VDM\Joomla\GetBible\Data; ###POWERCODE###
use VDM\Joomla\GetBible\Data\Scripture;
use VDM\Joomla\GetBible\Data\Prompt;
use VDM\Joomla\GetBible\Database\Load;
use VDM\Joomla\GetBible\Openai\Config;
/**
* The GetBible Response Data
*
* @since 2.0.1
*/
final class Response
{
/**
* The Scripture class
*
* @var Scripture
* @since 2.0.1
*/
protected Scripture $scripture;
/**
* The Prompt class
*
* @var Prompt
* @since 2.0.1
*/
protected Prompt $prompt;
/**
* The Load class
*
* @var Load
* @since 2.0.1
*/
protected Load $load;
/**
* The Config class
*
* @var Config
* @since 2.0.1
*/
protected Config $config;
/**
* The responses
*
* @var array
* @since 2.0.1
*/
protected array $responses = [];
/**
* The total responses
*
* @var int
* @since 2.0.1
*/
protected int $total = 0;
/**
* Constructor
*
* @param Scripture $scripture The scripture object.
* @param Prompt $prompt The prompt object.
* @param Load $load The load object.
* @param Config $config The config object.
*
* @since 2.0.1
*/
public function __construct(
Scripture $scripture,
Prompt $prompt,
Load $load,
Config $config)
{
$this->scripture = $scripture;
$this->prompt = $prompt;
$this->load = $load;
$this->config = $config;
}
/**
* Get the responses
*
* @return array|null True on success
* @since 2.0.1
*/
public function get(): ?array
{
// get the cache behaviour
$cache = $this->prompt->getCacheBehaviour();
if (empty($cache) || ($cache != 1 && $cache != 2))
{
return null;
}
// load the prompt GUID
$guid = $this->config->get('prompt');
if ($guid === null)
{
return null;
}
if (!isset($this->responses[$guid]))
{
$this->responses[$guid] = null;
$query = ['prompt' => $guid, 'published' => 1];
// Basic Caching - Words/Language
if ($cache == 1)
{
// any empty string so cause no value to be returned
$query['language'] = $this->scripture->get('translation_language', 'none__found');
$query['selected_word'] = $this->scripture->get('selected_word_text', 'none__found');
}
// Advanced Caching - Verse/Contex
else
{
// any empty string so cause no value to be returned
$query['abbreviation'] = $this->scripture->get('translation_abbreviation', 'none__found');
$query['book'] = $this->scripture->get('book_number', 'none__found');
$query['chapter'] = $this->scripture->get('chapter_number', 'none__found');
$query['verse'] = $this->scripture->get('verse_number', 'none__found');
// get the integration
$integration = $this->prompt->getIntegration();
if ($integration == 1 || $integration == 3)
{
$query['word'] = $this->scripture->get('selected_word_number', 'none__found');
}
}
$bucket = $this->load->items($query, 'open_ai_response');
if (is_array($bucket) && $bucket !== [])
{
foreach($bucket as $nr => &$response)
{
$response->messages = $this->load->items([
'prompt' => $guid,
'open_ai_response' => $response->response_id,
'published' => 1
], 'open_ai_message');
}
$this->responses[$guid] = $bucket;
}
}
return $this->responses[$guid];
}
/**
* is there enough response messages
*
* @return bool true if there is enough messages
* @since 2.0.1
*/
public function isEnough(): bool
{
return ($this->getTotal() >= $this->prompt->getCacheCapacity());
}
/**
* Get the total responses in cache
*
* @return int Number responses from OpenAI
* @since 2.0.1
*/
public function getTotal(): int
{
if ($this->total > 0 || ($responses = $this->get()) === null)
{
return $this->total;
}
$this->total = count((array) $responses);
return $this->total;
}
}

View File

@ -1,171 +1 @@
/** ###CODEPOWER###
* The Scripture class
*
* @var Scripture
* @since 2.0.1
*/
protected Scripture $scripture;
/**
* The Prompt class
*
* @var Prompt
* @since 2.0.1
*/
protected Prompt $prompt;
/**
* The Load class
*
* @var Load
* @since 2.0.1
*/
protected Load $load;
/**
* The Config class
*
* @var Config
* @since 2.0.1
*/
protected Config $config;
/**
* The responses
*
* @var array
* @since 2.0.1
*/
protected array $responses = [];
/**
* The total responses
*
* @var int
* @since 2.0.1
*/
protected int $total = 0;
/**
* Constructor
*
* @param Scripture $scripture The scripture object.
* @param Prompt $prompt The prompt object.
* @param Load $load The load object.
* @param Config $config The config object.
*
* @since 2.0.1
*/
public function __construct(
Scripture $scripture,
Prompt $prompt,
Load $load,
Config $config)
{
$this->scripture = $scripture;
$this->prompt = $prompt;
$this->load = $load;
$this->config = $config;
}
/**
* Get the responses
*
* @return array|null True on success
* @since 2.0.1
*/
public function get(): ?array
{
// get the cache behaviour
$cache = $this->prompt->getCacheBehaviour();
if (empty($cache) || ($cache != 1 && $cache != 2))
{
return null;
}
// load the prompt GUID
$guid = $this->config->get('prompt');
if ($guid === null)
{
return null;
}
if (!isset($this->responses[$guid]))
{
$this->responses[$guid] = null;
$query = ['prompt' => $guid, 'published' => 1];
// Basic Caching - Words/Language
if ($cache == 1)
{
// any empty string so cause no value to be returned
$query['language'] = $this->scripture->get('translation_language', 'none__found');
$query['selected_word'] = $this->scripture->get('selected_word_text', 'none__found');
}
// Advanced Caching - Verse/Contex
else
{
// any empty string so cause no value to be returned
$query['abbreviation'] = $this->scripture->get('translation_abbreviation', 'none__found');
$query['book'] = $this->scripture->get('book_number', 'none__found');
$query['chapter'] = $this->scripture->get('chapter_number', 'none__found');
$query['verse'] = $this->scripture->get('verse_number', 'none__found');
// get the integration
$integration = $this->prompt->getIntegration();
if ($integration == 1 || $integration == 3)
{
$query['word'] = $this->scripture->get('selected_word_number', 'none__found');
}
}
$bucket = $this->load->items($query, 'open_ai_response');
if (is_array($bucket) && $bucket !== [])
{
foreach($bucket as $nr => &$response)
{
$response->messages = $this->load->items([
'prompt' => $guid,
'open_ai_response' => $response->response_id,
'published' => 1
], 'open_ai_message');
}
$this->responses[$guid] = $bucket;
}
}
return $this->responses[$guid];
}
/**
* is there enough response messages
*
* @return bool true if there is enough messages
* @since 2.0.1
*/
public function isEnough(): bool
{
return ($this->getTotal() >= $this->prompt->getCacheCapacity());
}
/**
* Get the total responses in cache
*
* @return int Number responses from OpenAI
* @since 2.0.1
*/
public function getTotal(): int
{
if ($this->total > 0 || ($responses = $this->get()) === null)
{
return $this->total;
}
$this->total = count((array) $responses);
return $this->total;
}

View File

@ -1,35 +1 @@
{ ###POWERLINKER###
"add_head": "0",
"add_licensing_template": "2",
"extends": "0",
"guid": "44c15b17-e096-47c0-8769-42ea9b692cb2",
"implements": null,
"load_selection": null,
"name": "Response",
"power_version": "1.0.0",
"system_name": "Joomla.GetBible.Data.Response",
"type": "final class",
"use_selection": {
"use_selection0": {
"use": "17d87374-2953-4d6c-9fdd-4220d6ad1564",
"as": "default"
},
"use_selection1": {
"use": "3f785d63-a592-463d-9f5f-b2b5a8edd561",
"as": "default"
},
"use_selection2": {
"use": "c03b9c61-17d3-4774-a335-783903719f83",
"as": "default"
},
"use_selection3": {
"use": "3af7864b-f1f3-491e-b16f-0504f890086d",
"as": "default"
}
},
"namespace": "VDM\\Joomla\\GetBible\\Data.Response",
"description": "The GetBible Response Data\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": ""
}

View File

@ -1,61 +1 @@
``` ###POWERREADME###
██████╗ ██████╗ ██╗ ██╗███████╗██████╗
██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗
██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝
██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
```
# 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)

View File

@ -9,88 +9,4 @@
* @license GNU General Public License version 2 or later; see LICENSE.txt * @license GNU General Public License version 2 or later; see LICENSE.txt
*/ */
namespace VDM\Joomla\GetBible\Api; ###POWERCODE###
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')
)
)
);
}
}

View File

@ -1,70 +1 @@
/** ###CODEPOWER###
* 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')
)
)
);
}

View File

@ -1,18 +1 @@
{ ###POWERLINKER###
"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": ""
}

View File

@ -1,113 +1 @@
``` ###POWERREADME###
██████╗ ██████╗ ██╗ ██╗███████╗██████╗
██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗
██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝
██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
```
# final class Chapter (Details)
> namespace: **VDM\Joomla\GetBible\Data**
```uml
@startuml
class Chapter << (F,LightGreen) >> #Green {
# Load $load
# Config $config
# array $chapters
+ __construct(Load $load, Config $config)
+ getNumber() : string
+ getName() : string
+ getText() : string
+ getVerses() : ?array
- get() : ?object
- loadChapterData(string $abbreviation, int $book, ...) : ?object
- convertVersesToText(array $verses) : string
- generateCacheKey(string $abbreviation, int $book, ...) : string
}
note right of Chapter::__construct
Constructor
since: 2.0.1
end note
note left of Chapter::getNumber
Get the chapter number
since: 2.0.1
return: string
end note
note right of Chapter::getName
Get the chapter name
since: 2.0.1
return: string
end note
note left of Chapter::getText
Get the chapter text
since: 2.0.1
return: string
end note
note right of Chapter::getVerses
Get the chapter verses
since: 2.0.1
return: ?array
end note
note left of Chapter::get
Get the chapter
since: 2.0.1
return: ?object
end note
note right of Chapter::loadChapterData
Loads the chapter data from the database and updates the cache
since: 2.0.1
return: ?object
arguments:
string $abbreviation
int $book
int $chapter
end note
note left of Chapter::convertVersesToText
Convert verses to text
since: 2.0.1
return: string
end note
note right of Chapter::generateCacheKey
Generates a cache key based on the abbreviation, book, and chapter
since: 2.0.1
return: string
arguments:
string $abbreviation
int $book
int $chapter
end note
@enduml
```
---
```
██╗ ██████╗██████╗
██║██╔════╝██╔══██╗
██║██║ ██████╔╝
██ ██║██║ ██╔══██╗
╚█████╔╝╚██████╗██████╔╝
╚════╝ ╚═════╝╚═════╝
```
> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder)

View File

@ -9,206 +9,4 @@
* @license GNU General Public License version 2 or later; see LICENSE.txt * @license GNU General Public License version 2 or later; see LICENSE.txt
*/ */
namespace VDM\Joomla\GetBible\Data; ###POWERCODE###
use VDM\Joomla\GetBible\Database\Load;
use VDM\Joomla\GetBible\Openai\Config;
/**
* The GetBible Chapter Data
*
* @since 2.0.1
*/
final class Chapter
{
/**
* The Load class
*
* @var Load
* @since 2.0.1
*/
protected Load $load;
/**
* The Config class
*
* @var Config
* @since 2.0.1
*/
protected Config $config;
/**
* The chapters
*
* @var array
* @since 2.0.1
*/
protected array $chapters = [];
/**
* Constructor
*
* @param Load $load The load object.
* @param Config $config The config object.
*
* @since 2.0.1
*/
public function __construct(Load $load, Config $config)
{
$this->load = $load;
$this->config = $config;
}
/**
* Get the chapter number
*
* @return string The chapter number
* @since 2.0.1
*/
public function getNumber(): string
{
$chapter = $this->get();
return $chapter ? $chapter->chapter ?? '' : '';
}
/**
* Get the chapter name
*
* @return string The chapter name
* @since 2.0.1
*/
public function getName(): string
{
$chapter = $this->get();
return $chapter ? $chapter->name ?? '' : '';
}
/**
* Get the chapter text
*
* @return string The chapter text
* @since 2.0.1
*/
public function getText(): string
{
$chapter = $this->get();
return $chapter ? $chapter->text ?? '' : '';
}
/**
* Get the chapter verses
*
* @return array|null The chapter verses
* @since 2.0.1
*/
public function getVerses(): ?array
{
$chapter = $this->get();
return $chapter ? $chapter->verses ?? null : null;
}
/**
* Get the chapter
*
* @return object|null True on success
* @since 2.0.1
*/
private function get(): ?object
{
$abbreviation = $this->config->get('translation');
$book = $this->config->get('book');
$chapter = $this->config->get('chapter');
if (empty($abbreviation) || empty($book) || empty($chapter))
{
return null;
}
$cacheKey = $this->generateCacheKey($abbreviation, $book, $chapter);
if (isset($this->chapters[$cacheKey]))
{
return $this->chapters[$cacheKey];
}
return $this->loadChapterData($abbreviation, (int) $book, (int) $chapter);
}
/**
* Loads the chapter data from the database and updates the cache
*
* @param string $abbreviation The translation abbreviation.
* @param int $book The book number.
* @param int $chapter The chapter number.
*
* @return object|null The loaded chapter data, or null if not found or an error occurred.
* @since 2.0.1
*/
private function loadChapterData(string $abbreviation, int $book, int $chapter): ?object
{
$data = $this->load->item(
['abbreviation' => $abbreviation, 'book_nr' => $book, 'chapter' => $chapter, 'published' => 1],
'chapter'
);
if (!is_object($data))
{
return null;
}
$data->verses = $this->load->items(
['abbreviation' => $abbreviation, 'book_nr' => $book, 'chapter' => $chapter, 'published' => 1],
'verse'
);
if ($data->verses === null || !is_array($data->verses) || $data->verses === [])
{
return null;
}
$cacheKey = $this->generateCacheKey($abbreviation, $book, $chapter);
$data->text = $this->convertVersesToText($data->verses);
$this->chapters[$cacheKey] = $data;
return $this->chapters[$cacheKey];
}
/**
* Convert verses to text
*
* @param array $verses The chapter verses.
*
* @return string The verses in text.
* @since 2.0.1
*/
private function convertVersesToText(array $verses): string
{
$text = [];
foreach ($verses as $verse)
{
$text[] = trim($verse->verse) . ' ' . trim($verse->text);
}
return implode(' ', $text);
}
/**
* Generates a cache key based on the abbreviation, book, and chapter
*
* @param string $abbreviation The translation abbreviation.
* @param int $book The book number.
* @param int $chapter The chapter number.
*
* @return string The generated cache key.
* @since 2.0.1
*/
private function generateCacheKey(string $abbreviation, int $book, int $chapter): string
{
return $abbreviation . '_' . $book . '_' . $chapter;
}
}

View File

@ -1,187 +1 @@
/** ###CODEPOWER###
* The Load class
*
* @var Load
* @since 2.0.1
*/
protected Load $load;
/**
* The Config class
*
* @var Config
* @since 2.0.1
*/
protected Config $config;
/**
* The chapters
*
* @var array
* @since 2.0.1
*/
protected array $chapters = [];
/**
* Constructor
*
* @param Load $load The load object.
* @param Config $config The config object.
*
* @since 2.0.1
*/
public function __construct(Load $load, Config $config)
{
$this->load = $load;
$this->config = $config;
}
/**
* Get the chapter number
*
* @return string The chapter number
* @since 2.0.1
*/
public function getNumber(): string
{
$chapter = $this->get();
return $chapter ? $chapter->chapter ?? '' : '';
}
/**
* Get the chapter name
*
* @return string The chapter name
* @since 2.0.1
*/
public function getName(): string
{
$chapter = $this->get();
return $chapter ? $chapter->name ?? '' : '';
}
/**
* Get the chapter text
*
* @return string The chapter text
* @since 2.0.1
*/
public function getText(): string
{
$chapter = $this->get();
return $chapter ? $chapter->text ?? '' : '';
}
/**
* Get the chapter verses
*
* @return array|null The chapter verses
* @since 2.0.1
*/
public function getVerses(): ?array
{
$chapter = $this->get();
return $chapter ? $chapter->verses ?? null : null;
}
/**
* Get the chapter
*
* @return object|null True on success
* @since 2.0.1
*/
private function get(): ?object
{
$abbreviation = $this->config->get('translation');
$book = $this->config->get('book');
$chapter = $this->config->get('chapter');
if (empty($abbreviation) || empty($book) || empty($chapter))
{
return null;
}
$cacheKey = $this->generateCacheKey($abbreviation, $book, $chapter);
if (isset($this->chapters[$cacheKey]))
{
return $this->chapters[$cacheKey];
}
return $this->loadChapterData($abbreviation, (int) $book, (int) $chapter);
}
/**
* Loads the chapter data from the database and updates the cache
*
* @param string $abbreviation The translation abbreviation.
* @param int $book The book number.
* @param int $chapter The chapter number.
*
* @return object|null The loaded chapter data, or null if not found or an error occurred.
* @since 2.0.1
*/
private function loadChapterData(string $abbreviation, int $book, int $chapter): ?object
{
$data = $this->load->item(
['abbreviation' => $abbreviation, 'book_nr' => $book, 'chapter' => $chapter, 'published' => 1],
'chapter'
);
if (!is_object($data))
{
return null;
}
$data->verses = $this->load->items(
['abbreviation' => $abbreviation, 'book_nr' => $book, 'chapter' => $chapter, 'published' => 1],
'verse'
);
if ($data->verses === null || !is_array($data->verses) || $data->verses === [])
{
return null;
}
$cacheKey = $this->generateCacheKey($abbreviation, $book, $chapter);
$data->text = $this->convertVersesToText($data->verses);
$this->chapters[$cacheKey] = $data;
return $this->chapters[$cacheKey];
}
/**
* Convert verses to text
*
* @param array $verses The chapter verses.
*
* @return string The verses in text.
* @since 2.0.1
*/
private function convertVersesToText(array $verses): string
{
$text = [];
foreach ($verses as $verse)
{
$text[] = trim($verse->verse) . ' ' . trim($verse->text);
}
return implode(' ', $text);
}
/**
* Generates a cache key based on the abbreviation, book, and chapter
*
* @param string $abbreviation The translation abbreviation.
* @param int $book The book number.
* @param int $chapter The chapter number.
*
* @return string The generated cache key.
* @since 2.0.1
*/
private function generateCacheKey(string $abbreviation, int $book, int $chapter): string
{
return $abbreviation . '_' . $book . '_' . $chapter;
}

View File

@ -1,27 +1 @@
{ ###POWERLINKER###
"add_head": "0",
"add_licensing_template": "2",
"extends": "0",
"guid": "4a4c786d-51f4-421a-aa61-262dfd071880",
"implements": null,
"load_selection": null,
"name": "Chapter",
"power_version": "1.0.0",
"system_name": "Joomla.GetBible.Data.Chapter",
"type": "final class",
"use_selection": {
"use_selection0": {
"use": "c03b9c61-17d3-4774-a335-783903719f83",
"as": "default"
},
"use_selection1": {
"use": "3af7864b-f1f3-491e-b16f-0504f890086d",
"as": "default"
}
},
"namespace": "VDM\\Joomla\\GetBible\\Data.Chapter",
"description": "The GetBible Chapter Data\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": ""
}

View File

@ -1,122 +1 @@
``` ###POWERREADME###
██████╗ ██████╗ ██╗ ██╗███████╗██████╗
██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗
██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝
██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
```
# final class Paragraphs (Details)
> namespace: **VDM\Joomla\GetBible\Tagged**
```uml
@startuml
class Paragraphs << (F,LightGreen) >> #Green {
- int $previousBook
- int $previousChapter
- int $previousVerse
- int $group
- array $paragraphs
+ get(array $items, string $translation = 'kjv') : array
- resetProperties() : void
- sortIntoParagraphs(array $items) : void
- isNotSequential(object $item) : bool
- getKey(object $item) : string
- setDetails(object $item, string $key) : void
- addVerse(object $item, string $key) : void
- updatePrevious(object $item) : void
- setUrls(string $translation) : void
- setVerseAndName(array $paragraph) : void
- setUrl(array $paragraph, string $translation) : void
}
note right of Paragraphs::get
Main function to get sorted paragraphs.
since: 2.0.1
return: array
end note
note left of Paragraphs::resetProperties
Reset properties before getting paragraphs
since: 2.0.1
return: void
end note
note right of Paragraphs::sortIntoParagraphs
Sort items into paragraphs.
since: 2.0.1
return: void
end note
note left of Paragraphs::isNotSequential
Check if a verse is not sequential.
since: 2.0.1
return: bool
end note
note right of Paragraphs::getKey
Generate a key based on the verse item.
since: 2.0.1
return: string
end note
note left of Paragraphs::setDetails
Set details for a verse.
since: 2.0.1
return: void
end note
note right of Paragraphs::addVerse
Add a verse to the paragraphs.
since: 2.0.1
return: void
end note
note left of Paragraphs::updatePrevious
Update the previous verse, book, and chapter to the current one.
since: 2.0.1
return: void
end note
note right of Paragraphs::setUrls
Set URLs for the paragraphs.
since: 2.0.1
return: void
end note
note left of Paragraphs::setVerseAndName
Set verse and name for a paragraph.
since: 2.0.1
return: void
end note
note right of Paragraphs::setUrl
Set URL for a paragraph.
since: 2.0.1
return: void
end note
@enduml
```
---
```
██╗ ██████╗██████╗
██║██╔════╝██╔══██╗
██║██║ ██████╔╝
██ ██║██║ ██╔══██╗
╚█████╔╝╚██████╗██████╔╝
╚════╝ ╚═════╝╚═════╝
```
> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder)

View File

@ -9,267 +9,4 @@
* @license GNU General Public License version 2 or later; see LICENSE.txt * @license GNU General Public License version 2 or later; see LICENSE.txt
*/ */
namespace VDM\Joomla\GetBible\Tagged; ###POWERCODE###
use Joomla\CMS\Router\Route;
/**
* The GetBible Tagged Paragraphs
*
* @since 2.0.1
*/
final class Paragraphs
{
/**
* The Previous Book number
*
* @var int
* @since 2.0.1
*/
private int $previousBook = 0;
/**
* The Previous Chapter number
*
* @var int
* @since 2.0.1
*/
private int $previousChapter = 0;
/**
* The Previous Verse number
*
* @var int
* @since 2.0.1
*/
private int $previousVerse = 0;
/**
* The Current Group number
*
* @var int
* @since 2.0.1
*/
private int $group = 0;
/**
* The paragraphs being build
*
* @var array
* @since 2.0.1
*/
private array $paragraphs = [];
/**
* Main function to get sorted paragraphs.
*
* @param array $items The items to be sorted into paragraphs.
* @param string $translation The translation to be used.
*
* @return array The sorted paragraphs.
* @since 2.0.1
*/
public function get(array $items, string $translation = 'kjv'): array
{
$this->resetProperties();
// sort the items by book, chapter, and verse
usort($items, function ($a, $b) {
if ($a->book_nr != $b->book_nr) {
return $a->book_nr - $b->book_nr;
}
if ($a->chapter != $b->chapter) {
return $a->chapter - $b->chapter;
}
return $a->verse - $b->verse;
});
$this->sortIntoParagraphs($items);
$this->setUrls($translation);
return $this->paragraphs;
}
/**
* Reset properties before getting paragraphs
*
* @return void
* @since 2.0.1
*/
private function resetProperties(): void
{
$this->previousBook = 0;
$this->previousChapter = 0;
$this->previousVerse = 0;
$this->group = 0;
$this->paragraphs = [];
}
/**
* Sort items into paragraphs.
*
* @param array $items The items to be sorted into paragraphs.
*
* @return void
* @since 2.0.1
*/
private function sortIntoParagraphs($items): void
{
foreach ($items as $item)
{
if ($this->isNotSequential($item))
{
$this->group++;
}
$key = $this->getKey($item);
if (empty($this->paragraphs[$key]))
{
$this->setDetails($item, $key);
}
$this->addVerse($item, $key);
$this->updatePrevious($item);
}
}
/**
* Check if a verse is not sequential.
*
* @param object $item The verse to be checked.
*
* @return bool Whether the verse is not sequential.
* @since 2.0.1
*/
private function isNotSequential(object $item): bool
{
return $this->previousVerse > 0
&& ((int) $item->book_nr > $this->previousBook
|| (int) $item->chapter > $this->previousChapter
|| (int) $item->verse > $this->previousVerse + 1);
}
/**
* Generate a key based on the verse item.
*
* @param object $item The verse item.
*
* @return string The generated key.
* @since 2.0.1
*/
private function getKey(object $item): string
{
return $item->book_nr . '_' . $item->chapter . '_' . $this->group;
}
/**
* Set details for a verse.
*
* @param object $item The verse item.
* @param string $key The key for the paragraph.
*
* @return void
* @since 2.0.1
*/
private function setDetails(object $item, string $key): void
{
$this->paragraphs[$key]['name'] = $item->name . ' ' . $item->chapter;
$this->paragraphs[$key]['book'] = $item->name;
$this->paragraphs[$key]['data_book'] = preg_replace('/[^\p{L}\p{N}\s]/u', '', $item->name);
$this->paragraphs[$key]['chapter'] = $item->chapter;
}
/**
* Add a verse to the paragraphs.
*
* @param object $item The verse item.
* @param string $key The key for the paragraph.
*
* @return void
* @since 2.0.1
*/
private function addVerse(object $item, string $key): void
{
$this->paragraphs[$key]['verses'][$item->verse] = ['number' => $item->verse, 'text' => $item->text];
}
/**
* Update the previous verse, book, and chapter to the current one.
*
* @param object $item The current verse item.
*
* @return void
* @since 2.0.1
*/
private function updatePrevious(object $item): void
{
$this->previousVerse = (int) $item->verse;
$this->previousBook = (int) $item->book_nr;
$this->previousChapter = (int) $item->chapter;
}
/**
* Set URLs for the paragraphs.
*
* @param string $translation The translation to be used.
*
* @return void
* @since 2.0.1
*/
private function setUrls(string $translation): void
{
if ($this->paragraphs !== [])
{
foreach ($this->paragraphs as $chapter => &$paragraph)
{
$this->setVerseAndName($paragraph);
$this->setUrl($paragraph, $translation);
}
}
}
/**
* Set verse and name for a paragraph.
*
* @param array $paragraph The paragraph to be updated.
*
* @return void
* @since 2.0.1
*/
private function setVerseAndName(array &$paragraph): void
{
$verse = array_keys($paragraph['verses']);
$first = reset($verse);
$last = end($verse);
if ($first == $last)
{
$paragraph['name'] .= ':' . $first;
$paragraph['verse'] = $first;
}
else
{
$paragraph['name'] .= ':' . $first . '-' . $last;
$paragraph['verse'] = $first . '-' . $last;
}
}
/**
* Set URL for a paragraph.
*
* @param array $paragraph The paragraph to be updated.
* @param string $translation The translation to be used.
*
* @return void
* @since 2.0.1
*/
private function setUrl(array &$paragraph, string $translation): void
{
$paragraph['url'] = Route::_('index.php?option=com_getbible&view=app&t=' . $translation . '&ref=' . $paragraph['book'] . '&chapter=' . $paragraph['chapter'] . '&verse=' . $paragraph['verse']);
}
}

View File

@ -1,249 +1 @@
/** ###CODEPOWER###
* The Previous Book number
*
* @var int
* @since 2.0.1
*/
private int $previousBook = 0;
/**
* The Previous Chapter number
*
* @var int
* @since 2.0.1
*/
private int $previousChapter = 0;
/**
* The Previous Verse number
*
* @var int
* @since 2.0.1
*/
private int $previousVerse = 0;
/**
* The Current Group number
*
* @var int
* @since 2.0.1
*/
private int $group = 0;
/**
* The paragraphs being build
*
* @var array
* @since 2.0.1
*/
private array $paragraphs = [];
/**
* Main function to get sorted paragraphs.
*
* @param array $items The items to be sorted into paragraphs.
* @param string $translation The translation to be used.
*
* @return array The sorted paragraphs.
* @since 2.0.1
*/
public function get(array $items, string $translation = 'kjv'): array
{
$this->resetProperties();
// sort the items by book, chapter, and verse
usort($items, function ($a, $b) {
if ($a->book_nr != $b->book_nr) {
return $a->book_nr - $b->book_nr;
}
if ($a->chapter != $b->chapter) {
return $a->chapter - $b->chapter;
}
return $a->verse - $b->verse;
});
$this->sortIntoParagraphs($items);
$this->setUrls($translation);
return $this->paragraphs;
}
/**
* Reset properties before getting paragraphs
*
* @return void
* @since 2.0.1
*/
private function resetProperties(): void
{
$this->previousBook = 0;
$this->previousChapter = 0;
$this->previousVerse = 0;
$this->group = 0;
$this->paragraphs = [];
}
/**
* Sort items into paragraphs.
*
* @param array $items The items to be sorted into paragraphs.
*
* @return void
* @since 2.0.1
*/
private function sortIntoParagraphs($items): void
{
foreach ($items as $item)
{
if ($this->isNotSequential($item))
{
$this->group++;
}
$key = $this->getKey($item);
if (empty($this->paragraphs[$key]))
{
$this->setDetails($item, $key);
}
$this->addVerse($item, $key);
$this->updatePrevious($item);
}
}
/**
* Check if a verse is not sequential.
*
* @param object $item The verse to be checked.
*
* @return bool Whether the verse is not sequential.
* @since 2.0.1
*/
private function isNotSequential(object $item): bool
{
return $this->previousVerse > 0
&& ((int) $item->book_nr > $this->previousBook
|| (int) $item->chapter > $this->previousChapter
|| (int) $item->verse > $this->previousVerse + 1);
}
/**
* Generate a key based on the verse item.
*
* @param object $item The verse item.
*
* @return string The generated key.
* @since 2.0.1
*/
private function getKey(object $item): string
{
return $item->book_nr . '_' . $item->chapter . '_' . $this->group;
}
/**
* Set details for a verse.
*
* @param object $item The verse item.
* @param string $key The key for the paragraph.
*
* @return void
* @since 2.0.1
*/
private function setDetails(object $item, string $key): void
{
$this->paragraphs[$key]['name'] = $item->name . ' ' . $item->chapter;
$this->paragraphs[$key]['book'] = $item->name;
$this->paragraphs[$key]['data_book'] = preg_replace('/[^\p{L}\p{N}\s]/u', '', $item->name);
$this->paragraphs[$key]['chapter'] = $item->chapter;
}
/**
* Add a verse to the paragraphs.
*
* @param object $item The verse item.
* @param string $key The key for the paragraph.
*
* @return void
* @since 2.0.1
*/
private function addVerse(object $item, string $key): void
{
$this->paragraphs[$key]['verses'][$item->verse] = ['number' => $item->verse, 'text' => $item->text];
}
/**
* Update the previous verse, book, and chapter to the current one.
*
* @param object $item The current verse item.
*
* @return void
* @since 2.0.1
*/
private function updatePrevious(object $item): void
{
$this->previousVerse = (int) $item->verse;
$this->previousBook = (int) $item->book_nr;
$this->previousChapter = (int) $item->chapter;
}
/**
* Set URLs for the paragraphs.
*
* @param string $translation The translation to be used.
*
* @return void
* @since 2.0.1
*/
private function setUrls(string $translation): void
{
if ($this->paragraphs !== [])
{
foreach ($this->paragraphs as $chapter => &$paragraph)
{
$this->setVerseAndName($paragraph);
$this->setUrl($paragraph, $translation);
}
}
}
/**
* Set verse and name for a paragraph.
*
* @param array $paragraph The paragraph to be updated.
*
* @return void
* @since 2.0.1
*/
private function setVerseAndName(array &$paragraph): void
{
$verse = array_keys($paragraph['verses']);
$first = reset($verse);
$last = end($verse);
if ($first == $last)
{
$paragraph['name'] .= ':' . $first;
$paragraph['verse'] = $first;
}
else
{
$paragraph['name'] .= ':' . $first . '-' . $last;
$paragraph['verse'] = $first . '-' . $last;
}
}
/**
* Set URL for a paragraph.
*
* @param array $paragraph The paragraph to be updated.
* @param string $translation The translation to be used.
*
* @return void
* @since 2.0.1
*/
private function setUrl(array &$paragraph, string $translation): void
{
$paragraph['url'] = Route::_('index.php?option=com_[[[component]]]&view=app&t=' . $translation . '&ref=' . $paragraph['book'] . '&chapter=' . $paragraph['chapter'] . '&verse=' . $paragraph['verse']);
}

View File

@ -1,18 +1 @@
{ ###POWERLINKER###
"add_head": "1",
"add_licensing_template": "2",
"extends": "0",
"guid": "4cfff1bc-02b3-4c52-9e6e-7ceefb505a32",
"implements": null,
"load_selection": null,
"name": "Paragraphs",
"power_version": "1.0.0",
"system_name": "Joomla.GetBible.Tagged.Paragraphs",
"type": "final class",
"use_selection": null,
"namespace": "VDM\\Joomla\\GetBible\\Tagged.Paragraphs",
"description": "The GetBible Tagged Paragraphs\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\\Router\\Route;",
"composer": ""
}

View File

@ -1,85 +1 @@
``` ###POWERREADME###
██████╗ ██████╗ ██╗ ██╗███████╗██████╗
██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗
██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝
██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
```
# 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)

View File

@ -9,141 +9,4 @@
* @license GNU General Public License version 2 or later; see LICENSE.txt * @license GNU General Public License version 2 or later; see LICENSE.txt
*/ */
namespace VDM\Joomla\GetBible\Service; ###POWERCODE###
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')
);
}
}

View File

@ -1,116 +1 @@
/** ###CODEPOWER###
* 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')
);
}

View File

@ -1,46 +1 @@
{ ###POWERLINKER###
"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": ""
}

View File

@ -1,117 +1 @@
``` ###POWERREADME###
██████╗ ██████╗ ██╗ ██╗███████╗██████╗
██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗
██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝
██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
```
# 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
+ getLoader(Container $container) : Loader
+ getLinker(Container $container) : Linker
+ getNote(Container $container) : Note
+ getTag(Container $container) : Tag
+ getTagged(Container $container) : Tagged
+ getTaggedParagraphs(Container $container) : Paragraphs
}
note right of App::register
Registers the service provider with a DI container.
since: 2.0.1
return: void
end note
note left 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 left 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 left of App::getLoader
Get the Loader class
since: 2.0.1
return: Loader
end note
note right of App::getLinker
Get the Linker class
since: 2.0.1
return: Linker
end note
note left of App::getNote
Get the Note class
since: 2.0.1
return: Note
end note
note right of App::getTag
Get the Tag class
since: 2.0.1
return: Tag
end note
note left of App::getTagged
Get the Tagged class
since: 2.0.1
return: Tagged
end note
note right of App::getTaggedParagraphs
Get the Paragraphs class
since: 2.0.1
return: Paragraphs
end note
@enduml
```
---
```
██╗ ██████╗██████╗
██║██╔════╝██╔══██╗
██║██║ ██████╔╝
██ ██║██║ ██╔══██╗
╚█████╔╝╚██████╗██████╔╝
╚════╝ ╚═════╝╚═════╝
```
> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder)

View File

@ -9,226 +9,4 @@
* @license GNU General Public License version 2 or later; see LICENSE.txt * @license GNU General Public License version 2 or later; see LICENSE.txt
*/ */
namespace VDM\Joomla\GetBible\Service; ###POWERCODE###
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\Loader;
use VDM\Joomla\GetBible\Linker;
use VDM\Joomla\GetBible\Note;
use VDM\Joomla\GetBible\Tag;
use VDM\Joomla\GetBible\Tagged;
use VDM\Joomla\GetBible\Tagged\Paragraphs;
/**
* 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(Loader::class, 'GetBible.Loader')
->share('GetBible.Loader', [$this, 'getLoader'], true);
$container->alias(Linker::class, 'GetBible.Linker')
->share('GetBible.Linker', [$this, 'getLinker'], true);
$container->alias(Note::class, 'GetBible.Note')
->share('GetBible.Note', [$this, 'getNote'], true);
$container->alias(Tag::class, 'GetBible.Tag')
->share('GetBible.Tag', [$this, 'getTag'], true);
$container->alias(Tagged::class, 'GetBible.Tagged')
->share('GetBible.Tagged', [$this, 'getTagged'], true);
$container->alias(Paragraphs::class, 'GetBible.Tagged.Paragraphs')
->share('GetBible.Tagged.Paragraphs', [$this, 'getTaggedParagraphs'], 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 Loader class
*
* @param Container $container The DI container.
*
* @return Loader
* @since 2.0.1
*/
public function getLoader(Container $container): Loader
{
return new Loader(
$container->get('GetBible.Load'),
$container->get('GetBible.Watcher')
);
}
/**
* Get the Linker class
*
* @param Container $container The DI container.
*
* @return Linker
* @since 2.0.1
*/
public function getLinker(Container $container): Linker
{
return new Linker(
$container->get('GetBible.Load'),
$container->get('GetBible.Insert'),
$container->get('GetBible.Update'),
$container->get('GetBible.Utilities.Session')
);
}
/**
* Get the Note class
*
* @param Container $container The DI container.
*
* @return Note
* @since 2.0.1
*/
public function getNote(Container $container): Note
{
return new Note(
$container->get('GetBible.Load'),
$container->get('GetBible.Insert'),
$container->get('GetBible.Update'),
$container->get('GetBible.Linker')
);
}
/**
* Get the Tag class
*
* @param Container $container The DI container.
*
* @return Tag
* @since 2.0.1
*/
public function getTag(Container $container): Tag
{
return new Tag(
$container->get('GetBible.Load'),
$container->get('GetBible.Insert'),
$container->get('GetBible.Update'),
$container->get('GetBible.Linker')
);
}
/**
* Get the Tagged class
*
* @param Container $container The DI container.
*
* @return Tagged
* @since 2.0.1
*/
public function getTagged(Container $container): Tagged
{
return new Tagged(
$container->get('GetBible.Load'),
$container->get('GetBible.Insert'),
$container->get('GetBible.Update'),
$container->get('GetBible.Linker')
);
}
/**
* Get the Paragraphs class
*
* @param Container $container The DI container.
*
* @return Paragraphs
* @since 2.0.1
*/
public function getTaggedParagraphs(Container $container): Paragraphs
{
return new Paragraphs();
}
}

View File

@ -1,197 +1 @@
/** ###CODEPOWER###
* 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(Loader::class, 'GetBible.Loader')
->share('GetBible.Loader', [$this, 'getLoader'], true);
$container->alias(Linker::class, 'GetBible.Linker')
->share('GetBible.Linker', [$this, 'getLinker'], true);
$container->alias(Note::class, 'GetBible.Note')
->share('GetBible.Note', [$this, 'getNote'], true);
$container->alias(Tag::class, 'GetBible.Tag')
->share('GetBible.Tag', [$this, 'getTag'], true);
$container->alias(Tagged::class, 'GetBible.Tagged')
->share('GetBible.Tagged', [$this, 'getTagged'], true);
$container->alias(Paragraphs::class, 'GetBible.Tagged.Paragraphs')
->share('GetBible.Tagged.Paragraphs', [$this, 'getTaggedParagraphs'], 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 Loader class
*
* @param Container $container The DI container.
*
* @return Loader
* @since 2.0.1
*/
public function getLoader(Container $container): Loader
{
return new Loader(
$container->get('GetBible.Load'),
$container->get('GetBible.Watcher')
);
}
/**
* Get the Linker class
*
* @param Container $container The DI container.
*
* @return Linker
* @since 2.0.1
*/
public function getLinker(Container $container): Linker
{
return new Linker(
$container->get('GetBible.Load'),
$container->get('GetBible.Insert'),
$container->get('GetBible.Update'),
$container->get('GetBible.Utilities.Session')
);
}
/**
* Get the Note class
*
* @param Container $container The DI container.
*
* @return Note
* @since 2.0.1
*/
public function getNote(Container $container): Note
{
return new Note(
$container->get('GetBible.Load'),
$container->get('GetBible.Insert'),
$container->get('GetBible.Update'),
$container->get('GetBible.Linker')
);
}
/**
* Get the Tag class
*
* @param Container $container The DI container.
*
* @return Tag
* @since 2.0.1
*/
public function getTag(Container $container): Tag
{
return new Tag(
$container->get('GetBible.Load'),
$container->get('GetBible.Insert'),
$container->get('GetBible.Update'),
$container->get('GetBible.Linker')
);
}
/**
* Get the Tagged class
*
* @param Container $container The DI container.
*
* @return Tagged
* @since 2.0.1
*/
public function getTagged(Container $container): Tagged
{
return new Tagged(
$container->get('GetBible.Load'),
$container->get('GetBible.Insert'),
$container->get('GetBible.Update'),
$container->get('GetBible.Linker')
);
}
/**
* Get the Paragraphs class
*
* @param Container $container The DI container.
*
* @return Paragraphs
* @since 2.0.1
*/
public function getTaggedParagraphs(Container $container): Paragraphs
{
return new Paragraphs();
}

View File

@ -1,62 +1 @@
{ ###POWERLINKER###
"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": "fb5683e2-67ec-413d-96fa-8465fd2f511c",
"as": "default"
},
"use_selection5": {
"use": "36ab759f-7b42-4465-9c17-56ba1dd05f90",
"as": "default"
},
"use_selection6": {
"use": "ebda6bd8-95b9-468b-a521-974205146018",
"as": "default"
},
"use_selection7": {
"use": "67f91b8b-7b48-4dbb-bbd5-7945c174622a",
"as": "default"
},
"use_selection8": {
"use": "2315a1c5-bcf6-401a-8d11-60f4d6d12dbb",
"as": "default"
},
"use_selection9": {
"use": "4cfff1bc-02b3-4c52-9e6e-7ceefb505a32",
"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": ""
}

View File

@ -1,96 +1 @@
``` ###POWERREADME###
██████╗ ██████╗ ██╗ ██╗███████╗██████╗
██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗
██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝
██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
```
# final class Tag (Details)
> namespace: **VDM\Joomla\GetBible**
```uml
@startuml
class Tag << (F,LightGreen) >> #Green {
# Load $load
# Insert $insert
# Update $update
# Linker $linker
+ __construct(Load $load, Insert $insert, ...)
+ create(string $name, ?string $description) : ?array
+ update(string $tag, string $name, ...) : ?array
+ delete(string $tag) : ?array
- get(string $linker, string $name) : ?object
- createTag(string $linker, string $name, ...) : bool
}
note right of Tag::__construct
Constructor
since: 2.0.1
arguments:
Load $load
Insert $insert
Update $update
Linker $linker
end note
note right of Tag::create
Create a tag
since: 2.0.1
return: ?array
end note
note right of Tag::update
Update a tag
since: 2.0.1
return: ?array
arguments:
string $tag
string $name
?string $description
end note
note right of Tag::delete
Delete a tag
since: 2.0.1
return: ?array
end note
note right of Tag::get
Get a tag
since: 2.0.1
return: ?object
end note
note right of Tag::createTag
Create a Tag
since: 2.0.1
return: bool
arguments:
string $linker
string $name
?string $description
end note
@enduml
```
---
```
██╗ ██████╗██████╗
██║██╔════╝██╔══██╗
██║██║ ██████╔╝
██ ██║██║ ██╔══██╗
╚█████╔╝╚██████╗██████╔╝
╚════╝ ╚═════╝╚═════╝
```
> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder)

View File

@ -9,285 +9,4 @@
* @license GNU General Public License version 2 or later; see LICENSE.txt * @license GNU General Public License version 2 or later; see LICENSE.txt
*/ */
namespace VDM\Joomla\GetBible; ###POWERCODE###
use Joomla\CMS\Language\Text;
use VDM\Joomla\GetBible\Database\Load;
use VDM\Joomla\GetBible\Database\Insert;
use VDM\Joomla\GetBible\Database\Update;
use VDM\Joomla\GetBible\Linker;
use VDM\Joomla\Utilities\GuidHelper;
/**
* The GetBible Tag
*
* @since 2.0.1
*/
final class Tag
{
/**
* 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 Linker class
*
* @var Linker
* @since 2.0.1
*/
protected Linker $linker;
/**
* Constructor
*
* @param Load $load The load object.
* @param Insert $insert The insert object.
* @param Update $update The update object.
* @param Linker $linker The linker object.
*
* @since 2.0.1
*/
public function __construct(
Load $load,
Insert $insert,
Update $update,
Linker $linker)
{
$this->load = $load;
$this->insert = $insert;
$this->update = $update;
$this->linker = $linker;
}
/**
* Create a tag
*
* @param string $name The tag name being created
* @param string|null $description The tag description being created
*
* @return array|null Array of the tag values on success
* @since 2.0.1
**/
public function create(string $name, ?string $description): ?array
{
// make sure the linker has access
if (($linker = $this->linker->get()) === null)
{
return [
'error' => Text::_("COM_GETBIBLE_WITHOUT_SELECTING_THE_CORRECT_FAVOURITE_VERSEBR_YOU_CANT_PERFORM_THE_INITIAL_ACTION"),
'access_required' => true
];
}
// get tag if it exist
$name = trim($name);
if (($tag = $this->get($linker, $name)) !== null)
{
// publish if not published
if ($tag->published != 1 && !$this->update->value(1, 'published', $tag->id, 'id', 'tag'))
{
return [
'error' => Text::_('COM_GETBIBLE_TAG_ALREADY_EXIST_BUT_COULD_NOT_BE_REACTIVATED')
];
}
// update the description if it does not match
$description = $description ?? '';
$description = trim($description);
if ($tag->description !== $description && $this->update->value($description, 'description', $tag->id, 'id', 'tag'))
{
$tag->description = $description;
}
$tag->published = 1;
$tag->success = Text::_('COM_GETBIBLE_THE_TAG_WAS_SUCCESSFULLY_REACTIVATED');
return (array) $tag;
}
// create a new tag
elseif (strlen($name) >= 2 && $this->createTag($linker, $name, $description)
&& ($tag = $this->get($linker, $name)) !== null)
{
$tag->success = Text::_('COM_GETBIBLE_THE_TAG_WAS_SUCCESSFULLY_CREATED');
return (array) $tag;
}
return null;
}
/**
* Update a tag
*
* @param string $tag The tag GUID value
* @param string $name The tag name being created
* @param string|null $description The tag description being created
*
* @return array|null Array of the tag values on success
* @since 2.0.1
**/
public function update(string $tag, string $name, ?string $description): ?array
{
// make sure the linker has access
if (($linker = $this->linker->get()) === null)
{
return [
'error' => Text::_("COM_GETBIBLE_WITHOUT_SELECTING_THE_CORRECT_FAVOURITE_VERSEBR_YOU_CANT_PERFORM_THE_INITIAL_ACTION"),
'access_required' => true
];
}
// get tag if it exist
$name = trim($name);
$tag = trim($tag);
if (($_tag = $this->load->item(['linker' => $linker, 'guid' => $tag], 'tag')) !== null)
{
// publish if not published
if ($_tag->published != 1 && !$this->update->value(1, 'published', $_tag->id, 'id', 'tag'))
{
return [
'error' => Text::_('COM_GETBIBLE_TAG_FOUND_BUT_COULD_NOT_BE_REACTIVATED')
];
}
// update the description if it does not match
$description = $description ?? '';
$description = trim($description);
$_tag->description = $_tag->description ?? '';
if ($_tag->description !== $description && $this->update->value($description, 'description', $_tag->id, 'id', 'tag'))
{
$_tag->description = $description;
}
// update the name if it does not match
if (strlen($name) >= 2 && $_tag->name !== $name && $this->update->value($name, 'name', $_tag->id, 'id', 'tag'))
{
$_tag->name = $name;
}
$_tag->published = 1;
$_tag->success = Text::_('COM_GETBIBLE_THE_TAG_WAS_SUCCESSFULLY_UPDATED');
return (array) $_tag;
}
//elseif (($_tag = $this->load->item(['guid' => $tag], 'tag')) !== null)
//{
// we may need to add this
//}
return [
'error' => Text::_("COM_GETBIBLE_THIS_TAG_DOESNT_BELONG_TO_YOU_THUS_YOU_CANNOT_EDIT_IT")
];
}
/**
* Delete a tag
*
* @param string $tag The tagged verse GUID value
*
* @return array|null Array of the message on success
* @since 2.0.1
**/
public function delete(string $tag): ?array
{
// make sure the linker has access
if (($linker = $this->linker->get()) === null)
{
return [
'error' => Text::_("COM_GETBIBLE_WITHOUT_SELECTING_THE_CORRECT_FAVOURITE_VERSEBR_YOU_CANT_PERFORM_THE_INITIAL_ACTION"),
'access_required' => true
];
}
// make sure the linker has access to delete this tag
if (($id = $this->load->value(['guid' => $tag, 'linker' => $linker], 'id', 'tag')) !== null && $id > 0
&& $this->update->value(-2, 'published', $id, 'id', 'tag'))
{
return [
'success' => Text::_('COM_GETBIBLE_TAG_SUCCESSFULLY_DELETED')
];
}
return [
'error' => Text::_("COM_GETBIBLE_THIS_TAG_DOESNT_BELONG_TO_YOU_THUS_YOU_CANNOT_DELETE_IT")
];
}
/**
* Get a tag
*
* @param string $linker The linker GUID value
* @param string $name The tag name
*
* @return object|null Array of the tagged verse values on success
* @since 2.0.1
**/
private function get(
string $linker,
string $name
): ?object
{
// get tag if it exist
if (($tag = $this->load->item([
'linker' => $linker,
'name' => $name
], 'tag')) !== null)
{
return $tag;
}
return null;
}
/**
* Create a Tag
*
* @param string $linker The linker GUID value
* @param string $name The tag name
* @param string|null $description The tag description being created
*
* @return bool True on success
* @since 2.0.1
**/
private function createTag(
string $linker,
string $name,
?string $description
): bool
{
$guid = (string) GuidHelper::get();
while (!GuidHelper::valid($guid, 'tag', 0, 'getbible'))
{
// must always be set
$guid = (string) GuidHelper::get();
}
return $this->insert->row([
'access' => 0,
'linker' => $linker,
'name' => $name,
'description' => $description ?? '',
'guid' => $guid
], 'tag');
}
}

View File

@ -1,262 +1 @@
/** ###CODEPOWER###
* 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 Linker class
*
* @var Linker
* @since 2.0.1
*/
protected Linker $linker;
/**
* Constructor
*
* @param Load $load The load object.
* @param Insert $insert The insert object.
* @param Update $update The update object.
* @param Linker $linker The linker object.
*
* @since 2.0.1
*/
public function __construct(
Load $load,
Insert $insert,
Update $update,
Linker $linker)
{
$this->load = $load;
$this->insert = $insert;
$this->update = $update;
$this->linker = $linker;
}
/**
* Create a tag
*
* @param string $name The tag name being created
* @param string|null $description The tag description being created
*
* @return array|null Array of the tag values on success
* @since 2.0.1
**/
public function create(string $name, ?string $description): ?array
{
// make sure the linker has access
if (($linker = $this->linker->get()) === null)
{
return [
'error' => Text::_("Without selecting the correct favourite verse,<br />you can't perform the initial action."),
'access_required' => true
];
}
// get tag if it exist
$name = trim($name);
if (($tag = $this->get($linker, $name)) !== null)
{
// publish if not published
if ($tag->published != 1 && !$this->update->value(1, 'published', $tag->id, 'id', 'tag'))
{
return [
'error' => Text::_('Tag already exist, but could not be reactivated.')
];
}
// update the description if it does not match
$description = $description ?? '';
$description = trim($description);
if ($tag->description !== $description && $this->update->value($description, 'description', $tag->id, 'id', 'tag'))
{
$tag->description = $description;
}
$tag->published = 1;
$tag->success = Text::_('The tag was successfully reactivated.');
return (array) $tag;
}
// create a new tag
elseif (strlen($name) >= 2 && $this->createTag($linker, $name, $description)
&& ($tag = $this->get($linker, $name)) !== null)
{
$tag->success = Text::_('The tag was successfully created.');
return (array) $tag;
}
return null;
}
/**
* Update a tag
*
* @param string $tag The tag GUID value
* @param string $name The tag name being created
* @param string|null $description The tag description being created
*
* @return array|null Array of the tag values on success
* @since 2.0.1
**/
public function update(string $tag, string $name, ?string $description): ?array
{
// make sure the linker has access
if (($linker = $this->linker->get()) === null)
{
return [
'error' => Text::_("Without selecting the correct favourite verse,<br />you can't perform the initial action."),
'access_required' => true
];
}
// get tag if it exist
$name = trim($name);
$tag = trim($tag);
if (($_tag = $this->load->item(['linker' => $linker, 'guid' => $tag], 'tag')) !== null)
{
// publish if not published
if ($_tag->published != 1 && !$this->update->value(1, 'published', $_tag->id, 'id', 'tag'))
{
return [
'error' => Text::_('Tag found, but could not be reactivated.')
];
}
// update the description if it does not match
$description = $description ?? '';
$description = trim($description);
$_tag->description = $_tag->description ?? '';
if ($_tag->description !== $description && $this->update->value($description, 'description', $_tag->id, 'id', 'tag'))
{
$_tag->description = $description;
}
// update the name if it does not match
if (strlen($name) >= 2 && $_tag->name !== $name && $this->update->value($name, 'name', $_tag->id, 'id', 'tag'))
{
$_tag->name = $name;
}
$_tag->published = 1;
$_tag->success = Text::_('The tag was successfully updated.');
return (array) $_tag;
}
//elseif (($_tag = $this->load->item(['guid' => $tag], 'tag')) !== null)
//{
// we may need to add this
//}
return [
'error' => Text::_("This tag doesn't belong to you, thus you cannot edit it.")
];
}
/**
* Delete a tag
*
* @param string $tag The tagged verse GUID value
*
* @return array|null Array of the message on success
* @since 2.0.1
**/
public function delete(string $tag): ?array
{
// make sure the linker has access
if (($linker = $this->linker->get()) === null)
{
return [
'error' => Text::_("Without selecting the correct favourite verse,<br />you can't perform the initial action."),
'access_required' => true
];
}
// make sure the linker has access to delete this tag
if (($id = $this->load->value(['guid' => $tag, 'linker' => $linker], 'id', 'tag')) !== null && $id > 0
&& $this->update->value(-2, 'published', $id, 'id', 'tag'))
{
return [
'success' => Text::_('Tag successfully deleted.')
];
}
return [
'error' => Text::_("This tag doesn't belong to you, thus you cannot delete it.")
];
}
/**
* Get a tag
*
* @param string $linker The linker GUID value
* @param string $name The tag name
*
* @return object|null Array of the tagged verse values on success
* @since 2.0.1
**/
private function get(
string $linker,
string $name
): ?object
{
// get tag if it exist
if (($tag = $this->load->item([
'linker' => $linker,
'name' => $name
], 'tag')) !== null)
{
return $tag;
}
return null;
}
/**
* Create a Tag
*
* @param string $linker The linker GUID value
* @param string $name The tag name
* @param string|null $description The tag description being created
*
* @return bool True on success
* @since 2.0.1
**/
private function createTag(
string $linker,
string $name,
?string $description
): bool
{
$guid = (string) GuidHelper::get();
while (!GuidHelper::valid($guid, 'tag', 0, '[[[component]]]'))
{
// must always be set
$guid = (string) GuidHelper::get();
}
return $this->insert->row([
'access' => 0,
'linker' => $linker,
'name' => $name,
'description' => $description ?? '',
'guid' => $guid
], 'tag');
}

View File

@ -1,39 +1 @@
{ ###POWERLINKER###
"add_head": "1",
"add_licensing_template": "2",
"extends": "0",
"guid": "67f91b8b-7b48-4dbb-bbd5-7945c174622a",
"implements": null,
"load_selection": null,
"name": "Tag",
"power_version": "1.0.0",
"system_name": "Joomla.GetBible.Tag",
"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": "36ab759f-7b42-4465-9c17-56ba1dd05f90",
"as": "default"
},
"use_selection4": {
"use": "9c513baf-b279-43fd-ae29-a585c8cbc4f0",
"as": "default"
}
},
"namespace": "VDM\\Joomla\\GetBible\\Tag",
"description": "The GetBible Tag\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\\Language\\Text;",
"composer": ""
}

View File

@ -1,69 +1 @@
``` ###POWERREADME###
██████╗ ██████╗ ██╗ ██╗███████╗██████╗
██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗
██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝
██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
```
# 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)

View File

@ -9,73 +9,4 @@
* @license GNU General Public License version 2 or later; see LICENSE.txt * @license GNU General Public License version 2 or later; see LICENSE.txt
*/ */
namespace VDM\Joomla\GetBible; ###POWERCODE###
use VDM\Joomla\Utilities\Component\Helper;
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';
}
}

View File

@ -1,54 +1 @@
/** ###CODEPOWER###
* 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';
}

View File

@ -1,23 +1 @@
{ ###POWERLINKER###
"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": "640b5352-fb09-425f-a26e-cd44eda03f15",
"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": ""
}

View File

@ -1,44 +1 @@
``` ###POWERREADME###
██████╗ ██████╗ ██╗ ██╗███████╗██████╗
██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗
██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝
██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
```
# 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)

View File

@ -9,59 +9,4 @@
* @license GNU General Public License version 2 or later; see LICENSE.txt * @license GNU General Public License version 2 or later; see LICENSE.txt
*/ */
namespace VDM\Joomla\GetBible\Abstraction; ###POWERCODE###
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;
}
}

View File

@ -1,39 +1 @@
/** ###CODEPOWER###
* 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;
}

View File

@ -1,31 +1 @@
{ ###POWERLINKER###
"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": ""
}

View File

@ -1,75 +1 @@
``` ###POWERREADME###
██████╗ ██████╗ ██╗ ██╗███████╗██████╗
██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗
██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝
██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
```
# final class Translation (Details)
> namespace: **VDM\Joomla\GetBible\Watcher**
```uml
@startuml
class Translation << (F,LightGreen) >> #Green {
# Translations $translations
+ __construct(Load $load, Insert $insert, ...)
+ translations() : bool
+ sync(string $translation) : bool
- load(string $translation) : bool
- update() : bool
}
note right of Translation::__construct
Constructor
since: 2.0.1
arguments:
Load $load
Insert $insert
Update $update
Translations $translations
end note
note right of Translation::translations
Update translations details
since: 2.0.1
return: bool
end note
note right of Translation::sync
Sync the target being watched
since: 2.0.1
return: bool
end note
note right of Translation::load
Load Translation
since: 2.0.1
return: bool
end note
note right of Translation::update
Trigger the update of all translations
since: 2.0.1
return: bool
end note
@enduml
```
---
```
██╗ ██████╗██████╗
██║██╔════╝██╔══██╗
██║██║ ██████╔╝
██ ██║██║ ██╔══██╗
╚█████╔╝╚██████╗██████╔╝
╚════╝ ╚═════╝╚═════╝
```
> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder)

View File

@ -9,191 +9,4 @@
* @license GNU General Public License version 2 or later; see LICENSE.txt * @license GNU General Public License version 2 or later; see LICENSE.txt
*/ */
namespace VDM\Joomla\GetBible\Watcher; ###POWERCODE###
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\Abstraction\Watcher;
/**
* The GetBible Translation Watcher
*
* @since 2.0.1
*/
final class Translation extends Watcher
{
/**
* The Translations class
*
* @var Translations
* @since 2.0.1
*/
protected Translations $translations;
/**
* 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.
*
* @since 2.0.1
*/
public function __construct(
Load $load,
Insert $insert,
Update $update,
Translations $translations)
{
// load the parent constructor
parent::__construct($load, $insert, $update);
$this->translations = $translations;
// set the table
$this->table = 'translation';
}
/**
* Update translations details
*
* @return bool True on success
* @since 2.0.1
*/
public function translations(): bool
{
return $this->update();
}
/**
* Sync the target being watched
*
* @param string $translation The translation.
*
* @return bool True on success
* @since 2.0.1
*/
public function sync(string $translation): bool
{
// load the target if not found
if ($this->load($translation))
{
if ($this->isNew() || $this->hold())
{
return true;
}
// get API hash value
$hash = $this->translations->sha($translation);
// confirm hash has not changed
if (hash_equals($hash, $this->target->sha))
{
return $this->bump();
}
if ($this->update())
{
return true;
}
}
return false;
}
/**
* Load Translation
*
* @param string $translation The translation.
*
* @return bool True if translation found
* @since 2.0.1
*/
private function load(string $translation): bool
{
// check local value
if (($this->target = $this->load->item(['abbreviation' => $translation], $this->table)) !== null)
{
return true;
}
// get all the translations
$translations = $this->translations->list();
// check return data
if (!isset($translations->{$translation}) || !isset($translations->{$translation}->sha))
{
return false;
}
// add them to the database
$this->insert->items((array) $translations, 'translation');
if (($this->target = $this->load->item(['abbreviation' => $translation], $this->table)) !== null)
{
$this->fresh = true;
}
return $this->fresh;
}
/**
* Trigger the update of all translations
*
* @return bool True if update was a success
* @since 2.0.1
*/
private function update(): bool
{
// get translations from the API
if (($translations = $this->translations->list()) === null)
{
return false;
}
// get the local published translations
$local_translations = $this->load->items(['published' => 1], $this->table);
$update = [];
$insert = [];
$match = ['key' => 'abbreviation', 'value' => ''];
// dynamic update all translations
foreach ($translations as $translation)
{
// check if the verse exist
$match['value'] = $translation->abbreviation ?? null;
if ($local_translations !== null && ($object = $this->getTarget($match, $local_translations)) !== null)
{
$translation->id = $object->id;
$translation->created = $this->today;
$update[] = $translation;
}
else
{
$insert[] = $translation;
}
}
// check if we have values to insert
$inserted = false;
if ($insert !== [])
{
$inserted = $this->insert->items($insert, $this->table);
}
// update the local values
if ($update !== [] && $this->update->items($update, 'id', $this->table))
{
return true;
}
return $inserted;
}
}

View File

@ -1,169 +1 @@
/** ###CODEPOWER###
* The Translations class
*
* @var Translations
* @since 2.0.1
*/
protected Translations $translations;
/**
* 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.
*
* @since 2.0.1
*/
public function __construct(
Load $load,
Insert $insert,
Update $update,
Translations $translations)
{
// load the parent constructor
parent::__construct($load, $insert, $update);
$this->translations = $translations;
// set the table
$this->table = 'translation';
}
/**
* Update translations details
*
* @return bool True on success
* @since 2.0.1
*/
public function translations(): bool
{
return $this->update();
}
/**
* Sync the target being watched
*
* @param string $translation The translation.
*
* @return bool True on success
* @since 2.0.1
*/
public function sync(string $translation): bool
{
// load the target if not found
if ($this->load($translation))
{
if ($this->isNew() || $this->hold())
{
return true;
}
// get API hash value
$hash = $this->translations->sha($translation);
// confirm hash has not changed
if (hash_equals($hash, $this->target->sha))
{
return $this->bump();
}
if ($this->update())
{
return true;
}
}
return false;
}
/**
* Load Translation
*
* @param string $translation The translation.
*
* @return bool True if translation found
* @since 2.0.1
*/
private function load(string $translation): bool
{
// check local value
if (($this->target = $this->load->item(['abbreviation' => $translation], $this->table)) !== null)
{
return true;
}
// get all the translations
$translations = $this->translations->list();
// check return data
if (!isset($translations->{$translation}) || !isset($translations->{$translation}->sha))
{
return false;
}
// add them to the database
$this->insert->items((array) $translations, 'translation');
if (($this->target = $this->load->item(['abbreviation' => $translation], $this->table)) !== null)
{
$this->fresh = true;
}
return $this->fresh;
}
/**
* Trigger the update of all translations
*
* @return bool True if update was a success
* @since 2.0.1
*/
private function update(): bool
{
// get translations from the API
if (($translations = $this->translations->list()) === null)
{
return false;
}
// get the local published translations
$local_translations = $this->load->items(['published' => 1], $this->table);
$update = [];
$insert = [];
$match = ['key' => 'abbreviation', 'value' => ''];
// dynamic update all translations
foreach ($translations as $translation)
{
// check if the verse exist
$match['value'] = $translation->abbreviation ?? null;
if ($local_translations !== null && ($object = $this->getTarget($match, $local_translations)) !== null)
{
$translation->id = $object->id;
$translation->created = $this->today;
$update[] = $translation;
}
else
{
$insert[] = $translation;
}
}
// check if we have values to insert
$inserted = false;
if ($insert !== [])
{
$inserted = $this->insert->items($insert, $this->table);
}
// update the local values
if ($update !== [] && $this->update->items($update, 'id', $this->table))
{
return true;
}
return $inserted;
}

View File

@ -1,35 +1 @@
{ ###POWERLINKER###
"add_head": "0",
"add_licensing_template": "2",
"extends": "37e36c41-16a7-4c5d-972c-99acad5fd0b1",
"guid": "7d592acd-f031-4d0f-b667-584c88ae0495",
"implements": null,
"load_selection": null,
"name": "Translation",
"power_version": "1.0.0",
"system_name": "Joomla.GetBible.Watcher.Translation",
"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"
}
},
"namespace": "VDM\\Joomla\\GetBible\\Watcher.Translation",
"description": "The GetBible Translation 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": "",
"composer": ""
}

View File

@ -1,21 +1 @@
``` ###POWERREADME###
██████╗ ██████╗ ██╗ ██╗███████╗██████╗
██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗
██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝
██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
```
> Error adding class diagram
---
```
██╗ ██████╗██████╗
██║██╔════╝██╔══██╗
██║██║ ██████╔╝
██ ██║██║ ██╔══██╗
╚█████╔╝╚██████╗██████╔╝
╚════╝ ╚═════╝╚═════╝
```
> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder)

View File

@ -9,15 +9,4 @@
* @license GNU General Public License version 2 or later; see LICENSE.txt * @license GNU General Public License version 2 or later; see LICENSE.txt
*/ */
namespace VDM\Joomla\GetBible; ###POWERCODE###
/**
* The GetBible Search
*
* @since 2.0.1
*/
final class Search
{
}

View File

@ -1,18 +1 @@
{ ###POWERLINKER###
"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": ""
}

View File

@ -1,53 +1 @@
``` ###POWERREADME###
██████╗ ██████╗ ██╗ ██╗███████╗██████╗
██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗
██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝
██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
```
# final class SessionHelper (Details)
> namespace: **VDM\Joomla\GetBible\Utilities**
```uml
@startuml
class SessionHelper << (F,LightGreen) >> #Green {
# Session $session
+ __construct(?Session $session = null)
+ get(string $name, mixed $default = null) : mixed
+ set(string $name, mixed $value = null) : mixed
}
note right of SessionHelper::__construct
Constructor
since: 3.2.0
end note
note right of SessionHelper::get
Get data from the session store
since: 2.1.0
return: mixed
end note
note right of SessionHelper::set
Set data into the session store.
since: 2.1.0
return: mixed
end note
@enduml
```
---
```
██╗ ██████╗██████╗
██║██╔════╝██╔══██╗
██║██║ ██████╔╝
██ ██║██║ ██╔══██╗
╚█████╔╝╚██████╗██████╔╝
╚════╝ ╚═════╝╚═════╝
```
> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder)

View File

@ -9,68 +9,4 @@
* @license GNU General Public License version 2 or later; see LICENSE.txt * @license GNU General Public License version 2 or later; see LICENSE.txt
*/ */
namespace VDM\Joomla\GetBible\Utilities; ###POWERCODE###
use Joomla\CMS\Factory as JoomlaFactory;
use Joomla\CMS\Session\Session;
use VDM\Joomla\Utilities\GuidHelper;
/**
* The GetBible Session Helper
* - Just for easy set and get
*
* @since 2.0.1
*/
final class SessionHelper
{
/**
* The Session
*
* @var Session
* @since 3.2.0
*/
protected Session $session;
/**
* Constructor
*
* @param Session|null $session The Joomla session.
*
* @since 3.2.0
*/
public function __construct(?Session $session = null)
{
$this->session = $session ?: JoomlaFactory::getSession();
}
/**
* Get data from the session store
*
* @param string $name Name of a variable
* @param mixed $default Default value of a variable if not set
*
* @return mixed Value of a variable
* @since 2.1.0
*/
public function get(string $name, $default = null)
{
return $this->session->get($name, $default);
}
/**
* Set data into the session store.
*
* @param string $name Name of a variable.
* @param mixed $value Value of a variable.
*
* @return mixed Old value of a variable.
* @since 2.1.0
*/
public function set($name, $value = null)
{
return $this->session->set($name, $value);
}
}

View File

@ -1,47 +1 @@
/** ###CODEPOWER###
* The Session
*
* @var Session
* @since 3.2.0
*/
protected Session $session;
/**
* Constructor
*
* @param Session|null $session The Joomla session.
*
* @since 3.2.0
*/
public function __construct(?Session $session = null)
{
$this->session = $session ?: JoomlaFactory::getSession();
}
/**
* Get data from the session store
*
* @param string $name Name of a variable
* @param mixed $default Default value of a variable if not set
*
* @return mixed Value of a variable
* @since 2.1.0
*/
public function get(string $name, $default = null)
{
return $this->session->get($name, $default);
}
/**
* Set data into the session store.
*
* @param string $name Name of a variable.
* @param mixed $value Value of a variable.
*
* @return mixed Old value of a variable.
* @since 2.1.0
*/
public function set($name, $value = null)
{
return $this->session->set($name, $value);
}

View File

@ -1,23 +1 @@
{ ###POWERLINKER###
"add_head": "1",
"add_licensing_template": "2",
"extends": "0",
"guid": "84e84cd1-c938-4559-8414-d5692db4118e",
"implements": null,
"load_selection": null,
"name": "SessionHelper",
"power_version": "1.0.0",
"system_name": "Joomla.GetBible.Utilities.SessionHelper",
"type": "final class",
"use_selection": {
"use_selection0": {
"use": "9c513baf-b279-43fd-ae29-a585c8cbc4f0",
"as": "default"
}
},
"namespace": "VDM\\Joomla\\GetBible\\Utilities.SessionHelper",
"description": "The GetBible Session Helper\r\n - Just for easy set and get\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\\Factory as JoomlaFactory;\r\nuse Joomla\\CMS\\Session\\Session;",
"composer": ""
}

View File

@ -1,156 +1 @@
``` ###POWERREADME###
██████╗ ██████╗ ██╗ ██╗███████╗██████╗
██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗
██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝
██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
```
# final class Word (Details)
> namespace: **VDM\Joomla\GetBible\Data**
```uml
@startuml
class Word << (F,LightGreen) >> #Green {
# Verse $verse
# Config $config
# Prompt $prompt
# array $words
# array $sequential
# ?array $verses
# ?array $valid
+ __construct(Verse $verse, Config $config, ...)
+ getNumber() : string
+ getText() : string
- get() : ?object
- loadWordData(string $cacheKey, string $verses, ...) : ?object
- selectedWordNumbers(string $verse, string $words) : array
- selectedWordNumbersToString(array $wordNumberArray) : string
- selectedWord(array $words) : array
- selectedWordToString(array $wordArray) : string
- splitAndTrim(string $str) : array
- isValidWordNumber(int $verseNumber, int $wordNumber) : bool
- isSequential(array $arr) : bool
- generateCacheKey(string $abbreviation, int $book, ...) : string
}
note right of Word::__construct
Constructor
since: 2.0.1
arguments:
Verse $verse
Config $config
Prompt $prompt
end note
note left of Word::getNumber
Get the word number/s
since: 2.0.1
return: string
end note
note right of Word::getText
Get the word text
since: 2.0.1
return: string
end note
note left of Word::get
Get the words
since: 2.0.1
return: ?object
end note
note right of Word::loadWordData
Loads the word data
since: 2.0.1
return: ?object
arguments:
string $cacheKey
string $verses
string $words
end note
note left of Word::selectedWordNumbers
Build word number array from verse and words.
since: 2.0.1
return: array
end note
note right of Word::selectedWordNumbersToString
Converts word number array to string.
since: 2.0.1
return: string
end note
note left of Word::selectedWord
Build word array from verse and words.
since: 2.0.1
return: array
end note
note right of Word::selectedWordToString
Converts word array to string.
since: 2.0.1
return: string
end note
note left of Word::splitAndTrim
Split string by '-' and trim each element.
since: 2.0.1
return: array
end note
note right of Word::isValidWordNumber
Check if a word exist in a verse
since: 2.0.1
return: bool
end note
note left of Word::isSequential
Check if an array values is sequential.
since: 2.0.1
return: bool
end note
note right of Word::generateCacheKey
Generates a cache key based on the abbreviation, book, chapter, verses, and words
since: 2.0.1
return: string
arguments:
string $abbreviation
int $book
int $chapter
string $verses
string $words
end note
@enduml
```
---
```
██╗ ██████╗██████╗
██║██╔════╝██╔══██╗
██║██║ ██████╔╝
██ ██║██║ ██╔══██╗
╚█████╔╝╚██████╗██████╔╝
╚════╝ ╚═════╝╚═════╝
```
> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder)

View File

@ -9,383 +9,4 @@
* @license GNU General Public License version 2 or later; see LICENSE.txt * @license GNU General Public License version 2 or later; see LICENSE.txt
*/ */
namespace VDM\Joomla\GetBible\Data; ###POWERCODE###
use VDM\Joomla\GetBible\Data\Verse;
use VDM\Joomla\GetBible\Openai\Config;
use VDM\Joomla\GetBible\Data\Prompt;
/**
* The GetBible Word Data
*
* @since 2.0.1
*/
final class Word
{
/**
* The Verse class
*
* @var Verse
* @since 2.0.1
*/
protected Verse $verse;
/**
* The Config class
*
* @var Config
* @since 2.0.1
*/
protected Config $config;
/**
* The Prompt class
*
* @var Prompt
* @since 2.0.1
*/
protected Prompt $prompt;
/**
* The words
*
* @var array
* @since 2.0.1
*/
protected array $words = [];
/**
* The check if words are sequential
*
* @var array
* @since 2.0.1
*/
protected array $sequential = [];
/**
* The active verses
*
* @var array|null
* @since 2.0.1
*/
protected ?array $verses = null;
/**
* The valid verse numbers
*
* @var array|null
* @since 2.0.1
*/
protected ?array $valid = null;
/**
* Constructor
*
* @param Verse $verse The verse object.
* @param Config $config The config object.
* @param Prompt $prompt The prompt object.
*
* @since 2.0.1
*/
public function __construct(Verse $verse, Config $config, Prompt $prompt)
{
$this->verse = $verse;
$this->config = $config;
$this->prompt = $prompt;
}
/**
* Get the word number/s
*
* @return string The word number/s
* @since 2.0.1
*/
public function getNumber(): string
{
$word = $this->get();
return $word ? $word->number ?? '' : '';
}
/**
* Get the word text
*
* @return string The verse text
* @since 2.0.1
*/
public function getText(): string
{
$word = $this->get();
return $word ? $word->text ?? '' : '';
}
/**
* Get the words
*
* @return object|null True on success
* @since 2.0.1
*/
private function get(): ?object
{
$abbreviation = $this->config->get('translation');
$book = $this->config->get('book');
$chapter = $this->config->get('chapter');
$verse = $this->config->get('verse');
$words = $this->config->get('words');
if (empty($abbreviation) || empty($book) || empty($chapter) || empty($verse) || empty($words))
{
return null;
}
$cacheKey = $this->generateCacheKey($abbreviation, $book, $chapter, $verse, $words);
if (isset($this->words[$cacheKey]))
{
return $this->words[$cacheKey];
}
return $this->loadWordData($cacheKey, $verse, $words);
}
/**
* Loads the word data
*
* @param string $cacheKey The cache key.
* @param string $verses The selected verses.
* @param string $words The selected words.
*
* @return object|null The loaded word data, or null if not found or an error occurred.
* @since 2.0.1
*/
private function loadWordData(string $cacheKey, string $verses, string $words): ?object
{
$this->valid = $this->verse->getValid();
$this->verses = $this->verse->getVerse();
if (empty($this->verses) || empty($this->valid))
{
$this->words[$cacheKey] = null;
return null;
}
$data = new \stdClass();
$data->number_array = $this->selectedWordNumbers($verses, $words);
if (empty($data->number_array))
{
$this->words[$cacheKey] = null;
return null;
}
$data->number = $this->selectedWordNumbersToString($data->number_array);
$data->text_array = $this->selectedWord($data->number_array);
if (empty($data->text_array))
{
$this->words[$cacheKey] = null;
return null;
}
$data->text = $this->selectedWordToString($data->text_array);
$this->words[$cacheKey] = $data;
return $this->words[$cacheKey];
}
/**
* Build word number array from verse and words.
*
* @param string $verse The verse selected.
* @param string $words The words words.
*
* @return array The word number array.
* @since 2.0.1
*/
private function selectedWordNumbers(string $verse, string $words): array
{
$verse = $this->splitAndTrim($verse);
$words = $this->splitAndTrim($words);
$array = [];
$integration = $this->prompt->getIntegration();
$this->sequential = [];
foreach ($verse as $key => $verse)
{
if (isset($words[$key]) && in_array($verse, $this->valid) &&
$this->isValidWordNumber($verse, $words[$key]))
{
$array[$verse][] = $words[$key];
if ($integration == 1)
{
break;
}
}
}
return $array;
}
/**
* Converts word number array to string.
*
* @param array $wordNumberArray The word number array.
*
* @return string The word number string.
* @since 2.0.1
*/
private function selectedWordNumbersToString(array $wordNumberArray): string
{
$word_number = [];
if (count($wordNumberArray) == 1)
{
$word_number[] = implode(',', array_values($wordNumberArray)[0]);
}
else
{
foreach ($wordNumberArray as $verse => $words)
{
$word_number[] = $verse . ':' . implode(',', $words);
}
}
return implode(';', $word_number);
}
/**
* Build word array from verse and words.
*
* @param array $words The words array.
*
* @return array The word array.
* @since 2.0.1
*/
private function selectedWord(array $words): array
{
$word_array = [];
foreach ($words as $verse => $word_numbers)
{
foreach ($word_numbers as $word)
{
if (isset($this->verses[$verse][$word]))
{
$word_array[$verse][] = $this->verses[$verse][$word];
}
}
}
return $word_array;
}
/**
* Converts word array to string.
*
* @param array $wordArray The word array.
*
* @return string The word string.
* @since 2.0.1
*/
private function selectedWordToString(array $wordArray): string
{
$word_number = [];
foreach ($wordArray as $verse => $words)
{
$word_number[] = implode(' ', $words);
}
return implode(' ', $word_number);
}
/**
* Split string by '-' and trim each element.
*
* @param string $str The string to be split.
*
* @return array The splitted and trimmed array.
* @since 2.0.1
*/
private function splitAndTrim(string $str): array
{
if (strpos($str, '-') !== false)
{
$array = array_map('trim', explode('-', $str));
sort($array);
return $array;
}
return [trim($str)];
}
/**
* Check if a word exist in a verse
*
* @param int $verseNumber The verse number.
* @param int $wordNumber The word number.
*
* @return bool True on success
* @since 2.0.1
*/
private function isValidWordNumber(int $verseNumber, int $wordNumber): bool
{
// we add the next word number to check sequential selection of words
$this->sequential[$verseNumber][$wordNumber] = $wordNumber;
if (count($this->sequential[$verseNumber]) > 1 && !$this->isSequential($this->sequential[$verseNumber]))
{
return false;
}
return isset($this->verses[$verseNumber][$wordNumber]);
}
/**
* Check if an array values is sequential.
*
* @param array $arr The number array.
*
* @return bool true if sequential
* @since 2.0.1
*/
private function isSequential(array $arr): bool
{
$arr = array_values($arr); // Reset keys
for ($i = 0, $len = count($arr) - 1; $i < $len; $i++)
{
if ($arr[$i] + 1 !== $arr[$i + 1])
{
return false;
}
}
return true;
}
/**
* Generates a cache key based on the abbreviation, book, chapter, verses, and words
*
* @param string $abbreviation The translation abbreviation.
* @param int $book The book number.
* @param int $chapter The chapter number.
* @param string $verses The selected verses.
* @param string $words The selected words.
*
* @return string The generated cache key.
* @since 2.0.1
*/
private function generateCacheKey($abbreviation, $book, int $chapter, string $verses, string $words): string
{
return $abbreviation . '_' . $book . '_' . $chapter . '_' . $verses . '_' . $words;
}
}

View File

@ -1,363 +1 @@
/** ###CODEPOWER###
* The Verse class
*
* @var Verse
* @since 2.0.1
*/
protected Verse $verse;
/**
* The Config class
*
* @var Config
* @since 2.0.1
*/
protected Config $config;
/**
* The Prompt class
*
* @var Prompt
* @since 2.0.1
*/
protected Prompt $prompt;
/**
* The words
*
* @var array
* @since 2.0.1
*/
protected array $words = [];
/**
* The check if words are sequential
*
* @var array
* @since 2.0.1
*/
protected array $sequential = [];
/**
* The active verses
*
* @var array|null
* @since 2.0.1
*/
protected ?array $verses = null;
/**
* The valid verse numbers
*
* @var array|null
* @since 2.0.1
*/
protected ?array $valid = null;
/**
* Constructor
*
* @param Verse $verse The verse object.
* @param Config $config The config object.
* @param Prompt $prompt The prompt object.
*
* @since 2.0.1
*/
public function __construct(Verse $verse, Config $config, Prompt $prompt)
{
$this->verse = $verse;
$this->config = $config;
$this->prompt = $prompt;
}
/**
* Get the word number/s
*
* @return string The word number/s
* @since 2.0.1
*/
public function getNumber(): string
{
$word = $this->get();
return $word ? $word->number ?? '' : '';
}
/**
* Get the word text
*
* @return string The verse text
* @since 2.0.1
*/
public function getText(): string
{
$word = $this->get();
return $word ? $word->text ?? '' : '';
}
/**
* Get the words
*
* @return object|null True on success
* @since 2.0.1
*/
private function get(): ?object
{
$abbreviation = $this->config->get('translation');
$book = $this->config->get('book');
$chapter = $this->config->get('chapter');
$verse = $this->config->get('verse');
$words = $this->config->get('words');
if (empty($abbreviation) || empty($book) || empty($chapter) || empty($verse) || empty($words))
{
return null;
}
$cacheKey = $this->generateCacheKey($abbreviation, $book, $chapter, $verse, $words);
if (isset($this->words[$cacheKey]))
{
return $this->words[$cacheKey];
}
return $this->loadWordData($cacheKey, $verse, $words);
}
/**
* Loads the word data
*
* @param string $cacheKey The cache key.
* @param string $verses The selected verses.
* @param string $words The selected words.
*
* @return object|null The loaded word data, or null if not found or an error occurred.
* @since 2.0.1
*/
private function loadWordData(string $cacheKey, string $verses, string $words): ?object
{
$this->valid = $this->verse->getValid();
$this->verses = $this->verse->getVerse();
if (empty($this->verses) || empty($this->valid))
{
$this->words[$cacheKey] = null;
return null;
}
$data = new \stdClass();
$data->number_array = $this->selectedWordNumbers($verses, $words);
if (empty($data->number_array))
{
$this->words[$cacheKey] = null;
return null;
}
$data->number = $this->selectedWordNumbersToString($data->number_array);
$data->text_array = $this->selectedWord($data->number_array);
if (empty($data->text_array))
{
$this->words[$cacheKey] = null;
return null;
}
$data->text = $this->selectedWordToString($data->text_array);
$this->words[$cacheKey] = $data;
return $this->words[$cacheKey];
}
/**
* Build word number array from verse and words.
*
* @param string $verse The verse selected.
* @param string $words The words words.
*
* @return array The word number array.
* @since 2.0.1
*/
private function selectedWordNumbers(string $verse, string $words): array
{
$verse = $this->splitAndTrim($verse);
$words = $this->splitAndTrim($words);
$array = [];
$integration = $this->prompt->getIntegration();
$this->sequential = [];
foreach ($verse as $key => $verse)
{
if (isset($words[$key]) && in_array($verse, $this->valid) &&
$this->isValidWordNumber($verse, $words[$key]))
{
$array[$verse][] = $words[$key];
if ($integration == 1)
{
break;
}
}
}
return $array;
}
/**
* Converts word number array to string.
*
* @param array $wordNumberArray The word number array.
*
* @return string The word number string.
* @since 2.0.1
*/
private function selectedWordNumbersToString(array $wordNumberArray): string
{
$word_number = [];
if (count($wordNumberArray) == 1)
{
$word_number[] = implode(',', array_values($wordNumberArray)[0]);
}
else
{
foreach ($wordNumberArray as $verse => $words)
{
$word_number[] = $verse . ':' . implode(',', $words);
}
}
return implode(';', $word_number);
}
/**
* Build word array from verse and words.
*
* @param array $words The words array.
*
* @return array The word array.
* @since 2.0.1
*/
private function selectedWord(array $words): array
{
$word_array = [];
foreach ($words as $verse => $word_numbers)
{
foreach ($word_numbers as $word)
{
if (isset($this->verses[$verse][$word]))
{
$word_array[$verse][] = $this->verses[$verse][$word];
}
}
}
return $word_array;
}
/**
* Converts word array to string.
*
* @param array $wordArray The word array.
*
* @return string The word string.
* @since 2.0.1
*/
private function selectedWordToString(array $wordArray): string
{
$word_number = [];
foreach ($wordArray as $verse => $words)
{
$word_number[] = implode(' ', $words);
}
return implode(' ', $word_number);
}
/**
* Split string by '-' and trim each element.
*
* @param string $str The string to be split.
*
* @return array The splitted and trimmed array.
* @since 2.0.1
*/
private function splitAndTrim(string $str): array
{
if (strpos($str, '-') !== false)
{
$array = array_map('trim', explode('-', $str));
sort($array);
return $array;
}
return [trim($str)];
}
/**
* Check if a word exist in a verse
*
* @param int $verseNumber The verse number.
* @param int $wordNumber The word number.
*
* @return bool True on success
* @since 2.0.1
*/
private function isValidWordNumber(int $verseNumber, int $wordNumber): bool
{
// we add the next word number to check sequential selection of words
$this->sequential[$verseNumber][$wordNumber] = $wordNumber;
if (count($this->sequential[$verseNumber]) > 1 && !$this->isSequential($this->sequential[$verseNumber]))
{
return false;
}
return isset($this->verses[$verseNumber][$wordNumber]);
}
/**
* Check if an array values is sequential.
*
* @param array $arr The number array.
*
* @return bool true if sequential
* @since 2.0.1
*/
private function isSequential(array $arr): bool
{
$arr = array_values($arr); // Reset keys
for ($i = 0, $len = count($arr) - 1; $i < $len; $i++)
{
if ($arr[$i] + 1 !== $arr[$i + 1])
{
return false;
}
}
return true;
}
/**
* Generates a cache key based on the abbreviation, book, chapter, verses, and words
*
* @param string $abbreviation The translation abbreviation.
* @param int $book The book number.
* @param int $chapter The chapter number.
* @param string $verses The selected verses.
* @param string $words The selected words.
*
* @return string The generated cache key.
* @since 2.0.1
*/
private function generateCacheKey($abbreviation, $book, int $chapter, string $verses, string $words): string
{
return $abbreviation . '_' . $book . '_' . $chapter . '_' . $verses . '_' . $words;
}

View File

@ -1,31 +1 @@
{ ###POWERLINKER###
"add_head": "0",
"add_licensing_template": "2",
"extends": "0",
"guid": "899551ac-943e-4f81-becd-7e15c41f1081",
"implements": null,
"load_selection": null,
"name": "Word",
"power_version": "1.0.0",
"system_name": "Joomla.GetBible.Data.Word",
"type": "final class",
"use_selection": {
"use_selection0": {
"use": "e3798c7e-aae1-4e38-ba78-6018ce94630b",
"as": "default"
},
"use_selection1": {
"use": "3af7864b-f1f3-491e-b16f-0504f890086d",
"as": "default"
},
"use_selection2": {
"use": "3f785d63-a592-463d-9f5f-b2b5a8edd561",
"as": "default"
}
},
"namespace": "VDM\\Joomla\\GetBible\\Data.Word",
"description": "The GetBible Word Data\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": ""
}

View File

@ -1,140 +1 @@
``` ###POWERREADME###
██████╗ ██████╗ ██╗ ██╗███████╗██████╗
██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗
██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝
██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
```
# 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
# string $active
+ __construct(Config $config, Http $http, ...)
+ isDaily() : bool
+ setActive(?int $book, ?int $chapter, ...) : void
+ 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::isDaily
method to validate if this is still the daily verse
since: 2.0.1
return: bool
end note
note right of DailyScripture::setActive
Set Current active verse
since: 2.0.1
return: void
arguments:
?int $book
?int $chapter
?string $verses
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)

View File

@ -9,266 +9,4 @@
* @license GNU General Public License version 2 or later; see LICENSE.txt * @license GNU General Public License version 2 or later; see LICENSE.txt
*/ */
namespace VDM\Joomla\GetBible; ###POWERCODE###
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;
/**
* The active verse
*
* @var string
* @since 2.0.1
*/
protected string $active = '';
/**
* 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;
}
/**
* method to validate if this is still the daily verse
*
* @return bool true if it is daily
* @since 2.0.1
*/
public function isDaily(): bool
{
return (strcasecmp($this->active, $this->reference) == 0);
}
/**
* Set Current active verse
*
* @return int|null Book number
* @return int|null Chapter number
* @return string|null Verses
*
* @since 2.0.1
*/
public function setActive(?int $book, ?int $chapter, ?string $verses): void
{
$active = '';
if ($book !== null)
{
$active = $book;
if ($chapter !== null)
{
$this->book = (int) $book;
$this->chapter = (int) $chapter;
$active .= ' ' . $chapter;
if ($verses !== null)
{
$active .= ':' . $verses;
$this->verses = $verses;
}
$this->active = $active;
}
}
}
/**
* 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)
{
$this->active = $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);
}
}

View File

@ -1,246 +1 @@
/** ###CODEPOWER###
* 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;
/**
* The active verse
*
* @var string
* @since 2.0.1
*/
protected string $active = '';
/**
* 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;
}
/**
* method to validate if this is still the daily verse
*
* @return bool true if it is daily
* @since 2.0.1
*/
public function isDaily(): bool
{
return (strcasecmp($this->active, $this->reference) == 0);
}
/**
* Set Current active verse
*
* @return int|null Book number
* @return int|null Chapter number
* @return string|null Verses
*
* @since 2.0.1
*/
public function setActive(?int $book, ?int $chapter, ?string $verses): void
{
$active = '';
if ($book !== null)
{
$active = $book;
if ($chapter !== null)
{
$this->book = (int) $book;
$this->chapter = (int) $chapter;
$active .= ' ' . $chapter;
if ($verses !== null)
{
$active .= ':' . $verses;
$this->verses = $verses;
}
$this->active = $active;
}
}
}
/**
* 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)
{
$this->active = $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);
}

View File

@ -1,31 +1 @@
{ ###POWERLINKER###
"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": ""
}

View File

@ -1,93 +1 @@
``` ###POWERREADME###
██████╗ ██████╗ ██╗ ██╗███████╗██████╗
██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗
██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝
██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
```
# 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)

View File

@ -9,151 +9,4 @@
* @license GNU General Public License version 2 or later; see LICENSE.txt * @license GNU General Public License version 2 or later; see LICENSE.txt
*/ */
namespace VDM\Joomla\GetBible\Model; ###POWERCODE###
use VDM\Joomla\Abstraction\BaseConfig as 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 '';
}
}

View File

@ -1,129 +1 @@
/** ###CODEPOWER###
* 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 '';
}

View File

@ -1,33 +1 @@
{ ###POWERLINKER###
"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": "ffbd4e1f-a342-4080-ab7d-1de3741bf319",
"as": "Config"
},
"use_selection1": {
"use": "ff8d5fdb-2d1f-4178-bd18-a43b8efd1068",
"as": "default"
},
"use_selection2": {
"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": ""
}

Some files were not shown because too many files have changed in this diff Show More