From 273d88dacfa6b9d819ce20173b57aa94d682150d Mon Sep 17 00:00:00 2001 From: aB0t Date: Tue, 26 Sep 2023 08:24:03 +0200 Subject: [PATCH] update 2023-09-26 08:24:03 --- README.md | 127 +- .../README.md | 135 +- .../code.php | 421 ++++++- .../code.power | 401 +++++- .../settings.json | 40 +- .../README.md | 54 +- .../code.php | 67 +- .../code.power | 49 +- .../settings.json | 31 +- .../README.md | 55 +- .../code.php | 76 +- .../code.power | 54 +- .../settings.json | 46 +- .../README.md | 66 +- .../code.php | 144 ++- .../code.power | 125 +- .../settings.json | 40 +- .../README.md | 126 +- .../code.php | 354 +++++- .../code.power | 330 ++++- .../settings.json | 44 +- .../README.md | 134 +- .../code.php | 266 +++- .../code.power | 238 +++- .../settings.json | 71 +- .../README.md | 205 +++- .../code.php | 608 ++++++++- .../code.power | 587 ++++++++- .../settings.json | 40 +- .../README.md | 91 +- .../code.php | 210 +++- .../code.power | 192 ++- .../settings.json | 32 +- .../README.md | 175 ++- .../code.php | 295 ++++- .../code.power | 276 ++++- .../settings.json | 24 +- .../README.md | 160 ++- .../code.php | 317 ++++- .../code.power | 301 ++++- .../settings.json | 28 +- .../README.md | 73 +- .../code.php | 190 ++- .../code.power | 172 ++- .../settings.json | 36 +- .../README.md | 62 +- .../code.php | 86 +- .../code.power | 71 +- .../settings.json | 19 +- .../README.md | 114 +- .../code.php | 204 +++- .../code.power | 188 ++- .../settings.json | 28 +- .../README.md | 123 +- .../code.php | 265 +++- .../code.power | 250 +++- .../settings.json | 19 +- .../README.md | 86 +- .../code.php | 139 ++- .../code.power | 117 +- .../settings.json | 47 +- .../README.md | 118 +- .../code.php | 224 +++- .../code.power | 198 ++- .../settings.json | 63 +- .../README.md | 97 +- .../code.php | 283 ++++- .../code.power | 263 +++- .../settings.json | 40 +- .../README.md | 70 +- .../code.php | 71 +- .../code.power | 55 +- .../settings.json | 24 +- .../README.md | 45 +- .../code.php | 57 +- .../code.power | 40 +- .../settings.json | 32 +- .../README.md | 76 +- .../code.php | 189 ++- .../code.power | 170 ++- .../settings.json | 36 +- .../README.md | 22 +- .../code.php | 13 +- .../settings.json | 19 +- .../README.md | 54 +- .../code.php | 66 +- .../code.power | 48 +- .../settings.json | 24 +- .../README.md | 157 ++- .../code.php | 381 +++++- .../code.power | 364 +++++- .../settings.json | 32 +- .../README.md | 141 ++- .../code.php | 264 +++- .../code.power | 247 +++- .../settings.json | 32 +- .../README.md | 94 +- .../code.php | 149 ++- .../code.power | 130 +- .../settings.json | 34 +- .../README.md | 89 +- .../code.php | 151 ++- .../code.power | 135 +- .../settings.json | 28 +- .../README.md | 59 +- .../code.php | 110 +- .../code.power | 98 +- .../settings.json | 19 +- .../README.md | 67 +- .../code.php | 90 +- .../code.power | 75 +- .../settings.json | 19 +- .../README.md | 70 +- .../code.php | 111 +- .../code.power | 91 +- .../settings.json | 39 +- .../README.md | 43 +- .../code.php | 34 +- .../code.power | 19 +- .../settings.json | 19 +- .../README.md | 94 +- .../code.php | 150 ++- .../code.power | 129 +- .../settings.json | 42 +- .../README.md | 54 +- .../code.php | 71 +- .../code.power | 53 +- .../settings.json | 31 +- .../README.md | 70 +- .../code.php | 111 +- .../code.power | 91 +- .../settings.json | 39 +- .../README.md | 78 +- .../code.php | 114 +- .../code.power | 93 +- .../settings.json | 43 +- .../README.md | 37 +- .../code.php | 38 +- .../code.power | 22 +- .../settings.json | 20 +- .../README.md | 71 +- .../code.php | 141 ++- .../code.power | 125 +- .../settings.json | 28 +- .../README.md | 54 +- .../code.php | 64 +- .../code.power | 49 +- .../settings.json | 19 +- .../README.md | 150 ++- .../code.php | 252 +++- .../code.power | 235 +++- .../settings.json | 32 +- .../README.md | 76 +- .../code.php | 208 +++- .../code.power | 189 ++- .../settings.json | 36 +- .../README.md | 80 +- .../code.php | 130 +- .../code.power | 114 +- .../settings.json | 28 +- .../README.md | 70 +- .../code.php | 116 +- .../code.power | 96 +- .../settings.json | 39 +- .../README.md | 59 +- .../code.php | 113 +- .../code.power | 96 +- .../settings.json | 28 +- .../README.md | 111 +- .../code.php | 158 ++- .../code.power | 142 ++- .../settings.json | 28 +- .../README.md | 166 ++- .../code.php | 443 ++++++- .../code.power | 425 ++++++- .../settings.json | 36 +- .../README.md | 98 +- .../code.php | 231 +++- .../code.power | 211 +++- .../settings.json | 40 +- .../README.md | 107 +- .../code.php | 298 ++++- .../code.power | 279 ++++- .../settings.json | 40 +- .../README.md | 53 +- .../code.php | 94 +- .../code.power | 77 +- .../settings.json | 32 +- .../README.md | 55 +- .../code.php | 76 +- .../code.power | 54 +- .../settings.json | 46 +- .../README.md | 150 ++- .../code.php | 333 ++++- .../code.power | 315 ++++- .../settings.json | 36 +- .../README.md | 80 +- .../code.php | 146 ++- .../code.power | 130 +- .../settings.json | 28 +- .../README.md | 48 +- .../code.php | 73 +- .../code.power | 56 +- .../settings.json | 28 +- .../README.md | 46 +- .../code.php | 53 +- .../code.power | 37 +- .../settings.json | 24 +- .../README.md | 30 +- .../code.php | 1084 ++++++++++++++++- .../code.power | 8 +- .../settings.json | 21 +- super-powers.json | 586 ++++++++- 213 files changed, 25589 insertions(+), 213 deletions(-) diff --git a/README.md b/README.md index 433b69e..9c21870 100644 --- a/README.md +++ b/README.md @@ -1 +1,126 @@ -###POWERREADME### \ No newline at end of file +``` +███████╗██╗ ██╗██████╗ ███████╗██████╗ +██╔════╝██║ ██║██╔══██╗██╔════╝██╔══██╗ +███████╗██║ ██║██████╔╝█████╗ ██████╔╝ +╚════██║██║ ██║██╔═══╝ ██╔══╝ ██╔══██╗ +███████║╚██████╔╝██║ ███████╗██║ ██║ +╚══════╝ ╚═════╝ ╚═╝ ╚══════╝╚═╝ ╚═╝ +██████╗ ██████╗ ██╗ ██╗███████╗██████╗ ███████╗ +██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗██╔════╝ +██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝███████╗ +██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗╚════██║ +██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║███████║ +╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝╚══════╝ +``` + +### 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) + diff --git a/src/07d3888a-5f35-4ba7-977f-fb2f5cf99061/README.md b/src/07d3888a-5f35-4ba7-977f-fb2f5cf99061/README.md index 433b69e..a8e01c4 100644 --- a/src/07d3888a-5f35-4ba7-977f-fb2f5cf99061/README.md +++ b/src/07d3888a-5f35-4ba7-977f-fb2f5cf99061/README.md @@ -1 +1,134 @@ -###POWERREADME### \ No newline at end of file +``` +██████╗ ██████╗ ██╗ ██╗███████╗██████╗ +██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗ +██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝ +██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗ +██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║ +╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝ +``` +# 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) + diff --git a/src/07d3888a-5f35-4ba7-977f-fb2f5cf99061/code.php b/src/07d3888a-5f35-4ba7-977f-fb2f5cf99061/code.php index 3d222d0..c38f519 100644 --- a/src/07d3888a-5f35-4ba7-977f-fb2f5cf99061/code.php +++ b/src/07d3888a-5f35-4ba7-977f-fb2f5cf99061/code.php @@ -9,4 +9,423 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ -###POWERCODE### +namespace VDM\Joomla\GetBible\Watcher; + + +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'); + } +} + diff --git a/src/07d3888a-5f35-4ba7-977f-fb2f5cf99061/code.power b/src/07d3888a-5f35-4ba7-977f-fb2f5cf99061/code.power index 69309b0..d578622 100644 --- a/src/07d3888a-5f35-4ba7-977f-fb2f5cf99061/code.power +++ b/src/07d3888a-5f35-4ba7-977f-fb2f5cf99061/code.power @@ -1 +1,400 @@ -###CODEPOWER### \ No newline at end of file + /** + * 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'); + } \ No newline at end of file diff --git a/src/07d3888a-5f35-4ba7-977f-fb2f5cf99061/settings.json b/src/07d3888a-5f35-4ba7-977f-fb2f5cf99061/settings.json index 6b3b222..031a79b 100644 --- a/src/07d3888a-5f35-4ba7-977f-fb2f5cf99061/settings.json +++ b/src/07d3888a-5f35-4ba7-977f-fb2f5cf99061/settings.json @@ -1 +1,39 @@ -###POWERLINKER### \ No newline at end of file +{ + "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 \r\n * @git 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": "" +} \ No newline at end of file diff --git a/src/116eb429-bc51-4d14-b9aa-7145c86a29d1/README.md b/src/116eb429-bc51-4d14-b9aa-7145c86a29d1/README.md index 433b69e..14eec52 100644 --- a/src/116eb429-bc51-4d14-b9aa-7145c86a29d1/README.md +++ b/src/116eb429-bc51-4d14-b9aa-7145c86a29d1/README.md @@ -1 +1,53 @@ -###POWERREADME### \ No newline at end of file +``` +██████╗ ██████╗ ██╗ ██╗███████╗██████╗ +██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗ +██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝ +██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗ +██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║ +╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝ +``` +# 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) + diff --git a/src/116eb429-bc51-4d14-b9aa-7145c86a29d1/code.php b/src/116eb429-bc51-4d14-b9aa-7145c86a29d1/code.php index 3d222d0..2fd9db7 100644 --- a/src/116eb429-bc51-4d14-b9aa-7145c86a29d1/code.php +++ b/src/116eb429-bc51-4d14-b9aa-7145c86a29d1/code.php @@ -9,4 +9,69 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ -###POWERCODE### +namespace VDM\Joomla\GetBible\Service; + + +use Joomla\DI\Container; +use Joomla\DI\ServiceProviderInterface; +use VDM\Joomla\GetBible\Model\Upsert; +use VDM\Joomla\GetBible\Model\Load; + + +/** + * The GetBible Model Service + * + * @since 2.0.1 + */ +class Model implements ServiceProviderInterface +{ + /** + * Registers the service provider with a DI container. + * + * @param Container $container The DI container. + * + * @return void + * @since 2.0.1 + */ + public function register(Container $container) + { + $container->alias(Upsert::class, 'GetBible.Model.Upsert') + ->share('GetBible.Model.Upsert', [$this, 'getUpsert'], true); + + $container->alias(Load::class, 'GetBible.Model.Load') + ->share('GetBible.Model.Load', [$this, 'getLoad'], true); + } + + /** + * Get the Upsert class + * + * @param Container $container The DI container. + * + * @return Upsert + * @since 2.0.1 + */ + public function getUpsert(Container $container): Upsert + { + return new Upsert( + $container->get('GetBible.Config'), + $container->get('GetBible.Table') + ); + } + + /** + * Get the Load class + * + * @param Container $container The DI container. + * + * @return Load + * @since 2.0.1 + */ + public function getLoad(Container $container): Load + { + return new Load( + $container->get('GetBible.Config'), + $container->get('GetBible.Table') + ); + } +} + diff --git a/src/116eb429-bc51-4d14-b9aa-7145c86a29d1/code.power b/src/116eb429-bc51-4d14-b9aa-7145c86a29d1/code.power index 69309b0..b81d844 100644 --- a/src/116eb429-bc51-4d14-b9aa-7145c86a29d1/code.power +++ b/src/116eb429-bc51-4d14-b9aa-7145c86a29d1/code.power @@ -1 +1,48 @@ -###CODEPOWER### \ No newline at end of file + /** + * 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') + ); + } \ No newline at end of file diff --git a/src/116eb429-bc51-4d14-b9aa-7145c86a29d1/settings.json b/src/116eb429-bc51-4d14-b9aa-7145c86a29d1/settings.json index 6b3b222..798e00d 100644 --- a/src/116eb429-bc51-4d14-b9aa-7145c86a29d1/settings.json +++ b/src/116eb429-bc51-4d14-b9aa-7145c86a29d1/settings.json @@ -1 +1,30 @@ -###POWERLINKER### \ No newline at end of file +{ + "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 \r\n * @git 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": "" +} \ No newline at end of file diff --git a/src/11892cfa-374e-4e3f-b0bc-531871c822d9/README.md b/src/11892cfa-374e-4e3f-b0bc-531871c822d9/README.md index 433b69e..565fc78 100644 --- a/src/11892cfa-374e-4e3f-b0bc-531871c822d9/README.md +++ b/src/11892cfa-374e-4e3f-b0bc-531871c822d9/README.md @@ -1 +1,54 @@ -###POWERREADME### \ No newline at end of file +``` +██████╗ ██████╗ ██╗ ██╗███████╗██████╗ +██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗ +██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝ +██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗ +██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║ +╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝ +``` +# 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) + diff --git a/src/11892cfa-374e-4e3f-b0bc-531871c822d9/code.php b/src/11892cfa-374e-4e3f-b0bc-531871c822d9/code.php index 3d222d0..4aeffeb 100644 --- a/src/11892cfa-374e-4e3f-b0bc-531871c822d9/code.php +++ b/src/11892cfa-374e-4e3f-b0bc-531871c822d9/code.php @@ -9,4 +9,78 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ -###POWERCODE### +namespace VDM\Joomla\GetBible; + + +use Joomla\DI\Container; +use VDM\Joomla\GetBible\Service\Api; +use VDM\Joomla\GetBible\Service\Utilities; +use VDM\Joomla\GetBible\Service\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()); + } +} + diff --git a/src/11892cfa-374e-4e3f-b0bc-531871c822d9/code.power b/src/11892cfa-374e-4e3f-b0bc-531871c822d9/code.power index 69309b0..09c8a68 100644 --- a/src/11892cfa-374e-4e3f-b0bc-531871c822d9/code.power +++ b/src/11892cfa-374e-4e3f-b0bc-531871c822d9/code.power @@ -1 +1,53 @@ -###CODEPOWER### \ No newline at end of file + /** + * 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()); + } \ No newline at end of file diff --git a/src/11892cfa-374e-4e3f-b0bc-531871c822d9/settings.json b/src/11892cfa-374e-4e3f-b0bc-531871c822d9/settings.json index 6b3b222..a67fbca 100644 --- a/src/11892cfa-374e-4e3f-b0bc-531871c822d9/settings.json +++ b/src/11892cfa-374e-4e3f-b0bc-531871c822d9/settings.json @@ -1 +1,45 @@ -###POWERLINKER### \ No newline at end of file +{ + "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 \r\n * @git 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": "" +} \ No newline at end of file diff --git a/src/17d87374-2953-4d6c-9fdd-4220d6ad1564/README.md b/src/17d87374-2953-4d6c-9fdd-4220d6ad1564/README.md index 433b69e..9f2d0a5 100644 --- a/src/17d87374-2953-4d6c-9fdd-4220d6ad1564/README.md +++ b/src/17d87374-2953-4d6c-9fdd-4220d6ad1564/README.md @@ -1 +1,65 @@ -###POWERREADME### \ No newline at end of file +``` +██████╗ ██████╗ ██╗ ██╗███████╗██████╗ +██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗ +██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝ +██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗ +██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║ +╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝ +``` +# 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) + diff --git a/src/17d87374-2953-4d6c-9fdd-4220d6ad1564/code.php b/src/17d87374-2953-4d6c-9fdd-4220d6ad1564/code.php index 3d222d0..904363c 100644 --- a/src/17d87374-2953-4d6c-9fdd-4220d6ad1564/code.php +++ b/src/17d87374-2953-4d6c-9fdd-4220d6ad1564/code.php @@ -9,4 +9,146 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ -###POWERCODE### +namespace VDM\Joomla\GetBible\Data; + + +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() + ]; + } +} + diff --git a/src/17d87374-2953-4d6c-9fdd-4220d6ad1564/code.power b/src/17d87374-2953-4d6c-9fdd-4220d6ad1564/code.power index 69309b0..a305d13 100644 --- a/src/17d87374-2953-4d6c-9fdd-4220d6ad1564/code.power +++ b/src/17d87374-2953-4d6c-9fdd-4220d6ad1564/code.power @@ -1 +1,124 @@ -###CODEPOWER### \ No newline at end of file + /** + * 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() + ]; + } \ No newline at end of file diff --git a/src/17d87374-2953-4d6c-9fdd-4220d6ad1564/settings.json b/src/17d87374-2953-4d6c-9fdd-4220d6ad1564/settings.json index 6b3b222..66d131f 100644 --- a/src/17d87374-2953-4d6c-9fdd-4220d6ad1564/settings.json +++ b/src/17d87374-2953-4d6c-9fdd-4220d6ad1564/settings.json @@ -1 +1,39 @@ -###POWERLINKER### \ No newline at end of file +{ + "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 \r\n * @git 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": "" +} \ No newline at end of file diff --git a/src/2315a1c5-bcf6-401a-8d11-60f4d6d12dbb/README.md b/src/2315a1c5-bcf6-401a-8d11-60f4d6d12dbb/README.md index 433b69e..c0f1c3b 100644 --- a/src/2315a1c5-bcf6-401a-8d11-60f4d6d12dbb/README.md +++ b/src/2315a1c5-bcf6-401a-8d11-60f4d6d12dbb/README.md @@ -1 +1,125 @@ -###POWERREADME### \ No newline at end of file +``` +██████╗ ██████╗ ██╗ ██╗███████╗██████╗ +██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗ +██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝ +██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗ +██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║ +╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝ +``` +# 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) + diff --git a/src/2315a1c5-bcf6-401a-8d11-60f4d6d12dbb/code.php b/src/2315a1c5-bcf6-401a-8d11-60f4d6d12dbb/code.php index 3d222d0..64416ea 100644 --- a/src/2315a1c5-bcf6-401a-8d11-60f4d6d12dbb/code.php +++ b/src/2315a1c5-bcf6-401a-8d11-60f4d6d12dbb/code.php @@ -9,4 +9,356 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ -###POWERCODE### +namespace VDM\Joomla\GetBible; + + +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'); + } +} + diff --git a/src/2315a1c5-bcf6-401a-8d11-60f4d6d12dbb/code.power b/src/2315a1c5-bcf6-401a-8d11-60f4d6d12dbb/code.power index 69309b0..8395d6b 100644 --- a/src/2315a1c5-bcf6-401a-8d11-60f4d6d12dbb/code.power +++ b/src/2315a1c5-bcf6-401a-8d11-60f4d6d12dbb/code.power @@ -1 +1,329 @@ -###CODEPOWER### \ No newline at end of file + /** + * 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,
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,
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 %s 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'); + } \ No newline at end of file diff --git a/src/2315a1c5-bcf6-401a-8d11-60f4d6d12dbb/settings.json b/src/2315a1c5-bcf6-401a-8d11-60f4d6d12dbb/settings.json index 6b3b222..15c3806 100644 --- a/src/2315a1c5-bcf6-401a-8d11-60f4d6d12dbb/settings.json +++ b/src/2315a1c5-bcf6-401a-8d11-60f4d6d12dbb/settings.json @@ -1 +1,43 @@ -###POWERLINKER### \ No newline at end of file +{ + "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 \r\n * @git 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": "" +} \ No newline at end of file diff --git a/src/3439e63b-d8f1-42ce-a765-60d56b1fbe21/README.md b/src/3439e63b-d8f1-42ce-a765-60d56b1fbe21/README.md index 433b69e..5ed91b9 100644 --- a/src/3439e63b-d8f1-42ce-a765-60d56b1fbe21/README.md +++ b/src/3439e63b-d8f1-42ce-a765-60d56b1fbe21/README.md @@ -1 +1,133 @@ -###POWERREADME### \ No newline at end of file +``` +██████╗ ██████╗ ██╗ ██╗███████╗██████╗ +██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗ +██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝ +██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗ +██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║ +╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝ +``` +# 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) + diff --git a/src/3439e63b-d8f1-42ce-a765-60d56b1fbe21/code.php b/src/3439e63b-d8f1-42ce-a765-60d56b1fbe21/code.php index 3d222d0..20eca16 100644 --- a/src/3439e63b-d8f1-42ce-a765-60d56b1fbe21/code.php +++ b/src/3439e63b-d8f1-42ce-a765-60d56b1fbe21/code.php @@ -9,4 +9,268 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ -###POWERCODE### +namespace VDM\Joomla\GetBible\Service; + + +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') + ); + } +} + diff --git a/src/3439e63b-d8f1-42ce-a765-60d56b1fbe21/code.power b/src/3439e63b-d8f1-42ce-a765-60d56b1fbe21/code.power index 69309b0..b7f7204 100644 --- a/src/3439e63b-d8f1-42ce-a765-60d56b1fbe21/code.power +++ b/src/3439e63b-d8f1-42ce-a765-60d56b1fbe21/code.power @@ -1 +1,237 @@ -###CODEPOWER### \ No newline at end of file + /** + * 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') + ); + } \ No newline at end of file diff --git a/src/3439e63b-d8f1-42ce-a765-60d56b1fbe21/settings.json b/src/3439e63b-d8f1-42ce-a765-60d56b1fbe21/settings.json index 6b3b222..e4a47e3 100644 --- a/src/3439e63b-d8f1-42ce-a765-60d56b1fbe21/settings.json +++ b/src/3439e63b-d8f1-42ce-a765-60d56b1fbe21/settings.json @@ -1 +1,70 @@ -###POWERLINKER### \ No newline at end of file +{ + "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 \r\n * @git 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": "" +} \ No newline at end of file diff --git a/src/36ab759f-7b42-4465-9c17-56ba1dd05f90/README.md b/src/36ab759f-7b42-4465-9c17-56ba1dd05f90/README.md index 433b69e..79478b5 100644 --- a/src/36ab759f-7b42-4465-9c17-56ba1dd05f90/README.md +++ b/src/36ab759f-7b42-4465-9c17-56ba1dd05f90/README.md @@ -1 +1,204 @@ -###POWERREADME### \ No newline at end of file +``` +██████╗ ██████╗ ██╗ ██╗███████╗██████╗ +██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗ +██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝ +██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗ +██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║ +╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝ +``` +# 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) + diff --git a/src/36ab759f-7b42-4465-9c17-56ba1dd05f90/code.php b/src/36ab759f-7b42-4465-9c17-56ba1dd05f90/code.php index 3d222d0..9a94bed 100644 --- a/src/36ab759f-7b42-4465-9c17-56ba1dd05f90/code.php +++ b/src/36ab759f-7b42-4465-9c17-56ba1dd05f90/code.php @@ -9,4 +9,610 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ -###POWERCODE### +namespace VDM\Joomla\GetBible; + + +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; + } +} + diff --git a/src/36ab759f-7b42-4465-9c17-56ba1dd05f90/code.power b/src/36ab759f-7b42-4465-9c17-56ba1dd05f90/code.power index 69309b0..9a17545 100644 --- a/src/36ab759f-7b42-4465-9c17-56ba1dd05f90/code.power +++ b/src/36ab759f-7b42-4465-9c17-56ba1dd05f90/code.power @@ -1 +1,586 @@ -###CODEPOWER### \ No newline at end of file + /** + * 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,
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; + } \ No newline at end of file diff --git a/src/36ab759f-7b42-4465-9c17-56ba1dd05f90/settings.json b/src/36ab759f-7b42-4465-9c17-56ba1dd05f90/settings.json index 6b3b222..604f5ff 100644 --- a/src/36ab759f-7b42-4465-9c17-56ba1dd05f90/settings.json +++ b/src/36ab759f-7b42-4465-9c17-56ba1dd05f90/settings.json @@ -1 +1,39 @@ -###POWERLINKER### \ No newline at end of file +{ + "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 \r\n * @git 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": "" +} \ No newline at end of file diff --git a/src/37e36c41-16a7-4c5d-972c-99acad5fd0b1/README.md b/src/37e36c41-16a7-4c5d-972c-99acad5fd0b1/README.md index 433b69e..5883bbe 100644 --- a/src/37e36c41-16a7-4c5d-972c-99acad5fd0b1/README.md +++ b/src/37e36c41-16a7-4c5d-972c-99acad5fd0b1/README.md @@ -1 +1,90 @@ -###POWERREADME### \ No newline at end of file +``` +██████╗ ██████╗ ██╗ ██╗███████╗██████╗ +██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗ +██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝ +██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗ +██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║ +╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝ +``` +# 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) + diff --git a/src/37e36c41-16a7-4c5d-972c-99acad5fd0b1/code.php b/src/37e36c41-16a7-4c5d-972c-99acad5fd0b1/code.php index 3d222d0..d37c895 100644 --- a/src/37e36c41-16a7-4c5d-972c-99acad5fd0b1/code.php +++ b/src/37e36c41-16a7-4c5d-972c-99acad5fd0b1/code.php @@ -9,4 +9,212 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ -###POWERCODE### +namespace VDM\Joomla\GetBible\Abstraction; + + +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; + } +} + diff --git a/src/37e36c41-16a7-4c5d-972c-99acad5fd0b1/code.power b/src/37e36c41-16a7-4c5d-972c-99acad5fd0b1/code.power index 69309b0..2e7f428 100644 --- a/src/37e36c41-16a7-4c5d-972c-99acad5fd0b1/code.power +++ b/src/37e36c41-16a7-4c5d-972c-99acad5fd0b1/code.power @@ -1 +1,191 @@ -###CODEPOWER### \ No newline at end of file + /** + * 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; + } \ No newline at end of file diff --git a/src/37e36c41-16a7-4c5d-972c-99acad5fd0b1/settings.json b/src/37e36c41-16a7-4c5d-972c-99acad5fd0b1/settings.json index 6b3b222..57dd256 100644 --- a/src/37e36c41-16a7-4c5d-972c-99acad5fd0b1/settings.json +++ b/src/37e36c41-16a7-4c5d-972c-99acad5fd0b1/settings.json @@ -1 +1,31 @@ -###POWERLINKER### \ No newline at end of file +{ + "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 \r\n * @git 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": "" +} \ No newline at end of file diff --git a/src/3af7864b-f1f3-491e-b16f-0504f890086d/README.md b/src/3af7864b-f1f3-491e-b16f-0504f890086d/README.md index 433b69e..6f03125 100644 --- a/src/3af7864b-f1f3-491e-b16f-0504f890086d/README.md +++ b/src/3af7864b-f1f3-491e-b16f-0504f890086d/README.md @@ -1 +1,174 @@ -###POWERREADME### \ No newline at end of file +``` +██████╗ ██████╗ ██╗ ██╗███████╗██████╗ +██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗ +██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝ +██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗ +██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║ +╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝ +``` +# 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) + diff --git a/src/3af7864b-f1f3-491e-b16f-0504f890086d/code.php b/src/3af7864b-f1f3-491e-b16f-0504f890086d/code.php index 3d222d0..1c95a39 100644 --- a/src/3af7864b-f1f3-491e-b16f-0504f890086d/code.php +++ b/src/3af7864b-f1f3-491e-b16f-0504f890086d/code.php @@ -9,4 +9,297 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ -###POWERCODE### +namespace VDM\Joomla\GetBible\Openai; + + +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); + } +} + diff --git a/src/3af7864b-f1f3-491e-b16f-0504f890086d/code.power b/src/3af7864b-f1f3-491e-b16f-0504f890086d/code.power index 69309b0..3a69462 100644 --- a/src/3af7864b-f1f3-491e-b16f-0504f890086d/code.power +++ b/src/3af7864b-f1f3-491e-b16f-0504f890086d/code.power @@ -1 +1,275 @@ -###CODEPOWER### \ No newline at end of file + /** + * 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); + } \ No newline at end of file diff --git a/src/3af7864b-f1f3-491e-b16f-0504f890086d/settings.json b/src/3af7864b-f1f3-491e-b16f-0504f890086d/settings.json index 6b3b222..8eb9664 100644 --- a/src/3af7864b-f1f3-491e-b16f-0504f890086d/settings.json +++ b/src/3af7864b-f1f3-491e-b16f-0504f890086d/settings.json @@ -1 +1,23 @@ -###POWERLINKER### \ No newline at end of file +{ + "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 \r\n * @git 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": "" +} \ No newline at end of file diff --git a/src/3f785d63-a592-463d-9f5f-b2b5a8edd561/README.md b/src/3f785d63-a592-463d-9f5f-b2b5a8edd561/README.md index 433b69e..f7f92fa 100644 --- a/src/3f785d63-a592-463d-9f5f-b2b5a8edd561/README.md +++ b/src/3f785d63-a592-463d-9f5f-b2b5a8edd561/README.md @@ -1 +1,159 @@ -###POWERREADME### \ No newline at end of file +``` +██████╗ ██████╗ ██╗ ██╗███████╗██████╗ +██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗ +██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝ +██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗ +██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║ +╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝ +``` +# 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) + diff --git a/src/3f785d63-a592-463d-9f5f-b2b5a8edd561/code.php b/src/3f785d63-a592-463d-9f5f-b2b5a8edd561/code.php index 3d222d0..cde1a2b 100644 --- a/src/3f785d63-a592-463d-9f5f-b2b5a8edd561/code.php +++ b/src/3f785d63-a592-463d-9f5f-b2b5a8edd561/code.php @@ -9,4 +9,319 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ -###POWERCODE### +namespace VDM\Joomla\GetBible\Data; + + +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]; + } +} + diff --git a/src/3f785d63-a592-463d-9f5f-b2b5a8edd561/code.power b/src/3f785d63-a592-463d-9f5f-b2b5a8edd561/code.power index 69309b0..3d89395 100644 --- a/src/3f785d63-a592-463d-9f5f-b2b5a8edd561/code.power +++ b/src/3f785d63-a592-463d-9f5f-b2b5a8edd561/code.power @@ -1 +1,300 @@ -###CODEPOWER### \ No newline at end of file + /** + * 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]; + } \ No newline at end of file diff --git a/src/3f785d63-a592-463d-9f5f-b2b5a8edd561/settings.json b/src/3f785d63-a592-463d-9f5f-b2b5a8edd561/settings.json index 6b3b222..0e2145c 100644 --- a/src/3f785d63-a592-463d-9f5f-b2b5a8edd561/settings.json +++ b/src/3f785d63-a592-463d-9f5f-b2b5a8edd561/settings.json @@ -1 +1,27 @@ -###POWERLINKER### \ No newline at end of file +{ + "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 \r\n * @git 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": "" +} \ No newline at end of file diff --git a/src/44c15b17-e096-47c0-8769-42ea9b692cb2/README.md b/src/44c15b17-e096-47c0-8769-42ea9b692cb2/README.md index 433b69e..7b4f400 100644 --- a/src/44c15b17-e096-47c0-8769-42ea9b692cb2/README.md +++ b/src/44c15b17-e096-47c0-8769-42ea9b692cb2/README.md @@ -1 +1,72 @@ -###POWERREADME### \ No newline at end of file +``` +██████╗ ██████╗ ██╗ ██╗███████╗██████╗ +██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗ +██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝ +██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗ +██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║ +╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝ +``` +# 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) + diff --git a/src/44c15b17-e096-47c0-8769-42ea9b692cb2/code.php b/src/44c15b17-e096-47c0-8769-42ea9b692cb2/code.php index 3d222d0..eacc4d5 100644 --- a/src/44c15b17-e096-47c0-8769-42ea9b692cb2/code.php +++ b/src/44c15b17-e096-47c0-8769-42ea9b692cb2/code.php @@ -9,4 +9,192 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ -###POWERCODE### +namespace VDM\Joomla\GetBible\Data; + + +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; + } +} + diff --git a/src/44c15b17-e096-47c0-8769-42ea9b692cb2/code.power b/src/44c15b17-e096-47c0-8769-42ea9b692cb2/code.power index 69309b0..5035c1a 100644 --- a/src/44c15b17-e096-47c0-8769-42ea9b692cb2/code.power +++ b/src/44c15b17-e096-47c0-8769-42ea9b692cb2/code.power @@ -1 +1,171 @@ -###CODEPOWER### \ No newline at end of file + /** + * 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; + } \ No newline at end of file diff --git a/src/44c15b17-e096-47c0-8769-42ea9b692cb2/settings.json b/src/44c15b17-e096-47c0-8769-42ea9b692cb2/settings.json index 6b3b222..7ef8e77 100644 --- a/src/44c15b17-e096-47c0-8769-42ea9b692cb2/settings.json +++ b/src/44c15b17-e096-47c0-8769-42ea9b692cb2/settings.json @@ -1 +1,35 @@ -###POWERLINKER### \ No newline at end of file +{ + "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 \r\n * @git 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": "" +} \ No newline at end of file diff --git a/src/491c91ce-6355-40d3-bbbd-622473c6c026/README.md b/src/491c91ce-6355-40d3-bbbd-622473c6c026/README.md index 433b69e..973f6ca 100644 --- a/src/491c91ce-6355-40d3-bbbd-622473c6c026/README.md +++ b/src/491c91ce-6355-40d3-bbbd-622473c6c026/README.md @@ -1 +1,61 @@ -###POWERREADME### \ No newline at end of file +``` +██████╗ ██████╗ ██╗ ██╗███████╗██████╗ +██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗ +██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝ +██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗ +██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║ +╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝ +``` +# 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) + diff --git a/src/491c91ce-6355-40d3-bbbd-622473c6c026/code.php b/src/491c91ce-6355-40d3-bbbd-622473c6c026/code.php index 3d222d0..12a36ca 100644 --- a/src/491c91ce-6355-40d3-bbbd-622473c6c026/code.php +++ b/src/491c91ce-6355-40d3-bbbd-622473c6c026/code.php @@ -9,4 +9,88 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ -###POWERCODE### +namespace VDM\Joomla\GetBible\Api; + + +use VDM\Joomla\GetBible\Abstraction\Api; + + +/** + * The GetBible Books + * + * @since 2.0.1 + */ +final class Books extends Api +{ + /** + * Get the books in a translation + * + * @param string $translation The translation. + * + * @return object|null The response object or null if an error occurs. + * @since 2.0.1 + */ + public function get(string $translation = 'kjv'): ?object + { + return $this->response->get( + $this->http->get( + $this->uri->get($translation . '.json') + ) + ); + } + + /** + * List the books in a translation + * + * @param string $translation The translation. + * + * @return object|null The response object or null if an error occurs. + * @since 2.0.1 + */ + public function list(string $translation = 'kjv'): ?object + { + return $this->response->get( + $this->http->get( + $this->uri->get($translation . '/books.json') + ) + ); + } + + /** + * List the books checksums in a translation + * + * @param string $translation The translation. + * + * @return object|null The response object or null if an error occurs. + * @since 2.0.1 + */ + public function checksum(string $translation = 'kjv'): ?object + { + return $this->response->get( + $this->http->get( + $this->uri->get($translation . '/checksum.json') + ) + ); + } + + /** + * Get the book's checksums in a translation + * + * @param string $translation The translation. + * @param int $book The book number. + * + * @return string|null The response checksums or null if an error occurs. + * @since 2.0.1 + */ + public function sha(string $translation, int $book): ?string + { + return trim( + $this->response->get( + $this->http->get( + $this->uri->get($translation . '/' . $book . '.sha') + ) + ) + ); + } +} + diff --git a/src/491c91ce-6355-40d3-bbbd-622473c6c026/code.power b/src/491c91ce-6355-40d3-bbbd-622473c6c026/code.power index 69309b0..f8be15e 100644 --- a/src/491c91ce-6355-40d3-bbbd-622473c6c026/code.power +++ b/src/491c91ce-6355-40d3-bbbd-622473c6c026/code.power @@ -1 +1,70 @@ -###CODEPOWER### \ No newline at end of file + /** + * 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') + ) + ) + ); + } \ No newline at end of file diff --git a/src/491c91ce-6355-40d3-bbbd-622473c6c026/settings.json b/src/491c91ce-6355-40d3-bbbd-622473c6c026/settings.json index 6b3b222..90f5a3d 100644 --- a/src/491c91ce-6355-40d3-bbbd-622473c6c026/settings.json +++ b/src/491c91ce-6355-40d3-bbbd-622473c6c026/settings.json @@ -1 +1,18 @@ -###POWERLINKER### \ No newline at end of file +{ + "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 \r\n * @git 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": "" +} \ No newline at end of file diff --git a/src/4a4c786d-51f4-421a-aa61-262dfd071880/README.md b/src/4a4c786d-51f4-421a-aa61-262dfd071880/README.md index 433b69e..efa3980 100644 --- a/src/4a4c786d-51f4-421a-aa61-262dfd071880/README.md +++ b/src/4a4c786d-51f4-421a-aa61-262dfd071880/README.md @@ -1 +1,113 @@ -###POWERREADME### \ No newline at end of file +``` +██████╗ ██████╗ ██╗ ██╗███████╗██████╗ +██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗ +██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝ +██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗ +██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║ +╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝ +``` +# 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) + diff --git a/src/4a4c786d-51f4-421a-aa61-262dfd071880/code.php b/src/4a4c786d-51f4-421a-aa61-262dfd071880/code.php index 3d222d0..04e899a 100644 --- a/src/4a4c786d-51f4-421a-aa61-262dfd071880/code.php +++ b/src/4a4c786d-51f4-421a-aa61-262dfd071880/code.php @@ -9,4 +9,206 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ -###POWERCODE### +namespace VDM\Joomla\GetBible\Data; + + +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; + } +} + diff --git a/src/4a4c786d-51f4-421a-aa61-262dfd071880/code.power b/src/4a4c786d-51f4-421a-aa61-262dfd071880/code.power index 69309b0..e139021 100644 --- a/src/4a4c786d-51f4-421a-aa61-262dfd071880/code.power +++ b/src/4a4c786d-51f4-421a-aa61-262dfd071880/code.power @@ -1 +1,187 @@ -###CODEPOWER### \ No newline at end of file + /** + * 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; + } \ No newline at end of file diff --git a/src/4a4c786d-51f4-421a-aa61-262dfd071880/settings.json b/src/4a4c786d-51f4-421a-aa61-262dfd071880/settings.json index 6b3b222..0c77da3 100644 --- a/src/4a4c786d-51f4-421a-aa61-262dfd071880/settings.json +++ b/src/4a4c786d-51f4-421a-aa61-262dfd071880/settings.json @@ -1 +1,27 @@ -###POWERLINKER### \ No newline at end of file +{ + "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 \r\n * @git 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": "" +} \ No newline at end of file diff --git a/src/4cfff1bc-02b3-4c52-9e6e-7ceefb505a32/README.md b/src/4cfff1bc-02b3-4c52-9e6e-7ceefb505a32/README.md index 433b69e..4a14697 100644 --- a/src/4cfff1bc-02b3-4c52-9e6e-7ceefb505a32/README.md +++ b/src/4cfff1bc-02b3-4c52-9e6e-7ceefb505a32/README.md @@ -1 +1,122 @@ -###POWERREADME### \ No newline at end of file +``` +██████╗ ██████╗ ██╗ ██╗███████╗██████╗ +██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗ +██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝ +██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗ +██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║ +╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝ +``` +# 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) + diff --git a/src/4cfff1bc-02b3-4c52-9e6e-7ceefb505a32/code.php b/src/4cfff1bc-02b3-4c52-9e6e-7ceefb505a32/code.php index 3d222d0..9b46749 100644 --- a/src/4cfff1bc-02b3-4c52-9e6e-7ceefb505a32/code.php +++ b/src/4cfff1bc-02b3-4c52-9e6e-7ceefb505a32/code.php @@ -9,4 +9,267 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ -###POWERCODE### +namespace VDM\Joomla\GetBible\Tagged; + + +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']); + } +} + diff --git a/src/4cfff1bc-02b3-4c52-9e6e-7ceefb505a32/code.power b/src/4cfff1bc-02b3-4c52-9e6e-7ceefb505a32/code.power index 69309b0..e8112ec 100644 --- a/src/4cfff1bc-02b3-4c52-9e6e-7ceefb505a32/code.power +++ b/src/4cfff1bc-02b3-4c52-9e6e-7ceefb505a32/code.power @@ -1 +1,249 @@ -###CODEPOWER### \ No newline at end of file + /** + * 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']); + } \ No newline at end of file diff --git a/src/4cfff1bc-02b3-4c52-9e6e-7ceefb505a32/settings.json b/src/4cfff1bc-02b3-4c52-9e6e-7ceefb505a32/settings.json index 6b3b222..d6cf6f4 100644 --- a/src/4cfff1bc-02b3-4c52-9e6e-7ceefb505a32/settings.json +++ b/src/4cfff1bc-02b3-4c52-9e6e-7ceefb505a32/settings.json @@ -1 +1,18 @@ -###POWERLINKER### \ No newline at end of file +{ + "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 \r\n * @git 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": "" +} \ No newline at end of file diff --git a/src/51bb0397-fa7c-4f7a-a4c5-1f95fdacad38/README.md b/src/51bb0397-fa7c-4f7a-a4c5-1f95fdacad38/README.md index 433b69e..7b1813c 100644 --- a/src/51bb0397-fa7c-4f7a-a4c5-1f95fdacad38/README.md +++ b/src/51bb0397-fa7c-4f7a-a4c5-1f95fdacad38/README.md @@ -1 +1,85 @@ -###POWERREADME### \ No newline at end of file +``` +██████╗ ██████╗ ██╗ ██╗███████╗██████╗ +██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗ +██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝ +██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗ +██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║ +╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝ +``` +# 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) + diff --git a/src/51bb0397-fa7c-4f7a-a4c5-1f95fdacad38/code.php b/src/51bb0397-fa7c-4f7a-a4c5-1f95fdacad38/code.php index 3d222d0..b1a7039 100644 --- a/src/51bb0397-fa7c-4f7a-a4c5-1f95fdacad38/code.php +++ b/src/51bb0397-fa7c-4f7a-a4c5-1f95fdacad38/code.php @@ -9,4 +9,141 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ -###POWERCODE### +namespace VDM\Joomla\GetBible\Service; + + +use Joomla\DI\Container; +use Joomla\DI\ServiceProviderInterface; +use VDM\Joomla\Database\Insert as BaseInsert; +use VDM\Joomla\Database\Update as BaseUpdate; +use VDM\Joomla\Database\Load as BaseLoad; +use VDM\Joomla\GetBible\Database\Insert; +use VDM\Joomla\GetBible\Database\Load; +use VDM\Joomla\GetBible\Database\Update; + + +/** + * The GetBible Database Service + * + * @since 2.0.1 + */ +class Database implements ServiceProviderInterface +{ + /** + * Registers the service provider with a DI container. + * + * @param Container $container The DI container. + * + * @return void + * @since 2.0.1 + */ + public function register(Container $container) + { + $container->alias(BaseInsert::class, 'DB.Insert') + ->share('DB.Insert', [$this, 'getBaseInsert'], true); + + $container->alias(BaseUpdate::class, 'DB.Update') + ->share('DB.Update', [$this, 'getBaseUpdate'], true); + + $container->alias(BaseLoad::class, 'DB.Load') + ->share('DB.Load', [$this, 'getBaseLoad'], true); + + $container->alias(Insert::class, 'GetBible.Insert') + ->share('GetBible.Insert', [$this, 'getInsert'], true); + + $container->alias(Update::class, 'GetBible.Update') + ->share('GetBible.Update', [$this, 'getUpdate'], true); + + $container->alias(Load::class, 'GetBible.Load') + ->share('GetBible.Load', [$this, 'getLoad'], true); + } + + /** + * Get the BaseUpdate class + * + * @param Container $container The DI container. + * + * @return BaseUpdate + * @since 2.0.1 + */ + public function getBaseUpdate(Container $container): BaseUpdate + { + return new BaseUpdate(); + } + + /** + * Get the BaseInsert class + * + * @param Container $container The DI container. + * + * @return BaseInsert + * @since 2.0.1 + */ + public function getBaseInsert(Container $container): BaseInsert + { + return new BaseInsert(); + } + + /** + * Get the BaseLoad class + * + * @param Container $container The DI container. + * + * @return BaseLoad + * @since 2.0.1 + */ + public function getBaseLoad(Container $container): BaseLoad + { + return new BaseLoad(); + } + + /** + * Get the Insert class + * + * @param Container $container The DI container. + * + * @return Insert + * @since 2.0.1 + */ + public function getInsert(Container $container): Insert + { + return new Insert( + $container->get('GetBible.Model.Upsert'), + $container->get('DB.Insert') + ); + } + + /** + * Get the Update class + * + * @param Container $container The DI container. + * + * @return Update + * @since 2.0.1 + */ + public function getUpdate(Container $container): Update + { + return new Update( + $container->get('GetBible.Model.Upsert'), + $container->get('DB.Update') + ); + } + + /** + * Get the Table class + * + * @param Container $container The DI container. + * + * @return Load + * @since 2.0.1 + */ + public function getLoad(Container $container): Load + { + return new Load( + $container->get('GetBible.Table'), + $container->get('GetBible.Model.Load'), + $container->get('DB.Load') + ); + } +} + diff --git a/src/51bb0397-fa7c-4f7a-a4c5-1f95fdacad38/code.power b/src/51bb0397-fa7c-4f7a-a4c5-1f95fdacad38/code.power index 69309b0..453f383 100644 --- a/src/51bb0397-fa7c-4f7a-a4c5-1f95fdacad38/code.power +++ b/src/51bb0397-fa7c-4f7a-a4c5-1f95fdacad38/code.power @@ -1 +1,116 @@ -###CODEPOWER### \ No newline at end of file + /** + * 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') + ); + } \ No newline at end of file diff --git a/src/51bb0397-fa7c-4f7a-a4c5-1f95fdacad38/settings.json b/src/51bb0397-fa7c-4f7a-a4c5-1f95fdacad38/settings.json index 6b3b222..ed9dfb8 100644 --- a/src/51bb0397-fa7c-4f7a-a4c5-1f95fdacad38/settings.json +++ b/src/51bb0397-fa7c-4f7a-a4c5-1f95fdacad38/settings.json @@ -1 +1,46 @@ -###POWERLINKER### \ No newline at end of file +{ + "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 \r\n * @git 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": "" +} \ No newline at end of file diff --git a/src/56465044-94ed-4e00-b6db-160c67163df8/README.md b/src/56465044-94ed-4e00-b6db-160c67163df8/README.md index 433b69e..ee2fa9a 100644 --- a/src/56465044-94ed-4e00-b6db-160c67163df8/README.md +++ b/src/56465044-94ed-4e00-b6db-160c67163df8/README.md @@ -1 +1,117 @@ -###POWERREADME### \ No newline at end of file +``` +██████╗ ██████╗ ██╗ ██╗███████╗██████╗ +██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗ +██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝ +██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗ +██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║ +╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝ +``` +# 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) + diff --git a/src/56465044-94ed-4e00-b6db-160c67163df8/code.php b/src/56465044-94ed-4e00-b6db-160c67163df8/code.php index 3d222d0..9a32b1d 100644 --- a/src/56465044-94ed-4e00-b6db-160c67163df8/code.php +++ b/src/56465044-94ed-4e00-b6db-160c67163df8/code.php @@ -9,4 +9,226 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ -###POWERCODE### +namespace VDM\Joomla\GetBible\Service; + + +use Joomla\DI\Container; +use Joomla\DI\ServiceProviderInterface; +use VDM\Joomla\GetBible\Config; +use VDM\Joomla\GetBible\Table; +use VDM\Joomla\GetBible\DailyScripture; +use VDM\Joomla\GetBible\Search; +use VDM\Joomla\GetBible\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(); + } +} + diff --git a/src/56465044-94ed-4e00-b6db-160c67163df8/code.power b/src/56465044-94ed-4e00-b6db-160c67163df8/code.power index 69309b0..43d8637 100644 --- a/src/56465044-94ed-4e00-b6db-160c67163df8/code.power +++ b/src/56465044-94ed-4e00-b6db-160c67163df8/code.power @@ -1 +1,197 @@ -###CODEPOWER### \ No newline at end of file + /** + * 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(); + } \ No newline at end of file diff --git a/src/56465044-94ed-4e00-b6db-160c67163df8/settings.json b/src/56465044-94ed-4e00-b6db-160c67163df8/settings.json index 6b3b222..a338bd6 100644 --- a/src/56465044-94ed-4e00-b6db-160c67163df8/settings.json +++ b/src/56465044-94ed-4e00-b6db-160c67163df8/settings.json @@ -1 +1,62 @@ -###POWERLINKER### \ No newline at end of file +{ + "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 \r\n * @git 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": "" +} \ No newline at end of file diff --git a/src/67f91b8b-7b48-4dbb-bbd5-7945c174622a/README.md b/src/67f91b8b-7b48-4dbb-bbd5-7945c174622a/README.md index 433b69e..30645be 100644 --- a/src/67f91b8b-7b48-4dbb-bbd5-7945c174622a/README.md +++ b/src/67f91b8b-7b48-4dbb-bbd5-7945c174622a/README.md @@ -1 +1,96 @@ -###POWERREADME### \ No newline at end of file +``` +██████╗ ██████╗ ██╗ ██╗███████╗██████╗ +██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗ +██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝ +██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗ +██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║ +╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝ +``` +# 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) + diff --git a/src/67f91b8b-7b48-4dbb-bbd5-7945c174622a/code.php b/src/67f91b8b-7b48-4dbb-bbd5-7945c174622a/code.php index 3d222d0..82f0a7c 100644 --- a/src/67f91b8b-7b48-4dbb-bbd5-7945c174622a/code.php +++ b/src/67f91b8b-7b48-4dbb-bbd5-7945c174622a/code.php @@ -9,4 +9,285 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ -###POWERCODE### +namespace VDM\Joomla\GetBible; + + +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'); + } +} + diff --git a/src/67f91b8b-7b48-4dbb-bbd5-7945c174622a/code.power b/src/67f91b8b-7b48-4dbb-bbd5-7945c174622a/code.power index 69309b0..741ab12 100644 --- a/src/67f91b8b-7b48-4dbb-bbd5-7945c174622a/code.power +++ b/src/67f91b8b-7b48-4dbb-bbd5-7945c174622a/code.power @@ -1 +1,262 @@ -###CODEPOWER### \ No newline at end of file + /** + * 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,
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,
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,
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'); + } \ No newline at end of file diff --git a/src/67f91b8b-7b48-4dbb-bbd5-7945c174622a/settings.json b/src/67f91b8b-7b48-4dbb-bbd5-7945c174622a/settings.json index 6b3b222..3cfd979 100644 --- a/src/67f91b8b-7b48-4dbb-bbd5-7945c174622a/settings.json +++ b/src/67f91b8b-7b48-4dbb-bbd5-7945c174622a/settings.json @@ -1 +1,39 @@ -###POWERLINKER### \ No newline at end of file +{ + "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 \r\n * @git 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": "" +} \ No newline at end of file diff --git a/src/71075f03-4e77-4fc0-840a-ef55fd9260b2/README.md b/src/71075f03-4e77-4fc0-840a-ef55fd9260b2/README.md index 433b69e..4548616 100644 --- a/src/71075f03-4e77-4fc0-840a-ef55fd9260b2/README.md +++ b/src/71075f03-4e77-4fc0-840a-ef55fd9260b2/README.md @@ -1 +1,69 @@ -###POWERREADME### \ No newline at end of file +``` +██████╗ ██████╗ ██╗ ██╗███████╗██████╗ +██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗ +██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝ +██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗ +██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║ +╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝ +``` +# 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) + diff --git a/src/71075f03-4e77-4fc0-840a-ef55fd9260b2/code.php b/src/71075f03-4e77-4fc0-840a-ef55fd9260b2/code.php index 3d222d0..1221c33 100644 --- a/src/71075f03-4e77-4fc0-840a-ef55fd9260b2/code.php +++ b/src/71075f03-4e77-4fc0-840a-ef55fd9260b2/code.php @@ -9,4 +9,73 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ -###POWERCODE### +namespace VDM\Joomla\GetBible; + + +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'; + } +} + diff --git a/src/71075f03-4e77-4fc0-840a-ef55fd9260b2/code.power b/src/71075f03-4e77-4fc0-840a-ef55fd9260b2/code.power index 69309b0..cfc8322 100644 --- a/src/71075f03-4e77-4fc0-840a-ef55fd9260b2/code.power +++ b/src/71075f03-4e77-4fc0-840a-ef55fd9260b2/code.power @@ -1 +1,54 @@ -###CODEPOWER### \ No newline at end of file + /** + * 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'; + } \ No newline at end of file diff --git a/src/71075f03-4e77-4fc0-840a-ef55fd9260b2/settings.json b/src/71075f03-4e77-4fc0-840a-ef55fd9260b2/settings.json index 6b3b222..673c46d 100644 --- a/src/71075f03-4e77-4fc0-840a-ef55fd9260b2/settings.json +++ b/src/71075f03-4e77-4fc0-840a-ef55fd9260b2/settings.json @@ -1 +1,23 @@ -###POWERLINKER### \ No newline at end of file +{ + "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 \r\n * @git 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": "" +} \ No newline at end of file diff --git a/src/7b490e63-8d1f-46de-a0c4-154272fd5d7f/README.md b/src/7b490e63-8d1f-46de-a0c4-154272fd5d7f/README.md index 433b69e..42b93f7 100644 --- a/src/7b490e63-8d1f-46de-a0c4-154272fd5d7f/README.md +++ b/src/7b490e63-8d1f-46de-a0c4-154272fd5d7f/README.md @@ -1 +1,44 @@ -###POWERREADME### \ No newline at end of file +``` +██████╗ ██████╗ ██╗ ██╗███████╗██████╗ +██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗ +██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝ +██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗ +██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║ +╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝ +``` +# 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) + diff --git a/src/7b490e63-8d1f-46de-a0c4-154272fd5d7f/code.php b/src/7b490e63-8d1f-46de-a0c4-154272fd5d7f/code.php index 3d222d0..c2b23ca 100644 --- a/src/7b490e63-8d1f-46de-a0c4-154272fd5d7f/code.php +++ b/src/7b490e63-8d1f-46de-a0c4-154272fd5d7f/code.php @@ -9,4 +9,59 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ -###POWERCODE### +namespace VDM\Joomla\GetBible\Abstraction; + + +use VDM\Joomla\GetBible\Utilities\Http; +use VDM\Joomla\GetBible\Utilities\Uri; +use VDM\Joomla\GetBible\Utilities\Response; + + +/** + * The GetBible Api + * + * @since 2.0.1 + */ +abstract class Api +{ + /** + * The Http class + * + * @var Http + * @since 2.0.1 + */ + protected Http $http; + + /** + * The Uri class + * + * @var Uri + * @since 2.0.1 + */ + protected Uri $uri; + + /** + * The Response class + * + * @var Response + * @since 2.0.1 + */ + protected Response $response; + + /** + * Constructor. + * + * @param Http $http The http class. + * @param Uri $uri The uri class. + * @param Response $response The response class. + * + * @since 2.0.1 + **/ + public function __construct(Http $http, Uri $uri, Response $response) + { + $this->http = $http; + $this->uri = $uri; + $this->response = $response; + } +} + diff --git a/src/7b490e63-8d1f-46de-a0c4-154272fd5d7f/code.power b/src/7b490e63-8d1f-46de-a0c4-154272fd5d7f/code.power index 69309b0..d9716f5 100644 --- a/src/7b490e63-8d1f-46de-a0c4-154272fd5d7f/code.power +++ b/src/7b490e63-8d1f-46de-a0c4-154272fd5d7f/code.power @@ -1 +1,39 @@ -###CODEPOWER### \ No newline at end of file + /** + * 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; + } \ No newline at end of file diff --git a/src/7b490e63-8d1f-46de-a0c4-154272fd5d7f/settings.json b/src/7b490e63-8d1f-46de-a0c4-154272fd5d7f/settings.json index 6b3b222..c6f9e05 100644 --- a/src/7b490e63-8d1f-46de-a0c4-154272fd5d7f/settings.json +++ b/src/7b490e63-8d1f-46de-a0c4-154272fd5d7f/settings.json @@ -1 +1,31 @@ -###POWERLINKER### \ No newline at end of file +{ + "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 \r\n * @git 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": "" +} \ No newline at end of file diff --git a/src/7d592acd-f031-4d0f-b667-584c88ae0495/README.md b/src/7d592acd-f031-4d0f-b667-584c88ae0495/README.md index 433b69e..4636309 100644 --- a/src/7d592acd-f031-4d0f-b667-584c88ae0495/README.md +++ b/src/7d592acd-f031-4d0f-b667-584c88ae0495/README.md @@ -1 +1,75 @@ -###POWERREADME### \ No newline at end of file +``` +██████╗ ██████╗ ██╗ ██╗███████╗██████╗ +██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗ +██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝ +██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗ +██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║ +╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝ +``` +# 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) + diff --git a/src/7d592acd-f031-4d0f-b667-584c88ae0495/code.php b/src/7d592acd-f031-4d0f-b667-584c88ae0495/code.php index 3d222d0..1f81965 100644 --- a/src/7d592acd-f031-4d0f-b667-584c88ae0495/code.php +++ b/src/7d592acd-f031-4d0f-b667-584c88ae0495/code.php @@ -9,4 +9,191 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ -###POWERCODE### +namespace VDM\Joomla\GetBible\Watcher; + + +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; + } +} + diff --git a/src/7d592acd-f031-4d0f-b667-584c88ae0495/code.power b/src/7d592acd-f031-4d0f-b667-584c88ae0495/code.power index 69309b0..4113175 100644 --- a/src/7d592acd-f031-4d0f-b667-584c88ae0495/code.power +++ b/src/7d592acd-f031-4d0f-b667-584c88ae0495/code.power @@ -1 +1,169 @@ -###CODEPOWER### \ No newline at end of file + /** + * 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; + } \ No newline at end of file diff --git a/src/7d592acd-f031-4d0f-b667-584c88ae0495/settings.json b/src/7d592acd-f031-4d0f-b667-584c88ae0495/settings.json index 6b3b222..8e959b0 100644 --- a/src/7d592acd-f031-4d0f-b667-584c88ae0495/settings.json +++ b/src/7d592acd-f031-4d0f-b667-584c88ae0495/settings.json @@ -1 +1,35 @@ -###POWERLINKER### \ No newline at end of file +{ + "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 \r\n * @git 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": "" +} \ No newline at end of file diff --git a/src/8336e3c4-f11b-41bc-a2b1-976f99442a84/README.md b/src/8336e3c4-f11b-41bc-a2b1-976f99442a84/README.md index 433b69e..8e5d4c1 100644 --- a/src/8336e3c4-f11b-41bc-a2b1-976f99442a84/README.md +++ b/src/8336e3c4-f11b-41bc-a2b1-976f99442a84/README.md @@ -1 +1,21 @@ -###POWERREADME### \ No newline at end of file +``` +██████╗ ██████╗ ██╗ ██╗███████╗██████╗ +██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗ +██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝ +██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗ +██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║ +╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝ +``` +> Error adding class diagram + +--- +``` + ██╗ ██████╗██████╗ + ██║██╔════╝██╔══██╗ + ██║██║ ██████╔╝ +██ ██║██║ ██╔══██╗ +╚█████╔╝╚██████╗██████╔╝ + ╚════╝ ╚═════╝╚═════╝ +``` +> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder) + diff --git a/src/8336e3c4-f11b-41bc-a2b1-976f99442a84/code.php b/src/8336e3c4-f11b-41bc-a2b1-976f99442a84/code.php index 3d222d0..7483592 100644 --- a/src/8336e3c4-f11b-41bc-a2b1-976f99442a84/code.php +++ b/src/8336e3c4-f11b-41bc-a2b1-976f99442a84/code.php @@ -9,4 +9,15 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ -###POWERCODE### +namespace VDM\Joomla\GetBible; + + +/** + * The GetBible Search + * + * @since 2.0.1 + */ +final class Search +{ +} + diff --git a/src/8336e3c4-f11b-41bc-a2b1-976f99442a84/settings.json b/src/8336e3c4-f11b-41bc-a2b1-976f99442a84/settings.json index 6b3b222..27f1757 100644 --- a/src/8336e3c4-f11b-41bc-a2b1-976f99442a84/settings.json +++ b/src/8336e3c4-f11b-41bc-a2b1-976f99442a84/settings.json @@ -1 +1,18 @@ -###POWERLINKER### \ No newline at end of file +{ + "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 \r\n * @git 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": "" +} \ No newline at end of file diff --git a/src/84e84cd1-c938-4559-8414-d5692db4118e/README.md b/src/84e84cd1-c938-4559-8414-d5692db4118e/README.md index 433b69e..e4ae99c 100644 --- a/src/84e84cd1-c938-4559-8414-d5692db4118e/README.md +++ b/src/84e84cd1-c938-4559-8414-d5692db4118e/README.md @@ -1 +1,53 @@ -###POWERREADME### \ No newline at end of file +``` +██████╗ ██████╗ ██╗ ██╗███████╗██████╗ +██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗ +██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝ +██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗ +██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║ +╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝ +``` +# 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) + diff --git a/src/84e84cd1-c938-4559-8414-d5692db4118e/code.php b/src/84e84cd1-c938-4559-8414-d5692db4118e/code.php index 3d222d0..cf010ee 100644 --- a/src/84e84cd1-c938-4559-8414-d5692db4118e/code.php +++ b/src/84e84cd1-c938-4559-8414-d5692db4118e/code.php @@ -9,4 +9,68 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ -###POWERCODE### +namespace VDM\Joomla\GetBible\Utilities; + + +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); + } +} + diff --git a/src/84e84cd1-c938-4559-8414-d5692db4118e/code.power b/src/84e84cd1-c938-4559-8414-d5692db4118e/code.power index 69309b0..92307ea 100644 --- a/src/84e84cd1-c938-4559-8414-d5692db4118e/code.power +++ b/src/84e84cd1-c938-4559-8414-d5692db4118e/code.power @@ -1 +1,47 @@ -###CODEPOWER### \ No newline at end of file + /** + * 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); + } \ No newline at end of file diff --git a/src/84e84cd1-c938-4559-8414-d5692db4118e/settings.json b/src/84e84cd1-c938-4559-8414-d5692db4118e/settings.json index 6b3b222..f3bf549 100644 --- a/src/84e84cd1-c938-4559-8414-d5692db4118e/settings.json +++ b/src/84e84cd1-c938-4559-8414-d5692db4118e/settings.json @@ -1 +1,23 @@ -###POWERLINKER### \ No newline at end of file +{ + "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 \r\n * @git 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": "" +} \ No newline at end of file diff --git a/src/899551ac-943e-4f81-becd-7e15c41f1081/README.md b/src/899551ac-943e-4f81-becd-7e15c41f1081/README.md index 433b69e..6554574 100644 --- a/src/899551ac-943e-4f81-becd-7e15c41f1081/README.md +++ b/src/899551ac-943e-4f81-becd-7e15c41f1081/README.md @@ -1 +1,156 @@ -###POWERREADME### \ No newline at end of file +``` +██████╗ ██████╗ ██╗ ██╗███████╗██████╗ +██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗ +██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝ +██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗ +██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║ +╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝ +``` +# 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) + diff --git a/src/899551ac-943e-4f81-becd-7e15c41f1081/code.php b/src/899551ac-943e-4f81-becd-7e15c41f1081/code.php index 3d222d0..0c80681 100644 --- a/src/899551ac-943e-4f81-becd-7e15c41f1081/code.php +++ b/src/899551ac-943e-4f81-becd-7e15c41f1081/code.php @@ -9,4 +9,383 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ -###POWERCODE### +namespace VDM\Joomla\GetBible\Data; + + +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; + } +} + diff --git a/src/899551ac-943e-4f81-becd-7e15c41f1081/code.power b/src/899551ac-943e-4f81-becd-7e15c41f1081/code.power index 69309b0..7f3bcbb 100644 --- a/src/899551ac-943e-4f81-becd-7e15c41f1081/code.power +++ b/src/899551ac-943e-4f81-becd-7e15c41f1081/code.power @@ -1 +1,363 @@ -###CODEPOWER### \ No newline at end of file + /** + * 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; + } \ No newline at end of file diff --git a/src/899551ac-943e-4f81-becd-7e15c41f1081/settings.json b/src/899551ac-943e-4f81-becd-7e15c41f1081/settings.json index 6b3b222..59028ac 100644 --- a/src/899551ac-943e-4f81-becd-7e15c41f1081/settings.json +++ b/src/899551ac-943e-4f81-becd-7e15c41f1081/settings.json @@ -1 +1,31 @@ -###POWERLINKER### \ No newline at end of file +{ + "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 \r\n * @git 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": "" +} \ No newline at end of file diff --git a/src/90f2ee7a-c041-4316-ad54-af4f97fa3003/README.md b/src/90f2ee7a-c041-4316-ad54-af4f97fa3003/README.md index 433b69e..de9c3c0 100644 --- a/src/90f2ee7a-c041-4316-ad54-af4f97fa3003/README.md +++ b/src/90f2ee7a-c041-4316-ad54-af4f97fa3003/README.md @@ -1 +1,140 @@ -###POWERREADME### \ No newline at end of file +``` +██████╗ ██████╗ ██╗ ██╗███████╗██████╗ +██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗ +██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝ +██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗ +██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║ +╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝ +``` +# 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) + diff --git a/src/90f2ee7a-c041-4316-ad54-af4f97fa3003/code.php b/src/90f2ee7a-c041-4316-ad54-af4f97fa3003/code.php index 3d222d0..95a1b05 100644 --- a/src/90f2ee7a-c041-4316-ad54-af4f97fa3003/code.php +++ b/src/90f2ee7a-c041-4316-ad54-af4f97fa3003/code.php @@ -9,4 +9,266 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ -###POWERCODE### +namespace VDM\Joomla\GetBible; + + +use VDM\Joomla\GetBible\Config; +use VDM\Joomla\GetBible\Utilities\Http; +use VDM\Joomla\GetBible\Database\Load; + + +/** + * The GetBible Daily Scripture + * + * @since 2.0.1 + */ +final class DailyScripture +{ + /** + * The book number + * + * @var string|null + * @since 2.0.1 + */ + protected ?int $book = null; + + /** + * The chapter number + * + * @var int|null + * @since 2.0.1 + */ + protected ?int $chapter = null; + + /** + * The verses string + * + * @var string|null + * @since 2.0.1 + */ + protected ?string $verses = null; + + /** + * The reference string + * + * @var string|null + * @since 2.0.1 + */ + protected ?string $reference = null; + + /** + * The load object + * + * @var Load + * @since 2.0.1 + */ + protected Load $load; + + /** + * 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); + } +} + diff --git a/src/90f2ee7a-c041-4316-ad54-af4f97fa3003/code.power b/src/90f2ee7a-c041-4316-ad54-af4f97fa3003/code.power index 69309b0..cdc5bde 100644 --- a/src/90f2ee7a-c041-4316-ad54-af4f97fa3003/code.power +++ b/src/90f2ee7a-c041-4316-ad54-af4f97fa3003/code.power @@ -1 +1,246 @@ -###CODEPOWER### \ No newline at end of file + /** + * 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); + } \ No newline at end of file diff --git a/src/90f2ee7a-c041-4316-ad54-af4f97fa3003/settings.json b/src/90f2ee7a-c041-4316-ad54-af4f97fa3003/settings.json index 6b3b222..f27881c 100644 --- a/src/90f2ee7a-c041-4316-ad54-af4f97fa3003/settings.json +++ b/src/90f2ee7a-c041-4316-ad54-af4f97fa3003/settings.json @@ -1 +1,31 @@ -###POWERLINKER### \ No newline at end of file +{ + "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 \r\n * @git 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": "" +} \ No newline at end of file diff --git a/src/91b37bd7-b314-48be-91cf-434ec823bd80/README.md b/src/91b37bd7-b314-48be-91cf-434ec823bd80/README.md index 433b69e..4055382 100644 --- a/src/91b37bd7-b314-48be-91cf-434ec823bd80/README.md +++ b/src/91b37bd7-b314-48be-91cf-434ec823bd80/README.md @@ -1 +1,93 @@ -###POWERREADME### \ No newline at end of file +``` +██████╗ ██████╗ ██╗ ██╗███████╗██████╗ +██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗ +██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝ +██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗ +██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║ +╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝ +``` +# 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) + diff --git a/src/91b37bd7-b314-48be-91cf-434ec823bd80/code.php b/src/91b37bd7-b314-48be-91cf-434ec823bd80/code.php index 3d222d0..5c53ea3 100644 --- a/src/91b37bd7-b314-48be-91cf-434ec823bd80/code.php +++ b/src/91b37bd7-b314-48be-91cf-434ec823bd80/code.php @@ -9,4 +9,151 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ -###POWERCODE### +namespace VDM\Joomla\GetBible\Model; + + +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 ''; + } +} + diff --git a/src/91b37bd7-b314-48be-91cf-434ec823bd80/code.power b/src/91b37bd7-b314-48be-91cf-434ec823bd80/code.power index 69309b0..1977223 100644 --- a/src/91b37bd7-b314-48be-91cf-434ec823bd80/code.power +++ b/src/91b37bd7-b314-48be-91cf-434ec823bd80/code.power @@ -1 +1,129 @@ -###CODEPOWER### \ No newline at end of file + /** + * 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 ''; + } \ No newline at end of file diff --git a/src/91b37bd7-b314-48be-91cf-434ec823bd80/settings.json b/src/91b37bd7-b314-48be-91cf-434ec823bd80/settings.json index 6b3b222..f0389c5 100644 --- a/src/91b37bd7-b314-48be-91cf-434ec823bd80/settings.json +++ b/src/91b37bd7-b314-48be-91cf-434ec823bd80/settings.json @@ -1 +1,33 @@ -###POWERLINKER### \ No newline at end of file +{ + "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 \r\n * @git 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": "" +} \ No newline at end of file diff --git a/src/a07d90f6-6ff2-40a1-99c1-0f2cf33c9adf/README.md b/src/a07d90f6-6ff2-40a1-99c1-0f2cf33c9adf/README.md index 433b69e..18db48b 100644 --- a/src/a07d90f6-6ff2-40a1-99c1-0f2cf33c9adf/README.md +++ b/src/a07d90f6-6ff2-40a1-99c1-0f2cf33c9adf/README.md @@ -1 +1,88 @@ -###POWERREADME### \ No newline at end of file +``` +██████╗ ██████╗ ██╗ ██╗███████╗██████╗ +██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗ +██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝ +██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗ +██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║ +╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝ +``` +# final class Insert (Details) +> namespace: **VDM\Joomla\GetBible\Database** +```uml +@startuml +class Insert << (F,LightGreen) >> #Green { + # Model $model + # Database $database + + __construct(Model $model, Database $database) + + value(mixed $value, string $field, ...) : bool + + row(array $item, string $table) : bool + + rows(?array $items, string $table) : bool + + item(object $item, string $table) : bool + + items(?array $items, string $table) : bool +} + +note right of Insert::__construct + Constructor + + since: 2.0.1 +end note + +note right of Insert::value + Insert a value to a given table +Example: $this->value(Value, 'value_key', 'table_name'); + + since: 2.0.1 + return: bool + + arguments: + mixed $value + string $field + string $table +end note + +note right of Insert::row + Insert single row with multiple values to a given table +Example: $this->item(Array, 'table_name'); + + since: 2.0.1 + return: bool +end note + +note right of Insert::rows + Insert multiple rows to a given table +Example: $this->items(Array, 'table_name'); + + since: 2.0.1 + return: bool +end note + +note right of Insert::item + Insert single item with multiple values to a given table +Example: $this->item(Object, 'table_name'); + + since: 2.0.1 + return: bool +end note + +note right of Insert::items + Insert multiple items to a given table +Example: $this->items(Array, 'table_name'); + + since: 2.0.1 + return: bool +end note + +@enduml +``` + +--- +``` + ██╗ ██████╗██████╗ + ██║██╔════╝██╔══██╗ + ██║██║ ██████╔╝ +██ ██║██║ ██╔══██╗ +╚█████╔╝╚██████╗██████╔╝ + ╚════╝ ╚═════╝╚═════╝ +``` +> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder) + diff --git a/src/a07d90f6-6ff2-40a1-99c1-0f2cf33c9adf/code.php b/src/a07d90f6-6ff2-40a1-99c1-0f2cf33c9adf/code.php index 3d222d0..010bac0 100644 --- a/src/a07d90f6-6ff2-40a1-99c1-0f2cf33c9adf/code.php +++ b/src/a07d90f6-6ff2-40a1-99c1-0f2cf33c9adf/code.php @@ -9,4 +9,153 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ -###POWERCODE### +namespace VDM\Joomla\GetBible\Database; + + +use VDM\Joomla\GetBible\Model\Upsert as Model; +use VDM\Joomla\Database\Insert as Database; + + +/** + * GetBible Database Insert + * + * @since 2.0.1 + */ +final class Insert +{ + /** + * Model + * + * @var Model + * @since 2.0.1 + */ + protected Model $model; + + /** + * Database + * + * @var Database + * @since 2.0.1 + */ + protected Database $database; + + /** + * Constructor + * + * @param Model $model The set model object. + * @param Database $database The insert database object. + * + * @since 2.0.1 + */ + public function __construct(Model $model, Database $database) + { + $this->model = $model; + $this->database = $database; + } + + /** + * Insert a value to a given table + * Example: $this->value(Value, 'value_key', 'table_name'); + * + * @param mixed $value The field value + * @param string $field The field key + * @param string $table Target table + * + * @return bool + * @since 2.0.1 + */ + public function value($value, string $field, string $table): bool + { + // build the array + $item = []; + $item[$field] = $value; + + // Insert the column of this table + return $this->row($item, $table); + } + + /** + * Insert single row with multiple values to a given table + * Example: $this->item(Array, 'table_name'); + * + * @param array $item The item to save + * @param string $table Target table + * + * @return bool + * @since 2.0.1 + */ + public function row(array $item, string $table): bool + { + // check if array could be modelled + if (($item = $this->model->row($item, $table)) !== null) + { + // Insert the column of this table + return $this->database->row($item, $table); + } + return false; + } + + /** + * Insert multiple rows to a given table + * Example: $this->items(Array, 'table_name'); + * + * @param array|null $items The items updated in database (array of arrays) + * @param string $table Target table + * + * @return bool + * @since 2.0.1 + */ + public function rows(?array $items, string $table): bool + { + // check if arrays could be modelled + if (($items = $this->model->rows($items, $table)) !== null) + { + // Insert the column of this table + return $this->database->rows($items, $table); + } + return false; + } + + /** + * Insert single item with multiple values to a given table + * Example: $this->item(Object, 'table_name'); + * + * @param object $item The item to save + * @param string $table Target table + * + * @return bool + * @since 2.0.1 + */ + public function item(object $item, string $table): bool + { + // check if object could be modelled + if (($item = $this->model->item($item, $table)) !== null) + { + // Insert the column of this table. + return $this->database->item($item, $table); + } + return false; + } + + /** + * Insert multiple items to a given table + * Example: $this->items(Array, 'table_name'); + * + * @param array|null $items The items updated in database (array of objects) + * @param string $table Target table + * + * @return bool + * @since 2.0.1 + */ + public function items(?array $items, string $table): bool + { + // check if object could be modelled + if (($items = $this->model->items($items, $table)) !== null) + { + // Insert the column of this table. + return $this->database->items($items, $table); + } + return false; + } +} + diff --git a/src/a07d90f6-6ff2-40a1-99c1-0f2cf33c9adf/code.power b/src/a07d90f6-6ff2-40a1-99c1-0f2cf33c9adf/code.power index 69309b0..99039d1 100644 --- a/src/a07d90f6-6ff2-40a1-99c1-0f2cf33c9adf/code.power +++ b/src/a07d90f6-6ff2-40a1-99c1-0f2cf33c9adf/code.power @@ -1 +1,134 @@ -###CODEPOWER### \ No newline at end of file + /** + * Model + * + * @var Model + * @since 2.0.1 + */ + protected Model $model; + + /** + * Database + * + * @var Database + * @since 2.0.1 + */ + protected Database $database; + + /** + * Constructor + * + * @param Model $model The set model object. + * @param Database $database The insert database object. + * + * @since 2.0.1 + */ + public function __construct(Model $model, Database $database) + { + $this->model = $model; + $this->database = $database; + } + + /** + * Insert a value to a given table + * Example: $this->value(Value, 'value_key', 'table_name'); + * + * @param mixed $value The field value + * @param string $field The field key + * @param string $table Target table + * + * @return bool + * @since 2.0.1 + */ + public function value($value, string $field, string $table): bool + { + // build the array + $item = []; + $item[$field] = $value; + + // Insert the column of this table + return $this->row($item, $table); + } + + /** + * Insert single row with multiple values to a given table + * Example: $this->item(Array, 'table_name'); + * + * @param array $item The item to save + * @param string $table Target table + * + * @return bool + * @since 2.0.1 + */ + public function row(array $item, string $table): bool + { + // check if array could be modelled + if (($item = $this->model->row($item, $table)) !== null) + { + // Insert the column of this table + return $this->database->row($item, $table); + } + return false; + } + + /** + * Insert multiple rows to a given table + * Example: $this->items(Array, 'table_name'); + * + * @param array|null $items The items updated in database (array of arrays) + * @param string $table Target table + * + * @return bool + * @since 2.0.1 + */ + public function rows(?array $items, string $table): bool + { + // check if arrays could be modelled + if (($items = $this->model->rows($items, $table)) !== null) + { + // Insert the column of this table + return $this->database->rows($items, $table); + } + return false; + } + + /** + * Insert single item with multiple values to a given table + * Example: $this->item(Object, 'table_name'); + * + * @param object $item The item to save + * @param string $table Target table + * + * @return bool + * @since 2.0.1 + */ + public function item(object $item, string $table): bool + { + // check if object could be modelled + if (($item = $this->model->item($item, $table)) !== null) + { + // Insert the column of this table. + return $this->database->item($item, $table); + } + return false; + } + + /** + * Insert multiple items to a given table + * Example: $this->items(Array, 'table_name'); + * + * @param array|null $items The items updated in database (array of objects) + * @param string $table Target table + * + * @return bool + * @since 2.0.1 + */ + public function items(?array $items, string $table): bool + { + // check if object could be modelled + if (($items = $this->model->items($items, $table)) !== null) + { + // Insert the column of this table. + return $this->database->items($items, $table); + } + return false; + } \ No newline at end of file diff --git a/src/a07d90f6-6ff2-40a1-99c1-0f2cf33c9adf/settings.json b/src/a07d90f6-6ff2-40a1-99c1-0f2cf33c9adf/settings.json index 6b3b222..7785e7d 100644 --- a/src/a07d90f6-6ff2-40a1-99c1-0f2cf33c9adf/settings.json +++ b/src/a07d90f6-6ff2-40a1-99c1-0f2cf33c9adf/settings.json @@ -1 +1,27 @@ -###POWERLINKER### \ No newline at end of file +{ + "add_head": "0", + "add_licensing_template": "2", + "extends": "0", + "guid": "a07d90f6-6ff2-40a1-99c1-0f2cf33c9adf", + "implements": null, + "load_selection": null, + "name": "Insert", + "power_version": "1.0.0", + "system_name": "Joomla.GetBible.Database.Insert", + "type": "final class", + "use_selection": { + "use_selection0": { + "use": "91b37bd7-b314-48be-91cf-434ec823bd80", + "as": "Model" + }, + "use_selection1": { + "use": "524eb8f6-38d4-47dc-92ad-98b94e099ac0", + "as": "Database" + } + }, + "namespace": "VDM\\Joomla\\GetBible\\Database.Insert", + "description": "GetBible Database Insert\r\n\r\n@since 2.0.1", + "licensing_template": "\/**\r\n * @package GetBible\r\n *\r\n * @created 30th May, 2023\r\n * @author Llewellyn van der Merwe \r\n * @git 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": "" +} \ No newline at end of file diff --git a/src/a5b32737-207d-4cf6-b8ae-ee815612c3a0/README.md b/src/a5b32737-207d-4cf6-b8ae-ee815612c3a0/README.md index 433b69e..eef234b 100644 --- a/src/a5b32737-207d-4cf6-b8ae-ee815612c3a0/README.md +++ b/src/a5b32737-207d-4cf6-b8ae-ee815612c3a0/README.md @@ -1 +1,58 @@ -###POWERREADME### \ No newline at end of file +``` +██████╗ ██████╗ ██╗ ██╗███████╗██████╗ +██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗ +██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝ +██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗ +██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║ +╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝ +``` +# final class StringHelper (Details) +> namespace: **VDM\Joomla\GetBible\Utilities** +```uml +@startuml +class StringHelper << (F,LightGreen) >> #Green { + + split(string $text) : array + + splitToWords(string $text, bool $punctuation = true) : array + + isCJK(string $text) : bool + + hasLength(string $word) : bool +} + +note right of StringHelper::split + Return an array of words + + return: array +end note + +note right of StringHelper::splitToWords + Return an array of only words + + return: array +end note + +note right of StringHelper::isCJK + Checks if a string contains characters typically used in East Asian languages (Chinese, Japanese, Korean) +These languages do not typically use word boundaries in the same way as languages written in Latin script + + return: bool +end note + +note right of StringHelper::hasLength + Make sure a string has a length + + return: bool +end note + +@enduml +``` + +--- +``` + ██╗ ██████╗██████╗ + ██║██╔════╝██╔══██╗ + ██║██║ ██████╔╝ +██ ██║██║ ██╔══██╗ +╚█████╔╝╚██████╗██████╔╝ + ╚════╝ ╚═════╝╚═════╝ +``` +> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder) + diff --git a/src/a5b32737-207d-4cf6-b8ae-ee815612c3a0/code.php b/src/a5b32737-207d-4cf6-b8ae-ee815612c3a0/code.php index 3d222d0..faad516 100644 --- a/src/a5b32737-207d-4cf6-b8ae-ee815612c3a0/code.php +++ b/src/a5b32737-207d-4cf6-b8ae-ee815612c3a0/code.php @@ -9,4 +9,112 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ -###POWERCODE### +namespace VDM\Joomla\GetBible\Utilities; + + +/** + * The GetBible String Helper + * + * @since 2.0.1 + */ +final class StringHelper +{ + /** + * Return an array of words + * + * @param string $text The actual sentence + * + * @return array An array of words + */ + public function split(string $text): array + { + if ($this->isCJK($text)) + { + // Split by characters for languages that don't use spaces + $words = (array) preg_split('//u', $text, -1, PREG_SPLIT_NO_EMPTY); + } + elseif (strpos($text, ' ') !== false) + { + // Split by spaces for languages that use them + $words = (array) preg_split('/(\s+)/u', $text, -1, PREG_SPLIT_DELIM_CAPTURE); + } + else + { + $words = [$text]; + } + + return $words; + } + + /** + * Return an array of only words + * + * @param string $text The actual sentence + * @param bool $punctuation Switch to keep or remove punctuation + * + * @return array An array of words + */ + public function splitToWords(string $text, bool $punctuation = true): array + { + $words = array_filter($this->split($text), function($word) { + $plain_word = preg_replace('/[^\p{L}\p{N}\s]/u', '', $word); + if ($this->hasLength($plain_word)) { + return true; + } return false; + }); + + if ($words === []) + { + return $words; + } + + // remove punctuation + if (!$punctuation) + { + $words = array_map(function($word) { + return preg_replace('/[^\p{L}\p{N}\s]/u', '', $word); + }, $words); + } + + // make the array 1 based + // so that the key 1 is the first word + array_unshift($words, null); + unset($words[0]); + + return $words; + } + + /** + * Checks if a string contains characters typically used in East Asian languages (Chinese, Japanese, Korean) + * These languages do not typically use word boundaries in the same way as languages written in Latin script + * + * @param string $text The string to be checked for CJK characters + * + * @return bool True if the string contains at least one CJK character, false otherwise + */ + public function isCJK(string $text): bool + { + if (preg_match('/[\x{4E00}-\x{9FFF}\x{3040}-\x{309F}\x{30A0}-\x{30FF}\x{AC00}-\x{D7AF}]/u', $text)) + { + return true; + } + return false; + } + + /** + * Make sure a string has a length + * + * @param string $word The actual string to check + * + * @return bool True if its a string with characters. + */ + public function hasLength(string $word): bool + { + // Trim the string + $trimmed = trim($word); + + // Return true if the trimmed string is not empty, false otherwise + return !empty($trimmed); + } +} + diff --git a/src/a5b32737-207d-4cf6-b8ae-ee815612c3a0/code.power b/src/a5b32737-207d-4cf6-b8ae-ee815612c3a0/code.power index 69309b0..418bfe0 100644 --- a/src/a5b32737-207d-4cf6-b8ae-ee815612c3a0/code.power +++ b/src/a5b32737-207d-4cf6-b8ae-ee815612c3a0/code.power @@ -1 +1,97 @@ -###CODEPOWER### \ No newline at end of file + /** + * Return an array of words + * + * @param string $text The actual sentence + * + * @return array An array of words + */ + public function split(string $text): array + { + if ($this->isCJK($text)) + { + // Split by characters for languages that don't use spaces + $words = (array) preg_split('//u', $text, -1, PREG_SPLIT_NO_EMPTY); + } + elseif (strpos($text, ' ') !== false) + { + // Split by spaces for languages that use them + $words = (array) preg_split('/(\s+)/u', $text, -1, PREG_SPLIT_DELIM_CAPTURE); + } + else + { + $words = [$text]; + } + + return $words; + } + + /** + * Return an array of only words + * + * @param string $text The actual sentence + * @param bool $punctuation Switch to keep or remove punctuation + * + * @return array An array of words + */ + public function splitToWords(string $text, bool $punctuation = true): array + { + $words = array_filter($this->split($text), function($word) { + $plain_word = preg_replace('/[^\p{L}\p{N}\s]/u', '', $word); + if ($this->hasLength($plain_word)) { + return true; + } return false; + }); + + if ($words === []) + { + return $words; + } + + // remove punctuation + if (!$punctuation) + { + $words = array_map(function($word) { + return preg_replace('/[^\p{L}\p{N}\s]/u', '', $word); + }, $words); + } + + // make the array 1 based + // so that the key 1 is the first word + array_unshift($words, null); + unset($words[0]); + + return $words; + } + + /** + * Checks if a string contains characters typically used in East Asian languages (Chinese, Japanese, Korean) + * These languages do not typically use word boundaries in the same way as languages written in Latin script + * + * @param string $text The string to be checked for CJK characters + * + * @return bool True if the string contains at least one CJK character, false otherwise + */ + public function isCJK(string $text): bool + { + if (preg_match('/[\x{4E00}-\x{9FFF}\x{3040}-\x{309F}\x{30A0}-\x{30FF}\x{AC00}-\x{D7AF}]/u', $text)) + { + return true; + } + return false; + } + + /** + * Make sure a string has a length + * + * @param string $word The actual string to check + * + * @return bool True if its a string with characters. + */ + public function hasLength(string $word): bool + { + // Trim the string + $trimmed = trim($word); + + // Return true if the trimmed string is not empty, false otherwise + return !empty($trimmed); + } \ No newline at end of file diff --git a/src/a5b32737-207d-4cf6-b8ae-ee815612c3a0/settings.json b/src/a5b32737-207d-4cf6-b8ae-ee815612c3a0/settings.json index 6b3b222..f2ea4a8 100644 --- a/src/a5b32737-207d-4cf6-b8ae-ee815612c3a0/settings.json +++ b/src/a5b32737-207d-4cf6-b8ae-ee815612c3a0/settings.json @@ -1 +1,18 @@ -###POWERLINKER### \ No newline at end of file +{ + "add_head": "0", + "add_licensing_template": "2", + "extends": "0", + "guid": "a5b32737-207d-4cf6-b8ae-ee815612c3a0", + "implements": null, + "load_selection": null, + "name": "StringHelper", + "power_version": "1.0.0", + "system_name": "Joomla.GetBible.Utilities.StringHelper", + "type": "final class", + "use_selection": null, + "namespace": "VDM\\Joomla\\GetBible\\Utilities.StringHelper", + "description": "The GetBible String Helper\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 \r\n * @git 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": "" +} \ No newline at end of file diff --git a/src/a752e4b2-9b5e-4188-8d33-3799c46d5119/README.md b/src/a752e4b2-9b5e-4188-8d33-3799c46d5119/README.md index 433b69e..3d55625 100644 --- a/src/a752e4b2-9b5e-4188-8d33-3799c46d5119/README.md +++ b/src/a752e4b2-9b5e-4188-8d33-3799c46d5119/README.md @@ -1 +1,66 @@ -###POWERREADME### \ No newline at end of file +``` +██████╗ ██████╗ ██╗ ██╗███████╗██████╗ +██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗ +██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝ +██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗ +██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║ +╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝ +``` +# final class Chapters (Details) +> namespace: **VDM\Joomla\GetBible\Api** +```uml +@startuml +class Chapters << (F,LightGreen) >> #Green { + + get(string $translation, int $book) : ?object + + list(string $translation, int $book) : ?object + + checksum(string $translation, int $book) : ?object + + sha(string $translation, int $book, ...) : ?string +} + +note right of Chapters::get + Get the chapters in a book in a translation + + since: 2.0.1 + return: ?object +end note + +note right of Chapters::list + List the chapters of a book in a translation + + since: 2.0.1 + return: ?object +end note + +note right of Chapters::checksum + List the chapters checksums of a book in a translation + + since: 2.0.1 + return: ?object +end note + +note right of Chapters::sha + Get the chapter's checksums of a book in a translation + + since: 2.0.1 + return: ?string + + arguments: + string $translation + int $book + int $chapter +end note + +@enduml +``` + +--- +``` + ██╗ ██████╗██████╗ + ██║██╔════╝██╔══██╗ + ██║██║ ██████╔╝ +██ ██║██║ ██╔══██╗ +╚█████╔╝╚██████╗██████╔╝ + ╚════╝ ╚═════╝╚═════╝ +``` +> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder) + diff --git a/src/a752e4b2-9b5e-4188-8d33-3799c46d5119/code.php b/src/a752e4b2-9b5e-4188-8d33-3799c46d5119/code.php index 3d222d0..0e9d06e 100644 --- a/src/a752e4b2-9b5e-4188-8d33-3799c46d5119/code.php +++ b/src/a752e4b2-9b5e-4188-8d33-3799c46d5119/code.php @@ -9,4 +9,92 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ -###POWERCODE### +namespace VDM\Joomla\GetBible\Api; + + +use VDM\Joomla\GetBible\Abstraction\Api; + + +/** + * The GetBible Book Chapters + * + * @since 2.0.1 + */ +final class Chapters extends Api +{ + /** + * Get the chapters in a book in a translation + * + * @param string $translation The translation. + * @param int $book The book number. + * + * @return object|null The response object or null if an error occurs. + * @since 2.0.1 + */ + public function get(string $translation, int $book): ?object + { + return $this->response->get( + $this->http->get( + $this->uri->get($translation . '/' . $book . '.json') + ) + ); + } + + /** + * List the chapters of a book in a translation + * + * @param string $translation The translation. + * @param int $book The book number. + * + * @return object|null The response object or null if an error occurs. + * @since 2.0.1 + */ + public function list( string $translation, int $book): ?object + { + return $this->response->get( + $this->http->get( + $this->uri->get($translation . '/' . $book . '/chapters.json') + ) + ); + } + + /** + * List the chapters checksums of a book in a translation + * + * @param string $translation The translation. + * @param int $book The book number. + * + * @return object|null The response object or null if an error occurs. + * @since 2.0.1 + */ + public function checksum(string $translation, int $book): ?object + { + return $this->response->get( + $this->http->get( + $this->uri->get($translation . '/' . $book . '/checksum.json') + ) + ); + } + + /** + * Get the chapter's checksums of a book in a translation + * + * @param string $translation The translation. + * @param int $book The book number. + * @param int $chapter The chapter number. + * + * @return string|null The response checksum or null if an error occurs. + * @since 2.0.1 + */ + public function sha(string $translation, int $book, int $chapter): ?string + { + return trim( + $this->response->get( + $this->http->get( + $this->uri->get($translation . '/' . $book . '/' . $chapter . '.sha') + ) + ) + ); + } +} + diff --git a/src/a752e4b2-9b5e-4188-8d33-3799c46d5119/code.power b/src/a752e4b2-9b5e-4188-8d33-3799c46d5119/code.power index 69309b0..98d0472 100644 --- a/src/a752e4b2-9b5e-4188-8d33-3799c46d5119/code.power +++ b/src/a752e4b2-9b5e-4188-8d33-3799c46d5119/code.power @@ -1 +1,74 @@ -###CODEPOWER### \ No newline at end of file + /** + * Get the chapters in a book in a translation + * + * @param string $translation The translation. + * @param int $book The book number. + * + * @return object|null The response object or null if an error occurs. + * @since 2.0.1 + */ + public function get(string $translation, int $book): ?object + { + return $this->response->get( + $this->http->get( + $this->uri->get($translation . '/' . $book . '.json') + ) + ); + } + + /** + * List the chapters of a book in a translation + * + * @param string $translation The translation. + * @param int $book The book number. + * + * @return object|null The response object or null if an error occurs. + * @since 2.0.1 + */ + public function list( string $translation, int $book): ?object + { + return $this->response->get( + $this->http->get( + $this->uri->get($translation . '/' . $book . '/chapters.json') + ) + ); + } + + /** + * List the chapters checksums of a book in a translation + * + * @param string $translation The translation. + * @param int $book The book number. + * + * @return object|null The response object or null if an error occurs. + * @since 2.0.1 + */ + public function checksum(string $translation, int $book): ?object + { + return $this->response->get( + $this->http->get( + $this->uri->get($translation . '/' . $book . '/checksum.json') + ) + ); + } + + /** + * Get the chapter's checksums of a book in a translation + * + * @param string $translation The translation. + * @param int $book The book number. + * @param int $chapter The chapter number. + * + * @return string|null The response checksum or null if an error occurs. + * @since 2.0.1 + */ + public function sha(string $translation, int $book, int $chapter): ?string + { + return trim( + $this->response->get( + $this->http->get( + $this->uri->get($translation . '/' . $book . '/' . $chapter . '.sha') + ) + ) + ); + } \ No newline at end of file diff --git a/src/a752e4b2-9b5e-4188-8d33-3799c46d5119/settings.json b/src/a752e4b2-9b5e-4188-8d33-3799c46d5119/settings.json index 6b3b222..c24f11f 100644 --- a/src/a752e4b2-9b5e-4188-8d33-3799c46d5119/settings.json +++ b/src/a752e4b2-9b5e-4188-8d33-3799c46d5119/settings.json @@ -1 +1,18 @@ -###POWERLINKER### \ No newline at end of file +{ + "add_head": "0", + "add_licensing_template": "2", + "extends": "7b490e63-8d1f-46de-a0c4-154272fd5d7f", + "guid": "a752e4b2-9b5e-4188-8d33-3799c46d5119", + "implements": null, + "load_selection": null, + "name": "Chapters", + "power_version": "1.0.0", + "system_name": "Joomla.GetBible.Api.Chapters", + "type": "final class", + "use_selection": null, + "namespace": "VDM\\Joomla\\GetBible\\Api.Chapters", + "description": "The GetBible Book Chapters\r\n\r\n@since 2.0.1", + "licensing_template": "\/**\r\n * @package GetBible\r\n *\r\n * @created 30th May, 2023\r\n * @author Llewellyn van der Merwe \r\n * @git 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": "" +} \ No newline at end of file diff --git a/src/ac5c7679-dd6e-4817-8e48-489e521122f1/README.md b/src/ac5c7679-dd6e-4817-8e48-489e521122f1/README.md index 433b69e..9aed782 100644 --- a/src/ac5c7679-dd6e-4817-8e48-489e521122f1/README.md +++ b/src/ac5c7679-dd6e-4817-8e48-489e521122f1/README.md @@ -1 +1,69 @@ -###POWERREADME### \ No newline at end of file +``` +██████╗ ██████╗ ██╗ ██╗███████╗██████╗ +██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗ +██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝ +██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗ +██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║ +╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝ +``` +# class Openai (Details) +> namespace: **VDM\Joomla\GetBible\Service** +```uml +@startuml +class Openai #Gold { + + register(Container $container) : void + + getChat(Container $container) : Chat + + getCompletions(Container $container) : Completions + + getModels(Container $container) : Models + + getModerate(Container $container) : Moderate +} + +note right of Openai::register + Registers the service provider with a DI container. + + since: 3.2.0 + return: void +end note + +note right of Openai::getChat + Get the Chat class + + since: 3.2.0 + return: Chat +end note + +note right of Openai::getCompletions + Get the Completions class + + since: 3.2.0 + return: Completions +end note + +note right of Openai::getModels + Get the Models class + + since: 3.2.0 + return: Models +end note + +note right of Openai::getModerate + Get the Moderate class + + since: 3.2.0 + return: Moderate +end note + +@enduml +``` + +--- +``` + ██╗ ██████╗██████╗ + ██║██╔════╝██╔══██╗ + ██║██║ ██████╔╝ +██ ██║██║ ██╔══██╗ +╚█████╔╝╚██████╗██████╔╝ + ╚════╝ ╚═════╝╚═════╝ +``` +> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder) + diff --git a/src/ac5c7679-dd6e-4817-8e48-489e521122f1/code.php b/src/ac5c7679-dd6e-4817-8e48-489e521122f1/code.php index 3d222d0..e33a1b5 100644 --- a/src/ac5c7679-dd6e-4817-8e48-489e521122f1/code.php +++ b/src/ac5c7679-dd6e-4817-8e48-489e521122f1/code.php @@ -9,4 +9,113 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ -###POWERCODE### +namespace VDM\Joomla\GetBible\Service; + + +use Joomla\DI\Container; +use Joomla\DI\ServiceProviderInterface; +use VDM\Joomla\Openai\Chat; +use VDM\Joomla\Openai\Completions; +use VDM\Joomla\Openai\Models; +use VDM\Joomla\Openai\Moderate; + + +/** + * The Openai Api Service + * + * @since 3.2.0 + */ +class Openai implements ServiceProviderInterface +{ + /** + * Registers the service provider with a DI container. + * + * @param Container $container The DI container. + * + * @return void + * @since 3.2.0 + */ + public function register(Container $container) + { + $container->alias(Chat::class, 'Openai.Chat') + ->share('Openai.Chat', [$this, 'getChat'], true); + + $container->alias(Completions::class, 'Openai.Completions') + ->share('Openai.Completions', [$this, 'getCompletions'], true); + + $container->alias(Models::class, 'Openai.Models') + ->share('Openai.Models', [$this, 'getModels'], true); + + $container->alias(Moderate::class, 'Openai.Moderate') + ->share('Openai.Moderate', [$this, 'getModerate'], true); + } + + /** + * Get the Chat class + * + * @param Container $container The DI container. + * + * @return Chat + * @since 3.2.0 + */ + public function getChat(Container $container): Chat + { + return new Chat( + $container->get('Openai.Utilities.Http'), + $container->get('Openai.Utilities.Uri'), + $container->get('Openai.Utilities.Response') + ); + } + + /** + * Get the Completions class + * + * @param Container $container The DI container. + * + * @return Completions + * @since 3.2.0 + */ + public function getCompletions(Container $container): Completions + { + return new Completions( + $container->get('Openai.Utilities.Http'), + $container->get('Openai.Utilities.Uri'), + $container->get('Openai.Utilities.Response') + ); + } + + /** + * Get the Models class + * + * @param Container $container The DI container. + * + * @return Models + * @since 3.2.0 + */ + public function getModels(Container $container): Models + { + return new Models( + $container->get('Openai.Utilities.Http'), + $container->get('Openai.Utilities.Uri'), + $container->get('Openai.Utilities.Response') + ); + } + + /** + * Get the Moderate class + * + * @param Container $container The DI container. + * + * @return Moderate + * @since 3.2.0 + */ + public function getModerate(Container $container): Moderate + { + return new Moderate( + $container->get('Openai.Utilities.Http'), + $container->get('Openai.Utilities.Uri'), + $container->get('Openai.Utilities.Response') + ); + } +} + diff --git a/src/ac5c7679-dd6e-4817-8e48-489e521122f1/code.power b/src/ac5c7679-dd6e-4817-8e48-489e521122f1/code.power index 69309b0..a977376 100644 --- a/src/ac5c7679-dd6e-4817-8e48-489e521122f1/code.power +++ b/src/ac5c7679-dd6e-4817-8e48-489e521122f1/code.power @@ -1 +1,90 @@ -###CODEPOWER### \ No newline at end of file + /** + * Registers the service provider with a DI container. + * + * @param Container $container The DI container. + * + * @return void + * @since 3.2.0 + */ + public function register(Container $container) + { + $container->alias(Chat::class, 'Openai.Chat') + ->share('Openai.Chat', [$this, 'getChat'], true); + + $container->alias(Completions::class, 'Openai.Completions') + ->share('Openai.Completions', [$this, 'getCompletions'], true); + + $container->alias(Models::class, 'Openai.Models') + ->share('Openai.Models', [$this, 'getModels'], true); + + $container->alias(Moderate::class, 'Openai.Moderate') + ->share('Openai.Moderate', [$this, 'getModerate'], true); + } + + /** + * Get the Chat class + * + * @param Container $container The DI container. + * + * @return Chat + * @since 3.2.0 + */ + public function getChat(Container $container): Chat + { + return new Chat( + $container->get('Openai.Utilities.Http'), + $container->get('Openai.Utilities.Uri'), + $container->get('Openai.Utilities.Response') + ); + } + + /** + * Get the Completions class + * + * @param Container $container The DI container. + * + * @return Completions + * @since 3.2.0 + */ + public function getCompletions(Container $container): Completions + { + return new Completions( + $container->get('Openai.Utilities.Http'), + $container->get('Openai.Utilities.Uri'), + $container->get('Openai.Utilities.Response') + ); + } + + /** + * Get the Models class + * + * @param Container $container The DI container. + * + * @return Models + * @since 3.2.0 + */ + public function getModels(Container $container): Models + { + return new Models( + $container->get('Openai.Utilities.Http'), + $container->get('Openai.Utilities.Uri'), + $container->get('Openai.Utilities.Response') + ); + } + + /** + * Get the Moderate class + * + * @param Container $container The DI container. + * + * @return Moderate + * @since 3.2.0 + */ + public function getModerate(Container $container): Moderate + { + return new Moderate( + $container->get('Openai.Utilities.Http'), + $container->get('Openai.Utilities.Uri'), + $container->get('Openai.Utilities.Response') + ); + } \ No newline at end of file diff --git a/src/ac5c7679-dd6e-4817-8e48-489e521122f1/settings.json b/src/ac5c7679-dd6e-4817-8e48-489e521122f1/settings.json index 6b3b222..0c0aa37 100644 --- a/src/ac5c7679-dd6e-4817-8e48-489e521122f1/settings.json +++ b/src/ac5c7679-dd6e-4817-8e48-489e521122f1/settings.json @@ -1 +1,38 @@ -###POWERLINKER### \ No newline at end of file +{ + "add_head": "1", + "add_licensing_template": "2", + "extends": "0", + "guid": "ac5c7679-dd6e-4817-8e48-489e521122f1", + "implements": [ + "-1" + ], + "load_selection": null, + "name": "Openai", + "power_version": "1.0.0", + "system_name": "Joomla.GetBible.Service.Openai", + "type": "class", + "use_selection": { + "use_selection0": { + "use": "c54c92da-2dd7-4136-81c9-1785f2fa0af5", + "as": "default" + }, + "use_selection1": { + "use": "796cca70-2577-4f8f-9a05-ac37db1f2f02", + "as": "default" + }, + "use_selection2": { + "use": "08abd2df-1406-4939-a1a6-94d2fce3f043", + "as": "default" + }, + "use_selection3": { + "use": "34f2c249-64a7-4229-9592-77e58f6e994f", + "as": "default" + } + }, + "namespace": "VDM\\Joomla\\GetBible\\Service.Openai", + "description": "The Openai Api Service\r\n\r\n@since 3.2.0", + "implements_custom": "ServiceProviderInterface", + "licensing_template": "\/**\r\n * @package GetBible\r\n *\r\n * @created 30th May, 2023\r\n * @author Llewellyn van der Merwe \r\n * @git 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": "" +} \ No newline at end of file diff --git a/src/afa508bf-78f8-4616-97cc-f2809584c086/README.md b/src/afa508bf-78f8-4616-97cc-f2809584c086/README.md index 433b69e..3216e12 100644 --- a/src/afa508bf-78f8-4616-97cc-f2809584c086/README.md +++ b/src/afa508bf-78f8-4616-97cc-f2809584c086/README.md @@ -1 +1,42 @@ -###POWERREADME### \ No newline at end of file +``` +██████╗ ██████╗ ██╗ ██╗███████╗██████╗ +██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗ +██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝ +██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗ +██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║ +╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝ +``` +# final class Verses (Details) +> namespace: **VDM\Joomla\GetBible\Api** +```uml +@startuml +class Verses << (F,LightGreen) >> #Green { + + get(string $translation, int $book, ...) : ?object +} + +note right of Verses::get + Get the verses of chapter in a book in a translation + + since: 2.0.1 + return: ?object + + arguments: + string $translation + int $book + int $chapter +end note + +@enduml +``` + +--- +``` + ██╗ ██████╗██████╗ + ██║██╔════╝██╔══██╗ + ██║██║ ██████╔╝ +██ ██║██║ ██╔══██╗ +╚█████╔╝╚██████╗██████╔╝ + ╚════╝ ╚═════╝╚═════╝ +``` +> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder) + diff --git a/src/afa508bf-78f8-4616-97cc-f2809584c086/code.php b/src/afa508bf-78f8-4616-97cc-f2809584c086/code.php index 3d222d0..8110f72 100644 --- a/src/afa508bf-78f8-4616-97cc-f2809584c086/code.php +++ b/src/afa508bf-78f8-4616-97cc-f2809584c086/code.php @@ -9,4 +9,36 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ -###POWERCODE### +namespace VDM\Joomla\GetBible\Api; + + +use VDM\Joomla\GetBible\Abstraction\Api; + + +/** + * The GetBible Book Chapter Verses + * + * @since 2.0.1 + */ +final class Verses extends Api +{ + /** + * Get the verses of chapter in a book in a translation + * + * @param string $translation The translation. + * @param int $book The book number. + * @param int $chapter The chapter number. + * + * @return object|null The response object or null if an error occurs. + * @since 2.0.1 + */ + public function get(string $translation, int $book, int $chapter): ?object + { + return $this->response->get( + $this->http->get( + $this->uri->get($translation . '/' . $book . '/' . $chapter . '.json') + ) + ); + } +} + diff --git a/src/afa508bf-78f8-4616-97cc-f2809584c086/code.power b/src/afa508bf-78f8-4616-97cc-f2809584c086/code.power index 69309b0..b1436ce 100644 --- a/src/afa508bf-78f8-4616-97cc-f2809584c086/code.power +++ b/src/afa508bf-78f8-4616-97cc-f2809584c086/code.power @@ -1 +1,18 @@ -###CODEPOWER### \ No newline at end of file + /** + * Get the verses of chapter in a book in a translation + * + * @param string $translation The translation. + * @param int $book The book number. + * @param int $chapter The chapter number. + * + * @return object|null The response object or null if an error occurs. + * @since 2.0.1 + */ + public function get(string $translation, int $book, int $chapter): ?object + { + return $this->response->get( + $this->http->get( + $this->uri->get($translation . '/' . $book . '/' . $chapter . '.json') + ) + ); + } \ No newline at end of file diff --git a/src/afa508bf-78f8-4616-97cc-f2809584c086/settings.json b/src/afa508bf-78f8-4616-97cc-f2809584c086/settings.json index 6b3b222..3f98d22 100644 --- a/src/afa508bf-78f8-4616-97cc-f2809584c086/settings.json +++ b/src/afa508bf-78f8-4616-97cc-f2809584c086/settings.json @@ -1 +1,18 @@ -###POWERLINKER### \ No newline at end of file +{ + "add_head": "0", + "add_licensing_template": "2", + "extends": "7b490e63-8d1f-46de-a0c4-154272fd5d7f", + "guid": "afa508bf-78f8-4616-97cc-f2809584c086", + "implements": null, + "load_selection": null, + "name": "Verses", + "power_version": "1.0.0", + "system_name": "Joomla.GetBible.Api.Verses", + "type": "final class", + "use_selection": null, + "namespace": "VDM\\Joomla\\GetBible\\Api.Verses", + "description": "The GetBible Book Chapter Verses\r\n\r\n@since 2.0.1", + "licensing_template": "\/**\r\n * @package GetBible\r\n *\r\n * @created 30th May, 2023\r\n * @author Llewellyn van der Merwe \r\n * @git 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": "" +} \ No newline at end of file diff --git a/src/b1bd2b4f-dede-44ad-86e9-2a595a0a9ca0/README.md b/src/b1bd2b4f-dede-44ad-86e9-2a595a0a9ca0/README.md index 433b69e..b3ec9aa 100644 --- a/src/b1bd2b4f-dede-44ad-86e9-2a595a0a9ca0/README.md +++ b/src/b1bd2b4f-dede-44ad-86e9-2a595a0a9ca0/README.md @@ -1 +1,93 @@ -###POWERREADME### \ No newline at end of file +``` +██████╗ ██████╗ ██╗ ██╗███████╗██████╗ +██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗ +██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝ +██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗ +██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║ +╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝ +``` +# final class Load (Details) +> namespace: **VDM\Joomla\GetBible\Model** +```uml +@startuml +class Load << (F,LightGreen) >> #Green { + # Config $config + + __construct(Config $config, Table $table) + + value(mixed $value, string $field, ...) : mixed + # validateBefore(mixed $value, ?string $field = null, ...) : bool + # validateAfter(mixed $value, ?string $field = null, ...) : bool + # getTable() : string + + modelDistributionHistory(mixed $value) : mixed +} + +note right of Load::__construct + Constructor + + since: 2.0.1 +end note + +note right of Load::value + Model the value +Example: $this->value(value, 'field_key', 'table_name'); + + since: 2.0.1 + return: mixed + + arguments: + mixed $value + string $field + ?string $table = null +end note + +note right of Load::validateBefore + Validate before the value is modelled + + since: 2.0.1 + return: bool + + arguments: + mixed $value + ?string $field = null + ?string $table = null +end note + +note right of Load::validateAfter + Validate after the value is modelled + + since: 2.0.1 + return: bool + + arguments: + mixed $value + ?string $field = null + ?string $table = null +end note + +note right of Load::getTable + Get the current active table + + since: 2.0.1 + return: string +end note + +note right of Load::modelDistributionHistory + Model Distribution History + + since: 2.0.1 + return: mixed +end note + +@enduml +``` + +--- +``` + ██╗ ██████╗██████╗ + ██║██╔════╝██╔══██╗ + ██║██║ ██████╔╝ +██ ██║██║ ██╔══██╗ +╚█████╔╝╚██████╗██████╔╝ + ╚════╝ ╚═════╝╚═════╝ +``` +> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder) + diff --git a/src/b1bd2b4f-dede-44ad-86e9-2a595a0a9ca0/code.php b/src/b1bd2b4f-dede-44ad-86e9-2a595a0a9ca0/code.php index 3d222d0..802f489 100644 --- a/src/b1bd2b4f-dede-44ad-86e9-2a595a0a9ca0/code.php +++ b/src/b1bd2b4f-dede-44ad-86e9-2a595a0a9ca0/code.php @@ -9,4 +9,152 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ -###POWERCODE### +namespace VDM\Joomla\GetBible\Model; + + +use VDM\Joomla\Abstraction\BaseConfig as Config; +use VDM\Joomla\GetBible\Table; +use VDM\Joomla\Utilities\StringHelper; +use VDM\Joomla\Utilities\ArrayHelper; +use VDM\Joomla\Utilities\ObjectHelper; +use VDM\Joomla\Interfaces\ModelInterface; +use VDM\Joomla\Abstraction\Model; + + +/** + * The GetBible Model to Load + * + * @since 2.0.1 + */ +final class Load extends Model implements ModelInterface +{ + /** + * GetBible Config + * + * @var Config + * @since 2.0.1 + */ + protected Config $config; + + /** + * Constructor + * + * @param Config $config The getBible config object. + * @param Table $table The getBible table object. + * + * @since 2.0.1 + */ + public function __construct(Config $config, Table $table) + { + parent::__construct($table); + + $this->config = $config; + } + + /** + * Model the value + * Example: $this->value(value, 'field_key', 'table_name'); + * + * @param mixed $value The value to model + * @param string $field The field key + * @param string|null $table The table + * + * @return mixed + * @since 2.0.1 + */ + public function value($value, string $field, ?string $table = null) + { + // set the table name + if (empty($table)) + { + $table = $this->getTable(); + } + + // check if this is a valid table + if (($store = $this->table->get($table, $field, 'store')) !== null) + { + // open the value based on the store method + switch($store) + { + case 'json': + $value = json_decode($value); + break; + } + + // Model Distribution History + if ($table === 'translation' && $field === 'distribution_history') + { + $value = $this->modelDistributionHistory($value); + } + } + + return $value; + } + + /** + * Validate before the value is modelled + * + * @param mixed $value The field value + * @param string|null $field The field key + * @param string|null $table The table + * + * @return bool + * @since 2.0.1 + */ + protected function validateBefore(&$value, ?string $field = null, ?string $table = null): bool + { + // only strings or numbers allowed + if (StringHelper::check($value) || is_numeric($value)) + { + return true; + } + // remove empty values + return false; + } + + /** + * Validate after the value is modelled + * + * @param mixed $value The field value + * @param string|null $field The field key + * @param string|null $table The table + * + * @return bool + * @since 2.0.1 + */ + protected function validateAfter(&$value, ?string $field = null, ?string $table = null): bool + { + // check values + if (StringHelper::check($value) || ArrayHelper::check($value, true) || ObjectHelper::check($value) || is_numeric($value)) + { + return true; + } + // remove empty values + return false; + } + + /** + * Get the current active table + * + * @return string + * @since 2.0.1 + */ + protected function getTable(): string + { + return $this->config->table_name; + } + + /** + * Model Distribution History + * + * @param mixed $value The value to model + * + * @return mixed + * @since 2.0.1 + */ + public function modelDistributionHistory($value) + { + return $value; + } +} + diff --git a/src/b1bd2b4f-dede-44ad-86e9-2a595a0a9ca0/code.power b/src/b1bd2b4f-dede-44ad-86e9-2a595a0a9ca0/code.power index 69309b0..1fb298c 100644 --- a/src/b1bd2b4f-dede-44ad-86e9-2a595a0a9ca0/code.power +++ b/src/b1bd2b4f-dede-44ad-86e9-2a595a0a9ca0/code.power @@ -1 +1,128 @@ -###CODEPOWER### \ No newline at end of file + /** + * GetBible Config + * + * @var Config + * @since 2.0.1 + */ + protected Config $config; + + /** + * Constructor + * + * @param Config $config The getBible config object. + * @param Table $table The getBible table object. + * + * @since 2.0.1 + */ + public function __construct(Config $config, Table $table) + { + parent::__construct($table); + + $this->config = $config; + } + + /** + * Model the value + * Example: $this->value(value, 'field_key', 'table_name'); + * + * @param mixed $value The value to model + * @param string $field The field key + * @param string|null $table The table + * + * @return mixed + * @since 2.0.1 + */ + public function value($value, string $field, ?string $table = null) + { + // set the table name + if (empty($table)) + { + $table = $this->getTable(); + } + + // check if this is a valid table + if (($store = $this->table->get($table, $field, 'store')) !== null) + { + // open the value based on the store method + switch($store) + { + case 'json': + $value = json_decode($value); + break; + } + + // Model Distribution History + if ($table === 'translation' && $field === 'distribution_history') + { + $value = $this->modelDistributionHistory($value); + } + } + + return $value; + } + + /** + * Validate before the value is modelled + * + * @param mixed $value The field value + * @param string|null $field The field key + * @param string|null $table The table + * + * @return bool + * @since 2.0.1 + */ + protected function validateBefore(&$value, ?string $field = null, ?string $table = null): bool + { + // only strings or numbers allowed + if (StringHelper::check($value) || is_numeric($value)) + { + return true; + } + // remove empty values + return false; + } + + /** + * Validate after the value is modelled + * + * @param mixed $value The field value + * @param string|null $field The field key + * @param string|null $table The table + * + * @return bool + * @since 2.0.1 + */ + protected function validateAfter(&$value, ?string $field = null, ?string $table = null): bool + { + // check values + if (StringHelper::check($value) || ArrayHelper::check($value, true) || ObjectHelper::check($value) || is_numeric($value)) + { + return true; + } + // remove empty values + return false; + } + + /** + * Get the current active table + * + * @return string + * @since 2.0.1 + */ + protected function getTable(): string + { + return $this->config->table_name; + } + + /** + * Model Distribution History + * + * @param mixed $value The value to model + * + * @return mixed + * @since 2.0.1 + */ + public function modelDistributionHistory($value) + { + return $value; + } \ No newline at end of file diff --git a/src/b1bd2b4f-dede-44ad-86e9-2a595a0a9ca0/settings.json b/src/b1bd2b4f-dede-44ad-86e9-2a595a0a9ca0/settings.json index 6b3b222..22c9ab1 100644 --- a/src/b1bd2b4f-dede-44ad-86e9-2a595a0a9ca0/settings.json +++ b/src/b1bd2b4f-dede-44ad-86e9-2a595a0a9ca0/settings.json @@ -1 +1,41 @@ -###POWERLINKER### \ No newline at end of file +{ + "add_head": "0", + "add_licensing_template": "2", + "extends": "584747d1-3a86-453d-b7a3-a2219de8d777", + "guid": "b1bd2b4f-dede-44ad-86e9-2a595a0a9ca0", + "implements": [ + "8aef58c1-3f70-4bd4-b9e4-3f29fcd41cff" + ], + "load_selection": null, + "name": "Load", + "power_version": "1.0.0", + "system_name": "Joomla.GetBible.Model.Load", + "type": "final class", + "use_selection": { + "use_selection0": { + "use": "ffbd4e1f-a342-4080-ab7d-1de3741bf319", + "as": "Config" + }, + "use_selection1": { + "use": "ff8d5fdb-2d1f-4178-bd18-a43b8efd1068", + "as": "default" + }, + "use_selection2": { + "use": "1f28cb53-60d9-4db1-b517-3c7dc6b429ef", + "as": "default" + }, + "use_selection3": { + "use": "0a59c65c-9daf-4bc9-baf4-e063ff9e6a8a", + "as": "default" + }, + "use_selection4": { + "use": "91004529-94a9-4590-b842-e7c6b624ecf5", + "as": "default" + } + }, + "namespace": "VDM\\Joomla\\GetBible\\Model.Load", + "description": "The GetBible Model to Load\r\n\r\n@since 2.0.1", + "licensing_template": "\/**\r\n * @package GetBible\r\n *\r\n * @created 30th May, 2023\r\n * @author Llewellyn van der Merwe \r\n * @git 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": "" +} \ No newline at end of file diff --git a/src/b2c9493f-692b-426b-af22-c6865f76c2bb/README.md b/src/b2c9493f-692b-426b-af22-c6865f76c2bb/README.md index 433b69e..b184f32 100644 --- a/src/b2c9493f-692b-426b-af22-c6865f76c2bb/README.md +++ b/src/b2c9493f-692b-426b-af22-c6865f76c2bb/README.md @@ -1 +1,53 @@ -###POWERREADME### \ No newline at end of file +``` +██████╗ ██████╗ ██╗ ██╗███████╗██████╗ +██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗ +██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝ +██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗ +██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║ +╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝ +``` +# class AI (Details) +> namespace: **VDM\Joomla\GetBible\Service** +```uml +@startuml +class AI #Gold { + + register(Container $container) : void + + getAI(Container $container) : GetBible + + getEngineer(Container $container) : Engineer +} + +note right of AI::register + Registers the service provider with a DI container. + + since: 3.2.0 + return: void +end note + +note right of AI::getAI + Get the GetBible AI class + + since: 3.2.0 + return: GetBible +end note + +note right of AI::getEngineer + Get the Engineer AI class + + since: 3.2.0 + return: Engineer +end note + +@enduml +``` + +--- +``` + ██╗ ██████╗██████╗ + ██║██╔════╝██╔══██╗ + ██║██║ ██████╔╝ +██ ██║██║ ██╔══██╗ +╚█████╔╝╚██████╗██████╔╝ + ╚════╝ ╚═════╝╚═════╝ +``` +> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder) + diff --git a/src/b2c9493f-692b-426b-af22-c6865f76c2bb/code.php b/src/b2c9493f-692b-426b-af22-c6865f76c2bb/code.php index 3d222d0..c53cb08 100644 --- a/src/b2c9493f-692b-426b-af22-c6865f76c2bb/code.php +++ b/src/b2c9493f-692b-426b-af22-c6865f76c2bb/code.php @@ -9,4 +9,73 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ -###POWERCODE### +namespace VDM\Joomla\GetBible\Service; + + +use Joomla\DI\Container; +use Joomla\DI\ServiceProviderInterface; +use VDM\Joomla\GetBible\AI as GetBible; +use VDM\Joomla\GetBible\AI\Engineer; + + +/** + * The GetBible AI Service + * + * @since 3.2.0 + */ +class AI 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(GetBible::class, 'GetBible.AI') + ->share('GetBible.AI', [$this, 'getAI'], true); + + $container->alias(Engineer::class, 'GetBible.AI.Engineer') + ->share('GetBible.AI.Engineer', [$this, 'getEngineer'], true); + } + + /** + * Get the GetBible AI class + * + * @param Container $container The DI container. + * + * @return GetBible + * @since 3.2.0 + */ + public function getAI(Container $container): GetBible + { + return new GetBible( + $container->get('GetBible.Config'), + $container->get('GetBible.Response'), + $container->get('GetBible.AI.Engineer') + ); + } + + /** + * Get the Engineer AI class + * + * @param Container $container The DI container. + * + * @return Engineer + * @since 3.2.0 + */ + public function getEngineer(Container $container): Engineer + { + return new Engineer( + $container->get('GetBible.Scripture'), + $container->get('GetBible.Prompt'), + $container->get('GetBible.Placeholders'), + $container->get('Openai.Chat'), + $container->get('GetBible.Insert') + ); + } +} + diff --git a/src/b2c9493f-692b-426b-af22-c6865f76c2bb/code.power b/src/b2c9493f-692b-426b-af22-c6865f76c2bb/code.power index 69309b0..8ab082a 100644 --- a/src/b2c9493f-692b-426b-af22-c6865f76c2bb/code.power +++ b/src/b2c9493f-692b-426b-af22-c6865f76c2bb/code.power @@ -1 +1,52 @@ -###CODEPOWER### \ No newline at end of file + /** + * 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(GetBible::class, 'GetBible.AI') + ->share('GetBible.AI', [$this, 'getAI'], true); + + $container->alias(Engineer::class, 'GetBible.AI.Engineer') + ->share('GetBible.AI.Engineer', [$this, 'getEngineer'], true); + } + + /** + * Get the GetBible AI class + * + * @param Container $container The DI container. + * + * @return GetBible + * @since 3.2.0 + */ + public function getAI(Container $container): GetBible + { + return new GetBible( + $container->get('GetBible.Config'), + $container->get('GetBible.Response'), + $container->get('GetBible.AI.Engineer') + ); + } + + /** + * Get the Engineer AI class + * + * @param Container $container The DI container. + * + * @return Engineer + * @since 3.2.0 + */ + public function getEngineer(Container $container): Engineer + { + return new Engineer( + $container->get('GetBible.Scripture'), + $container->get('GetBible.Prompt'), + $container->get('GetBible.Placeholders'), + $container->get('Openai.Chat'), + $container->get('GetBible.Insert') + ); + } \ No newline at end of file diff --git a/src/b2c9493f-692b-426b-af22-c6865f76c2bb/settings.json b/src/b2c9493f-692b-426b-af22-c6865f76c2bb/settings.json index 6b3b222..33df5b3 100644 --- a/src/b2c9493f-692b-426b-af22-c6865f76c2bb/settings.json +++ b/src/b2c9493f-692b-426b-af22-c6865f76c2bb/settings.json @@ -1 +1,30 @@ -###POWERLINKER### \ No newline at end of file +{ + "add_head": "1", + "add_licensing_template": "2", + "extends": "0", + "guid": "b2c9493f-692b-426b-af22-c6865f76c2bb", + "implements": [ + "-1" + ], + "load_selection": null, + "name": "AI", + "power_version": "1.0.0", + "system_name": "Joomla.GetBible.Service.AI", + "type": "class", + "use_selection": { + "use_selection0": { + "use": "f3757646-bc63-4f11-98c1-a2663180ab5e", + "as": "GetBible" + }, + "use_selection1": { + "use": "ed16a9c4-e026-4d16-be60-81892ce7c6a9", + "as": "default" + } + }, + "namespace": "VDM\\Joomla\\GetBible\\Service.AI", + "description": "The GetBible AI 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 \r\n * @git 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": "" +} \ No newline at end of file diff --git a/src/b32eea04-6b9c-469d-94db-35d610686cf1/README.md b/src/b32eea04-6b9c-469d-94db-35d610686cf1/README.md index 433b69e..9590f0b 100644 --- a/src/b32eea04-6b9c-469d-94db-35d610686cf1/README.md +++ b/src/b32eea04-6b9c-469d-94db-35d610686cf1/README.md @@ -1 +1,69 @@ -###POWERREADME### \ No newline at end of file +``` +██████╗ ██████╗ ██╗ ██╗███████╗██████╗ +██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗ +██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝ +██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗ +██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║ +╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝ +``` +# class Api (Details) +> namespace: **VDM\Joomla\GetBible\Service** +```uml +@startuml +class Api #Gold { + + register(Container $container) : void + + getTranslations(Container $container) : Translations + + getBooks(Container $container) : Books + + getChapters(Container $container) : Chapters + + getVerses(Container $container) : Verses +} + +note right of Api::register + Registers the service provider with a DI container. + + since: 2.0.1 + return: void +end note + +note right of Api::getTranslations + Get the Translations class + + since: 3.2.0 + return: Translations +end note + +note right of Api::getBooks + Get the Books class + + since: 3.2.0 + return: Books +end note + +note right of Api::getChapters + Get the Chapters class + + since: 3.2.0 + return: Chapters +end note + +note right of Api::getVerses + Get the Verses class + + since: 3.2.0 + return: Verses +end note + +@enduml +``` + +--- +``` + ██╗ ██████╗██████╗ + ██║██╔════╝██╔══██╗ + ██║██║ ██████╔╝ +██ ██║██║ ██╔══██╗ +╚█████╔╝╚██████╗██████╔╝ + ╚════╝ ╚═════╝╚═════╝ +``` +> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder) + diff --git a/src/b32eea04-6b9c-469d-94db-35d610686cf1/code.php b/src/b32eea04-6b9c-469d-94db-35d610686cf1/code.php index 3d222d0..b08eb75 100644 --- a/src/b32eea04-6b9c-469d-94db-35d610686cf1/code.php +++ b/src/b32eea04-6b9c-469d-94db-35d610686cf1/code.php @@ -9,4 +9,113 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ -###POWERCODE### +namespace VDM\Joomla\GetBible\Service; + + +use Joomla\DI\Container; +use Joomla\DI\ServiceProviderInterface; +use VDM\Joomla\GetBible\Api\Translations; +use VDM\Joomla\GetBible\Api\Books; +use VDM\Joomla\GetBible\Api\Chapters; +use VDM\Joomla\GetBible\Api\Verses; + + +/** + * The GetBible Api Service + * + * @since 2.0.1 + */ +class Api implements ServiceProviderInterface +{ + /** + * Registers the service provider with a DI container. + * + * @param Container $container The DI container. + * + * @return void + * @since 2.0.1 + */ + public function register(Container $container) + { + $container->alias(Translations::class, 'GetBible.Api.Translations') + ->share('GetBible.Api.Translations', [$this, 'getTranslations'], true); + + $container->alias(Books::class, 'GetBible.Api.Books') + ->share('GetBible.Api.Books', [$this, 'getBooks'], true); + + $container->alias(Chapters::class, 'GetBible.Api.Chapters') + ->share('GetBible.Api.Chapters', [$this, 'getChapters'], true); + + $container->alias(Verses::class, 'GetBible.Api.Verses') + ->share('GetBible.Api.Verses', [$this, 'getVerses'], true); + } + + /** + * Get the Translations class + * + * @param Container $container The DI container. + * + * @return Translations + * @since 3.2.0 + */ + public function getTranslations(Container $container): Translations + { + return new Translations( + $container->get('GetBible.Utilities.Http'), + $container->get('GetBible.Utilities.Uri'), + $container->get('GetBible.Utilities.Response') + ); + } + + /** + * Get the Books class + * + * @param Container $container The DI container. + * + * @return Books + * @since 3.2.0 + */ + public function getBooks(Container $container): Books + { + return new Books( + $container->get('GetBible.Utilities.Http'), + $container->get('GetBible.Utilities.Uri'), + $container->get('GetBible.Utilities.Response') + ); + } + + /** + * Get the Chapters class + * + * @param Container $container The DI container. + * + * @return Chapters + * @since 3.2.0 + */ + public function getChapters(Container $container): Chapters + { + return new Chapters( + $container->get('GetBible.Utilities.Http'), + $container->get('GetBible.Utilities.Uri'), + $container->get('GetBible.Utilities.Response') + ); + } + + /** + * Get the Verses class + * + * @param Container $container The DI container. + * + * @return Verses + * @since 3.2.0 + */ + public function getVerses(Container $container): Verses + { + return new Verses( + $container->get('GetBible.Utilities.Http'), + $container->get('GetBible.Utilities.Uri'), + $container->get('GetBible.Utilities.Response') + ); + } +} + diff --git a/src/b32eea04-6b9c-469d-94db-35d610686cf1/code.power b/src/b32eea04-6b9c-469d-94db-35d610686cf1/code.power index 69309b0..1dfb81e 100644 --- a/src/b32eea04-6b9c-469d-94db-35d610686cf1/code.power +++ b/src/b32eea04-6b9c-469d-94db-35d610686cf1/code.power @@ -1 +1,90 @@ -###CODEPOWER### \ No newline at end of file + /** + * Registers the service provider with a DI container. + * + * @param Container $container The DI container. + * + * @return void + * @since 2.0.1 + */ + public function register(Container $container) + { + $container->alias(Translations::class, 'GetBible.Api.Translations') + ->share('GetBible.Api.Translations', [$this, 'getTranslations'], true); + + $container->alias(Books::class, 'GetBible.Api.Books') + ->share('GetBible.Api.Books', [$this, 'getBooks'], true); + + $container->alias(Chapters::class, 'GetBible.Api.Chapters') + ->share('GetBible.Api.Chapters', [$this, 'getChapters'], true); + + $container->alias(Verses::class, 'GetBible.Api.Verses') + ->share('GetBible.Api.Verses', [$this, 'getVerses'], true); + } + + /** + * Get the Translations class + * + * @param Container $container The DI container. + * + * @return Translations + * @since 3.2.0 + */ + public function getTranslations(Container $container): Translations + { + return new Translations( + $container->get('GetBible.Utilities.Http'), + $container->get('GetBible.Utilities.Uri'), + $container->get('GetBible.Utilities.Response') + ); + } + + /** + * Get the Books class + * + * @param Container $container The DI container. + * + * @return Books + * @since 3.2.0 + */ + public function getBooks(Container $container): Books + { + return new Books( + $container->get('GetBible.Utilities.Http'), + $container->get('GetBible.Utilities.Uri'), + $container->get('GetBible.Utilities.Response') + ); + } + + /** + * Get the Chapters class + * + * @param Container $container The DI container. + * + * @return Chapters + * @since 3.2.0 + */ + public function getChapters(Container $container): Chapters + { + return new Chapters( + $container->get('GetBible.Utilities.Http'), + $container->get('GetBible.Utilities.Uri'), + $container->get('GetBible.Utilities.Response') + ); + } + + /** + * Get the Verses class + * + * @param Container $container The DI container. + * + * @return Verses + * @since 3.2.0 + */ + public function getVerses(Container $container): Verses + { + return new Verses( + $container->get('GetBible.Utilities.Http'), + $container->get('GetBible.Utilities.Uri'), + $container->get('GetBible.Utilities.Response') + ); + } \ No newline at end of file diff --git a/src/b32eea04-6b9c-469d-94db-35d610686cf1/settings.json b/src/b32eea04-6b9c-469d-94db-35d610686cf1/settings.json index 6b3b222..5343885 100644 --- a/src/b32eea04-6b9c-469d-94db-35d610686cf1/settings.json +++ b/src/b32eea04-6b9c-469d-94db-35d610686cf1/settings.json @@ -1 +1,38 @@ -###POWERLINKER### \ No newline at end of file +{ + "add_head": "1", + "add_licensing_template": "2", + "extends": "0", + "guid": "b32eea04-6b9c-469d-94db-35d610686cf1", + "implements": [ + "-1" + ], + "load_selection": null, + "name": "Api", + "power_version": "1.0.0", + "system_name": "Joomla.GetBible.Service.Api", + "type": "class", + "use_selection": { + "use_selection0": { + "use": "be0cae8b-4b78-4f59-b97b-9e31ee6f52e0", + "as": "default" + }, + "use_selection1": { + "use": "491c91ce-6355-40d3-bbbd-622473c6c026", + "as": "default" + }, + "use_selection2": { + "use": "a752e4b2-9b5e-4188-8d33-3799c46d5119", + "as": "default" + }, + "use_selection3": { + "use": "afa508bf-78f8-4616-97cc-f2809584c086", + "as": "default" + } + }, + "namespace": "VDM\\Joomla\\GetBible\\Service.Api", + "description": "The GetBible Api Service\r\n\r\n@since 2.0.1", + "implements_custom": "ServiceProviderInterface", + "licensing_template": "\/**\r\n * @package GetBible\r\n *\r\n * @created 30th May, 2023\r\n * @author Llewellyn van der Merwe \r\n * @git 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": "" +} \ No newline at end of file diff --git a/src/b89d74ef-c71c-4a58-8455-5dbdfe94027a/README.md b/src/b89d74ef-c71c-4a58-8455-5dbdfe94027a/README.md index 433b69e..267095e 100644 --- a/src/b89d74ef-c71c-4a58-8455-5dbdfe94027a/README.md +++ b/src/b89d74ef-c71c-4a58-8455-5dbdfe94027a/README.md @@ -1 +1,77 @@ -###POWERREADME### \ No newline at end of file +``` +██████╗ ██████╗ ██╗ ██╗███████╗██████╗ +██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗ +██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝ +██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗ +██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║ +╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝ +``` +# class Utilities (Details) +> namespace: **VDM\Joomla\GetBible\Service** +```uml +@startuml +class Utilities #Gold { + + register(Container $container) : void + + getUri(Container $container) : Uri + + getResponse(Container $container) : Response + + getHttp(Container $container) : Http + + getString(Container $container) : StringHelper + + getSession(Container $container) : SessionHelper +} + +note right of Utilities::register + Registers the service provider with a DI container. + + since: 3.2.0 + return: void +end note + +note right of Utilities::getUri + Get the Uri class + + since: 3.2.0 + return: Uri +end note + +note right of Utilities::getResponse + Get the Response class + + since: 3.2.0 + return: Response +end note + +note right of Utilities::getHttp + Get the Http class + + since: 3.2.0 + return: Http +end note + +note right of Utilities::getString + Get the String Helper class + + since: 3.2.0 + return: StringHelper +end note + +note right of Utilities::getSession + Get the Session Helper class + + since: 3.2.0 + return: SessionHelper +end note + +@enduml +``` + +--- +``` + ██╗ ██████╗██████╗ + ██║██╔════╝██╔══██╗ + ██║██║ ██████╔╝ +██ ██║██║ ██╔══██╗ +╚█████╔╝╚██████╗██████╔╝ + ╚════╝ ╚═════╝╚═════╝ +``` +> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder) + diff --git a/src/b89d74ef-c71c-4a58-8455-5dbdfe94027a/code.php b/src/b89d74ef-c71c-4a58-8455-5dbdfe94027a/code.php index 3d222d0..74a87e2 100644 --- a/src/b89d74ef-c71c-4a58-8455-5dbdfe94027a/code.php +++ b/src/b89d74ef-c71c-4a58-8455-5dbdfe94027a/code.php @@ -9,4 +9,116 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ -###POWERCODE### +namespace VDM\Joomla\GetBible\Service; + + +use Joomla\DI\Container; +use Joomla\DI\ServiceProviderInterface; +use VDM\Joomla\GetBible\Utilities\Uri; +use VDM\Joomla\GetBible\Utilities\Response; +use VDM\Joomla\GetBible\Utilities\Http; +use VDM\Joomla\GetBible\Utilities\StringHelper; +use VDM\Joomla\GetBible\Utilities\SessionHelper; + + +/** + * The GetBible Utilities Service + * + * @since 3.2.0 + */ +class Utilities implements ServiceProviderInterface +{ + /** + * Registers the service provider with a DI container. + * + * @param Container $container The DI container. + * + * @return void + * @since 3.2.0 + */ + public function register(Container $container) + { + $container->alias(Uri::class, 'GetBible.Utilities.Uri') + ->share('GetBible.Utilities.Uri', [$this, 'getUri'], true); + + $container->alias(Response::class, 'GetBible.Utilities.Response') + ->share('GetBible.Utilities.Response', [$this, 'getResponse'], true); + + $container->alias(Http::class, 'GetBible.Utilities.Http') + ->share('GetBible.Utilities.Http', [$this, 'getHttp'], true); + + $container->alias(StringHelper::class, 'GetBible.Utilities.String') + ->share('GetBible.Utilities.String', [$this, 'getString'], true); + + $container->alias(SessionHelper::class, 'GetBible.Utilities.Session') + ->share('GetBible.Utilities.Session', [$this, 'getSession'], true); + } + + /** + * Get the Uri class + * + * @param Container $container The DI container. + * + * @return Uri + * @since 3.2.0 + */ + public function getUri(Container $container): Uri + { + return new Uri( + $container->get('GetBible.Config') + ); + } + + /** + * Get the Response class + * + * @param Container $container The DI container. + * + * @return Response + * @since 3.2.0 + */ + public function getResponse(Container $container): Response + { + return new Response(); + } + + /** + * Get the Http class + * + * @param Container $container The DI container. + * + * @return Http + * @since 3.2.0 + */ + public function getHttp(Container $container): Http + { + return new Http(); + } + + /** + * 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 Session Helper class + * + * @param Container $container The DI container. + * + * @return SessionHelper + * @since 3.2.0 + */ + public function getSession(Container $container): SessionHelper + { + return new SessionHelper(); + } +} + diff --git a/src/b89d74ef-c71c-4a58-8455-5dbdfe94027a/code.power b/src/b89d74ef-c71c-4a58-8455-5dbdfe94027a/code.power index 69309b0..772350c 100644 --- a/src/b89d74ef-c71c-4a58-8455-5dbdfe94027a/code.power +++ b/src/b89d74ef-c71c-4a58-8455-5dbdfe94027a/code.power @@ -1 +1,92 @@ -###CODEPOWER### \ No newline at end of file + /** + * Registers the service provider with a DI container. + * + * @param Container $container The DI container. + * + * @return void + * @since 3.2.0 + */ + public function register(Container $container) + { + $container->alias(Uri::class, 'GetBible.Utilities.Uri') + ->share('GetBible.Utilities.Uri', [$this, 'getUri'], true); + + $container->alias(Response::class, 'GetBible.Utilities.Response') + ->share('GetBible.Utilities.Response', [$this, 'getResponse'], true); + + $container->alias(Http::class, 'GetBible.Utilities.Http') + ->share('GetBible.Utilities.Http', [$this, 'getHttp'], true); + + $container->alias(StringHelper::class, 'GetBible.Utilities.String') + ->share('GetBible.Utilities.String', [$this, 'getString'], true); + + $container->alias(SessionHelper::class, 'GetBible.Utilities.Session') + ->share('GetBible.Utilities.Session', [$this, 'getSession'], true); + } + + /** + * Get the Uri class + * + * @param Container $container The DI container. + * + * @return Uri + * @since 3.2.0 + */ + public function getUri(Container $container): Uri + { + return new Uri( + $container->get('GetBible.Config') + ); + } + + /** + * Get the Response class + * + * @param Container $container The DI container. + * + * @return Response + * @since 3.2.0 + */ + public function getResponse(Container $container): Response + { + return new Response(); + } + + /** + * Get the Http class + * + * @param Container $container The DI container. + * + * @return Http + * @since 3.2.0 + */ + public function getHttp(Container $container): Http + { + return new Http(); + } + + /** + * 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 Session Helper class + * + * @param Container $container The DI container. + * + * @return SessionHelper + * @since 3.2.0 + */ + public function getSession(Container $container): SessionHelper + { + return new SessionHelper(); + } \ No newline at end of file diff --git a/src/b89d74ef-c71c-4a58-8455-5dbdfe94027a/settings.json b/src/b89d74ef-c71c-4a58-8455-5dbdfe94027a/settings.json index 6b3b222..e4cc2e6 100644 --- a/src/b89d74ef-c71c-4a58-8455-5dbdfe94027a/settings.json +++ b/src/b89d74ef-c71c-4a58-8455-5dbdfe94027a/settings.json @@ -1 +1,42 @@ -###POWERLINKER### \ No newline at end of file +{ + "add_head": "1", + "add_licensing_template": "2", + "extends": "0", + "guid": "b89d74ef-c71c-4a58-8455-5dbdfe94027a", + "implements": [ + "-1" + ], + "load_selection": null, + "name": "Utilities", + "power_version": "1.0.0", + "system_name": "Joomla.GetBible.Service.Utilities", + "type": "class", + "use_selection": { + "use_selection0": { + "use": "fc9ab6f0-c31b-4077-bb1c-2dcddd36f6bb", + "as": "default" + }, + "use_selection1": { + "use": "c99e85a0-d120-4f25-bcbf-0940dd7b773b", + "as": "default" + }, + "use_selection2": { + "use": "b8c66089-735e-4081-825c-8fe36b28e4a6", + "as": "default" + }, + "use_selection3": { + "use": "a5b32737-207d-4cf6-b8ae-ee815612c3a0", + "as": "default" + }, + "use_selection4": { + "use": "84e84cd1-c938-4559-8414-d5692db4118e", + "as": "default" + } + }, + "namespace": "VDM\\Joomla\\GetBible\\Service.Utilities", + "description": "The GetBible Utilities Service\r\n\r\n@since 3.2.0", + "implements_custom": "ServiceProviderInterface", + "licensing_template": "\/**\r\n * @package GetBible\r\n *\r\n * @created 30th May, 2023\r\n * @author Llewellyn van der Merwe \r\n * @git 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": "" +} \ No newline at end of file diff --git a/src/b8c66089-735e-4081-825c-8fe36b28e4a6/README.md b/src/b8c66089-735e-4081-825c-8fe36b28e4a6/README.md index 433b69e..8f97030 100644 --- a/src/b8c66089-735e-4081-825c-8fe36b28e4a6/README.md +++ b/src/b8c66089-735e-4081-825c-8fe36b28e4a6/README.md @@ -1 +1,36 @@ -###POWERREADME### \ No newline at end of file +``` +██████╗ ██████╗ ██╗ ██╗███████╗██████╗ +██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗ +██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝ +██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗ +██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║ +╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝ +``` +# final class Http (Details) +> namespace: **VDM\Joomla\GetBible\Utilities** +```uml +@startuml +class Http << (F,LightGreen) >> #Green { + + __construct() +} + +note right of Http::__construct + Constructor. + + since: 2.0.1 +end note + +@enduml +``` + +--- +``` + ██╗ ██████╗██████╗ + ██║██╔════╝██╔══██╗ + ██║██║ ██████╔╝ +██ ██║██║ ██╔══██╗ +╚█████╔╝╚██████╗██████╔╝ + ╚════╝ ╚═════╝╚═════╝ +``` +> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder) + diff --git a/src/b8c66089-735e-4081-825c-8fe36b28e4a6/code.php b/src/b8c66089-735e-4081-825c-8fe36b28e4a6/code.php index 3d222d0..52c3cd4 100644 --- a/src/b8c66089-735e-4081-825c-8fe36b28e4a6/code.php +++ b/src/b8c66089-735e-4081-825c-8fe36b28e4a6/code.php @@ -9,4 +9,40 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ -###POWERCODE### +namespace VDM\Joomla\GetBible\Utilities; + + +use Joomla\CMS\Http\Http as JoomlaHttp; +use Joomla\Registry\Registry; + + +/** + * The GetBible Http + * + * @since 2.0.1 + */ +final class Http extends JoomlaHttp +{ + /** + * Constructor. + * + * @since 2.0.1 + * @throws \InvalidArgumentException + **/ + public function __construct() + { + // setup config + $config = [ + 'userAgent' => 'JoomlaGetBible/2.0', + 'headers' => [ + 'Content-Type' => 'application/json' + ] + ]; + + $options = new Registry($config); + + // run parent constructor + parent::__construct($options); + } +} + diff --git a/src/b8c66089-735e-4081-825c-8fe36b28e4a6/code.power b/src/b8c66089-735e-4081-825c-8fe36b28e4a6/code.power index 69309b0..d53a742 100644 --- a/src/b8c66089-735e-4081-825c-8fe36b28e4a6/code.power +++ b/src/b8c66089-735e-4081-825c-8fe36b28e4a6/code.power @@ -1 +1,21 @@ -###CODEPOWER### \ No newline at end of file + /** + * Constructor. + * + * @since 2.0.1 + * @throws \InvalidArgumentException + **/ + public function __construct() + { + // setup config + $config = [ + 'userAgent' => 'JoomlaGetBible/2.0', + 'headers' => [ + 'Content-Type' => 'application/json' + ] + ]; + + $options = new Registry($config); + + // run parent constructor + parent::__construct($options); + } \ No newline at end of file diff --git a/src/b8c66089-735e-4081-825c-8fe36b28e4a6/settings.json b/src/b8c66089-735e-4081-825c-8fe36b28e4a6/settings.json index 6b3b222..c40260d 100644 --- a/src/b8c66089-735e-4081-825c-8fe36b28e4a6/settings.json +++ b/src/b8c66089-735e-4081-825c-8fe36b28e4a6/settings.json @@ -1 +1,19 @@ -###POWERLINKER### \ No newline at end of file +{ + "add_head": "1", + "add_licensing_template": "2", + "extends": "-1", + "guid": "b8c66089-735e-4081-825c-8fe36b28e4a6", + "implements": null, + "load_selection": null, + "name": "Http", + "power_version": "1.0.0", + "system_name": "Joomla.GetBible.Utilities.Http", + "type": "final class", + "use_selection": null, + "namespace": "VDM\\Joomla\\GetBible\\Utilities.Http", + "description": "The GetBible Http\r\n\r\n@since 2.0.1", + "extends_custom": "JoomlaHttp", + "licensing_template": "\/**\r\n * @package GetBible\r\n *\r\n * @created 30th May, 2023\r\n * @author Llewellyn van der Merwe \r\n * @git GetBible \r\n * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.\r\n * @license GNU General Public License version 2 or later; see LICENSE.txt\r\n *\/\r\n", + "head": "use Joomla\\CMS\\Http\\Http as JoomlaHttp;\r\nuse Joomla\\Registry\\Registry;", + "composer": "" +} \ No newline at end of file diff --git a/src/ba2151c0-8ffa-4a07-ba6e-93f135a3e9d5/README.md b/src/ba2151c0-8ffa-4a07-ba6e-93f135a3e9d5/README.md index 433b69e..a537905 100644 --- a/src/ba2151c0-8ffa-4a07-ba6e-93f135a3e9d5/README.md +++ b/src/ba2151c0-8ffa-4a07-ba6e-93f135a3e9d5/README.md @@ -1 +1,70 @@ -###POWERREADME### \ No newline at end of file +``` +██████╗ ██████╗ ██╗ ██╗███████╗██████╗ +██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗ +██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝ +██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗ +██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║ +╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝ +``` +# final class Placeholders (Details) +> namespace: **VDM\Joomla\GetBible\Data** +```uml +@startuml +class Placeholders << (F,LightGreen) >> #Green { + # Scripture $scripture + # Prompt $prompt + + __construct(Scripture $scripture, Prompt $prompt) + + get() : array + - all() : array + - without() : array + - words() : array +} + +note right of Placeholders::__construct + Constructor + + since: 2.0.1 +end note + +note right of Placeholders::get + Get the Open AI response + + since: 2.0.1 + return: array +end note + +note right of Placeholders::all + Get All Placeholders + + since: 2.0.1 + return: array +end note + +note right of Placeholders::without + Get All Placeholders without words + + since: 2.0.1 + return: array +end note + +note right of Placeholders::words + Get Words Placeholders + + since: 2.0.1 + return: array +end note + +@enduml +``` + +--- +``` + ██╗ ██████╗██████╗ + ██║██╔════╝██╔══██╗ + ██║██║ ██████╔╝ +██ ██║██║ ██╔══██╗ +╚█████╔╝╚██████╗██████╔╝ + ╚════╝ ╚═════╝╚═════╝ +``` +> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder) + diff --git a/src/ba2151c0-8ffa-4a07-ba6e-93f135a3e9d5/code.php b/src/ba2151c0-8ffa-4a07-ba6e-93f135a3e9d5/code.php index 3d222d0..fdc0e91 100644 --- a/src/ba2151c0-8ffa-4a07-ba6e-93f135a3e9d5/code.php +++ b/src/ba2151c0-8ffa-4a07-ba6e-93f135a3e9d5/code.php @@ -9,4 +9,143 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ -###POWERCODE### +namespace VDM\Joomla\GetBible\Data; + + +use VDM\Joomla\GetBible\Data\Scripture; +use VDM\Joomla\GetBible\Data\Prompt; + + +/** + * The GetBible Prompt Placeholders + * + * @since 2.0.1 + */ +final class Placeholders +{ + /** + * The Scripture class + * + * @var Scripture + * @since 2.0.1 + */ + protected Scripture $scripture; + + /** + * The Prompt class + * + * @var Prompt + * @since 2.0.1 + */ + protected Prompt $prompt; + + /** + * Constructor + * + * @param Scripture $scripture The scripture object. + * @param Prompt $prompt The prompt object. + * + * @since 2.0.1 + */ + public function __construct( + Scripture $scripture, + Prompt $prompt) + { + $this->scripture = $scripture; + $this->prompt = $prompt; + } + + /** + * Get the Open AI response + * + * @return array Array of response messages + * @since 2.0.1 + */ + public function get(): array + { + $integration = $this->prompt->getIntegration(); + $cache_behaviour = $this->prompt->getCacheBehaviour(); + + if ($integration === null || $cache_behaviour === null) + { + return []; + } + + if (($integration == 1 || $integration == 3) && ($cache_behaviour == 0 || $cache_behaviour == 2)) + { + return $this->all(); + } + elseif ($integration == 2 && ($cache_behaviour == 0 || $cache_behaviour == 2)) + { + return $this->without(); + } + + return $this->words(); + } + + /** + * Get All Placeholders + * + * @return array Array of Placeholders + * @since 2.0.1 + */ + private function all(): array + { + return [ + '[translation_name]' => $this->scripture->get('translation_name', ''), + '[translation_language]' => $this->scripture->get('translation_language', ''), + '[translation_lcsh]' => $this->scripture->get('translation_lcsh', ''), + '[translation_abbreviation]' => $this->scripture->get('translation_abbreviation', ''), + '[book_number]' => $this->scripture->get('book_number', ''), + '[book_name]' => $this->scripture->get('book_name', ''), + '[chapter_number]' => $this->scripture->get('chapter_number', ''), + '[chapter_name]' => $this->scripture->get('chapter_name', ''), + '[chapter_text]' => $this->scripture->get('chapter_text', ''), + '[verse_number]' => $this->scripture->get('verse_number', ''), + '[verse_name]' => $this->scripture->get('verse_name', ''), + '[verse_text]' => $this->scripture->get('verse_text', ''), + '[selected_word_number]' => $this->scripture->get('selected_word_number', ''), + '[selected_word_text]' => $this->scripture->get('selected_word_text', '') + ]; + } + + /** + * Get All Placeholders without words + * + * @return array Array of Placeholders + * @since 2.0.1 + */ + private function without(): array + { + return [ + '[translation_name]' => $this->scripture->get('translation_name', ''), + '[translation_language]' => $this->scripture->get('translation_language', ''), + '[translation_lcsh]' => $this->scripture->get('translation_lcsh', ''), + '[translation_abbreviation]' => $this->scripture->get('translation_abbreviation', ''), + '[book_number]' => $this->scripture->get('book_number', ''), + '[book_name]' => $this->scripture->get('book_name', ''), + '[chapter_number]' => $this->scripture->get('chapter_number', ''), + '[chapter_name]' => $this->scripture->get('chapter_name', ''), + '[chapter_text]' => $this->scripture->get('chapter_text', ''), + '[verse_number]' => $this->scripture->get('verse_number', ''), + '[verse_name]' => $this->scripture->get('verse_name', ''), + '[verse_text]' => $this->scripture->get('verse_text', '') + ]; + } + + /** + * Get Words Placeholders + * + * @return array Array of Placeholders + * @since 2.0.1 + */ + private function words(): array + { + return [ + '[translation_language]' => $this->scripture->get('translation_language', ''), + '[translation_lcsh]' => $this->scripture->get('translation_lcsh', ''), + '[selected_word_text]' => $this->scripture->get('selected_word_text', '') + ]; + } +} + diff --git a/src/ba2151c0-8ffa-4a07-ba6e-93f135a3e9d5/code.power b/src/ba2151c0-8ffa-4a07-ba6e-93f135a3e9d5/code.power index 69309b0..f915290 100644 --- a/src/ba2151c0-8ffa-4a07-ba6e-93f135a3e9d5/code.power +++ b/src/ba2151c0-8ffa-4a07-ba6e-93f135a3e9d5/code.power @@ -1 +1,124 @@ -###CODEPOWER### \ No newline at end of file + /** + * The Scripture class + * + * @var Scripture + * @since 2.0.1 + */ + protected Scripture $scripture; + + /** + * The Prompt class + * + * @var Prompt + * @since 2.0.1 + */ + protected Prompt $prompt; + + /** + * Constructor + * + * @param Scripture $scripture The scripture object. + * @param Prompt $prompt The prompt object. + * + * @since 2.0.1 + */ + public function __construct( + Scripture $scripture, + Prompt $prompt) + { + $this->scripture = $scripture; + $this->prompt = $prompt; + } + + /** + * Get the Open AI response + * + * @return array Array of response messages + * @since 2.0.1 + */ + public function get(): array + { + $integration = $this->prompt->getIntegration(); + $cache_behaviour = $this->prompt->getCacheBehaviour(); + + if ($integration === null || $cache_behaviour === null) + { + return []; + } + + if (($integration == 1 || $integration == 3) && ($cache_behaviour == 0 || $cache_behaviour == 2)) + { + return $this->all(); + } + elseif ($integration == 2 && ($cache_behaviour == 0 || $cache_behaviour == 2)) + { + return $this->without(); + } + + return $this->words(); + } + + /** + * Get All Placeholders + * + * @return array Array of Placeholders + * @since 2.0.1 + */ + private function all(): array + { + return [ + '[translation_name]' => $this->scripture->get('translation_name', ''), + '[translation_language]' => $this->scripture->get('translation_language', ''), + '[translation_lcsh]' => $this->scripture->get('translation_lcsh', ''), + '[translation_abbreviation]' => $this->scripture->get('translation_abbreviation', ''), + '[book_number]' => $this->scripture->get('book_number', ''), + '[book_name]' => $this->scripture->get('book_name', ''), + '[chapter_number]' => $this->scripture->get('chapter_number', ''), + '[chapter_name]' => $this->scripture->get('chapter_name', ''), + '[chapter_text]' => $this->scripture->get('chapter_text', ''), + '[verse_number]' => $this->scripture->get('verse_number', ''), + '[verse_name]' => $this->scripture->get('verse_name', ''), + '[verse_text]' => $this->scripture->get('verse_text', ''), + '[selected_word_number]' => $this->scripture->get('selected_word_number', ''), + '[selected_word_text]' => $this->scripture->get('selected_word_text', '') + ]; + } + + /** + * Get All Placeholders without words + * + * @return array Array of Placeholders + * @since 2.0.1 + */ + private function without(): array + { + return [ + '[translation_name]' => $this->scripture->get('translation_name', ''), + '[translation_language]' => $this->scripture->get('translation_language', ''), + '[translation_lcsh]' => $this->scripture->get('translation_lcsh', ''), + '[translation_abbreviation]' => $this->scripture->get('translation_abbreviation', ''), + '[book_number]' => $this->scripture->get('book_number', ''), + '[book_name]' => $this->scripture->get('book_name', ''), + '[chapter_number]' => $this->scripture->get('chapter_number', ''), + '[chapter_name]' => $this->scripture->get('chapter_name', ''), + '[chapter_text]' => $this->scripture->get('chapter_text', ''), + '[verse_number]' => $this->scripture->get('verse_number', ''), + '[verse_name]' => $this->scripture->get('verse_name', ''), + '[verse_text]' => $this->scripture->get('verse_text', '') + ]; + } + + /** + * Get Words Placeholders + * + * @return array Array of Placeholders + * @since 2.0.1 + */ + private function words(): array + { + return [ + '[translation_language]' => $this->scripture->get('translation_language', ''), + '[translation_lcsh]' => $this->scripture->get('translation_lcsh', ''), + '[selected_word_text]' => $this->scripture->get('selected_word_text', '') + ]; + } \ No newline at end of file diff --git a/src/ba2151c0-8ffa-4a07-ba6e-93f135a3e9d5/settings.json b/src/ba2151c0-8ffa-4a07-ba6e-93f135a3e9d5/settings.json index 6b3b222..a9042a5 100644 --- a/src/ba2151c0-8ffa-4a07-ba6e-93f135a3e9d5/settings.json +++ b/src/ba2151c0-8ffa-4a07-ba6e-93f135a3e9d5/settings.json @@ -1 +1,27 @@ -###POWERLINKER### \ No newline at end of file +{ + "add_head": "0", + "add_licensing_template": "2", + "extends": "0", + "guid": "ba2151c0-8ffa-4a07-ba6e-93f135a3e9d5", + "implements": null, + "load_selection": null, + "name": "Placeholders", + "power_version": "1.0.0", + "system_name": "Joomla.GetBible.Data.Placeholders", + "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" + } + }, + "namespace": "VDM\\Joomla\\GetBible\\Data.Placeholders", + "description": "The GetBible Prompt Placeholders\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 \r\n * @git 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": "" +} \ No newline at end of file diff --git a/src/be0cae8b-4b78-4f59-b97b-9e31ee6f52e0/README.md b/src/be0cae8b-4b78-4f59-b97b-9e31ee6f52e0/README.md index 433b69e..baaeced 100644 --- a/src/be0cae8b-4b78-4f59-b97b-9e31ee6f52e0/README.md +++ b/src/be0cae8b-4b78-4f59-b97b-9e31ee6f52e0/README.md @@ -1 +1,53 @@ -###POWERREADME### \ No newline at end of file +``` +██████╗ ██████╗ ██╗ ██╗███████╗██████╗ +██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗ +██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝ +██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗ +██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║ +╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝ +``` +# final class Translations (Details) +> namespace: **VDM\Joomla\GetBible\Api** +```uml +@startuml +class Translations << (F,LightGreen) >> #Green { + + list() : ?object + + checksum() : ?object + + sha(string $translation = 'kjv') : ?string +} + +note right of Translations::list + List the translations + + since: 2.0.1 + return: ?object +end note + +note right of Translations::checksum + List the translations checksums + + since: 2.0.1 + return: ?object +end note + +note right of Translations::sha + Get the translation's checksums + + since: 2.0.1 + return: ?string +end note + +@enduml +``` + +--- +``` + ██╗ ██████╗██████╗ + ██║██╔════╝██╔══██╗ + ██║██║ ██████╔╝ +██ ██║██║ ██╔══██╗ +╚█████╔╝╚██████╗██████╔╝ + ╚════╝ ╚═════╝╚═════╝ +``` +> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder) + diff --git a/src/be0cae8b-4b78-4f59-b97b-9e31ee6f52e0/code.php b/src/be0cae8b-4b78-4f59-b97b-9e31ee6f52e0/code.php index 3d222d0..4ff0648 100644 --- a/src/be0cae8b-4b78-4f59-b97b-9e31ee6f52e0/code.php +++ b/src/be0cae8b-4b78-4f59-b97b-9e31ee6f52e0/code.php @@ -9,4 +9,66 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ -###POWERCODE### +namespace VDM\Joomla\GetBible\Api; + + +use VDM\Joomla\GetBible\Abstraction\Api; + + +/** + * The GetBible Translations + * + * @since 2.0.1 + */ +final class Translations extends Api +{ + /** + * List the translations + * + * @return object|null The response object or null if an error occurs. + * @since 2.0.1 + */ + public function list(): ?object + { + return $this->response->get( + $this->http->get( + $this->uri->get('translations.json') + ) + ); + } + + /** + * List the translations checksums + * + * @return object|null The response object or null if an error occurs. + * @since 2.0.1 + */ + public function checksum(): ?object + { + return $this->response->get( + $this->http->get( + $this->uri->get('checksum.json') + ) + ); + } + + /** + * Get the translation's checksums + * + * @param string $translation The translation. + * + * @return string|null The response checksum or null if an error occurs. + * @since 2.0.1 + */ + public function sha(string $translation = 'kjv'): ?string + { + return trim( + $this->response->get( + $this->http->get( + $this->uri->get($translation . '.sha') + ) + ) + ); + } +} + diff --git a/src/be0cae8b-4b78-4f59-b97b-9e31ee6f52e0/code.power b/src/be0cae8b-4b78-4f59-b97b-9e31ee6f52e0/code.power index 69309b0..8f48ac1 100644 --- a/src/be0cae8b-4b78-4f59-b97b-9e31ee6f52e0/code.power +++ b/src/be0cae8b-4b78-4f59-b97b-9e31ee6f52e0/code.power @@ -1 +1,48 @@ -###CODEPOWER### \ No newline at end of file + /** + * List the translations + * + * @return object|null The response object or null if an error occurs. + * @since 2.0.1 + */ + public function list(): ?object + { + return $this->response->get( + $this->http->get( + $this->uri->get('translations.json') + ) + ); + } + + /** + * List the translations checksums + * + * @return object|null The response object or null if an error occurs. + * @since 2.0.1 + */ + public function checksum(): ?object + { + return $this->response->get( + $this->http->get( + $this->uri->get('checksum.json') + ) + ); + } + + /** + * Get the translation's checksums + * + * @param string $translation The translation. + * + * @return string|null The response checksum or null if an error occurs. + * @since 2.0.1 + */ + public function sha(string $translation = 'kjv'): ?string + { + return trim( + $this->response->get( + $this->http->get( + $this->uri->get($translation . '.sha') + ) + ) + ); + } \ No newline at end of file diff --git a/src/be0cae8b-4b78-4f59-b97b-9e31ee6f52e0/settings.json b/src/be0cae8b-4b78-4f59-b97b-9e31ee6f52e0/settings.json index 6b3b222..41e09cc 100644 --- a/src/be0cae8b-4b78-4f59-b97b-9e31ee6f52e0/settings.json +++ b/src/be0cae8b-4b78-4f59-b97b-9e31ee6f52e0/settings.json @@ -1 +1,18 @@ -###POWERLINKER### \ No newline at end of file +{ + "add_head": "0", + "add_licensing_template": "2", + "extends": "7b490e63-8d1f-46de-a0c4-154272fd5d7f", + "guid": "be0cae8b-4b78-4f59-b97b-9e31ee6f52e0", + "implements": null, + "load_selection": null, + "name": "Translations", + "power_version": "1.0.0", + "system_name": "Joomla.GetBible.Api.Translations", + "type": "final class", + "use_selection": null, + "namespace": "VDM\\Joomla\\GetBible\\Api.Translations", + "description": "The GetBible Translations\r\n\r\n@since 2.0.1", + "licensing_template": "\/**\r\n * @package GetBible\r\n *\r\n * @created 30th May, 2023\r\n * @author Llewellyn van der Merwe \r\n * @git 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": "" +} \ No newline at end of file diff --git a/src/c03b9c61-17d3-4774-a335-783903719f83/README.md b/src/c03b9c61-17d3-4774-a335-783903719f83/README.md index 433b69e..f5aae96 100644 --- a/src/c03b9c61-17d3-4774-a335-783903719f83/README.md +++ b/src/c03b9c61-17d3-4774-a335-783903719f83/README.md @@ -1 +1,149 @@ -###POWERREADME### \ No newline at end of file +``` +██████╗ ██████╗ ██╗ ██╗███████╗██████╗ +██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗ +██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝ +██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗ +██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║ +╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝ +``` +# final class Load (Details) +> namespace: **VDM\Joomla\GetBible\Database** +```uml +@startuml +class Load << (F,LightGreen) >> #Green { + # Table $table + # Model $model + # Database $load + + __construct(Table $table, Model $model, ...) + + value(array $keys, string $field, ...) : mixed + + max(array $filter, string $field, ...) : ?int + + count(array $filter, string $table) : ?int + + item(array $keys, string $table) : ?object + + items(array $keys, string $table) : ?array + - prefix(array $keys) : array +} + +note right of Load::__construct + Constructor + + since: 2.0.1 + + arguments: + Table $table + Model $model + Database $load +end note + +note right of Load::value + Get a value from a given table +Example: $this->value( +[ +'abbreviation' => 'kjv', +'book_nr' => 62, +'chapter' => 3, +'verse' => 16 +], 'value_key', 'table_name' +); + + since: 2.0.1 + return: mixed + + arguments: + array $keys + string $field + string $table +end note + +note right of Load::max + Get the max value based on a filtered result from a given table +Example: $this->max( +[ +'abbreviation' => 'kjv', +'book_nr' => 62, +'chapter' => 3, +'verse' => 16 +], 'value_key', 'table_name' +); + + since: 2.0.1 + return: ?int + + arguments: + array $filter + string $field + string $table +end note + +note right of Load::count + Count the number of items based on filter result from a given table +Example: $this->count( +[ +'abbreviation' => 'kjv', +'book_nr' => 62, +'chapter' => 3, +'verse' => 16 +], 'table_name' +); + + since: 2.0.1 + return: ?int +end note + +note right of Load::item + Get values from a given table +Example: $this->item( +[ +'abbriviation' => 'kjv', +'book_nr' => 62, +'chapter' => 3, +'verse' => 16 +], 'table_name' +); + + since: 2.0.1 + return: ?object +end note + +note right of Load::items + Get values from a given table +Example: $this->items( +[ +'abbriviation' => [ +'operator' => 'IN', +'value' => ['kjv', 'aov'] +], +'book_nr' => 62, +'chapter' => 3, +'verse' => [ +'operator' => 'IN', +'value' => [16, 17, 18] +] +], 'table_name' +); +Example: $this->items($ids, 'table_name'); + + since: 2.0.1 + return: ?array +end note + +note right of Load::prefix + Add prefix to the keys + + since: 2.0.1 + return: array +end note + +@enduml +``` + +--- +``` + ██╗ ██████╗██████╗ + ██║██╔════╝██╔══██╗ + ██║██║ ██████╔╝ +██ ██║██║ ██╔══██╗ +╚█████╔╝╚██████╗██████╔╝ + ╚════╝ ╚═════╝╚═════╝ +``` +> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder) + diff --git a/src/c03b9c61-17d3-4774-a335-783903719f83/code.php b/src/c03b9c61-17d3-4774-a335-783903719f83/code.php index 3d222d0..86ba1ee 100644 --- a/src/c03b9c61-17d3-4774-a335-783903719f83/code.php +++ b/src/c03b9c61-17d3-4774-a335-783903719f83/code.php @@ -9,4 +9,254 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ -###POWERCODE### +namespace VDM\Joomla\GetBible\Database; + + +use VDM\Joomla\GetBible\Table; +use VDM\Joomla\GetBible\Model\Load as Model; +use VDM\Joomla\Database\Load as Database; + + +/** + * GetBible Database Load + * + * @since 2.0.1 + */ +final class Load +{ + /** + * Search Table + * + * @var Table + * @since 2.0.1 + */ + protected Table $table; + + /** + * Model Load + * + * @var Model + * @since 2.0.1 + */ + protected Model $model; + + /** + * Database Load + * + * @var Database + * @since 2.0.1 + */ + protected Database $load; + + /** + * Constructor + * + * @param Table $table The core table object. + * @param Model $model The model object. + * @param Database $load The database object. + * + * @since 2.0.1 + */ + public function __construct(Table $table, Model $model, Database $load) + { + $this->table = $table; + $this->model = $model; + $this->load = $load; + } + + /** + * Get a value from a given table + * Example: $this->value( + * [ + * 'abbreviation' => 'kjv', + * 'book_nr' => 62, + * 'chapter' => 3, + * 'verse' => 16 + * ], 'value_key', 'table_name' + * ); + * + * @param array $keys The item keys + * @param string $field The field key + * @param string $table The table + * + * @return mixed + * @since 2.0.1 + */ + public function value(array $keys, string $field, string $table) + { + // check if this is a valid table + if ($this->table->exist($table, $field)) + { + return $this->model->value( + $this->load->value( + ["a.${field}" => $field], + ['a' => $table], + $this->prefix($keys) + ), + $field, + $table + ); + } + + return null; + } + + /** + * Get the max value based on a filtered result from a given table + * Example: $this->max( + * [ + * 'abbreviation' => 'kjv', + * 'book_nr' => 62, + * 'chapter' => 3, + * 'verse' => 16 + * ], 'value_key', 'table_name' + * ); + * + * @param array $filter The filter keys + * @param string $field The field key + * @param string $table The table + * + * @return int|null + * @since 2.0.1 + */ + public function max(array $filter, string $field, string $table): ?int + { + // check if this is a valid table + if ($this->table->exist($table, $field)) + { + return $this->load->max( + $field, + ['a' => $table], + $this->prefix($filter) + ); + } + + return null; + } + + /** + * Count the number of items based on filter result from a given table + * Example: $this->count( + * [ + * 'abbreviation' => 'kjv', + * 'book_nr' => 62, + * 'chapter' => 3, + * 'verse' => 16 + * ], 'table_name' + * ); + * + * @param array $filter The filter keys + * @param string $table The table + * + * @return int|null + * @since 2.0.1 + */ + public function count(array $filter, string $table): ?int + { + // check if this is a valid table + if ($this->table->exist($table)) + { + return $this->load->count( + ['a' => $table], + $this->prefix($filter) + ); + } + + return null; + } + + /** + * Get values from a given table + * Example: $this->item( + * [ + * 'abbriviation' => 'kjv', + * 'book_nr' => 62, + * 'chapter' => 3, + * 'verse' => 16 + * ], 'table_name' + * ); + * + * @param array $keys The item keys + * @param string $table The table + * + * @return object|null + * @since 2.0.1 + */ + public function item(array $keys, string $table): ?object + { + // check if this is a valid table + if ($this->table->exist($table)) + { + return $this->model->item( + $this->load->item( + ['all' => 'a.*'], + ['a' => $table], + $this->prefix($keys) + ), + $table + ); + } + + return null; + } + + /** + * Get values from a given table + * Example: $this->items( + * [ + * 'abbriviation' => [ + * 'operator' => 'IN', + * 'value' => ['kjv', 'aov'] + * ], + * 'book_nr' => 62, + * 'chapter' => 3, + * 'verse' => [ + * 'operator' => 'IN', + * 'value' => [16, 17, 18] + * ] + * ], 'table_name' + * ); + * Example: $this->items($ids, 'table_name'); + * + * @param array $keys The item keys + * @param string $table The table + * + * @return array|null + * @since 2.0.1 + */ + public function items(array $keys, string $table): ?array + { + // check if this is a valid table + if ($this->table->exist($table)) + { + return $this->model->items( + $this->load->items( + ['all' => 'a.*'], ['a' => $table], $this->prefix($keys) + ), + $table + ); + } + + return null; + } + + /** + * Add prefix to the keys + * + * @param array $keys The query keys + * + * @return array + * @since 2.0.1 + */ + private function prefix(array &$keys): array + { + // update the key values + $bucket = []; + foreach ($keys as $k => $v) + { + $bucket['a.' . $k] = $v; + } + return $bucket; + } +} + diff --git a/src/c03b9c61-17d3-4774-a335-783903719f83/code.power b/src/c03b9c61-17d3-4774-a335-783903719f83/code.power index 69309b0..1040256 100644 --- a/src/c03b9c61-17d3-4774-a335-783903719f83/code.power +++ b/src/c03b9c61-17d3-4774-a335-783903719f83/code.power @@ -1 +1,234 @@ -###CODEPOWER### \ No newline at end of file + /** + * Search Table + * + * @var Table + * @since 2.0.1 + */ + protected Table $table; + + /** + * Model Load + * + * @var Model + * @since 2.0.1 + */ + protected Model $model; + + /** + * Database Load + * + * @var Database + * @since 2.0.1 + */ + protected Database $load; + + /** + * Constructor + * + * @param Table $table The core table object. + * @param Model $model The model object. + * @param Database $load The database object. + * + * @since 2.0.1 + */ + public function __construct(Table $table, Model $model, Database $load) + { + $this->table = $table; + $this->model = $model; + $this->load = $load; + } + + /** + * Get a value from a given table + * Example: $this->value( + * [ + * 'abbreviation' => 'kjv', + * 'book_nr' => 62, + * 'chapter' => 3, + * 'verse' => 16 + * ], 'value_key', 'table_name' + * ); + * + * @param array $keys The item keys + * @param string $field The field key + * @param string $table The table + * + * @return mixed + * @since 2.0.1 + */ + public function value(array $keys, string $field, string $table) + { + // check if this is a valid table + if ($this->table->exist($table, $field)) + { + return $this->model->value( + $this->load->value( + ["a.${field}" => $field], + ['a' => $table], + $this->prefix($keys) + ), + $field, + $table + ); + } + + return null; + } + + /** + * Get the max value based on a filtered result from a given table + * Example: $this->max( + * [ + * 'abbreviation' => 'kjv', + * 'book_nr' => 62, + * 'chapter' => 3, + * 'verse' => 16 + * ], 'value_key', 'table_name' + * ); + * + * @param array $filter The filter keys + * @param string $field The field key + * @param string $table The table + * + * @return int|null + * @since 2.0.1 + */ + public function max(array $filter, string $field, string $table): ?int + { + // check if this is a valid table + if ($this->table->exist($table, $field)) + { + return $this->load->max( + $field, + ['a' => $table], + $this->prefix($filter) + ); + } + + return null; + } + + /** + * Count the number of items based on filter result from a given table + * Example: $this->count( + * [ + * 'abbreviation' => 'kjv', + * 'book_nr' => 62, + * 'chapter' => 3, + * 'verse' => 16 + * ], 'table_name' + * ); + * + * @param array $filter The filter keys + * @param string $table The table + * + * @return int|null + * @since 2.0.1 + */ + public function count(array $filter, string $table): ?int + { + // check if this is a valid table + if ($this->table->exist($table)) + { + return $this->load->count( + ['a' => $table], + $this->prefix($filter) + ); + } + + return null; + } + + /** + * Get values from a given table + * Example: $this->item( + * [ + * 'abbriviation' => 'kjv', + * 'book_nr' => 62, + * 'chapter' => 3, + * 'verse' => 16 + * ], 'table_name' + * ); + * + * @param array $keys The item keys + * @param string $table The table + * + * @return object|null + * @since 2.0.1 + */ + public function item(array $keys, string $table): ?object + { + // check if this is a valid table + if ($this->table->exist($table)) + { + return $this->model->item( + $this->load->item( + ['all' => 'a.*'], + ['a' => $table], + $this->prefix($keys) + ), + $table + ); + } + + return null; + } + + /** + * Get values from a given table + * Example: $this->items( + * [ + * 'abbriviation' => [ + * 'operator' => 'IN', + * 'value' => ['kjv', 'aov'] + * ], + * 'book_nr' => 62, + * 'chapter' => 3, + * 'verse' => [ + * 'operator' => 'IN', + * 'value' => [16, 17, 18] + * ] + * ], 'table_name' + * ); + * Example: $this->items($ids, 'table_name'); + * + * @param array $keys The item keys + * @param string $table The table + * + * @return array|null + * @since 2.0.1 + */ + public function items(array $keys, string $table): ?array + { + // check if this is a valid table + if ($this->table->exist($table)) + { + return $this->model->items( + $this->load->items( + ['all' => 'a.*'], ['a' => $table], $this->prefix($keys) + ), + $table + ); + } + + return null; + } + + /** + * Add prefix to the keys + * + * @param array $keys The query keys + * + * @return array + * @since 2.0.1 + */ + private function prefix(array &$keys): array + { + // update the key values + $bucket = []; + foreach ($keys as $k => $v) + { + $bucket['a.' . $k] = $v; + } + return $bucket; + } \ No newline at end of file diff --git a/src/c03b9c61-17d3-4774-a335-783903719f83/settings.json b/src/c03b9c61-17d3-4774-a335-783903719f83/settings.json index 6b3b222..b72cd32 100644 --- a/src/c03b9c61-17d3-4774-a335-783903719f83/settings.json +++ b/src/c03b9c61-17d3-4774-a335-783903719f83/settings.json @@ -1 +1,31 @@ -###POWERLINKER### \ No newline at end of file +{ + "add_head": "0", + "add_licensing_template": "2", + "extends": "0", + "guid": "c03b9c61-17d3-4774-a335-783903719f83", + "implements": null, + "load_selection": null, + "name": "Load", + "power_version": "1.0.0", + "system_name": "Joomla.GetBible.Database.Load", + "type": "final class", + "use_selection": { + "use_selection0": { + "use": "ff8d5fdb-2d1f-4178-bd18-a43b8efd1068", + "as": "default" + }, + "use_selection1": { + "use": "b1bd2b4f-dede-44ad-86e9-2a595a0a9ca0", + "as": "Model" + }, + "use_selection2": { + "use": "06f8eada-d59b-441c-b287-0aea1793da5a", + "as": "Database" + } + }, + "namespace": "VDM\\Joomla\\GetBible\\Database.Load", + "description": "GetBible Database Load\r\n\r\n@since 2.0.1", + "licensing_template": "\/**\r\n * @package GetBible\r\n *\r\n * @created 30th May, 2023\r\n * @author Llewellyn van der Merwe \r\n * @git 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": "" +} \ No newline at end of file diff --git a/src/c2a8a5fa-8e7f-443a-86d7-a8c1e4cdfa98/README.md b/src/c2a8a5fa-8e7f-443a-86d7-a8c1e4cdfa98/README.md index 433b69e..197f838 100644 --- a/src/c2a8a5fa-8e7f-443a-86d7-a8c1e4cdfa98/README.md +++ b/src/c2a8a5fa-8e7f-443a-86d7-a8c1e4cdfa98/README.md @@ -1 +1,75 @@ -###POWERREADME### \ No newline at end of file +``` +██████╗ ██████╗ ██╗ ██╗███████╗██████╗ +██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗ +██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝ +██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗ +██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║ +╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝ +``` +# final class Book (Details) +> namespace: **VDM\Joomla\GetBible\Watcher** +```uml +@startuml +class Book << (F,LightGreen) >> #Green { + # Books $books + + __construct(Load $load, Insert $insert, ...) + + translations(array $translations) : bool + + sync(string $translation, int $book) : bool + - load(string $translation, int $book) : bool + - update(string $translation) : bool +} + +note right of Book::__construct + Constructor + + since: 2.0.1 + + arguments: + Load $load + Insert $insert + Update $update + Books $books +end note + +note right of Book::translations + Update translations books + + since: 2.0.1 + return: bool +end note + +note right of Book::sync + Sync the target being watched + + since: 2.0.1 + return: bool +end note + +note right of Book::load + Load Book + + since: 2.0.1 + return: bool +end note + +note right of Book::update + Trigger the update of all books of this translation + + since: 2.0.1 + return: bool +end note + +@enduml +``` + +--- +``` + ██╗ ██████╗██████╗ + ██║██╔════╝██╔══██╗ + ██║██║ ██████╔╝ +██ ██║██║ ██╔══██╗ +╚█████╔╝╚██████╗██████╔╝ + ╚════╝ ╚═════╝╚═════╝ +``` +> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder) + diff --git a/src/c2a8a5fa-8e7f-443a-86d7-a8c1e4cdfa98/code.php b/src/c2a8a5fa-8e7f-443a-86d7-a8c1e4cdfa98/code.php index 3d222d0..0d9c1bc 100644 --- a/src/c2a8a5fa-8e7f-443a-86d7-a8c1e4cdfa98/code.php +++ b/src/c2a8a5fa-8e7f-443a-86d7-a8c1e4cdfa98/code.php @@ -9,4 +9,210 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ -###POWERCODE### +namespace VDM\Joomla\GetBible\Watcher; + + +use VDM\Joomla\GetBible\Database\Load; +use VDM\Joomla\GetBible\Database\Insert; +use VDM\Joomla\GetBible\Database\Update; +use VDM\Joomla\GetBible\Api\Books; +use VDM\Joomla\GetBible\Abstraction\Watcher; + + +/** + * The GetBible Book Watcher + * + * @since 2.0.1 + */ +final class Book extends Watcher +{ + /** + * The Books class + * + * @var Books + * @since 2.0.1 + */ + protected Books $books; + + /** + * Constructor + * + * @param Load $load The load object. + * @param Insert $insert The insert object. + * @param Update $update The update object. + * @param Books $books The books API object. + * + * @since 2.0.1 + */ + public function __construct( + Load $load, + Insert $insert, + Update $update, + Books $books) + { + // load the parent constructor + parent::__construct($load, $insert, $update); + + $this->books = $books; + + // set the table + $this->table = 'book'; + } + + /** + * Update translations books + * + * @param array $translations The translations ids. + * + * @return bool True on success + * @since 2.0.1 + */ + public function translations(array $translations): bool + { + foreach ($translations as $translation) + { + if (($abbreviation = $this->load->value(['id' => $translation], 'abbreviation', 'translation')) === null) + { + return false; + } + + if (!$this->update($abbreviation)) + { + return false; + } + } + + return true; + } + + /** + * Sync the target being watched + * + * @param string $translation The translation. + * @param int $book The book number. + * + * @return bool True on success + * @since 2.0.1 + */ + public function sync(string $translation, int $book): bool + { + // load the target if not found + if ($this->load($translation, $book)) + { + if ($this->isNew() || $this->hold()) + { + return true; + } + + // get API hash value + $hash = $this->books->sha($translation, $book); + + // confirm hash has not changed + if (hash_equals($hash, $this->target->sha)) + { + return $this->bump(); + } + + if ($this->update($translation)) + { + return true; + } + } + + return false; + } + + /** + * Load Book + * + * @param string $translation The translation. + * @param int $book The book number. + * + * @return bool True if translation found + * @since 2.0.1 + */ + private function load(string $translation, int $book): bool + { + // check local value + if (($this->target = $this->load->item(['abbreviation' => $translation, 'nr' => $book], $this->table)) !== null) + { + return true; + } + + // get all this translation books + $books = $this->books->list($translation); + + // check return data + if (!isset($books->{$book}) || !isset($books->{$book}->sha)) + { + return false; + } + + // add them to the database + $this->insert->items((array) $books, 'book'); + + if (($this->target = $this->load->item(['abbreviation' => $translation, 'nr' => $book], $this->table)) !== null) + { + $this->fresh = true; + } + + return $this->fresh; + } + + /** + * Trigger the update of all books of this translation + * + * @param string $translation The translation. + * + * @return bool True if update was a success + * @since 2.0.1 + */ + private function update(string $translation): bool + { + // get translations from the API + if (($books = $this->books->list($translation)) === null) + { + return false; + } + + // get the local books + $local_books = $this->load->items(['abbreviation' => $translation], $this->table); + + $update = []; + $insert = []; + $match = ['key' => 'nr', 'value' => '']; + + // dynamic update all books + foreach ($books as $book) + { + // check if the verse exist + $match['value'] = (string) $book->nr; + if ($local_books !== null && ($object = $this->getTarget($match, $local_books)) !== null) + { + $book->id = $object->id; + $book->created = $this->today; + $update[] = $book; + } + else + { + $insert[] = $book; + } + } + + // 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; + } +} + diff --git a/src/c2a8a5fa-8e7f-443a-86d7-a8c1e4cdfa98/code.power b/src/c2a8a5fa-8e7f-443a-86d7-a8c1e4cdfa98/code.power index 69309b0..df18e8d 100644 --- a/src/c2a8a5fa-8e7f-443a-86d7-a8c1e4cdfa98/code.power +++ b/src/c2a8a5fa-8e7f-443a-86d7-a8c1e4cdfa98/code.power @@ -1 +1,188 @@ -###CODEPOWER### \ No newline at end of file + /** + * The Books class + * + * @var Books + * @since 2.0.1 + */ + protected Books $books; + + /** + * Constructor + * + * @param Load $load The load object. + * @param Insert $insert The insert object. + * @param Update $update The update object. + * @param Books $books The books API object. + * + * @since 2.0.1 + */ + public function __construct( + Load $load, + Insert $insert, + Update $update, + Books $books) + { + // load the parent constructor + parent::__construct($load, $insert, $update); + + $this->books = $books; + + // set the table + $this->table = 'book'; + } + + /** + * Update translations books + * + * @param array $translations The translations ids. + * + * @return bool True on success + * @since 2.0.1 + */ + public function translations(array $translations): bool + { + foreach ($translations as $translation) + { + if (($abbreviation = $this->load->value(['id' => $translation], 'abbreviation', 'translation')) === null) + { + return false; + } + + if (!$this->update($abbreviation)) + { + return false; + } + } + + return true; + } + + /** + * Sync the target being watched + * + * @param string $translation The translation. + * @param int $book The book number. + * + * @return bool True on success + * @since 2.0.1 + */ + public function sync(string $translation, int $book): bool + { + // load the target if not found + if ($this->load($translation, $book)) + { + if ($this->isNew() || $this->hold()) + { + return true; + } + + // get API hash value + $hash = $this->books->sha($translation, $book); + + // confirm hash has not changed + if (hash_equals($hash, $this->target->sha)) + { + return $this->bump(); + } + + if ($this->update($translation)) + { + return true; + } + } + + return false; + } + + /** + * Load Book + * + * @param string $translation The translation. + * @param int $book The book number. + * + * @return bool True if translation found + * @since 2.0.1 + */ + private function load(string $translation, int $book): bool + { + // check local value + if (($this->target = $this->load->item(['abbreviation' => $translation, 'nr' => $book], $this->table)) !== null) + { + return true; + } + + // get all this translation books + $books = $this->books->list($translation); + + // check return data + if (!isset($books->{$book}) || !isset($books->{$book}->sha)) + { + return false; + } + + // add them to the database + $this->insert->items((array) $books, 'book'); + + if (($this->target = $this->load->item(['abbreviation' => $translation, 'nr' => $book], $this->table)) !== null) + { + $this->fresh = true; + } + + return $this->fresh; + } + + /** + * Trigger the update of all books of this translation + * + * @param string $translation The translation. + * + * @return bool True if update was a success + * @since 2.0.1 + */ + private function update(string $translation): bool + { + // get translations from the API + if (($books = $this->books->list($translation)) === null) + { + return false; + } + + // get the local books + $local_books = $this->load->items(['abbreviation' => $translation], $this->table); + + $update = []; + $insert = []; + $match = ['key' => 'nr', 'value' => '']; + + // dynamic update all books + foreach ($books as $book) + { + // check if the verse exist + $match['value'] = (string) $book->nr; + if ($local_books !== null && ($object = $this->getTarget($match, $local_books)) !== null) + { + $book->id = $object->id; + $book->created = $this->today; + $update[] = $book; + } + else + { + $insert[] = $book; + } + } + + // 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; + } \ No newline at end of file diff --git a/src/c2a8a5fa-8e7f-443a-86d7-a8c1e4cdfa98/settings.json b/src/c2a8a5fa-8e7f-443a-86d7-a8c1e4cdfa98/settings.json index 6b3b222..05c5174 100644 --- a/src/c2a8a5fa-8e7f-443a-86d7-a8c1e4cdfa98/settings.json +++ b/src/c2a8a5fa-8e7f-443a-86d7-a8c1e4cdfa98/settings.json @@ -1 +1,35 @@ -###POWERLINKER### \ No newline at end of file +{ + "add_head": "0", + "add_licensing_template": "2", + "extends": "37e36c41-16a7-4c5d-972c-99acad5fd0b1", + "guid": "c2a8a5fa-8e7f-443a-86d7-a8c1e4cdfa98", + "implements": null, + "load_selection": null, + "name": "Book", + "power_version": "1.0.0", + "system_name": "Joomla.GetBible.Watcher.Book", + "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": "491c91ce-6355-40d3-bbbd-622473c6c026", + "as": "default" + } + }, + "namespace": "VDM\\Joomla\\GetBible\\Watcher.Book", + "description": "The GetBible Book 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 \r\n * @git 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": "" +} \ No newline at end of file diff --git a/src/c4098e1a-46dd-4d60-9277-b3668a09edc8/README.md b/src/c4098e1a-46dd-4d60-9277-b3668a09edc8/README.md index 433b69e..8cc090a 100644 --- a/src/c4098e1a-46dd-4d60-9277-b3668a09edc8/README.md +++ b/src/c4098e1a-46dd-4d60-9277-b3668a09edc8/README.md @@ -1 +1,79 @@ -###POWERREADME### \ No newline at end of file +``` +██████╗ ██████╗ ██╗ ██╗███████╗██████╗ +██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗ +██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝ +██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗ +██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║ +╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝ +``` +# final class Translation (Details) +> namespace: **VDM\Joomla\GetBible\Data** +```uml +@startuml +class Translation << (F,LightGreen) >> #Green { + # Load $load + # Config $config + # array $translations + + __construct(Load $load, Config $config) + + getName() : string + + getLanguage() : string + + getLcsh() : string + + getAbbreviation() : string + + get() : ?object +} + +note right of Translation::__construct + Constructor + + since: 2.0.1 +end note + +note right of Translation::getName + Get the translation name + + since: 2.0.1 + return: string +end note + +note right of Translation::getLanguage + Get the translation language + + since: 2.0.1 + return: string +end note + +note right of Translation::getLcsh + Get the translation distribution lcsh + + since: 2.0.1 + return: string +end note + +note right of Translation::getAbbreviation + Get the translation abbreviation + + since: 2.0.1 + return: string +end note + +note right of Translation::get + Get the translation + + since: 2.0.1 + return: ?object +end note + +@enduml +``` + +--- +``` + ██╗ ██████╗██████╗ + ██║██╔════╝██╔══██╗ + ██║██║ ██████╔╝ +██ ██║██║ ██╔══██╗ +╚█████╔╝╚██████╗██████╔╝ + ╚════╝ ╚═════╝╚═════╝ +``` +> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder) + diff --git a/src/c4098e1a-46dd-4d60-9277-b3668a09edc8/code.php b/src/c4098e1a-46dd-4d60-9277-b3668a09edc8/code.php index 3d222d0..193a72b 100644 --- a/src/c4098e1a-46dd-4d60-9277-b3668a09edc8/code.php +++ b/src/c4098e1a-46dd-4d60-9277-b3668a09edc8/code.php @@ -9,4 +9,132 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ -###POWERCODE### +namespace VDM\Joomla\GetBible\Data; + + +use VDM\Joomla\GetBible\Database\Load; +use VDM\Joomla\GetBible\Openai\Config; + + +/** + * The GetBible Translation Data + * + * @since 2.0.1 + */ +final class Translation +{ + /** + * 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 translations + * + * @var array + * @since 2.0.1 + */ + protected array $translations = []; + + /** + * 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 translation name + * + * @return string The translation name + * @since 2.0.1 + */ + public function getName(): string + { + $translation = $this->get(); + return $translation ? $translation->translation ?? '' : ''; + } + + /** + * Get the translation language + * + * @return string The translation language + * @since 2.0.1 + */ + public function getLanguage(): string + { + $translation = $this->get(); + $lang = trim(preg_replace('/Bible\.?/', '', $this->getLcsh())); + return $translation ? $translation->language ?? $lang : ''; + } + + /** + * Get the translation distribution lcsh + * + * @return string The translation lcsh + * @since 2.0.1 + */ + public function getLcsh(): string + { + $translation = $this->get(); + return $translation ? $translation->distribution_lcsh ?? '' : ''; + } + + /** + * Get the translation abbreviation + * + * @return string The translation abbreviation + * @since 2.0.1 + */ + public function getAbbreviation(): string + { + $translation = $this->get(); + return $translation ? $translation->abbreviation ?? '' : ''; + } + + /** + * Get the translation + * + * @return object|null True on success + * @since 2.0.1 + */ + public function get(): ?object + { + // get selected translation abbreviation + $abbreviation = $this->config->get('translation'); + + if (empty($abbreviation)) + { + return null; + } + + if (!isset($this->translations[$abbreviation])) + { + $this->translations[$abbreviation] = $this->load->item( + ['abbreviation' => $abbreviation, 'published' => 1], + 'translation' + ); + } + + return $this->translations[$abbreviation]; + } +} + diff --git a/src/c4098e1a-46dd-4d60-9277-b3668a09edc8/code.power b/src/c4098e1a-46dd-4d60-9277-b3668a09edc8/code.power index 69309b0..9425e54 100644 --- a/src/c4098e1a-46dd-4d60-9277-b3668a09edc8/code.power +++ b/src/c4098e1a-46dd-4d60-9277-b3668a09edc8/code.power @@ -1 +1,113 @@ -###CODEPOWER### \ No newline at end of file + /** + * 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 translations + * + * @var array + * @since 2.0.1 + */ + protected array $translations = []; + + /** + * 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 translation name + * + * @return string The translation name + * @since 2.0.1 + */ + public function getName(): string + { + $translation = $this->get(); + return $translation ? $translation->translation ?? '' : ''; + } + + /** + * Get the translation language + * + * @return string The translation language + * @since 2.0.1 + */ + public function getLanguage(): string + { + $translation = $this->get(); + $lang = trim(preg_replace('/Bible\.?/', '', $this->getLcsh())); + return $translation ? $translation->language ?? $lang : ''; + } + + /** + * Get the translation distribution lcsh + * + * @return string The translation lcsh + * @since 2.0.1 + */ + public function getLcsh(): string + { + $translation = $this->get(); + return $translation ? $translation->distribution_lcsh ?? '' : ''; + } + + /** + * Get the translation abbreviation + * + * @return string The translation abbreviation + * @since 2.0.1 + */ + public function getAbbreviation(): string + { + $translation = $this->get(); + return $translation ? $translation->abbreviation ?? '' : ''; + } + + /** + * Get the translation + * + * @return object|null True on success + * @since 2.0.1 + */ + public function get(): ?object + { + // get selected translation abbreviation + $abbreviation = $this->config->get('translation'); + + if (empty($abbreviation)) + { + return null; + } + + if (!isset($this->translations[$abbreviation])) + { + $this->translations[$abbreviation] = $this->load->item( + ['abbreviation' => $abbreviation, 'published' => 1], + 'translation' + ); + } + + return $this->translations[$abbreviation]; + } \ No newline at end of file diff --git a/src/c4098e1a-46dd-4d60-9277-b3668a09edc8/settings.json b/src/c4098e1a-46dd-4d60-9277-b3668a09edc8/settings.json index 6b3b222..32a2c9e 100644 --- a/src/c4098e1a-46dd-4d60-9277-b3668a09edc8/settings.json +++ b/src/c4098e1a-46dd-4d60-9277-b3668a09edc8/settings.json @@ -1 +1,27 @@ -###POWERLINKER### \ No newline at end of file +{ + "add_head": "0", + "add_licensing_template": "2", + "extends": "0", + "guid": "c4098e1a-46dd-4d60-9277-b3668a09edc8", + "implements": null, + "load_selection": null, + "name": "Translation", + "power_version": "1.0.0", + "system_name": "Joomla.GetBible.Data.Translation", + "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.Translation", + "description": "The GetBible Translation 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 \r\n * @git 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": "" +} \ No newline at end of file diff --git a/src/c5077cd8-b042-4295-99cf-3a5ba2af7dce/README.md b/src/c5077cd8-b042-4295-99cf-3a5ba2af7dce/README.md index 433b69e..9bfc0b9 100644 --- a/src/c5077cd8-b042-4295-99cf-3a5ba2af7dce/README.md +++ b/src/c5077cd8-b042-4295-99cf-3a5ba2af7dce/README.md @@ -1 +1,69 @@ -###POWERREADME### \ No newline at end of file +``` +██████╗ ██████╗ ██╗ ██╗███████╗██████╗ +██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗ +██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝ +██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗ +██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║ +╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝ +``` +# class Watcher (Details) +> namespace: **VDM\Joomla\GetBible\Service** +```uml +@startuml +class Watcher #Gold { + + register(Container $container) : void + + getWatcher(Container $container) : Watch + + getTranslation(Container $container) : Translation + + getBook(Container $container) : Book + + getChapter(Container $container) : Chapter +} + +note right of Watcher::register + Registers the service provider with a DI container. + + since: 2.0.1 + return: void +end note + +note right of Watcher::getWatcher + Get the Watcher class + + since: 2.0.1 + return: Watch +end note + +note right of Watcher::getTranslation + Get the Translation class + + since: 2.0.1 + return: Translation +end note + +note right of Watcher::getBook + Get the Book class + + since: 2.0.1 + return: Book +end note + +note right of Watcher::getChapter + Get the Chapter class + + since: 2.0.1 + return: Chapter +end note + +@enduml +``` + +--- +``` + ██╗ ██████╗██████╗ + ██║██╔════╝██╔══██╗ + ██║██║ ██████╔╝ +██ ██║██║ ██╔══██╗ +╚█████╔╝╚██████╗██████╔╝ + ╚════╝ ╚═════╝╚═════╝ +``` +> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder) + diff --git a/src/c5077cd8-b042-4295-99cf-3a5ba2af7dce/code.php b/src/c5077cd8-b042-4295-99cf-3a5ba2af7dce/code.php index 3d222d0..28a0e12 100644 --- a/src/c5077cd8-b042-4295-99cf-3a5ba2af7dce/code.php +++ b/src/c5077cd8-b042-4295-99cf-3a5ba2af7dce/code.php @@ -9,4 +9,118 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ -###POWERCODE### +namespace VDM\Joomla\GetBible\Service; + + +use Joomla\DI\Container; +use Joomla\DI\ServiceProviderInterface; +use VDM\Joomla\GetBible\Watcher as Watch; +use VDM\Joomla\GetBible\Watcher\Translation; +use VDM\Joomla\GetBible\Watcher\Book; +use VDM\Joomla\GetBible\Watcher\Chapter; + + +/** + * The GetBible Watcher Service + * + * @since 2.0.1 + */ +class Watcher 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(Watch::class, 'GetBible.Watcher') + ->share('GetBible.Watcher', [$this, 'getWatcher'], true); + + $container->alias(Translation::class, 'GetBible.Watcher.Translation') + ->share('GetBible.Watcher.Translation', [$this, 'getTranslation'], true); + + $container->alias(Book::class, 'GetBible.Watcher.Book') + ->share('GetBible.Watcher.Book', [$this, 'getBook'], true); + + $container->alias(Chapter::class, 'GetBible.Watcher.Chapter') + ->share('GetBible.Watcher.Chapter', [$this, 'getChapter'], true); + } + + /** + * Get the Watcher class + * + * @param Container $container The DI container. + * + * @return Watch + * @since 2.0.1 + */ + public function getWatcher(Container $container): Watch + { + return new Watch( + $container->get('GetBible.Load'), + $container->get('GetBible.Watcher.Translation'), + $container->get('GetBible.Watcher.Book'), + $container->get('GetBible.Watcher.Chapter') + ); + } + + /** + * Get the Translation class + * + * @param Container $container The DI container. + * + * @return Translation + * @since 2.0.1 + */ + public function getTranslation(Container $container): Translation + { + return new Translation( + $container->get('GetBible.Load'), + $container->get('GetBible.Insert'), + $container->get('GetBible.Update'), + $container->get('GetBible.Api.Translations') + ); + } + + /** + * Get the Book class + * + * @param Container $container The DI container. + * + * @return Book + * @since 2.0.1 + */ + public function getBook(Container $container): Book + { + return new Book( + $container->get('GetBible.Load'), + $container->get('GetBible.Insert'), + $container->get('GetBible.Update'), + $container->get('GetBible.Api.Books') + ); + } + + /** + * Get the Chapter class + * + * @param Container $container The DI container. + * + * @return Chapter + * @since 2.0.1 + */ + public function getChapter(Container $container): Chapter + { + return new Chapter( + $container->get('GetBible.Load'), + $container->get('GetBible.Insert'), + $container->get('GetBible.Update'), + $container->get('GetBible.Api.Chapters'), + $container->get('GetBible.Api.Verses') + ); + } +} + diff --git a/src/c5077cd8-b042-4295-99cf-3a5ba2af7dce/code.power b/src/c5077cd8-b042-4295-99cf-3a5ba2af7dce/code.power index 69309b0..cb35e24 100644 --- a/src/c5077cd8-b042-4295-99cf-3a5ba2af7dce/code.power +++ b/src/c5077cd8-b042-4295-99cf-3a5ba2af7dce/code.power @@ -1 +1,95 @@ -###CODEPOWER### \ No newline at end of file + /** + * 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(Watch::class, 'GetBible.Watcher') + ->share('GetBible.Watcher', [$this, 'getWatcher'], true); + + $container->alias(Translation::class, 'GetBible.Watcher.Translation') + ->share('GetBible.Watcher.Translation', [$this, 'getTranslation'], true); + + $container->alias(Book::class, 'GetBible.Watcher.Book') + ->share('GetBible.Watcher.Book', [$this, 'getBook'], true); + + $container->alias(Chapter::class, 'GetBible.Watcher.Chapter') + ->share('GetBible.Watcher.Chapter', [$this, 'getChapter'], true); + } + + /** + * Get the Watcher class + * + * @param Container $container The DI container. + * + * @return Watch + * @since 2.0.1 + */ + public function getWatcher(Container $container): Watch + { + return new Watch( + $container->get('GetBible.Load'), + $container->get('GetBible.Watcher.Translation'), + $container->get('GetBible.Watcher.Book'), + $container->get('GetBible.Watcher.Chapter') + ); + } + + /** + * Get the Translation class + * + * @param Container $container The DI container. + * + * @return Translation + * @since 2.0.1 + */ + public function getTranslation(Container $container): Translation + { + return new Translation( + $container->get('GetBible.Load'), + $container->get('GetBible.Insert'), + $container->get('GetBible.Update'), + $container->get('GetBible.Api.Translations') + ); + } + + /** + * Get the Book class + * + * @param Container $container The DI container. + * + * @return Book + * @since 2.0.1 + */ + public function getBook(Container $container): Book + { + return new Book( + $container->get('GetBible.Load'), + $container->get('GetBible.Insert'), + $container->get('GetBible.Update'), + $container->get('GetBible.Api.Books') + ); + } + + /** + * Get the Chapter class + * + * @param Container $container The DI container. + * + * @return Chapter + * @since 2.0.1 + */ + public function getChapter(Container $container): Chapter + { + return new Chapter( + $container->get('GetBible.Load'), + $container->get('GetBible.Insert'), + $container->get('GetBible.Update'), + $container->get('GetBible.Api.Chapters'), + $container->get('GetBible.Api.Verses') + ); + } \ No newline at end of file diff --git a/src/c5077cd8-b042-4295-99cf-3a5ba2af7dce/settings.json b/src/c5077cd8-b042-4295-99cf-3a5ba2af7dce/settings.json index 6b3b222..eb2a62f 100644 --- a/src/c5077cd8-b042-4295-99cf-3a5ba2af7dce/settings.json +++ b/src/c5077cd8-b042-4295-99cf-3a5ba2af7dce/settings.json @@ -1 +1,38 @@ -###POWERLINKER### \ No newline at end of file +{ + "add_head": "1", + "add_licensing_template": "2", + "extends": "0", + "guid": "c5077cd8-b042-4295-99cf-3a5ba2af7dce", + "implements": [ + "-1" + ], + "load_selection": null, + "name": "Watcher", + "power_version": "1.0.0", + "system_name": "Joomla.GetBible.Service.Watcher", + "type": "class", + "use_selection": { + "use_selection0": { + "use": "f815fb33-f721-48a5-a84e-53f1986e8881", + "as": "Watch" + }, + "use_selection1": { + "use": "7d592acd-f031-4d0f-b667-584c88ae0495", + "as": "default" + }, + "use_selection2": { + "use": "c2a8a5fa-8e7f-443a-86d7-a8c1e4cdfa98", + "as": "default" + }, + "use_selection3": { + "use": "07d3888a-5f35-4ba7-977f-fb2f5cf99061", + "as": "default" + } + }, + "namespace": "VDM\\Joomla\\GetBible\\Service.Watcher", + "description": "The GetBible Watcher 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 \r\n * @git 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": "" +} \ No newline at end of file diff --git a/src/c99e85a0-d120-4f25-bcbf-0940dd7b773b/README.md b/src/c99e85a0-d120-4f25-bcbf-0940dd7b773b/README.md index 433b69e..767903b 100644 --- a/src/c99e85a0-d120-4f25-bcbf-0940dd7b773b/README.md +++ b/src/c99e85a0-d120-4f25-bcbf-0940dd7b773b/README.md @@ -1 +1,58 @@ -###POWERREADME### \ No newline at end of file +``` +██████╗ ██████╗ ██╗ ██╗███████╗██████╗ +██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗ +██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝ +██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗ +██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║ +╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝ +``` +# final class Response (Details) +> namespace: **VDM\Joomla\GetBible\Utilities** +```uml +@startuml +class Response << (F,LightGreen) >> #Green { + + get(JoomlaResponse $response, int $expectedCode = 200, ...) : mixed + # getBody(JoomlaResponse $response, mixed $default = null) : mixed + # error(JoomlaResponse $response) : string +} + +note right of Response::get + Process the response and decode it. + + since: 2.0.1 + return: mixed + + arguments: + JoomlaResponse $response + int $expectedCode = 200 + mixed $default = null +end note + +note right of Response::getBody + Return the body from the response + + since: 2.0.1 + return: mixed +end note + +note right of Response::error + Get the error message from the GetBible API response + + since: 2.0.1 + return: string +end note + +@enduml +``` + +--- +``` + ██╗ ██████╗██████╗ + ██║██╔════╝██╔══██╗ + ██║██║ ██████╔╝ +██ ██║██║ ██╔══██╗ +╚█████╔╝╚██████╗██████╔╝ + ╚════╝ ╚═════╝╚═════╝ +``` +> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder) + diff --git a/src/c99e85a0-d120-4f25-bcbf-0940dd7b773b/code.php b/src/c99e85a0-d120-4f25-bcbf-0940dd7b773b/code.php index 3d222d0..4264c8a 100644 --- a/src/c99e85a0-d120-4f25-bcbf-0940dd7b773b/code.php +++ b/src/c99e85a0-d120-4f25-bcbf-0940dd7b773b/code.php @@ -9,4 +9,115 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ -###POWERCODE### +namespace VDM\Joomla\GetBible\Utilities; + + +use Joomla\CMS\Http\Response as JoomlaResponse; +use VDM\Joomla\Utilities\JsonHelper; +use VDM\Joomla\Utilities\StringHelper; + + +/** + * The GetBible Response + * + * @since 2.0.1 + */ +final class Response +{ + /** + * Process the response and decode it. + * + * @param JoomlaResponse $response The response. + * @param integer $expectedCode The expected "good" code. + * @param mixed $default The default if body not have length + * + * @return mixed + * + * @since 2.0.1 + * @throws \DomainException + **/ + public function get(JoomlaResponse $response, int $expectedCode = 200, $default = null) + { + // Validate the response code. + if ($response->code != $expectedCode) + { + // Decode the error response and throw an exception. + $message = $this->error($response); + + // Throw an exception with the GetBible error message and code. + throw new \DomainException($message, $response->code); + } + + return $this->getBody($response, $default); + } + + /** + * Return the body from the response + * + * @param JoomlaResponse $response The response. + * @param mixed $default The default if body not have length + * + * @return mixed + * @since 2.0.1 + **/ + protected function getBody(JoomlaResponse $response, $default = null) + { + // check that we have a body + if (isset($response->body) && StringHelper::check($response->body)) + { + // if it's JSON, decode it + if (JsonHelper::check($response->body)) + { + return json_decode((string) $response->body); + } + + // if it's XML, convert it to an object + libxml_use_internal_errors(true); + $xml = simplexml_load_string($response->body); + if ($xml !== false) + { + return $xml; + } + + // if it's neither JSON nor XML, return as is + return $response->body; + } + + return $default; + } + + /** + * Get the error message from the GetBible API response + * + * @param JoomlaResponse $response The response. + * + * @return string + * @since 2.0.1 + **/ + protected function error(JoomlaResponse $response): string + { + // do we have a json string + if (isset($response->body) && JsonHelper::check($response->body)) + { + $error = json_decode($response->body); + } + else + { + return 'Invalid or empty response body.'; + } + + // check if GetBible returned an error object + if (isset($error->Error)) + { + // error object found, extract message and code + $errorMessage = isset($error->Error->Message) ? $error->Error->Message : 'Unknown error.'; + $errorCode = isset($error->Error->Code) ? $error->Error->Code : 'Unknown error code.'; + + // return formatted error message + return 'Wasabi Error: ' . $errorMessage . ' Code: ' . $errorCode; + } + + return 'No error information found in response.'; + } +} + diff --git a/src/c99e85a0-d120-4f25-bcbf-0940dd7b773b/code.power b/src/c99e85a0-d120-4f25-bcbf-0940dd7b773b/code.power index 69309b0..f29c159 100644 --- a/src/c99e85a0-d120-4f25-bcbf-0940dd7b773b/code.power +++ b/src/c99e85a0-d120-4f25-bcbf-0940dd7b773b/code.power @@ -1 +1,95 @@ -###CODEPOWER### \ No newline at end of file + /** + * Process the response and decode it. + * + * @param JoomlaResponse $response The response. + * @param integer $expectedCode The expected "good" code. + * @param mixed $default The default if body not have length + * + * @return mixed + * + * @since 2.0.1 + * @throws \DomainException + **/ + public function get(JoomlaResponse $response, int $expectedCode = 200, $default = null) + { + // Validate the response code. + if ($response->code != $expectedCode) + { + // Decode the error response and throw an exception. + $message = $this->error($response); + + // Throw an exception with the GetBible error message and code. + throw new \DomainException($message, $response->code); + } + + return $this->getBody($response, $default); + } + + /** + * Return the body from the response + * + * @param JoomlaResponse $response The response. + * @param mixed $default The default if body not have length + * + * @return mixed + * @since 2.0.1 + **/ + protected function getBody(JoomlaResponse $response, $default = null) + { + // check that we have a body + if (isset($response->body) && StringHelper::check($response->body)) + { + // if it's JSON, decode it + if (JsonHelper::check($response->body)) + { + return json_decode((string) $response->body); + } + + // if it's XML, convert it to an object + libxml_use_internal_errors(true); + $xml = simplexml_load_string($response->body); + if ($xml !== false) + { + return $xml; + } + + // if it's neither JSON nor XML, return as is + return $response->body; + } + + return $default; + } + + /** + * Get the error message from the GetBible API response + * + * @param JoomlaResponse $response The response. + * + * @return string + * @since 2.0.1 + **/ + protected function error(JoomlaResponse $response): string + { + // do we have a json string + if (isset($response->body) && JsonHelper::check($response->body)) + { + $error = json_decode($response->body); + } + else + { + return 'Invalid or empty response body.'; + } + + // check if GetBible returned an error object + if (isset($error->Error)) + { + // error object found, extract message and code + $errorMessage = isset($error->Error->Message) ? $error->Error->Message : 'Unknown error.'; + $errorCode = isset($error->Error->Code) ? $error->Error->Code : 'Unknown error code.'; + + // return formatted error message + return 'Wasabi Error: ' . $errorMessage . ' Code: ' . $errorCode; + } + + return 'No error information found in response.'; + } \ No newline at end of file diff --git a/src/c99e85a0-d120-4f25-bcbf-0940dd7b773b/settings.json b/src/c99e85a0-d120-4f25-bcbf-0940dd7b773b/settings.json index 6b3b222..84f3cad 100644 --- a/src/c99e85a0-d120-4f25-bcbf-0940dd7b773b/settings.json +++ b/src/c99e85a0-d120-4f25-bcbf-0940dd7b773b/settings.json @@ -1 +1,27 @@ -###POWERLINKER### \ No newline at end of file +{ + "add_head": "1", + "add_licensing_template": "2", + "extends": "0", + "guid": "c99e85a0-d120-4f25-bcbf-0940dd7b773b", + "implements": null, + "load_selection": null, + "name": "Response", + "power_version": "1.0.0", + "system_name": "Joomla.GetBible.Utilities.Response", + "type": "final class", + "use_selection": { + "use_selection0": { + "use": "4b225c51-d293-48e4-b3f6-5136cf5c3f18", + "as": "default" + }, + "use_selection1": { + "use": "1f28cb53-60d9-4db1-b517-3c7dc6b429ef", + "as": "default" + } + }, + "namespace": "VDM\\Joomla\\GetBible\\Utilities.Response", + "description": "The GetBible Response\r\n\r\n@since 2.0.1", + "licensing_template": "\/**\r\n * @package GetBible\r\n *\r\n * @created 30th May, 2023\r\n * @author Llewellyn van der Merwe \r\n * @git GetBible \r\n * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.\r\n * @license GNU General Public License version 2 or later; see LICENSE.txt\r\n *\/\r\n", + "head": "use Joomla\\CMS\\Http\\Response as JoomlaResponse;", + "composer": "" +} \ No newline at end of file diff --git a/src/d7a5f0c6-de60-4d31-b3e4-5d668a8f7d2e/README.md b/src/d7a5f0c6-de60-4d31-b3e4-5d668a8f7d2e/README.md index 433b69e..6c5493a 100644 --- a/src/d7a5f0c6-de60-4d31-b3e4-5d668a8f7d2e/README.md +++ b/src/d7a5f0c6-de60-4d31-b3e4-5d668a8f7d2e/README.md @@ -1 +1,110 @@ -###POWERREADME### \ No newline at end of file +``` +██████╗ ██████╗ ██╗ ██╗███████╗██████╗ +██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗ +██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝ +██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗ +██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║ +╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝ +``` +# final class Update (Details) +> namespace: **VDM\Joomla\GetBible\Database** +```uml +@startuml +class Update << (F,LightGreen) >> #Green { + # Model $model + # Database $database + + __construct(Model $model, Database $database) + + value(mixed $value, string $field, ...) : bool + + row(array $item, string $key, ...) : bool + + rows(?array $items, string $key, ...) : bool + + item(object $item, string $key, ...) : bool + + items(?array $items, string $key, ...) : bool +} + +note right of Update::__construct + Constructor + + since: 2.0.1 +end note + +note right of Update::value + Update a value to a given table +Example: $this->value(Value, 'value_key', 'id', 'table_name'); + + since: 2.0.1 + return: bool + + arguments: + mixed $value + string $field + string $keyValue + string $key + string $table +end note + +note right of Update::row + Update single row with multiple values to a given table +Example: $this->item(Array, 'id', 'table_name'); + + since: 2.0.1 + return: bool + + arguments: + array $item + string $key + string $table +end note + +note right of Update::rows + Update multiple rows to a given table +Example: $this->items(Array, 'id', 'table_name'); + + since: 2.0.1 + return: bool + + arguments: + ?array $items + string $key + string $table +end note + +note right of Update::item + Update single item with multiple values to a given table +Example: $this->item(Object, 'id', 'table_name'); + + since: 2.0.1 + return: bool + + arguments: + object $item + string $key + string $table +end note + +note right of Update::items + Update multiple items to a given table +Example: $this->items(Array, 'id', 'table_name'); + + since: 2.0.1 + return: bool + + arguments: + ?array $items + string $key + string $table +end note + +@enduml +``` + +--- +``` + ██╗ ██████╗██████╗ + ██║██╔════╝██╔══██╗ + ██║██║ ██████╔╝ +██ ██║██║ ██╔══██╗ +╚█████╔╝╚██████╗██████╔╝ + ╚════╝ ╚═════╝╚═════╝ +``` +> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder) + diff --git a/src/d7a5f0c6-de60-4d31-b3e4-5d668a8f7d2e/code.php b/src/d7a5f0c6-de60-4d31-b3e4-5d668a8f7d2e/code.php index 3d222d0..dfa4101 100644 --- a/src/d7a5f0c6-de60-4d31-b3e4-5d668a8f7d2e/code.php +++ b/src/d7a5f0c6-de60-4d31-b3e4-5d668a8f7d2e/code.php @@ -9,4 +9,160 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ -###POWERCODE### +namespace VDM\Joomla\GetBible\Database; + + +use VDM\Joomla\GetBible\Model\Upsert as Model; +use VDM\Joomla\Database\Update as Database; + + +/** + * The GetBible Database Update + * + * @since 2.0.1 + */ +final class Update +{ + /** + * Model + * + * @var Model + * @since 2.0.1 + */ + protected Model $model; + + /** + * Database + * + * @var Database + * @since 2.0.1 + */ + protected Database $database; + + /** + * Constructor + * + * @param Model $model The set model object. + * @param Database $database The update database object. + * + * @since 2.0.1 + */ + public function __construct(Model $model, Database $database) + { + $this->model = $model; + $this->database = $database; + } + + /** + * Update a value to a given table + * Example: $this->value(Value, 'value_key', 'id', 'table_name'); + * + * @param mixed $value The field value + * @param string $field The field key + * @param string $keyValue The key value + * @param string $key The key name + * @param string $table Target table + * + * @return bool + * @since 2.0.1 + */ + public function value($value, string $field, string $keyValue, string $key, string $table): bool + { + // build the array + $item = []; + $item[$key] = $keyValue; + $item[$field] = $value; + + // Update the column of this table using guid as the primary key. + return $this->row($item, $key, $table); + } + + /** + * Update single row with multiple values to a given table + * Example: $this->item(Array, 'id', 'table_name'); + * + * @param array $item The item to save + * @param string $key The key name + * @param string $table Target table + * + * @return bool + * @since 2.0.1 + */ + public function row(array $item, string $key, string $table): bool + { + // check if object could be modelled + if (($item = $this->model->row($item, $table)) !== null) + { + // Update the column of this table using $key as the primary key. + return $this->database->row($item, $key, $table); + } + return false; + } + + /** + * Update multiple rows to a given table + * Example: $this->items(Array, 'id', 'table_name'); + * + * @param array|null $items The items updated in database (array of arrays) + * @param string $key The key name + * @param string $table Target table + * + * @return bool + * @since 2.0.1 + */ + public function rows(?array $items, string $key, string $table): bool + { + // check if object could be modelled + if (($items = $this->model->rows($items, $table)) !== null) + { + // Update the column of this table using $key as the primary key. + return $this->database->rows($items, $key, $table); + } + return false; + } + + /** + * Update single item with multiple values to a given table + * Example: $this->item(Object, 'id', 'table_name'); + * + * @param object $item The item to save + * @param string $key The key name + * @param string $table Target table + * + * @return bool + * @since 2.0.1 + */ + public function item(object $item, string $key, string $table): bool + { + // check if object could be modelled + if (($item = $this->model->item($item, $table)) !== null) + { + // Update the column of this table using $key as the primary key. + return $this->database->item($item, $key, $table); + } + return false; + } + + /** + * Update multiple items to a given table + * Example: $this->items(Array, 'id', 'table_name'); + * + * @param array|null $items The items updated in database (array of objects) + * @param string $key The key name + * @param string $table Target table + * + * @return bool + * @since 2.0.1 + */ + public function items(?array $items, string $key, string $table): bool + { + // check if object could be modelled + if (($items = $this->model->items($items, $table)) !== null) + { + // Update the column of this table using $key as the primary key. + return $this->database->items($items, $key, $table); + } + return false; + } +} + diff --git a/src/d7a5f0c6-de60-4d31-b3e4-5d668a8f7d2e/code.power b/src/d7a5f0c6-de60-4d31-b3e4-5d668a8f7d2e/code.power index 69309b0..89fdfc9 100644 --- a/src/d7a5f0c6-de60-4d31-b3e4-5d668a8f7d2e/code.power +++ b/src/d7a5f0c6-de60-4d31-b3e4-5d668a8f7d2e/code.power @@ -1 +1,141 @@ -###CODEPOWER### \ No newline at end of file + /** + * Model + * + * @var Model + * @since 2.0.1 + */ + protected Model $model; + + /** + * Database + * + * @var Database + * @since 2.0.1 + */ + protected Database $database; + + /** + * Constructor + * + * @param Model $model The set model object. + * @param Database $database The update database object. + * + * @since 2.0.1 + */ + public function __construct(Model $model, Database $database) + { + $this->model = $model; + $this->database = $database; + } + + /** + * Update a value to a given table + * Example: $this->value(Value, 'value_key', 'id', 'table_name'); + * + * @param mixed $value The field value + * @param string $field The field key + * @param string $keyValue The key value + * @param string $key The key name + * @param string $table Target table + * + * @return bool + * @since 2.0.1 + */ + public function value($value, string $field, string $keyValue, string $key, string $table): bool + { + // build the array + $item = []; + $item[$key] = $keyValue; + $item[$field] = $value; + + // Update the column of this table using guid as the primary key. + return $this->row($item, $key, $table); + } + + /** + * Update single row with multiple values to a given table + * Example: $this->item(Array, 'id', 'table_name'); + * + * @param array $item The item to save + * @param string $key The key name + * @param string $table Target table + * + * @return bool + * @since 2.0.1 + */ + public function row(array $item, string $key, string $table): bool + { + // check if object could be modelled + if (($item = $this->model->row($item, $table)) !== null) + { + // Update the column of this table using $key as the primary key. + return $this->database->row($item, $key, $table); + } + return false; + } + + /** + * Update multiple rows to a given table + * Example: $this->items(Array, 'id', 'table_name'); + * + * @param array|null $items The items updated in database (array of arrays) + * @param string $key The key name + * @param string $table Target table + * + * @return bool + * @since 2.0.1 + */ + public function rows(?array $items, string $key, string $table): bool + { + // check if object could be modelled + if (($items = $this->model->rows($items, $table)) !== null) + { + // Update the column of this table using $key as the primary key. + return $this->database->rows($items, $key, $table); + } + return false; + } + + /** + * Update single item with multiple values to a given table + * Example: $this->item(Object, 'id', 'table_name'); + * + * @param object $item The item to save + * @param string $key The key name + * @param string $table Target table + * + * @return bool + * @since 2.0.1 + */ + public function item(object $item, string $key, string $table): bool + { + // check if object could be modelled + if (($item = $this->model->item($item, $table)) !== null) + { + // Update the column of this table using $key as the primary key. + return $this->database->item($item, $key, $table); + } + return false; + } + + /** + * Update multiple items to a given table + * Example: $this->items(Array, 'id', 'table_name'); + * + * @param array|null $items The items updated in database (array of objects) + * @param string $key The key name + * @param string $table Target table + * + * @return bool + * @since 2.0.1 + */ + public function items(?array $items, string $key, string $table): bool + { + // check if object could be modelled + if (($items = $this->model->items($items, $table)) !== null) + { + // Update the column of this table using $key as the primary key. + return $this->database->items($items, $key, $table); + } + return false; + } \ No newline at end of file diff --git a/src/d7a5f0c6-de60-4d31-b3e4-5d668a8f7d2e/settings.json b/src/d7a5f0c6-de60-4d31-b3e4-5d668a8f7d2e/settings.json index 6b3b222..97ffa2d 100644 --- a/src/d7a5f0c6-de60-4d31-b3e4-5d668a8f7d2e/settings.json +++ b/src/d7a5f0c6-de60-4d31-b3e4-5d668a8f7d2e/settings.json @@ -1 +1,27 @@ -###POWERLINKER### \ No newline at end of file +{ + "add_head": "0", + "add_licensing_template": "2", + "extends": "0", + "guid": "d7a5f0c6-de60-4d31-b3e4-5d668a8f7d2e", + "implements": null, + "load_selection": null, + "name": "Update", + "power_version": "1.0.0", + "system_name": "Joomla.GetBible.Database.Update", + "type": "final class", + "use_selection": { + "use_selection0": { + "use": "91b37bd7-b314-48be-91cf-434ec823bd80", + "as": "Model" + }, + "use_selection1": { + "use": "cce56585-58b0-4f72-a92c-e2635ea52d83", + "as": "Database" + } + }, + "namespace": "VDM\\Joomla\\GetBible\\Database.Update", + "description": "The GetBible Database Update\r\n\r\n@since 2.0.1", + "licensing_template": "\/**\r\n * @package GetBible\r\n *\r\n * @created 30th May, 2023\r\n * @author Llewellyn van der Merwe \r\n * @git 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": "" +} \ No newline at end of file diff --git a/src/e3798c7e-aae1-4e38-ba78-6018ce94630b/README.md b/src/e3798c7e-aae1-4e38-ba78-6018ce94630b/README.md index 433b69e..d1833df 100644 --- a/src/e3798c7e-aae1-4e38-ba78-6018ce94630b/README.md +++ b/src/e3798c7e-aae1-4e38-ba78-6018ce94630b/README.md @@ -1 +1,165 @@ -###POWERREADME### \ No newline at end of file +``` +██████╗ ██████╗ ██╗ ██╗███████╗██████╗ +██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗ +██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝ +██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗ +██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║ +╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝ +``` +# final class Verse (Details) +> namespace: **VDM\Joomla\GetBible\Data** +```uml +@startuml +class Verse << (F,LightGreen) >> #Green { + # Chapter $chapter + # Config $config + # Prompt $prompt + # StringHelper $stringHelper + # array $verses + + __construct(Chapter $chapter, Config $config, ...) + + getNumber() : string + + getName() : string + + getText() : string + + getVerse() : ?array + + getValid() : ?array + - get() : ?object + - loadVerseData(string $cacheKey, string $verses) : ?object + - selectedVersesRange(string $verses) : array + - splitAndTrim(string $str) : array + - validateSelectedVersesNumbers(array $verses, array $chapter) : ?string + - getVersesString(array $verses, array $chapter) : ?string + - getVersesArray(array $verses, array $chapter) : ?array + - validVerseNumbers(array $range) : ?array + - generateCacheKey(string $abbreviation, int $book, ...) : string +} + +note right of Verse::__construct + Constructor + + since: 2.0.1 + + arguments: + Chapter $chapter + Config $config + Prompt $prompt + StringHelper $stringHelper +end note + +note left of Verse::getNumber + Get the verse number/s + + since: 2.0.1 + return: string +end note + +note right of Verse::getName + Get the verse name + + since: 2.0.1 + return: string +end note + +note left of Verse::getText + Get the verse text + + since: 2.0.1 + return: string +end note + +note right of Verse::getVerse + Get the verse array + + since: 2.0.1 + return: ?array +end note + +note left of Verse::getValid + Get the valid verse numbers + + since: 2.0.1 + return: ?array +end note + +note right of Verse::get + Get the verse + + since: 2.0.1 + return: ?object +end note + +note left of Verse::loadVerseData + Loads the verse data + + since: 2.0.1 + return: ?object +end note + +note right of Verse::selectedVersesRange + Get the range of verses selected + + since: 2.0.1 + return: array +end note + +note left of Verse::splitAndTrim + Split string by '-' and trim each element. + + since: 2.0.1 + return: array +end note + +note right of Verse::validateSelectedVersesNumbers + Validate that these verse numbers exist in chapter + + since: 2.0.1 + return: ?string +end note + +note left of Verse::getVersesString + Get the verses selected as text string + + since: 2.0.1 + return: ?string +end note + +note right of Verse::getVersesArray + Get the verses selected as multidimensional array + + since: 2.0.1 + return: ?array +end note + +note left of Verse::validVerseNumbers + Get all valid verse numbers + + since: 2.0.1 + return: ?array +end note + +note right of Verse::generateCacheKey + Generates a cache key based on the abbreviation, book, chapter, and verses + + since: 2.0.1 + return: string + + arguments: + string $abbreviation + int $book + int $chapter + string $verses +end note + +@enduml +``` + +--- +``` + ██╗ ██████╗██████╗ + ██║██╔════╝██╔══██╗ + ██║██║ ██████╔╝ +██ ██║██║ ██╔══██╗ +╚█████╔╝╚██████╗██████╔╝ + ╚════╝ ╚═════╝╚═════╝ +``` +> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder) + diff --git a/src/e3798c7e-aae1-4e38-ba78-6018ce94630b/code.php b/src/e3798c7e-aae1-4e38-ba78-6018ce94630b/code.php index 3d222d0..4ef1905 100644 --- a/src/e3798c7e-aae1-4e38-ba78-6018ce94630b/code.php +++ b/src/e3798c7e-aae1-4e38-ba78-6018ce94630b/code.php @@ -9,4 +9,445 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ -###POWERCODE### +namespace VDM\Joomla\GetBible\Data; + + +use VDM\Joomla\GetBible\Data\Chapter; +use VDM\Joomla\GetBible\Openai\Config; +use VDM\Joomla\GetBible\Data\Prompt; +use VDM\Joomla\GetBible\Utilities\StringHelper; + + +/** + * The GetBible Verse Data + * + * @since 2.0.1 + */ +final class Verse +{ + /** + * The Chapter class + * + * @var Chapter + * @since 2.0.1 + */ + protected Chapter $chapter; + + /** + * 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 StringHelper class + * + * @var StringHelper + * @since 2.0.1 + */ + protected StringHelper $stringHelper; + + /** + * The verses + * + * @var array + * @since 2.0.1 + */ + protected array $verses = []; + + /** + * Constructor + * + * @param Chapter $chapter The chapter object. + * @param Config $config The config object. + * @param Prompt $prompt The prompt object. + * @param StringHelper $stringHelper The string helper object. + * + * @since 2.0.1 + */ + public function __construct(Chapter $chapter, Config $config, Prompt $prompt, StringHelper $stringHelper) + { + $this->chapter = $chapter; + $this->config = $config; + $this->prompt = $prompt; + $this->stringHelper = $stringHelper; + } + + /** + * Get the verse number/s + * + * @return string The verse number/s + * @since 2.0.1 + */ + public function getNumber(): string + { + $verse = $this->get(); + return $verse ? $verse->number ?? '' : ''; + } + + /** + * Get the verse name + * + * @return string The verse name + * @since 2.0.1 + */ + public function getName(): string + { + $verse = $this->get(); + return $verse ? $verse->name ?? '' : ''; + } + + /** + * Get the verse text + * + * @return string The verse text + * @since 2.0.1 + */ + public function getText(): string + { + $verse = $this->get(); + return $verse ? $verse->text ?? '' : ''; + } + + /** + * Get the verse array + * + * @return array|null The verse array + * @since 2.0.1 + */ + public function getVerse(): ?array + { + $verse = $this->get(); + return $verse ? $verse->verse ?? null : null; + } + + /** + * Get the valid verse numbers + * + * @return array|null The verse number array + * @since 2.0.1 + */ + public function getValid(): ?array + { + $verse = $this->get(); + return $verse ? $verse->valid ?? null : null; + } + + /** + * Get the verse + * + * @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'); + + if (empty($abbreviation) || empty($book) || empty($chapter) || empty($verse)) + { + return null; + } + + $cacheKey = $this->generateCacheKey($abbreviation, $book, $chapter, $verse); + + if (isset($this->verses[$cacheKey])) + { + return $this->verses[$cacheKey]; + } + + return $this->loadVerseData($cacheKey, $verse); + } + + /** + * Loads the verse data + * + * @param string $cacheKey The cache key. + * @param string $verses The selected verses. + * + * @return object|null The loaded verse data, or null if not found or an error occurred. + * @since 2.0.1 + */ + private function loadVerseData(string $cacheKey, string $verses): ?object + { + $chapter = $this->chapter->getVerses(); + + if (empty($chapter)) + { + $this->verses[$cacheKey] = null; + + return null; + } + + $data = new \stdClass(); + + $data->range = $this->selectedVersesRange($verses); + + $data->number = $this->validateSelectedVersesNumbers($data->range, $chapter); + + $chapter_name = $this->chapter->getName(); + + if (empty($data->number) || empty($chapter_name)) + { + $this->verses[$cacheKey] = null; + + return null; + } + + $data->name = $chapter_name . ':' . $data->number; + + $data->text = $this->getVersesString($data->range, $chapter); + + $data->verse = $this->getVersesArray($data->range, $chapter); + + if (empty($data->text) || empty($data->verse)) + { + $this->verses[$cacheKey] = null; + + return null; + } + + $data->valid = $this->validVerseNumbers($data->range); + + $this->verses[$cacheKey] = $data; + + return $this->verses[$cacheKey]; + } + + /** + * Get the range of verses selected + * + * @param string $verses The selected verses + * + * @return array The the raw selected verses + * @since 2.0.1 + */ + private function selectedVersesRange(string $verses): array + { + $bucket = []; + + if (strpos($verses, '-') !== false) + { + $_verses = $this->splitAndTrim($verses); + + $min_verse = min($_verses); + $max_verse = max($_verses); + + $bucket[] = $min_verse; + if ($min_verse != $max_verse && $this->prompt->getIntegration() == 2) + { + $bucket[] = $max_verse; + } + } + else + { + $bucket[] = trim($verses); + } + + return $bucket; + } + + /** + * 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)]; + } + + /** + * Validate that these verse numbers exist in chapter + * + * @param array $verses The selected verse numbers + * @param array $chapter The chapter verses + * + * @return string|null The the valid verse numbers or empty string + * @since 2.0.1 + */ + private function validateSelectedVersesNumbers(array &$verses, array $chapter): ?string + { + $valid = []; + + foreach ($chapter as $verse) + { + if (isset($verses[0]) && $verse->verse == $verses[0]) + { + $valid[0] = $verses[0]; + } + elseif (isset($verses[1]) && $verse->verse == $verses[1]) + { + $valid[1] = $verses[1]; + } + } + + if ($valid !== []) + { + // update the verse array to its valid state + $verses = $valid; + + return implode('-', $valid); + } + + $verses = []; + + return null; + } + + /** + * Get the verses selected as text string + * + * @param array $verses The valid selected verse numbers + * @param array $chapter The chapter verses + * + * @return string|null The selected verses as a string + * @since 2.0.1 + */ + private function getVersesString(array $verses, array $chapter): ?string + { + $text = []; + + $add = false; + + foreach ($chapter as $verse) + { + if ($verse->verse == $verses[0]) + { + $add = true; + } + elseif (!isset($verses[1])) + { + $add = false; + } + + if ($add) + { + $text[] = trim($verse->verse) . ' ' . trim($verse->text); + } + + if (isset($verses[1]) && $verse->verse == $verses[1]) + { + $add = false; + } + } + + if (empty($text)) + { + return null; + } + + return implode(' ', $text); + } + + /** + * Get the verses selected as multidimensional array + * + * @param array $verses The valid selected verse numbers + * @param array $chapter The chapter verses + * + * @return array|null The selected verses as an array + * @since 2.0.1 + */ + private function getVersesArray(array $verses, array $chapter): ?array + { + $text = []; + + $add = false; + + foreach ($chapter as $verse) + { + if ($verse->verse == $verses[0]) + { + $add = true; + } + elseif (!isset($verses[1])) + { + $add = false; + } + + if ($add) + { + $text[$verse->verse] = $this->stringHelper->splitToWords(trim($verse->text), false); + } + + if (isset($verses[1]) && $verse->verse == $verses[1]) + { + $add = false; + } + } + + if (empty($text)) + { + return null; + } + + return $text; + } + + /** + * Get all valid verse numbers + * + * @param array $verses The verse range + * + * @return array|null The the valid verses + * @since 2.0.1 + */ + private function validVerseNumbers(array $range): ?array + { + if(count($range) == 1) + { + return $range; + } + elseif(count($range) == 2) + { + // sort the array in ascending order to make sure the range goes from lower to higher + sort($range); + + return range($range[0], $range[1]); + } + + return null; + } + + /** + * Generates a cache key based on the abbreviation, book, chapter, and verses + * + * @param string $abbreviation The translation abbreviation. + * @param int $book The book number. + * @param int $chapter The chapter number. + * @param string $verses The selected verses. + * + * @return string The generated cache key. + * @since 2.0.1 + */ + private function generateCacheKey($abbreviation, $book, int $chapter, string $verses): string + { + return $abbreviation . '_' . $book . '_' . $chapter . '_' . $verses; + } +} + diff --git a/src/e3798c7e-aae1-4e38-ba78-6018ce94630b/code.power b/src/e3798c7e-aae1-4e38-ba78-6018ce94630b/code.power index 69309b0..5d6a3ab 100644 --- a/src/e3798c7e-aae1-4e38-ba78-6018ce94630b/code.power +++ b/src/e3798c7e-aae1-4e38-ba78-6018ce94630b/code.power @@ -1 +1,424 @@ -###CODEPOWER### \ No newline at end of file + /** + * The Chapter class + * + * @var Chapter + * @since 2.0.1 + */ + protected Chapter $chapter; + + /** + * 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 StringHelper class + * + * @var StringHelper + * @since 2.0.1 + */ + protected StringHelper $stringHelper; + + /** + * The verses + * + * @var array + * @since 2.0.1 + */ + protected array $verses = []; + + /** + * Constructor + * + * @param Chapter $chapter The chapter object. + * @param Config $config The config object. + * @param Prompt $prompt The prompt object. + * @param StringHelper $stringHelper The string helper object. + * + * @since 2.0.1 + */ + public function __construct(Chapter $chapter, Config $config, Prompt $prompt, StringHelper $stringHelper) + { + $this->chapter = $chapter; + $this->config = $config; + $this->prompt = $prompt; + $this->stringHelper = $stringHelper; + } + + /** + * Get the verse number/s + * + * @return string The verse number/s + * @since 2.0.1 + */ + public function getNumber(): string + { + $verse = $this->get(); + return $verse ? $verse->number ?? '' : ''; + } + + /** + * Get the verse name + * + * @return string The verse name + * @since 2.0.1 + */ + public function getName(): string + { + $verse = $this->get(); + return $verse ? $verse->name ?? '' : ''; + } + + /** + * Get the verse text + * + * @return string The verse text + * @since 2.0.1 + */ + public function getText(): string + { + $verse = $this->get(); + return $verse ? $verse->text ?? '' : ''; + } + + /** + * Get the verse array + * + * @return array|null The verse array + * @since 2.0.1 + */ + public function getVerse(): ?array + { + $verse = $this->get(); + return $verse ? $verse->verse ?? null : null; + } + + /** + * Get the valid verse numbers + * + * @return array|null The verse number array + * @since 2.0.1 + */ + public function getValid(): ?array + { + $verse = $this->get(); + return $verse ? $verse->valid ?? null : null; + } + + /** + * Get the verse + * + * @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'); + + if (empty($abbreviation) || empty($book) || empty($chapter) || empty($verse)) + { + return null; + } + + $cacheKey = $this->generateCacheKey($abbreviation, $book, $chapter, $verse); + + if (isset($this->verses[$cacheKey])) + { + return $this->verses[$cacheKey]; + } + + return $this->loadVerseData($cacheKey, $verse); + } + + /** + * Loads the verse data + * + * @param string $cacheKey The cache key. + * @param string $verses The selected verses. + * + * @return object|null The loaded verse data, or null if not found or an error occurred. + * @since 2.0.1 + */ + private function loadVerseData(string $cacheKey, string $verses): ?object + { + $chapter = $this->chapter->getVerses(); + + if (empty($chapter)) + { + $this->verses[$cacheKey] = null; + + return null; + } + + $data = new \stdClass(); + + $data->range = $this->selectedVersesRange($verses); + + $data->number = $this->validateSelectedVersesNumbers($data->range, $chapter); + + $chapter_name = $this->chapter->getName(); + + if (empty($data->number) || empty($chapter_name)) + { + $this->verses[$cacheKey] = null; + + return null; + } + + $data->name = $chapter_name . ':' . $data->number; + + $data->text = $this->getVersesString($data->range, $chapter); + + $data->verse = $this->getVersesArray($data->range, $chapter); + + if (empty($data->text) || empty($data->verse)) + { + $this->verses[$cacheKey] = null; + + return null; + } + + $data->valid = $this->validVerseNumbers($data->range); + + $this->verses[$cacheKey] = $data; + + return $this->verses[$cacheKey]; + } + + /** + * Get the range of verses selected + * + * @param string $verses The selected verses + * + * @return array The the raw selected verses + * @since 2.0.1 + */ + private function selectedVersesRange(string $verses): array + { + $bucket = []; + + if (strpos($verses, '-') !== false) + { + $_verses = $this->splitAndTrim($verses); + + $min_verse = min($_verses); + $max_verse = max($_verses); + + $bucket[] = $min_verse; + if ($min_verse != $max_verse && $this->prompt->getIntegration() == 2) + { + $bucket[] = $max_verse; + } + } + else + { + $bucket[] = trim($verses); + } + + return $bucket; + } + + /** + * 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)]; + } + + /** + * Validate that these verse numbers exist in chapter + * + * @param array $verses The selected verse numbers + * @param array $chapter The chapter verses + * + * @return string|null The the valid verse numbers or empty string + * @since 2.0.1 + */ + private function validateSelectedVersesNumbers(array &$verses, array $chapter): ?string + { + $valid = []; + + foreach ($chapter as $verse) + { + if (isset($verses[0]) && $verse->verse == $verses[0]) + { + $valid[0] = $verses[0]; + } + elseif (isset($verses[1]) && $verse->verse == $verses[1]) + { + $valid[1] = $verses[1]; + } + } + + if ($valid !== []) + { + // update the verse array to its valid state + $verses = $valid; + + return implode('-', $valid); + } + + $verses = []; + + return null; + } + + /** + * Get the verses selected as text string + * + * @param array $verses The valid selected verse numbers + * @param array $chapter The chapter verses + * + * @return string|null The selected verses as a string + * @since 2.0.1 + */ + private function getVersesString(array $verses, array $chapter): ?string + { + $text = []; + + $add = false; + + foreach ($chapter as $verse) + { + if ($verse->verse == $verses[0]) + { + $add = true; + } + elseif (!isset($verses[1])) + { + $add = false; + } + + if ($add) + { + $text[] = trim($verse->verse) . ' ' . trim($verse->text); + } + + if (isset($verses[1]) && $verse->verse == $verses[1]) + { + $add = false; + } + } + + if (empty($text)) + { + return null; + } + + return implode(' ', $text); + } + + /** + * Get the verses selected as multidimensional array + * + * @param array $verses The valid selected verse numbers + * @param array $chapter The chapter verses + * + * @return array|null The selected verses as an array + * @since 2.0.1 + */ + private function getVersesArray(array $verses, array $chapter): ?array + { + $text = []; + + $add = false; + + foreach ($chapter as $verse) + { + if ($verse->verse == $verses[0]) + { + $add = true; + } + elseif (!isset($verses[1])) + { + $add = false; + } + + if ($add) + { + $text[$verse->verse] = $this->stringHelper->splitToWords(trim($verse->text), false); + } + + if (isset($verses[1]) && $verse->verse == $verses[1]) + { + $add = false; + } + } + + if (empty($text)) + { + return null; + } + + return $text; + } + + /** + * Get all valid verse numbers + * + * @param array $verses The verse range + * + * @return array|null The the valid verses + * @since 2.0.1 + */ + private function validVerseNumbers(array $range): ?array + { + if(count($range) == 1) + { + return $range; + } + elseif(count($range) == 2) + { + // sort the array in ascending order to make sure the range goes from lower to higher + sort($range); + + return range($range[0], $range[1]); + } + + return null; + } + + /** + * Generates a cache key based on the abbreviation, book, chapter, and verses + * + * @param string $abbreviation The translation abbreviation. + * @param int $book The book number. + * @param int $chapter The chapter number. + * @param string $verses The selected verses. + * + * @return string The generated cache key. + * @since 2.0.1 + */ + private function generateCacheKey($abbreviation, $book, int $chapter, string $verses): string + { + return $abbreviation . '_' . $book . '_' . $chapter . '_' . $verses; + } \ No newline at end of file diff --git a/src/e3798c7e-aae1-4e38-ba78-6018ce94630b/settings.json b/src/e3798c7e-aae1-4e38-ba78-6018ce94630b/settings.json index 6b3b222..c354d9d 100644 --- a/src/e3798c7e-aae1-4e38-ba78-6018ce94630b/settings.json +++ b/src/e3798c7e-aae1-4e38-ba78-6018ce94630b/settings.json @@ -1 +1,35 @@ -###POWERLINKER### \ No newline at end of file +{ + "add_head": "0", + "add_licensing_template": "2", + "extends": "0", + "guid": "e3798c7e-aae1-4e38-ba78-6018ce94630b", + "implements": null, + "load_selection": null, + "name": "Verse", + "power_version": "1.0.0", + "system_name": "Joomla.GetBible.Data.Verse", + "type": "final class", + "use_selection": { + "use_selection0": { + "use": "4a4c786d-51f4-421a-aa61-262dfd071880", + "as": "default" + }, + "use_selection1": { + "use": "3af7864b-f1f3-491e-b16f-0504f890086d", + "as": "default" + }, + "use_selection2": { + "use": "3f785d63-a592-463d-9f5f-b2b5a8edd561", + "as": "default" + }, + "use_selection3": { + "use": "a5b32737-207d-4cf6-b8ae-ee815612c3a0", + "as": "default" + } + }, + "namespace": "VDM\\Joomla\\GetBible\\Data.Verse", + "description": "The GetBible Verse 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 \r\n * @git 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": "" +} \ No newline at end of file diff --git a/src/ebda6bd8-95b9-468b-a521-974205146018/README.md b/src/ebda6bd8-95b9-468b-a521-974205146018/README.md index 433b69e..4ce8943 100644 --- a/src/ebda6bd8-95b9-468b-a521-974205146018/README.md +++ b/src/ebda6bd8-95b9-468b-a521-974205146018/README.md @@ -1 +1,97 @@ -###POWERREADME### \ No newline at end of file +``` +██████╗ ██████╗ ██╗ ██╗███████╗██████╗ +██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗ +██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝ +██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗ +██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║ +╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝ +``` +# final class Note (Details) +> namespace: **VDM\Joomla\GetBible** +```uml +@startuml +class Note << (F,LightGreen) >> #Green { + # Load $load + # Insert $insert + # Update $update + # Linker $linker + + __construct(Load $load, Insert $insert, ...) + + set(int $book, int $chapter, ...) : ?array + + delete(string $note) : bool + - get(string $linker, int $book, ...) : ?object + - create(string $linker, int $book, ...) : bool +} + +note right of Note::__construct + Constructor + + since: 2.0.1 + + arguments: + Load $load + Insert $insert + Update $update + Linker $linker +end note + +note right of Note::set + Set a note + + since: 2.0.1 + return: ?array + + arguments: + int $book + int $chapter + int $verse + ?string $note +end note + +note right of Note::delete + Delete a note + + since: 2.0.1 + return: bool +end note + +note right of Note::get + Get a note + + since: 2.0.1 + return: ?object + + arguments: + string $linker + int $book + int $chapter + int $verse +end note + +note right of Note::create + Create a note + + since: 2.0.1 + return: bool + + arguments: + string $linker + int $book + int $chapter + int $verse + ?string $note +end note + +@enduml +``` + +--- +``` + ██╗ ██████╗██████╗ + ██║██╔════╝██╔══██╗ + ██║██║ ██████╔╝ +██ ██║██║ ██╔══██╗ +╚█████╔╝╚██████╗██████╔╝ + ╚════╝ ╚═════╝╚═════╝ +``` +> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder) + diff --git a/src/ebda6bd8-95b9-468b-a521-974205146018/code.php b/src/ebda6bd8-95b9-468b-a521-974205146018/code.php index 3d222d0..c2932dd 100644 --- a/src/ebda6bd8-95b9-468b-a521-974205146018/code.php +++ b/src/ebda6bd8-95b9-468b-a521-974205146018/code.php @@ -9,4 +9,233 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ -###POWERCODE### +namespace VDM\Joomla\GetBible; + + +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 Note + * + * @since 2.0.1 + */ +final class Note +{ + /** + * 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; + } + + /** + * Set a note + * + * @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|null $note The note being made + * + * @return array|null Array of the note values on success + * @since 2.0.1 + **/ + public function set( + int $book, + int $chapter, + int $verse, + ?string $note + ): ?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 note if it exists + if (($_note = $this->get($linker, $book, $chapter, $verse)) !== null) + { + // publish if not published + if ($_note->published != 1 && !$this->update->value(1, 'published', $_note->id, 'id', 'note')) + { + return [ + 'error' => Text::_('COM_GETBIBLE_NOTE_ALREADY_EXIST_BUT_COULD_NOT_BE_REACTIVATED') + ]; + } + + // update the note if needed + if ((!isset($_note->note) || $_note->note !== $note) && !$this->update->value($note, 'note', $_note->id, 'id', 'note')) + { + return [ + 'error' => Text::_('COM_GETBIBLE_NOTE_ALREADY_EXIST_BUT_COULD_NOT_UPDATE_THE_NOTE_TEXT') + ]; + } + + $_note->published = 1; + $_note->note = $note; + $_note->success = Text::_('COM_GETBIBLE_THE_NOTE_WAS_SUCCESSFULLY_UPDATED'); + return (array) $_note; + } + // create a new tag + elseif ($this->create($linker, $book, $chapter, $verse, $note) + && ($_note = $this->get($linker, $book, $chapter, $verse)) !== null) + { + $_note->success = Text::_('COM_GETBIBLE_THE_NOTE_WAS_SUCCESSFULLY_CREATED'); + return (array) $_note; + } + + return null; + } + + /** + * Delete a note + * + * @param string $note The note GUID value + * + * @return bool True on success + * @since 2.0.1 + **/ + public function delete(string $note): bool + { + // make sure the linker has access + if (($linker = $this->linker->get()) === null) + { + return false; + } + + // make sure the linker has access to delete this tag + if (($id = $this->load->value(['guid' => $note, 'linker' => $linker], 'id', 'note')) !== null && $id > 0) + { + return $this->update->value(-2, 'published', $id, 'id', 'note'); + } + + return false; + } + + /** + * Get a note + * + * @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 + * + * @return object|null Object of the note values on success + * @since 2.0.1 + **/ + private function get( + string $linker, + int $book, + int $chapter, + int $verse + ): ?object + { + // get note if it exist + if (($note = $this->load->item([ + 'linker' => $linker, + 'book_nr' => $book, + 'chapter' => $chapter, + 'verse' => $verse + ], 'note')) !== null) + { + return $note; + } + + return null; + } + + /** + * Create a note + * + * @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|null $note The note being created (allow empty notes) + * + * @return bool True on success + * @since 2.0.1 + **/ + private function create( + string $linker, + int $book, + int $chapter, + int $verse, + ?string $note + ): bool + { + $guid = (string) GuidHelper::get(); + while (!GuidHelper::valid($guid, 'note', 0, 'getbible')) + { + // must always be set + $guid = (string) GuidHelper::get(); + } + + return $this->insert->row([ + 'note' => $note ?? '', + 'access' => 0, + 'linker' => $linker, + 'book_nr' => $book, + 'chapter' => $chapter, + 'verse' => $verse, + 'guid' => $guid + ], 'note'); + } +} + diff --git a/src/ebda6bd8-95b9-468b-a521-974205146018/code.power b/src/ebda6bd8-95b9-468b-a521-974205146018/code.power index 69309b0..a9bcbe7 100644 --- a/src/ebda6bd8-95b9-468b-a521-974205146018/code.power +++ b/src/ebda6bd8-95b9-468b-a521-974205146018/code.power @@ -1 +1,210 @@ -###CODEPOWER### \ No newline at end of file + /** + * 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; + } + + /** + * Set a note + * + * @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|null $note The note being made + * + * @return array|null Array of the note values on success + * @since 2.0.1 + **/ + public function set( + int $book, + int $chapter, + int $verse, + ?string $note + ): ?array + { + // make sure the linker has access + if (($linker = $this->linker->get()) === null) + { + return [ + 'error' => Text::_("Without selecting the correct favourite verse,
you can't perform the initial action."), + 'access_required' => true + ]; + } + + // get note if it exists + if (($_note = $this->get($linker, $book, $chapter, $verse)) !== null) + { + // publish if not published + if ($_note->published != 1 && !$this->update->value(1, 'published', $_note->id, 'id', 'note')) + { + return [ + 'error' => Text::_('Note already exist, but could not be reactivated.') + ]; + } + + // update the note if needed + if ((!isset($_note->note) || $_note->note !== $note) && !$this->update->value($note, 'note', $_note->id, 'id', 'note')) + { + return [ + 'error' => Text::_('Note already exist, but could not update the note text.') + ]; + } + + $_note->published = 1; + $_note->note = $note; + $_note->success = Text::_('The note was successfully updated.'); + return (array) $_note; + } + // create a new tag + elseif ($this->create($linker, $book, $chapter, $verse, $note) + && ($_note = $this->get($linker, $book, $chapter, $verse)) !== null) + { + $_note->success = Text::_('The note was successfully created.'); + return (array) $_note; + } + + return null; + } + + /** + * Delete a note + * + * @param string $note The note GUID value + * + * @return bool True on success + * @since 2.0.1 + **/ + public function delete(string $note): bool + { + // make sure the linker has access + if (($linker = $this->linker->get()) === null) + { + return false; + } + + // make sure the linker has access to delete this tag + if (($id = $this->load->value(['guid' => $note, 'linker' => $linker], 'id', 'note')) !== null && $id > 0) + { + return $this->update->value(-2, 'published', $id, 'id', 'note'); + } + + return false; + } + + /** + * Get a note + * + * @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 + * + * @return object|null Object of the note values on success + * @since 2.0.1 + **/ + private function get( + string $linker, + int $book, + int $chapter, + int $verse + ): ?object + { + // get note if it exist + if (($note = $this->load->item([ + 'linker' => $linker, + 'book_nr' => $book, + 'chapter' => $chapter, + 'verse' => $verse + ], 'note')) !== null) + { + return $note; + } + + return null; + } + + /** + * Create a note + * + * @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|null $note The note being created (allow empty notes) + * + * @return bool True on success + * @since 2.0.1 + **/ + private function create( + string $linker, + int $book, + int $chapter, + int $verse, + ?string $note + ): bool + { + $guid = (string) GuidHelper::get(); + while (!GuidHelper::valid($guid, 'note', 0, '[[[component]]]')) + { + // must always be set + $guid = (string) GuidHelper::get(); + } + + return $this->insert->row([ + 'note' => $note ?? '', + 'access' => 0, + 'linker' => $linker, + 'book_nr' => $book, + 'chapter' => $chapter, + 'verse' => $verse, + 'guid' => $guid + ], 'note'); + } \ No newline at end of file diff --git a/src/ebda6bd8-95b9-468b-a521-974205146018/settings.json b/src/ebda6bd8-95b9-468b-a521-974205146018/settings.json index 6b3b222..7f924d7 100644 --- a/src/ebda6bd8-95b9-468b-a521-974205146018/settings.json +++ b/src/ebda6bd8-95b9-468b-a521-974205146018/settings.json @@ -1 +1,39 @@ -###POWERLINKER### \ No newline at end of file +{ + "add_head": "1", + "add_licensing_template": "2", + "extends": "0", + "guid": "ebda6bd8-95b9-468b-a521-974205146018", + "implements": null, + "load_selection": null, + "name": "Note", + "power_version": "1.0.0", + "system_name": "Joomla.GetBible.Note", + "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\\Note", + "description": "The GetBible Note\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 \r\n * @git 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": "" +} \ No newline at end of file diff --git a/src/ed16a9c4-e026-4d16-be60-81892ce7c6a9/README.md b/src/ed16a9c4-e026-4d16-be60-81892ce7c6a9/README.md index 433b69e..18f2f50 100644 --- a/src/ed16a9c4-e026-4d16-be60-81892ce7c6a9/README.md +++ b/src/ed16a9c4-e026-4d16-be60-81892ce7c6a9/README.md @@ -1 +1,106 @@ -###POWERREADME### \ No newline at end of file +``` +██████╗ ██████╗ ██╗ ██╗███████╗██████╗ +██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗ +██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝ +██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗ +██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║ +╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝ +``` +# final class Engineer (Details) +> namespace: **VDM\Joomla\GetBible\AI** +```uml +@startuml +class Engineer << (F,LightGreen) >> #Green { + # Scripture $scripture + # Prompt $prompt + # Placeholders $placeholders + # Chat $chat + # Insert $insert + # ?array $messages + # ?object $response + + __construct(Scripture $scripture, Prompt $prompt, ...) + + get() : ?array + - saveMessages() : bool + - saveResponse() : bool + - modelResponse() : bool + - modelMessages() : bool + - getResponse() : bool + - getMessages() : ?array +} + +note right of Engineer::__construct + Constructor + + since: 2.0.1 + + arguments: + Scripture $scripture + Prompt $prompt + Placeholders $placeholders + Chat $chat + Insert $insert +end note + +note left of Engineer::get + Return the current data state + + since: 2.0.1 + return: ?array +end note + +note right of Engineer::saveMessages + Save the messages + + since: 2.0.1 + return: bool +end note + +note left of Engineer::saveResponse + Save the response + + since: 2.0.1 + return: bool +end note + +note right of Engineer::modelResponse + Prep the response data + + since: 2.0.1 + return: bool +end note + +note left of Engineer::modelMessages + Prep the messages + + since: 2.0.1 + return: bool +end note + +note right of Engineer::getResponse + Get the Open AI response + + since: 2.0.1 + return: bool +end note + +note left of Engineer::getMessages + Get the ready to use prompt messages + + since: 2.0.1 + return: ?array +end note + +@enduml +``` + +--- +``` + ██╗ ██████╗██████╗ + ██║██╔════╝██╔══██╗ + ██║██║ ██████╔╝ +██ ██║██║ ██╔══██╗ +╚█████╔╝╚██████╗██████╔╝ + ╚════╝ ╚═════╝╚═════╝ +``` +> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder) + diff --git a/src/ed16a9c4-e026-4d16-be60-81892ce7c6a9/code.php b/src/ed16a9c4-e026-4d16-be60-81892ce7c6a9/code.php index 3d222d0..45b4366 100644 --- a/src/ed16a9c4-e026-4d16-be60-81892ce7c6a9/code.php +++ b/src/ed16a9c4-e026-4d16-be60-81892ce7c6a9/code.php @@ -9,4 +9,300 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ -###POWERCODE### +namespace VDM\Joomla\GetBible\AI; + + +use VDM\Joomla\GetBible\Data\Scripture; +use VDM\Joomla\GetBible\Data\Prompt; +use VDM\Joomla\GetBible\Data\Placeholders; +use VDM\Joomla\Openai\Chat; +use VDM\Joomla\GetBible\Database\Insert; + + +/** + * The GetBible AI Engineer + * + * @since 2.0.1 + */ +final class Engineer +{ + /** + * 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 Placeholders class + * + * @var Placeholders + * @since 2.0.1 + */ + protected Placeholders $placeholders; + + /** + * The Chat class + * + * @var Chat + * @since 2.0.1 + */ + protected Chat $chat; + + /** + * The Insert class + * + * @var Insert + * @since 2.0.1 + */ + protected Insert $insert; + + /** + * The request messages + * + * @var array|null + * @since 2.0.1 + */ + protected ?array $messages = null; + + /** + * The response object + * + * @var object|null + * @since 2.0.1 + */ + protected ?object $response = null; + + /** + * Constructor + * + * @param Scripture $scripture The scripture object. + * @param Prompt $prompt The prompt object. + * @param Placeholders $placeholders The placeholders object. + * @param Chat $chat The chat object. + * @param Insert $insert The insert object. + * + * @since 2.0.1 + */ + public function __construct( + Scripture $scripture, + Prompt $prompt, + Placeholders $placeholders, + Chat $chat, + Insert $insert) + { + $this->scripture = $scripture; + $this->prompt = $prompt; + $this->placeholders = $placeholders; + $this->chat = $chat; + $this->insert = $insert; + } + + /** + * Return the current data state + * + * @return array|null True on success + * @since 2.0.1 + */ + public function get(): ?array + { + if ($this->getResponse() && $this->modelMessages() && $this->modelResponse() + && $this->saveResponse() && $this->saveMessages()) + { + // add this response's messages + $this->response->messages = $this->messages ?? ''; + + return [ + $this->response + ]; + } + + return null; + } + + /** + * Save the messages + * + * @return bool True on success + * @since 2.0.1 + */ + private function saveMessages(): bool + { + return $this->insert->items($this->messages, 'open_ai_message'); + } + + /** + * Save the response + * + * @return bool True on success + * @since 2.0.1 + */ + private function saveResponse(): bool + { + return $this->insert->item($this->response, 'open_ai_response'); + } + + /** + * Prep the response data + * + * @return bool True on success + * @since 2.0.1 + */ + private function modelResponse(): bool + { + if ($this->response) + { + $data = new \stdClass(); + // Bible link + $data->abbreviation = $this->scripture->get('translation_abbreviation', ''); + $data->language = $this->scripture->get('translation_language', ''); + $data->lcsh = $this->scripture->get('translation_lcsh', ''); + $data->book = $this->scripture->get('book_number', ''); + $data->chapter = $this->scripture->get('chapter_number', ''); + $data->verse = $this->scripture->get('verse_number', ''); + $data->word = $this->scripture->get('selected_word_number', ''); + $data->selected_word = $this->scripture->get('selected_word_text', ''); + // Prompt data + $data->prompt = $this->prompt->getGuid(); + $data->model = $this->prompt->getModel(); + $data->max_tokens = $this->prompt->getMaxTokens(); + $data->temperature = $this->prompt->getTemperature(); + $data->top_p = $this->prompt->getTopP(); + $data->presence_penalty = $this->prompt->getPresencePenalty(); + $data->frequency_penalty = $this->prompt->getFrequencyPenalty(); + $data->n = ''; + // Response data + $data->response_id = $this->response->id ?? ''; + $data->response_object = $this->response->object ?? ''; + $data->response_model = $this->response->model ?? ''; + $data->response_created = $this->response->created ?? ''; + $data->prompt_tokens = $this->response->usage->prompt_tokens ?? ''; + $data->completion_tokens = $this->response->usage->completion_tokens ?? ''; + $data->total_tokens = $this->response->usage->total_tokens ?? ''; + + $this->response = $data; + + return true; + } + + return false; + } + + /** + * Prep the messages + * + * @return bool True on success + * @since 2.0.1 + */ + private function modelMessages(): bool + { + if (isset($this->response->choices) && + is_array($this->response->choices) && + $this->response->choices !== []) + { + // set some global keys + $open_ai_response = $this->response->id ?? ''; + $prompt = $this->prompt->getGuid(); + // if Persistently we archive this response + $cache_type = $this->prompt->getCacheBehaviour(); + $state = ($cache_type == 0) ? 2 : 1; + + // update the system messages + $index = (int) 0 - count($this->messages); + foreach ($this->messages as $n => &$message) + { + $message->prompt = $prompt; + $message->open_ai_response = $open_ai_response; + $message->source = 1; // prompt as source + $message->index = $index; + $message->published = $state; + + $index++; + } + + // now add the response messages + foreach ($this->response->choices as $choice) + { + $choice->message->prompt = $prompt; + $choice->message->open_ai_response = $open_ai_response; + $choice->message->source = 2; // open AI as source + $choice->message->index = $choice->index; + $choice->message->name = 'Open-AI'; + $choice->message->published = $state; + + $this->messages[] = $choice->message; + } + + // we remove it from the response object + unset($this->response->choices); + + return true; + } + + return false; + } + + /** + * Get the Open AI response + * + * @return bool True on success + * @since 2.0.1 + */ + private function getResponse(): bool + { + if (($this->messages = $this->getMessages()) !== null) + { + $this->response = $this->chat->create( + $this->prompt->getModel(), + $this->messages, + $this->prompt->getMaxTokens(), + $this->prompt->getTemperature(), + $this->prompt->getTopP(), + $this->prompt->getN(), + null, + null, + $this->prompt->getPresencePenalty(), + $this->prompt->getFrequencyPenalty(), + null + ); + + return true; + } + + return false; + } + + /** + * Get the ready to use prompt messages + * + * @return array|null Array of prompt messages + * @since 2.0.1 + */ + private function getMessages(): ?array + { + if (($placeholders = $this->placeholders->get()) !== null && + ($messages = $this->prompt->getMessages()) !== null) + { + return array_map(function ($message) use($placeholders) { + $message->content = str_replace( + array_keys($placeholders), + array_values($placeholders), + $message->content + ); + return $message; + }, $messages); + } + + return null; + } +} + diff --git a/src/ed16a9c4-e026-4d16-be60-81892ce7c6a9/code.power b/src/ed16a9c4-e026-4d16-be60-81892ce7c6a9/code.power index 69309b0..33f1c3e 100644 --- a/src/ed16a9c4-e026-4d16-be60-81892ce7c6a9/code.power +++ b/src/ed16a9c4-e026-4d16-be60-81892ce7c6a9/code.power @@ -1 +1,278 @@ -###CODEPOWER### \ No newline at end of file + /** + * 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 Placeholders class + * + * @var Placeholders + * @since 2.0.1 + */ + protected Placeholders $placeholders; + + /** + * The Chat class + * + * @var Chat + * @since 2.0.1 + */ + protected Chat $chat; + + /** + * The Insert class + * + * @var Insert + * @since 2.0.1 + */ + protected Insert $insert; + + /** + * The request messages + * + * @var array|null + * @since 2.0.1 + */ + protected ?array $messages = null; + + /** + * The response object + * + * @var object|null + * @since 2.0.1 + */ + protected ?object $response = null; + + /** + * Constructor + * + * @param Scripture $scripture The scripture object. + * @param Prompt $prompt The prompt object. + * @param Placeholders $placeholders The placeholders object. + * @param Chat $chat The chat object. + * @param Insert $insert The insert object. + * + * @since 2.0.1 + */ + public function __construct( + Scripture $scripture, + Prompt $prompt, + Placeholders $placeholders, + Chat $chat, + Insert $insert) + { + $this->scripture = $scripture; + $this->prompt = $prompt; + $this->placeholders = $placeholders; + $this->chat = $chat; + $this->insert = $insert; + } + + /** + * Return the current data state + * + * @return array|null True on success + * @since 2.0.1 + */ + public function get(): ?array + { + if ($this->getResponse() && $this->modelMessages() && $this->modelResponse() + && $this->saveResponse() && $this->saveMessages()) + { + // add this response's messages + $this->response->messages = $this->messages ?? ''; + + return [ + $this->response + ]; + } + + return null; + } + + /** + * Save the messages + * + * @return bool True on success + * @since 2.0.1 + */ + private function saveMessages(): bool + { + return $this->insert->items($this->messages, 'open_ai_message'); + } + + /** + * Save the response + * + * @return bool True on success + * @since 2.0.1 + */ + private function saveResponse(): bool + { + return $this->insert->item($this->response, 'open_ai_response'); + } + + /** + * Prep the response data + * + * @return bool True on success + * @since 2.0.1 + */ + private function modelResponse(): bool + { + if ($this->response) + { + $data = new \stdClass(); + // Bible link + $data->abbreviation = $this->scripture->get('translation_abbreviation', ''); + $data->language = $this->scripture->get('translation_language', ''); + $data->lcsh = $this->scripture->get('translation_lcsh', ''); + $data->book = $this->scripture->get('book_number', ''); + $data->chapter = $this->scripture->get('chapter_number', ''); + $data->verse = $this->scripture->get('verse_number', ''); + $data->word = $this->scripture->get('selected_word_number', ''); + $data->selected_word = $this->scripture->get('selected_word_text', ''); + // Prompt data + $data->prompt = $this->prompt->getGuid(); + $data->model = $this->prompt->getModel(); + $data->max_tokens = $this->prompt->getMaxTokens(); + $data->temperature = $this->prompt->getTemperature(); + $data->top_p = $this->prompt->getTopP(); + $data->presence_penalty = $this->prompt->getPresencePenalty(); + $data->frequency_penalty = $this->prompt->getFrequencyPenalty(); + $data->n = ''; + // Response data + $data->response_id = $this->response->id ?? ''; + $data->response_object = $this->response->object ?? ''; + $data->response_model = $this->response->model ?? ''; + $data->response_created = $this->response->created ?? ''; + $data->prompt_tokens = $this->response->usage->prompt_tokens ?? ''; + $data->completion_tokens = $this->response->usage->completion_tokens ?? ''; + $data->total_tokens = $this->response->usage->total_tokens ?? ''; + + $this->response = $data; + + return true; + } + + return false; + } + + /** + * Prep the messages + * + * @return bool True on success + * @since 2.0.1 + */ + private function modelMessages(): bool + { + if (isset($this->response->choices) && + is_array($this->response->choices) && + $this->response->choices !== []) + { + // set some global keys + $open_ai_response = $this->response->id ?? ''; + $prompt = $this->prompt->getGuid(); + // if Persistently we archive this response + $cache_type = $this->prompt->getCacheBehaviour(); + $state = ($cache_type == 0) ? 2 : 1; + + // update the system messages + $index = (int) 0 - count($this->messages); + foreach ($this->messages as $n => &$message) + { + $message->prompt = $prompt; + $message->open_ai_response = $open_ai_response; + $message->source = 1; // prompt as source + $message->index = $index; + $message->published = $state; + + $index++; + } + + // now add the response messages + foreach ($this->response->choices as $choice) + { + $choice->message->prompt = $prompt; + $choice->message->open_ai_response = $open_ai_response; + $choice->message->source = 2; // open AI as source + $choice->message->index = $choice->index; + $choice->message->name = 'Open-AI'; + $choice->message->published = $state; + + $this->messages[] = $choice->message; + } + + // we remove it from the response object + unset($this->response->choices); + + return true; + } + + return false; + } + + /** + * Get the Open AI response + * + * @return bool True on success + * @since 2.0.1 + */ + private function getResponse(): bool + { + if (($this->messages = $this->getMessages()) !== null) + { + $this->response = $this->chat->create( + $this->prompt->getModel(), + $this->messages, + $this->prompt->getMaxTokens(), + $this->prompt->getTemperature(), + $this->prompt->getTopP(), + $this->prompt->getN(), + null, + null, + $this->prompt->getPresencePenalty(), + $this->prompt->getFrequencyPenalty(), + null + ); + + return true; + } + + return false; + } + + /** + * Get the ready to use prompt messages + * + * @return array|null Array of prompt messages + * @since 2.0.1 + */ + private function getMessages(): ?array + { + if (($placeholders = $this->placeholders->get()) !== null && + ($messages = $this->prompt->getMessages()) !== null) + { + return array_map(function ($message) use($placeholders) { + $message->content = str_replace( + array_keys($placeholders), + array_values($placeholders), + $message->content + ); + return $message; + }, $messages); + } + + return null; + } \ No newline at end of file diff --git a/src/ed16a9c4-e026-4d16-be60-81892ce7c6a9/settings.json b/src/ed16a9c4-e026-4d16-be60-81892ce7c6a9/settings.json index 6b3b222..7cba697 100644 --- a/src/ed16a9c4-e026-4d16-be60-81892ce7c6a9/settings.json +++ b/src/ed16a9c4-e026-4d16-be60-81892ce7c6a9/settings.json @@ -1 +1,39 @@ -###POWERLINKER### \ No newline at end of file +{ + "add_head": "0", + "add_licensing_template": "2", + "extends": "0", + "guid": "ed16a9c4-e026-4d16-be60-81892ce7c6a9", + "implements": null, + "load_selection": null, + "name": "Engineer", + "power_version": "1.0.0", + "system_name": "Joomla.GetBible.AI.Engineer", + "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": "ba2151c0-8ffa-4a07-ba6e-93f135a3e9d5", + "as": "default" + }, + "use_selection3": { + "use": "c54c92da-2dd7-4136-81c9-1785f2fa0af5", + "as": "default" + }, + "use_selection4": { + "use": "a07d90f6-6ff2-40a1-99c1-0f2cf33c9adf", + "as": "default" + } + }, + "namespace": "VDM\\Joomla\\GetBible\\AI.Engineer", + "description": "The GetBible AI Engineer\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 \r\n * @git 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": "" +} \ No newline at end of file diff --git a/src/f3757646-bc63-4f11-98c1-a2663180ab5e/README.md b/src/f3757646-bc63-4f11-98c1-a2663180ab5e/README.md index 433b69e..1f5e6cd 100644 --- a/src/f3757646-bc63-4f11-98c1-a2663180ab5e/README.md +++ b/src/f3757646-bc63-4f11-98c1-a2663180ab5e/README.md @@ -1 +1,52 @@ -###POWERREADME### \ No newline at end of file +``` +██████╗ ██████╗ ██╗ ██╗███████╗██████╗ +██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗ +██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝ +██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗ +██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║ +╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝ +``` +# final class AI (Details) +> namespace: **VDM\Joomla\GetBible** +```uml +@startuml +class AI << (F,LightGreen) >> #Green { + # Config $config + # Response $response + # Engineer $engineer + + __construct(Config $config, Response $response, ...) + + get() : ?array +} + +note right of AI::__construct + Constructor + + since: 2.0.1 + + arguments: + Config $config + Response $response + Engineer $engineer +end note + +note right of AI::get + Get the Open AI response + + since: 2.0.1 + return: ?array +end note + +@enduml +``` + +--- +``` + ██╗ ██████╗██████╗ + ██║██╔════╝██╔══██╗ + ██║██║ ██████╔╝ +██ ██║██║ ██╔══██╗ +╚█████╔╝╚██████╗██████╔╝ + ╚════╝ ╚═════╝╚═════╝ +``` +> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder) + diff --git a/src/f3757646-bc63-4f11-98c1-a2663180ab5e/code.php b/src/f3757646-bc63-4f11-98c1-a2663180ab5e/code.php index 3d222d0..927d809 100644 --- a/src/f3757646-bc63-4f11-98c1-a2663180ab5e/code.php +++ b/src/f3757646-bc63-4f11-98c1-a2663180ab5e/code.php @@ -9,4 +9,96 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ -###POWERCODE### +namespace VDM\Joomla\GetBible; + + +use VDM\Joomla\GetBible\Openai\Config; +use VDM\Joomla\GetBible\Data\Response; +use VDM\Joomla\GetBible\AI\Engineer; + + +/** + * The GetBible AI + * + * @since 2.0.1 + */ +final class AI +{ + /** + * The Config class + * + * @var Config + * @since 2.0.1 + */ + protected Config $config; + + /** + * The Response class + * + * @var Response + * @since 2.0.1 + */ + protected Response $response; + + /** + * The Engineer class + * + * @var Engineer + * @since 2.0.1 + */ + protected Engineer $engineer; + + /** + * Constructor + * + * @param Config $config The response object. + * @param Response $response The response object. + * @param Engineer $engineer The engineer object. + * + * @since 2.0.1 + */ + public function __construct(Config $config, Response $response, Engineer $engineer) + { + $this->config = $config; + $this->response = $response; + $this->engineer = $engineer; + } + + /** + * Get the Open AI response + * + * @return array|null Array of response messages + * @since 2.0.1 + */ + public function get(): ?array + { + // If Open AI isn't enabled in the config, we return null right away. + if (!$this->config->get('enable_open_ai')) + { + return null; + } + + // If we have enough responses already, return them. + $response = $this->response->get(); + if ($this->response->isEnough()) + { + return $response; + } + + // If there is no existing response and engineer has any response, return it. + if (empty($response)) + { + return $this->engineer->get(); + } + + // If there are existing responses, we append the first response from the engineer (if any). + $_response = $this->engineer->get(); + if (!empty($_response)) + { + $response[] = $_response[0]; + } + + return $response; + } +} + diff --git a/src/f3757646-bc63-4f11-98c1-a2663180ab5e/code.power b/src/f3757646-bc63-4f11-98c1-a2663180ab5e/code.power index 69309b0..ce52ea5 100644 --- a/src/f3757646-bc63-4f11-98c1-a2663180ab5e/code.power +++ b/src/f3757646-bc63-4f11-98c1-a2663180ab5e/code.power @@ -1 +1,76 @@ -###CODEPOWER### \ No newline at end of file + /** + * The Config class + * + * @var Config + * @since 2.0.1 + */ + protected Config $config; + + /** + * The Response class + * + * @var Response + * @since 2.0.1 + */ + protected Response $response; + + /** + * The Engineer class + * + * @var Engineer + * @since 2.0.1 + */ + protected Engineer $engineer; + + /** + * Constructor + * + * @param Config $config The response object. + * @param Response $response The response object. + * @param Engineer $engineer The engineer object. + * + * @since 2.0.1 + */ + public function __construct(Config $config, Response $response, Engineer $engineer) + { + $this->config = $config; + $this->response = $response; + $this->engineer = $engineer; + } + + /** + * Get the Open AI response + * + * @return array|null Array of response messages + * @since 2.0.1 + */ + public function get(): ?array + { + // If Open AI isn't enabled in the config, we return null right away. + if (!$this->config->get('enable_open_ai')) + { + return null; + } + + // If we have enough responses already, return them. + $response = $this->response->get(); + if ($this->response->isEnough()) + { + return $response; + } + + // If there is no existing response and engineer has any response, return it. + if (empty($response)) + { + return $this->engineer->get(); + } + + // If there are existing responses, we append the first response from the engineer (if any). + $_response = $this->engineer->get(); + if (!empty($_response)) + { + $response[] = $_response[0]; + } + + return $response; + } \ No newline at end of file diff --git a/src/f3757646-bc63-4f11-98c1-a2663180ab5e/settings.json b/src/f3757646-bc63-4f11-98c1-a2663180ab5e/settings.json index 6b3b222..1a2d6db 100644 --- a/src/f3757646-bc63-4f11-98c1-a2663180ab5e/settings.json +++ b/src/f3757646-bc63-4f11-98c1-a2663180ab5e/settings.json @@ -1 +1,31 @@ -###POWERLINKER### \ No newline at end of file +{ + "add_head": "0", + "add_licensing_template": "2", + "extends": "0", + "guid": "f3757646-bc63-4f11-98c1-a2663180ab5e", + "implements": null, + "load_selection": null, + "name": "AI", + "power_version": "1.0.0", + "system_name": "Joomla.GetBible.AI", + "type": "final class", + "use_selection": { + "use_selection0": { + "use": "3af7864b-f1f3-491e-b16f-0504f890086d", + "as": "default" + }, + "use_selection1": { + "use": "44c15b17-e096-47c0-8769-42ea9b692cb2", + "as": "default" + }, + "use_selection2": { + "use": "ed16a9c4-e026-4d16-be60-81892ce7c6a9", + "as": "default" + } + }, + "namespace": "VDM\\Joomla\\GetBible\\AI", + "description": "The GetBible AI\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 \r\n * @git 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": "" +} \ No newline at end of file diff --git a/src/f722bb8b-d377-4425-b1e4-2fe1734a3664/README.md b/src/f722bb8b-d377-4425-b1e4-2fe1734a3664/README.md index 433b69e..0396c67 100644 --- a/src/f722bb8b-d377-4425-b1e4-2fe1734a3664/README.md +++ b/src/f722bb8b-d377-4425-b1e4-2fe1734a3664/README.md @@ -1 +1,54 @@ -###POWERREADME### \ No newline at end of file +``` +██████╗ ██████╗ ██╗ ██╗███████╗██████╗ +██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗ +██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝ +██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗ +██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║ +╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝ +``` +# abstract class Openai (Details) +> namespace: **VDM\Joomla\GetBible** +```uml +@startuml +abstract Openai #Orange { + # static $container + + {static} _(string $key) : Mixed + + {static} getContainer() : Container + # {static} createContainer() : Container +} + +note right of Openai::_ + Get any class from the package container + + since: 3.2.0 + return: Mixed +end note + +note right of Openai::getContainer + Get the global package container + + since: 3.2.0 + return: Container +end note + +note right of Openai::createContainer + Create a container object + + since: 3.2.0 + return: Container +end note + +@enduml +``` + +--- +``` + ██╗ ██████╗██████╗ + ██║██╔════╝██╔══██╗ + ██║██║ ██████╔╝ +██ ██║██║ ██╔══██╗ +╚█████╔╝╚██████╗██████╔╝ + ╚════╝ ╚═════╝╚═════╝ +``` +> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder) + diff --git a/src/f722bb8b-d377-4425-b1e4-2fe1734a3664/code.php b/src/f722bb8b-d377-4425-b1e4-2fe1734a3664/code.php index 3d222d0..8cc9fe9 100644 --- a/src/f722bb8b-d377-4425-b1e4-2fe1734a3664/code.php +++ b/src/f722bb8b-d377-4425-b1e4-2fe1734a3664/code.php @@ -9,4 +9,78 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ -###POWERCODE### +namespace VDM\Joomla\GetBible; + + +use Joomla\DI\Container; +use VDM\Joomla\GetBible\Service\Openai as Api; +use VDM\Joomla\Openai\Service\Utilities; +use VDM\Joomla\GetBible\Service\Data; +use VDM\Joomla\GetBible\Service\AI; +use VDM\Joomla\GetBible\Service\Model; +use VDM\Joomla\GetBible\Service\Database; +use VDM\Joomla\Interfaces\FactoryInterface; + + +/** + * Openai Factory + * + * @since 3.2.0 + */ +abstract class Openai implements FactoryInterface +{ + /** + * Global Package Container + * + * @var Container + * @since 3.2.0 + **/ + protected static $container = null; + + /** + * Get any class from the package container + * + * @param string $key The container class key + * + * @return Mixed + * @since 3.2.0 + */ + public static function _($key) + { + return self::getContainer()->get($key); + } + + /** + * Get the global package container + * + * @return Container + * @since 3.2.0 + */ + public static function getContainer(): Container + { + if (!self::$container) + { + self::$container = self::createContainer(); + } + + return self::$container; + } + + /** + * Create a container object + * + * @return Container + * @since 3.2.0 + */ + protected static function createContainer(): Container + { + return (new Container()) + ->registerServiceProvider(new Api()) + ->registerServiceProvider(new Utilities()) + ->registerServiceProvider(new Data()) + ->registerServiceProvider(new AI()) + ->registerServiceProvider(new Model()) + ->registerServiceProvider(new Database()); + } +} + diff --git a/src/f722bb8b-d377-4425-b1e4-2fe1734a3664/code.power b/src/f722bb8b-d377-4425-b1e4-2fe1734a3664/code.power index 69309b0..460c3a8 100644 --- a/src/f722bb8b-d377-4425-b1e4-2fe1734a3664/code.power +++ b/src/f722bb8b-d377-4425-b1e4-2fe1734a3664/code.power @@ -1 +1,53 @@ -###CODEPOWER### \ No newline at end of file + /** + * Global Package Container + * + * @var Container + * @since 3.2.0 + **/ + protected static $container = null; + + /** + * Get any class from the package container + * + * @param string $key The container class key + * + * @return Mixed + * @since 3.2.0 + */ + public static function _($key) + { + return self::getContainer()->get($key); + } + + /** + * Get the global package container + * + * @return Container + * @since 3.2.0 + */ + public static function getContainer(): Container + { + if (!self::$container) + { + self::$container = self::createContainer(); + } + + return self::$container; + } + + /** + * Create a container object + * + * @return Container + * @since 3.2.0 + */ + protected static function createContainer(): Container + { + return (new Container()) + ->registerServiceProvider(new Api()) + ->registerServiceProvider(new Utilities()) + ->registerServiceProvider(new Data()) + ->registerServiceProvider(new AI()) + ->registerServiceProvider(new Model()) + ->registerServiceProvider(new Database()); + } \ No newline at end of file diff --git a/src/f722bb8b-d377-4425-b1e4-2fe1734a3664/settings.json b/src/f722bb8b-d377-4425-b1e4-2fe1734a3664/settings.json index 6b3b222..2577f25 100644 --- a/src/f722bb8b-d377-4425-b1e4-2fe1734a3664/settings.json +++ b/src/f722bb8b-d377-4425-b1e4-2fe1734a3664/settings.json @@ -1 +1,45 @@ -###POWERLINKER### \ No newline at end of file +{ + "add_head": "1", + "add_licensing_template": "2", + "extends": "0", + "guid": "f722bb8b-d377-4425-b1e4-2fe1734a3664", + "implements": [ + "caf33c5d-858c-4f9a-894f-ab302ec5445a" + ], + "load_selection": null, + "name": "Openai", + "power_version": "1.0.0", + "system_name": "GetBible.Openai", + "type": "abstract class", + "use_selection": { + "use_selection0": { + "use": "ac5c7679-dd6e-4817-8e48-489e521122f1", + "as": "Api" + }, + "use_selection1": { + "use": "07858e1f-5698-4227-8941-03dc93557938", + "as": "default" + }, + "use_selection5": { + "use": "3439e63b-d8f1-42ce-a765-60d56b1fbe21", + "as": "default" + }, + "use_selection2": { + "use": "b2c9493f-692b-426b-af22-c6865f76c2bb", + "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\\Openai", + "description": "Openai Factory\r\n\r\n@since 3.2.0", + "licensing_template": "\/**\r\n * @package GetBible\r\n *\r\n * @created 30th May, 2023\r\n * @author Llewellyn van der Merwe \r\n * @git 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": "" +} \ No newline at end of file diff --git a/src/f815fb33-f721-48a5-a84e-53f1986e8881/README.md b/src/f815fb33-f721-48a5-a84e-53f1986e8881/README.md index 433b69e..ac26cd6 100644 --- a/src/f815fb33-f721-48a5-a84e-53f1986e8881/README.md +++ b/src/f815fb33-f721-48a5-a84e-53f1986e8881/README.md @@ -1 +1,149 @@ -###POWERREADME### \ No newline at end of file +``` +██████╗ ██████╗ ██╗ ██╗███████╗██████╗ +██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗ +██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝ +██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗ +██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║ +╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝ +``` +# final class Watcher (Details) +> namespace: **VDM\Joomla\GetBible** +```uml +@startuml +class Watcher << (F,LightGreen) >> #Green { + # Load $load + # Translation $translation + # Book $book + # Chapter $chapter + # bool $fresh + + __construct(Load $load, Translation $translation, ...) + + sync(string $translation, int $book, ...) : bool + + isNew() : bool + + enoughVerses(string $translation = 'kjv') : bool + + totalVerses(string $translation = 'kjv') : ?int + + getNextChapter(string $translation, int $book, ...) : ?int + + getPreviousChapter(int $chapter, bool $force = false) : ?int + + getLastChapter(string $translation, int $book) : ?int + + getNextBook(string $translation, int $book, ...) : ?int + + getPreviousBook(string $translation, int $book, ...) : ?int + - forceUpdate(bool $state) : void +} + +note right of Watcher::__construct + Constructor + + since: 2.0.1 + + arguments: + Load $load + Translation $translation + Book $book + Chapter $chapter +end note + +note left of Watcher::sync + Watching that the local Database and API is in sync + + since: 2.0.1 + return: bool + + arguments: + string $translation + int $book + int $chapter + bool $force = false +end note + +note right of Watcher::isNew + The see if new chapters was installed, and therefore new + + since: 2.0.1 + return: bool +end note + +note left of Watcher::enoughVerses + Check if a translation has enough verses + + since: 2.0.1 + return: bool +end note + +note right of Watcher::totalVerses + Get the total number of verses in the database of a given translation + + since: 2.0.1 + return: ?int +end note + +note left of Watcher::getNextChapter + Get the next chapter + + since: 2.0.1 + return: ?int + + arguments: + string $translation + int $book + int $chapter + bool $force = false +end note + +note right of Watcher::getPreviousChapter + Get the previous chapter + + since: 2.0.1 + return: ?int +end note + +note left of Watcher::getLastChapter + Get the last chapter of a book + + since: 2.0.1 + return: ?int +end note + +note right of Watcher::getNextBook + Get the next book + + since: 2.0.1 + return: ?int + + arguments: + string $translation + int $book + int $try +end note + +note left of Watcher::getPreviousBook + Get the previous book + + since: 2.0.1 + return: ?int + + arguments: + string $translation + int $book + int $try +end note + +note right of Watcher::forceUpdate + The method to set the update state + + since: 2.0.1 + return: void +end note + +@enduml +``` + +--- +``` + ██╗ ██████╗██████╗ + ██║██╔════╝██╔══██╗ + ██║██║ ██████╔╝ +██ ██║██║ ██╔══██╗ +╚█████╔╝╚██████╗██████╔╝ + ╚════╝ ╚═════╝╚═════╝ +``` +> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder) + diff --git a/src/f815fb33-f721-48a5-a84e-53f1986e8881/code.php b/src/f815fb33-f721-48a5-a84e-53f1986e8881/code.php index 3d222d0..c88f4e2 100644 --- a/src/f815fb33-f721-48a5-a84e-53f1986e8881/code.php +++ b/src/f815fb33-f721-48a5-a84e-53f1986e8881/code.php @@ -9,4 +9,335 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ -###POWERCODE### +namespace VDM\Joomla\GetBible; + + +use VDM\Joomla\GetBible\Database\Load; +use VDM\Joomla\GetBible\Watcher\Translation; +use VDM\Joomla\GetBible\Watcher\Book; +use VDM\Joomla\GetBible\Watcher\Chapter; + + +/** + * The GetBible Watcher + * + * @since 2.0.1 + */ +final class Watcher +{ + /** + * The Load class + * + * @var Load + * @since 2.0.1 + */ + protected Load $load; + + /** + * 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 fresh load switch + * + * @var bool + * @since 2.0.1 + */ + protected bool $fresh = false; + + /** + * Constructor + * + * @param Load $load The load object. + * @param Translation $translation The translations API object. + * @param Book $book The books API object. + * @param Chapter $chapter The chapters API object. + * + * @since 2.0.1 + */ + public function __construct( + Load $load, + Translation $translation, + Book $book, + Chapter $chapter) + { + $this->load = $load; + $this->translation = $translation; + $this->book = $book; + $this->chapter = $chapter; + } + + /** + * Watching that the local Database and API is in sync + * + * @param string $translation The translation. + * @param int $book The book number. + * @param int $chapter The chapter number. + * @param bool $force The switch to force an update. + * + * @return bool True on success + * @since 2.0.1 + */ + public function sync(string $translation, int $book, int $chapter, bool $force = false): bool + { + // set the update state + $this->forceUpdate($force); + + // is the translation details in sync + if (!$this->translation->sync($translation)) + { + return false; + } + + // is the book details in sync + if (!$this->book->sync($translation, $book)) + { + return false; + } + + // is the chapter and its verses in sync + if (!$this->chapter->sync($translation, $book, $chapter)) + { + return false; + } + + // if any is new, then this is class should not load any more stuff + $this->fresh = ($this->translation->isNew() || $this->book->isNew() || $this->chapter->isNew()); + + return true; + } + + /** + * The see if new chapters was installed, and therefore new + * + * @return bool true if is new + * @since 2.0.1 + */ + public function isNew(): bool + { + return $this->fresh; + } + + /** + * Check if a translation has enough verses + * + * @param string $translation The translation. + * + * @return bool + * @since 2.0.1 + */ + public function enoughVerses(string $translation = 'kjv'): bool + { + $total = $this->totalVerses($translation); + + if ($total < 10000) + { + return false; + } + + return true; + } + + /** + * Get the total number of verses in the database of a given translation + * + * @param string $translation The translation. + * + * @return int|null + * @since 2.0.1 + */ + public function totalVerses(string $translation = 'kjv'): ?int + { + return $this->load->count( + ['abbreviation' => $translation], 'verse' + ); + } + + /** + * Get the next chapter + * + * @param string $translation The translation. + * @param int $book The book number. + * @param int $chapter The chapter number. + * @param bool $force The switch to force the getting. + * + * @return int|null Number if there is a next, else null + * @since 2.0.1 + */ + public function getNextChapter(string $translation, int $book, int $chapter, bool $force = false): ?int + { + // we load the next chapter + $next = $chapter + 1; + // check if this books has this next chapter + if (($force || !$this->isNew()) && $this->load->value( + ['abbreviation' => $translation, 'book_nr' => $book, 'chapter' => $next], + 'sha', 'chapter' + )) + { + return $next; + } + + return null; + } + + /** + * Get the previous chapter + * + * @param int $chapter The chapter number. + * @param bool $force The switch to force the getting. + * + * @return int|null Number if there is a previous, else null + * @since 2.0.1 + */ + public function getPreviousChapter(int $chapter, bool $force = false): ?int + { + // we load the previous chapter + $previous = $chapter - 1; + if (($force || !$this->isNew()) && $previous > 0) + { + return $previous; + } + + return null; + } + + /** + * Get the last chapter of a book + * + * @param string $translation The translation. + * @param int $book The book number. + * + * @return int|null Number if there is a previous, else null + * @since 2.0.1 + */ + public function getLastChapter(string $translation, int $book): ?int + { + // we load the last chapter + return $this->load->max( + ['abbreviation' => $translation, 'book_nr' => $book], + 'chapter', 'chapter' + ); + } + + /** + * Get the next book + * + * @param string $translation The translation. + * @param int $book The book number. + * @param int $try The number of tries + * + * @return int|null Number if there is a next, else null + * @since 2.0.1 + */ + public function getNextBook(string $translation, int $book, int $try = 0): ?int + { + // we load the next chapter + $next = $book + 1; + + // if we already looked over 90 + if ($next >= 90) + { + $next = 1; + } + + // check if this book exist + if ($this->load->value( + ['abbreviation' => $translation, 'nr' => $next], + 'sha', 'book' + )) + { + return $next; + } + + $try++; + + // could not be found :( + if ($try >= 180) + { + return null; + } + + return $this->getNextBook($translation, $next, $try); + } + + /** + * Get the previous book + * + * @param string $translation The translation. + * @param int $book The book number. + * @param int $try The number of tries + * + * @return int|null Number if there is a previous, else null + * @since 2.0.1 + */ + public function getPreviousBook(string $translation, int $book, int $try = 0): ?int + { + // we load the previous book + $previous = $book - 1; + + // if we already looked over 90 + if ($previous <= 0) + { + $previous = 90; + } + + // check if this book exist + if ($this->load->value( + ['abbreviation' => $translation, 'nr' => $previous], + 'sha', 'book' + )) + { + return $previous; + } + + $try++; + + // could not be found :( + if ($try >= 180) + { + return null; + } + + return $this->getPreviousBook($translation, $previous, $try); + } + + /** + * The method to set the update state + * + * @param bool $state The switch to force an update. + * + * @return void + * @since 2.0.1 + */ + private function forceUpdate(bool $state): void + { + // force all updates + if ($state) + { + $this->translation->forceUpdate(); + $this->book->forceUpdate(); + $this->chapter->forceUpdate(); + } + } +} + diff --git a/src/f815fb33-f721-48a5-a84e-53f1986e8881/code.power b/src/f815fb33-f721-48a5-a84e-53f1986e8881/code.power index 69309b0..048d19c 100644 --- a/src/f815fb33-f721-48a5-a84e-53f1986e8881/code.power +++ b/src/f815fb33-f721-48a5-a84e-53f1986e8881/code.power @@ -1 +1,314 @@ -###CODEPOWER### \ No newline at end of file + /** + * The Load class + * + * @var Load + * @since 2.0.1 + */ + protected Load $load; + + /** + * 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 fresh load switch + * + * @var bool + * @since 2.0.1 + */ + protected bool $fresh = false; + + /** + * Constructor + * + * @param Load $load The load object. + * @param Translation $translation The translations API object. + * @param Book $book The books API object. + * @param Chapter $chapter The chapters API object. + * + * @since 2.0.1 + */ + public function __construct( + Load $load, + Translation $translation, + Book $book, + Chapter $chapter) + { + $this->load = $load; + $this->translation = $translation; + $this->book = $book; + $this->chapter = $chapter; + } + + /** + * Watching that the local Database and API is in sync + * + * @param string $translation The translation. + * @param int $book The book number. + * @param int $chapter The chapter number. + * @param bool $force The switch to force an update. + * + * @return bool True on success + * @since 2.0.1 + */ + public function sync(string $translation, int $book, int $chapter, bool $force = false): bool + { + // set the update state + $this->forceUpdate($force); + + // is the translation details in sync + if (!$this->translation->sync($translation)) + { + return false; + } + + // is the book details in sync + if (!$this->book->sync($translation, $book)) + { + return false; + } + + // is the chapter and its verses in sync + if (!$this->chapter->sync($translation, $book, $chapter)) + { + return false; + } + + // if any is new, then this is class should not load any more stuff + $this->fresh = ($this->translation->isNew() || $this->book->isNew() || $this->chapter->isNew()); + + return true; + } + + /** + * The see if new chapters was installed, and therefore new + * + * @return bool true if is new + * @since 2.0.1 + */ + public function isNew(): bool + { + return $this->fresh; + } + + /** + * Check if a translation has enough verses + * + * @param string $translation The translation. + * + * @return bool + * @since 2.0.1 + */ + public function enoughVerses(string $translation = 'kjv'): bool + { + $total = $this->totalVerses($translation); + + if ($total < 10000) + { + return false; + } + + return true; + } + + /** + * Get the total number of verses in the database of a given translation + * + * @param string $translation The translation. + * + * @return int|null + * @since 2.0.1 + */ + public function totalVerses(string $translation = 'kjv'): ?int + { + return $this->load->count( + ['abbreviation' => $translation], 'verse' + ); + } + + /** + * Get the next chapter + * + * @param string $translation The translation. + * @param int $book The book number. + * @param int $chapter The chapter number. + * @param bool $force The switch to force the getting. + * + * @return int|null Number if there is a next, else null + * @since 2.0.1 + */ + public function getNextChapter(string $translation, int $book, int $chapter, bool $force = false): ?int + { + // we load the next chapter + $next = $chapter + 1; + // check if this books has this next chapter + if (($force || !$this->isNew()) && $this->load->value( + ['abbreviation' => $translation, 'book_nr' => $book, 'chapter' => $next], + 'sha', 'chapter' + )) + { + return $next; + } + + return null; + } + + /** + * Get the previous chapter + * + * @param int $chapter The chapter number. + * @param bool $force The switch to force the getting. + * + * @return int|null Number if there is a previous, else null + * @since 2.0.1 + */ + public function getPreviousChapter(int $chapter, bool $force = false): ?int + { + // we load the previous chapter + $previous = $chapter - 1; + if (($force || !$this->isNew()) && $previous > 0) + { + return $previous; + } + + return null; + } + + /** + * Get the last chapter of a book + * + * @param string $translation The translation. + * @param int $book The book number. + * + * @return int|null Number if there is a previous, else null + * @since 2.0.1 + */ + public function getLastChapter(string $translation, int $book): ?int + { + // we load the last chapter + return $this->load->max( + ['abbreviation' => $translation, 'book_nr' => $book], + 'chapter', 'chapter' + ); + } + + /** + * Get the next book + * + * @param string $translation The translation. + * @param int $book The book number. + * @param int $try The number of tries + * + * @return int|null Number if there is a next, else null + * @since 2.0.1 + */ + public function getNextBook(string $translation, int $book, int $try = 0): ?int + { + // we load the next chapter + $next = $book + 1; + + // if we already looked over 90 + if ($next >= 90) + { + $next = 1; + } + + // check if this book exist + if ($this->load->value( + ['abbreviation' => $translation, 'nr' => $next], + 'sha', 'book' + )) + { + return $next; + } + + $try++; + + // could not be found :( + if ($try >= 180) + { + return null; + } + + return $this->getNextBook($translation, $next, $try); + } + + /** + * Get the previous book + * + * @param string $translation The translation. + * @param int $book The book number. + * @param int $try The number of tries + * + * @return int|null Number if there is a previous, else null + * @since 2.0.1 + */ + public function getPreviousBook(string $translation, int $book, int $try = 0): ?int + { + // we load the previous book + $previous = $book - 1; + + // if we already looked over 90 + if ($previous <= 0) + { + $previous = 90; + } + + // check if this book exist + if ($this->load->value( + ['abbreviation' => $translation, 'nr' => $previous], + 'sha', 'book' + )) + { + return $previous; + } + + $try++; + + // could not be found :( + if ($try >= 180) + { + return null; + } + + return $this->getPreviousBook($translation, $previous, $try); + } + + /** + * The method to set the update state + * + * @param bool $state The switch to force an update. + * + * @return void + * @since 2.0.1 + */ + private function forceUpdate(bool $state): void + { + // force all updates + if ($state) + { + $this->translation->forceUpdate(); + $this->book->forceUpdate(); + $this->chapter->forceUpdate(); + } + } \ No newline at end of file diff --git a/src/f815fb33-f721-48a5-a84e-53f1986e8881/settings.json b/src/f815fb33-f721-48a5-a84e-53f1986e8881/settings.json index 6b3b222..f32fd24 100644 --- a/src/f815fb33-f721-48a5-a84e-53f1986e8881/settings.json +++ b/src/f815fb33-f721-48a5-a84e-53f1986e8881/settings.json @@ -1 +1,35 @@ -###POWERLINKER### \ No newline at end of file +{ + "add_head": "0", + "add_licensing_template": "2", + "extends": "0", + "guid": "f815fb33-f721-48a5-a84e-53f1986e8881", + "implements": null, + "load_selection": null, + "name": "Watcher", + "power_version": "1.0.0", + "system_name": "Joomla.GetBible.Watcher", + "type": "final class", + "use_selection": { + "use_selection0": { + "use": "c03b9c61-17d3-4774-a335-783903719f83", + "as": "default" + }, + "use_selection1": { + "use": "7d592acd-f031-4d0f-b667-584c88ae0495", + "as": "default" + }, + "use_selection2": { + "use": "c2a8a5fa-8e7f-443a-86d7-a8c1e4cdfa98", + "as": "default" + }, + "use_selection3": { + "use": "07d3888a-5f35-4ba7-977f-fb2f5cf99061", + "as": "default" + } + }, + "namespace": "VDM\\Joomla\\GetBible\\Watcher", + "description": "The GetBible Watcher\r\n\r\n@since 2.0.1", + "licensing_template": "\/**\r\n * @package GetBible\r\n *\r\n * @created 30th May, 2023\r\n * @author Llewellyn van der Merwe \r\n * @git 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": "" +} \ No newline at end of file diff --git a/src/fa776320-65f8-4198-a517-58cd94b3b7b7/README.md b/src/fa776320-65f8-4198-a517-58cd94b3b7b7/README.md index 433b69e..e0d990f 100644 --- a/src/fa776320-65f8-4198-a517-58cd94b3b7b7/README.md +++ b/src/fa776320-65f8-4198-a517-58cd94b3b7b7/README.md @@ -1 +1,79 @@ -###POWERREADME### \ No newline at end of file +``` +██████╗ ██████╗ ██╗ ██╗███████╗██████╗ +██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗ +██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝ +██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗ +██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║ +╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝ +``` +# final class Book (Details) +> namespace: **VDM\Joomla\GetBible\Data** +```uml +@startuml +class Book << (F,LightGreen) >> #Green { + # Load $load + # Config $config + # array $books + + __construct(Load $load, Config $config) + + getNumber() : string + + getName() : string + - get() : ?object + - loadBookData(string $abbreviation, int $book) : ?object + - generateCacheKey(string $abbreviation, int $book) : string +} + +note right of Book::__construct + Constructor + + since: 2.0.1 +end note + +note right of Book::getNumber + Get the book number + + since: 2.0.1 + return: string +end note + +note right of Book::getName + Get the book name + + since: 2.0.1 + return: string +end note + +note right of Book::get + Get the book + + since: 2.0.1 + return: ?object +end note + +note right of Book::loadBookData + Loads the book data from the database and updates the cache + + since: 2.0.1 + return: ?object +end note + +note right of Book::generateCacheKey + Generates a cache key based on the abbreviation, and book + + since: 2.0.1 + return: string +end note + +@enduml +``` + +--- +``` + ██╗ ██████╗██████╗ + ██║██╔════╝██╔══██╗ + ██║██║ ██████╔╝ +██ ██║██║ ██╔══██╗ +╚█████╔╝╚██████╗██████╔╝ + ╚════╝ ╚═════╝╚═════╝ +``` +> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder) + diff --git a/src/fa776320-65f8-4198-a517-58cd94b3b7b7/code.php b/src/fa776320-65f8-4198-a517-58cd94b3b7b7/code.php index 3d222d0..da5d4f8 100644 --- a/src/fa776320-65f8-4198-a517-58cd94b3b7b7/code.php +++ b/src/fa776320-65f8-4198-a517-58cd94b3b7b7/code.php @@ -9,4 +9,148 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ -###POWERCODE### +namespace VDM\Joomla\GetBible\Data; + + +use VDM\Joomla\GetBible\Database\Load; +use VDM\Joomla\GetBible\Openai\Config; + + +/** + * The GetBible Book Data + * + * @since 2.0.1 + */ +final class Book +{ + /** + * 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 books + * + * @var array + * @since 2.0.1 + */ + protected array $books = []; + + /** + * 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 book number + * + * @return string The book number + * @since 2.0.1 + */ + public function getNumber(): string + { + $book = $this->get(); + return $book ? $book->nr ?? '' : ''; + } + + /** + * Get the book name + * + * @return string The book name + * @since 2.0.1 + */ + public function getName(): string + { + $book = $this->get(); + return $book ? $book->name ?? '' : ''; + } + + /** + * Get the book + * + * @return object|null True on success + * @since 2.0.1 + */ + private function get(): ?object + { + $abbreviation = $this->config->get('translation'); + $book = $this->config->get('book'); + + if (empty($abbreviation) || empty($book)) + { + return null; + } + + $cacheKey = $this->generateCacheKey($abbreviation, $book); + + if (isset($this->books[$cacheKey])) + { + return $this->books[$cacheKey]; + } + + return $this->loadBookData($abbreviation, $book); + } + + /** + * Loads the book data from the database and updates the cache + * + * @param string $abbreviation The translation abbreviation. + * @param int $book The book number. + * + * @return object|null The loaded book data, or null if not found or an error occurred. + * @since 2.0.1 + */ + private function loadBookData(string $abbreviation, int $book): ?object + { + $data = $this->load->item( + ['abbreviation' => $abbreviation, 'nr' => $book], + 'book' + ); + + if (!is_object($data)) + { + return null; + } + + $cacheKey = $this->generateCacheKey($abbreviation, $book); + + $this->books[$cacheKey] = $data; + + return $this->books[$cacheKey]; + } + + /** + * Generates a cache key based on the abbreviation, and book + * + * @param string $abbreviation The translation abbreviation. + * @param int $book The book number. + * + * @return string The generated cache key. + * @since 2.0.1 + */ + private function generateCacheKey(string $abbreviation, int $book): string + { + return $abbreviation . $book; + } +} + diff --git a/src/fa776320-65f8-4198-a517-58cd94b3b7b7/code.power b/src/fa776320-65f8-4198-a517-58cd94b3b7b7/code.power index 69309b0..295bfb6 100644 --- a/src/fa776320-65f8-4198-a517-58cd94b3b7b7/code.power +++ b/src/fa776320-65f8-4198-a517-58cd94b3b7b7/code.power @@ -1 +1,129 @@ -###CODEPOWER### \ No newline at end of file + /** + * 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 books + * + * @var array + * @since 2.0.1 + */ + protected array $books = []; + + /** + * 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 book number + * + * @return string The book number + * @since 2.0.1 + */ + public function getNumber(): string + { + $book = $this->get(); + return $book ? $book->nr ?? '' : ''; + } + + /** + * Get the book name + * + * @return string The book name + * @since 2.0.1 + */ + public function getName(): string + { + $book = $this->get(); + return $book ? $book->name ?? '' : ''; + } + + /** + * Get the book + * + * @return object|null True on success + * @since 2.0.1 + */ + private function get(): ?object + { + $abbreviation = $this->config->get('translation'); + $book = $this->config->get('book'); + + if (empty($abbreviation) || empty($book)) + { + return null; + } + + $cacheKey = $this->generateCacheKey($abbreviation, $book); + + if (isset($this->books[$cacheKey])) + { + return $this->books[$cacheKey]; + } + + return $this->loadBookData($abbreviation, $book); + } + + /** + * Loads the book data from the database and updates the cache + * + * @param string $abbreviation The translation abbreviation. + * @param int $book The book number. + * + * @return object|null The loaded book data, or null if not found or an error occurred. + * @since 2.0.1 + */ + private function loadBookData(string $abbreviation, int $book): ?object + { + $data = $this->load->item( + ['abbreviation' => $abbreviation, 'nr' => $book], + 'book' + ); + + if (!is_object($data)) + { + return null; + } + + $cacheKey = $this->generateCacheKey($abbreviation, $book); + + $this->books[$cacheKey] = $data; + + return $this->books[$cacheKey]; + } + + /** + * Generates a cache key based on the abbreviation, and book + * + * @param string $abbreviation The translation abbreviation. + * @param int $book The book number. + * + * @return string The generated cache key. + * @since 2.0.1 + */ + private function generateCacheKey(string $abbreviation, int $book): string + { + return $abbreviation . $book; + } \ No newline at end of file diff --git a/src/fa776320-65f8-4198-a517-58cd94b3b7b7/settings.json b/src/fa776320-65f8-4198-a517-58cd94b3b7b7/settings.json index 6b3b222..cb9d288 100644 --- a/src/fa776320-65f8-4198-a517-58cd94b3b7b7/settings.json +++ b/src/fa776320-65f8-4198-a517-58cd94b3b7b7/settings.json @@ -1 +1,27 @@ -###POWERLINKER### \ No newline at end of file +{ + "add_head": "0", + "add_licensing_template": "2", + "extends": "0", + "guid": "fa776320-65f8-4198-a517-58cd94b3b7b7", + "implements": null, + "load_selection": null, + "name": "Book", + "power_version": "1.0.0", + "system_name": "Joomla.GetBible.Data.Book", + "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.Book", + "description": "The GetBible Book 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 \r\n * @git 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": "" +} \ No newline at end of file diff --git a/src/fb5683e2-67ec-413d-96fa-8465fd2f511c/README.md b/src/fb5683e2-67ec-413d-96fa-8465fd2f511c/README.md index 433b69e..c3d476b 100644 --- a/src/fb5683e2-67ec-413d-96fa-8465fd2f511c/README.md +++ b/src/fb5683e2-67ec-413d-96fa-8465fd2f511c/README.md @@ -1 +1,47 @@ -###POWERREADME### \ No newline at end of file +``` +██████╗ ██████╗ ██╗ ██╗███████╗██████╗ +██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗ +██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝ +██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗ +██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║ +╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝ +``` +# final class Loader (Details) +> namespace: **VDM\Joomla\GetBible** +```uml +@startuml +class Loader << (F,LightGreen) >> #Green { + # Load $load + # Watcher $watcher + # Registry $plugin + + __construct(Load $load, Watcher $watcher) + + set($row, Registry $plugin) : bool +} + +note right of Loader::__construct + Constructor + + since: 2.0.1 +end note + +note right of Loader::set + The setting of Scripture into Content starts here + + since: 2.0.1 + return: bool +end note + +@enduml +``` + +--- +``` + ██╗ ██████╗██████╗ + ██║██╔════╝██╔══██╗ + ██║██║ ██████╔╝ +██ ██║██║ ██╔══██╗ +╚█████╔╝╚██████╗██████╔╝ + ╚════╝ ╚═════╝╚═════╝ +``` +> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder) + diff --git a/src/fb5683e2-67ec-413d-96fa-8465fd2f511c/code.php b/src/fb5683e2-67ec-413d-96fa-8465fd2f511c/code.php index 3d222d0..1598913 100644 --- a/src/fb5683e2-67ec-413d-96fa-8465fd2f511c/code.php +++ b/src/fb5683e2-67ec-413d-96fa-8465fd2f511c/code.php @@ -9,4 +9,75 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ -###POWERCODE### +namespace VDM\Joomla\GetBible; + + +use Joomla\Registry\Registry; +use VDM\Joomla\GetBible\Database\Load; +use VDM\Joomla\GetBible\Watcher; + + +/** + * The GetBible Loader of Scripture in Content + * + * @since 2.0.1 + */ +final class Loader +{ + /** + * The Load class + * + * @var Load + * @since 2.0.1 + */ + protected Load $load; + + /** + * The Watcher class + * + * @var Watcher + * @since 2.0.1 + */ + protected Watcher $watcher; + + /** + * The Plugin Params class + * + * @var Registry + * @since 2.0.1 + */ + protected Registry $plugin; + + /** + * Constructor + * + * @param Load $load The load object. + * @param Watcher $watcher The watcher object. + * + * @since 2.0.1 + */ + public function __construct( + Load $load, + Watcher $watcher) + { + $this->load = $load; + $this->watcher = $watcher; + } + + /** + * The setting of Scripture into Content starts here + * + * @param object &$row The article object. Note $article->text is also available + * @param Registry $plugin The plugin params + * + * @return void + * @since 2.0.1 + */ + public function set(&$row, Registry $plugin): bool + { + $this->plugin = $plugin; + + return; + } +} + diff --git a/src/fb5683e2-67ec-413d-96fa-8465fd2f511c/code.power b/src/fb5683e2-67ec-413d-96fa-8465fd2f511c/code.power index 69309b0..07b6f72 100644 --- a/src/fb5683e2-67ec-413d-96fa-8465fd2f511c/code.power +++ b/src/fb5683e2-67ec-413d-96fa-8465fd2f511c/code.power @@ -1 +1,55 @@ -###CODEPOWER### \ No newline at end of file + /** + * The Load class + * + * @var Load + * @since 2.0.1 + */ + protected Load $load; + + /** + * The Watcher class + * + * @var Watcher + * @since 2.0.1 + */ + protected Watcher $watcher; + + /** + * The Plugin Params class + * + * @var Registry + * @since 2.0.1 + */ + protected Registry $plugin; + + /** + * Constructor + * + * @param Load $load The load object. + * @param Watcher $watcher The watcher object. + * + * @since 2.0.1 + */ + public function __construct( + Load $load, + Watcher $watcher) + { + $this->load = $load; + $this->watcher = $watcher; + } + + /** + * The setting of Scripture into Content starts here + * + * @param object &$row The article object. Note $article->text is also available + * @param Registry $plugin The plugin params + * + * @return void + * @since 2.0.1 + */ + public function set(&$row, Registry $plugin): bool + { + $this->plugin = $plugin; + + return; + } \ No newline at end of file diff --git a/src/fb5683e2-67ec-413d-96fa-8465fd2f511c/settings.json b/src/fb5683e2-67ec-413d-96fa-8465fd2f511c/settings.json index 6b3b222..d8bfcb5 100644 --- a/src/fb5683e2-67ec-413d-96fa-8465fd2f511c/settings.json +++ b/src/fb5683e2-67ec-413d-96fa-8465fd2f511c/settings.json @@ -1 +1,27 @@ -###POWERLINKER### \ No newline at end of file +{ + "add_head": "1", + "add_licensing_template": "2", + "extends": "0", + "guid": "fb5683e2-67ec-413d-96fa-8465fd2f511c", + "implements": null, + "load_selection": null, + "name": "Loader", + "power_version": "1.0.0", + "system_name": "Joomla.GetBible.Loader", + "type": "final class", + "use_selection": { + "use_selection0": { + "use": "c03b9c61-17d3-4774-a335-783903719f83", + "as": "default" + }, + "use_selection1": { + "use": "f815fb33-f721-48a5-a84e-53f1986e8881", + "as": "default" + } + }, + "namespace": "VDM\\Joomla\\GetBible\\Loader", + "description": "The GetBible Loader of Scripture in Content\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 \r\n * @git 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;", + "composer": "" +} \ No newline at end of file diff --git a/src/fc9ab6f0-c31b-4077-bb1c-2dcddd36f6bb/README.md b/src/fc9ab6f0-c31b-4077-bb1c-2dcddd36f6bb/README.md index 433b69e..c788465 100644 --- a/src/fc9ab6f0-c31b-4077-bb1c-2dcddd36f6bb/README.md +++ b/src/fc9ab6f0-c31b-4077-bb1c-2dcddd36f6bb/README.md @@ -1 +1,45 @@ -###POWERREADME### \ No newline at end of file +``` +██████╗ ██████╗ ██╗ ██╗███████╗██████╗ +██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗ +██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝ +██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗ +██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║ +╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝ +``` +# final class Uri (Details) +> namespace: **VDM\Joomla\GetBible\Utilities** +```uml +@startuml +class Uri << (F,LightGreen) >> #Green { + # Config $config + + __construct(Config $config) + + get(string $path) : JoomlaUri +} + +note right of Uri::__construct + Constructor + + since: 2.0.1 +end note + +note right of Uri::get + Method to build and return a full request URL for the request. + + since: 2.0.1 + return: JoomlaUri +end note + +@enduml +``` + +--- +``` + ██╗ ██████╗██████╗ + ██║██╔════╝██╔══██╗ + ██║██║ ██████╔╝ +██ ██║██║ ██╔══██╗ +╚█████╔╝╚██████╗██████╔╝ + ╚════╝ ╚═════╝╚═════╝ +``` +> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder) + diff --git a/src/fc9ab6f0-c31b-4077-bb1c-2dcddd36f6bb/code.php b/src/fc9ab6f0-c31b-4077-bb1c-2dcddd36f6bb/code.php index 3d222d0..094555e 100644 --- a/src/fc9ab6f0-c31b-4077-bb1c-2dcddd36f6bb/code.php +++ b/src/fc9ab6f0-c31b-4077-bb1c-2dcddd36f6bb/code.php @@ -9,4 +9,55 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ -###POWERCODE### +namespace VDM\Joomla\GetBible\Utilities; + + +use Joomla\Uri\Uri as JoomlaUri; +use VDM\Joomla\GetBible\Config; + + +/** + * The GetBible Uri + * + * @since 2.0.1 + */ +final class Uri +{ + /** + * The Config class + * + * @var Config + * @since 2.0.1 + */ + protected Config $config; + + /** + * Constructor + * + * @param Config $config The config class. + * + * @since 2.0.1 + **/ + public function __construct(Config $config) + { + // set the API config + $this->config = $config; + } + + /** + * Method to build and return a full request URL for the request. + * + * @param string $path URL to inflect + * + * @return JoomlaUri + * @since 2.0.1 + **/ + public function get(string $path): JoomlaUri + { + // Get a new Uri object focusing the api url and given path. + $uri = new JoomlaUri($this->config->endpoint . $path); + + return $uri; + } +} + diff --git a/src/fc9ab6f0-c31b-4077-bb1c-2dcddd36f6bb/code.power b/src/fc9ab6f0-c31b-4077-bb1c-2dcddd36f6bb/code.power index 69309b0..ae416f7 100644 --- a/src/fc9ab6f0-c31b-4077-bb1c-2dcddd36f6bb/code.power +++ b/src/fc9ab6f0-c31b-4077-bb1c-2dcddd36f6bb/code.power @@ -1 +1,36 @@ -###CODEPOWER### \ No newline at end of file + /** + * The Config class + * + * @var Config + * @since 2.0.1 + */ + protected Config $config; + + /** + * Constructor + * + * @param Config $config The config class. + * + * @since 2.0.1 + **/ + public function __construct(Config $config) + { + // set the API config + $this->config = $config; + } + + /** + * Method to build and return a full request URL for the request. + * + * @param string $path URL to inflect + * + * @return JoomlaUri + * @since 2.0.1 + **/ + public function get(string $path): JoomlaUri + { + // Get a new Uri object focusing the api url and given path. + $uri = new JoomlaUri($this->config->endpoint . $path); + + return $uri; + } \ No newline at end of file diff --git a/src/fc9ab6f0-c31b-4077-bb1c-2dcddd36f6bb/settings.json b/src/fc9ab6f0-c31b-4077-bb1c-2dcddd36f6bb/settings.json index 6b3b222..ce2a9a7 100644 --- a/src/fc9ab6f0-c31b-4077-bb1c-2dcddd36f6bb/settings.json +++ b/src/fc9ab6f0-c31b-4077-bb1c-2dcddd36f6bb/settings.json @@ -1 +1,23 @@ -###POWERLINKER### \ No newline at end of file +{ + "add_head": "1", + "add_licensing_template": "2", + "extends": "0", + "guid": "fc9ab6f0-c31b-4077-bb1c-2dcddd36f6bb", + "implements": null, + "load_selection": null, + "name": "Uri", + "power_version": "1.0.0", + "system_name": "Joomla.GetBible.Utilities.Uri", + "type": "final class", + "use_selection": { + "use_selection0": { + "use": "71075f03-4e77-4fc0-840a-ef55fd9260b2", + "as": "default" + } + }, + "namespace": "VDM\\Joomla\\GetBible\\Utilities.Uri", + "description": "The GetBible Uri\r\n\r\n@since 2.0.1", + "licensing_template": "\/**\r\n * @package GetBible\r\n *\r\n * @created 30th May, 2023\r\n * @author Llewellyn van der Merwe \r\n * @git GetBible \r\n * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.\r\n * @license GNU General Public License version 2 or later; see LICENSE.txt\r\n *\/\r\n", + "head": "use Joomla\\Uri\\Uri as JoomlaUri;", + "composer": "" +} \ No newline at end of file diff --git a/src/ff8d5fdb-2d1f-4178-bd18-a43b8efd1068/README.md b/src/ff8d5fdb-2d1f-4178-bd18-a43b8efd1068/README.md index 433b69e..d09bca5 100644 --- a/src/ff8d5fdb-2d1f-4178-bd18-a43b8efd1068/README.md +++ b/src/ff8d5fdb-2d1f-4178-bd18-a43b8efd1068/README.md @@ -1 +1,29 @@ -###POWERREADME### \ No newline at end of file +``` +██████╗ ██████╗ ██╗ ██╗███████╗██████╗ +██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗ +██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝ +██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗ +██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║ +╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝ +``` +# class Table (Details) +> namespace: **VDM\Joomla\GetBible** +```uml +@startuml +class Table #Gold { +} + +@enduml +``` + +--- +``` + ██╗ ██████╗██████╗ + ██║██╔════╝██╔══██╗ + ██║██║ ██████╔╝ +██ ██║██║ ██╔══██╗ +╚█████╔╝╚██████╗██████╔╝ + ╚════╝ ╚═════╝╚═════╝ +``` +> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder) + diff --git a/src/ff8d5fdb-2d1f-4178-bd18-a43b8efd1068/code.php b/src/ff8d5fdb-2d1f-4178-bd18-a43b8efd1068/code.php index 3d222d0..a14da6f 100644 --- a/src/ff8d5fdb-2d1f-4178-bd18-a43b8efd1068/code.php +++ b/src/ff8d5fdb-2d1f-4178-bd18-a43b8efd1068/code.php @@ -9,4 +9,1086 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ -###POWERCODE### +namespace VDM\Joomla\GetBible; + + +use VDM\Joomla\Interfaces\Tableinterface; +use VDM\Joomla\Abstraction\BaseTable; + + +/** + * GetBible Tables + * + * @since 2.0.1 + */ +class Table extends BaseTable implements Tableinterface +{ + /** + * All areas/views/tables with their field details + * + * @var array + * @since 2.0.1 + **/ + protected array $tables = [ + 'linker' => [ + 'name' => [ + 'name' => 'name', + 'label' => 'COM_GETBIBLE_LINKER_NAME_LABEL', + 'type' => 'text', + 'title' => true, + 'list' => 'linkers', + 'store' => NULL, + 'tab_name' => 'Details', + ], + 'guid' => [ + 'name' => 'guid', + 'label' => 'COM_GETBIBLE_LINKER_GUID_LABEL', + 'type' => 'text', + 'title' => false, + 'list' => 'linkers', + 'store' => NULL, + 'tab_name' => 'publishing', + ], + 'public_tagged_verses' => [ + 'name' => 'public_tagged_verses', + 'label' => 'COM_GETBIBLE_LINKER_PUBLIC_TAGGED_VERSES_LABEL', + 'type' => 'radio', + 'title' => false, + 'list' => 'linkers', + 'store' => NULL, + 'tab_name' => 'Details', + ], + 'public_notes' => [ + 'name' => 'public_notes', + 'label' => 'COM_GETBIBLE_LINKER_PUBLIC_NOTES_LABEL', + 'type' => 'radio', + 'title' => false, + 'list' => 'linkers', + 'store' => NULL, + 'tab_name' => 'Details', + ], + ], + 'note' => [ + 'book_nr' => [ + 'name' => 'book_nr', + 'label' => 'COM_GETBIBLE_NOTE_BOOK_NR_LABEL', + 'type' => 'number', + 'title' => false, + 'list' => 'notes', + 'store' => NULL, + 'tab_name' => 'Details', + ], + 'linker' => [ + 'name' => 'linker', + 'label' => 'COM_GETBIBLE_NOTE_LINKER_LABEL', + 'type' => 'linkers', + 'title' => false, + 'list' => 'notes', + 'store' => NULL, + 'tab_name' => 'Details', + ], + 'access' => [ + 'name' => 'access', + 'label' => 'COM_GETBIBLE_NOTE_ACCESS_LABEL', + 'type' => 'radio', + 'title' => false, + 'list' => 'notes', + 'store' => NULL, + 'tab_name' => 'Details', + ], + 'guid' => [ + 'name' => 'guid', + 'label' => 'COM_GETBIBLE_NOTE_GUID_LABEL', + 'type' => 'text', + 'title' => false, + 'list' => 'notes', + 'store' => NULL, + 'tab_name' => 'publishing', + ], + 'note' => [ + 'name' => 'note', + 'label' => 'COM_GETBIBLE_NOTE_NOTE_LABEL', + 'type' => 'textarea', + 'title' => false, + 'list' => 'notes', + 'store' => NULL, + 'tab_name' => 'Details', + ], + 'verse' => [ + 'name' => 'verse', + 'label' => 'COM_GETBIBLE_NOTE_VERSE_LABEL', + 'type' => 'number', + 'title' => false, + 'list' => 'notes', + 'store' => NULL, + 'tab_name' => 'Details', + ], + 'chapter' => [ + 'name' => 'chapter', + 'label' => 'COM_GETBIBLE_NOTE_CHAPTER_LABEL', + 'type' => 'number', + 'title' => false, + 'list' => 'notes', + 'store' => NULL, + 'tab_name' => 'Details', + ], + ], + 'tagged_verse' => [ + 'book_nr' => [ + 'name' => 'book_nr', + 'label' => 'COM_GETBIBLE_TAGGED_VERSE_BOOK_NR_LABEL', + 'type' => 'number', + 'title' => false, + 'list' => 'tagged_verses', + 'store' => NULL, + 'tab_name' => 'Details', + ], + 'abbreviation' => [ + 'name' => 'abbreviation', + 'label' => 'COM_GETBIBLE_TAGGED_VERSE_ABBREVIATION_LABEL', + 'type' => 'translations', + 'title' => false, + 'list' => 'tagged_verses', + 'store' => NULL, + 'tab_name' => 'Details', + ], + 'access' => [ + 'name' => 'access', + 'label' => 'COM_GETBIBLE_TAGGED_VERSE_ACCESS_LABEL', + 'type' => 'radio', + 'title' => false, + 'list' => 'tagged_verses', + 'store' => NULL, + 'tab_name' => 'Details', + ], + 'linker' => [ + 'name' => 'linker', + 'label' => 'COM_GETBIBLE_TAGGED_VERSE_LINKER_LABEL', + 'type' => 'linkers', + 'title' => false, + 'list' => 'tagged_verses', + 'store' => NULL, + 'tab_name' => 'Details', + ], + 'tag' => [ + 'name' => 'tag', + 'label' => 'COM_GETBIBLE_TAGGED_VERSE_TAG_LABEL', + 'type' => 'tagers', + 'title' => false, + 'list' => 'tagged_verses', + 'store' => NULL, + 'tab_name' => 'Details', + ], + 'guid' => [ + 'name' => 'guid', + 'label' => 'COM_GETBIBLE_TAGGED_VERSE_GUID_LABEL', + 'type' => 'text', + 'title' => false, + 'list' => 'tagged_verses', + 'store' => NULL, + 'tab_name' => 'publishing', + ], + 'verse' => [ + 'name' => 'verse', + 'label' => 'COM_GETBIBLE_TAGGED_VERSE_VERSE_LABEL', + 'type' => 'number', + 'title' => false, + 'list' => 'tagged_verses', + 'store' => NULL, + 'tab_name' => 'Details', + ], + 'chapter' => [ + 'name' => 'chapter', + 'label' => 'COM_GETBIBLE_TAGGED_VERSE_CHAPTER_LABEL', + 'type' => 'number', + 'title' => false, + 'list' => 'tagged_verses', + 'store' => NULL, + 'tab_name' => 'Details', + ], + ], + 'prompt' => [ + 'name' => [ + 'name' => 'name', + 'label' => 'COM_GETBIBLE_PROMPT_NAME_LABEL', + 'type' => 'text', + 'title' => true, + 'list' => 'prompts', + 'store' => NULL, + 'tab_name' => 'Prompt', + ], + 'integration' => [ + 'name' => 'integration', + 'label' => 'COM_GETBIBLE_PROMPT_INTEGRATION_LABEL', + 'type' => 'list', + 'title' => false, + 'list' => 'prompts', + 'store' => NULL, + 'tab_name' => 'Prompt', + ], + 'cache_behaviour' => [ + 'name' => 'cache_behaviour', + 'label' => 'COM_GETBIBLE_PROMPT_CACHE_BEHAVIOUR_LABEL', + 'type' => 'list', + 'title' => false, + 'list' => 'prompts', + 'store' => NULL, + 'tab_name' => 'Prompt', + ], + 'abbreviation' => [ + 'name' => 'abbreviation', + 'label' => 'COM_GETBIBLE_PROMPT_ABBREVIATION_LABEL', + 'type' => 'targettranslations', + 'title' => false, + 'list' => 'prompts', + 'store' => NULL, + 'tab_name' => 'Prompt', + ], + 'guid' => [ + 'name' => 'guid', + 'label' => 'COM_GETBIBLE_PROMPT_GUID_LABEL', + 'type' => 'text', + 'title' => false, + 'list' => 'prompts', + 'store' => NULL, + 'tab_name' => 'publishing', + ], + 'model' => [ + 'name' => 'model', + 'label' => 'COM_GETBIBLE_PROMPT_MODEL_LABEL', + 'type' => 'list', + 'title' => false, + 'list' => 'prompts', + 'store' => NULL, + 'tab_name' => 'Open AI', + ], + 'presence_penalty' => [ + 'name' => 'presence_penalty', + 'label' => 'COM_GETBIBLE_PROMPT_PRESENCE_PENALTY_LABEL', + 'type' => 'number', + 'title' => false, + 'list' => 'prompts', + 'store' => NULL, + 'tab_name' => 'Open AI', + ], + 'org_token' => [ + 'name' => 'org_token', + 'label' => 'COM_GETBIBLE_PROMPT_ORG_TOKEN_LABEL', + 'type' => 'password', + 'title' => false, + 'list' => 'prompts', + 'store' => NULL, + 'tab_name' => 'Open AI', + ], + 'token' => [ + 'name' => 'token', + 'label' => 'COM_GETBIBLE_PROMPT_TOKEN_LABEL', + 'type' => 'password', + 'title' => false, + 'list' => 'prompts', + 'store' => NULL, + 'tab_name' => 'Open AI', + ], + 'n_override' => [ + 'name' => 'n_override', + 'label' => 'COM_GETBIBLE_PROMPT_N_OVERRIDE_LABEL', + 'type' => 'radio', + 'title' => false, + 'list' => 'prompts', + 'store' => NULL, + 'tab_name' => 'Open AI', + ], + 'cache_capacity' => [ + 'name' => 'cache_capacity', + 'label' => 'COM_GETBIBLE_PROMPT_CACHE_CAPACITY_LABEL', + 'type' => 'number', + 'title' => false, + 'list' => 'prompts', + 'store' => NULL, + 'tab_name' => 'Prompt', + ], + 'messages' => [ + 'name' => 'messages', + 'label' => 'COM_GETBIBLE_PROMPT_MESSAGES_LABEL', + 'type' => 'subform', + 'title' => false, + 'list' => 'prompts', + 'store' => 'json', + 'tab_name' => 'Prompt', + ], + 'response_retrieval' => [ + 'name' => 'response_retrieval', + 'label' => 'COM_GETBIBLE_PROMPT_RESPONSE_RETRIEVAL_LABEL', + 'type' => 'radio', + 'title' => false, + 'list' => 'prompts', + 'store' => NULL, + 'tab_name' => 'Prompt', + ], + 'frequency_penalty_override' => [ + 'name' => 'frequency_penalty_override', + 'label' => 'COM_GETBIBLE_PROMPT_FREQUENCY_PENALTY_OVERRIDE_LABEL', + 'type' => 'radio', + 'title' => false, + 'list' => 'prompts', + 'store' => NULL, + 'tab_name' => 'Open AI', + ], + 'n' => [ + 'name' => 'n', + 'label' => 'COM_GETBIBLE_PROMPT_N_LABEL', + 'type' => 'number', + 'title' => false, + 'list' => 'prompts', + 'store' => NULL, + 'tab_name' => 'Open AI', + ], + 'max_tokens_override' => [ + 'name' => 'max_tokens_override', + 'label' => 'COM_GETBIBLE_PROMPT_MAX_TOKENS_OVERRIDE_LABEL', + 'type' => 'radio', + 'title' => false, + 'list' => 'prompts', + 'store' => NULL, + 'tab_name' => 'Open AI', + ], + 'token_override' => [ + 'name' => 'token_override', + 'label' => 'COM_GETBIBLE_PROMPT_TOKEN_OVERRIDE_LABEL', + 'type' => 'radio', + 'title' => false, + 'list' => 'prompts', + 'store' => NULL, + 'tab_name' => 'Open AI', + ], + 'max_tokens' => [ + 'name' => 'max_tokens', + 'label' => 'COM_GETBIBLE_PROMPT_MAX_TOKENS_LABEL', + 'type' => 'number', + 'title' => false, + 'list' => 'prompts', + 'store' => NULL, + 'tab_name' => 'Open AI', + ], + 'ai_org_token_override' => [ + 'name' => 'ai_org_token_override', + 'label' => 'COM_GETBIBLE_PROMPT_AI_ORG_TOKEN_OVERRIDE_LABEL', + 'type' => 'radio', + 'title' => false, + 'list' => 'prompts', + 'store' => NULL, + 'tab_name' => 'Open AI', + ], + 'temperature_override' => [ + 'name' => 'temperature_override', + 'label' => 'COM_GETBIBLE_PROMPT_TEMPERATURE_OVERRIDE_LABEL', + 'type' => 'radio', + 'title' => false, + 'list' => 'prompts', + 'store' => NULL, + 'tab_name' => 'Open AI', + ], + 'presence_penalty_override' => [ + 'name' => 'presence_penalty_override', + 'label' => 'COM_GETBIBLE_PROMPT_PRESENCE_PENALTY_OVERRIDE_LABEL', + 'type' => 'radio', + 'title' => false, + 'list' => 'prompts', + 'store' => NULL, + 'tab_name' => 'Open AI', + ], + 'top_p_override' => [ + 'name' => 'top_p_override', + 'label' => 'COM_GETBIBLE_PROMPT_TOP_P_OVERRIDE_LABEL', + 'type' => 'radio', + 'title' => false, + 'list' => 'prompts', + 'store' => NULL, + 'tab_name' => 'Open AI', + ], + 'frequency_penalty' => [ + 'name' => 'frequency_penalty', + 'label' => 'COM_GETBIBLE_PROMPT_FREQUENCY_PENALTY_LABEL', + 'type' => 'number', + 'title' => false, + 'list' => 'prompts', + 'store' => NULL, + 'tab_name' => 'Open AI', + ], + 'top_p' => [ + 'name' => 'top_p', + 'label' => 'COM_GETBIBLE_PROMPT_TOP_P_LABEL', + 'type' => 'number', + 'title' => false, + 'list' => 'prompts', + 'store' => NULL, + 'tab_name' => 'Open AI', + ], + 'temperature' => [ + 'name' => 'temperature', + 'label' => 'COM_GETBIBLE_PROMPT_TEMPERATURE_LABEL', + 'type' => 'number', + 'title' => false, + 'list' => 'prompts', + 'store' => NULL, + 'tab_name' => 'Open AI', + ], + ], + 'open_ai_response' => [ + 'response_id' => [ + 'name' => 'response_id', + 'label' => 'COM_GETBIBLE_OPEN_AI_RESPONSE_RESPONSE_ID_LABEL', + 'type' => 'text', + 'title' => true, + 'list' => 'open_ai_responses', + 'store' => NULL, + 'tab_name' => 'Details', + ], + 'prompt' => [ + 'name' => 'prompt', + 'label' => 'COM_GETBIBLE_OPEN_AI_RESPONSE_PROMPT_LABEL', + 'type' => 'prompts', + 'title' => false, + 'list' => 'open_ai_responses', + 'store' => NULL, + 'tab_name' => 'Details', + ], + 'response_object' => [ + 'name' => 'response_object', + 'label' => 'COM_GETBIBLE_OPEN_AI_RESPONSE_RESPONSE_OBJECT_LABEL', + 'type' => 'text', + 'title' => false, + 'list' => 'open_ai_responses', + 'store' => NULL, + 'tab_name' => 'Details', + ], + 'response_model' => [ + 'name' => 'response_model', + 'label' => 'COM_GETBIBLE_OPEN_AI_RESPONSE_RESPONSE_MODEL_LABEL', + 'type' => 'text', + 'title' => false, + 'list' => 'open_ai_responses', + 'store' => NULL, + 'tab_name' => 'Details', + ], + 'total_tokens' => [ + 'name' => 'total_tokens', + 'label' => 'COM_GETBIBLE_OPEN_AI_RESPONSE_TOTAL_TOKENS_LABEL', + 'type' => 'number', + 'title' => false, + 'list' => 'open_ai_responses', + 'store' => NULL, + 'tab_name' => 'Details', + ], + 'n' => [ + 'name' => 'n', + 'label' => 'COM_GETBIBLE_OPEN_AI_RESPONSE_N_LABEL', + 'type' => 'number', + 'title' => false, + 'list' => 'open_ai_responses', + 'store' => NULL, + 'tab_name' => 'Prompt', + ], + 'frequency_penalty' => [ + 'name' => 'frequency_penalty', + 'label' => 'COM_GETBIBLE_OPEN_AI_RESPONSE_FREQUENCY_PENALTY_LABEL', + 'type' => 'number', + 'title' => false, + 'list' => 'open_ai_responses', + 'store' => NULL, + 'tab_name' => 'Prompt', + ], + 'presence_penalty' => [ + 'name' => 'presence_penalty', + 'label' => 'COM_GETBIBLE_OPEN_AI_RESPONSE_PRESENCE_PENALTY_LABEL', + 'type' => 'number', + 'title' => false, + 'list' => 'open_ai_responses', + 'store' => NULL, + 'tab_name' => 'Prompt', + ], + 'word' => [ + 'name' => 'word', + 'label' => 'COM_GETBIBLE_OPEN_AI_RESPONSE_WORD_LABEL', + 'type' => 'text', + 'title' => false, + 'list' => 'open_ai_responses', + 'store' => NULL, + 'tab_name' => 'Bible', + ], + 'chapter' => [ + 'name' => 'chapter', + 'label' => 'COM_GETBIBLE_OPEN_AI_RESPONSE_CHAPTER_LABEL', + 'type' => 'text', + 'title' => false, + 'list' => 'open_ai_responses', + 'store' => NULL, + 'tab_name' => 'Bible', + ], + 'lcsh' => [ + 'name' => 'lcsh', + 'label' => 'COM_GETBIBLE_OPEN_AI_RESPONSE_LCSH_LABEL', + 'type' => 'text', + 'title' => false, + 'list' => 'open_ai_responses', + 'store' => NULL, + 'tab_name' => 'Bible', + ], + 'completion_tokens' => [ + 'name' => 'completion_tokens', + 'label' => 'COM_GETBIBLE_OPEN_AI_RESPONSE_COMPLETION_TOKENS_LABEL', + 'type' => 'number', + 'title' => false, + 'list' => 'open_ai_responses', + 'store' => NULL, + 'tab_name' => 'Details', + ], + 'prompt_tokens' => [ + 'name' => 'prompt_tokens', + 'label' => 'COM_GETBIBLE_OPEN_AI_RESPONSE_PROMPT_TOKENS_LABEL', + 'type' => 'number', + 'title' => false, + 'list' => 'open_ai_responses', + 'store' => NULL, + 'tab_name' => 'Details', + ], + 'response_created' => [ + 'name' => 'response_created', + 'label' => 'COM_GETBIBLE_OPEN_AI_RESPONSE_RESPONSE_CREATED_LABEL', + 'type' => 'text', + 'title' => false, + 'list' => 'open_ai_responses', + 'store' => NULL, + 'tab_name' => 'Details', + ], + 'abbreviation' => [ + 'name' => 'abbreviation', + 'label' => 'COM_GETBIBLE_OPEN_AI_RESPONSE_ABBREVIATION_LABEL', + 'type' => 'targettranslations', + 'title' => false, + 'list' => 'open_ai_responses', + 'store' => NULL, + 'tab_name' => 'Bible', + ], + 'language' => [ + 'name' => 'language', + 'label' => 'COM_GETBIBLE_OPEN_AI_RESPONSE_LANGUAGE_LABEL', + 'type' => 'text', + 'title' => false, + 'list' => 'open_ai_responses', + 'store' => NULL, + 'tab_name' => 'Bible', + ], + 'max_tokens' => [ + 'name' => 'max_tokens', + 'label' => 'COM_GETBIBLE_OPEN_AI_RESPONSE_MAX_TOKENS_LABEL', + 'type' => 'number', + 'title' => false, + 'list' => 'open_ai_responses', + 'store' => NULL, + 'tab_name' => 'Prompt', + ], + 'book' => [ + 'name' => 'book', + 'label' => 'COM_GETBIBLE_OPEN_AI_RESPONSE_BOOK_LABEL', + 'type' => 'text', + 'title' => false, + 'list' => 'open_ai_responses', + 'store' => NULL, + 'tab_name' => 'Bible', + ], + 'temperature' => [ + 'name' => 'temperature', + 'label' => 'COM_GETBIBLE_OPEN_AI_RESPONSE_TEMPERATURE_LABEL', + 'type' => 'number', + 'title' => false, + 'list' => 'open_ai_responses', + 'store' => NULL, + 'tab_name' => 'Prompt', + ], + 'verse' => [ + 'name' => 'verse', + 'label' => 'COM_GETBIBLE_OPEN_AI_RESPONSE_VERSE_LABEL', + 'type' => 'text', + 'title' => false, + 'list' => 'open_ai_responses', + 'store' => NULL, + 'tab_name' => 'Bible', + ], + 'top_p' => [ + 'name' => 'top_p', + 'label' => 'COM_GETBIBLE_OPEN_AI_RESPONSE_TOP_P_LABEL', + 'type' => 'number', + 'title' => false, + 'list' => 'open_ai_responses', + 'store' => NULL, + 'tab_name' => 'Prompt', + ], + 'selected_word' => [ + 'name' => 'selected_word', + 'label' => 'COM_GETBIBLE_OPEN_AI_RESPONSE_SELECTED_WORD_LABEL', + 'type' => 'text', + 'title' => false, + 'list' => 'open_ai_responses', + 'store' => NULL, + 'tab_name' => 'Bible', + ], + 'model' => [ + 'name' => 'model', + 'label' => 'COM_GETBIBLE_OPEN_AI_RESPONSE_MODEL_LABEL', + 'type' => 'list', + 'title' => false, + 'list' => 'open_ai_responses', + 'store' => NULL, + 'tab_name' => 'Prompt', + ], + ], + 'open_ai_message' => [ + 'role' => [ + 'name' => 'role', + 'label' => 'COM_GETBIBLE_OPEN_AI_MESSAGE_ROLE_LABEL', + 'type' => 'list', + 'title' => true, + 'list' => 'open_ai_messages', + 'store' => NULL, + 'tab_name' => 'Message', + ], + 'open_ai_response' => [ + 'name' => 'open_ai_response', + 'label' => 'COM_GETBIBLE_OPEN_AI_MESSAGE_OPEN_AI_RESPONSE_LABEL', + 'type' => 'openairesponses', + 'title' => false, + 'list' => 'open_ai_messages', + 'store' => NULL, + 'tab_name' => 'Message', + ], + 'prompt' => [ + 'name' => 'prompt', + 'label' => 'COM_GETBIBLE_OPEN_AI_MESSAGE_PROMPT_LABEL', + 'type' => 'prompts', + 'title' => false, + 'list' => 'open_ai_messages', + 'store' => NULL, + 'tab_name' => 'Message', + ], + 'source' => [ + 'name' => 'source', + 'label' => 'COM_GETBIBLE_OPEN_AI_MESSAGE_SOURCE_LABEL', + 'type' => 'radio', + 'title' => false, + 'list' => 'open_ai_messages', + 'store' => NULL, + 'tab_name' => 'Message', + ], + 'content' => [ + 'name' => 'content', + 'label' => 'COM_GETBIBLE_OPEN_AI_MESSAGE_CONTENT_LABEL', + 'type' => 'textarea', + 'title' => false, + 'list' => 'open_ai_messages', + 'store' => NULL, + 'tab_name' => 'Message', + ], + 'name' => [ + 'name' => 'name', + 'label' => 'COM_GETBIBLE_OPEN_AI_MESSAGE_NAME_LABEL', + 'type' => 'text', + 'title' => false, + 'list' => 'open_ai_messages', + 'store' => NULL, + 'tab_name' => 'Message', + ], + 'index' => [ + 'name' => 'index', + 'label' => 'COM_GETBIBLE_OPEN_AI_MESSAGE_INDEX_LABEL', + 'type' => 'number', + 'title' => false, + 'list' => 'open_ai_messages', + 'store' => NULL, + 'tab_name' => 'Message', + ], + ], + 'password' => [ + 'name' => [ + 'name' => 'name', + 'label' => 'COM_GETBIBLE_PASSWORD_NAME_LABEL', + 'type' => 'text', + 'title' => true, + 'list' => 'passwords', + 'store' => NULL, + 'tab_name' => 'Details', + ], + 'linker' => [ + 'name' => 'linker', + 'label' => 'COM_GETBIBLE_PASSWORD_LINKER_LABEL', + 'type' => 'linkers', + 'title' => false, + 'list' => 'passwords', + 'store' => NULL, + 'tab_name' => 'Details', + ], + 'guid' => [ + 'name' => 'guid', + 'label' => 'COM_GETBIBLE_PASSWORD_GUID_LABEL', + 'type' => 'text', + 'title' => false, + 'list' => 'passwords', + 'store' => NULL, + 'tab_name' => 'publishing', + ], + 'password' => [ + 'name' => 'password', + 'label' => 'COM_GETBIBLE_PASSWORD_PASSWORD_LABEL', + 'type' => 'password', + 'title' => false, + 'list' => 'passwords', + 'store' => NULL, + 'tab_name' => 'Details', + ], + ], + 'tag' => [ + 'name' => [ + 'name' => 'name', + 'label' => 'COM_GETBIBLE_TAG_NAME_LABEL', + 'type' => 'text', + 'title' => true, + 'list' => 'tags', + 'store' => NULL, + 'tab_name' => 'Details', + ], + 'linker' => [ + 'name' => 'linker', + 'label' => 'COM_GETBIBLE_TAG_LINKER_LABEL', + 'type' => 'linkers', + 'title' => false, + 'list' => 'tags', + 'store' => NULL, + 'tab_name' => 'Details', + ], + 'access' => [ + 'name' => 'access', + 'label' => 'COM_GETBIBLE_TAG_ACCESS_LABEL', + 'type' => 'radio', + 'title' => false, + 'list' => 'tags', + 'store' => NULL, + 'tab_name' => 'Details', + ], + 'guid' => [ + 'name' => 'guid', + 'label' => 'COM_GETBIBLE_TAG_GUID_LABEL', + 'type' => 'text', + 'title' => false, + 'list' => 'tags', + 'store' => NULL, + 'tab_name' => 'publishing', + ], + 'description' => [ + 'name' => 'description', + 'label' => 'COM_GETBIBLE_TAG_DESCRIPTION_LABEL', + 'type' => 'textarea', + 'title' => false, + 'list' => 'tags', + 'store' => NULL, + 'tab_name' => 'Details', + ], + ], + 'translation' => [ + 'translation' => [ + 'name' => 'translation', + 'label' => 'COM_GETBIBLE_TRANSLATION_TRANSLATION_LABEL', + 'type' => 'text', + 'title' => true, + 'list' => 'translations', + 'store' => NULL, + 'tab_name' => 'Details', + ], + 'abbreviation' => [ + 'name' => 'abbreviation', + 'label' => 'COM_GETBIBLE_TRANSLATION_ABBREVIATION_LABEL', + 'type' => 'text', + 'title' => false, + 'list' => 'translations', + 'store' => NULL, + 'tab_name' => 'Details', + ], + 'language' => [ + 'name' => 'language', + 'label' => 'COM_GETBIBLE_TRANSLATION_LANGUAGE_LABEL', + 'type' => 'text', + 'title' => false, + 'list' => 'translations', + 'store' => NULL, + 'tab_name' => 'Details', + ], + 'direction' => [ + 'name' => 'direction', + 'label' => 'COM_GETBIBLE_TRANSLATION_DIRECTION_LABEL', + 'type' => 'radio', + 'title' => false, + 'list' => 'translations', + 'store' => NULL, + 'tab_name' => 'Details', + ], + 'distribution_history' => [ + 'name' => 'distribution_history', + 'label' => 'COM_GETBIBLE_TRANSLATION_DISTRIBUTION_HISTORY_LABEL', + 'type' => 'subform', + 'title' => false, + 'list' => 'translations', + 'store' => 'json', + 'tab_name' => 'Details', + ], + 'distribution_about' => [ + 'name' => 'distribution_about', + 'label' => 'COM_GETBIBLE_TRANSLATION_DISTRIBUTION_ABOUT_LABEL', + 'type' => 'textarea', + 'title' => false, + 'list' => 'translations', + 'store' => NULL, + 'tab_name' => 'Details', + ], + 'distribution_license' => [ + 'name' => 'distribution_license', + 'label' => 'COM_GETBIBLE_TRANSLATION_DISTRIBUTION_LICENSE_LABEL', + 'type' => 'textarea', + 'title' => false, + 'list' => 'translations', + 'store' => NULL, + 'tab_name' => 'Details', + ], + 'distribution_source' => [ + 'name' => 'distribution_source', + 'label' => 'COM_GETBIBLE_TRANSLATION_DISTRIBUTION_SOURCE_LABEL', + 'type' => 'text', + 'title' => false, + 'list' => 'translations', + 'store' => NULL, + 'tab_name' => 'Details', + ], + 'distribution_sourcetype' => [ + 'name' => 'distribution_sourcetype', + 'label' => 'COM_GETBIBLE_TRANSLATION_DISTRIBUTION_SOURCETYPE_LABEL', + 'type' => 'text', + 'title' => false, + 'list' => 'translations', + 'store' => NULL, + 'tab_name' => 'Details', + ], + 'distribution_versification' => [ + 'name' => 'distribution_versification', + 'label' => 'COM_GETBIBLE_TRANSLATION_DISTRIBUTION_VERSIFICATION_LABEL', + 'type' => 'text', + 'title' => false, + 'list' => 'translations', + 'store' => NULL, + 'tab_name' => 'Details', + ], + 'sha' => [ + 'name' => 'sha', + 'label' => 'COM_GETBIBLE_TRANSLATION_SHA_LABEL', + 'type' => 'text', + 'title' => false, + 'list' => 'translations', + 'store' => NULL, + 'tab_name' => 'Details', + ], + 'encoding' => [ + 'name' => 'encoding', + 'label' => 'COM_GETBIBLE_TRANSLATION_ENCODING_LABEL', + 'type' => 'text', + 'title' => false, + 'list' => 'translations', + 'store' => NULL, + 'tab_name' => 'Details', + ], + 'distribution_lcsh' => [ + 'name' => 'distribution_lcsh', + 'label' => 'COM_GETBIBLE_TRANSLATION_DISTRIBUTION_LCSH_LABEL', + 'type' => 'text', + 'title' => false, + 'list' => 'translations', + 'store' => NULL, + 'tab_name' => 'Details', + ], + 'distribution_version_date' => [ + 'name' => 'distribution_version_date', + 'label' => 'COM_GETBIBLE_TRANSLATION_DISTRIBUTION_VERSION_DATE_LABEL', + 'type' => 'text', + 'title' => false, + 'list' => 'translations', + 'store' => NULL, + 'tab_name' => 'Details', + ], + 'distribution_version' => [ + 'name' => 'distribution_version', + 'label' => 'COM_GETBIBLE_TRANSLATION_DISTRIBUTION_VERSION_LABEL', + 'type' => 'text', + 'title' => false, + 'list' => 'translations', + 'store' => NULL, + 'tab_name' => 'Details', + ], + 'lang' => [ + 'name' => 'lang', + 'label' => 'COM_GETBIBLE_TRANSLATION_LANG_LABEL', + 'type' => 'text', + 'title' => false, + 'list' => 'translations', + 'store' => NULL, + 'tab_name' => 'Details', + ], + 'distribution_abbreviation' => [ + 'name' => 'distribution_abbreviation', + 'label' => 'COM_GETBIBLE_TRANSLATION_DISTRIBUTION_ABBREVIATION_LABEL', + 'type' => 'text', + 'title' => false, + 'list' => 'translations', + 'store' => NULL, + 'tab_name' => 'Details', + ], + ], + 'book' => [ + 'name' => [ + 'name' => 'name', + 'label' => 'COM_GETBIBLE_BOOK_NAME_LABEL', + 'type' => 'text', + 'title' => true, + 'list' => 'books', + 'store' => NULL, + 'tab_name' => 'Details', + ], + 'abbreviation' => [ + 'name' => 'abbreviation', + 'label' => 'COM_GETBIBLE_BOOK_ABBREVIATION_LABEL', + 'type' => 'translations', + 'title' => false, + 'list' => 'books', + 'store' => NULL, + 'tab_name' => 'Details', + ], + 'nr' => [ + 'name' => 'nr', + 'label' => 'COM_GETBIBLE_BOOK_NR_LABEL', + 'type' => 'number', + 'title' => false, + 'list' => 'books', + 'store' => NULL, + 'tab_name' => 'Details', + ], + 'sha' => [ + 'name' => 'sha', + 'label' => 'COM_GETBIBLE_BOOK_SHA_LABEL', + 'type' => 'text', + 'title' => false, + 'list' => 'books', + 'store' => NULL, + 'tab_name' => 'Details', + ], + ], + 'chapter' => [ + 'name' => [ + 'name' => 'name', + 'label' => 'COM_GETBIBLE_CHAPTER_NAME_LABEL', + 'type' => 'text', + 'title' => true, + 'list' => 'chapters', + 'store' => NULL, + 'tab_name' => 'Details', + ], + 'chapter' => [ + 'name' => 'chapter', + 'label' => 'COM_GETBIBLE_CHAPTER_CHAPTER_LABEL', + 'type' => 'number', + 'title' => false, + 'list' => 'chapters', + 'store' => NULL, + 'tab_name' => 'Details', + ], + 'book_nr' => [ + 'name' => 'book_nr', + 'label' => 'COM_GETBIBLE_CHAPTER_BOOK_NR_LABEL', + 'type' => 'number', + 'title' => false, + 'list' => 'chapters', + 'store' => NULL, + 'tab_name' => 'Details', + ], + 'abbreviation' => [ + 'name' => 'abbreviation', + 'label' => 'COM_GETBIBLE_CHAPTER_ABBREVIATION_LABEL', + 'type' => 'translations', + 'title' => false, + 'list' => 'chapters', + 'store' => NULL, + 'tab_name' => 'Details', + ], + 'sha' => [ + 'name' => 'sha', + 'label' => 'COM_GETBIBLE_CHAPTER_SHA_LABEL', + 'type' => 'text', + 'title' => false, + 'list' => 'chapters', + 'store' => NULL, + 'tab_name' => 'Details', + ], + ], + 'verse' => [ + 'book_nr' => [ + 'name' => 'book_nr', + 'label' => 'COM_GETBIBLE_VERSE_BOOK_NR_LABEL', + 'type' => 'number', + 'title' => true, + 'list' => 'verses', + 'store' => NULL, + 'tab_name' => 'Details', + ], + 'chapter' => [ + 'name' => 'chapter', + 'label' => 'COM_GETBIBLE_VERSE_CHAPTER_LABEL', + 'type' => 'number', + 'title' => false, + 'list' => 'verses', + 'store' => NULL, + 'tab_name' => 'Details', + ], + 'verse' => [ + 'name' => 'verse', + 'label' => 'COM_GETBIBLE_VERSE_VERSE_LABEL', + 'type' => 'number', + 'title' => false, + 'list' => 'verses', + 'store' => NULL, + 'tab_name' => 'Details', + ], + 'abbreviation' => [ + 'name' => 'abbreviation', + 'label' => 'COM_GETBIBLE_VERSE_ABBREVIATION_LABEL', + 'type' => 'translations', + 'title' => false, + 'list' => 'verses', + 'store' => NULL, + 'tab_name' => 'Details', + ], + 'text' => [ + 'name' => 'text', + 'label' => 'COM_GETBIBLE_VERSE_TEXT_LABEL', + 'type' => 'textarea', + 'title' => false, + 'list' => 'verses', + 'store' => NULL, + 'tab_name' => 'Details', + ], + 'name' => [ + 'name' => 'name', + 'label' => 'COM_GETBIBLE_VERSE_NAME_LABEL', + 'type' => 'text', + 'title' => false, + 'list' => 'verses', + 'store' => NULL, + 'tab_name' => 'Details', + ], + ], + ]; +} + diff --git a/src/ff8d5fdb-2d1f-4178-bd18-a43b8efd1068/code.power b/src/ff8d5fdb-2d1f-4178-bd18-a43b8efd1068/code.power index 69309b0..0dc7272 100644 --- a/src/ff8d5fdb-2d1f-4178-bd18-a43b8efd1068/code.power +++ b/src/ff8d5fdb-2d1f-4178-bd18-a43b8efd1068/code.power @@ -1 +1,7 @@ -###CODEPOWER### \ No newline at end of file + /** + * All areas/views/tables with their field details + * + * @var array + * @since 2.0.1 + **/ + protected array $tables = ###ALL_COMPONENT_FIELDS###; \ No newline at end of file diff --git a/src/ff8d5fdb-2d1f-4178-bd18-a43b8efd1068/settings.json b/src/ff8d5fdb-2d1f-4178-bd18-a43b8efd1068/settings.json index 6b3b222..a25a895 100644 --- a/src/ff8d5fdb-2d1f-4178-bd18-a43b8efd1068/settings.json +++ b/src/ff8d5fdb-2d1f-4178-bd18-a43b8efd1068/settings.json @@ -1 +1,20 @@ -###POWERLINKER### \ No newline at end of file +{ + "add_head": "0", + "add_licensing_template": "2", + "extends": "e0f6ddbe-2a35-4537-942c-faff2ebd04f6", + "guid": "ff8d5fdb-2d1f-4178-bd18-a43b8efd1068", + "implements": [ + "2da6d6c4-eb29-4d69-8bc2-36d96e916adf" + ], + "load_selection": null, + "name": "Table", + "power_version": "2.0.0", + "system_name": "Joomla.GetBible.Table", + "type": "class", + "use_selection": null, + "namespace": "VDM\\Joomla\\GetBible\\Table", + "description": "GetBible Tables\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 \r\n * @git 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": "" +} \ No newline at end of file diff --git a/super-powers.json b/super-powers.json index 18f683b..2055b3b 100644 --- a/super-powers.json +++ b/super-powers.json @@ -1 +1,585 @@ -###POWERINDEX### \ No newline at end of file +{ + "07d3888a-5f35-4ba7-977f-fb2f5cf99061": { + "name": "Chapter", + "type": "final class", + "namespace": "VDM\\Joomla\\GetBible\\Watcher", + "code": "src\/07d3888a-5f35-4ba7-977f-fb2f5cf99061\/code.php", + "power": "src\/07d3888a-5f35-4ba7-977f-fb2f5cf99061\/code.power", + "settings": "src\/07d3888a-5f35-4ba7-977f-fb2f5cf99061\/settings.json", + "path": "src\/07d3888a-5f35-4ba7-977f-fb2f5cf99061", + "spk": "Super__07d3888a_5f35_4ba7_977f_fb2f5cf99061__Power", + "guid": "07d3888a-5f35-4ba7-977f-fb2f5cf99061" + }, + "116eb429-bc51-4d14-b9aa-7145c86a29d1": { + "name": "Model", + "type": "class", + "namespace": "VDM\\Joomla\\GetBible\\Service", + "code": "src\/116eb429-bc51-4d14-b9aa-7145c86a29d1\/code.php", + "power": "src\/116eb429-bc51-4d14-b9aa-7145c86a29d1\/code.power", + "settings": "src\/116eb429-bc51-4d14-b9aa-7145c86a29d1\/settings.json", + "path": "src\/116eb429-bc51-4d14-b9aa-7145c86a29d1", + "spk": "Super__116eb429_bc51_4d14_b9aa_7145c86a29d1__Power", + "guid": "116eb429-bc51-4d14-b9aa-7145c86a29d1" + }, + "11892cfa-374e-4e3f-b0bc-531871c822d9": { + "name": "Factory", + "type": "abstract class", + "namespace": "VDM\\Joomla\\GetBible", + "code": "src\/11892cfa-374e-4e3f-b0bc-531871c822d9\/code.php", + "power": "src\/11892cfa-374e-4e3f-b0bc-531871c822d9\/code.power", + "settings": "src\/11892cfa-374e-4e3f-b0bc-531871c822d9\/settings.json", + "path": "src\/11892cfa-374e-4e3f-b0bc-531871c822d9", + "spk": "Super__11892cfa_374e_4e3f_b0bc_531871c822d9__Power", + "guid": "11892cfa-374e-4e3f-b0bc-531871c822d9" + }, + "17d87374-2953-4d6c-9fdd-4220d6ad1564": { + "name": "Scripture", + "type": "final class", + "namespace": "VDM\\Joomla\\GetBible\\Data", + "code": "src\/17d87374-2953-4d6c-9fdd-4220d6ad1564\/code.php", + "power": "src\/17d87374-2953-4d6c-9fdd-4220d6ad1564\/code.power", + "settings": "src\/17d87374-2953-4d6c-9fdd-4220d6ad1564\/settings.json", + "path": "src\/17d87374-2953-4d6c-9fdd-4220d6ad1564", + "spk": "Super__17d87374_2953_4d6c_9fdd_4220d6ad1564__Power", + "guid": "17d87374-2953-4d6c-9fdd-4220d6ad1564" + }, + "2315a1c5-bcf6-401a-8d11-60f4d6d12dbb": { + "name": "Tagged", + "type": "final class", + "namespace": "VDM\\Joomla\\GetBible", + "code": "src\/2315a1c5-bcf6-401a-8d11-60f4d6d12dbb\/code.php", + "power": "src\/2315a1c5-bcf6-401a-8d11-60f4d6d12dbb\/code.power", + "settings": "src\/2315a1c5-bcf6-401a-8d11-60f4d6d12dbb\/settings.json", + "path": "src\/2315a1c5-bcf6-401a-8d11-60f4d6d12dbb", + "spk": "Super__2315a1c5_bcf6_401a_8d11_60f4d6d12dbb__Power", + "guid": "2315a1c5-bcf6-401a-8d11-60f4d6d12dbb" + }, + "3439e63b-d8f1-42ce-a765-60d56b1fbe21": { + "name": "Data", + "type": "class", + "namespace": "VDM\\Joomla\\GetBible\\Service", + "code": "src\/3439e63b-d8f1-42ce-a765-60d56b1fbe21\/code.php", + "power": "src\/3439e63b-d8f1-42ce-a765-60d56b1fbe21\/code.power", + "settings": "src\/3439e63b-d8f1-42ce-a765-60d56b1fbe21\/settings.json", + "path": "src\/3439e63b-d8f1-42ce-a765-60d56b1fbe21", + "spk": "Super__3439e63b_d8f1_42ce_a765_60d56b1fbe21__Power", + "guid": "3439e63b-d8f1-42ce-a765-60d56b1fbe21" + }, + "36ab759f-7b42-4465-9c17-56ba1dd05f90": { + "name": "Linker", + "type": "final class", + "namespace": "VDM\\Joomla\\GetBible", + "code": "src\/36ab759f-7b42-4465-9c17-56ba1dd05f90\/code.php", + "power": "src\/36ab759f-7b42-4465-9c17-56ba1dd05f90\/code.power", + "settings": "src\/36ab759f-7b42-4465-9c17-56ba1dd05f90\/settings.json", + "path": "src\/36ab759f-7b42-4465-9c17-56ba1dd05f90", + "spk": "Super__36ab759f_7b42_4465_9c17_56ba1dd05f90__Power", + "guid": "36ab759f-7b42-4465-9c17-56ba1dd05f90" + }, + "37e36c41-16a7-4c5d-972c-99acad5fd0b1": { + "name": "Watcher", + "type": "abstract class", + "namespace": "VDM\\Joomla\\GetBible\\Abstraction", + "code": "src\/37e36c41-16a7-4c5d-972c-99acad5fd0b1\/code.php", + "power": "src\/37e36c41-16a7-4c5d-972c-99acad5fd0b1\/code.power", + "settings": "src\/37e36c41-16a7-4c5d-972c-99acad5fd0b1\/settings.json", + "path": "src\/37e36c41-16a7-4c5d-972c-99acad5fd0b1", + "spk": "Super__37e36c41_16a7_4c5d_972c_99acad5fd0b1__Power", + "guid": "37e36c41-16a7-4c5d-972c-99acad5fd0b1" + }, + "3af7864b-f1f3-491e-b16f-0504f890086d": { + "name": "Config", + "type": "class", + "namespace": "VDM\\Joomla\\GetBible\\Openai", + "code": "src\/3af7864b-f1f3-491e-b16f-0504f890086d\/code.php", + "power": "src\/3af7864b-f1f3-491e-b16f-0504f890086d\/code.power", + "settings": "src\/3af7864b-f1f3-491e-b16f-0504f890086d\/settings.json", + "path": "src\/3af7864b-f1f3-491e-b16f-0504f890086d", + "spk": "Super__3af7864b_f1f3_491e_b16f_0504f890086d__Power", + "guid": "3af7864b-f1f3-491e-b16f-0504f890086d" + }, + "3f785d63-a592-463d-9f5f-b2b5a8edd561": { + "name": "Prompt", + "type": "final class", + "namespace": "VDM\\Joomla\\GetBible\\Data", + "code": "src\/3f785d63-a592-463d-9f5f-b2b5a8edd561\/code.php", + "power": "src\/3f785d63-a592-463d-9f5f-b2b5a8edd561\/code.power", + "settings": "src\/3f785d63-a592-463d-9f5f-b2b5a8edd561\/settings.json", + "path": "src\/3f785d63-a592-463d-9f5f-b2b5a8edd561", + "spk": "Super__3f785d63_a592_463d_9f5f_b2b5a8edd561__Power", + "guid": "3f785d63-a592-463d-9f5f-b2b5a8edd561" + }, + "44c15b17-e096-47c0-8769-42ea9b692cb2": { + "name": "Response", + "type": "final class", + "namespace": "VDM\\Joomla\\GetBible\\Data", + "code": "src\/44c15b17-e096-47c0-8769-42ea9b692cb2\/code.php", + "power": "src\/44c15b17-e096-47c0-8769-42ea9b692cb2\/code.power", + "settings": "src\/44c15b17-e096-47c0-8769-42ea9b692cb2\/settings.json", + "path": "src\/44c15b17-e096-47c0-8769-42ea9b692cb2", + "spk": "Super__44c15b17_e096_47c0_8769_42ea9b692cb2__Power", + "guid": "44c15b17-e096-47c0-8769-42ea9b692cb2" + }, + "491c91ce-6355-40d3-bbbd-622473c6c026": { + "name": "Books", + "type": "final class", + "namespace": "VDM\\Joomla\\GetBible\\Api", + "code": "src\/491c91ce-6355-40d3-bbbd-622473c6c026\/code.php", + "power": "src\/491c91ce-6355-40d3-bbbd-622473c6c026\/code.power", + "settings": "src\/491c91ce-6355-40d3-bbbd-622473c6c026\/settings.json", + "path": "src\/491c91ce-6355-40d3-bbbd-622473c6c026", + "spk": "Super__491c91ce_6355_40d3_bbbd_622473c6c026__Power", + "guid": "491c91ce-6355-40d3-bbbd-622473c6c026" + }, + "4a4c786d-51f4-421a-aa61-262dfd071880": { + "name": "Chapter", + "type": "final class", + "namespace": "VDM\\Joomla\\GetBible\\Data", + "code": "src\/4a4c786d-51f4-421a-aa61-262dfd071880\/code.php", + "power": "src\/4a4c786d-51f4-421a-aa61-262dfd071880\/code.power", + "settings": "src\/4a4c786d-51f4-421a-aa61-262dfd071880\/settings.json", + "path": "src\/4a4c786d-51f4-421a-aa61-262dfd071880", + "spk": "Super__4a4c786d_51f4_421a_aa61_262dfd071880__Power", + "guid": "4a4c786d-51f4-421a-aa61-262dfd071880" + }, + "4cfff1bc-02b3-4c52-9e6e-7ceefb505a32": { + "name": "Paragraphs", + "type": "final class", + "namespace": "VDM\\Joomla\\GetBible\\Tagged", + "code": "src\/4cfff1bc-02b3-4c52-9e6e-7ceefb505a32\/code.php", + "power": "src\/4cfff1bc-02b3-4c52-9e6e-7ceefb505a32\/code.power", + "settings": "src\/4cfff1bc-02b3-4c52-9e6e-7ceefb505a32\/settings.json", + "path": "src\/4cfff1bc-02b3-4c52-9e6e-7ceefb505a32", + "spk": "Super__4cfff1bc_02b3_4c52_9e6e_7ceefb505a32__Power", + "guid": "4cfff1bc-02b3-4c52-9e6e-7ceefb505a32" + }, + "51bb0397-fa7c-4f7a-a4c5-1f95fdacad38": { + "name": "Database", + "type": "class", + "namespace": "VDM\\Joomla\\GetBible\\Service", + "code": "src\/51bb0397-fa7c-4f7a-a4c5-1f95fdacad38\/code.php", + "power": "src\/51bb0397-fa7c-4f7a-a4c5-1f95fdacad38\/code.power", + "settings": "src\/51bb0397-fa7c-4f7a-a4c5-1f95fdacad38\/settings.json", + "path": "src\/51bb0397-fa7c-4f7a-a4c5-1f95fdacad38", + "spk": "Super__51bb0397_fa7c_4f7a_a4c5_1f95fdacad38__Power", + "guid": "51bb0397-fa7c-4f7a-a4c5-1f95fdacad38" + }, + "56465044-94ed-4e00-b6db-160c67163df8": { + "name": "App", + "type": "class", + "namespace": "VDM\\Joomla\\GetBible\\Service", + "code": "src\/56465044-94ed-4e00-b6db-160c67163df8\/code.php", + "power": "src\/56465044-94ed-4e00-b6db-160c67163df8\/code.power", + "settings": "src\/56465044-94ed-4e00-b6db-160c67163df8\/settings.json", + "path": "src\/56465044-94ed-4e00-b6db-160c67163df8", + "spk": "Super__56465044_94ed_4e00_b6db_160c67163df8__Power", + "guid": "56465044-94ed-4e00-b6db-160c67163df8" + }, + "67f91b8b-7b48-4dbb-bbd5-7945c174622a": { + "name": "Tag", + "type": "final class", + "namespace": "VDM\\Joomla\\GetBible", + "code": "src\/67f91b8b-7b48-4dbb-bbd5-7945c174622a\/code.php", + "power": "src\/67f91b8b-7b48-4dbb-bbd5-7945c174622a\/code.power", + "settings": "src\/67f91b8b-7b48-4dbb-bbd5-7945c174622a\/settings.json", + "path": "src\/67f91b8b-7b48-4dbb-bbd5-7945c174622a", + "spk": "Super__67f91b8b_7b48_4dbb_bbd5_7945c174622a__Power", + "guid": "67f91b8b-7b48-4dbb-bbd5-7945c174622a" + }, + "71075f03-4e77-4fc0-840a-ef55fd9260b2": { + "name": "Config", + "type": "class", + "namespace": "VDM\\Joomla\\GetBible", + "code": "src\/71075f03-4e77-4fc0-840a-ef55fd9260b2\/code.php", + "power": "src\/71075f03-4e77-4fc0-840a-ef55fd9260b2\/code.power", + "settings": "src\/71075f03-4e77-4fc0-840a-ef55fd9260b2\/settings.json", + "path": "src\/71075f03-4e77-4fc0-840a-ef55fd9260b2", + "spk": "Super__71075f03_4e77_4fc0_840a_ef55fd9260b2__Power", + "guid": "71075f03-4e77-4fc0-840a-ef55fd9260b2" + }, + "7b490e63-8d1f-46de-a0c4-154272fd5d7f": { + "name": "Api", + "type": "abstract class", + "namespace": "VDM\\Joomla\\GetBible\\Abstraction", + "code": "src\/7b490e63-8d1f-46de-a0c4-154272fd5d7f\/code.php", + "power": "src\/7b490e63-8d1f-46de-a0c4-154272fd5d7f\/code.power", + "settings": "src\/7b490e63-8d1f-46de-a0c4-154272fd5d7f\/settings.json", + "path": "src\/7b490e63-8d1f-46de-a0c4-154272fd5d7f", + "spk": "Super__7b490e63_8d1f_46de_a0c4_154272fd5d7f__Power", + "guid": "7b490e63-8d1f-46de-a0c4-154272fd5d7f" + }, + "7d592acd-f031-4d0f-b667-584c88ae0495": { + "name": "Translation", + "type": "final class", + "namespace": "VDM\\Joomla\\GetBible\\Watcher", + "code": "src\/7d592acd-f031-4d0f-b667-584c88ae0495\/code.php", + "power": "src\/7d592acd-f031-4d0f-b667-584c88ae0495\/code.power", + "settings": "src\/7d592acd-f031-4d0f-b667-584c88ae0495\/settings.json", + "path": "src\/7d592acd-f031-4d0f-b667-584c88ae0495", + "spk": "Super__7d592acd_f031_4d0f_b667_584c88ae0495__Power", + "guid": "7d592acd-f031-4d0f-b667-584c88ae0495" + }, + "8336e3c4-f11b-41bc-a2b1-976f99442a84": { + "name": "Search", + "type": "final class", + "namespace": "VDM\\Joomla\\GetBible", + "code": "src\/8336e3c4-f11b-41bc-a2b1-976f99442a84\/code.php", + "power": "src\/8336e3c4-f11b-41bc-a2b1-976f99442a84\/code.power", + "settings": "src\/8336e3c4-f11b-41bc-a2b1-976f99442a84\/settings.json", + "path": "src\/8336e3c4-f11b-41bc-a2b1-976f99442a84", + "spk": "Super__8336e3c4_f11b_41bc_a2b1_976f99442a84__Power", + "guid": "8336e3c4-f11b-41bc-a2b1-976f99442a84" + }, + "84e84cd1-c938-4559-8414-d5692db4118e": { + "name": "SessionHelper", + "type": "final class", + "namespace": "VDM\\Joomla\\GetBible\\Utilities", + "code": "src\/84e84cd1-c938-4559-8414-d5692db4118e\/code.php", + "power": "src\/84e84cd1-c938-4559-8414-d5692db4118e\/code.power", + "settings": "src\/84e84cd1-c938-4559-8414-d5692db4118e\/settings.json", + "path": "src\/84e84cd1-c938-4559-8414-d5692db4118e", + "spk": "Super__84e84cd1_c938_4559_8414_d5692db4118e__Power", + "guid": "84e84cd1-c938-4559-8414-d5692db4118e" + }, + "899551ac-943e-4f81-becd-7e15c41f1081": { + "name": "Word", + "type": "final class", + "namespace": "VDM\\Joomla\\GetBible\\Data", + "code": "src\/899551ac-943e-4f81-becd-7e15c41f1081\/code.php", + "power": "src\/899551ac-943e-4f81-becd-7e15c41f1081\/code.power", + "settings": "src\/899551ac-943e-4f81-becd-7e15c41f1081\/settings.json", + "path": "src\/899551ac-943e-4f81-becd-7e15c41f1081", + "spk": "Super__899551ac_943e_4f81_becd_7e15c41f1081__Power", + "guid": "899551ac-943e-4f81-becd-7e15c41f1081" + }, + "90f2ee7a-c041-4316-ad54-af4f97fa3003": { + "name": "DailyScripture", + "type": "final class", + "namespace": "VDM\\Joomla\\GetBible", + "code": "src\/90f2ee7a-c041-4316-ad54-af4f97fa3003\/code.php", + "power": "src\/90f2ee7a-c041-4316-ad54-af4f97fa3003\/code.power", + "settings": "src\/90f2ee7a-c041-4316-ad54-af4f97fa3003\/settings.json", + "path": "src\/90f2ee7a-c041-4316-ad54-af4f97fa3003", + "spk": "Super__90f2ee7a_c041_4316_ad54_af4f97fa3003__Power", + "guid": "90f2ee7a-c041-4316-ad54-af4f97fa3003" + }, + "91b37bd7-b314-48be-91cf-434ec823bd80": { + "name": "Upsert", + "type": "final class", + "namespace": "VDM\\Joomla\\GetBible\\Model", + "code": "src\/91b37bd7-b314-48be-91cf-434ec823bd80\/code.php", + "power": "src\/91b37bd7-b314-48be-91cf-434ec823bd80\/code.power", + "settings": "src\/91b37bd7-b314-48be-91cf-434ec823bd80\/settings.json", + "path": "src\/91b37bd7-b314-48be-91cf-434ec823bd80", + "spk": "Super__91b37bd7_b314_48be_91cf_434ec823bd80__Power", + "guid": "91b37bd7-b314-48be-91cf-434ec823bd80" + }, + "a07d90f6-6ff2-40a1-99c1-0f2cf33c9adf": { + "name": "Insert", + "type": "final class", + "namespace": "VDM\\Joomla\\GetBible\\Database", + "code": "src\/a07d90f6-6ff2-40a1-99c1-0f2cf33c9adf\/code.php", + "power": "src\/a07d90f6-6ff2-40a1-99c1-0f2cf33c9adf\/code.power", + "settings": "src\/a07d90f6-6ff2-40a1-99c1-0f2cf33c9adf\/settings.json", + "path": "src\/a07d90f6-6ff2-40a1-99c1-0f2cf33c9adf", + "spk": "Super__a07d90f6_6ff2_40a1_99c1_0f2cf33c9adf__Power", + "guid": "a07d90f6-6ff2-40a1-99c1-0f2cf33c9adf" + }, + "a5b32737-207d-4cf6-b8ae-ee815612c3a0": { + "name": "StringHelper", + "type": "final class", + "namespace": "VDM\\Joomla\\GetBible\\Utilities", + "code": "src\/a5b32737-207d-4cf6-b8ae-ee815612c3a0\/code.php", + "power": "src\/a5b32737-207d-4cf6-b8ae-ee815612c3a0\/code.power", + "settings": "src\/a5b32737-207d-4cf6-b8ae-ee815612c3a0\/settings.json", + "path": "src\/a5b32737-207d-4cf6-b8ae-ee815612c3a0", + "spk": "Super__a5b32737_207d_4cf6_b8ae_ee815612c3a0__Power", + "guid": "a5b32737-207d-4cf6-b8ae-ee815612c3a0" + }, + "a752e4b2-9b5e-4188-8d33-3799c46d5119": { + "name": "Chapters", + "type": "final class", + "namespace": "VDM\\Joomla\\GetBible\\Api", + "code": "src\/a752e4b2-9b5e-4188-8d33-3799c46d5119\/code.php", + "power": "src\/a752e4b2-9b5e-4188-8d33-3799c46d5119\/code.power", + "settings": "src\/a752e4b2-9b5e-4188-8d33-3799c46d5119\/settings.json", + "path": "src\/a752e4b2-9b5e-4188-8d33-3799c46d5119", + "spk": "Super__a752e4b2_9b5e_4188_8d33_3799c46d5119__Power", + "guid": "a752e4b2-9b5e-4188-8d33-3799c46d5119" + }, + "ac5c7679-dd6e-4817-8e48-489e521122f1": { + "name": "Openai", + "type": "class", + "namespace": "VDM\\Joomla\\GetBible\\Service", + "code": "src\/ac5c7679-dd6e-4817-8e48-489e521122f1\/code.php", + "power": "src\/ac5c7679-dd6e-4817-8e48-489e521122f1\/code.power", + "settings": "src\/ac5c7679-dd6e-4817-8e48-489e521122f1\/settings.json", + "path": "src\/ac5c7679-dd6e-4817-8e48-489e521122f1", + "spk": "Super__ac5c7679_dd6e_4817_8e48_489e521122f1__Power", + "guid": "ac5c7679-dd6e-4817-8e48-489e521122f1" + }, + "afa508bf-78f8-4616-97cc-f2809584c086": { + "name": "Verses", + "type": "final class", + "namespace": "VDM\\Joomla\\GetBible\\Api", + "code": "src\/afa508bf-78f8-4616-97cc-f2809584c086\/code.php", + "power": "src\/afa508bf-78f8-4616-97cc-f2809584c086\/code.power", + "settings": "src\/afa508bf-78f8-4616-97cc-f2809584c086\/settings.json", + "path": "src\/afa508bf-78f8-4616-97cc-f2809584c086", + "spk": "Super__afa508bf_78f8_4616_97cc_f2809584c086__Power", + "guid": "afa508bf-78f8-4616-97cc-f2809584c086" + }, + "b1bd2b4f-dede-44ad-86e9-2a595a0a9ca0": { + "name": "Load", + "type": "final class", + "namespace": "VDM\\Joomla\\GetBible\\Model", + "code": "src\/b1bd2b4f-dede-44ad-86e9-2a595a0a9ca0\/code.php", + "power": "src\/b1bd2b4f-dede-44ad-86e9-2a595a0a9ca0\/code.power", + "settings": "src\/b1bd2b4f-dede-44ad-86e9-2a595a0a9ca0\/settings.json", + "path": "src\/b1bd2b4f-dede-44ad-86e9-2a595a0a9ca0", + "spk": "Super__b1bd2b4f_dede_44ad_86e9_2a595a0a9ca0__Power", + "guid": "b1bd2b4f-dede-44ad-86e9-2a595a0a9ca0" + }, + "b2c9493f-692b-426b-af22-c6865f76c2bb": { + "name": "AI", + "type": "class", + "namespace": "VDM\\Joomla\\GetBible\\Service", + "code": "src\/b2c9493f-692b-426b-af22-c6865f76c2bb\/code.php", + "power": "src\/b2c9493f-692b-426b-af22-c6865f76c2bb\/code.power", + "settings": "src\/b2c9493f-692b-426b-af22-c6865f76c2bb\/settings.json", + "path": "src\/b2c9493f-692b-426b-af22-c6865f76c2bb", + "spk": "Super__b2c9493f_692b_426b_af22_c6865f76c2bb__Power", + "guid": "b2c9493f-692b-426b-af22-c6865f76c2bb" + }, + "b32eea04-6b9c-469d-94db-35d610686cf1": { + "name": "Api", + "type": "class", + "namespace": "VDM\\Joomla\\GetBible\\Service", + "code": "src\/b32eea04-6b9c-469d-94db-35d610686cf1\/code.php", + "power": "src\/b32eea04-6b9c-469d-94db-35d610686cf1\/code.power", + "settings": "src\/b32eea04-6b9c-469d-94db-35d610686cf1\/settings.json", + "path": "src\/b32eea04-6b9c-469d-94db-35d610686cf1", + "spk": "Super__b32eea04_6b9c_469d_94db_35d610686cf1__Power", + "guid": "b32eea04-6b9c-469d-94db-35d610686cf1" + }, + "b89d74ef-c71c-4a58-8455-5dbdfe94027a": { + "name": "Utilities", + "type": "class", + "namespace": "VDM\\Joomla\\GetBible\\Service", + "code": "src\/b89d74ef-c71c-4a58-8455-5dbdfe94027a\/code.php", + "power": "src\/b89d74ef-c71c-4a58-8455-5dbdfe94027a\/code.power", + "settings": "src\/b89d74ef-c71c-4a58-8455-5dbdfe94027a\/settings.json", + "path": "src\/b89d74ef-c71c-4a58-8455-5dbdfe94027a", + "spk": "Super__b89d74ef_c71c_4a58_8455_5dbdfe94027a__Power", + "guid": "b89d74ef-c71c-4a58-8455-5dbdfe94027a" + }, + "b8c66089-735e-4081-825c-8fe36b28e4a6": { + "name": "Http", + "type": "final class", + "namespace": "VDM\\Joomla\\GetBible\\Utilities", + "code": "src\/b8c66089-735e-4081-825c-8fe36b28e4a6\/code.php", + "power": "src\/b8c66089-735e-4081-825c-8fe36b28e4a6\/code.power", + "settings": "src\/b8c66089-735e-4081-825c-8fe36b28e4a6\/settings.json", + "path": "src\/b8c66089-735e-4081-825c-8fe36b28e4a6", + "spk": "Super__b8c66089_735e_4081_825c_8fe36b28e4a6__Power", + "guid": "b8c66089-735e-4081-825c-8fe36b28e4a6" + }, + "ba2151c0-8ffa-4a07-ba6e-93f135a3e9d5": { + "name": "Placeholders", + "type": "final class", + "namespace": "VDM\\Joomla\\GetBible\\Data", + "code": "src\/ba2151c0-8ffa-4a07-ba6e-93f135a3e9d5\/code.php", + "power": "src\/ba2151c0-8ffa-4a07-ba6e-93f135a3e9d5\/code.power", + "settings": "src\/ba2151c0-8ffa-4a07-ba6e-93f135a3e9d5\/settings.json", + "path": "src\/ba2151c0-8ffa-4a07-ba6e-93f135a3e9d5", + "spk": "Super__ba2151c0_8ffa_4a07_ba6e_93f135a3e9d5__Power", + "guid": "ba2151c0-8ffa-4a07-ba6e-93f135a3e9d5" + }, + "be0cae8b-4b78-4f59-b97b-9e31ee6f52e0": { + "name": "Translations", + "type": "final class", + "namespace": "VDM\\Joomla\\GetBible\\Api", + "code": "src\/be0cae8b-4b78-4f59-b97b-9e31ee6f52e0\/code.php", + "power": "src\/be0cae8b-4b78-4f59-b97b-9e31ee6f52e0\/code.power", + "settings": "src\/be0cae8b-4b78-4f59-b97b-9e31ee6f52e0\/settings.json", + "path": "src\/be0cae8b-4b78-4f59-b97b-9e31ee6f52e0", + "spk": "Super__be0cae8b_4b78_4f59_b97b_9e31ee6f52e0__Power", + "guid": "be0cae8b-4b78-4f59-b97b-9e31ee6f52e0" + }, + "c03b9c61-17d3-4774-a335-783903719f83": { + "name": "Load", + "type": "final class", + "namespace": "VDM\\Joomla\\GetBible\\Database", + "code": "src\/c03b9c61-17d3-4774-a335-783903719f83\/code.php", + "power": "src\/c03b9c61-17d3-4774-a335-783903719f83\/code.power", + "settings": "src\/c03b9c61-17d3-4774-a335-783903719f83\/settings.json", + "path": "src\/c03b9c61-17d3-4774-a335-783903719f83", + "spk": "Super__c03b9c61_17d3_4774_a335_783903719f83__Power", + "guid": "c03b9c61-17d3-4774-a335-783903719f83" + }, + "c2a8a5fa-8e7f-443a-86d7-a8c1e4cdfa98": { + "name": "Book", + "type": "final class", + "namespace": "VDM\\Joomla\\GetBible\\Watcher", + "code": "src\/c2a8a5fa-8e7f-443a-86d7-a8c1e4cdfa98\/code.php", + "power": "src\/c2a8a5fa-8e7f-443a-86d7-a8c1e4cdfa98\/code.power", + "settings": "src\/c2a8a5fa-8e7f-443a-86d7-a8c1e4cdfa98\/settings.json", + "path": "src\/c2a8a5fa-8e7f-443a-86d7-a8c1e4cdfa98", + "spk": "Super__c2a8a5fa_8e7f_443a_86d7_a8c1e4cdfa98__Power", + "guid": "c2a8a5fa-8e7f-443a-86d7-a8c1e4cdfa98" + }, + "c4098e1a-46dd-4d60-9277-b3668a09edc8": { + "name": "Translation", + "type": "final class", + "namespace": "VDM\\Joomla\\GetBible\\Data", + "code": "src\/c4098e1a-46dd-4d60-9277-b3668a09edc8\/code.php", + "power": "src\/c4098e1a-46dd-4d60-9277-b3668a09edc8\/code.power", + "settings": "src\/c4098e1a-46dd-4d60-9277-b3668a09edc8\/settings.json", + "path": "src\/c4098e1a-46dd-4d60-9277-b3668a09edc8", + "spk": "Super__c4098e1a_46dd_4d60_9277_b3668a09edc8__Power", + "guid": "c4098e1a-46dd-4d60-9277-b3668a09edc8" + }, + "c5077cd8-b042-4295-99cf-3a5ba2af7dce": { + "name": "Watcher", + "type": "class", + "namespace": "VDM\\Joomla\\GetBible\\Service", + "code": "src\/c5077cd8-b042-4295-99cf-3a5ba2af7dce\/code.php", + "power": "src\/c5077cd8-b042-4295-99cf-3a5ba2af7dce\/code.power", + "settings": "src\/c5077cd8-b042-4295-99cf-3a5ba2af7dce\/settings.json", + "path": "src\/c5077cd8-b042-4295-99cf-3a5ba2af7dce", + "spk": "Super__c5077cd8_b042_4295_99cf_3a5ba2af7dce__Power", + "guid": "c5077cd8-b042-4295-99cf-3a5ba2af7dce" + }, + "c99e85a0-d120-4f25-bcbf-0940dd7b773b": { + "name": "Response", + "type": "final class", + "namespace": "VDM\\Joomla\\GetBible\\Utilities", + "code": "src\/c99e85a0-d120-4f25-bcbf-0940dd7b773b\/code.php", + "power": "src\/c99e85a0-d120-4f25-bcbf-0940dd7b773b\/code.power", + "settings": "src\/c99e85a0-d120-4f25-bcbf-0940dd7b773b\/settings.json", + "path": "src\/c99e85a0-d120-4f25-bcbf-0940dd7b773b", + "spk": "Super__c99e85a0_d120_4f25_bcbf_0940dd7b773b__Power", + "guid": "c99e85a0-d120-4f25-bcbf-0940dd7b773b" + }, + "d7a5f0c6-de60-4d31-b3e4-5d668a8f7d2e": { + "name": "Update", + "type": "final class", + "namespace": "VDM\\Joomla\\GetBible\\Database", + "code": "src\/d7a5f0c6-de60-4d31-b3e4-5d668a8f7d2e\/code.php", + "power": "src\/d7a5f0c6-de60-4d31-b3e4-5d668a8f7d2e\/code.power", + "settings": "src\/d7a5f0c6-de60-4d31-b3e4-5d668a8f7d2e\/settings.json", + "path": "src\/d7a5f0c6-de60-4d31-b3e4-5d668a8f7d2e", + "spk": "Super__d7a5f0c6_de60_4d31_b3e4_5d668a8f7d2e__Power", + "guid": "d7a5f0c6-de60-4d31-b3e4-5d668a8f7d2e" + }, + "e3798c7e-aae1-4e38-ba78-6018ce94630b": { + "name": "Verse", + "type": "final class", + "namespace": "VDM\\Joomla\\GetBible\\Data", + "code": "src\/e3798c7e-aae1-4e38-ba78-6018ce94630b\/code.php", + "power": "src\/e3798c7e-aae1-4e38-ba78-6018ce94630b\/code.power", + "settings": "src\/e3798c7e-aae1-4e38-ba78-6018ce94630b\/settings.json", + "path": "src\/e3798c7e-aae1-4e38-ba78-6018ce94630b", + "spk": "Super__e3798c7e_aae1_4e38_ba78_6018ce94630b__Power", + "guid": "e3798c7e-aae1-4e38-ba78-6018ce94630b" + }, + "ebda6bd8-95b9-468b-a521-974205146018": { + "name": "Note", + "type": "final class", + "namespace": "VDM\\Joomla\\GetBible", + "code": "src\/ebda6bd8-95b9-468b-a521-974205146018\/code.php", + "power": "src\/ebda6bd8-95b9-468b-a521-974205146018\/code.power", + "settings": "src\/ebda6bd8-95b9-468b-a521-974205146018\/settings.json", + "path": "src\/ebda6bd8-95b9-468b-a521-974205146018", + "spk": "Super__ebda6bd8_95b9_468b_a521_974205146018__Power", + "guid": "ebda6bd8-95b9-468b-a521-974205146018" + }, + "ed16a9c4-e026-4d16-be60-81892ce7c6a9": { + "name": "Engineer", + "type": "final class", + "namespace": "VDM\\Joomla\\GetBible\\AI", + "code": "src\/ed16a9c4-e026-4d16-be60-81892ce7c6a9\/code.php", + "power": "src\/ed16a9c4-e026-4d16-be60-81892ce7c6a9\/code.power", + "settings": "src\/ed16a9c4-e026-4d16-be60-81892ce7c6a9\/settings.json", + "path": "src\/ed16a9c4-e026-4d16-be60-81892ce7c6a9", + "spk": "Super__ed16a9c4_e026_4d16_be60_81892ce7c6a9__Power", + "guid": "ed16a9c4-e026-4d16-be60-81892ce7c6a9" + }, + "f3757646-bc63-4f11-98c1-a2663180ab5e": { + "name": "AI", + "type": "final class", + "namespace": "VDM\\Joomla\\GetBible", + "code": "src\/f3757646-bc63-4f11-98c1-a2663180ab5e\/code.php", + "power": "src\/f3757646-bc63-4f11-98c1-a2663180ab5e\/code.power", + "settings": "src\/f3757646-bc63-4f11-98c1-a2663180ab5e\/settings.json", + "path": "src\/f3757646-bc63-4f11-98c1-a2663180ab5e", + "spk": "Super__f3757646_bc63_4f11_98c1_a2663180ab5e__Power", + "guid": "f3757646-bc63-4f11-98c1-a2663180ab5e" + }, + "f722bb8b-d377-4425-b1e4-2fe1734a3664": { + "name": "Openai", + "type": "abstract class", + "namespace": "VDM\\Joomla\\GetBible", + "code": "src\/f722bb8b-d377-4425-b1e4-2fe1734a3664\/code.php", + "power": "src\/f722bb8b-d377-4425-b1e4-2fe1734a3664\/code.power", + "settings": "src\/f722bb8b-d377-4425-b1e4-2fe1734a3664\/settings.json", + "path": "src\/f722bb8b-d377-4425-b1e4-2fe1734a3664", + "spk": "Super__f722bb8b_d377_4425_b1e4_2fe1734a3664__Power", + "guid": "f722bb8b-d377-4425-b1e4-2fe1734a3664" + }, + "f815fb33-f721-48a5-a84e-53f1986e8881": { + "name": "Watcher", + "type": "final class", + "namespace": "VDM\\Joomla\\GetBible", + "code": "src\/f815fb33-f721-48a5-a84e-53f1986e8881\/code.php", + "power": "src\/f815fb33-f721-48a5-a84e-53f1986e8881\/code.power", + "settings": "src\/f815fb33-f721-48a5-a84e-53f1986e8881\/settings.json", + "path": "src\/f815fb33-f721-48a5-a84e-53f1986e8881", + "spk": "Super__f815fb33_f721_48a5_a84e_53f1986e8881__Power", + "guid": "f815fb33-f721-48a5-a84e-53f1986e8881" + }, + "fa776320-65f8-4198-a517-58cd94b3b7b7": { + "name": "Book", + "type": "final class", + "namespace": "VDM\\Joomla\\GetBible\\Data", + "code": "src\/fa776320-65f8-4198-a517-58cd94b3b7b7\/code.php", + "power": "src\/fa776320-65f8-4198-a517-58cd94b3b7b7\/code.power", + "settings": "src\/fa776320-65f8-4198-a517-58cd94b3b7b7\/settings.json", + "path": "src\/fa776320-65f8-4198-a517-58cd94b3b7b7", + "spk": "Super__fa776320_65f8_4198_a517_58cd94b3b7b7__Power", + "guid": "fa776320-65f8-4198-a517-58cd94b3b7b7" + }, + "fb5683e2-67ec-413d-96fa-8465fd2f511c": { + "name": "Loader", + "type": "final class", + "namespace": "VDM\\Joomla\\GetBible", + "code": "src\/fb5683e2-67ec-413d-96fa-8465fd2f511c\/code.php", + "power": "src\/fb5683e2-67ec-413d-96fa-8465fd2f511c\/code.power", + "settings": "src\/fb5683e2-67ec-413d-96fa-8465fd2f511c\/settings.json", + "path": "src\/fb5683e2-67ec-413d-96fa-8465fd2f511c", + "spk": "Super__fb5683e2_67ec_413d_96fa_8465fd2f511c__Power", + "guid": "fb5683e2-67ec-413d-96fa-8465fd2f511c" + }, + "fc9ab6f0-c31b-4077-bb1c-2dcddd36f6bb": { + "name": "Uri", + "type": "final class", + "namespace": "VDM\\Joomla\\GetBible\\Utilities", + "code": "src\/fc9ab6f0-c31b-4077-bb1c-2dcddd36f6bb\/code.php", + "power": "src\/fc9ab6f0-c31b-4077-bb1c-2dcddd36f6bb\/code.power", + "settings": "src\/fc9ab6f0-c31b-4077-bb1c-2dcddd36f6bb\/settings.json", + "path": "src\/fc9ab6f0-c31b-4077-bb1c-2dcddd36f6bb", + "spk": "Super__fc9ab6f0_c31b_4077_bb1c_2dcddd36f6bb__Power", + "guid": "fc9ab6f0-c31b-4077-bb1c-2dcddd36f6bb" + }, + "ff8d5fdb-2d1f-4178-bd18-a43b8efd1068": { + "name": "Table", + "type": "class", + "namespace": "VDM\\Joomla\\GetBible", + "code": "src\/ff8d5fdb-2d1f-4178-bd18-a43b8efd1068\/code.php", + "power": "src\/ff8d5fdb-2d1f-4178-bd18-a43b8efd1068\/code.power", + "settings": "src\/ff8d5fdb-2d1f-4178-bd18-a43b8efd1068\/settings.json", + "path": "src\/ff8d5fdb-2d1f-4178-bd18-a43b8efd1068", + "spk": "Super__ff8d5fdb_2d1f_4178_bd18_a43b8efd1068__Power", + "guid": "ff8d5fdb-2d1f-4178-bd18-a43b8efd1068" + } +} \ No newline at end of file