From 29e38023c0a9e695f16314030715ee65c8a2f98f Mon Sep 17 00:00:00 2001 From: aB0t Date: Wed, 21 Aug 2024 23:08:24 +0200 Subject: [PATCH] Update 2024-08-21 11:08:12 --- README.md | 64 +- .../README.md | 36 +- .../code.php | 78 + .../code.power | 74 + .../settings.json | 16 + .../README.md | 156 ++ .../code.php | 338 ++++ .../code.power | 300 +++ .../settings.json | 70 + .../README.md | 4 +- .../code.php | 2 +- .../settings.json | 2 +- .../README.md | 129 ++ .../code.php | 277 +++ .../code.power | 241 +++ .../settings.json | 60 + .../README.md | 96 + .../code.php | 198 ++ .../code.power | 169 ++ .../settings.json | 32 + .../README.md | 95 + .../code.php | 934 +++++++++ .../code.power | 891 +++++++++ .../settings.json | 82 + .../README.md | 80 + .../code.php | 138 ++ .../code.power | 112 ++ .../settings.json | 19 + .../README.md | 8 - .../code.php | 56 +- .../code.power | 56 +- .../README.md | 66 + .../code.php | 78 + .../code.power | 51 + .../settings.json | 28 + .../README.md | 60 + .../code.php | 90 + .../code.power | 63 + .../settings.json | 24 + .../README.md | 94 + .../code.php | 215 ++ .../code.power | 185 ++ .../settings.json | 38 + .../README.md | 82 +- .../code.php | 1763 +++++++++-------- .../code.power | 1762 ++++++++-------- .../settings.json | 4 + .../README.md | 69 + .../code.php | 101 + .../code.power | 74 + .../settings.json | 28 + .../README.md | 181 ++ .../code.php | 830 ++++++++ .../code.power | 786 ++++++++ .../settings.json | 94 + .../README.md | 95 + .../code.php | 934 +++++++++ .../code.power | 891 +++++++++ .../settings.json | 82 + .../README.md | 84 + .../code.php | 129 ++ .../code.power | 103 + .../settings.json | 19 + .../README.md | 55 + .../code.php | 34 + .../code.power | 11 + .../settings.json | 19 + .../code.php | 20 +- .../code.power | 15 +- .../settings.json | 2 +- .../README.md | 4 +- .../code.php | 2 +- .../settings.json | 2 +- .../README.md | 156 ++ .../code.php | 570 ++++++ .../code.power | 526 +++++ .../settings.json | 90 + .../README.md | 61 + .../code.php | 106 + .../code.power | 76 + .../settings.json | 38 + .../README.md | 61 + .../code.php | 106 + .../code.power | 76 + .../settings.json | 38 + .../code.php | 54 + .../code.power | 54 + .../code.php | 2 +- .../code.power | 2 +- .../README.md | 61 + .../code.php | 71 + .../code.power | 43 + .../settings.json | 30 + .../code.php | 2 +- .../code.power | 2 +- .../README.md | 19 +- .../code.php | 203 +- .../code.power | 203 +- .../README.md | 14 +- .../code.php | 28 + .../code.power | 27 + .../settings.json | 4 + .../README.md | 32 +- .../code.php | 131 +- .../code.power | 122 +- .../settings.json | 42 +- .../code.php | 20 +- .../code.power | 15 +- .../settings.json | 2 +- .../code.php | 5 + .../code.power | 5 + .../README.md | 176 ++ .../code.php | 392 ++++ .../code.power | 352 ++++ .../settings.json | 78 + .../README.md | 176 ++ .../code.php | 392 ++++ .../code.power | 352 ++++ .../settings.json | 78 + .../README.md | 68 + .../code.php | 52 + .../code.power | 29 + .../settings.json | 19 + .../README.md | 4 +- .../code.php | 2 +- .../settings.json | 2 +- .../README.md | 26 +- .../code.php | 20 + .../code.power | 19 + .../settings.json | 20 +- .../README.md | 52 + .../code.php | 33 + .../code.power | 10 + .../settings.json | 19 + .../README.md | 8 - .../code.php | 66 +- .../code.power | 66 +- .../README.md | 52 + .../code.php | 32 + .../code.power | 9 + .../settings.json | 19 + .../README.md | 149 ++ .../code.php | 326 +++ .../code.power | 287 +++ .../settings.json | 71 + .../README.md | 93 +- .../code.php | 297 ++- .../code.power | 282 ++- .../settings.json | 44 +- .../README.md | 52 +- .../code.php | 114 ++ .../code.power | 108 + .../settings.json | 26 +- .../README.md | 61 + .../code.php | 78 + .../code.power | 50 + .../settings.json | 30 + .../README.md | 156 ++ .../code.php | 569 ++++++ .../code.power | 525 +++++ .../settings.json | 90 + .../README.md | 45 + .../code.php | 34 + .../code.power | 6 + .../settings.json | 26 + .../README.md | 2 +- .../code.php | 17 +- .../code.power | 8 +- .../settings.json | 12 +- .../README.md | 156 ++ .../code.php | 569 ++++++ .../code.power | 525 +++++ .../settings.json | 90 + .../README.md | 25 +- .../code.php | 57 + .../code.power | 57 + .../README.md | 8 + .../code.php | 33 + .../code.power | 31 + .../settings.json | 11 +- .../README.md | 243 +++ .../code.php | 794 ++++++++ .../code.power | 756 +++++++ .../settings.json | 66 + .../README.md | 181 ++ .../code.php | 830 ++++++++ .../code.power | 786 ++++++++ .../settings.json | 94 + .../README.md | 4 +- .../code.php | 2 +- .../settings.json | 2 +- .../code.php | 4 +- .../code.power | 4 +- .../README.md | 52 + .../code.php | 33 + .../code.power | 10 + .../settings.json | 19 + .../code.php | 2 + .../code.power | 1 + .../settings.json | 4 + .../code.php | 2 +- .../code.power | 2 +- .../README.md | 94 + .../code.php | 215 ++ .../code.power | 185 ++ .../settings.json | 38 + .../settings.json | 2 +- .../README.md | 52 + .../code.php | 30 + .../code.power | 7 + .../settings.json | 19 + .../code.php | 2 +- .../settings.json | 2 +- super-powers.json | 366 +++- 214 files changed, 27531 insertions(+), 2292 deletions(-) create mode 100644 src/03b75302-98ba-47ac-859f-1f49b738f66c/README.md create mode 100644 src/03b75302-98ba-47ac-859f-1f49b738f66c/code.php create mode 100644 src/03b75302-98ba-47ac-859f-1f49b738f66c/code.power create mode 100644 src/03b75302-98ba-47ac-859f-1f49b738f66c/settings.json create mode 100644 src/058cfcd7-1f84-4cc6-8bcc-7672f316881d/README.md create mode 100644 src/058cfcd7-1f84-4cc6-8bcc-7672f316881d/code.php create mode 100644 src/058cfcd7-1f84-4cc6-8bcc-7672f316881d/code.power create mode 100644 src/058cfcd7-1f84-4cc6-8bcc-7672f316881d/settings.json create mode 100644 src/0b0e574c-aab4-4eaf-96d8-d7210d8ed93e/README.md create mode 100644 src/0b0e574c-aab4-4eaf-96d8-d7210d8ed93e/code.php create mode 100644 src/0b0e574c-aab4-4eaf-96d8-d7210d8ed93e/code.power create mode 100644 src/0b0e574c-aab4-4eaf-96d8-d7210d8ed93e/settings.json create mode 100644 src/174f5c9c-5e03-4261-94ca-279ca76c710d/README.md create mode 100644 src/174f5c9c-5e03-4261-94ca-279ca76c710d/code.php create mode 100644 src/174f5c9c-5e03-4261-94ca-279ca76c710d/code.power create mode 100644 src/174f5c9c-5e03-4261-94ca-279ca76c710d/settings.json create mode 100644 src/1d051a2f-0691-45a8-b3d9-d0c1adcd73bc/README.md create mode 100644 src/1d051a2f-0691-45a8-b3d9-d0c1adcd73bc/code.php create mode 100644 src/1d051a2f-0691-45a8-b3d9-d0c1adcd73bc/code.power create mode 100644 src/1d051a2f-0691-45a8-b3d9-d0c1adcd73bc/settings.json create mode 100644 src/23f459a4-7c2a-4cbf-b0a6-8a11954140a9/README.md create mode 100644 src/23f459a4-7c2a-4cbf-b0a6-8a11954140a9/code.php create mode 100644 src/23f459a4-7c2a-4cbf-b0a6-8a11954140a9/code.power create mode 100644 src/23f459a4-7c2a-4cbf-b0a6-8a11954140a9/settings.json create mode 100644 src/263f0227-3cc2-4a88-9818-edb20081c30c/README.md create mode 100644 src/263f0227-3cc2-4a88-9818-edb20081c30c/code.php create mode 100644 src/263f0227-3cc2-4a88-9818-edb20081c30c/code.power create mode 100644 src/263f0227-3cc2-4a88-9818-edb20081c30c/settings.json create mode 100644 src/28c8eed4-58cf-4d40-9053-ad77b6edfa9d/README.md create mode 100644 src/28c8eed4-58cf-4d40-9053-ad77b6edfa9d/code.php create mode 100644 src/28c8eed4-58cf-4d40-9053-ad77b6edfa9d/code.power create mode 100644 src/28c8eed4-58cf-4d40-9053-ad77b6edfa9d/settings.json create mode 100644 src/344d36be-3949-4848-8cb0-e3d3d9d05c36/README.md create mode 100644 src/344d36be-3949-4848-8cb0-e3d3d9d05c36/code.php create mode 100644 src/344d36be-3949-4848-8cb0-e3d3d9d05c36/code.power create mode 100644 src/344d36be-3949-4848-8cb0-e3d3d9d05c36/settings.json create mode 100644 src/34daa4c8-45c3-4249-baa3-1bedf8ed3ebc/README.md create mode 100644 src/34daa4c8-45c3-4249-baa3-1bedf8ed3ebc/code.php create mode 100644 src/34daa4c8-45c3-4249-baa3-1bedf8ed3ebc/code.power create mode 100644 src/34daa4c8-45c3-4249-baa3-1bedf8ed3ebc/settings.json create mode 100644 src/361e08c0-5916-4b77-b6a2-c16a769bbc40/README.md create mode 100644 src/361e08c0-5916-4b77-b6a2-c16a769bbc40/code.php create mode 100644 src/361e08c0-5916-4b77-b6a2-c16a769bbc40/code.power create mode 100644 src/361e08c0-5916-4b77-b6a2-c16a769bbc40/settings.json create mode 100644 src/375543cd-5f2a-4893-982e-a73eaa55360d/README.md create mode 100644 src/375543cd-5f2a-4893-982e-a73eaa55360d/code.php create mode 100644 src/375543cd-5f2a-4893-982e-a73eaa55360d/code.power create mode 100644 src/375543cd-5f2a-4893-982e-a73eaa55360d/settings.json create mode 100644 src/40e17114-2193-4a61-9233-47b5f4193665/README.md create mode 100644 src/40e17114-2193-4a61-9233-47b5f4193665/code.php create mode 100644 src/40e17114-2193-4a61-9233-47b5f4193665/code.power create mode 100644 src/40e17114-2193-4a61-9233-47b5f4193665/settings.json create mode 100644 src/54e05f58-6538-42ec-ba46-b136f33e7cc7/README.md create mode 100644 src/54e05f58-6538-42ec-ba46-b136f33e7cc7/code.php create mode 100644 src/54e05f58-6538-42ec-ba46-b136f33e7cc7/code.power create mode 100644 src/54e05f58-6538-42ec-ba46-b136f33e7cc7/settings.json create mode 100644 src/60c3ccc5-36dc-4480-b5c4-252c37212f61/README.md create mode 100644 src/60c3ccc5-36dc-4480-b5c4-252c37212f61/code.php create mode 100644 src/60c3ccc5-36dc-4480-b5c4-252c37212f61/code.power create mode 100644 src/60c3ccc5-36dc-4480-b5c4-252c37212f61/settings.json create mode 100644 src/63865266-62e0-40bd-820c-e95449d12982/README.md create mode 100644 src/63865266-62e0-40bd-820c-e95449d12982/code.php create mode 100644 src/63865266-62e0-40bd-820c-e95449d12982/code.power create mode 100644 src/63865266-62e0-40bd-820c-e95449d12982/settings.json create mode 100644 src/6dd2d394-8dde-4eb7-8505-cd7d345c49e3/README.md create mode 100644 src/6dd2d394-8dde-4eb7-8505-cd7d345c49e3/code.php create mode 100644 src/6dd2d394-8dde-4eb7-8505-cd7d345c49e3/code.power create mode 100644 src/6dd2d394-8dde-4eb7-8505-cd7d345c49e3/settings.json create mode 100644 src/7f75b300-534c-4f63-a368-6f4abc4cea58/README.md create mode 100644 src/7f75b300-534c-4f63-a368-6f4abc4cea58/code.php create mode 100644 src/7f75b300-534c-4f63-a368-6f4abc4cea58/code.power create mode 100644 src/7f75b300-534c-4f63-a368-6f4abc4cea58/settings.json create mode 100644 src/84fe58db-d64d-42c6-9b41-f80bcff34c7f/README.md create mode 100644 src/84fe58db-d64d-42c6-9b41-f80bcff34c7f/code.php create mode 100644 src/84fe58db-d64d-42c6-9b41-f80bcff34c7f/code.power create mode 100644 src/84fe58db-d64d-42c6-9b41-f80bcff34c7f/settings.json create mode 100644 src/8cc85656-a925-4a46-a49b-83c72167fd6a/README.md create mode 100644 src/8cc85656-a925-4a46-a49b-83c72167fd6a/code.php create mode 100644 src/8cc85656-a925-4a46-a49b-83c72167fd6a/code.power create mode 100644 src/8cc85656-a925-4a46-a49b-83c72167fd6a/settings.json create mode 100644 src/914db7f5-82d8-4d3b-a1c1-eb476b1898c2/README.md create mode 100644 src/914db7f5-82d8-4d3b-a1c1-eb476b1898c2/code.php create mode 100644 src/914db7f5-82d8-4d3b-a1c1-eb476b1898c2/code.power create mode 100644 src/914db7f5-82d8-4d3b-a1c1-eb476b1898c2/settings.json create mode 100644 src/97177ca9-a51a-4d24-81e1-8747b6e7d76c/README.md create mode 100644 src/97177ca9-a51a-4d24-81e1-8747b6e7d76c/code.php create mode 100644 src/97177ca9-a51a-4d24-81e1-8747b6e7d76c/code.power create mode 100644 src/97177ca9-a51a-4d24-81e1-8747b6e7d76c/settings.json create mode 100644 src/98ac432d-df19-4c40-bb12-8104ea4362c8/README.md create mode 100644 src/98ac432d-df19-4c40-bb12-8104ea4362c8/code.php create mode 100644 src/98ac432d-df19-4c40-bb12-8104ea4362c8/code.power create mode 100644 src/98ac432d-df19-4c40-bb12-8104ea4362c8/settings.json create mode 100644 src/a5f658ff-3962-475d-8cf8-c91da562bf49/README.md create mode 100644 src/a5f658ff-3962-475d-8cf8-c91da562bf49/code.php create mode 100644 src/a5f658ff-3962-475d-8cf8-c91da562bf49/code.power create mode 100644 src/a5f658ff-3962-475d-8cf8-c91da562bf49/settings.json create mode 100644 src/a7124f78-21c5-400e-984d-4c5463cb2315/README.md create mode 100644 src/a7124f78-21c5-400e-984d-4c5463cb2315/code.php create mode 100644 src/a7124f78-21c5-400e-984d-4c5463cb2315/code.power create mode 100644 src/a7124f78-21c5-400e-984d-4c5463cb2315/settings.json create mode 100644 src/a8c6158a-6fd2-476b-a5ea-c81f1ecd2356/README.md create mode 100644 src/a8c6158a-6fd2-476b-a5ea-c81f1ecd2356/code.php create mode 100644 src/a8c6158a-6fd2-476b-a5ea-c81f1ecd2356/code.power create mode 100644 src/a8c6158a-6fd2-476b-a5ea-c81f1ecd2356/settings.json create mode 100644 src/af6d0e6a-61d2-4250-9e2f-bed5591e2786/README.md create mode 100644 src/af6d0e6a-61d2-4250-9e2f-bed5591e2786/code.php create mode 100644 src/af6d0e6a-61d2-4250-9e2f-bed5591e2786/code.power create mode 100644 src/af6d0e6a-61d2-4250-9e2f-bed5591e2786/settings.json create mode 100644 src/caf559ee-8337-4f07-9e4a-394d4e06afdc/README.md create mode 100644 src/caf559ee-8337-4f07-9e4a-394d4e06afdc/code.php create mode 100644 src/caf559ee-8337-4f07-9e4a-394d4e06afdc/code.power create mode 100644 src/caf559ee-8337-4f07-9e4a-394d4e06afdc/settings.json create mode 100644 src/d05c22be-9641-47fb-8a7b-063c43e7f1bf/README.md create mode 100644 src/d05c22be-9641-47fb-8a7b-063c43e7f1bf/code.php create mode 100644 src/d05c22be-9641-47fb-8a7b-063c43e7f1bf/code.power create mode 100644 src/d05c22be-9641-47fb-8a7b-063c43e7f1bf/settings.json create mode 100644 src/d6ae90a5-44b4-4ce4-aedc-86c90a242912/README.md create mode 100644 src/d6ae90a5-44b4-4ce4-aedc-86c90a242912/code.php create mode 100644 src/d6ae90a5-44b4-4ce4-aedc-86c90a242912/code.power create mode 100644 src/d6ae90a5-44b4-4ce4-aedc-86c90a242912/settings.json create mode 100644 src/ec808f55-6703-46c0-8a6d-33c9d4e0e9fa/README.md create mode 100644 src/ec808f55-6703-46c0-8a6d-33c9d4e0e9fa/code.php create mode 100644 src/ec808f55-6703-46c0-8a6d-33c9d4e0e9fa/code.power create mode 100644 src/ec808f55-6703-46c0-8a6d-33c9d4e0e9fa/settings.json create mode 100644 src/ef66b17c-ffae-414a-9067-20a63ba2bec5/README.md create mode 100644 src/ef66b17c-ffae-414a-9067-20a63ba2bec5/code.php create mode 100644 src/ef66b17c-ffae-414a-9067-20a63ba2bec5/code.power create mode 100644 src/ef66b17c-ffae-414a-9067-20a63ba2bec5/settings.json diff --git a/README.md b/README.md index 80cfb3c..db8e090 100644 --- a/README.md +++ b/README.md @@ -31,10 +31,10 @@ This repository contains an index (see below) of all the approved powers within - **abstract class Factory** | [Details](src/d910d8b8-4c23-4f3e-8cda-438f2d2bd7ac) | [Code](src/d910d8b8-4c23-4f3e-8cda-438f2d2bd7ac/code.php) | [Settings](src/d910d8b8-4c23-4f3e-8cda-438f2d2bd7ac/settings.json) | SPK: `Super---d910d8b8_4c23_4f3e_8cda_438f2d2bd7ac---Power` - **final class Component** | [Details](src/e2472b22-a329-44d8-b4a2-ae3ba99e17a0) | [Code](src/e2472b22-a329-44d8-b4a2-ae3ba99e17a0/code.php) | [Settings](src/e2472b22-a329-44d8-b4a2-ae3ba99e17a0/settings.json) | SPK: `Super---e2472b22_a329_44d8_b4a2_ae3ba99e17a0---Power` - **final class JoomlaPower** | [Details](src/3730a000-ab64-477d-8b0f-70eaf71b517a) | [Code](src/3730a000-ab64-477d-8b0f-70eaf71b517a/code.php) | [Settings](src/3730a000-ab64-477d-8b0f-70eaf71b517a/settings.json) | SPK: `Super---3730a000_ab64_477d_8b0f_70eaf71b517a---Power` + - **final class Language** | [Details](src/8eee7df5-2775-41a9-9372-c46c5939a252) | [Code](src/8eee7df5-2775-41a9-9372-c46c5939a252/code.php) | [Settings](src/8eee7df5-2775-41a9-9372-c46c5939a252/settings.json) | SPK: `Super---8eee7df5_2775_41a9_9372_c46c5939a252---Power` - **class Config** | [Details](src/fa4bf18e-301e-42e3-91fb-6e0096c07adc) | [Code](src/fa4bf18e-301e-42e3-91fb-6e0096c07adc/code.php) | [Settings](src/fa4bf18e-301e-42e3-91fb-6e0096c07adc/settings.json) | SPK: `Super---fa4bf18e_301e_42e3_91fb_6e0096c07adc---Power` - **class Customcode** | [Details](src/313b43c4-98c3-4f62-9177-2d73ec8eba31) | [Code](src/313b43c4-98c3-4f62-9177-2d73ec8eba31/code.php) | [Settings](src/313b43c4-98c3-4f62-9177-2d73ec8eba31/settings.json) | SPK: `Super---313b43c4_98c3_4f62_9177_2d73ec8eba31---Power` - **class Field** | [Details](src/d7ba2d5d-10b6-470d-978d-9f91ea65ee75) | [Code](src/d7ba2d5d-10b6-470d-978d-9f91ea65ee75/code.php) | [Settings](src/d7ba2d5d-10b6-470d-978d-9f91ea65ee75/settings.json) | SPK: `Super---d7ba2d5d_10b6_470d_978d_9f91ea65ee75---Power` - - **class Language** | [Details](src/8eee7df5-2775-41a9-9372-c46c5939a252) | [Code](src/8eee7df5-2775-41a9-9372-c46c5939a252/code.php) | [Settings](src/8eee7df5-2775-41a9-9372-c46c5939a252/settings.json) | SPK: `Super---8eee7df5_2775_41a9_9372_c46c5939a252---Power` - **class Placeholder** | [Details](src/06453ada-e370-49f0-b262-e3f5a8ed0c2c) | [Code](src/06453ada-e370-49f0-b262-e3f5a8ed0c2c/code.php) | [Settings](src/06453ada-e370-49f0-b262-e3f5a8ed0c2c/settings.json) | SPK: `Super---06453ada_e370_49f0_b262_e3f5a8ed0c2c---Power` - **class Power** | [Details](src/b836c1b1-b6b1-44f7-b8a2-9a763a4185b1) | [Code](src/b836c1b1-b6b1-44f7-b8a2-9a763a4185b1/code.php) | [Settings](src/b836c1b1-b6b1-44f7-b8a2-9a763a4185b1/settings.json) | SPK: `Super---b836c1b1_b6b1_44f7_b8a2_9a763a4185b1---Power` - **class Registry** | [Details](src/e5d9804f-0eb0-4ee9-b406-ad4e8cdbc1f6) | [Code](src/e5d9804f-0eb0-4ee9-b406-ad4e8cdbc1f6/code.php) | [Settings](src/e5d9804f-0eb0-4ee9-b406-ad4e8cdbc1f6/settings.json) | SPK: `Super---e5d9804f_0eb0_4ee9_b406_ad4e8cdbc1f6---Power` @@ -136,6 +136,7 @@ This repository contains an index (see below) of all the approved powers within - **final class ModelMediumField** | [Details](src/b0b26749-5e2c-4b56-8982-48172f2531fa) | [Code](src/b0b26749-5e2c-4b56-8982-48172f2531fa/code.php) | [Settings](src/b0b26749-5e2c-4b56-8982-48172f2531fa/settings.json) | SPK: `Super---b0b26749_5e2c_4b56_8982_48172f2531fa---Power` - **final class ModelWhmcsField** | [Details](src/28cac2bb-df04-454f-b4d6-923b573eb94e) | [Code](src/28cac2bb-df04-454f-b4d6-923b573eb94e/code.php) | [Settings](src/28cac2bb-df04-454f-b4d6-923b573eb94e/settings.json) | SPK: `Super---28cac2bb_df04_454f_b4d6_923b573eb94e---Power` - **final class MovedPublishingFields** | [Details](src/9cdff2af-bd1b-452f-810e-d034b9720d2a) | [Code](src/9cdff2af-bd1b-452f-810e-d034b9720d2a/code.php) | [Settings](src/9cdff2af-bd1b-452f-810e-d034b9720d2a/settings.json) | SPK: `Super---9cdff2af_bd1b_452f_810e_d034b9720d2a---Power` + - **final class Multilingual** | [Details](src/a8c6158a-6fd2-476b-a5ea-c81f1ecd2356) | [Code](src/a8c6158a-6fd2-476b-a5ea-c81f1ecd2356/code.php) | [Settings](src/a8c6158a-6fd2-476b-a5ea-c81f1ecd2356/settings.json) | SPK: `Super---a8c6158a_6fd2_476b_a5ea_c81f1ecd2356---Power` - **final class MysqlTableSetting** | [Details](src/9ff6d6cd-afea-4f15-a67b-fd132d386989) | [Code](src/9ff6d6cd-afea-4f15-a67b-fd132d386989/code.php) | [Settings](src/9ff6d6cd-afea-4f15-a67b-fd132d386989/settings.json) | SPK: `Super---9ff6d6cd_afea_4f15_a67b_fd132d386989---Power` - **final class NewPublishingFields** | [Details](src/0f141480-afe6-41fb-996c-2a4e566a2f0d) | [Code](src/0f141480-afe6-41fb-996c-2a4e566a2f0d/code.php) | [Settings](src/0f141480-afe6-41fb-996c-2a4e566a2f0d/settings.json) | SPK: `Super---0f141480_afe6_41fb_996c_2a4e566a2f0d---Power` - **final class OrderZero** | [Details](src/66b7b5f8-60d6-427a-9f8c-84c11a3d6780) | [Code](src/66b7b5f8-60d6-427a-9f8c-84c11a3d6780/code.php) | [Settings](src/66b7b5f8-60d6-427a-9f8c-84c11a3d6780/settings.json) | SPK: `Super---66b7b5f8_60d6_427a_9f8c_84c11a3d6780---Power` @@ -205,6 +206,7 @@ This repository contains an index (see below) of all the approved powers within - **final class FieldString** | [Details](src/44d039b9-d293-481b-b560-23a6e7a63962) | [Code](src/44d039b9-d293-481b-b560-23a6e7a63962/code.php) | [Settings](src/44d039b9-d293-481b-b560-23a6e7a63962/settings.json) | SPK: `Super---44d039b9_d293_481b_b560_23a6e7a63962---Power` - **final class FieldXML** | [Details](src/ac691a05-5630-4002-b166-dedec3fb0fcb) | [Code](src/ac691a05-5630-4002-b166-dedec3fb0fcb/code.php) | [Settings](src/ac691a05-5630-4002-b166-dedec3fb0fcb/settings.json) | SPK: `Super---ac691a05_5630_4002_b166_dedec3fb0fcb---Power` - **final class FieldsetDynamic** | [Details](src/b5986fab-17ca-4236-8c0c-81ebd2bb82ba) | [Code](src/b5986fab-17ca-4236-8c0c-81ebd2bb82ba/code.php) | [Settings](src/b5986fab-17ca-4236-8c0c-81ebd2bb82ba/settings.json) | SPK: `Super---b5986fab_17ca_4236_8c0c_81ebd2bb82ba---Power` + - **final class FieldsetExtension** | [Details](src/23f459a4-7c2a-4cbf-b0a6-8a11954140a9) | [Code](src/23f459a4-7c2a-4cbf-b0a6-8a11954140a9/code.php) | [Settings](src/23f459a4-7c2a-4cbf-b0a6-8a11954140a9/settings.json) | SPK: `Super---23f459a4_7c2a_4cbf_b0a6_8a11954140a9---Power` - **final class FieldsetString** | [Details](src/05448890-e324-41a0-b6db-d804bfc241cc) | [Code](src/05448890-e324-41a0-b6db-d804bfc241cc/code.php) | [Settings](src/05448890-e324-41a0-b6db-d804bfc241cc/settings.json) | SPK: `Super---05448890_e324_41a0_b6db_d804bfc241cc---Power` - **final class FieldsetXML** | [Details](src/79739667-72c6-4576-9830-7b1eb92e4791) | [Code](src/79739667-72c6-4576-9830-7b1eb92e4791/code.php) | [Settings](src/79739667-72c6-4576-9830-7b1eb92e4791/settings.json) | SPK: `Super---79739667_72c6_4576_9830_7b1eb92e4791---Power` - **final class Layout** | [Details](src/a0f032db-2242-41df-8e4a-5e9e6f88201d) | [Code](src/a0f032db-2242-41df-8e4a-5e9e6f88201d/code.php) | [Settings](src/a0f032db-2242-41df-8e4a-5e9e6f88201d/settings.json) | SPK: `Super---a0f032db_2242_41df_8e4a_5e9e6f88201d---Power` @@ -251,6 +253,7 @@ This repository contains an index (see below) of all the approved powers within - **interface HistoryInterface** | [Details](src/4325745f-da1f-4d4d-a591-3189fe8c06e5) | [Code](src/4325745f-da1f-4d4d-a591-3189fe8c06e5/code.php) | [Settings](src/4325745f-da1f-4d4d-a591-3189fe8c06e5/settings.json) | SPK: `Super---4325745f_da1f_4d4d_a591_3189fe8c06e5---Power` - **interface LanguageInterface** | [Details](src/d6592c9b-93a6-41b3-83c7-c43a0a80cb83) | [Code](src/d6592c9b-93a6-41b3-83c7-c43a0a80cb83/code.php) | [Settings](src/d6592c9b-93a6-41b3-83c7-c43a0a80cb83/settings.json) | SPK: `Super---d6592c9b_93a6_41b3_83c7_c43a0a80cb83---Power` - **interface PlaceholderInterface** | [Details](src/a6cdd935-c038-4a54-8446-54bed87f003c) | [Code](src/a6cdd935-c038-4a54-8446-54bed87f003c/code.php) | [Settings](src/a6cdd935-c038-4a54-8446-54bed87f003c/settings.json) | SPK: `Super---a6cdd935_c038_4a54_8446_54bed87f003c---Power` + - **interface PluginDataInterface** | [Details](src/8cc85656-a925-4a46-a49b-83c72167fd6a) | [Code](src/8cc85656-a925-4a46-a49b-83c72167fd6a/code.php) | [Settings](src/8cc85656-a925-4a46-a49b-83c72167fd6a/settings.json) | SPK: `Super---8cc85656_a925_4a46_a49b_83c72167fd6a---Power` - **interface PowerInterface** | [Details](src/1133c2d7-ba7e-4c95-8cde-01f084d04682) | [Code](src/1133c2d7-ba7e-4c95-8cde-01f084d04682/code.php) | [Settings](src/1133c2d7-ba7e-4c95-8cde-01f084d04682/settings.json) | SPK: `Super---1133c2d7_ba7e_4c95_8cde_01f084d04682---Power` - **Namespace**: [VDM\Joomla\Componentbuilder\Compiler\JoomlaFive](#vdm-joomla-componentbuilder-compiler-joomlafive) @@ -275,14 +278,16 @@ This repository contains an index (see below) of all the approved powers within - **class Data** | [Details](src/cb11e8d9-69c2-4095-831c-59908ea402e7) | [Code](src/cb11e8d9-69c2-4095-831c-59908ea402e7/code.php) | [Settings](src/cb11e8d9-69c2-4095-831c-59908ea402e7/settings.json) | SPK: `Super---cb11e8d9_69c2_4095_831c_59908ea402e7---Power` - **class Structure** | [Details](src/071c7cff-4c88-4b80-bd99-066c572dcb71) | [Code](src/071c7cff-4c88-4b80-bd99-066c572dcb71/code.php) | [Settings](src/071c7cff-4c88-4b80-bd99-066c572dcb71/settings.json) | SPK: `Super---071c7cff_4c88_4b80_bd99_066c572dcb71---Power` -- **Namespace**: [VDM\Joomla\Componentbuilder\Compiler\Joomlaplugin](#vdm-joomla-componentbuilder-compiler-joomlaplugin) - - - **class Data** | [Details](src/766a9524-37df-4604-91a7-b98a6150ee26) | [Code](src/766a9524-37df-4604-91a7-b98a6150ee26/code.php) | [Settings](src/766a9524-37df-4604-91a7-b98a6150ee26/settings.json) | SPK: `Super---766a9524_37df_4604_91a7_b98a6150ee26---Power` - - **class Structure** | [Details](src/a900b836-f2eb-4f13-8f28-b7cac839c7ff) | [Code](src/a900b836-f2eb-4f13-8f28-b7cac839c7ff/code.php) | [Settings](src/a900b836-f2eb-4f13-8f28-b7cac839c7ff/settings.json) | SPK: `Super---a900b836_f2eb_4f13_8f28_b7cac839c7ff---Power` - **Namespace**: [VDM\Joomla\Componentbuilder\Compiler\Language](#vdm-joomla-componentbuilder-compiler-language) - - **class Extractor** | [Details](src/d33b9278-c409-4aec-a047-b72f56712391) | [Code](src/d33b9278-c409-4aec-a047-b72f56712391/code.php) | [Settings](src/d33b9278-c409-4aec-a047-b72f56712391/settings.json) | SPK: `Super---d33b9278_c409_4aec_a047_b72f56712391---Power` - - **class Fieldset** | [Details](src/4ad7020e-39ab-49ba-977b-de6084944502) | [Code](src/4ad7020e-39ab-49ba-977b-de6084944502/code.php) | [Settings](src/4ad7020e-39ab-49ba-977b-de6084944502/settings.json) | SPK: `Super---4ad7020e_39ab_49ba_977b_de6084944502---Power` + - **final class Extractor** | [Details](src/d33b9278-c409-4aec-a047-b72f56712391) | [Code](src/d33b9278-c409-4aec-a047-b72f56712391/code.php) | [Settings](src/d33b9278-c409-4aec-a047-b72f56712391/settings.json) | SPK: `Super---d33b9278_c409_4aec_a047_b72f56712391---Power` + - **final class Fieldset** | [Details](src/4ad7020e-39ab-49ba-977b-de6084944502) | [Code](src/4ad7020e-39ab-49ba-977b-de6084944502/code.php) | [Settings](src/4ad7020e-39ab-49ba-977b-de6084944502/settings.json) | SPK: `Super---4ad7020e_39ab_49ba_977b_de6084944502---Power` + - **final class Insert** | [Details](src/1d051a2f-0691-45a8-b3d9-d0c1adcd73bc) | [Code](src/1d051a2f-0691-45a8-b3d9-d0c1adcd73bc/code.php) | [Settings](src/1d051a2f-0691-45a8-b3d9-d0c1adcd73bc/settings.json) | SPK: `Super---1d051a2f_0691_45a8_b3d9_d0c1adcd73bc---Power` + - **final class Multilingual** | [Details](src/263f0227-3cc2-4a88-9818-edb20081c30c) | [Code](src/263f0227-3cc2-4a88-9818-edb20081c30c/code.php) | [Settings](src/263f0227-3cc2-4a88-9818-edb20081c30c/settings.json) | SPK: `Super---263f0227_3cc2_4a88_9818_edb20081c30c---Power` + - **final class Purge** | [Details](src/0b0e574c-aab4-4eaf-96d8-d7210d8ed93e) | [Code](src/0b0e574c-aab4-4eaf-96d8-d7210d8ed93e/code.php) | [Settings](src/0b0e574c-aab4-4eaf-96d8-d7210d8ed93e/settings.json) | SPK: `Super---0b0e574c_aab4_4eaf_96d8_d7210d8ed93e---Power` + - **final class Set** | [Details](src/058cfcd7-1f84-4cc6-8bcc-7672f316881d) | [Code](src/058cfcd7-1f84-4cc6-8bcc-7672f316881d/code.php) | [Settings](src/058cfcd7-1f84-4cc6-8bcc-7672f316881d/settings.json) | SPK: `Super---058cfcd7_1f84_4cc6_8bcc_7672f316881d---Power` + - **final class Translation** | [Details](src/344d36be-3949-4848-8cb0-e3d3d9d05c36) | [Code](src/344d36be-3949-4848-8cb0-e3d3d9d05c36/code.php) | [Settings](src/344d36be-3949-4848-8cb0-e3d3d9d05c36/settings.json) | SPK: `Super---344d36be_3949_4848_8cb0_e3d3d9d05c36---Power` + - **final class Update** | [Details](src/375543cd-5f2a-4893-982e-a73eaa55360d) | [Code](src/375543cd-5f2a-4893-982e-a73eaa55360d/code.php) | [Settings](src/375543cd-5f2a-4893-982e-a73eaa55360d/settings.json) | SPK: `Super---375543cd_5f2a_4893_982e_a73eaa55360d---Power` - **Namespace**: [VDM\Joomla\Componentbuilder\Compiler\Library](#vdm-joomla-componentbuilder-compiler-library) - **class Data** | [Details](src/7175c1cd-2071-4cd7-b499-23881e168c3f) | [Code](src/7175c1cd-2071-4cd7-b499-23881e168c3f/code.php) | [Settings](src/7175c1cd-2071-4cd7-b499-23881e168c3f/settings.json) | SPK: `Super---7175c1cd_2071_4cd7_b499_23881e168c3f---Power` @@ -332,9 +337,9 @@ This repository contains an index (see below) of all the approved powers within - **class Reverse** | [Details](src/ca111518-e47c-4049-b1b2-cb010f23866f) | [Code](src/ca111518-e47c-4049-b1b2-cb010f23866f/code.php) | [Settings](src/ca111518-e47c-4049-b1b2-cb010f23866f/settings.json) | SPK: `Super---ca111518_e47c_4049_b1b2_cb010f23866f---Power` - **Namespace**: [VDM\Joomla\Componentbuilder\Compiler\Power](#vdm-joomla-componentbuilder-compiler-power) + - **final class Infusion** | [Details](src/0419081e-4cb3-4c65-8c6a-ffe941fb0f1c) | [Code](src/0419081e-4cb3-4c65-8c6a-ffe941fb0f1c/code.php) | [Settings](src/0419081e-4cb3-4c65-8c6a-ffe941fb0f1c/settings.json) | SPK: `Super---0419081e_4cb3_4c65_8c6a_ffe941fb0f1c---Power` - **class Autoloader** | [Details](src/6e64917c-d687-4ef3-a655-811319f5a81e) | [Code](src/6e64917c-d687-4ef3-a655-811319f5a81e/code.php) | [Settings](src/6e64917c-d687-4ef3-a655-811319f5a81e/settings.json) | SPK: `Super---6e64917c_d687_4ef3_a655_811319f5a81e---Power` - **class Extractor** | [Details](src/eeb03266-22fd-45bb-953a-961bb6be3a54) | [Code](src/eeb03266-22fd-45bb-953a-961bb6be3a54/code.php) | [Settings](src/eeb03266-22fd-45bb-953a-961bb6be3a54/settings.json) | SPK: `Super---eeb03266_22fd_45bb_953a_961bb6be3a54---Power` - - **class Infusion** | [Details](src/0419081e-4cb3-4c65-8c6a-ffe941fb0f1c) | [Code](src/0419081e-4cb3-4c65-8c6a-ffe941fb0f1c/code.php) | [Settings](src/0419081e-4cb3-4c65-8c6a-ffe941fb0f1c/settings.json) | SPK: `Super---0419081e_4cb3_4c65_8c6a_ffe941fb0f1c---Power` - **class Injector** | [Details](src/763d137c-42bc-4282-98d8-cc5c0654985f) | [Code](src/763d137c-42bc-4282-98d8-cc5c0654985f/code.php) | [Settings](src/763d137c-42bc-4282-98d8-cc5c0654985f/settings.json) | SPK: `Super---763d137c_42bc_4282_98d8_cc5c0654985f---Power` - **class Structure** | [Details](src/324566de-0f7d-4b6e-9caf-8424d55013ae) | [Code](src/324566de-0f7d-4b6e-9caf-8424d55013ae/code.php) | [Settings](src/324566de-0f7d-4b6e-9caf-8424d55013ae/settings.json) | SPK: `Super---324566de_0f7d_4b6e_9caf_8424d55013ae---Power` - **Namespace**: [VDM\Joomla\Componentbuilder\Compiler\Service](#vdm-joomla-componentbuilder-compiler-service) @@ -342,6 +347,7 @@ This repository contains an index (see below) of all the approved powers within - **class Adminview** | [Details](src/2dd1289a-4000-43cc-8c62-77ff32de56bf) | [Code](src/2dd1289a-4000-43cc-8c62-77ff32de56bf/code.php) | [Settings](src/2dd1289a-4000-43cc-8c62-77ff32de56bf/settings.json) | SPK: `Super---2dd1289a_4000_43cc_8c62_77ff32de56bf---Power` - **class ArchitectureController** | [Details](src/56ba30f5-a5c4-4c4c-be6f-a56f7f9cbc60) | [Code](src/56ba30f5-a5c4-4c4c-be6f-a56f7f9cbc60/code.php) | [Settings](src/56ba30f5-a5c4-4c4c-be6f-a56f7f9cbc60/settings.json) | SPK: `Super---56ba30f5_a5c4_4c4c_be6f_a56f7f9cbc60---Power` - **class ArchitectureModel** | [Details](src/bbd36fbf-d905-47e8-8e67-9ea6ec734712) | [Code](src/bbd36fbf-d905-47e8-8e67-9ea6ec734712/code.php) | [Settings](src/bbd36fbf-d905-47e8-8e67-9ea6ec734712/settings.json) | SPK: `Super---bbd36fbf_d905_47e8_8e67_9ea6ec734712---Power` + - **class ArchitecturePlugin** | [Details](src/98ac432d-df19-4c40-bb12-8104ea4362c8) | [Code](src/98ac432d-df19-4c40-bb12-8104ea4362c8/code.php) | [Settings](src/98ac432d-df19-4c40-bb12-8104ea4362c8/settings.json) | SPK: `Super---98ac432d_df19_4c40_bb12_8104ea4362c8---Power` - **class BuilderAJ** | [Details](src/c7230c8c-ea88-4d8d-8c53-6136133195b7) | [Code](src/c7230c8c-ea88-4d8d-8c53-6136133195b7/code.php) | [Settings](src/c7230c8c-ea88-4d8d-8c53-6136133195b7/settings.json) | SPK: `Super---c7230c8c_ea88_4d8d_8c53_6136133195b7---Power` - **class BuilderLZ** | [Details](src/2c76c06e-a371-4b73-9fbe-b4d9b4df55d7) | [Code](src/2c76c06e-a371-4b73-9fbe-b4d9b4df55d7/code.php) | [Settings](src/2c76c06e-a371-4b73-9fbe-b4d9b4df55d7/settings.json) | SPK: `Super---2c76c06e_a371_4b73_9fbe_b4d9b4df55d7---Power` - **class Compiler** | [Details](src/ea5ed06e-72ae-4906-9167-1cc0fa32fe69) | [Code](src/ea5ed06e-72ae-4906-9167-1cc0fa32fe69/code.php) | [Settings](src/ea5ed06e-72ae-4906-9167-1cc0fa32fe69/settings.json) | SPK: `Super---ea5ed06e_72ae_4906_9167_1cc0fa32fe69---Power` @@ -384,6 +390,10 @@ This repository contains an index (see below) of all the approved powers within - **class Pathfix** | [Details](src/cdc9b06d-8333-4fa7-ab4d-b810dd90f95f) | [Code](src/cdc9b06d-8333-4fa7-ab4d-b810dd90f95f/code.php) | [Settings](src/cdc9b06d-8333-4fa7-ab4d-b810dd90f95f/settings.json) | SPK: `Super---cdc9b06d_8333_4fa7_ab4d_b810dd90f95f---Power` - **class Paths** | [Details](src/6f20369a-8536-4870-a1a3-cda254c939c8) | [Code](src/6f20369a-8536-4870-a1a3-cda254c939c8/code.php) | [Settings](src/6f20369a-8536-4870-a1a3-cda254c939c8/settings.json) | SPK: `Super---6f20369a_8536_4870_a1a3_cda254c939c8---Power` - **class Structure** | [Details](src/1efdded5-d6c8-452c-8f37-0374483a7b3f) | [Code](src/1efdded5-d6c8-452c-8f37-0374483a7b3f/code.php) | [Settings](src/1efdded5-d6c8-452c-8f37-0374483a7b3f/settings.json) | SPK: `Super---1efdded5_d6c8_452c_8f37_0374483a7b3f---Power` +- **Namespace**: [VDM\Joomla\Componentbuilder\Interfaces\Plugin](#vdm-joomla-componentbuilder-interfaces-plugin) + + - **interface InfusionInterface** | [Details](src/40e17114-2193-4a61-9233-47b5f4193665) | [Code](src/40e17114-2193-4a61-9233-47b5f4193665/code.php) | [Settings](src/40e17114-2193-4a61-9233-47b5f4193665/settings.json) | SPK: `Super---40e17114_2193_4a61_9233_47b5f4193665---Power` + - **interface StructureInterface** | [Details](src/ef66b17c-ffae-414a-9067-20a63ba2bec5) | [Code](src/ef66b17c-ffae-414a-9067-20a63ba2bec5/code.php) | [Settings](src/ef66b17c-ffae-414a-9067-20a63ba2bec5/settings.json) | SPK: `Super---ef66b17c_ffae_414a_9067_20a63ba2bec5---Power` - **Namespace**: [VDM\Joomla\Componentbuilder\JoomlaPower\Readme](#vdm-joomla-componentbuilder-joomlapower-readme) - **final class Item** | [Details](src/fcbd0dd7-1f26-472e-abd3-56265f4999f2) | [Code](src/fcbd0dd7-1f26-472e-abd3-56265f4999f2/code.php) | [Settings](src/fcbd0dd7-1f26-472e-abd3-56265f4999f2/settings.json) | SPK: `Super---fcbd0dd7_1f26_472e_abd3_56265f4999f2---Power` @@ -410,6 +420,7 @@ This repository contains an index (see below) of all the approved powers within - **Namespace**: [VDM\Joomla\Componentbuilder\Power\Remote](#vdm-joomla-componentbuilder-power-remote) - **final class Get** | [Details](src/3ab0eba9-f37b-4b37-aec1-2e78067f2aff) | [Code](src/3ab0eba9-f37b-4b37-aec1-2e78067f2aff/code.php) | [Settings](src/3ab0eba9-f37b-4b37-aec1-2e78067f2aff/settings.json) | SPK: `Super---3ab0eba9_f37b_4b37_aec1_2e78067f2aff---Power` + - **final class Set** | [Details](src/caf559ee-8337-4f07-9e4a-394d4e06afdc) | [Code](src/caf559ee-8337-4f07-9e4a-394d4e06afdc/code.php) | [Settings](src/caf559ee-8337-4f07-9e4a-394d4e06afdc/settings.json) | SPK: `Super---caf559ee_8337_4f07_9e4a_394d4e06afdc---Power` - **Namespace**: [VDM\Joomla\Componentbuilder\Power\Service](#vdm-joomla-componentbuilder-power-service) - **class Generator** | [Details](src/a7101bbc-3c81-4b52-a4aa-522291f7594b) | [Code](src/a7101bbc-3c81-4b52-a4aa-522291f7594b/code.php) | [Settings](src/a7101bbc-3c81-4b52-a4aa-522291f7594b/settings.json) | SPK: `Super---a7101bbc_3c81_4b52_a4aa_522291f7594b---Power` @@ -482,6 +493,21 @@ This repository contains an index (see below) of all the approved powers within - **interface ExtractorInterface** | [Details](src/c159425c-51f9-4a15-af99-f2d0c6d7aae8) | [Code](src/c159425c-51f9-4a15-af99-f2d0c6d7aae8/code.php) | [Settings](src/c159425c-51f9-4a15-af99-f2d0c6d7aae8/settings.json) | SPK: `Super---c159425c_51f9_4a15_af99_f2d0c6d7aae8---Power` - **interface InjectorInterface** | [Details](src/e923311a-4058-4e81-9f67-5956fd0c627c) | [Code](src/e923311a-4058-4e81-9f67-5956fd0c627c/code.php) | [Settings](src/e923311a-4058-4e81-9f67-5956fd0c627c/settings.json) | SPK: `Super---e923311a_4058_4e81_9f67_5956fd0c627c---Power` +- **Namespace**: [VDM\Joomla\Componentbuilder\Compiler\Joomlaplugin\JoomlaFive](#vdm-joomla-componentbuilder-compiler-joomlaplugin-joomlafive) + + - **final class Data** | [Details](src/174f5c9c-5e03-4261-94ca-279ca76c710d) | [Code](src/174f5c9c-5e03-4261-94ca-279ca76c710d/code.php) | [Settings](src/174f5c9c-5e03-4261-94ca-279ca76c710d/settings.json) | SPK: `Super---174f5c9c_5e03_4261_94ca_279ca76c710d---Power` + - **final class Infusion** | [Details](src/7f75b300-534c-4f63-a368-6f4abc4cea58) | [Code](src/7f75b300-534c-4f63-a368-6f4abc4cea58/code.php) | [Settings](src/7f75b300-534c-4f63-a368-6f4abc4cea58/settings.json) | SPK: `Super---7f75b300_534c_4f63_a368_6f4abc4cea58---Power` + - **class Structure** | [Details](src/d05c22be-9641-47fb-8a7b-063c43e7f1bf) | [Code](src/d05c22be-9641-47fb-8a7b-063c43e7f1bf/code.php) | [Settings](src/d05c22be-9641-47fb-8a7b-063c43e7f1bf/settings.json) | SPK: `Super---d05c22be_9641_47fb_8a7b_063c43e7f1bf---Power` +- **Namespace**: [VDM\Joomla\Componentbuilder\Compiler\Joomlaplugin\JoomlaFour](#vdm-joomla-componentbuilder-compiler-joomlaplugin-joomlafour) + + - **final class Data** | [Details](src/361e08c0-5916-4b77-b6a2-c16a769bbc40) | [Code](src/361e08c0-5916-4b77-b6a2-c16a769bbc40/code.php) | [Settings](src/361e08c0-5916-4b77-b6a2-c16a769bbc40/settings.json) | SPK: `Super---361e08c0_5916_4b77_b6a2_c16a769bbc40---Power` + - **final class Infusion** | [Details](src/84fe58db-d64d-42c6-9b41-f80bcff34c7f) | [Code](src/84fe58db-d64d-42c6-9b41-f80bcff34c7f/code.php) | [Settings](src/84fe58db-d64d-42c6-9b41-f80bcff34c7f/settings.json) | SPK: `Super---84fe58db_d64d_42c6_9b41_f80bcff34c7f---Power` + - **class Structure** | [Details](src/34daa4c8-45c3-4249-baa3-1bedf8ed3ebc) | [Code](src/34daa4c8-45c3-4249-baa3-1bedf8ed3ebc/code.php) | [Settings](src/34daa4c8-45c3-4249-baa3-1bedf8ed3ebc/settings.json) | SPK: `Super---34daa4c8_45c3_4249_baa3_1bedf8ed3ebc---Power` +- **Namespace**: [VDM\Joomla\Componentbuilder\Compiler\Joomlaplugin\JoomlaThree](#vdm-joomla-componentbuilder-compiler-joomlaplugin-joomlathree) + + - **final class Data** | [Details](src/766a9524-37df-4604-91a7-b98a6150ee26) | [Code](src/766a9524-37df-4604-91a7-b98a6150ee26/code.php) | [Settings](src/766a9524-37df-4604-91a7-b98a6150ee26/settings.json) | SPK: `Super---766a9524_37df_4604_91a7_b98a6150ee26---Power` + - **final class Infusion** | [Details](src/03b75302-98ba-47ac-859f-1f49b738f66c) | [Code](src/03b75302-98ba-47ac-859f-1f49b738f66c/code.php) | [Settings](src/03b75302-98ba-47ac-859f-1f49b738f66c/settings.json) | SPK: `Super---03b75302_98ba_47ac_859f_1f49b738f66c---Power` + - **class Structure** | [Details](src/a900b836-f2eb-4f13-8f28-b7cac839c7ff) | [Code](src/a900b836-f2eb-4f13-8f28-b7cac839c7ff/code.php) | [Settings](src/a900b836-f2eb-4f13-8f28-b7cac839c7ff/settings.json) | SPK: `Super---a900b836_f2eb_4f13_8f28_b7cac839c7ff---Power` - **Namespace**: [VDM\Joomla\Componentbuilder\Compiler\Model\JoomlaFive](#vdm-joomla-componentbuilder-compiler-model-joomlafive) - **final class Customtabs** | [Details](src/92cc3144-1d3d-45b2-b49f-c7d356950033) | [Code](src/92cc3144-1d3d-45b2-b49f-c7d356950033/code.php) | [Settings](src/92cc3144-1d3d-45b2-b49f-c7d356950033/settings.json) | SPK: `Super---92cc3144_1d3d_45b2_b49f_c7d356950033---Power` @@ -491,6 +517,9 @@ This repository contains an index (see below) of all the approved powers within - **Namespace**: [VDM\Joomla\Componentbuilder\Compiler\Model\JoomlaThree](#vdm-joomla-componentbuilder-compiler-model-joomlathree) - **final class Customtabs** | [Details](src/fa8c1125-d370-4cb6-a7ff-eb32193c198c) | [Code](src/fa8c1125-d370-4cb6-a7ff-eb32193c198c/code.php) | [Settings](src/fa8c1125-d370-4cb6-a7ff-eb32193c198c/settings.json) | SPK: `Super---fa8c1125_d370_4cb6_a7ff_eb32193c198c---Power` +- **Namespace**: [VDM\Joomla\Componentbuilder\Interfaces\Architecture\Plugin](#vdm-joomla-componentbuilder-interfaces-architecture-plugin) + + - **interface MainXMLInterface** | [Details](src/97177ca9-a51a-4d24-81e1-8747b6e7d76c) | [Code](src/97177ca9-a51a-4d24-81e1-8747b6e7d76c/code.php) | [Settings](src/97177ca9-a51a-4d24-81e1-8747b6e7d76c/settings.json) | SPK: `Super---97177ca9_a51a_4d24_81e1_8747b6e7d76c---Power` - **Namespace**: [VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaFive\Controller](#vdm-joomla-componentbuilder-compiler-architecture-joomlafive-controller) - **final class AllowAdd** | [Details](src/005fce79-1b62-4a93-8d5e-8c89fee1afc6) | [Code](src/005fce79-1b62-4a93-8d5e-8c89fee1afc6/code.php) | [Settings](src/005fce79-1b62-4a93-8d5e-8c89fee1afc6/settings.json) | SPK: `Super---005fce79_1b62_4a93_8d5e_8c89fee1afc6---Power` @@ -500,6 +529,11 @@ This repository contains an index (see below) of all the approved powers within - **final class CanDelete** | [Details](src/34df20ec-67db-4e7e-be61-fb94d360c408) | [Code](src/34df20ec-67db-4e7e-be61-fb94d360c408/code.php) | [Settings](src/34df20ec-67db-4e7e-be61-fb94d360c408/settings.json) | SPK: `Super---34df20ec_67db_4e7e_be61_fb94d360c408---Power` - **final class CanEditState** | [Details](src/318a98a3-bb6f-42cb-a000-352d4c848b51) | [Code](src/318a98a3-bb6f-42cb-a000-352d4c848b51/code.php) | [Settings](src/318a98a3-bb6f-42cb-a000-352d4c848b51/settings.json) | SPK: `Super---318a98a3_bb6f_42cb_a000_352d4c848b51---Power` +- **Namespace**: [VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaFive\Plugin](#vdm-joomla-componentbuilder-compiler-architecture-joomlafive-plugin) + + - **final class Extension** | [Details](src/28c8eed4-58cf-4d40-9053-ad77b6edfa9d) | [Code](src/28c8eed4-58cf-4d40-9053-ad77b6edfa9d/code.php) | [Settings](src/28c8eed4-58cf-4d40-9053-ad77b6edfa9d/settings.json) | SPK: `Super---28c8eed4_58cf_4d40_9053_ad77b6edfa9d---Power` + - **final class MainXML** | [Details](src/a7124f78-21c5-400e-984d-4c5463cb2315) | [Code](src/a7124f78-21c5-400e-984d-4c5463cb2315/code.php) | [Settings](src/a7124f78-21c5-400e-984d-4c5463cb2315/settings.json) | SPK: `Super---a7124f78_21c5_400e_984d_4c5463cb2315---Power` + - **final class Provider** | [Details](src/63865266-62e0-40bd-820c-e95449d12982) | [Code](src/63865266-62e0-40bd-820c-e95449d12982/code.php) | [Settings](src/63865266-62e0-40bd-820c-e95449d12982/settings.json) | SPK: `Super---63865266_62e0_40bd_820c_e95449d12982---Power` - **Namespace**: [VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaFour\Controller](#vdm-joomla-componentbuilder-compiler-architecture-joomlafour-controller) - **final class AllowAdd** | [Details](src/425b1107-933d-4436-87ac-63540ec101c5) | [Code](src/425b1107-933d-4436-87ac-63540ec101c5/code.php) | [Settings](src/425b1107-933d-4436-87ac-63540ec101c5/settings.json) | SPK: `Super---425b1107_933d_4436_87ac_63540ec101c5---Power` @@ -509,6 +543,11 @@ This repository contains an index (see below) of all the approved powers within - **final class CanDelete** | [Details](src/2a69a8ab-cea0-4c75-92d5-9495cb740e0f) | [Code](src/2a69a8ab-cea0-4c75-92d5-9495cb740e0f/code.php) | [Settings](src/2a69a8ab-cea0-4c75-92d5-9495cb740e0f/settings.json) | SPK: `Super---2a69a8ab_cea0_4c75_92d5_9495cb740e0f---Power` - **final class CanEditState** | [Details](src/cb2a82a5-aa49-4d46-b765-9b3feb118208) | [Code](src/cb2a82a5-aa49-4d46-b765-9b3feb118208/code.php) | [Settings](src/cb2a82a5-aa49-4d46-b765-9b3feb118208/settings.json) | SPK: `Super---cb2a82a5_aa49_4d46_b765_9b3feb118208---Power` +- **Namespace**: [VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaFour\Plugin](#vdm-joomla-componentbuilder-compiler-architecture-joomlafour-plugin) + + - **final class Extension** | [Details](src/ec808f55-6703-46c0-8a6d-33c9d4e0e9fa) | [Code](src/ec808f55-6703-46c0-8a6d-33c9d4e0e9fa/code.php) | [Settings](src/ec808f55-6703-46c0-8a6d-33c9d4e0e9fa/settings.json) | SPK: `Super---ec808f55_6703_46c0_8a6d_33c9d4e0e9fa---Power` + - **final class MainXML** | [Details](src/af6d0e6a-61d2-4250-9e2f-bed5591e2786) | [Code](src/af6d0e6a-61d2-4250-9e2f-bed5591e2786/code.php) | [Settings](src/af6d0e6a-61d2-4250-9e2f-bed5591e2786/settings.json) | SPK: `Super---af6d0e6a_61d2_4250_9e2f_bed5591e2786---Power` + - **final class Provider** | [Details](src/60c3ccc5-36dc-4480-b5c4-252c37212f61) | [Code](src/60c3ccc5-36dc-4480-b5c4-252c37212f61/code.php) | [Settings](src/60c3ccc5-36dc-4480-b5c4-252c37212f61/settings.json) | SPK: `Super---60c3ccc5_36dc_4480_b5c4_252c37212f61---Power` - **Namespace**: [VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaThree\Controller](#vdm-joomla-componentbuilder-compiler-architecture-joomlathree-controller) - **final class AllowAdd** | [Details](src/f21388dc-5ddc-4970-a3c2-55f075024762) | [Code](src/f21388dc-5ddc-4970-a3c2-55f075024762/code.php) | [Settings](src/f21388dc-5ddc-4970-a3c2-55f075024762/settings.json) | SPK: `Super---f21388dc_5ddc_4970_a3c2_55f075024762---Power` @@ -518,6 +557,11 @@ This repository contains an index (see below) of all the approved powers within - **final class CanDelete** | [Details](src/23766738-d0a4-4d0a-8555-7e4c97c0cddd) | [Code](src/23766738-d0a4-4d0a-8555-7e4c97c0cddd/code.php) | [Settings](src/23766738-d0a4-4d0a-8555-7e4c97c0cddd/settings.json) | SPK: `Super---23766738_d0a4_4d0a_8555_7e4c97c0cddd---Power` - **final class CanEditState** | [Details](src/bce9ac2b-9f46-413f-b046-9e8af3f7dfbe) | [Code](src/bce9ac2b-9f46-413f-b046-9e8af3f7dfbe/code.php) | [Settings](src/bce9ac2b-9f46-413f-b046-9e8af3f7dfbe/settings.json) | SPK: `Super---bce9ac2b_9f46_413f_b046_9e8af3f7dfbe---Power` +- **Namespace**: [VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaThree\Plugin](#vdm-joomla-componentbuilder-compiler-architecture-joomlathree-plugin) + + - **final class Extension** | [Details](src/a5f658ff-3962-475d-8cf8-c91da562bf49) | [Code](src/a5f658ff-3962-475d-8cf8-c91da562bf49/code.php) | [Settings](src/a5f658ff-3962-475d-8cf8-c91da562bf49/settings.json) | SPK: `Super---a5f658ff_3962_475d_8cf8_c91da562bf49---Power` + - **final class MainXML** | [Details](src/54e05f58-6538-42ec-ba46-b136f33e7cc7) | [Code](src/54e05f58-6538-42ec-ba46-b136f33e7cc7/code.php) | [Settings](src/54e05f58-6538-42ec-ba46-b136f33e7cc7/settings.json) | SPK: `Super---54e05f58_6538_42ec_ba46_b136f33e7cc7---Power` + - **final class Provider** | [Details](src/6dd2d394-8dde-4eb7-8505-cd7d345c49e3) | [Code](src/6dd2d394-8dde-4eb7-8505-cd7d345c49e3/code.php) | [Settings](src/6dd2d394-8dde-4eb7-8505-cd7d345c49e3/settings.json) | SPK: `Super---6dd2d394_8dde_4eb7_8505_cd7d345c49e3---Power` - **Namespace**: [VDM\Joomla\Componentbuilder\Compiler\Interfaces\Architecture\Controller](#vdm-joomla-componentbuilder-compiler-interfaces-architecture-controller) - **interface AllowAddInterface** | [Details](src/c9700450-4f44-4455-bc86-6a7660daadee) | [Code](src/c9700450-4f44-4455-bc86-6a7660daadee/code.php) | [Settings](src/c9700450-4f44-4455-bc86-6a7660daadee/settings.json) | SPK: `Super---c9700450_4f44_4455_bc86_6a7660daadee---Power` @@ -527,6 +571,10 @@ This repository contains an index (see below) of all the approved powers within - **interface CanDeleteInterface** | [Details](src/e00a7d1d-6d80-41c5-bf13-32d41bc5bf91) | [Code](src/e00a7d1d-6d80-41c5-bf13-32d41bc5bf91/code.php) | [Settings](src/e00a7d1d-6d80-41c5-bf13-32d41bc5bf91/settings.json) | SPK: `Super---e00a7d1d_6d80_41c5_bf13_32d41bc5bf91---Power` - **interface CanEditStateInterface** | [Details](src/600515b1-493f-4448-96fe-018e54e087c8) | [Code](src/600515b1-493f-4448-96fe-018e54e087c8/code.php) | [Settings](src/600515b1-493f-4448-96fe-018e54e087c8/settings.json) | SPK: `Super---600515b1_493f_4448_96fe_018e54e087c8---Power` +- **Namespace**: [VDM\Joomla\Componentbuilder\Compiler\Interfaces\Architecture\Plugin](#vdm-joomla-componentbuilder-compiler-interfaces-architecture-plugin) + + - **interface ExtensionInterface** | [Details](src/914db7f5-82d8-4d3b-a1c1-eb476b1898c2) | [Code](src/914db7f5-82d8-4d3b-a1c1-eb476b1898c2/code.php) | [Settings](src/914db7f5-82d8-4d3b-a1c1-eb476b1898c2/settings.json) | SPK: `Super---914db7f5_82d8_4d3b_a1c1_eb476b1898c2---Power` + - **interface ProviderInterface** | [Details](src/d6ae90a5-44b4-4ce4-aedc-86c90a242912) | [Code](src/d6ae90a5-44b4-4ce4-aedc-86c90a242912/code.php) | [Settings](src/d6ae90a5-44b4-4ce4-aedc-86c90a242912/settings.json) | SPK: `Super---d6ae90a5_44b4_4ce4_aedc_86c90a242912---Power` > remember to replace the `---` with `___` in the SPK to activate that Power in your code --- diff --git a/src/02bc072b-1e89-46c1-9732-4da77b1a9ac9/README.md b/src/02bc072b-1e89-46c1-9732-4da77b1a9ac9/README.md index 95cedac..01a8048 100644 --- a/src/02bc072b-1e89-46c1-9732-4da77b1a9ac9/README.md +++ b/src/02bc072b-1e89-46c1-9732-4da77b1a9ac9/README.md @@ -17,7 +17,11 @@ class Power #Gold { + getTable(Container $container) : Table + getGrep(Container $container) : Grep + getRemoteGet(Container $container) : Get + + getRemoteSet(Container $container) : Set + + getItemReadme(Container $container) : ItemReadme + + getMainReadme(Container $container) : MainReadme + getParser(Container $container) : Parser + + getPlantuml(Container $container) : Plantuml } note right of Power::register @@ -27,7 +31,7 @@ note right of Power::register return: void end note -note right of Power::getConfig +note left of Power::getConfig Get The Config Class. since: 3.2.0 @@ -41,7 +45,7 @@ note right of Power::getTable return: Table end note -note right of Power::getGrep +note left of Power::getGrep Get The Grep Class. since: 3.2.0 @@ -55,12 +59,40 @@ note right of Power::getRemoteGet return: Get end note +note left of Power::getRemoteSet + Get The Remote Set Class. + + since: 5.0.3 + return: Set +end note + +note right of Power::getItemReadme + Get The Readme Class. + + since: 5.0.3 + return: ItemReadme +end note + +note left of Power::getMainReadme + Get The Readme Class. + + since: 5.0.3 + return: MainReadme +end note + note right of Power::getParser Get The Parser Class. since: 3.2.0 return: Parser end note + +note left of Power::getPlantuml + Get The Plantuml Class. + + since: 5.0.3 + return: Plantuml +end note @enduml ``` diff --git a/src/02bc072b-1e89-46c1-9732-4da77b1a9ac9/code.php b/src/02bc072b-1e89-46c1-9732-4da77b1a9ac9/code.php index 34af01e..2763c2f 100644 --- a/src/02bc072b-1e89-46c1-9732-4da77b1a9ac9/code.php +++ b/src/02bc072b-1e89-46c1-9732-4da77b1a9ac9/code.php @@ -18,7 +18,11 @@ use VDM\Joomla\Componentbuilder\Power\Config; use VDM\Joomla\Componentbuilder\Table; use VDM\Joomla\Componentbuilder\Power\Grep; use VDM\Joomla\Componentbuilder\Power\Remote\Get; +use VDM\Joomla\Componentbuilder\Power\Remote\Set; use VDM\Joomla\Componentbuilder\Power\Parser; +use VDM\Joomla\Componentbuilder\Power\Plantuml; +use VDM\Joomla\Componentbuilder\Power\Readme\Item as ItemReadme; +use VDM\Joomla\Componentbuilder\Power\Readme\Main as MainReadme; /** @@ -50,8 +54,20 @@ class Power implements ServiceProviderInterface $container->alias(Get::class, 'Power.Remote.Get') ->share('Power.Remote.Get', [$this, 'getRemoteGet'], true); + $container->alias(Set::class, 'Power.Remote.Set') + ->share('Power.Remote.Set', [$this, 'getRemoteSet'], true); + $container->alias(Parser::class, 'Power.Parser') ->share('Power.Parser', [$this, 'getParser'], true); + + $container->alias(Plantuml::class, 'Power.Plantuml') + ->share('Power.Plantuml', [$this, 'getPlantuml'], true); + + $container->alias(ItemReadme::class, 'Power.Readme.Item') + ->share('Power.Readme.Item', [$this, 'getItemReadme'], true); + + $container->alias(MainReadme::class, 'Power.Readme.Main') + ->share('Power.Readme.Main', [$this, 'getMainReadme'], true); } /** @@ -113,6 +129,55 @@ class Power implements ServiceProviderInterface ); } + /** + * Get The Remote Set Class. + * + * @param Container $container The DI container. + * + * @return Set + * @since 5.0.3 + */ + public function getRemoteSet(Container $container): Set + { + return new Set( + $container->get('Config')->approved_paths, + $container->get('Power.Grep'), + $container->get('Data.Items'), + $container->get('Power.Readme.Item'), + $container->get('Power.Readme.Main'), + $container->get('Gitea.Repository.Contents'), null, null, null, + $container->get('Power.Parser') + ); + } + + /** + * Get The Readme Class. + * + * @param Container $container The DI container. + * + * @return ItemReadme + * @since 5.0.3 + */ + public function getItemReadme(Container $container): ItemReadme + { + return new ItemReadme( + $container->get('Power.Plantuml') + ); + } + + /** + * Get The Readme Class. + * + * @param Container $container The DI container. + * + * @return MainReadme + * @since 5.0.3 + */ + public function getMainReadme(Container $container): MainReadme + { + return new MainReadme(); + } + /** * Get The Parser Class. * @@ -124,6 +189,19 @@ class Power implements ServiceProviderInterface public function getParser(Container $container): Parser { return new Parser(); + } + + /** + * Get The Plantuml Class. + * + * @param Container $container The DI container. + * + * @return Plantuml + * @since 5.0.3 + */ + public function getPlantuml(Container $container): Plantuml + { + return new Plantuml(); } } diff --git a/src/02bc072b-1e89-46c1-9732-4da77b1a9ac9/code.power b/src/02bc072b-1e89-46c1-9732-4da77b1a9ac9/code.power index 70906f8..477976b 100644 --- a/src/02bc072b-1e89-46c1-9732-4da77b1a9ac9/code.power +++ b/src/02bc072b-1e89-46c1-9732-4da77b1a9ac9/code.power @@ -20,8 +20,20 @@ $container->alias(Get::class, 'Power.Remote.Get') ->share('Power.Remote.Get', [$this, 'getRemoteGet'], true); + $container->alias(Set::class, 'Power.Remote.Set') + ->share('Power.Remote.Set', [$this, 'getRemoteSet'], true); + $container->alias(Parser::class, 'Power.Parser') ->share('Power.Parser', [$this, 'getParser'], true); + + $container->alias(Plantuml::class, 'Power.Plantuml') + ->share('Power.Plantuml', [$this, 'getPlantuml'], true); + + $container->alias(ItemReadme::class, 'Power.Readme.Item') + ->share('Power.Readme.Item', [$this, 'getItemReadme'], true); + + $container->alias(MainReadme::class, 'Power.Readme.Main') + ->share('Power.Readme.Main', [$this, 'getMainReadme'], true); } /** @@ -83,6 +95,55 @@ ); } + /** + * Get The Remote Set Class. + * + * @param Container $container The DI container. + * + * @return Set + * @since 5.0.3 + */ + public function getRemoteSet(Container $container): Set + { + return new Set( + $container->get('Config')->approved_paths, + $container->get('Power.Grep'), + $container->get('Data.Items'), + $container->get('Power.Readme.Item'), + $container->get('Power.Readme.Main'), + $container->get('Gitea.Repository.Contents'), null, null, null, + $container->get('Power.Parser') + ); + } + + /** + * Get The Readme Class. + * + * @param Container $container The DI container. + * + * @return ItemReadme + * @since 5.0.3 + */ + public function getItemReadme(Container $container): ItemReadme + { + return new ItemReadme( + $container->get('Power.Plantuml') + ); + } + + /** + * Get The Readme Class. + * + * @param Container $container The DI container. + * + * @return MainReadme + * @since 5.0.3 + */ + public function getMainReadme(Container $container): MainReadme + { + return new MainReadme(); + } + /** * Get The Parser Class. * @@ -94,4 +155,17 @@ public function getParser(Container $container): Parser { return new Parser(); + } + + /** + * Get The Plantuml Class. + * + * @param Container $container The DI container. + * + * @return Plantuml + * @since 5.0.3 + */ + public function getPlantuml(Container $container): Plantuml + { + return new Plantuml(); } \ No newline at end of file diff --git a/src/02bc072b-1e89-46c1-9732-4da77b1a9ac9/settings.json b/src/02bc072b-1e89-46c1-9732-4da77b1a9ac9/settings.json index 8144ee2..0d12725 100644 --- a/src/02bc072b-1e89-46c1-9732-4da77b1a9ac9/settings.json +++ b/src/02bc072b-1e89-46c1-9732-4da77b1a9ac9/settings.json @@ -29,8 +29,24 @@ "as": "default" }, "use_selection4": { + "use": "caf559ee-8337-4f07-9e4a-394d4e06afdc", + "as": "default" + }, + "use_selection5": { "use": "95d0e03f-24fd-4412-bc2e-f0899fcc3205", "as": "default" + }, + "use_selection6": { + "use": "ff5e9e63-86d0-4691-ab59-d4b9d9154096", + "as": "default" + }, + "use_selection7": { + "use": "efb1d0f8-2d14-4d2c-8b5f-4fcdd9df45a5", + "as": "ItemReadme" + }, + "use_selection8": { + "use": "0d08c583-04d5-454e-b756-48ca05e1651a", + "as": "MainReadme" } }, "extendsinterfaces": null, diff --git a/src/03b75302-98ba-47ac-859f-1f49b738f66c/README.md b/src/03b75302-98ba-47ac-859f-1f49b738f66c/README.md new file mode 100644 index 0000000..a0506e9 --- /dev/null +++ b/src/03b75302-98ba-47ac-859f-1f49b738f66c/README.md @@ -0,0 +1,156 @@ +``` +██████╗ ██████╗ ██╗ ██╗███████╗██████╗ +██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗ +██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝ +██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗ +██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║ +╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝ +``` +# final class Infusion (Details) +> namespace: **VDM\Joomla\Componentbuilder\Compiler\Joomlaplugin\JoomlaThree** + +```uml +@startuml +class Infusion << (F,LightGreen) >> #RoyalBlue { + # Config $config + # Placeholder $placeholder + # Header $header + # Event $event + # Data $data + # InstallScript $installscript + # Extension $extension + # MainXML $mainxml + # ContentMulti $contentmulti + # FieldsetExtension $fieldsetextension + + __construct(Config $config, Placeholder $placeholder, ...) + + set() : void + # triggerBeforeInfusionEvent(object $plugin) : void + # setPlaceholders(object $plugin) : void + # buildPluginContent(object $plugin) : void + # setExtensionClassHeader(object $plugin) : void + # setExtensionClass(object $plugin) : void + # setInstallClass(object $plugin) : void + # setFieldsets(object $plugin) : void + # setMainXml(object $plugin) : void + # triggerAfterInfusionEvent(object $plugin) : void +} + +note right of Infusion::__construct + Constructor. + + since: 5.0.2 + + arguments: + Config $config + Placeholder $placeholder + Header $header + Event $event + Data $data + InstallScript $installscript + Extension $extension + MainXML $mainxml + ContentMulti $contentmulti + FieldsetExtension $fieldsetextension +end note + +note left of Infusion::set + Infuse the plugin data into the content. +This method processes each plugin in the data set, triggering events +before and after infusion, setting placeholders, and adding content +such as headers, classes, and XML configurations. + + since: 5.0.2 + return: void +end note + +note right of Infusion::triggerBeforeInfusionEvent + Trigger the event before infusing the plugin data. + + since: 5.0.2 + return: void +end note + +note left of Infusion::setPlaceholders + Set placeholders based on plugin data. + + since: 5.0.2 + return: void +end note + +note right of Infusion::buildPluginContent + Build and set the content related to the plugin. + + since: 5.0.2 + return: void +end note + +note left of Infusion::setExtensionClassHeader + Set the extension class header content. + + since: 5.0.2 + return: void +end note + +note right of Infusion::setExtensionClass + Set the extension class content. + + since: 5.0.2 + return: void +end note + +note left of Infusion::setInstallClass + Set the install script content, if needed. + + since: 5.0.2 + return: void +end note + +note right of Infusion::setFieldsets + Set fieldset content based on form files. + + since: 5.0.2 + return: void +end note + +note left of Infusion::setMainXml + Set the main XML content for the plugin. + + since: 5.0.2 + return: void +end note + +note right of Infusion::triggerAfterInfusionEvent + Trigger the event after infusing the plugin data. + + since: 5.0.2 + return: void +end note + +@enduml +``` + +The Power feature in JCB allows you to write PHP classes and their implementations, making it easy to include them in your Joomla project. JCB handles linking, autoloading, namespacing, and folder structure creation for you. + +By using the SPK (Super Power Key) in your custom code (replacing the class name in your code with the SPK), JCB will automatically pull the power from the repository into your project. This makes it available in your JCB instance, allowing you to edit it and include the class in your generated Joomla component. + +JCB uses placeholders like [[[`NamespacePrefix`]]] and [[[`ComponentNamespace`]]] in namespacing to prevent collisions and improve reusability across different JCB systems. You can also set the **JCB powers path** globally or per component under the **Dynamic Integration** tab, providing flexibility and easy maintainability. + +To add this specific Power to your project in JCB: + +> simply use this SPK +``` +Super---03b75302_98ba_47ac_859f_1f49b738f66c---Power +``` +> remember to replace the `---` with `___` to activate this Power in your code + +--- +``` + ██╗ ██████╗██████╗ + ██║██╔════╝██╔══██╗ + ██║██║ ██████╔╝ +██ ██║██║ ██╔══██╗ +╚█████╔╝╚██████╗██████╔╝ + ╚════╝ ╚═════╝╚═════╝ +``` +> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder) + diff --git a/src/03b75302-98ba-47ac-859f-1f49b738f66c/code.php b/src/03b75302-98ba-47ac-859f-1f49b738f66c/code.php new file mode 100644 index 0000000..1f6eb28 --- /dev/null +++ b/src/03b75302-98ba-47ac-859f-1f49b738f66c/code.php @@ -0,0 +1,338 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Componentbuilder\Compiler\Joomlaplugin\JoomlaThree; + + +use VDM\Joomla\Componentbuilder\Compiler\Config; +use VDM\Joomla\Componentbuilder\Compiler\Placeholder; +use VDM\Joomla\Componentbuilder\Compiler\Interfaces\HeaderInterface as Header; +use VDM\Joomla\Componentbuilder\Compiler\Interfaces\EventInterface as Event; +use VDM\Joomla\Componentbuilder\Compiler\Interfaces\PluginDataInterface as Data; +use VDM\Joomla\Componentbuilder\Compiler\Interfaces\GetScriptInterface as InstallScript; +use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Architecture\Plugin\ExtensionInterface as Extension; +use VDM\Joomla\Componentbuilder\Interfaces\Architecture\Plugin\MainXMLInterface as MainXML; +use VDM\Joomla\Componentbuilder\Compiler\Builder\ContentMulti; +use VDM\Joomla\Componentbuilder\Compiler\Creator\FieldsetExtension; +use VDM\Joomla\Utilities\ObjectHelper; +use VDM\Joomla\Utilities\ArrayHelper; +use VDM\Joomla\Componentbuilder\Interfaces\Plugin\InfusionInterface; + + +/** + * Joomla 3 Plugin Infusion Class + * + * @since 5.0.2 + */ +final class Infusion implements InfusionInterface +{ + /** + * The Config Class. + * + * @var Config + * @since 5.0.2 + */ + protected Config $config; + + /** + * The Placeholder Class. + * + * @var Placeholder + * @since 5.0.2 + */ + protected Placeholder $placeholder; + + /** + * The Header Class. + * + * @var Header + * @since 5.0.2 + */ + protected Header $header; + + /** + * The EventInterface Class. + * + * @var Event + * @since 5.0.2 + */ + protected Event $event; + + /** + * The Plugin Data Class. + * + * @var Data + * @since 5.0.2 + */ + protected Data $data; + + /** + * The Get Script Class. + * + * @var InstallScript + * @since 5.0.2 + */ + protected InstallScript $installscript; + + /** + * The Extension Class. + * + * @var Extension + * @since 5.0.2 + */ + protected Extension $extension; + + /** + * The Main XML Class. + * + * @var MainXML + * @since 5.0.2 + */ + protected MainXML $mainxml; + + /** + * The Content Multi Class. + * + * @var ContentMulti + * @since 5.0.2 + */ + protected ContentMulti $contentmulti; + + /** + * The Fieldset Extension Class. + * + * @var FieldsetExtension + * @since 5.0.2 + */ + protected FieldsetExtension $fieldsetextension; + + /** + * Constructor. + * + * @param Config $config The Config Class. + * @param Placeholder $placeholder The Placeholder Class. + * @param Header $header The HeaderInterface Class. + * @param Event $event The EventInterface Class. + * @param Data $data The PluginDataInterface Class. + * @param InstallScript $installscript The GetScriptInterface Class. + * @param Extension $extension The ExtensionInterface Class. + * @param MainXML $mainxml The MainXMLInterface Class. + * @param ContentMulti $contentmulti The ContentMulti Class. + * @param FieldsetExtension $fieldsetextension The FieldsetExtension Class. + * + * @since 5.0.2 + */ + public function __construct(Config $config, Placeholder $placeholder, Header $header, + Event $event, Data $data, InstallScript $installscript, + Extension $extension, MainXML $mainxml, + ContentMulti $contentmulti, + FieldsetExtension $fieldsetextension) + { + $this->config = $config; + $this->placeholder = $placeholder; + $this->header = $header; + $this->event = $event; + $this->data = $data; + $this->installscript = $installscript; + $this->extension = $extension; + $this->mainxml = $mainxml; + $this->contentmulti = $contentmulti; + $this->fieldsetextension = $fieldsetextension; + } + + /** + * Infuse the plugin data into the content. + * + * This method processes each plugin in the data set, triggering events + * before and after infusion, setting placeholders, and adding content + * such as headers, classes, and XML configurations. + * + * @return void + * @since 5.0.2 + */ + public function set(): void + { + if (!$this->data->exists()) + { + return; + } + + foreach ($this->data->get() as $plugin) + { + if (!ObjectHelper::check($plugin)) + { + continue; + } + + $this->triggerBeforeInfusionEvent($plugin); + $this->setPlaceholders($plugin); + $this->buildPluginContent($plugin); + $this->triggerAfterInfusionEvent($plugin); + } + } + + /** + * Trigger the event before infusing the plugin data. + * + * @param object $plugin The plugin object being processed. + * + * @return void + * @since 5.0.2 + */ + protected function triggerBeforeInfusionEvent(&$plugin): void + { + $this->event->trigger('jcb_ce_onBeforeInfusePluginData', [&$plugin]); + } + + /** + * Set placeholders based on plugin data. + * + * @param object $plugin The plugin object being processed. + * + * @return void + * @since 5.0.2 + */ + protected function setPlaceholders($plugin): void + { + $this->placeholder->set('PluginGroupNamespace', $plugin->group_namespace ?? ''); + $this->placeholder->set('PluginNamespace', $plugin->namespace ?? ''); + + $this->config->build_target = $plugin->key; + $this->config->lang_target = $plugin->key; + $this->config->set('lang_prefix', $plugin->lang_prefix); + } + + /** + * Build and set the content related to the plugin. + * + * @param object $plugin The plugin object being processed. + * + * @return void + * @since 5.0.2 + */ + protected function buildPluginContent($plugin): void + { + $this->setExtensionClassHeader($plugin); + $this->setExtensionClass($plugin); + + if ($plugin->add_install_script) + { + $this->setInstallClass($plugin); + } + + if (isset($plugin->form_files) && ArrayHelper::check($plugin->form_files)) + { + $this->setFieldsets($plugin); + } + + $this->setMainXml($plugin); + } + + /** + * Set the extension class header content. + * + * @param object $plugin The plugin object being processed. + * + * @return void + * @since 5.0.2 + */ + protected function setExtensionClassHeader($plugin): void + { + $headerContent = trim( + $this->header->get('plugin.extension.header', $plugin->class_name) + . PHP_EOL . ($plugin->header ?? '') + ); + + $this->contentmulti->set("{$plugin->key}|EXTENSION_CLASS_HEADER", $headerContent); + } + + /** + * Set the extension class content. + * + * @param object $plugin The plugin object being processed. + * + * @return void + * @since 5.0.2 + */ + protected function setExtensionClass($plugin): void + { + $extensionContent = $this->extension->get($plugin); + $this->contentmulti->set("{$plugin->key}|EXTENSION_CLASS", $extensionContent); + } + + /** + * Set the install script content, if needed. + * + * @param object $plugin The plugin object being processed. + * + * @return void + * @since 5.0.2 + */ + protected function setInstallClass($plugin): void + { + $installContent = $this->installscript->get($plugin); + $this->contentmulti->set("{$plugin->key}|INSTALL_CLASS", $installContent); + } + + /** + * Set fieldset content based on form files. + * + * @param object $plugin The plugin object being processed. + * + * @return void + * @since 5.0.2 + */ + protected function setFieldsets($plugin): void + { + foreach ($plugin->form_files as $file => $files) + { + foreach ($files as $field_name => $fieldsets) + { + foreach ($fieldsets as $fieldset => $fields) + { + $fieldsetContent = $this->fieldsetextension->get($plugin, $fields); + $this->contentmulti->set( + "{$plugin->key}|FIELDSET_{$file}{$field_name}{$fieldset}", + $fieldsetContent + ); + } + } + } + } + + /** + * Set the main XML content for the plugin. + * + * @param object $plugin The plugin object being processed. + * + * @return void + * @since 5.0.2 + */ + protected function setMainXml($plugin): void + { + $mainXmlContent = $this->mainxml->get($plugin); + $this->contentmulti->set("{$plugin->key}|MAINXML", $mainXmlContent); + } + + /** + * Trigger the event after infusing the plugin data. + * + * @param object $plugin The plugin object being processed. + * + * @return void + * @since 5.0.2 + */ + protected function triggerAfterInfusionEvent(&$plugin): void + { + $this->event->trigger('jcb_ce_onAfterInfusePluginData', [&$plugin]); + } +} + diff --git a/src/03b75302-98ba-47ac-859f-1f49b738f66c/code.power b/src/03b75302-98ba-47ac-859f-1f49b738f66c/code.power new file mode 100644 index 0000000..1f19ffc --- /dev/null +++ b/src/03b75302-98ba-47ac-859f-1f49b738f66c/code.power @@ -0,0 +1,300 @@ + /** + * The Config Class. + * + * @var Config + * @since 5.0.2 + */ + protected Config $config; + + /** + * The Placeholder Class. + * + * @var Placeholder + * @since 5.0.2 + */ + protected Placeholder $placeholder; + + /** + * The Header Class. + * + * @var Header + * @since 5.0.2 + */ + protected Header $header; + + /** + * The EventInterface Class. + * + * @var Event + * @since 5.0.2 + */ + protected Event $event; + + /** + * The Plugin Data Class. + * + * @var Data + * @since 5.0.2 + */ + protected Data $data; + + /** + * The Get Script Class. + * + * @var InstallScript + * @since 5.0.2 + */ + protected InstallScript $installscript; + + /** + * The Extension Class. + * + * @var Extension + * @since 5.0.2 + */ + protected Extension $extension; + + /** + * The Main XML Class. + * + * @var MainXML + * @since 5.0.2 + */ + protected MainXML $mainxml; + + /** + * The Content Multi Class. + * + * @var ContentMulti + * @since 5.0.2 + */ + protected ContentMulti $contentmulti; + + /** + * The Fieldset Extension Class. + * + * @var FieldsetExtension + * @since 5.0.2 + */ + protected FieldsetExtension $fieldsetextension; + + /** + * Constructor. + * + * @param Config $config The Config Class. + * @param Placeholder $placeholder The Placeholder Class. + * @param Header $header The HeaderInterface Class. + * @param Event $event The EventInterface Class. + * @param Data $data The PluginDataInterface Class. + * @param InstallScript $installscript The GetScriptInterface Class. + * @param Extension $extension The ExtensionInterface Class. + * @param MainXML $mainxml The MainXMLInterface Class. + * @param ContentMulti $contentmulti The ContentMulti Class. + * @param FieldsetExtension $fieldsetextension The FieldsetExtension Class. + * + * @since 5.0.2 + */ + public function __construct(Config $config, Placeholder $placeholder, Header $header, + Event $event, Data $data, InstallScript $installscript, + Extension $extension, MainXML $mainxml, + ContentMulti $contentmulti, + FieldsetExtension $fieldsetextension) + { + $this->config = $config; + $this->placeholder = $placeholder; + $this->header = $header; + $this->event = $event; + $this->data = $data; + $this->installscript = $installscript; + $this->extension = $extension; + $this->mainxml = $mainxml; + $this->contentmulti = $contentmulti; + $this->fieldsetextension = $fieldsetextension; + } + + /** + * Infuse the plugin data into the content. + * + * This method processes each plugin in the data set, triggering events + * before and after infusion, setting placeholders, and adding content + * such as headers, classes, and XML configurations. + * + * @return void + * @since 5.0.2 + */ + public function set(): void + { + if (!$this->data->exists()) + { + return; + } + + foreach ($this->data->get() as $plugin) + { + if (!ObjectHelper::check($plugin)) + { + continue; + } + + $this->triggerBeforeInfusionEvent($plugin); + $this->setPlaceholders($plugin); + $this->buildPluginContent($plugin); + $this->triggerAfterInfusionEvent($plugin); + } + } + + /** + * Trigger the event before infusing the plugin data. + * + * @param object $plugin The plugin object being processed. + * + * @return void + * @since 5.0.2 + */ + protected function triggerBeforeInfusionEvent(&$plugin): void + { + $this->event->trigger('jcb_ce_onBeforeInfusePluginData', [&$plugin]); + } + + /** + * Set placeholders based on plugin data. + * + * @param object $plugin The plugin object being processed. + * + * @return void + * @since 5.0.2 + */ + protected function setPlaceholders($plugin): void + { + $this->placeholder->set('PluginGroupNamespace', $plugin->group_namespace ?? ''); + $this->placeholder->set('PluginNamespace', $plugin->namespace ?? ''); + + $this->config->build_target = $plugin->key; + $this->config->lang_target = $plugin->key; + $this->config->set('lang_prefix', $plugin->lang_prefix); + } + + /** + * Build and set the content related to the plugin. + * + * @param object $plugin The plugin object being processed. + * + * @return void + * @since 5.0.2 + */ + protected function buildPluginContent($plugin): void + { + $this->setExtensionClassHeader($plugin); + $this->setExtensionClass($plugin); + + if ($plugin->add_install_script) + { + $this->setInstallClass($plugin); + } + + if (isset($plugin->form_files) && ArrayHelper::check($plugin->form_files)) + { + $this->setFieldsets($plugin); + } + + $this->setMainXml($plugin); + } + + /** + * Set the extension class header content. + * + * @param object $plugin The plugin object being processed. + * + * @return void + * @since 5.0.2 + */ + protected function setExtensionClassHeader($plugin): void + { + $headerContent = trim( + $this->header->get('plugin.extension.header', $plugin->class_name) + . PHP_EOL . ($plugin->header ?? '') + ); + + $this->contentmulti->set("{$plugin->key}|EXTENSION_CLASS_HEADER", $headerContent); + } + + /** + * Set the extension class content. + * + * @param object $plugin The plugin object being processed. + * + * @return void + * @since 5.0.2 + */ + protected function setExtensionClass($plugin): void + { + $extensionContent = $this->extension->get($plugin); + $this->contentmulti->set("{$plugin->key}|EXTENSION_CLASS", $extensionContent); + } + + /** + * Set the install script content, if needed. + * + * @param object $plugin The plugin object being processed. + * + * @return void + * @since 5.0.2 + */ + protected function setInstallClass($plugin): void + { + $installContent = $this->installscript->get($plugin); + $this->contentmulti->set("{$plugin->key}|INSTALL_CLASS", $installContent); + } + + /** + * Set fieldset content based on form files. + * + * @param object $plugin The plugin object being processed. + * + * @return void + * @since 5.0.2 + */ + protected function setFieldsets($plugin): void + { + foreach ($plugin->form_files as $file => $files) + { + foreach ($files as $field_name => $fieldsets) + { + foreach ($fieldsets as $fieldset => $fields) + { + $fieldsetContent = $this->fieldsetextension->get($plugin, $fields); + $this->contentmulti->set( + "{$plugin->key}|FIELDSET_{$file}{$field_name}{$fieldset}", + $fieldsetContent + ); + } + } + } + } + + /** + * Set the main XML content for the plugin. + * + * @param object $plugin The plugin object being processed. + * + * @return void + * @since 5.0.2 + */ + protected function setMainXml($plugin): void + { + $mainXmlContent = $this->mainxml->get($plugin); + $this->contentmulti->set("{$plugin->key}|MAINXML", $mainXmlContent); + } + + /** + * Trigger the event after infusing the plugin data. + * + * @param object $plugin The plugin object being processed. + * + * @return void + * @since 5.0.2 + */ + protected function triggerAfterInfusionEvent(&$plugin): void + { + $this->event->trigger('jcb_ce_onAfterInfusePluginData', [&$plugin]); + } \ No newline at end of file diff --git a/src/03b75302-98ba-47ac-859f-1f49b738f66c/settings.json b/src/03b75302-98ba-47ac-859f-1f49b738f66c/settings.json new file mode 100644 index 0000000..183d39c --- /dev/null +++ b/src/03b75302-98ba-47ac-859f-1f49b738f66c/settings.json @@ -0,0 +1,70 @@ +{ + "add_head": "0", + "add_licensing_template": "2", + "extends": "", + "guid": "03b75302-98ba-47ac-859f-1f49b738f66c", + "implements": [ + "40e17114-2193-4a61-9233-47b5f4193665" + ], + "load_selection": null, + "name": "Infusion", + "power_version": "1.0.0", + "system_name": "JCB.Compiler.Joomlaplugin.J3.Infusion", + "type": "final class", + "use_selection": { + "use_selection0": { + "use": "fa4bf18e-301e-42e3-91fb-6e0096c07adc", + "as": "default" + }, + "use_selection1": { + "use": "06453ada-e370-49f0-b262-e3f5a8ed0c2c", + "as": "default" + }, + "use_selection2": { + "use": "3a777d70-52ad-49ec-9016-6f7438608613", + "as": "Header" + }, + "use_selection3": { + "use": "20ed72b0-fcac-4344-aee1-8a65e3bf221d", + "as": "Event" + }, + "use_selection4": { + "use": "8cc85656-a925-4a46-a49b-83c72167fd6a", + "as": "Data" + }, + "use_selection5": { + "use": "2e6731ba-3a03-4836-b2c2-4e50e38cb890", + "as": "InstallScript" + }, + "use_selection6": { + "use": "914db7f5-82d8-4d3b-a1c1-eb476b1898c2", + "as": "Extension" + }, + "use_selection7": { + "use": "97177ca9-a51a-4d24-81e1-8747b6e7d76c", + "as": "MainXML" + }, + "use_selection8": { + "use": "5f57ff1a-c196-45b1-a2ac-33766b44fb95", + "as": "default" + }, + "use_selection9": { + "use": "23f459a4-7c2a-4cbf-b0a6-8a11954140a9", + "as": "default" + }, + "use_selection10": { + "use": "91004529-94a9-4590-b842-e7c6b624ecf5", + "as": "default" + }, + "use_selection11": { + "use": "0a59c65c-9daf-4bc9-baf4-e063ff9e6a8a", + "as": "default" + } + }, + "extendsinterfaces": null, + "namespace": "[[[NamespacePrefix]]]\\Joomla\\[[[ComponentNamespace]]].Compiler.Joomlaplugin.JoomlaThree.Infusion", + "description": "Joomla 3 Plugin Infusion Class\r\n\r\n@since 5.0.2", + "licensing_template": "\/**\r\n * @package Joomla.Component.Builder\r\n *\r\n * @created 4th September, 2022\r\n * @author Llewellyn van der Merwe \r\n * @git Joomla Component Builder \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/0419081e-4cb3-4c65-8c6a-ffe941fb0f1c/README.md b/src/0419081e-4cb3-4c65-8c6a-ffe941fb0f1c/README.md index 4974e33..d905a3a 100644 --- a/src/0419081e-4cb3-4c65-8c6a-ffe941fb0f1c/README.md +++ b/src/0419081e-4cb3-4c65-8c6a-ffe941fb0f1c/README.md @@ -6,12 +6,12 @@ ██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║ ╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝ ``` -# class Infusion (Details) +# final class Infusion (Details) > namespace: **VDM\Joomla\Componentbuilder\Compiler\Power** ```uml @startuml -class Infusion #Gold { +class Infusion << (F,LightGreen) >> #RoyalBlue { # Config $config # Power $power # Content $content diff --git a/src/0419081e-4cb3-4c65-8c6a-ffe941fb0f1c/code.php b/src/0419081e-4cb3-4c65-8c6a-ffe941fb0f1c/code.php index b0b9248..e47164e 100644 --- a/src/0419081e-4cb3-4c65-8c6a-ffe941fb0f1c/code.php +++ b/src/0419081e-4cb3-4c65-8c6a-ffe941fb0f1c/code.php @@ -30,7 +30,7 @@ use VDM\Joomla\Utilities\ObjectHelper; * Compiler Power Infusion * @since 3.2.0 */ -class Infusion +final class Infusion { /** * The Config Class. diff --git a/src/0419081e-4cb3-4c65-8c6a-ffe941fb0f1c/settings.json b/src/0419081e-4cb3-4c65-8c6a-ffe941fb0f1c/settings.json index be3fb89..c719bdf 100644 --- a/src/0419081e-4cb3-4c65-8c6a-ffe941fb0f1c/settings.json +++ b/src/0419081e-4cb3-4c65-8c6a-ffe941fb0f1c/settings.json @@ -8,7 +8,7 @@ "name": "Infusion", "power_version": "1.0.0", "system_name": "JCB.Compiler.Power.Infusion", - "type": "class", + "type": "final class", "use_selection": { "use_selection0": { "use": "fa4bf18e-301e-42e3-91fb-6e0096c07adc", diff --git a/src/058cfcd7-1f84-4cc6-8bcc-7672f316881d/README.md b/src/058cfcd7-1f84-4cc6-8bcc-7672f316881d/README.md new file mode 100644 index 0000000..f9bacf0 --- /dev/null +++ b/src/058cfcd7-1f84-4cc6-8bcc-7672f316881d/README.md @@ -0,0 +1,129 @@ +``` +██████╗ ██████╗ ██╗ ██╗███████╗██████╗ +██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗ +██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝ +██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗ +██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║ +╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝ +``` +# final class Set (Details) +> namespace: **VDM\Joomla\Componentbuilder\Compiler\Language** + +```uml +@startuml +class Set << (F,LightGreen) >> #RoyalBlue { + # Config $config + # Language $language + # Multilingual $multilingual + # Languages $languages + # Insert $insert + # Update $update + + __construct(Config $config, Language $language, ...) + + execute(array $strings, int $target_id, ...) : void + # processString(string $string, array $strings, ...) : void + # updateOrInsertString(string $string, $multiLangString, ...) : void + # getTargets(array $multiLangString, string $target, ...) : array +} + +note right of Set::__construct + Constructor. + + since: 5.0.2 + + arguments: + Config $config + Language $language + Multilingual $multilingual + Languages $languages + Insert $insert + Update $update +end note + +note right of Set::execute + Set the current language values to the database. +This method inserts or updates language strings in the database based on the current state. + + since: 5.0.2 + return: void + + arguments: + array $strings + int $target_id + string $target = 'components' +end note + +note right of Set::processString + Process an individual language string for database update or insert. + + since: 5.0.2 + return: void + + arguments: + string $string + array $strings + string $area + string $placeholder + $multiLangString + string $target + int $target_id + string $today + $counterInsert + $counterUpdate +end note + +note right of Set::updateOrInsertString + Update or insert a language string in the database. + + since: 5.0.2 + return: void + + arguments: + string $string + $multiLangString + string $target + int $target_id + string $today + $counterInsert + $counterUpdate +end note + +note right of Set::getTargets + Get targets for a given string. + + since: 5.0.2 + return: array + + arguments: + array $multiLangString + string $target + int $target_id +end note + +@enduml +``` + +The Power feature in JCB allows you to write PHP classes and their implementations, making it easy to include them in your Joomla project. JCB handles linking, autoloading, namespacing, and folder structure creation for you. + +By using the SPK (Super Power Key) in your custom code (replacing the class name in your code with the SPK), JCB will automatically pull the power from the repository into your project. This makes it available in your JCB instance, allowing you to edit it and include the class in your generated Joomla component. + +JCB uses placeholders like [[[`NamespacePrefix`]]] and [[[`ComponentNamespace`]]] in namespacing to prevent collisions and improve reusability across different JCB systems. You can also set the **JCB powers path** globally or per component under the **Dynamic Integration** tab, providing flexibility and easy maintainability. + +To add this specific Power to your project in JCB: + +> simply use this SPK +``` +Super---058cfcd7_1f84_4cc6_8bcc_7672f316881d---Power +``` +> remember to replace the `---` with `___` to activate this Power in your code + +--- +``` + ██╗ ██████╗██████╗ + ██║██╔════╝██╔══██╗ + ██║██║ ██████╔╝ +██ ██║██║ ██╔══██╗ +╚█████╔╝╚██████╗██████╔╝ + ╚════╝ ╚═════╝╚═════╝ +``` +> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder) + diff --git a/src/058cfcd7-1f84-4cc6-8bcc-7672f316881d/code.php b/src/058cfcd7-1f84-4cc6-8bcc-7672f316881d/code.php new file mode 100644 index 0000000..959c57d --- /dev/null +++ b/src/058cfcd7-1f84-4cc6-8bcc-7672f316881d/code.php @@ -0,0 +1,277 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Componentbuilder\Compiler\Language; + + +use Joomla\CMS\Factory; +use VDM\Joomla\Componentbuilder\Compiler\Config; +use VDM\Joomla\Componentbuilder\Compiler\Language; +use VDM\Joomla\Componentbuilder\Compiler\Builder\Multilingual; +use VDM\Joomla\Componentbuilder\Compiler\Builder\Languages; +use VDM\Joomla\Componentbuilder\Compiler\Language\Insert; +use VDM\Joomla\Componentbuilder\Compiler\Language\Update; +use VDM\Joomla\Utilities\StringHelper; +use VDM\Joomla\Utilities\JsonHelper; +use VDM\Joomla\Utilities\ArrayHelper; +use VDM\Joomla\Utilities\MathHelper; + + +/** + * Compiler Set Language Strings + * + * @since 5.0.2 + */ +final class Set +{ + /** + * The Config Class. + * + * @var Config + * @since 5.0.2 + */ + protected Config $config; + + /** + * The Language Class. + * + * @var Language + * @since 5.0.2 + */ + protected Language $language; + + /** + * The Multilingual Class. + * + * @var Multilingual + * @since 5.0.2 + */ + protected Multilingual $multilingual; + + /** + * The Languages Class. + * + * @var Languages + * @since 5.0.2 + */ + protected Languages $languages; + + /** + * The Insert Class. + * + * @var Insert + * @since 5.0.2 + */ + protected Insert $insert; + + /** + * The Update Class. + * + * @var Update + * @since 5.0.2 + */ + protected Update $update; + + /** + * Constructor. + * + * @param Config $config The Config Class. + * @param Language $language The Language Class. + * @param Messages $messages The Language Messages Class. + * @param Multilingual $multilingual The Multilingual Class. + * @param Languages $languages The Languages Class. + * @param Insert $insert The Insert Class. + * @param Update $update The Update Class. + * + * @since 5.0.2 + */ + public function __construct(Config $config, Language $language, + Multilingual $multilingual, Languages $languages, + Insert $insert, Update $update) + { + $this->config = $config; + $this->language = $language; + $this->multilingual = $multilingual; + $this->languages = $languages; + $this->insert = $insert; + $this->update = $update; + } + + /** + * Set the current language values to the database. + * + * This method inserts or updates language strings in the database based on the current state. + * + * @param array $strings The language strings to process. + * @param int $target_id The target component ID. + * @param string $target The target extension type (default is 'components'). + * + * @return void + * @since 5.0.2 + */ + public function execute(array $strings, int $target_id, string $target = 'components'): void + { + $counterInsert = 0; + $counterUpdate = 0; + $today = Factory::getDate()->toSql(); + $langTag = $this->config->get('lang_tag', 'en-GB'); + $multiLangString = $this->multilingual->get($target, []); + + foreach ($this->languages->get("{$target}.{$langTag}") as $area => $placeholders) + { + foreach ($placeholders as $placeholder => $string) + { + if (StringHelper::check($string)) + { + $this->processString( + $string, $strings, $area, $placeholder, $multiLangString, $target, $target_id, $today, $counterInsert, $counterUpdate + ); + } + } + } + + $this->multilingual->set($target, $multiLangString); + $this->update->execute(); + $this->insert->execute($target); + } + + /** + * Process an individual language string for database update or insert. + * + * @param string $string The language string to process. + * @param array $strings The language strings array. + * @param string $area The targeted area. + * @param string $placeholder The placeholder. + * @param array &$multiLangString The multilingual string array. + * @param string $target The target extension type. + * @param int $target_id The target component ID. + * @param string $today The current date. + * @param int &$counterInsert The insert counter. + * @param int &$counterUpdate The update counter. + * + * @return void + * @since 5.0.2 + */ + protected function processString(string $string, array &$strings, string $area, + string $placeholder, array &$multiLangString, string $target, + int $target_id, string $today, int &$counterInsert, int &$counterUpdate): void + { + $remove = false; + + if (isset($multiLangString[$string])) + { + if (isset($multiLangString[$string]['translation']) && JsonHelper::check($multiLangString[$string]['translation'])) + { + $multiLangString[$string]['translation'] = json_decode((string) $multiLangString[$string]['translation'], true); + } + + if (isset($multiLangString[$string]['translation']) && ArrayHelper::check($multiLangString[$string]['translation'])) + { + foreach ($multiLangString[$string]['translation'] as $translations) + { + if (isset($translations['language']) && isset($translations['translation'])) + { + $multiLangTag = $translations['language']; + $this->languages->set("{$target}.{$multiLangTag}.{$area}.{$placeholder}", $this->language->fix($translations['translation'])); + } + } + } + else + { + $remove = true; + } + } + + if (StringHelper::check($string) && ($key = array_search($string, $strings)) !== false) + { + $this->updateOrInsertString($string, $multiLangString, $target, $target_id, $today, $counterInsert, $counterUpdate); + + if ($remove) + { + unset($multiLangString[$string]); + } + + unset($strings[$key]); + } + } + + /** + * Update or insert a language string in the database. + * + * @param string $string The language string to update or insert. + * @param array &$multiLangString The multilingual string array. + * @param string $target The target extension type. + * @param int $target_id The target component ID. + * @param string $today The current date. + * @param int &$counterInsert The insert counter. + * @param int &$counterUpdate The update counter. + * + * @return void + * @since 5.0.2 + */ + protected function updateOrInsertString(string $string, array &$multiLangString, string $target, int $target_id, string $today, int &$counterInsert, int &$counterUpdate): void + { + if (isset($multiLangString[$string])) + { + $id = $multiLangString[$string]['id']; + $targets = $this->getTargets($multiLangString[$string], $target, $target_id); + + $this->update->set($id, $target, $targets, 1, $today, $counterUpdate); + + $counterUpdate++; + + $this->update->execute(50); + } + else + { + $this->insert->set($target, $counterInsert, json_encode([$target_id])); + $this->insert->set($target, $counterInsert, $string); + $this->insert->set($target, $counterInsert, 1); + $this->insert->set($target, $counterInsert, $today); + $this->insert->set($target, $counterInsert, 1); + $this->insert->set($target, $counterInsert, 1); + $this->insert->set($target, $counterInsert, 1); + + $counterInsert++; + + $this->insert->execute($target, 100); + } + } + + /** + * Get targets for a given string. + * + * @param array $multiLangString The multilingual string array. + * @param string $target The target extension type. + * @param int $target_id The target component ID. + * + * @return array The updated targets array. + * @since 5.0.2 + */ + protected function getTargets(array $multiLangString, string $target, int $target_id): array + { + if (JsonHelper::check($multiLangString[$target])) + { + $targets = (array) json_decode((string) $multiLangString[$target], true); + if (!in_array($target_id, $targets)) + { + $targets[] = $target_id; + } + } + else + { + $targets = [$target_id]; + } + + return $targets; + } +} + diff --git a/src/058cfcd7-1f84-4cc6-8bcc-7672f316881d/code.power b/src/058cfcd7-1f84-4cc6-8bcc-7672f316881d/code.power new file mode 100644 index 0000000..4fe9e47 --- /dev/null +++ b/src/058cfcd7-1f84-4cc6-8bcc-7672f316881d/code.power @@ -0,0 +1,241 @@ + /** + * The Config Class. + * + * @var Config + * @since 5.0.2 + */ + protected Config $config; + + /** + * The Language Class. + * + * @var Language + * @since 5.0.2 + */ + protected Language $language; + + /** + * The Multilingual Class. + * + * @var Multilingual + * @since 5.0.2 + */ + protected Multilingual $multilingual; + + /** + * The Languages Class. + * + * @var Languages + * @since 5.0.2 + */ + protected Languages $languages; + + /** + * The Insert Class. + * + * @var Insert + * @since 5.0.2 + */ + protected Insert $insert; + + /** + * The Update Class. + * + * @var Update + * @since 5.0.2 + */ + protected Update $update; + + /** + * Constructor. + * + * @param Config $config The Config Class. + * @param Language $language The Language Class. + * @param Messages $messages The Language Messages Class. + * @param Multilingual $multilingual The Multilingual Class. + * @param Languages $languages The Languages Class. + * @param Insert $insert The Insert Class. + * @param Update $update The Update Class. + * + * @since 5.0.2 + */ + public function __construct(Config $config, Language $language, + Multilingual $multilingual, Languages $languages, + Insert $insert, Update $update) + { + $this->config = $config; + $this->language = $language; + $this->multilingual = $multilingual; + $this->languages = $languages; + $this->insert = $insert; + $this->update = $update; + } + + /** + * Set the current language values to the database. + * + * This method inserts or updates language strings in the database based on the current state. + * + * @param array $strings The language strings to process. + * @param int $target_id The target component ID. + * @param string $target The target extension type (default is 'components'). + * + * @return void + * @since 5.0.2 + */ + public function execute(array $strings, int $target_id, string $target = 'components'): void + { + $counterInsert = 0; + $counterUpdate = 0; + $today = Factory::getDate()->toSql(); + $langTag = $this->config->get('lang_tag', 'en-GB'); + $multiLangString = $this->multilingual->get($target, []); + + foreach ($this->languages->get("{$target}.{$langTag}") as $area => $placeholders) + { + foreach ($placeholders as $placeholder => $string) + { + if (StringHelper::check($string)) + { + $this->processString( + $string, $strings, $area, $placeholder, $multiLangString, $target, $target_id, $today, $counterInsert, $counterUpdate + ); + } + } + } + + $this->multilingual->set($target, $multiLangString); + $this->update->execute(); + $this->insert->execute($target); + } + + /** + * Process an individual language string for database update or insert. + * + * @param string $string The language string to process. + * @param array $strings The language strings array. + * @param string $area The targeted area. + * @param string $placeholder The placeholder. + * @param array &$multiLangString The multilingual string array. + * @param string $target The target extension type. + * @param int $target_id The target component ID. + * @param string $today The current date. + * @param int &$counterInsert The insert counter. + * @param int &$counterUpdate The update counter. + * + * @return void + * @since 5.0.2 + */ + protected function processString(string $string, array &$strings, string $area, + string $placeholder, array &$multiLangString, string $target, + int $target_id, string $today, int &$counterInsert, int &$counterUpdate): void + { + $remove = false; + + if (isset($multiLangString[$string])) + { + if (isset($multiLangString[$string]['translation']) && JsonHelper::check($multiLangString[$string]['translation'])) + { + $multiLangString[$string]['translation'] = json_decode((string) $multiLangString[$string]['translation'], true); + } + + if (isset($multiLangString[$string]['translation']) && ArrayHelper::check($multiLangString[$string]['translation'])) + { + foreach ($multiLangString[$string]['translation'] as $translations) + { + if (isset($translations['language']) && isset($translations['translation'])) + { + $multiLangTag = $translations['language']; + $this->languages->set("{$target}.{$multiLangTag}.{$area}.{$placeholder}", $this->language->fix($translations['translation'])); + } + } + } + else + { + $remove = true; + } + } + + if (StringHelper::check($string) && ($key = array_search($string, $strings)) !== false) + { + $this->updateOrInsertString($string, $multiLangString, $target, $target_id, $today, $counterInsert, $counterUpdate); + + if ($remove) + { + unset($multiLangString[$string]); + } + + unset($strings[$key]); + } + } + + /** + * Update or insert a language string in the database. + * + * @param string $string The language string to update or insert. + * @param array &$multiLangString The multilingual string array. + * @param string $target The target extension type. + * @param int $target_id The target component ID. + * @param string $today The current date. + * @param int &$counterInsert The insert counter. + * @param int &$counterUpdate The update counter. + * + * @return void + * @since 5.0.2 + */ + protected function updateOrInsertString(string $string, array &$multiLangString, string $target, int $target_id, string $today, int &$counterInsert, int &$counterUpdate): void + { + if (isset($multiLangString[$string])) + { + $id = $multiLangString[$string]['id']; + $targets = $this->getTargets($multiLangString[$string], $target, $target_id); + + $this->update->set($id, $target, $targets, 1, $today, $counterUpdate); + + $counterUpdate++; + + $this->update->execute(50); + } + else + { + $this->insert->set($target, $counterInsert, json_encode([$target_id])); + $this->insert->set($target, $counterInsert, $string); + $this->insert->set($target, $counterInsert, 1); + $this->insert->set($target, $counterInsert, $today); + $this->insert->set($target, $counterInsert, 1); + $this->insert->set($target, $counterInsert, 1); + $this->insert->set($target, $counterInsert, 1); + + $counterInsert++; + + $this->insert->execute($target, 100); + } + } + + /** + * Get targets for a given string. + * + * @param array $multiLangString The multilingual string array. + * @param string $target The target extension type. + * @param int $target_id The target component ID. + * + * @return array The updated targets array. + * @since 5.0.2 + */ + protected function getTargets(array $multiLangString, string $target, int $target_id): array + { + if (JsonHelper::check($multiLangString[$target])) + { + $targets = (array) json_decode((string) $multiLangString[$target], true); + if (!in_array($target_id, $targets)) + { + $targets[] = $target_id; + } + } + else + { + $targets = [$target_id]; + } + + return $targets; + } \ No newline at end of file diff --git a/src/058cfcd7-1f84-4cc6-8bcc-7672f316881d/settings.json b/src/058cfcd7-1f84-4cc6-8bcc-7672f316881d/settings.json new file mode 100644 index 0000000..8a31c14 --- /dev/null +++ b/src/058cfcd7-1f84-4cc6-8bcc-7672f316881d/settings.json @@ -0,0 +1,60 @@ +{ + "add_head": "1", + "add_licensing_template": "2", + "extends": "", + "guid": "058cfcd7-1f84-4cc6-8bcc-7672f316881d", + "implements": null, + "load_selection": null, + "name": "Set", + "power_version": "1.0.0", + "system_name": "JCB.Compiler.Language.Set", + "type": "final class", + "use_selection": { + "use_selection0": { + "use": "fa4bf18e-301e-42e3-91fb-6e0096c07adc", + "as": "default" + }, + "use_selection1": { + "use": "8eee7df5-2775-41a9-9372-c46c5939a252", + "as": "default" + }, + "use_selection3": { + "use": "a8c6158a-6fd2-476b-a5ea-c81f1ecd2356", + "as": "default" + }, + "use_selection4": { + "use": "7526a39a-ada3-4499-8d75-81beff33f949", + "as": "default" + }, + "use_selection5": { + "use": "1d051a2f-0691-45a8-b3d9-d0c1adcd73bc", + "as": "default" + }, + "use_selection6": { + "use": "375543cd-5f2a-4893-982e-a73eaa55360d", + "as": "default" + }, + "use_selection7": { + "use": "1f28cb53-60d9-4db1-b517-3c7dc6b429ef", + "as": "default" + }, + "use_selection8": { + "use": "4b225c51-d293-48e4-b3f6-5136cf5c3f18", + "as": "default" + }, + "use_selection9": { + "use": "0a59c65c-9daf-4bc9-baf4-e063ff9e6a8a", + "as": "default" + }, + "use_selection10": { + "use": "152c8793-8b75-4715-996a-257b9f65451c", + "as": "default" + } + }, + "extendsinterfaces": null, + "namespace": "[[[NamespacePrefix]]]\\Joomla\\[[[ComponentNamespace]]].Compiler.Language.Set", + "description": "Compiler Set Language Strings\r\n\r\n@since 5.0.2", + "licensing_template": "\/**\r\n * @package Joomla.Component.Builder\r\n *\r\n * @created 4th September, 2022\r\n * @author Llewellyn van der Merwe \r\n * @git Joomla Component Builder \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;", + "composer": "" +} \ No newline at end of file diff --git a/src/0b0e574c-aab4-4eaf-96d8-d7210d8ed93e/README.md b/src/0b0e574c-aab4-4eaf-96d8-d7210d8ed93e/README.md new file mode 100644 index 0000000..663995c --- /dev/null +++ b/src/0b0e574c-aab4-4eaf-96d8-d7210d8ed93e/README.md @@ -0,0 +1,96 @@ +``` +██████╗ ██████╗ ██╗ ██╗███████╗██████╗ +██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗ +██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝ +██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗ +██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║ +╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝ +``` +# final class Purge (Details) +> namespace: **VDM\Joomla\Componentbuilder\Compiler\Language** + +```uml +@startuml +class Purge << (F,LightGreen) >> #RoyalBlue { + # Update $update + # $db + + __construct(Update $update) + + execute(array $values, int $targetId, ...) : void + # handleUnlinkedString(array $item, array $targetTypes, ...) : void + # removeExitingLangString(int $id) : void +} + +note right of Purge::__construct + Constructor. + + since: 5.0.2 +end note + +note right of Purge::execute + Purge the unused language strings. +This method removes or updates language strings that are no longer linked +to the specified component. It checks if the strings are linked to other +extensions and either updates, archives, or deletes them based on the +conditions. + + since: 5.0.2 + return: void + + arguments: + array $values + int $targetId + string $target = 'components' +end note + +note right of Purge::handleUnlinkedString + Handle strings that are unlinked from the current component. +This method checks if a string is linked to other extensions and either updates, +archives, or deletes it based on the conditions. + + since: 5.0.2 + return: void + + arguments: + array $item + array $targetTypes + array $targets + string $today + int $counter +end note + +note right of Purge::removeExitingLangString + Remove existing language translation strings. +This method deletes a language string from the database based on its ID. + + since: 5.0.2 + return: void +end note + +@enduml +``` + +The Power feature in JCB allows you to write PHP classes and their implementations, making it easy to include them in your Joomla project. JCB handles linking, autoloading, namespacing, and folder structure creation for you. + +By using the SPK (Super Power Key) in your custom code (replacing the class name in your code with the SPK), JCB will automatically pull the power from the repository into your project. This makes it available in your JCB instance, allowing you to edit it and include the class in your generated Joomla component. + +JCB uses placeholders like [[[`NamespacePrefix`]]] and [[[`ComponentNamespace`]]] in namespacing to prevent collisions and improve reusability across different JCB systems. You can also set the **JCB powers path** globally or per component under the **Dynamic Integration** tab, providing flexibility and easy maintainability. + +To add this specific Power to your project in JCB: + +> simply use this SPK +``` +Super---0b0e574c_aab4_4eaf_96d8_d7210d8ed93e---Power +``` +> remember to replace the `---` with `___` to activate this Power in your code + +--- +``` + ██╗ ██████╗██████╗ + ██║██╔════╝██╔══██╗ + ██║██║ ██████╔╝ +██ ██║██║ ██╔══██╗ +╚█████╔╝╚██████╗██████╔╝ + ╚════╝ ╚═════╝╚═════╝ +``` +> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder) + diff --git a/src/0b0e574c-aab4-4eaf-96d8-d7210d8ed93e/code.php b/src/0b0e574c-aab4-4eaf-96d8-d7210d8ed93e/code.php new file mode 100644 index 0000000..cead24f --- /dev/null +++ b/src/0b0e574c-aab4-4eaf-96d8-d7210d8ed93e/code.php @@ -0,0 +1,198 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Componentbuilder\Compiler\Language; + + +use Joomla\CMS\Factory; +use VDM\Joomla\Componentbuilder\Compiler\Language\Update; +use VDM\Joomla\Utilities\JsonHelper; +use VDM\Joomla\Utilities\ArrayHelper; + + +/** + * Compiler Remove Existing Language Strings + * + * @since 5.0.2 + */ +final class Purge +{ + /** + * The Update Class. + * + * @var Update + * @since 5.0.2 + */ + protected Update $update; + + /** + * Database object to query local DB + * + * @since 5.0.2 + **/ + protected $db; + + /** + * Constructor. + * + * @param Update $update The Update Class. + * + * @since 5.0.2 + */ + public function __construct(Update $update) + { + $this->update = $update; + $this->db = Factory::getDbo(); + } + + /** + * Purge the unused language strings. + * + * This method removes or updates language strings that are no longer linked + * to the specified component. It checks if the strings are linked to other + * extensions and either updates, archives, or deletes them based on the + * conditions. + * + * @param array $values The active strings. + * @param int $targetId The target component ID. + * @param string $target The target extension type (default is 'components'). + * + * @return void + * @since 5.0.2 + */ + public function execute(array $values, int $targetId, string $target = 'components'): void + { + $target_types = ['components' => 'components', 'modules' => 'modules', 'plugins' => 'plugins']; + + if (isset($target_types[$target])) + { + unset($target_types[$target]); + + // Create a new query object. + $query = $this->db->getQuery(true); + $query->from($this->db->quoteName('#__componentbuilder_language_translation', 'a')) + ->select($this->db->quoteName(['a.id', 'a.translation', 'a.components', 'a.modules', 'a.plugins'])) + ->where($this->db->quoteName('a.source') . ' NOT IN (' . implode(',', array_map(fn($a) => $this->db->quote($a), $values)) . ')') + ->where($this->db->quoteName('a.published') . ' = 1'); + + $this->db->setQuery($query); + $this->db->execute(); + + if ($this->db->getNumRows()) + { + $counterUpdate = 0; + $otherStrings = $this->db->loadAssocList(); + $today = Factory::getDate()->toSql(); + + foreach ($otherStrings as $item) + { + if (JsonHelper::check($item[$target])) + { + $targets = (array) json_decode((string) $item[$target], true); + + if (($key = array_search($targetId, $targets)) !== false) + { + unset($targets[$key]); + + if (ArrayHelper::check($targets)) + { + $this->update->set($item['id'], $target, $targets, 1, $today, $counterUpdate); + + $counterUpdate++; + + $this->update->execute(50); + } + else + { + $this->handleUnlinkedString($item, $target_types, $targets, $today, $counterUpdate); + } + } + } + } + + $this->update->execute(); + } + } + } + + /** + * Handle strings that are unlinked from the current component. + * + * This method checks if a string is linked to other extensions and either updates, + * archives, or deletes it based on the conditions. + * + * @param array $item The language string item. + * @param array $targetTypes The target extension types. + * @param array $targets The targets to update. + * @param string $today The current date. + * @param int $counter The update counter. + * + * @return void + * @since 5.0.2 + */ + protected function handleUnlinkedString(array $item, array $targetTypes, array $targets, string $today, int &$counter): void + { + // the action (1 = remove, 2 = archive, 0 = do nothing) + $action_with_string = 1; + + foreach ($targetTypes as $other_target) + { + if ($action_with_string && JsonHelper::check($item[$other_target])) + { + $other_targets = (array) json_decode((string) $item[$other_target], true); + + if (ArrayHelper::check($other_targets)) + { + $action_with_string = 0; + } + } + } + + if ($action_with_string && JsonHelper::check($item['translation'])) + { + $translation = json_decode((string) $item['translation'], true); + + if (ArrayHelper::check($translation)) + { + $this->update->set($item['id'], $targets, $targets, 2, $today, $counter); + $counter++; + $this->update->execute(50); + $action_with_string = 2; + } + } + + if ($action_with_string == 1) + { + $this->removeExitingLangString($item['id']); + } + } + + /** + * Remove existing language translation strings. + * + * This method deletes a language string from the database based on its ID. + * + * @param int $id The string ID to remove. + * + * @return void + * @since 5.0.2 + */ + protected function removeExitingLangString(int $id): void + { + $query = $this->db->getQuery(true); + $query->delete($this->db->quoteName('#__componentbuilder_language_translation')) + ->where($this->db->quoteName('id') . ' = ' . (int) $id); + + $this->db->setQuery($query); + $this->db->execute(); + } +} + diff --git a/src/0b0e574c-aab4-4eaf-96d8-d7210d8ed93e/code.power b/src/0b0e574c-aab4-4eaf-96d8-d7210d8ed93e/code.power new file mode 100644 index 0000000..63e2f47 --- /dev/null +++ b/src/0b0e574c-aab4-4eaf-96d8-d7210d8ed93e/code.power @@ -0,0 +1,169 @@ + /** + * The Update Class. + * + * @var Update + * @since 5.0.2 + */ + protected Update $update; + + /** + * Database object to query local DB + * + * @since 5.0.2 + **/ + protected $db; + + /** + * Constructor. + * + * @param Update $update The Update Class. + * + * @since 5.0.2 + */ + public function __construct(Update $update) + { + $this->update = $update; + $this->db = Factory::getDbo(); + } + + /** + * Purge the unused language strings. + * + * This method removes or updates language strings that are no longer linked + * to the specified component. It checks if the strings are linked to other + * extensions and either updates, archives, or deletes them based on the + * conditions. + * + * @param array $values The active strings. + * @param int $targetId The target component ID. + * @param string $target The target extension type (default is 'components'). + * + * @return void + * @since 5.0.2 + */ + public function execute(array $values, int $targetId, string $target = 'components'): void + { + $target_types = ['components' => 'components', 'modules' => 'modules', 'plugins' => 'plugins']; + + if (isset($target_types[$target])) + { + unset($target_types[$target]); + + // Create a new query object. + $query = $this->db->getQuery(true); + $query->from($this->db->quoteName('#__componentbuilder_language_translation', 'a')) + ->select($this->db->quoteName(['a.id', 'a.translation', 'a.components', 'a.modules', 'a.plugins'])) + ->where($this->db->quoteName('a.source') . ' NOT IN (' . implode(',', array_map(fn($a) => $this->db->quote($a), $values)) . ')') + ->where($this->db->quoteName('a.published') . ' = 1'); + + $this->db->setQuery($query); + $this->db->execute(); + + if ($this->db->getNumRows()) + { + $counterUpdate = 0; + $otherStrings = $this->db->loadAssocList(); + $today = Factory::getDate()->toSql(); + + foreach ($otherStrings as $item) + { + if (JsonHelper::check($item[$target])) + { + $targets = (array) json_decode((string) $item[$target], true); + + if (($key = array_search($targetId, $targets)) !== false) + { + unset($targets[$key]); + + if (ArrayHelper::check($targets)) + { + $this->update->set($item['id'], $target, $targets, 1, $today, $counterUpdate); + + $counterUpdate++; + + $this->update->execute(50); + } + else + { + $this->handleUnlinkedString($item, $target_types, $targets, $today, $counterUpdate); + } + } + } + } + + $this->update->execute(); + } + } + } + + /** + * Handle strings that are unlinked from the current component. + * + * This method checks if a string is linked to other extensions and either updates, + * archives, or deletes it based on the conditions. + * + * @param array $item The language string item. + * @param array $targetTypes The target extension types. + * @param array $targets The targets to update. + * @param string $today The current date. + * @param int $counter The update counter. + * + * @return void + * @since 5.0.2 + */ + protected function handleUnlinkedString(array $item, array $targetTypes, array $targets, string $today, int &$counter): void + { + // the action (1 = remove, 2 = archive, 0 = do nothing) + $action_with_string = 1; + + foreach ($targetTypes as $other_target) + { + if ($action_with_string && JsonHelper::check($item[$other_target])) + { + $other_targets = (array) json_decode((string) $item[$other_target], true); + + if (ArrayHelper::check($other_targets)) + { + $action_with_string = 0; + } + } + } + + if ($action_with_string && JsonHelper::check($item['translation'])) + { + $translation = json_decode((string) $item['translation'], true); + + if (ArrayHelper::check($translation)) + { + $this->update->set($item['id'], $targets, $targets, 2, $today, $counter); + $counter++; + $this->update->execute(50); + $action_with_string = 2; + } + } + + if ($action_with_string == 1) + { + $this->removeExitingLangString($item['id']); + } + } + + /** + * Remove existing language translation strings. + * + * This method deletes a language string from the database based on its ID. + * + * @param int $id The string ID to remove. + * + * @return void + * @since 5.0.2 + */ + protected function removeExitingLangString(int $id): void + { + $query = $this->db->getQuery(true); + $query->delete($this->db->quoteName('#__componentbuilder_language_translation')) + ->where($this->db->quoteName('id') . ' = ' . (int) $id); + + $this->db->setQuery($query); + $this->db->execute(); + } \ No newline at end of file diff --git a/src/0b0e574c-aab4-4eaf-96d8-d7210d8ed93e/settings.json b/src/0b0e574c-aab4-4eaf-96d8-d7210d8ed93e/settings.json new file mode 100644 index 0000000..90fa075 --- /dev/null +++ b/src/0b0e574c-aab4-4eaf-96d8-d7210d8ed93e/settings.json @@ -0,0 +1,32 @@ +{ + "add_head": "1", + "add_licensing_template": "2", + "extends": "", + "guid": "0b0e574c-aab4-4eaf-96d8-d7210d8ed93e", + "implements": null, + "load_selection": null, + "name": "Purge", + "power_version": "1.0.0", + "system_name": "JCB.Compiler.Language.Purge", + "type": "final class", + "use_selection": { + "use_selection0": { + "use": "375543cd-5f2a-4893-982e-a73eaa55360d", + "as": "default" + }, + "use_selection1": { + "use": "4b225c51-d293-48e4-b3f6-5136cf5c3f18", + "as": "default" + }, + "use_selection2": { + "use": "0a59c65c-9daf-4bc9-baf4-e063ff9e6a8a", + "as": "default" + } + }, + "extendsinterfaces": null, + "namespace": "[[[NamespacePrefix]]]\\Joomla\\[[[ComponentNamespace]]].Compiler.Language.Purge", + "description": "Compiler Remove Existing Language Strings\r\n\r\n@since 5.0.2", + "licensing_template": "\/**\r\n * @package Joomla.Component.Builder\r\n *\r\n * @created 4th September, 2022\r\n * @author Llewellyn van der Merwe \r\n * @git Joomla Component Builder \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;", + "composer": "" +} \ No newline at end of file diff --git a/src/174f5c9c-5e03-4261-94ca-279ca76c710d/README.md b/src/174f5c9c-5e03-4261-94ca-279ca76c710d/README.md new file mode 100644 index 0000000..02bb3c4 --- /dev/null +++ b/src/174f5c9c-5e03-4261-94ca-279ca76c710d/README.md @@ -0,0 +1,95 @@ +``` +██████╗ ██████╗ ██╗ ██╗███████╗██████╗ +██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗ +██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝ +██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗ +██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║ +╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝ +``` +# final class Data (Details) +> namespace: **VDM\Joomla\Componentbuilder\Compiler\Joomlaplugin\JoomlaFive** + +```uml +@startuml +class Data << (F,LightGreen) >> #RoyalBlue { + # array $data + # Config $config + # Customcode $customcode + # Gui $gui + # Placeholder $placeholder + # Language $language + # Field $field + # FieldName $fieldname + # Filesfolders $filesfolders + # $db + + __construct(Config $config, Customcode $customcode, ...) + + get(int $id = null) : object|array|null + + exists(int $id = null) : bool + + set(int $id) : bool +} + +note right of Data::__construct + Constructor. + + since: 5.0.2 + + arguments: + Config $config + Customcode $customcode + Gui $gui + Placeholder $placeholder + Language $language + Field $field + FieldName $fieldname + Filesfolders $filesfolders +end note + +note right of Data::get + Get the Joomla Plugin/s + + since: 3.2.0 + return: object|array|null +end note + +note right of Data::exists + Check if the Joomla Plugin/s exists + + since: 3.2.0 + return: bool +end note + +note right of Data::set + Set the Joomla Plugin + + since: 3.2.0 + return: bool +end note + +@enduml +``` + +The Power feature in JCB allows you to write PHP classes and their implementations, making it easy to include them in your Joomla project. JCB handles linking, autoloading, namespacing, and folder structure creation for you. + +By using the SPK (Super Power Key) in your custom code (replacing the class name in your code with the SPK), JCB will automatically pull the power from the repository into your project. This makes it available in your JCB instance, allowing you to edit it and include the class in your generated Joomla component. + +JCB uses placeholders like [[[`NamespacePrefix`]]] and [[[`ComponentNamespace`]]] in namespacing to prevent collisions and improve reusability across different JCB systems. You can also set the **JCB powers path** globally or per component under the **Dynamic Integration** tab, providing flexibility and easy maintainability. + +To add this specific Power to your project in JCB: + +> simply use this SPK +``` +Super---174f5c9c_5e03_4261_94ca_279ca76c710d---Power +``` +> remember to replace the `---` with `___` to activate this Power in your code + +--- +``` + ██╗ ██████╗██████╗ + ██║██╔════╝██╔══██╗ + ██║██║ ██████╔╝ +██ ██║██║ ██╔══██╗ +╚█████╔╝╚██████╗██████╔╝ + ╚════╝ ╚═════╝╚═════╝ +``` +> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder) + diff --git a/src/174f5c9c-5e03-4261-94ca-279ca76c710d/code.php b/src/174f5c9c-5e03-4261-94ca-279ca76c710d/code.php new file mode 100644 index 0000000..e3af760 --- /dev/null +++ b/src/174f5c9c-5e03-4261-94ca-279ca76c710d/code.php @@ -0,0 +1,934 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Componentbuilder\Compiler\Joomlaplugin\JoomlaFive; + + +use Joomla\CMS\Factory; +use Joomla\CMS\Filter\OutputFilter; +use VDM\Joomla\Componentbuilder\Compiler\Config; +use VDM\Joomla\Componentbuilder\Compiler\Customcode; +use VDM\Joomla\Componentbuilder\Compiler\Customcode\Gui; +use VDM\Joomla\Componentbuilder\Compiler\Placeholder; +use VDM\Joomla\Componentbuilder\Compiler\Language; +use VDM\Joomla\Componentbuilder\Compiler\Field; +use VDM\Joomla\Componentbuilder\Compiler\Field\Name as FieldName; +use VDM\Joomla\Componentbuilder\Compiler\Model\Filesfolders; +use VDM\Joomla\Utilities\ArrayHelper; +use VDM\Joomla\Utilities\String\ClassfunctionHelper; +use VDM\Joomla\Utilities\String\PluginHelper; +use VDM\Joomla\Utilities\JsonHelper; +use VDM\Joomla\Utilities\StringHelper; +use VDM\Joomla\Utilities\GetHelper; +use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent; +use VDM\Joomla\Componentbuilder\Compiler\Interfaces\PluginDataInterface; + + +/** + * Joomla 5 Plug-in Data Class + * + * @since 5.0.2 + */ +final class Data implements PluginDataInterface +{ + /** + * Compiler Joomla Plug-in's Data + * + * @var array + * @since 3.2.0 + */ + protected array $data = []; + + /** + * The Configure Class. + * + * @var Config + * @since 5.0.2 + */ + protected Config $config; + + /** + * The Customcode Class. + * + * @var Customcode + * @since 5.0.2 + */ + protected Customcode $customcode; + + /** + * The Gui Class. + * + * @var Gui + * @since 5.0.2 + */ + protected Gui $gui; + + /** + * The Placeholder Class. + * + * @var Placeholder + * @since 5.0.2 + */ + protected Placeholder $placeholder; + + /** + * The Language Class. + * + * @var Language + * @since 5.0.2 + */ + protected Language $language; + + /** + * The Field Class. + * + * @var Field + * @since 5.0.2 + */ + protected Field $field; + + /** + * The Name Class. + * + * @var FieldName + * @since 5.0.2 + */ + protected FieldName $fieldname; + + /** + * The Filesfolders Class. + * + * @var Filesfolders + * @since 5.0.2 + */ + protected Filesfolders $filesfolders; + + /** + * Database object to query local DB + * + * @since 3.2.0 + **/ + protected $db; + + /** + * Define the mappings of traits and classes to their respective methods and services + * + * @var array + * @since 5.0.2 + **/ + protected array $service_checks = [ + 'DatabaseAwareTrait' => [ + 'trait' => 'Joomla\Database\DatabaseAwareTrait', + 'class' => 'Joomla__'.'_ae15e6b6_f7de_43ad_be4b_71499ae88f45___Power', + 'method' => 'setDatabase', + 'service' => 'Joomla__'.'_7bd29d76_73c9_4c07_a5da_4f7a32aff78f___Power' + ], + 'UserFactoryAwareTrait' => [ + 'trait' => 'Joomla\CMS\User\UserFactoryAwareTrait', + 'class' => 'Joomla__'.'_a6b2c321_5de3_4425_b05f_e5340965fb80___Power', + 'method' => 'setUserFactory', + 'service' => 'Joomla__'.'_c2980d12_c3ef_4e23_b4a2_e6af1f5900a9___Power' + ] + ]; + + /** + * Constructor. + * + * @param Config $config The Config Class. + * @param Customcode $customcode The Customcode Class. + * @param Gui $gui The Gui Class. + * @param Placeholder $placeholder The Placeholder Class. + * @param Language $language The Language Class. + * @param Field $field The Field Class. + * @param FieldName $fieldname The Name Class. + * @param Filesfolders $filesfolders The Filesfolders Class. + * + * @since 5.0.2 + */ + public function __construct(Config $config, Customcode $customcode, Gui $gui, + Placeholder $placeholder, Language $language, + Field $field, FieldName $fieldname, + Filesfolders $filesfolders) + { + $this->config = $config; + $this->customcode = $customcode; + $this->gui = $gui; + $this->placeholder = $placeholder; + $this->language = $language; + $this->field = $field; + $this->fieldname = $fieldname; + $this->filesfolders = $filesfolders; + $this->db = Factory::getDbo(); + } + + /** + * Get the Joomla Plugin/s + * + * @param int|null $id the plugin id + * + * @return object|array|null if ID found it returns object, if no ID given it returns all set + * @since 3.2.0 + */ + public function get(int $id = null) + { + if (is_null($id) && $this->exists()) + { + return $this->data; + } + elseif ($this->exists($id)) + { + return $this->data[$id]; + } + + return null; + } + + /** + * Check if the Joomla Plugin/s exists + * + * @param int|null $id the plugin id + * + * @return bool if ID found it returns true, if no ID given it returns true if any are set + * @since 3.2.0 + */ + public function exists(int $id = null): bool + { + if (is_null($id)) + { + return ArrayHelper::check($this->data); + } + elseif (isset($this->data[$id])) + { + return true; + } + + return $this->set($id); + } + + /** + * Set the Joomla Plugin + * + * @param int $id the plugin id + * + * @return bool true on success + * @since 3.2.0 + */ + public function set(int $id): bool + { + if (isset($this->data[$id])) + { + return true; + } + else + { + // Create a new query object. + $query = $this->db->getQuery(true); + + $query->select('a.*'); + $query->select( + $this->db->quoteName( + array( + 'g.name', + 'e.name', + 'e.head', + 'e.comment', + 'e.id', + 'f.addfiles', + 'f.addfolders', + 'f.addfilesfullpath', + 'f.addfoldersfullpath', + 'f.addurls', + 'u.version_update', + 'u.id' + ), array( + 'group', + 'extends', + 'class_head', + 'comment', + 'class_id', + 'addfiles', + 'addfolders', + 'addfilesfullpath', + 'addfoldersfullpath', + 'addurls', + 'version_update', + 'version_update_id' + ) + ) + ); + // from these tables + $query->from('#__componentbuilder_joomla_plugin AS a'); + $query->join( + 'LEFT', $this->db->quoteName( + '#__componentbuilder_joomla_plugin_group', 'g' + ) . ' ON (' . $this->db->quoteName('a.joomla_plugin_group') + . ' = ' . $this->db->quoteName('g.id') . ')' + ); + $query->join( + 'LEFT', + $this->db->quoteName('#__componentbuilder_class_extends', 'e') + . ' ON (' . $this->db->quoteName('a.class_extends') . ' = ' + . $this->db->quoteName('e.id') . ')' + ); + $query->join( + 'LEFT', $this->db->quoteName( + '#__componentbuilder_joomla_plugin_updates', 'u' + ) . ' ON (' . $this->db->quoteName('a.id') . ' = ' + . $this->db->quoteName('u.joomla_plugin') . ')' + ); + $query->join( + 'LEFT', $this->db->quoteName( + '#__componentbuilder_joomla_plugin_files_folders_urls', 'f' + ) . ' ON (' . $this->db->quoteName('a.id') . ' = ' + . $this->db->quoteName('f.joomla_plugin') . ')' + ); + $query->where($this->db->quoteName('a.id') . ' = ' . (int) $id); + $query->where($this->db->quoteName('a.published') . ' >= 1'); + $this->db->setQuery($query); + $this->db->execute(); + if ($this->db->getNumRows()) + { + // get the plugin data + $plugin = $this->db->loadObject(); + + // tweak system to set stuff to the plugin domain + $_backup_target = $this->config->build_target; + $_backup_lang = $this->config->lang_target; + $_backup_langPrefix = $this->config->lang_prefix; + + // set some keys + $plugin->target_type = 'pLuG!n'; + $plugin->key = $plugin->id . '_' . $plugin->target_type; + + // update to point to plugin + $this->config->build_target = $plugin->key; + $this->config->lang_target = $plugin->key; + + // set version if not set + if (empty($plugin->plugin_version)) + { + $plugin->plugin_version = '1.0.0'; + } + + // set GUI mapper + $guiMapper = array('table' => 'joomla_plugin', + 'id' => (int) $id, 'type' => 'php'); + + // update the name if it has dynamic values + $plugin->name = $this->placeholder->update_( + $this->customcode->update($plugin->name) + ); + + // update the name if it has dynamic values + $plugin->code_name + = ClassfunctionHelper::safe( + $plugin->name + ); + + // set official name + $plugin->official_name = ucwords( + $plugin->group . ' - ' . $plugin->name + ); + + // set lang prefix + $plugin->lang_prefix = PluginHelper::safeLangPrefix( + $plugin->code_name, + $plugin->group + ); + + // set langPrefix + $this->config->lang_prefix = $plugin->lang_prefix; + + // set plugin class name + $plugin->class_name = ucfirst( + $plugin->code_name + ); + // set plugin context name + $plugin->context_name = strtolower((string) + $plugin->code_name + ); + + // set plugin namespace + $plugin->namespace = $plugin->code_name; + + // set plugin group namespace + $plugin->group_namespace = ucfirst( + $plugin->group + ); + + // set plugin install class name + $plugin->installer_class_name + = PluginHelper::safeInstallClassName( + $plugin->code_name, + $plugin->group + ); + + // set plugin folder name + $plugin->folder_name + = PluginHelper::safeFolderName( + $plugin->code_name, + $plugin->group + ); + + // set the zip name + $plugin->zip_name = $plugin->folder_name . '_v' . str_replace( + '.', '_', (string) $plugin->plugin_version + ) . '__J' . $this->config->joomla_version; + + // set plugin file name + $plugin->file_name = $plugin->context_name; + $plugin->class_file_name = $plugin->code_name; + + // set plugin context + $plugin->context = $plugin->folder_name . '.' . $plugin->id; + + // set official_name lang strings + $this->language->set( + $plugin->key, $this->config->lang_prefix, $plugin->official_name + ); + + // set some placeholder for this plugin + $this->placeholder->set('Plugin_name', $plugin->official_name); + $this->placeholder->set('PLUGIN_NAME', $plugin->official_name); + $this->placeholder->set('Plugin', ucfirst((string) $plugin->code_name)); + $this->placeholder->set('plugin', strtolower((string) $plugin->code_name)); + $this->placeholder->set('Plugin_group', ucfirst((string) $plugin->group)); + $this->placeholder->set('plugin_group', strtolower((string) $plugin->group)); + $this->placeholder->set('plugin.version', $plugin->plugin_version); + $this->placeholder->set('VERSION', $plugin->plugin_version); + $this->placeholder->set('plugin_version', str_replace( + '.', '_', (string) $plugin->plugin_version + )); + + // set description + $this->placeholder->set('DESCRIPTION', ''); + if (!isset($plugin->description) + || !StringHelper::check( + $plugin->description + )) + { + $plugin->description = ''; + } + else + { + $plugin->description = $this->placeholder->update_( + $this->customcode->update($plugin->description) + ); + $this->language->set( + $plugin->key, $plugin->lang_prefix . '_DESCRIPTION', + $plugin->description + ); + // set description + $this->placeholder->set('DESCRIPTION', $plugin->description); + $plugin->description = '

' . $plugin->description . '

'; + } + + // get author name + $project_author = $this->config->project_author; + + // we can only set these if the component was passed + $plugin->xml_description = "

" . $plugin->official_name + . " (v." . $plugin->plugin_version + . ")

" + . $plugin->description . "

Created by " . trim( + (string) OutputFilter::cleanText($project_author) + ) . "
Development started " + . Factory::getDate($plugin->created)->format("jS F, Y") + . "

"; + + // set xml discription + $this->language->set( + $plugin->key, $plugin->lang_prefix . '_XML_DESCRIPTION', + $plugin->xml_description + ); + + // update the readme if set + if ($plugin->addreadme == 1 && !empty($plugin->readme)) + { + $plugin->readme = $this->placeholder->update_( + $this->customcode->update(base64_decode((string) $plugin->readme)) + ); + } + else + { + $plugin->addreadme = 0; + unset($plugin->readme); + } + + // open some base64 strings + if (!empty($plugin->main_class_code)) + { + // set GUI mapper field + $guiMapper['field'] = 'main_class_code'; + // base64 Decode main_class_code. + $plugin->main_class_code = $this->gui->set( + $this->placeholder->update_( + $this->customcode->update( + base64_decode((string) $plugin->main_class_code) + ) + ), + $guiMapper + ); + } + + // set the head :) + if ($plugin->add_head == 1 && !empty($plugin->head)) + { + // set GUI mapper field + $guiMapper['field'] = 'head'; + // base64 Decode head. + $plugin->header = $this->gui->set( + $this->placeholder->update_( + $this->customcode->update( + base64_decode((string) $plugin->head) + ) + ), + $guiMapper + ); + } + elseif (!empty($plugin->class_head)) + { + // base64 Decode head. + $plugin->header = $this->gui->set( + $this->placeholder->update_( + $this->customcode->update( + base64_decode((string) $plugin->class_head) + ) + ), + array( + 'table' => 'class_extends', + 'field' => 'head', + 'id' => (int) $plugin->class_id, + 'type' => 'php') + ); + } + unset($plugin->class_head); + + // Check the plugin's code and header for each trait + foreach ($this->service_checks as $key => $info) + { + if (strpos($plugin->main_class_code, $key) !== false || + strpos($plugin->main_class_code, $info['class']) !== false || + strpos($plugin->header, $info['trait']) !== false) + { + $service_provider[] = Indent::_(4) . "\$plugin->{$info['method']}(\$container->get({$info['service']}::class));"; + } + } + + // Assign service provider if any services were added + if (!empty($service_provider)) + { + $plugin->service_provider = implode(PHP_EOL, $service_provider); + } + + // set the comment + if (!empty($plugin->comment)) + { + // base64 Decode comment. + $plugin->comment = $this->gui->set( + $this->placeholder->update_( + $this->customcode->update( + base64_decode((string) $plugin->comment) + ) + ), + array( + 'table' => 'class_extends', + 'field' => 'comment', + 'id' => (int) $plugin->class_id, + 'type' => 'php') + ); + } + + // start the config array + $plugin->config_fields = []; + // create the form arrays + $plugin->form_files = []; + $plugin->fieldsets_label = []; + $plugin->fieldsets_paths = []; + $plugin->add_rule_path = []; + $plugin->add_field_path = []; + // set global fields rule to default component path + $plugin->fields_rules_paths = 1; + // set the fields data + $plugin->fields = (isset($plugin->fields) + && JsonHelper::check($plugin->fields)) + ? json_decode((string) $plugin->fields, true) : null; + if (ArrayHelper::check($plugin->fields)) + { + // ket global key + $key = $plugin->key; + $dynamic_fields = array('fieldset' => 'basic', + 'fields_name' => 'params', + 'file' => 'config'); + foreach ($plugin->fields as $n => &$form) + { + if (isset($form['fields']) + && ArrayHelper::check( + $form['fields'] + )) + { + // make sure the dynamic_field is set to dynamic_value by default + foreach ( + $dynamic_fields as $dynamic_field => + $dynamic_value + ) + { + if (!isset($form[$dynamic_field]) + || !StringHelper::check( + $form[$dynamic_field] + )) + { + $form[$dynamic_field] = $dynamic_value; + } + else + { + if ('fields_name' === $dynamic_field + && strpos((string) $form[$dynamic_field], '.') + !== false) + { + $form[$dynamic_field] + = $form[$dynamic_field]; + } + else + { + $form[$dynamic_field] + = StringHelper::safe( + $form[$dynamic_field] + ); + } + } + } + // check if field is external form file + if (!isset($form['plugin']) || $form['plugin'] != 1) + { + // now build the form key + $unique = $form['file'] . $form['fields_name'] + . $form['fieldset']; + } + else + { + // now build the form key + $unique = $form['fields_name'] + . $form['fieldset']; + } + // set global fields rule path switchs + if ($plugin->fields_rules_paths == 1 + && isset($form['fields_rules_paths']) + && $form['fields_rules_paths'] == 2) + { + $plugin->fields_rules_paths = 2; + } + // set where to path is pointing + $plugin->fieldsets_paths[$unique] + = $form['fields_rules_paths']; + // add the label if set to lang + if (isset($form['label']) + && StringHelper::check( + $form['label'] + )) + { + $plugin->fieldsets_label[$unique] + = $this->language->key($form['label']); + } + // check for extra rule paths + if (isset($form['addrulepath']) + && ArrayHelper::check($form['addrulepath'])) + { + foreach ($form['addrulepath'] as $add_rule_path) + { + if (StringHelper::check($add_rule_path['path'])) + { + $plugin->add_rule_path[$unique] = $add_rule_path['path']; + } + } + } + // check for extra field paths + if (isset($form['addfieldpath']) + && ArrayHelper::check($form['addfieldpath'])) + { + foreach ($form['addfieldpath'] as $add_field_path) + { + if (StringHelper::check($add_field_path['path'])) + { + $plugin->add_field_path[$unique] = $add_field_path['path']; + } + } + } + // build the fields + $form['fields'] = array_map( + function ($field) use ($key, $unique) { + // make sure the alias and title is 0 + $field['alias'] = 0; + $field['title'] = 0; + // set the field details + $this->field->set( + $field, $key, $key, $unique + ); + // update the default if set + if (StringHelper::check( + $field['custom_value'] + ) + && isset($field['settings'])) + { + if (($old_default + = GetHelper::between( + $field['settings']->xml, + 'default="', '"', false + )) !== false) + { + // replace old default + $field['settings']->xml + = str_replace( + 'default="' . $old_default + . '"', 'default="' + . $field['custom_value'] . '"', + (string) $field['settings']->xml + ); + } + else + { + // add the default (hmmm not ideal but okay it should work) + $field['settings']->xml + = 'default="' + . $field['custom_value'] . '" ' + . $field['settings']->xml; + } + } + unset($field['custom_value']); + + // return field + return $field; + }, array_values($form['fields']) + ); + // check if field is external form file + if (!isset($form['plugin']) || $form['plugin'] != 1) + { + // load the form file + if (!isset($plugin->form_files[$form['file']])) + { + $plugin->form_files[$form['file']] + = []; + } + if (!isset($plugin->form_files[$form['file']][$form['fields_name']])) + { + $plugin->form_files[$form['file']][$form['fields_name']] + = []; + } + if (!isset($plugin->form_files[$form['file']][$form['fields_name']][$form['fieldset']])) + { + $plugin->form_files[$form['file']][$form['fields_name']][$form['fieldset']] + = []; + } + // do some house cleaning (for fields) + foreach ($form['fields'] as $field) + { + // so first we lock the field name in + $this->fieldname->get( + $field, $plugin->key, $unique + ); + // add the fields to the global form file builder + $plugin->form_files[$form['file']][$form['fields_name']][$form['fieldset']][] + = $field; + } + // remove form + unset($plugin->fields[$n]); + } + else + { + // load the config form + if (!isset($plugin->config_fields[$form['fields_name']])) + { + $plugin->config_fields[$form['fields_name']] + = []; + } + if (!isset($plugin->config_fields[$form['fields_name']][$form['fieldset']])) + { + $plugin->config_fields[$form['fields_name']][$form['fieldset']] + = []; + } + // do some house cleaning (for fields) + foreach ($form['fields'] as $field) + { + // so first we lock the field name in + $this->fieldname->get( + $field, $plugin->key, $unique + ); + // add the fields to the config builder + $plugin->config_fields[$form['fields_name']][$form['fieldset']][] + = $field; + } + // remove form + unset($plugin->fields[$n]); + } + } + else + { + unset($plugin->fields[$n]); + } + } + } + unset($plugin->fields); + + // set files and folders + $this->filesfolders->set($plugin); + + // add PHP in plugin install + $plugin->add_install_script = true; + $addScriptMethods = [ + 'php_preflight', + 'php_postflight', + 'php_method', + 'php_script' + ]; + $addScriptTypes = [ + 'install', + 'update', + 'uninstall', + 'construct' + ]; + foreach ($addScriptMethods as $scriptMethod) + { + foreach ($addScriptTypes as $scriptType) + { + if (isset( $plugin->{'add_' . $scriptMethod . '_' . $scriptType}) + && $plugin->{'add_' . $scriptMethod . '_' . $scriptType} == 1 + && StringHelper::check( + $plugin->{$scriptMethod . '_' . $scriptType} + )) + { + // set GUI mapper field + $guiMapper['field'] = $scriptMethod . '_' . $scriptType; + $plugin->{$scriptMethod . '_' . $scriptType} = $this->gui->set( + $this->placeholder->update_( + $this->customcode->update( + base64_decode( + (string) $plugin->{$scriptMethod . '_' . $scriptType} + ) + ) + ), + $guiMapper + ); + } + else + { + unset($plugin->{$scriptMethod . '_' . $scriptType}); + $plugin->{'add_' . $scriptMethod . '_' . $scriptType} = 0; + } + } + } + + // add_sql + if ($plugin->add_sql == 1 + && StringHelper::check($plugin->sql)) + { + $plugin->sql = $this->placeholder->update_( + $this->customcode->update(base64_decode((string) $plugin->sql)) + ); + } + else + { + unset($plugin->sql); + $plugin->add_sql = 0; + } + + // add_sql_uninstall + if ($plugin->add_sql_uninstall == 1 + && StringHelper::check( + $plugin->sql_uninstall + )) + { + $plugin->sql_uninstall = $this->placeholder->update_( + $this->customcode->update( + base64_decode((string) $plugin->sql_uninstall) + ) + ); + } + else + { + unset($plugin->sql_uninstall); + $plugin->add_sql_uninstall = 0; + } + + // update the URL of the update_server if set + if ($plugin->add_update_server == 1 + && StringHelper::check( + $plugin->update_server_url + )) + { + $plugin->update_server_url = $this->placeholder->update_( + $this->customcode->update($plugin->update_server_url) + ); + } + + // add the update/sales server FTP details if that is the expected protocol + $serverArray = array('update_server', 'sales_server'); + foreach ($serverArray as $server) + { + if ($plugin->{'add_' . $server} == 1 + && is_numeric( + $plugin->{$server} + ) + && $plugin->{$server} > 0) + { + // get the server protocol + $plugin->{$server . '_protocol'} + = GetHelper::var( + 'server', (int) $plugin->{$server}, 'id', 'protocol' + ); + } + else + { + $plugin->{$server} = 0; + // only change this for sales server (update server can be added locally to the zip file) + if ('sales_server' === $server) + { + $plugin->{'add_' . $server} = 0; + } + $plugin->{$server . '_protocol'} = 0; + } + } + + // old path (to remove) + $plugin->remove_file_paths = []; + $plugin->remove_file_paths[] = "/plugins/{$plugin->group}/{$plugin->context_name}/{$plugin->file_name}.php"; + + // set the update server stuff (TODO) + // update_server_xml_path + // update_server_xml_file_name + + // rest globals + $this->config->build_target = $_backup_target; + $this->config->lang_target = $_backup_lang; + $this->config->set('lang_prefix', $_backup_langPrefix); + + $this->placeholder->remove('Plugin_name'); + $this->placeholder->remove('Plugin'); + $this->placeholder->remove('plugin'); + $this->placeholder->remove('Plugin_group'); + $this->placeholder->remove('plugin_group'); + $this->placeholder->remove('plugin.version'); + $this->placeholder->remove('plugin_version'); + $this->placeholder->remove('VERSION'); + $this->placeholder->remove('DESCRIPTION'); + $this->placeholder->remove('PLUGIN_NAME'); + + $this->data[$id] = $plugin; + + return true; + } + } + + return false; + } +} + diff --git a/src/174f5c9c-5e03-4261-94ca-279ca76c710d/code.power b/src/174f5c9c-5e03-4261-94ca-279ca76c710d/code.power new file mode 100644 index 0000000..1a897da --- /dev/null +++ b/src/174f5c9c-5e03-4261-94ca-279ca76c710d/code.power @@ -0,0 +1,891 @@ + /** + * Compiler Joomla Plug-in's Data + * + * @var array + * @since 3.2.0 + */ + protected array $data = []; + + /** + * The Configure Class. + * + * @var Config + * @since 5.0.2 + */ + protected Config $config; + + /** + * The Customcode Class. + * + * @var Customcode + * @since 5.0.2 + */ + protected Customcode $customcode; + + /** + * The Gui Class. + * + * @var Gui + * @since 5.0.2 + */ + protected Gui $gui; + + /** + * The Placeholder Class. + * + * @var Placeholder + * @since 5.0.2 + */ + protected Placeholder $placeholder; + + /** + * The Language Class. + * + * @var Language + * @since 5.0.2 + */ + protected Language $language; + + /** + * The Field Class. + * + * @var Field + * @since 5.0.2 + */ + protected Field $field; + + /** + * The Name Class. + * + * @var FieldName + * @since 5.0.2 + */ + protected FieldName $fieldname; + + /** + * The Filesfolders Class. + * + * @var Filesfolders + * @since 5.0.2 + */ + protected Filesfolders $filesfolders; + + /** + * Database object to query local DB + * + * @since 3.2.0 + **/ + protected $db; + + /** + * Define the mappings of traits and classes to their respective methods and services + * + * @var array + * @since 5.0.2 + **/ + protected array $service_checks = [ + 'DatabaseAwareTrait' => [ + 'trait' => 'Joomla\Database\DatabaseAwareTrait', + 'class' => 'Joomla__'.'_ae15e6b6_f7de_43ad_be4b_71499ae88f45___Power', + 'method' => 'setDatabase', + 'service' => 'Joomla__'.'_7bd29d76_73c9_4c07_a5da_4f7a32aff78f___Power' + ], + 'UserFactoryAwareTrait' => [ + 'trait' => 'Joomla\CMS\User\UserFactoryAwareTrait', + 'class' => 'Joomla__'.'_a6b2c321_5de3_4425_b05f_e5340965fb80___Power', + 'method' => 'setUserFactory', + 'service' => 'Joomla__'.'_c2980d12_c3ef_4e23_b4a2_e6af1f5900a9___Power' + ] + ]; + + /** + * Constructor. + * + * @param Config $config The Config Class. + * @param Customcode $customcode The Customcode Class. + * @param Gui $gui The Gui Class. + * @param Placeholder $placeholder The Placeholder Class. + * @param Language $language The Language Class. + * @param Field $field The Field Class. + * @param FieldName $fieldname The Name Class. + * @param Filesfolders $filesfolders The Filesfolders Class. + * + * @since 5.0.2 + */ + public function __construct(Config $config, Customcode $customcode, Gui $gui, + Placeholder $placeholder, Language $language, + Field $field, FieldName $fieldname, + Filesfolders $filesfolders) + { + $this->config = $config; + $this->customcode = $customcode; + $this->gui = $gui; + $this->placeholder = $placeholder; + $this->language = $language; + $this->field = $field; + $this->fieldname = $fieldname; + $this->filesfolders = $filesfolders; + $this->db = Factory::getDbo(); + } + + /** + * Get the Joomla Plugin/s + * + * @param int|null $id the plugin id + * + * @return object|array|null if ID found it returns object, if no ID given it returns all set + * @since 3.2.0 + */ + public function get(int $id = null) + { + if (is_null($id) && $this->exists()) + { + return $this->data; + } + elseif ($this->exists($id)) + { + return $this->data[$id]; + } + + return null; + } + + /** + * Check if the Joomla Plugin/s exists + * + * @param int|null $id the plugin id + * + * @return bool if ID found it returns true, if no ID given it returns true if any are set + * @since 3.2.0 + */ + public function exists(int $id = null): bool + { + if (is_null($id)) + { + return ArrayHelper::check($this->data); + } + elseif (isset($this->data[$id])) + { + return true; + } + + return $this->set($id); + } + + /** + * Set the Joomla Plugin + * + * @param int $id the plugin id + * + * @return bool true on success + * @since 3.2.0 + */ + public function set(int $id): bool + { + if (isset($this->data[$id])) + { + return true; + } + else + { + // Create a new query object. + $query = $this->db->getQuery(true); + + $query->select('a.*'); + $query->select( + $this->db->quoteName( + array( + 'g.name', + 'e.name', + 'e.head', + 'e.comment', + 'e.id', + 'f.addfiles', + 'f.addfolders', + 'f.addfilesfullpath', + 'f.addfoldersfullpath', + 'f.addurls', + 'u.version_update', + 'u.id' + ), array( + 'group', + 'extends', + 'class_head', + 'comment', + 'class_id', + 'addfiles', + 'addfolders', + 'addfilesfullpath', + 'addfoldersfullpath', + 'addurls', + 'version_update', + 'version_update_id' + ) + ) + ); + // from these tables + $query->from('#__componentbuilder_joomla_plugin AS a'); + $query->join( + 'LEFT', $this->db->quoteName( + '#__componentbuilder_joomla_plugin_group', 'g' + ) . ' ON (' . $this->db->quoteName('a.joomla_plugin_group') + . ' = ' . $this->db->quoteName('g.id') . ')' + ); + $query->join( + 'LEFT', + $this->db->quoteName('#__componentbuilder_class_extends', 'e') + . ' ON (' . $this->db->quoteName('a.class_extends') . ' = ' + . $this->db->quoteName('e.id') . ')' + ); + $query->join( + 'LEFT', $this->db->quoteName( + '#__componentbuilder_joomla_plugin_updates', 'u' + ) . ' ON (' . $this->db->quoteName('a.id') . ' = ' + . $this->db->quoteName('u.joomla_plugin') . ')' + ); + $query->join( + 'LEFT', $this->db->quoteName( + '#__componentbuilder_joomla_plugin_files_folders_urls', 'f' + ) . ' ON (' . $this->db->quoteName('a.id') . ' = ' + . $this->db->quoteName('f.joomla_plugin') . ')' + ); + $query->where($this->db->quoteName('a.id') . ' = ' . (int) $id); + $query->where($this->db->quoteName('a.published') . ' >= 1'); + $this->db->setQuery($query); + $this->db->execute(); + if ($this->db->getNumRows()) + { + // get the plugin data + $plugin = $this->db->loadObject(); + + // tweak system to set stuff to the plugin domain + $_backup_target = $this->config->build_target; + $_backup_lang = $this->config->lang_target; + $_backup_langPrefix = $this->config->lang_prefix; + + // set some keys + $plugin->target_type = 'pLuG!n'; + $plugin->key = $plugin->id . '_' . $plugin->target_type; + + // update to point to plugin + $this->config->build_target = $plugin->key; + $this->config->lang_target = $plugin->key; + + // set version if not set + if (empty($plugin->plugin_version)) + { + $plugin->plugin_version = '1.0.0'; + } + + // set GUI mapper + $guiMapper = array('table' => 'joomla_plugin', + 'id' => (int) $id, 'type' => 'php'); + + // update the name if it has dynamic values + $plugin->name = $this->placeholder->update_( + $this->customcode->update($plugin->name) + ); + + // update the name if it has dynamic values + $plugin->code_name + = ClassfunctionHelper::safe( + $plugin->name + ); + + // set official name + $plugin->official_name = ucwords( + $plugin->group . ' - ' . $plugin->name + ); + + // set lang prefix + $plugin->lang_prefix = PluginHelper::safeLangPrefix( + $plugin->code_name, + $plugin->group + ); + + // set langPrefix + $this->config->lang_prefix = $plugin->lang_prefix; + + // set plugin class name + $plugin->class_name = ucfirst( + $plugin->code_name + ); + // set plugin context name + $plugin->context_name = strtolower((string) + $plugin->code_name + ); + + // set plugin namespace + $plugin->namespace = $plugin->code_name; + + // set plugin group namespace + $plugin->group_namespace = ucfirst( + $plugin->group + ); + + // set plugin install class name + $plugin->installer_class_name + = PluginHelper::safeInstallClassName( + $plugin->code_name, + $plugin->group + ); + + // set plugin folder name + $plugin->folder_name + = PluginHelper::safeFolderName( + $plugin->code_name, + $plugin->group + ); + + // set the zip name + $plugin->zip_name = $plugin->folder_name . '_v' . str_replace( + '.', '_', (string) $plugin->plugin_version + ) . '__J' . $this->config->joomla_version; + + // set plugin file name + $plugin->file_name = $plugin->context_name; + $plugin->class_file_name = $plugin->code_name; + + // set plugin context + $plugin->context = $plugin->folder_name . '.' . $plugin->id; + + // set official_name lang strings + $this->language->set( + $plugin->key, $this->config->lang_prefix, $plugin->official_name + ); + + // set some placeholder for this plugin + $this->placeholder->set('Plugin_name', $plugin->official_name); + $this->placeholder->set('PLUGIN_NAME', $plugin->official_name); + $this->placeholder->set('Plugin', ucfirst((string) $plugin->code_name)); + $this->placeholder->set('plugin', strtolower((string) $plugin->code_name)); + $this->placeholder->set('Plugin_group', ucfirst((string) $plugin->group)); + $this->placeholder->set('plugin_group', strtolower((string) $plugin->group)); + $this->placeholder->set('plugin.version', $plugin->plugin_version); + $this->placeholder->set('VERSION', $plugin->plugin_version); + $this->placeholder->set('plugin_version', str_replace( + '.', '_', (string) $plugin->plugin_version + )); + + // set description + $this->placeholder->set('DESCRIPTION', ''); + if (!isset($plugin->description) + || !StringHelper::check( + $plugin->description + )) + { + $plugin->description = ''; + } + else + { + $plugin->description = $this->placeholder->update_( + $this->customcode->update($plugin->description) + ); + $this->language->set( + $plugin->key, $plugin->lang_prefix . '_DESCRIPTION', + $plugin->description + ); + // set description + $this->placeholder->set('DESCRIPTION', $plugin->description); + $plugin->description = '

' . $plugin->description . '

'; + } + + // get author name + $project_author = $this->config->project_author; + + // we can only set these if the component was passed + $plugin->xml_description = "

" . $plugin->official_name + . " (v." . $plugin->plugin_version + . ")

" + . $plugin->description . "

Created by " . trim( + (string) OutputFilter::cleanText($project_author) + ) . "
Development started " + . Factory::getDate($plugin->created)->format("jS F, Y") + . "

"; + + // set xml discription + $this->language->set( + $plugin->key, $plugin->lang_prefix . '_XML_DESCRIPTION', + $plugin->xml_description + ); + + // update the readme if set + if ($plugin->addreadme == 1 && !empty($plugin->readme)) + { + $plugin->readme = $this->placeholder->update_( + $this->customcode->update(base64_decode((string) $plugin->readme)) + ); + } + else + { + $plugin->addreadme = 0; + unset($plugin->readme); + } + + // open some base64 strings + if (!empty($plugin->main_class_code)) + { + // set GUI mapper field + $guiMapper['field'] = 'main_class_code'; + // base64 Decode main_class_code. + $plugin->main_class_code = $this->gui->set( + $this->placeholder->update_( + $this->customcode->update( + base64_decode((string) $plugin->main_class_code) + ) + ), + $guiMapper + ); + } + + // set the head :) + if ($plugin->add_head == 1 && !empty($plugin->head)) + { + // set GUI mapper field + $guiMapper['field'] = 'head'; + // base64 Decode head. + $plugin->header = $this->gui->set( + $this->placeholder->update_( + $this->customcode->update( + base64_decode((string) $plugin->head) + ) + ), + $guiMapper + ); + } + elseif (!empty($plugin->class_head)) + { + // base64 Decode head. + $plugin->header = $this->gui->set( + $this->placeholder->update_( + $this->customcode->update( + base64_decode((string) $plugin->class_head) + ) + ), + array( + 'table' => 'class_extends', + 'field' => 'head', + 'id' => (int) $plugin->class_id, + 'type' => 'php') + ); + } + unset($plugin->class_head); + + // Check the plugin's code and header for each trait + foreach ($this->service_checks as $key => $info) + { + if (strpos($plugin->main_class_code, $key) !== false || + strpos($plugin->main_class_code, $info['class']) !== false || + strpos($plugin->header, $info['trait']) !== false) + { + $service_provider[] = Indent::_(4) . "\$plugin->{$info['method']}(\$container->get({$info['service']}::class));"; + } + } + + // Assign service provider if any services were added + if (!empty($service_provider)) + { + $plugin->service_provider = implode(PHP_EOL, $service_provider); + } + + // set the comment + if (!empty($plugin->comment)) + { + // base64 Decode comment. + $plugin->comment = $this->gui->set( + $this->placeholder->update_( + $this->customcode->update( + base64_decode((string) $plugin->comment) + ) + ), + array( + 'table' => 'class_extends', + 'field' => 'comment', + 'id' => (int) $plugin->class_id, + 'type' => 'php') + ); + } + + // start the config array + $plugin->config_fields = []; + // create the form arrays + $plugin->form_files = []; + $plugin->fieldsets_label = []; + $plugin->fieldsets_paths = []; + $plugin->add_rule_path = []; + $plugin->add_field_path = []; + // set global fields rule to default component path + $plugin->fields_rules_paths = 1; + // set the fields data + $plugin->fields = (isset($plugin->fields) + && JsonHelper::check($plugin->fields)) + ? json_decode((string) $plugin->fields, true) : null; + if (ArrayHelper::check($plugin->fields)) + { + // ket global key + $key = $plugin->key; + $dynamic_fields = array('fieldset' => 'basic', + 'fields_name' => 'params', + 'file' => 'config'); + foreach ($plugin->fields as $n => &$form) + { + if (isset($form['fields']) + && ArrayHelper::check( + $form['fields'] + )) + { + // make sure the dynamic_field is set to dynamic_value by default + foreach ( + $dynamic_fields as $dynamic_field => + $dynamic_value + ) + { + if (!isset($form[$dynamic_field]) + || !StringHelper::check( + $form[$dynamic_field] + )) + { + $form[$dynamic_field] = $dynamic_value; + } + else + { + if ('fields_name' === $dynamic_field + && strpos((string) $form[$dynamic_field], '.') + !== false) + { + $form[$dynamic_field] + = $form[$dynamic_field]; + } + else + { + $form[$dynamic_field] + = StringHelper::safe( + $form[$dynamic_field] + ); + } + } + } + // check if field is external form file + if (!isset($form['plugin']) || $form['plugin'] != 1) + { + // now build the form key + $unique = $form['file'] . $form['fields_name'] + . $form['fieldset']; + } + else + { + // now build the form key + $unique = $form['fields_name'] + . $form['fieldset']; + } + // set global fields rule path switchs + if ($plugin->fields_rules_paths == 1 + && isset($form['fields_rules_paths']) + && $form['fields_rules_paths'] == 2) + { + $plugin->fields_rules_paths = 2; + } + // set where to path is pointing + $plugin->fieldsets_paths[$unique] + = $form['fields_rules_paths']; + // add the label if set to lang + if (isset($form['label']) + && StringHelper::check( + $form['label'] + )) + { + $plugin->fieldsets_label[$unique] + = $this->language->key($form['label']); + } + // check for extra rule paths + if (isset($form['addrulepath']) + && ArrayHelper::check($form['addrulepath'])) + { + foreach ($form['addrulepath'] as $add_rule_path) + { + if (StringHelper::check($add_rule_path['path'])) + { + $plugin->add_rule_path[$unique] = $add_rule_path['path']; + } + } + } + // check for extra field paths + if (isset($form['addfieldpath']) + && ArrayHelper::check($form['addfieldpath'])) + { + foreach ($form['addfieldpath'] as $add_field_path) + { + if (StringHelper::check($add_field_path['path'])) + { + $plugin->add_field_path[$unique] = $add_field_path['path']; + } + } + } + // build the fields + $form['fields'] = array_map( + function ($field) use ($key, $unique) { + // make sure the alias and title is 0 + $field['alias'] = 0; + $field['title'] = 0; + // set the field details + $this->field->set( + $field, $key, $key, $unique + ); + // update the default if set + if (StringHelper::check( + $field['custom_value'] + ) + && isset($field['settings'])) + { + if (($old_default + = GetHelper::between( + $field['settings']->xml, + 'default="', '"', false + )) !== false) + { + // replace old default + $field['settings']->xml + = str_replace( + 'default="' . $old_default + . '"', 'default="' + . $field['custom_value'] . '"', + (string) $field['settings']->xml + ); + } + else + { + // add the default (hmmm not ideal but okay it should work) + $field['settings']->xml + = 'default="' + . $field['custom_value'] . '" ' + . $field['settings']->xml; + } + } + unset($field['custom_value']); + + // return field + return $field; + }, array_values($form['fields']) + ); + // check if field is external form file + if (!isset($form['plugin']) || $form['plugin'] != 1) + { + // load the form file + if (!isset($plugin->form_files[$form['file']])) + { + $plugin->form_files[$form['file']] + = []; + } + if (!isset($plugin->form_files[$form['file']][$form['fields_name']])) + { + $plugin->form_files[$form['file']][$form['fields_name']] + = []; + } + if (!isset($plugin->form_files[$form['file']][$form['fields_name']][$form['fieldset']])) + { + $plugin->form_files[$form['file']][$form['fields_name']][$form['fieldset']] + = []; + } + // do some house cleaning (for fields) + foreach ($form['fields'] as $field) + { + // so first we lock the field name in + $this->fieldname->get( + $field, $plugin->key, $unique + ); + // add the fields to the global form file builder + $plugin->form_files[$form['file']][$form['fields_name']][$form['fieldset']][] + = $field; + } + // remove form + unset($plugin->fields[$n]); + } + else + { + // load the config form + if (!isset($plugin->config_fields[$form['fields_name']])) + { + $plugin->config_fields[$form['fields_name']] + = []; + } + if (!isset($plugin->config_fields[$form['fields_name']][$form['fieldset']])) + { + $plugin->config_fields[$form['fields_name']][$form['fieldset']] + = []; + } + // do some house cleaning (for fields) + foreach ($form['fields'] as $field) + { + // so first we lock the field name in + $this->fieldname->get( + $field, $plugin->key, $unique + ); + // add the fields to the config builder + $plugin->config_fields[$form['fields_name']][$form['fieldset']][] + = $field; + } + // remove form + unset($plugin->fields[$n]); + } + } + else + { + unset($plugin->fields[$n]); + } + } + } + unset($plugin->fields); + + // set files and folders + $this->filesfolders->set($plugin); + + // add PHP in plugin install + $plugin->add_install_script = true; + $addScriptMethods = [ + 'php_preflight', + 'php_postflight', + 'php_method', + 'php_script' + ]; + $addScriptTypes = [ + 'install', + 'update', + 'uninstall', + 'construct' + ]; + foreach ($addScriptMethods as $scriptMethod) + { + foreach ($addScriptTypes as $scriptType) + { + if (isset( $plugin->{'add_' . $scriptMethod . '_' . $scriptType}) + && $plugin->{'add_' . $scriptMethod . '_' . $scriptType} == 1 + && StringHelper::check( + $plugin->{$scriptMethod . '_' . $scriptType} + )) + { + // set GUI mapper field + $guiMapper['field'] = $scriptMethod . '_' . $scriptType; + $plugin->{$scriptMethod . '_' . $scriptType} = $this->gui->set( + $this->placeholder->update_( + $this->customcode->update( + base64_decode( + (string) $plugin->{$scriptMethod . '_' . $scriptType} + ) + ) + ), + $guiMapper + ); + } + else + { + unset($plugin->{$scriptMethod . '_' . $scriptType}); + $plugin->{'add_' . $scriptMethod . '_' . $scriptType} = 0; + } + } + } + + // add_sql + if ($plugin->add_sql == 1 + && StringHelper::check($plugin->sql)) + { + $plugin->sql = $this->placeholder->update_( + $this->customcode->update(base64_decode((string) $plugin->sql)) + ); + } + else + { + unset($plugin->sql); + $plugin->add_sql = 0; + } + + // add_sql_uninstall + if ($plugin->add_sql_uninstall == 1 + && StringHelper::check( + $plugin->sql_uninstall + )) + { + $plugin->sql_uninstall = $this->placeholder->update_( + $this->customcode->update( + base64_decode((string) $plugin->sql_uninstall) + ) + ); + } + else + { + unset($plugin->sql_uninstall); + $plugin->add_sql_uninstall = 0; + } + + // update the URL of the update_server if set + if ($plugin->add_update_server == 1 + && StringHelper::check( + $plugin->update_server_url + )) + { + $plugin->update_server_url = $this->placeholder->update_( + $this->customcode->update($plugin->update_server_url) + ); + } + + // add the update/sales server FTP details if that is the expected protocol + $serverArray = array('update_server', 'sales_server'); + foreach ($serverArray as $server) + { + if ($plugin->{'add_' . $server} == 1 + && is_numeric( + $plugin->{$server} + ) + && $plugin->{$server} > 0) + { + // get the server protocol + $plugin->{$server . '_protocol'} + = GetHelper::var( + 'server', (int) $plugin->{$server}, 'id', 'protocol' + ); + } + else + { + $plugin->{$server} = 0; + // only change this for sales server (update server can be added locally to the zip file) + if ('sales_server' === $server) + { + $plugin->{'add_' . $server} = 0; + } + $plugin->{$server . '_protocol'} = 0; + } + } + + // old path (to remove) + $plugin->remove_file_paths = []; + $plugin->remove_file_paths[] = "/plugins/{$plugin->group}/{$plugin->context_name}/{$plugin->file_name}.php"; + + // set the update server stuff (TODO) + // update_server_xml_path + // update_server_xml_file_name + + // rest globals + $this->config->build_target = $_backup_target; + $this->config->lang_target = $_backup_lang; + $this->config->set('lang_prefix', $_backup_langPrefix); + + $this->placeholder->remove('Plugin_name'); + $this->placeholder->remove('Plugin'); + $this->placeholder->remove('plugin'); + $this->placeholder->remove('Plugin_group'); + $this->placeholder->remove('plugin_group'); + $this->placeholder->remove('plugin.version'); + $this->placeholder->remove('plugin_version'); + $this->placeholder->remove('VERSION'); + $this->placeholder->remove('DESCRIPTION'); + $this->placeholder->remove('PLUGIN_NAME'); + + $this->data[$id] = $plugin; + + return true; + } + } + + return false; + } \ No newline at end of file diff --git a/src/174f5c9c-5e03-4261-94ca-279ca76c710d/settings.json b/src/174f5c9c-5e03-4261-94ca-279ca76c710d/settings.json new file mode 100644 index 0000000..dcd0237 --- /dev/null +++ b/src/174f5c9c-5e03-4261-94ca-279ca76c710d/settings.json @@ -0,0 +1,82 @@ +{ + "add_head": "1", + "add_licensing_template": "2", + "extends": "", + "guid": "174f5c9c-5e03-4261-94ca-279ca76c710d", + "implements": [ + "8cc85656-a925-4a46-a49b-83c72167fd6a" + ], + "load_selection": null, + "name": "Data", + "power_version": "1.0.0", + "system_name": "JCB.Compiler.Joomlaplugin.J5.Data", + "type": "final class", + "use_selection": { + "use_selection0": { + "use": "fa4bf18e-301e-42e3-91fb-6e0096c07adc", + "as": "default" + }, + "use_selection1": { + "use": "313b43c4-98c3-4f62-9177-2d73ec8eba31", + "as": "default" + }, + "use_selection2": { + "use": "1bd48df2-4f7e-4581-9fe9-4b54e59105e3", + "as": "default" + }, + "use_selection3": { + "use": "06453ada-e370-49f0-b262-e3f5a8ed0c2c", + "as": "default" + }, + "use_selection4": { + "use": "8eee7df5-2775-41a9-9372-c46c5939a252", + "as": "default" + }, + "use_selection5": { + "use": "d7ba2d5d-10b6-470d-978d-9f91ea65ee75", + "as": "default" + }, + "use_selection6": { + "use": "9387215f-a965-4421-acf3-5e8f9d11382f", + "as": "FieldName" + }, + "use_selection7": { + "use": "f4578c04-a81e-4218-b80d-b0612196eaf0", + "as": "default" + }, + "use_selection8": { + "use": "0a59c65c-9daf-4bc9-baf4-e063ff9e6a8a", + "as": "default" + }, + "use_selection9": { + "use": "30c5b4c2-f75f-4d15-869a-f8bfedd87358", + "as": "default" + }, + "use_selection10": { + "use": "3cf76fbf-fd95-4a33-878e-7aff6d36b7f6", + "as": "default" + }, + "use_selection11": { + "use": "4b225c51-d293-48e4-b3f6-5136cf5c3f18", + "as": "default" + }, + "use_selection12": { + "use": "1f28cb53-60d9-4db1-b517-3c7dc6b429ef", + "as": "default" + }, + "use_selection13": { + "use": "db87c339-5bb6-4291-a7ef-2c48ea1b06bc", + "as": "default" + }, + "use_selection14": { + "use": "a68c010b-e92e-47d5-8a44-d23cfddeb6c6", + "as": "default" + } + }, + "extendsinterfaces": null, + "namespace": "[[[NamespacePrefix]]]\\Joomla\\[[[ComponentNamespace]]].Compiler.Joomlaplugin.JoomlaFive.Data", + "description": "Joomla 5 Plug-in Data Class\r\n\r\n@since 5.0.2", + "licensing_template": "\/**\r\n * @package Joomla.Component.Builder\r\n *\r\n * @created 4th September, 2022\r\n * @author Llewellyn van der Merwe \r\n * @git Joomla Component Builder \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;\r\nuse Joomla\\CMS\\Filter\\OutputFilter;", + "composer": "" +} \ No newline at end of file diff --git a/src/1d051a2f-0691-45a8-b3d9-d0c1adcd73bc/README.md b/src/1d051a2f-0691-45a8-b3d9-d0c1adcd73bc/README.md new file mode 100644 index 0000000..2078442 --- /dev/null +++ b/src/1d051a2f-0691-45a8-b3d9-d0c1adcd73bc/README.md @@ -0,0 +1,80 @@ +``` +██████╗ ██████╗ ██╗ ██╗███████╗██████╗ +██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗ +██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝ +██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗ +██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║ +╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝ +``` +# final class Insert (Details) +> namespace: **VDM\Joomla\Componentbuilder\Compiler\Language** + +```uml +@startuml +class Insert << (F,LightGreen) >> #RoyalBlue { + # array $items + # $db + + __construct() + + set(string $target, int $counter, ...) : void + + execute(string $target, int $when = 1) : void +} + +note right of Insert::__construct + Constructor. + + since: 5.0.2 +end note + +note right of Insert::set + Sets a value in a multi-dimensional array within the `items` property. +This method ensures that the array structure is properly initialized before +inserting the value at the specified target and counter position. + + since: 5.0.2 + return: void + + arguments: + string $target + int $counter + string $value +end note + +note right of Insert::execute + Store the language placeholders and execute the database insert operation. +This method checks if the target key exists in the `items` array and if the count +of its elements meets or exceeds the specified threshold (`$when`). If the conditions +are met, it constructs and executes a database insert query to store the language +placeholders. The array of items for the target is then cleared. + + since: 5.0.2 + return: void +end note + +@enduml +``` + +The Power feature in JCB allows you to write PHP classes and their implementations, making it easy to include them in your Joomla project. JCB handles linking, autoloading, namespacing, and folder structure creation for you. + +By using the SPK (Super Power Key) in your custom code (replacing the class name in your code with the SPK), JCB will automatically pull the power from the repository into your project. This makes it available in your JCB instance, allowing you to edit it and include the class in your generated Joomla component. + +JCB uses placeholders like [[[`NamespacePrefix`]]] and [[[`ComponentNamespace`]]] in namespacing to prevent collisions and improve reusability across different JCB systems. You can also set the **JCB powers path** globally or per component under the **Dynamic Integration** tab, providing flexibility and easy maintainability. + +To add this specific Power to your project in JCB: + +> simply use this SPK +``` +Super---1d051a2f_0691_45a8_b3d9_d0c1adcd73bc---Power +``` +> remember to replace the `---` with `___` to activate this Power in your code + +--- +``` + ██╗ ██████╗██████╗ + ██║██╔════╝██╔══██╗ + ██║██║ ██████╔╝ +██ ██║██║ ██╔══██╗ +╚█████╔╝╚██████╗██████╔╝ + ╚════╝ ╚═════╝╚═════╝ +``` +> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder) + diff --git a/src/1d051a2f-0691-45a8-b3d9-d0c1adcd73bc/code.php b/src/1d051a2f-0691-45a8-b3d9-d0c1adcd73bc/code.php new file mode 100644 index 0000000..68ae2b8 --- /dev/null +++ b/src/1d051a2f-0691-45a8-b3d9-d0c1adcd73bc/code.php @@ -0,0 +1,138 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Componentbuilder\Compiler\Language; + + +use Joomla\CMS\Factory; + + +/** + * Compiler Insert New Language Strings + * + * @since 5.0.2 + */ +final class Insert +{ + /** + * The items to insert + * + * @var array + * @since 5.0.2 + **/ + protected array $items = []; + + /** + * Database object to query local DB + * + * @since 5.0.2 + **/ + protected $db; + + /** + * Constructor. + * + * @since 5.0.2 + */ + public function __construct() + { + $this->db = Factory::getDbo(); + } + + /** + * Sets a value in a multi-dimensional array within the `items` property. + * + * This method ensures that the array structure is properly initialized before + * inserting the value at the specified target and counter position. + * + * @param string $target The key in the first dimension of the array. + * @param int $counter The key in the second dimension of the array. + * @param string $value The value to be inserted. + * + * @return void + * @since 5.0.2 + */ + public function set(string $target, int $counter, string $value): void + { + // Ensure the target key exists in the items array + if (!isset($this->items[$target])) + { + $this->items[$target] = []; + } + + // Ensure the counter key exists within the target array + if (!isset($this->items[$target][$counter])) + { + $this->items[$target][$counter] = []; + } + + // Append the value to the array at the specified target and counter position + $this->items[$target][$counter][] = $this->db->quote($value); + } + + /** + * Store the language placeholders and execute the database insert operation. + * + * This method checks if the target key exists in the `items` array and if the count + * of its elements meets or exceeds the specified threshold (`$when`). If the conditions + * are met, it constructs and executes a database insert query to store the language + * placeholders. The array of items for the target is then cleared. + * + * @param string $target The target extension type. + * @param int $when The threshold count to determine when to update. Default is 1. + * + * @return void + * @since 5.0.2 + */ + public function execute(string $target, int $when = 1): void + { + if (isset($this->items[$target]) && count((array) $this->items[$target]) >= $when) + { + // Create a new query object. + $query = $this->db->getQuery(true); + $continue = false; + + // Insert columns. + $columns = array($target, 'source', 'published', 'created', 'created_by', 'version', 'access'); + + // Prepare the insert query. + $query->insert($this->db->quoteName('#__componentbuilder_language_translation')); + $query->columns($this->db->quoteName($columns)); + + foreach ($this->items[$target] as $values) + { + if (count((array) $values) == 7) + { + $query->values(implode(',', $values)); + $continue = true; + } + else + { + // TODO: Handle line mismatch, this should not happen. + } + } + + // Clear the values array. + $this->items[$target] = []; + + if (!$continue) + { + // Ensure we don't continue if no values were loaded. + return; + } + + // Set the query using our newly populated query object and execute it. + $this->db->setQuery($query); + $this->db->execute(); + } + } +} + diff --git a/src/1d051a2f-0691-45a8-b3d9-d0c1adcd73bc/code.power b/src/1d051a2f-0691-45a8-b3d9-d0c1adcd73bc/code.power new file mode 100644 index 0000000..507e639 --- /dev/null +++ b/src/1d051a2f-0691-45a8-b3d9-d0c1adcd73bc/code.power @@ -0,0 +1,112 @@ + /** + * The items to insert + * + * @var array + * @since 5.0.2 + **/ + protected array $items = []; + + /** + * Database object to query local DB + * + * @since 5.0.2 + **/ + protected $db; + + /** + * Constructor. + * + * @since 5.0.2 + */ + public function __construct() + { + $this->db = Factory::getDbo(); + } + + /** + * Sets a value in a multi-dimensional array within the `items` property. + * + * This method ensures that the array structure is properly initialized before + * inserting the value at the specified target and counter position. + * + * @param string $target The key in the first dimension of the array. + * @param int $counter The key in the second dimension of the array. + * @param string $value The value to be inserted. + * + * @return void + * @since 5.0.2 + */ + public function set(string $target, int $counter, string $value): void + { + // Ensure the target key exists in the items array + if (!isset($this->items[$target])) + { + $this->items[$target] = []; + } + + // Ensure the counter key exists within the target array + if (!isset($this->items[$target][$counter])) + { + $this->items[$target][$counter] = []; + } + + // Append the value to the array at the specified target and counter position + $this->items[$target][$counter][] = $this->db->quote($value); + } + + /** + * Store the language placeholders and execute the database insert operation. + * + * This method checks if the target key exists in the `items` array and if the count + * of its elements meets or exceeds the specified threshold (`$when`). If the conditions + * are met, it constructs and executes a database insert query to store the language + * placeholders. The array of items for the target is then cleared. + * + * @param string $target The target extension type. + * @param int $when The threshold count to determine when to update. Default is 1. + * + * @return void + * @since 5.0.2 + */ + public function execute(string $target, int $when = 1): void + { + if (isset($this->items[$target]) && count((array) $this->items[$target]) >= $when) + { + // Create a new query object. + $query = $this->db->getQuery(true); + $continue = false; + + // Insert columns. + $columns = array($target, 'source', 'published', 'created', 'created_by', 'version', 'access'); + + // Prepare the insert query. + $query->insert($this->db->quoteName('#__componentbuilder_language_translation')); + $query->columns($this->db->quoteName($columns)); + + foreach ($this->items[$target] as $values) + { + if (count((array) $values) == 7) + { + $query->values(implode(',', $values)); + $continue = true; + } + else + { + // TODO: Handle line mismatch, this should not happen. + } + } + + // Clear the values array. + $this->items[$target] = []; + + if (!$continue) + { + // Ensure we don't continue if no values were loaded. + return; + } + + // Set the query using our newly populated query object and execute it. + $this->db->setQuery($query); + $this->db->execute(); + } + } \ No newline at end of file diff --git a/src/1d051a2f-0691-45a8-b3d9-d0c1adcd73bc/settings.json b/src/1d051a2f-0691-45a8-b3d9-d0c1adcd73bc/settings.json new file mode 100644 index 0000000..e4d0037 --- /dev/null +++ b/src/1d051a2f-0691-45a8-b3d9-d0c1adcd73bc/settings.json @@ -0,0 +1,19 @@ +{ + "add_head": "1", + "add_licensing_template": "2", + "extends": "", + "guid": "1d051a2f-0691-45a8-b3d9-d0c1adcd73bc", + "implements": null, + "load_selection": null, + "name": "Insert", + "power_version": "1.0.0", + "system_name": "JCB.Compiler.Language.Insert", + "type": "final class", + "use_selection": null, + "extendsinterfaces": null, + "namespace": "[[[NamespacePrefix]]]\\Joomla\\[[[ComponentNamespace]]].Compiler.Language.Insert", + "description": "Compiler Insert New Language Strings\r\n\r\n@since 5.0.2", + "licensing_template": "\/**\r\n * @package Joomla.Component.Builder\r\n *\r\n * @created 4th September, 2022\r\n * @author Llewellyn van der Merwe \r\n * @git Joomla Component Builder \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;", + "composer": "" +} \ No newline at end of file diff --git a/src/1ee227b9-da0f-4e7b-ae66-99a9d53f6f49/README.md b/src/1ee227b9-da0f-4e7b-ae66-99a9d53f6f49/README.md index 25882ed..9be52ce 100644 --- a/src/1ee227b9-da0f-4e7b-ae66-99a9d53f6f49/README.md +++ b/src/1ee227b9-da0f-4e7b-ae66-99a9d53f6f49/README.md @@ -29,7 +29,6 @@ class Header << (F,LightGreen) >> #RoyalBlue { + __construct(Config $config, Event $event, ...) + get(string $context, string $codeName) : string # getHeaders(string $context) : array - # setHelperClassHeader(array $headers, string $target_client) : void } note right of Header::__construct @@ -63,13 +62,6 @@ note right of Header::getHeaders since: 3.2.0 return: array end note - -note right of Header::setHelperClassHeader - set Helper Dynamic Headers - - since: 3.2.0 - return: void -end note @enduml ``` diff --git a/src/1ee227b9-da0f-4e7b-ae66-99a9d53f6f49/code.php b/src/1ee227b9-da0f-4e7b-ae66-99a9d53f6f49/code.php index 807d5cd..5c24e8f 100644 --- a/src/1ee227b9-da0f-4e7b-ae66-99a9d53f6f49/code.php +++ b/src/1ee227b9-da0f-4e7b-ae66-99a9d53f6f49/code.php @@ -228,11 +228,6 @@ final class Header implements HeaderInterface // get dynamic headers switch ($context) { - case 'admin.helper': - case 'site.helper': - $this->setHelperClassHeader($headers, $codeName); - break; - case 'admin.view.html': case 'admin.views.html': case 'custom.admin.view.html': @@ -267,6 +262,10 @@ final class Header implements HeaderInterface $headers[] = 'use Joomla\CMS\Helper\TagsHelper;'; break; + case 'plugin.provider.header': + $headers[] = "use {$this->NamespacePrefix}\\Plugin\\[[[PluginGroupNamespace]]]\\[[[PluginNamespace]]]\\Extension\\{$codeName};"; + break; + default: break; } @@ -553,6 +552,33 @@ final class Header implements HeaderInterface $headers[] = 'use Joomla\CMS\Form\Field\###FORM_EXTENDS###;'; break; + case 'plugin.extension.header': + $headers = []; + break; + case 'plugin.provider.header': + $headers = []; + $headers[] = 'use Joomla\CMS\Factory;'; + $headers[] = 'use Joomla\CMS\Plugin\PluginHelper;'; + $headers[] = 'use Joomla\CMS\Extension\PluginInterface;'; + $headers[] = 'use Joomla\Event\DispatcherInterface;'; + $headers[] = 'use Joomla\DI\ServiceProviderInterface;'; + $headers[] = 'use Joomla\DI\Container;'; + break; + + case 'api.view.controller': + case 'api.views.controller': + $headers = []; + $headers[] = 'use Joomla\CMS\Factory;'; + $headers[] = 'use Joomla\CMS\MVC\Controller\ApiController;'; + break; + + case 'api.view.json': + case 'api.views.json': + $headers = []; + $headers[] = 'use Joomla\CMS\Factory;'; + $headers[] = 'use Joomla\CMS\MVC\View\JsonApiView as BaseApiView;'; + break; + default: break; } @@ -560,26 +586,6 @@ final class Header implements HeaderInterface $this->headers[$context] = $headers; return $headers; - } - - /** - * set Helper Dynamic Headers - * - * @param array $headers The headers array - * @param string $target_client - * - * @return void - * @since 3.2.0 - */ - protected function setHelperClassHeader(&$headers, $target_client) - { - // add only to admin client - if ('admin' === $target_client && $this->config->get('add_eximport', false)) - { - $headers[] = 'use PhpOffice\PhpSpreadsheet\IOFactory;'; - $headers[] = 'use PhpOffice\PhpSpreadsheet\Spreadsheet;'; - $headers[] = 'use PhpOffice\PhpSpreadsheet\Writer\Xlsx;'; - } } } diff --git a/src/1ee227b9-da0f-4e7b-ae66-99a9d53f6f49/code.power b/src/1ee227b9-da0f-4e7b-ae66-99a9d53f6f49/code.power index 2a61f61..6d23938 100644 --- a/src/1ee227b9-da0f-4e7b-ae66-99a9d53f6f49/code.power +++ b/src/1ee227b9-da0f-4e7b-ae66-99a9d53f6f49/code.power @@ -192,11 +192,6 @@ // get dynamic headers switch ($context) { - case 'admin.helper': - case 'site.helper': - $this->setHelperClassHeader($headers, $codeName); - break; - case 'admin.view.html': case 'admin.views.html': case 'custom.admin.view.html': @@ -231,6 +226,10 @@ $headers[] = 'use Joomla\CMS\Helper\TagsHelper;'; break; + case 'plugin.provider.header': + $headers[] = "use {$this->NamespacePrefix}\\Plugin\\[[[PluginGroupNamespace]]]\\[[[PluginNamespace]]]\\Extension\\{$codeName};"; + break; + default: break; } @@ -517,6 +516,33 @@ $headers[] = 'use Joomla\CMS\Form\Field\###FORM_EXTENDS###;'; break; + case 'plugin.extension.header': + $headers = []; + break; + case 'plugin.provider.header': + $headers = []; + $headers[] = 'use Joomla\CMS\Factory;'; + $headers[] = 'use Joomla\CMS\Plugin\PluginHelper;'; + $headers[] = 'use Joomla\CMS\Extension\PluginInterface;'; + $headers[] = 'use Joomla\Event\DispatcherInterface;'; + $headers[] = 'use Joomla\DI\ServiceProviderInterface;'; + $headers[] = 'use Joomla\DI\Container;'; + break; + + case 'api.view.controller': + case 'api.views.controller': + $headers = []; + $headers[] = 'use Joomla\CMS\Factory;'; + $headers[] = 'use Joomla\CMS\MVC\Controller\ApiController;'; + break; + + case 'api.view.json': + case 'api.views.json': + $headers = []; + $headers[] = 'use Joomla\CMS\Factory;'; + $headers[] = 'use Joomla\CMS\MVC\View\JsonApiView as BaseApiView;'; + break; + default: break; } @@ -524,24 +550,4 @@ $this->headers[$context] = $headers; return $headers; - } - - /** - * set Helper Dynamic Headers - * - * @param array $headers The headers array - * @param string $target_client - * - * @return void - * @since 3.2.0 - */ - protected function setHelperClassHeader(&$headers, $target_client) - { - // add only to admin client - if ('admin' === $target_client && $this->config->get('add_eximport', false)) - { - $headers[] = 'use PhpOffice\PhpSpreadsheet\IOFactory;'; - $headers[] = 'use PhpOffice\PhpSpreadsheet\Spreadsheet;'; - $headers[] = 'use PhpOffice\PhpSpreadsheet\Writer\Xlsx;'; - } } \ No newline at end of file diff --git a/src/23f459a4-7c2a-4cbf-b0a6-8a11954140a9/README.md b/src/23f459a4-7c2a-4cbf-b0a6-8a11954140a9/README.md new file mode 100644 index 0000000..46f13b7 --- /dev/null +++ b/src/23f459a4-7c2a-4cbf-b0a6-8a11954140a9/README.md @@ -0,0 +1,66 @@ +``` +██████╗ ██████╗ ██╗ ██╗███████╗██████╗ +██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗ +██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝ +██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗ +██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║ +╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝ +``` +# final class FieldsetExtension (Details) +> namespace: **VDM\Joomla\Componentbuilder\Compiler\Creator** + +```uml +@startuml +class FieldsetExtension << (F,LightGreen) >> #RoyalBlue { + # Placeholder $placeholder + # FieldsetDynamic $fieldsetdynamic + + __construct(Placeholder $placeholder, FieldsetDynamic $fieldsetdynamic) + + get(object $extension, array $fields, ...) : string +} + +note right of FieldsetExtension::__construct + Constructor. + + since: 5.0.2 +end note + +note right of FieldsetExtension::get + build field set for an extention + + since: 5.0.2 + return: string + + arguments: + object $extension + array $fields + string $dbkey = 'zz' +end note + +@enduml +``` + +The Power feature in JCB allows you to write PHP classes and their implementations, making it easy to include them in your Joomla project. JCB handles linking, autoloading, namespacing, and folder structure creation for you. + +By using the SPK (Super Power Key) in your custom code (replacing the class name in your code with the SPK), JCB will automatically pull the power from the repository into your project. This makes it available in your JCB instance, allowing you to edit it and include the class in your generated Joomla component. + +JCB uses placeholders like [[[`NamespacePrefix`]]] and [[[`ComponentNamespace`]]] in namespacing to prevent collisions and improve reusability across different JCB systems. You can also set the **JCB powers path** globally or per component under the **Dynamic Integration** tab, providing flexibility and easy maintainability. + +To add this specific Power to your project in JCB: + +> simply use this SPK +``` +Super---23f459a4_7c2a_4cbf_b0a6_8a11954140a9---Power +``` +> remember to replace the `---` with `___` to activate this Power in your code + +--- +``` + ██╗ ██████╗██████╗ + ██║██╔════╝██╔══██╗ + ██║██║ ██████╔╝ +██ ██║██║ ██╔══██╗ +╚█████╔╝╚██████╗██████╔╝ + ╚════╝ ╚═════╝╚═════╝ +``` +> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder) + diff --git a/src/23f459a4-7c2a-4cbf-b0a6-8a11954140a9/code.php b/src/23f459a4-7c2a-4cbf-b0a6-8a11954140a9/code.php new file mode 100644 index 0000000..1f72846 --- /dev/null +++ b/src/23f459a4-7c2a-4cbf-b0a6-8a11954140a9/code.php @@ -0,0 +1,78 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Componentbuilder\Compiler\Creator; + + +use VDM\Joomla\Componentbuilder\Compiler\Component\Placeholder; +use VDM\Joomla\Componentbuilder\Compiler\Creator\FieldsetDynamic; + + +/** + * Extension Fieldset Creator Class + * + * @since 5.0.2 + */ +final class FieldsetExtension +{ + /** + * The Placeholder Class. + * + * @var Placeholder + * @since 5.0.2 + */ + protected Placeholder $placeholder; + + /** + * The FieldsetDynamic Class. + * + * @var FieldsetDynamic + * @since 5.0.2 + */ + protected FieldsetDynamic $fieldsetdynamic; + + /** + * Constructor. + * + * @param Placeholder $placeholder The Placeholder Class. + * @param FieldsetDynamic $fieldsetdynamic The Fieldset Dynamic Class. + * + * @since 5.0.2 + */ + public function __construct(Placeholder $placeholder, FieldsetDynamic $fieldsetdynamic) + { + $this->placeholder = $placeholder; + $this->fieldsetdynamic = $fieldsetdynamic; + } + + /** + * build field set for an extention + * + * @param object $extension The extention object + * @param array $fields The fields to build + * @param string $dbkey The database key + * + * @return string The fields set in xml + * + * @since 5.0.2 + */ + public function get(object $extension, array $fields, string $dbkey = 'zz'): string + { + // get global placeholders + $placeholder = $this->placeholder->get(); + // build the fieldset + return $this->fieldsetdynamic->get( + $fields, $extension->lang_prefix, $extension->key, $extension->key, + $placeholder, $dbkey + ); + } +} + diff --git a/src/23f459a4-7c2a-4cbf-b0a6-8a11954140a9/code.power b/src/23f459a4-7c2a-4cbf-b0a6-8a11954140a9/code.power new file mode 100644 index 0000000..e0ad54f --- /dev/null +++ b/src/23f459a4-7c2a-4cbf-b0a6-8a11954140a9/code.power @@ -0,0 +1,51 @@ + /** + * The Placeholder Class. + * + * @var Placeholder + * @since 5.0.2 + */ + protected Placeholder $placeholder; + + /** + * The FieldsetDynamic Class. + * + * @var FieldsetDynamic + * @since 5.0.2 + */ + protected FieldsetDynamic $fieldsetdynamic; + + /** + * Constructor. + * + * @param Placeholder $placeholder The Placeholder Class. + * @param FieldsetDynamic $fieldsetdynamic The Fieldset Dynamic Class. + * + * @since 5.0.2 + */ + public function __construct(Placeholder $placeholder, FieldsetDynamic $fieldsetdynamic) + { + $this->placeholder = $placeholder; + $this->fieldsetdynamic = $fieldsetdynamic; + } + + /** + * build field set for an extention + * + * @param object $extension The extention object + * @param array $fields The fields to build + * @param string $dbkey The database key + * + * @return string The fields set in xml + * + * @since 5.0.2 + */ + public function get(object $extension, array $fields, string $dbkey = 'zz'): string + { + // get global placeholders + $placeholder = $this->placeholder->get(); + // build the fieldset + return $this->fieldsetdynamic->get( + $fields, $extension->lang_prefix, $extension->key, $extension->key, + $placeholder, $dbkey + ); + } \ No newline at end of file diff --git a/src/23f459a4-7c2a-4cbf-b0a6-8a11954140a9/settings.json b/src/23f459a4-7c2a-4cbf-b0a6-8a11954140a9/settings.json new file mode 100644 index 0000000..d656b72 --- /dev/null +++ b/src/23f459a4-7c2a-4cbf-b0a6-8a11954140a9/settings.json @@ -0,0 +1,28 @@ +{ + "add_head": "0", + "add_licensing_template": "2", + "extends": "", + "guid": "23f459a4-7c2a-4cbf-b0a6-8a11954140a9", + "implements": null, + "load_selection": null, + "name": "FieldsetExtension", + "power_version": "1.0.0", + "system_name": "JCB.Compiler.Creator.FieldsetExtension", + "type": "final class", + "use_selection": { + "use_selection0": { + "use": "aecc17ba-0b0f-4e5c-ae43-71be063a3dcb", + "as": "default" + }, + "use_selection1": { + "use": "b5986fab-17ca-4236-8c0c-81ebd2bb82ba", + "as": "default" + } + }, + "extendsinterfaces": null, + "namespace": "[[[NamespacePrefix]]]\\Joomla\\[[[ComponentNamespace]]].Compiler.Creator.FieldsetExtension", + "description": "Extension Fieldset Creator Class\r\n\r\n@since 5.0.2", + "licensing_template": "\/**\r\n * @package Joomla.Component.Builder\r\n *\r\n * @created 4th September, 2022\r\n * @author Llewellyn van der Merwe \r\n * @git Joomla Component Builder \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/263f0227-3cc2-4a88-9818-edb20081c30c/README.md b/src/263f0227-3cc2-4a88-9818-edb20081c30c/README.md new file mode 100644 index 0000000..cf03cf5 --- /dev/null +++ b/src/263f0227-3cc2-4a88-9818-edb20081c30c/README.md @@ -0,0 +1,60 @@ +``` +██████╗ ██████╗ ██╗ ██╗███████╗██████╗ +██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗ +██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝ +██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗ +██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║ +╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝ +``` +# final class Multilingual (Details) +> namespace: **VDM\Joomla\Componentbuilder\Compiler\Language** + +```uml +@startuml +class Multilingual << (F,LightGreen) >> #RoyalBlue { + # $db + + __construct() + + get(array $values) : ?array +} + +note right of Multilingual::__construct + Constructor. + + since: 5.0.2 +end note + +note right of Multilingual::get + Get the other languages + + since: 5.0.2 + return: ?array +end note + +@enduml +``` + +The Power feature in JCB allows you to write PHP classes and their implementations, making it easy to include them in your Joomla project. JCB handles linking, autoloading, namespacing, and folder structure creation for you. + +By using the SPK (Super Power Key) in your custom code (replacing the class name in your code with the SPK), JCB will automatically pull the power from the repository into your project. This makes it available in your JCB instance, allowing you to edit it and include the class in your generated Joomla component. + +JCB uses placeholders like [[[`NamespacePrefix`]]] and [[[`ComponentNamespace`]]] in namespacing to prevent collisions and improve reusability across different JCB systems. You can also set the **JCB powers path** globally or per component under the **Dynamic Integration** tab, providing flexibility and easy maintainability. + +To add this specific Power to your project in JCB: + +> simply use this SPK +``` +Super---263f0227_3cc2_4a88_9818_edb20081c30c---Power +``` +> remember to replace the `---` with `___` to activate this Power in your code + +--- +``` + ██╗ ██████╗██████╗ + ██║██╔════╝██╔══██╗ + ██║██║ ██████╔╝ +██ ██║██║ ██╔══██╗ +╚█████╔╝╚██████╗██████╔╝ + ╚════╝ ╚═════╝╚═════╝ +``` +> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder) + diff --git a/src/263f0227-3cc2-4a88-9818-edb20081c30c/code.php b/src/263f0227-3cc2-4a88-9818-edb20081c30c/code.php new file mode 100644 index 0000000..481ccb4 --- /dev/null +++ b/src/263f0227-3cc2-4a88-9818-edb20081c30c/code.php @@ -0,0 +1,90 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Componentbuilder\Compiler\Language; + + +use Joomla\CMS\Factory; +use VDM\Joomla\Utilities\ArrayHelper; + + +/** + * Compiler Language Multilingual + * + * @since 5.0.2 + */ +final class Multilingual +{ + /** + * Database object to query local DB + * + * @since 5.0.2 + **/ + protected $db; + + /** + * Constructor. + * + * @since 5.0.2 + */ + public function __construct() + { + $this->db = Factory::getDbo(); + } + + /** + * Get the other languages + * + * @param array $values The lang strings to get + * + * @return array + * @since 5.0.2 + */ + public function get(array $values): ?array + { + // Create a new query object. + $query = $this->db->getQuery(true); + + $query->from( + $this->db->quoteName( + '#__componentbuilder_language_translation', 'a' + ) + ); + + if (ArrayHelper::check($values)) + { + $query->select( + $this->db->quoteName( + array('a.id', 'a.translation', 'a.source', 'a.components', + 'a.modules', 'a.plugins', 'a.published') + ) + ); + + $query->where( + $this->db->quoteName('a.source') . ' IN (' . implode( + ',', array_map( + fn($a) => $this->db->quote($a), $values + ) + ) . ')' + ); + + $this->db->setQuery($query); + $this->db->execute(); + if ($this->db->getNumRows()) + { + return $this->db->loadAssocList('source'); + } + } + + return null; + } +} + diff --git a/src/263f0227-3cc2-4a88-9818-edb20081c30c/code.power b/src/263f0227-3cc2-4a88-9818-edb20081c30c/code.power new file mode 100644 index 0000000..685d6fa --- /dev/null +++ b/src/263f0227-3cc2-4a88-9818-edb20081c30c/code.power @@ -0,0 +1,63 @@ + /** + * Database object to query local DB + * + * @since 5.0.2 + **/ + protected $db; + + /** + * Constructor. + * + * @since 5.0.2 + */ + public function __construct() + { + $this->db = Factory::getDbo(); + } + + /** + * Get the other languages + * + * @param array $values The lang strings to get + * + * @return array + * @since 5.0.2 + */ + public function get(array $values): ?array + { + // Create a new query object. + $query = $this->db->getQuery(true); + + $query->from( + $this->db->quoteName( + '#__[[[component]]]_language_translation', 'a' + ) + ); + + if (ArrayHelper::check($values)) + { + $query->select( + $this->db->quoteName( + array('a.id', 'a.translation', 'a.source', 'a.components', + 'a.modules', 'a.plugins', 'a.published') + ) + ); + + $query->where( + $this->db->quoteName('a.source') . ' IN (' . implode( + ',', array_map( + fn($a) => $this->db->quote($a), $values + ) + ) . ')' + ); + + $this->db->setQuery($query); + $this->db->execute(); + if ($this->db->getNumRows()) + { + return $this->db->loadAssocList('source'); + } + } + + return null; + } \ No newline at end of file diff --git a/src/263f0227-3cc2-4a88-9818-edb20081c30c/settings.json b/src/263f0227-3cc2-4a88-9818-edb20081c30c/settings.json new file mode 100644 index 0000000..44b0968 --- /dev/null +++ b/src/263f0227-3cc2-4a88-9818-edb20081c30c/settings.json @@ -0,0 +1,24 @@ +{ + "add_head": "1", + "add_licensing_template": "2", + "extends": "", + "guid": "263f0227-3cc2-4a88-9818-edb20081c30c", + "implements": null, + "load_selection": null, + "name": "Multilingual", + "power_version": "1.0.0", + "system_name": "JCB.Compiler.Language.Multilingual", + "type": "final class", + "use_selection": { + "use_selection0": { + "use": "0a59c65c-9daf-4bc9-baf4-e063ff9e6a8a", + "as": "default" + } + }, + "extendsinterfaces": null, + "namespace": "[[[NamespacePrefix]]]\\Joomla\\[[[ComponentNamespace]]].Compiler.Language.Multilingual", + "description": "Compiler Language Multilingual\r\n\r\n@since 5.0.2", + "licensing_template": "\/**\r\n * @package Joomla.Component.Builder\r\n *\r\n * @created 4th September, 2022\r\n * @author Llewellyn van der Merwe \r\n * @git Joomla Component Builder \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;", + "composer": "" +} \ No newline at end of file diff --git a/src/28c8eed4-58cf-4d40-9053-ad77b6edfa9d/README.md b/src/28c8eed4-58cf-4d40-9053-ad77b6edfa9d/README.md new file mode 100644 index 0000000..4eacafc --- /dev/null +++ b/src/28c8eed4-58cf-4d40-9053-ad77b6edfa9d/README.md @@ -0,0 +1,94 @@ +``` +██████╗ ██████╗ ██╗ ██╗███████╗██████╗ +██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗ +██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝ +██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗ +██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║ +╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝ +``` +# final class Extension (Details) +> namespace: **VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaFive\Plugin** + +```uml +@startuml +class Extension << (F,LightGreen) >> #RoyalBlue { + # Placeholder $placeholder + # Builder $builder + # Parser $parser + + __construct(Placeholder $placeholder, Builder $builder, ...) + + get(object $plugin) : string + # addNeededMethods(string $code) : bool + # addGetSubscribedEvents(array $methods) : ?string + # getSubscribedEvents(array $methods) : bool +} + +note right of Extension::__construct + Constructor. + + since: 5.0.2 + + arguments: + Placeholder $placeholder + Builder $builder + Parser $parser +end note + +note right of Extension::get + Get the updated placeholder content for the given plugin. + + since: 5.0.2 + return: string +end note + +note right of Extension::addNeededMethods + Ensures that the required methods are present in the plugin code. +This method checks the plugin's code for the presence of required methods, +particularly the method that indicates implementation of the SubscriberInterface. +If the necessary method is missing, it adds it to the code. + + since: 5.0.2 + return: bool +end note + +note right of Extension::addGetSubscribedEvents + Add the getSubscribedEvents method + + since: 5.0.2 + return: ?string +end note + +note right of Extension::getSubscribedEvents + Check if the getSubscribedEvents is set + + since: 5.0.2 + return: bool +end note + +@enduml +``` + +The Power feature in JCB allows you to write PHP classes and their implementations, making it easy to include them in your Joomla project. JCB handles linking, autoloading, namespacing, and folder structure creation for you. + +By using the SPK (Super Power Key) in your custom code (replacing the class name in your code with the SPK), JCB will automatically pull the power from the repository into your project. This makes it available in your JCB instance, allowing you to edit it and include the class in your generated Joomla component. + +JCB uses placeholders like [[[`NamespacePrefix`]]] and [[[`ComponentNamespace`]]] in namespacing to prevent collisions and improve reusability across different JCB systems. You can also set the **JCB powers path** globally or per component under the **Dynamic Integration** tab, providing flexibility and easy maintainability. + +To add this specific Power to your project in JCB: + +> simply use this SPK +``` +Super---28c8eed4_58cf_4d40_9053_ad77b6edfa9d---Power +``` +> remember to replace the `---` with `___` to activate this Power in your code + +--- +``` + ██╗ ██████╗██████╗ + ██║██╔════╝██╔══██╗ + ██║██║ ██████╔╝ +██ ██║██║ ██╔══██╗ +╚█████╔╝╚██████╗██████╔╝ + ╚════╝ ╚═════╝╚═════╝ +``` +> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder) + diff --git a/src/28c8eed4-58cf-4d40-9053-ad77b6edfa9d/code.php b/src/28c8eed4-58cf-4d40-9053-ad77b6edfa9d/code.php new file mode 100644 index 0000000..d3218db --- /dev/null +++ b/src/28c8eed4-58cf-4d40-9053-ad77b6edfa9d/code.php @@ -0,0 +1,215 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaFive\Plugin; + + +use VDM\Joomla\Componentbuilder\Compiler\Placeholder; +use VDM\Joomla\Componentbuilder\Compiler\Builder\ContentOne as Builder; +use VDM\Joomla\Componentbuilder\Power\Parser; +use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent; +use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Architecture\Plugin\ExtensionInterface; + + +/** + * Plugin Extension Class for Joomla 5 + * + * @since 5.0.2 + */ +final class Extension implements ExtensionInterface +{ + /** + * The Placeholder Class. + * + * @var Placeholder + * @since 5.0.2 + */ + protected Placeholder $placeholder; + + /** + * The ContentOne Class. + * + * @var Builder + * @since 5.0.2 + */ + protected Builder $builder; + + /** + * The Parser Class. + * + * @var Parser + * @since 5.0.2 + */ + protected Parser $parser; + + /** + * Constructor. + * + * @param Placeholder $placeholder The Placeholder Class. + * @param Builder $builder The Content One Class. + * @param Parser $parser The Parser Class. + * + * @since 5.0.2 + */ + public function __construct(Placeholder $placeholder, Builder $builder, Parser $parser) + { + $this->placeholder = $placeholder; + $this->builder = $builder; + $this->parser = $parser; + } + + /** + * Get the updated placeholder content for the given plugin. + * + * @param object $plugin The plugin object containing the necessary data. + * + * @return string The updated placeholder content. + * + * @since 5.0.2 + */ + public function get(object $plugin): string + { + $add_subscriber_interface = $this->addNeededMethods($plugin->main_class_code); + + $extension = []; + $extension[] = $plugin->comment . PHP_EOL . 'final class '; + $extension[] = $plugin->class_name . ' extends ' . $plugin->extends; + if ($add_subscriber_interface) + { + $extension[] = ' implements Joomla__' . '_c06c5116_6b9d_487c_9b09_5094ec4506a3___Power'; + } + $extension[] = PHP_EOL . '{' . PHP_EOL; + $extension[] = $plugin->main_class_code; + $extension[] = PHP_EOL . '}' . PHP_EOL; + + return $this->placeholder->update( + implode('', $extension), + $this->builder->allActive() + ); + } + + /** + * Ensures that the required methods are present in the plugin code. + * + * This method checks the plugin's code for the presence of required methods, + * particularly the method that indicates implementation of the SubscriberInterface. + * If the necessary method is missing, it adds it to the code. + * + * @param string $code The main code of the plugin, passed by reference. + * + * @return bool Returns true if the SubscriberInterface implementation is added or already present, false otherwise. + * + * @since 5.0.2 + */ + protected function addNeededMethods(string &$code): bool + { + // Parse the code to extract its structure, particularly its methods. + $code_structure = $this->parser->code($code); + + if (empty($code_structure['methods'])) + { + return false; + } + + // Check if methods are defined and if getSubscribedEvents is not present. + if (!$this->getSubscribedEvents($code_structure['methods'])) + { + // Attempt to add the getSubscribedEvents method. + $method = $this->addGetSubscribedEvents($code_structure['methods']); + if ($method !== null) + { + // Append the new method to the code and indicate that the interface must be added. + $code .= $method; + + return true; + } + + // Return false if the event method could not be added. + return false; + } + + // Return true if getSubscribedEvents is already present. + return true; + } + + /** + * Add the getSubscribedEvents method + * + * @param array $methods The plugin methods. + * + * @return string|null The getSubscribedEvents code + * + * @since 5.0.2 + */ + protected function addGetSubscribedEvents(array $methods): ?string + { + $events = []; + $counter = 0; + foreach ($methods as $method) + { + if ($method['access'] === 'public' && !$method['static'] && !$method['abstract']) + { + $events[$method['name']] = Indent::_(3) . "'{$method['name']}' => '{$method['name']}'"; + + // autoloaded when method start with 'on' + // so we can ignore adding the getSubscribedEvents + if (substr($method['name'], 0, 2) === 'on') + { + $counter++; + } + } + } + + if ($events === [] || $counter == count($events)) + { + return null; + } + + $method = []; + $method[] = PHP_EOL . PHP_EOL . Indent::_(1) . '/**'; + $method[] = Indent::_(1) . ' * Returns an array of events this subscriber will listen to.'; + $method[] = Indent::_(1) . ' *'; + $method[] = Indent::_(1) . ' * @return array'; + $method[] = Indent::_(1) . ' *'; + $method[] = Indent::_(1) . ' * @since 5.0.0'; + $method[] = Indent::_(1) . ' */'; + $method[] = Indent::_(1) . 'public static function getSubscribedEvents(): array'; + $method[] = Indent::_(1) . '{'; + $method[] = Indent::_(2) . 'return ['; + $method[] = implode(',' . PHP_EOL, $events); + $method[] = Indent::_(2) . '];'; + $method[] = Indent::_(1) . '}'; + + return implode(PHP_EOL, $method); + } + + /** + * Check if the getSubscribedEvents is set + * + * @param array $methods The plugin methods. + * + * @return bool + * + * @since 5.0.2 + */ + protected function getSubscribedEvents(array $methods): bool + { + foreach ($methods as $method) + { + if ($method['name'] === 'getSubscribedEvents' && $method['static'] && !$method['abstract']) + { + return true; + } + } + return false; + } +} + diff --git a/src/28c8eed4-58cf-4d40-9053-ad77b6edfa9d/code.power b/src/28c8eed4-58cf-4d40-9053-ad77b6edfa9d/code.power new file mode 100644 index 0000000..a70193c --- /dev/null +++ b/src/28c8eed4-58cf-4d40-9053-ad77b6edfa9d/code.power @@ -0,0 +1,185 @@ + /** + * The Placeholder Class. + * + * @var Placeholder + * @since 5.0.2 + */ + protected Placeholder $placeholder; + + /** + * The ContentOne Class. + * + * @var Builder + * @since 5.0.2 + */ + protected Builder $builder; + + /** + * The Parser Class. + * + * @var Parser + * @since 5.0.2 + */ + protected Parser $parser; + + /** + * Constructor. + * + * @param Placeholder $placeholder The Placeholder Class. + * @param Builder $builder The Content One Class. + * @param Parser $parser The Parser Class. + * + * @since 5.0.2 + */ + public function __construct(Placeholder $placeholder, Builder $builder, Parser $parser) + { + $this->placeholder = $placeholder; + $this->builder = $builder; + $this->parser = $parser; + } + + /** + * Get the updated placeholder content for the given plugin. + * + * @param object $plugin The plugin object containing the necessary data. + * + * @return string The updated placeholder content. + * + * @since 5.0.2 + */ + public function get(object $plugin): string + { + $add_subscriber_interface = $this->addNeededMethods($plugin->main_class_code); + + $extension = []; + $extension[] = $plugin->comment . PHP_EOL . 'final class '; + $extension[] = $plugin->class_name . ' extends ' . $plugin->extends; + if ($add_subscriber_interface) + { + $extension[] = ' implements Joomla__' . '_c06c5116_6b9d_487c_9b09_5094ec4506a3___Power'; + } + $extension[] = PHP_EOL . '{' . PHP_EOL; + $extension[] = $plugin->main_class_code; + $extension[] = PHP_EOL . '}' . PHP_EOL; + + return $this->placeholder->update( + implode('', $extension), + $this->builder->allActive() + ); + } + + /** + * Ensures that the required methods are present in the plugin code. + * + * This method checks the plugin's code for the presence of required methods, + * particularly the method that indicates implementation of the SubscriberInterface. + * If the necessary method is missing, it adds it to the code. + * + * @param string $code The main code of the plugin, passed by reference. + * + * @return bool Returns true if the SubscriberInterface implementation is added or already present, false otherwise. + * + * @since 5.0.2 + */ + protected function addNeededMethods(string &$code): bool + { + // Parse the code to extract its structure, particularly its methods. + $code_structure = $this->parser->code($code); + + if (empty($code_structure['methods'])) + { + return false; + } + + // Check if methods are defined and if getSubscribedEvents is not present. + if (!$this->getSubscribedEvents($code_structure['methods'])) + { + // Attempt to add the getSubscribedEvents method. + $method = $this->addGetSubscribedEvents($code_structure['methods']); + if ($method !== null) + { + // Append the new method to the code and indicate that the interface must be added. + $code .= $method; + + return true; + } + + // Return false if the event method could not be added. + return false; + } + + // Return true if getSubscribedEvents is already present. + return true; + } + + /** + * Add the getSubscribedEvents method + * + * @param array $methods The plugin methods. + * + * @return string|null The getSubscribedEvents code + * + * @since 5.0.2 + */ + protected function addGetSubscribedEvents(array $methods): ?string + { + $events = []; + $counter = 0; + foreach ($methods as $method) + { + if ($method['access'] === 'public' && !$method['static'] && !$method['abstract']) + { + $events[$method['name']] = Indent::_(3) . "'{$method['name']}' => '{$method['name']}'"; + + // autoloaded when method start with 'on' + // so we can ignore adding the getSubscribedEvents + if (substr($method['name'], 0, 2) === 'on') + { + $counter++; + } + } + } + + if ($events === [] || $counter == count($events)) + { + return null; + } + + $method = []; + $method[] = PHP_EOL . PHP_EOL . Indent::_(1) . '/**'; + $method[] = Indent::_(1) . ' * Returns an array of events this subscriber will listen to.'; + $method[] = Indent::_(1) . ' *'; + $method[] = Indent::_(1) . ' * @return array'; + $method[] = Indent::_(1) . ' *'; + $method[] = Indent::_(1) . ' * @since 5.0.0'; + $method[] = Indent::_(1) . ' */'; + $method[] = Indent::_(1) . 'public static function getSubscribedEvents(): array'; + $method[] = Indent::_(1) . '{'; + $method[] = Indent::_(2) . 'return ['; + $method[] = implode(',' . PHP_EOL, $events); + $method[] = Indent::_(2) . '];'; + $method[] = Indent::_(1) . '}'; + + return implode(PHP_EOL, $method); + } + + /** + * Check if the getSubscribedEvents is set + * + * @param array $methods The plugin methods. + * + * @return bool + * + * @since 5.0.2 + */ + protected function getSubscribedEvents(array $methods): bool + { + foreach ($methods as $method) + { + if ($method['name'] === 'getSubscribedEvents' && $method['static'] && !$method['abstract']) + { + return true; + } + } + return false; + } \ No newline at end of file diff --git a/src/28c8eed4-58cf-4d40-9053-ad77b6edfa9d/settings.json b/src/28c8eed4-58cf-4d40-9053-ad77b6edfa9d/settings.json new file mode 100644 index 0000000..88c3ecb --- /dev/null +++ b/src/28c8eed4-58cf-4d40-9053-ad77b6edfa9d/settings.json @@ -0,0 +1,38 @@ +{ + "add_head": "0", + "add_licensing_template": "2", + "extends": "", + "guid": "28c8eed4-58cf-4d40-9053-ad77b6edfa9d", + "implements": [ + "914db7f5-82d8-4d3b-a1c1-eb476b1898c2" + ], + "load_selection": null, + "name": "Extension", + "power_version": "1.0.0", + "system_name": "JCB.Architecture.J5.Plugin.Extension", + "type": "final class", + "use_selection": { + "use_selection0": { + "use": "06453ada-e370-49f0-b262-e3f5a8ed0c2c", + "as": "default" + }, + "use_selection1": { + "use": "adfbe68a-6d22-43e5-aee8-2787e8c47e75", + "as": "Builder" + }, + "use_selection2": { + "use": "95d0e03f-24fd-4412-bc2e-f0899fcc3205", + "as": "default" + }, + "use_selection3": { + "use": "a68c010b-e92e-47d5-8a44-d23cfddeb6c6", + "as": "default" + } + }, + "extendsinterfaces": null, + "namespace": "[[[NamespacePrefix]]]\\Joomla\\[[[ComponentNamespace]]].Compiler.Architecture.JoomlaFive.Plugin.Extension", + "description": "Plugin Extension Class for Joomla 5\r\n\r\n@since 5.0.2", + "licensing_template": "\/**\r\n * @package Joomla.Component.Builder\r\n *\r\n * @created 4th September, 2022\r\n * @author Llewellyn van der Merwe \r\n * @git Joomla Component Builder \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/2c76c06e-a371-4b73-9fbe-b4d9b4df55d7/README.md b/src/2c76c06e-a371-4b73-9fbe-b4d9b4df55d7/README.md index 449a16f..fc08bbe 100644 --- a/src/2c76c06e-a371-4b73-9fbe-b4d9b4df55d7/README.md +++ b/src/2c76c06e-a371-4b73-9fbe-b4d9b4df55d7/README.md @@ -30,6 +30,7 @@ class BuilderLZ #Gold { + getModelMediumField(Container $container) : ModelMediumField + getModelWhmcsField(Container $container) : ModelWhmcsField + getMovedPublishingFields(Container $container) : MovedPublishingFields + + getMultilingual(Container $container) : Multilingual + getMysqlTableSetting(Container $container) : MysqlTableSetting + getNewPublishingFields(Container $container) : NewPublishingFields + getOrderZero(Container $container) : OrderZero @@ -195,259 +196,266 @@ note left of BuilderLZ::getMovedPublishingFields return: MovedPublishingFields end note -note right of BuilderLZ::getMysqlTableSetting +note right of BuilderLZ::getMultilingual + Get The Multilingual Class. + + since: 3.2.0 + return: Multilingual +end note + +note left of BuilderLZ::getMysqlTableSetting Get The MysqlTableSetting Class. since: 3.2.0 return: MysqlTableSetting end note -note left of BuilderLZ::getNewPublishingFields +note right of BuilderLZ::getNewPublishingFields Get The NewPublishingFields Class. since: 3.2.0 return: NewPublishingFields end note -note right of BuilderLZ::getOrderZero +note left of BuilderLZ::getOrderZero Get The OrderZero Class. since: 3.2.0 return: OrderZero end note -note left of BuilderLZ::getOtherFilter +note right of BuilderLZ::getOtherFilter Get The OtherFilter Class. since: 3.2.0 return: OtherFilter end note -note right of BuilderLZ::getOtherGroup +note left of BuilderLZ::getOtherGroup Get The OtherGroup Class. since: 3.2.0 return: OtherGroup end note -note left of BuilderLZ::getOtherJoin +note right of BuilderLZ::getOtherJoin Get The OtherJoin Class. since: 3.2.0 return: OtherJoin end note -note right of BuilderLZ::getOtherOrder +note left of BuilderLZ::getOtherOrder Get The OtherOrder Class. since: 3.2.0 return: OtherOrder end note -note left of BuilderLZ::getOtherQuery +note right of BuilderLZ::getOtherQuery Get The OtherQuery Class. since: 3.2.0 return: OtherQuery end note -note right of BuilderLZ::getOtherWhere +note left of BuilderLZ::getOtherWhere Get The OtherWhere Class. since: 3.2.0 return: OtherWhere end note -note left of BuilderLZ::getPermissionAction +note right of BuilderLZ::getPermissionAction Get The PermissionAction Class. since: 3.2.0 return: PermissionAction end note -note right of BuilderLZ::getPermissionComponent +note left of BuilderLZ::getPermissionComponent Get The PermissionComponent Class. since: 3.2.0 return: PermissionComponent end note -note left of BuilderLZ::getPermissionCore +note right of BuilderLZ::getPermissionCore Get The PermissionCore Class. since: 3.2.0 return: PermissionCore end note -note right of BuilderLZ::getPermissionDashboard +note left of BuilderLZ::getPermissionDashboard Get The PermissionDashboard Class. since: 3.2.0 return: PermissionDashboard end note -note left of BuilderLZ::getPermissionFields +note right of BuilderLZ::getPermissionFields Get The PermissionFields Class. since: 3.2.0 return: PermissionFields end note -note right of BuilderLZ::getPermissionGlobalAction +note left of BuilderLZ::getPermissionGlobalAction Get The PermissionGlobalAction Class. since: 3.2.0 return: PermissionGlobalAction end note -note left of BuilderLZ::getPermissionViews +note right of BuilderLZ::getPermissionViews Get The PermissionViews Class. since: 3.2.0 return: PermissionViews end note -note right of BuilderLZ::getRequest +note left of BuilderLZ::getRequest Get The Request Class. since: 3.2.0 return: Request end note -note left of BuilderLZ::getRouter +note right of BuilderLZ::getRouter Get The Router Class. since: 3.2.0 return: Router end note -note right of BuilderLZ::getScriptMediaSwitch +note left of BuilderLZ::getScriptMediaSwitch Get The ScriptMediaSwitch Class. since: 3.2.0 return: ScriptMediaSwitch end note -note left of BuilderLZ::getScriptUserSwitch +note right of BuilderLZ::getScriptUserSwitch Get The ScriptUserSwitch Class. since: 3.2.0 return: ScriptUserSwitch end note -note right of BuilderLZ::getSearch +note left of BuilderLZ::getSearch Get The Search Class. since: 3.2.0 return: Search end note -note left of BuilderLZ::getSelectionTranslation +note right of BuilderLZ::getSelectionTranslation Get The SelectionTranslation Class. since: 3.2.0 return: SelectionTranslation end note -note right of BuilderLZ::getSiteDecrypt +note left of BuilderLZ::getSiteDecrypt Get The SiteDecrypt Class. since: 3.2.0 return: SiteDecrypt end note -note left of BuilderLZ::getSiteDynamicGet +note right of BuilderLZ::getSiteDynamicGet Get The SiteDynamicGet Class. since: 3.2.0 return: SiteDynamicGet end note -note right of BuilderLZ::getSiteEditView +note left of BuilderLZ::getSiteEditView Get The SiteEditView Class. since: 3.2.0 return: SiteEditView end note -note left of BuilderLZ::getSiteFieldData +note right of BuilderLZ::getSiteFieldData Get The SiteFieldData Class. since: 3.2.0 return: SiteFieldData end note -note right of BuilderLZ::getSiteFieldDecodeFilter +note left of BuilderLZ::getSiteFieldDecodeFilter Get The SiteFieldDecodeFilter Class. since: 3.2.0 return: SiteFieldDecodeFilter end note -note left of BuilderLZ::getSiteFields +note right of BuilderLZ::getSiteFields Get The SiteFields Class. since: 3.2.0 return: SiteFields end note -note right of BuilderLZ::getSiteMainGet +note left of BuilderLZ::getSiteMainGet Get The SiteMainGet Class. since: 3.2.0 return: SiteMainGet end note -note left of BuilderLZ::getSort +note right of BuilderLZ::getSort Get The Sort Class. since: 3.2.0 return: Sort end note -note right of BuilderLZ::getTabCounter +note left of BuilderLZ::getTabCounter Get The TabCounter Class. since: 3.2.0 return: TabCounter end note -note left of BuilderLZ::getTags +note right of BuilderLZ::getTags Get The Tags Class. since: 3.2.0 return: Tags end note -note right of BuilderLZ::getTemplateData +note left of BuilderLZ::getTemplateData Get The TemplateData Class. since: 3.2.0 return: TemplateData end note -note left of BuilderLZ::getTitle +note right of BuilderLZ::getTitle Get The Title Class. since: 3.2.0 return: Title end note -note right of BuilderLZ::getUikitComp +note left of BuilderLZ::getUikitComp Get The UikitComp Class. since: 3.2.0 return: UikitComp end note -note left of BuilderLZ::getUpdateMysql +note right of BuilderLZ::getUpdateMysql Get The UpdateMysql Class. since: 3.2.0 return: UpdateMysql end note -note right of BuilderLZ::getViewsDefaultOrdering +note left of BuilderLZ::getViewsDefaultOrdering Get The ViewsDefaultOrdering Class. since: 3.2.0 diff --git a/src/2c76c06e-a371-4b73-9fbe-b4d9b4df55d7/code.php b/src/2c76c06e-a371-4b73-9fbe-b4d9b4df55d7/code.php index 6a8a6a6..a202629 100644 --- a/src/2c76c06e-a371-4b73-9fbe-b4d9b4df55d7/code.php +++ b/src/2c76c06e-a371-4b73-9fbe-b4d9b4df55d7/code.php @@ -31,6 +31,7 @@ use VDM\Joomla\Componentbuilder\Compiler\Builder\ModelExpertFieldInitiator; use VDM\Joomla\Componentbuilder\Compiler\Builder\ModelMediumField; use VDM\Joomla\Componentbuilder\Compiler\Builder\ModelWhmcsField; use VDM\Joomla\Componentbuilder\Compiler\Builder\MovedPublishingFields; +use VDM\Joomla\Componentbuilder\Compiler\Builder\Multilingual; use VDM\Joomla\Componentbuilder\Compiler\Builder\MysqlTableSetting; use VDM\Joomla\Componentbuilder\Compiler\Builder\NewPublishingFields; use VDM\Joomla\Componentbuilder\Compiler\Builder\OrderZero; @@ -77,879 +78,895 @@ use VDM\Joomla\Componentbuilder\Compiler\Builder\ViewsDefaultOrdering; */ class BuilderLZ 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(Languages::class, 'Compiler.Builder.Languages') - ->share('Compiler.Builder.Languages', [$this, 'getLanguages'], true); - - $container->alias(LanguageMessages::class, 'Compiler.Builder.Language.Messages') - ->share('Compiler.Builder.Language.Messages', [$this, 'getLanguageMessages'], true); - - $container->alias(Layout::class, 'Compiler.Builder.Layout') - ->share('Compiler.Builder.Layout', [$this, 'getLayout'], true); - - $container->alias(LayoutData::class, 'Compiler.Builder.Layout.Data') - ->share('Compiler.Builder.Layout.Data', [$this, 'getLayoutData'], true); - - $container->alias(LibraryManager::class, 'Compiler.Builder.Library.Manager') - ->share('Compiler.Builder.Library.Manager', [$this, 'getLibraryManager'], true); - - $container->alias(ListFieldClass::class, 'Compiler.Builder.List.Field.Class') - ->share('Compiler.Builder.List.Field.Class', [$this, 'getListFieldClass'], true); - - $container->alias(ListHeadOverride::class, 'Compiler.Builder.List.Head.Override') - ->share('Compiler.Builder.List.Head.Override', [$this, 'getListHeadOverride'], true); - - $container->alias(ListJoin::class, 'Compiler.Builder.List.Join') - ->share('Compiler.Builder.List.Join', [$this, 'getListJoin'], true); - - $container->alias(Lists::class, 'Compiler.Builder.Lists') - ->share('Compiler.Builder.Lists', [$this, 'getLists'], true); - - $container->alias(MainTextField::class, 'Compiler.Builder.Main.Text.Field') - ->share('Compiler.Builder.Main.Text.Field', [$this, 'getMainTextField'], true); - - $container->alias(MetaData::class, 'Compiler.Builder.Meta.Data') - ->share('Compiler.Builder.Meta.Data', [$this, 'getMetaData'], true); - - $container->alias(ModelBasicField::class, 'Compiler.Builder.Model.Basic.Field') - ->share('Compiler.Builder.Model.Basic.Field', [$this, 'getModelBasicField'], true); - - $container->alias(ModelExpertField::class, 'Compiler.Builder.Model.Expert.Field') - ->share('Compiler.Builder.Model.Expert.Field', [$this, 'getModelExpertField'], true); - - $container->alias(ModelExpertFieldInitiator::class, 'Compiler.Builder.Model.Expert.Field.Initiator') - ->share('Compiler.Builder.Model.Expert.Field.Initiator', [$this, 'getModelExpertFieldInitiator'], true); - - $container->alias(ModelMediumField::class, 'Compiler.Builder.Model.Medium.Field') - ->share('Compiler.Builder.Model.Medium.Field', [$this, 'getModelMediumField'], true); - - $container->alias(ModelWhmcsField::class, 'Compiler.Builder.Model.Whmcs.Field') - ->share('Compiler.Builder.Model.Whmcs.Field', [$this, 'getModelWhmcsField'], true); - - $container->alias(MovedPublishingFields::class, 'Compiler.Builder.Moved.Publishing.Fields') - ->share('Compiler.Builder.Moved.Publishing.Fields', [$this, 'getMovedPublishingFields'], true); - - $container->alias(MysqlTableSetting::class, 'Compiler.Builder.Mysql.Table.Setting') - ->share('Compiler.Builder.Mysql.Table.Setting', [$this, 'getMysqlTableSetting'], true); - - $container->alias(NewPublishingFields::class, 'Compiler.Builder.New.Publishing.Fields') - ->share('Compiler.Builder.New.Publishing.Fields', [$this, 'getNewPublishingFields'], true); - - $container->alias(OrderZero::class, 'Compiler.Builder.Order.Zero') - ->share('Compiler.Builder.Order.Zero', [$this, 'getOrderZero'], true); - - $container->alias(OtherFilter::class, 'Compiler.Builder.Other.Filter') - ->share('Compiler.Builder.Other.Filter', [$this, 'getOtherFilter'], true); - - $container->alias(OtherGroup::class, 'Compiler.Builder.Other.Group') - ->share('Compiler.Builder.Other.Group', [$this, 'getOtherGroup'], true); - - $container->alias(OtherJoin::class, 'Compiler.Builder.Other.Join') - ->share('Compiler.Builder.Other.Join', [$this, 'getOtherJoin'], true); - - $container->alias(OtherOrder::class, 'Compiler.Builder.Other.Order') - ->share('Compiler.Builder.Other.Order', [$this, 'getOtherOrder'], true); - - $container->alias(OtherQuery::class, 'Compiler.Builder.Other.Query') - ->share('Compiler.Builder.Other.Query', [$this, 'getOtherQuery'], true); - - $container->alias(OtherWhere::class, 'Compiler.Builder.Other.Where') - ->share('Compiler.Builder.Other.Where', [$this, 'getOtherWhere'], true); - - $container->alias(PermissionAction::class, 'Compiler.Builder.Permission.Action') - ->share('Compiler.Builder.Permission.Action', [$this, 'getPermissionAction'], true); - - $container->alias(PermissionComponent::class, 'Compiler.Builder.Permission.Component') - ->share('Compiler.Builder.Permission.Component', [$this, 'getPermissionComponent'], true); - - $container->alias(PermissionCore::class, 'Compiler.Builder.Permission.Core') - ->share('Compiler.Builder.Permission.Core', [$this, 'getPermissionCore'], true); - - $container->alias(PermissionDashboard::class, 'Compiler.Builder.Permission.Dashboard') - ->share('Compiler.Builder.Permission.Dashboard', [$this, 'getPermissionDashboard'], true); - - $container->alias(PermissionFields::class, 'Compiler.Builder.Permission.Fields') - ->share('Compiler.Builder.Permission.Fields', [$this, 'getPermissionFields'], true); - - $container->alias(PermissionGlobalAction::class, 'Compiler.Builder.Permission.Global.Action') - ->share('Compiler.Builder.Permission.Global.Action', [$this, 'getPermissionGlobalAction'], true); - - $container->alias(PermissionViews::class, 'Compiler.Builder.Permission.Views') - ->share('Compiler.Builder.Permission.Views', [$this, 'getPermissionViews'], true); - - $container->alias(Request::class, 'Compiler.Builder.Request') - ->share('Compiler.Builder.Request', [$this, 'getRequest'], true); - - $container->alias(Router::class, 'Compiler.Builder.Router') - ->share('Compiler.Builder.Router', [$this, 'getRouter'], true); - - $container->alias(ScriptMediaSwitch::class, 'Compiler.Builder.Script.Media.Switch') - ->share('Compiler.Builder.Script.Media.Switch', [$this, 'getScriptMediaSwitch'], true); - - $container->alias(ScriptUserSwitch::class, 'Compiler.Builder.Script.User.Switch') - ->share('Compiler.Builder.Script.User.Switch', [$this, 'getScriptUserSwitch'], true); - - $container->alias(Search::class, 'Compiler.Builder.Search') - ->share('Compiler.Builder.Search', [$this, 'getSearch'], true); - - $container->alias(SelectionTranslation::class, 'Compiler.Builder.Selection.Translation') - ->share('Compiler.Builder.Selection.Translation', [$this, 'getSelectionTranslation'], true); - - $container->alias(SiteDecrypt::class, 'Compiler.Builder.Site.Decrypt') - ->share('Compiler.Builder.Site.Decrypt', [$this, 'getSiteDecrypt'], true); - - $container->alias(SiteDynamicGet::class, 'Compiler.Builder.Site.Dynamic.Get') - ->share('Compiler.Builder.Site.Dynamic.Get', [$this, 'getSiteDynamicGet'], true); - - $container->alias(SiteEditView::class, 'Compiler.Builder.Site.Edit.View') - ->share('Compiler.Builder.Site.Edit.View', [$this, 'getSiteEditView'], true); - - $container->alias(SiteFieldData::class, 'Compiler.Builder.Site.Field.Data') - ->share('Compiler.Builder.Site.Field.Data', [$this, 'getSiteFieldData'], true); - - $container->alias(SiteFieldDecodeFilter::class, 'Compiler.Builder.Site.Field.Decode.Filter') - ->share('Compiler.Builder.Site.Field.Decode.Filter', [$this, 'getSiteFieldDecodeFilter'], true); - - $container->alias(SiteFields::class, 'Compiler.Builder.Site.Fields') - ->share('Compiler.Builder.Site.Fields', [$this, 'getSiteFields'], true); - - $container->alias(SiteMainGet::class, 'Compiler.Builder.Site.Main.Get') - ->share('Compiler.Builder.Site.Main.Get', [$this, 'getSiteMainGet'], true); - - $container->alias(Sort::class, 'Compiler.Builder.Sort') - ->share('Compiler.Builder.Sort', [$this, 'getSort'], true); - - $container->alias(TabCounter::class, 'Compiler.Builder.Tab.Counter') - ->share('Compiler.Builder.Tab.Counter', [$this, 'getTabCounter'], true); - - $container->alias(Tags::class, 'Compiler.Builder.Tags') - ->share('Compiler.Builder.Tags', [$this, 'getTags'], true); - - $container->alias(TemplateData::class, 'Compiler.Builder.Template.Data') - ->share('Compiler.Builder.Template.Data', [$this, 'getTemplateData'], true); - - $container->alias(Title::class, 'Compiler.Builder.Title') - ->share('Compiler.Builder.Title', [$this, 'getTitle'], true); - - $container->alias(UikitComp::class, 'Compiler.Builder.Uikit.Comp') - ->share('Compiler.Builder.Uikit.Comp', [$this, 'getUikitComp'], true); - - $container->alias(UpdateMysql::class, 'Compiler.Builder.Update.Mysql') - ->share('Compiler.Builder.Update.Mysql', [$this, 'getUpdateMysql'], true); - - $container->alias(ViewsDefaultOrdering::class, 'Compiler.Builder.Views.Default.Ordering') - ->share('Compiler.Builder.Views.Default.Ordering', [$this, 'getViewsDefaultOrdering'], true); - } - - /** - * Get The Languages Class. - * - * @param Container $container The DI container. - * - * @return Languages - * @since 3.2.0 - */ - public function getLanguages(Container $container): Languages - { - return new Languages(); - } - - /** - * Get The LanguageMessages Class. - * - * @param Container $container The DI container. - * - * @return LanguageMessages - * @since 3.2.0 - */ - public function getLanguageMessages(Container $container): LanguageMessages - { - return new LanguageMessages(); - } - - /** - * Get The Layout Class. - * - * @param Container $container The DI container. - * - * @return Layout - * @since 3.2.0 - */ - public function getLayout(Container $container): Layout - { - return new Layout(); - } - - /** - * Get The LayoutData Class. - * - * @param Container $container The DI container. - * - * @return LayoutData - * @since 3.2.0 - */ - public function getLayoutData(Container $container): LayoutData - { - return new LayoutData(); - } - - /** - * Get The LibraryManager Class. - * - * @param Container $container The DI container. - * - * @return LibraryManager - * @since 3.2.0 - */ - public function getLibraryManager(Container $container): LibraryManager - { - return new LibraryManager(); - } - - /** - * Get The ListFieldClass Class. - * - * @param Container $container The DI container. - * - * @return ListFieldClass - * @since 3.2.0 - */ - public function getListFieldClass(Container $container): ListFieldClass - { - return new ListFieldClass(); - } - - /** - * Get The ListHeadOverride Class. - * - * @param Container $container The DI container. - * - * @return ListHeadOverride - * @since 3.2.0 - */ - public function getListHeadOverride(Container $container): ListHeadOverride - { - return new ListHeadOverride(); - } - - /** - * Get The ListJoin Class. - * - * @param Container $container The DI container. - * - * @return ListJoin - * @since 3.2.0 - */ - public function getListJoin(Container $container): ListJoin - { - return new ListJoin(); - } - - /** - * Get The Lists Class. - * - * @param Container $container The DI container. - * - * @return Lists - * @since 3.2.0 - */ - public function getLists(Container $container): Lists - { - return new Lists(); - } - - /** - * Get The MainTextField Class. - * - * @param Container $container The DI container. - * - * @return MainTextField - * @since 3.2.0 - */ - public function getMainTextField(Container $container): MainTextField - { - return new MainTextField(); - } - - /** - * Get The MetaData Class. - * - * @param Container $container The DI container. - * - * @return MetaData - * @since 3.2.0 - */ - public function getMetaData(Container $container): MetaData - { - return new MetaData(); - } - - /** - * Get The ModelBasicField Class. - * - * @param Container $container The DI container. - * - * @return ModelBasicField - * @since 3.2.0 - */ - public function getModelBasicField(Container $container): ModelBasicField - { - return new ModelBasicField(); - } - - /** - * Get The ModelExpertField Class. - * - * @param Container $container The DI container. - * - * @return ModelExpertField - * @since 3.2.0 - */ - public function getModelExpertField(Container $container): ModelExpertField - { - return new ModelExpertField(); - } - - /** - * Get The ModelExpertFieldInitiator Class. - * - * @param Container $container The DI container. - * - * @return ModelExpertFieldInitiator - * @since 3.2.0 - */ - public function getModelExpertFieldInitiator(Container $container): ModelExpertFieldInitiator - { - return new ModelExpertFieldInitiator(); - } - - /** - * Get The ModelMediumField Class. - * - * @param Container $container The DI container. - * - * @return ModelMediumField - * @since 3.2.0 - */ - public function getModelMediumField(Container $container): ModelMediumField - { - return new ModelMediumField(); - } - - /** - * Get The ModelWhmcsField Class. - * - * @param Container $container The DI container. - * - * @return ModelWhmcsField - * @since 3.2.0 - */ - public function getModelWhmcsField(Container $container): ModelWhmcsField - { - return new ModelWhmcsField(); - } - - /** - * Get The MovedPublishingFields Class. - * - * @param Container $container The DI container. - * - * @return MovedPublishingFields - * @since 3.2.0 - */ - public function getMovedPublishingFields(Container $container): MovedPublishingFields - { - return new MovedPublishingFields(); - } - - /** - * Get The MysqlTableSetting Class. - * - * @param Container $container The DI container. - * - * @return MysqlTableSetting - * @since 3.2.0 - */ - public function getMysqlTableSetting(Container $container): MysqlTableSetting - { - return new MysqlTableSetting(); - } - - /** - * Get The NewPublishingFields Class. - * - * @param Container $container The DI container. - * - * @return NewPublishingFields - * @since 3.2.0 - */ - public function getNewPublishingFields(Container $container): NewPublishingFields - { - return new NewPublishingFields(); - } - - /** - * Get The OrderZero Class. - * - * @param Container $container The DI container. - * - * @return OrderZero - * @since 3.2.0 - */ - public function getOrderZero(Container $container): OrderZero - { - return new OrderZero(); - } - - /** - * Get The OtherFilter Class. - * - * @param Container $container The DI container. - * - * @return OtherFilter - * @since 3.2.0 - */ - public function getOtherFilter(Container $container): OtherFilter - { - return new OtherFilter(); - } - - /** - * Get The OtherGroup Class. - * - * @param Container $container The DI container. - * - * @return OtherGroup - * @since 3.2.0 - */ - public function getOtherGroup(Container $container): OtherGroup - { - return new OtherGroup(); - } - - /** - * Get The OtherJoin Class. - * - * @param Container $container The DI container. - * - * @return OtherJoin - * @since 3.2.0 - */ - public function getOtherJoin(Container $container): OtherJoin - { - return new OtherJoin(); - } - - /** - * Get The OtherOrder Class. - * - * @param Container $container The DI container. - * - * @return OtherOrder - * @since 3.2.0 - */ - public function getOtherOrder(Container $container): OtherOrder - { - return new OtherOrder(); - } - - /** - * Get The OtherQuery Class. - * - * @param Container $container The DI container. - * - * @return OtherQuery - * @since 3.2.0 - */ - public function getOtherQuery(Container $container): OtherQuery - { - return new OtherQuery(); - } - - /** - * Get The OtherWhere Class. - * - * @param Container $container The DI container. - * - * @return OtherWhere - * @since 3.2.0 - */ - public function getOtherWhere(Container $container): OtherWhere - { - return new OtherWhere(); - } - - /** - * Get The PermissionAction Class. - * - * @param Container $container The DI container. - * - * @return PermissionAction - * @since 3.2.0 - */ - public function getPermissionAction(Container $container): PermissionAction - { - return new PermissionAction(); - } - - /** - * Get The PermissionComponent Class. - * - * @param Container $container The DI container. - * - * @return PermissionComponent - * @since 3.2.0 - */ - public function getPermissionComponent(Container $container): PermissionComponent - { - return new PermissionComponent(); - } - - /** - * Get The PermissionCore Class. - * - * @param Container $container The DI container. - * - * @return PermissionCore - * @since 3.2.0 - */ - public function getPermissionCore(Container $container): PermissionCore - { - return new PermissionCore(); - } - - /** - * Get The PermissionDashboard Class. - * - * @param Container $container The DI container. - * - * @return PermissionDashboard - * @since 3.2.0 - */ - public function getPermissionDashboard(Container $container): PermissionDashboard - { - return new PermissionDashboard(); - } - - /** - * Get The PermissionFields Class. - * - * @param Container $container The DI container. - * - * @return PermissionFields - * @since 3.2.0 - */ - public function getPermissionFields(Container $container): PermissionFields - { - return new PermissionFields(); - } - - /** - * Get The PermissionGlobalAction Class. - * - * @param Container $container The DI container. - * - * @return PermissionGlobalAction - * @since 3.2.0 - */ - public function getPermissionGlobalAction(Container $container): PermissionGlobalAction - { - return new PermissionGlobalAction(); - } - - /** - * Get The PermissionViews Class. - * - * @param Container $container The DI container. - * - * @return PermissionViews - * @since 3.2.0 - */ - public function getPermissionViews(Container $container): PermissionViews - { - return new PermissionViews(); - } - - /** - * Get The Request Class. - * - * @param Container $container The DI container. - * - * @return Request - * @since 3.2.0 - */ - public function getRequest(Container $container): Request - { - return new Request(); - } - - /** - * Get The Router Class. - * - * @param Container $container The DI container. - * - * @return Router - * @since 3.2.0 - */ - public function getRouter(Container $container): Router - { - return new Router(); - } - - /** - * Get The ScriptMediaSwitch Class. - * - * @param Container $container The DI container. - * - * @return ScriptMediaSwitch - * @since 3.2.0 - */ - public function getScriptMediaSwitch(Container $container): ScriptMediaSwitch - { - return new ScriptMediaSwitch(); - } - - /** - * Get The ScriptUserSwitch Class. - * - * @param Container $container The DI container. - * - * @return ScriptUserSwitch - * @since 3.2.0 - */ - public function getScriptUserSwitch(Container $container): ScriptUserSwitch - { - return new ScriptUserSwitch(); - } - - /** - * Get The Search Class. - * - * @param Container $container The DI container. - * - * @return Search - * @since 3.2.0 - */ - public function getSearch(Container $container): Search - { - return new Search(); - } - - /** - * Get The SelectionTranslation Class. - * - * @param Container $container The DI container. - * - * @return SelectionTranslation - * @since 3.2.0 - */ - public function getSelectionTranslation(Container $container): SelectionTranslation - { - return new SelectionTranslation(); - } - - /** - * Get The SiteDecrypt Class. - * - * @param Container $container The DI container. - * - * @return SiteDecrypt - * @since 3.2.0 - */ - public function getSiteDecrypt(Container $container): SiteDecrypt - { - return new SiteDecrypt(); - } - - /** - * Get The SiteDynamicGet Class. - * - * @param Container $container The DI container. - * - * @return SiteDynamicGet - * @since 3.2.0 - */ - public function getSiteDynamicGet(Container $container): SiteDynamicGet - { - return new SiteDynamicGet(); - } - - /** - * Get The SiteEditView Class. - * - * @param Container $container The DI container. - * - * @return SiteEditView - * @since 3.2.0 - */ - public function getSiteEditView(Container $container): SiteEditView - { - return new SiteEditView(); - } - - /** - * Get The SiteFieldData Class. - * - * @param Container $container The DI container. - * - * @return SiteFieldData - * @since 3.2.0 - */ - public function getSiteFieldData(Container $container): SiteFieldData - { - return new SiteFieldData(); - } - - /** - * Get The SiteFieldDecodeFilter Class. - * - * @param Container $container The DI container. - * - * @return SiteFieldDecodeFilter - * @since 3.2.0 - */ - public function getSiteFieldDecodeFilter(Container $container): SiteFieldDecodeFilter - { - return new SiteFieldDecodeFilter(); - } - - /** - * Get The SiteFields Class. - * - * @param Container $container The DI container. - * - * @return SiteFields - * @since 3.2.0 - */ - public function getSiteFields(Container $container): SiteFields - { - return new SiteFields(); - } - - /** - * Get The SiteMainGet Class. - * - * @param Container $container The DI container. - * - * @return SiteMainGet - * @since 3.2.0 - */ - public function getSiteMainGet(Container $container): SiteMainGet - { - return new SiteMainGet(); - } - - /** - * Get The Sort Class. - * - * @param Container $container The DI container. - * - * @return Sort - * @since 3.2.0 - */ - public function getSort(Container $container): Sort - { - return new Sort(); - } - - /** - * Get The TabCounter Class. - * - * @param Container $container The DI container. - * - * @return TabCounter - * @since 3.2.0 - */ - public function getTabCounter(Container $container): TabCounter - { - return new TabCounter(); - } - - /** - * Get The Tags Class. - * - * @param Container $container The DI container. - * - * @return Tags - * @since 3.2.0 - */ - public function getTags(Container $container): Tags - { - return new Tags(); - } - - /** - * Get The TemplateData Class. - * - * @param Container $container The DI container. - * - * @return TemplateData - * @since 3.2.0 - */ - public function getTemplateData(Container $container): TemplateData - { - return new TemplateData(); - } - - /** - * Get The Title Class. - * - * @param Container $container The DI container. - * - * @return Title - * @since 3.2.0 - */ - public function getTitle(Container $container): Title - { - return new Title(); - } - - /** - * Get The UikitComp Class. - * - * @param Container $container The DI container. - * - * @return UikitComp - * @since 3.2.0 - */ - public function getUikitComp(Container $container): UikitComp - { - return new UikitComp(); - } - - /** - * Get The UpdateMysql Class. - * - * @param Container $container The DI container. - * - * @return UpdateMysql - * @since 3.2.0 - */ - public function getUpdateMysql(Container $container): UpdateMysql - { - return new UpdateMysql(); - } - - /** - * Get The ViewsDefaultOrdering Class. - * - * @param Container $container The DI container. - * - * @return ViewsDefaultOrdering - * @since 3.2.0 - */ - public function getViewsDefaultOrdering(Container $container): ViewsDefaultOrdering - { - return new ViewsDefaultOrdering(); + /** + * 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(Languages::class, 'Compiler.Builder.Languages') + ->share('Compiler.Builder.Languages', [$this, 'getLanguages'], true); + + $container->alias(LanguageMessages::class, 'Compiler.Builder.Language.Messages') + ->share('Compiler.Builder.Language.Messages', [$this, 'getLanguageMessages'], true); + + $container->alias(Layout::class, 'Compiler.Builder.Layout') + ->share('Compiler.Builder.Layout', [$this, 'getLayout'], true); + + $container->alias(LayoutData::class, 'Compiler.Builder.Layout.Data') + ->share('Compiler.Builder.Layout.Data', [$this, 'getLayoutData'], true); + + $container->alias(LibraryManager::class, 'Compiler.Builder.Library.Manager') + ->share('Compiler.Builder.Library.Manager', [$this, 'getLibraryManager'], true); + + $container->alias(ListFieldClass::class, 'Compiler.Builder.List.Field.Class') + ->share('Compiler.Builder.List.Field.Class', [$this, 'getListFieldClass'], true); + + $container->alias(ListHeadOverride::class, 'Compiler.Builder.List.Head.Override') + ->share('Compiler.Builder.List.Head.Override', [$this, 'getListHeadOverride'], true); + + $container->alias(ListJoin::class, 'Compiler.Builder.List.Join') + ->share('Compiler.Builder.List.Join', [$this, 'getListJoin'], true); + + $container->alias(Lists::class, 'Compiler.Builder.Lists') + ->share('Compiler.Builder.Lists', [$this, 'getLists'], true); + + $container->alias(MainTextField::class, 'Compiler.Builder.Main.Text.Field') + ->share('Compiler.Builder.Main.Text.Field', [$this, 'getMainTextField'], true); + + $container->alias(MetaData::class, 'Compiler.Builder.Meta.Data') + ->share('Compiler.Builder.Meta.Data', [$this, 'getMetaData'], true); + + $container->alias(ModelBasicField::class, 'Compiler.Builder.Model.Basic.Field') + ->share('Compiler.Builder.Model.Basic.Field', [$this, 'getModelBasicField'], true); + + $container->alias(ModelExpertField::class, 'Compiler.Builder.Model.Expert.Field') + ->share('Compiler.Builder.Model.Expert.Field', [$this, 'getModelExpertField'], true); + + $container->alias(ModelExpertFieldInitiator::class, 'Compiler.Builder.Model.Expert.Field.Initiator') + ->share('Compiler.Builder.Model.Expert.Field.Initiator', [$this, 'getModelExpertFieldInitiator'], true); + + $container->alias(ModelMediumField::class, 'Compiler.Builder.Model.Medium.Field') + ->share('Compiler.Builder.Model.Medium.Field', [$this, 'getModelMediumField'], true); + + $container->alias(ModelWhmcsField::class, 'Compiler.Builder.Model.Whmcs.Field') + ->share('Compiler.Builder.Model.Whmcs.Field', [$this, 'getModelWhmcsField'], true); + + $container->alias(MovedPublishingFields::class, 'Compiler.Builder.Moved.Publishing.Fields') + ->share('Compiler.Builder.Moved.Publishing.Fields', [$this, 'getMovedPublishingFields'], true); + + $container->alias(Multilingual::class, 'Compiler.Builder.Multilingual') + ->share('Compiler.Builder.Multilingual', [$this, 'getMultilingual'], true); + + $container->alias(MysqlTableSetting::class, 'Compiler.Builder.Mysql.Table.Setting') + ->share('Compiler.Builder.Mysql.Table.Setting', [$this, 'getMysqlTableSetting'], true); + + $container->alias(NewPublishingFields::class, 'Compiler.Builder.New.Publishing.Fields') + ->share('Compiler.Builder.New.Publishing.Fields', [$this, 'getNewPublishingFields'], true); + + $container->alias(OrderZero::class, 'Compiler.Builder.Order.Zero') + ->share('Compiler.Builder.Order.Zero', [$this, 'getOrderZero'], true); + + $container->alias(OtherFilter::class, 'Compiler.Builder.Other.Filter') + ->share('Compiler.Builder.Other.Filter', [$this, 'getOtherFilter'], true); + + $container->alias(OtherGroup::class, 'Compiler.Builder.Other.Group') + ->share('Compiler.Builder.Other.Group', [$this, 'getOtherGroup'], true); + + $container->alias(OtherJoin::class, 'Compiler.Builder.Other.Join') + ->share('Compiler.Builder.Other.Join', [$this, 'getOtherJoin'], true); + + $container->alias(OtherOrder::class, 'Compiler.Builder.Other.Order') + ->share('Compiler.Builder.Other.Order', [$this, 'getOtherOrder'], true); + + $container->alias(OtherQuery::class, 'Compiler.Builder.Other.Query') + ->share('Compiler.Builder.Other.Query', [$this, 'getOtherQuery'], true); + + $container->alias(OtherWhere::class, 'Compiler.Builder.Other.Where') + ->share('Compiler.Builder.Other.Where', [$this, 'getOtherWhere'], true); + + $container->alias(PermissionAction::class, 'Compiler.Builder.Permission.Action') + ->share('Compiler.Builder.Permission.Action', [$this, 'getPermissionAction'], true); + + $container->alias(PermissionComponent::class, 'Compiler.Builder.Permission.Component') + ->share('Compiler.Builder.Permission.Component', [$this, 'getPermissionComponent'], true); + + $container->alias(PermissionCore::class, 'Compiler.Builder.Permission.Core') + ->share('Compiler.Builder.Permission.Core', [$this, 'getPermissionCore'], true); + + $container->alias(PermissionDashboard::class, 'Compiler.Builder.Permission.Dashboard') + ->share('Compiler.Builder.Permission.Dashboard', [$this, 'getPermissionDashboard'], true); + + $container->alias(PermissionFields::class, 'Compiler.Builder.Permission.Fields') + ->share('Compiler.Builder.Permission.Fields', [$this, 'getPermissionFields'], true); + + $container->alias(PermissionGlobalAction::class, 'Compiler.Builder.Permission.Global.Action') + ->share('Compiler.Builder.Permission.Global.Action', [$this, 'getPermissionGlobalAction'], true); + + $container->alias(PermissionViews::class, 'Compiler.Builder.Permission.Views') + ->share('Compiler.Builder.Permission.Views', [$this, 'getPermissionViews'], true); + + $container->alias(Request::class, 'Compiler.Builder.Request') + ->share('Compiler.Builder.Request', [$this, 'getRequest'], true); + + $container->alias(Router::class, 'Compiler.Builder.Router') + ->share('Compiler.Builder.Router', [$this, 'getRouter'], true); + + $container->alias(ScriptMediaSwitch::class, 'Compiler.Builder.Script.Media.Switch') + ->share('Compiler.Builder.Script.Media.Switch', [$this, 'getScriptMediaSwitch'], true); + + $container->alias(ScriptUserSwitch::class, 'Compiler.Builder.Script.User.Switch') + ->share('Compiler.Builder.Script.User.Switch', [$this, 'getScriptUserSwitch'], true); + + $container->alias(Search::class, 'Compiler.Builder.Search') + ->share('Compiler.Builder.Search', [$this, 'getSearch'], true); + + $container->alias(SelectionTranslation::class, 'Compiler.Builder.Selection.Translation') + ->share('Compiler.Builder.Selection.Translation', [$this, 'getSelectionTranslation'], true); + + $container->alias(SiteDecrypt::class, 'Compiler.Builder.Site.Decrypt') + ->share('Compiler.Builder.Site.Decrypt', [$this, 'getSiteDecrypt'], true); + + $container->alias(SiteDynamicGet::class, 'Compiler.Builder.Site.Dynamic.Get') + ->share('Compiler.Builder.Site.Dynamic.Get', [$this, 'getSiteDynamicGet'], true); + + $container->alias(SiteEditView::class, 'Compiler.Builder.Site.Edit.View') + ->share('Compiler.Builder.Site.Edit.View', [$this, 'getSiteEditView'], true); + + $container->alias(SiteFieldData::class, 'Compiler.Builder.Site.Field.Data') + ->share('Compiler.Builder.Site.Field.Data', [$this, 'getSiteFieldData'], true); + + $container->alias(SiteFieldDecodeFilter::class, 'Compiler.Builder.Site.Field.Decode.Filter') + ->share('Compiler.Builder.Site.Field.Decode.Filter', [$this, 'getSiteFieldDecodeFilter'], true); + + $container->alias(SiteFields::class, 'Compiler.Builder.Site.Fields') + ->share('Compiler.Builder.Site.Fields', [$this, 'getSiteFields'], true); + + $container->alias(SiteMainGet::class, 'Compiler.Builder.Site.Main.Get') + ->share('Compiler.Builder.Site.Main.Get', [$this, 'getSiteMainGet'], true); + + $container->alias(Sort::class, 'Compiler.Builder.Sort') + ->share('Compiler.Builder.Sort', [$this, 'getSort'], true); + + $container->alias(TabCounter::class, 'Compiler.Builder.Tab.Counter') + ->share('Compiler.Builder.Tab.Counter', [$this, 'getTabCounter'], true); + + $container->alias(Tags::class, 'Compiler.Builder.Tags') + ->share('Compiler.Builder.Tags', [$this, 'getTags'], true); + + $container->alias(TemplateData::class, 'Compiler.Builder.Template.Data') + ->share('Compiler.Builder.Template.Data', [$this, 'getTemplateData'], true); + + $container->alias(Title::class, 'Compiler.Builder.Title') + ->share('Compiler.Builder.Title', [$this, 'getTitle'], true); + + $container->alias(UikitComp::class, 'Compiler.Builder.Uikit.Comp') + ->share('Compiler.Builder.Uikit.Comp', [$this, 'getUikitComp'], true); + + $container->alias(UpdateMysql::class, 'Compiler.Builder.Update.Mysql') + ->share('Compiler.Builder.Update.Mysql', [$this, 'getUpdateMysql'], true); + + $container->alias(ViewsDefaultOrdering::class, 'Compiler.Builder.Views.Default.Ordering') + ->share('Compiler.Builder.Views.Default.Ordering', [$this, 'getViewsDefaultOrdering'], true); + } + + /** + * Get The Languages Class. + * + * @param Container $container The DI container. + * + * @return Languages + * @since 3.2.0 + */ + public function getLanguages(Container $container): Languages + { + return new Languages(); + } + + /** + * Get The LanguageMessages Class. + * + * @param Container $container The DI container. + * + * @return LanguageMessages + * @since 3.2.0 + */ + public function getLanguageMessages(Container $container): LanguageMessages + { + return new LanguageMessages(); + } + + /** + * Get The Layout Class. + * + * @param Container $container The DI container. + * + * @return Layout + * @since 3.2.0 + */ + public function getLayout(Container $container): Layout + { + return new Layout(); + } + + /** + * Get The LayoutData Class. + * + * @param Container $container The DI container. + * + * @return LayoutData + * @since 3.2.0 + */ + public function getLayoutData(Container $container): LayoutData + { + return new LayoutData(); + } + + /** + * Get The LibraryManager Class. + * + * @param Container $container The DI container. + * + * @return LibraryManager + * @since 3.2.0 + */ + public function getLibraryManager(Container $container): LibraryManager + { + return new LibraryManager(); + } + + /** + * Get The ListFieldClass Class. + * + * @param Container $container The DI container. + * + * @return ListFieldClass + * @since 3.2.0 + */ + public function getListFieldClass(Container $container): ListFieldClass + { + return new ListFieldClass(); + } + + /** + * Get The ListHeadOverride Class. + * + * @param Container $container The DI container. + * + * @return ListHeadOverride + * @since 3.2.0 + */ + public function getListHeadOverride(Container $container): ListHeadOverride + { + return new ListHeadOverride(); + } + + /** + * Get The ListJoin Class. + * + * @param Container $container The DI container. + * + * @return ListJoin + * @since 3.2.0 + */ + public function getListJoin(Container $container): ListJoin + { + return new ListJoin(); + } + + /** + * Get The Lists Class. + * + * @param Container $container The DI container. + * + * @return Lists + * @since 3.2.0 + */ + public function getLists(Container $container): Lists + { + return new Lists(); + } + + /** + * Get The MainTextField Class. + * + * @param Container $container The DI container. + * + * @return MainTextField + * @since 3.2.0 + */ + public function getMainTextField(Container $container): MainTextField + { + return new MainTextField(); + } + + /** + * Get The MetaData Class. + * + * @param Container $container The DI container. + * + * @return MetaData + * @since 3.2.0 + */ + public function getMetaData(Container $container): MetaData + { + return new MetaData(); + } + + /** + * Get The ModelBasicField Class. + * + * @param Container $container The DI container. + * + * @return ModelBasicField + * @since 3.2.0 + */ + public function getModelBasicField(Container $container): ModelBasicField + { + return new ModelBasicField(); + } + + /** + * Get The ModelExpertField Class. + * + * @param Container $container The DI container. + * + * @return ModelExpertField + * @since 3.2.0 + */ + public function getModelExpertField(Container $container): ModelExpertField + { + return new ModelExpertField(); + } + + /** + * Get The ModelExpertFieldInitiator Class. + * + * @param Container $container The DI container. + * + * @return ModelExpertFieldInitiator + * @since 3.2.0 + */ + public function getModelExpertFieldInitiator(Container $container): ModelExpertFieldInitiator + { + return new ModelExpertFieldInitiator(); + } + + /** + * Get The ModelMediumField Class. + * + * @param Container $container The DI container. + * + * @return ModelMediumField + * @since 3.2.0 + */ + public function getModelMediumField(Container $container): ModelMediumField + { + return new ModelMediumField(); + } + + /** + * Get The ModelWhmcsField Class. + * + * @param Container $container The DI container. + * + * @return ModelWhmcsField + * @since 3.2.0 + */ + public function getModelWhmcsField(Container $container): ModelWhmcsField + { + return new ModelWhmcsField(); + } + + /** + * Get The MovedPublishingFields Class. + * + * @param Container $container The DI container. + * + * @return MovedPublishingFields + * @since 3.2.0 + */ + public function getMovedPublishingFields(Container $container): MovedPublishingFields + { + return new MovedPublishingFields(); + } + + /** + * Get The Multilingual Class. + * + * @param Container $container The DI container. + * + * @return Multilingual + * @since 3.2.0 + */ + public function getMultilingual(Container $container): Multilingual + { + return new Multilingual(); + } + + /** + * Get The MysqlTableSetting Class. + * + * @param Container $container The DI container. + * + * @return MysqlTableSetting + * @since 3.2.0 + */ + public function getMysqlTableSetting(Container $container): MysqlTableSetting + { + return new MysqlTableSetting(); + } + + /** + * Get The NewPublishingFields Class. + * + * @param Container $container The DI container. + * + * @return NewPublishingFields + * @since 3.2.0 + */ + public function getNewPublishingFields(Container $container): NewPublishingFields + { + return new NewPublishingFields(); + } + + /** + * Get The OrderZero Class. + * + * @param Container $container The DI container. + * + * @return OrderZero + * @since 3.2.0 + */ + public function getOrderZero(Container $container): OrderZero + { + return new OrderZero(); + } + + /** + * Get The OtherFilter Class. + * + * @param Container $container The DI container. + * + * @return OtherFilter + * @since 3.2.0 + */ + public function getOtherFilter(Container $container): OtherFilter + { + return new OtherFilter(); + } + + /** + * Get The OtherGroup Class. + * + * @param Container $container The DI container. + * + * @return OtherGroup + * @since 3.2.0 + */ + public function getOtherGroup(Container $container): OtherGroup + { + return new OtherGroup(); + } + + /** + * Get The OtherJoin Class. + * + * @param Container $container The DI container. + * + * @return OtherJoin + * @since 3.2.0 + */ + public function getOtherJoin(Container $container): OtherJoin + { + return new OtherJoin(); + } + + /** + * Get The OtherOrder Class. + * + * @param Container $container The DI container. + * + * @return OtherOrder + * @since 3.2.0 + */ + public function getOtherOrder(Container $container): OtherOrder + { + return new OtherOrder(); + } + + /** + * Get The OtherQuery Class. + * + * @param Container $container The DI container. + * + * @return OtherQuery + * @since 3.2.0 + */ + public function getOtherQuery(Container $container): OtherQuery + { + return new OtherQuery(); + } + + /** + * Get The OtherWhere Class. + * + * @param Container $container The DI container. + * + * @return OtherWhere + * @since 3.2.0 + */ + public function getOtherWhere(Container $container): OtherWhere + { + return new OtherWhere(); + } + + /** + * Get The PermissionAction Class. + * + * @param Container $container The DI container. + * + * @return PermissionAction + * @since 3.2.0 + */ + public function getPermissionAction(Container $container): PermissionAction + { + return new PermissionAction(); + } + + /** + * Get The PermissionComponent Class. + * + * @param Container $container The DI container. + * + * @return PermissionComponent + * @since 3.2.0 + */ + public function getPermissionComponent(Container $container): PermissionComponent + { + return new PermissionComponent(); + } + + /** + * Get The PermissionCore Class. + * + * @param Container $container The DI container. + * + * @return PermissionCore + * @since 3.2.0 + */ + public function getPermissionCore(Container $container): PermissionCore + { + return new PermissionCore(); + } + + /** + * Get The PermissionDashboard Class. + * + * @param Container $container The DI container. + * + * @return PermissionDashboard + * @since 3.2.0 + */ + public function getPermissionDashboard(Container $container): PermissionDashboard + { + return new PermissionDashboard(); + } + + /** + * Get The PermissionFields Class. + * + * @param Container $container The DI container. + * + * @return PermissionFields + * @since 3.2.0 + */ + public function getPermissionFields(Container $container): PermissionFields + { + return new PermissionFields(); + } + + /** + * Get The PermissionGlobalAction Class. + * + * @param Container $container The DI container. + * + * @return PermissionGlobalAction + * @since 3.2.0 + */ + public function getPermissionGlobalAction(Container $container): PermissionGlobalAction + { + return new PermissionGlobalAction(); + } + + /** + * Get The PermissionViews Class. + * + * @param Container $container The DI container. + * + * @return PermissionViews + * @since 3.2.0 + */ + public function getPermissionViews(Container $container): PermissionViews + { + return new PermissionViews(); + } + + /** + * Get The Request Class. + * + * @param Container $container The DI container. + * + * @return Request + * @since 3.2.0 + */ + public function getRequest(Container $container): Request + { + return new Request(); + } + + /** + * Get The Router Class. + * + * @param Container $container The DI container. + * + * @return Router + * @since 3.2.0 + */ + public function getRouter(Container $container): Router + { + return new Router(); + } + + /** + * Get The ScriptMediaSwitch Class. + * + * @param Container $container The DI container. + * + * @return ScriptMediaSwitch + * @since 3.2.0 + */ + public function getScriptMediaSwitch(Container $container): ScriptMediaSwitch + { + return new ScriptMediaSwitch(); + } + + /** + * Get The ScriptUserSwitch Class. + * + * @param Container $container The DI container. + * + * @return ScriptUserSwitch + * @since 3.2.0 + */ + public function getScriptUserSwitch(Container $container): ScriptUserSwitch + { + return new ScriptUserSwitch(); + } + + /** + * Get The Search Class. + * + * @param Container $container The DI container. + * + * @return Search + * @since 3.2.0 + */ + public function getSearch(Container $container): Search + { + return new Search(); + } + + /** + * Get The SelectionTranslation Class. + * + * @param Container $container The DI container. + * + * @return SelectionTranslation + * @since 3.2.0 + */ + public function getSelectionTranslation(Container $container): SelectionTranslation + { + return new SelectionTranslation(); + } + + /** + * Get The SiteDecrypt Class. + * + * @param Container $container The DI container. + * + * @return SiteDecrypt + * @since 3.2.0 + */ + public function getSiteDecrypt(Container $container): SiteDecrypt + { + return new SiteDecrypt(); + } + + /** + * Get The SiteDynamicGet Class. + * + * @param Container $container The DI container. + * + * @return SiteDynamicGet + * @since 3.2.0 + */ + public function getSiteDynamicGet(Container $container): SiteDynamicGet + { + return new SiteDynamicGet(); + } + + /** + * Get The SiteEditView Class. + * + * @param Container $container The DI container. + * + * @return SiteEditView + * @since 3.2.0 + */ + public function getSiteEditView(Container $container): SiteEditView + { + return new SiteEditView(); + } + + /** + * Get The SiteFieldData Class. + * + * @param Container $container The DI container. + * + * @return SiteFieldData + * @since 3.2.0 + */ + public function getSiteFieldData(Container $container): SiteFieldData + { + return new SiteFieldData(); + } + + /** + * Get The SiteFieldDecodeFilter Class. + * + * @param Container $container The DI container. + * + * @return SiteFieldDecodeFilter + * @since 3.2.0 + */ + public function getSiteFieldDecodeFilter(Container $container): SiteFieldDecodeFilter + { + return new SiteFieldDecodeFilter(); + } + + /** + * Get The SiteFields Class. + * + * @param Container $container The DI container. + * + * @return SiteFields + * @since 3.2.0 + */ + public function getSiteFields(Container $container): SiteFields + { + return new SiteFields(); + } + + /** + * Get The SiteMainGet Class. + * + * @param Container $container The DI container. + * + * @return SiteMainGet + * @since 3.2.0 + */ + public function getSiteMainGet(Container $container): SiteMainGet + { + return new SiteMainGet(); + } + + /** + * Get The Sort Class. + * + * @param Container $container The DI container. + * + * @return Sort + * @since 3.2.0 + */ + public function getSort(Container $container): Sort + { + return new Sort(); + } + + /** + * Get The TabCounter Class. + * + * @param Container $container The DI container. + * + * @return TabCounter + * @since 3.2.0 + */ + public function getTabCounter(Container $container): TabCounter + { + return new TabCounter(); + } + + /** + * Get The Tags Class. + * + * @param Container $container The DI container. + * + * @return Tags + * @since 3.2.0 + */ + public function getTags(Container $container): Tags + { + return new Tags(); + } + + /** + * Get The TemplateData Class. + * + * @param Container $container The DI container. + * + * @return TemplateData + * @since 3.2.0 + */ + public function getTemplateData(Container $container): TemplateData + { + return new TemplateData(); + } + + /** + * Get The Title Class. + * + * @param Container $container The DI container. + * + * @return Title + * @since 3.2.0 + */ + public function getTitle(Container $container): Title + { + return new Title(); + } + + /** + * Get The UikitComp Class. + * + * @param Container $container The DI container. + * + * @return UikitComp + * @since 3.2.0 + */ + public function getUikitComp(Container $container): UikitComp + { + return new UikitComp(); + } + + /** + * Get The UpdateMysql Class. + * + * @param Container $container The DI container. + * + * @return UpdateMysql + * @since 3.2.0 + */ + public function getUpdateMysql(Container $container): UpdateMysql + { + return new UpdateMysql(); + } + + /** + * Get The ViewsDefaultOrdering Class. + * + * @param Container $container The DI container. + * + * @return ViewsDefaultOrdering + * @since 3.2.0 + */ + public function getViewsDefaultOrdering(Container $container): ViewsDefaultOrdering + { + return new ViewsDefaultOrdering(); } } diff --git a/src/2c76c06e-a371-4b73-9fbe-b4d9b4df55d7/code.power b/src/2c76c06e-a371-4b73-9fbe-b4d9b4df55d7/code.power index 94aabe5..baf751b 100644 --- a/src/2c76c06e-a371-4b73-9fbe-b4d9b4df55d7/code.power +++ b/src/2c76c06e-a371-4b73-9fbe-b4d9b4df55d7/code.power @@ -1,874 +1,890 @@ - /** - * 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(Languages::class, 'Compiler.Builder.Languages') - ->share('Compiler.Builder.Languages', [$this, 'getLanguages'], true); - - $container->alias(LanguageMessages::class, 'Compiler.Builder.Language.Messages') - ->share('Compiler.Builder.Language.Messages', [$this, 'getLanguageMessages'], true); - - $container->alias(Layout::class, 'Compiler.Builder.Layout') - ->share('Compiler.Builder.Layout', [$this, 'getLayout'], true); - - $container->alias(LayoutData::class, 'Compiler.Builder.Layout.Data') - ->share('Compiler.Builder.Layout.Data', [$this, 'getLayoutData'], true); - - $container->alias(LibraryManager::class, 'Compiler.Builder.Library.Manager') - ->share('Compiler.Builder.Library.Manager', [$this, 'getLibraryManager'], true); - - $container->alias(ListFieldClass::class, 'Compiler.Builder.List.Field.Class') - ->share('Compiler.Builder.List.Field.Class', [$this, 'getListFieldClass'], true); - - $container->alias(ListHeadOverride::class, 'Compiler.Builder.List.Head.Override') - ->share('Compiler.Builder.List.Head.Override', [$this, 'getListHeadOverride'], true); - - $container->alias(ListJoin::class, 'Compiler.Builder.List.Join') - ->share('Compiler.Builder.List.Join', [$this, 'getListJoin'], true); - - $container->alias(Lists::class, 'Compiler.Builder.Lists') - ->share('Compiler.Builder.Lists', [$this, 'getLists'], true); - - $container->alias(MainTextField::class, 'Compiler.Builder.Main.Text.Field') - ->share('Compiler.Builder.Main.Text.Field', [$this, 'getMainTextField'], true); - - $container->alias(MetaData::class, 'Compiler.Builder.Meta.Data') - ->share('Compiler.Builder.Meta.Data', [$this, 'getMetaData'], true); - - $container->alias(ModelBasicField::class, 'Compiler.Builder.Model.Basic.Field') - ->share('Compiler.Builder.Model.Basic.Field', [$this, 'getModelBasicField'], true); - - $container->alias(ModelExpertField::class, 'Compiler.Builder.Model.Expert.Field') - ->share('Compiler.Builder.Model.Expert.Field', [$this, 'getModelExpertField'], true); - - $container->alias(ModelExpertFieldInitiator::class, 'Compiler.Builder.Model.Expert.Field.Initiator') - ->share('Compiler.Builder.Model.Expert.Field.Initiator', [$this, 'getModelExpertFieldInitiator'], true); - - $container->alias(ModelMediumField::class, 'Compiler.Builder.Model.Medium.Field') - ->share('Compiler.Builder.Model.Medium.Field', [$this, 'getModelMediumField'], true); - - $container->alias(ModelWhmcsField::class, 'Compiler.Builder.Model.Whmcs.Field') - ->share('Compiler.Builder.Model.Whmcs.Field', [$this, 'getModelWhmcsField'], true); - - $container->alias(MovedPublishingFields::class, 'Compiler.Builder.Moved.Publishing.Fields') - ->share('Compiler.Builder.Moved.Publishing.Fields', [$this, 'getMovedPublishingFields'], true); - - $container->alias(MysqlTableSetting::class, 'Compiler.Builder.Mysql.Table.Setting') - ->share('Compiler.Builder.Mysql.Table.Setting', [$this, 'getMysqlTableSetting'], true); - - $container->alias(NewPublishingFields::class, 'Compiler.Builder.New.Publishing.Fields') - ->share('Compiler.Builder.New.Publishing.Fields', [$this, 'getNewPublishingFields'], true); - - $container->alias(OrderZero::class, 'Compiler.Builder.Order.Zero') - ->share('Compiler.Builder.Order.Zero', [$this, 'getOrderZero'], true); - - $container->alias(OtherFilter::class, 'Compiler.Builder.Other.Filter') - ->share('Compiler.Builder.Other.Filter', [$this, 'getOtherFilter'], true); - - $container->alias(OtherGroup::class, 'Compiler.Builder.Other.Group') - ->share('Compiler.Builder.Other.Group', [$this, 'getOtherGroup'], true); - - $container->alias(OtherJoin::class, 'Compiler.Builder.Other.Join') - ->share('Compiler.Builder.Other.Join', [$this, 'getOtherJoin'], true); - - $container->alias(OtherOrder::class, 'Compiler.Builder.Other.Order') - ->share('Compiler.Builder.Other.Order', [$this, 'getOtherOrder'], true); - - $container->alias(OtherQuery::class, 'Compiler.Builder.Other.Query') - ->share('Compiler.Builder.Other.Query', [$this, 'getOtherQuery'], true); - - $container->alias(OtherWhere::class, 'Compiler.Builder.Other.Where') - ->share('Compiler.Builder.Other.Where', [$this, 'getOtherWhere'], true); - - $container->alias(PermissionAction::class, 'Compiler.Builder.Permission.Action') - ->share('Compiler.Builder.Permission.Action', [$this, 'getPermissionAction'], true); - - $container->alias(PermissionComponent::class, 'Compiler.Builder.Permission.Component') - ->share('Compiler.Builder.Permission.Component', [$this, 'getPermissionComponent'], true); - - $container->alias(PermissionCore::class, 'Compiler.Builder.Permission.Core') - ->share('Compiler.Builder.Permission.Core', [$this, 'getPermissionCore'], true); - - $container->alias(PermissionDashboard::class, 'Compiler.Builder.Permission.Dashboard') - ->share('Compiler.Builder.Permission.Dashboard', [$this, 'getPermissionDashboard'], true); - - $container->alias(PermissionFields::class, 'Compiler.Builder.Permission.Fields') - ->share('Compiler.Builder.Permission.Fields', [$this, 'getPermissionFields'], true); - - $container->alias(PermissionGlobalAction::class, 'Compiler.Builder.Permission.Global.Action') - ->share('Compiler.Builder.Permission.Global.Action', [$this, 'getPermissionGlobalAction'], true); - - $container->alias(PermissionViews::class, 'Compiler.Builder.Permission.Views') - ->share('Compiler.Builder.Permission.Views', [$this, 'getPermissionViews'], true); - - $container->alias(Request::class, 'Compiler.Builder.Request') - ->share('Compiler.Builder.Request', [$this, 'getRequest'], true); - - $container->alias(Router::class, 'Compiler.Builder.Router') - ->share('Compiler.Builder.Router', [$this, 'getRouter'], true); - - $container->alias(ScriptMediaSwitch::class, 'Compiler.Builder.Script.Media.Switch') - ->share('Compiler.Builder.Script.Media.Switch', [$this, 'getScriptMediaSwitch'], true); - - $container->alias(ScriptUserSwitch::class, 'Compiler.Builder.Script.User.Switch') - ->share('Compiler.Builder.Script.User.Switch', [$this, 'getScriptUserSwitch'], true); - - $container->alias(Search::class, 'Compiler.Builder.Search') - ->share('Compiler.Builder.Search', [$this, 'getSearch'], true); - - $container->alias(SelectionTranslation::class, 'Compiler.Builder.Selection.Translation') - ->share('Compiler.Builder.Selection.Translation', [$this, 'getSelectionTranslation'], true); - - $container->alias(SiteDecrypt::class, 'Compiler.Builder.Site.Decrypt') - ->share('Compiler.Builder.Site.Decrypt', [$this, 'getSiteDecrypt'], true); - - $container->alias(SiteDynamicGet::class, 'Compiler.Builder.Site.Dynamic.Get') - ->share('Compiler.Builder.Site.Dynamic.Get', [$this, 'getSiteDynamicGet'], true); - - $container->alias(SiteEditView::class, 'Compiler.Builder.Site.Edit.View') - ->share('Compiler.Builder.Site.Edit.View', [$this, 'getSiteEditView'], true); - - $container->alias(SiteFieldData::class, 'Compiler.Builder.Site.Field.Data') - ->share('Compiler.Builder.Site.Field.Data', [$this, 'getSiteFieldData'], true); - - $container->alias(SiteFieldDecodeFilter::class, 'Compiler.Builder.Site.Field.Decode.Filter') - ->share('Compiler.Builder.Site.Field.Decode.Filter', [$this, 'getSiteFieldDecodeFilter'], true); - - $container->alias(SiteFields::class, 'Compiler.Builder.Site.Fields') - ->share('Compiler.Builder.Site.Fields', [$this, 'getSiteFields'], true); - - $container->alias(SiteMainGet::class, 'Compiler.Builder.Site.Main.Get') - ->share('Compiler.Builder.Site.Main.Get', [$this, 'getSiteMainGet'], true); - - $container->alias(Sort::class, 'Compiler.Builder.Sort') - ->share('Compiler.Builder.Sort', [$this, 'getSort'], true); - - $container->alias(TabCounter::class, 'Compiler.Builder.Tab.Counter') - ->share('Compiler.Builder.Tab.Counter', [$this, 'getTabCounter'], true); - - $container->alias(Tags::class, 'Compiler.Builder.Tags') - ->share('Compiler.Builder.Tags', [$this, 'getTags'], true); - - $container->alias(TemplateData::class, 'Compiler.Builder.Template.Data') - ->share('Compiler.Builder.Template.Data', [$this, 'getTemplateData'], true); - - $container->alias(Title::class, 'Compiler.Builder.Title') - ->share('Compiler.Builder.Title', [$this, 'getTitle'], true); - - $container->alias(UikitComp::class, 'Compiler.Builder.Uikit.Comp') - ->share('Compiler.Builder.Uikit.Comp', [$this, 'getUikitComp'], true); - - $container->alias(UpdateMysql::class, 'Compiler.Builder.Update.Mysql') - ->share('Compiler.Builder.Update.Mysql', [$this, 'getUpdateMysql'], true); - - $container->alias(ViewsDefaultOrdering::class, 'Compiler.Builder.Views.Default.Ordering') - ->share('Compiler.Builder.Views.Default.Ordering', [$this, 'getViewsDefaultOrdering'], true); - } - - /** - * Get The Languages Class. - * - * @param Container $container The DI container. - * - * @return Languages - * @since 3.2.0 - */ - public function getLanguages(Container $container): Languages - { - return new Languages(); - } - - /** - * Get The LanguageMessages Class. - * - * @param Container $container The DI container. - * - * @return LanguageMessages - * @since 3.2.0 - */ - public function getLanguageMessages(Container $container): LanguageMessages - { - return new LanguageMessages(); - } - - /** - * Get The Layout Class. - * - * @param Container $container The DI container. - * - * @return Layout - * @since 3.2.0 - */ - public function getLayout(Container $container): Layout - { - return new Layout(); - } - - /** - * Get The LayoutData Class. - * - * @param Container $container The DI container. - * - * @return LayoutData - * @since 3.2.0 - */ - public function getLayoutData(Container $container): LayoutData - { - return new LayoutData(); - } - - /** - * Get The LibraryManager Class. - * - * @param Container $container The DI container. - * - * @return LibraryManager - * @since 3.2.0 - */ - public function getLibraryManager(Container $container): LibraryManager - { - return new LibraryManager(); - } - - /** - * Get The ListFieldClass Class. - * - * @param Container $container The DI container. - * - * @return ListFieldClass - * @since 3.2.0 - */ - public function getListFieldClass(Container $container): ListFieldClass - { - return new ListFieldClass(); - } - - /** - * Get The ListHeadOverride Class. - * - * @param Container $container The DI container. - * - * @return ListHeadOverride - * @since 3.2.0 - */ - public function getListHeadOverride(Container $container): ListHeadOverride - { - return new ListHeadOverride(); - } - - /** - * Get The ListJoin Class. - * - * @param Container $container The DI container. - * - * @return ListJoin - * @since 3.2.0 - */ - public function getListJoin(Container $container): ListJoin - { - return new ListJoin(); - } - - /** - * Get The Lists Class. - * - * @param Container $container The DI container. - * - * @return Lists - * @since 3.2.0 - */ - public function getLists(Container $container): Lists - { - return new Lists(); - } - - /** - * Get The MainTextField Class. - * - * @param Container $container The DI container. - * - * @return MainTextField - * @since 3.2.0 - */ - public function getMainTextField(Container $container): MainTextField - { - return new MainTextField(); - } - - /** - * Get The MetaData Class. - * - * @param Container $container The DI container. - * - * @return MetaData - * @since 3.2.0 - */ - public function getMetaData(Container $container): MetaData - { - return new MetaData(); - } - - /** - * Get The ModelBasicField Class. - * - * @param Container $container The DI container. - * - * @return ModelBasicField - * @since 3.2.0 - */ - public function getModelBasicField(Container $container): ModelBasicField - { - return new ModelBasicField(); - } - - /** - * Get The ModelExpertField Class. - * - * @param Container $container The DI container. - * - * @return ModelExpertField - * @since 3.2.0 - */ - public function getModelExpertField(Container $container): ModelExpertField - { - return new ModelExpertField(); - } - - /** - * Get The ModelExpertFieldInitiator Class. - * - * @param Container $container The DI container. - * - * @return ModelExpertFieldInitiator - * @since 3.2.0 - */ - public function getModelExpertFieldInitiator(Container $container): ModelExpertFieldInitiator - { - return new ModelExpertFieldInitiator(); - } - - /** - * Get The ModelMediumField Class. - * - * @param Container $container The DI container. - * - * @return ModelMediumField - * @since 3.2.0 - */ - public function getModelMediumField(Container $container): ModelMediumField - { - return new ModelMediumField(); - } - - /** - * Get The ModelWhmcsField Class. - * - * @param Container $container The DI container. - * - * @return ModelWhmcsField - * @since 3.2.0 - */ - public function getModelWhmcsField(Container $container): ModelWhmcsField - { - return new ModelWhmcsField(); - } - - /** - * Get The MovedPublishingFields Class. - * - * @param Container $container The DI container. - * - * @return MovedPublishingFields - * @since 3.2.0 - */ - public function getMovedPublishingFields(Container $container): MovedPublishingFields - { - return new MovedPublishingFields(); - } - - /** - * Get The MysqlTableSetting Class. - * - * @param Container $container The DI container. - * - * @return MysqlTableSetting - * @since 3.2.0 - */ - public function getMysqlTableSetting(Container $container): MysqlTableSetting - { - return new MysqlTableSetting(); - } - - /** - * Get The NewPublishingFields Class. - * - * @param Container $container The DI container. - * - * @return NewPublishingFields - * @since 3.2.0 - */ - public function getNewPublishingFields(Container $container): NewPublishingFields - { - return new NewPublishingFields(); - } - - /** - * Get The OrderZero Class. - * - * @param Container $container The DI container. - * - * @return OrderZero - * @since 3.2.0 - */ - public function getOrderZero(Container $container): OrderZero - { - return new OrderZero(); - } - - /** - * Get The OtherFilter Class. - * - * @param Container $container The DI container. - * - * @return OtherFilter - * @since 3.2.0 - */ - public function getOtherFilter(Container $container): OtherFilter - { - return new OtherFilter(); - } - - /** - * Get The OtherGroup Class. - * - * @param Container $container The DI container. - * - * @return OtherGroup - * @since 3.2.0 - */ - public function getOtherGroup(Container $container): OtherGroup - { - return new OtherGroup(); - } - - /** - * Get The OtherJoin Class. - * - * @param Container $container The DI container. - * - * @return OtherJoin - * @since 3.2.0 - */ - public function getOtherJoin(Container $container): OtherJoin - { - return new OtherJoin(); - } - - /** - * Get The OtherOrder Class. - * - * @param Container $container The DI container. - * - * @return OtherOrder - * @since 3.2.0 - */ - public function getOtherOrder(Container $container): OtherOrder - { - return new OtherOrder(); - } - - /** - * Get The OtherQuery Class. - * - * @param Container $container The DI container. - * - * @return OtherQuery - * @since 3.2.0 - */ - public function getOtherQuery(Container $container): OtherQuery - { - return new OtherQuery(); - } - - /** - * Get The OtherWhere Class. - * - * @param Container $container The DI container. - * - * @return OtherWhere - * @since 3.2.0 - */ - public function getOtherWhere(Container $container): OtherWhere - { - return new OtherWhere(); - } - - /** - * Get The PermissionAction Class. - * - * @param Container $container The DI container. - * - * @return PermissionAction - * @since 3.2.0 - */ - public function getPermissionAction(Container $container): PermissionAction - { - return new PermissionAction(); - } - - /** - * Get The PermissionComponent Class. - * - * @param Container $container The DI container. - * - * @return PermissionComponent - * @since 3.2.0 - */ - public function getPermissionComponent(Container $container): PermissionComponent - { - return new PermissionComponent(); - } - - /** - * Get The PermissionCore Class. - * - * @param Container $container The DI container. - * - * @return PermissionCore - * @since 3.2.0 - */ - public function getPermissionCore(Container $container): PermissionCore - { - return new PermissionCore(); - } - - /** - * Get The PermissionDashboard Class. - * - * @param Container $container The DI container. - * - * @return PermissionDashboard - * @since 3.2.0 - */ - public function getPermissionDashboard(Container $container): PermissionDashboard - { - return new PermissionDashboard(); - } - - /** - * Get The PermissionFields Class. - * - * @param Container $container The DI container. - * - * @return PermissionFields - * @since 3.2.0 - */ - public function getPermissionFields(Container $container): PermissionFields - { - return new PermissionFields(); - } - - /** - * Get The PermissionGlobalAction Class. - * - * @param Container $container The DI container. - * - * @return PermissionGlobalAction - * @since 3.2.0 - */ - public function getPermissionGlobalAction(Container $container): PermissionGlobalAction - { - return new PermissionGlobalAction(); - } - - /** - * Get The PermissionViews Class. - * - * @param Container $container The DI container. - * - * @return PermissionViews - * @since 3.2.0 - */ - public function getPermissionViews(Container $container): PermissionViews - { - return new PermissionViews(); - } - - /** - * Get The Request Class. - * - * @param Container $container The DI container. - * - * @return Request - * @since 3.2.0 - */ - public function getRequest(Container $container): Request - { - return new Request(); - } - - /** - * Get The Router Class. - * - * @param Container $container The DI container. - * - * @return Router - * @since 3.2.0 - */ - public function getRouter(Container $container): Router - { - return new Router(); - } - - /** - * Get The ScriptMediaSwitch Class. - * - * @param Container $container The DI container. - * - * @return ScriptMediaSwitch - * @since 3.2.0 - */ - public function getScriptMediaSwitch(Container $container): ScriptMediaSwitch - { - return new ScriptMediaSwitch(); - } - - /** - * Get The ScriptUserSwitch Class. - * - * @param Container $container The DI container. - * - * @return ScriptUserSwitch - * @since 3.2.0 - */ - public function getScriptUserSwitch(Container $container): ScriptUserSwitch - { - return new ScriptUserSwitch(); - } - - /** - * Get The Search Class. - * - * @param Container $container The DI container. - * - * @return Search - * @since 3.2.0 - */ - public function getSearch(Container $container): Search - { - return new Search(); - } - - /** - * Get The SelectionTranslation Class. - * - * @param Container $container The DI container. - * - * @return SelectionTranslation - * @since 3.2.0 - */ - public function getSelectionTranslation(Container $container): SelectionTranslation - { - return new SelectionTranslation(); - } - - /** - * Get The SiteDecrypt Class. - * - * @param Container $container The DI container. - * - * @return SiteDecrypt - * @since 3.2.0 - */ - public function getSiteDecrypt(Container $container): SiteDecrypt - { - return new SiteDecrypt(); - } - - /** - * Get The SiteDynamicGet Class. - * - * @param Container $container The DI container. - * - * @return SiteDynamicGet - * @since 3.2.0 - */ - public function getSiteDynamicGet(Container $container): SiteDynamicGet - { - return new SiteDynamicGet(); - } - - /** - * Get The SiteEditView Class. - * - * @param Container $container The DI container. - * - * @return SiteEditView - * @since 3.2.0 - */ - public function getSiteEditView(Container $container): SiteEditView - { - return new SiteEditView(); - } - - /** - * Get The SiteFieldData Class. - * - * @param Container $container The DI container. - * - * @return SiteFieldData - * @since 3.2.0 - */ - public function getSiteFieldData(Container $container): SiteFieldData - { - return new SiteFieldData(); - } - - /** - * Get The SiteFieldDecodeFilter Class. - * - * @param Container $container The DI container. - * - * @return SiteFieldDecodeFilter - * @since 3.2.0 - */ - public function getSiteFieldDecodeFilter(Container $container): SiteFieldDecodeFilter - { - return new SiteFieldDecodeFilter(); - } - - /** - * Get The SiteFields Class. - * - * @param Container $container The DI container. - * - * @return SiteFields - * @since 3.2.0 - */ - public function getSiteFields(Container $container): SiteFields - { - return new SiteFields(); - } - - /** - * Get The SiteMainGet Class. - * - * @param Container $container The DI container. - * - * @return SiteMainGet - * @since 3.2.0 - */ - public function getSiteMainGet(Container $container): SiteMainGet - { - return new SiteMainGet(); - } - - /** - * Get The Sort Class. - * - * @param Container $container The DI container. - * - * @return Sort - * @since 3.2.0 - */ - public function getSort(Container $container): Sort - { - return new Sort(); - } - - /** - * Get The TabCounter Class. - * - * @param Container $container The DI container. - * - * @return TabCounter - * @since 3.2.0 - */ - public function getTabCounter(Container $container): TabCounter - { - return new TabCounter(); - } - - /** - * Get The Tags Class. - * - * @param Container $container The DI container. - * - * @return Tags - * @since 3.2.0 - */ - public function getTags(Container $container): Tags - { - return new Tags(); - } - - /** - * Get The TemplateData Class. - * - * @param Container $container The DI container. - * - * @return TemplateData - * @since 3.2.0 - */ - public function getTemplateData(Container $container): TemplateData - { - return new TemplateData(); - } - - /** - * Get The Title Class. - * - * @param Container $container The DI container. - * - * @return Title - * @since 3.2.0 - */ - public function getTitle(Container $container): Title - { - return new Title(); - } - - /** - * Get The UikitComp Class. - * - * @param Container $container The DI container. - * - * @return UikitComp - * @since 3.2.0 - */ - public function getUikitComp(Container $container): UikitComp - { - return new UikitComp(); - } - - /** - * Get The UpdateMysql Class. - * - * @param Container $container The DI container. - * - * @return UpdateMysql - * @since 3.2.0 - */ - public function getUpdateMysql(Container $container): UpdateMysql - { - return new UpdateMysql(); - } - - /** - * Get The ViewsDefaultOrdering Class. - * - * @param Container $container The DI container. - * - * @return ViewsDefaultOrdering - * @since 3.2.0 - */ - public function getViewsDefaultOrdering(Container $container): ViewsDefaultOrdering - { - return new ViewsDefaultOrdering(); + /** + * 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(Languages::class, 'Compiler.Builder.Languages') + ->share('Compiler.Builder.Languages', [$this, 'getLanguages'], true); + + $container->alias(LanguageMessages::class, 'Compiler.Builder.Language.Messages') + ->share('Compiler.Builder.Language.Messages', [$this, 'getLanguageMessages'], true); + + $container->alias(Layout::class, 'Compiler.Builder.Layout') + ->share('Compiler.Builder.Layout', [$this, 'getLayout'], true); + + $container->alias(LayoutData::class, 'Compiler.Builder.Layout.Data') + ->share('Compiler.Builder.Layout.Data', [$this, 'getLayoutData'], true); + + $container->alias(LibraryManager::class, 'Compiler.Builder.Library.Manager') + ->share('Compiler.Builder.Library.Manager', [$this, 'getLibraryManager'], true); + + $container->alias(ListFieldClass::class, 'Compiler.Builder.List.Field.Class') + ->share('Compiler.Builder.List.Field.Class', [$this, 'getListFieldClass'], true); + + $container->alias(ListHeadOverride::class, 'Compiler.Builder.List.Head.Override') + ->share('Compiler.Builder.List.Head.Override', [$this, 'getListHeadOverride'], true); + + $container->alias(ListJoin::class, 'Compiler.Builder.List.Join') + ->share('Compiler.Builder.List.Join', [$this, 'getListJoin'], true); + + $container->alias(Lists::class, 'Compiler.Builder.Lists') + ->share('Compiler.Builder.Lists', [$this, 'getLists'], true); + + $container->alias(MainTextField::class, 'Compiler.Builder.Main.Text.Field') + ->share('Compiler.Builder.Main.Text.Field', [$this, 'getMainTextField'], true); + + $container->alias(MetaData::class, 'Compiler.Builder.Meta.Data') + ->share('Compiler.Builder.Meta.Data', [$this, 'getMetaData'], true); + + $container->alias(ModelBasicField::class, 'Compiler.Builder.Model.Basic.Field') + ->share('Compiler.Builder.Model.Basic.Field', [$this, 'getModelBasicField'], true); + + $container->alias(ModelExpertField::class, 'Compiler.Builder.Model.Expert.Field') + ->share('Compiler.Builder.Model.Expert.Field', [$this, 'getModelExpertField'], true); + + $container->alias(ModelExpertFieldInitiator::class, 'Compiler.Builder.Model.Expert.Field.Initiator') + ->share('Compiler.Builder.Model.Expert.Field.Initiator', [$this, 'getModelExpertFieldInitiator'], true); + + $container->alias(ModelMediumField::class, 'Compiler.Builder.Model.Medium.Field') + ->share('Compiler.Builder.Model.Medium.Field', [$this, 'getModelMediumField'], true); + + $container->alias(ModelWhmcsField::class, 'Compiler.Builder.Model.Whmcs.Field') + ->share('Compiler.Builder.Model.Whmcs.Field', [$this, 'getModelWhmcsField'], true); + + $container->alias(MovedPublishingFields::class, 'Compiler.Builder.Moved.Publishing.Fields') + ->share('Compiler.Builder.Moved.Publishing.Fields', [$this, 'getMovedPublishingFields'], true); + + $container->alias(Multilingual::class, 'Compiler.Builder.Multilingual') + ->share('Compiler.Builder.Multilingual', [$this, 'getMultilingual'], true); + + $container->alias(MysqlTableSetting::class, 'Compiler.Builder.Mysql.Table.Setting') + ->share('Compiler.Builder.Mysql.Table.Setting', [$this, 'getMysqlTableSetting'], true); + + $container->alias(NewPublishingFields::class, 'Compiler.Builder.New.Publishing.Fields') + ->share('Compiler.Builder.New.Publishing.Fields', [$this, 'getNewPublishingFields'], true); + + $container->alias(OrderZero::class, 'Compiler.Builder.Order.Zero') + ->share('Compiler.Builder.Order.Zero', [$this, 'getOrderZero'], true); + + $container->alias(OtherFilter::class, 'Compiler.Builder.Other.Filter') + ->share('Compiler.Builder.Other.Filter', [$this, 'getOtherFilter'], true); + + $container->alias(OtherGroup::class, 'Compiler.Builder.Other.Group') + ->share('Compiler.Builder.Other.Group', [$this, 'getOtherGroup'], true); + + $container->alias(OtherJoin::class, 'Compiler.Builder.Other.Join') + ->share('Compiler.Builder.Other.Join', [$this, 'getOtherJoin'], true); + + $container->alias(OtherOrder::class, 'Compiler.Builder.Other.Order') + ->share('Compiler.Builder.Other.Order', [$this, 'getOtherOrder'], true); + + $container->alias(OtherQuery::class, 'Compiler.Builder.Other.Query') + ->share('Compiler.Builder.Other.Query', [$this, 'getOtherQuery'], true); + + $container->alias(OtherWhere::class, 'Compiler.Builder.Other.Where') + ->share('Compiler.Builder.Other.Where', [$this, 'getOtherWhere'], true); + + $container->alias(PermissionAction::class, 'Compiler.Builder.Permission.Action') + ->share('Compiler.Builder.Permission.Action', [$this, 'getPermissionAction'], true); + + $container->alias(PermissionComponent::class, 'Compiler.Builder.Permission.Component') + ->share('Compiler.Builder.Permission.Component', [$this, 'getPermissionComponent'], true); + + $container->alias(PermissionCore::class, 'Compiler.Builder.Permission.Core') + ->share('Compiler.Builder.Permission.Core', [$this, 'getPermissionCore'], true); + + $container->alias(PermissionDashboard::class, 'Compiler.Builder.Permission.Dashboard') + ->share('Compiler.Builder.Permission.Dashboard', [$this, 'getPermissionDashboard'], true); + + $container->alias(PermissionFields::class, 'Compiler.Builder.Permission.Fields') + ->share('Compiler.Builder.Permission.Fields', [$this, 'getPermissionFields'], true); + + $container->alias(PermissionGlobalAction::class, 'Compiler.Builder.Permission.Global.Action') + ->share('Compiler.Builder.Permission.Global.Action', [$this, 'getPermissionGlobalAction'], true); + + $container->alias(PermissionViews::class, 'Compiler.Builder.Permission.Views') + ->share('Compiler.Builder.Permission.Views', [$this, 'getPermissionViews'], true); + + $container->alias(Request::class, 'Compiler.Builder.Request') + ->share('Compiler.Builder.Request', [$this, 'getRequest'], true); + + $container->alias(Router::class, 'Compiler.Builder.Router') + ->share('Compiler.Builder.Router', [$this, 'getRouter'], true); + + $container->alias(ScriptMediaSwitch::class, 'Compiler.Builder.Script.Media.Switch') + ->share('Compiler.Builder.Script.Media.Switch', [$this, 'getScriptMediaSwitch'], true); + + $container->alias(ScriptUserSwitch::class, 'Compiler.Builder.Script.User.Switch') + ->share('Compiler.Builder.Script.User.Switch', [$this, 'getScriptUserSwitch'], true); + + $container->alias(Search::class, 'Compiler.Builder.Search') + ->share('Compiler.Builder.Search', [$this, 'getSearch'], true); + + $container->alias(SelectionTranslation::class, 'Compiler.Builder.Selection.Translation') + ->share('Compiler.Builder.Selection.Translation', [$this, 'getSelectionTranslation'], true); + + $container->alias(SiteDecrypt::class, 'Compiler.Builder.Site.Decrypt') + ->share('Compiler.Builder.Site.Decrypt', [$this, 'getSiteDecrypt'], true); + + $container->alias(SiteDynamicGet::class, 'Compiler.Builder.Site.Dynamic.Get') + ->share('Compiler.Builder.Site.Dynamic.Get', [$this, 'getSiteDynamicGet'], true); + + $container->alias(SiteEditView::class, 'Compiler.Builder.Site.Edit.View') + ->share('Compiler.Builder.Site.Edit.View', [$this, 'getSiteEditView'], true); + + $container->alias(SiteFieldData::class, 'Compiler.Builder.Site.Field.Data') + ->share('Compiler.Builder.Site.Field.Data', [$this, 'getSiteFieldData'], true); + + $container->alias(SiteFieldDecodeFilter::class, 'Compiler.Builder.Site.Field.Decode.Filter') + ->share('Compiler.Builder.Site.Field.Decode.Filter', [$this, 'getSiteFieldDecodeFilter'], true); + + $container->alias(SiteFields::class, 'Compiler.Builder.Site.Fields') + ->share('Compiler.Builder.Site.Fields', [$this, 'getSiteFields'], true); + + $container->alias(SiteMainGet::class, 'Compiler.Builder.Site.Main.Get') + ->share('Compiler.Builder.Site.Main.Get', [$this, 'getSiteMainGet'], true); + + $container->alias(Sort::class, 'Compiler.Builder.Sort') + ->share('Compiler.Builder.Sort', [$this, 'getSort'], true); + + $container->alias(TabCounter::class, 'Compiler.Builder.Tab.Counter') + ->share('Compiler.Builder.Tab.Counter', [$this, 'getTabCounter'], true); + + $container->alias(Tags::class, 'Compiler.Builder.Tags') + ->share('Compiler.Builder.Tags', [$this, 'getTags'], true); + + $container->alias(TemplateData::class, 'Compiler.Builder.Template.Data') + ->share('Compiler.Builder.Template.Data', [$this, 'getTemplateData'], true); + + $container->alias(Title::class, 'Compiler.Builder.Title') + ->share('Compiler.Builder.Title', [$this, 'getTitle'], true); + + $container->alias(UikitComp::class, 'Compiler.Builder.Uikit.Comp') + ->share('Compiler.Builder.Uikit.Comp', [$this, 'getUikitComp'], true); + + $container->alias(UpdateMysql::class, 'Compiler.Builder.Update.Mysql') + ->share('Compiler.Builder.Update.Mysql', [$this, 'getUpdateMysql'], true); + + $container->alias(ViewsDefaultOrdering::class, 'Compiler.Builder.Views.Default.Ordering') + ->share('Compiler.Builder.Views.Default.Ordering', [$this, 'getViewsDefaultOrdering'], true); + } + + /** + * Get The Languages Class. + * + * @param Container $container The DI container. + * + * @return Languages + * @since 3.2.0 + */ + public function getLanguages(Container $container): Languages + { + return new Languages(); + } + + /** + * Get The LanguageMessages Class. + * + * @param Container $container The DI container. + * + * @return LanguageMessages + * @since 3.2.0 + */ + public function getLanguageMessages(Container $container): LanguageMessages + { + return new LanguageMessages(); + } + + /** + * Get The Layout Class. + * + * @param Container $container The DI container. + * + * @return Layout + * @since 3.2.0 + */ + public function getLayout(Container $container): Layout + { + return new Layout(); + } + + /** + * Get The LayoutData Class. + * + * @param Container $container The DI container. + * + * @return LayoutData + * @since 3.2.0 + */ + public function getLayoutData(Container $container): LayoutData + { + return new LayoutData(); + } + + /** + * Get The LibraryManager Class. + * + * @param Container $container The DI container. + * + * @return LibraryManager + * @since 3.2.0 + */ + public function getLibraryManager(Container $container): LibraryManager + { + return new LibraryManager(); + } + + /** + * Get The ListFieldClass Class. + * + * @param Container $container The DI container. + * + * @return ListFieldClass + * @since 3.2.0 + */ + public function getListFieldClass(Container $container): ListFieldClass + { + return new ListFieldClass(); + } + + /** + * Get The ListHeadOverride Class. + * + * @param Container $container The DI container. + * + * @return ListHeadOverride + * @since 3.2.0 + */ + public function getListHeadOverride(Container $container): ListHeadOverride + { + return new ListHeadOverride(); + } + + /** + * Get The ListJoin Class. + * + * @param Container $container The DI container. + * + * @return ListJoin + * @since 3.2.0 + */ + public function getListJoin(Container $container): ListJoin + { + return new ListJoin(); + } + + /** + * Get The Lists Class. + * + * @param Container $container The DI container. + * + * @return Lists + * @since 3.2.0 + */ + public function getLists(Container $container): Lists + { + return new Lists(); + } + + /** + * Get The MainTextField Class. + * + * @param Container $container The DI container. + * + * @return MainTextField + * @since 3.2.0 + */ + public function getMainTextField(Container $container): MainTextField + { + return new MainTextField(); + } + + /** + * Get The MetaData Class. + * + * @param Container $container The DI container. + * + * @return MetaData + * @since 3.2.0 + */ + public function getMetaData(Container $container): MetaData + { + return new MetaData(); + } + + /** + * Get The ModelBasicField Class. + * + * @param Container $container The DI container. + * + * @return ModelBasicField + * @since 3.2.0 + */ + public function getModelBasicField(Container $container): ModelBasicField + { + return new ModelBasicField(); + } + + /** + * Get The ModelExpertField Class. + * + * @param Container $container The DI container. + * + * @return ModelExpertField + * @since 3.2.0 + */ + public function getModelExpertField(Container $container): ModelExpertField + { + return new ModelExpertField(); + } + + /** + * Get The ModelExpertFieldInitiator Class. + * + * @param Container $container The DI container. + * + * @return ModelExpertFieldInitiator + * @since 3.2.0 + */ + public function getModelExpertFieldInitiator(Container $container): ModelExpertFieldInitiator + { + return new ModelExpertFieldInitiator(); + } + + /** + * Get The ModelMediumField Class. + * + * @param Container $container The DI container. + * + * @return ModelMediumField + * @since 3.2.0 + */ + public function getModelMediumField(Container $container): ModelMediumField + { + return new ModelMediumField(); + } + + /** + * Get The ModelWhmcsField Class. + * + * @param Container $container The DI container. + * + * @return ModelWhmcsField + * @since 3.2.0 + */ + public function getModelWhmcsField(Container $container): ModelWhmcsField + { + return new ModelWhmcsField(); + } + + /** + * Get The MovedPublishingFields Class. + * + * @param Container $container The DI container. + * + * @return MovedPublishingFields + * @since 3.2.0 + */ + public function getMovedPublishingFields(Container $container): MovedPublishingFields + { + return new MovedPublishingFields(); + } + + /** + * Get The Multilingual Class. + * + * @param Container $container The DI container. + * + * @return Multilingual + * @since 3.2.0 + */ + public function getMultilingual(Container $container): Multilingual + { + return new Multilingual(); + } + + /** + * Get The MysqlTableSetting Class. + * + * @param Container $container The DI container. + * + * @return MysqlTableSetting + * @since 3.2.0 + */ + public function getMysqlTableSetting(Container $container): MysqlTableSetting + { + return new MysqlTableSetting(); + } + + /** + * Get The NewPublishingFields Class. + * + * @param Container $container The DI container. + * + * @return NewPublishingFields + * @since 3.2.0 + */ + public function getNewPublishingFields(Container $container): NewPublishingFields + { + return new NewPublishingFields(); + } + + /** + * Get The OrderZero Class. + * + * @param Container $container The DI container. + * + * @return OrderZero + * @since 3.2.0 + */ + public function getOrderZero(Container $container): OrderZero + { + return new OrderZero(); + } + + /** + * Get The OtherFilter Class. + * + * @param Container $container The DI container. + * + * @return OtherFilter + * @since 3.2.0 + */ + public function getOtherFilter(Container $container): OtherFilter + { + return new OtherFilter(); + } + + /** + * Get The OtherGroup Class. + * + * @param Container $container The DI container. + * + * @return OtherGroup + * @since 3.2.0 + */ + public function getOtherGroup(Container $container): OtherGroup + { + return new OtherGroup(); + } + + /** + * Get The OtherJoin Class. + * + * @param Container $container The DI container. + * + * @return OtherJoin + * @since 3.2.0 + */ + public function getOtherJoin(Container $container): OtherJoin + { + return new OtherJoin(); + } + + /** + * Get The OtherOrder Class. + * + * @param Container $container The DI container. + * + * @return OtherOrder + * @since 3.2.0 + */ + public function getOtherOrder(Container $container): OtherOrder + { + return new OtherOrder(); + } + + /** + * Get The OtherQuery Class. + * + * @param Container $container The DI container. + * + * @return OtherQuery + * @since 3.2.0 + */ + public function getOtherQuery(Container $container): OtherQuery + { + return new OtherQuery(); + } + + /** + * Get The OtherWhere Class. + * + * @param Container $container The DI container. + * + * @return OtherWhere + * @since 3.2.0 + */ + public function getOtherWhere(Container $container): OtherWhere + { + return new OtherWhere(); + } + + /** + * Get The PermissionAction Class. + * + * @param Container $container The DI container. + * + * @return PermissionAction + * @since 3.2.0 + */ + public function getPermissionAction(Container $container): PermissionAction + { + return new PermissionAction(); + } + + /** + * Get The PermissionComponent Class. + * + * @param Container $container The DI container. + * + * @return PermissionComponent + * @since 3.2.0 + */ + public function getPermissionComponent(Container $container): PermissionComponent + { + return new PermissionComponent(); + } + + /** + * Get The PermissionCore Class. + * + * @param Container $container The DI container. + * + * @return PermissionCore + * @since 3.2.0 + */ + public function getPermissionCore(Container $container): PermissionCore + { + return new PermissionCore(); + } + + /** + * Get The PermissionDashboard Class. + * + * @param Container $container The DI container. + * + * @return PermissionDashboard + * @since 3.2.0 + */ + public function getPermissionDashboard(Container $container): PermissionDashboard + { + return new PermissionDashboard(); + } + + /** + * Get The PermissionFields Class. + * + * @param Container $container The DI container. + * + * @return PermissionFields + * @since 3.2.0 + */ + public function getPermissionFields(Container $container): PermissionFields + { + return new PermissionFields(); + } + + /** + * Get The PermissionGlobalAction Class. + * + * @param Container $container The DI container. + * + * @return PermissionGlobalAction + * @since 3.2.0 + */ + public function getPermissionGlobalAction(Container $container): PermissionGlobalAction + { + return new PermissionGlobalAction(); + } + + /** + * Get The PermissionViews Class. + * + * @param Container $container The DI container. + * + * @return PermissionViews + * @since 3.2.0 + */ + public function getPermissionViews(Container $container): PermissionViews + { + return new PermissionViews(); + } + + /** + * Get The Request Class. + * + * @param Container $container The DI container. + * + * @return Request + * @since 3.2.0 + */ + public function getRequest(Container $container): Request + { + return new Request(); + } + + /** + * Get The Router Class. + * + * @param Container $container The DI container. + * + * @return Router + * @since 3.2.0 + */ + public function getRouter(Container $container): Router + { + return new Router(); + } + + /** + * Get The ScriptMediaSwitch Class. + * + * @param Container $container The DI container. + * + * @return ScriptMediaSwitch + * @since 3.2.0 + */ + public function getScriptMediaSwitch(Container $container): ScriptMediaSwitch + { + return new ScriptMediaSwitch(); + } + + /** + * Get The ScriptUserSwitch Class. + * + * @param Container $container The DI container. + * + * @return ScriptUserSwitch + * @since 3.2.0 + */ + public function getScriptUserSwitch(Container $container): ScriptUserSwitch + { + return new ScriptUserSwitch(); + } + + /** + * Get The Search Class. + * + * @param Container $container The DI container. + * + * @return Search + * @since 3.2.0 + */ + public function getSearch(Container $container): Search + { + return new Search(); + } + + /** + * Get The SelectionTranslation Class. + * + * @param Container $container The DI container. + * + * @return SelectionTranslation + * @since 3.2.0 + */ + public function getSelectionTranslation(Container $container): SelectionTranslation + { + return new SelectionTranslation(); + } + + /** + * Get The SiteDecrypt Class. + * + * @param Container $container The DI container. + * + * @return SiteDecrypt + * @since 3.2.0 + */ + public function getSiteDecrypt(Container $container): SiteDecrypt + { + return new SiteDecrypt(); + } + + /** + * Get The SiteDynamicGet Class. + * + * @param Container $container The DI container. + * + * @return SiteDynamicGet + * @since 3.2.0 + */ + public function getSiteDynamicGet(Container $container): SiteDynamicGet + { + return new SiteDynamicGet(); + } + + /** + * Get The SiteEditView Class. + * + * @param Container $container The DI container. + * + * @return SiteEditView + * @since 3.2.0 + */ + public function getSiteEditView(Container $container): SiteEditView + { + return new SiteEditView(); + } + + /** + * Get The SiteFieldData Class. + * + * @param Container $container The DI container. + * + * @return SiteFieldData + * @since 3.2.0 + */ + public function getSiteFieldData(Container $container): SiteFieldData + { + return new SiteFieldData(); + } + + /** + * Get The SiteFieldDecodeFilter Class. + * + * @param Container $container The DI container. + * + * @return SiteFieldDecodeFilter + * @since 3.2.0 + */ + public function getSiteFieldDecodeFilter(Container $container): SiteFieldDecodeFilter + { + return new SiteFieldDecodeFilter(); + } + + /** + * Get The SiteFields Class. + * + * @param Container $container The DI container. + * + * @return SiteFields + * @since 3.2.0 + */ + public function getSiteFields(Container $container): SiteFields + { + return new SiteFields(); + } + + /** + * Get The SiteMainGet Class. + * + * @param Container $container The DI container. + * + * @return SiteMainGet + * @since 3.2.0 + */ + public function getSiteMainGet(Container $container): SiteMainGet + { + return new SiteMainGet(); + } + + /** + * Get The Sort Class. + * + * @param Container $container The DI container. + * + * @return Sort + * @since 3.2.0 + */ + public function getSort(Container $container): Sort + { + return new Sort(); + } + + /** + * Get The TabCounter Class. + * + * @param Container $container The DI container. + * + * @return TabCounter + * @since 3.2.0 + */ + public function getTabCounter(Container $container): TabCounter + { + return new TabCounter(); + } + + /** + * Get The Tags Class. + * + * @param Container $container The DI container. + * + * @return Tags + * @since 3.2.0 + */ + public function getTags(Container $container): Tags + { + return new Tags(); + } + + /** + * Get The TemplateData Class. + * + * @param Container $container The DI container. + * + * @return TemplateData + * @since 3.2.0 + */ + public function getTemplateData(Container $container): TemplateData + { + return new TemplateData(); + } + + /** + * Get The Title Class. + * + * @param Container $container The DI container. + * + * @return Title + * @since 3.2.0 + */ + public function getTitle(Container $container): Title + { + return new Title(); + } + + /** + * Get The UikitComp Class. + * + * @param Container $container The DI container. + * + * @return UikitComp + * @since 3.2.0 + */ + public function getUikitComp(Container $container): UikitComp + { + return new UikitComp(); + } + + /** + * Get The UpdateMysql Class. + * + * @param Container $container The DI container. + * + * @return UpdateMysql + * @since 3.2.0 + */ + public function getUpdateMysql(Container $container): UpdateMysql + { + return new UpdateMysql(); + } + + /** + * Get The ViewsDefaultOrdering Class. + * + * @param Container $container The DI container. + * + * @return ViewsDefaultOrdering + * @since 3.2.0 + */ + public function getViewsDefaultOrdering(Container $container): ViewsDefaultOrdering + { + return new ViewsDefaultOrdering(); } \ No newline at end of file diff --git a/src/2c76c06e-a371-4b73-9fbe-b4d9b4df55d7/settings.json b/src/2c76c06e-a371-4b73-9fbe-b4d9b4df55d7/settings.json index 010f769..3707e0e 100644 --- a/src/2c76c06e-a371-4b73-9fbe-b4d9b4df55d7/settings.json +++ b/src/2c76c06e-a371-4b73-9fbe-b4d9b4df55d7/settings.json @@ -80,6 +80,10 @@ "use": "9cdff2af-bd1b-452f-810e-d034b9720d2a", "as": "default" }, + "use_selection54": { + "use": "a8c6158a-6fd2-476b-a5ea-c81f1ecd2356", + "as": "default" + }, "use_selection17": { "use": "9ff6d6cd-afea-4f15-a67b-fd132d386989", "as": "default" diff --git a/src/344d36be-3949-4848-8cb0-e3d3d9d05c36/README.md b/src/344d36be-3949-4848-8cb0-e3d3d9d05c36/README.md new file mode 100644 index 0000000..a920c85 --- /dev/null +++ b/src/344d36be-3949-4848-8cb0-e3d3d9d05c36/README.md @@ -0,0 +1,69 @@ +``` +██████╗ ██████╗ ██╗ ██╗███████╗██████╗ +██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗ +██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝ +██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗ +██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║ +╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝ +``` +# final class Translation (Details) +> namespace: **VDM\Joomla\Componentbuilder\Compiler\Language** + +```uml +@startuml +class Translation << (F,LightGreen) >> #RoyalBlue { + # Config $config + # Messages $messages + + __construct(Config $config, Messages $messages) + + check(string $tag, array $languageStrings, ...) : bool +} + +note right of Translation::__construct + Constructor. + + since: 5.0.2 +end note + +note right of Translation::check + Check if a translation should be added. +This method determines if a translation should be included based on the percentage +of translated strings and logs the decision. + + since: 5.0.2 + return: bool + + arguments: + string $tag + array $languageStrings + int $total + string $file_name +end note + +@enduml +``` + +The Power feature in JCB allows you to write PHP classes and their implementations, making it easy to include them in your Joomla project. JCB handles linking, autoloading, namespacing, and folder structure creation for you. + +By using the SPK (Super Power Key) in your custom code (replacing the class name in your code with the SPK), JCB will automatically pull the power from the repository into your project. This makes it available in your JCB instance, allowing you to edit it and include the class in your generated Joomla component. + +JCB uses placeholders like [[[`NamespacePrefix`]]] and [[[`ComponentNamespace`]]] in namespacing to prevent collisions and improve reusability across different JCB systems. You can also set the **JCB powers path** globally or per component under the **Dynamic Integration** tab, providing flexibility and easy maintainability. + +To add this specific Power to your project in JCB: + +> simply use this SPK +``` +Super---344d36be_3949_4848_8cb0_e3d3d9d05c36---Power +``` +> remember to replace the `---` with `___` to activate this Power in your code + +--- +``` + ██╗ ██████╗██████╗ + ██║██╔════╝██╔══██╗ + ██║██║ ██████╔╝ +██ ██║██║ ██╔══██╗ +╚█████╔╝╚██████╗██████╔╝ + ╚════╝ ╚═════╝╚═════╝ +``` +> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder) + diff --git a/src/344d36be-3949-4848-8cb0-e3d3d9d05c36/code.php b/src/344d36be-3949-4848-8cb0-e3d3d9d05c36/code.php new file mode 100644 index 0000000..193c072 --- /dev/null +++ b/src/344d36be-3949-4848-8cb0-e3d3d9d05c36/code.php @@ -0,0 +1,101 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Componentbuilder\Compiler\Language; + + +use VDM\Joomla\Componentbuilder\Compiler\Config; +use VDM\Joomla\Componentbuilder\Compiler\Builder\LanguageMessages as Messages; + + +/** + * Compiler Language Translation Checker + * + * @since 5.0.2 + */ +final class Translation +{ + /** + * The Config Class. + * + * @var Config + * @since 5.0.2 + */ + protected Config $config; + + /** + * The Language Messages Class. + * + * @var Messages + * @since 5.0.2 + */ + protected Messages $messages; + + /** + * Constructor. + * + * @param Config $config The Config Class. + * @param Messages $messages The Language Messages Class. + * + * @since 5.0.2 + */ + public function __construct(Config $config, Messages $messages) + { + $this->config = $config; + $this->messages = $messages; + } + + /** + * Check if a translation should be added. + * + * This method determines if a translation should be included based on the percentage + * of translated strings and logs the decision. + * + * @param string $tag The language tag. + * @param array $languageStrings The active language strings. + * @param int $total The total number of strings. + * @param string $file_name The file name. + * + * @return bool Returns true if the translation should be added; false otherwise. + * @since 5.0.2 + */ + public function check(string &$tag, array &$languageStrings, int &$total, string &$file_name): bool + { + $langTag = $this->config->get('lang_tag', 'en-GB'); + if ($langTag !== $tag) + { + $langStringNr = count($languageStrings); + $percentage = ($langStringNr / $total) * 100; + $stringName = ($langStringNr == 1) ? "(string $tag translated)" : "(strings $tag translated)"; + + if (!$this->config->get('debug_line_nr', false)) + { + if ($percentage < $this->config->percentage_language_add) + { + $this->messages->set( + "exclude.$file_name", + "$total(total " . $langTag . " strings) only $langStringNr $stringName = $percentage" + ); + + return false; + } + } + + $this->messages->set( + "include.$file_name", + "$total(total " . $langTag . " strings) and $langStringNr $stringName = $percentage" + ); + } + + return true; + } +} + diff --git a/src/344d36be-3949-4848-8cb0-e3d3d9d05c36/code.power b/src/344d36be-3949-4848-8cb0-e3d3d9d05c36/code.power new file mode 100644 index 0000000..8e35dfd --- /dev/null +++ b/src/344d36be-3949-4848-8cb0-e3d3d9d05c36/code.power @@ -0,0 +1,74 @@ + /** + * The Config Class. + * + * @var Config + * @since 5.0.2 + */ + protected Config $config; + + /** + * The Language Messages Class. + * + * @var Messages + * @since 5.0.2 + */ + protected Messages $messages; + + /** + * Constructor. + * + * @param Config $config The Config Class. + * @param Messages $messages The Language Messages Class. + * + * @since 5.0.2 + */ + public function __construct(Config $config, Messages $messages) + { + $this->config = $config; + $this->messages = $messages; + } + + /** + * Check if a translation should be added. + * + * This method determines if a translation should be included based on the percentage + * of translated strings and logs the decision. + * + * @param string $tag The language tag. + * @param array $languageStrings The active language strings. + * @param int $total The total number of strings. + * @param string $file_name The file name. + * + * @return bool Returns true if the translation should be added; false otherwise. + * @since 5.0.2 + */ + public function check(string &$tag, array &$languageStrings, int &$total, string &$file_name): bool + { + $langTag = $this->config->get('lang_tag', 'en-GB'); + if ($langTag !== $tag) + { + $langStringNr = count($languageStrings); + $percentage = ($langStringNr / $total) * 100; + $stringName = ($langStringNr == 1) ? "(string $tag translated)" : "(strings $tag translated)"; + + if (!$this->config->get('debug_line_nr', false)) + { + if ($percentage < $this->config->percentage_language_add) + { + $this->messages->set( + "exclude.$file_name", + "$total(total " . $langTag . " strings) only $langStringNr $stringName = $percentage" + ); + + return false; + } + } + + $this->messages->set( + "include.$file_name", + "$total(total " . $langTag . " strings) and $langStringNr $stringName = $percentage" + ); + } + + return true; + } \ No newline at end of file diff --git a/src/344d36be-3949-4848-8cb0-e3d3d9d05c36/settings.json b/src/344d36be-3949-4848-8cb0-e3d3d9d05c36/settings.json new file mode 100644 index 0000000..a2c027c --- /dev/null +++ b/src/344d36be-3949-4848-8cb0-e3d3d9d05c36/settings.json @@ -0,0 +1,28 @@ +{ + "add_head": "0", + "add_licensing_template": "2", + "extends": "", + "guid": "344d36be-3949-4848-8cb0-e3d3d9d05c36", + "implements": null, + "load_selection": null, + "name": "Translation", + "power_version": "1.0.0", + "system_name": "JCB.Compiler.Language.Translation", + "type": "final class", + "use_selection": { + "use_selection0": { + "use": "fa4bf18e-301e-42e3-91fb-6e0096c07adc", + "as": "default" + }, + "use_selection1": { + "use": "44efa649-736d-4656-a0ec-e4f1653a6742", + "as": "Messages" + } + }, + "extendsinterfaces": null, + "namespace": "[[[NamespacePrefix]]]\\Joomla\\[[[ComponentNamespace]]].Compiler.Language.Translation", + "description": "Compiler Language Translation Checker\r\n\r\n@since 5.0.2", + "licensing_template": "\/**\r\n * @package Joomla.Component.Builder\r\n *\r\n * @created 4th September, 2022\r\n * @author Llewellyn van der Merwe \r\n * @git Joomla Component Builder \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/34daa4c8-45c3-4249-baa3-1bedf8ed3ebc/README.md b/src/34daa4c8-45c3-4249-baa3-1bedf8ed3ebc/README.md new file mode 100644 index 0000000..c1b2094 --- /dev/null +++ b/src/34daa4c8-45c3-4249-baa3-1bedf8ed3ebc/README.md @@ -0,0 +1,181 @@ +``` +██████╗ ██████╗ ██╗ ██╗███████╗██████╗ +██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗ +██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝ +██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗ +██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║ +╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝ +``` +# class Structure (Details) +> namespace: **VDM\Joomla\Componentbuilder\Compiler\Joomlaplugin\JoomlaFour** + +```uml +@startuml +class Structure #Gold { + # Plugin $plugin + # Component $component + # Config $config + # Registry $registry + # Dispenser $dispenser + # Event $event + # Counter $counter + # Folder $folder + # File $file + # Files $files + # Placeholder $placeholder + # string $NamespacePrefix + # string $ComponentNamespace + + __construct(Plugin $plugin, Component $component, ...) + + build() : void + # getXML(object $plugin) : string + # pluginPath(object $plugin) : void + # setMainClassFile(object $plugin) : void + # setServiceProviderClassFile(object $plugin) : void + # setMainXmlFile(object $plugin) : void + # setInstallScript(object $plugin) : void + # setReadme(object $plugin) : void + # setForms(object $plugin) : void + # setSQL(object $plugin) : void + # setFiles(object $plugin) : void + # setFolders(object $plugin) : void + # setUrls(object $plugin) : void +} + +note right of Structure::__construct + Constructor. + + since: 3.2.0 + + arguments: + Plugin $plugin + Component $component + Config $config + Registry $registry + Dispenser $dispenser + Event $event + Counter $counter + Folder $folder + File $file + Files $files + Placeholder $placeholder +end note + +note left of Structure::build + Build the Plugins files, folders, url's and config + + since: 3.2.0 + return: void +end note + +note right of Structure::getXML + get the plugin xml template + + since: 3.2.0 + return: string +end note + +note left of Structure::pluginPath + set the plugin path + + since: 3.2.0 + return: void +end note + +note right of Structure::setMainClassFile + set the main class path + + since: 3.2.0 + return: void +end note + +note left of Structure::setServiceProviderClassFile + set the service provider path + + since: 3.2.0 + return: void +end note + +note right of Structure::setMainXmlFile + set the main xml file + + since: 3.2.0 + return: void +end note + +note left of Structure::setInstallScript + set the install script file + + since: 3.2.0 + return: void +end note + +note right of Structure::setReadme + set the readme file + + since: 3.2.0 + return: void +end note + +note left of Structure::setForms + set the form files and folders + + since: 3.2.0 + return: void +end note + +note right of Structure::setSQL + set the sql stuff + + since: 3.2.0 + return: void +end note + +note left of Structure::setFiles + set the files + + since: 3.2.0 + return: void +end note + +note right of Structure::setFolders + set the folders + + since: 3.2.0 + return: void +end note + +note left of Structure::setUrls + set the urls + + since: 3.2.0 + return: void +end note + +@enduml +``` + +The Power feature in JCB allows you to write PHP classes and their implementations, making it easy to include them in your Joomla project. JCB handles linking, autoloading, namespacing, and folder structure creation for you. + +By using the SPK (Super Power Key) in your custom code (replacing the class name in your code with the SPK), JCB will automatically pull the power from the repository into your project. This makes it available in your JCB instance, allowing you to edit it and include the class in your generated Joomla component. + +JCB uses placeholders like [[[`NamespacePrefix`]]] and [[[`ComponentNamespace`]]] in namespacing to prevent collisions and improve reusability across different JCB systems. You can also set the **JCB powers path** globally or per component under the **Dynamic Integration** tab, providing flexibility and easy maintainability. + +To add this specific Power to your project in JCB: + +> simply use this SPK +``` +Super---34daa4c8_45c3_4249_baa3_1bedf8ed3ebc---Power +``` +> remember to replace the `---` with `___` to activate this Power in your code + +--- +``` + ██╗ ██████╗██████╗ + ██║██╔════╝██╔══██╗ + ██║██║ ██████╔╝ +██ ██║██║ ██╔══██╗ +╚█████╔╝╚██████╗██████╔╝ + ╚════╝ ╚═════╝╚═════╝ +``` +> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder) + diff --git a/src/34daa4c8-45c3-4249-baa3-1bedf8ed3ebc/code.php b/src/34daa4c8-45c3-4249-baa3-1bedf8ed3ebc/code.php new file mode 100644 index 0000000..056f419 --- /dev/null +++ b/src/34daa4c8-45c3-4249-baa3-1bedf8ed3ebc/code.php @@ -0,0 +1,830 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Componentbuilder\Compiler\Joomlaplugin\JoomlaFour; + + +use VDM\Joomla\Componentbuilder\Compiler\Interfaces\PluginDataInterface as Plugin; +use VDM\Joomla\Componentbuilder\Compiler\Component; +use VDM\Joomla\Componentbuilder\Compiler\Config; +use VDM\Joomla\Componentbuilder\Compiler\Registry; +use VDM\Joomla\Componentbuilder\Compiler\Customcode\Dispenser; +use VDM\Joomla\Componentbuilder\Compiler\Interfaces\EventInterface as Event; +use VDM\Joomla\Componentbuilder\Compiler\Utilities\Counter; +use VDM\Joomla\Componentbuilder\Compiler\Utilities\Folder; +use VDM\Joomla\Componentbuilder\Compiler\Utilities\File; +use VDM\Joomla\Componentbuilder\Compiler\Utilities\Files; +use VDM\Joomla\Componentbuilder\Compiler\Placeholder; +use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent; +use VDM\Joomla\Componentbuilder\Compiler\Utilities\Placefix; +use VDM\Joomla\Componentbuilder\Compiler\Utilities\Line; +use VDM\Joomla\Utilities\ArrayHelper; +use VDM\Joomla\Utilities\ObjectHelper; +use VDM\Joomla\Utilities\StringHelper; +use VDM\Joomla\Utilities\FileHelper; +use VDM\Joomla\Componentbuilder\Interfaces\Plugin\StructureInterface; + + +/** + * Joomla 4 Plugin Builder Class + * + * @since 5.0.2 + */ +class Structure implements StructureInterface +{ + /** + * The Data Class. + * + * @var Plugin + * @since 3.2.0 + */ + protected Plugin $plugin; + + /** + * The Component Class. + * + * @var Component + * @since 3.2.0 + */ + protected Component $component; + + /** + * The Config Class. + * + * @var Config + * @since 3.2.0 + */ + protected Config $config; + + /** + * The Registry Class. + * + * @var Registry + * @since 3.2.0 + */ + protected Registry $registry; + + /** + * The Dispenser Class. + * + * @var Dispenser + * @since 3.2.0 + */ + protected Dispenser $dispenser; + + /** + * The EventInterface Class. + * + * @var Event + * @since 3.2.0 + */ + protected Event $event; + + /** + * The Counter Class. + * + * @var Counter + * @since 3.2.0 + */ + protected Counter $counter; + + /** + * The Folder Class. + * + * @var Folder + * @since 3.2.0 + */ + protected Folder $folder; + + /** + * The File Class. + * + * @var File + * @since 3.2.0 + */ + protected File $file; + + /** + * The Files Class. + * + * @var Files + * @since 3.2.0 + */ + protected Files $files; + + /** + * The Placeholder Class. + * + * @var Placeholder + * @since 5.0.0 + */ + protected Placeholder $placeholder; + + /** + * The Namespace Prefix + * + * @var string + * @since 5.0.0 + */ + protected string $NamespacePrefix; + + /** + * The Component Namespace (in code) + * + * @var string + * @since 3.2.0 + */ + protected string $ComponentNamespace; + + /** + * Constructor. + * + * @param Plugin $plugin The Data Class. + * @param Component $component The Component Class. + * @param Config $config The Config Class. + * @param Registry $registry The Registry Class. + * @param Dispenser $dispenser The Dispenser Class. + * @param Event $event The EventInterface Class. + * @param Counter $counter The Counter Class. + * @param Folder $folder The Folder Class. + * @param File $file The File Class. + * @param Files $files The Files Class. + * @param Placeholder $placeholder The Placeholder Class. + * + * @since 3.2.0 + */ + public function __construct(Plugin $plugin, Component $component, Config $config, + Registry $registry, Dispenser $dispenser, Event $event, + Counter $counter, Folder $folder, File $file, + Files $files, Placeholder $placeholder) + { + $this->plugin = $plugin; + $this->component = $component; + $this->config = $config; + $this->registry = $registry; + $this->dispenser = $dispenser; + $this->event = $event; + $this->counter = $counter; + $this->folder = $folder; + $this->file = $file; + $this->files = $files; + $this->placeholder = $placeholder; + + // set some global values + $this->NamespacePrefix = $this->placeholder->get('NamespacePrefix'); + $this->ComponentNamespace = $this->placeholder->get('ComponentNamespace'); + } + + /** + * Build the Plugins files, folders, url's and config + * + * @return void + * @since 3.2.0 + */ + public function build() + { + if ($this->plugin->exists()) + { + // for plugin event TODO change event api signatures + $component_context = $this->config->component_context; + $plugins = $this->plugin->get(); + + // Trigger Event: jcb_ce_onBeforeSetPlugins + $this->event->trigger( + 'jcb_ce_onBeforeBuildPlugins', + array(&$component_context, &$plugins) + ); + + foreach ($plugins as $plugin) + { + if (ObjectHelper::check($plugin) + && isset($plugin->folder_name) + && StringHelper::check($plugin->folder_name)) + { + // plugin path + $this->pluginPath($plugin); + + // create src folder + $this->folder->create($plugin->folder_path . '/src'); + + // set the plugin paths + $this->registry->set('dynamic_paths.' . $plugin->key, $plugin->folder_path); + + // make sure there is no old build + $this->folder->remove($plugin->folder_path); + + // creat the main component folder + $this->folder->create($plugin->folder_path); + + // set main class file + $this->setMainClassFile($plugin); + + // set service provider class file + $this->setServiceProviderClassFile($plugin); + + // set main xml file + $this->setMainXmlFile($plugin); + + // set install script if needed + $this->setInstallScript($plugin); + + // set readme if found + $this->setReadme($plugin); + + // set fields & rules folders if needed + if (isset($plugin->fields_rules_paths) + && $plugin->fields_rules_paths == 2) + { + // create fields folder + $this->folder->create($plugin->folder_path . '/src/Field'); + + // create rules folder + $this->folder->create($plugin->folder_path . '/src/Rule'); + } + + // set forms folder if needed + $this->setForms($plugin); + + // set SQL stuff if needed + $this->setSQL($plugin); + + // create the language folder path + $this->folder->create($plugin->folder_path . '/language'); + + // also create the lang tag folder path + $this->folder->create( + $plugin->folder_path . '/language/' . $this->config->get('lang_tag', 'en-GB') + ); + + // check if this plugin has files + $this->setFiles($plugin); + + // check if this plugin has folders + $this->setFolders($plugin); + + // check if this plugin has urls + $this->setUrls($plugin); + } + } + } + } + + /** + * get the plugin xml template + * + * @param object $plugin The plugin object + * + * @return string + * @since 3.2.0 + */ + protected function getXML(object $plugin): string + { + $xml = ''; + $xml .= PHP_EOL . ''; + $xml .= PHP_EOL . Indent::_(1) . '' . $plugin->lang_prefix + . ''; + $xml .= PHP_EOL . Indent::_(1) . '' . Placefix::_h('BUILDDATE') . ''; + $xml .= PHP_EOL . Indent::_(1) . '' . Placefix::_h('AUTHOR') . ''; + $xml .= PHP_EOL . Indent::_(1) . '' . Placefix::_h('AUTHOREMAIL') . ''; + $xml .= PHP_EOL . Indent::_(1) . '' . Placefix::_h('AUTHORWEBSITE') . ''; + $xml .= PHP_EOL . Indent::_(1) . '' . Placefix::_h('COPYRIGHT') . ''; + $xml .= PHP_EOL . Indent::_(1) . '' . Placefix::_h('LICENSE') . ''; + $xml .= PHP_EOL . Indent::_(1) . '' . $plugin->plugin_version + . ''; + $xml .= PHP_EOL . Indent::_(1) . '' . "{$this->NamespacePrefix}\\Plugin\\{$plugin->group_namespace}\\{$plugin->namespace}" + . ''; + $xml .= PHP_EOL . Indent::_(1) . '' . $plugin->lang_prefix + . '_XML_DESCRIPTION'; + $xml .= Placefix::_h('MAINXML'); + $xml .= PHP_EOL . ''; + + return $xml; + } + + /** + * set the plugin path + * + * @param object $plugin The plugin object + * + * @return void + * @since 3.2.0 + */ + protected function pluginPath(object &$plugin): void + { + $plugin->folder_path = $this->config->get('compiler_path', JPATH_COMPONENT_ADMINISTRATOR . '/compiler') . '/' + . $plugin->folder_name; + } + + /** + * set the main class path + * + * @param object $plugin The plugin object + * + * @return void + * @since 3.2.0 + */ + protected function setMainClassFile(object $plugin): void + { + // create extension folder + $this->folder->create($plugin->folder_path . '/src/Extension'); + + $file_details = [ + 'path' => $plugin->folder_path . '/src/Extension/' . $plugin->class_file_name . '.php', + 'name' => $plugin->class_file_name . '.php', + 'zip' => 'src/Extension/' . $plugin->class_file_name . '.php' + ]; + + $this->file->write( + $file_details['path'], + 'NamespacePrefix}\\Plugin\\{$plugin->group_namespace}\\{$plugin->namespace}\\Extension;" . + PHP_EOL . PHP_EOL . Placefix::_h('EXTENSION_CLASS_HEADER') . + PHP_EOL . PHP_EOL . '// No direct access to this file' . PHP_EOL . + "defined('_JEXEC') or die('Restricted access');" . + PHP_EOL . PHP_EOL . + Placefix::_h('EXTENSION_CLASS') + ); + + $this->files->appendArray($plugin->key, $file_details); + + // count the file created + $this->counter->file++; + } + + /** + * set the service provider path + * + * @param object $plugin The plugin object + * + * @return void + * @since 3.2.0 + */ + protected function setServiceProviderClassFile(object $plugin): void + { + // create services folder + $this->folder->create($plugin->folder_path . '/services'); + + $file_details = [ + 'path' => $plugin->folder_path . '/services/provider.php', + 'name' => 'provider.php', + 'zip' => 'services/provider.php' + ]; + + $this->file->write( + $file_details['path'], + 'files->appendArray($plugin->key, $file_details); + + // count the file created + $this->counter->file++; + } + + /** + * set the main xml file + * + * @param object $plugin The plugin object + * + * @return void + * @since 3.2.0 + */ + protected function setMainXmlFile(object $plugin): void + { + $file_details = [ + 'path' => $plugin->folder_path . '/' . $plugin->file_name . '.xml', + 'name' => $plugin->file_name . '.xml', + 'zip' => $plugin->file_name . '.xml' + ]; + + $this->file->write( + $file_details['path'], + $this->getXML($plugin) + ); + + $this->files->appendArray($plugin->key, $file_details); + + // count the file created + $this->counter->file++; + } + + /** + * set the install script file + * + * @param object $plugin The plugin object + * + * @return void + * @since 3.2.0 + */ + protected function setInstallScript(object $plugin): void + { + if ($plugin->add_install_script) + { + $file_details = [ + 'path' => $plugin->folder_path . '/script.php', + 'name' => 'script.php', + 'zip' => 'script.php' + ]; + + $this->file->write( + $file_details['path'], + 'files->appendArray($plugin->key, $file_details); + + // count the file created + $this->counter->file++; + } + } + + /** + * set the readme file + * + * @param object $plugin The plugin object + * + * @return void + * @since 3.2.0 + */ + protected function setReadme(object $plugin): void + { + if ($plugin->addreadme) + { + $file_details = [ + 'path' => $plugin->folder_path . '/README.md', + 'name' => 'README.md', + 'zip' => 'README.md' + ]; + + $this->file->write($file_details['path'], $plugin->readme); + $this->files->appendArray($plugin->key, $file_details); + + // count the file created + $this->counter->file++; + } + } + + /** + * set the form files and folders + * + * @param object $plugin The plugin object + * + * @return void + * @since 3.2.0 + */ + protected function setForms(object $plugin): void + { + if (isset($plugin->form_files) + && ArrayHelper::check($plugin->form_files)) + { + $Group = ucfirst((string) $plugin->group); + $FileName = $plugin->file_name; + + // create forms folder + $this->folder->create($plugin->folder_path . '/forms'); + + // set the template files + foreach ($plugin->form_files as $file => $fields) + { + // set file details + $file_details = [ + 'path' => $plugin->folder_path . '/forms/' . $file . '.xml', + 'name' => $file . '.xml', + 'zip' => 'forms/' . $file . '.xml' + ]; + + // build basic XML + $xml = ''; + $xml .= PHP_EOL . ''; + + // search if we must add the component path + $add_component_path = false; + foreach ($fields as $field_name => $fieldsets) + { + if (!$add_component_path) + { + foreach ($fieldsets as $fieldset => $field) + { + if (!$add_component_path + && isset($plugin->fieldsets_paths[$file . $field_name . $fieldset]) + && $plugin->fieldsets_paths[$file. $field_name . $fieldset] == 1) + { + $add_component_path = true; + } + } + } + } + + // only add if part of the component field types path is required + if ($add_component_path) + { + $xml .= PHP_EOL . ''; + } + else + { + $xml .= PHP_EOL . '
'; + } + + // add the fields + foreach ($fields as $field_name => $fieldsets) + { + // check if we have an double fields naming set + $field_name_inner = ''; + $field_name_outer = $field_name; + if (strpos((string)$field_name, '.') !== false) + { + $field_names = explode('.', (string)$field_name); + if (count((array)$field_names) == 2) + { + $field_name_outer = $field_names[0]; + $field_name_inner = $field_names[1]; + } + } + $xml .= PHP_EOL . Indent::_(1) + . ''; + foreach ($fieldsets as $fieldset => $field) + { + // default to the field set name + $label = $fieldset; + if (isset($plugin->fieldsets_label[$file . $field_name . $fieldset])) + { + $label = $plugin->fieldsets_label[$file . $field_name . $fieldset]; + } + + // add path to plugin rules and custom fields + if (isset($plugin->fieldsets_paths[$file . $field_name . $fieldset]) + && ($plugin->fieldsets_paths[$file . $field_name . $fieldset] == 2 + || $plugin->fieldsets_paths[$file . $field_name . $fieldset] == 3)) + { + if (!isset($plugin->add_rule_path[$file . $field_name . $fieldset])) + { + $plugin->add_rule_path[$file . $field_name . $fieldset] = + "{$this->NamespacePrefix}\\Plugin\\{$Group}\\{$FileName}\\Rule"; + } + + if (!isset($plugin->add_field_path[$file . $field_name . $fieldset])) + { + $plugin->add_field_path[$file . $field_name . $fieldset] = + "{$this->NamespacePrefix}\\Plugin\\{$Group}\\{$FileName}\\Field"; + } + } + + // add path to plugin rules and custom fields + if (isset($plugin->add_rule_path[$file . $field_name . $fieldset]) + || isset($plugin->add_field_path[$file . $field_name . $fieldset])) + { + $xml .= PHP_EOL . Indent::_(1) . ''; + + $xml .= PHP_EOL . Indent::_(1) . '
add_rule_path[$file . $field_name . $fieldset])) + { + $xml .= PHP_EOL . Indent::_(2) + . 'addrulepath="' . $plugin->add_rule_path[$file . $field_name . $fieldset] . '"'; + } + + if (isset($plugin->add_field_path[$file . $field_name . $fieldset])) + { + $xml .= PHP_EOL . Indent::_(2) + . 'addfieldpath="' . $plugin->add_field_path[$file . $field_name . $fieldset] . '"'; + } + + $xml .= PHP_EOL . Indent::_(1) . '>'; + } + else + { + $xml .= PHP_EOL . Indent::_(1) . '
'; + } + + // check if we have an inner field set + if (StringHelper::check($field_name_inner)) + { + $xml .= PHP_EOL . Indent::_(1) + . ''; + } + + // add the placeholder of the fields + $xml .= Placefix::_h('FIELDSET_' . $file + . $field_name . $fieldset); + + // check if we have an inner field set + if (StringHelper::check($field_name_inner)) + { + $xml .= PHP_EOL . Indent::_(1) + . ''; + } + $xml .= PHP_EOL . Indent::_(1) + . '
'; + } + $xml .= PHP_EOL . Indent::_(1) . ''; + } + $xml .= PHP_EOL . ''; + + // add xml to file + $this->file->write($file_details['path'], $xml); + $this->files->appendArray($plugin->key, $file_details); + + // count the file created + $this->counter->file++; + } + } + } + + /** + * set the sql stuff + * + * @param object $plugin The plugin object + * + * @return void + * @since 3.2.0 + */ + protected function setSQL(object $plugin): void + { + if ($plugin->add_sql || $plugin->add_sql_uninstall) + { + // create SQL folder + $this->folder->create($plugin->folder_path . '/sql'); + + // create mysql folder + $this->folder->create( + $plugin->folder_path . '/sql/mysql' + ); + + // now set the install file + if ($plugin->add_sql) + { + $this->file->write( + $plugin->folder_path . '/sql/mysql/install.sql', + $plugin->sql + ); + + // count the file created + $this->counter->file++; + } + + // now set the uninstall file + if ($plugin->add_sql_uninstall) + { + $this->file->write( + $plugin->folder_path + . '/sql/mysql/uninstall.sql', + $plugin->sql_uninstall + ); + + // count the file created + $this->counter->file++; + } + } + } + + /** + * set the files + * + * @param object $plugin The plugin object + * + * @return void + * @since 3.2.0 + */ + protected function setFiles(object $plugin): void + { + if (isset($plugin->files) && ArrayHelper::check($plugin->files)) + { + // add to component files + foreach ($plugin->files as $file) + { + // set the path finder + $file['target_type'] = $plugin->target_type; + $file['target_id'] = $plugin->id; + + $this->component->appendArray('files', $file); + } + } + } + + /** + * set the folders + * + * @param object $plugin The plugin object + * + * @return void + * @since 3.2.0 + */ + protected function setFolders(object $plugin): void + { + if (isset($plugin->folders) && ArrayHelper::check($plugin->folders)) + { + // add to component folders + foreach ($plugin->folders as $folder) + { + // set the path finder + $folder['target_type'] = $plugin->target_type; + $folder['target_id'] = $plugin->id; + + $this->component->appendArray('folders', $folder); + } + } + } + + /** + * set the urls + * + * @param object $plugin The plugin object + * + * @return void + * @since 3.2.0 + */ + protected function setUrls(object &$plugin): void + { + if (isset($plugin->urls) && ArrayHelper::check($plugin->urls)) + { + // add to component urls + foreach ($plugin->urls as &$url) + { + // should we add the local folder + if (isset($url['type']) && $url['type'] > 1 + && isset($url['url']) + && StringHelper::check($url['url'])) + { + // set file name + $fileName = basename((string)$url['url']); + + // get the file contents + $data = FileHelper::getContent( + $url['url'] + ); + + // build sub path + if (strpos($fileName, '.js') !== false) + { + $path = '/js'; + } + elseif (strpos($fileName, '.css') !== false) + { + $path = '/css'; + } + else + { + $path = ''; + } + + // create sub media folder path if not set + $this->folder->create( + $plugin->folder_path . $path + ); + + // set the path to plugin file + $url['path'] = $plugin->folder_path . $path + . '/' . $fileName; // we need this for later + + // write data to path + $this->file->write($url['path'], $data); + + // count the file created + $this->counter->file++; + } + } + } + } +} + diff --git a/src/34daa4c8-45c3-4249-baa3-1bedf8ed3ebc/code.power b/src/34daa4c8-45c3-4249-baa3-1bedf8ed3ebc/code.power new file mode 100644 index 0000000..f72bd3a --- /dev/null +++ b/src/34daa4c8-45c3-4249-baa3-1bedf8ed3ebc/code.power @@ -0,0 +1,786 @@ + /** + * The Data Class. + * + * @var Plugin + * @since 3.2.0 + */ + protected Plugin $plugin; + + /** + * The Component Class. + * + * @var Component + * @since 3.2.0 + */ + protected Component $component; + + /** + * The Config Class. + * + * @var Config + * @since 3.2.0 + */ + protected Config $config; + + /** + * The Registry Class. + * + * @var Registry + * @since 3.2.0 + */ + protected Registry $registry; + + /** + * The Dispenser Class. + * + * @var Dispenser + * @since 3.2.0 + */ + protected Dispenser $dispenser; + + /** + * The EventInterface Class. + * + * @var Event + * @since 3.2.0 + */ + protected Event $event; + + /** + * The Counter Class. + * + * @var Counter + * @since 3.2.0 + */ + protected Counter $counter; + + /** + * The Folder Class. + * + * @var Folder + * @since 3.2.0 + */ + protected Folder $folder; + + /** + * The File Class. + * + * @var File + * @since 3.2.0 + */ + protected File $file; + + /** + * The Files Class. + * + * @var Files + * @since 3.2.0 + */ + protected Files $files; + + /** + * The Placeholder Class. + * + * @var Placeholder + * @since 5.0.0 + */ + protected Placeholder $placeholder; + + /** + * The Namespace Prefix + * + * @var string + * @since 5.0.0 + */ + protected string $NamespacePrefix; + + /** + * The Component Namespace (in code) + * + * @var string + * @since 3.2.0 + */ + protected string $ComponentNamespace; + + /** + * Constructor. + * + * @param Plugin $plugin The Data Class. + * @param Component $component The Component Class. + * @param Config $config The Config Class. + * @param Registry $registry The Registry Class. + * @param Dispenser $dispenser The Dispenser Class. + * @param Event $event The EventInterface Class. + * @param Counter $counter The Counter Class. + * @param Folder $folder The Folder Class. + * @param File $file The File Class. + * @param Files $files The Files Class. + * @param Placeholder $placeholder The Placeholder Class. + * + * @since 3.2.0 + */ + public function __construct(Plugin $plugin, Component $component, Config $config, + Registry $registry, Dispenser $dispenser, Event $event, + Counter $counter, Folder $folder, File $file, + Files $files, Placeholder $placeholder) + { + $this->plugin = $plugin; + $this->component = $component; + $this->config = $config; + $this->registry = $registry; + $this->dispenser = $dispenser; + $this->event = $event; + $this->counter = $counter; + $this->folder = $folder; + $this->file = $file; + $this->files = $files; + $this->placeholder = $placeholder; + + // set some global values + $this->NamespacePrefix = $this->placeholder->get('NamespacePrefix'); + $this->ComponentNamespace = $this->placeholder->get('ComponentNamespace'); + } + + /** + * Build the Plugins files, folders, url's and config + * + * @return void + * @since 3.2.0 + */ + public function build() + { + if ($this->plugin->exists()) + { + // for plugin event TODO change event api signatures + $component_context = $this->config->component_context; + $plugins = $this->plugin->get(); + + // Trigger Event: jcb_ce_onBeforeSetPlugins + $this->event->trigger( + 'jcb_ce_onBeforeBuildPlugins', + array(&$component_context, &$plugins) + ); + + foreach ($plugins as $plugin) + { + if (ObjectHelper::check($plugin) + && isset($plugin->folder_name) + && StringHelper::check($plugin->folder_name)) + { + // plugin path + $this->pluginPath($plugin); + + // create src folder + $this->folder->create($plugin->folder_path . '/src'); + + // set the plugin paths + $this->registry->set('dynamic_paths.' . $plugin->key, $plugin->folder_path); + + // make sure there is no old build + $this->folder->remove($plugin->folder_path); + + // creat the main component folder + $this->folder->create($plugin->folder_path); + + // set main class file + $this->setMainClassFile($plugin); + + // set service provider class file + $this->setServiceProviderClassFile($plugin); + + // set main xml file + $this->setMainXmlFile($plugin); + + // set install script if needed + $this->setInstallScript($plugin); + + // set readme if found + $this->setReadme($plugin); + + // set fields & rules folders if needed + if (isset($plugin->fields_rules_paths) + && $plugin->fields_rules_paths == 2) + { + // create fields folder + $this->folder->create($plugin->folder_path . '/src/Field'); + + // create rules folder + $this->folder->create($plugin->folder_path . '/src/Rule'); + } + + // set forms folder if needed + $this->setForms($plugin); + + // set SQL stuff if needed + $this->setSQL($plugin); + + // create the language folder path + $this->folder->create($plugin->folder_path . '/language'); + + // also create the lang tag folder path + $this->folder->create( + $plugin->folder_path . '/language/' . $this->config->get('lang_tag', 'en-GB') + ); + + // check if this plugin has files + $this->setFiles($plugin); + + // check if this plugin has folders + $this->setFolders($plugin); + + // check if this plugin has urls + $this->setUrls($plugin); + } + } + } + } + + /** + * get the plugin xml template + * + * @param object $plugin The plugin object + * + * @return string + * @since 3.2.0 + */ + protected function getXML(object $plugin): string + { + $xml = ''; + $xml .= PHP_EOL . ''; + $xml .= PHP_EOL . Indent::_(1) . '' . $plugin->lang_prefix + . ''; + $xml .= PHP_EOL . Indent::_(1) . '' . Placefix::_h('BUILDDATE') . ''; + $xml .= PHP_EOL . Indent::_(1) . '' . Placefix::_h('AUTHOR') . ''; + $xml .= PHP_EOL . Indent::_(1) . '' . Placefix::_h('AUTHOREMAIL') . ''; + $xml .= PHP_EOL . Indent::_(1) . '' . Placefix::_h('AUTHORWEBSITE') . ''; + $xml .= PHP_EOL . Indent::_(1) . '' . Placefix::_h('COPYRIGHT') . ''; + $xml .= PHP_EOL . Indent::_(1) . '' . Placefix::_h('LICENSE') . ''; + $xml .= PHP_EOL . Indent::_(1) . '' . $plugin->plugin_version + . ''; + $xml .= PHP_EOL . Indent::_(1) . '' . "{$this->NamespacePrefix}\\Plugin\\{$plugin->group_namespace}\\{$plugin->namespace}" + . ''; + $xml .= PHP_EOL . Indent::_(1) . '' . $plugin->lang_prefix + . '_XML_DESCRIPTION'; + $xml .= Placefix::_h('MAINXML'); + $xml .= PHP_EOL . ''; + + return $xml; + } + + /** + * set the plugin path + * + * @param object $plugin The plugin object + * + * @return void + * @since 3.2.0 + */ + protected function pluginPath(object &$plugin): void + { + $plugin->folder_path = $this->config->get('compiler_path', JPATH_COMPONENT_ADMINISTRATOR . '/compiler') . '/' + . $plugin->folder_name; + } + + /** + * set the main class path + * + * @param object $plugin The plugin object + * + * @return void + * @since 3.2.0 + */ + protected function setMainClassFile(object $plugin): void + { + // create extension folder + $this->folder->create($plugin->folder_path . '/src/Extension'); + + $file_details = [ + 'path' => $plugin->folder_path . '/src/Extension/' . $plugin->class_file_name . '.php', + 'name' => $plugin->class_file_name . '.php', + 'zip' => 'src/Extension/' . $plugin->class_file_name . '.php' + ]; + + $this->file->write( + $file_details['path'], + 'NamespacePrefix}\\Plugin\\{$plugin->group_namespace}\\{$plugin->namespace}\\Extension;" . + PHP_EOL . PHP_EOL . Placefix::_h('EXTENSION_CLASS_HEADER') . + PHP_EOL . PHP_EOL . '// No direct access to this file' . PHP_EOL . + "defined('_JEXEC') or die('Restricted access');" . + PHP_EOL . PHP_EOL . + Placefix::_h('EXTENSION_CLASS') + ); + + $this->files->appendArray($plugin->key, $file_details); + + // count the file created + $this->counter->file++; + } + + /** + * set the service provider path + * + * @param object $plugin The plugin object + * + * @return void + * @since 3.2.0 + */ + protected function setServiceProviderClassFile(object $plugin): void + { + // create services folder + $this->folder->create($plugin->folder_path . '/services'); + + $file_details = [ + 'path' => $plugin->folder_path . '/services/provider.php', + 'name' => 'provider.php', + 'zip' => 'services/provider.php' + ]; + + $this->file->write( + $file_details['path'], + 'files->appendArray($plugin->key, $file_details); + + // count the file created + $this->counter->file++; + } + + /** + * set the main xml file + * + * @param object $plugin The plugin object + * + * @return void + * @since 3.2.0 + */ + protected function setMainXmlFile(object $plugin): void + { + $file_details = [ + 'path' => $plugin->folder_path . '/' . $plugin->file_name . '.xml', + 'name' => $plugin->file_name . '.xml', + 'zip' => $plugin->file_name . '.xml' + ]; + + $this->file->write( + $file_details['path'], + $this->getXML($plugin) + ); + + $this->files->appendArray($plugin->key, $file_details); + + // count the file created + $this->counter->file++; + } + + /** + * set the install script file + * + * @param object $plugin The plugin object + * + * @return void + * @since 3.2.0 + */ + protected function setInstallScript(object $plugin): void + { + if ($plugin->add_install_script) + { + $file_details = [ + 'path' => $plugin->folder_path . '/script.php', + 'name' => 'script.php', + 'zip' => 'script.php' + ]; + + $this->file->write( + $file_details['path'], + 'files->appendArray($plugin->key, $file_details); + + // count the file created + $this->counter->file++; + } + } + + /** + * set the readme file + * + * @param object $plugin The plugin object + * + * @return void + * @since 3.2.0 + */ + protected function setReadme(object $plugin): void + { + if ($plugin->addreadme) + { + $file_details = [ + 'path' => $plugin->folder_path . '/README.md', + 'name' => 'README.md', + 'zip' => 'README.md' + ]; + + $this->file->write($file_details['path'], $plugin->readme); + $this->files->appendArray($plugin->key, $file_details); + + // count the file created + $this->counter->file++; + } + } + + /** + * set the form files and folders + * + * @param object $plugin The plugin object + * + * @return void + * @since 3.2.0 + */ + protected function setForms(object $plugin): void + { + if (isset($plugin->form_files) + && ArrayHelper::check($plugin->form_files)) + { + $Group = ucfirst((string) $plugin->group); + $FileName = $plugin->file_name; + + // create forms folder + $this->folder->create($plugin->folder_path . '/forms'); + + // set the template files + foreach ($plugin->form_files as $file => $fields) + { + // set file details + $file_details = [ + 'path' => $plugin->folder_path . '/forms/' . $file . '.xml', + 'name' => $file . '.xml', + 'zip' => 'forms/' . $file . '.xml' + ]; + + // build basic XML + $xml = ''; + $xml .= PHP_EOL . ''; + + // search if we must add the component path + $add_component_path = false; + foreach ($fields as $field_name => $fieldsets) + { + if (!$add_component_path) + { + foreach ($fieldsets as $fieldset => $field) + { + if (!$add_component_path + && isset($plugin->fieldsets_paths[$file . $field_name . $fieldset]) + && $plugin->fieldsets_paths[$file. $field_name . $fieldset] == 1) + { + $add_component_path = true; + } + } + } + } + + // only add if part of the component field types path is required + if ($add_component_path) + { + $xml .= PHP_EOL . ''; + } + else + { + $xml .= PHP_EOL . '
'; + } + + // add the fields + foreach ($fields as $field_name => $fieldsets) + { + // check if we have an double fields naming set + $field_name_inner = ''; + $field_name_outer = $field_name; + if (strpos((string)$field_name, '.') !== false) + { + $field_names = explode('.', (string)$field_name); + if (count((array)$field_names) == 2) + { + $field_name_outer = $field_names[0]; + $field_name_inner = $field_names[1]; + } + } + $xml .= PHP_EOL . Indent::_(1) + . ''; + foreach ($fieldsets as $fieldset => $field) + { + // default to the field set name + $label = $fieldset; + if (isset($plugin->fieldsets_label[$file . $field_name . $fieldset])) + { + $label = $plugin->fieldsets_label[$file . $field_name . $fieldset]; + } + + // add path to plugin rules and custom fields + if (isset($plugin->fieldsets_paths[$file . $field_name . $fieldset]) + && ($plugin->fieldsets_paths[$file . $field_name . $fieldset] == 2 + || $plugin->fieldsets_paths[$file . $field_name . $fieldset] == 3)) + { + if (!isset($plugin->add_rule_path[$file . $field_name . $fieldset])) + { + $plugin->add_rule_path[$file . $field_name . $fieldset] = + "{$this->NamespacePrefix}\\Plugin\\{$Group}\\{$FileName}\\Rule"; + } + + if (!isset($plugin->add_field_path[$file . $field_name . $fieldset])) + { + $plugin->add_field_path[$file . $field_name . $fieldset] = + "{$this->NamespacePrefix}\\Plugin\\{$Group}\\{$FileName}\\Field"; + } + } + + // add path to plugin rules and custom fields + if (isset($plugin->add_rule_path[$file . $field_name . $fieldset]) + || isset($plugin->add_field_path[$file . $field_name . $fieldset])) + { + $xml .= PHP_EOL . Indent::_(1) . ''; + + $xml .= PHP_EOL . Indent::_(1) . '
add_rule_path[$file . $field_name . $fieldset])) + { + $xml .= PHP_EOL . Indent::_(2) + . 'addrulepath="' . $plugin->add_rule_path[$file . $field_name . $fieldset] . '"'; + } + + if (isset($plugin->add_field_path[$file . $field_name . $fieldset])) + { + $xml .= PHP_EOL . Indent::_(2) + . 'addfieldpath="' . $plugin->add_field_path[$file . $field_name . $fieldset] . '"'; + } + + $xml .= PHP_EOL . Indent::_(1) . '>'; + } + else + { + $xml .= PHP_EOL . Indent::_(1) . '
'; + } + + // check if we have an inner field set + if (StringHelper::check($field_name_inner)) + { + $xml .= PHP_EOL . Indent::_(1) + . ''; + } + + // add the placeholder of the fields + $xml .= Placefix::_h('FIELDSET_' . $file + . $field_name . $fieldset); + + // check if we have an inner field set + if (StringHelper::check($field_name_inner)) + { + $xml .= PHP_EOL . Indent::_(1) + . ''; + } + $xml .= PHP_EOL . Indent::_(1) + . '
'; + } + $xml .= PHP_EOL . Indent::_(1) . ''; + } + $xml .= PHP_EOL . ''; + + // add xml to file + $this->file->write($file_details['path'], $xml); + $this->files->appendArray($plugin->key, $file_details); + + // count the file created + $this->counter->file++; + } + } + } + + /** + * set the sql stuff + * + * @param object $plugin The plugin object + * + * @return void + * @since 3.2.0 + */ + protected function setSQL(object $plugin): void + { + if ($plugin->add_sql || $plugin->add_sql_uninstall) + { + // create SQL folder + $this->folder->create($plugin->folder_path . '/sql'); + + // create mysql folder + $this->folder->create( + $plugin->folder_path . '/sql/mysql' + ); + + // now set the install file + if ($plugin->add_sql) + { + $this->file->write( + $plugin->folder_path . '/sql/mysql/install.sql', + $plugin->sql + ); + + // count the file created + $this->counter->file++; + } + + // now set the uninstall file + if ($plugin->add_sql_uninstall) + { + $this->file->write( + $plugin->folder_path + . '/sql/mysql/uninstall.sql', + $plugin->sql_uninstall + ); + + // count the file created + $this->counter->file++; + } + } + } + + /** + * set the files + * + * @param object $plugin The plugin object + * + * @return void + * @since 3.2.0 + */ + protected function setFiles(object $plugin): void + { + if (isset($plugin->files) && ArrayHelper::check($plugin->files)) + { + // add to component files + foreach ($plugin->files as $file) + { + // set the path finder + $file['target_type'] = $plugin->target_type; + $file['target_id'] = $plugin->id; + + $this->component->appendArray('files', $file); + } + } + } + + /** + * set the folders + * + * @param object $plugin The plugin object + * + * @return void + * @since 3.2.0 + */ + protected function setFolders(object $plugin): void + { + if (isset($plugin->folders) && ArrayHelper::check($plugin->folders)) + { + // add to component folders + foreach ($plugin->folders as $folder) + { + // set the path finder + $folder['target_type'] = $plugin->target_type; + $folder['target_id'] = $plugin->id; + + $this->component->appendArray('folders', $folder); + } + } + } + + /** + * set the urls + * + * @param object $plugin The plugin object + * + * @return void + * @since 3.2.0 + */ + protected function setUrls(object &$plugin): void + { + if (isset($plugin->urls) && ArrayHelper::check($plugin->urls)) + { + // add to component urls + foreach ($plugin->urls as &$url) + { + // should we add the local folder + if (isset($url['type']) && $url['type'] > 1 + && isset($url['url']) + && StringHelper::check($url['url'])) + { + // set file name + $fileName = basename((string)$url['url']); + + // get the file contents + $data = FileHelper::getContent( + $url['url'] + ); + + // build sub path + if (strpos($fileName, '.js') !== false) + { + $path = '/js'; + } + elseif (strpos($fileName, '.css') !== false) + { + $path = '/css'; + } + else + { + $path = ''; + } + + // create sub media folder path if not set + $this->folder->create( + $plugin->folder_path . $path + ); + + // set the path to plugin file + $url['path'] = $plugin->folder_path . $path + . '/' . $fileName; // we need this for later + + // write data to path + $this->file->write($url['path'], $data); + + // count the file created + $this->counter->file++; + } + } + } + } \ No newline at end of file diff --git a/src/34daa4c8-45c3-4249-baa3-1bedf8ed3ebc/settings.json b/src/34daa4c8-45c3-4249-baa3-1bedf8ed3ebc/settings.json new file mode 100644 index 0000000..282e4e6 --- /dev/null +++ b/src/34daa4c8-45c3-4249-baa3-1bedf8ed3ebc/settings.json @@ -0,0 +1,94 @@ +{ + "add_head": "0", + "add_licensing_template": "2", + "extends": "", + "guid": "34daa4c8-45c3-4249-baa3-1bedf8ed3ebc", + "implements": [ + "ef66b17c-ffae-414a-9067-20a63ba2bec5" + ], + "load_selection": null, + "name": "Structure", + "power_version": "1.0.0", + "system_name": "JCB.Compiler.Joomlaplugin.J4.Structure", + "type": "class", + "use_selection": { + "use_selection0": { + "use": "8cc85656-a925-4a46-a49b-83c72167fd6a", + "as": "Plugin" + }, + "use_selection1": { + "use": "e2472b22-a329-44d8-b4a2-ae3ba99e17a0", + "as": "default" + }, + "use_selection2": { + "use": "fa4bf18e-301e-42e3-91fb-6e0096c07adc", + "as": "default" + }, + "use_selection3": { + "use": "e5d9804f-0eb0-4ee9-b406-ad4e8cdbc1f6", + "as": "default" + }, + "use_selection4": { + "use": "f1dc6430-fb54-452e-aa53-ce32ae93db88", + "as": "default" + }, + "use_selection5": { + "use": "20ed72b0-fcac-4344-aee1-8a65e3bf221d", + "as": "Event" + }, + "use_selection6": { + "use": "e6d871a6-bbe7-497d-af01-68f6bb9a87f4", + "as": "default" + }, + "use_selection7": { + "use": "6bbb6ffe-3f09-4c21-aa9d-c93159afa1e1", + "as": "default" + }, + "use_selection8": { + "use": "5c75b455-3d4c-452a-867e-e90424a64c88", + "as": "default" + }, + "use_selection9": { + "use": "1d967151-7c20-4ca7-9400-65233cdcd4db", + "as": "default" + }, + "use_selection10": { + "use": "06453ada-e370-49f0-b262-e3f5a8ed0c2c", + "as": "default" + }, + "use_selection11": { + "use": "a68c010b-e92e-47d5-8a44-d23cfddeb6c6", + "as": "default" + }, + "use_selection12": { + "use": "500f3a7f-c16d-4dd4-81b2-2df6776b5388", + "as": "default" + }, + "use_selection13": { + "use": "4e6ff11d-bebf-42f5-8fd7-b2f882857222", + "as": "default" + }, + "use_selection14": { + "use": "0a59c65c-9daf-4bc9-baf4-e063ff9e6a8a", + "as": "default" + }, + "use_selection15": { + "use": "91004529-94a9-4590-b842-e7c6b624ecf5", + "as": "default" + }, + "use_selection16": { + "use": "1f28cb53-60d9-4db1-b517-3c7dc6b429ef", + "as": "default" + }, + "use_selection17": { + "use": "a223b31e-ea1d-4cdf-92ae-5f9becffaff0", + "as": "default" + } + }, + "extendsinterfaces": null, + "namespace": "[[[NamespacePrefix]]]\\Joomla\\[[[ComponentNamespace]]].Compiler.Joomlaplugin.JoomlaFour.Structure", + "description": "Joomla 4 Plugin Builder Class\r\n\r\n@since 5.0.2", + "licensing_template": "\/**\r\n * @package Joomla.Component.Builder\r\n *\r\n * @created 4th September, 2022\r\n * @author Llewellyn van der Merwe \r\n * @git Joomla Component Builder \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/361e08c0-5916-4b77-b6a2-c16a769bbc40/README.md b/src/361e08c0-5916-4b77-b6a2-c16a769bbc40/README.md new file mode 100644 index 0000000..ab67b20 --- /dev/null +++ b/src/361e08c0-5916-4b77-b6a2-c16a769bbc40/README.md @@ -0,0 +1,95 @@ +``` +██████╗ ██████╗ ██╗ ██╗███████╗██████╗ +██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗ +██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝ +██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗ +██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║ +╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝ +``` +# final class Data (Details) +> namespace: **VDM\Joomla\Componentbuilder\Compiler\Joomlaplugin\JoomlaFour** + +```uml +@startuml +class Data << (F,LightGreen) >> #RoyalBlue { + # array $data + # Config $config + # Customcode $customcode + # Gui $gui + # Placeholder $placeholder + # Language $language + # Field $field + # FieldName $fieldname + # Filesfolders $filesfolders + # $db + + __construct(Config $config, Customcode $customcode, ...) + + get(int $id = null) : object|array|null + + exists(int $id = null) : bool + + set(int $id) : bool +} + +note right of Data::__construct + Constructor. + + since: 5.0.2 + + arguments: + Config $config + Customcode $customcode + Gui $gui + Placeholder $placeholder + Language $language + Field $field + FieldName $fieldname + Filesfolders $filesfolders +end note + +note right of Data::get + Get the Joomla Plugin/s + + since: 3.2.0 + return: object|array|null +end note + +note right of Data::exists + Check if the Joomla Plugin/s exists + + since: 3.2.0 + return: bool +end note + +note right of Data::set + Set the Joomla Plugin + + since: 3.2.0 + return: bool +end note + +@enduml +``` + +The Power feature in JCB allows you to write PHP classes and their implementations, making it easy to include them in your Joomla project. JCB handles linking, autoloading, namespacing, and folder structure creation for you. + +By using the SPK (Super Power Key) in your custom code (replacing the class name in your code with the SPK), JCB will automatically pull the power from the repository into your project. This makes it available in your JCB instance, allowing you to edit it and include the class in your generated Joomla component. + +JCB uses placeholders like [[[`NamespacePrefix`]]] and [[[`ComponentNamespace`]]] in namespacing to prevent collisions and improve reusability across different JCB systems. You can also set the **JCB powers path** globally or per component under the **Dynamic Integration** tab, providing flexibility and easy maintainability. + +To add this specific Power to your project in JCB: + +> simply use this SPK +``` +Super---361e08c0_5916_4b77_b6a2_c16a769bbc40---Power +``` +> remember to replace the `---` with `___` to activate this Power in your code + +--- +``` + ██╗ ██████╗██████╗ + ██║██╔════╝██╔══██╗ + ██║██║ ██████╔╝ +██ ██║██║ ██╔══██╗ +╚█████╔╝╚██████╗██████╔╝ + ╚════╝ ╚═════╝╚═════╝ +``` +> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder) + diff --git a/src/361e08c0-5916-4b77-b6a2-c16a769bbc40/code.php b/src/361e08c0-5916-4b77-b6a2-c16a769bbc40/code.php new file mode 100644 index 0000000..8f65953 --- /dev/null +++ b/src/361e08c0-5916-4b77-b6a2-c16a769bbc40/code.php @@ -0,0 +1,934 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Componentbuilder\Compiler\Joomlaplugin\JoomlaFour; + + +use Joomla\CMS\Factory; +use Joomla\CMS\Filter\OutputFilter; +use VDM\Joomla\Componentbuilder\Compiler\Config; +use VDM\Joomla\Componentbuilder\Compiler\Customcode; +use VDM\Joomla\Componentbuilder\Compiler\Customcode\Gui; +use VDM\Joomla\Componentbuilder\Compiler\Placeholder; +use VDM\Joomla\Componentbuilder\Compiler\Language; +use VDM\Joomla\Componentbuilder\Compiler\Field; +use VDM\Joomla\Componentbuilder\Compiler\Field\Name as FieldName; +use VDM\Joomla\Componentbuilder\Compiler\Model\Filesfolders; +use VDM\Joomla\Utilities\ArrayHelper; +use VDM\Joomla\Utilities\String\ClassfunctionHelper; +use VDM\Joomla\Utilities\String\PluginHelper; +use VDM\Joomla\Utilities\JsonHelper; +use VDM\Joomla\Utilities\StringHelper; +use VDM\Joomla\Utilities\GetHelper; +use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent; +use VDM\Joomla\Componentbuilder\Compiler\Interfaces\PluginDataInterface; + + +/** + * Joomla 4 Plug-in Data Class + * + * @since 5.0.2 + */ +final class Data implements PluginDataInterface +{ + /** + * Compiler Joomla Plug-in's Data + * + * @var array + * @since 3.2.0 + */ + protected array $data = []; + + /** + * The Configure Class. + * + * @var Config + * @since 5.0.2 + */ + protected Config $config; + + /** + * The Customcode Class. + * + * @var Customcode + * @since 5.0.2 + */ + protected Customcode $customcode; + + /** + * The Gui Class. + * + * @var Gui + * @since 5.0.2 + */ + protected Gui $gui; + + /** + * The Placeholder Class. + * + * @var Placeholder + * @since 5.0.2 + */ + protected Placeholder $placeholder; + + /** + * The Language Class. + * + * @var Language + * @since 5.0.2 + */ + protected Language $language; + + /** + * The Field Class. + * + * @var Field + * @since 5.0.2 + */ + protected Field $field; + + /** + * The Name Class. + * + * @var FieldName + * @since 5.0.2 + */ + protected FieldName $fieldname; + + /** + * The Filesfolders Class. + * + * @var Filesfolders + * @since 5.0.2 + */ + protected Filesfolders $filesfolders; + + /** + * Database object to query local DB + * + * @since 3.2.0 + **/ + protected $db; + + /** + * Define the mappings of traits and classes to their respective methods and services + * + * @var array + * @since 5.0.2 + **/ + protected array $service_checks = [ + 'DatabaseAwareTrait' => [ + 'trait' => 'Joomla\Database\DatabaseAwareTrait', + 'class' => 'Joomla__'.'_ae15e6b6_f7de_43ad_be4b_71499ae88f45___Power', + 'method' => 'setDatabase', + 'service' => 'Joomla__'.'_7bd29d76_73c9_4c07_a5da_4f7a32aff78f___Power' + ], + 'UserFactoryAwareTrait' => [ + 'trait' => 'Joomla\CMS\User\UserFactoryAwareTrait', + 'class' => 'Joomla__'.'_a6b2c321_5de3_4425_b05f_e5340965fb80___Power', + 'method' => 'setUserFactory', + 'service' => 'Joomla__'.'_c2980d12_c3ef_4e23_b4a2_e6af1f5900a9___Power' + ] + ]; + + /** + * Constructor. + * + * @param Config $config The Config Class. + * @param Customcode $customcode The Customcode Class. + * @param Gui $gui The Gui Class. + * @param Placeholder $placeholder The Placeholder Class. + * @param Language $language The Language Class. + * @param Field $field The Field Class. + * @param FieldName $fieldname The Name Class. + * @param Filesfolders $filesfolders The Filesfolders Class. + * + * @since 5.0.2 + */ + public function __construct(Config $config, Customcode $customcode, Gui $gui, + Placeholder $placeholder, Language $language, + Field $field, FieldName $fieldname, + Filesfolders $filesfolders) + { + $this->config = $config; + $this->customcode = $customcode; + $this->gui = $gui; + $this->placeholder = $placeholder; + $this->language = $language; + $this->field = $field; + $this->fieldname = $fieldname; + $this->filesfolders = $filesfolders; + $this->db = Factory::getDbo(); + } + + /** + * Get the Joomla Plugin/s + * + * @param int|null $id the plugin id + * + * @return object|array|null if ID found it returns object, if no ID given it returns all set + * @since 3.2.0 + */ + public function get(int $id = null) + { + if (is_null($id) && $this->exists()) + { + return $this->data; + } + elseif ($this->exists($id)) + { + return $this->data[$id]; + } + + return null; + } + + /** + * Check if the Joomla Plugin/s exists + * + * @param int|null $id the plugin id + * + * @return bool if ID found it returns true, if no ID given it returns true if any are set + * @since 3.2.0 + */ + public function exists(int $id = null): bool + { + if (is_null($id)) + { + return ArrayHelper::check($this->data); + } + elseif (isset($this->data[$id])) + { + return true; + } + + return $this->set($id); + } + + /** + * Set the Joomla Plugin + * + * @param int $id the plugin id + * + * @return bool true on success + * @since 3.2.0 + */ + public function set(int $id): bool + { + if (isset($this->data[$id])) + { + return true; + } + else + { + // Create a new query object. + $query = $this->db->getQuery(true); + + $query->select('a.*'); + $query->select( + $this->db->quoteName( + array( + 'g.name', + 'e.name', + 'e.head', + 'e.comment', + 'e.id', + 'f.addfiles', + 'f.addfolders', + 'f.addfilesfullpath', + 'f.addfoldersfullpath', + 'f.addurls', + 'u.version_update', + 'u.id' + ), array( + 'group', + 'extends', + 'class_head', + 'comment', + 'class_id', + 'addfiles', + 'addfolders', + 'addfilesfullpath', + 'addfoldersfullpath', + 'addurls', + 'version_update', + 'version_update_id' + ) + ) + ); + // from these tables + $query->from('#__componentbuilder_joomla_plugin AS a'); + $query->join( + 'LEFT', $this->db->quoteName( + '#__componentbuilder_joomla_plugin_group', 'g' + ) . ' ON (' . $this->db->quoteName('a.joomla_plugin_group') + . ' = ' . $this->db->quoteName('g.id') . ')' + ); + $query->join( + 'LEFT', + $this->db->quoteName('#__componentbuilder_class_extends', 'e') + . ' ON (' . $this->db->quoteName('a.class_extends') . ' = ' + . $this->db->quoteName('e.id') . ')' + ); + $query->join( + 'LEFT', $this->db->quoteName( + '#__componentbuilder_joomla_plugin_updates', 'u' + ) . ' ON (' . $this->db->quoteName('a.id') . ' = ' + . $this->db->quoteName('u.joomla_plugin') . ')' + ); + $query->join( + 'LEFT', $this->db->quoteName( + '#__componentbuilder_joomla_plugin_files_folders_urls', 'f' + ) . ' ON (' . $this->db->quoteName('a.id') . ' = ' + . $this->db->quoteName('f.joomla_plugin') . ')' + ); + $query->where($this->db->quoteName('a.id') . ' = ' . (int) $id); + $query->where($this->db->quoteName('a.published') . ' >= 1'); + $this->db->setQuery($query); + $this->db->execute(); + if ($this->db->getNumRows()) + { + // get the plugin data + $plugin = $this->db->loadObject(); + + // tweak system to set stuff to the plugin domain + $_backup_target = $this->config->build_target; + $_backup_lang = $this->config->lang_target; + $_backup_langPrefix = $this->config->lang_prefix; + + // set some keys + $plugin->target_type = 'pLuG!n'; + $plugin->key = $plugin->id . '_' . $plugin->target_type; + + // update to point to plugin + $this->config->build_target = $plugin->key; + $this->config->lang_target = $plugin->key; + + // set version if not set + if (empty($plugin->plugin_version)) + { + $plugin->plugin_version = '1.0.0'; + } + + // set GUI mapper + $guiMapper = array('table' => 'joomla_plugin', + 'id' => (int) $id, 'type' => 'php'); + + // update the name if it has dynamic values + $plugin->name = $this->placeholder->update_( + $this->customcode->update($plugin->name) + ); + + // update the name if it has dynamic values + $plugin->code_name + = ClassfunctionHelper::safe( + $plugin->name + ); + + // set official name + $plugin->official_name = ucwords( + $plugin->group . ' - ' . $plugin->name + ); + + // set lang prefix + $plugin->lang_prefix = PluginHelper::safeLangPrefix( + $plugin->code_name, + $plugin->group + ); + + // set langPrefix + $this->config->lang_prefix = $plugin->lang_prefix; + + // set plugin class name + $plugin->class_name = ucfirst( + $plugin->code_name + ); + // set plugin context name + $plugin->context_name = strtolower((string) + $plugin->code_name + ); + + // set plugin namespace + $plugin->namespace = $plugin->code_name; + + // set plugin group namespace + $plugin->group_namespace = ucfirst( + $plugin->group + ); + + // set plugin install class name + $plugin->installer_class_name + = PluginHelper::safeInstallClassName( + $plugin->code_name, + $plugin->group + ); + + // set plugin folder name + $plugin->folder_name + = PluginHelper::safeFolderName( + $plugin->code_name, + $plugin->group + ); + + // set the zip name + $plugin->zip_name = $plugin->folder_name . '_v' . str_replace( + '.', '_', (string) $plugin->plugin_version + ) . '__J' . $this->config->joomla_version; + + // set plugin file name + $plugin->file_name = $plugin->context_name; + $plugin->class_file_name = $plugin->code_name; + + // set plugin context + $plugin->context = $plugin->folder_name . '.' . $plugin->id; + + // set official_name lang strings + $this->language->set( + $plugin->key, $this->config->lang_prefix, $plugin->official_name + ); + + // set some placeholder for this plugin + $this->placeholder->set('Plugin_name', $plugin->official_name); + $this->placeholder->set('PLUGIN_NAME', $plugin->official_name); + $this->placeholder->set('Plugin', ucfirst((string) $plugin->code_name)); + $this->placeholder->set('plugin', strtolower((string) $plugin->code_name)); + $this->placeholder->set('Plugin_group', ucfirst((string) $plugin->group)); + $this->placeholder->set('plugin_group', strtolower((string) $plugin->group)); + $this->placeholder->set('plugin.version', $plugin->plugin_version); + $this->placeholder->set('VERSION', $plugin->plugin_version); + $this->placeholder->set('plugin_version', str_replace( + '.', '_', (string) $plugin->plugin_version + )); + + // set description + $this->placeholder->set('DESCRIPTION', ''); + if (!isset($plugin->description) + || !StringHelper::check( + $plugin->description + )) + { + $plugin->description = ''; + } + else + { + $plugin->description = $this->placeholder->update_( + $this->customcode->update($plugin->description) + ); + $this->language->set( + $plugin->key, $plugin->lang_prefix . '_DESCRIPTION', + $plugin->description + ); + // set description + $this->placeholder->set('DESCRIPTION', $plugin->description); + $plugin->description = '

' . $plugin->description . '

'; + } + + // get author name + $project_author = $this->config->project_author; + + // we can only set these if the component was passed + $plugin->xml_description = "

" . $plugin->official_name + . " (v." . $plugin->plugin_version + . ")

" + . $plugin->description . "

Created by " . trim( + (string) OutputFilter::cleanText($project_author) + ) . "
Development started " + . Factory::getDate($plugin->created)->format("jS F, Y") + . "

"; + + // set xml discription + $this->language->set( + $plugin->key, $plugin->lang_prefix . '_XML_DESCRIPTION', + $plugin->xml_description + ); + + // update the readme if set + if ($plugin->addreadme == 1 && !empty($plugin->readme)) + { + $plugin->readme = $this->placeholder->update_( + $this->customcode->update(base64_decode((string) $plugin->readme)) + ); + } + else + { + $plugin->addreadme = 0; + unset($plugin->readme); + } + + // open some base64 strings + if (!empty($plugin->main_class_code)) + { + // set GUI mapper field + $guiMapper['field'] = 'main_class_code'; + // base64 Decode main_class_code. + $plugin->main_class_code = $this->gui->set( + $this->placeholder->update_( + $this->customcode->update( + base64_decode((string) $plugin->main_class_code) + ) + ), + $guiMapper + ); + } + + // set the head :) + if ($plugin->add_head == 1 && !empty($plugin->head)) + { + // set GUI mapper field + $guiMapper['field'] = 'head'; + // base64 Decode head. + $plugin->header = $this->gui->set( + $this->placeholder->update_( + $this->customcode->update( + base64_decode((string) $plugin->head) + ) + ), + $guiMapper + ); + } + elseif (!empty($plugin->class_head)) + { + // base64 Decode head. + $plugin->header = $this->gui->set( + $this->placeholder->update_( + $this->customcode->update( + base64_decode((string) $plugin->class_head) + ) + ), + array( + 'table' => 'class_extends', + 'field' => 'head', + 'id' => (int) $plugin->class_id, + 'type' => 'php') + ); + } + unset($plugin->class_head); + + // Check the plugin's code and header for each trait + foreach ($this->service_checks as $key => $info) + { + if (strpos($plugin->main_class_code, $key) !== false || + strpos($plugin->main_class_code, $info['class']) !== false || + strpos($plugin->header, $info['trait']) !== false) + { + $service_provider[] = Indent::_(4) . "\$plugin->{$info['method']}(\$container->get({$info['service']}::class));"; + } + } + + // Assign service provider if any services were added + if (!empty($service_provider)) + { + $plugin->service_provider = implode(PHP_EOL, $service_provider); + } + + // set the comment + if (!empty($plugin->comment)) + { + // base64 Decode comment. + $plugin->comment = $this->gui->set( + $this->placeholder->update_( + $this->customcode->update( + base64_decode((string) $plugin->comment) + ) + ), + array( + 'table' => 'class_extends', + 'field' => 'comment', + 'id' => (int) $plugin->class_id, + 'type' => 'php') + ); + } + + // start the config array + $plugin->config_fields = []; + // create the form arrays + $plugin->form_files = []; + $plugin->fieldsets_label = []; + $plugin->fieldsets_paths = []; + $plugin->add_rule_path = []; + $plugin->add_field_path = []; + // set global fields rule to default component path + $plugin->fields_rules_paths = 1; + // set the fields data + $plugin->fields = (isset($plugin->fields) + && JsonHelper::check($plugin->fields)) + ? json_decode((string) $plugin->fields, true) : null; + if (ArrayHelper::check($plugin->fields)) + { + // ket global key + $key = $plugin->key; + $dynamic_fields = array('fieldset' => 'basic', + 'fields_name' => 'params', + 'file' => 'config'); + foreach ($plugin->fields as $n => &$form) + { + if (isset($form['fields']) + && ArrayHelper::check( + $form['fields'] + )) + { + // make sure the dynamic_field is set to dynamic_value by default + foreach ( + $dynamic_fields as $dynamic_field => + $dynamic_value + ) + { + if (!isset($form[$dynamic_field]) + || !StringHelper::check( + $form[$dynamic_field] + )) + { + $form[$dynamic_field] = $dynamic_value; + } + else + { + if ('fields_name' === $dynamic_field + && strpos((string) $form[$dynamic_field], '.') + !== false) + { + $form[$dynamic_field] + = $form[$dynamic_field]; + } + else + { + $form[$dynamic_field] + = StringHelper::safe( + $form[$dynamic_field] + ); + } + } + } + // check if field is external form file + if (!isset($form['plugin']) || $form['plugin'] != 1) + { + // now build the form key + $unique = $form['file'] . $form['fields_name'] + . $form['fieldset']; + } + else + { + // now build the form key + $unique = $form['fields_name'] + . $form['fieldset']; + } + // set global fields rule path switchs + if ($plugin->fields_rules_paths == 1 + && isset($form['fields_rules_paths']) + && $form['fields_rules_paths'] == 2) + { + $plugin->fields_rules_paths = 2; + } + // set where to path is pointing + $plugin->fieldsets_paths[$unique] + = $form['fields_rules_paths']; + // add the label if set to lang + if (isset($form['label']) + && StringHelper::check( + $form['label'] + )) + { + $plugin->fieldsets_label[$unique] + = $this->language->key($form['label']); + } + // check for extra rule paths + if (isset($form['addrulepath']) + && ArrayHelper::check($form['addrulepath'])) + { + foreach ($form['addrulepath'] as $add_rule_path) + { + if (StringHelper::check($add_rule_path['path'])) + { + $plugin->add_rule_path[$unique] = $add_rule_path['path']; + } + } + } + // check for extra field paths + if (isset($form['addfieldpath']) + && ArrayHelper::check($form['addfieldpath'])) + { + foreach ($form['addfieldpath'] as $add_field_path) + { + if (StringHelper::check($add_field_path['path'])) + { + $plugin->add_field_path[$unique] = $add_field_path['path']; + } + } + } + // build the fields + $form['fields'] = array_map( + function ($field) use ($key, $unique) { + // make sure the alias and title is 0 + $field['alias'] = 0; + $field['title'] = 0; + // set the field details + $this->field->set( + $field, $key, $key, $unique + ); + // update the default if set + if (StringHelper::check( + $field['custom_value'] + ) + && isset($field['settings'])) + { + if (($old_default + = GetHelper::between( + $field['settings']->xml, + 'default="', '"', false + )) !== false) + { + // replace old default + $field['settings']->xml + = str_replace( + 'default="' . $old_default + . '"', 'default="' + . $field['custom_value'] . '"', + (string) $field['settings']->xml + ); + } + else + { + // add the default (hmmm not ideal but okay it should work) + $field['settings']->xml + = 'default="' + . $field['custom_value'] . '" ' + . $field['settings']->xml; + } + } + unset($field['custom_value']); + + // return field + return $field; + }, array_values($form['fields']) + ); + // check if field is external form file + if (!isset($form['plugin']) || $form['plugin'] != 1) + { + // load the form file + if (!isset($plugin->form_files[$form['file']])) + { + $plugin->form_files[$form['file']] + = []; + } + if (!isset($plugin->form_files[$form['file']][$form['fields_name']])) + { + $plugin->form_files[$form['file']][$form['fields_name']] + = []; + } + if (!isset($plugin->form_files[$form['file']][$form['fields_name']][$form['fieldset']])) + { + $plugin->form_files[$form['file']][$form['fields_name']][$form['fieldset']] + = []; + } + // do some house cleaning (for fields) + foreach ($form['fields'] as $field) + { + // so first we lock the field name in + $this->fieldname->get( + $field, $plugin->key, $unique + ); + // add the fields to the global form file builder + $plugin->form_files[$form['file']][$form['fields_name']][$form['fieldset']][] + = $field; + } + // remove form + unset($plugin->fields[$n]); + } + else + { + // load the config form + if (!isset($plugin->config_fields[$form['fields_name']])) + { + $plugin->config_fields[$form['fields_name']] + = []; + } + if (!isset($plugin->config_fields[$form['fields_name']][$form['fieldset']])) + { + $plugin->config_fields[$form['fields_name']][$form['fieldset']] + = []; + } + // do some house cleaning (for fields) + foreach ($form['fields'] as $field) + { + // so first we lock the field name in + $this->fieldname->get( + $field, $plugin->key, $unique + ); + // add the fields to the config builder + $plugin->config_fields[$form['fields_name']][$form['fieldset']][] + = $field; + } + // remove form + unset($plugin->fields[$n]); + } + } + else + { + unset($plugin->fields[$n]); + } + } + } + unset($plugin->fields); + + // set files and folders + $this->filesfolders->set($plugin); + + // add PHP in plugin install + $plugin->add_install_script = true; + $addScriptMethods = [ + 'php_preflight', + 'php_postflight', + 'php_method', + 'php_script' + ]; + $addScriptTypes = [ + 'install', + 'update', + 'uninstall', + 'construct' + ]; + foreach ($addScriptMethods as $scriptMethod) + { + foreach ($addScriptTypes as $scriptType) + { + if (isset( $plugin->{'add_' . $scriptMethod . '_' . $scriptType}) + && $plugin->{'add_' . $scriptMethod . '_' . $scriptType} == 1 + && StringHelper::check( + $plugin->{$scriptMethod . '_' . $scriptType} + )) + { + // set GUI mapper field + $guiMapper['field'] = $scriptMethod . '_' . $scriptType; + $plugin->{$scriptMethod . '_' . $scriptType} = $this->gui->set( + $this->placeholder->update_( + $this->customcode->update( + base64_decode( + (string) $plugin->{$scriptMethod . '_' . $scriptType} + ) + ) + ), + $guiMapper + ); + } + else + { + unset($plugin->{$scriptMethod . '_' . $scriptType}); + $plugin->{'add_' . $scriptMethod . '_' . $scriptType} = 0; + } + } + } + + // add_sql + if ($plugin->add_sql == 1 + && StringHelper::check($plugin->sql)) + { + $plugin->sql = $this->placeholder->update_( + $this->customcode->update(base64_decode((string) $plugin->sql)) + ); + } + else + { + unset($plugin->sql); + $plugin->add_sql = 0; + } + + // add_sql_uninstall + if ($plugin->add_sql_uninstall == 1 + && StringHelper::check( + $plugin->sql_uninstall + )) + { + $plugin->sql_uninstall = $this->placeholder->update_( + $this->customcode->update( + base64_decode((string) $plugin->sql_uninstall) + ) + ); + } + else + { + unset($plugin->sql_uninstall); + $plugin->add_sql_uninstall = 0; + } + + // update the URL of the update_server if set + if ($plugin->add_update_server == 1 + && StringHelper::check( + $plugin->update_server_url + )) + { + $plugin->update_server_url = $this->placeholder->update_( + $this->customcode->update($plugin->update_server_url) + ); + } + + // add the update/sales server FTP details if that is the expected protocol + $serverArray = array('update_server', 'sales_server'); + foreach ($serverArray as $server) + { + if ($plugin->{'add_' . $server} == 1 + && is_numeric( + $plugin->{$server} + ) + && $plugin->{$server} > 0) + { + // get the server protocol + $plugin->{$server . '_protocol'} + = GetHelper::var( + 'server', (int) $plugin->{$server}, 'id', 'protocol' + ); + } + else + { + $plugin->{$server} = 0; + // only change this for sales server (update server can be added locally to the zip file) + if ('sales_server' === $server) + { + $plugin->{'add_' . $server} = 0; + } + $plugin->{$server . '_protocol'} = 0; + } + } + + // old path (to remove) + $plugin->remove_file_paths = []; + $plugin->remove_file_paths[] = "/plugins/{$plugin->group}/{$plugin->context_name}/{$plugin->file_name}.php"; + + // set the update server stuff (TODO) + // update_server_xml_path + // update_server_xml_file_name + + // rest globals + $this->config->build_target = $_backup_target; + $this->config->lang_target = $_backup_lang; + $this->config->set('lang_prefix', $_backup_langPrefix); + + $this->placeholder->remove('Plugin_name'); + $this->placeholder->remove('Plugin'); + $this->placeholder->remove('plugin'); + $this->placeholder->remove('Plugin_group'); + $this->placeholder->remove('plugin_group'); + $this->placeholder->remove('plugin.version'); + $this->placeholder->remove('plugin_version'); + $this->placeholder->remove('VERSION'); + $this->placeholder->remove('DESCRIPTION'); + $this->placeholder->remove('PLUGIN_NAME'); + + $this->data[$id] = $plugin; + + return true; + } + } + + return false; + } +} + diff --git a/src/361e08c0-5916-4b77-b6a2-c16a769bbc40/code.power b/src/361e08c0-5916-4b77-b6a2-c16a769bbc40/code.power new file mode 100644 index 0000000..1a897da --- /dev/null +++ b/src/361e08c0-5916-4b77-b6a2-c16a769bbc40/code.power @@ -0,0 +1,891 @@ + /** + * Compiler Joomla Plug-in's Data + * + * @var array + * @since 3.2.0 + */ + protected array $data = []; + + /** + * The Configure Class. + * + * @var Config + * @since 5.0.2 + */ + protected Config $config; + + /** + * The Customcode Class. + * + * @var Customcode + * @since 5.0.2 + */ + protected Customcode $customcode; + + /** + * The Gui Class. + * + * @var Gui + * @since 5.0.2 + */ + protected Gui $gui; + + /** + * The Placeholder Class. + * + * @var Placeholder + * @since 5.0.2 + */ + protected Placeholder $placeholder; + + /** + * The Language Class. + * + * @var Language + * @since 5.0.2 + */ + protected Language $language; + + /** + * The Field Class. + * + * @var Field + * @since 5.0.2 + */ + protected Field $field; + + /** + * The Name Class. + * + * @var FieldName + * @since 5.0.2 + */ + protected FieldName $fieldname; + + /** + * The Filesfolders Class. + * + * @var Filesfolders + * @since 5.0.2 + */ + protected Filesfolders $filesfolders; + + /** + * Database object to query local DB + * + * @since 3.2.0 + **/ + protected $db; + + /** + * Define the mappings of traits and classes to their respective methods and services + * + * @var array + * @since 5.0.2 + **/ + protected array $service_checks = [ + 'DatabaseAwareTrait' => [ + 'trait' => 'Joomla\Database\DatabaseAwareTrait', + 'class' => 'Joomla__'.'_ae15e6b6_f7de_43ad_be4b_71499ae88f45___Power', + 'method' => 'setDatabase', + 'service' => 'Joomla__'.'_7bd29d76_73c9_4c07_a5da_4f7a32aff78f___Power' + ], + 'UserFactoryAwareTrait' => [ + 'trait' => 'Joomla\CMS\User\UserFactoryAwareTrait', + 'class' => 'Joomla__'.'_a6b2c321_5de3_4425_b05f_e5340965fb80___Power', + 'method' => 'setUserFactory', + 'service' => 'Joomla__'.'_c2980d12_c3ef_4e23_b4a2_e6af1f5900a9___Power' + ] + ]; + + /** + * Constructor. + * + * @param Config $config The Config Class. + * @param Customcode $customcode The Customcode Class. + * @param Gui $gui The Gui Class. + * @param Placeholder $placeholder The Placeholder Class. + * @param Language $language The Language Class. + * @param Field $field The Field Class. + * @param FieldName $fieldname The Name Class. + * @param Filesfolders $filesfolders The Filesfolders Class. + * + * @since 5.0.2 + */ + public function __construct(Config $config, Customcode $customcode, Gui $gui, + Placeholder $placeholder, Language $language, + Field $field, FieldName $fieldname, + Filesfolders $filesfolders) + { + $this->config = $config; + $this->customcode = $customcode; + $this->gui = $gui; + $this->placeholder = $placeholder; + $this->language = $language; + $this->field = $field; + $this->fieldname = $fieldname; + $this->filesfolders = $filesfolders; + $this->db = Factory::getDbo(); + } + + /** + * Get the Joomla Plugin/s + * + * @param int|null $id the plugin id + * + * @return object|array|null if ID found it returns object, if no ID given it returns all set + * @since 3.2.0 + */ + public function get(int $id = null) + { + if (is_null($id) && $this->exists()) + { + return $this->data; + } + elseif ($this->exists($id)) + { + return $this->data[$id]; + } + + return null; + } + + /** + * Check if the Joomla Plugin/s exists + * + * @param int|null $id the plugin id + * + * @return bool if ID found it returns true, if no ID given it returns true if any are set + * @since 3.2.0 + */ + public function exists(int $id = null): bool + { + if (is_null($id)) + { + return ArrayHelper::check($this->data); + } + elseif (isset($this->data[$id])) + { + return true; + } + + return $this->set($id); + } + + /** + * Set the Joomla Plugin + * + * @param int $id the plugin id + * + * @return bool true on success + * @since 3.2.0 + */ + public function set(int $id): bool + { + if (isset($this->data[$id])) + { + return true; + } + else + { + // Create a new query object. + $query = $this->db->getQuery(true); + + $query->select('a.*'); + $query->select( + $this->db->quoteName( + array( + 'g.name', + 'e.name', + 'e.head', + 'e.comment', + 'e.id', + 'f.addfiles', + 'f.addfolders', + 'f.addfilesfullpath', + 'f.addfoldersfullpath', + 'f.addurls', + 'u.version_update', + 'u.id' + ), array( + 'group', + 'extends', + 'class_head', + 'comment', + 'class_id', + 'addfiles', + 'addfolders', + 'addfilesfullpath', + 'addfoldersfullpath', + 'addurls', + 'version_update', + 'version_update_id' + ) + ) + ); + // from these tables + $query->from('#__componentbuilder_joomla_plugin AS a'); + $query->join( + 'LEFT', $this->db->quoteName( + '#__componentbuilder_joomla_plugin_group', 'g' + ) . ' ON (' . $this->db->quoteName('a.joomla_plugin_group') + . ' = ' . $this->db->quoteName('g.id') . ')' + ); + $query->join( + 'LEFT', + $this->db->quoteName('#__componentbuilder_class_extends', 'e') + . ' ON (' . $this->db->quoteName('a.class_extends') . ' = ' + . $this->db->quoteName('e.id') . ')' + ); + $query->join( + 'LEFT', $this->db->quoteName( + '#__componentbuilder_joomla_plugin_updates', 'u' + ) . ' ON (' . $this->db->quoteName('a.id') . ' = ' + . $this->db->quoteName('u.joomla_plugin') . ')' + ); + $query->join( + 'LEFT', $this->db->quoteName( + '#__componentbuilder_joomla_plugin_files_folders_urls', 'f' + ) . ' ON (' . $this->db->quoteName('a.id') . ' = ' + . $this->db->quoteName('f.joomla_plugin') . ')' + ); + $query->where($this->db->quoteName('a.id') . ' = ' . (int) $id); + $query->where($this->db->quoteName('a.published') . ' >= 1'); + $this->db->setQuery($query); + $this->db->execute(); + if ($this->db->getNumRows()) + { + // get the plugin data + $plugin = $this->db->loadObject(); + + // tweak system to set stuff to the plugin domain + $_backup_target = $this->config->build_target; + $_backup_lang = $this->config->lang_target; + $_backup_langPrefix = $this->config->lang_prefix; + + // set some keys + $plugin->target_type = 'pLuG!n'; + $plugin->key = $plugin->id . '_' . $plugin->target_type; + + // update to point to plugin + $this->config->build_target = $plugin->key; + $this->config->lang_target = $plugin->key; + + // set version if not set + if (empty($plugin->plugin_version)) + { + $plugin->plugin_version = '1.0.0'; + } + + // set GUI mapper + $guiMapper = array('table' => 'joomla_plugin', + 'id' => (int) $id, 'type' => 'php'); + + // update the name if it has dynamic values + $plugin->name = $this->placeholder->update_( + $this->customcode->update($plugin->name) + ); + + // update the name if it has dynamic values + $plugin->code_name + = ClassfunctionHelper::safe( + $plugin->name + ); + + // set official name + $plugin->official_name = ucwords( + $plugin->group . ' - ' . $plugin->name + ); + + // set lang prefix + $plugin->lang_prefix = PluginHelper::safeLangPrefix( + $plugin->code_name, + $plugin->group + ); + + // set langPrefix + $this->config->lang_prefix = $plugin->lang_prefix; + + // set plugin class name + $plugin->class_name = ucfirst( + $plugin->code_name + ); + // set plugin context name + $plugin->context_name = strtolower((string) + $plugin->code_name + ); + + // set plugin namespace + $plugin->namespace = $plugin->code_name; + + // set plugin group namespace + $plugin->group_namespace = ucfirst( + $plugin->group + ); + + // set plugin install class name + $plugin->installer_class_name + = PluginHelper::safeInstallClassName( + $plugin->code_name, + $plugin->group + ); + + // set plugin folder name + $plugin->folder_name + = PluginHelper::safeFolderName( + $plugin->code_name, + $plugin->group + ); + + // set the zip name + $plugin->zip_name = $plugin->folder_name . '_v' . str_replace( + '.', '_', (string) $plugin->plugin_version + ) . '__J' . $this->config->joomla_version; + + // set plugin file name + $plugin->file_name = $plugin->context_name; + $plugin->class_file_name = $plugin->code_name; + + // set plugin context + $plugin->context = $plugin->folder_name . '.' . $plugin->id; + + // set official_name lang strings + $this->language->set( + $plugin->key, $this->config->lang_prefix, $plugin->official_name + ); + + // set some placeholder for this plugin + $this->placeholder->set('Plugin_name', $plugin->official_name); + $this->placeholder->set('PLUGIN_NAME', $plugin->official_name); + $this->placeholder->set('Plugin', ucfirst((string) $plugin->code_name)); + $this->placeholder->set('plugin', strtolower((string) $plugin->code_name)); + $this->placeholder->set('Plugin_group', ucfirst((string) $plugin->group)); + $this->placeholder->set('plugin_group', strtolower((string) $plugin->group)); + $this->placeholder->set('plugin.version', $plugin->plugin_version); + $this->placeholder->set('VERSION', $plugin->plugin_version); + $this->placeholder->set('plugin_version', str_replace( + '.', '_', (string) $plugin->plugin_version + )); + + // set description + $this->placeholder->set('DESCRIPTION', ''); + if (!isset($plugin->description) + || !StringHelper::check( + $plugin->description + )) + { + $plugin->description = ''; + } + else + { + $plugin->description = $this->placeholder->update_( + $this->customcode->update($plugin->description) + ); + $this->language->set( + $plugin->key, $plugin->lang_prefix . '_DESCRIPTION', + $plugin->description + ); + // set description + $this->placeholder->set('DESCRIPTION', $plugin->description); + $plugin->description = '

' . $plugin->description . '

'; + } + + // get author name + $project_author = $this->config->project_author; + + // we can only set these if the component was passed + $plugin->xml_description = "

" . $plugin->official_name + . " (v." . $plugin->plugin_version + . ")

" + . $plugin->description . "

Created by " . trim( + (string) OutputFilter::cleanText($project_author) + ) . "
Development started " + . Factory::getDate($plugin->created)->format("jS F, Y") + . "

"; + + // set xml discription + $this->language->set( + $plugin->key, $plugin->lang_prefix . '_XML_DESCRIPTION', + $plugin->xml_description + ); + + // update the readme if set + if ($plugin->addreadme == 1 && !empty($plugin->readme)) + { + $plugin->readme = $this->placeholder->update_( + $this->customcode->update(base64_decode((string) $plugin->readme)) + ); + } + else + { + $plugin->addreadme = 0; + unset($plugin->readme); + } + + // open some base64 strings + if (!empty($plugin->main_class_code)) + { + // set GUI mapper field + $guiMapper['field'] = 'main_class_code'; + // base64 Decode main_class_code. + $plugin->main_class_code = $this->gui->set( + $this->placeholder->update_( + $this->customcode->update( + base64_decode((string) $plugin->main_class_code) + ) + ), + $guiMapper + ); + } + + // set the head :) + if ($plugin->add_head == 1 && !empty($plugin->head)) + { + // set GUI mapper field + $guiMapper['field'] = 'head'; + // base64 Decode head. + $plugin->header = $this->gui->set( + $this->placeholder->update_( + $this->customcode->update( + base64_decode((string) $plugin->head) + ) + ), + $guiMapper + ); + } + elseif (!empty($plugin->class_head)) + { + // base64 Decode head. + $plugin->header = $this->gui->set( + $this->placeholder->update_( + $this->customcode->update( + base64_decode((string) $plugin->class_head) + ) + ), + array( + 'table' => 'class_extends', + 'field' => 'head', + 'id' => (int) $plugin->class_id, + 'type' => 'php') + ); + } + unset($plugin->class_head); + + // Check the plugin's code and header for each trait + foreach ($this->service_checks as $key => $info) + { + if (strpos($plugin->main_class_code, $key) !== false || + strpos($plugin->main_class_code, $info['class']) !== false || + strpos($plugin->header, $info['trait']) !== false) + { + $service_provider[] = Indent::_(4) . "\$plugin->{$info['method']}(\$container->get({$info['service']}::class));"; + } + } + + // Assign service provider if any services were added + if (!empty($service_provider)) + { + $plugin->service_provider = implode(PHP_EOL, $service_provider); + } + + // set the comment + if (!empty($plugin->comment)) + { + // base64 Decode comment. + $plugin->comment = $this->gui->set( + $this->placeholder->update_( + $this->customcode->update( + base64_decode((string) $plugin->comment) + ) + ), + array( + 'table' => 'class_extends', + 'field' => 'comment', + 'id' => (int) $plugin->class_id, + 'type' => 'php') + ); + } + + // start the config array + $plugin->config_fields = []; + // create the form arrays + $plugin->form_files = []; + $plugin->fieldsets_label = []; + $plugin->fieldsets_paths = []; + $plugin->add_rule_path = []; + $plugin->add_field_path = []; + // set global fields rule to default component path + $plugin->fields_rules_paths = 1; + // set the fields data + $plugin->fields = (isset($plugin->fields) + && JsonHelper::check($plugin->fields)) + ? json_decode((string) $plugin->fields, true) : null; + if (ArrayHelper::check($plugin->fields)) + { + // ket global key + $key = $plugin->key; + $dynamic_fields = array('fieldset' => 'basic', + 'fields_name' => 'params', + 'file' => 'config'); + foreach ($plugin->fields as $n => &$form) + { + if (isset($form['fields']) + && ArrayHelper::check( + $form['fields'] + )) + { + // make sure the dynamic_field is set to dynamic_value by default + foreach ( + $dynamic_fields as $dynamic_field => + $dynamic_value + ) + { + if (!isset($form[$dynamic_field]) + || !StringHelper::check( + $form[$dynamic_field] + )) + { + $form[$dynamic_field] = $dynamic_value; + } + else + { + if ('fields_name' === $dynamic_field + && strpos((string) $form[$dynamic_field], '.') + !== false) + { + $form[$dynamic_field] + = $form[$dynamic_field]; + } + else + { + $form[$dynamic_field] + = StringHelper::safe( + $form[$dynamic_field] + ); + } + } + } + // check if field is external form file + if (!isset($form['plugin']) || $form['plugin'] != 1) + { + // now build the form key + $unique = $form['file'] . $form['fields_name'] + . $form['fieldset']; + } + else + { + // now build the form key + $unique = $form['fields_name'] + . $form['fieldset']; + } + // set global fields rule path switchs + if ($plugin->fields_rules_paths == 1 + && isset($form['fields_rules_paths']) + && $form['fields_rules_paths'] == 2) + { + $plugin->fields_rules_paths = 2; + } + // set where to path is pointing + $plugin->fieldsets_paths[$unique] + = $form['fields_rules_paths']; + // add the label if set to lang + if (isset($form['label']) + && StringHelper::check( + $form['label'] + )) + { + $plugin->fieldsets_label[$unique] + = $this->language->key($form['label']); + } + // check for extra rule paths + if (isset($form['addrulepath']) + && ArrayHelper::check($form['addrulepath'])) + { + foreach ($form['addrulepath'] as $add_rule_path) + { + if (StringHelper::check($add_rule_path['path'])) + { + $plugin->add_rule_path[$unique] = $add_rule_path['path']; + } + } + } + // check for extra field paths + if (isset($form['addfieldpath']) + && ArrayHelper::check($form['addfieldpath'])) + { + foreach ($form['addfieldpath'] as $add_field_path) + { + if (StringHelper::check($add_field_path['path'])) + { + $plugin->add_field_path[$unique] = $add_field_path['path']; + } + } + } + // build the fields + $form['fields'] = array_map( + function ($field) use ($key, $unique) { + // make sure the alias and title is 0 + $field['alias'] = 0; + $field['title'] = 0; + // set the field details + $this->field->set( + $field, $key, $key, $unique + ); + // update the default if set + if (StringHelper::check( + $field['custom_value'] + ) + && isset($field['settings'])) + { + if (($old_default + = GetHelper::between( + $field['settings']->xml, + 'default="', '"', false + )) !== false) + { + // replace old default + $field['settings']->xml + = str_replace( + 'default="' . $old_default + . '"', 'default="' + . $field['custom_value'] . '"', + (string) $field['settings']->xml + ); + } + else + { + // add the default (hmmm not ideal but okay it should work) + $field['settings']->xml + = 'default="' + . $field['custom_value'] . '" ' + . $field['settings']->xml; + } + } + unset($field['custom_value']); + + // return field + return $field; + }, array_values($form['fields']) + ); + // check if field is external form file + if (!isset($form['plugin']) || $form['plugin'] != 1) + { + // load the form file + if (!isset($plugin->form_files[$form['file']])) + { + $plugin->form_files[$form['file']] + = []; + } + if (!isset($plugin->form_files[$form['file']][$form['fields_name']])) + { + $plugin->form_files[$form['file']][$form['fields_name']] + = []; + } + if (!isset($plugin->form_files[$form['file']][$form['fields_name']][$form['fieldset']])) + { + $plugin->form_files[$form['file']][$form['fields_name']][$form['fieldset']] + = []; + } + // do some house cleaning (for fields) + foreach ($form['fields'] as $field) + { + // so first we lock the field name in + $this->fieldname->get( + $field, $plugin->key, $unique + ); + // add the fields to the global form file builder + $plugin->form_files[$form['file']][$form['fields_name']][$form['fieldset']][] + = $field; + } + // remove form + unset($plugin->fields[$n]); + } + else + { + // load the config form + if (!isset($plugin->config_fields[$form['fields_name']])) + { + $plugin->config_fields[$form['fields_name']] + = []; + } + if (!isset($plugin->config_fields[$form['fields_name']][$form['fieldset']])) + { + $plugin->config_fields[$form['fields_name']][$form['fieldset']] + = []; + } + // do some house cleaning (for fields) + foreach ($form['fields'] as $field) + { + // so first we lock the field name in + $this->fieldname->get( + $field, $plugin->key, $unique + ); + // add the fields to the config builder + $plugin->config_fields[$form['fields_name']][$form['fieldset']][] + = $field; + } + // remove form + unset($plugin->fields[$n]); + } + } + else + { + unset($plugin->fields[$n]); + } + } + } + unset($plugin->fields); + + // set files and folders + $this->filesfolders->set($plugin); + + // add PHP in plugin install + $plugin->add_install_script = true; + $addScriptMethods = [ + 'php_preflight', + 'php_postflight', + 'php_method', + 'php_script' + ]; + $addScriptTypes = [ + 'install', + 'update', + 'uninstall', + 'construct' + ]; + foreach ($addScriptMethods as $scriptMethod) + { + foreach ($addScriptTypes as $scriptType) + { + if (isset( $plugin->{'add_' . $scriptMethod . '_' . $scriptType}) + && $plugin->{'add_' . $scriptMethod . '_' . $scriptType} == 1 + && StringHelper::check( + $plugin->{$scriptMethod . '_' . $scriptType} + )) + { + // set GUI mapper field + $guiMapper['field'] = $scriptMethod . '_' . $scriptType; + $plugin->{$scriptMethod . '_' . $scriptType} = $this->gui->set( + $this->placeholder->update_( + $this->customcode->update( + base64_decode( + (string) $plugin->{$scriptMethod . '_' . $scriptType} + ) + ) + ), + $guiMapper + ); + } + else + { + unset($plugin->{$scriptMethod . '_' . $scriptType}); + $plugin->{'add_' . $scriptMethod . '_' . $scriptType} = 0; + } + } + } + + // add_sql + if ($plugin->add_sql == 1 + && StringHelper::check($plugin->sql)) + { + $plugin->sql = $this->placeholder->update_( + $this->customcode->update(base64_decode((string) $plugin->sql)) + ); + } + else + { + unset($plugin->sql); + $plugin->add_sql = 0; + } + + // add_sql_uninstall + if ($plugin->add_sql_uninstall == 1 + && StringHelper::check( + $plugin->sql_uninstall + )) + { + $plugin->sql_uninstall = $this->placeholder->update_( + $this->customcode->update( + base64_decode((string) $plugin->sql_uninstall) + ) + ); + } + else + { + unset($plugin->sql_uninstall); + $plugin->add_sql_uninstall = 0; + } + + // update the URL of the update_server if set + if ($plugin->add_update_server == 1 + && StringHelper::check( + $plugin->update_server_url + )) + { + $plugin->update_server_url = $this->placeholder->update_( + $this->customcode->update($plugin->update_server_url) + ); + } + + // add the update/sales server FTP details if that is the expected protocol + $serverArray = array('update_server', 'sales_server'); + foreach ($serverArray as $server) + { + if ($plugin->{'add_' . $server} == 1 + && is_numeric( + $plugin->{$server} + ) + && $plugin->{$server} > 0) + { + // get the server protocol + $plugin->{$server . '_protocol'} + = GetHelper::var( + 'server', (int) $plugin->{$server}, 'id', 'protocol' + ); + } + else + { + $plugin->{$server} = 0; + // only change this for sales server (update server can be added locally to the zip file) + if ('sales_server' === $server) + { + $plugin->{'add_' . $server} = 0; + } + $plugin->{$server . '_protocol'} = 0; + } + } + + // old path (to remove) + $plugin->remove_file_paths = []; + $plugin->remove_file_paths[] = "/plugins/{$plugin->group}/{$plugin->context_name}/{$plugin->file_name}.php"; + + // set the update server stuff (TODO) + // update_server_xml_path + // update_server_xml_file_name + + // rest globals + $this->config->build_target = $_backup_target; + $this->config->lang_target = $_backup_lang; + $this->config->set('lang_prefix', $_backup_langPrefix); + + $this->placeholder->remove('Plugin_name'); + $this->placeholder->remove('Plugin'); + $this->placeholder->remove('plugin'); + $this->placeholder->remove('Plugin_group'); + $this->placeholder->remove('plugin_group'); + $this->placeholder->remove('plugin.version'); + $this->placeholder->remove('plugin_version'); + $this->placeholder->remove('VERSION'); + $this->placeholder->remove('DESCRIPTION'); + $this->placeholder->remove('PLUGIN_NAME'); + + $this->data[$id] = $plugin; + + return true; + } + } + + return false; + } \ No newline at end of file diff --git a/src/361e08c0-5916-4b77-b6a2-c16a769bbc40/settings.json b/src/361e08c0-5916-4b77-b6a2-c16a769bbc40/settings.json new file mode 100644 index 0000000..2646b39 --- /dev/null +++ b/src/361e08c0-5916-4b77-b6a2-c16a769bbc40/settings.json @@ -0,0 +1,82 @@ +{ + "add_head": "1", + "add_licensing_template": "2", + "extends": "", + "guid": "361e08c0-5916-4b77-b6a2-c16a769bbc40", + "implements": [ + "8cc85656-a925-4a46-a49b-83c72167fd6a" + ], + "load_selection": null, + "name": "Data", + "power_version": "1.0.0", + "system_name": "JCB.Compiler.Joomlaplugin.J4.Data", + "type": "final class", + "use_selection": { + "use_selection0": { + "use": "fa4bf18e-301e-42e3-91fb-6e0096c07adc", + "as": "default" + }, + "use_selection1": { + "use": "313b43c4-98c3-4f62-9177-2d73ec8eba31", + "as": "default" + }, + "use_selection2": { + "use": "1bd48df2-4f7e-4581-9fe9-4b54e59105e3", + "as": "default" + }, + "use_selection3": { + "use": "06453ada-e370-49f0-b262-e3f5a8ed0c2c", + "as": "default" + }, + "use_selection4": { + "use": "8eee7df5-2775-41a9-9372-c46c5939a252", + "as": "default" + }, + "use_selection5": { + "use": "d7ba2d5d-10b6-470d-978d-9f91ea65ee75", + "as": "default" + }, + "use_selection6": { + "use": "9387215f-a965-4421-acf3-5e8f9d11382f", + "as": "FieldName" + }, + "use_selection7": { + "use": "f4578c04-a81e-4218-b80d-b0612196eaf0", + "as": "default" + }, + "use_selection8": { + "use": "0a59c65c-9daf-4bc9-baf4-e063ff9e6a8a", + "as": "default" + }, + "use_selection9": { + "use": "30c5b4c2-f75f-4d15-869a-f8bfedd87358", + "as": "default" + }, + "use_selection10": { + "use": "3cf76fbf-fd95-4a33-878e-7aff6d36b7f6", + "as": "default" + }, + "use_selection11": { + "use": "4b225c51-d293-48e4-b3f6-5136cf5c3f18", + "as": "default" + }, + "use_selection12": { + "use": "1f28cb53-60d9-4db1-b517-3c7dc6b429ef", + "as": "default" + }, + "use_selection13": { + "use": "db87c339-5bb6-4291-a7ef-2c48ea1b06bc", + "as": "default" + }, + "use_selection14": { + "use": "a68c010b-e92e-47d5-8a44-d23cfddeb6c6", + "as": "default" + } + }, + "extendsinterfaces": null, + "namespace": "[[[NamespacePrefix]]]\\Joomla\\[[[ComponentNamespace]]].Compiler.Joomlaplugin.JoomlaFour.Data", + "description": "Joomla 4 Plug-in Data Class\r\n\r\n@since 5.0.2", + "licensing_template": "\/**\r\n * @package Joomla.Component.Builder\r\n *\r\n * @created 4th September, 2022\r\n * @author Llewellyn van der Merwe \r\n * @git Joomla Component Builder \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;\r\nuse Joomla\\CMS\\Filter\\OutputFilter;", + "composer": "" +} \ No newline at end of file diff --git a/src/375543cd-5f2a-4893-982e-a73eaa55360d/README.md b/src/375543cd-5f2a-4893-982e-a73eaa55360d/README.md new file mode 100644 index 0000000..c3597a6 --- /dev/null +++ b/src/375543cd-5f2a-4893-982e-a73eaa55360d/README.md @@ -0,0 +1,84 @@ +``` +██████╗ ██████╗ ██╗ ██╗███████╗██████╗ +██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗ +██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝ +██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗ +██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║ +╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝ +``` +# final class Update (Details) +> namespace: **VDM\Joomla\Componentbuilder\Compiler\Language** + +```uml +@startuml +class Update << (F,LightGreen) >> #RoyalBlue { + # array $items + # $db + # $user + + __construct() + + set(int $id, string $target, ...) : void + + execute(int $when = 1) : void +} + +note right of Update::__construct + Constructor. + + since: 5.0.2 +end note + +note right of Update::set + Add a language string to the existing language strings array for updating. +This method prepares and stores the update information for a language string +in the `items` array, which is later used by the `execute` method to update +the database. + + since: 5.0.2 + return: void + + arguments: + int $id + string $target + array $targets + int $published + string $today + int $counter +end note + +note right of Update::execute + Update the language placeholders in the database. +This method updates the language placeholders in the database if the number of items +meets or exceeds the specified threshold (`$when`). It constructs and executes an +update query for each set of values in the `items` array. + + since: 5.0.2 + return: void +end note + +@enduml +``` + +The Power feature in JCB allows you to write PHP classes and their implementations, making it easy to include them in your Joomla project. JCB handles linking, autoloading, namespacing, and folder structure creation for you. + +By using the SPK (Super Power Key) in your custom code (replacing the class name in your code with the SPK), JCB will automatically pull the power from the repository into your project. This makes it available in your JCB instance, allowing you to edit it and include the class in your generated Joomla component. + +JCB uses placeholders like [[[`NamespacePrefix`]]] and [[[`ComponentNamespace`]]] in namespacing to prevent collisions and improve reusability across different JCB systems. You can also set the **JCB powers path** globally or per component under the **Dynamic Integration** tab, providing flexibility and easy maintainability. + +To add this specific Power to your project in JCB: + +> simply use this SPK +``` +Super---375543cd_5f2a_4893_982e_a73eaa55360d---Power +``` +> remember to replace the `---` with `___` to activate this Power in your code + +--- +``` + ██╗ ██████╗██████╗ + ██║██╔════╝██╔══██╗ + ██║██║ ██████╔╝ +██ ██║██║ ██╔══██╗ +╚█████╔╝╚██████╗██████╔╝ + ╚════╝ ╚═════╝╚═════╝ +``` +> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder) + diff --git a/src/375543cd-5f2a-4893-982e-a73eaa55360d/code.php b/src/375543cd-5f2a-4893-982e-a73eaa55360d/code.php new file mode 100644 index 0000000..d870674 --- /dev/null +++ b/src/375543cd-5f2a-4893-982e-a73eaa55360d/code.php @@ -0,0 +1,129 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Componentbuilder\Compiler\Language; + + +use Joomla\CMS\Factory; + + +/** + * Compiler Update Existing Language Strings + * + * @since 5.0.2 + */ +final class Update +{ + /** + * The items to update + * + * @var array + * @since 5.0.2 + **/ + protected array $items = []; + + /** + * Database object to query local DB + * + * @since 5.0.2 + **/ + protected $db; + + /** + * User object + * + * @since 5.0.2 + **/ + protected $user; + + /** + * Constructor. + * + * @since 5.0.2 + */ + public function __construct() + { + $this->db = Factory::getDbo(); + $this->user = Factory::getUser(); + } + + /** + * Add a language string to the existing language strings array for updating. + * + * This method prepares and stores the update information for a language string + * in the `items` array, which is later used by the `execute` method to update + * the database. + * + * @param int $id The ID of the language string. + * @param string $target The target field to be updated. + * @param array $targets The new values for the target field. + * @param int $published The published state. + * @param string $today The current date. + * @param int $counter The counter for the items array. + * + * @return void + * @since 5.0.2 + */ + public function set(int $id, string $target, array $targets, int $published, string $today, int $counter): void + { + // Start the bucket for this language item. + $this->items[$counter] = []; + $this->items[$counter]['id'] = (int) $id; + + // Prepare the conditions for the update query. + $this->items[$counter]['conditions'] = []; + $this->items[$counter]['conditions'][] = $this->db->quoteName('id') . ' = ' . $this->db->quote($id); + + // Prepare the fields for the update query. + $this->items[$counter]['fields'] = []; + $this->items[$counter]['fields'][] = $this->db->quoteName($target) . ' = ' . $this->db->quote(json_encode($targets)); + $this->items[$counter]['fields'][] = $this->db->quoteName('published') . ' = ' . $this->db->quote($published); + $this->items[$counter]['fields'][] = $this->db->quoteName('modified') . ' = ' . $this->db->quote($today); + $this->items[$counter]['fields'][] = $this->db->quoteName('modified_by') . ' = ' . $this->db->quote((int) $this->user->id); + } + + /** + * Update the language placeholders in the database. + * + * This method updates the language placeholders in the database if the number of items + * meets or exceeds the specified threshold (`$when`). It constructs and executes an + * update query for each set of values in the `items` array. + * + * @param int $when The threshold count to determine when to update. Default is 1. + * + * @return void + * @since 5.0.2 + */ + public function execute(int $when = 1): void + { + if (count((array) $this->items) >= $when) + { + foreach ($this->items as $values) + { + // Create a new query object. + $query = $this->db->getQuery(true); + + // Prepare the update query. + $query->update($this->db->quoteName('#__componentbuilder_language_translation')) + ->set($values['fields']) + ->where($values['conditions']); + + // Set the query using our newly populated query object and execute it. + $this->db->setQuery($query); + $this->db->execute(); + } + + // Clear the items array. + $this->items = []; + } + } +} + diff --git a/src/375543cd-5f2a-4893-982e-a73eaa55360d/code.power b/src/375543cd-5f2a-4893-982e-a73eaa55360d/code.power new file mode 100644 index 0000000..f0e9b80 --- /dev/null +++ b/src/375543cd-5f2a-4893-982e-a73eaa55360d/code.power @@ -0,0 +1,103 @@ + /** + * The items to update + * + * @var array + * @since 5.0.2 + **/ + protected array $items = []; + + /** + * Database object to query local DB + * + * @since 5.0.2 + **/ + protected $db; + + /** + * User object + * + * @since 5.0.2 + **/ + protected $user; + + /** + * Constructor. + * + * @since 5.0.2 + */ + public function __construct() + { + $this->db = Factory::getDbo(); + $this->user = Factory::getUser(); + } + + /** + * Add a language string to the existing language strings array for updating. + * + * This method prepares and stores the update information for a language string + * in the `items` array, which is later used by the `execute` method to update + * the database. + * + * @param int $id The ID of the language string. + * @param string $target The target field to be updated. + * @param array $targets The new values for the target field. + * @param int $published The published state. + * @param string $today The current date. + * @param int $counter The counter for the items array. + * + * @return void + * @since 5.0.2 + */ + public function set(int $id, string $target, array $targets, int $published, string $today, int $counter): void + { + // Start the bucket for this language item. + $this->items[$counter] = []; + $this->items[$counter]['id'] = (int) $id; + + // Prepare the conditions for the update query. + $this->items[$counter]['conditions'] = []; + $this->items[$counter]['conditions'][] = $this->db->quoteName('id') . ' = ' . $this->db->quote($id); + + // Prepare the fields for the update query. + $this->items[$counter]['fields'] = []; + $this->items[$counter]['fields'][] = $this->db->quoteName($target) . ' = ' . $this->db->quote(json_encode($targets)); + $this->items[$counter]['fields'][] = $this->db->quoteName('published') . ' = ' . $this->db->quote($published); + $this->items[$counter]['fields'][] = $this->db->quoteName('modified') . ' = ' . $this->db->quote($today); + $this->items[$counter]['fields'][] = $this->db->quoteName('modified_by') . ' = ' . $this->db->quote((int) $this->user->id); + } + + /** + * Update the language placeholders in the database. + * + * This method updates the language placeholders in the database if the number of items + * meets or exceeds the specified threshold (`$when`). It constructs and executes an + * update query for each set of values in the `items` array. + * + * @param int $when The threshold count to determine when to update. Default is 1. + * + * @return void + * @since 5.0.2 + */ + public function execute(int $when = 1): void + { + if (count((array) $this->items) >= $when) + { + foreach ($this->items as $values) + { + // Create a new query object. + $query = $this->db->getQuery(true); + + // Prepare the update query. + $query->update($this->db->quoteName('#__componentbuilder_language_translation')) + ->set($values['fields']) + ->where($values['conditions']); + + // Set the query using our newly populated query object and execute it. + $this->db->setQuery($query); + $this->db->execute(); + } + + // Clear the items array. + $this->items = []; + } + } \ No newline at end of file diff --git a/src/375543cd-5f2a-4893-982e-a73eaa55360d/settings.json b/src/375543cd-5f2a-4893-982e-a73eaa55360d/settings.json new file mode 100644 index 0000000..df13927 --- /dev/null +++ b/src/375543cd-5f2a-4893-982e-a73eaa55360d/settings.json @@ -0,0 +1,19 @@ +{ + "add_head": "1", + "add_licensing_template": "2", + "extends": "", + "guid": "375543cd-5f2a-4893-982e-a73eaa55360d", + "implements": null, + "load_selection": null, + "name": "Update", + "power_version": "1.0.0", + "system_name": "JCB.Compiler.Language.Update", + "type": "final class", + "use_selection": null, + "extendsinterfaces": null, + "namespace": "[[[NamespacePrefix]]]\\Joomla\\[[[ComponentNamespace]]].Compiler.Language.Update", + "description": "Compiler Update Existing Language Strings\r\n\r\n@since 5.0.2", + "licensing_template": "\/**\r\n * @package Joomla.Component.Builder\r\n *\r\n * @created 4th September, 2022\r\n * @author Llewellyn van der Merwe \r\n * @git Joomla Component Builder \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;", + "composer": "" +} \ No newline at end of file diff --git a/src/40e17114-2193-4a61-9233-47b5f4193665/README.md b/src/40e17114-2193-4a61-9233-47b5f4193665/README.md new file mode 100644 index 0000000..1160d70 --- /dev/null +++ b/src/40e17114-2193-4a61-9233-47b5f4193665/README.md @@ -0,0 +1,55 @@ +``` +██████╗ ██████╗ ██╗ ██╗███████╗██████╗ +██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗ +██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝ +██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗ +██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║ +╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝ +``` +# interface InfusionInterface (Details) +> namespace: **VDM\Joomla\Componentbuilder\Interfaces\Plugin** + +```uml +@startuml +interface InfusionInterface #Lavender { + + set() : void +} + +note right of InfusionInterface::set + Infuse the plugin data into the content. +This method processes each plugin in the data set, triggering events +before and after infusion, setting placeholders, and adding content +such as headers, classes, and XML configurations. + + since: 5.0.2 + return: void +end note + +@enduml +``` + +The Power feature in JCB allows you to write PHP classes and their implementations, making it easy to include them in your Joomla project. JCB handles linking, autoloading, namespacing, and folder structure creation for you. + +By using the SPK (Super Power Key) in your custom code (replacing the class name in your code with the SPK), JCB will automatically pull the power from the repository into your project. This makes it available in your JCB instance, allowing you to edit it and include the class in your generated Joomla component. + +JCB uses placeholders like [[[`NamespacePrefix`]]] and [[[`ComponentNamespace`]]] in namespacing to prevent collisions and improve reusability across different JCB systems. You can also set the **JCB powers path** globally or per component under the **Dynamic Integration** tab, providing flexibility and easy maintainability. + +To add this specific Power to your project in JCB: + +> simply use this SPK +``` +Super---40e17114_2193_4a61_9233_47b5f4193665---Power +``` +> remember to replace the `---` with `___` to activate this Power in your code + +--- +``` + ██╗ ██████╗██████╗ + ██║██╔════╝██╔══██╗ + ██║██║ ██████╔╝ +██ ██║██║ ██╔══██╗ +╚█████╔╝╚██████╗██████╔╝ + ╚════╝ ╚═════╝╚═════╝ +``` +> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder) + diff --git a/src/40e17114-2193-4a61-9233-47b5f4193665/code.php b/src/40e17114-2193-4a61-9233-47b5f4193665/code.php new file mode 100644 index 0000000..0397c37 --- /dev/null +++ b/src/40e17114-2193-4a61-9233-47b5f4193665/code.php @@ -0,0 +1,34 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Componentbuilder\Interfaces\Plugin; + + +/** + * Plug-in Infusion Interface + * + * @since 5.0.2 + */ +interface InfusionInterface +{ + /** + * Infuse the plugin data into the content. + * + * This method processes each plugin in the data set, triggering events + * before and after infusion, setting placeholders, and adding content + * such as headers, classes, and XML configurations. + * + * @return void + * @since 5.0.2 + */ + public function set(): void; +} + diff --git a/src/40e17114-2193-4a61-9233-47b5f4193665/code.power b/src/40e17114-2193-4a61-9233-47b5f4193665/code.power new file mode 100644 index 0000000..a8dde4f --- /dev/null +++ b/src/40e17114-2193-4a61-9233-47b5f4193665/code.power @@ -0,0 +1,11 @@ + /** + * Infuse the plugin data into the content. + * + * This method processes each plugin in the data set, triggering events + * before and after infusion, setting placeholders, and adding content + * such as headers, classes, and XML configurations. + * + * @return void + * @since 5.0.2 + */ + public function set(): void; \ No newline at end of file diff --git a/src/40e17114-2193-4a61-9233-47b5f4193665/settings.json b/src/40e17114-2193-4a61-9233-47b5f4193665/settings.json new file mode 100644 index 0000000..4748594 --- /dev/null +++ b/src/40e17114-2193-4a61-9233-47b5f4193665/settings.json @@ -0,0 +1,19 @@ +{ + "add_head": "0", + "add_licensing_template": "2", + "extends": "", + "guid": "40e17114-2193-4a61-9233-47b5f4193665", + "implements": null, + "load_selection": null, + "name": "InfusionInterface", + "power_version": "1.0.0", + "system_name": "JCB.Interfaces.Plugin.InfusionInterface", + "type": "interface", + "use_selection": null, + "extendsinterfaces": null, + "namespace": "[[[NamespacePrefix]]]\\Joomla\\[[[ComponentNamespace]]].Interfaces.Plugin.InfusionInterface", + "description": "Plug-in Infusion Interface\r\n\r\n@since 5.0.2", + "licensing_template": "\/**\r\n * @package Joomla.Component.Builder\r\n *\r\n * @created 4th September, 2022\r\n * @author Llewellyn van der Merwe \r\n * @git Joomla Component Builder \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/4729c2b0-f12b-4397-8d77-055d38bca98b/code.php b/src/4729c2b0-f12b-4397-8d77-055d38bca98b/code.php index 578f5f6..0017f05 100644 --- a/src/4729c2b0-f12b-4397-8d77-055d38bca98b/code.php +++ b/src/4729c2b0-f12b-4397-8d77-055d38bca98b/code.php @@ -13,8 +13,9 @@ namespace VDM\Joomla\Componentbuilder\Compiler\JoomlaFour; use Joomla\CMS\Factory; -use Joomla\Registry\Registry; -use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\Event\DispatcherInterface; +use Joomla\Registry\Registry; use VDM\Joomla\Utilities\Component\Helper; use VDM\Joomla\Componentbuilder\Compiler\Interfaces\EventInterface; @@ -35,9 +36,9 @@ final class Event implements EventInterface protected $activePlugins = false; /** - * The application to trigger and event TODO + * The dispatcher to get events * - * @since 3.2.0 + * @since 5.0.2 */ protected $dispatcher; @@ -69,7 +70,7 @@ final class Event implements EventInterface } } - $this->dispatcher = Factory::getApplication(); + $this->dispatcher = Factory::getContainer()->get(DispatcherInterface::class); } /** @@ -89,8 +90,13 @@ final class Event implements EventInterface { try { - // Trigger this compiler event. - $results = $this->dispatcher->triggerEvent($event, $data ?? []); + $data ??= []; + $listeners = $this->dispatcher->getListeners($event); + foreach ($listeners as $listener) + { + // Call the listener with the unpacked arguments + $listener(...$data); + } } catch (\Exception $e) { diff --git a/src/4729c2b0-f12b-4397-8d77-055d38bca98b/code.power b/src/4729c2b0-f12b-4397-8d77-055d38bca98b/code.power index 4527c51..4825283 100644 --- a/src/4729c2b0-f12b-4397-8d77-055d38bca98b/code.power +++ b/src/4729c2b0-f12b-4397-8d77-055d38bca98b/code.power @@ -7,9 +7,9 @@ protected $activePlugins = false; /** - * The application to trigger and event TODO + * The dispatcher to get events * - * @since 3.2.0 + * @since 5.0.2 */ protected $dispatcher; @@ -41,7 +41,7 @@ } } - $this->dispatcher = Factory::getApplication(); + $this->dispatcher = Factory::getContainer()->get(DispatcherInterface::class); } /** @@ -61,8 +61,13 @@ { try { - // Trigger this compiler event. - $results = $this->dispatcher->triggerEvent($event, $data ?? []); + $data ??= []; + $listeners = $this->dispatcher->getListeners($event); + foreach ($listeners as $listener) + { + // Call the listener with the unpacked arguments + $listener(...$data); + } } catch (\Exception $e) { diff --git a/src/4729c2b0-f12b-4397-8d77-055d38bca98b/settings.json b/src/4729c2b0-f12b-4397-8d77-055d38bca98b/settings.json index bc22a4b..f56f2bf 100644 --- a/src/4729c2b0-f12b-4397-8d77-055d38bca98b/settings.json +++ b/src/4729c2b0-f12b-4397-8d77-055d38bca98b/settings.json @@ -21,6 +21,6 @@ "namespace": "[[[NamespacePrefix]]]\\Joomla\\[[[ComponentNamespace]]].Compiler.JoomlaFour.Event", "description": "Compiler Events\r\n\r\n@since 3.2.0", "licensing_template": "\/**\r\n * @package Joomla.Component.Builder\r\n *\r\n * @created 4th September, 2022\r\n * @author Llewellyn van der Merwe \r\n * @git Joomla Component Builder \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;\r\nuse Joomla\\Registry\\Registry;\r\nuse Joomla\\CMS\\Plugin\\PluginHelper;", + "head": "use Joomla\\CMS\\Factory;\r\nuse Joomla\\CMS\\Plugin\\PluginHelper;\r\nuse Joomla\\Event\\DispatcherInterface;\r\nuse Joomla\\Registry\\Registry;", "composer": "" } \ No newline at end of file diff --git a/src/4ad7020e-39ab-49ba-977b-de6084944502/README.md b/src/4ad7020e-39ab-49ba-977b-de6084944502/README.md index 161decf..cfa1bae 100644 --- a/src/4ad7020e-39ab-49ba-977b-de6084944502/README.md +++ b/src/4ad7020e-39ab-49ba-977b-de6084944502/README.md @@ -6,12 +6,12 @@ ██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║ ╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝ ``` -# class Fieldset (Details) +# final class Fieldset (Details) > namespace: **VDM\Joomla\Componentbuilder\Compiler\Language** ```uml @startuml -class Fieldset #Gold { +class Fieldset << (F,LightGreen) >> #RoyalBlue { # Language $language # MetaData $metadata # AccessSwitch $accessswitch diff --git a/src/4ad7020e-39ab-49ba-977b-de6084944502/code.php b/src/4ad7020e-39ab-49ba-977b-de6084944502/code.php index ce42c5a..33433a8 100644 --- a/src/4ad7020e-39ab-49ba-977b-de6084944502/code.php +++ b/src/4ad7020e-39ab-49ba-977b-de6084944502/code.php @@ -23,7 +23,7 @@ use VDM\Joomla\Componentbuilder\Compiler\Builder\AccessSwitchList; * * @since 3.2.0 */ -class Fieldset +final class Fieldset { /** * The Language Class. diff --git a/src/4ad7020e-39ab-49ba-977b-de6084944502/settings.json b/src/4ad7020e-39ab-49ba-977b-de6084944502/settings.json index 82dffb8..2fa8028 100644 --- a/src/4ad7020e-39ab-49ba-977b-de6084944502/settings.json +++ b/src/4ad7020e-39ab-49ba-977b-de6084944502/settings.json @@ -8,7 +8,7 @@ "name": "Fieldset", "power_version": "1.0.0", "system_name": "JCB.Compiler.Language.Fieldset", - "type": "class", + "type": "final class", "use_selection": { "use_selection0": { "use": "8eee7df5-2775-41a9-9372-c46c5939a252", diff --git a/src/54e05f58-6538-42ec-ba46-b136f33e7cc7/README.md b/src/54e05f58-6538-42ec-ba46-b136f33e7cc7/README.md new file mode 100644 index 0000000..ec18486 --- /dev/null +++ b/src/54e05f58-6538-42ec-ba46-b136f33e7cc7/README.md @@ -0,0 +1,156 @@ +``` +██████╗ ██████╗ ██╗ ██╗███████╗██████╗ +██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗ +██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝ +██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗ +██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║ +╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝ +``` +# final class MainXML (Details) +> namespace: **VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaThree\Plugin** + +```uml +@startuml +class MainXML << (F,LightGreen) >> #RoyalBlue { + # Config $config + # Language $language + # Set $set + # Purge $purge + # Translation $translation + # Multilingual $multilingual + # Event $event + # FieldsetExtension $fieldsetextension + # ContentOne $contentone + # Languages $languages + # BuilderMultilingual $buildermultilingual + # Counter $counter + # File $file + + __construct(Config $config, Language $language, ...) + + get(object $plugin) : string + # buildConfigFields(object $plugin) : array + # shouldAddComponentPath(object $plugin) : bool + # generateScriptAndSqlXml(object $plugin) : string + # generateLanguageXml(object $plugin, array $languageFiles) : string + # generateFileXml(object $plugin, array $languageFiles) : string + # generateConfigXml(object $plugin, array $configFields, ...) : string + # generateUpdateServerXml(object $plugin) : string + # generateLanguageFiles(object $plugin) : array +} + +note right of MainXML::__construct + Constructor. + + since: 5.0.2 + + arguments: + Config $config + Language $language + Set $set + Purge $purge + Translation $translation + Multilingual $multilingual + Event $event + FieldsetExtension $fieldsetextension + ContentOne $contentone + Languages $languages + BuilderMultilingual $buildermultilingual + Counter $counter + File $file +end note + +note left of MainXML::get + Generates the main XML for the plugin. + + since: 5.0.2 + return: string +end note + +note right of MainXML::buildConfigFields + Build configuration fields XML. + + since: 5.0.2 + return: array +end note + +note left of MainXML::shouldAddComponentPath + Determine if the component path should be added. + + since: 5.0.2 + return: bool +end note + +note right of MainXML::generateScriptAndSqlXml + Generate XML for script and SQL files. + + since: 5.0.2 + return: string +end note + +note left of MainXML::generateLanguageXml + Generate XML for language files. + + since: 5.0.2 + return: string +end note + +note right of MainXML::generateFileXml + Generate the XML for the files. + + since: 5.0.2 + return: string +end note + +note left of MainXML::generateConfigXml + Generate XML for configuration fields. + + since: 5.0.2 + return: string + + arguments: + object $plugin + array $configFields + bool $addComponentPath +end note + +note right of MainXML::generateUpdateServerXml + Generate XML for update servers. + + since: 5.0.2 + return: string +end note + +note left of MainXML::generateLanguageFiles + Generate language files. + + since: 5.0.2 + return: array +end note + +@enduml +``` + +The Power feature in JCB allows you to write PHP classes and their implementations, making it easy to include them in your Joomla project. JCB handles linking, autoloading, namespacing, and folder structure creation for you. + +By using the SPK (Super Power Key) in your custom code (replacing the class name in your code with the SPK), JCB will automatically pull the power from the repository into your project. This makes it available in your JCB instance, allowing you to edit it and include the class in your generated Joomla component. + +JCB uses placeholders like [[[`NamespacePrefix`]]] and [[[`ComponentNamespace`]]] in namespacing to prevent collisions and improve reusability across different JCB systems. You can also set the **JCB powers path** globally or per component under the **Dynamic Integration** tab, providing flexibility and easy maintainability. + +To add this specific Power to your project in JCB: + +> simply use this SPK +``` +Super---54e05f58_6538_42ec_ba46_b136f33e7cc7---Power +``` +> remember to replace the `---` with `___` to activate this Power in your code + +--- +``` + ██╗ ██████╗██████╗ + ██║██╔════╝██╔══██╗ + ██║██║ ██████╔╝ +██ ██║██║ ██╔══██╗ +╚█████╔╝╚██████╗██████╔╝ + ╚════╝ ╚═════╝╚═════╝ +``` +> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder) + diff --git a/src/54e05f58-6538-42ec-ba46-b136f33e7cc7/code.php b/src/54e05f58-6538-42ec-ba46-b136f33e7cc7/code.php new file mode 100644 index 0000000..28b9ea7 --- /dev/null +++ b/src/54e05f58-6538-42ec-ba46-b136f33e7cc7/code.php @@ -0,0 +1,570 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaThree\Plugin; + + +use Joomla\CMS\Filesystem\Folder; +use VDM\Joomla\Componentbuilder\Compiler\Config; +use VDM\Joomla\Componentbuilder\Compiler\Language; +use VDM\Joomla\Componentbuilder\Compiler\Language\Set; +use VDM\Joomla\Componentbuilder\Compiler\Language\Purge; +use VDM\Joomla\Componentbuilder\Compiler\Language\Translation; +use VDM\Joomla\Componentbuilder\Compiler\Language\Multilingual; +use VDM\Joomla\Componentbuilder\Compiler\Interfaces\EventInterface as Event; +use VDM\Joomla\Componentbuilder\Compiler\Creator\FieldsetExtension; +use VDM\Joomla\Componentbuilder\Compiler\Builder\ContentOne; +use VDM\Joomla\Componentbuilder\Compiler\Builder\Languages; +use VDM\Joomla\Componentbuilder\Compiler\Builder\Multilingual as BuilderMultilingual; +use VDM\Joomla\Componentbuilder\Compiler\Utilities\Counter; +use VDM\Joomla\Componentbuilder\Compiler\Utilities\File; +use VDM\Joomla\Componentbuilder\Compiler\Utilities\Line; +use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent; +use VDM\Joomla\Utilities\ArrayHelper; +use VDM\Joomla\Utilities\StringHelper; +use VDM\Joomla\Componentbuilder\Interfaces\Architecture\Plugin\MainXMLInterface; + + +/** + * Joomla 3 Plugin Main XML Class + * + * @since 5.0.2 + */ +final class MainXML implements MainXMLInterface +{ + /** + * The Config Class. + * + * @var Config + * @since 5.0.2 + */ + protected Config $config; + + /** + * The Language Class. + * + * @var Language + * @since 5.0.2 + */ + protected Language $language; + + /** + * The Set Class. + * + * @var Set + * @since 5.0.2 + */ + protected Set $set; + + /** + * The Purge Class. + * + * @var Purge + * @since 5.0.2 + */ + protected Purge $purge; + + /** + * The Translation Class. + * + * @var Translation + * @since 5.0.2 + */ + protected Translation $translation; + + /** + * The Multilingual Class. + * + * @var Multilingual + * @since 5.0.2 + */ + protected Multilingual $multilingual; + + /** + * The EventInterface Class. + * + * @var Event + * @since 5.0.2 + */ + protected Event $event; + + /** + * The FieldsetExtension Class. + * + * @var FieldsetExtension + * @since 5.0.2 + */ + protected FieldsetExtension $fieldsetextension; + + /** + * The ContentOne Class. + * + * @var ContentOne + * @since 5.0.2 + */ + protected ContentOne $contentone; + + /** + * The Languages Class. + * + * @var Languages + * @since 5.0.2 + */ + protected Languages $languages; + + /** + * The Multilingual Class. + * + * @var BuilderMultilingual + * @since 5.0.2 + */ + protected BuilderMultilingual $buildermultilingual; + + /** + * The Counter Class. + * + * @var Counter + * @since 5.0.2 + */ + protected Counter $counter; + + /** + * The File Class. + * + * @var File + * @since 5.0.2 + */ + protected File $file; + + /** + * Constructor. + * + * @param Config $config The Config Class. + * @param Language $language The Language Class. + * @param Set $set The Set Class. + * @param Purge $purge The Purge Class. + * @param Translation $translation The Translation Class. + * @param Multilingual $multilingual The Multilingual Class. + * @param Event $event The EventInterface Class. + * @param FieldsetExtension $fieldsetextension The FieldsetExtension Class. + * @param ContentOne $contentone The ContentOne Class. + * @param Languages $languages The Languages Class. + * @param BuilderMultilingual $buildermultilingual The Multilingual Class. + * @param Counter $counter The Counter Class. + * @param File $file The File Class. + * + * @since 5.0.2 + */ + public function __construct(Config $config, Language $language, Set $set, Purge $purge, + Translation $translation, Multilingual $multilingual, + Event $event, FieldsetExtension $fieldsetextension, + ContentOne $contentone, Languages $languages, + BuilderMultilingual $buildermultilingual, + Counter $counter, File $file) + { + $this->config = $config; + $this->language = $language; + $this->set = $set; + $this->purge = $purge; + $this->translation = $translation; + $this->multilingual = $multilingual; + $this->event = $event; + $this->fieldsetextension = $fieldsetextension; + $this->contentone = $contentone; + $this->languages = $languages; + $this->buildermultilingual = $buildermultilingual; + $this->counter = $counter; + $this->file = $file; + } + + /** + * Generates the main XML for the plugin. + * + * @param object $plugin The plugin object. + * + * @return string The generated XML. + * @since 5.0.2 + */ + public function get(object $plugin): string + { + $config_fields = $this->buildConfigFields($plugin); + $add_component_path = $this->shouldAddComponentPath($plugin); + $language_files = $this->generateLanguageFiles($plugin); + + $xml = $this->generateScriptAndSqlXml($plugin); + $xml .= $this->generateLanguageXml($plugin, $language_files); + $xml .= $this->generateFileXml($plugin, $language_files); + $xml .= $this->generateConfigXml($plugin, $config_fields, $add_component_path); + $xml .= $this->generateUpdateServerXml($plugin); + + return $xml; + } + + /** + * Build configuration fields XML. + * + * @param object $plugin The plugin object. + * + * @return array The configuration fields. + * @since 5.0.2 + */ + protected function buildConfigFields(object $plugin): array + { + $configFields = []; + if (!isset($plugin->config_fields) || !ArrayHelper::check($plugin->config_fields)) + { + return $configFields; + } + + $dbKey = 'yy'; + + foreach ($plugin->config_fields as $fieldName => $fieldsets) + { + foreach ($fieldsets as $fieldset => $fields) + { + $xmlFields = $this->fieldsetextension->get($plugin, $fields, $dbKey); + if (isset($xmlFields) && StringHelper::check($xmlFields)) + { + $configFields["{$fieldName}{$fieldset}"] = $xmlFields; + } + $dbKey++; + } + } + + return $configFields; + } + + /** + * Determine if the component path should be added. + * + * @param object $plugin The plugin object. + * + * @return bool True if the component path should be added, false otherwise. + * @since 5.0.2 + */ + protected function shouldAddComponentPath(object $plugin): bool + { + if (!isset($plugin->config_fields) || !ArrayHelper::check($plugin->config_fields) || + !isset($plugin->fieldsets_paths) || !ArrayHelper::check($plugin->fieldsets_paths)) + { + return false; + } + + foreach ($plugin->config_fields as $fieldName => $fieldsets) + { + foreach ($fieldsets as $fieldset => $fields) + { + if (isset($plugin->fieldsets_paths["{$fieldName}{$fieldset}"]) && + $plugin->fieldsets_paths["{$fieldName}{$fieldset}"] == 1) + { + return true; + } + } + } + + return false; + } + + /** + * Generate XML for script and SQL files. + * + * @param object $plugin The plugin object. + * + * @return string The XML for script and SQL files. + * @since 5.0.2 + */ + protected function generateScriptAndSqlXml(object $plugin): string + { + $xml = ''; + + if ($plugin->add_install_script) + { + $xml .= PHP_EOL . PHP_EOL . Indent::_(1) . ''; + $xml .= PHP_EOL . Indent::_(1) . 'script.php'; + } + + if ($plugin->add_sql) + { + $xml .= PHP_EOL . PHP_EOL . Indent::_(1) . ''; + $xml .= PHP_EOL . Indent::_(1) . ''; + $xml .= PHP_EOL . Indent::_(2) . ''; + $xml .= PHP_EOL . Indent::_(3) . 'sql/mysql/install.sql'; + $xml .= PHP_EOL . Indent::_(2) . ''; + $xml .= PHP_EOL . Indent::_(1) . ''; + } + + if ($plugin->add_sql_uninstall) + { + $xml .= PHP_EOL . PHP_EOL . Indent::_(1) . ''; + $xml .= PHP_EOL . Indent::_(1) . ''; + $xml .= PHP_EOL . Indent::_(2) . ''; + $xml .= PHP_EOL . Indent::_(3) . 'sql/mysql/uninstall.sql'; + $xml .= PHP_EOL . Indent::_(2) . ''; + $xml .= PHP_EOL . Indent::_(1) . ''; + } + + return $xml; + } + + /** + * Generate XML for language files. + * + * @param object $plugin The plugin object. + * @param array $languageFiles The language files. + * + * @return string The XML for language files. + * @since 5.0.2 + */ + protected function generateLanguageXml(object $plugin, array $languageFiles): string + { + $xml = ''; + + if (ArrayHelper::check($languageFiles)) + { + $xml .= PHP_EOL . PHP_EOL . Indent::_(1) . ''; + $xml .= PHP_EOL . Indent::_(1) . ''; + + foreach ($languageFiles as $addTag) + { + $xml .= PHP_EOL . Indent::_(2) . '' . $addTag . '/' . $addTag . '.plg_' + . strtolower((string) $plugin->group) . '_' . strtolower( + (string) $plugin->code_name + ) . '.ini'; + $xml .= PHP_EOL . Indent::_(2) . '' . $addTag . '/' . $addTag . '.plg_' + . strtolower((string) $plugin->group) . '_' . strtolower( + (string) $plugin->code_name + ) . '.sys.ini'; + } + $xml .= PHP_EOL . Indent::_(1) . ''; + } + + return $xml; + } + + /** + * Generate the XML for the files. + * + * @param object $plugin The plugin object. + * @param array $languageFiles The language files. + * + * @return string The XML for the files. + * @since 5.0.2 + */ + protected function generateFileXml(object $plugin, array $languageFiles): string + { + $files = Folder::files($plugin->folder_path); + $folders = Folder::folders($plugin->folder_path); + $ignore = ['sql', 'language', 'script.php', "{$plugin->file_name}.xml", "{$plugin->file_name}.php"]; + + $xml = PHP_EOL . PHP_EOL . Indent::_(1) . ''; + $xml .= PHP_EOL . Indent::_(1) . ''; + $xml .= PHP_EOL . Indent::_(2) . "file_name}\">{$plugin->file_name}.php"; + + foreach ($files as $file) + { + if (!in_array($file, $ignore)) + { + $xml .= PHP_EOL . Indent::_(2) . "{$file}"; + } + } + + if (!empty($languageFiles)) + { + $xml .= PHP_EOL . Indent::_(2) . 'language'; + } + + if ($plugin->add_sql || $plugin->add_sql_uninstall) + { + $xml .= PHP_EOL . Indent::_(2) . 'sql'; + } + + foreach ($folders as $folder) + { + if (!in_array($folder, $ignore)) + { + $xml .= PHP_EOL . Indent::_(2) . "{$folder}"; + } + } + + $xml .= PHP_EOL . Indent::_(1) . ''; + + return $xml; + } + + /** + * Generate XML for configuration fields. + * + * @param object $plugin The plugin object. + * @param array $configFields The configuration fields. + * @param bool $addComponentPath Whether to add the component path. + * + * @return string The XML for configuration fields. + * @since 5.0.2 + */ + protected function generateConfigXml(object $plugin, array $configFields, bool $addComponentPath): string + { + if (!isset($plugin->config_fields) || !ArrayHelper::check($configFields)) + { + return ''; + } + + $xml = PHP_EOL . PHP_EOL . Indent::_(1) . ''; + $xml .= $addComponentPath ? PHP_EOL . Indent::_(1) . ''; + + if ($addComponentPath) + { + $xml .= PHP_EOL . Indent::_(2) . 'addrulepath="/administrator/components/com_' . $this->config->component_code_name . '/models/rules"'; + $xml .= PHP_EOL . Indent::_(2) . 'addfieldpath="/administrator/components/com_' . $this->config->component_code_name . '/models/fields"'; + + $xml .= PHP_EOL . Indent::_(1) . '>'; + } + + foreach ($plugin->config_fields as $fieldName => $fieldsets) + { + $xml .= PHP_EOL . Indent::_(1) . ""; + + foreach ($fieldsets as $fieldset => $fields) + { + $label = $plugin->fieldsets_label["{$fieldName}{$fieldset}"] ?? $fieldset; + + $xml .= PHP_EOL . Indent::_(1) . "
"; + + if (isset($configFields["{$fieldName}{$fieldset}"])) + { + $xml .= $configFields["{$fieldName}{$fieldset}"]; + } + + $xml .= PHP_EOL . Indent::_(1) . '
'; + } + + $xml .= PHP_EOL . Indent::_(1) . '
'; + } + + $xml .= PHP_EOL . Indent::_(1) . ''; + + return $xml; + } + + /** + * Generate XML for update servers. + * + * @param object $plugin The plugin object. + * + * @return string The XML for update servers. + * @since 5.0.2 + */ + protected function generateUpdateServerXml(object $plugin): string + { + $xml = ''; + + if ($plugin->add_update_server) + { + $xml = PHP_EOL . PHP_EOL . Indent::_(1) . ''; + $xml .= PHP_EOL . Indent::_(1) . ''; + $xml .= PHP_EOL . Indent::_(2) . '' . $plugin->update_server_url . ''; + $xml .= PHP_EOL . Indent::_(1) . ''; + } + + return $xml; + } + + /** + * Generate language files. + * + * @param object $plugin The plugin object. + * + * @return array The language files. + * @since 5.0.2 + */ + protected function generateLanguageFiles(object $plugin): array + { + $languageFiles = []; + + if (!$this->language->exist($plugin->key)) + { + return $languageFiles; + } + + $langContent = $this->language->getTarget($plugin->key); + $this->event->trigger('jcb_ce_onBeforeBuildPluginLang', [&$plugin, &$langContent]); + + $values = array_unique($langContent); + $this->buildermultilingual->set('plugins', $this->multilingual->get($values)); + + $langTag = $this->config->get('lang_tag', 'en-GB'); + $this->languages->set("plugins.{$langTag}.all", $langContent); + $this->language->setTarget($plugin->key, null); + + $this->set->execute($values, $plugin->id, 'plugins'); + $this->purge->execute($values, $plugin->id, 'plugins'); + + $this->event->trigger('jcb_ce_onBeforeBuildPluginLangFiles', [&$plugin]); + + if ($this->languages->IsArray('plugins')) + { + foreach ($this->languages->get('plugins') as $tag => $areas) + { + $tag = trim($tag); + foreach ($areas as $area => $languageStrings) + { + $fileName = "{$tag}.plg_" . strtolower((string)$plugin->group) . '_' . strtolower((string)$plugin->code_name) . '.ini'; + $total = count($values); + if ($this->translation->check($tag, $languageStrings, $total, $fileName)) + { + $lang = array_map( + fn($langString, $placeholder) => "{$placeholder}=\"{$langString}\"", + array_values($languageStrings), + array_keys($languageStrings) + ); + + $path = "{$plugin->folder_path}/language/{$tag}/"; + + if (!Folder::exists($path)) + { + Folder::create($path); + $this->counter->folder++; + } + + $this->file->write($path . $fileName, implode(PHP_EOL, $lang)); + $this->file->write( + $path . $tag . '.plg_' . strtolower((string)$plugin->group) . '_' . strtolower((string)$plugin->code_name) . '.sys.ini', + implode(PHP_EOL, $lang) + ); + + $this->counter->line += count($lang); + unset($lang); + + $languageFiles[$tag] = $tag; + } + } + } + } + + return $languageFiles; + } +} + diff --git a/src/54e05f58-6538-42ec-ba46-b136f33e7cc7/code.power b/src/54e05f58-6538-42ec-ba46-b136f33e7cc7/code.power new file mode 100644 index 0000000..63399a8 --- /dev/null +++ b/src/54e05f58-6538-42ec-ba46-b136f33e7cc7/code.power @@ -0,0 +1,526 @@ + /** + * The Config Class. + * + * @var Config + * @since 5.0.2 + */ + protected Config $config; + + /** + * The Language Class. + * + * @var Language + * @since 5.0.2 + */ + protected Language $language; + + /** + * The Set Class. + * + * @var Set + * @since 5.0.2 + */ + protected Set $set; + + /** + * The Purge Class. + * + * @var Purge + * @since 5.0.2 + */ + protected Purge $purge; + + /** + * The Translation Class. + * + * @var Translation + * @since 5.0.2 + */ + protected Translation $translation; + + /** + * The Multilingual Class. + * + * @var Multilingual + * @since 5.0.2 + */ + protected Multilingual $multilingual; + + /** + * The EventInterface Class. + * + * @var Event + * @since 5.0.2 + */ + protected Event $event; + + /** + * The FieldsetExtension Class. + * + * @var FieldsetExtension + * @since 5.0.2 + */ + protected FieldsetExtension $fieldsetextension; + + /** + * The ContentOne Class. + * + * @var ContentOne + * @since 5.0.2 + */ + protected ContentOne $contentone; + + /** + * The Languages Class. + * + * @var Languages + * @since 5.0.2 + */ + protected Languages $languages; + + /** + * The Multilingual Class. + * + * @var BuilderMultilingual + * @since 5.0.2 + */ + protected BuilderMultilingual $buildermultilingual; + + /** + * The Counter Class. + * + * @var Counter + * @since 5.0.2 + */ + protected Counter $counter; + + /** + * The File Class. + * + * @var File + * @since 5.0.2 + */ + protected File $file; + + /** + * Constructor. + * + * @param Config $config The Config Class. + * @param Language $language The Language Class. + * @param Set $set The Set Class. + * @param Purge $purge The Purge Class. + * @param Translation $translation The Translation Class. + * @param Multilingual $multilingual The Multilingual Class. + * @param Event $event The EventInterface Class. + * @param FieldsetExtension $fieldsetextension The FieldsetExtension Class. + * @param ContentOne $contentone The ContentOne Class. + * @param Languages $languages The Languages Class. + * @param BuilderMultilingual $buildermultilingual The Multilingual Class. + * @param Counter $counter The Counter Class. + * @param File $file The File Class. + * + * @since 5.0.2 + */ + public function __construct(Config $config, Language $language, Set $set, Purge $purge, + Translation $translation, Multilingual $multilingual, + Event $event, FieldsetExtension $fieldsetextension, + ContentOne $contentone, Languages $languages, + BuilderMultilingual $buildermultilingual, + Counter $counter, File $file) + { + $this->config = $config; + $this->language = $language; + $this->set = $set; + $this->purge = $purge; + $this->translation = $translation; + $this->multilingual = $multilingual; + $this->event = $event; + $this->fieldsetextension = $fieldsetextension; + $this->contentone = $contentone; + $this->languages = $languages; + $this->buildermultilingual = $buildermultilingual; + $this->counter = $counter; + $this->file = $file; + } + + /** + * Generates the main XML for the plugin. + * + * @param object $plugin The plugin object. + * + * @return string The generated XML. + * @since 5.0.2 + */ + public function get(object $plugin): string + { + $config_fields = $this->buildConfigFields($plugin); + $add_component_path = $this->shouldAddComponentPath($plugin); + $language_files = $this->generateLanguageFiles($plugin); + + $xml = $this->generateScriptAndSqlXml($plugin); + $xml .= $this->generateLanguageXml($plugin, $language_files); + $xml .= $this->generateFileXml($plugin, $language_files); + $xml .= $this->generateConfigXml($plugin, $config_fields, $add_component_path); + $xml .= $this->generateUpdateServerXml($plugin); + + return $xml; + } + + /** + * Build configuration fields XML. + * + * @param object $plugin The plugin object. + * + * @return array The configuration fields. + * @since 5.0.2 + */ + protected function buildConfigFields(object $plugin): array + { + $configFields = []; + if (!isset($plugin->config_fields) || !ArrayHelper::check($plugin->config_fields)) + { + return $configFields; + } + + $dbKey = 'yy'; + + foreach ($plugin->config_fields as $fieldName => $fieldsets) + { + foreach ($fieldsets as $fieldset => $fields) + { + $xmlFields = $this->fieldsetextension->get($plugin, $fields, $dbKey); + if (isset($xmlFields) && StringHelper::check($xmlFields)) + { + $configFields["{$fieldName}{$fieldset}"] = $xmlFields; + } + $dbKey++; + } + } + + return $configFields; + } + + /** + * Determine if the component path should be added. + * + * @param object $plugin The plugin object. + * + * @return bool True if the component path should be added, false otherwise. + * @since 5.0.2 + */ + protected function shouldAddComponentPath(object $plugin): bool + { + if (!isset($plugin->config_fields) || !ArrayHelper::check($plugin->config_fields) || + !isset($plugin->fieldsets_paths) || !ArrayHelper::check($plugin->fieldsets_paths)) + { + return false; + } + + foreach ($plugin->config_fields as $fieldName => $fieldsets) + { + foreach ($fieldsets as $fieldset => $fields) + { + if (isset($plugin->fieldsets_paths["{$fieldName}{$fieldset}"]) && + $plugin->fieldsets_paths["{$fieldName}{$fieldset}"] == 1) + { + return true; + } + } + } + + return false; + } + + /** + * Generate XML for script and SQL files. + * + * @param object $plugin The plugin object. + * + * @return string The XML for script and SQL files. + * @since 5.0.2 + */ + protected function generateScriptAndSqlXml(object $plugin): string + { + $xml = ''; + + if ($plugin->add_install_script) + { + $xml .= PHP_EOL . PHP_EOL . Indent::_(1) . ''; + $xml .= PHP_EOL . Indent::_(1) . 'script.php'; + } + + if ($plugin->add_sql) + { + $xml .= PHP_EOL . PHP_EOL . Indent::_(1) . ''; + $xml .= PHP_EOL . Indent::_(1) . ''; + $xml .= PHP_EOL . Indent::_(2) . ''; + $xml .= PHP_EOL . Indent::_(3) . 'sql/mysql/install.sql'; + $xml .= PHP_EOL . Indent::_(2) . ''; + $xml .= PHP_EOL . Indent::_(1) . ''; + } + + if ($plugin->add_sql_uninstall) + { + $xml .= PHP_EOL . PHP_EOL . Indent::_(1) . ''; + $xml .= PHP_EOL . Indent::_(1) . ''; + $xml .= PHP_EOL . Indent::_(2) . ''; + $xml .= PHP_EOL . Indent::_(3) . 'sql/mysql/uninstall.sql'; + $xml .= PHP_EOL . Indent::_(2) . ''; + $xml .= PHP_EOL . Indent::_(1) . ''; + } + + return $xml; + } + + /** + * Generate XML for language files. + * + * @param object $plugin The plugin object. + * @param array $languageFiles The language files. + * + * @return string The XML for language files. + * @since 5.0.2 + */ + protected function generateLanguageXml(object $plugin, array $languageFiles): string + { + $xml = ''; + + if (ArrayHelper::check($languageFiles)) + { + $xml .= PHP_EOL . PHP_EOL . Indent::_(1) . ''; + $xml .= PHP_EOL . Indent::_(1) . ''; + + foreach ($languageFiles as $addTag) + { + $xml .= PHP_EOL . Indent::_(2) . '' . $addTag . '/' . $addTag . '.plg_' + . strtolower((string) $plugin->group) . '_' . strtolower( + (string) $plugin->code_name + ) . '.ini'; + $xml .= PHP_EOL . Indent::_(2) . '' . $addTag . '/' . $addTag . '.plg_' + . strtolower((string) $plugin->group) . '_' . strtolower( + (string) $plugin->code_name + ) . '.sys.ini'; + } + $xml .= PHP_EOL . Indent::_(1) . ''; + } + + return $xml; + } + + /** + * Generate the XML for the files. + * + * @param object $plugin The plugin object. + * @param array $languageFiles The language files. + * + * @return string The XML for the files. + * @since 5.0.2 + */ + protected function generateFileXml(object $plugin, array $languageFiles): string + { + $files = Folder::files($plugin->folder_path); + $folders = Folder::folders($plugin->folder_path); + $ignore = ['sql', 'language', 'script.php', "{$plugin->file_name}.xml", "{$plugin->file_name}.php"]; + + $xml = PHP_EOL . PHP_EOL . Indent::_(1) . ''; + $xml .= PHP_EOL . Indent::_(1) . ''; + $xml .= PHP_EOL . Indent::_(2) . "file_name}\">{$plugin->file_name}.php"; + + foreach ($files as $file) + { + if (!in_array($file, $ignore)) + { + $xml .= PHP_EOL . Indent::_(2) . "{$file}"; + } + } + + if (!empty($languageFiles)) + { + $xml .= PHP_EOL . Indent::_(2) . 'language'; + } + + if ($plugin->add_sql || $plugin->add_sql_uninstall) + { + $xml .= PHP_EOL . Indent::_(2) . 'sql'; + } + + foreach ($folders as $folder) + { + if (!in_array($folder, $ignore)) + { + $xml .= PHP_EOL . Indent::_(2) . "{$folder}"; + } + } + + $xml .= PHP_EOL . Indent::_(1) . ''; + + return $xml; + } + + /** + * Generate XML for configuration fields. + * + * @param object $plugin The plugin object. + * @param array $configFields The configuration fields. + * @param bool $addComponentPath Whether to add the component path. + * + * @return string The XML for configuration fields. + * @since 5.0.2 + */ + protected function generateConfigXml(object $plugin, array $configFields, bool $addComponentPath): string + { + if (!isset($plugin->config_fields) || !ArrayHelper::check($configFields)) + { + return ''; + } + + $xml = PHP_EOL . PHP_EOL . Indent::_(1) . ''; + $xml .= $addComponentPath ? PHP_EOL . Indent::_(1) . ''; + + if ($addComponentPath) + { + $xml .= PHP_EOL . Indent::_(2) . 'addrulepath="/administrator/components/com_' . $this->config->component_code_name . '/models/rules"'; + $xml .= PHP_EOL . Indent::_(2) . 'addfieldpath="/administrator/components/com_' . $this->config->component_code_name . '/models/fields"'; + + $xml .= PHP_EOL . Indent::_(1) . '>'; + } + + foreach ($plugin->config_fields as $fieldName => $fieldsets) + { + $xml .= PHP_EOL . Indent::_(1) . ""; + + foreach ($fieldsets as $fieldset => $fields) + { + $label = $plugin->fieldsets_label["{$fieldName}{$fieldset}"] ?? $fieldset; + + $xml .= PHP_EOL . Indent::_(1) . "
"; + + if (isset($configFields["{$fieldName}{$fieldset}"])) + { + $xml .= $configFields["{$fieldName}{$fieldset}"]; + } + + $xml .= PHP_EOL . Indent::_(1) . '
'; + } + + $xml .= PHP_EOL . Indent::_(1) . '
'; + } + + $xml .= PHP_EOL . Indent::_(1) . ''; + + return $xml; + } + + /** + * Generate XML for update servers. + * + * @param object $plugin The plugin object. + * + * @return string The XML for update servers. + * @since 5.0.2 + */ + protected function generateUpdateServerXml(object $plugin): string + { + $xml = ''; + + if ($plugin->add_update_server) + { + $xml = PHP_EOL . PHP_EOL . Indent::_(1) . ''; + $xml .= PHP_EOL . Indent::_(1) . ''; + $xml .= PHP_EOL . Indent::_(2) . '' . $plugin->update_server_url . ''; + $xml .= PHP_EOL . Indent::_(1) . ''; + } + + return $xml; + } + + /** + * Generate language files. + * + * @param object $plugin The plugin object. + * + * @return array The language files. + * @since 5.0.2 + */ + protected function generateLanguageFiles(object $plugin): array + { + $languageFiles = []; + + if (!$this->language->exist($plugin->key)) + { + return $languageFiles; + } + + $langContent = $this->language->getTarget($plugin->key); + $this->event->trigger('jcb_ce_onBeforeBuildPluginLang', [&$plugin, &$langContent]); + + $values = array_unique($langContent); + $this->buildermultilingual->set('plugins', $this->multilingual->get($values)); + + $langTag = $this->config->get('lang_tag', 'en-GB'); + $this->languages->set("plugins.{$langTag}.all", $langContent); + $this->language->setTarget($plugin->key, null); + + $this->set->execute($values, $plugin->id, 'plugins'); + $this->purge->execute($values, $plugin->id, 'plugins'); + + $this->event->trigger('jcb_ce_onBeforeBuildPluginLangFiles', [&$plugin]); + + if ($this->languages->IsArray('plugins')) + { + foreach ($this->languages->get('plugins') as $tag => $areas) + { + $tag = trim($tag); + foreach ($areas as $area => $languageStrings) + { + $fileName = "{$tag}.plg_" . strtolower((string)$plugin->group) . '_' . strtolower((string)$plugin->code_name) . '.ini'; + $total = count($values); + if ($this->translation->check($tag, $languageStrings, $total, $fileName)) + { + $lang = array_map( + fn($langString, $placeholder) => "{$placeholder}=\"{$langString}\"", + array_values($languageStrings), + array_keys($languageStrings) + ); + + $path = "{$plugin->folder_path}/language/{$tag}/"; + + if (!Folder::exists($path)) + { + Folder::create($path); + $this->counter->folder++; + } + + $this->file->write($path . $fileName, implode(PHP_EOL, $lang)); + $this->file->write( + $path . $tag . '.plg_' . strtolower((string)$plugin->group) . '_' . strtolower((string)$plugin->code_name) . '.sys.ini', + implode(PHP_EOL, $lang) + ); + + $this->counter->line += count($lang); + unset($lang); + + $languageFiles[$tag] = $tag; + } + } + } + } + + return $languageFiles; + } \ No newline at end of file diff --git a/src/54e05f58-6538-42ec-ba46-b136f33e7cc7/settings.json b/src/54e05f58-6538-42ec-ba46-b136f33e7cc7/settings.json new file mode 100644 index 0000000..57fcc89 --- /dev/null +++ b/src/54e05f58-6538-42ec-ba46-b136f33e7cc7/settings.json @@ -0,0 +1,90 @@ +{ + "add_head": "1", + "add_licensing_template": "2", + "extends": "", + "guid": "54e05f58-6538-42ec-ba46-b136f33e7cc7", + "implements": [ + "97177ca9-a51a-4d24-81e1-8747b6e7d76c" + ], + "load_selection": null, + "name": "MainXML", + "power_version": "1.0.0", + "system_name": "JCB.Architecture.J3.Plugin.MainXML", + "type": "final class", + "use_selection": { + "use_selection0": { + "use": "fa4bf18e-301e-42e3-91fb-6e0096c07adc", + "as": "default" + }, + "use_selection1": { + "use": "8eee7df5-2775-41a9-9372-c46c5939a252", + "as": "default" + }, + "use_selection2": { + "use": "058cfcd7-1f84-4cc6-8bcc-7672f316881d", + "as": "default" + }, + "use_selection3": { + "use": "0b0e574c-aab4-4eaf-96d8-d7210d8ed93e", + "as": "default" + }, + "use_selection4": { + "use": "344d36be-3949-4848-8cb0-e3d3d9d05c36", + "as": "default" + }, + "use_selection5": { + "use": "263f0227-3cc2-4a88-9818-edb20081c30c", + "as": "default" + }, + "use_selection6": { + "use": "20ed72b0-fcac-4344-aee1-8a65e3bf221d", + "as": "Event" + }, + "use_selection7": { + "use": "23f459a4-7c2a-4cbf-b0a6-8a11954140a9", + "as": "default" + }, + "use_selection8": { + "use": "adfbe68a-6d22-43e5-aee8-2787e8c47e75", + "as": "default" + }, + "use_selection9": { + "use": "7526a39a-ada3-4499-8d75-81beff33f949", + "as": "default" + }, + "use_selection10": { + "use": "a8c6158a-6fd2-476b-a5ea-c81f1ecd2356", + "as": "BuilderMultilingual" + }, + "use_selection11": { + "use": "e6d871a6-bbe7-497d-af01-68f6bb9a87f4", + "as": "default" + }, + "use_selection12": { + "use": "5c75b455-3d4c-452a-867e-e90424a64c88", + "as": "default" + }, + "use_selection13": { + "use": "4e6ff11d-bebf-42f5-8fd7-b2f882857222", + "as": "default" + }, + "use_selection14": { + "use": "a68c010b-e92e-47d5-8a44-d23cfddeb6c6", + "as": "default" + }, + "use_selection15": { + "use": "0a59c65c-9daf-4bc9-baf4-e063ff9e6a8a", + "as": "default" + }, + "use_selection16": { + "use": "1f28cb53-60d9-4db1-b517-3c7dc6b429ef", + "as": "default" + } + }, + "extendsinterfaces": null, + "namespace": "[[[NamespacePrefix]]]\\Joomla\\[[[ComponentNamespace]]].Compiler.Architecture.JoomlaThree.Plugin.MainXML", + "description": "Joomla 3 Plugin Main XML Class\r\n\r\n@since 5.0.2", + "licensing_template": "\/**\r\n * @package Joomla.Component.Builder\r\n *\r\n * @created 4th September, 2022\r\n * @author Llewellyn van der Merwe \r\n * @git Joomla Component Builder \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\\Filesystem\\Folder;", + "composer": "" +} \ No newline at end of file diff --git a/src/60c3ccc5-36dc-4480-b5c4-252c37212f61/README.md b/src/60c3ccc5-36dc-4480-b5c4-252c37212f61/README.md new file mode 100644 index 0000000..4dc7f22 --- /dev/null +++ b/src/60c3ccc5-36dc-4480-b5c4-252c37212f61/README.md @@ -0,0 +1,61 @@ +``` +██████╗ ██████╗ ██╗ ██╗███████╗██████╗ +██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗ +██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝ +██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗ +██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║ +╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝ +``` +# final class Provider (Details) +> namespace: **VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaFour\Plugin** + +```uml +@startuml +class Provider << (F,LightGreen) >> #RoyalBlue { + # Placeholder $placeholder + # Builder $builder + + __construct(Placeholder $placeholder, Builder $builder) + + get(object $plugin) : string +} + +note right of Provider::__construct + Constructor. + + since: 5.0.2 +end note + +note right of Provider::get + Get the updated provider for the given plugin. + + since: 5.0.2 + return: string +end note + +@enduml +``` + +The Power feature in JCB allows you to write PHP classes and their implementations, making it easy to include them in your Joomla project. JCB handles linking, autoloading, namespacing, and folder structure creation for you. + +By using the SPK (Super Power Key) in your custom code (replacing the class name in your code with the SPK), JCB will automatically pull the power from the repository into your project. This makes it available in your JCB instance, allowing you to edit it and include the class in your generated Joomla component. + +JCB uses placeholders like [[[`NamespacePrefix`]]] and [[[`ComponentNamespace`]]] in namespacing to prevent collisions and improve reusability across different JCB systems. You can also set the **JCB powers path** globally or per component under the **Dynamic Integration** tab, providing flexibility and easy maintainability. + +To add this specific Power to your project in JCB: + +> simply use this SPK +``` +Super---60c3ccc5_36dc_4480_b5c4_252c37212f61---Power +``` +> remember to replace the `---` with `___` to activate this Power in your code + +--- +``` + ██╗ ██████╗██████╗ + ██║██╔════╝██╔══██╗ + ██║██║ ██████╔╝ +██ ██║██║ ██╔══██╗ +╚█████╔╝╚██████╗██████╔╝ + ╚════╝ ╚═════╝╚═════╝ +``` +> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder) + diff --git a/src/60c3ccc5-36dc-4480-b5c4-252c37212f61/code.php b/src/60c3ccc5-36dc-4480-b5c4-252c37212f61/code.php new file mode 100644 index 0000000..c431dbc --- /dev/null +++ b/src/60c3ccc5-36dc-4480-b5c4-252c37212f61/code.php @@ -0,0 +1,106 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaFour\Plugin; + + +use VDM\Joomla\Componentbuilder\Compiler\Placeholder; +use VDM\Joomla\Componentbuilder\Compiler\Builder\ContentOne as Builder; +use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent; +use VDM\Joomla\Componentbuilder\Compiler\Utilities\Line; +use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Architecture\Plugin\ProviderInterface; + + +/** + * Plugin Provider Class for Joomla 4 + * + * @since 5.0.2 + */ +final class Provider implements ProviderInterface +{ + /** + * The Placeholder Class. + * + * @var Placeholder + * @since 5.0.2 + */ + protected Placeholder $placeholder; + + /** + * The ContentOne Class. + * + * @var Builder + * @since 5.0.2 + */ + protected Builder $builder; + + /** + * Constructor. + * + * @param Placeholder $placeholder The Placeholder Class. + * @param Builder $builder The Content One Class. + * + * @since 5.0.2 + */ + public function __construct(Placeholder $placeholder, Builder $builder) + { + $this->placeholder = $placeholder; + $this->builder = $builder; + } + + /** + * Get the updated provider for the given plugin. + * + * @param object $plugin The plugin object containing the necessary data. + * + * @return string The provider content. + * + * @since 5.0.2 + */ + public function get(object $plugin): string + { + $group = strtolower((string) $plugin->group); + + $provider = []; + $provider[] = PHP_EOL . PHP_EOL . "return new class () implements ServiceProviderInterface {"; + $provider[] = Indent::_(1) . "/**"; + $provider[] = Indent::_(1) . "*" . Line::_(__Line__, __Class__) + . " Registers the service provider with a DI container."; + $provider[] = Indent::_(1) . "*"; + $provider[] = Indent::_(1) . "* @param Container \$container The DI container."; + $provider[] = Indent::_(1) . "*"; + $provider[] = Indent::_(1) . "* @return void"; + $provider[] = Indent::_(1) . "* @since 4.3.0"; + $provider[] = Indent::_(1) . "*/"; + $provider[] = Indent::_(1) . "public function register(Container \$container)"; + $provider[] = Indent::_(1) . "{"; + $provider[] = Indent::_(2) . "\$container->set("; + $provider[] = Indent::_(3) . "PluginInterface::class,"; + $provider[] = Indent::_(3) . "function (Container \$container) {"; + $provider[] = Indent::_(4) . "\$plugin = new {$plugin->class_name}("; + $provider[] = Indent::_(5) . "\$container->get(DispatcherInterface::class),"; + $provider[] = Indent::_(5) . "(array) PluginHelper::getPlugin('{$group}', '{$plugin->context_name}')"; + $provider[] = Indent::_(4) . ");"; + $provider[] = Indent::_(4) . "\$plugin->setApplication(Factory::getApplication());"; + $provider[] = $plugin->service_provider ?? ''; // to add extra plug-in suff + $provider[] = Indent::_(4) . "return \$plugin;"; + $provider[] = Indent::_(3) . "}"; + $provider[] = Indent::_(2) . ");"; + $provider[] = Indent::_(1) . "}"; + $provider[] = "};"; + + return $this->placeholder->update( + implode(PHP_EOL, $provider). PHP_EOL, + $this->builder->allActive() + ); + } +} + diff --git a/src/60c3ccc5-36dc-4480-b5c4-252c37212f61/code.power b/src/60c3ccc5-36dc-4480-b5c4-252c37212f61/code.power new file mode 100644 index 0000000..00a9965 --- /dev/null +++ b/src/60c3ccc5-36dc-4480-b5c4-252c37212f61/code.power @@ -0,0 +1,76 @@ + /** + * The Placeholder Class. + * + * @var Placeholder + * @since 5.0.2 + */ + protected Placeholder $placeholder; + + /** + * The ContentOne Class. + * + * @var Builder + * @since 5.0.2 + */ + protected Builder $builder; + + /** + * Constructor. + * + * @param Placeholder $placeholder The Placeholder Class. + * @param Builder $builder The Content One Class. + * + * @since 5.0.2 + */ + public function __construct(Placeholder $placeholder, Builder $builder) + { + $this->placeholder = $placeholder; + $this->builder = $builder; + } + + /** + * Get the updated provider for the given plugin. + * + * @param object $plugin The plugin object containing the necessary data. + * + * @return string The provider content. + * + * @since 5.0.2 + */ + public function get(object $plugin): string + { + $group = strtolower((string) $plugin->group); + + $provider = []; + $provider[] = PHP_EOL . PHP_EOL . "return new class () implements ServiceProviderInterface {"; + $provider[] = Indent::_(1) . "/**"; + $provider[] = Indent::_(1) . "*" . Line::_(__Line__, __Class__) + . " Registers the service provider with a DI container."; + $provider[] = Indent::_(1) . "*"; + $provider[] = Indent::_(1) . "* @param Container \$container The DI container."; + $provider[] = Indent::_(1) . "*"; + $provider[] = Indent::_(1) . "* @return void"; + $provider[] = Indent::_(1) . "* @since 4.3.0"; + $provider[] = Indent::_(1) . "*/"; + $provider[] = Indent::_(1) . "public function register(Container \$container)"; + $provider[] = Indent::_(1) . "{"; + $provider[] = Indent::_(2) . "\$container->set("; + $provider[] = Indent::_(3) . "PluginInterface::class,"; + $provider[] = Indent::_(3) . "function (Container \$container) {"; + $provider[] = Indent::_(4) . "\$plugin = new {$plugin->class_name}("; + $provider[] = Indent::_(5) . "\$container->get(DispatcherInterface::class),"; + $provider[] = Indent::_(5) . "(array) PluginHelper::getPlugin('{$group}', '{$plugin->context_name}')"; + $provider[] = Indent::_(4) . ");"; + $provider[] = Indent::_(4) . "\$plugin->setApplication(Factory::getApplication());"; + $provider[] = $plugin->service_provider ?? ''; // to add extra plug-in suff + $provider[] = Indent::_(4) . "return \$plugin;"; + $provider[] = Indent::_(3) . "}"; + $provider[] = Indent::_(2) . ");"; + $provider[] = Indent::_(1) . "}"; + $provider[] = "};"; + + return $this->placeholder->update( + implode(PHP_EOL, $provider). PHP_EOL, + $this->builder->allActive() + ); + } \ No newline at end of file diff --git a/src/60c3ccc5-36dc-4480-b5c4-252c37212f61/settings.json b/src/60c3ccc5-36dc-4480-b5c4-252c37212f61/settings.json new file mode 100644 index 0000000..4035a10 --- /dev/null +++ b/src/60c3ccc5-36dc-4480-b5c4-252c37212f61/settings.json @@ -0,0 +1,38 @@ +{ + "add_head": "0", + "add_licensing_template": "2", + "extends": "", + "guid": "60c3ccc5-36dc-4480-b5c4-252c37212f61", + "implements": [ + "d6ae90a5-44b4-4ce4-aedc-86c90a242912" + ], + "load_selection": null, + "name": "Provider", + "power_version": "1.0.0", + "system_name": "JCB.Architecture.J4.Plugin.Provider", + "type": "final class", + "use_selection": { + "use_selection0": { + "use": "06453ada-e370-49f0-b262-e3f5a8ed0c2c", + "as": "default" + }, + "use_selection1": { + "use": "adfbe68a-6d22-43e5-aee8-2787e8c47e75", + "as": "Builder" + }, + "use_selection3": { + "use": "a68c010b-e92e-47d5-8a44-d23cfddeb6c6", + "as": "default" + }, + "use_selection2": { + "use": "4e6ff11d-bebf-42f5-8fd7-b2f882857222", + "as": "default" + } + }, + "extendsinterfaces": null, + "namespace": "[[[NamespacePrefix]]]\\Joomla\\[[[ComponentNamespace]]].Compiler.Architecture.JoomlaFour.Plugin.Provider", + "description": "Plugin Provider Class for Joomla 4\r\n\r\n@since 5.0.2", + "licensing_template": "\/**\r\n * @package Joomla.Component.Builder\r\n *\r\n * @created 4th September, 2022\r\n * @author Llewellyn van der Merwe \r\n * @git Joomla Component Builder \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/63865266-62e0-40bd-820c-e95449d12982/README.md b/src/63865266-62e0-40bd-820c-e95449d12982/README.md new file mode 100644 index 0000000..9605bb2 --- /dev/null +++ b/src/63865266-62e0-40bd-820c-e95449d12982/README.md @@ -0,0 +1,61 @@ +``` +██████╗ ██████╗ ██╗ ██╗███████╗██████╗ +██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗ +██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝ +██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗ +██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║ +╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝ +``` +# final class Provider (Details) +> namespace: **VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaFive\Plugin** + +```uml +@startuml +class Provider << (F,LightGreen) >> #RoyalBlue { + # Placeholder $placeholder + # Builder $builder + + __construct(Placeholder $placeholder, Builder $builder) + + get(object $plugin) : string +} + +note right of Provider::__construct + Constructor. + + since: 5.0.2 +end note + +note right of Provider::get + Get the updated provider for the given plugin. + + since: 5.0.2 + return: string +end note + +@enduml +``` + +The Power feature in JCB allows you to write PHP classes and their implementations, making it easy to include them in your Joomla project. JCB handles linking, autoloading, namespacing, and folder structure creation for you. + +By using the SPK (Super Power Key) in your custom code (replacing the class name in your code with the SPK), JCB will automatically pull the power from the repository into your project. This makes it available in your JCB instance, allowing you to edit it and include the class in your generated Joomla component. + +JCB uses placeholders like [[[`NamespacePrefix`]]] and [[[`ComponentNamespace`]]] in namespacing to prevent collisions and improve reusability across different JCB systems. You can also set the **JCB powers path** globally or per component under the **Dynamic Integration** tab, providing flexibility and easy maintainability. + +To add this specific Power to your project in JCB: + +> simply use this SPK +``` +Super---63865266_62e0_40bd_820c_e95449d12982---Power +``` +> remember to replace the `---` with `___` to activate this Power in your code + +--- +``` + ██╗ ██████╗██████╗ + ██║██╔════╝██╔══██╗ + ██║██║ ██████╔╝ +██ ██║██║ ██╔══██╗ +╚█████╔╝╚██████╗██████╔╝ + ╚════╝ ╚═════╝╚═════╝ +``` +> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder) + diff --git a/src/63865266-62e0-40bd-820c-e95449d12982/code.php b/src/63865266-62e0-40bd-820c-e95449d12982/code.php new file mode 100644 index 0000000..813d5e0 --- /dev/null +++ b/src/63865266-62e0-40bd-820c-e95449d12982/code.php @@ -0,0 +1,106 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaFive\Plugin; + + +use VDM\Joomla\Componentbuilder\Compiler\Placeholder; +use VDM\Joomla\Componentbuilder\Compiler\Builder\ContentOne as Builder; +use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent; +use VDM\Joomla\Componentbuilder\Compiler\Utilities\Line; +use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Architecture\Plugin\ProviderInterface; + + +/** + * Plugin Provider Class for Joomla 5 + * + * @since 5.0.2 + */ +final class Provider implements ProviderInterface +{ + /** + * The Placeholder Class. + * + * @var Placeholder + * @since 5.0.2 + */ + protected Placeholder $placeholder; + + /** + * The ContentOne Class. + * + * @var Builder + * @since 5.0.2 + */ + protected Builder $builder; + + /** + * Constructor. + * + * @param Placeholder $placeholder The Placeholder Class. + * @param Builder $builder The Content One Class. + * + * @since 5.0.2 + */ + public function __construct(Placeholder $placeholder, Builder $builder) + { + $this->placeholder = $placeholder; + $this->builder = $builder; + } + + /** + * Get the updated provider for the given plugin. + * + * @param object $plugin The plugin object containing the necessary data. + * + * @return string The provider content. + * + * @since 5.0.2 + */ + public function get(object $plugin): string + { + $group = strtolower((string) $plugin->group); + + $provider = []; + $provider[] = PHP_EOL . PHP_EOL . "return new class () implements ServiceProviderInterface {"; + $provider[] = Indent::_(1) . "/**"; + $provider[] = Indent::_(1) . "*" . Line::_(__Line__, __Class__) + . " Registers the service provider with a DI container."; + $provider[] = Indent::_(1) . "*"; + $provider[] = Indent::_(1) . "* @param Container \$container The DI container."; + $provider[] = Indent::_(1) . "*"; + $provider[] = Indent::_(1) . "* @return void"; + $provider[] = Indent::_(1) . "* @since 4.3.0"; + $provider[] = Indent::_(1) . "*/"; + $provider[] = Indent::_(1) . "public function register(Container \$container)"; + $provider[] = Indent::_(1) . "{"; + $provider[] = Indent::_(2) . "\$container->set("; + $provider[] = Indent::_(3) . "PluginInterface::class,"; + $provider[] = Indent::_(3) . "function (Container \$container) {"; + $provider[] = Indent::_(4) . "\$plugin = new {$plugin->class_name}("; + $provider[] = Indent::_(5) . "\$container->get(DispatcherInterface::class),"; + $provider[] = Indent::_(5) . "(array) PluginHelper::getPlugin('{$group}', '{$plugin->context_name}')"; + $provider[] = Indent::_(4) . ");"; + $provider[] = Indent::_(4) . "\$plugin->setApplication(Factory::getApplication());"; + $provider[] = $plugin->service_provider ?? ''; // to add extra plug-in suff + $provider[] = Indent::_(4) . "return \$plugin;"; + $provider[] = Indent::_(3) . "}"; + $provider[] = Indent::_(2) . ");"; + $provider[] = Indent::_(1) . "}"; + $provider[] = "};"; + + return $this->placeholder->update( + implode(PHP_EOL, $provider). PHP_EOL, + $this->builder->allActive() + ); + } +} + diff --git a/src/63865266-62e0-40bd-820c-e95449d12982/code.power b/src/63865266-62e0-40bd-820c-e95449d12982/code.power new file mode 100644 index 0000000..00a9965 --- /dev/null +++ b/src/63865266-62e0-40bd-820c-e95449d12982/code.power @@ -0,0 +1,76 @@ + /** + * The Placeholder Class. + * + * @var Placeholder + * @since 5.0.2 + */ + protected Placeholder $placeholder; + + /** + * The ContentOne Class. + * + * @var Builder + * @since 5.0.2 + */ + protected Builder $builder; + + /** + * Constructor. + * + * @param Placeholder $placeholder The Placeholder Class. + * @param Builder $builder The Content One Class. + * + * @since 5.0.2 + */ + public function __construct(Placeholder $placeholder, Builder $builder) + { + $this->placeholder = $placeholder; + $this->builder = $builder; + } + + /** + * Get the updated provider for the given plugin. + * + * @param object $plugin The plugin object containing the necessary data. + * + * @return string The provider content. + * + * @since 5.0.2 + */ + public function get(object $plugin): string + { + $group = strtolower((string) $plugin->group); + + $provider = []; + $provider[] = PHP_EOL . PHP_EOL . "return new class () implements ServiceProviderInterface {"; + $provider[] = Indent::_(1) . "/**"; + $provider[] = Indent::_(1) . "*" . Line::_(__Line__, __Class__) + . " Registers the service provider with a DI container."; + $provider[] = Indent::_(1) . "*"; + $provider[] = Indent::_(1) . "* @param Container \$container The DI container."; + $provider[] = Indent::_(1) . "*"; + $provider[] = Indent::_(1) . "* @return void"; + $provider[] = Indent::_(1) . "* @since 4.3.0"; + $provider[] = Indent::_(1) . "*/"; + $provider[] = Indent::_(1) . "public function register(Container \$container)"; + $provider[] = Indent::_(1) . "{"; + $provider[] = Indent::_(2) . "\$container->set("; + $provider[] = Indent::_(3) . "PluginInterface::class,"; + $provider[] = Indent::_(3) . "function (Container \$container) {"; + $provider[] = Indent::_(4) . "\$plugin = new {$plugin->class_name}("; + $provider[] = Indent::_(5) . "\$container->get(DispatcherInterface::class),"; + $provider[] = Indent::_(5) . "(array) PluginHelper::getPlugin('{$group}', '{$plugin->context_name}')"; + $provider[] = Indent::_(4) . ");"; + $provider[] = Indent::_(4) . "\$plugin->setApplication(Factory::getApplication());"; + $provider[] = $plugin->service_provider ?? ''; // to add extra plug-in suff + $provider[] = Indent::_(4) . "return \$plugin;"; + $provider[] = Indent::_(3) . "}"; + $provider[] = Indent::_(2) . ");"; + $provider[] = Indent::_(1) . "}"; + $provider[] = "};"; + + return $this->placeholder->update( + implode(PHP_EOL, $provider). PHP_EOL, + $this->builder->allActive() + ); + } \ No newline at end of file diff --git a/src/63865266-62e0-40bd-820c-e95449d12982/settings.json b/src/63865266-62e0-40bd-820c-e95449d12982/settings.json new file mode 100644 index 0000000..233928c --- /dev/null +++ b/src/63865266-62e0-40bd-820c-e95449d12982/settings.json @@ -0,0 +1,38 @@ +{ + "add_head": "0", + "add_licensing_template": "2", + "extends": "", + "guid": "63865266-62e0-40bd-820c-e95449d12982", + "implements": [ + "d6ae90a5-44b4-4ce4-aedc-86c90a242912" + ], + "load_selection": null, + "name": "Provider", + "power_version": "1.0.0", + "system_name": "JCB.Architecture.J5.Plugin.Provider", + "type": "final class", + "use_selection": { + "use_selection0": { + "use": "06453ada-e370-49f0-b262-e3f5a8ed0c2c", + "as": "default" + }, + "use_selection1": { + "use": "adfbe68a-6d22-43e5-aee8-2787e8c47e75", + "as": "Builder" + }, + "use_selection2": { + "use": "a68c010b-e92e-47d5-8a44-d23cfddeb6c6", + "as": "default" + }, + "use_selection3": { + "use": "4e6ff11d-bebf-42f5-8fd7-b2f882857222", + "as": "default" + } + }, + "extendsinterfaces": null, + "namespace": "[[[NamespacePrefix]]]\\Joomla\\[[[ComponentNamespace]]].Compiler.Architecture.JoomlaFive.Plugin.Provider", + "description": "Plugin Provider Class for Joomla 5\r\n\r\n@since 5.0.2", + "licensing_template": "\/**\r\n * @package Joomla.Component.Builder\r\n *\r\n * @created 4th September, 2022\r\n * @author Llewellyn van der Merwe \r\n * @git Joomla Component Builder \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/6784dd52-0909-451a-a872-9a942a023c68/code.php b/src/6784dd52-0909-451a-a872-9a942a023c68/code.php index d35f84b..2b93cdd 100644 --- a/src/6784dd52-0909-451a-a872-9a942a023c68/code.php +++ b/src/6784dd52-0909-451a-a872-9a942a023c68/code.php @@ -143,6 +143,60 @@ final class Grep extends ExtendingGrep implements GrepInterface // set the git details in params $power->main_class_code = $code; } + + // set the git details in params + $path_guid = $path->guid ?? null; + if ($path_guid !== null) + { + // get the Settings meta + if (($meta = $this->contents->metadata($path->organisation, $path->repository, $path->index->{$guid}->settings, $branch)) !== null && + isset($meta->sha)) + { + if (isset($power->params) && is_object($power->params) && + isset($power->params->source) && is_array($power->params->source)) + { + $power->params->source[$path_guid . '-settings'] = $meta->sha; + } + else + { + $power->params = (object) [ + 'source' => [$path_guid . '-settings' => $meta->sha] + ]; + } + } + // get the power meta + if (($meta = $this->contents->metadata($path->organisation, $path->repository, $path->index->{$guid}->power, $branch)) !== null && + isset($meta->sha)) + { + if (isset($power->params) && is_object($power->params) && + isset($power->params->source) && is_array($power->params->source)) + { + $power->params->source[$path_guid . '-power'] = $meta->sha; + } + else + { + $power->params = (object) [ + 'source' => [$path_guid . '-power' => $meta->sha] + ]; + } + } + // get the README meta + if (($meta = $this->contents->metadata($path->organisation, $path->repository, $path->index->{$guid}->path . '/README.md', $branch)) !== null && + isset($meta->sha)) + { + if (isset($power->params) && is_object($power->params) && + isset($power->params->source) && is_array($power->params->source)) + { + $power->params->source[$path_guid . '-readme'] = $meta->sha; + } + else + { + $power->params = (object) [ + 'source' => [$path_guid . '-readme' => $meta->sha] + ]; + } + } + } } // reset back to the global base and token diff --git a/src/6784dd52-0909-451a-a872-9a942a023c68/code.power b/src/6784dd52-0909-451a-a872-9a942a023c68/code.power index 2c71033..44d8b96 100644 --- a/src/6784dd52-0909-451a-a872-9a942a023c68/code.power +++ b/src/6784dd52-0909-451a-a872-9a942a023c68/code.power @@ -110,6 +110,60 @@ // set the git details in params $power->main_class_code = $code; } + + // set the git details in params + $path_guid = $path->guid ?? null; + if ($path_guid !== null) + { + // get the Settings meta + if (($meta = $this->contents->metadata($path->organisation, $path->repository, $path->index->{$guid}->settings, $branch)) !== null && + isset($meta->sha)) + { + if (isset($power->params) && is_object($power->params) && + isset($power->params->source) && is_array($power->params->source)) + { + $power->params->source[$path_guid . '-settings'] = $meta->sha; + } + else + { + $power->params = (object) [ + 'source' => [$path_guid . '-settings' => $meta->sha] + ]; + } + } + // get the power meta + if (($meta = $this->contents->metadata($path->organisation, $path->repository, $path->index->{$guid}->power, $branch)) !== null && + isset($meta->sha)) + { + if (isset($power->params) && is_object($power->params) && + isset($power->params->source) && is_array($power->params->source)) + { + $power->params->source[$path_guid . '-power'] = $meta->sha; + } + else + { + $power->params = (object) [ + 'source' => [$path_guid . '-power' => $meta->sha] + ]; + } + } + // get the README meta + if (($meta = $this->contents->metadata($path->organisation, $path->repository, $path->index->{$guid}->path . '/README.md', $branch)) !== null && + isset($meta->sha)) + { + if (isset($power->params) && is_object($power->params) && + isset($power->params->source) && is_array($power->params->source)) + { + $power->params->source[$path_guid . '-readme'] = $meta->sha; + } + else + { + $power->params = (object) [ + 'source' => [$path_guid . '-readme' => $meta->sha] + ]; + } + } + } } // reset back to the global base and token diff --git a/src/69d2b980-a665-48cd-96f8-757bf3810b41/code.php b/src/69d2b980-a665-48cd-96f8-757bf3810b41/code.php index 1feea90..93ca161 100644 --- a/src/69d2b980-a665-48cd-96f8-757bf3810b41/code.php +++ b/src/69d2b980-a665-48cd-96f8-757bf3810b41/code.php @@ -351,7 +351,7 @@ final class Settings implements SettingsInterface $this->config->get('footable', false)) { $this->addImportViewFolder(); - $this->addPhpSpreadsheetFolder(); + // $this->addPhpSpreadsheetFolder(); // soon $this->addUikitFolder(); $this->addFooTableFolder(); } diff --git a/src/69d2b980-a665-48cd-96f8-757bf3810b41/code.power b/src/69d2b980-a665-48cd-96f8-757bf3810b41/code.power index 94e562f..67a6493 100644 --- a/src/69d2b980-a665-48cd-96f8-757bf3810b41/code.power +++ b/src/69d2b980-a665-48cd-96f8-757bf3810b41/code.power @@ -315,7 +315,7 @@ $this->config->get('footable', false)) { $this->addImportViewFolder(); - $this->addPhpSpreadsheetFolder(); + // $this->addPhpSpreadsheetFolder(); // soon $this->addUikitFolder(); $this->addFooTableFolder(); } diff --git a/src/6dd2d394-8dde-4eb7-8505-cd7d345c49e3/README.md b/src/6dd2d394-8dde-4eb7-8505-cd7d345c49e3/README.md new file mode 100644 index 0000000..06e4548 --- /dev/null +++ b/src/6dd2d394-8dde-4eb7-8505-cd7d345c49e3/README.md @@ -0,0 +1,61 @@ +``` +██████╗ ██████╗ ██╗ ██╗███████╗██████╗ +██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗ +██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝ +██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗ +██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║ +╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝ +``` +# final class Provider (Details) +> namespace: **VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaThree\Plugin** + +```uml +@startuml +class Provider << (F,LightGreen) >> #RoyalBlue { + # Placeholder $placeholder + # Builder $builder + + __construct(Placeholder $placeholder, Builder $builder) + + get(object $plugin) : string +} + +note right of Provider::__construct + Constructor. + + since: 5.0.2 +end note + +note right of Provider::get + Get the updated provider for the given plugin. + + since: 5.0.2 + return: string +end note + +@enduml +``` + +The Power feature in JCB allows you to write PHP classes and their implementations, making it easy to include them in your Joomla project. JCB handles linking, autoloading, namespacing, and folder structure creation for you. + +By using the SPK (Super Power Key) in your custom code (replacing the class name in your code with the SPK), JCB will automatically pull the power from the repository into your project. This makes it available in your JCB instance, allowing you to edit it and include the class in your generated Joomla component. + +JCB uses placeholders like [[[`NamespacePrefix`]]] and [[[`ComponentNamespace`]]] in namespacing to prevent collisions and improve reusability across different JCB systems. You can also set the **JCB powers path** globally or per component under the **Dynamic Integration** tab, providing flexibility and easy maintainability. + +To add this specific Power to your project in JCB: + +> simply use this SPK +``` +Super---6dd2d394_8dde_4eb7_8505_cd7d345c49e3---Power +``` +> remember to replace the `---` with `___` to activate this Power in your code + +--- +``` + ██╗ ██████╗██████╗ + ██║██╔════╝██╔══██╗ + ██║██║ ██████╔╝ +██ ██║██║ ██╔══██╗ +╚█████╔╝╚██████╗██████╔╝ + ╚════╝ ╚═════╝╚═════╝ +``` +> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder) + diff --git a/src/6dd2d394-8dde-4eb7-8505-cd7d345c49e3/code.php b/src/6dd2d394-8dde-4eb7-8505-cd7d345c49e3/code.php new file mode 100644 index 0000000..650ef86 --- /dev/null +++ b/src/6dd2d394-8dde-4eb7-8505-cd7d345c49e3/code.php @@ -0,0 +1,71 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaThree\Plugin; + + +use VDM\Joomla\Componentbuilder\Compiler\Placeholder; +use VDM\Joomla\Componentbuilder\Compiler\Builder\ContentOne as Builder; +use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Architecture\Plugin\ProviderInterface; + + +/** + * Plugin Provider Class for Joomla 3 + * + * @since 5.0.2 + */ +final class Provider implements ProviderInterface +{ + /** + * The Placeholder Class. + * + * @var Placeholder + * @since 5.0.2 + */ + protected Placeholder $placeholder; + + /** + * The ContentOne Class. + * + * @var Builder + * @since 5.0.2 + */ + protected Builder $builder; + + /** + * Constructor. + * + * @param Placeholder $placeholder The Placeholder Class. + * @param Builder $builder The Content One Class. + * + * @since 5.0.2 + */ + public function __construct(Placeholder $placeholder, Builder $builder) + { + $this->placeholder = $placeholder; + $this->builder = $builder; + } + + /** + * Get the updated provider for the given plugin. + * + * @param object $plugin The plugin object containing the necessary data. + * + * @return string The provider content. + * + * @since 5.0.2 + */ + public function get(object $plugin): string + { + return ''; // no provider in Joomla 3 + } +} + diff --git a/src/6dd2d394-8dde-4eb7-8505-cd7d345c49e3/code.power b/src/6dd2d394-8dde-4eb7-8505-cd7d345c49e3/code.power new file mode 100644 index 0000000..40f9d46 --- /dev/null +++ b/src/6dd2d394-8dde-4eb7-8505-cd7d345c49e3/code.power @@ -0,0 +1,43 @@ + /** + * The Placeholder Class. + * + * @var Placeholder + * @since 5.0.2 + */ + protected Placeholder $placeholder; + + /** + * The ContentOne Class. + * + * @var Builder + * @since 5.0.2 + */ + protected Builder $builder; + + /** + * Constructor. + * + * @param Placeholder $placeholder The Placeholder Class. + * @param Builder $builder The Content One Class. + * + * @since 5.0.2 + */ + public function __construct(Placeholder $placeholder, Builder $builder) + { + $this->placeholder = $placeholder; + $this->builder = $builder; + } + + /** + * Get the updated provider for the given plugin. + * + * @param object $plugin The plugin object containing the necessary data. + * + * @return string The provider content. + * + * @since 5.0.2 + */ + public function get(object $plugin): string + { + return ''; // no provider in Joomla 3 + } \ No newline at end of file diff --git a/src/6dd2d394-8dde-4eb7-8505-cd7d345c49e3/settings.json b/src/6dd2d394-8dde-4eb7-8505-cd7d345c49e3/settings.json new file mode 100644 index 0000000..56e866e --- /dev/null +++ b/src/6dd2d394-8dde-4eb7-8505-cd7d345c49e3/settings.json @@ -0,0 +1,30 @@ +{ + "add_head": "0", + "add_licensing_template": "2", + "extends": "", + "guid": "6dd2d394-8dde-4eb7-8505-cd7d345c49e3", + "implements": [ + "d6ae90a5-44b4-4ce4-aedc-86c90a242912" + ], + "load_selection": null, + "name": "Provider", + "power_version": "1.0.0", + "system_name": "JCB.Architecture.J3.Plugin.Provider", + "type": "final class", + "use_selection": { + "use_selection0": { + "use": "06453ada-e370-49f0-b262-e3f5a8ed0c2c", + "as": "default" + }, + "use_selection1": { + "use": "adfbe68a-6d22-43e5-aee8-2787e8c47e75", + "as": "Builder" + } + }, + "extendsinterfaces": null, + "namespace": "[[[NamespacePrefix]]]\\Joomla\\[[[ComponentNamespace]]].Compiler.Architecture.JoomlaThree.Plugin.Provider", + "description": "Plugin Provider Class for Joomla 3\r\n\r\n@since 5.0.2", + "licensing_template": "\/**\r\n * @package Joomla.Component.Builder\r\n *\r\n * @created 4th September, 2022\r\n * @author Llewellyn van der Merwe \r\n * @git Joomla Component Builder \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/6e64917c-d687-4ef3-a655-811319f5a81e/code.php b/src/6e64917c-d687-4ef3-a655-811319f5a81e/code.php index f91ec89..7b5e02f 100644 --- a/src/6e64917c-d687-4ef3-a655-811319f5a81e/code.php +++ b/src/6e64917c-d687-4ef3-a655-811319f5a81e/code.php @@ -72,7 +72,7 @@ class Autoloader * * @param Power $power The Power Class. * @param Config $config The Config Class. - * @param Content $content The ContentOne Class. + * @param Content $content The Content One Class. * * @since 3.2.0 */ diff --git a/src/6e64917c-d687-4ef3-a655-811319f5a81e/code.power b/src/6e64917c-d687-4ef3-a655-811319f5a81e/code.power index 1e23a43..2a7bc57 100644 --- a/src/6e64917c-d687-4ef3-a655-811319f5a81e/code.power +++ b/src/6e64917c-d687-4ef3-a655-811319f5a81e/code.power @@ -43,7 +43,7 @@ * * @param Power $power The Power Class. * @param Config $config The Config Class. - * @param Content $content The ContentOne Class. + * @param Content $content The Content One Class. * * @since 3.2.0 */ diff --git a/src/73183d13-9b2e-4879-b05a-52298d5b31f7/README.md b/src/73183d13-9b2e-4879-b05a-52298d5b31f7/README.md index f8a511d..d53140e 100644 --- a/src/73183d13-9b2e-4879-b05a-52298d5b31f7/README.md +++ b/src/73183d13-9b2e-4879-b05a-52298d5b31f7/README.md @@ -21,6 +21,11 @@ class InstallScript << (F,LightGreen) >> #RoyalBlue { # array $uninstall # bool $preflightActive # bool $postflightActive + # array $removeFilePaths + # array $removeFolderPaths + # $app + # array $deleteFiles + # array $deleteFolders + get(object $extension) : string # rest() : void # build() : string @@ -28,6 +33,7 @@ class InstallScript << (F,LightGreen) >> #RoyalBlue { # construct() : string # main(string $name) : string # flight(string $name) : string + # removeFiles() : string } note right of InstallScript::get @@ -37,7 +43,7 @@ note right of InstallScript::get return: string end note -note right of InstallScript::rest +note left of InstallScript::rest Reset all bucket at the start of each build since: 3.2.0 @@ -51,7 +57,7 @@ note right of InstallScript::build return: string end note -note right of InstallScript::head +note left of InstallScript::head get install script head since: 3.2.0 @@ -65,7 +71,7 @@ note right of InstallScript::construct return: string end note -note right of InstallScript::main +note left of InstallScript::main build main methods since: 3.2.0 @@ -78,6 +84,13 @@ note right of InstallScript::flight since: 3.2.0 return: string end note + +note left of InstallScript::removeFiles + build remove files methods + + since: 5.0.2 + return: string +end note @enduml ``` diff --git a/src/73183d13-9b2e-4879-b05a-52298d5b31f7/code.php b/src/73183d13-9b2e-4879-b05a-52298d5b31f7/code.php index 6b24caf..7ffce1f 100644 --- a/src/73183d13-9b2e-4879-b05a-52298d5b31f7/code.php +++ b/src/73183d13-9b2e-4879-b05a-52298d5b31f7/code.php @@ -115,6 +115,22 @@ final class InstallScript implements GetScriptInterface */ protected array $postflightBucket = ['install' => [], 'uninstall' => [], 'discover_install' => [], 'update' => []]; + /** + * The paths of the old plugin class files + * + * @var array + * @since 5.0.2 + */ + protected array $removeFilePaths = []; + + /** + * The paths of the old plugin folders + * + * @var array + * @since 5.0.2 + */ + protected array $removeFolderPaths = []; + /** * get install script * @@ -128,6 +144,10 @@ final class InstallScript implements GetScriptInterface // purge the object $this->rest(); + // set the remove path + $this->removeFilePaths = $extension->remove_file_paths ?? []; + $this->removeFolderPaths = $extension->remove_folder_paths ?? []; + // loop over methods and types foreach ($this->methods as $method) { @@ -171,6 +191,8 @@ final class InstallScript implements GetScriptInterface */ protected function rest(): void { + $this->removeFilePaths = []; + $this->removeFolderPaths = []; $this->construct = []; $this->install = []; $this->update = []; @@ -210,6 +232,9 @@ final class InstallScript implements GetScriptInterface // load postflight method if set $script .= $this->flight('postflight'); + // load remove files method + $script .= $this->removeFiles(); + // close the class $script .= PHP_EOL . '}' . PHP_EOL; @@ -229,9 +254,11 @@ final class InstallScript implements GetScriptInterface // start build $script = PHP_EOL . 'use Joomla\CMS\Factory;'; + $script .= PHP_EOL . 'use Joomla\CMS\Version;'; + $script .= PHP_EOL . 'use Joomla\CMS\Installer\InstallerAdapter;'; $script .= PHP_EOL . 'use Joomla\CMS\Language\Text;'; - $script .= PHP_EOL . 'use Joomla\CMS\Filesystem\File;'; - $script .= PHP_EOL . 'use Joomla\CMS\Filesystem\Folder;' . PHP_EOL; + $script .= PHP_EOL . 'use Joomla\Filesystem\File;'; + $script .= PHP_EOL . 'use Joomla\Filesystem\Folder;' . PHP_EOL; $script .= PHP_EOL . '/**'; $script .= PHP_EOL . ' * ' . $extension->official_name . ' script file.'; @@ -252,26 +279,87 @@ final class InstallScript implements GetScriptInterface */ protected function construct(): string { - // return empty string if not set - if (!ArrayHelper::check($this->construct)) - { - return ''; - } - // the __construct script - $script = PHP_EOL . PHP_EOL . Indent::_(1) . '/**'; + $script = PHP_EOL . Indent::_(1) . '/**'; + $script .= PHP_EOL . Indent::_(1) . ' *' . Line::_(__Line__, __Class__) + .' The CMS Application.'; + $script .= PHP_EOL . Indent::_(1) . ' *'; + $script .= PHP_EOL . Indent::_(1) . ' * @since 4.4.2'; + $script .= PHP_EOL . Indent::_(1) . ' */'; + $script .= PHP_EOL . Indent::_(1) . 'protected $app;'; + + $script .= PHP_EOL . PHP_EOL . Indent::_(1) . '/**'; + $script .= PHP_EOL . Indent::_(1) . ' *' . Line::_(__Line__, __Class__) + .' A list of files to be deleted'; + $script .= PHP_EOL . Indent::_(1) . ' *'; + $script .= PHP_EOL . Indent::_(1) . ' * @var array'; + $script .= PHP_EOL . Indent::_(1) . ' * @since 3.6'; + $script .= PHP_EOL . Indent::_(1) . ' */'; + $script .= PHP_EOL . Indent::_(1) . 'protected array $deleteFiles = [];'; + + $script .= PHP_EOL . PHP_EOL . Indent::_(1) . '/**'; + $script .= PHP_EOL . Indent::_(1) . ' *' . Line::_(__Line__, __Class__) + .' A list of folders to be deleted'; + $script .= PHP_EOL . Indent::_(1) . ' *'; + $script .= PHP_EOL . Indent::_(1) . ' * @var array'; + $script .= PHP_EOL . Indent::_(1) . ' * @since 3.6'; + $script .= PHP_EOL . Indent::_(1) . ' */'; + $script .= PHP_EOL . Indent::_(1) . 'protected array $deleteFolders = [];'; + + $script .= PHP_EOL . PHP_EOL . Indent::_(1) . '/**'; $script .= PHP_EOL . Indent::_(1) . ' * Constructor'; $script .= PHP_EOL . Indent::_(1) . ' *'; $script .= PHP_EOL . Indent::_(1) - . ' * @param Joomla\CMS\Installer\InstallerAdapter $adapter The object responsible for running this script'; + . ' * @param InstallerAdapter $adapter The object responsible for running this script'; $script .= PHP_EOL . Indent::_(1) . ' */'; $script .= PHP_EOL . Indent::_(1) . 'public function __construct($adapter)'; $script .= PHP_EOL . Indent::_(1) . '{'; - $script .= PHP_EOL . implode(PHP_EOL . PHP_EOL, $this->construct); + + $script .= PHP_EOL . Indent::_(2) . '//' . Line::_(__Line__, __Class__) + . ' get application'; + $script .= PHP_EOL . Indent::_(2) + . '$this->app = Factory::getApplication();' . PHP_EOL; + + if (ArrayHelper::check($this->construct)) + { + $script .= PHP_EOL . implode(PHP_EOL . PHP_EOL, $this->construct); + } + + // check if custom remove file is set + if ($this->removeFilePaths !== [] && strpos($script, '$this->deleteFiles') === false) + { + // add the default delete files + foreach ($this->removeFilePaths as $filePath) + { + $script .= PHP_EOL . Indent::_(2) . "if (is_file(JPATH_ROOT . '$filePath'))"; + $script .= PHP_EOL . Indent::_(2) . "{"; + $script .= PHP_EOL . Indent::_(3) . "\$this->deleteFiles[] = '$filePath';"; + $script .= PHP_EOL . Indent::_(2) . "}"; + } + } + + // check if custom remove file is set + if ($this->removeFolderPaths !== [] && strpos($script, '$this->deleteFolders') === false) + { + // add the default delete folders + foreach ($this->removeFolderPaths as $folderPath) + { + $script .= PHP_EOL . Indent::_(2) . "if (is_dir(JPATH_ROOT . '$folderPath'))"; + $script .= PHP_EOL . Indent::_(2) . "{"; + $script .= PHP_EOL . Indent::_(3) . "\$this->deleteFolders[] = '$folderPath';"; + $script .= PHP_EOL . Indent::_(2) . "}"; + } + } + // close the function $script .= PHP_EOL . Indent::_(1) . '}'; + // add remove files + $this->preflightBucket['bottom'][] = Indent::_(2) . '//' . Line::_(__Line__, __Class__) + .' remove old files and folders'; + $this->preflightBucket['bottom'][] = Indent::_(2) . '$this->removeFiles();'; + return $script; } @@ -295,7 +383,7 @@ final class InstallScript implements GetScriptInterface $script .= PHP_EOL . Indent::_(1) . " * Called on $name"; $script .= PHP_EOL . Indent::_(1) . ' *'; $script .= PHP_EOL . Indent::_(1) - . ' * @param Joomla\CMS\Installer\InstallerAdapter $adapter The object responsible for running this script'; + . ' * @param InstallerAdapter $adapter The object responsible for running this script'; $script .= PHP_EOL . Indent::_(1) . ' *'; $script .= PHP_EOL . Indent::_(1) . ' * @return boolean True on success'; @@ -325,12 +413,6 @@ final class InstallScript implements GetScriptInterface */ protected function flight(string $name): string { - // return empty string if not set - if (empty($this->{$name . 'Active'})) - { - return ''; - } - // the pre/post function types $script = PHP_EOL . PHP_EOL . Indent::_(1) . '/**'; $script .= PHP_EOL . Indent::_(1) @@ -339,7 +421,7 @@ final class InstallScript implements GetScriptInterface $script .= PHP_EOL . Indent::_(1) . ' * @param string $route Which action is happening (install|uninstall|discover_install|update)'; $script .= PHP_EOL . Indent::_(1) - . ' * @param Joomla\CMS\Installer\InstallerAdapter $adapter The object responsible for running this script'; + . ' * @param InstallerAdapter $adapter The object responsible for running this script'; $script .= PHP_EOL . Indent::_(1) . ' *'; $script .= PHP_EOL . Indent::_(1) . ' * @return boolean True on success'; @@ -348,9 +430,9 @@ final class InstallScript implements GetScriptInterface . $name . '($route, $adapter)'; $script .= PHP_EOL . Indent::_(1) . '{'; $script .= PHP_EOL . Indent::_(2) . '//' . Line::_(__Line__, __Class__) - . ' get application'; + . ' set application to local method var, just use $this->app in future [we will drop $app in J6]'; $script .= PHP_EOL . Indent::_(2) - . '$app = Factory::getApplication();' . PHP_EOL; + . '$app = $this->app;' . PHP_EOL; // add the default version check (TODO) must make this dynamic if ('preflight' === $name) @@ -358,37 +440,88 @@ final class InstallScript implements GetScriptInterface $script .= PHP_EOL . Indent::_(2) . '//' . Line::_(__Line__, __Class__) .' the default for both install and update'; $script .= PHP_EOL . Indent::_(2) - . '$jversion = new JVersion();'; + . '$jversion = new Version();'; $script .= PHP_EOL . Indent::_(2) - . "if (!\$jversion->isCompatible('3.8.0'))"; + . "if (!\$jversion->isCompatible('5.0.0'))"; $script .= PHP_EOL . Indent::_(2) . '{'; $script .= PHP_EOL . Indent::_(3) - . "\$app->enqueueMessage('Please upgrade to at least Joomla! 3.8.0 before continuing!', 'error');"; + . "\$app->enqueueMessage('Please upgrade to at least Joomla! 5.0.0 before continuing!', 'error');"; $script .= PHP_EOL . Indent::_(3) . 'return false;'; $script .= PHP_EOL . Indent::_(2) . '}' . PHP_EOL; } - // now add the scripts - foreach ($this->{$name . 'Bucket'} as $route => $_script) + if (!empty($this->{$name . 'Active'})) { - if (ArrayHelper::check($_script)) + // now add the scripts + foreach ($this->{$name . 'Bucket'} as $route => $_script) { - // set the if and script - $script .= PHP_EOL . Indent::_(2) . "if ('" . $route - . "' === \$route)"; - $script .= PHP_EOL . Indent::_(2) . '{'; - $script .= PHP_EOL . implode( - PHP_EOL . PHP_EOL, $_script - ); - $script .= PHP_EOL . Indent::_(2) . '}' . PHP_EOL; + if (ArrayHelper::check($_script) && $route !== 'bottom') + { + // set the if and script + $script .= PHP_EOL . Indent::_(2) . "if ('" . $route + . "' === \$route)"; + $script .= PHP_EOL . Indent::_(2) . '{'; + $script .= PHP_EOL . implode( + PHP_EOL . PHP_EOL, $_script + ); + $script .= PHP_EOL . Indent::_(2) . '}' . PHP_EOL; + } } } + if (isset($this->{$name . 'Bucket'}['bottom']) && ArrayHelper::check($this->{$name . 'Bucket'}['bottom'])) + { + $script .= PHP_EOL . implode( + PHP_EOL , $this->{$name . 'Bucket'}['bottom'] + ) . PHP_EOL; + } + // return true $script .= PHP_EOL . Indent::_(2) . 'return true;'; // close the function $script .= PHP_EOL . Indent::_(1) . '}'; + return $script; + } + + /** + * build remove files methods + * + * @return string + * @since 5.0.2 + */ + protected function removeFiles(): string + { + $script = PHP_EOL . PHP_EOL . Indent::_(1) . '/**'; + $script .= PHP_EOL . Indent::_(1) . ' * Remove the files and folders in the given array from'; + $script .= PHP_EOL . Indent::_(1) . ' *'; + $script .= PHP_EOL . Indent::_(1) . ' * @return void'; + $script .= PHP_EOL . Indent::_(1) . ' * @since 5.0.2'; + $script .= PHP_EOL . Indent::_(1) . ' */'; + $script .= PHP_EOL . Indent::_(1) . 'protected function removeFiles()'; + $script .= PHP_EOL . Indent::_(1) . '{'; + $script .= PHP_EOL . Indent::_(2) . 'if (!empty($this->deleteFiles))'; + $script .= PHP_EOL . Indent::_(2) . '{'; + $script .= PHP_EOL . Indent::_(3) . 'foreach ($this->deleteFiles as $file)'; + $script .= PHP_EOL . Indent::_(3) . '{'; + $script .= PHP_EOL . Indent::_(4) . 'if (is_file(JPATH_ROOT . $file) && !File::delete(JPATH_ROOT . $file))'; + $script .= PHP_EOL . Indent::_(4) . '{'; + $script .= PHP_EOL . Indent::_(5) . 'echo Text::sprintf(\'JLIB_INSTALLER_ERROR_FILE_FOLDER\', $file) . \'
\';'; + $script .= PHP_EOL . Indent::_(4) . '}'; + $script .= PHP_EOL . Indent::_(3) . '}'; + $script .= PHP_EOL . Indent::_(2) . '}'; + $script .= PHP_EOL . PHP_EOL . Indent::_(2) . 'if (!empty($this->deleteFolders))'; + $script .= PHP_EOL . Indent::_(2) . '{'; + $script .= PHP_EOL . Indent::_(3) . 'foreach ($this->deleteFolders as $folder)'; + $script .= PHP_EOL . Indent::_(3) . '{'; + $script .= PHP_EOL . Indent::_(4) . 'if (is_dir(JPATH_ROOT . $folder) && !Folder::delete(JPATH_ROOT . $folder))'; + $script .= PHP_EOL . Indent::_(4) . '{'; + $script .= PHP_EOL . Indent::_(5) . 'echo Text::sprintf(\'JLIB_INSTALLER_ERROR_FILE_FOLDER\', $folder) . \'
\';'; + $script .= PHP_EOL . Indent::_(4) . '}'; + $script .= PHP_EOL . Indent::_(3) . '}'; + $script .= PHP_EOL . Indent::_(2) . '}'; + $script .= PHP_EOL . Indent::_(1) . '}'; + return $script; } } diff --git a/src/73183d13-9b2e-4879-b05a-52298d5b31f7/code.power b/src/73183d13-9b2e-4879-b05a-52298d5b31f7/code.power index 391c370..e2a6a25 100644 --- a/src/73183d13-9b2e-4879-b05a-52298d5b31f7/code.power +++ b/src/73183d13-9b2e-4879-b05a-52298d5b31f7/code.power @@ -86,6 +86,22 @@ */ protected array $postflightBucket = ['install' => [], 'uninstall' => [], 'discover_install' => [], 'update' => []]; + /** + * The paths of the old plugin class files + * + * @var array + * @since 5.0.2 + */ + protected array $removeFilePaths = []; + + /** + * The paths of the old plugin folders + * + * @var array + * @since 5.0.2 + */ + protected array $removeFolderPaths = []; + /** * get install script * @@ -99,6 +115,10 @@ // purge the object $this->rest(); + // set the remove path + $this->removeFilePaths = $extension->remove_file_paths ?? []; + $this->removeFolderPaths = $extension->remove_folder_paths ?? []; + // loop over methods and types foreach ($this->methods as $method) { @@ -142,6 +162,8 @@ */ protected function rest(): void { + $this->removeFilePaths = []; + $this->removeFolderPaths = []; $this->construct = []; $this->install = []; $this->update = []; @@ -181,6 +203,9 @@ // load postflight method if set $script .= $this->flight('postflight'); + // load remove files method + $script .= $this->removeFiles(); + // close the class $script .= PHP_EOL . '}' . PHP_EOL; @@ -200,9 +225,11 @@ // start build $script = PHP_EOL . 'use Joomla\CMS\Factory;'; + $script .= PHP_EOL . 'use Joomla\CMS\Version;'; + $script .= PHP_EOL . 'use Joomla\CMS\Installer\InstallerAdapter;'; $script .= PHP_EOL . 'use Joomla\CMS\Language\Text;'; - $script .= PHP_EOL . 'use Joomla\CMS\Filesystem\File;'; - $script .= PHP_EOL . 'use Joomla\CMS\Filesystem\Folder;' . PHP_EOL; + $script .= PHP_EOL . 'use Joomla\Filesystem\File;'; + $script .= PHP_EOL . 'use Joomla\Filesystem\Folder;' . PHP_EOL; $script .= PHP_EOL . '/**'; $script .= PHP_EOL . ' * ' . $extension->official_name . ' script file.'; @@ -223,26 +250,87 @@ */ protected function construct(): string { - // return empty string if not set - if (!ArrayHelper::check($this->construct)) - { - return ''; - } - // the __construct script - $script = PHP_EOL . PHP_EOL . Indent::_(1) . '/**'; + $script = PHP_EOL . Indent::_(1) . '/**'; + $script .= PHP_EOL . Indent::_(1) . ' *' . Line::_(__Line__, __Class__) + .' The CMS Application.'; + $script .= PHP_EOL . Indent::_(1) . ' *'; + $script .= PHP_EOL . Indent::_(1) . ' * @since 4.4.2'; + $script .= PHP_EOL . Indent::_(1) . ' */'; + $script .= PHP_EOL . Indent::_(1) . 'protected $app;'; + + $script .= PHP_EOL . PHP_EOL . Indent::_(1) . '/**'; + $script .= PHP_EOL . Indent::_(1) . ' *' . Line::_(__Line__, __Class__) + .' A list of files to be deleted'; + $script .= PHP_EOL . Indent::_(1) . ' *'; + $script .= PHP_EOL . Indent::_(1) . ' * @var array'; + $script .= PHP_EOL . Indent::_(1) . ' * @since 3.6'; + $script .= PHP_EOL . Indent::_(1) . ' */'; + $script .= PHP_EOL . Indent::_(1) . 'protected array $deleteFiles = [];'; + + $script .= PHP_EOL . PHP_EOL . Indent::_(1) . '/**'; + $script .= PHP_EOL . Indent::_(1) . ' *' . Line::_(__Line__, __Class__) + .' A list of folders to be deleted'; + $script .= PHP_EOL . Indent::_(1) . ' *'; + $script .= PHP_EOL . Indent::_(1) . ' * @var array'; + $script .= PHP_EOL . Indent::_(1) . ' * @since 3.6'; + $script .= PHP_EOL . Indent::_(1) . ' */'; + $script .= PHP_EOL . Indent::_(1) . 'protected array $deleteFolders = [];'; + + $script .= PHP_EOL . PHP_EOL . Indent::_(1) . '/**'; $script .= PHP_EOL . Indent::_(1) . ' * Constructor'; $script .= PHP_EOL . Indent::_(1) . ' *'; $script .= PHP_EOL . Indent::_(1) - . ' * @param Joomla\CMS\Installer\InstallerAdapter $adapter The object responsible for running this script'; + . ' * @param InstallerAdapter $adapter The object responsible for running this script'; $script .= PHP_EOL . Indent::_(1) . ' */'; $script .= PHP_EOL . Indent::_(1) . 'public function __construct($adapter)'; $script .= PHP_EOL . Indent::_(1) . '{'; - $script .= PHP_EOL . implode(PHP_EOL . PHP_EOL, $this->construct); + + $script .= PHP_EOL . Indent::_(2) . '//' . Line::_(__Line__, __Class__) + . ' get application'; + $script .= PHP_EOL . Indent::_(2) + . '$this->app = Factory::getApplication();' . PHP_EOL; + + if (ArrayHelper::check($this->construct)) + { + $script .= PHP_EOL . implode(PHP_EOL . PHP_EOL, $this->construct); + } + + // check if custom remove file is set + if ($this->removeFilePaths !== [] && strpos($script, '$this->deleteFiles') === false) + { + // add the default delete files + foreach ($this->removeFilePaths as $filePath) + { + $script .= PHP_EOL . Indent::_(2) . "if (is_file(JPATH_ROOT . '$filePath'))"; + $script .= PHP_EOL . Indent::_(2) . "{"; + $script .= PHP_EOL . Indent::_(3) . "\$this->deleteFiles[] = '$filePath';"; + $script .= PHP_EOL . Indent::_(2) . "}"; + } + } + + // check if custom remove file is set + if ($this->removeFolderPaths !== [] && strpos($script, '$this->deleteFolders') === false) + { + // add the default delete folders + foreach ($this->removeFolderPaths as $folderPath) + { + $script .= PHP_EOL . Indent::_(2) . "if (is_dir(JPATH_ROOT . '$folderPath'))"; + $script .= PHP_EOL . Indent::_(2) . "{"; + $script .= PHP_EOL . Indent::_(3) . "\$this->deleteFolders[] = '$folderPath';"; + $script .= PHP_EOL . Indent::_(2) . "}"; + } + } + // close the function $script .= PHP_EOL . Indent::_(1) . '}'; + // add remove files + $this->preflightBucket['bottom'][] = Indent::_(2) . '//' . Line::_(__Line__, __Class__) + .' remove old files and folders'; + $this->preflightBucket['bottom'][] = Indent::_(2) . '$this->removeFiles();'; + return $script; } @@ -266,7 +354,7 @@ $script .= PHP_EOL . Indent::_(1) . " * Called on $name"; $script .= PHP_EOL . Indent::_(1) . ' *'; $script .= PHP_EOL . Indent::_(1) - . ' * @param Joomla\CMS\Installer\InstallerAdapter $adapter The object responsible for running this script'; + . ' * @param InstallerAdapter $adapter The object responsible for running this script'; $script .= PHP_EOL . Indent::_(1) . ' *'; $script .= PHP_EOL . Indent::_(1) . ' * @return boolean True on success'; @@ -296,12 +384,6 @@ */ protected function flight(string $name): string { - // return empty string if not set - if (empty($this->{$name . 'Active'})) - { - return ''; - } - // the pre/post function types $script = PHP_EOL . PHP_EOL . Indent::_(1) . '/**'; $script .= PHP_EOL . Indent::_(1) @@ -310,7 +392,7 @@ $script .= PHP_EOL . Indent::_(1) . ' * @param string $route Which action is happening (install|uninstall|discover_install|update)'; $script .= PHP_EOL . Indent::_(1) - . ' * @param Joomla\CMS\Installer\InstallerAdapter $adapter The object responsible for running this script'; + . ' * @param InstallerAdapter $adapter The object responsible for running this script'; $script .= PHP_EOL . Indent::_(1) . ' *'; $script .= PHP_EOL . Indent::_(1) . ' * @return boolean True on success'; @@ -319,9 +401,9 @@ . $name . '($route, $adapter)'; $script .= PHP_EOL . Indent::_(1) . '{'; $script .= PHP_EOL . Indent::_(2) . '//' . Line::_(__Line__, __Class__) - . ' get application'; + . ' set application to local method var, just use $this->app in future [we will drop $app in J6]'; $script .= PHP_EOL . Indent::_(2) - . '$app = Factory::getApplication();' . PHP_EOL; + . '$app = $this->app;' . PHP_EOL; // add the default version check (TODO) must make this dynamic if ('preflight' === $name) @@ -329,36 +411,87 @@ $script .= PHP_EOL . Indent::_(2) . '//' . Line::_(__Line__, __Class__) .' the default for both install and update'; $script .= PHP_EOL . Indent::_(2) - . '$jversion = new JVersion();'; + . '$jversion = new Version();'; $script .= PHP_EOL . Indent::_(2) - . "if (!\$jversion->isCompatible('3.8.0'))"; + . "if (!\$jversion->isCompatible('5.0.0'))"; $script .= PHP_EOL . Indent::_(2) . '{'; $script .= PHP_EOL . Indent::_(3) - . "\$app->enqueueMessage('Please upgrade to at least Joomla! 3.8.0 before continuing!', 'error');"; + . "\$app->enqueueMessage('Please upgrade to at least Joomla! 5.0.0 before continuing!', 'error');"; $script .= PHP_EOL . Indent::_(3) . 'return false;'; $script .= PHP_EOL . Indent::_(2) . '}' . PHP_EOL; } - // now add the scripts - foreach ($this->{$name . 'Bucket'} as $route => $_script) + if (!empty($this->{$name . 'Active'})) { - if (ArrayHelper::check($_script)) + // now add the scripts + foreach ($this->{$name . 'Bucket'} as $route => $_script) { - // set the if and script - $script .= PHP_EOL . Indent::_(2) . "if ('" . $route - . "' === \$route)"; - $script .= PHP_EOL . Indent::_(2) . '{'; - $script .= PHP_EOL . implode( - PHP_EOL . PHP_EOL, $_script - ); - $script .= PHP_EOL . Indent::_(2) . '}' . PHP_EOL; + if (ArrayHelper::check($_script) && $route !== 'bottom') + { + // set the if and script + $script .= PHP_EOL . Indent::_(2) . "if ('" . $route + . "' === \$route)"; + $script .= PHP_EOL . Indent::_(2) . '{'; + $script .= PHP_EOL . implode( + PHP_EOL . PHP_EOL, $_script + ); + $script .= PHP_EOL . Indent::_(2) . '}' . PHP_EOL; + } } } + if (isset($this->{$name . 'Bucket'}['bottom']) && ArrayHelper::check($this->{$name . 'Bucket'}['bottom'])) + { + $script .= PHP_EOL . implode( + PHP_EOL , $this->{$name . 'Bucket'}['bottom'] + ) . PHP_EOL; + } + // return true $script .= PHP_EOL . Indent::_(2) . 'return true;'; // close the function $script .= PHP_EOL . Indent::_(1) . '}'; + return $script; + } + + /** + * build remove files methods + * + * @return string + * @since 5.0.2 + */ + protected function removeFiles(): string + { + $script = PHP_EOL . PHP_EOL . Indent::_(1) . '/**'; + $script .= PHP_EOL . Indent::_(1) . ' * Remove the files and folders in the given array from'; + $script .= PHP_EOL . Indent::_(1) . ' *'; + $script .= PHP_EOL . Indent::_(1) . ' * @return void'; + $script .= PHP_EOL . Indent::_(1) . ' * @since 5.0.2'; + $script .= PHP_EOL . Indent::_(1) . ' */'; + $script .= PHP_EOL . Indent::_(1) . 'protected function removeFiles()'; + $script .= PHP_EOL . Indent::_(1) . '{'; + $script .= PHP_EOL . Indent::_(2) . 'if (!empty($this->deleteFiles))'; + $script .= PHP_EOL . Indent::_(2) . '{'; + $script .= PHP_EOL . Indent::_(3) . 'foreach ($this->deleteFiles as $file)'; + $script .= PHP_EOL . Indent::_(3) . '{'; + $script .= PHP_EOL . Indent::_(4) . 'if (is_file(JPATH_ROOT . $file) && !File::delete(JPATH_ROOT . $file))'; + $script .= PHP_EOL . Indent::_(4) . '{'; + $script .= PHP_EOL . Indent::_(5) . 'echo Text::sprintf(\'JLIB_INSTALLER_ERROR_FILE_FOLDER\', $file) . \'
\';'; + $script .= PHP_EOL . Indent::_(4) . '}'; + $script .= PHP_EOL . Indent::_(3) . '}'; + $script .= PHP_EOL . Indent::_(2) . '}'; + $script .= PHP_EOL . PHP_EOL . Indent::_(2) . 'if (!empty($this->deleteFolders))'; + $script .= PHP_EOL . Indent::_(2) . '{'; + $script .= PHP_EOL . Indent::_(3) . 'foreach ($this->deleteFolders as $folder)'; + $script .= PHP_EOL . Indent::_(3) . '{'; + $script .= PHP_EOL . Indent::_(4) . 'if (is_dir(JPATH_ROOT . $folder) && !Folder::delete(JPATH_ROOT . $folder))'; + $script .= PHP_EOL . Indent::_(4) . '{'; + $script .= PHP_EOL . Indent::_(5) . 'echo Text::sprintf(\'JLIB_INSTALLER_ERROR_FILE_FOLDER\', $folder) . \'
\';'; + $script .= PHP_EOL . Indent::_(4) . '}'; + $script .= PHP_EOL . Indent::_(3) . '}'; + $script .= PHP_EOL . Indent::_(2) . '}'; + $script .= PHP_EOL . Indent::_(1) . '}'; + return $script; } \ No newline at end of file diff --git a/src/763d137c-42bc-4282-98d8-cc5c0654985f/README.md b/src/763d137c-42bc-4282-98d8-cc5c0654985f/README.md index 1e7fdb2..a99326f 100644 --- a/src/763d137c-42bc-4282-98d8-cc5c0654985f/README.md +++ b/src/763d137c-42bc-4282-98d8-cc5c0654985f/README.md @@ -35,6 +35,7 @@ class Injector #Gold { # shouldAddTraitStatement(object $power) : bool # handleTraitLogic(string $name, object $power, ...) : void # addUseStatement(string $name, string $className, ...) : void + # countPartsInString(string $string) : int # addUseStatements(string $code, ?array $useStatements) : string # addLines(string $code, string $lines) : string # addLinesAfterDefinedLine(string $code, string $lines) : string @@ -173,21 +174,28 @@ note left of Injector::addUseStatement string $namespaceStatement end note -note right of Injector::addUseStatements +note right of Injector::countPartsInString + Counts the number of parts in a string separated by backslashes. + + since: 5.0.2 + return: int +end note + +note left of Injector::addUseStatements Insert a line before the class declaration in the given class code. since: 3.2.0 return: string end note -note left of Injector::addLines +note right of Injector::addLines Insert a line before the class declaration in the given class code. since: 3.2.0 return: string end note -note right of Injector::addLinesAfterDefinedLine +note left of Injector::addLinesAfterDefinedLine Inserts a new line after the defined('_JEXEC') line. since: 3.2.0 diff --git a/src/763d137c-42bc-4282-98d8-cc5c0654985f/code.php b/src/763d137c-42bc-4282-98d8-cc5c0654985f/code.php index d55c2ac..08bd614 100644 --- a/src/763d137c-42bc-4282-98d8-cc5c0654985f/code.php +++ b/src/763d137c-42bc-4282-98d8-cc5c0654985f/code.php @@ -16,6 +16,7 @@ use VDM\Joomla\Componentbuilder\Compiler\Interfaces\PowerInterface as Power; use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Power\ExtractorInterface as Extractor; use VDM\Joomla\Componentbuilder\Power\Parser; use VDM\Joomla\Componentbuilder\Compiler\Placeholder; +use VDM\Joomla\Utilities\ArrayHelper; use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Power\InjectorInterface; @@ -476,6 +477,12 @@ class Injector implements InjectorInterface */ protected function addUseStatement(string &$name, string $className, string $namespaceStatement): void { + // we don't add use statements with just one part + if ($this->countPartsInString($namespaceStatement) <= 1) + { + return; // we just update the code + } + if ($name !== $className) { $statement = 'use ' . $namespaceStatement . ' as ' . $name . ';'; @@ -488,6 +495,27 @@ class Injector implements InjectorInterface $this->useStatements[$name] = $statement; } + /** + * Counts the number of parts in a string separated by backslashes. + * + * @param string $string The input string to be evaluated. + * + * @return int The number of parts separated by backslashes. + * @since 5.0.2 + */ + protected function countPartsInString(string $string): int + { + // Split the string by the backslash + $parts = explode('\\', $string); + + // Count the number of parts and return the result + if (($number = ArrayHelper::check($parts, true)) !== false) + { + return $number; + } + return 0; + } + /** * Insert a line before the class declaration in the given class code. * diff --git a/src/763d137c-42bc-4282-98d8-cc5c0654985f/code.power b/src/763d137c-42bc-4282-98d8-cc5c0654985f/code.power index bd84e86..a58cbf6 100644 --- a/src/763d137c-42bc-4282-98d8-cc5c0654985f/code.power +++ b/src/763d137c-42bc-4282-98d8-cc5c0654985f/code.power @@ -449,6 +449,12 @@ */ protected function addUseStatement(string &$name, string $className, string $namespaceStatement): void { + // we don't add use statements with just one part + if ($this->countPartsInString($namespaceStatement) <= 1) + { + return; // we just update the code + } + if ($name !== $className) { $statement = 'use ' . $namespaceStatement . ' as ' . $name . ';'; @@ -461,6 +467,27 @@ $this->useStatements[$name] = $statement; } + /** + * Counts the number of parts in a string separated by backslashes. + * + * @param string $string The input string to be evaluated. + * + * @return int The number of parts separated by backslashes. + * @since 5.0.2 + */ + protected function countPartsInString(string $string): int + { + // Split the string by the backslash + $parts = explode('\\', $string); + + // Count the number of parts and return the result + if (($number = ArrayHelper::check($parts, true)) !== false) + { + return $number; + } + return 0; + } + /** * Insert a line before the class declaration in the given class code. * diff --git a/src/763d137c-42bc-4282-98d8-cc5c0654985f/settings.json b/src/763d137c-42bc-4282-98d8-cc5c0654985f/settings.json index d9fc868..a072526 100644 --- a/src/763d137c-42bc-4282-98d8-cc5c0654985f/settings.json +++ b/src/763d137c-42bc-4282-98d8-cc5c0654985f/settings.json @@ -27,6 +27,10 @@ "use_selection3": { "use": "06453ada-e370-49f0-b262-e3f5a8ed0c2c", "as": "default" + }, + "use_selection4": { + "use": "0a59c65c-9daf-4bc9-baf4-e063ff9e6a8a", + "as": "default" } }, "extendsinterfaces": null, diff --git a/src/766a9524-37df-4604-91a7-b98a6150ee26/README.md b/src/766a9524-37df-4604-91a7-b98a6150ee26/README.md index 2e75fa9..fcfa498 100644 --- a/src/766a9524-37df-4604-91a7-b98a6150ee26/README.md +++ b/src/766a9524-37df-4604-91a7-b98a6150ee26/README.md @@ -6,12 +6,12 @@ ██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║ ╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝ ``` -# class Data (Details) -> namespace: **VDM\Joomla\Componentbuilder\Compiler\Joomlaplugin** +# final class Data (Details) +> namespace: **VDM\Joomla\Componentbuilder\Compiler\Joomlaplugin\JoomlaThree** ```uml @startuml -class Data #Gold { +class Data << (F,LightGreen) >> #RoyalBlue { # array $data # Config $config # Customcode $customcode @@ -19,29 +19,29 @@ class Data #Gold { # Placeholder $placeholder # Language $language # Field $field - # FieldName $fieldName - # Filesfolders $filesFolders + # FieldName $fieldname + # Filesfolders $filesfolders # $db - + __construct(?Config $config = null, ?Customcode $customcode = null, ...) + + __construct(Config $config, Customcode $customcode, ...) + get(int $id = null) : object|array|null + exists(int $id = null) : bool + set(int $id) : bool } note right of Data::__construct - Constructor + Constructor. - since: 3.2.0 + since: 5.0.2 arguments: - ?Config $config = null - ?Customcode $customcode = null - ?Gui $gui = null - ?Placeholder $placeholder = null - ?Language $language = null - ?Field $field = null - ?FieldName $fieldName = null - ?Filesfolders $filesFolders = null + Config $config + Customcode $customcode + Gui $gui + Placeholder $placeholder + Language $language + Field $field + FieldName $fieldname + Filesfolders $filesfolders end note note right of Data::get diff --git a/src/766a9524-37df-4604-91a7-b98a6150ee26/code.php b/src/766a9524-37df-4604-91a7-b98a6150ee26/code.php index a328bd7..9ae35e9 100644 --- a/src/766a9524-37df-4604-91a7-b98a6150ee26/code.php +++ b/src/766a9524-37df-4604-91a7-b98a6150ee26/code.php @@ -9,12 +9,11 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ -namespace VDM\Joomla\Componentbuilder\Compiler\Joomlaplugin; +namespace VDM\Joomla\Componentbuilder\Compiler\Joomlaplugin\JoomlaThree; use Joomla\CMS\Factory; use Joomla\CMS\Filter\OutputFilter; -use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler; use VDM\Joomla\Componentbuilder\Compiler\Config; use VDM\Joomla\Componentbuilder\Compiler\Customcode; use VDM\Joomla\Componentbuilder\Compiler\Customcode\Gui; @@ -29,17 +28,18 @@ use VDM\Joomla\Utilities\String\PluginHelper; use VDM\Joomla\Utilities\JsonHelper; use VDM\Joomla\Utilities\StringHelper; use VDM\Joomla\Utilities\GetHelper; +use VDM\Joomla\Componentbuilder\Compiler\Interfaces\PluginDataInterface; /** - * Joomla Plugin Data Class + * Joomla 3 Plug-in Data Class * * @since 3.2.0 */ -class Data +final class Data implements PluginDataInterface { /** - * Compiler Joomla Plugins Data + * Compiler Joomla Plug-in's Data * * @var array * @since 3.2.0 @@ -47,68 +47,68 @@ class Data protected array $data = []; /** - * Compiler Config + * The Configure Class. * - * @var Config - * @since 3.2.0 + * @var Config + * @since 5.0.2 */ protected Config $config; /** - * Compiler Customcode + * The Customcode Class. * - * @var Customcode - * @since 3.2.0 + * @var Customcode + * @since 5.0.2 */ protected Customcode $customcode; /** - * Compiler Customcode in Gui + * The Gui Class. * - * @var Gui - * @since 3.2.0 - **/ + * @var Gui + * @since 5.0.2 + */ protected Gui $gui; /** - * Compiler Placeholder + * The Placeholder Class. * - * @var Placeholder - * @since 3.2.0 - **/ + * @var Placeholder + * @since 5.0.2 + */ protected Placeholder $placeholder; /** - * Compiler Language + * The Language Class. * - * @var Language - * @since 3.2.0 - **/ + * @var Language + * @since 5.0.2 + */ protected Language $language; /** - * Compiler Field + * The Field Class. * - * @var Field - * @since 3.2.0 + * @var Field + * @since 5.0.2 */ protected Field $field; /** - * Compiler field name + * The Name Class. * - * @var FieldName - * @since 3.2.0 + * @var FieldName + * @since 5.0.2 */ - protected FieldName $fieldName; + protected FieldName $fieldname; /** - * Compiler Files Folders + * The Filesfolders Class. * - * @var Filesfolders - * @since 3.2.0 + * @var Filesfolders + * @since 5.0.2 */ - protected Filesfolders $filesFolders; + protected Filesfolders $filesfolders; /** * Database object to query local DB @@ -118,32 +118,32 @@ class Data protected $db; /** - * Constructor + * Constructor. * - * @param Config|null $config The compiler config object. - * @param Customcode|null $customcode The compiler customcode object. - * @param Gui|null $gui The compiler customcode gui. - * @param Placeholder|null $placeholder The compiler placeholder object. - * @param Language|null $language The compiler Language object. - * @param Field|null $field The compiler field data object. - * @param FieldName|null $fieldName The compiler field name object. - * @param Filesfolders|null $filesFolders The compiler files folders object. + * @param Config $config The Config Class. + * @param Customcode $customcode The Customcode Class. + * @param Gui $gui The Gui Class. + * @param Placeholder $placeholder The Placeholder Class. + * @param Language $language The Language Class. + * @param Field $field The Field Class. + * @param FieldName $fieldname The Name Class. + * @param Filesfolders $filesfolders The Filesfolders Class. * - * @since 3.2.0 + * @since 5.0.2 */ - public function __construct(?Config $config = null, ?Customcode $customcode = null, - ?Gui $gui = null, ?Placeholder $placeholder = null, - ?Language $language = null, ?Field $field = null, ?FieldName $fieldName = null, - ?Filesfolders $filesFolders = null) + public function __construct(Config $config, Customcode $customcode, Gui $gui, + Placeholder $placeholder, Language $language, + Field $field, FieldName $fieldname, + Filesfolders $filesfolders) { - $this->config = $config ?: Compiler::_('Config'); - $this->customcode = $customcode ?: Compiler::_('Customcode'); - $this->gui = $gui ?: Compiler::_('Customcode.Gui'); - $this->placeholder = $placeholder ?: Compiler::_('Placeholder'); - $this->language = $language ?: Compiler::_('Language'); - $this->field = $field ?: Compiler::_('Field'); - $this->fieldName = $fieldName ?: Compiler::_('Field.Name'); - $this->filesFolders = $filesFolders ?: Compiler::_('Model.Filesfolders'); + $this->config = $config; + $this->customcode = $customcode; + $this->gui = $gui; + $this->placeholder = $placeholder; + $this->language = $language; + $this->field = $field; + $this->fieldname = $fieldname; + $this->filesfolders = $filesfolders; $this->db = Factory::getDbo(); } @@ -454,7 +454,7 @@ class Data // set GUI mapper field $guiMapper['field'] = 'head'; // base64 Decode head. - $plugin->head = $this->gui->set( + $plugin->header = $this->gui->set( $this->placeholder->update_( $this->customcode->update( base64_decode((string) $plugin->head) @@ -466,7 +466,7 @@ class Data elseif (!empty($plugin->class_head)) { // base64 Decode head. - $plugin->head = $this->gui->set( + $plugin->header = $this->gui->set( $this->placeholder->update_( $this->customcode->update( base64_decode((string) $plugin->class_head) @@ -683,7 +683,7 @@ class Data foreach ($form['fields'] as $field) { // so first we lock the field name in - $this->fieldName->get( + $this->fieldname->get( $field, $plugin->key, $unique ); // add the fields to the global form file builder @@ -710,7 +710,7 @@ class Data foreach ($form['fields'] as $field) { // so first we lock the field name in - $this->fieldName->get( + $this->fieldname->get( $field, $plugin->key, $unique ); // add the fields to the config builder @@ -730,19 +730,21 @@ class Data unset($plugin->fields); // set files and folders - $this->filesFolders->set($plugin); + $this->filesfolders->set($plugin); // add PHP in plugin install $plugin->add_install_script = true; $addScriptMethods = [ 'php_preflight', 'php_postflight', - 'php_method' + 'php_method', + 'php_script' ]; $addScriptTypes = [ 'install', 'update', - 'uninstall' + 'uninstall', + 'construct' ]; foreach ($addScriptMethods as $scriptMethod) { @@ -873,7 +875,6 @@ class Data } return false; - } - + } } diff --git a/src/766a9524-37df-4604-91a7-b98a6150ee26/code.power b/src/766a9524-37df-4604-91a7-b98a6150ee26/code.power index 870060b..8b72eaa 100644 --- a/src/766a9524-37df-4604-91a7-b98a6150ee26/code.power +++ b/src/766a9524-37df-4604-91a7-b98a6150ee26/code.power @@ -1,5 +1,5 @@ /** - * Compiler Joomla Plugins Data + * Compiler Joomla Plug-in's Data * * @var array * @since 3.2.0 @@ -7,68 +7,68 @@ protected array $data = []; /** - * Compiler Config + * The Configure Class. * - * @var Config - * @since 3.2.0 + * @var Config + * @since 5.0.2 */ protected Config $config; /** - * Compiler Customcode + * The Customcode Class. * - * @var Customcode - * @since 3.2.0 + * @var Customcode + * @since 5.0.2 */ protected Customcode $customcode; /** - * Compiler Customcode in Gui + * The Gui Class. * - * @var Gui - * @since 3.2.0 - **/ + * @var Gui + * @since 5.0.2 + */ protected Gui $gui; /** - * Compiler Placeholder + * The Placeholder Class. * - * @var Placeholder - * @since 3.2.0 - **/ + * @var Placeholder + * @since 5.0.2 + */ protected Placeholder $placeholder; /** - * Compiler Language + * The Language Class. * - * @var Language - * @since 3.2.0 - **/ + * @var Language + * @since 5.0.2 + */ protected Language $language; /** - * Compiler Field + * The Field Class. * - * @var Field - * @since 3.2.0 + * @var Field + * @since 5.0.2 */ protected Field $field; /** - * Compiler field name + * The Name Class. * - * @var FieldName - * @since 3.2.0 + * @var FieldName + * @since 5.0.2 */ - protected FieldName $fieldName; + protected FieldName $fieldname; /** - * Compiler Files Folders + * The Filesfolders Class. * - * @var Filesfolders - * @since 3.2.0 + * @var Filesfolders + * @since 5.0.2 */ - protected Filesfolders $filesFolders; + protected Filesfolders $filesfolders; /** * Database object to query local DB @@ -78,32 +78,32 @@ protected $db; /** - * Constructor + * Constructor. * - * @param Config|null $config The compiler config object. - * @param Customcode|null $customcode The compiler customcode object. - * @param Gui|null $gui The compiler customcode gui. - * @param Placeholder|null $placeholder The compiler placeholder object. - * @param Language|null $language The compiler Language object. - * @param Field|null $field The compiler field data object. - * @param FieldName|null $fieldName The compiler field name object. - * @param Filesfolders|null $filesFolders The compiler files folders object. + * @param Config $config The Config Class. + * @param Customcode $customcode The Customcode Class. + * @param Gui $gui The Gui Class. + * @param Placeholder $placeholder The Placeholder Class. + * @param Language $language The Language Class. + * @param Field $field The Field Class. + * @param FieldName $fieldname The Name Class. + * @param Filesfolders $filesfolders The Filesfolders Class. * - * @since 3.2.0 + * @since 5.0.2 */ - public function __construct(?Config $config = null, ?Customcode $customcode = null, - ?Gui $gui = null, ?Placeholder $placeholder = null, - ?Language $language = null, ?Field $field = null, ?FieldName $fieldName = null, - ?Filesfolders $filesFolders = null) + public function __construct(Config $config, Customcode $customcode, Gui $gui, + Placeholder $placeholder, Language $language, + Field $field, FieldName $fieldname, + Filesfolders $filesfolders) { - $this->config = $config ?: Compiler::_('Config'); - $this->customcode = $customcode ?: Compiler::_('Customcode'); - $this->gui = $gui ?: Compiler::_('Customcode.Gui'); - $this->placeholder = $placeholder ?: Compiler::_('Placeholder'); - $this->language = $language ?: Compiler::_('Language'); - $this->field = $field ?: Compiler::_('Field'); - $this->fieldName = $fieldName ?: Compiler::_('Field.Name'); - $this->filesFolders = $filesFolders ?: Compiler::_('Model.Filesfolders'); + $this->config = $config; + $this->customcode = $customcode; + $this->gui = $gui; + $this->placeholder = $placeholder; + $this->language = $language; + $this->field = $field; + $this->fieldname = $fieldname; + $this->filesfolders = $filesfolders; $this->db = Factory::getDbo(); } @@ -414,7 +414,7 @@ // set GUI mapper field $guiMapper['field'] = 'head'; // base64 Decode head. - $plugin->head = $this->gui->set( + $plugin->header = $this->gui->set( $this->placeholder->update_( $this->customcode->update( base64_decode((string) $plugin->head) @@ -426,7 +426,7 @@ elseif (!empty($plugin->class_head)) { // base64 Decode head. - $plugin->head = $this->gui->set( + $plugin->header = $this->gui->set( $this->placeholder->update_( $this->customcode->update( base64_decode((string) $plugin->class_head) @@ -643,7 +643,7 @@ foreach ($form['fields'] as $field) { // so first we lock the field name in - $this->fieldName->get( + $this->fieldname->get( $field, $plugin->key, $unique ); // add the fields to the global form file builder @@ -670,7 +670,7 @@ foreach ($form['fields'] as $field) { // so first we lock the field name in - $this->fieldName->get( + $this->fieldname->get( $field, $plugin->key, $unique ); // add the fields to the config builder @@ -690,19 +690,21 @@ unset($plugin->fields); // set files and folders - $this->filesFolders->set($plugin); + $this->filesfolders->set($plugin); // add PHP in plugin install $plugin->add_install_script = true; $addScriptMethods = [ 'php_preflight', 'php_postflight', - 'php_method' + 'php_method', + 'php_script' ]; $addScriptTypes = [ 'install', 'update', - 'uninstall' + 'uninstall', + 'construct' ]; foreach ($addScriptMethods as $scriptMethod) { @@ -833,4 +835,4 @@ } return false; - } + } \ No newline at end of file diff --git a/src/766a9524-37df-4604-91a7-b98a6150ee26/settings.json b/src/766a9524-37df-4604-91a7-b98a6150ee26/settings.json index ba98333..14c525b 100644 --- a/src/766a9524-37df-4604-91a7-b98a6150ee26/settings.json +++ b/src/766a9524-37df-4604-91a7-b98a6150ee26/settings.json @@ -3,77 +3,75 @@ "add_licensing_template": "2", "extends": "", "guid": "766a9524-37df-4604-91a7-b98a6150ee26", - "implements": null, + "implements": [ + "8cc85656-a925-4a46-a49b-83c72167fd6a" + ], "load_selection": null, "name": "Data", "power_version": "1.0.0", - "system_name": "JCB.Compiler.Joomlaplugin.Data", - "type": "class", + "system_name": "JCB.Compiler.Joomlaplugin.J3.Data", + "type": "final class", "use_selection": { "use_selection0": { - "use": "d910d8b8-4c23-4f3e-8cda-438f2d2bd7ac", - "as": "Compiler" - }, - "use_selection1": { "use": "fa4bf18e-301e-42e3-91fb-6e0096c07adc", "as": "default" }, - "use_selection2": { + "use_selection1": { "use": "313b43c4-98c3-4f62-9177-2d73ec8eba31", "as": "default" }, - "use_selection3": { + "use_selection2": { "use": "1bd48df2-4f7e-4581-9fe9-4b54e59105e3", "as": "default" }, - "use_selection4": { + "use_selection3": { "use": "06453ada-e370-49f0-b262-e3f5a8ed0c2c", "as": "default" }, - "use_selection5": { + "use_selection4": { "use": "8eee7df5-2775-41a9-9372-c46c5939a252", "as": "default" }, - "use_selection6": { + "use_selection5": { "use": "d7ba2d5d-10b6-470d-978d-9f91ea65ee75", "as": "default" }, - "use_selection7": { + "use_selection6": { "use": "9387215f-a965-4421-acf3-5e8f9d11382f", "as": "FieldName" }, - "use_selection8": { + "use_selection7": { "use": "f4578c04-a81e-4218-b80d-b0612196eaf0", "as": "default" }, - "use_selection9": { + "use_selection8": { "use": "0a59c65c-9daf-4bc9-baf4-e063ff9e6a8a", "as": "default" }, - "use_selection10": { + "use_selection9": { "use": "30c5b4c2-f75f-4d15-869a-f8bfedd87358", "as": "default" }, - "use_selection11": { + "use_selection10": { "use": "3cf76fbf-fd95-4a33-878e-7aff6d36b7f6", "as": "default" }, - "use_selection12": { + "use_selection11": { "use": "4b225c51-d293-48e4-b3f6-5136cf5c3f18", "as": "default" }, - "use_selection13": { + "use_selection12": { "use": "1f28cb53-60d9-4db1-b517-3c7dc6b429ef", "as": "default" }, - "use_selection14": { + "use_selection13": { "use": "db87c339-5bb6-4291-a7ef-2c48ea1b06bc", "as": "default" } }, "extendsinterfaces": null, - "namespace": "[[[NamespacePrefix]]]\\Joomla\\[[[ComponentNamespace]]].Compiler.Joomlaplugin.Data", - "description": "Joomla Plugin Data Class\r\n\r\n@since 3.2.0", + "namespace": "[[[NamespacePrefix]]]\\Joomla\\[[[ComponentNamespace]]].Compiler.Joomlaplugin.JoomlaThree.Data", + "description": "Joomla 3 Plug-in Data Class\r\n\r\n@since 3.2.0", "licensing_template": "\/**\r\n * @package Joomla.Component.Builder\r\n *\r\n * @created 4th September, 2022\r\n * @author Llewellyn van der Merwe \r\n * @git Joomla Component Builder \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;\r\nuse Joomla\\CMS\\Filter\\OutputFilter;", "composer": "" diff --git a/src/77224dc6-8024-47eb-896e-18ec3aa23420/code.php b/src/77224dc6-8024-47eb-896e-18ec3aa23420/code.php index f38ac5e..0c432fd 100644 --- a/src/77224dc6-8024-47eb-896e-18ec3aa23420/code.php +++ b/src/77224dc6-8024-47eb-896e-18ec3aa23420/code.php @@ -13,8 +13,9 @@ namespace VDM\Joomla\Componentbuilder\Compiler\JoomlaFive; use Joomla\CMS\Factory; -use Joomla\Registry\Registry; -use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\Event\DispatcherInterface; +use Joomla\Registry\Registry; use VDM\Joomla\Utilities\Component\Helper; use VDM\Joomla\Componentbuilder\Compiler\Interfaces\EventInterface; @@ -35,9 +36,9 @@ class Event implements EventInterface protected $activePlugins = false; /** - * The application to trigger and event TODO + * The dispatcher to get events * - * @since 3.2.0 + * @since 5.0.2 */ protected $dispatcher; @@ -69,7 +70,7 @@ class Event implements EventInterface } } - $this->dispatcher = Factory::getApplication(); + $this->dispatcher = Factory::getContainer()->get(DispatcherInterface::class); } /** @@ -89,8 +90,13 @@ class Event implements EventInterface { try { - // Trigger this compiler event. - $results = $this->dispatcher->triggerEvent($event, $data ?? []); + $data ??= []; + $listeners = $this->dispatcher->getListeners($event); + foreach ($listeners as $listener) + { + // Call the listener with the unpacked arguments + $listener(...$data); + } } catch (\Exception $e) { diff --git a/src/77224dc6-8024-47eb-896e-18ec3aa23420/code.power b/src/77224dc6-8024-47eb-896e-18ec3aa23420/code.power index 4527c51..4825283 100644 --- a/src/77224dc6-8024-47eb-896e-18ec3aa23420/code.power +++ b/src/77224dc6-8024-47eb-896e-18ec3aa23420/code.power @@ -7,9 +7,9 @@ protected $activePlugins = false; /** - * The application to trigger and event TODO + * The dispatcher to get events * - * @since 3.2.0 + * @since 5.0.2 */ protected $dispatcher; @@ -41,7 +41,7 @@ } } - $this->dispatcher = Factory::getApplication(); + $this->dispatcher = Factory::getContainer()->get(DispatcherInterface::class); } /** @@ -61,8 +61,13 @@ { try { - // Trigger this compiler event. - $results = $this->dispatcher->triggerEvent($event, $data ?? []); + $data ??= []; + $listeners = $this->dispatcher->getListeners($event); + foreach ($listeners as $listener) + { + // Call the listener with the unpacked arguments + $listener(...$data); + } } catch (\Exception $e) { diff --git a/src/77224dc6-8024-47eb-896e-18ec3aa23420/settings.json b/src/77224dc6-8024-47eb-896e-18ec3aa23420/settings.json index 34f2278..cf8b6e6 100644 --- a/src/77224dc6-8024-47eb-896e-18ec3aa23420/settings.json +++ b/src/77224dc6-8024-47eb-896e-18ec3aa23420/settings.json @@ -21,6 +21,6 @@ "namespace": "[[[NamespacePrefix]]]\\Joomla\\[[[ComponentNamespace]]].Compiler.JoomlaFive.Event", "description": "Compiler Events\r\n\r\n@since 3.2.0", "licensing_template": "\/**\r\n * @package Joomla.Component.Builder\r\n *\r\n * @created 4th September, 2022\r\n * @author Llewellyn van der Merwe \r\n * @git Joomla Component Builder \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;\r\nuse Joomla\\Registry\\Registry;\r\nuse Joomla\\CMS\\Plugin\\PluginHelper;", + "head": "use Joomla\\CMS\\Factory;\r\nuse Joomla\\CMS\\Plugin\\PluginHelper;\r\nuse Joomla\\Event\\DispatcherInterface;\r\nuse Joomla\\Registry\\Registry;", "composer": "" } \ No newline at end of file diff --git a/src/7b56a097-9979-477b-b18a-c9dfc2f1e13b/code.php b/src/7b56a097-9979-477b-b18a-c9dfc2f1e13b/code.php index b48b73b..bf46f1a 100644 --- a/src/7b56a097-9979-477b-b18a-c9dfc2f1e13b/code.php +++ b/src/7b56a097-9979-477b-b18a-c9dfc2f1e13b/code.php @@ -205,6 +205,11 @@ final class Header implements HeaderInterface $headers[] = 'use Joomla\CMS\Helper\TagsHelper;'; break; + case 'plugin.extension.header': + case 'plugin.provider.header': + $headers = []; + break; + default: break; } diff --git a/src/7b56a097-9979-477b-b18a-c9dfc2f1e13b/code.power b/src/7b56a097-9979-477b-b18a-c9dfc2f1e13b/code.power index 8b3e599..6cb26e4 100644 --- a/src/7b56a097-9979-477b-b18a-c9dfc2f1e13b/code.power +++ b/src/7b56a097-9979-477b-b18a-c9dfc2f1e13b/code.power @@ -169,6 +169,11 @@ $headers[] = 'use Joomla\CMS\Helper\TagsHelper;'; break; + case 'plugin.extension.header': + case 'plugin.provider.header': + $headers = []; + break; + default: break; } diff --git a/src/7f75b300-534c-4f63-a368-6f4abc4cea58/README.md b/src/7f75b300-534c-4f63-a368-6f4abc4cea58/README.md new file mode 100644 index 0000000..e364dcc --- /dev/null +++ b/src/7f75b300-534c-4f63-a368-6f4abc4cea58/README.md @@ -0,0 +1,176 @@ +``` +██████╗ ██████╗ ██╗ ██╗███████╗██████╗ +██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗ +██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝ +██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗ +██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║ +╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝ +``` +# final class Infusion (Details) +> namespace: **VDM\Joomla\Componentbuilder\Compiler\Joomlaplugin\JoomlaFive** + +```uml +@startuml +class Infusion << (F,LightGreen) >> #RoyalBlue { + # Config $config + # Placeholder $placeholder + # Header $header + # Event $event + # Data $data + # InstallScript $installscript + # Extension $extension + # Provider $provider + # MainXML $mainxml + # ContentMulti $contentmulti + # ContentOne $contentone + # FieldsetExtension $fieldsetextension + + __construct(Config $config, Placeholder $placeholder, ...) + + set() : void + # triggerBeforeInfusionEvent(object $plugin) : void + # setPlaceholders(object $plugin) : void + # buildPluginContent(object $plugin) : void + # setExtensionClassHeader(object $plugin) : void + # setExtensionClass(object $plugin) : void + # setProviderClassHeader(object $plugin) : void + # setProviderClass(object $plugin) : void + # setInstallClass(object $plugin) : void + # setFieldsets(object $plugin) : void + # setMainXml(object $plugin) : void + # triggerAfterInfusionEvent(object $plugin) : void +} + +note right of Infusion::__construct + Constructor. + + since: 5.0.2 + + arguments: + Config $config + Placeholder $placeholder + Header $header + Event $event + Data $data + InstallScript $installscript + Extension $extension + Provider $provider + MainXML $mainxml + ContentMulti $contentmulti + ContentOne $contentone + FieldsetExtension $fieldsetextension +end note + +note left of Infusion::set + Infuse the plugin data into the content. +This method processes each plugin in the data set, triggering events +before and after infusion, setting placeholders, and adding content +such as headers, classes, and XML configurations. + + since: 5.0.2 + return: void +end note + +note right of Infusion::triggerBeforeInfusionEvent + Trigger the event before infusing the plugin data. + + since: 5.0.2 + return: void +end note + +note left of Infusion::setPlaceholders + Set placeholders based on plugin data. + + since: 5.0.2 + return: void +end note + +note right of Infusion::buildPluginContent + Build and set the content related to the plugin. + + since: 5.0.2 + return: void +end note + +note left of Infusion::setExtensionClassHeader + Set the extension class header content. + + since: 5.0.2 + return: void +end note + +note right of Infusion::setExtensionClass + Set the extension class content. + + since: 5.0.2 + return: void +end note + +note left of Infusion::setProviderClassHeader + Set the provider class header content. + + since: 5.0.2 + return: void +end note + +note right of Infusion::setProviderClass + Set the provider class content. + + since: 5.0.2 + return: void +end note + +note left of Infusion::setInstallClass + Set the install script content, if needed. + + since: 5.0.2 + return: void +end note + +note right of Infusion::setFieldsets + Set fieldset content based on form files. + + since: 5.0.2 + return: void +end note + +note left of Infusion::setMainXml + Set the main XML content for the plugin. + + since: 5.0.2 + return: void +end note + +note right of Infusion::triggerAfterInfusionEvent + Trigger the event after infusing the plugin data. + + since: 5.0.2 + return: void +end note + +@enduml +``` + +The Power feature in JCB allows you to write PHP classes and their implementations, making it easy to include them in your Joomla project. JCB handles linking, autoloading, namespacing, and folder structure creation for you. + +By using the SPK (Super Power Key) in your custom code (replacing the class name in your code with the SPK), JCB will automatically pull the power from the repository into your project. This makes it available in your JCB instance, allowing you to edit it and include the class in your generated Joomla component. + +JCB uses placeholders like [[[`NamespacePrefix`]]] and [[[`ComponentNamespace`]]] in namespacing to prevent collisions and improve reusability across different JCB systems. You can also set the **JCB powers path** globally or per component under the **Dynamic Integration** tab, providing flexibility and easy maintainability. + +To add this specific Power to your project in JCB: + +> simply use this SPK +``` +Super---7f75b300_534c_4f63_a368_6f4abc4cea58---Power +``` +> remember to replace the `---` with `___` to activate this Power in your code + +--- +``` + ██╗ ██████╗██████╗ + ██║██╔════╝██╔══██╗ + ██║██║ ██████╔╝ +██ ██║██║ ██╔══██╗ +╚█████╔╝╚██████╗██████╔╝ + ╚════╝ ╚═════╝╚═════╝ +``` +> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder) + diff --git a/src/7f75b300-534c-4f63-a368-6f4abc4cea58/code.php b/src/7f75b300-534c-4f63-a368-6f4abc4cea58/code.php new file mode 100644 index 0000000..d5ed7b0 --- /dev/null +++ b/src/7f75b300-534c-4f63-a368-6f4abc4cea58/code.php @@ -0,0 +1,392 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Componentbuilder\Compiler\Joomlaplugin\JoomlaFive; + + +use VDM\Joomla\Componentbuilder\Compiler\Config; +use VDM\Joomla\Componentbuilder\Compiler\Placeholder; +use VDM\Joomla\Componentbuilder\Compiler\Interfaces\HeaderInterface as Header; +use VDM\Joomla\Componentbuilder\Compiler\Interfaces\EventInterface as Event; +use VDM\Joomla\Componentbuilder\Compiler\Interfaces\PluginDataInterface as Data; +use VDM\Joomla\Componentbuilder\Compiler\Interfaces\GetScriptInterface as InstallScript; +use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Architecture\Plugin\ExtensionInterface as Extension; +use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Architecture\Plugin\ProviderInterface as Provider; +use VDM\Joomla\Componentbuilder\Interfaces\Architecture\Plugin\MainXMLInterface as MainXML; +use VDM\Joomla\Componentbuilder\Compiler\Builder\ContentMulti; +use VDM\Joomla\Componentbuilder\Compiler\Builder\ContentOne; +use VDM\Joomla\Componentbuilder\Compiler\Creator\FieldsetExtension; +use VDM\Joomla\Utilities\ObjectHelper; +use VDM\Joomla\Utilities\ArrayHelper; +use VDM\Joomla\Componentbuilder\Interfaces\Plugin\InfusionInterface; + + +/** + * Joomla 5 Plugin Infusion Class + * + * @since 5.0.2 + */ +final class Infusion implements InfusionInterface +{ + /** + * The Config Class. + * + * @var Config + * @since 5.0.2 + */ + protected Config $config; + + /** + * The Placeholder Class. + * + * @var Placeholder + * @since 5.0.2 + */ + protected Placeholder $placeholder; + + /** + * The Header Class. + * + * @var Header + * @since 5.0.2 + */ + protected Header $header; + + /** + * The Event Class. + * + * @var Event + * @since 5.0.2 + */ + protected Event $event; + + /** + * The PluginData Class. + * + * @var Data + * @since 5.0.2 + */ + protected Data $data; + + /** + * The GetScript Class. + * + * @var InstallScript + * @since 5.0.2 + */ + protected InstallScript $installscript; + + /** + * The Extension Class. + * + * @var Extension + * @since 5.0.2 + */ + protected Extension $extension; + + /** + * The Provider Class. + * + * @var Provider + * @since 5.0.2 + */ + protected Provider $provider; + + /** + * The MainXML Class. + * + * @var MainXML + * @since 5.0.2 + */ + protected MainXML $mainxml; + + /** + * The Content Multi Class. + * + * @var ContentMulti + * @since 5.0.2 + */ + protected ContentMulti $contentmulti; + + /** + * The Content One Class. + * + * @var ContentOne + * @since 5.0.2 + */ + protected ContentOne $contentone; + + /** + * The Fieldset Extension Class. + * + * @var FieldsetExtension + * @since 5.0.2 + */ + protected FieldsetExtension $fieldsetextension; + + /** + * Constructor. + * + * @param Config $config The Config Class. + * @param Placeholder $placeholder The Placeholder Class. + * @param Header $header The HeaderInterface Class. + * @param Event $event The EventInterface Class. + * @param Data $data The PluginDataInterface Class. + * @param InstallScript $installscript The GetScriptInterface Class. + * @param Extension $extension The ExtensionInterface Class. + * @param Provider $provider The ProviderInterface Class. + * @param MainXML $mainxml The MainXMLInterface Class. + * @param ContentMulti $contentmulti The ContentMulti Class. + * @param ContentOne $contentone The ContentOne Class. + * @param FieldsetExtension $fieldsetextension The FieldsetExtension Class. + * + * @since 5.0.2 + */ + public function __construct(Config $config, Placeholder $placeholder, Header $header, + Event $event, Data $data, InstallScript $installscript, + Extension $extension, Provider $provider, + MainXML $mainxml, ContentMulti $contentmulti, + ContentOne $contentone, FieldsetExtension $fieldsetextension) + { + $this->config = $config; + $this->placeholder = $placeholder; + $this->header = $header; + $this->event = $event; + $this->data = $data; + $this->installscript = $installscript; + $this->extension = $extension; + $this->provider = $provider; + $this->mainxml = $mainxml; + $this->contentmulti = $contentmulti; + $this->contentone = $contentone; + $this->fieldsetextension = $fieldsetextension; + } + + /** + * Infuse the plugin data into the content. + * + * This method processes each plugin in the data set, triggering events + * before and after infusion, setting placeholders, and adding content + * such as headers, classes, and XML configurations. + * + * @return void + * @since 5.0.2 + */ + public function set(): void + { + if (!$this->data->exists()) + { + return; + } + + foreach ($this->data->get() as $plugin) + { + if (!ObjectHelper::check($plugin)) + { + continue; + } + + $this->triggerBeforeInfusionEvent($plugin); + $this->setPlaceholders($plugin); + $this->buildPluginContent($plugin); + $this->triggerAfterInfusionEvent($plugin); + } + } + + /** + * Trigger the event before infusing the plugin data. + * + * @param object $plugin The plugin object being processed. + * + * @return void + * @since 5.0.2 + */ + protected function triggerBeforeInfusionEvent(&$plugin): void + { + $this->event->trigger('jcb_ce_onBeforeInfusePluginData', [&$plugin]); + } + + /** + * Set placeholders based on plugin data. + * + * @param object $plugin The plugin object being processed. + * + * @return void + * @since 5.0.2 + */ + protected function setPlaceholders($plugin): void + { + $this->placeholder->set('PluginGroupNamespace', $plugin->group_namespace ?? ''); + $this->placeholder->set('PluginNamespace', $plugin->namespace ?? ''); + + $this->config->build_target = $plugin->key; + $this->config->lang_target = $plugin->key; + $this->config->set('lang_prefix', $plugin->lang_prefix); + } + + /** + * Build and set the content related to the plugin. + * + * @param object $plugin The plugin object being processed. + * + * @return void + * @since 5.0.2 + */ + protected function buildPluginContent($plugin): void + { + $this->setExtensionClassHeader($plugin); + $this->setExtensionClass($plugin); + $this->setProviderClassHeader($plugin); + $this->setProviderClass($plugin); + + if ($plugin->add_install_script) + { + $this->setInstallClass($plugin); + } + + if (isset($plugin->form_files) && ArrayHelper::check($plugin->form_files)) + { + $this->setFieldsets($plugin); + } + + $this->setMainXml($plugin); + } + + /** + * Set the extension class header content. + * + * @param object $plugin The plugin object being processed. + * + * @return void + * @since 5.0.2 + */ + protected function setExtensionClassHeader($plugin): void + { + $headerContent = trim( + $this->header->get('plugin.extension.header', $plugin->class_name) + . PHP_EOL . ($plugin->header ?? '') + ); + + $this->contentmulti->set("{$plugin->key}|EXTENSION_CLASS_HEADER", + $this->placeholder->update($headerContent, $this->contentone->allActive()) + ); + } + + /** + * Set the extension class content. + * + * @param object $plugin The plugin object being processed. + * + * @return void + * @since 5.0.2 + */ + protected function setExtensionClass($plugin): void + { + $extensionContent = $this->extension->get($plugin); + $this->contentmulti->set("{$plugin->key}|EXTENSION_CLASS", $extensionContent); + } + + /** + * Set the provider class header content. + * + * @param object $plugin The plugin object being processed. + * + * @return void + * @since 5.0.2 + */ + protected function setProviderClassHeader($plugin): void + { + $providerHeader = $this->header->get('plugin.provider.header', $plugin->class_name); + $this->contentmulti->set("{$plugin->key}|PROVIDER_CLASS_HEADER", $providerHeader); + } + + /** + * Set the provider class content. + * + * @param object $plugin The plugin object being processed. + * + * @return void + * @since 5.0.2 + */ + protected function setProviderClass($plugin): void + { + $providerContent = $this->provider->get($plugin); + $this->contentmulti->set("{$plugin->key}|PROVIDER_CLASS", $providerContent); + } + + /** + * Set the install script content, if needed. + * + * @param object $plugin The plugin object being processed. + * + * @return void + * @since 5.0.2 + */ + protected function setInstallClass($plugin): void + { + $installContent = $this->installscript->get($plugin); + $this->contentmulti->set("{$plugin->key}|INSTALL_CLASS", $installContent); + } + + /** + * Set fieldset content based on form files. + * + * @param object $plugin The plugin object being processed. + * + * @return void + * @since 5.0.2 + */ + protected function setFieldsets($plugin): void + { + foreach ($plugin->form_files as $file => $files) + { + foreach ($files as $field_name => $fieldsets) + { + foreach ($fieldsets as $fieldset => $fields) + { + $fieldsetContent = $this->fieldsetextension->get($plugin, $fields); + $this->contentmulti->set( + "{$plugin->key}|FIELDSET_{$file}{$field_name}{$fieldset}", + $fieldsetContent + ); + } + } + } + } + + /** + * Set the main XML content for the plugin. + * + * @param object $plugin The plugin object being processed. + * + * @return void + * @since 5.0.2 + */ + protected function setMainXml($plugin): void + { + $mainXmlContent = $this->mainxml->get($plugin); + $this->contentmulti->set("{$plugin->key}|MAINXML", $mainXmlContent); + } + + /** + * Trigger the event after infusing the plugin data. + * + * @param object $plugin The plugin object being processed. + * + * @return void + * @since 5.0.2 + */ + protected function triggerAfterInfusionEvent(&$plugin): void + { + $this->event->trigger('jcb_ce_onAfterInfusePluginData', [&$plugin]); + } +} + diff --git a/src/7f75b300-534c-4f63-a368-6f4abc4cea58/code.power b/src/7f75b300-534c-4f63-a368-6f4abc4cea58/code.power new file mode 100644 index 0000000..53ee9c4 --- /dev/null +++ b/src/7f75b300-534c-4f63-a368-6f4abc4cea58/code.power @@ -0,0 +1,352 @@ + /** + * The Config Class. + * + * @var Config + * @since 5.0.2 + */ + protected Config $config; + + /** + * The Placeholder Class. + * + * @var Placeholder + * @since 5.0.2 + */ + protected Placeholder $placeholder; + + /** + * The Header Class. + * + * @var Header + * @since 5.0.2 + */ + protected Header $header; + + /** + * The Event Class. + * + * @var Event + * @since 5.0.2 + */ + protected Event $event; + + /** + * The PluginData Class. + * + * @var Data + * @since 5.0.2 + */ + protected Data $data; + + /** + * The GetScript Class. + * + * @var InstallScript + * @since 5.0.2 + */ + protected InstallScript $installscript; + + /** + * The Extension Class. + * + * @var Extension + * @since 5.0.2 + */ + protected Extension $extension; + + /** + * The Provider Class. + * + * @var Provider + * @since 5.0.2 + */ + protected Provider $provider; + + /** + * The MainXML Class. + * + * @var MainXML + * @since 5.0.2 + */ + protected MainXML $mainxml; + + /** + * The Content Multi Class. + * + * @var ContentMulti + * @since 5.0.2 + */ + protected ContentMulti $contentmulti; + + /** + * The Content One Class. + * + * @var ContentOne + * @since 5.0.2 + */ + protected ContentOne $contentone; + + /** + * The Fieldset Extension Class. + * + * @var FieldsetExtension + * @since 5.0.2 + */ + protected FieldsetExtension $fieldsetextension; + + /** + * Constructor. + * + * @param Config $config The Config Class. + * @param Placeholder $placeholder The Placeholder Class. + * @param Header $header The HeaderInterface Class. + * @param Event $event The EventInterface Class. + * @param Data $data The PluginDataInterface Class. + * @param InstallScript $installscript The GetScriptInterface Class. + * @param Extension $extension The ExtensionInterface Class. + * @param Provider $provider The ProviderInterface Class. + * @param MainXML $mainxml The MainXMLInterface Class. + * @param ContentMulti $contentmulti The ContentMulti Class. + * @param ContentOne $contentone The ContentOne Class. + * @param FieldsetExtension $fieldsetextension The FieldsetExtension Class. + * + * @since 5.0.2 + */ + public function __construct(Config $config, Placeholder $placeholder, Header $header, + Event $event, Data $data, InstallScript $installscript, + Extension $extension, Provider $provider, + MainXML $mainxml, ContentMulti $contentmulti, + ContentOne $contentone, FieldsetExtension $fieldsetextension) + { + $this->config = $config; + $this->placeholder = $placeholder; + $this->header = $header; + $this->event = $event; + $this->data = $data; + $this->installscript = $installscript; + $this->extension = $extension; + $this->provider = $provider; + $this->mainxml = $mainxml; + $this->contentmulti = $contentmulti; + $this->contentone = $contentone; + $this->fieldsetextension = $fieldsetextension; + } + + /** + * Infuse the plugin data into the content. + * + * This method processes each plugin in the data set, triggering events + * before and after infusion, setting placeholders, and adding content + * such as headers, classes, and XML configurations. + * + * @return void + * @since 5.0.2 + */ + public function set(): void + { + if (!$this->data->exists()) + { + return; + } + + foreach ($this->data->get() as $plugin) + { + if (!ObjectHelper::check($plugin)) + { + continue; + } + + $this->triggerBeforeInfusionEvent($plugin); + $this->setPlaceholders($plugin); + $this->buildPluginContent($plugin); + $this->triggerAfterInfusionEvent($plugin); + } + } + + /** + * Trigger the event before infusing the plugin data. + * + * @param object $plugin The plugin object being processed. + * + * @return void + * @since 5.0.2 + */ + protected function triggerBeforeInfusionEvent(&$plugin): void + { + $this->event->trigger('jcb_ce_onBeforeInfusePluginData', [&$plugin]); + } + + /** + * Set placeholders based on plugin data. + * + * @param object $plugin The plugin object being processed. + * + * @return void + * @since 5.0.2 + */ + protected function setPlaceholders($plugin): void + { + $this->placeholder->set('PluginGroupNamespace', $plugin->group_namespace ?? ''); + $this->placeholder->set('PluginNamespace', $plugin->namespace ?? ''); + + $this->config->build_target = $plugin->key; + $this->config->lang_target = $plugin->key; + $this->config->set('lang_prefix', $plugin->lang_prefix); + } + + /** + * Build and set the content related to the plugin. + * + * @param object $plugin The plugin object being processed. + * + * @return void + * @since 5.0.2 + */ + protected function buildPluginContent($plugin): void + { + $this->setExtensionClassHeader($plugin); + $this->setExtensionClass($plugin); + $this->setProviderClassHeader($plugin); + $this->setProviderClass($plugin); + + if ($plugin->add_install_script) + { + $this->setInstallClass($plugin); + } + + if (isset($plugin->form_files) && ArrayHelper::check($plugin->form_files)) + { + $this->setFieldsets($plugin); + } + + $this->setMainXml($plugin); + } + + /** + * Set the extension class header content. + * + * @param object $plugin The plugin object being processed. + * + * @return void + * @since 5.0.2 + */ + protected function setExtensionClassHeader($plugin): void + { + $headerContent = trim( + $this->header->get('plugin.extension.header', $plugin->class_name) + . PHP_EOL . ($plugin->header ?? '') + ); + + $this->contentmulti->set("{$plugin->key}|EXTENSION_CLASS_HEADER", + $this->placeholder->update($headerContent, $this->contentone->allActive()) + ); + } + + /** + * Set the extension class content. + * + * @param object $plugin The plugin object being processed. + * + * @return void + * @since 5.0.2 + */ + protected function setExtensionClass($plugin): void + { + $extensionContent = $this->extension->get($plugin); + $this->contentmulti->set("{$plugin->key}|EXTENSION_CLASS", $extensionContent); + } + + /** + * Set the provider class header content. + * + * @param object $plugin The plugin object being processed. + * + * @return void + * @since 5.0.2 + */ + protected function setProviderClassHeader($plugin): void + { + $providerHeader = $this->header->get('plugin.provider.header', $plugin->class_name); + $this->contentmulti->set("{$plugin->key}|PROVIDER_CLASS_HEADER", $providerHeader); + } + + /** + * Set the provider class content. + * + * @param object $plugin The plugin object being processed. + * + * @return void + * @since 5.0.2 + */ + protected function setProviderClass($plugin): void + { + $providerContent = $this->provider->get($plugin); + $this->contentmulti->set("{$plugin->key}|PROVIDER_CLASS", $providerContent); + } + + /** + * Set the install script content, if needed. + * + * @param object $plugin The plugin object being processed. + * + * @return void + * @since 5.0.2 + */ + protected function setInstallClass($plugin): void + { + $installContent = $this->installscript->get($plugin); + $this->contentmulti->set("{$plugin->key}|INSTALL_CLASS", $installContent); + } + + /** + * Set fieldset content based on form files. + * + * @param object $plugin The plugin object being processed. + * + * @return void + * @since 5.0.2 + */ + protected function setFieldsets($plugin): void + { + foreach ($plugin->form_files as $file => $files) + { + foreach ($files as $field_name => $fieldsets) + { + foreach ($fieldsets as $fieldset => $fields) + { + $fieldsetContent = $this->fieldsetextension->get($plugin, $fields); + $this->contentmulti->set( + "{$plugin->key}|FIELDSET_{$file}{$field_name}{$fieldset}", + $fieldsetContent + ); + } + } + } + } + + /** + * Set the main XML content for the plugin. + * + * @param object $plugin The plugin object being processed. + * + * @return void + * @since 5.0.2 + */ + protected function setMainXml($plugin): void + { + $mainXmlContent = $this->mainxml->get($plugin); + $this->contentmulti->set("{$plugin->key}|MAINXML", $mainXmlContent); + } + + /** + * Trigger the event after infusing the plugin data. + * + * @param object $plugin The plugin object being processed. + * + * @return void + * @since 5.0.2 + */ + protected function triggerAfterInfusionEvent(&$plugin): void + { + $this->event->trigger('jcb_ce_onAfterInfusePluginData', [&$plugin]); + } \ No newline at end of file diff --git a/src/7f75b300-534c-4f63-a368-6f4abc4cea58/settings.json b/src/7f75b300-534c-4f63-a368-6f4abc4cea58/settings.json new file mode 100644 index 0000000..298c421 --- /dev/null +++ b/src/7f75b300-534c-4f63-a368-6f4abc4cea58/settings.json @@ -0,0 +1,78 @@ +{ + "add_head": "0", + "add_licensing_template": "2", + "extends": "", + "guid": "7f75b300-534c-4f63-a368-6f4abc4cea58", + "implements": [ + "40e17114-2193-4a61-9233-47b5f4193665" + ], + "load_selection": null, + "name": "Infusion", + "power_version": "1.0.0", + "system_name": "JCB.Compiler.Joomlaplugin.J5.Infusion", + "type": "final class", + "use_selection": { + "use_selection0": { + "use": "fa4bf18e-301e-42e3-91fb-6e0096c07adc", + "as": "default" + }, + "use_selection1": { + "use": "06453ada-e370-49f0-b262-e3f5a8ed0c2c", + "as": "default" + }, + "use_selection2": { + "use": "3a777d70-52ad-49ec-9016-6f7438608613", + "as": "Header" + }, + "use_selection3": { + "use": "20ed72b0-fcac-4344-aee1-8a65e3bf221d", + "as": "Event" + }, + "use_selection4": { + "use": "8cc85656-a925-4a46-a49b-83c72167fd6a", + "as": "Data" + }, + "use_selection5": { + "use": "2e6731ba-3a03-4836-b2c2-4e50e38cb890", + "as": "InstallScript" + }, + "use_selection6": { + "use": "914db7f5-82d8-4d3b-a1c1-eb476b1898c2", + "as": "Extension" + }, + "use_selection7": { + "use": "d6ae90a5-44b4-4ce4-aedc-86c90a242912", + "as": "Provider" + }, + "use_selection8": { + "use": "97177ca9-a51a-4d24-81e1-8747b6e7d76c", + "as": "MainXML" + }, + "use_selection9": { + "use": "5f57ff1a-c196-45b1-a2ac-33766b44fb95", + "as": "default" + }, + "use_selection10": { + "use": "adfbe68a-6d22-43e5-aee8-2787e8c47e75", + "as": "default" + }, + "use_selection11": { + "use": "23f459a4-7c2a-4cbf-b0a6-8a11954140a9", + "as": "default" + }, + "use_selection12": { + "use": "91004529-94a9-4590-b842-e7c6b624ecf5", + "as": "default" + }, + "use_selection13": { + "use": "0a59c65c-9daf-4bc9-baf4-e063ff9e6a8a", + "as": "default" + } + }, + "extendsinterfaces": null, + "namespace": "[[[NamespacePrefix]]]\\Joomla\\[[[ComponentNamespace]]].Compiler.Joomlaplugin.JoomlaFive.Infusion", + "description": "Joomla 5 Plugin Infusion Class\r\n\r\n@since 5.0.2", + "licensing_template": "\/**\r\n * @package Joomla.Component.Builder\r\n *\r\n * @created 4th September, 2022\r\n * @author Llewellyn van der Merwe \r\n * @git Joomla Component Builder \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/84fe58db-d64d-42c6-9b41-f80bcff34c7f/README.md b/src/84fe58db-d64d-42c6-9b41-f80bcff34c7f/README.md new file mode 100644 index 0000000..5638b90 --- /dev/null +++ b/src/84fe58db-d64d-42c6-9b41-f80bcff34c7f/README.md @@ -0,0 +1,176 @@ +``` +██████╗ ██████╗ ██╗ ██╗███████╗██████╗ +██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗ +██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝ +██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗ +██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║ +╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝ +``` +# final class Infusion (Details) +> namespace: **VDM\Joomla\Componentbuilder\Compiler\Joomlaplugin\JoomlaFour** + +```uml +@startuml +class Infusion << (F,LightGreen) >> #RoyalBlue { + # Config $config + # Placeholder $placeholder + # Header $header + # Event $event + # Data $data + # InstallScript $installscript + # Extension $extension + # Provider $provider + # MainXML $mainxml + # ContentMulti $contentmulti + # ContentOne $contentone + # FieldsetExtension $fieldsetextension + + __construct(Config $config, Placeholder $placeholder, ...) + + set() : void + # triggerBeforeInfusionEvent(object $plugin) : void + # setPlaceholders(object $plugin) : void + # buildPluginContent(object $plugin) : void + # setExtensionClassHeader(object $plugin) : void + # setExtensionClass(object $plugin) : void + # setProviderClassHeader(object $plugin) : void + # setProviderClass(object $plugin) : void + # setInstallClass(object $plugin) : void + # setFieldsets(object $plugin) : void + # setMainXml(object $plugin) : void + # triggerAfterInfusionEvent(object $plugin) : void +} + +note right of Infusion::__construct + Constructor. + + since: 5.0.2 + + arguments: + Config $config + Placeholder $placeholder + Header $header + Event $event + Data $data + InstallScript $installscript + Extension $extension + Provider $provider + MainXML $mainxml + ContentMulti $contentmulti + ContentOne $contentone + FieldsetExtension $fieldsetextension +end note + +note left of Infusion::set + Infuse the plugin data into the content. +This method processes each plugin in the data set, triggering events +before and after infusion, setting placeholders, and adding content +such as headers, classes, and XML configurations. + + since: 5.0.2 + return: void +end note + +note right of Infusion::triggerBeforeInfusionEvent + Trigger the event before infusing the plugin data. + + since: 5.0.2 + return: void +end note + +note left of Infusion::setPlaceholders + Set placeholders based on plugin data. + + since: 5.0.2 + return: void +end note + +note right of Infusion::buildPluginContent + Build and set the content related to the plugin. + + since: 5.0.2 + return: void +end note + +note left of Infusion::setExtensionClassHeader + Set the extension class header content. + + since: 5.0.2 + return: void +end note + +note right of Infusion::setExtensionClass + Set the extension class content. + + since: 5.0.2 + return: void +end note + +note left of Infusion::setProviderClassHeader + Set the provider class header content. + + since: 5.0.2 + return: void +end note + +note right of Infusion::setProviderClass + Set the provider class content. + + since: 5.0.2 + return: void +end note + +note left of Infusion::setInstallClass + Set the install script content, if needed. + + since: 5.0.2 + return: void +end note + +note right of Infusion::setFieldsets + Set fieldset content based on form files. + + since: 5.0.2 + return: void +end note + +note left of Infusion::setMainXml + Set the main XML content for the plugin. + + since: 5.0.2 + return: void +end note + +note right of Infusion::triggerAfterInfusionEvent + Trigger the event after infusing the plugin data. + + since: 5.0.2 + return: void +end note + +@enduml +``` + +The Power feature in JCB allows you to write PHP classes and their implementations, making it easy to include them in your Joomla project. JCB handles linking, autoloading, namespacing, and folder structure creation for you. + +By using the SPK (Super Power Key) in your custom code (replacing the class name in your code with the SPK), JCB will automatically pull the power from the repository into your project. This makes it available in your JCB instance, allowing you to edit it and include the class in your generated Joomla component. + +JCB uses placeholders like [[[`NamespacePrefix`]]] and [[[`ComponentNamespace`]]] in namespacing to prevent collisions and improve reusability across different JCB systems. You can also set the **JCB powers path** globally or per component under the **Dynamic Integration** tab, providing flexibility and easy maintainability. + +To add this specific Power to your project in JCB: + +> simply use this SPK +``` +Super---84fe58db_d64d_42c6_9b41_f80bcff34c7f---Power +``` +> remember to replace the `---` with `___` to activate this Power in your code + +--- +``` + ██╗ ██████╗██████╗ + ██║██╔════╝██╔══██╗ + ██║██║ ██████╔╝ +██ ██║██║ ██╔══██╗ +╚█████╔╝╚██████╗██████╔╝ + ╚════╝ ╚═════╝╚═════╝ +``` +> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder) + diff --git a/src/84fe58db-d64d-42c6-9b41-f80bcff34c7f/code.php b/src/84fe58db-d64d-42c6-9b41-f80bcff34c7f/code.php new file mode 100644 index 0000000..79caa32 --- /dev/null +++ b/src/84fe58db-d64d-42c6-9b41-f80bcff34c7f/code.php @@ -0,0 +1,392 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Componentbuilder\Compiler\Joomlaplugin\JoomlaFour; + + +use VDM\Joomla\Componentbuilder\Compiler\Config; +use VDM\Joomla\Componentbuilder\Compiler\Placeholder; +use VDM\Joomla\Componentbuilder\Compiler\Interfaces\HeaderInterface as Header; +use VDM\Joomla\Componentbuilder\Compiler\Interfaces\EventInterface as Event; +use VDM\Joomla\Componentbuilder\Compiler\Interfaces\PluginDataInterface as Data; +use VDM\Joomla\Componentbuilder\Compiler\Interfaces\GetScriptInterface as InstallScript; +use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Architecture\Plugin\ExtensionInterface as Extension; +use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Architecture\Plugin\ProviderInterface as Provider; +use VDM\Joomla\Componentbuilder\Interfaces\Architecture\Plugin\MainXMLInterface as MainXML; +use VDM\Joomla\Componentbuilder\Compiler\Builder\ContentMulti; +use VDM\Joomla\Componentbuilder\Compiler\Builder\ContentOne; +use VDM\Joomla\Componentbuilder\Compiler\Creator\FieldsetExtension; +use VDM\Joomla\Utilities\ObjectHelper; +use VDM\Joomla\Utilities\ArrayHelper; +use VDM\Joomla\Componentbuilder\Interfaces\Plugin\InfusionInterface; + + +/** + * Joomla 4 Plugin Infusion Class + * + * @since 5.0.2 + */ +final class Infusion implements InfusionInterface +{ + /** + * The Config Class. + * + * @var Config + * @since 5.0.2 + */ + protected Config $config; + + /** + * The Placeholder Class. + * + * @var Placeholder + * @since 5.0.2 + */ + protected Placeholder $placeholder; + + /** + * The Header Class. + * + * @var Header + * @since 5.0.2 + */ + protected Header $header; + + /** + * The Event Class. + * + * @var Event + * @since 5.0.2 + */ + protected Event $event; + + /** + * The PluginData Class. + * + * @var Data + * @since 5.0.2 + */ + protected Data $data; + + /** + * The GetScript Class. + * + * @var InstallScript + * @since 5.0.2 + */ + protected InstallScript $installscript; + + /** + * The Extension Class. + * + * @var Extension + * @since 5.0.2 + */ + protected Extension $extension; + + /** + * The Provider Class. + * + * @var Provider + * @since 5.0.2 + */ + protected Provider $provider; + + /** + * The MainXML Class. + * + * @var MainXML + * @since 5.0.2 + */ + protected MainXML $mainxml; + + /** + * The Content Multi Class. + * + * @var ContentMulti + * @since 5.0.2 + */ + protected ContentMulti $contentmulti; + + /** + * The Content One Class. + * + * @var ContentOne + * @since 5.0.2 + */ + protected ContentOne $contentone; + + /** + * The Fieldset Extension Class. + * + * @var FieldsetExtension + * @since 5.0.2 + */ + protected FieldsetExtension $fieldsetextension; + + /** + * Constructor. + * + * @param Config $config The Config Class. + * @param Placeholder $placeholder The Placeholder Class. + * @param Header $header The HeaderInterface Class. + * @param Event $event The EventInterface Class. + * @param Data $data The PluginDataInterface Class. + * @param InstallScript $installscript The GetScriptInterface Class. + * @param Extension $extension The ExtensionInterface Class. + * @param Provider $provider The ProviderInterface Class. + * @param MainXML $mainxml The MainXMLInterface Class. + * @param ContentMulti $contentmulti The ContentMulti Class. + * @param ContentOne $contentone The ContentOne Class. + * @param FieldsetExtension $fieldsetextension The FieldsetExtension Class. + * + * @since 5.0.2 + */ + public function __construct(Config $config, Placeholder $placeholder, Header $header, + Event $event, Data $data, InstallScript $installscript, + Extension $extension, Provider $provider, + MainXML $mainxml, ContentMulti $contentmulti, + ContentOne $contentone, FieldsetExtension $fieldsetextension) + { + $this->config = $config; + $this->placeholder = $placeholder; + $this->header = $header; + $this->event = $event; + $this->data = $data; + $this->installscript = $installscript; + $this->extension = $extension; + $this->provider = $provider; + $this->mainxml = $mainxml; + $this->contentmulti = $contentmulti; + $this->contentone = $contentone; + $this->fieldsetextension = $fieldsetextension; + } + + /** + * Infuse the plugin data into the content. + * + * This method processes each plugin in the data set, triggering events + * before and after infusion, setting placeholders, and adding content + * such as headers, classes, and XML configurations. + * + * @return void + * @since 5.0.2 + */ + public function set(): void + { + if (!$this->data->exists()) + { + return; + } + + foreach ($this->data->get() as $plugin) + { + if (!ObjectHelper::check($plugin)) + { + continue; + } + + $this->triggerBeforeInfusionEvent($plugin); + $this->setPlaceholders($plugin); + $this->buildPluginContent($plugin); + $this->triggerAfterInfusionEvent($plugin); + } + } + + /** + * Trigger the event before infusing the plugin data. + * + * @param object $plugin The plugin object being processed. + * + * @return void + * @since 5.0.2 + */ + protected function triggerBeforeInfusionEvent(&$plugin): void + { + $this->event->trigger('jcb_ce_onBeforeInfusePluginData', [&$plugin]); + } + + /** + * Set placeholders based on plugin data. + * + * @param object $plugin The plugin object being processed. + * + * @return void + * @since 5.0.2 + */ + protected function setPlaceholders($plugin): void + { + $this->placeholder->set('PluginGroupNamespace', $plugin->group_namespace ?? ''); + $this->placeholder->set('PluginNamespace', $plugin->namespace ?? ''); + + $this->config->build_target = $plugin->key; + $this->config->lang_target = $plugin->key; + $this->config->set('lang_prefix', $plugin->lang_prefix); + } + + /** + * Build and set the content related to the plugin. + * + * @param object $plugin The plugin object being processed. + * + * @return void + * @since 5.0.2 + */ + protected function buildPluginContent($plugin): void + { + $this->setExtensionClassHeader($plugin); + $this->setExtensionClass($plugin); + $this->setProviderClassHeader($plugin); + $this->setProviderClass($plugin); + + if ($plugin->add_install_script) + { + $this->setInstallClass($plugin); + } + + if (isset($plugin->form_files) && ArrayHelper::check($plugin->form_files)) + { + $this->setFieldsets($plugin); + } + + $this->setMainXml($plugin); + } + + /** + * Set the extension class header content. + * + * @param object $plugin The plugin object being processed. + * + * @return void + * @since 5.0.2 + */ + protected function setExtensionClassHeader($plugin): void + { + $headerContent = trim( + $this->header->get('plugin.extension.header', $plugin->class_name) + . PHP_EOL . ($plugin->header ?? '') + ); + + $this->contentmulti->set("{$plugin->key}|EXTENSION_CLASS_HEADER", + $this->placeholder->update($headerContent, $this->contentone->allActive()) + ); + } + + /** + * Set the extension class content. + * + * @param object $plugin The plugin object being processed. + * + * @return void + * @since 5.0.2 + */ + protected function setExtensionClass($plugin): void + { + $extensionContent = $this->extension->get($plugin); + $this->contentmulti->set("{$plugin->key}|EXTENSION_CLASS", $extensionContent); + } + + /** + * Set the provider class header content. + * + * @param object $plugin The plugin object being processed. + * + * @return void + * @since 5.0.2 + */ + protected function setProviderClassHeader($plugin): void + { + $providerHeader = $this->header->get('plugin.provider.header', $plugin->class_name); + $this->contentmulti->set("{$plugin->key}|PROVIDER_CLASS_HEADER", $providerHeader); + } + + /** + * Set the provider class content. + * + * @param object $plugin The plugin object being processed. + * + * @return void + * @since 5.0.2 + */ + protected function setProviderClass($plugin): void + { + $providerContent = $this->provider->get($plugin); + $this->contentmulti->set("{$plugin->key}|PROVIDER_CLASS", $providerContent); + } + + /** + * Set the install script content, if needed. + * + * @param object $plugin The plugin object being processed. + * + * @return void + * @since 5.0.2 + */ + protected function setInstallClass($plugin): void + { + $installContent = $this->installscript->get($plugin); + $this->contentmulti->set("{$plugin->key}|INSTALL_CLASS", $installContent); + } + + /** + * Set fieldset content based on form files. + * + * @param object $plugin The plugin object being processed. + * + * @return void + * @since 5.0.2 + */ + protected function setFieldsets($plugin): void + { + foreach ($plugin->form_files as $file => $files) + { + foreach ($files as $field_name => $fieldsets) + { + foreach ($fieldsets as $fieldset => $fields) + { + $fieldsetContent = $this->fieldsetextension->get($plugin, $fields); + $this->contentmulti->set( + "{$plugin->key}|FIELDSET_{$file}{$field_name}{$fieldset}", + $fieldsetContent + ); + } + } + } + } + + /** + * Set the main XML content for the plugin. + * + * @param object $plugin The plugin object being processed. + * + * @return void + * @since 5.0.2 + */ + protected function setMainXml($plugin): void + { + $mainXmlContent = $this->mainxml->get($plugin); + $this->contentmulti->set("{$plugin->key}|MAINXML", $mainXmlContent); + } + + /** + * Trigger the event after infusing the plugin data. + * + * @param object $plugin The plugin object being processed. + * + * @return void + * @since 5.0.2 + */ + protected function triggerAfterInfusionEvent(&$plugin): void + { + $this->event->trigger('jcb_ce_onAfterInfusePluginData', [&$plugin]); + } +} + diff --git a/src/84fe58db-d64d-42c6-9b41-f80bcff34c7f/code.power b/src/84fe58db-d64d-42c6-9b41-f80bcff34c7f/code.power new file mode 100644 index 0000000..53ee9c4 --- /dev/null +++ b/src/84fe58db-d64d-42c6-9b41-f80bcff34c7f/code.power @@ -0,0 +1,352 @@ + /** + * The Config Class. + * + * @var Config + * @since 5.0.2 + */ + protected Config $config; + + /** + * The Placeholder Class. + * + * @var Placeholder + * @since 5.0.2 + */ + protected Placeholder $placeholder; + + /** + * The Header Class. + * + * @var Header + * @since 5.0.2 + */ + protected Header $header; + + /** + * The Event Class. + * + * @var Event + * @since 5.0.2 + */ + protected Event $event; + + /** + * The PluginData Class. + * + * @var Data + * @since 5.0.2 + */ + protected Data $data; + + /** + * The GetScript Class. + * + * @var InstallScript + * @since 5.0.2 + */ + protected InstallScript $installscript; + + /** + * The Extension Class. + * + * @var Extension + * @since 5.0.2 + */ + protected Extension $extension; + + /** + * The Provider Class. + * + * @var Provider + * @since 5.0.2 + */ + protected Provider $provider; + + /** + * The MainXML Class. + * + * @var MainXML + * @since 5.0.2 + */ + protected MainXML $mainxml; + + /** + * The Content Multi Class. + * + * @var ContentMulti + * @since 5.0.2 + */ + protected ContentMulti $contentmulti; + + /** + * The Content One Class. + * + * @var ContentOne + * @since 5.0.2 + */ + protected ContentOne $contentone; + + /** + * The Fieldset Extension Class. + * + * @var FieldsetExtension + * @since 5.0.2 + */ + protected FieldsetExtension $fieldsetextension; + + /** + * Constructor. + * + * @param Config $config The Config Class. + * @param Placeholder $placeholder The Placeholder Class. + * @param Header $header The HeaderInterface Class. + * @param Event $event The EventInterface Class. + * @param Data $data The PluginDataInterface Class. + * @param InstallScript $installscript The GetScriptInterface Class. + * @param Extension $extension The ExtensionInterface Class. + * @param Provider $provider The ProviderInterface Class. + * @param MainXML $mainxml The MainXMLInterface Class. + * @param ContentMulti $contentmulti The ContentMulti Class. + * @param ContentOne $contentone The ContentOne Class. + * @param FieldsetExtension $fieldsetextension The FieldsetExtension Class. + * + * @since 5.0.2 + */ + public function __construct(Config $config, Placeholder $placeholder, Header $header, + Event $event, Data $data, InstallScript $installscript, + Extension $extension, Provider $provider, + MainXML $mainxml, ContentMulti $contentmulti, + ContentOne $contentone, FieldsetExtension $fieldsetextension) + { + $this->config = $config; + $this->placeholder = $placeholder; + $this->header = $header; + $this->event = $event; + $this->data = $data; + $this->installscript = $installscript; + $this->extension = $extension; + $this->provider = $provider; + $this->mainxml = $mainxml; + $this->contentmulti = $contentmulti; + $this->contentone = $contentone; + $this->fieldsetextension = $fieldsetextension; + } + + /** + * Infuse the plugin data into the content. + * + * This method processes each plugin in the data set, triggering events + * before and after infusion, setting placeholders, and adding content + * such as headers, classes, and XML configurations. + * + * @return void + * @since 5.0.2 + */ + public function set(): void + { + if (!$this->data->exists()) + { + return; + } + + foreach ($this->data->get() as $plugin) + { + if (!ObjectHelper::check($plugin)) + { + continue; + } + + $this->triggerBeforeInfusionEvent($plugin); + $this->setPlaceholders($plugin); + $this->buildPluginContent($plugin); + $this->triggerAfterInfusionEvent($plugin); + } + } + + /** + * Trigger the event before infusing the plugin data. + * + * @param object $plugin The plugin object being processed. + * + * @return void + * @since 5.0.2 + */ + protected function triggerBeforeInfusionEvent(&$plugin): void + { + $this->event->trigger('jcb_ce_onBeforeInfusePluginData', [&$plugin]); + } + + /** + * Set placeholders based on plugin data. + * + * @param object $plugin The plugin object being processed. + * + * @return void + * @since 5.0.2 + */ + protected function setPlaceholders($plugin): void + { + $this->placeholder->set('PluginGroupNamespace', $plugin->group_namespace ?? ''); + $this->placeholder->set('PluginNamespace', $plugin->namespace ?? ''); + + $this->config->build_target = $plugin->key; + $this->config->lang_target = $plugin->key; + $this->config->set('lang_prefix', $plugin->lang_prefix); + } + + /** + * Build and set the content related to the plugin. + * + * @param object $plugin The plugin object being processed. + * + * @return void + * @since 5.0.2 + */ + protected function buildPluginContent($plugin): void + { + $this->setExtensionClassHeader($plugin); + $this->setExtensionClass($plugin); + $this->setProviderClassHeader($plugin); + $this->setProviderClass($plugin); + + if ($plugin->add_install_script) + { + $this->setInstallClass($plugin); + } + + if (isset($plugin->form_files) && ArrayHelper::check($plugin->form_files)) + { + $this->setFieldsets($plugin); + } + + $this->setMainXml($plugin); + } + + /** + * Set the extension class header content. + * + * @param object $plugin The plugin object being processed. + * + * @return void + * @since 5.0.2 + */ + protected function setExtensionClassHeader($plugin): void + { + $headerContent = trim( + $this->header->get('plugin.extension.header', $plugin->class_name) + . PHP_EOL . ($plugin->header ?? '') + ); + + $this->contentmulti->set("{$plugin->key}|EXTENSION_CLASS_HEADER", + $this->placeholder->update($headerContent, $this->contentone->allActive()) + ); + } + + /** + * Set the extension class content. + * + * @param object $plugin The plugin object being processed. + * + * @return void + * @since 5.0.2 + */ + protected function setExtensionClass($plugin): void + { + $extensionContent = $this->extension->get($plugin); + $this->contentmulti->set("{$plugin->key}|EXTENSION_CLASS", $extensionContent); + } + + /** + * Set the provider class header content. + * + * @param object $plugin The plugin object being processed. + * + * @return void + * @since 5.0.2 + */ + protected function setProviderClassHeader($plugin): void + { + $providerHeader = $this->header->get('plugin.provider.header', $plugin->class_name); + $this->contentmulti->set("{$plugin->key}|PROVIDER_CLASS_HEADER", $providerHeader); + } + + /** + * Set the provider class content. + * + * @param object $plugin The plugin object being processed. + * + * @return void + * @since 5.0.2 + */ + protected function setProviderClass($plugin): void + { + $providerContent = $this->provider->get($plugin); + $this->contentmulti->set("{$plugin->key}|PROVIDER_CLASS", $providerContent); + } + + /** + * Set the install script content, if needed. + * + * @param object $plugin The plugin object being processed. + * + * @return void + * @since 5.0.2 + */ + protected function setInstallClass($plugin): void + { + $installContent = $this->installscript->get($plugin); + $this->contentmulti->set("{$plugin->key}|INSTALL_CLASS", $installContent); + } + + /** + * Set fieldset content based on form files. + * + * @param object $plugin The plugin object being processed. + * + * @return void + * @since 5.0.2 + */ + protected function setFieldsets($plugin): void + { + foreach ($plugin->form_files as $file => $files) + { + foreach ($files as $field_name => $fieldsets) + { + foreach ($fieldsets as $fieldset => $fields) + { + $fieldsetContent = $this->fieldsetextension->get($plugin, $fields); + $this->contentmulti->set( + "{$plugin->key}|FIELDSET_{$file}{$field_name}{$fieldset}", + $fieldsetContent + ); + } + } + } + } + + /** + * Set the main XML content for the plugin. + * + * @param object $plugin The plugin object being processed. + * + * @return void + * @since 5.0.2 + */ + protected function setMainXml($plugin): void + { + $mainXmlContent = $this->mainxml->get($plugin); + $this->contentmulti->set("{$plugin->key}|MAINXML", $mainXmlContent); + } + + /** + * Trigger the event after infusing the plugin data. + * + * @param object $plugin The plugin object being processed. + * + * @return void + * @since 5.0.2 + */ + protected function triggerAfterInfusionEvent(&$plugin): void + { + $this->event->trigger('jcb_ce_onAfterInfusePluginData', [&$plugin]); + } \ No newline at end of file diff --git a/src/84fe58db-d64d-42c6-9b41-f80bcff34c7f/settings.json b/src/84fe58db-d64d-42c6-9b41-f80bcff34c7f/settings.json new file mode 100644 index 0000000..6b2ae18 --- /dev/null +++ b/src/84fe58db-d64d-42c6-9b41-f80bcff34c7f/settings.json @@ -0,0 +1,78 @@ +{ + "add_head": "0", + "add_licensing_template": "2", + "extends": "", + "guid": "84fe58db-d64d-42c6-9b41-f80bcff34c7f", + "implements": [ + "40e17114-2193-4a61-9233-47b5f4193665" + ], + "load_selection": null, + "name": "Infusion", + "power_version": "1.0.0", + "system_name": "JCB.Compiler.Joomlaplugin.J4.Infusion", + "type": "final class", + "use_selection": { + "use_selection0": { + "use": "fa4bf18e-301e-42e3-91fb-6e0096c07adc", + "as": "default" + }, + "use_selection1": { + "use": "06453ada-e370-49f0-b262-e3f5a8ed0c2c", + "as": "default" + }, + "use_selection2": { + "use": "3a777d70-52ad-49ec-9016-6f7438608613", + "as": "Header" + }, + "use_selection3": { + "use": "20ed72b0-fcac-4344-aee1-8a65e3bf221d", + "as": "Event" + }, + "use_selection4": { + "use": "8cc85656-a925-4a46-a49b-83c72167fd6a", + "as": "Data" + }, + "use_selection5": { + "use": "2e6731ba-3a03-4836-b2c2-4e50e38cb890", + "as": "InstallScript" + }, + "use_selection6": { + "use": "914db7f5-82d8-4d3b-a1c1-eb476b1898c2", + "as": "Extension" + }, + "use_selection13": { + "use": "d6ae90a5-44b4-4ce4-aedc-86c90a242912", + "as": "Provider" + }, + "use_selection7": { + "use": "97177ca9-a51a-4d24-81e1-8747b6e7d76c", + "as": "MainXML" + }, + "use_selection8": { + "use": "5f57ff1a-c196-45b1-a2ac-33766b44fb95", + "as": "default" + }, + "use_selection9": { + "use": "adfbe68a-6d22-43e5-aee8-2787e8c47e75", + "as": "default" + }, + "use_selection10": { + "use": "23f459a4-7c2a-4cbf-b0a6-8a11954140a9", + "as": "default" + }, + "use_selection11": { + "use": "91004529-94a9-4590-b842-e7c6b624ecf5", + "as": "default" + }, + "use_selection12": { + "use": "0a59c65c-9daf-4bc9-baf4-e063ff9e6a8a", + "as": "default" + } + }, + "extendsinterfaces": null, + "namespace": "[[[NamespacePrefix]]]\\Joomla\\[[[ComponentNamespace]]].Compiler.Joomlaplugin.JoomlaFour.Infusion", + "description": "Joomla 4 Plugin Infusion Class\r\n\r\n@since 5.0.2", + "licensing_template": "\/**\r\n * @package Joomla.Component.Builder\r\n *\r\n * @created 4th September, 2022\r\n * @author Llewellyn van der Merwe \r\n * @git Joomla Component Builder \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/8cc85656-a925-4a46-a49b-83c72167fd6a/README.md b/src/8cc85656-a925-4a46-a49b-83c72167fd6a/README.md new file mode 100644 index 0000000..8d55364 --- /dev/null +++ b/src/8cc85656-a925-4a46-a49b-83c72167fd6a/README.md @@ -0,0 +1,68 @@ +``` +██████╗ ██████╗ ██╗ ██╗███████╗██████╗ +██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗ +██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝ +██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗ +██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║ +╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝ +``` +# interface PluginDataInterface (Details) +> namespace: **VDM\Joomla\Componentbuilder\Compiler\Interfaces** + +```uml +@startuml +interface PluginDataInterface #Lavender { + + get(int $id = null) : object|array|null + + exists(int $id = null) : bool + + set(int $id) : bool +} + +note right of PluginDataInterface::get + Get the Joomla Plugin/s + + since: 3.2.0 + return: object|array|null +end note + +note right of PluginDataInterface::exists + Check if the Joomla Plugin/s exists + + since: 3.2.0 + return: bool +end note + +note right of PluginDataInterface::set + Set the Joomla Plugin + + since: 3.2.0 + return: bool +end note + +@enduml +``` + +The Power feature in JCB allows you to write PHP classes and their implementations, making it easy to include them in your Joomla project. JCB handles linking, autoloading, namespacing, and folder structure creation for you. + +By using the SPK (Super Power Key) in your custom code (replacing the class name in your code with the SPK), JCB will automatically pull the power from the repository into your project. This makes it available in your JCB instance, allowing you to edit it and include the class in your generated Joomla component. + +JCB uses placeholders like [[[`NamespacePrefix`]]] and [[[`ComponentNamespace`]]] in namespacing to prevent collisions and improve reusability across different JCB systems. You can also set the **JCB powers path** globally or per component under the **Dynamic Integration** tab, providing flexibility and easy maintainability. + +To add this specific Power to your project in JCB: + +> simply use this SPK +``` +Super---8cc85656_a925_4a46_a49b_83c72167fd6a---Power +``` +> remember to replace the `---` with `___` to activate this Power in your code + +--- +``` + ██╗ ██████╗██████╗ + ██║██╔════╝██╔══██╗ + ██║██║ ██████╔╝ +██ ██║██║ ██╔══██╗ +╚█████╔╝╚██████╗██████╔╝ + ╚════╝ ╚═════╝╚═════╝ +``` +> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder) + diff --git a/src/8cc85656-a925-4a46-a49b-83c72167fd6a/code.php b/src/8cc85656-a925-4a46-a49b-83c72167fd6a/code.php new file mode 100644 index 0000000..9671aee --- /dev/null +++ b/src/8cc85656-a925-4a46-a49b-83c72167fd6a/code.php @@ -0,0 +1,52 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Componentbuilder\Compiler\Interfaces; + + +/** + * Plug-in Data Interface + * + * @since 5.0.2 + */ +interface PluginDataInterface +{ + /** + * Get the Joomla Plugin/s + * + * @param int|null $id the plugin id + * + * @return object|array|null if ID found it returns object, if no ID given it returns all set + * @since 3.2.0 + */ + public function get(int $id = null); + + /** + * Check if the Joomla Plugin/s exists + * + * @param int|null $id the plugin id + * + * @return bool if ID found it returns true, if no ID given it returns true if any are set + * @since 3.2.0 + */ + public function exists(int $id = null): bool; + + /** + * Set the Joomla Plugin + * + * @param int $id the plugin id + * + * @return bool true on success + * @since 3.2.0 + */ + public function set(int $id): bool; +} + diff --git a/src/8cc85656-a925-4a46-a49b-83c72167fd6a/code.power b/src/8cc85656-a925-4a46-a49b-83c72167fd6a/code.power new file mode 100644 index 0000000..9b670b8 --- /dev/null +++ b/src/8cc85656-a925-4a46-a49b-83c72167fd6a/code.power @@ -0,0 +1,29 @@ + /** + * Get the Joomla Plugin/s + * + * @param int|null $id the plugin id + * + * @return object|array|null if ID found it returns object, if no ID given it returns all set + * @since 3.2.0 + */ + public function get(int $id = null); + + /** + * Check if the Joomla Plugin/s exists + * + * @param int|null $id the plugin id + * + * @return bool if ID found it returns true, if no ID given it returns true if any are set + * @since 3.2.0 + */ + public function exists(int $id = null): bool; + + /** + * Set the Joomla Plugin + * + * @param int $id the plugin id + * + * @return bool true on success + * @since 3.2.0 + */ + public function set(int $id): bool; \ No newline at end of file diff --git a/src/8cc85656-a925-4a46-a49b-83c72167fd6a/settings.json b/src/8cc85656-a925-4a46-a49b-83c72167fd6a/settings.json new file mode 100644 index 0000000..6d28e9e --- /dev/null +++ b/src/8cc85656-a925-4a46-a49b-83c72167fd6a/settings.json @@ -0,0 +1,19 @@ +{ + "add_head": "0", + "add_licensing_template": "2", + "extends": "", + "guid": "8cc85656-a925-4a46-a49b-83c72167fd6a", + "implements": null, + "load_selection": null, + "name": "PluginDataInterface", + "power_version": "2.0.0", + "system_name": "JCB.Interfaces.PluginDataInterface", + "type": "interface", + "use_selection": null, + "extendsinterfaces": null, + "namespace": "[[[NamespacePrefix]]]\\Joomla\\[[[ComponentNamespace]]].Compiler.Interfaces.PluginDataInterface", + "description": "Plug-in Data Interface\r\n\r\n@since 5.0.2", + "licensing_template": "\/**\r\n * @package Joomla.Component.Builder\r\n *\r\n * @created 4th September, 2022\r\n * @author Llewellyn van der Merwe \r\n * @git Joomla Component Builder \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/8eee7df5-2775-41a9-9372-c46c5939a252/README.md b/src/8eee7df5-2775-41a9-9372-c46c5939a252/README.md index 4e1aa69..61365ae 100644 --- a/src/8eee7df5-2775-41a9-9372-c46c5939a252/README.md +++ b/src/8eee7df5-2775-41a9-9372-c46c5939a252/README.md @@ -6,12 +6,12 @@ ██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║ ╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝ ``` -# class Language (Details) +# final class Language (Details) > namespace: **VDM\Joomla\Componentbuilder\Compiler** ```uml @startuml -class Language #Gold { +class Language << (F,LightGreen) >> #RoyalBlue { # array $content # Config $config + __construct(?Config $config = null) diff --git a/src/8eee7df5-2775-41a9-9372-c46c5939a252/code.php b/src/8eee7df5-2775-41a9-9372-c46c5939a252/code.php index 73011bb..1990b0f 100644 --- a/src/8eee7df5-2775-41a9-9372-c46c5939a252/code.php +++ b/src/8eee7df5-2775-41a9-9372-c46c5939a252/code.php @@ -24,7 +24,7 @@ use VDM\Joomla\Componentbuilder\Compiler\Interfaces\LanguageInterface; * * @since 3.2.0 */ -class Language implements LanguageInterface +final class Language implements LanguageInterface { /** * The language content diff --git a/src/8eee7df5-2775-41a9-9372-c46c5939a252/settings.json b/src/8eee7df5-2775-41a9-9372-c46c5939a252/settings.json index bc4fa1d..b112f6b 100644 --- a/src/8eee7df5-2775-41a9-9372-c46c5939a252/settings.json +++ b/src/8eee7df5-2775-41a9-9372-c46c5939a252/settings.json @@ -10,7 +10,7 @@ "name": "Language", "power_version": "1.0.0", "system_name": "JCB.Compiler.Language", - "type": "class", + "type": "final class", "use_selection": { "use_selection0": { "use": "0a59c65c-9daf-4bc9-baf4-e063ff9e6a8a", diff --git a/src/8fdd604f-53e7-4a91-9935-afcfd2f6ac1b/README.md b/src/8fdd604f-53e7-4a91-9935-afcfd2f6ac1b/README.md index 35b3f12..311e5ee 100644 --- a/src/8fdd604f-53e7-4a91-9935-afcfd2f6ac1b/README.md +++ b/src/8fdd604f-53e7-4a91-9935-afcfd2f6ac1b/README.md @@ -37,6 +37,7 @@ class Creator #Gold { + getRouterConstructorManual(Container $container) : RouterConstructorManual + getRouterMethodsDefault(Container $container) : RouterMethodsDefault + getRouterMethodsManual(Container $container) : RouterMethodsManual + + getFieldsetExtension(Container $container) : FieldsetExtension + getFieldsetString(Container $container) : FieldsetString + getFieldsetXML(Container $container) : FieldsetXML + getFieldsetDynamic(Container $container) : FieldsetDynamic @@ -223,63 +224,70 @@ note right of Creator::getRouterMethodsManual return: RouterMethodsManual end note -note left of Creator::getFieldsetString +note left of Creator::getFieldsetExtension + Get The FieldsetExtension Class. + + since: 5.0.2 + return: FieldsetExtension +end note + +note right of Creator::getFieldsetString Get The FieldsetString Class. since: 3.2.0 return: FieldsetString end note -note right of Creator::getFieldsetXML +note left of Creator::getFieldsetXML Get The FieldsetXML Class. since: 3.2.0 return: FieldsetXML end note -note left of Creator::getFieldsetDynamic +note right of Creator::getFieldsetDynamic Get The FieldsetDynamic Class. since: 3.2.0 return: FieldsetDynamic end note -note right of Creator::getFieldXML +note left of Creator::getFieldXML Get The FieldXML Class. since: 3.2.0 return: FieldXML end note -note left of Creator::getFieldString +note right of Creator::getFieldString Get The FieldString Class. since: 3.2.0 return: FieldString end note -note right of Creator::getFieldDynamic +note left of Creator::getFieldDynamic Get The FieldDynamic Class. since: 3.2.0 return: FieldDynamic end note -note left of Creator::getFieldAsString +note right of Creator::getFieldAsString Get The FieldAsString Class. since: 3.2.0 return: FieldAsString end note -note right of Creator::getFieldType +note left of Creator::getFieldType Get The Fieldtypeinterface Class. since: 3.2.0 return: FieldType end note -note left of Creator::getFieldset +note right of Creator::getFieldset Get The Fieldsetinterface Class. since: 3.2.0 diff --git a/src/8fdd604f-53e7-4a91-9935-afcfd2f6ac1b/code.php b/src/8fdd604f-53e7-4a91-9935-afcfd2f6ac1b/code.php index 36aa474..6cebf37 100644 --- a/src/8fdd604f-53e7-4a91-9935-afcfd2f6ac1b/code.php +++ b/src/8fdd604f-53e7-4a91-9935-afcfd2f6ac1b/code.php @@ -38,6 +38,7 @@ use VDM\Joomla\Componentbuilder\Compiler\Creator\RouterConstructorDefault; use VDM\Joomla\Componentbuilder\Compiler\Creator\RouterConstructorManual; use VDM\Joomla\Componentbuilder\Compiler\Creator\RouterMethodsDefault; use VDM\Joomla\Componentbuilder\Compiler\Creator\RouterMethodsManual; +use VDM\Joomla\Componentbuilder\Compiler\Creator\FieldsetExtension; use VDM\Joomla\Componentbuilder\Compiler\Creator\FieldsetString; use VDM\Joomla\Componentbuilder\Compiler\Creator\FieldsetXML; use VDM\Joomla\Componentbuilder\Compiler\Creator\FieldsetDynamic; @@ -84,6 +85,9 @@ class Creator implements ServiceProviderInterface $container->alias(CustomButtonPermissions::class, 'Compiler.Creator.Custom.Button.Permissions') ->share('Compiler.Creator.Custom.Button.Permissions', [$this, 'getCustomButtonPermissions'], true); + $container->alias(FieldsetExtension::class, 'Compiler.Creator.Fieldset.Extension') + ->share('Compiler.Creator.Fieldset.Extension', [$this, 'getFieldsetExtension'], true); + $container->alias(ConfigFieldsets::class, 'Compiler.Creator.Config.Fieldsets') ->share('Compiler.Creator.Config.Fieldsets', [$this, 'getConfigFieldsets'], true); @@ -669,6 +673,22 @@ class Creator implements ServiceProviderInterface ); } + /** + * Get The FieldsetExtension Class. + * + * @param Container $container The DI container. + * + * @return FieldsetExtension + * @since 5.0.2 + */ + public function getFieldsetExtension(Container $container): FieldsetExtension + { + return new FieldsetExtension( + $container->get('Component.Placeholder'), + $container->get('Compiler.Creator.Fieldset.Dynamic') + ); + } + /** * Get The FieldsetString Class. * diff --git a/src/8fdd604f-53e7-4a91-9935-afcfd2f6ac1b/code.power b/src/8fdd604f-53e7-4a91-9935-afcfd2f6ac1b/code.power index b7b5413..8289539 100644 --- a/src/8fdd604f-53e7-4a91-9935-afcfd2f6ac1b/code.power +++ b/src/8fdd604f-53e7-4a91-9935-afcfd2f6ac1b/code.power @@ -26,6 +26,9 @@ $container->alias(CustomButtonPermissions::class, 'Compiler.Creator.Custom.Button.Permissions') ->share('Compiler.Creator.Custom.Button.Permissions', [$this, 'getCustomButtonPermissions'], true); + $container->alias(FieldsetExtension::class, 'Compiler.Creator.Fieldset.Extension') + ->share('Compiler.Creator.Fieldset.Extension', [$this, 'getFieldsetExtension'], true); + $container->alias(ConfigFieldsets::class, 'Compiler.Creator.Config.Fieldsets') ->share('Compiler.Creator.Config.Fieldsets', [$this, 'getConfigFieldsets'], true); @@ -611,6 +614,22 @@ ); } + /** + * Get The FieldsetExtension Class. + * + * @param Container $container The DI container. + * + * @return FieldsetExtension + * @since 5.0.2 + */ + public function getFieldsetExtension(Container $container): FieldsetExtension + { + return new FieldsetExtension( + $container->get('Component.Placeholder'), + $container->get('Compiler.Creator.Fieldset.Dynamic') + ); + } + /** * Get The FieldsetString Class. * diff --git a/src/8fdd604f-53e7-4a91-9935-afcfd2f6ac1b/settings.json b/src/8fdd604f-53e7-4a91-9935-afcfd2f6ac1b/settings.json index 2584083..dba2ef1 100644 --- a/src/8fdd604f-53e7-4a91-9935-afcfd2f6ac1b/settings.json +++ b/src/8fdd604f-53e7-4a91-9935-afcfd2f6ac1b/settings.json @@ -109,38 +109,42 @@ "as": "default" }, "use_selection24": { - "use": "05448890-e324-41a0-b6db-d804bfc241cc", + "use": "23f459a4-7c2a-4cbf-b0a6-8a11954140a9", "as": "default" }, "use_selection25": { - "use": "79739667-72c6-4576-9830-7b1eb92e4791", + "use": "05448890-e324-41a0-b6db-d804bfc241cc", "as": "default" }, "use_selection26": { - "use": "b5986fab-17ca-4236-8c0c-81ebd2bb82ba", + "use": "79739667-72c6-4576-9830-7b1eb92e4791", "as": "default" }, "use_selection27": { - "use": "ac691a05-5630-4002-b166-dedec3fb0fcb", + "use": "b5986fab-17ca-4236-8c0c-81ebd2bb82ba", "as": "default" }, "use_selection28": { - "use": "44d039b9-d293-481b-b560-23a6e7a63962", + "use": "ac691a05-5630-4002-b166-dedec3fb0fcb", "as": "default" }, "use_selection29": { - "use": "4801f8b0-4a4a-4eda-8f0e-cf77f042c35e", + "use": "44d039b9-d293-481b-b560-23a6e7a63962", "as": "default" }, "use_selection30": { - "use": "f48764e0-16c6-459c-8576-af7616f3b720", + "use": "4801f8b0-4a4a-4eda-8f0e-cf77f042c35e", "as": "default" }, "use_selection31": { + "use": "f48764e0-16c6-459c-8576-af7616f3b720", + "as": "default" + }, + "use_selection32": { "use": "2d27c436-4d8e-4692-8382-d9e97af2231c", "as": "FieldType" }, - "use_selection32": { + "use_selection33": { "use": "d44f3294-6b68-4d85-a617-15fb772b7d14", "as": "Fieldset" } diff --git a/src/914db7f5-82d8-4d3b-a1c1-eb476b1898c2/README.md b/src/914db7f5-82d8-4d3b-a1c1-eb476b1898c2/README.md new file mode 100644 index 0000000..4c2d980 --- /dev/null +++ b/src/914db7f5-82d8-4d3b-a1c1-eb476b1898c2/README.md @@ -0,0 +1,52 @@ +``` +██████╗ ██████╗ ██╗ ██╗███████╗██████╗ +██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗ +██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝ +██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗ +██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║ +╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝ +``` +# interface ExtensionInterface (Details) +> namespace: **VDM\Joomla\Componentbuilder\Compiler\Interfaces\Architecture\Plugin** + +```uml +@startuml +interface ExtensionInterface #Lavender { + + get(object $plugin) : string +} + +note right of ExtensionInterface::get + Get the updated placeholder content for the given plugin. + + since: 5.0.2 + return: string +end note + +@enduml +``` + +The Power feature in JCB allows you to write PHP classes and their implementations, making it easy to include them in your Joomla project. JCB handles linking, autoloading, namespacing, and folder structure creation for you. + +By using the SPK (Super Power Key) in your custom code (replacing the class name in your code with the SPK), JCB will automatically pull the power from the repository into your project. This makes it available in your JCB instance, allowing you to edit it and include the class in your generated Joomla component. + +JCB uses placeholders like [[[`NamespacePrefix`]]] and [[[`ComponentNamespace`]]] in namespacing to prevent collisions and improve reusability across different JCB systems. You can also set the **JCB powers path** globally or per component under the **Dynamic Integration** tab, providing flexibility and easy maintainability. + +To add this specific Power to your project in JCB: + +> simply use this SPK +``` +Super---914db7f5_82d8_4d3b_a1c1_eb476b1898c2---Power +``` +> remember to replace the `---` with `___` to activate this Power in your code + +--- +``` + ██╗ ██████╗██████╗ + ██║██╔════╝██╔══██╗ + ██║██║ ██████╔╝ +██ ██║██║ ██╔══██╗ +╚█████╔╝╚██████╗██████╔╝ + ╚════╝ ╚═════╝╚═════╝ +``` +> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder) + diff --git a/src/914db7f5-82d8-4d3b-a1c1-eb476b1898c2/code.php b/src/914db7f5-82d8-4d3b-a1c1-eb476b1898c2/code.php new file mode 100644 index 0000000..6ee63bf --- /dev/null +++ b/src/914db7f5-82d8-4d3b-a1c1-eb476b1898c2/code.php @@ -0,0 +1,33 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Componentbuilder\Compiler\Interfaces\Architecture\Plugin; + + +/** + * Plugin Extension Interface + * + * @since 5.0.2 + */ +interface ExtensionInterface +{ + /** + * Get the updated placeholder content for the given plugin. + * + * @param object $plugin The plugin object containing the necessary data. + * + * @return string The updated placeholder content. + * + * @since 5.0.2 + */ + public function get(object $plugin): string; +} + diff --git a/src/914db7f5-82d8-4d3b-a1c1-eb476b1898c2/code.power b/src/914db7f5-82d8-4d3b-a1c1-eb476b1898c2/code.power new file mode 100644 index 0000000..4ed6345 --- /dev/null +++ b/src/914db7f5-82d8-4d3b-a1c1-eb476b1898c2/code.power @@ -0,0 +1,10 @@ + /** + * Get the updated placeholder content for the given plugin. + * + * @param object $plugin The plugin object containing the necessary data. + * + * @return string The updated placeholder content. + * + * @since 5.0.2 + */ + public function get(object $plugin): string; \ No newline at end of file diff --git a/src/914db7f5-82d8-4d3b-a1c1-eb476b1898c2/settings.json b/src/914db7f5-82d8-4d3b-a1c1-eb476b1898c2/settings.json new file mode 100644 index 0000000..c5a6728 --- /dev/null +++ b/src/914db7f5-82d8-4d3b-a1c1-eb476b1898c2/settings.json @@ -0,0 +1,19 @@ +{ + "add_head": "0", + "add_licensing_template": "2", + "extends": "", + "guid": "914db7f5-82d8-4d3b-a1c1-eb476b1898c2", + "implements": null, + "load_selection": null, + "name": "ExtensionInterface", + "power_version": "1.0.0", + "system_name": "JCB.Interfaces.Architecture.Plugin.Extension", + "type": "interface", + "use_selection": null, + "extendsinterfaces": null, + "namespace": "[[[NamespacePrefix]]]\\Joomla\\[[[ComponentNamespace]]].Compiler.Interfaces.Architecture.Plugin.ExtensionInterface", + "description": "Plugin Extension Interface\r\n\r\n@since 5.0.2", + "licensing_template": "\/**\r\n * @package Joomla.Component.Builder\r\n *\r\n * @created 4th September, 2022\r\n * @author Llewellyn van der Merwe \r\n * @git Joomla Component Builder \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/95deb809-5f43-400b-939f-f9ceef720b13/README.md b/src/95deb809-5f43-400b-939f-f9ceef720b13/README.md index 5166821..17aad81 100644 --- a/src/95deb809-5f43-400b-939f-f9ceef720b13/README.md +++ b/src/95deb809-5f43-400b-939f-f9ceef720b13/README.md @@ -29,7 +29,6 @@ class Header << (F,LightGreen) >> #RoyalBlue { + __construct(Config $config, Event $event, ...) + get(string $context, string $codeName) : string # getHeaders(string $context) : array - # setHelperClassHeader(array $headers, string $target_client) : void } note right of Header::__construct @@ -63,13 +62,6 @@ note right of Header::getHeaders since: 3.2.0 return: array end note - -note right of Header::setHelperClassHeader - set Helper Dynamic Headers - - since: 3.2.0 - return: void -end note @enduml ``` diff --git a/src/95deb809-5f43-400b-939f-f9ceef720b13/code.php b/src/95deb809-5f43-400b-939f-f9ceef720b13/code.php index 6cd4325..58576bb 100644 --- a/src/95deb809-5f43-400b-939f-f9ceef720b13/code.php +++ b/src/95deb809-5f43-400b-939f-f9ceef720b13/code.php @@ -200,7 +200,7 @@ final class Header implements HeaderInterface $headers = $this->getHeaders($context); // add to all except the helper classes - if ('admin.helper' !== $context && 'site.helper' !== $context) + if ('admin.helper' !== $context && 'site.helper' !== $context && 'plugin.extension.header' !== $context && 'plugin.provider.header' !== $context) { $target = 'Administrator'; if ($this->config->get('build_target', 'admin') === 'site') @@ -228,11 +228,6 @@ final class Header implements HeaderInterface // get dynamic headers switch ($context) { - case 'admin.helper': - case 'site.helper': - $this->setHelperClassHeader($headers, $codeName); - break; - case 'admin.view.html': case 'admin.views.html': case 'custom.admin.view.html': @@ -243,7 +238,7 @@ final class Header implements HeaderInterface if ((2 == $this->config->uikit || 1 == $this->config->uikit) && $this->uikitcomp->exists($codeName)) { - $headers[] = 'use Joomla\CMS\Filesystem\File;'; + $headers[] = 'use Joomla\Filesystem\File;'; } break; @@ -267,6 +262,10 @@ final class Header implements HeaderInterface $headers[] = 'use Joomla\CMS\Helper\TagsHelper;'; break; + case 'plugin.provider.header': + $headers[] = "use {$this->NamespacePrefix}\\Plugin\\[[[PluginGroupNamespace]]]\\[[[PluginNamespace]]]\\Extension\\{$codeName};"; + break; + default: break; } @@ -313,7 +312,7 @@ final class Header implements HeaderInterface $headers[] = 'use Joomla\CMS\Access\Access;'; $headers[] = 'use Joomla\CMS\Access\Rules as AccessRules;'; $headers[] = 'use Joomla\CMS\Component\ComponentHelper;'; - $headers[] = 'use Joomla\CMS\Filesystem\File;'; + $headers[] = 'use Joomla\Filesystem\File;'; $headers[] = 'use Joomla\CMS\Language\Language;'; $headers[] = 'use Joomla\CMS\MVC\Model\BaseDatabaseModel;'; $headers[] = 'use Joomla\CMS\Object\CMSObject;'; @@ -503,8 +502,8 @@ final class Header implements HeaderInterface break; case 'import.custom.model': case 'import.model': - $headers[] = 'use Joomla\CMS\Filesystem\File;'; - $headers[] = 'use Joomla\CMS\Filesystem\Folder;'; + $headers[] = 'use Joomla\Filesystem\File;'; + $headers[] = 'use Joomla\Filesystem\Folder;'; $headers[] = 'use Joomla\CMS\Filesystem\Path;'; $headers[] = 'use Joomla\CMS\Filter\OutputFilter;'; $headers[] = 'use Joomla\CMS\Installer\InstallerHelper;'; @@ -553,6 +552,33 @@ final class Header implements HeaderInterface $headers[] = 'use Joomla\CMS\Form\Field\###FORM_EXTENDS###;'; break; + case 'plugin.extension.header': + $headers = []; + break; + case 'plugin.provider.header': + $headers = []; + $headers[] = 'use Joomla\CMS\Factory;'; + $headers[] = 'use Joomla\CMS\Plugin\PluginHelper;'; + $headers[] = 'use Joomla\CMS\Extension\PluginInterface;'; + $headers[] = 'use Joomla\Event\DispatcherInterface;'; + $headers[] = 'use Joomla\DI\ServiceProviderInterface;'; + $headers[] = 'use Joomla\DI\Container;'; + break; + + case 'api.view.controller': + case 'api.views.controller': + $headers = []; + $headers[] = 'use Joomla\CMS\Factory;'; + $headers[] = 'use Joomla\CMS\MVC\Controller\ApiController;'; + break; + + case 'api.view.json': + case 'api.views.json': + $headers = []; + $headers[] = 'use Joomla\CMS\Factory;'; + $headers[] = 'use Joomla\CMS\MVC\View\JsonApiView as BaseApiView;'; + break; + default: break; } @@ -560,26 +586,6 @@ final class Header implements HeaderInterface $this->headers[$context] = $headers; return $headers; - } - - /** - * set Helper Dynamic Headers - * - * @param array $headers The headers array - * @param string $target_client - * - * @return void - * @since 3.2.0 - */ - protected function setHelperClassHeader(&$headers, $target_client) - { - // add only to admin client - if ('admin' === $target_client && $this->config->get('add_eximport', false)) - { - $headers[] = 'use PhpOffice\PhpSpreadsheet\IOFactory;'; - $headers[] = 'use PhpOffice\PhpSpreadsheet\Spreadsheet;'; - $headers[] = 'use PhpOffice\PhpSpreadsheet\Writer\Xlsx;'; - } } } diff --git a/src/95deb809-5f43-400b-939f-f9ceef720b13/code.power b/src/95deb809-5f43-400b-939f-f9ceef720b13/code.power index 2a61f61..fab981a 100644 --- a/src/95deb809-5f43-400b-939f-f9ceef720b13/code.power +++ b/src/95deb809-5f43-400b-939f-f9ceef720b13/code.power @@ -164,7 +164,7 @@ $headers = $this->getHeaders($context); // add to all except the helper classes - if ('admin.helper' !== $context && 'site.helper' !== $context) + if ('admin.helper' !== $context && 'site.helper' !== $context && 'plugin.extension.header' !== $context && 'plugin.provider.header' !== $context) { $target = 'Administrator'; if ($this->config->get('build_target', 'admin') === 'site') @@ -192,11 +192,6 @@ // get dynamic headers switch ($context) { - case 'admin.helper': - case 'site.helper': - $this->setHelperClassHeader($headers, $codeName); - break; - case 'admin.view.html': case 'admin.views.html': case 'custom.admin.view.html': @@ -207,7 +202,7 @@ if ((2 == $this->config->uikit || 1 == $this->config->uikit) && $this->uikitcomp->exists($codeName)) { - $headers[] = 'use Joomla\CMS\Filesystem\File;'; + $headers[] = 'use Joomla\Filesystem\File;'; } break; @@ -231,6 +226,10 @@ $headers[] = 'use Joomla\CMS\Helper\TagsHelper;'; break; + case 'plugin.provider.header': + $headers[] = "use {$this->NamespacePrefix}\\Plugin\\[[[PluginGroupNamespace]]]\\[[[PluginNamespace]]]\\Extension\\{$codeName};"; + break; + default: break; } @@ -277,7 +276,7 @@ $headers[] = 'use Joomla\CMS\Access\Access;'; $headers[] = 'use Joomla\CMS\Access\Rules as AccessRules;'; $headers[] = 'use Joomla\CMS\Component\ComponentHelper;'; - $headers[] = 'use Joomla\CMS\Filesystem\File;'; + $headers[] = 'use Joomla\Filesystem\File;'; $headers[] = 'use Joomla\CMS\Language\Language;'; $headers[] = 'use Joomla\CMS\MVC\Model\BaseDatabaseModel;'; $headers[] = 'use Joomla\CMS\Object\CMSObject;'; @@ -467,8 +466,8 @@ break; case 'import.custom.model': case 'import.model': - $headers[] = 'use Joomla\CMS\Filesystem\File;'; - $headers[] = 'use Joomla\CMS\Filesystem\Folder;'; + $headers[] = 'use Joomla\Filesystem\File;'; + $headers[] = 'use Joomla\Filesystem\Folder;'; $headers[] = 'use Joomla\CMS\Filesystem\Path;'; $headers[] = 'use Joomla\CMS\Filter\OutputFilter;'; $headers[] = 'use Joomla\CMS\Installer\InstallerHelper;'; @@ -517,6 +516,33 @@ $headers[] = 'use Joomla\CMS\Form\Field\###FORM_EXTENDS###;'; break; + case 'plugin.extension.header': + $headers = []; + break; + case 'plugin.provider.header': + $headers = []; + $headers[] = 'use Joomla\CMS\Factory;'; + $headers[] = 'use Joomla\CMS\Plugin\PluginHelper;'; + $headers[] = 'use Joomla\CMS\Extension\PluginInterface;'; + $headers[] = 'use Joomla\Event\DispatcherInterface;'; + $headers[] = 'use Joomla\DI\ServiceProviderInterface;'; + $headers[] = 'use Joomla\DI\Container;'; + break; + + case 'api.view.controller': + case 'api.views.controller': + $headers = []; + $headers[] = 'use Joomla\CMS\Factory;'; + $headers[] = 'use Joomla\CMS\MVC\Controller\ApiController;'; + break; + + case 'api.view.json': + case 'api.views.json': + $headers = []; + $headers[] = 'use Joomla\CMS\Factory;'; + $headers[] = 'use Joomla\CMS\MVC\View\JsonApiView as BaseApiView;'; + break; + default: break; } @@ -524,24 +550,4 @@ $this->headers[$context] = $headers; return $headers; - } - - /** - * set Helper Dynamic Headers - * - * @param array $headers The headers array - * @param string $target_client - * - * @return void - * @since 3.2.0 - */ - protected function setHelperClassHeader(&$headers, $target_client) - { - // add only to admin client - if ('admin' === $target_client && $this->config->get('add_eximport', false)) - { - $headers[] = 'use PhpOffice\PhpSpreadsheet\IOFactory;'; - $headers[] = 'use PhpOffice\PhpSpreadsheet\Spreadsheet;'; - $headers[] = 'use PhpOffice\PhpSpreadsheet\Writer\Xlsx;'; - } } \ No newline at end of file diff --git a/src/97177ca9-a51a-4d24-81e1-8747b6e7d76c/README.md b/src/97177ca9-a51a-4d24-81e1-8747b6e7d76c/README.md new file mode 100644 index 0000000..665f685 --- /dev/null +++ b/src/97177ca9-a51a-4d24-81e1-8747b6e7d76c/README.md @@ -0,0 +1,52 @@ +``` +██████╗ ██████╗ ██╗ ██╗███████╗██████╗ +██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗ +██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝ +██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗ +██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║ +╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝ +``` +# interface MainXMLInterface (Details) +> namespace: **VDM\Joomla\Componentbuilder\Interfaces\Architecture\Plugin** + +```uml +@startuml +interface MainXMLInterface #Lavender { + + get(object $plugin) : string +} + +note right of MainXMLInterface::get + Generates the main XML for the plugin. + + since: 5.0.2 + return: string +end note + +@enduml +``` + +The Power feature in JCB allows you to write PHP classes and their implementations, making it easy to include them in your Joomla project. JCB handles linking, autoloading, namespacing, and folder structure creation for you. + +By using the SPK (Super Power Key) in your custom code (replacing the class name in your code with the SPK), JCB will automatically pull the power from the repository into your project. This makes it available in your JCB instance, allowing you to edit it and include the class in your generated Joomla component. + +JCB uses placeholders like [[[`NamespacePrefix`]]] and [[[`ComponentNamespace`]]] in namespacing to prevent collisions and improve reusability across different JCB systems. You can also set the **JCB powers path** globally or per component under the **Dynamic Integration** tab, providing flexibility and easy maintainability. + +To add this specific Power to your project in JCB: + +> simply use this SPK +``` +Super---97177ca9_a51a_4d24_81e1_8747b6e7d76c---Power +``` +> remember to replace the `---` with `___` to activate this Power in your code + +--- +``` + ██╗ ██████╗██████╗ + ██║██╔════╝██╔══██╗ + ██║██║ ██████╔╝ +██ ██║██║ ██╔══██╗ +╚█████╔╝╚██████╗██████╔╝ + ╚════╝ ╚═════╝╚═════╝ +``` +> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder) + diff --git a/src/97177ca9-a51a-4d24-81e1-8747b6e7d76c/code.php b/src/97177ca9-a51a-4d24-81e1-8747b6e7d76c/code.php new file mode 100644 index 0000000..ade51fc --- /dev/null +++ b/src/97177ca9-a51a-4d24-81e1-8747b6e7d76c/code.php @@ -0,0 +1,32 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Componentbuilder\Interfaces\Architecture\Plugin; + + +/** + * Main XML Interface + * + * @since 5.0.0 + */ +interface MainXMLInterface +{ + /** + * Generates the main XML for the plugin. + * + * @param object $plugin The plugin object. + * + * @return string The generated XML. + * @since 5.0.2 + */ + public function get(object $plugin): string; +} + diff --git a/src/97177ca9-a51a-4d24-81e1-8747b6e7d76c/code.power b/src/97177ca9-a51a-4d24-81e1-8747b6e7d76c/code.power new file mode 100644 index 0000000..36b16dc --- /dev/null +++ b/src/97177ca9-a51a-4d24-81e1-8747b6e7d76c/code.power @@ -0,0 +1,9 @@ + /** + * Generates the main XML for the plugin. + * + * @param object $plugin The plugin object. + * + * @return string The generated XML. + * @since 5.0.2 + */ + public function get(object $plugin): string; \ No newline at end of file diff --git a/src/97177ca9-a51a-4d24-81e1-8747b6e7d76c/settings.json b/src/97177ca9-a51a-4d24-81e1-8747b6e7d76c/settings.json new file mode 100644 index 0000000..85e79c2 --- /dev/null +++ b/src/97177ca9-a51a-4d24-81e1-8747b6e7d76c/settings.json @@ -0,0 +1,19 @@ +{ + "add_head": "0", + "add_licensing_template": "2", + "extends": "", + "guid": "97177ca9-a51a-4d24-81e1-8747b6e7d76c", + "implements": null, + "load_selection": null, + "name": "MainXMLInterface", + "power_version": "1.0.0", + "system_name": "JCB.Interfaces.ArchitecturePlugin.MainXMLInterface", + "type": "interface", + "use_selection": null, + "extendsinterfaces": null, + "namespace": "[[[NamespacePrefix]]]\\Joomla\\[[[ComponentNamespace]]].Interfaces.Architecture.Plugin.MainXMLInterface", + "description": "Main XML Interface\r\n\r\n@since 5.0.0", + "licensing_template": "\/**\r\n * @package Joomla.Component.Builder\r\n *\r\n * @created 4th September, 2022\r\n * @author Llewellyn van der Merwe \r\n * @git Joomla Component Builder \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/98ac432d-df19-4c40-bb12-8104ea4362c8/README.md b/src/98ac432d-df19-4c40-bb12-8104ea4362c8/README.md new file mode 100644 index 0000000..4aad86a --- /dev/null +++ b/src/98ac432d-df19-4c40-bb12-8104ea4362c8/README.md @@ -0,0 +1,149 @@ +``` +██████╗ ██████╗ ██╗ ██╗███████╗██████╗ +██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗ +██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝ +██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗ +██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║ +╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝ +``` +# class ArchitecturePlugin (Details) +> namespace: **VDM\Joomla\Componentbuilder\Compiler\Service** + +```uml +@startuml +class ArchitecturePlugin #Gold { + # int $targetVersion + + register(Container $container) : void + + getExtension(Container $container) : Extension + + getJ5Extension(Container $container) : J5Extension + + getJ4Extension(Container $container) : J4Extension + + getJ3Extension(Container $container) : J3Extension + + getProvider(Container $container) : Provider + + getJ5Provider(Container $container) : J5Provider + + getJ4Provider(Container $container) : J4Provider + + getJ3Provider(Container $container) : J3Provider + + getMainXML(Container $container) : MainXML + + getJ5MainXML(Container $container) : J5MainXML + + getJ4MainXML(Container $container) : J4MainXML + + getJ3MainXML(Container $container) : J3MainXML +} + +note right of ArchitecturePlugin::register + Registers the service provider with a DI container. + + since: 5.0.2 + return: void +end note + +note left of ArchitecturePlugin::getExtension + Get The Extension Class. + + since: 5.0.2 + return: Extension +end note + +note right of ArchitecturePlugin::getJ5Extension + Get The Extension Class. + + since: 5.0.2 + return: J5Extension +end note + +note left of ArchitecturePlugin::getJ4Extension + Get The Extension Class. + + since: 5.0.2 + return: J4Extension +end note + +note right of ArchitecturePlugin::getJ3Extension + Get The Extension Class. + + since: 5.0.2 + return: J3Extension +end note + +note left of ArchitecturePlugin::getProvider + Get The ProviderInterface Class. + + since: 5.0.2 + return: Provider +end note + +note right of ArchitecturePlugin::getJ5Provider + Get The Provider Class. + + since: 5.0.2 + return: J5Provider +end note + +note left of ArchitecturePlugin::getJ4Provider + Get The Provider Class. + + since: 5.0.2 + return: J4Provider +end note + +note right of ArchitecturePlugin::getJ3Provider + Get The Provider Class. + + since: 5.0.2 + return: J3Provider +end note + +note left of ArchitecturePlugin::getMainXML + Get The MainXML Class. + + since: 5.0.2 + return: MainXML +end note + +note right of ArchitecturePlugin::getJ5MainXML + Get The MainXML Class. + + since: 5.0.2 + return: J5MainXML +end note + +note left of ArchitecturePlugin::getJ4MainXML + Get The MainXML Class. + + since: 5.0.2 + return: J4MainXML +end note + +note right of ArchitecturePlugin::getJ3MainXML + Get The MainXML Class. + + since: 5.0.2 + return: J3MainXML +end note + +@enduml +``` + +The Power feature in JCB allows you to write PHP classes and their implementations, making it easy to include them in your Joomla project. JCB handles linking, autoloading, namespacing, and folder structure creation for you. + +By using the SPK (Super Power Key) in your custom code (replacing the class name in your code with the SPK), JCB will automatically pull the power from the repository into your project. This makes it available in your JCB instance, allowing you to edit it and include the class in your generated Joomla component. + +JCB uses placeholders like [[[`NamespacePrefix`]]] and [[[`ComponentNamespace`]]] in namespacing to prevent collisions and improve reusability across different JCB systems. You can also set the **JCB powers path** globally or per component under the **Dynamic Integration** tab, providing flexibility and easy maintainability. + +To add this specific Power to your project in JCB: + +> simply use this SPK +``` +Super---98ac432d_df19_4c40_bb12_8104ea4362c8---Power +``` +> remember to replace the `---` with `___` to activate this Power in your code + +--- +``` + ██╗ ██████╗██████╗ + ██║██╔════╝██╔══██╗ + ██║██║ ██████╔╝ +██ ██║██║ ██╔══██╗ +╚█████╔╝╚██████╗██████╔╝ + ╚════╝ ╚═════╝╚═════╝ +``` +> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder) + diff --git a/src/98ac432d-df19-4c40-bb12-8104ea4362c8/code.php b/src/98ac432d-df19-4c40-bb12-8104ea4362c8/code.php new file mode 100644 index 0000000..c7a9eb3 --- /dev/null +++ b/src/98ac432d-df19-4c40-bb12-8104ea4362c8/code.php @@ -0,0 +1,326 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Componentbuilder\Compiler\Service; + + +use Joomla\DI\Container; +use Joomla\DI\ServiceProviderInterface; +use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Architecture\Plugin\ExtensionInterface as Extension; +use VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaFive\Plugin\Extension as J5Extension; +use VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaFour\Plugin\Extension as J4Extension; +use VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaThree\Plugin\Extension as J3Extension; +use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Architecture\Plugin\ProviderInterface as Provider; +use VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaFive\Plugin\Provider as J5Provider; +use VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaFour\Plugin\Provider as J4Provider; +use VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaThree\Plugin\Provider as J3Provider; +use VDM\Joomla\Componentbuilder\Interfaces\Architecture\Plugin\MainXMLInterface as MainXML; +use VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaFive\Plugin\MainXML as J5MainXML; +use VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaFour\Plugin\MainXML as J4MainXML; +use VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaThree\Plugin\MainXML as J3MainXML; + + +/** + * Architecture Plugin Service Provider + * + * @since 5.0.2 + */ +class ArchitecturePlugin implements ServiceProviderInterface +{ + /** + * Current Joomla Version Being Build + * + * @var int + * @since 5.0.2 + **/ + protected int $targetVersion; + + /** + * Registers the service provider with a DI container. + * + * @param Container $container The DI container. + * + * @return void + * @since 5.0.2 + */ + public function register(Container $container) + { + $container->alias(Extension::class, 'Architecture.Plugin.Extension') + ->share('Architecture.Plugin.Extension', [$this, 'getExtension'], true); + + $container->alias(J5Extension::class, 'Architecture.Plugin.J5.Extension') + ->share('Architecture.Plugin.J5.Extension', [$this, 'getJ5Extension'], true); + + $container->alias(J4Extension::class, 'Architecture.Plugin.J4.Extension') + ->share('Architecture.Plugin.J4.Extension', [$this, 'getJ4Extension'], true); + + $container->alias(J3Extension::class, 'Architecture.Plugin.J3.Extension') + ->share('Architecture.Plugin.J3.Extension', [$this, 'getJ3Extension'], true); + + $container->alias(Provider::class, 'Architecture.Plugin.Provider') + ->share('Architecture.Plugin.Provider', [$this, 'getProvider'], true); + + $container->alias(J5Provider::class, 'Architecture.Plugin.J5.Provider') + ->share('Architecture.Plugin.J5.Provider', [$this, 'getJ5Provider'], true); + + $container->alias(J4Provider::class, 'Architecture.Plugin.J4.Provider') + ->share('Architecture.Plugin.J4.Provider', [$this, 'getJ4Provider'], true); + + $container->alias(J3Provider::class, 'Architecture.Plugin.J3.Provider') + ->share('Architecture.Plugin.J3.Provider', [$this, 'getJ3Provider'], true); + + $container->alias(MainXML::class, 'Architecture.Plugin.MainXML') + ->share('Architecture.Plugin.MainXML', [$this, 'getMainXML'], true); + + $container->alias(J5MainXML::class, 'Architecture.Plugin.J5.MainXML') + ->share('Architecture.Plugin.J5.MainXML', [$this, 'getJ5MainXML'], true); + + $container->alias(J4MainXML::class, 'Architecture.Plugin.J4.MainXML') + ->share('Architecture.Plugin.J4.MainXML', [$this, 'getJ4MainXML'], true); + + $container->alias(J3MainXML::class, 'Architecture.Plugin.J3.MainXML') + ->share('Architecture.Plugin.J3.MainXML', [$this, 'getJ3MainXML'], true); + } + + /** + * Get The Extension Class. + * + * @param Container $container The DI container. + * + * @return Extension + * @since 5.0.2 + */ + public function getExtension(Container $container): Extension + { + if (empty($this->targetVersion)) + { + $this->targetVersion = $container->get('Config')->joomla_version; + } + + return $container->get('Architecture.Plugin.J' . $this->targetVersion . '.Extension'); + } + + /** + * Get The Extension Class. + * + * @param Container $container The DI container. + * + * @return J5Extension + * @since 5.0.2 + */ + public function getJ5Extension(Container $container): J5Extension + { + return new J5Extension( + $container->get('Placeholder'), + $container->get('Compiler.Builder.Content.One'), + $container->get('Power.Parser') + ); + } + + /** + * Get The Extension Class. + * + * @param Container $container The DI container. + * + * @return J4Extension + * @since 5.0.2 + */ + public function getJ4Extension(Container $container): J4Extension + { + return new J4Extension( + $container->get('Placeholder'), + $container->get('Compiler.Builder.Content.One'), + $container->get('Power.Parser') + ); + } + + /** + * Get The Extension Class. + * + * @param Container $container The DI container. + * + * @return J3Extension + * @since 5.0.2 + */ + public function getJ3Extension(Container $container): J3Extension + { + return new J3Extension( + $container->get('Placeholder'), + $container->get('Compiler.Builder.Content.One') + ); + } + + /** + * Get The ProviderInterface Class. + * + * @param Container $container The DI container. + * + * @return Provider + * @since 5.0.2 + */ + public function getProvider(Container $container): Provider + { + if (empty($this->targetVersion)) + { + $this->targetVersion = $container->get('Config')->joomla_version; + } + + return $container->get('Architecture.Plugin.J' . $this->targetVersion . '.Provider'); + } + + /** + * Get The Provider Class. + * + * @param Container $container The DI container. + * + * @return J5Provider + * @since 5.0.2 + */ + public function getJ5Provider(Container $container): J5Provider + { + return new J5Provider( + $container->get('Placeholder'), + $container->get('Compiler.Builder.Content.One') + ); + } + + /** + * Get The Provider Class. + * + * @param Container $container The DI container. + * + * @return J4Provider + * @since 5.0.2 + */ + public function getJ4Provider(Container $container): J4Provider + { + return new J4Provider( + $container->get('Placeholder'), + $container->get('Compiler.Builder.Content.One') + ); + } + + /** + * Get The Provider Class. + * + * @param Container $container The DI container. + * + * @return J3Provider + * @since 5.0.2 + */ + public function getJ3Provider(Container $container): J3Provider + { + return new J3Provider( + $container->get('Placeholder'), + $container->get('Compiler.Builder.Content.One') + ); + } + + /** + * Get The MainXML Class. + * + * @param Container $container The DI container. + * + * @return MainXML + * @since 5.0.2 + */ + public function getMainXML(Container $container): MainXML + { + if (empty($this->targetVersion)) + { + $this->targetVersion = $container->get('Config')->joomla_version; + } + + return $container->get('Architecture.Plugin.J' . $this->targetVersion . '.MainXML'); + } + + /** + * Get The MainXML Class. + * + * @param Container $container The DI container. + * + * @return J5MainXML + * @since 5.0.2 + */ + public function getJ5MainXML(Container $container): J5MainXML + { + return new J5MainXML( + $container->get('Config'), + $container->get('Language'), + $container->get('Language.Set'), + $container->get('Language.Purge'), + $container->get('Language.Translation'), + $container->get('Language.Multilingual'), + $container->get('Event'), + $container->get('Compiler.Creator.Fieldset.Extension'), + $container->get('Compiler.Builder.Content.One'), + $container->get('Compiler.Builder.Languages'), + $container->get('Compiler.Builder.Multilingual'), + $container->get('Utilities.Counter'), + $container->get('Utilities.File') + ); + } + + /** + * Get The MainXML Class. + * + * @param Container $container The DI container. + * + * @return J4MainXML + * @since 5.0.2 + */ + public function getJ4MainXML(Container $container): J4MainXML + { + return new J4MainXML( + $container->get('Config'), + $container->get('Language'), + $container->get('Language.Set'), + $container->get('Language.Purge'), + $container->get('Language.Translation'), + $container->get('Language.Multilingual'), + $container->get('Event'), + $container->get('Compiler.Creator.Fieldset.Extension'), + $container->get('Compiler.Builder.Content.One'), + $container->get('Compiler.Builder.Languages'), + $container->get('Compiler.Builder.Multilingual'), + $container->get('Utilities.Counter'), + $container->get('Utilities.File') + ); + } + + /** + * Get The MainXML Class. + * + * @param Container $container The DI container. + * + * @return J3MainXML + * @since 5.0.2 + */ + public function getJ3MainXML(Container $container): J3MainXML + { + return new J3MainXML( + $container->get('Config'), + $container->get('Language'), + $container->get('Language.Set'), + $container->get('Language.Purge'), + $container->get('Language.Translation'), + $container->get('Language.Multilingual'), + $container->get('Event'), + $container->get('Compiler.Creator.Fieldset.Extension'), + $container->get('Compiler.Builder.Content.One'), + $container->get('Compiler.Builder.Languages'), + $container->get('Compiler.Builder.Multilingual'), + $container->get('Utilities.Counter'), + $container->get('Utilities.File') + ); + } +} + diff --git a/src/98ac432d-df19-4c40-bb12-8104ea4362c8/code.power b/src/98ac432d-df19-4c40-bb12-8104ea4362c8/code.power new file mode 100644 index 0000000..3860ba3 --- /dev/null +++ b/src/98ac432d-df19-4c40-bb12-8104ea4362c8/code.power @@ -0,0 +1,287 @@ + /** + * Current Joomla Version Being Build + * + * @var int + * @since 5.0.2 + **/ + protected int $targetVersion; + + /** + * Registers the service provider with a DI container. + * + * @param Container $container The DI container. + * + * @return void + * @since 5.0.2 + */ + public function register(Container $container) + { + $container->alias(Extension::class, 'Architecture.Plugin.Extension') + ->share('Architecture.Plugin.Extension', [$this, 'getExtension'], true); + + $container->alias(J5Extension::class, 'Architecture.Plugin.J5.Extension') + ->share('Architecture.Plugin.J5.Extension', [$this, 'getJ5Extension'], true); + + $container->alias(J4Extension::class, 'Architecture.Plugin.J4.Extension') + ->share('Architecture.Plugin.J4.Extension', [$this, 'getJ4Extension'], true); + + $container->alias(J3Extension::class, 'Architecture.Plugin.J3.Extension') + ->share('Architecture.Plugin.J3.Extension', [$this, 'getJ3Extension'], true); + + $container->alias(Provider::class, 'Architecture.Plugin.Provider') + ->share('Architecture.Plugin.Provider', [$this, 'getProvider'], true); + + $container->alias(J5Provider::class, 'Architecture.Plugin.J5.Provider') + ->share('Architecture.Plugin.J5.Provider', [$this, 'getJ5Provider'], true); + + $container->alias(J4Provider::class, 'Architecture.Plugin.J4.Provider') + ->share('Architecture.Plugin.J4.Provider', [$this, 'getJ4Provider'], true); + + $container->alias(J3Provider::class, 'Architecture.Plugin.J3.Provider') + ->share('Architecture.Plugin.J3.Provider', [$this, 'getJ3Provider'], true); + + $container->alias(MainXML::class, 'Architecture.Plugin.MainXML') + ->share('Architecture.Plugin.MainXML', [$this, 'getMainXML'], true); + + $container->alias(J5MainXML::class, 'Architecture.Plugin.J5.MainXML') + ->share('Architecture.Plugin.J5.MainXML', [$this, 'getJ5MainXML'], true); + + $container->alias(J4MainXML::class, 'Architecture.Plugin.J4.MainXML') + ->share('Architecture.Plugin.J4.MainXML', [$this, 'getJ4MainXML'], true); + + $container->alias(J3MainXML::class, 'Architecture.Plugin.J3.MainXML') + ->share('Architecture.Plugin.J3.MainXML', [$this, 'getJ3MainXML'], true); + } + + /** + * Get The Extension Class. + * + * @param Container $container The DI container. + * + * @return Extension + * @since 5.0.2 + */ + public function getExtension(Container $container): Extension + { + if (empty($this->targetVersion)) + { + $this->targetVersion = $container->get('Config')->joomla_version; + } + + return $container->get('Architecture.Plugin.J' . $this->targetVersion . '.Extension'); + } + + /** + * Get The Extension Class. + * + * @param Container $container The DI container. + * + * @return J5Extension + * @since 5.0.2 + */ + public function getJ5Extension(Container $container): J5Extension + { + return new J5Extension( + $container->get('Placeholder'), + $container->get('Compiler.Builder.Content.One'), + $container->get('Power.Parser') + ); + } + + /** + * Get The Extension Class. + * + * @param Container $container The DI container. + * + * @return J4Extension + * @since 5.0.2 + */ + public function getJ4Extension(Container $container): J4Extension + { + return new J4Extension( + $container->get('Placeholder'), + $container->get('Compiler.Builder.Content.One'), + $container->get('Power.Parser') + ); + } + + /** + * Get The Extension Class. + * + * @param Container $container The DI container. + * + * @return J3Extension + * @since 5.0.2 + */ + public function getJ3Extension(Container $container): J3Extension + { + return new J3Extension( + $container->get('Placeholder'), + $container->get('Compiler.Builder.Content.One') + ); + } + + /** + * Get The ProviderInterface Class. + * + * @param Container $container The DI container. + * + * @return Provider + * @since 5.0.2 + */ + public function getProvider(Container $container): Provider + { + if (empty($this->targetVersion)) + { + $this->targetVersion = $container->get('Config')->joomla_version; + } + + return $container->get('Architecture.Plugin.J' . $this->targetVersion . '.Provider'); + } + + /** + * Get The Provider Class. + * + * @param Container $container The DI container. + * + * @return J5Provider + * @since 5.0.2 + */ + public function getJ5Provider(Container $container): J5Provider + { + return new J5Provider( + $container->get('Placeholder'), + $container->get('Compiler.Builder.Content.One') + ); + } + + /** + * Get The Provider Class. + * + * @param Container $container The DI container. + * + * @return J4Provider + * @since 5.0.2 + */ + public function getJ4Provider(Container $container): J4Provider + { + return new J4Provider( + $container->get('Placeholder'), + $container->get('Compiler.Builder.Content.One') + ); + } + + /** + * Get The Provider Class. + * + * @param Container $container The DI container. + * + * @return J3Provider + * @since 5.0.2 + */ + public function getJ3Provider(Container $container): J3Provider + { + return new J3Provider( + $container->get('Placeholder'), + $container->get('Compiler.Builder.Content.One') + ); + } + + /** + * Get The MainXML Class. + * + * @param Container $container The DI container. + * + * @return MainXML + * @since 5.0.2 + */ + public function getMainXML(Container $container): MainXML + { + if (empty($this->targetVersion)) + { + $this->targetVersion = $container->get('Config')->joomla_version; + } + + return $container->get('Architecture.Plugin.J' . $this->targetVersion . '.MainXML'); + } + + /** + * Get The MainXML Class. + * + * @param Container $container The DI container. + * + * @return J5MainXML + * @since 5.0.2 + */ + public function getJ5MainXML(Container $container): J5MainXML + { + return new J5MainXML( + $container->get('Config'), + $container->get('Language'), + $container->get('Language.Set'), + $container->get('Language.Purge'), + $container->get('Language.Translation'), + $container->get('Language.Multilingual'), + $container->get('Event'), + $container->get('Compiler.Creator.Fieldset.Extension'), + $container->get('Compiler.Builder.Content.One'), + $container->get('Compiler.Builder.Languages'), + $container->get('Compiler.Builder.Multilingual'), + $container->get('Utilities.Counter'), + $container->get('Utilities.File') + ); + } + + /** + * Get The MainXML Class. + * + * @param Container $container The DI container. + * + * @return J4MainXML + * @since 5.0.2 + */ + public function getJ4MainXML(Container $container): J4MainXML + { + return new J4MainXML( + $container->get('Config'), + $container->get('Language'), + $container->get('Language.Set'), + $container->get('Language.Purge'), + $container->get('Language.Translation'), + $container->get('Language.Multilingual'), + $container->get('Event'), + $container->get('Compiler.Creator.Fieldset.Extension'), + $container->get('Compiler.Builder.Content.One'), + $container->get('Compiler.Builder.Languages'), + $container->get('Compiler.Builder.Multilingual'), + $container->get('Utilities.Counter'), + $container->get('Utilities.File') + ); + } + + /** + * Get The MainXML Class. + * + * @param Container $container The DI container. + * + * @return J3MainXML + * @since 5.0.2 + */ + public function getJ3MainXML(Container $container): J3MainXML + { + return new J3MainXML( + $container->get('Config'), + $container->get('Language'), + $container->get('Language.Set'), + $container->get('Language.Purge'), + $container->get('Language.Translation'), + $container->get('Language.Multilingual'), + $container->get('Event'), + $container->get('Compiler.Creator.Fieldset.Extension'), + $container->get('Compiler.Builder.Content.One'), + $container->get('Compiler.Builder.Languages'), + $container->get('Compiler.Builder.Multilingual'), + $container->get('Utilities.Counter'), + $container->get('Utilities.File') + ); + } \ No newline at end of file diff --git a/src/98ac432d-df19-4c40-bb12-8104ea4362c8/settings.json b/src/98ac432d-df19-4c40-bb12-8104ea4362c8/settings.json new file mode 100644 index 0000000..85b205c --- /dev/null +++ b/src/98ac432d-df19-4c40-bb12-8104ea4362c8/settings.json @@ -0,0 +1,71 @@ +{ + "add_head": "1", + "add_licensing_template": "2", + "extends": "", + "guid": "98ac432d-df19-4c40-bb12-8104ea4362c8", + "implements": [ + "-1" + ], + "load_selection": null, + "name": "ArchitecturePlugin", + "power_version": "1.0.0", + "system_name": "JCB.Compiler.Service.ArchitecturePlugin", + "type": "class", + "use_selection": { + "use_selection0": { + "use": "914db7f5-82d8-4d3b-a1c1-eb476b1898c2", + "as": "Extension" + }, + "use_selection1": { + "use": "28c8eed4-58cf-4d40-9053-ad77b6edfa9d", + "as": "J5Extension" + }, + "use_selection2": { + "use": "ec808f55-6703-46c0-8a6d-33c9d4e0e9fa", + "as": "J4Extension" + }, + "use_selection3": { + "use": "a5f658ff-3962-475d-8cf8-c91da562bf49", + "as": "J3Extension" + }, + "use_selection4": { + "use": "d6ae90a5-44b4-4ce4-aedc-86c90a242912", + "as": "Provider" + }, + "use_selection5": { + "use": "63865266-62e0-40bd-820c-e95449d12982", + "as": "J5Provider" + }, + "use_selection6": { + "use": "60c3ccc5-36dc-4480-b5c4-252c37212f61", + "as": "J4Provider" + }, + "use_selection7": { + "use": "6dd2d394-8dde-4eb7-8505-cd7d345c49e3", + "as": "J3Provider" + }, + "use_selection8": { + "use": "97177ca9-a51a-4d24-81e1-8747b6e7d76c", + "as": "MainXML" + }, + "use_selection9": { + "use": "a7124f78-21c5-400e-984d-4c5463cb2315", + "as": "J5MainXML" + }, + "use_selection10": { + "use": "af6d0e6a-61d2-4250-9e2f-bed5591e2786", + "as": "J4MainXML" + }, + "use_selection11": { + "use": "54e05f58-6538-42ec-ba46-b136f33e7cc7", + "as": "J3MainXML" + } + }, + "extendsinterfaces": null, + "namespace": "[[[NamespacePrefix]]]\\Joomla\\[[[ComponentNamespace]]].Compiler.Service.ArchitecturePlugin", + "description": "Architecture Plugin Service Provider\r\n\r\n@since 5.0.2", + "implements_custom": "ServiceProviderInterface", + "licensing_template": "\/**\r\n * @package Joomla.Component.Builder\r\n *\r\n * @created 4th September, 2022\r\n * @author Llewellyn van der Merwe \r\n * @git Joomla Component Builder \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/9eba241c-af90-42dd-ae05-92ff4d8391d3/README.md b/src/9eba241c-af90-42dd-ae05-92ff4d8391d3/README.md index 3ec5358..1395c6f 100644 --- a/src/9eba241c-af90-42dd-ae05-92ff4d8391d3/README.md +++ b/src/9eba241c-af90-42dd-ae05-92ff4d8391d3/README.md @@ -12,9 +12,20 @@ ```uml @startuml class Joomlaplugin #Gold { + # $targetVersion + register(Container $container) : void - + getData(Container $container) : Data + + getPluginData(Container $container) : PluginData + + getJ3PluginData(Container $container) : J3PluginData + + getJ4PluginData(Container $container) : J4PluginData + + getJ5PluginData(Container $container) : J5PluginData + getStructure(Container $container) : Structure + + getJ3Structure(Container $container) : J3Structure + + getJ4Structure(Container $container) : J4Structure + + getJ5Structure(Container $container) : J5Structure + + getInfusion(Container $container) : Infusion + + getJ3Infusion(Container $container) : J3Infusion + + getJ4Infusion(Container $container) : J4Infusion + + getJ5Infusion(Container $container) : J5Infusion } note right of Joomlaplugin::register @@ -24,19 +35,89 @@ note right of Joomlaplugin::register return: void end note -note right of Joomlaplugin::getData - Get the Joomla Plugin Data +note left of Joomlaplugin::getPluginData + Get The Plug-in Data Class. - since: 3.2.0 - return: Data + since: 5.0.2 + return: PluginData end note -note right of Joomlaplugin::getStructure +note right of Joomlaplugin::getJ3PluginData + Get The PluginData Class. + + since: 5.0.2 + return: J3PluginData +end note + +note left of Joomlaplugin::getJ4PluginData + Get The PluginData Class. + + since: 5.0.2 + return: J4PluginData +end note + +note right of Joomlaplugin::getJ5PluginData + Get The PluginData Class. + + since: 5.0.2 + return: J5PluginData +end note + +note left of Joomlaplugin::getStructure Get the Joomla Plugin Structure Builder since: 3.2.0 return: Structure end note + +note right of Joomlaplugin::getJ3Structure + Get the Joomla 3 Plugin Structure Builder + + since: 5.0.2 + return: J3Structure +end note + +note left of Joomlaplugin::getJ4Structure + Get the Joomla 4 Plugin Structure Builder + + since: 5.0.2 + return: J4Structure +end note + +note right of Joomlaplugin::getJ5Structure + Get the Joomla 5 Plugin Structure Builder + + since: 5.0.2 + return: J5Structure +end note + +note left of Joomlaplugin::getInfusion + Get The InfusionInterface Class. + + since: 5.0.2 + return: Infusion +end note + +note right of Joomlaplugin::getJ3Infusion + Get The Infusion Class. + + since: 5.0.2 + return: J3Infusion +end note + +note left of Joomlaplugin::getJ4Infusion + Get The Infusion Class. + + since: 5.0.2 + return: J4Infusion +end note + +note right of Joomlaplugin::getJ5Infusion + Get The Infusion Class. + + since: 5.0.2 + return: J5Infusion +end note @enduml ``` diff --git a/src/9eba241c-af90-42dd-ae05-92ff4d8391d3/code.php b/src/9eba241c-af90-42dd-ae05-92ff4d8391d3/code.php index a8343f1..299cad0 100644 --- a/src/9eba241c-af90-42dd-ae05-92ff4d8391d3/code.php +++ b/src/9eba241c-af90-42dd-ae05-92ff4d8391d3/code.php @@ -14,8 +14,18 @@ namespace VDM\Joomla\Componentbuilder\Compiler\Service; use Joomla\DI\Container; use Joomla\DI\ServiceProviderInterface; -use VDM\Joomla\Componentbuilder\Compiler\Joomlaplugin\Data; -use VDM\Joomla\Componentbuilder\Compiler\Joomlaplugin\Structure; +use VDM\Joomla\Componentbuilder\Compiler\Joomlaplugin\JoomlaThree\Data as J3PluginData; +use VDM\Joomla\Componentbuilder\Compiler\Joomlaplugin\JoomlaFour\Data as J4PluginData; +use VDM\Joomla\Componentbuilder\Compiler\Joomlaplugin\JoomlaFive\Data as J5PluginData; +use VDM\Joomla\Componentbuilder\Compiler\Interfaces\PluginDataInterface as PluginData; +use VDM\Joomla\Componentbuilder\Compiler\Joomlaplugin\JoomlaThree\Structure as J3Structure; +use VDM\Joomla\Componentbuilder\Compiler\Joomlaplugin\JoomlaFour\Structure as J4Structure; +use VDM\Joomla\Componentbuilder\Compiler\Joomlaplugin\JoomlaFive\Structure as J5Structure; +use VDM\Joomla\Componentbuilder\Interfaces\Plugin\StructureInterface as Structure; +use VDM\Joomla\Componentbuilder\Compiler\Joomlaplugin\JoomlaThree\Infusion as J3Infusion; +use VDM\Joomla\Componentbuilder\Compiler\Joomlaplugin\JoomlaFour\Infusion as J4Infusion; +use VDM\Joomla\Componentbuilder\Compiler\Joomlaplugin\JoomlaFive\Infusion as J5Infusion; +use VDM\Joomla\Componentbuilder\Interfaces\Plugin\InfusionInterface as Infusion; /** @@ -25,34 +35,134 @@ use VDM\Joomla\Componentbuilder\Compiler\Joomlaplugin\Structure; */ class Joomlaplugin implements ServiceProviderInterface { + /** + * Current Joomla Version Being Build + * + * @var int + * @since 5.0.2 + **/ + protected $targetVersion; + /** * Registers the service provider with a DI container. * * @param Container $container The DI container. * * @return void - * @since 3.2.0 + * @since 3.2.0 */ public function register(Container $container) { - $container->alias(Data::class, 'Joomlaplugin.Data') - ->share('Joomlaplugin.Data', [$this, 'getData'], true); + $container->alias(J3PluginData::class, 'Joomlaplugin.J3.Data') + ->share('Joomlaplugin.J3.Data', [$this, 'getJ3PluginData'], true); + + $container->alias(J4PluginData::class, 'Joomlaplugin.J4.Data') + ->share('Joomlaplugin.J4.Data', [$this, 'getJ4PluginData'], true); + + $container->alias(J5PluginData::class, 'Joomlaplugin.J5.Data') + ->share('Joomlaplugin.J5.Data', [$this, 'getJ5PluginData'], true); + + $container->alias(PluginData::class, 'Joomlaplugin.Data') + ->share('Joomlaplugin.Data', [$this, 'getPluginData'], true); + + $container->alias(J3Structure::class, 'Joomlaplugin.J3.Structure') + ->share('Joomlaplugin.J3.Structure', [$this, 'getJ3Structure'], true); + + $container->alias(J4Structure::class, 'Joomlaplugin.J4.Structure') + ->share('Joomlaplugin.J4.Structure', [$this, 'getJ4Structure'], true); + + $container->alias(J5Structure::class, 'Joomlaplugin.J5.Structure') + ->share('Joomlaplugin.J5.Structure', [$this, 'getJ5Structure'], true); $container->alias(Structure::class, 'Joomlaplugin.Structure') ->share('Joomlaplugin.Structure', [$this, 'getStructure'], true); + + $container->alias(J3Infusion::class, 'Joomlaplugin.J3.Infusion') + ->share('Joomlaplugin.J3.Infusion', [$this, 'getJ3Infusion'], true); + + $container->alias(J4Infusion::class, 'Joomlaplugin.J4.Infusion') + ->share('Joomlaplugin.J4.Infusion', [$this, 'getJ4Infusion'], true); + + $container->alias(J5Infusion::class, 'Joomlaplugin.J5.Infusion') + ->share('Joomlaplugin.J5.Infusion', [$this, 'getJ5Infusion'], true); + + $container->alias(Infusion::class, 'Joomlaplugin.Infusion') + ->share('Joomlaplugin.Infusion', [$this, 'getInfusion'], true); } /** - * Get the Joomla Plugin Data + * Get The Plug-in Data Class. * * @param Container $container The DI container. * - * @return Data - * @since 3.2.0 + * @return PluginData + * @since 5.0.2 */ - public function getData(Container $container): Data + public function getPluginData(Container $container): PluginData { - return new Data( + if (empty($this->targetVersion)) + { + $this->targetVersion = $container->get('Config')->joomla_version; + } + + return $container->get('Joomlaplugin.J' . $this->targetVersion . '.Data'); + } + + /** + * Get The PluginData Class. + * + * @param Container $container The DI container. + * + * @return J3PluginData + * @since 5.0.2 + */ + public function getJ3PluginData(Container $container): J3PluginData + { + return new J3PluginData( + $container->get('Config'), + $container->get('Customcode'), + $container->get('Customcode.Gui'), + $container->get('Placeholder'), + $container->get('Language'), + $container->get('Field'), + $container->get('Field.Name'), + $container->get('Model.Filesfolders') + ); + } + + /** + * Get The PluginData Class. + * + * @param Container $container The DI container. + * + * @return J4PluginData + * @since 5.0.2 + */ + public function getJ4PluginData(Container $container): J4PluginData + { + return new J4PluginData( + $container->get('Config'), + $container->get('Customcode'), + $container->get('Customcode.Gui'), + $container->get('Placeholder'), + $container->get('Language'), + $container->get('Field'), + $container->get('Field.Name'), + $container->get('Model.Filesfolders') + ); + } + + /** + * Get The PluginData Class. + * + * @param Container $container The DI container. + * + * @return J5PluginData + * @since 5.0.2 + */ + public function getJ5PluginData(Container $container): J5PluginData + { + return new J5PluginData( $container->get('Config'), $container->get('Customcode'), $container->get('Customcode.Gui'), @@ -70,11 +180,29 @@ class Joomlaplugin implements ServiceProviderInterface * @param Container $container The DI container. * * @return Structure - * @since 3.2.0 + * @since 3.2.0 */ public function getStructure(Container $container): Structure { - return new Structure( + if (empty($this->targetVersion)) + { + $this->targetVersion = $container->get('Config')->joomla_version; + } + + return $container->get('Joomlaplugin.J' . $this->targetVersion . '.Structure'); + } + + /** + * Get the Joomla 3 Plugin Structure Builder + * + * @param Container $container The DI container. + * + * @return Structure + * @since 5.0.2 + */ + public function getJ3Structure(Container $container): J3Structure + { + return new J3Structure( $container->get('Joomlaplugin.Data'), $container->get('Component'), $container->get('Config'), @@ -87,6 +215,149 @@ class Joomlaplugin implements ServiceProviderInterface $container->get('Utilities.Files') ); } - + + /** + * Get the Joomla 4 Plugin Structure Builder + * + * @param Container $container The DI container. + * + * @return Structure + * @since 5.0.2 + */ + public function getJ4Structure(Container $container): J4Structure + { + return new J4Structure( + $container->get('Joomlaplugin.Data'), + $container->get('Component'), + $container->get('Config'), + $container->get('Registry'), + $container->get('Customcode.Dispenser'), + $container->get('Event'), + $container->get('Utilities.Counter'), + $container->get('Utilities.Folder'), + $container->get('Utilities.File'), + $container->get('Utilities.Files'), + $container->get('Placeholder') + ); + } + + /** + * Get the Joomla 5 Plugin Structure Builder + * + * @param Container $container The DI container. + * + * @return Structure + * @since 5.0.2 + */ + public function getJ5Structure(Container $container): J5Structure + { + return new J5Structure( + $container->get('Joomlaplugin.Data'), + $container->get('Component'), + $container->get('Config'), + $container->get('Registry'), + $container->get('Customcode.Dispenser'), + $container->get('Event'), + $container->get('Utilities.Counter'), + $container->get('Utilities.Folder'), + $container->get('Utilities.File'), + $container->get('Utilities.Files'), + $container->get('Placeholder') + ); + } + + /** + * Get The InfusionInterface Class. + * + * @param Container $container The DI container. + * + * @return Infusion + * @since 5.0.2 + */ + public function getInfusion(Container $container): Infusion + { + if (empty($this->targetVersion)) + { + $this->targetVersion = $container->get('Config')->joomla_version; + } + + return $container->get('Joomlaplugin.J' . $this->targetVersion . '.Infusion'); + } + + /** + * Get The Infusion Class. + * + * @param Container $container The DI container. + * + * @return J3Infusion + * @since 5.0.2 + */ + public function getJ3Infusion(Container $container): J3Infusion + { + return new J3Infusion( + $container->get('Config'), + $container->get('Placeholder'), + $container->get('Header'), + $container->get('Event'), + $container->get('Joomlaplugin.Data'), + $container->get('Extension.InstallScript'), + $container->get('Architecture.Plugin.Extension'), + $container->get('Architecture.Plugin.MainXML'), + $container->get('Compiler.Builder.Content.Multi'), + $container->get('Compiler.Creator.Fieldset.Extension') + ); + } + + /** + * Get The Infusion Class. + * + * @param Container $container The DI container. + * + * @return J4Infusion + * @since 5.0.2 + */ + public function getJ4Infusion(Container $container): J4Infusion + { + return new J4Infusion( + $container->get('Config'), + $container->get('Placeholder'), + $container->get('Header'), + $container->get('Event'), + $container->get('Joomlaplugin.Data'), + $container->get('Extension.InstallScript'), + $container->get('Architecture.Plugin.Extension'), + $container->get('Architecture.Plugin.Provider'), + $container->get('Architecture.Plugin.MainXML'), + $container->get('Compiler.Builder.Content.Multi'), + $container->get('Compiler.Builder.Content.One'), + $container->get('Compiler.Creator.Fieldset.Extension') + ); + } + + /** + * Get The Infusion Class. + * + * @param Container $container The DI container. + * + * @return J5Infusion + * @since 5.0.2 + */ + public function getJ5Infusion(Container $container): J5Infusion + { + return new J5Infusion( + $container->get('Config'), + $container->get('Placeholder'), + $container->get('Header'), + $container->get('Event'), + $container->get('Joomlaplugin.Data'), + $container->get('Extension.InstallScript'), + $container->get('Architecture.Plugin.Extension'), + $container->get('Architecture.Plugin.Provider'), + $container->get('Architecture.Plugin.MainXML'), + $container->get('Compiler.Builder.Content.Multi'), + $container->get('Compiler.Builder.Content.One'), + $container->get('Compiler.Creator.Fieldset.Extension') + ); + } } diff --git a/src/9eba241c-af90-42dd-ae05-92ff4d8391d3/code.power b/src/9eba241c-af90-42dd-ae05-92ff4d8391d3/code.power index 261453c..078a2ca 100644 --- a/src/9eba241c-af90-42dd-ae05-92ff4d8391d3/code.power +++ b/src/9eba241c-af90-42dd-ae05-92ff4d8391d3/code.power @@ -1,31 +1,131 @@ + /** + * Current Joomla Version Being Build + * + * @var int + * @since 5.0.2 + **/ + protected $targetVersion; + /** * Registers the service provider with a DI container. * * @param Container $container The DI container. * * @return void - * @since 3.2.0 + * @since 3.2.0 */ public function register(Container $container) { - $container->alias(Data::class, 'Joomlaplugin.Data') - ->share('Joomlaplugin.Data', [$this, 'getData'], true); + $container->alias(J3PluginData::class, 'Joomlaplugin.J3.Data') + ->share('Joomlaplugin.J3.Data', [$this, 'getJ3PluginData'], true); + + $container->alias(J4PluginData::class, 'Joomlaplugin.J4.Data') + ->share('Joomlaplugin.J4.Data', [$this, 'getJ4PluginData'], true); + + $container->alias(J5PluginData::class, 'Joomlaplugin.J5.Data') + ->share('Joomlaplugin.J5.Data', [$this, 'getJ5PluginData'], true); + + $container->alias(PluginData::class, 'Joomlaplugin.Data') + ->share('Joomlaplugin.Data', [$this, 'getPluginData'], true); + + $container->alias(J3Structure::class, 'Joomlaplugin.J3.Structure') + ->share('Joomlaplugin.J3.Structure', [$this, 'getJ3Structure'], true); + + $container->alias(J4Structure::class, 'Joomlaplugin.J4.Structure') + ->share('Joomlaplugin.J4.Structure', [$this, 'getJ4Structure'], true); + + $container->alias(J5Structure::class, 'Joomlaplugin.J5.Structure') + ->share('Joomlaplugin.J5.Structure', [$this, 'getJ5Structure'], true); $container->alias(Structure::class, 'Joomlaplugin.Structure') ->share('Joomlaplugin.Structure', [$this, 'getStructure'], true); + + $container->alias(J3Infusion::class, 'Joomlaplugin.J3.Infusion') + ->share('Joomlaplugin.J3.Infusion', [$this, 'getJ3Infusion'], true); + + $container->alias(J4Infusion::class, 'Joomlaplugin.J4.Infusion') + ->share('Joomlaplugin.J4.Infusion', [$this, 'getJ4Infusion'], true); + + $container->alias(J5Infusion::class, 'Joomlaplugin.J5.Infusion') + ->share('Joomlaplugin.J5.Infusion', [$this, 'getJ5Infusion'], true); + + $container->alias(Infusion::class, 'Joomlaplugin.Infusion') + ->share('Joomlaplugin.Infusion', [$this, 'getInfusion'], true); } /** - * Get the Joomla Plugin Data + * Get The Plug-in Data Class. * * @param Container $container The DI container. * - * @return Data - * @since 3.2.0 + * @return PluginData + * @since 5.0.2 */ - public function getData(Container $container): Data + public function getPluginData(Container $container): PluginData { - return new Data( + if (empty($this->targetVersion)) + { + $this->targetVersion = $container->get('Config')->joomla_version; + } + + return $container->get('Joomlaplugin.J' . $this->targetVersion . '.Data'); + } + + /** + * Get The PluginData Class. + * + * @param Container $container The DI container. + * + * @return J3PluginData + * @since 5.0.2 + */ + public function getJ3PluginData(Container $container): J3PluginData + { + return new J3PluginData( + $container->get('Config'), + $container->get('Customcode'), + $container->get('Customcode.Gui'), + $container->get('Placeholder'), + $container->get('Language'), + $container->get('Field'), + $container->get('Field.Name'), + $container->get('Model.Filesfolders') + ); + } + + /** + * Get The PluginData Class. + * + * @param Container $container The DI container. + * + * @return J4PluginData + * @since 5.0.2 + */ + public function getJ4PluginData(Container $container): J4PluginData + { + return new J4PluginData( + $container->get('Config'), + $container->get('Customcode'), + $container->get('Customcode.Gui'), + $container->get('Placeholder'), + $container->get('Language'), + $container->get('Field'), + $container->get('Field.Name'), + $container->get('Model.Filesfolders') + ); + } + + /** + * Get The PluginData Class. + * + * @param Container $container The DI container. + * + * @return J5PluginData + * @since 5.0.2 + */ + public function getJ5PluginData(Container $container): J5PluginData + { + return new J5PluginData( $container->get('Config'), $container->get('Customcode'), $container->get('Customcode.Gui'), @@ -43,11 +143,29 @@ * @param Container $container The DI container. * * @return Structure - * @since 3.2.0 + * @since 3.2.0 */ public function getStructure(Container $container): Structure { - return new Structure( + if (empty($this->targetVersion)) + { + $this->targetVersion = $container->get('Config')->joomla_version; + } + + return $container->get('Joomlaplugin.J' . $this->targetVersion . '.Structure'); + } + + /** + * Get the Joomla 3 Plugin Structure Builder + * + * @param Container $container The DI container. + * + * @return Structure + * @since 5.0.2 + */ + public function getJ3Structure(Container $container): J3Structure + { + return new J3Structure( $container->get('Joomlaplugin.Data'), $container->get('Component'), $container->get('Config'), @@ -60,3 +178,147 @@ $container->get('Utilities.Files') ); } + + /** + * Get the Joomla 4 Plugin Structure Builder + * + * @param Container $container The DI container. + * + * @return Structure + * @since 5.0.2 + */ + public function getJ4Structure(Container $container): J4Structure + { + return new J4Structure( + $container->get('Joomlaplugin.Data'), + $container->get('Component'), + $container->get('Config'), + $container->get('Registry'), + $container->get('Customcode.Dispenser'), + $container->get('Event'), + $container->get('Utilities.Counter'), + $container->get('Utilities.Folder'), + $container->get('Utilities.File'), + $container->get('Utilities.Files'), + $container->get('Placeholder') + ); + } + + /** + * Get the Joomla 5 Plugin Structure Builder + * + * @param Container $container The DI container. + * + * @return Structure + * @since 5.0.2 + */ + public function getJ5Structure(Container $container): J5Structure + { + return new J5Structure( + $container->get('Joomlaplugin.Data'), + $container->get('Component'), + $container->get('Config'), + $container->get('Registry'), + $container->get('Customcode.Dispenser'), + $container->get('Event'), + $container->get('Utilities.Counter'), + $container->get('Utilities.Folder'), + $container->get('Utilities.File'), + $container->get('Utilities.Files'), + $container->get('Placeholder') + ); + } + + /** + * Get The InfusionInterface Class. + * + * @param Container $container The DI container. + * + * @return Infusion + * @since 5.0.2 + */ + public function getInfusion(Container $container): Infusion + { + if (empty($this->targetVersion)) + { + $this->targetVersion = $container->get('Config')->joomla_version; + } + + return $container->get('Joomlaplugin.J' . $this->targetVersion . '.Infusion'); + } + + /** + * Get The Infusion Class. + * + * @param Container $container The DI container. + * + * @return J3Infusion + * @since 5.0.2 + */ + public function getJ3Infusion(Container $container): J3Infusion + { + return new J3Infusion( + $container->get('Config'), + $container->get('Placeholder'), + $container->get('Header'), + $container->get('Event'), + $container->get('Joomlaplugin.Data'), + $container->get('Extension.InstallScript'), + $container->get('Architecture.Plugin.Extension'), + $container->get('Architecture.Plugin.MainXML'), + $container->get('Compiler.Builder.Content.Multi'), + $container->get('Compiler.Creator.Fieldset.Extension') + ); + } + + /** + * Get The Infusion Class. + * + * @param Container $container The DI container. + * + * @return J4Infusion + * @since 5.0.2 + */ + public function getJ4Infusion(Container $container): J4Infusion + { + return new J4Infusion( + $container->get('Config'), + $container->get('Placeholder'), + $container->get('Header'), + $container->get('Event'), + $container->get('Joomlaplugin.Data'), + $container->get('Extension.InstallScript'), + $container->get('Architecture.Plugin.Extension'), + $container->get('Architecture.Plugin.Provider'), + $container->get('Architecture.Plugin.MainXML'), + $container->get('Compiler.Builder.Content.Multi'), + $container->get('Compiler.Builder.Content.One'), + $container->get('Compiler.Creator.Fieldset.Extension') + ); + } + + /** + * Get The Infusion Class. + * + * @param Container $container The DI container. + * + * @return J5Infusion + * @since 5.0.2 + */ + public function getJ5Infusion(Container $container): J5Infusion + { + return new J5Infusion( + $container->get('Config'), + $container->get('Placeholder'), + $container->get('Header'), + $container->get('Event'), + $container->get('Joomlaplugin.Data'), + $container->get('Extension.InstallScript'), + $container->get('Architecture.Plugin.Extension'), + $container->get('Architecture.Plugin.Provider'), + $container->get('Architecture.Plugin.MainXML'), + $container->get('Compiler.Builder.Content.Multi'), + $container->get('Compiler.Builder.Content.One'), + $container->get('Compiler.Creator.Fieldset.Extension') + ); + } \ No newline at end of file diff --git a/src/9eba241c-af90-42dd-ae05-92ff4d8391d3/settings.json b/src/9eba241c-af90-42dd-ae05-92ff4d8391d3/settings.json index aed855d..d440adc 100644 --- a/src/9eba241c-af90-42dd-ae05-92ff4d8391d3/settings.json +++ b/src/9eba241c-af90-42dd-ae05-92ff4d8391d3/settings.json @@ -14,11 +14,51 @@ "use_selection": { "use_selection0": { "use": "766a9524-37df-4604-91a7-b98a6150ee26", - "as": "default" + "as": "J3PluginData" }, "use_selection1": { + "use": "361e08c0-5916-4b77-b6a2-c16a769bbc40", + "as": "J4PluginData" + }, + "use_selection2": { + "use": "174f5c9c-5e03-4261-94ca-279ca76c710d", + "as": "J5PluginData" + }, + "use_selection3": { + "use": "8cc85656-a925-4a46-a49b-83c72167fd6a", + "as": "PluginData" + }, + "use_selection4": { "use": "a900b836-f2eb-4f13-8f28-b7cac839c7ff", - "as": "default" + "as": "J3Structure" + }, + "use_selection5": { + "use": "34daa4c8-45c3-4249-baa3-1bedf8ed3ebc", + "as": "J4Structure" + }, + "use_selection6": { + "use": "d05c22be-9641-47fb-8a7b-063c43e7f1bf", + "as": "J5Structure" + }, + "use_selection7": { + "use": "ef66b17c-ffae-414a-9067-20a63ba2bec5", + "as": "Structure" + }, + "use_selection8": { + "use": "03b75302-98ba-47ac-859f-1f49b738f66c", + "as": "J3Infusion" + }, + "use_selection9": { + "use": "84fe58db-d64d-42c6-9b41-f80bcff34c7f", + "as": "J4Infusion" + }, + "use_selection10": { + "use": "7f75b300-534c-4f63-a368-6f4abc4cea58", + "as": "J5Infusion" + }, + "use_selection11": { + "use": "40e17114-2193-4a61-9233-47b5f4193665", + "as": "Infusion" } }, "extendsinterfaces": null, diff --git a/src/9f00e793-86f8-4ef9-b775-a3eb129f83c0/README.md b/src/9f00e793-86f8-4ef9-b775-a3eb129f83c0/README.md index a9b5f39..8124e9f 100644 --- a/src/9f00e793-86f8-4ef9-b775-a3eb129f83c0/README.md +++ b/src/9f00e793-86f8-4ef9-b775-a3eb129f83c0/README.md @@ -14,8 +14,14 @@ class Language #Gold { + register(Container $container) : void + getCompilerLanguage(Container $container) : CompilerLanguage + + getSet(Container $container) : Set + + getPurge(Container $container) : Purge + + getInsert(Container $container) : Insert + + getUpdate(Container $container) : Update + getExtractor(Container $container) : Extractor + getFieldset(Container $container) : Fieldset + + getMultilingual(Container $container) : Multilingual + + getTranslation(Container $container) : Translation } note right of Language::register @@ -25,13 +31,41 @@ note right of Language::register return: void end note -note right of Language::getCompilerLanguage +note left of Language::getCompilerLanguage Get The Language Class. since: 3.2.0 return: CompilerLanguage end note +note right of Language::getSet + Get The Set Class. + + since: 3.2.0 + return: Set +end note + +note left of Language::getPurge + Get The Purge Class. + + since: 5.0.2 + return: Purge +end note + +note right of Language::getInsert + Get The Insert Class. + + since: 5.0.2 + return: Insert +end note + +note left of Language::getUpdate + Get The Update Class. + + since: 5.0.2 + return: Update +end note + note right of Language::getExtractor Get The Extractor Class. @@ -39,12 +73,26 @@ note right of Language::getExtractor return: Extractor end note -note right of Language::getFieldset +note left of Language::getFieldset Get The Fieldset Class. since: 3.2.0 return: Fieldset end note + +note right of Language::getMultilingual + Get The Multilingual Class. + + since: 5.0.2 + return: Multilingual +end note + +note left of Language::getTranslation + Get The Translation Class. + + since: 3.2.0 + return: Translation +end note @enduml ``` diff --git a/src/9f00e793-86f8-4ef9-b775-a3eb129f83c0/code.php b/src/9f00e793-86f8-4ef9-b775-a3eb129f83c0/code.php index 0fc4e7e..c7f0eed 100644 --- a/src/9f00e793-86f8-4ef9-b775-a3eb129f83c0/code.php +++ b/src/9f00e793-86f8-4ef9-b775-a3eb129f83c0/code.php @@ -15,8 +15,14 @@ namespace VDM\Joomla\Componentbuilder\Compiler\Service; use Joomla\DI\Container; use Joomla\DI\ServiceProviderInterface; use VDM\Joomla\Componentbuilder\Compiler\Language as CompilerLanguage; +use VDM\Joomla\Componentbuilder\Compiler\Language\Set; +use VDM\Joomla\Componentbuilder\Compiler\Language\Purge; +use VDM\Joomla\Componentbuilder\Compiler\Language\Insert; +use VDM\Joomla\Componentbuilder\Compiler\Language\Update; use VDM\Joomla\Componentbuilder\Compiler\Language\Extractor; use VDM\Joomla\Componentbuilder\Compiler\Language\Fieldset; +use VDM\Joomla\Componentbuilder\Compiler\Language\Multilingual; +use VDM\Joomla\Componentbuilder\Compiler\Language\Translation; /** @@ -39,11 +45,29 @@ class Language implements ServiceProviderInterface $container->alias(CompilerLanguage::class, 'Language') ->share('Language', [$this, 'getCompilerLanguage'], true); + $container->alias(Set::class, 'Language.Set') + ->share('Language.Set', [$this, 'getSet'], true); + + $container->alias(Purge::class, 'Language.Purge') + ->share('Language.Purge', [$this, 'getPurge'], true); + + $container->alias(Insert::class, 'Language.Insert') + ->share('Language.Insert', [$this, 'getInsert'], true); + + $container->alias(Update::class, 'Language.Update') + ->share('Language.Update', [$this, 'getUpdate'], true); + $container->alias(Extractor::class, 'Language.Extractor') ->share('Language.Extractor', [$this, 'getExtractor'], true); $container->alias(Fieldset::class, 'Language.Fieldset') ->share('Language.Fieldset', [$this, 'getFieldset'], true); + + $container->alias(Multilingual::class, 'Language.Multilingual') + ->share('Language.Multilingual', [$this, 'getMultilingual'], true); + + $container->alias(Translation::class, 'Language.Translation') + ->share('Language.Translation', [$this, 'getTranslation'], true); } /** @@ -61,6 +85,67 @@ class Language implements ServiceProviderInterface ); } + /** + * Get The Set Class. + * + * @param Container $container The DI container. + * + * @return Set + * @since 3.2.0 + */ + public function getSet(Container $container): Set + { + return new Set( + $container->get('Config'), + $container->get('Language'), + $container->get('Compiler.Builder.Multilingual'), + $container->get('Compiler.Builder.Languages'), + $container->get('Language.Insert'), + $container->get('Language.Update') + ); + } + + /** + * Get The Purge Class. + * + * @param Container $container The DI container. + * + * @return Purge + * @since 5.0.2 + */ + public function getPurge(Container $container): Purge + { + return new Purge( + $container->get('Language.Update') + ); + } + + /** + * Get The Insert Class. + * + * @param Container $container The DI container. + * + * @return Insert + * @since 5.0.2 + */ + public function getInsert(Container $container): Insert + { + return new Insert(); + } + + /** + * Get The Update Class. + * + * @param Container $container The DI container. + * + * @return Update + * @since 5.0.2 + */ + public function getUpdate(Container $container): Update + { + return new Update(); + } + /** * Get The Extractor Class. * @@ -94,6 +179,35 @@ class Language implements ServiceProviderInterface $container->get('Compiler.Builder.Access.Switch'), $container->get('Compiler.Builder.Access.Switch.List') ); + } + + /** + * Get The Multilingual Class. + * + * @param Container $container The DI container. + * + * @return Multilingual + * @since 5.0.2 + */ + public function getMultilingual(Container $container): Multilingual + { + return new Multilingual(); + } + + /** + * 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('Config'), + $container->get('Compiler.Builder.Language.Messages') + ); } } diff --git a/src/9f00e793-86f8-4ef9-b775-a3eb129f83c0/code.power b/src/9f00e793-86f8-4ef9-b775-a3eb129f83c0/code.power index 0b9febf..66f2566 100644 --- a/src/9f00e793-86f8-4ef9-b775-a3eb129f83c0/code.power +++ b/src/9f00e793-86f8-4ef9-b775-a3eb129f83c0/code.power @@ -11,11 +11,29 @@ $container->alias(CompilerLanguage::class, 'Language') ->share('Language', [$this, 'getCompilerLanguage'], true); + $container->alias(Set::class, 'Language.Set') + ->share('Language.Set', [$this, 'getSet'], true); + + $container->alias(Purge::class, 'Language.Purge') + ->share('Language.Purge', [$this, 'getPurge'], true); + + $container->alias(Insert::class, 'Language.Insert') + ->share('Language.Insert', [$this, 'getInsert'], true); + + $container->alias(Update::class, 'Language.Update') + ->share('Language.Update', [$this, 'getUpdate'], true); + $container->alias(Extractor::class, 'Language.Extractor') ->share('Language.Extractor', [$this, 'getExtractor'], true); $container->alias(Fieldset::class, 'Language.Fieldset') ->share('Language.Fieldset', [$this, 'getFieldset'], true); + + $container->alias(Multilingual::class, 'Language.Multilingual') + ->share('Language.Multilingual', [$this, 'getMultilingual'], true); + + $container->alias(Translation::class, 'Language.Translation') + ->share('Language.Translation', [$this, 'getTranslation'], true); } /** @@ -33,6 +51,67 @@ ); } + /** + * Get The Set Class. + * + * @param Container $container The DI container. + * + * @return Set + * @since 3.2.0 + */ + public function getSet(Container $container): Set + { + return new Set( + $container->get('Config'), + $container->get('Language'), + $container->get('Compiler.Builder.Multilingual'), + $container->get('Compiler.Builder.Languages'), + $container->get('Language.Insert'), + $container->get('Language.Update') + ); + } + + /** + * Get The Purge Class. + * + * @param Container $container The DI container. + * + * @return Purge + * @since 5.0.2 + */ + public function getPurge(Container $container): Purge + { + return new Purge( + $container->get('Language.Update') + ); + } + + /** + * Get The Insert Class. + * + * @param Container $container The DI container. + * + * @return Insert + * @since 5.0.2 + */ + public function getInsert(Container $container): Insert + { + return new Insert(); + } + + /** + * Get The Update Class. + * + * @param Container $container The DI container. + * + * @return Update + * @since 5.0.2 + */ + public function getUpdate(Container $container): Update + { + return new Update(); + } + /** * Get The Extractor Class. * @@ -66,4 +145,33 @@ $container->get('Compiler.Builder.Access.Switch'), $container->get('Compiler.Builder.Access.Switch.List') ); + } + + /** + * Get The Multilingual Class. + * + * @param Container $container The DI container. + * + * @return Multilingual + * @since 5.0.2 + */ + public function getMultilingual(Container $container): Multilingual + { + return new Multilingual(); + } + + /** + * 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('Config'), + $container->get('Compiler.Builder.Language.Messages') + ); } \ No newline at end of file diff --git a/src/9f00e793-86f8-4ef9-b775-a3eb129f83c0/settings.json b/src/9f00e793-86f8-4ef9-b775-a3eb129f83c0/settings.json index a82e60b..001a17b 100644 --- a/src/9f00e793-86f8-4ef9-b775-a3eb129f83c0/settings.json +++ b/src/9f00e793-86f8-4ef9-b775-a3eb129f83c0/settings.json @@ -17,12 +17,36 @@ "as": "CompilerLanguage" }, "use_selection1": { - "use": "d33b9278-c409-4aec-a047-b72f56712391", + "use": "058cfcd7-1f84-4cc6-8bcc-7672f316881d", "as": "default" }, "use_selection2": { + "use": "0b0e574c-aab4-4eaf-96d8-d7210d8ed93e", + "as": "default" + }, + "use_selection3": { + "use": "1d051a2f-0691-45a8-b3d9-d0c1adcd73bc", + "as": "default" + }, + "use_selection4": { + "use": "375543cd-5f2a-4893-982e-a73eaa55360d", + "as": "default" + }, + "use_selection5": { + "use": "d33b9278-c409-4aec-a047-b72f56712391", + "as": "default" + }, + "use_selection6": { "use": "4ad7020e-39ab-49ba-977b-de6084944502", "as": "default" + }, + "use_selection7": { + "use": "263f0227-3cc2-4a88-9818-edb20081c30c", + "as": "default" + }, + "use_selection8": { + "use": "344d36be-3949-4848-8cb0-e3d3d9d05c36", + "as": "default" } }, "extendsinterfaces": null, diff --git a/src/a5f658ff-3962-475d-8cf8-c91da562bf49/README.md b/src/a5f658ff-3962-475d-8cf8-c91da562bf49/README.md new file mode 100644 index 0000000..24bb77c --- /dev/null +++ b/src/a5f658ff-3962-475d-8cf8-c91da562bf49/README.md @@ -0,0 +1,61 @@ +``` +██████╗ ██████╗ ██╗ ██╗███████╗██████╗ +██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗ +██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝ +██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗ +██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║ +╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝ +``` +# final class Extension (Details) +> namespace: **VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaThree\Plugin** + +```uml +@startuml +class Extension << (F,LightGreen) >> #RoyalBlue { + # Placeholder $placeholder + # Builder $builder + + __construct(Placeholder $placeholder, Builder $builder) + + get(object $plugin) : string +} + +note right of Extension::__construct + Constructor. + + since: 5.0.2 +end note + +note right of Extension::get + Get the updated placeholder content for the given plugin. + + since: 5.0.2 + return: string +end note + +@enduml +``` + +The Power feature in JCB allows you to write PHP classes and their implementations, making it easy to include them in your Joomla project. JCB handles linking, autoloading, namespacing, and folder structure creation for you. + +By using the SPK (Super Power Key) in your custom code (replacing the class name in your code with the SPK), JCB will automatically pull the power from the repository into your project. This makes it available in your JCB instance, allowing you to edit it and include the class in your generated Joomla component. + +JCB uses placeholders like [[[`NamespacePrefix`]]] and [[[`ComponentNamespace`]]] in namespacing to prevent collisions and improve reusability across different JCB systems. You can also set the **JCB powers path** globally or per component under the **Dynamic Integration** tab, providing flexibility and easy maintainability. + +To add this specific Power to your project in JCB: + +> simply use this SPK +``` +Super---a5f658ff_3962_475d_8cf8_c91da562bf49---Power +``` +> remember to replace the `---` with `___` to activate this Power in your code + +--- +``` + ██╗ ██████╗██████╗ + ██║██╔════╝██╔══██╗ + ██║██║ ██████╔╝ +██ ██║██║ ██╔══██╗ +╚█████╔╝╚██████╗██████╔╝ + ╚════╝ ╚═════╝╚═════╝ +``` +> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder) + diff --git a/src/a5f658ff-3962-475d-8cf8-c91da562bf49/code.php b/src/a5f658ff-3962-475d-8cf8-c91da562bf49/code.php new file mode 100644 index 0000000..913d5c2 --- /dev/null +++ b/src/a5f658ff-3962-475d-8cf8-c91da562bf49/code.php @@ -0,0 +1,78 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaThree\Plugin; + + +use VDM\Joomla\Componentbuilder\Compiler\Placeholder; +use VDM\Joomla\Componentbuilder\Compiler\Builder\ContentOne as Builder; +use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Architecture\Plugin\ExtensionInterface; + + +/** + * Plugin Extension Class for Joomla 3 + * + * @since 5.0.2 + */ +final class Extension implements ExtensionInterface +{ + /** + * The Placeholder Class. + * + * @var Placeholder + * @since 5.0.2 + */ + protected Placeholder $placeholder; + + /** + * The ContentOne Class. + * + * @var Builder + * @since 5.0.2 + */ + protected Builder $builder; + + /** + * Constructor. + * + * @param Placeholder $placeholder The Placeholder Class. + * @param Builder $builder The Content One Class. + * + * @since 5.0.2 + */ + public function __construct(Placeholder $placeholder, Builder $builder) + { + $this->placeholder = $placeholder; + $this->builder = $builder; + } + + /** + * Get the updated placeholder content for the given plugin. + * + * @param object $plugin The plugin object containing the necessary data. + * + * @return string The updated placeholder content. + * + * @since 5.0.2 + */ + public function get(object $plugin): string + { + return $this->placeholder->update( + $plugin->comment . PHP_EOL . 'class ' . + $plugin->class_name . ' extends ' . + $plugin->extends . PHP_EOL . '{' . PHP_EOL . + $plugin->main_class_code . PHP_EOL . + "}" . PHP_EOL, + $this->builder->allActive() + ); + } +} + diff --git a/src/a5f658ff-3962-475d-8cf8-c91da562bf49/code.power b/src/a5f658ff-3962-475d-8cf8-c91da562bf49/code.power new file mode 100644 index 0000000..6c2ddb7 --- /dev/null +++ b/src/a5f658ff-3962-475d-8cf8-c91da562bf49/code.power @@ -0,0 +1,50 @@ + /** + * The Placeholder Class. + * + * @var Placeholder + * @since 5.0.2 + */ + protected Placeholder $placeholder; + + /** + * The ContentOne Class. + * + * @var Builder + * @since 5.0.2 + */ + protected Builder $builder; + + /** + * Constructor. + * + * @param Placeholder $placeholder The Placeholder Class. + * @param Builder $builder The Content One Class. + * + * @since 5.0.2 + */ + public function __construct(Placeholder $placeholder, Builder $builder) + { + $this->placeholder = $placeholder; + $this->builder = $builder; + } + + /** + * Get the updated placeholder content for the given plugin. + * + * @param object $plugin The plugin object containing the necessary data. + * + * @return string The updated placeholder content. + * + * @since 5.0.2 + */ + public function get(object $plugin): string + { + return $this->placeholder->update( + $plugin->comment . PHP_EOL . 'class ' . + $plugin->class_name . ' extends ' . + $plugin->extends . PHP_EOL . '{' . PHP_EOL . + $plugin->main_class_code . PHP_EOL . + "}" . PHP_EOL, + $this->builder->allActive() + ); + } \ No newline at end of file diff --git a/src/a5f658ff-3962-475d-8cf8-c91da562bf49/settings.json b/src/a5f658ff-3962-475d-8cf8-c91da562bf49/settings.json new file mode 100644 index 0000000..09b1072 --- /dev/null +++ b/src/a5f658ff-3962-475d-8cf8-c91da562bf49/settings.json @@ -0,0 +1,30 @@ +{ + "add_head": "0", + "add_licensing_template": "2", + "extends": "", + "guid": "a5f658ff-3962-475d-8cf8-c91da562bf49", + "implements": [ + "914db7f5-82d8-4d3b-a1c1-eb476b1898c2" + ], + "load_selection": null, + "name": "Extension", + "power_version": "1.0.0", + "system_name": "JCB.Architecture.J3.Plugin.Extension", + "type": "final class", + "use_selection": { + "use_selection0": { + "use": "06453ada-e370-49f0-b262-e3f5a8ed0c2c", + "as": "default" + }, + "use_selection1": { + "use": "adfbe68a-6d22-43e5-aee8-2787e8c47e75", + "as": "Builder" + } + }, + "extendsinterfaces": null, + "namespace": "[[[NamespacePrefix]]]\\Joomla\\[[[ComponentNamespace]]].Compiler.Architecture.JoomlaThree.Plugin.Extension", + "description": "Plugin Extension Class for Joomla 3\r\n\r\n@since 5.0.2", + "licensing_template": "\/**\r\n * @package Joomla.Component.Builder\r\n *\r\n * @created 4th September, 2022\r\n * @author Llewellyn van der Merwe \r\n * @git Joomla Component Builder \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/a7124f78-21c5-400e-984d-4c5463cb2315/README.md b/src/a7124f78-21c5-400e-984d-4c5463cb2315/README.md new file mode 100644 index 0000000..abc9375 --- /dev/null +++ b/src/a7124f78-21c5-400e-984d-4c5463cb2315/README.md @@ -0,0 +1,156 @@ +``` +██████╗ ██████╗ ██╗ ██╗███████╗██████╗ +██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗ +██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝ +██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗ +██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║ +╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝ +``` +# final class MainXML (Details) +> namespace: **VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaFive\Plugin** + +```uml +@startuml +class MainXML << (F,LightGreen) >> #RoyalBlue { + # Config $config + # Language $language + # Set $set + # Purge $purge + # Translation $translation + # Multilingual $multilingual + # Event $event + # FieldsetExtension $fieldsetextension + # ContentOne $contentone + # Languages $languages + # BuilderMultilingual $buildermultilingual + # Counter $counter + # File $file + + __construct(Config $config, Language $language, ...) + + get(object $plugin) : string + # buildConfigFields(object $plugin) : array + # shouldAddComponentPath(object $plugin) : bool + # generateScriptAndSqlXml(object $plugin) : string + # generateLanguageXml(object $plugin, array $languageFiles) : string + # generateFileXml(object $plugin, array $languageFiles) : string + # generateConfigXml(object $plugin, array $configFields, ...) : string + # generateUpdateServerXml(object $plugin) : string + # generateLanguageFiles(object $plugin) : array +} + +note right of MainXML::__construct + Constructor. + + since: 5.0.2 + + arguments: + Config $config + Language $language + Set $set + Purge $purge + Translation $translation + Multilingual $multilingual + Event $event + FieldsetExtension $fieldsetextension + ContentOne $contentone + Languages $languages + BuilderMultilingual $buildermultilingual + Counter $counter + File $file +end note + +note left of MainXML::get + Generates the main XML for the plugin. + + since: 5.0.2 + return: string +end note + +note right of MainXML::buildConfigFields + Build configuration fields XML. + + since: 5.0.2 + return: array +end note + +note left of MainXML::shouldAddComponentPath + Determine if the component path should be added. + + since: 5.0.2 + return: bool +end note + +note right of MainXML::generateScriptAndSqlXml + Generate XML for script and SQL files. + + since: 5.0.2 + return: string +end note + +note left of MainXML::generateLanguageXml + Generate XML for language files. + + since: 5.0.2 + return: string +end note + +note right of MainXML::generateFileXml + Generate the XML for the files. + + since: 5.0.2 + return: string +end note + +note left of MainXML::generateConfigXml + Generate XML for configuration fields. + + since: 5.0.2 + return: string + + arguments: + object $plugin + array $configFields + bool $addComponentPath +end note + +note right of MainXML::generateUpdateServerXml + Generate XML for update servers. + + since: 5.0.2 + return: string +end note + +note left of MainXML::generateLanguageFiles + Generate language files. + + since: 5.0.2 + return: array +end note + +@enduml +``` + +The Power feature in JCB allows you to write PHP classes and their implementations, making it easy to include them in your Joomla project. JCB handles linking, autoloading, namespacing, and folder structure creation for you. + +By using the SPK (Super Power Key) in your custom code (replacing the class name in your code with the SPK), JCB will automatically pull the power from the repository into your project. This makes it available in your JCB instance, allowing you to edit it and include the class in your generated Joomla component. + +JCB uses placeholders like [[[`NamespacePrefix`]]] and [[[`ComponentNamespace`]]] in namespacing to prevent collisions and improve reusability across different JCB systems. You can also set the **JCB powers path** globally or per component under the **Dynamic Integration** tab, providing flexibility and easy maintainability. + +To add this specific Power to your project in JCB: + +> simply use this SPK +``` +Super---a7124f78_21c5_400e_984d_4c5463cb2315---Power +``` +> remember to replace the `---` with `___` to activate this Power in your code + +--- +``` + ██╗ ██████╗██████╗ + ██║██╔════╝██╔══██╗ + ██║██║ ██████╔╝ +██ ██║██║ ██╔══██╗ +╚█████╔╝╚██████╗██████╔╝ + ╚════╝ ╚═════╝╚═════╝ +``` +> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder) + diff --git a/src/a7124f78-21c5-400e-984d-4c5463cb2315/code.php b/src/a7124f78-21c5-400e-984d-4c5463cb2315/code.php new file mode 100644 index 0000000..36bd243 --- /dev/null +++ b/src/a7124f78-21c5-400e-984d-4c5463cb2315/code.php @@ -0,0 +1,569 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaFive\Plugin; + + +use Joomla\CMS\Filesystem\Folder; +use VDM\Joomla\Componentbuilder\Compiler\Config; +use VDM\Joomla\Componentbuilder\Compiler\Language; +use VDM\Joomla\Componentbuilder\Compiler\Language\Set; +use VDM\Joomla\Componentbuilder\Compiler\Language\Purge; +use VDM\Joomla\Componentbuilder\Compiler\Language\Translation; +use VDM\Joomla\Componentbuilder\Compiler\Language\Multilingual; +use VDM\Joomla\Componentbuilder\Compiler\Interfaces\EventInterface as Event; +use VDM\Joomla\Componentbuilder\Compiler\Creator\FieldsetExtension; +use VDM\Joomla\Componentbuilder\Compiler\Builder\ContentOne; +use VDM\Joomla\Componentbuilder\Compiler\Builder\Languages; +use VDM\Joomla\Componentbuilder\Compiler\Builder\Multilingual as BuilderMultilingual; +use VDM\Joomla\Componentbuilder\Compiler\Utilities\Counter; +use VDM\Joomla\Componentbuilder\Compiler\Utilities\File; +use VDM\Joomla\Componentbuilder\Compiler\Utilities\Line; +use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent; +use VDM\Joomla\Utilities\ArrayHelper; +use VDM\Joomla\Utilities\StringHelper; +use VDM\Joomla\Componentbuilder\Interfaces\Architecture\Plugin\MainXMLInterface; + + +/** + * Joomla 5 Plugin Main XML Class + * + * @since 5.0.2 + */ +final class MainXML implements MainXMLInterface +{ + /** + * The Config Class. + * + * @var Config + * @since 5.0.2 + */ + protected Config $config; + + /** + * The Language Class. + * + * @var Language + * @since 5.0.2 + */ + protected Language $language; + + /** + * The Set Class. + * + * @var Set + * @since 5.0.2 + */ + protected Set $set; + + /** + * The Purge Class. + * + * @var Purge + * @since 5.0.2 + */ + protected Purge $purge; + + /** + * The Translation Class. + * + * @var Translation + * @since 5.0.2 + */ + protected Translation $translation; + + /** + * The Multilingual Class. + * + * @var Multilingual + * @since 5.0.2 + */ + protected Multilingual $multilingual; + + /** + * The EventInterface Class. + * + * @var Event + * @since 5.0.2 + */ + protected Event $event; + + /** + * The FieldsetExtension Class. + * + * @var FieldsetExtension + * @since 5.0.2 + */ + protected FieldsetExtension $fieldsetextension; + + /** + * The ContentOne Class. + * + * @var ContentOne + * @since 5.0.2 + */ + protected ContentOne $contentone; + + /** + * The Languages Class. + * + * @var Languages + * @since 5.0.2 + */ + protected Languages $languages; + + /** + * The Multilingual Class. + * + * @var BuilderMultilingual + * @since 5.0.2 + */ + protected BuilderMultilingual $buildermultilingual; + + /** + * The Counter Class. + * + * @var Counter + * @since 5.0.2 + */ + protected Counter $counter; + + /** + * The File Class. + * + * @var File + * @since 5.0.2 + */ + protected File $file; + + /** + * Constructor. + * + * @param Config $config The Config Class. + * @param Language $language The Language Class. + * @param Set $set The Set Class. + * @param Purge $purge The Purge Class. + * @param Translation $translation The Translation Class. + * @param Multilingual $multilingual The Multilingual Class. + * @param Event $event The EventInterface Class. + * @param FieldsetExtension $fieldsetextension The FieldsetExtension Class. + * @param ContentOne $contentone The ContentOne Class. + * @param Languages $languages The Languages Class. + * @param BuilderMultilingual $buildermultilingual The Multilingual Class. + * @param Counter $counter The Counter Class. + * @param File $file The File Class. + * + * @since 5.0.2 + */ + public function __construct(Config $config, Language $language, Set $set, Purge $purge, + Translation $translation, Multilingual $multilingual, + Event $event, FieldsetExtension $fieldsetextension, + ContentOne $contentone, Languages $languages, + BuilderMultilingual $buildermultilingual, + Counter $counter, File $file) + { + $this->config = $config; + $this->language = $language; + $this->set = $set; + $this->purge = $purge; + $this->translation = $translation; + $this->multilingual = $multilingual; + $this->event = $event; + $this->fieldsetextension = $fieldsetextension; + $this->contentone = $contentone; + $this->languages = $languages; + $this->buildermultilingual = $buildermultilingual; + $this->counter = $counter; + $this->file = $file; + } + + /** + * Generates the main XML for the plugin. + * + * @param object $plugin The plugin object. + * + * @return string The generated XML. + * @since 5.0.2 + */ + public function get(object $plugin): string + { + $config_fields = $this->buildConfigFields($plugin); + $add_component_path = $this->shouldAddComponentPath($plugin); + $language_files = $this->generateLanguageFiles($plugin); + + $xml = $this->generateScriptAndSqlXml($plugin); + $xml .= $this->generateLanguageXml($plugin, $language_files); + $xml .= $this->generateFileXml($plugin, $language_files); + $xml .= $this->generateConfigXml($plugin, $config_fields, $add_component_path); + $xml .= $this->generateUpdateServerXml($plugin); + + return $xml; + } + + /** + * Build configuration fields XML. + * + * @param object $plugin The plugin object. + * + * @return array The configuration fields. + * @since 5.0.2 + */ + protected function buildConfigFields(object $plugin): array + { + $configFields = []; + if (!isset($plugin->config_fields) || !ArrayHelper::check($plugin->config_fields)) + { + return $configFields; + } + + $dbKey = 'yy'; + + foreach ($plugin->config_fields as $fieldName => $fieldsets) + { + foreach ($fieldsets as $fieldset => $fields) + { + $xmlFields = $this->fieldsetextension->get($plugin, $fields, $dbKey); + if (isset($xmlFields) && StringHelper::check($xmlFields)) + { + $configFields["{$fieldName}{$fieldset}"] = $xmlFields; + } + $dbKey++; + } + } + + return $configFields; + } + + /** + * Determine if the component path should be added. + * + * @param object $plugin The plugin object. + * + * @return bool True if the component path should be added, false otherwise. + * @since 5.0.2 + */ + protected function shouldAddComponentPath(object $plugin): bool + { + if (!isset($plugin->config_fields) || !ArrayHelper::check($plugin->config_fields) || + !isset($plugin->fieldsets_paths) || !ArrayHelper::check($plugin->fieldsets_paths)) + { + return false; + } + + foreach ($plugin->config_fields as $fieldName => $fieldsets) + { + foreach ($fieldsets as $fieldset => $fields) + { + if (isset($plugin->fieldsets_paths["{$fieldName}{$fieldset}"]) && + $plugin->fieldsets_paths["{$fieldName}{$fieldset}"] == 1) + { + return true; + } + } + } + + return false; + } + + /** + * Generate XML for script and SQL files. + * + * @param object $plugin The plugin object. + * + * @return string The XML for script and SQL files. + * @since 5.0.2 + */ + protected function generateScriptAndSqlXml(object $plugin): string + { + $xml = ''; + + if ($plugin->add_install_script) + { + $xml .= PHP_EOL . PHP_EOL . Indent::_(1) . ''; + $xml .= PHP_EOL . Indent::_(1) . 'script.php'; + } + + if ($plugin->add_sql) + { + $xml .= PHP_EOL . PHP_EOL . Indent::_(1) . ''; + $xml .= PHP_EOL . Indent::_(1) . ''; + $xml .= PHP_EOL . Indent::_(2) . ''; + $xml .= PHP_EOL . Indent::_(3) . 'sql/mysql/install.sql'; + $xml .= PHP_EOL . Indent::_(2) . ''; + $xml .= PHP_EOL . Indent::_(1) . ''; + } + + if ($plugin->add_sql_uninstall) + { + $xml .= PHP_EOL . PHP_EOL . Indent::_(1) . ''; + $xml .= PHP_EOL . Indent::_(1) . ''; + $xml .= PHP_EOL . Indent::_(2) . ''; + $xml .= PHP_EOL . Indent::_(3) . 'sql/mysql/uninstall.sql'; + $xml .= PHP_EOL . Indent::_(2) . ''; + $xml .= PHP_EOL . Indent::_(1) . ''; + } + + return $xml; + } + + /** + * Generate XML for language files. + * + * @param object $plugin The plugin object. + * @param array $languageFiles The language files. + * + * @return string The XML for language files. + * @since 5.0.2 + */ + protected function generateLanguageXml(object $plugin, array $languageFiles): string + { + $xml = ''; + + if (ArrayHelper::check($languageFiles)) + { + $xml .= PHP_EOL . PHP_EOL . Indent::_(1) . ''; + $xml .= PHP_EOL . Indent::_(1) . ''; + + foreach ($languageFiles as $addTag) + { + $xml .= PHP_EOL . Indent::_(2) . '' . $addTag . '/plg_' + . strtolower((string) $plugin->group) . '_' . + (string) $plugin->file_name + . '.ini'; + $xml .= PHP_EOL . Indent::_(2) . '' . $addTag . '/plg_' + . strtolower((string) $plugin->group) . '_' . + (string) $plugin->file_name + . '.sys.ini'; + } + $xml .= PHP_EOL . Indent::_(1) . ''; + } + + return $xml; + } + + /** + * Generate the XML for the files. + * + * @param object $plugin The plugin object. + * @param array $languageFiles The language files. + * + * @return string The XML for the files. + * @since 5.0.2 + */ + protected function generateFileXml(object $plugin, array $languageFiles): string + { + $files = Folder::files($plugin->folder_path); + $folders = Folder::folders($plugin->folder_path); + $ignore = ['sql', 'language', 'script.php', "{$plugin->file_name}.xml"]; + + $xml = PHP_EOL . PHP_EOL . Indent::_(1) . ''; + $xml .= PHP_EOL . Indent::_(1) . ''; + $xml .= PHP_EOL . Indent::_(2) . "context_name}\">services"; + + foreach ($files as $file) + { + if (!in_array($file, $ignore)) + { + $xml .= PHP_EOL . Indent::_(2) . "{$file}"; + } + } + + if (!empty($languageFiles)) + { + // $xml .= PHP_EOL . Indent::_(2) . 'language'; + } + + if ($plugin->add_sql || $plugin->add_sql_uninstall) + { + $xml .= PHP_EOL . Indent::_(2) . 'sql'; + } + + foreach ($folders as $folder) + { + if (!in_array($folder, $ignore)) + { + $xml .= PHP_EOL . Indent::_(2) . "{$folder}"; + } + } + + $xml .= PHP_EOL . Indent::_(1) . ''; + + return $xml; + } + + /** + * Generate XML for configuration fields. + * + * @param object $plugin The plugin object. + * @param array $configFields The configuration fields. + * @param bool $addComponentPath Whether to add the component path. + * + * @return string The XML for configuration fields. + * @since 5.0.2 + */ + protected function generateConfigXml(object $plugin, array $configFields, bool $addComponentPath): string + { + if (!isset($plugin->config_fields) || !ArrayHelper::check($configFields)) + { + return ''; + } + + $xml = PHP_EOL . PHP_EOL . Indent::_(1) . ''; + $xml .= $addComponentPath ? PHP_EOL . Indent::_(1) . ''; + + if ($addComponentPath) + { + $xml .= PHP_EOL . Indent::_(3) . 'addruleprefix="' . $this->config->namespace_prefix . '\Component\\' . $this->contentone->get('ComponentNamespace') . '\Administrator\Rule"'; + $xml .= PHP_EOL . Indent::_(3) . 'addfieldprefix="' . $this->config->namespace_prefix . '\Component\\' . $this->contentone->get('ComponentNamespace') . '\Administrator\Field">'; + $xml .= PHP_EOL . Indent::_(1) . '>'; + } + + foreach ($plugin->config_fields as $fieldName => $fieldsets) + { + $xml .= PHP_EOL . Indent::_(1) . ""; + + foreach ($fieldsets as $fieldset => $fields) + { + $label = $plugin->fieldsets_label["{$fieldName}{$fieldset}"] ?? $fieldset; + + $xml .= PHP_EOL . Indent::_(1) . "
"; + + if (isset($configFields["{$fieldName}{$fieldset}"])) + { + $xml .= $configFields["{$fieldName}{$fieldset}"]; + } + + $xml .= PHP_EOL . Indent::_(1) . '
'; + } + + $xml .= PHP_EOL . Indent::_(1) . '
'; + } + + $xml .= PHP_EOL . Indent::_(1) . ''; + + return $xml; + } + + /** + * Generate XML for update servers. + * + * @param object $plugin The plugin object. + * + * @return string The XML for update servers. + * @since 5.0.2 + */ + protected function generateUpdateServerXml(object $plugin): string + { + $xml = ''; + + if ($plugin->add_update_server) + { + $xml = PHP_EOL . PHP_EOL . Indent::_(1) . ''; + $xml .= PHP_EOL . Indent::_(1) . ''; + $xml .= PHP_EOL . Indent::_(2) . '' . $plugin->update_server_url . ''; + $xml .= PHP_EOL . Indent::_(1) . ''; + } + + return $xml; + } + + /** + * Generate language files. + * + * @param object $plugin The plugin object. + * + * @return array The language files. + * @since 5.0.2 + */ + protected function generateLanguageFiles(object $plugin): array + { + $languageFiles = []; + + if (!$this->language->exist($plugin->key)) + { + return $languageFiles; + } + + $langContent = $this->language->getTarget($plugin->key); + $this->event->trigger('jcb_ce_onBeforeBuildPluginLang', [&$plugin, &$langContent]); + + $values = array_unique($langContent); + $this->buildermultilingual->set('plugins', $this->multilingual->get($values)); + + $langTag = $this->config->get('lang_tag', 'en-GB'); + $this->languages->set("plugins.{$langTag}.all", $langContent); + $this->language->setTarget($plugin->key, null); + + $this->set->execute($values, $plugin->id, 'plugins'); + $this->purge->execute($values, $plugin->id, 'plugins'); + + $this->event->trigger('jcb_ce_onBeforeBuildPluginLangFiles', [&$plugin]); + + if ($this->languages->IsArray('plugins')) + { + foreach ($this->languages->get('plugins') as $tag => $areas) + { + $tag = trim($tag); + foreach ($areas as $area => $languageStrings) + { + $fileName = "plg_" . strtolower((string)$plugin->group) . '_' . $plugin->file_name . '.ini'; + $total = count($values); + if ($this->translation->check($tag, $languageStrings, $total, $fileName)) + { + $lang = array_map( + fn($langString, $placeholder) => "{$placeholder}=\"{$langString}\"", + array_values($languageStrings), + array_keys($languageStrings) + ); + + $path = "{$plugin->folder_path}/language/{$tag}/"; + + if (!Folder::exists($path)) + { + Folder::create($path); + $this->counter->folder++; + } + + $this->file->write($path . $fileName, implode(PHP_EOL, $lang)); + $this->file->write( + $path . 'plg_' . strtolower((string)$plugin->group) . '_' . $plugin->file_name . '.sys.ini', + implode(PHP_EOL, $lang) + ); + + $this->counter->line += count($lang); + unset($lang); + + $languageFiles[$tag] = $tag; + } + } + } + } + + return $languageFiles; + } +} + diff --git a/src/a7124f78-21c5-400e-984d-4c5463cb2315/code.power b/src/a7124f78-21c5-400e-984d-4c5463cb2315/code.power new file mode 100644 index 0000000..e54f639 --- /dev/null +++ b/src/a7124f78-21c5-400e-984d-4c5463cb2315/code.power @@ -0,0 +1,525 @@ + /** + * The Config Class. + * + * @var Config + * @since 5.0.2 + */ + protected Config $config; + + /** + * The Language Class. + * + * @var Language + * @since 5.0.2 + */ + protected Language $language; + + /** + * The Set Class. + * + * @var Set + * @since 5.0.2 + */ + protected Set $set; + + /** + * The Purge Class. + * + * @var Purge + * @since 5.0.2 + */ + protected Purge $purge; + + /** + * The Translation Class. + * + * @var Translation + * @since 5.0.2 + */ + protected Translation $translation; + + /** + * The Multilingual Class. + * + * @var Multilingual + * @since 5.0.2 + */ + protected Multilingual $multilingual; + + /** + * The EventInterface Class. + * + * @var Event + * @since 5.0.2 + */ + protected Event $event; + + /** + * The FieldsetExtension Class. + * + * @var FieldsetExtension + * @since 5.0.2 + */ + protected FieldsetExtension $fieldsetextension; + + /** + * The ContentOne Class. + * + * @var ContentOne + * @since 5.0.2 + */ + protected ContentOne $contentone; + + /** + * The Languages Class. + * + * @var Languages + * @since 5.0.2 + */ + protected Languages $languages; + + /** + * The Multilingual Class. + * + * @var BuilderMultilingual + * @since 5.0.2 + */ + protected BuilderMultilingual $buildermultilingual; + + /** + * The Counter Class. + * + * @var Counter + * @since 5.0.2 + */ + protected Counter $counter; + + /** + * The File Class. + * + * @var File + * @since 5.0.2 + */ + protected File $file; + + /** + * Constructor. + * + * @param Config $config The Config Class. + * @param Language $language The Language Class. + * @param Set $set The Set Class. + * @param Purge $purge The Purge Class. + * @param Translation $translation The Translation Class. + * @param Multilingual $multilingual The Multilingual Class. + * @param Event $event The EventInterface Class. + * @param FieldsetExtension $fieldsetextension The FieldsetExtension Class. + * @param ContentOne $contentone The ContentOne Class. + * @param Languages $languages The Languages Class. + * @param BuilderMultilingual $buildermultilingual The Multilingual Class. + * @param Counter $counter The Counter Class. + * @param File $file The File Class. + * + * @since 5.0.2 + */ + public function __construct(Config $config, Language $language, Set $set, Purge $purge, + Translation $translation, Multilingual $multilingual, + Event $event, FieldsetExtension $fieldsetextension, + ContentOne $contentone, Languages $languages, + BuilderMultilingual $buildermultilingual, + Counter $counter, File $file) + { + $this->config = $config; + $this->language = $language; + $this->set = $set; + $this->purge = $purge; + $this->translation = $translation; + $this->multilingual = $multilingual; + $this->event = $event; + $this->fieldsetextension = $fieldsetextension; + $this->contentone = $contentone; + $this->languages = $languages; + $this->buildermultilingual = $buildermultilingual; + $this->counter = $counter; + $this->file = $file; + } + + /** + * Generates the main XML for the plugin. + * + * @param object $plugin The plugin object. + * + * @return string The generated XML. + * @since 5.0.2 + */ + public function get(object $plugin): string + { + $config_fields = $this->buildConfigFields($plugin); + $add_component_path = $this->shouldAddComponentPath($plugin); + $language_files = $this->generateLanguageFiles($plugin); + + $xml = $this->generateScriptAndSqlXml($plugin); + $xml .= $this->generateLanguageXml($plugin, $language_files); + $xml .= $this->generateFileXml($plugin, $language_files); + $xml .= $this->generateConfigXml($plugin, $config_fields, $add_component_path); + $xml .= $this->generateUpdateServerXml($plugin); + + return $xml; + } + + /** + * Build configuration fields XML. + * + * @param object $plugin The plugin object. + * + * @return array The configuration fields. + * @since 5.0.2 + */ + protected function buildConfigFields(object $plugin): array + { + $configFields = []; + if (!isset($plugin->config_fields) || !ArrayHelper::check($plugin->config_fields)) + { + return $configFields; + } + + $dbKey = 'yy'; + + foreach ($plugin->config_fields as $fieldName => $fieldsets) + { + foreach ($fieldsets as $fieldset => $fields) + { + $xmlFields = $this->fieldsetextension->get($plugin, $fields, $dbKey); + if (isset($xmlFields) && StringHelper::check($xmlFields)) + { + $configFields["{$fieldName}{$fieldset}"] = $xmlFields; + } + $dbKey++; + } + } + + return $configFields; + } + + /** + * Determine if the component path should be added. + * + * @param object $plugin The plugin object. + * + * @return bool True if the component path should be added, false otherwise. + * @since 5.0.2 + */ + protected function shouldAddComponentPath(object $plugin): bool + { + if (!isset($plugin->config_fields) || !ArrayHelper::check($plugin->config_fields) || + !isset($plugin->fieldsets_paths) || !ArrayHelper::check($plugin->fieldsets_paths)) + { + return false; + } + + foreach ($plugin->config_fields as $fieldName => $fieldsets) + { + foreach ($fieldsets as $fieldset => $fields) + { + if (isset($plugin->fieldsets_paths["{$fieldName}{$fieldset}"]) && + $plugin->fieldsets_paths["{$fieldName}{$fieldset}"] == 1) + { + return true; + } + } + } + + return false; + } + + /** + * Generate XML for script and SQL files. + * + * @param object $plugin The plugin object. + * + * @return string The XML for script and SQL files. + * @since 5.0.2 + */ + protected function generateScriptAndSqlXml(object $plugin): string + { + $xml = ''; + + if ($plugin->add_install_script) + { + $xml .= PHP_EOL . PHP_EOL . Indent::_(1) . ''; + $xml .= PHP_EOL . Indent::_(1) . 'script.php'; + } + + if ($plugin->add_sql) + { + $xml .= PHP_EOL . PHP_EOL . Indent::_(1) . ''; + $xml .= PHP_EOL . Indent::_(1) . ''; + $xml .= PHP_EOL . Indent::_(2) . ''; + $xml .= PHP_EOL . Indent::_(3) . 'sql/mysql/install.sql'; + $xml .= PHP_EOL . Indent::_(2) . ''; + $xml .= PHP_EOL . Indent::_(1) . ''; + } + + if ($plugin->add_sql_uninstall) + { + $xml .= PHP_EOL . PHP_EOL . Indent::_(1) . ''; + $xml .= PHP_EOL . Indent::_(1) . ''; + $xml .= PHP_EOL . Indent::_(2) . ''; + $xml .= PHP_EOL . Indent::_(3) . 'sql/mysql/uninstall.sql'; + $xml .= PHP_EOL . Indent::_(2) . ''; + $xml .= PHP_EOL . Indent::_(1) . ''; + } + + return $xml; + } + + /** + * Generate XML for language files. + * + * @param object $plugin The plugin object. + * @param array $languageFiles The language files. + * + * @return string The XML for language files. + * @since 5.0.2 + */ + protected function generateLanguageXml(object $plugin, array $languageFiles): string + { + $xml = ''; + + if (ArrayHelper::check($languageFiles)) + { + $xml .= PHP_EOL . PHP_EOL . Indent::_(1) . ''; + $xml .= PHP_EOL . Indent::_(1) . ''; + + foreach ($languageFiles as $addTag) + { + $xml .= PHP_EOL . Indent::_(2) . '' . $addTag . '/plg_' + . strtolower((string) $plugin->group) . '_' . + (string) $plugin->file_name + . '.ini'; + $xml .= PHP_EOL . Indent::_(2) . '' . $addTag . '/plg_' + . strtolower((string) $plugin->group) . '_' . + (string) $plugin->file_name + . '.sys.ini'; + } + $xml .= PHP_EOL . Indent::_(1) . ''; + } + + return $xml; + } + + /** + * Generate the XML for the files. + * + * @param object $plugin The plugin object. + * @param array $languageFiles The language files. + * + * @return string The XML for the files. + * @since 5.0.2 + */ + protected function generateFileXml(object $plugin, array $languageFiles): string + { + $files = Folder::files($plugin->folder_path); + $folders = Folder::folders($plugin->folder_path); + $ignore = ['sql', 'language', 'script.php', "{$plugin->file_name}.xml"]; + + $xml = PHP_EOL . PHP_EOL . Indent::_(1) . ''; + $xml .= PHP_EOL . Indent::_(1) . ''; + $xml .= PHP_EOL . Indent::_(2) . "context_name}\">services"; + + foreach ($files as $file) + { + if (!in_array($file, $ignore)) + { + $xml .= PHP_EOL . Indent::_(2) . "{$file}"; + } + } + + if (!empty($languageFiles)) + { + // $xml .= PHP_EOL . Indent::_(2) . 'language'; + } + + if ($plugin->add_sql || $plugin->add_sql_uninstall) + { + $xml .= PHP_EOL . Indent::_(2) . 'sql'; + } + + foreach ($folders as $folder) + { + if (!in_array($folder, $ignore)) + { + $xml .= PHP_EOL . Indent::_(2) . "{$folder}"; + } + } + + $xml .= PHP_EOL . Indent::_(1) . ''; + + return $xml; + } + + /** + * Generate XML for configuration fields. + * + * @param object $plugin The plugin object. + * @param array $configFields The configuration fields. + * @param bool $addComponentPath Whether to add the component path. + * + * @return string The XML for configuration fields. + * @since 5.0.2 + */ + protected function generateConfigXml(object $plugin, array $configFields, bool $addComponentPath): string + { + if (!isset($plugin->config_fields) || !ArrayHelper::check($configFields)) + { + return ''; + } + + $xml = PHP_EOL . PHP_EOL . Indent::_(1) . ''; + $xml .= $addComponentPath ? PHP_EOL . Indent::_(1) . ''; + + if ($addComponentPath) + { + $xml .= PHP_EOL . Indent::_(3) . 'addruleprefix="' . $this->config->namespace_prefix . '\Component\\' . $this->contentone->get('ComponentNamespace') . '\Administrator\Rule"'; + $xml .= PHP_EOL . Indent::_(3) . 'addfieldprefix="' . $this->config->namespace_prefix . '\Component\\' . $this->contentone->get('ComponentNamespace') . '\Administrator\Field">'; + $xml .= PHP_EOL . Indent::_(1) . '>'; + } + + foreach ($plugin->config_fields as $fieldName => $fieldsets) + { + $xml .= PHP_EOL . Indent::_(1) . ""; + + foreach ($fieldsets as $fieldset => $fields) + { + $label = $plugin->fieldsets_label["{$fieldName}{$fieldset}"] ?? $fieldset; + + $xml .= PHP_EOL . Indent::_(1) . "
"; + + if (isset($configFields["{$fieldName}{$fieldset}"])) + { + $xml .= $configFields["{$fieldName}{$fieldset}"]; + } + + $xml .= PHP_EOL . Indent::_(1) . '
'; + } + + $xml .= PHP_EOL . Indent::_(1) . '
'; + } + + $xml .= PHP_EOL . Indent::_(1) . ''; + + return $xml; + } + + /** + * Generate XML for update servers. + * + * @param object $plugin The plugin object. + * + * @return string The XML for update servers. + * @since 5.0.2 + */ + protected function generateUpdateServerXml(object $plugin): string + { + $xml = ''; + + if ($plugin->add_update_server) + { + $xml = PHP_EOL . PHP_EOL . Indent::_(1) . ''; + $xml .= PHP_EOL . Indent::_(1) . ''; + $xml .= PHP_EOL . Indent::_(2) . '' . $plugin->update_server_url . ''; + $xml .= PHP_EOL . Indent::_(1) . ''; + } + + return $xml; + } + + /** + * Generate language files. + * + * @param object $plugin The plugin object. + * + * @return array The language files. + * @since 5.0.2 + */ + protected function generateLanguageFiles(object $plugin): array + { + $languageFiles = []; + + if (!$this->language->exist($plugin->key)) + { + return $languageFiles; + } + + $langContent = $this->language->getTarget($plugin->key); + $this->event->trigger('jcb_ce_onBeforeBuildPluginLang', [&$plugin, &$langContent]); + + $values = array_unique($langContent); + $this->buildermultilingual->set('plugins', $this->multilingual->get($values)); + + $langTag = $this->config->get('lang_tag', 'en-GB'); + $this->languages->set("plugins.{$langTag}.all", $langContent); + $this->language->setTarget($plugin->key, null); + + $this->set->execute($values, $plugin->id, 'plugins'); + $this->purge->execute($values, $plugin->id, 'plugins'); + + $this->event->trigger('jcb_ce_onBeforeBuildPluginLangFiles', [&$plugin]); + + if ($this->languages->IsArray('plugins')) + { + foreach ($this->languages->get('plugins') as $tag => $areas) + { + $tag = trim($tag); + foreach ($areas as $area => $languageStrings) + { + $fileName = "plg_" . strtolower((string)$plugin->group) . '_' . $plugin->file_name . '.ini'; + $total = count($values); + if ($this->translation->check($tag, $languageStrings, $total, $fileName)) + { + $lang = array_map( + fn($langString, $placeholder) => "{$placeholder}=\"{$langString}\"", + array_values($languageStrings), + array_keys($languageStrings) + ); + + $path = "{$plugin->folder_path}/language/{$tag}/"; + + if (!Folder::exists($path)) + { + Folder::create($path); + $this->counter->folder++; + } + + $this->file->write($path . $fileName, implode(PHP_EOL, $lang)); + $this->file->write( + $path . 'plg_' . strtolower((string)$plugin->group) . '_' . $plugin->file_name . '.sys.ini', + implode(PHP_EOL, $lang) + ); + + $this->counter->line += count($lang); + unset($lang); + + $languageFiles[$tag] = $tag; + } + } + } + } + + return $languageFiles; + } \ No newline at end of file diff --git a/src/a7124f78-21c5-400e-984d-4c5463cb2315/settings.json b/src/a7124f78-21c5-400e-984d-4c5463cb2315/settings.json new file mode 100644 index 0000000..7404093 --- /dev/null +++ b/src/a7124f78-21c5-400e-984d-4c5463cb2315/settings.json @@ -0,0 +1,90 @@ +{ + "add_head": "1", + "add_licensing_template": "2", + "extends": "", + "guid": "a7124f78-21c5-400e-984d-4c5463cb2315", + "implements": [ + "97177ca9-a51a-4d24-81e1-8747b6e7d76c" + ], + "load_selection": null, + "name": "MainXML", + "power_version": "1.0.0", + "system_name": "JCB.Architecture.J5.Plugin.MainXML", + "type": "final class", + "use_selection": { + "use_selection0": { + "use": "fa4bf18e-301e-42e3-91fb-6e0096c07adc", + "as": "default" + }, + "use_selection1": { + "use": "8eee7df5-2775-41a9-9372-c46c5939a252", + "as": "default" + }, + "use_selection2": { + "use": "058cfcd7-1f84-4cc6-8bcc-7672f316881d", + "as": "default" + }, + "use_selection3": { + "use": "0b0e574c-aab4-4eaf-96d8-d7210d8ed93e", + "as": "default" + }, + "use_selection4": { + "use": "344d36be-3949-4848-8cb0-e3d3d9d05c36", + "as": "default" + }, + "use_selection5": { + "use": "263f0227-3cc2-4a88-9818-edb20081c30c", + "as": "default" + }, + "use_selection6": { + "use": "20ed72b0-fcac-4344-aee1-8a65e3bf221d", + "as": "Event" + }, + "use_selection7": { + "use": "23f459a4-7c2a-4cbf-b0a6-8a11954140a9", + "as": "default" + }, + "use_selection8": { + "use": "adfbe68a-6d22-43e5-aee8-2787e8c47e75", + "as": "default" + }, + "use_selection9": { + "use": "7526a39a-ada3-4499-8d75-81beff33f949", + "as": "default" + }, + "use_selection10": { + "use": "a8c6158a-6fd2-476b-a5ea-c81f1ecd2356", + "as": "BuilderMultilingual" + }, + "use_selection11": { + "use": "e6d871a6-bbe7-497d-af01-68f6bb9a87f4", + "as": "default" + }, + "use_selection12": { + "use": "5c75b455-3d4c-452a-867e-e90424a64c88", + "as": "default" + }, + "use_selection13": { + "use": "4e6ff11d-bebf-42f5-8fd7-b2f882857222", + "as": "default" + }, + "use_selection14": { + "use": "a68c010b-e92e-47d5-8a44-d23cfddeb6c6", + "as": "default" + }, + "use_selection15": { + "use": "0a59c65c-9daf-4bc9-baf4-e063ff9e6a8a", + "as": "default" + }, + "use_selection16": { + "use": "1f28cb53-60d9-4db1-b517-3c7dc6b429ef", + "as": "default" + } + }, + "extendsinterfaces": null, + "namespace": "[[[NamespacePrefix]]]\\Joomla\\[[[ComponentNamespace]]].Compiler.Architecture.JoomlaFive.Plugin.MainXML", + "description": "Joomla 5 Plugin Main XML Class\r\n\r\n@since 5.0.2", + "licensing_template": "\/**\r\n * @package Joomla.Component.Builder\r\n *\r\n * @created 4th September, 2022\r\n * @author Llewellyn van der Merwe \r\n * @git Joomla Component Builder \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\\Filesystem\\Folder;", + "composer": "" +} \ No newline at end of file diff --git a/src/a8c6158a-6fd2-476b-a5ea-c81f1ecd2356/README.md b/src/a8c6158a-6fd2-476b-a5ea-c81f1ecd2356/README.md new file mode 100644 index 0000000..dc11808 --- /dev/null +++ b/src/a8c6158a-6fd2-476b-a5ea-c81f1ecd2356/README.md @@ -0,0 +1,45 @@ +``` +██████╗ ██████╗ ██╗ ██╗███████╗██████╗ +██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗ +██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝ +██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗ +██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║ +╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝ +``` +# final class Multilingual (Details) +> namespace: **VDM\Joomla\Componentbuilder\Compiler\Builder** +> extends: **Registry** + +```uml +@startuml +class Multilingual << (F,LightGreen) >> #RoyalBlue { +} + +@enduml +``` + +The Power feature in JCB allows you to write PHP classes and their implementations, making it easy to include them in your Joomla project. JCB handles linking, autoloading, namespacing, and folder structure creation for you. + +By using the SPK (Super Power Key) in your custom code (replacing the class name in your code with the SPK), JCB will automatically pull the power from the repository into your project. This makes it available in your JCB instance, allowing you to edit it and include the class in your generated Joomla component. + +JCB uses placeholders like [[[`NamespacePrefix`]]] and [[[`ComponentNamespace`]]] in namespacing to prevent collisions and improve reusability across different JCB systems. You can also set the **JCB powers path** globally or per component under the **Dynamic Integration** tab, providing flexibility and easy maintainability. + +To add this specific Power to your project in JCB: + +> simply use this SPK +``` +Super---a8c6158a_6fd2_476b_a5ea_c81f1ecd2356---Power +``` +> remember to replace the `---` with `___` to activate this Power in your code + +--- +``` + ██╗ ██████╗██████╗ + ██║██╔════╝██╔══██╗ + ██║██║ ██████╔╝ +██ ██║██║ ██╔══██╗ +╚█████╔╝╚██████╗██████╔╝ + ╚════╝ ╚═════╝╚═════╝ +``` +> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder) + diff --git a/src/a8c6158a-6fd2-476b-a5ea-c81f1ecd2356/code.php b/src/a8c6158a-6fd2-476b-a5ea-c81f1ecd2356/code.php new file mode 100644 index 0000000..8fc4abd --- /dev/null +++ b/src/a8c6158a-6fd2-476b-a5ea-c81f1ecd2356/code.php @@ -0,0 +1,34 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Componentbuilder\Compiler\Builder; + + +use VDM\Joomla\Abstraction\Registry\Traits\IsArray; +use VDM\Joomla\Interfaces\Registryinterface; +use VDM\Joomla\Abstraction\Registry; + + +/** + * Multilingual Builder Class + * + * @since 5.0.2 + */ +final class Multilingual extends Registry implements Registryinterface +{ + /** + * Is an Array + * + * @since 5.0.2 + */ + use IsArray; +} + diff --git a/src/a8c6158a-6fd2-476b-a5ea-c81f1ecd2356/code.power b/src/a8c6158a-6fd2-476b-a5ea-c81f1ecd2356/code.power new file mode 100644 index 0000000..983a363 --- /dev/null +++ b/src/a8c6158a-6fd2-476b-a5ea-c81f1ecd2356/code.power @@ -0,0 +1,6 @@ + /** + * Is an Array + * + * @since 5.0.2 + */ + use IsArray; \ No newline at end of file diff --git a/src/a8c6158a-6fd2-476b-a5ea-c81f1ecd2356/settings.json b/src/a8c6158a-6fd2-476b-a5ea-c81f1ecd2356/settings.json new file mode 100644 index 0000000..2965095 --- /dev/null +++ b/src/a8c6158a-6fd2-476b-a5ea-c81f1ecd2356/settings.json @@ -0,0 +1,26 @@ +{ + "add_head": "0", + "add_licensing_template": "2", + "extends": "7e822c03-1b20-41d1-9427-f5b8d5836af7", + "guid": "a8c6158a-6fd2-476b-a5ea-c81f1ecd2356", + "implements": [ + "64e291c2-11f1-423d-a44d-837cc12cc017" + ], + "load_selection": null, + "name": "Multilingual", + "power_version": "1.0.0", + "system_name": "JCB.Compiler.Builder.Multilingual", + "type": "final class", + "use_selection": { + "use_selection0": { + "use": "c09e8968-c767-4175-bb3d-8432f206a2c7", + "as": "default" + } + }, + "extendsinterfaces": null, + "namespace": "[[[NamespacePrefix]]]\\Joomla\\[[[ComponentNamespace]]].Compiler.Builder.Multilingual", + "description": "Multilingual Builder Class\r\n\r\n@since 5.0.2", + "licensing_template": "\/**\r\n * @package Joomla.Component.Builder\r\n *\r\n * @created 4th September, 2022\r\n * @author Llewellyn van der Merwe \r\n * @git Joomla Component Builder \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/a900b836-f2eb-4f13-8f28-b7cac839c7ff/README.md b/src/a900b836-f2eb-4f13-8f28-b7cac839c7ff/README.md index 63b6e58..1275b12 100644 --- a/src/a900b836-f2eb-4f13-8f28-b7cac839c7ff/README.md +++ b/src/a900b836-f2eb-4f13-8f28-b7cac839c7ff/README.md @@ -7,7 +7,7 @@ ╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝ ``` # class Structure (Details) -> namespace: **VDM\Joomla\Componentbuilder\Compiler\Joomlaplugin** +> namespace: **VDM\Joomla\Componentbuilder\Compiler\Joomlaplugin\JoomlaThree** ```uml @startuml diff --git a/src/a900b836-f2eb-4f13-8f28-b7cac839c7ff/code.php b/src/a900b836-f2eb-4f13-8f28-b7cac839c7ff/code.php index 99e2bde..b4c0f13 100644 --- a/src/a900b836-f2eb-4f13-8f28-b7cac839c7ff/code.php +++ b/src/a900b836-f2eb-4f13-8f28-b7cac839c7ff/code.php @@ -9,10 +9,10 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ -namespace VDM\Joomla\Componentbuilder\Compiler\Joomlaplugin; +namespace VDM\Joomla\Componentbuilder\Compiler\Joomlaplugin\JoomlaThree; -use VDM\Joomla\Componentbuilder\Compiler\Joomlaplugin\Data as Plugin; +use VDM\Joomla\Componentbuilder\Compiler\Interfaces\PluginDataInterface as Plugin; use VDM\Joomla\Componentbuilder\Compiler\Component; use VDM\Joomla\Componentbuilder\Compiler\Config; use VDM\Joomla\Componentbuilder\Compiler\Registry; @@ -29,14 +29,15 @@ use VDM\Joomla\Utilities\ArrayHelper; use VDM\Joomla\Utilities\ObjectHelper; use VDM\Joomla\Utilities\StringHelper; use VDM\Joomla\Utilities\FileHelper; +use VDM\Joomla\Componentbuilder\Interfaces\Plugin\StructureInterface; /** - * Joomla Plugin Builder Class + * Joomla 3 Plugin Builder Class * * @since 3.2.0 */ -class Structure +class Structure implements StructureInterface { /** * The Data Class. @@ -306,9 +307,9 @@ class Structure 'files->appendArray($plugin->key, $file_details); @@ -368,7 +369,7 @@ class Structure PHP_EOL . Placefix::_h('BOM') . PHP_EOL . PHP_EOL . '// No direct access to this file' . PHP_EOL . "defined('_JEXEC') or die('Restricted access');" . PHP_EOL . - Placefix::_h('INSTALLCLASS') + Placefix::_h('INSTALL_CLASS') ); $this->files->appendArray($plugin->key, $file_details); diff --git a/src/a900b836-f2eb-4f13-8f28-b7cac839c7ff/code.power b/src/a900b836-f2eb-4f13-8f28-b7cac839c7ff/code.power index 4dad4eb..c959573 100644 --- a/src/a900b836-f2eb-4f13-8f28-b7cac839c7ff/code.power +++ b/src/a900b836-f2eb-4f13-8f28-b7cac839c7ff/code.power @@ -266,9 +266,9 @@ 'files->appendArray($plugin->key, $file_details); @@ -328,7 +328,7 @@ PHP_EOL . Placefix::_h('BOM') . PHP_EOL . PHP_EOL . '// No direct access to this file' . PHP_EOL . "defined('_JEXEC') or die('Restricted access');" . PHP_EOL . - Placefix::_h('INSTALLCLASS') + Placefix::_h('INSTALL_CLASS') ); $this->files->appendArray($plugin->key, $file_details); diff --git a/src/a900b836-f2eb-4f13-8f28-b7cac839c7ff/settings.json b/src/a900b836-f2eb-4f13-8f28-b7cac839c7ff/settings.json index ae4df71..86aef0c 100644 --- a/src/a900b836-f2eb-4f13-8f28-b7cac839c7ff/settings.json +++ b/src/a900b836-f2eb-4f13-8f28-b7cac839c7ff/settings.json @@ -3,15 +3,17 @@ "add_licensing_template": "2", "extends": "", "guid": "a900b836-f2eb-4f13-8f28-b7cac839c7ff", - "implements": null, + "implements": [ + "ef66b17c-ffae-414a-9067-20a63ba2bec5" + ], "load_selection": null, "name": "Structure", "power_version": "1.0.0", - "system_name": "JCB.Compiler.Joomlaplugin.Structure", + "system_name": "JCB.Compiler.Joomlaplugin.J3.Structure", "type": "class", "use_selection": { "use_selection0": { - "use": "766a9524-37df-4604-91a7-b98a6150ee26", + "use": "8cc85656-a925-4a46-a49b-83c72167fd6a", "as": "Plugin" }, "use_selection1": { @@ -80,8 +82,8 @@ } }, "extendsinterfaces": null, - "namespace": "[[[NamespacePrefix]]]\\Joomla\\[[[ComponentNamespace]]].Compiler.Joomlaplugin.Structure", - "description": "Joomla Plugin Builder Class\r\n\r\n@since 3.2.0", + "namespace": "[[[NamespacePrefix]]]\\Joomla\\[[[ComponentNamespace]]].Compiler.Joomlaplugin.JoomlaThree.Structure", + "description": "Joomla 3 Plugin Builder Class\r\n\r\n@since 3.2.0", "licensing_template": "\/**\r\n * @package Joomla.Component.Builder\r\n *\r\n * @created 4th September, 2022\r\n * @author Llewellyn van der Merwe \r\n * @git Joomla Component Builder \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": "" diff --git a/src/af6d0e6a-61d2-4250-9e2f-bed5591e2786/README.md b/src/af6d0e6a-61d2-4250-9e2f-bed5591e2786/README.md new file mode 100644 index 0000000..dfce073 --- /dev/null +++ b/src/af6d0e6a-61d2-4250-9e2f-bed5591e2786/README.md @@ -0,0 +1,156 @@ +``` +██████╗ ██████╗ ██╗ ██╗███████╗██████╗ +██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗ +██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝ +██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗ +██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║ +╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝ +``` +# final class MainXML (Details) +> namespace: **VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaFour\Plugin** + +```uml +@startuml +class MainXML << (F,LightGreen) >> #RoyalBlue { + # Config $config + # Language $language + # Set $set + # Purge $purge + # Translation $translation + # Multilingual $multilingual + # Event $event + # FieldsetExtension $fieldsetextension + # ContentOne $contentone + # Languages $languages + # BuilderMultilingual $buildermultilingual + # Counter $counter + # File $file + + __construct(Config $config, Language $language, ...) + + get(object $plugin) : string + # buildConfigFields(object $plugin) : array + # shouldAddComponentPath(object $plugin) : bool + # generateScriptAndSqlXml(object $plugin) : string + # generateLanguageXml(object $plugin, array $languageFiles) : string + # generateFileXml(object $plugin, array $languageFiles) : string + # generateConfigXml(object $plugin, array $configFields, ...) : string + # generateUpdateServerXml(object $plugin) : string + # generateLanguageFiles(object $plugin) : array +} + +note right of MainXML::__construct + Constructor. + + since: 5.0.2 + + arguments: + Config $config + Language $language + Set $set + Purge $purge + Translation $translation + Multilingual $multilingual + Event $event + FieldsetExtension $fieldsetextension + ContentOne $contentone + Languages $languages + BuilderMultilingual $buildermultilingual + Counter $counter + File $file +end note + +note left of MainXML::get + Generates the main XML for the plugin. + + since: 5.0.2 + return: string +end note + +note right of MainXML::buildConfigFields + Build configuration fields XML. + + since: 5.0.2 + return: array +end note + +note left of MainXML::shouldAddComponentPath + Determine if the component path should be added. + + since: 5.0.2 + return: bool +end note + +note right of MainXML::generateScriptAndSqlXml + Generate XML for script and SQL files. + + since: 5.0.2 + return: string +end note + +note left of MainXML::generateLanguageXml + Generate XML for language files. + + since: 5.0.2 + return: string +end note + +note right of MainXML::generateFileXml + Generate the XML for the files. + + since: 5.0.2 + return: string +end note + +note left of MainXML::generateConfigXml + Generate XML for configuration fields. + + since: 5.0.2 + return: string + + arguments: + object $plugin + array $configFields + bool $addComponentPath +end note + +note right of MainXML::generateUpdateServerXml + Generate XML for update servers. + + since: 5.0.2 + return: string +end note + +note left of MainXML::generateLanguageFiles + Generate language files. + + since: 5.0.2 + return: array +end note + +@enduml +``` + +The Power feature in JCB allows you to write PHP classes and their implementations, making it easy to include them in your Joomla project. JCB handles linking, autoloading, namespacing, and folder structure creation for you. + +By using the SPK (Super Power Key) in your custom code (replacing the class name in your code with the SPK), JCB will automatically pull the power from the repository into your project. This makes it available in your JCB instance, allowing you to edit it and include the class in your generated Joomla component. + +JCB uses placeholders like [[[`NamespacePrefix`]]] and [[[`ComponentNamespace`]]] in namespacing to prevent collisions and improve reusability across different JCB systems. You can also set the **JCB powers path** globally or per component under the **Dynamic Integration** tab, providing flexibility and easy maintainability. + +To add this specific Power to your project in JCB: + +> simply use this SPK +``` +Super---af6d0e6a_61d2_4250_9e2f_bed5591e2786---Power +``` +> remember to replace the `---` with `___` to activate this Power in your code + +--- +``` + ██╗ ██████╗██████╗ + ██║██╔════╝██╔══██╗ + ██║██║ ██████╔╝ +██ ██║██║ ██╔══██╗ +╚█████╔╝╚██████╗██████╔╝ + ╚════╝ ╚═════╝╚═════╝ +``` +> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder) + diff --git a/src/af6d0e6a-61d2-4250-9e2f-bed5591e2786/code.php b/src/af6d0e6a-61d2-4250-9e2f-bed5591e2786/code.php new file mode 100644 index 0000000..9212ac8 --- /dev/null +++ b/src/af6d0e6a-61d2-4250-9e2f-bed5591e2786/code.php @@ -0,0 +1,569 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaFour\Plugin; + + +use Joomla\CMS\Filesystem\Folder; +use VDM\Joomla\Componentbuilder\Compiler\Config; +use VDM\Joomla\Componentbuilder\Compiler\Language; +use VDM\Joomla\Componentbuilder\Compiler\Language\Set; +use VDM\Joomla\Componentbuilder\Compiler\Language\Purge; +use VDM\Joomla\Componentbuilder\Compiler\Language\Translation; +use VDM\Joomla\Componentbuilder\Compiler\Language\Multilingual; +use VDM\Joomla\Componentbuilder\Compiler\Interfaces\EventInterface as Event; +use VDM\Joomla\Componentbuilder\Compiler\Creator\FieldsetExtension; +use VDM\Joomla\Componentbuilder\Compiler\Builder\ContentOne; +use VDM\Joomla\Componentbuilder\Compiler\Builder\Languages; +use VDM\Joomla\Componentbuilder\Compiler\Builder\Multilingual as BuilderMultilingual; +use VDM\Joomla\Componentbuilder\Compiler\Utilities\Counter; +use VDM\Joomla\Componentbuilder\Compiler\Utilities\File; +use VDM\Joomla\Componentbuilder\Compiler\Utilities\Line; +use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent; +use VDM\Joomla\Utilities\ArrayHelper; +use VDM\Joomla\Utilities\StringHelper; +use VDM\Joomla\Componentbuilder\Interfaces\Architecture\Plugin\MainXMLInterface; + + +/** + * Joomla 4 Plugin Main XML Class + * + * @since 5.0.2 + */ +final class MainXML implements MainXMLInterface +{ + /** + * The Config Class. + * + * @var Config + * @since 5.0.2 + */ + protected Config $config; + + /** + * The Language Class. + * + * @var Language + * @since 5.0.2 + */ + protected Language $language; + + /** + * The Set Class. + * + * @var Set + * @since 5.0.2 + */ + protected Set $set; + + /** + * The Purge Class. + * + * @var Purge + * @since 5.0.2 + */ + protected Purge $purge; + + /** + * The Translation Class. + * + * @var Translation + * @since 5.0.2 + */ + protected Translation $translation; + + /** + * The Multilingual Class. + * + * @var Multilingual + * @since 5.0.2 + */ + protected Multilingual $multilingual; + + /** + * The EventInterface Class. + * + * @var Event + * @since 5.0.2 + */ + protected Event $event; + + /** + * The FieldsetExtension Class. + * + * @var FieldsetExtension + * @since 5.0.2 + */ + protected FieldsetExtension $fieldsetextension; + + /** + * The ContentOne Class. + * + * @var ContentOne + * @since 5.0.2 + */ + protected ContentOne $contentone; + + /** + * The Languages Class. + * + * @var Languages + * @since 5.0.2 + */ + protected Languages $languages; + + /** + * The Multilingual Class. + * + * @var BuilderMultilingual + * @since 5.0.2 + */ + protected BuilderMultilingual $buildermultilingual; + + /** + * The Counter Class. + * + * @var Counter + * @since 5.0.2 + */ + protected Counter $counter; + + /** + * The File Class. + * + * @var File + * @since 5.0.2 + */ + protected File $file; + + /** + * Constructor. + * + * @param Config $config The Config Class. + * @param Language $language The Language Class. + * @param Set $set The Set Class. + * @param Purge $purge The Purge Class. + * @param Translation $translation The Translation Class. + * @param Multilingual $multilingual The Multilingual Class. + * @param Event $event The EventInterface Class. + * @param FieldsetExtension $fieldsetextension The FieldsetExtension Class. + * @param ContentOne $contentone The ContentOne Class. + * @param Languages $languages The Languages Class. + * @param BuilderMultilingual $buildermultilingual The Multilingual Class. + * @param Counter $counter The Counter Class. + * @param File $file The File Class. + * + * @since 5.0.2 + */ + public function __construct(Config $config, Language $language, Set $set, Purge $purge, + Translation $translation, Multilingual $multilingual, + Event $event, FieldsetExtension $fieldsetextension, + ContentOne $contentone, Languages $languages, + BuilderMultilingual $buildermultilingual, + Counter $counter, File $file) + { + $this->config = $config; + $this->language = $language; + $this->set = $set; + $this->purge = $purge; + $this->translation = $translation; + $this->multilingual = $multilingual; + $this->event = $event; + $this->fieldsetextension = $fieldsetextension; + $this->contentone = $contentone; + $this->languages = $languages; + $this->buildermultilingual = $buildermultilingual; + $this->counter = $counter; + $this->file = $file; + } + + /** + * Generates the main XML for the plugin. + * + * @param object $plugin The plugin object. + * + * @return string The generated XML. + * @since 5.0.2 + */ + public function get(object $plugin): string + { + $config_fields = $this->buildConfigFields($plugin); + $add_component_path = $this->shouldAddComponentPath($plugin); + $language_files = $this->generateLanguageFiles($plugin); + + $xml = $this->generateScriptAndSqlXml($plugin); + $xml .= $this->generateLanguageXml($plugin, $language_files); + $xml .= $this->generateFileXml($plugin, $language_files); + $xml .= $this->generateConfigXml($plugin, $config_fields, $add_component_path); + $xml .= $this->generateUpdateServerXml($plugin); + + return $xml; + } + + /** + * Build configuration fields XML. + * + * @param object $plugin The plugin object. + * + * @return array The configuration fields. + * @since 5.0.2 + */ + protected function buildConfigFields(object $plugin): array + { + $configFields = []; + if (!isset($plugin->config_fields) || !ArrayHelper::check($plugin->config_fields)) + { + return $configFields; + } + + $dbKey = 'yy'; + + foreach ($plugin->config_fields as $fieldName => $fieldsets) + { + foreach ($fieldsets as $fieldset => $fields) + { + $xmlFields = $this->fieldsetextension->get($plugin, $fields, $dbKey); + if (isset($xmlFields) && StringHelper::check($xmlFields)) + { + $configFields["{$fieldName}{$fieldset}"] = $xmlFields; + } + $dbKey++; + } + } + + return $configFields; + } + + /** + * Determine if the component path should be added. + * + * @param object $plugin The plugin object. + * + * @return bool True if the component path should be added, false otherwise. + * @since 5.0.2 + */ + protected function shouldAddComponentPath(object $plugin): bool + { + if (!isset($plugin->config_fields) || !ArrayHelper::check($plugin->config_fields) || + !isset($plugin->fieldsets_paths) || !ArrayHelper::check($plugin->fieldsets_paths)) + { + return false; + } + + foreach ($plugin->config_fields as $fieldName => $fieldsets) + { + foreach ($fieldsets as $fieldset => $fields) + { + if (isset($plugin->fieldsets_paths["{$fieldName}{$fieldset}"]) && + $plugin->fieldsets_paths["{$fieldName}{$fieldset}"] == 1) + { + return true; + } + } + } + + return false; + } + + /** + * Generate XML for script and SQL files. + * + * @param object $plugin The plugin object. + * + * @return string The XML for script and SQL files. + * @since 5.0.2 + */ + protected function generateScriptAndSqlXml(object $plugin): string + { + $xml = ''; + + if ($plugin->add_install_script) + { + $xml .= PHP_EOL . PHP_EOL . Indent::_(1) . ''; + $xml .= PHP_EOL . Indent::_(1) . 'script.php'; + } + + if ($plugin->add_sql) + { + $xml .= PHP_EOL . PHP_EOL . Indent::_(1) . ''; + $xml .= PHP_EOL . Indent::_(1) . ''; + $xml .= PHP_EOL . Indent::_(2) . ''; + $xml .= PHP_EOL . Indent::_(3) . 'sql/mysql/install.sql'; + $xml .= PHP_EOL . Indent::_(2) . ''; + $xml .= PHP_EOL . Indent::_(1) . ''; + } + + if ($plugin->add_sql_uninstall) + { + $xml .= PHP_EOL . PHP_EOL . Indent::_(1) . ''; + $xml .= PHP_EOL . Indent::_(1) . ''; + $xml .= PHP_EOL . Indent::_(2) . ''; + $xml .= PHP_EOL . Indent::_(3) . 'sql/mysql/uninstall.sql'; + $xml .= PHP_EOL . Indent::_(2) . ''; + $xml .= PHP_EOL . Indent::_(1) . ''; + } + + return $xml; + } + + /** + * Generate XML for language files. + * + * @param object $plugin The plugin object. + * @param array $languageFiles The language files. + * + * @return string The XML for language files. + * @since 5.0.2 + */ + protected function generateLanguageXml(object $plugin, array $languageFiles): string + { + $xml = ''; + + if (ArrayHelper::check($languageFiles)) + { + $xml .= PHP_EOL . PHP_EOL . Indent::_(1) . ''; + $xml .= PHP_EOL . Indent::_(1) . ''; + + foreach ($languageFiles as $addTag) + { + $xml .= PHP_EOL . Indent::_(2) . '' . $addTag . '/plg_' + . strtolower((string) $plugin->group) . '_' . + (string) $plugin->file_name + . '.ini'; + $xml .= PHP_EOL . Indent::_(2) . '' . $addTag . '/plg_' + . strtolower((string) $plugin->group) . '_' . + (string) $plugin->file_name + . '.sys.ini'; + } + $xml .= PHP_EOL . Indent::_(1) . ''; + } + + return $xml; + } + + /** + * Generate the XML for the files. + * + * @param object $plugin The plugin object. + * @param array $languageFiles The language files. + * + * @return string The XML for the files. + * @since 5.0.2 + */ + protected function generateFileXml(object $plugin, array $languageFiles): string + { + $files = Folder::files($plugin->folder_path); + $folders = Folder::folders($plugin->folder_path); + $ignore = ['sql', 'language', 'script.php', "{$plugin->file_name}.xml"]; + + $xml = PHP_EOL . PHP_EOL . Indent::_(1) . ''; + $xml .= PHP_EOL . Indent::_(1) . ''; + $xml .= PHP_EOL . Indent::_(2) . "context_name}\">services"; + + foreach ($files as $file) + { + if (!in_array($file, $ignore)) + { + $xml .= PHP_EOL . Indent::_(2) . "{$file}"; + } + } + + if (!empty($languageFiles)) + { + // $xml .= PHP_EOL . Indent::_(2) . 'language'; + } + + if ($plugin->add_sql || $plugin->add_sql_uninstall) + { + $xml .= PHP_EOL . Indent::_(2) . 'sql'; + } + + foreach ($folders as $folder) + { + if (!in_array($folder, $ignore)) + { + $xml .= PHP_EOL . Indent::_(2) . "{$folder}"; + } + } + + $xml .= PHP_EOL . Indent::_(1) . ''; + + return $xml; + } + + /** + * Generate XML for configuration fields. + * + * @param object $plugin The plugin object. + * @param array $configFields The configuration fields. + * @param bool $addComponentPath Whether to add the component path. + * + * @return string The XML for configuration fields. + * @since 5.0.2 + */ + protected function generateConfigXml(object $plugin, array $configFields, bool $addComponentPath): string + { + if (!isset($plugin->config_fields) || !ArrayHelper::check($configFields)) + { + return ''; + } + + $xml = PHP_EOL . PHP_EOL . Indent::_(1) . ''; + $xml .= $addComponentPath ? PHP_EOL . Indent::_(1) . ''; + + if ($addComponentPath) + { + $xml .= PHP_EOL . Indent::_(3) . 'addruleprefix="' . $this->config->namespace_prefix . '\Component\\' . $this->contentone->get('ComponentNamespace') . '\Administrator\Rule"'; + $xml .= PHP_EOL . Indent::_(3) . 'addfieldprefix="' . $this->config->namespace_prefix . '\Component\\' . $this->contentone->get('ComponentNamespace') . '\Administrator\Field">'; + $xml .= PHP_EOL . Indent::_(1) . '>'; + } + + foreach ($plugin->config_fields as $fieldName => $fieldsets) + { + $xml .= PHP_EOL . Indent::_(1) . ""; + + foreach ($fieldsets as $fieldset => $fields) + { + $label = $plugin->fieldsets_label["{$fieldName}{$fieldset}"] ?? $fieldset; + + $xml .= PHP_EOL . Indent::_(1) . "
"; + + if (isset($configFields["{$fieldName}{$fieldset}"])) + { + $xml .= $configFields["{$fieldName}{$fieldset}"]; + } + + $xml .= PHP_EOL . Indent::_(1) . '
'; + } + + $xml .= PHP_EOL . Indent::_(1) . '
'; + } + + $xml .= PHP_EOL . Indent::_(1) . ''; + + return $xml; + } + + /** + * Generate XML for update servers. + * + * @param object $plugin The plugin object. + * + * @return string The XML for update servers. + * @since 5.0.2 + */ + protected function generateUpdateServerXml(object $plugin): string + { + $xml = ''; + + if ($plugin->add_update_server) + { + $xml = PHP_EOL . PHP_EOL . Indent::_(1) . ''; + $xml .= PHP_EOL . Indent::_(1) . ''; + $xml .= PHP_EOL . Indent::_(2) . '' . $plugin->update_server_url . ''; + $xml .= PHP_EOL . Indent::_(1) . ''; + } + + return $xml; + } + + /** + * Generate language files. + * + * @param object $plugin The plugin object. + * + * @return array The language files. + * @since 5.0.2 + */ + protected function generateLanguageFiles(object $plugin): array + { + $languageFiles = []; + + if (!$this->language->exist($plugin->key)) + { + return $languageFiles; + } + + $langContent = $this->language->getTarget($plugin->key); + $this->event->trigger('jcb_ce_onBeforeBuildPluginLang', [&$plugin, &$langContent]); + + $values = array_unique($langContent); + $this->buildermultilingual->set('plugins', $this->multilingual->get($values)); + + $langTag = $this->config->get('lang_tag', 'en-GB'); + $this->languages->set("plugins.{$langTag}.all", $langContent); + $this->language->setTarget($plugin->key, null); + + $this->set->execute($values, $plugin->id, 'plugins'); + $this->purge->execute($values, $plugin->id, 'plugins'); + + $this->event->trigger('jcb_ce_onBeforeBuildPluginLangFiles', [&$plugin]); + + if ($this->languages->IsArray('plugins')) + { + foreach ($this->languages->get('plugins') as $tag => $areas) + { + $tag = trim($tag); + foreach ($areas as $area => $languageStrings) + { + $fileName = "plg_" . strtolower((string)$plugin->group) . '_' . $plugin->file_name . '.ini'; + $total = count($values); + if ($this->translation->check($tag, $languageStrings, $total, $fileName)) + { + $lang = array_map( + fn($langString, $placeholder) => "{$placeholder}=\"{$langString}\"", + array_values($languageStrings), + array_keys($languageStrings) + ); + + $path = "{$plugin->folder_path}/language/{$tag}/"; + + if (!Folder::exists($path)) + { + Folder::create($path); + $this->counter->folder++; + } + + $this->file->write($path . $fileName, implode(PHP_EOL, $lang)); + $this->file->write( + $path . 'plg_' . strtolower((string)$plugin->group) . '_' . $plugin->file_name . '.sys.ini', + implode(PHP_EOL, $lang) + ); + + $this->counter->line += count($lang); + unset($lang); + + $languageFiles[$tag] = $tag; + } + } + } + } + + return $languageFiles; + } +} + diff --git a/src/af6d0e6a-61d2-4250-9e2f-bed5591e2786/code.power b/src/af6d0e6a-61d2-4250-9e2f-bed5591e2786/code.power new file mode 100644 index 0000000..e54f639 --- /dev/null +++ b/src/af6d0e6a-61d2-4250-9e2f-bed5591e2786/code.power @@ -0,0 +1,525 @@ + /** + * The Config Class. + * + * @var Config + * @since 5.0.2 + */ + protected Config $config; + + /** + * The Language Class. + * + * @var Language + * @since 5.0.2 + */ + protected Language $language; + + /** + * The Set Class. + * + * @var Set + * @since 5.0.2 + */ + protected Set $set; + + /** + * The Purge Class. + * + * @var Purge + * @since 5.0.2 + */ + protected Purge $purge; + + /** + * The Translation Class. + * + * @var Translation + * @since 5.0.2 + */ + protected Translation $translation; + + /** + * The Multilingual Class. + * + * @var Multilingual + * @since 5.0.2 + */ + protected Multilingual $multilingual; + + /** + * The EventInterface Class. + * + * @var Event + * @since 5.0.2 + */ + protected Event $event; + + /** + * The FieldsetExtension Class. + * + * @var FieldsetExtension + * @since 5.0.2 + */ + protected FieldsetExtension $fieldsetextension; + + /** + * The ContentOne Class. + * + * @var ContentOne + * @since 5.0.2 + */ + protected ContentOne $contentone; + + /** + * The Languages Class. + * + * @var Languages + * @since 5.0.2 + */ + protected Languages $languages; + + /** + * The Multilingual Class. + * + * @var BuilderMultilingual + * @since 5.0.2 + */ + protected BuilderMultilingual $buildermultilingual; + + /** + * The Counter Class. + * + * @var Counter + * @since 5.0.2 + */ + protected Counter $counter; + + /** + * The File Class. + * + * @var File + * @since 5.0.2 + */ + protected File $file; + + /** + * Constructor. + * + * @param Config $config The Config Class. + * @param Language $language The Language Class. + * @param Set $set The Set Class. + * @param Purge $purge The Purge Class. + * @param Translation $translation The Translation Class. + * @param Multilingual $multilingual The Multilingual Class. + * @param Event $event The EventInterface Class. + * @param FieldsetExtension $fieldsetextension The FieldsetExtension Class. + * @param ContentOne $contentone The ContentOne Class. + * @param Languages $languages The Languages Class. + * @param BuilderMultilingual $buildermultilingual The Multilingual Class. + * @param Counter $counter The Counter Class. + * @param File $file The File Class. + * + * @since 5.0.2 + */ + public function __construct(Config $config, Language $language, Set $set, Purge $purge, + Translation $translation, Multilingual $multilingual, + Event $event, FieldsetExtension $fieldsetextension, + ContentOne $contentone, Languages $languages, + BuilderMultilingual $buildermultilingual, + Counter $counter, File $file) + { + $this->config = $config; + $this->language = $language; + $this->set = $set; + $this->purge = $purge; + $this->translation = $translation; + $this->multilingual = $multilingual; + $this->event = $event; + $this->fieldsetextension = $fieldsetextension; + $this->contentone = $contentone; + $this->languages = $languages; + $this->buildermultilingual = $buildermultilingual; + $this->counter = $counter; + $this->file = $file; + } + + /** + * Generates the main XML for the plugin. + * + * @param object $plugin The plugin object. + * + * @return string The generated XML. + * @since 5.0.2 + */ + public function get(object $plugin): string + { + $config_fields = $this->buildConfigFields($plugin); + $add_component_path = $this->shouldAddComponentPath($plugin); + $language_files = $this->generateLanguageFiles($plugin); + + $xml = $this->generateScriptAndSqlXml($plugin); + $xml .= $this->generateLanguageXml($plugin, $language_files); + $xml .= $this->generateFileXml($plugin, $language_files); + $xml .= $this->generateConfigXml($plugin, $config_fields, $add_component_path); + $xml .= $this->generateUpdateServerXml($plugin); + + return $xml; + } + + /** + * Build configuration fields XML. + * + * @param object $plugin The plugin object. + * + * @return array The configuration fields. + * @since 5.0.2 + */ + protected function buildConfigFields(object $plugin): array + { + $configFields = []; + if (!isset($plugin->config_fields) || !ArrayHelper::check($plugin->config_fields)) + { + return $configFields; + } + + $dbKey = 'yy'; + + foreach ($plugin->config_fields as $fieldName => $fieldsets) + { + foreach ($fieldsets as $fieldset => $fields) + { + $xmlFields = $this->fieldsetextension->get($plugin, $fields, $dbKey); + if (isset($xmlFields) && StringHelper::check($xmlFields)) + { + $configFields["{$fieldName}{$fieldset}"] = $xmlFields; + } + $dbKey++; + } + } + + return $configFields; + } + + /** + * Determine if the component path should be added. + * + * @param object $plugin The plugin object. + * + * @return bool True if the component path should be added, false otherwise. + * @since 5.0.2 + */ + protected function shouldAddComponentPath(object $plugin): bool + { + if (!isset($plugin->config_fields) || !ArrayHelper::check($plugin->config_fields) || + !isset($plugin->fieldsets_paths) || !ArrayHelper::check($plugin->fieldsets_paths)) + { + return false; + } + + foreach ($plugin->config_fields as $fieldName => $fieldsets) + { + foreach ($fieldsets as $fieldset => $fields) + { + if (isset($plugin->fieldsets_paths["{$fieldName}{$fieldset}"]) && + $plugin->fieldsets_paths["{$fieldName}{$fieldset}"] == 1) + { + return true; + } + } + } + + return false; + } + + /** + * Generate XML for script and SQL files. + * + * @param object $plugin The plugin object. + * + * @return string The XML for script and SQL files. + * @since 5.0.2 + */ + protected function generateScriptAndSqlXml(object $plugin): string + { + $xml = ''; + + if ($plugin->add_install_script) + { + $xml .= PHP_EOL . PHP_EOL . Indent::_(1) . ''; + $xml .= PHP_EOL . Indent::_(1) . 'script.php'; + } + + if ($plugin->add_sql) + { + $xml .= PHP_EOL . PHP_EOL . Indent::_(1) . ''; + $xml .= PHP_EOL . Indent::_(1) . ''; + $xml .= PHP_EOL . Indent::_(2) . ''; + $xml .= PHP_EOL . Indent::_(3) . 'sql/mysql/install.sql'; + $xml .= PHP_EOL . Indent::_(2) . ''; + $xml .= PHP_EOL . Indent::_(1) . ''; + } + + if ($plugin->add_sql_uninstall) + { + $xml .= PHP_EOL . PHP_EOL . Indent::_(1) . ''; + $xml .= PHP_EOL . Indent::_(1) . ''; + $xml .= PHP_EOL . Indent::_(2) . ''; + $xml .= PHP_EOL . Indent::_(3) . 'sql/mysql/uninstall.sql'; + $xml .= PHP_EOL . Indent::_(2) . ''; + $xml .= PHP_EOL . Indent::_(1) . ''; + } + + return $xml; + } + + /** + * Generate XML for language files. + * + * @param object $plugin The plugin object. + * @param array $languageFiles The language files. + * + * @return string The XML for language files. + * @since 5.0.2 + */ + protected function generateLanguageXml(object $plugin, array $languageFiles): string + { + $xml = ''; + + if (ArrayHelper::check($languageFiles)) + { + $xml .= PHP_EOL . PHP_EOL . Indent::_(1) . ''; + $xml .= PHP_EOL . Indent::_(1) . ''; + + foreach ($languageFiles as $addTag) + { + $xml .= PHP_EOL . Indent::_(2) . '' . $addTag . '/plg_' + . strtolower((string) $plugin->group) . '_' . + (string) $plugin->file_name + . '.ini'; + $xml .= PHP_EOL . Indent::_(2) . '' . $addTag . '/plg_' + . strtolower((string) $plugin->group) . '_' . + (string) $plugin->file_name + . '.sys.ini'; + } + $xml .= PHP_EOL . Indent::_(1) . ''; + } + + return $xml; + } + + /** + * Generate the XML for the files. + * + * @param object $plugin The plugin object. + * @param array $languageFiles The language files. + * + * @return string The XML for the files. + * @since 5.0.2 + */ + protected function generateFileXml(object $plugin, array $languageFiles): string + { + $files = Folder::files($plugin->folder_path); + $folders = Folder::folders($plugin->folder_path); + $ignore = ['sql', 'language', 'script.php', "{$plugin->file_name}.xml"]; + + $xml = PHP_EOL . PHP_EOL . Indent::_(1) . ''; + $xml .= PHP_EOL . Indent::_(1) . ''; + $xml .= PHP_EOL . Indent::_(2) . "context_name}\">services"; + + foreach ($files as $file) + { + if (!in_array($file, $ignore)) + { + $xml .= PHP_EOL . Indent::_(2) . "{$file}"; + } + } + + if (!empty($languageFiles)) + { + // $xml .= PHP_EOL . Indent::_(2) . 'language'; + } + + if ($plugin->add_sql || $plugin->add_sql_uninstall) + { + $xml .= PHP_EOL . Indent::_(2) . 'sql'; + } + + foreach ($folders as $folder) + { + if (!in_array($folder, $ignore)) + { + $xml .= PHP_EOL . Indent::_(2) . "{$folder}"; + } + } + + $xml .= PHP_EOL . Indent::_(1) . ''; + + return $xml; + } + + /** + * Generate XML for configuration fields. + * + * @param object $plugin The plugin object. + * @param array $configFields The configuration fields. + * @param bool $addComponentPath Whether to add the component path. + * + * @return string The XML for configuration fields. + * @since 5.0.2 + */ + protected function generateConfigXml(object $plugin, array $configFields, bool $addComponentPath): string + { + if (!isset($plugin->config_fields) || !ArrayHelper::check($configFields)) + { + return ''; + } + + $xml = PHP_EOL . PHP_EOL . Indent::_(1) . ''; + $xml .= $addComponentPath ? PHP_EOL . Indent::_(1) . ''; + + if ($addComponentPath) + { + $xml .= PHP_EOL . Indent::_(3) . 'addruleprefix="' . $this->config->namespace_prefix . '\Component\\' . $this->contentone->get('ComponentNamespace') . '\Administrator\Rule"'; + $xml .= PHP_EOL . Indent::_(3) . 'addfieldprefix="' . $this->config->namespace_prefix . '\Component\\' . $this->contentone->get('ComponentNamespace') . '\Administrator\Field">'; + $xml .= PHP_EOL . Indent::_(1) . '>'; + } + + foreach ($plugin->config_fields as $fieldName => $fieldsets) + { + $xml .= PHP_EOL . Indent::_(1) . ""; + + foreach ($fieldsets as $fieldset => $fields) + { + $label = $plugin->fieldsets_label["{$fieldName}{$fieldset}"] ?? $fieldset; + + $xml .= PHP_EOL . Indent::_(1) . "
"; + + if (isset($configFields["{$fieldName}{$fieldset}"])) + { + $xml .= $configFields["{$fieldName}{$fieldset}"]; + } + + $xml .= PHP_EOL . Indent::_(1) . '
'; + } + + $xml .= PHP_EOL . Indent::_(1) . '
'; + } + + $xml .= PHP_EOL . Indent::_(1) . ''; + + return $xml; + } + + /** + * Generate XML for update servers. + * + * @param object $plugin The plugin object. + * + * @return string The XML for update servers. + * @since 5.0.2 + */ + protected function generateUpdateServerXml(object $plugin): string + { + $xml = ''; + + if ($plugin->add_update_server) + { + $xml = PHP_EOL . PHP_EOL . Indent::_(1) . ''; + $xml .= PHP_EOL . Indent::_(1) . ''; + $xml .= PHP_EOL . Indent::_(2) . '' . $plugin->update_server_url . ''; + $xml .= PHP_EOL . Indent::_(1) . ''; + } + + return $xml; + } + + /** + * Generate language files. + * + * @param object $plugin The plugin object. + * + * @return array The language files. + * @since 5.0.2 + */ + protected function generateLanguageFiles(object $plugin): array + { + $languageFiles = []; + + if (!$this->language->exist($plugin->key)) + { + return $languageFiles; + } + + $langContent = $this->language->getTarget($plugin->key); + $this->event->trigger('jcb_ce_onBeforeBuildPluginLang', [&$plugin, &$langContent]); + + $values = array_unique($langContent); + $this->buildermultilingual->set('plugins', $this->multilingual->get($values)); + + $langTag = $this->config->get('lang_tag', 'en-GB'); + $this->languages->set("plugins.{$langTag}.all", $langContent); + $this->language->setTarget($plugin->key, null); + + $this->set->execute($values, $plugin->id, 'plugins'); + $this->purge->execute($values, $plugin->id, 'plugins'); + + $this->event->trigger('jcb_ce_onBeforeBuildPluginLangFiles', [&$plugin]); + + if ($this->languages->IsArray('plugins')) + { + foreach ($this->languages->get('plugins') as $tag => $areas) + { + $tag = trim($tag); + foreach ($areas as $area => $languageStrings) + { + $fileName = "plg_" . strtolower((string)$plugin->group) . '_' . $plugin->file_name . '.ini'; + $total = count($values); + if ($this->translation->check($tag, $languageStrings, $total, $fileName)) + { + $lang = array_map( + fn($langString, $placeholder) => "{$placeholder}=\"{$langString}\"", + array_values($languageStrings), + array_keys($languageStrings) + ); + + $path = "{$plugin->folder_path}/language/{$tag}/"; + + if (!Folder::exists($path)) + { + Folder::create($path); + $this->counter->folder++; + } + + $this->file->write($path . $fileName, implode(PHP_EOL, $lang)); + $this->file->write( + $path . 'plg_' . strtolower((string)$plugin->group) . '_' . $plugin->file_name . '.sys.ini', + implode(PHP_EOL, $lang) + ); + + $this->counter->line += count($lang); + unset($lang); + + $languageFiles[$tag] = $tag; + } + } + } + } + + return $languageFiles; + } \ No newline at end of file diff --git a/src/af6d0e6a-61d2-4250-9e2f-bed5591e2786/settings.json b/src/af6d0e6a-61d2-4250-9e2f-bed5591e2786/settings.json new file mode 100644 index 0000000..f024961 --- /dev/null +++ b/src/af6d0e6a-61d2-4250-9e2f-bed5591e2786/settings.json @@ -0,0 +1,90 @@ +{ + "add_head": "1", + "add_licensing_template": "2", + "extends": "", + "guid": "af6d0e6a-61d2-4250-9e2f-bed5591e2786", + "implements": [ + "97177ca9-a51a-4d24-81e1-8747b6e7d76c" + ], + "load_selection": null, + "name": "MainXML", + "power_version": "1.0.0", + "system_name": "JCB.Architecture.J4.Plugin.MainXML", + "type": "final class", + "use_selection": { + "use_selection0": { + "use": "fa4bf18e-301e-42e3-91fb-6e0096c07adc", + "as": "default" + }, + "use_selection1": { + "use": "8eee7df5-2775-41a9-9372-c46c5939a252", + "as": "default" + }, + "use_selection2": { + "use": "058cfcd7-1f84-4cc6-8bcc-7672f316881d", + "as": "default" + }, + "use_selection3": { + "use": "0b0e574c-aab4-4eaf-96d8-d7210d8ed93e", + "as": "default" + }, + "use_selection4": { + "use": "344d36be-3949-4848-8cb0-e3d3d9d05c36", + "as": "default" + }, + "use_selection5": { + "use": "263f0227-3cc2-4a88-9818-edb20081c30c", + "as": "default" + }, + "use_selection6": { + "use": "20ed72b0-fcac-4344-aee1-8a65e3bf221d", + "as": "Event" + }, + "use_selection7": { + "use": "23f459a4-7c2a-4cbf-b0a6-8a11954140a9", + "as": "default" + }, + "use_selection8": { + "use": "adfbe68a-6d22-43e5-aee8-2787e8c47e75", + "as": "default" + }, + "use_selection9": { + "use": "7526a39a-ada3-4499-8d75-81beff33f949", + "as": "default" + }, + "use_selection10": { + "use": "a8c6158a-6fd2-476b-a5ea-c81f1ecd2356", + "as": "BuilderMultilingual" + }, + "use_selection11": { + "use": "e6d871a6-bbe7-497d-af01-68f6bb9a87f4", + "as": "default" + }, + "use_selection12": { + "use": "5c75b455-3d4c-452a-867e-e90424a64c88", + "as": "default" + }, + "use_selection13": { + "use": "4e6ff11d-bebf-42f5-8fd7-b2f882857222", + "as": "default" + }, + "use_selection14": { + "use": "a68c010b-e92e-47d5-8a44-d23cfddeb6c6", + "as": "default" + }, + "use_selection15": { + "use": "0a59c65c-9daf-4bc9-baf4-e063ff9e6a8a", + "as": "default" + }, + "use_selection16": { + "use": "1f28cb53-60d9-4db1-b517-3c7dc6b429ef", + "as": "default" + } + }, + "extendsinterfaces": null, + "namespace": "[[[NamespacePrefix]]]\\Joomla\\[[[ComponentNamespace]]].Compiler.Architecture.JoomlaFour.Plugin.MainXML", + "description": "Joomla 4 Plugin Main XML Class\r\n\r\n@since 5.0.2", + "licensing_template": "\/**\r\n * @package Joomla.Component.Builder\r\n *\r\n * @created 4th September, 2022\r\n * @author Llewellyn van der Merwe \r\n * @git Joomla Component Builder \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\\Filesystem\\Folder;", + "composer": "" +} \ No newline at end of file diff --git a/src/b69a23db-0a62-4840-a9c5-b2d8d63ecc6c/README.md b/src/b69a23db-0a62-4840-a9c5-b2d8d63ecc6c/README.md index 68edcc9..c969972 100644 --- a/src/b69a23db-0a62-4840-a9c5-b2d8d63ecc6c/README.md +++ b/src/b69a23db-0a62-4840-a9c5-b2d8d63ecc6c/README.md @@ -25,8 +25,10 @@ class Structuremultiple << (F,LightGreen) >> #RoyalBlue { # site() : bool # custom() : bool - isValidAdminView(array $view, array $config) : bool + - hasApi(array $view) : int - isValidView(array $view, array $config) : bool - buildAdminView(array $view, array $config) : void + - buildApi(array $view, array $config, ...) : void - buildView(array $view, array $config, ...) : void } @@ -80,20 +82,39 @@ note left of Structuremultiple::isValidAdminView return: bool end note -note right of Structuremultiple::isValidView +note right of Structuremultiple::hasApi + Check if the view has an API + + since: 5.0.2 + return: int +end note + +note left of Structuremultiple::isValidView Check if the view is a valid view since: 3.2.0 return: bool end note -note left of Structuremultiple::buildAdminView +note right of Structuremultiple::buildAdminView Build the admin view since: 3.2.0 return: void end note +note left of Structuremultiple::buildApi + Build the api + + since: 5.0.2 + return: void + + arguments: + array $view + array $config + int $targetArea +end note + note right of Structuremultiple::buildView Build the custom view diff --git a/src/b69a23db-0a62-4840-a9c5-b2d8d63ecc6c/code.php b/src/b69a23db-0a62-4840-a9c5-b2d8d63ecc6c/code.php index 45f11cf..e2c9778 100644 --- a/src/b69a23db-0a62-4840-a9c5-b2d8d63ecc6c/code.php +++ b/src/b69a23db-0a62-4840-a9c5-b2d8d63ecc6c/code.php @@ -157,6 +157,7 @@ final class Structuremultiple $config = []; $checkin = false; + $api = null; foreach ($this->component->get('admin_views') as $view) { @@ -174,8 +175,16 @@ final class Structuremultiple $checkin = true; $this->config->set('add_checkin', $checkin); } + + if (($target = $this->hasApi($view)) > 0) + { + $this->buildApi($view, $config, $target); + $api = 1; + } } + $this->config->set('add_api', $api); + return true; } @@ -265,6 +274,25 @@ final class Structuremultiple return true; } + /** + * Check if the view has an API + * + * @param array $view + * + * @return int + * @since 5.0.2 + */ + private function hasApi(array $view): int + { + // only for Joomla 4 and above + if ($this->config->get('joomla_version', 3) < 4 || !isset($view['add_api'])) + { + return 0; + } + + return (int) $view['add_api']; + } + /** * Check if the view is a valid view * @@ -333,6 +361,35 @@ final class Structuremultiple } } + /** + * Build the api + * + * @param array $view + * @param array $config + * @param int $targetArea + * + * @return void + * @since 5.0.2 + */ + private function buildApi(array $view, array $config, int $targetArea) + { + $settings = $view['settings']; + + // build the api + if ($settings->name_single != 'null' && $targetArea !== 1) + { + $target = ['api' => $settings->name_single]; + $this->structure->build($target, 'single', false, $config); + } + + // build the list view + if ($settings->name_list != 'null' && $targetArea !== 3) + { + $target = ['api' => $settings->name_list]; + $this->structure->build($target, 'list', false, $config); + } + } + /** * Build the custom view * diff --git a/src/b69a23db-0a62-4840-a9c5-b2d8d63ecc6c/code.power b/src/b69a23db-0a62-4840-a9c5-b2d8d63ecc6c/code.power index c642148..641c095 100644 --- a/src/b69a23db-0a62-4840-a9c5-b2d8d63ecc6c/code.power +++ b/src/b69a23db-0a62-4840-a9c5-b2d8d63ecc6c/code.power @@ -124,6 +124,7 @@ $config = []; $checkin = false; + $api = null; foreach ($this->component->get('admin_views') as $view) { @@ -141,8 +142,16 @@ $checkin = true; $this->config->set('add_checkin', $checkin); } + + if (($target = $this->hasApi($view)) > 0) + { + $this->buildApi($view, $config, $target); + $api = 1; + } } + $this->config->set('add_api', $api); + return true; } @@ -232,6 +241,25 @@ return true; } + /** + * Check if the view has an API + * + * @param array $view + * + * @return int + * @since 5.0.2 + */ + private function hasApi(array $view): int + { + // only for Joomla 4 and above + if ($this->config->get('joomla_version', 3) < 4 || !isset($view['add_api'])) + { + return 0; + } + + return (int) $view['add_api']; + } + /** * Check if the view is a valid view * @@ -300,6 +328,35 @@ } } + /** + * Build the api + * + * @param array $view + * @param array $config + * @param int $targetArea + * + * @return void + * @since 5.0.2 + */ + private function buildApi(array $view, array $config, int $targetArea) + { + $settings = $view['settings']; + + // build the api + if ($settings->name_single != 'null' && $targetArea !== 1) + { + $target = ['api' => $settings->name_single]; + $this->structure->build($target, 'single', false, $config); + } + + // build the list view + if ($settings->name_list != 'null' && $targetArea !== 3) + { + $target = ['api' => $settings->name_list]; + $this->structure->build($target, 'list', false, $config); + } + } + /** * Build the custom view * diff --git a/src/c6619b00-261c-473b-8094-d4fe9e6bab39/README.md b/src/c6619b00-261c-473b-8094-d4fe9e6bab39/README.md index e170aac..a21fb0e 100644 --- a/src/c6619b00-261c-473b-8094-d4fe9e6bab39/README.md +++ b/src/c6619b00-261c-473b-8094-d4fe9e6bab39/README.md @@ -13,6 +13,7 @@ @startuml abstract RepoHelper #Orange { + {static} get(int $target) : ?array + # {static} setPlaceholders(string $placeholders) : array } note right of RepoHelper::get @@ -21,6 +22,13 @@ note right of RepoHelper::get since: 3.2.0 return: ?array end note + +note right of RepoHelper::setPlaceholders + set the placeholders for this repo + + since: 5.0.3 + return: array +end note @enduml ``` diff --git a/src/c6619b00-261c-473b-8094-d4fe9e6bab39/code.php b/src/c6619b00-261c-473b-8094-d4fe9e6bab39/code.php index 52036a9..0fca27e 100644 --- a/src/c6619b00-261c-473b-8094-d4fe9e6bab39/code.php +++ b/src/c6619b00-261c-473b-8094-d4fe9e6bab39/code.php @@ -13,6 +13,8 @@ namespace VDM\Joomla\Componentbuilder\Utilities; use Joomla\CMS\Factory; +use VDM\Joomla\Utilities\JsonHelper; +use VDM\Joomla\Utilities\ArrayHelper; /** @@ -45,6 +47,7 @@ abstract class RepoHelper 'username', 'target', 'access_repo', + 'addplaceholders', 'guid' ))) ->from($db->quoteName('#__componentbuilder_repository')) @@ -66,13 +69,43 @@ abstract class RepoHelper unset($item->token); } unset($item->access_repo); + + $item->placeholders = self::setPlaceholders($item->addplaceholders ?? ''); + unset($item->addplaceholders); + $path = $item->organisation . '/' . $item->repository; $options[$path] = $item; } + return $options; } return null; + } + + /** + * set the placeholders for this repo + * + * @param string $placeholders The repo placeholders + * + * @return array The result set + * @since 5.0.3 + **/ + protected static function setPlaceholders(string $placeholders): array + { + $bucket = []; + if (JsonHelper::check($placeholders)) + { + $placeholders = json_decode((string) $placeholders, true); + if (ArrayHelper::check($placeholders)) + { + foreach ($placeholders as $row) + { + $bucket[$row['target']] = $row['value']; + } + } + } + return $bucket; } } diff --git a/src/c6619b00-261c-473b-8094-d4fe9e6bab39/code.power b/src/c6619b00-261c-473b-8094-d4fe9e6bab39/code.power index eb6410e..9e48f41 100644 --- a/src/c6619b00-261c-473b-8094-d4fe9e6bab39/code.power +++ b/src/c6619b00-261c-473b-8094-d4fe9e6bab39/code.power @@ -21,6 +21,7 @@ 'username', 'target', 'access_repo', + 'addplaceholders', 'guid' ))) ->from($db->quoteName('#__componentbuilder_repository')) @@ -42,11 +43,41 @@ unset($item->token); } unset($item->access_repo); + + $item->placeholders = self::setPlaceholders($item->addplaceholders ?? ''); + unset($item->addplaceholders); + $path = $item->organisation . '/' . $item->repository; $options[$path] = $item; } + return $options; } return null; + } + + /** + * set the placeholders for this repo + * + * @param string $placeholders The repo placeholders + * + * @return array The result set + * @since 5.0.3 + **/ + protected static function setPlaceholders(string $placeholders): array + { + $bucket = []; + if (JsonHelper::check($placeholders)) + { + $placeholders = json_decode((string) $placeholders, true); + if (ArrayHelper::check($placeholders)) + { + foreach ($placeholders as $row) + { + $bucket[$row['target']] = $row['value']; + } + } + } + return $bucket; } \ No newline at end of file diff --git a/src/c6619b00-261c-473b-8094-d4fe9e6bab39/settings.json b/src/c6619b00-261c-473b-8094-d4fe9e6bab39/settings.json index 7e79a6c..474b773 100644 --- a/src/c6619b00-261c-473b-8094-d4fe9e6bab39/settings.json +++ b/src/c6619b00-261c-473b-8094-d4fe9e6bab39/settings.json @@ -9,7 +9,16 @@ "power_version": "1.0.0", "system_name": "JCB.Utilities.RepoHelper", "type": "abstract class", - "use_selection": null, + "use_selection": { + "use_selection0": { + "use": "4b225c51-d293-48e4-b3f6-5136cf5c3f18", + "as": "default" + }, + "use_selection1": { + "use": "0a59c65c-9daf-4bc9-baf4-e063ff9e6a8a", + "as": "default" + } + }, "extendsinterfaces": null, "namespace": "[[[NamespacePrefix]]]\\Joomla\\[[[ComponentNamespace]]].Utilities.RepoHelper", "description": "Repositories Helper\r\n\r\n@since 3.2.2", diff --git a/src/caf559ee-8337-4f07-9e4a-394d4e06afdc/README.md b/src/caf559ee-8337-4f07-9e4a-394d4e06afdc/README.md new file mode 100644 index 0000000..c77b2c4 --- /dev/null +++ b/src/caf559ee-8337-4f07-9e4a-394d4e06afdc/README.md @@ -0,0 +1,243 @@ +``` +██████╗ ██████╗ ██╗ ██╗███████╗██████╗ +██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗ +██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝ +██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗ +██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║ +╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝ +``` +# final class Set (Details) +> namespace: **VDM\Joomla\Componentbuilder\Power\Remote** +> extends: **ExtendingSet** + +```uml +@startuml +class Set << (F,LightGreen) >> #RoyalBlue { + # string $table + # string $area + # array $map + # ?Parser $parser + + __construct(array $repos, Grep $grep, ...) + # mapItemValue_extends(array $item, $power) : void + # mapItemValue_extendsinterfaces(array $item, $power) : void + # mapItemValue_use_selection(array $item, $power) : void + # mapItemValue_load_selection(array $item, $power) : void + # mapItemValue_composer(array $item, $power) : void + # mapItemValue_implements(array $item, $power) : void + # updateItem(object $item, object $existing, ...) : bool + # updatePower(object $item, object $existing, ...) : bool + # createItem(object $item, object $repo) : void + # createPower(object $item, object $repo) : void + # updateItemReadme(object $item, object $existing, ...) : void + # createItemReadme(object $item, object $repo) : void + # targetRepo(object $item, object $repo) : bool + # index_map_IndexName(object $item) : ?string + # index_map_TypeName(object $item) : ?string + # index_map_CodePath(object $item) : ?string + # index_map_PowerPath(object $item) : ?string + # index_map_NameSpace(object $item) : ?string + # getNamespace(string $namespace, string $className) : ?string + # getCleanNamespace(string $namespace) : string +} + +note right of Set::__construct + Constructor. + + since: 3.2.2 + + arguments: + array $repos + Grep $grep + Items $items + ItemReadme $itemReadme + MainReadme $mainReadme + Git $git + ?string $table = null + ?string $settingsPath = null + ?string $settingsIndexPath = null + ?Parser $parser = null +end note + +note left of Set::mapItemValue_extends + Map a single item value (extends) + + since: 5.0.2 + return: void +end note + +note right of Set::mapItemValue_extendsinterfaces + Map a single item value (extendsinterfaces) + + since: 5.0.2 + return: void +end note + +note left of Set::mapItemValue_use_selection + Map a single item value (use_selection) + + since: 5.0.2 + return: void +end note + +note right of Set::mapItemValue_load_selection + Map a single item value (load_selection) + + since: 5.0.2 + return: void +end note + +note left of Set::mapItemValue_composer + Map a single item value (composer) + + since: 5.0.2 + return: void +end note + +note right of Set::mapItemValue_implements + Map a single item value (implements) + + since: 5.0.2 + return: void +end note + +note left of Set::updateItem + update an existing item (if changed) + + since: 5.0.3 + return: bool + + arguments: + object $item + object $existing + object $repo +end note + +note right of Set::updatePower + update an existing power code (if changed) + + since: 5.0.3 + return: bool + + arguments: + object $item + object $existing + object $repo +end note + +note left of Set::createItem + create a new item + + since: 5.0.3 + return: void +end note + +note right of Set::createPower + create a new power + + since: 5.0.3 + return: void +end note + +note left of Set::updateItemReadme + update an existing item readme + + since: 5.0.3 + return: void + + arguments: + object $item + object $existing + object $repo +end note + +note right of Set::createItemReadme + create a new item readme + + since: 5.0.3 + return: void +end note + +note left of Set::targetRepo + check that we have a target repo of this item + + since: 5.0.3 + return: bool +end note + +note right of Set::index_map_IndexName + Get the item name for the index values + + since: 5.0.3 + return: ?string +end note + +note left of Set::index_map_TypeName + Get the item type for the index values + + since: 5.0.3 + return: ?string +end note + +note right of Set::index_map_CodePath + Get the item code path for the index values + + since: 5.0.3 + return: ?string +end note + +note left of Set::index_map_PowerPath + Get the item power path for the index values + + since: 5.0.3 + return: ?string +end note + +note right of Set::index_map_NameSpace + Get the item namespace for the index values + + since: 5.0.3 + return: ?string +end note + +note left of Set::getNamespace + Set the namespace for this power + + since: 5.0.3 + return: ?string +end note + +note right of Set::getCleanNamespace + Get Clean Namespace without use or ; as part of the name space + + since: 5.0.3 + return: string +end note + +@enduml +``` + +The Power feature in JCB allows you to write PHP classes and their implementations, making it easy to include them in your Joomla project. JCB handles linking, autoloading, namespacing, and folder structure creation for you. + +By using the SPK (Super Power Key) in your custom code (replacing the class name in your code with the SPK), JCB will automatically pull the power from the repository into your project. This makes it available in your JCB instance, allowing you to edit it and include the class in your generated Joomla component. + +JCB uses placeholders like [[[`NamespacePrefix`]]] and [[[`ComponentNamespace`]]] in namespacing to prevent collisions and improve reusability across different JCB systems. You can also set the **JCB powers path** globally or per component under the **Dynamic Integration** tab, providing flexibility and easy maintainability. + +To add this specific Power to your project in JCB: + +> simply use this SPK +``` +Super---caf559ee_8337_4f07_9e4a_394d4e06afdc---Power +``` +> remember to replace the `---` with `___` to activate this Power in your code + +--- +``` + ██╗ ██████╗██████╗ + ██║██╔════╝██╔══██╗ + ██║██║ ██████╔╝ +██ ██║██║ ██╔══██╗ +╚█████╔╝╚██████╗██████╔╝ + ╚════╝ ╚═════╝╚═════╝ +``` +> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder) + diff --git a/src/caf559ee-8337-4f07-9e4a-394d4e06afdc/code.php b/src/caf559ee-8337-4f07-9e4a-394d4e06afdc/code.php new file mode 100644 index 0000000..037a9a2 --- /dev/null +++ b/src/caf559ee-8337-4f07-9e4a-394d4e06afdc/code.php @@ -0,0 +1,794 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Componentbuilder\Power\Remote; + + +use VDM\Joomla\Interfaces\GrepInterface as Grep; +use VDM\Joomla\Interfaces\Data\ItemsInterface as Items; +use VDM\Joomla\Interfaces\Readme\ItemInterface as ItemReadme; +use VDM\Joomla\Interfaces\Readme\MainInterface as MainReadme; +use VDM\Joomla\Interfaces\Git\Repository\ContentsInterface as Git; +use VDM\Joomla\Componentbuilder\Power\Parser; +use VDM\Joomla\Utilities\String\NamespaceHelper; +use VDM\Joomla\Utilities\ArrayHelper; +use VDM\Joomla\Utilities\StringHelper; +use VDM\Joomla\Utilities\String\ClassfunctionHelper; +use VDM\Joomla\Utilities\GuidHelper; +use VDM\Joomla\Interfaces\Remote\SetInterface; +use VDM\Joomla\Abstraction\Remote\Set as ExtendingSet; + + +/** + * Set Power based on global unique ids to remote repository + * + * @since 5.0.2 + */ +final class Set extends ExtendingSet implements SetInterface +{ + /** + * Table Name + * + * @var string + * @since 5.0.3 + */ + protected string $table = 'power'; + + /** + * Area Name + * + * @var string + * @since 5.0.3 + */ + protected string $area = 'Super Power'; + + /** + * Prefix Key + * + * @var string + * @since 5.0.3 + */ + protected string $prefix_key = 'Super---'; + + /** + * The item map + * + * @var array + * @since 5.0.3 + */ + protected array $map = [ + 'add_head' => 'add_head', + 'description' => 'description', + 'extends' => 'extends', + 'extendsinterfaces' => 'extendsinterfaces', + 'guid' => 'guid', + 'head' => 'head', + 'use_selection' => 'use_selection', + 'implements' => 'implements', + 'load_selection' => 'load_selection', + 'name' => 'name', + 'power_version' => 'power_version', + 'system_name' => 'system_name', + 'type' => 'type', + 'namespace' => 'namespace', + 'composer' => 'composer', + 'add_licensing_template' => 'add_licensing_template', + 'licensing_template' => 'licensing_template', + 'main_class_code' => 'main_class_code' + ]; + + /** + * The index map + * + * @var array + * @since 5.0.3 + */ + protected array $index_map = [ + 'name' => 'index_map_IndexName', + 'type' => 'index_map_TypeName', + 'namespace' => 'index_map_NameSpace', + 'code' => 'index_map_CodePath', + 'power' => 'index_map_PowerPath', + 'settings' => 'index_map_IndexSettingsPath', + 'path' => 'index_map_IndexPath', + 'spk' => 'index_map_IndexKey', + 'guid' => 'index_map_IndexGUID' + ]; + + /** + * The item settings file path + * + * @var string + * @since 5.0.3 + */ + protected string $settings_path = 'settings.json'; + + /** + * The index settings file path + * + * @var string + * @since 5.0.3 + */ + protected string $index_settings_path = 'super-powers.json'; + + /** + * The Parser Class. + * + * @var Parser|null + * @since 5.0.2 + */ + protected ?Parser $parser; + + /** + * Constructor. + * + * @param array $repos The active repos + * @param Grep $grep The Grep Class. + * @param Items $items The Items Class. + * @param ItemReadme $itemReadme The Item Readme Class. + * @param MainReadme $mainReadme The Main Readme Class. + * @param Git $git The Contents Class. + * @param string|null $table The table name. + * @param string|null $settingsPath The settings path. + * @param string|null $settingsIndexPath The index settings path. + * @param Parser|null $parser The Parser Class. + * + * @since 3.2.2 + */ + public function __construct(array $repos, Grep $grep, Items $items, + ItemReadme $itemReadme, MainReadme $mainReadme, Git $git, + ?string $table = null, ?string $settingsPath = null, + ?string $settingsIndexPath = null, ?Parser $parser = null) + { + parent::__construct($repos, $grep, $items, $itemReadme, $mainReadme, + $git, $table, $settingsPath, $settingsIndexPath); + + $this->parser = $parser; + } + + /** + * Map a single item value (extends) + * + * @param object $item The item to be mapped + * @param array $item The bucket to to place new values + * @param string $map The item map to be mapped + * + * @return void + * @since 5.0.2 + */ + protected function mapItemValue_extends(object &$item, array &$power): void + { + if ($item->type !== 'interface') + { + $value = $item->extends ?? ''; + $extends_custom = $item->extends_custom ?? null; + if ($value == -1 && $extends_custom !== null) + { + $power['extends_name'] = ClassfunctionHelper::safe( + $this->updatePlaceholders((string) $extends_custom) + ); + $power['extends_custom'] = $extends_custom; + $power['extends'] = -1; + } + elseif (GuidHelper::valid($value)) + { + $name = GuidHelper::item($value, 'power', 'a.name', 'componentbuilder'); + if ($name !== null) + { + $power['extends_name'] = ClassfunctionHelper::safe( + $this->updatePlaceholders($name) + ); + } + } + else + { + $power['extends'] = ''; + } + // always rest these for normal classes + $power['extendsinterfaces'] = null; + $power['extendsinterfaces_custom'] = ''; + } + } + + /** + * Map a single item value (extendsinterfaces) + * + * @param object $item The item to be mapped + * @param array $item The bucket to to place new values + * @param string $map The item map to be mapped + * + * @return void + * @since 5.0.2 + */ + protected function mapItemValue_extendsinterfaces(object &$item, array &$power): void + { + if ($item->type === 'interface') + { + $values = $item->extendsinterfaces ?? null; + if (!empty($values)) + { + $values = (array) $values; + $extends_names = []; + $extendsinterfaces_custom = $item->extendsinterfaces_custom ?? null; + + foreach ($values as $value) + { + if ($value == -1 && StringHelper::check($extendsinterfaces_custom)) + { + $extends_names[] = ClassfunctionHelper::safe( + $this->updatePlaceholders($extendsinterfaces_custom) + ); + + $power['extendsinterfaces_custom'] = $extendsinterfaces_custom; + $extendsinterfaces_custom = null; + } + elseif (GuidHelper::valid($value)) + { + $name = GuidHelper::item($value, 'power', 'a.name', 'componentbuilder'); + if ($name !== null) + { + $extends_names[] = ClassfunctionHelper::safe( + $this->updatePlaceholders($name) + ); + } + } + } + + if ($extends_names !== []) + { + $power['extendsinterfaces'] = array_values($values); + $power['extends_name'] = implode(', ', $extends_names); + } + } + else + { + $power['extendsinterfaces'] = null; + $power['extendsinterfaces_custom'] = ''; + } + // always rest these for interfaces + $power['extends'] = ''; + $power['extends_custom'] = ''; + } + } + + /** + * Map a single item value (use_selection) + * + * @param object $item The item to be mapped + * @param array $item The bucket to to place new values + * @param string $map The item map to be mapped + * + * @return void + * @since 5.0.2 + */ + protected function mapItemValue_use_selection(object &$item, array &$power): void + { + $value = $item->use_selection ?? null; + if (!empty($value)) + { + $value = (array) $value; + $power['use_selection'] = $value; + } + else + { + $power['use_selection'] = null; + } + } + + /** + * Map a single item value (load_selection) + * + * @param object $item The item to be mapped + * @param array $item The bucket to to place new values + * @param string $map The item map to be mapped + * + * @return void + * @since 5.0.2 + */ + protected function mapItemValue_load_selection(object &$item, array &$power): void + { + $value = $item->load_selection ?? null; + if (!empty($value)) + { + $value = (array) $value; + $power['load_selection'] = $value; + } + else + { + $power['load_selection'] = null; + } + } + + /** + * Map a single item value (composer) + * + * @param object $item The item to be mapped + * @param array $item The bucket to to place new values + * @param string $map The item map to be mapped + * + * @return void + * @since 5.0.2 + */ + protected function mapItemValue_composer(object &$item, array &$power): void + { + $value = $item->composer ?? null; + if (!empty($value)) + { + $value = (array) $value; + $power['composer'] = array_values($value); + } + else + { + $power['composer'] = ''; + } + } + + /** + * Map a single item value (implements) + * + * @param object $item The item to be mapped + * @param array $item The bucket to to place new values + * @param string $map The item map to be mapped + * + * @return void + * @since 5.0.2 + */ + protected function mapItemValue_implements(object &$item, array &$power): void + { + $values = $item->implements ?? ''; + if (!empty($values)) + { + $values = (array) $values; + $implement_names = []; + $implements_custom = $item->implements_custom ?? null; + + foreach ($values as $value) + { + if ($value == -1 && StringHelper::check($implements_custom)) + { + $implement_names[] = ClassfunctionHelper::safe( + $this->updatePlaceholders($implements_custom) + ); + $implements_custom = null; + } + elseif (GuidHelper::valid($value)) + { + $name = GuidHelper::item($value, 'power', 'a.name', 'componentbuilder'); + if ($name !== null) + { + $implement_names[] = ClassfunctionHelper::safe( + $this->updatePlaceholders($name) + ); + } + } + } + + if ($implement_names !== []) + { + $power['implements'] = array_values($values); + $power['implement_names'] = $implement_names; + } + else + { + $power['implements'] = null; + } + } + } + + /** + * update an existing item (if changed) + * + * @param object $item + * @param object $existing + * @param object $repo + * + * @return bool + * @since 5.0.3 + */ + protected function updateItem(object $item, object $existing, object $repo): bool + { + // make sure there was a change + $sha = $existing->params->source[$repo->guid . '-settings'] ?? null; + $_existing = $this->mapItem($existing); + + if ($sha === null || $this->areObjectsEqual($item, $_existing)) + { + return false; + } + else + { + // strip these values form the settings + $code = (string) $item->main_class_code ?? ''; + $extends_name = (string) $item->extends_name ?? ''; + $implement_names = (string) $item->implement_names ?? ''; + unset($item->main_class_code); + unset($item->extends_name); + unset($item->implement_names); + + $this->git->update( + $repo->organisation, // The owner name. + $repo->repository, // The repository name. + 'src/' . $item->guid . '/' . $this->getSettingsPath(), // The file path. + json_encode($item, JSON_PRETTY_PRINT), // The file content. + 'Update ' . $item->system_name . ' settings', // The commit message. + $sha, // The blob SHA of the old file. + $repo->write_branch // The branch name. + ); + + $item->main_class_code = $code; + $item->extends_name = $extends_name; + $item->implement_names = $implement_names; + } + + return $this->updatePower($item, $existing, $repo); + } + + /** + * update an existing power code (if changed) + * + * @param object $item + * @param object $existing + * @param object $repo + * + * @return bool + * @since 5.0.3 + */ + protected function updatePower(object $item, object $existing, object $repo): bool + { + // make sure there was a change + $sha = $existing->params->source[$repo->guid . '-power'] ?? null; + + if ($sha === null) + { + return false; + } + + // Calculate the new SHA from the current content + $power = $item->main_class_code ?? ''; + $newSha = sha1("blob " . strlen($power) . "\0" . $power); + + // Check if the new SHA matches the existing SHA + if ($sha === $newSha) + { + return false; + } + + $this->git->update( + $repo->organisation, // The owner name. + $repo->repository, // The repository name. + 'src/' . $item->guid . '/code.power', // The file path. + $power, // The file content. + 'Update ' . $item->system_name . ' code', // The commit message. + $sha, // The blob SHA of the old file. + $repo->write_branch // The branch name. + ); + + return true; + } + + /** + * create a new item + * + * @param object $item + * @param object $repo + * + * @return void + * @since 5.0.3 + */ + protected function createItem(object $item, object $repo): void + { + // strip these values form the settings + $code = (string) $item->main_class_code ?? ''; + $extends_name = (string) $item->extends_name ?? ''; + $implement_names = (string) $item->implement_names ?? ''; + unset($item->main_class_code); + unset($item->extends_name); + unset($item->implement_names); + + $this->git->create( + $repo->organisation, // The owner name. + $repo->repository, // The repository name. + 'src/' . $item->guid . '/' . $this->getSettingsPath(), // The file path. + json_encode($item, JSON_PRETTY_PRINT), // The file content. + 'Create ' . $item->system_name . ' settings', // The commit message. + $repo->write_branch // The branch name. + ); + + $item->main_class_code = $code; + $item->extends_name = $extends_name; + $item->implement_names = $implement_names; + + $this->createPower($item, $repo); + } + + /** + * create a new power + * + * @param object $item + * @param object $repo + * + * @return void + * @since 5.0.3 + */ + protected function createPower(object $item, object $repo): void + { + $this->git->create( + $repo->organisation, // The owner name. + $repo->repository, // The repository name. + 'src/' . $item->guid . '/code.power', // The file path. + $item->main_class_code, // The file content. + 'Create ' . $item->system_name . ' code', // The commit message. + $repo->write_branch // The branch name. + ); + } + + /** + * update an existing item readme + * + * @param object $item + * @param object $existing + * @param object $repo + * + * @return void + * @since 5.0.3 + */ + protected function updateItemReadme(object $item, object $existing, object $repo): void + { + // make sure there was a change + $sha = $existing->params->source[$repo->guid . '-readme'] ?? null; + if ($sha === null) + { + return; + } + + if ($this->parser !== null) + { + $item->parsed_class_code = $this->parser->code($item->main_class_code); + } + $item->code_name = $this->index_map_IndexName($item); + $item->_namespace = $this->index_map_NameSpace($item); + + $readme = $this->itemReadme->get($item); + $newSha = sha1("blob " . strlen($readme) . "\0" . $readme); + + // Check if the new SHA matches the existing SHA + if ($sha === $newSha) + { + return; + } + + $this->git->update( + $repo->organisation, // The owner name. + $repo->repository, // The repository name. + 'src/' . $item->guid . '/README.md', // The file path. + $readme, // The file content. + 'Update ' . $item->system_name . ' readme file', // The commit message. + $sha, // The blob SHA of the old file. + $repo->write_branch // The branch name. + ); + } + + /** + * create a new item readme + * + * @param object $item + * @param object $repo + * + * @return void + * @since 5.0.3 + */ + protected function createItemReadme(object $item, object $repo): void + { + if ($this->parser !== null) + { + $item->parsed_class_code = $this->parser->code($item->main_class_code); + } + $item->code_name = $this->index_map_IndexName($item); + $item->_namespace = $this->index_map_NameSpace($item); + + $this->git->create( + $repo->organisation, // The owner name. + $repo->repository, // The repository name. + 'src/' . $item->guid . '/README.md', // The file path. + $this->itemReadme->get($item), // The file content. + 'Create ' . $item->system_name . ' readme file', // The commit message. + $repo->write_branch // The branch name. + ); + } + + /** + * check that we have a target repo of this item + * + * @param object $item The item + * @param object $repo The current repo + * + * @return bool + * @since 5.0.3 + */ + protected function targetRepo(object $item, object $repo): bool + { + if (!isset($item->approved) || $item->approved != 1 || + !isset($item->approved_paths) || !is_array($item->approved_paths)) + { + return false; + } + + $repo_path = "{$repo->organisation}/{$repo->repository}"; + + foreach ($item->approved_paths as $approved_path) + { + if ($repo_path === $approved_path) + { + return true; + } + } + + return false; + } + + /** + * Get the item name for the index values + * + * @param object $item + * + * @return string|null + * @since 5.0.3 + */ + protected function index_map_IndexName(object $item): ?string + { + $name = $item->name ?? null; + if ($name !== null) + { + return ClassfunctionHelper::safe( + $this->updatePlaceholders($name) + ); + } + + return null; + } + + /** + * Get the item type for the index values + * + * @param object $item + * + * @return string|null + * @since 5.0.3 + */ + protected function index_map_TypeName(object $item): ?string + { + return $item->type ?? null; + } + + /** + * Get the item code path for the index values + * + * @param object $item + * + * @return string|null + * @since 5.0.3 + */ + protected function index_map_CodePath(object $item): ?string + { + return $this->index_map_IndexPath($item) . '/code.php'; + } + + /** + * Get the item power path for the index values + * + * @param object $item + * + * @return string|null + * @since 5.0.3 + */ + protected function index_map_PowerPath(object $item): ?string + { + return $this->index_map_IndexPath($item) . '/code.power'; + } + + /** + * Get the item namespace for the index values + * + * @param object $item + * + * @return string|null + * @since 5.0.3 + */ + protected function index_map_NameSpace(object $item): ?string + { + return $this->getNamespace($item->namespace ?? '', $item->name ?? ''); + } + + /** + * Set the namespace for this power + * + * @param string $namespace The raw namespace + * @param string $className The class name + * + * @return string|null + * @since 5.0.3 + */ + protected function getNamespace(string $namespace, string $className): ?string + { + // set namespace + $namespace = $this->updatePlaceholders($namespace); + + // validate namespace + if (strpos($namespace, '\\') === false) + { + // we break out here + return null; + } + + // setup the path array + $path_array = (array) explode('\\', $namespace); + + // make sure it has two or more + if (ArrayHelper::check($path_array) <= 1) + { + // we break out here + return null; + } + + // get the file and class name (the last value in array) + $file_name = array_pop($path_array); + + // do we have src folders + if (strpos($file_name, '.') !== false) + { + // we have src folders in the namespace + $src_array = (array) explode('.', $file_name); + + // get the file and class name (the last value in array) + $file_name = array_pop($src_array); + + // namespace array + $namespace_array = [...$path_array, ...$src_array]; + } + else + { + // namespace array + $namespace_array = $path_array; + } + + // the last value is the same as the class name + if ($file_name !== $className) + { + // we break out here + return null; + } + + // make sure the arrays are namespace safe + $namespace_array = + array_map( + fn($val) => $this->getCleanNamespace($val), + $namespace_array + ); + + // set the actual class namespace + return implode('\\', $namespace_array); + } + + /** + * Get Clean Namespace without use or ; as part of the name space + * + * @param string $namespace The actual name space + * + * @return string + * @since 5.0.3 + */ + protected function getCleanNamespace(string $namespace): string + { + // trim possible (use) or (;) or (starting or ending \) added to the namespace + return NamespaceHelper::safe(str_replace(['use ', ';'], '', $namespace)); + } +} + diff --git a/src/caf559ee-8337-4f07-9e4a-394d4e06afdc/code.power b/src/caf559ee-8337-4f07-9e4a-394d4e06afdc/code.power new file mode 100644 index 0000000..84a1904 --- /dev/null +++ b/src/caf559ee-8337-4f07-9e4a-394d4e06afdc/code.power @@ -0,0 +1,756 @@ + /** + * Table Name + * + * @var string + * @since 5.0.3 + */ + protected string $table = 'power'; + + /** + * Area Name + * + * @var string + * @since 5.0.3 + */ + protected string $area = 'Super Power'; + + /** + * Prefix Key + * + * @var string + * @since 5.0.3 + */ + protected string $prefix_key = 'Super---'; + + /** + * The item map + * + * @var array + * @since 5.0.3 + */ + protected array $map = [ + 'add_head' => 'add_head', + 'description' => 'description', + 'extends' => 'extends', + 'extendsinterfaces' => 'extendsinterfaces', + 'guid' => 'guid', + 'head' => 'head', + 'use_selection' => 'use_selection', + 'implements' => 'implements', + 'load_selection' => 'load_selection', + 'name' => 'name', + 'power_version' => 'power_version', + 'system_name' => 'system_name', + 'type' => 'type', + 'namespace' => 'namespace', + 'composer' => 'composer', + 'add_licensing_template' => 'add_licensing_template', + 'licensing_template' => 'licensing_template', + 'main_class_code' => 'main_class_code' + ]; + + /** + * The index map + * + * @var array + * @since 5.0.3 + */ + protected array $index_map = [ + 'name' => 'index_map_IndexName', + 'type' => 'index_map_TypeName', + 'namespace' => 'index_map_NameSpace', + 'code' => 'index_map_CodePath', + 'power' => 'index_map_PowerPath', + 'settings' => 'index_map_IndexSettingsPath', + 'path' => 'index_map_IndexPath', + 'spk' => 'index_map_IndexKey', + 'guid' => 'index_map_IndexGUID' + ]; + + /** + * The item settings file path + * + * @var string + * @since 5.0.3 + */ + protected string $settings_path = 'settings.json'; + + /** + * The index settings file path + * + * @var string + * @since 5.0.3 + */ + protected string $index_settings_path = 'super-powers.json'; + + /** + * The Parser Class. + * + * @var Parser|null + * @since 5.0.2 + */ + protected ?Parser $parser; + + /** + * Constructor. + * + * @param array $repos The active repos + * @param Grep $grep The Grep Class. + * @param Items $items The Items Class. + * @param ItemReadme $itemReadme The Item Readme Class. + * @param MainReadme $mainReadme The Main Readme Class. + * @param Git $git The Contents Class. + * @param string|null $table The table name. + * @param string|null $settingsPath The settings path. + * @param string|null $settingsIndexPath The index settings path. + * @param Parser|null $parser The Parser Class. + * + * @since 3.2.2 + */ + public function __construct(array $repos, Grep $grep, Items $items, + ItemReadme $itemReadme, MainReadme $mainReadme, Git $git, + ?string $table = null, ?string $settingsPath = null, + ?string $settingsIndexPath = null, ?Parser $parser = null) + { + parent::__construct($repos, $grep, $items, $itemReadme, $mainReadme, + $git, $table, $settingsPath, $settingsIndexPath); + + $this->parser = $parser; + } + + /** + * Map a single item value (extends) + * + * @param object $item The item to be mapped + * @param array $item The bucket to to place new values + * @param string $map The item map to be mapped + * + * @return void + * @since 5.0.2 + */ + protected function mapItemValue_extends(object &$item, array &$power): void + { + if ($item->type !== 'interface') + { + $value = $item->extends ?? ''; + $extends_custom = $item->extends_custom ?? null; + if ($value == -1 && $extends_custom !== null) + { + $power['extends_name'] = ClassfunctionHelper::safe( + $this->updatePlaceholders((string) $extends_custom) + ); + $power['extends_custom'] = $extends_custom; + $power['extends'] = -1; + } + elseif (GuidHelper::valid($value)) + { + $name = GuidHelper::item($value, 'power', 'a.name', '[[[component]]]'); + if ($name !== null) + { + $power['extends_name'] = ClassfunctionHelper::safe( + $this->updatePlaceholders($name) + ); + } + } + else + { + $power['extends'] = ''; + } + // always rest these for normal classes + $power['extendsinterfaces'] = null; + $power['extendsinterfaces_custom'] = ''; + } + } + + /** + * Map a single item value (extendsinterfaces) + * + * @param object $item The item to be mapped + * @param array $item The bucket to to place new values + * @param string $map The item map to be mapped + * + * @return void + * @since 5.0.2 + */ + protected function mapItemValue_extendsinterfaces(object &$item, array &$power): void + { + if ($item->type === 'interface') + { + $values = $item->extendsinterfaces ?? null; + if (!empty($values)) + { + $values = (array) $values; + $extends_names = []; + $extendsinterfaces_custom = $item->extendsinterfaces_custom ?? null; + + foreach ($values as $value) + { + if ($value == -1 && StringHelper::check($extendsinterfaces_custom)) + { + $extends_names[] = ClassfunctionHelper::safe( + $this->updatePlaceholders($extendsinterfaces_custom) + ); + + $power['extendsinterfaces_custom'] = $extendsinterfaces_custom; + $extendsinterfaces_custom = null; + } + elseif (GuidHelper::valid($value)) + { + $name = GuidHelper::item($value, 'power', 'a.name', '[[[component]]]'); + if ($name !== null) + { + $extends_names[] = ClassfunctionHelper::safe( + $this->updatePlaceholders($name) + ); + } + } + } + + if ($extends_names !== []) + { + $power['extendsinterfaces'] = array_values($values); + $power['extends_name'] = implode(', ', $extends_names); + } + } + else + { + $power['extendsinterfaces'] = null; + $power['extendsinterfaces_custom'] = ''; + } + // always rest these for interfaces + $power['extends'] = ''; + $power['extends_custom'] = ''; + } + } + + /** + * Map a single item value (use_selection) + * + * @param object $item The item to be mapped + * @param array $item The bucket to to place new values + * @param string $map The item map to be mapped + * + * @return void + * @since 5.0.2 + */ + protected function mapItemValue_use_selection(object &$item, array &$power): void + { + $value = $item->use_selection ?? null; + if (!empty($value)) + { + $value = (array) $value; + $power['use_selection'] = $value; + } + else + { + $power['use_selection'] = null; + } + } + + /** + * Map a single item value (load_selection) + * + * @param object $item The item to be mapped + * @param array $item The bucket to to place new values + * @param string $map The item map to be mapped + * + * @return void + * @since 5.0.2 + */ + protected function mapItemValue_load_selection(object &$item, array &$power): void + { + $value = $item->load_selection ?? null; + if (!empty($value)) + { + $value = (array) $value; + $power['load_selection'] = $value; + } + else + { + $power['load_selection'] = null; + } + } + + /** + * Map a single item value (composer) + * + * @param object $item The item to be mapped + * @param array $item The bucket to to place new values + * @param string $map The item map to be mapped + * + * @return void + * @since 5.0.2 + */ + protected function mapItemValue_composer(object &$item, array &$power): void + { + $value = $item->composer ?? null; + if (!empty($value)) + { + $value = (array) $value; + $power['composer'] = array_values($value); + } + else + { + $power['composer'] = ''; + } + } + + /** + * Map a single item value (implements) + * + * @param object $item The item to be mapped + * @param array $item The bucket to to place new values + * @param string $map The item map to be mapped + * + * @return void + * @since 5.0.2 + */ + protected function mapItemValue_implements(object &$item, array &$power): void + { + $values = $item->implements ?? ''; + if (!empty($values)) + { + $values = (array) $values; + $implement_names = []; + $implements_custom = $item->implements_custom ?? null; + + foreach ($values as $value) + { + if ($value == -1 && StringHelper::check($implements_custom)) + { + $implement_names[] = ClassfunctionHelper::safe( + $this->updatePlaceholders($implements_custom) + ); + $implements_custom = null; + } + elseif (GuidHelper::valid($value)) + { + $name = GuidHelper::item($value, 'power', 'a.name', '[[[component]]]'); + if ($name !== null) + { + $implement_names[] = ClassfunctionHelper::safe( + $this->updatePlaceholders($name) + ); + } + } + } + + if ($implement_names !== []) + { + $power['implements'] = array_values($values); + $power['implement_names'] = $implement_names; + } + else + { + $power['implements'] = null; + } + } + } + + /** + * update an existing item (if changed) + * + * @param object $item + * @param object $existing + * @param object $repo + * + * @return bool + * @since 5.0.3 + */ + protected function updateItem(object $item, object $existing, object $repo): bool + { + // make sure there was a change + $sha = $existing->params->source[$repo->guid . '-settings'] ?? null; + $_existing = $this->mapItem($existing); + + if ($sha === null || $this->areObjectsEqual($item, $_existing)) + { + return false; + } + else + { + // strip these values form the settings + $code = (string) $item->main_class_code ?? ''; + $extends_name = (string) $item->extends_name ?? ''; + $implement_names = (string) $item->implement_names ?? ''; + unset($item->main_class_code); + unset($item->extends_name); + unset($item->implement_names); + + $this->git->update( + $repo->organisation, // The owner name. + $repo->repository, // The repository name. + 'src/' . $item->guid . '/' . $this->getSettingsPath(), // The file path. + json_encode($item, JSON_PRETTY_PRINT), // The file content. + 'Update ' . $item->system_name . ' settings', // The commit message. + $sha, // The blob SHA of the old file. + $repo->write_branch // The branch name. + ); + + $item->main_class_code = $code; + $item->extends_name = $extends_name; + $item->implement_names = $implement_names; + } + + return $this->updatePower($item, $existing, $repo); + } + + /** + * update an existing power code (if changed) + * + * @param object $item + * @param object $existing + * @param object $repo + * + * @return bool + * @since 5.0.3 + */ + protected function updatePower(object $item, object $existing, object $repo): bool + { + // make sure there was a change + $sha = $existing->params->source[$repo->guid . '-power'] ?? null; + + if ($sha === null) + { + return false; + } + + // Calculate the new SHA from the current content + $power = $item->main_class_code ?? ''; + $newSha = sha1("blob " . strlen($power) . "\0" . $power); + + // Check if the new SHA matches the existing SHA + if ($sha === $newSha) + { + return false; + } + + $this->git->update( + $repo->organisation, // The owner name. + $repo->repository, // The repository name. + 'src/' . $item->guid . '/code.power', // The file path. + $power, // The file content. + 'Update ' . $item->system_name . ' code', // The commit message. + $sha, // The blob SHA of the old file. + $repo->write_branch // The branch name. + ); + + return true; + } + + /** + * create a new item + * + * @param object $item + * @param object $repo + * + * @return void + * @since 5.0.3 + */ + protected function createItem(object $item, object $repo): void + { + // strip these values form the settings + $code = (string) $item->main_class_code ?? ''; + $extends_name = (string) $item->extends_name ?? ''; + $implement_names = (string) $item->implement_names ?? ''; + unset($item->main_class_code); + unset($item->extends_name); + unset($item->implement_names); + + $this->git->create( + $repo->organisation, // The owner name. + $repo->repository, // The repository name. + 'src/' . $item->guid . '/' . $this->getSettingsPath(), // The file path. + json_encode($item, JSON_PRETTY_PRINT), // The file content. + 'Create ' . $item->system_name . ' settings', // The commit message. + $repo->write_branch // The branch name. + ); + + $item->main_class_code = $code; + $item->extends_name = $extends_name; + $item->implement_names = $implement_names; + + $this->createPower($item, $repo); + } + + /** + * create a new power + * + * @param object $item + * @param object $repo + * + * @return void + * @since 5.0.3 + */ + protected function createPower(object $item, object $repo): void + { + $this->git->create( + $repo->organisation, // The owner name. + $repo->repository, // The repository name. + 'src/' . $item->guid . '/code.power', // The file path. + $item->main_class_code, // The file content. + 'Create ' . $item->system_name . ' code', // The commit message. + $repo->write_branch // The branch name. + ); + } + + /** + * update an existing item readme + * + * @param object $item + * @param object $existing + * @param object $repo + * + * @return void + * @since 5.0.3 + */ + protected function updateItemReadme(object $item, object $existing, object $repo): void + { + // make sure there was a change + $sha = $existing->params->source[$repo->guid . '-readme'] ?? null; + if ($sha === null) + { + return; + } + + if ($this->parser !== null) + { + $item->parsed_class_code = $this->parser->code($item->main_class_code); + } + $item->code_name = $this->index_map_IndexName($item); + $item->_namespace = $this->index_map_NameSpace($item); + + $readme = $this->itemReadme->get($item); + $newSha = sha1("blob " . strlen($readme) . "\0" . $readme); + + // Check if the new SHA matches the existing SHA + if ($sha === $newSha) + { + return; + } + + $this->git->update( + $repo->organisation, // The owner name. + $repo->repository, // The repository name. + 'src/' . $item->guid . '/README.md', // The file path. + $readme, // The file content. + 'Update ' . $item->system_name . ' readme file', // The commit message. + $sha, // The blob SHA of the old file. + $repo->write_branch // The branch name. + ); + } + + /** + * create a new item readme + * + * @param object $item + * @param object $repo + * + * @return void + * @since 5.0.3 + */ + protected function createItemReadme(object $item, object $repo): void + { + if ($this->parser !== null) + { + $item->parsed_class_code = $this->parser->code($item->main_class_code); + } + $item->code_name = $this->index_map_IndexName($item); + $item->_namespace = $this->index_map_NameSpace($item); + + $this->git->create( + $repo->organisation, // The owner name. + $repo->repository, // The repository name. + 'src/' . $item->guid . '/README.md', // The file path. + $this->itemReadme->get($item), // The file content. + 'Create ' . $item->system_name . ' readme file', // The commit message. + $repo->write_branch // The branch name. + ); + } + + /** + * check that we have a target repo of this item + * + * @param object $item The item + * @param object $repo The current repo + * + * @return bool + * @since 5.0.3 + */ + protected function targetRepo(object $item, object $repo): bool + { + if (!isset($item->approved) || $item->approved != 1 || + !isset($item->approved_paths) || !is_array($item->approved_paths)) + { + return false; + } + + $repo_path = "{$repo->organisation}/{$repo->repository}"; + + foreach ($item->approved_paths as $approved_path) + { + if ($repo_path === $approved_path) + { + return true; + } + } + + return false; + } + + /** + * Get the item name for the index values + * + * @param object $item + * + * @return string|null + * @since 5.0.3 + */ + protected function index_map_IndexName(object $item): ?string + { + $name = $item->name ?? null; + if ($name !== null) + { + return ClassfunctionHelper::safe( + $this->updatePlaceholders($name) + ); + } + + return null; + } + + /** + * Get the item type for the index values + * + * @param object $item + * + * @return string|null + * @since 5.0.3 + */ + protected function index_map_TypeName(object $item): ?string + { + return $item->type ?? null; + } + + /** + * Get the item code path for the index values + * + * @param object $item + * + * @return string|null + * @since 5.0.3 + */ + protected function index_map_CodePath(object $item): ?string + { + return $this->index_map_IndexPath($item) . '/code.php'; + } + + /** + * Get the item power path for the index values + * + * @param object $item + * + * @return string|null + * @since 5.0.3 + */ + protected function index_map_PowerPath(object $item): ?string + { + return $this->index_map_IndexPath($item) . '/code.power'; + } + + /** + * Get the item namespace for the index values + * + * @param object $item + * + * @return string|null + * @since 5.0.3 + */ + protected function index_map_NameSpace(object $item): ?string + { + return $this->getNamespace($item->namespace ?? '', $item->name ?? ''); + } + + /** + * Set the namespace for this power + * + * @param string $namespace The raw namespace + * @param string $className The class name + * + * @return string|null + * @since 5.0.3 + */ + protected function getNamespace(string $namespace, string $className): ?string + { + // set namespace + $namespace = $this->updatePlaceholders($namespace); + + // validate namespace + if (strpos($namespace, '\\') === false) + { + // we break out here + return null; + } + + // setup the path array + $path_array = (array) explode('\\', $namespace); + + // make sure it has two or more + if (ArrayHelper::check($path_array) <= 1) + { + // we break out here + return null; + } + + // get the file and class name (the last value in array) + $file_name = array_pop($path_array); + + // do we have src folders + if (strpos($file_name, '.') !== false) + { + // we have src folders in the namespace + $src_array = (array) explode('.', $file_name); + + // get the file and class name (the last value in array) + $file_name = array_pop($src_array); + + // namespace array + $namespace_array = [...$path_array, ...$src_array]; + } + else + { + // namespace array + $namespace_array = $path_array; + } + + // the last value is the same as the class name + if ($file_name !== $className) + { + // we break out here + return null; + } + + // make sure the arrays are namespace safe + $namespace_array = + array_map( + fn($val) => $this->getCleanNamespace($val), + $namespace_array + ); + + // set the actual class namespace + return implode('\\', $namespace_array); + } + + /** + * Get Clean Namespace without use or ; as part of the name space + * + * @param string $namespace The actual name space + * + * @return string + * @since 5.0.3 + */ + protected function getCleanNamespace(string $namespace): string + { + // trim possible (use) or (;) or (starting or ending \) added to the namespace + return NamespaceHelper::safe(str_replace(['use ', ';'], '', $namespace)); + } \ No newline at end of file diff --git a/src/caf559ee-8337-4f07-9e4a-394d4e06afdc/settings.json b/src/caf559ee-8337-4f07-9e4a-394d4e06afdc/settings.json new file mode 100644 index 0000000..08d34a2 --- /dev/null +++ b/src/caf559ee-8337-4f07-9e4a-394d4e06afdc/settings.json @@ -0,0 +1,66 @@ +{ + "add_head": "0", + "add_licensing_template": "2", + "extends": "eb7d69c2-4ee9-4bd0-aacc-ab51a12be895", + "guid": "caf559ee-8337-4f07-9e4a-394d4e06afdc", + "implements": [ + "e335dd61-c2f9-4536-8ed9-aec5edee0b26" + ], + "load_selection": null, + "name": "Set", + "power_version": "1.0.0", + "system_name": "JCB.Power.Remote.Set", + "type": "final class", + "use_selection": { + "use_selection0": { + "use": "c182506a-ab84-439c-b962-1e606b58d545", + "as": "Grep" + }, + "use_selection1": { + "use": "7212e4db-371f-4cfd-8122-32e9bb100d83", + "as": "Items" + }, + "use_selection2": { + "use": "65a0f81a-14fc-4870-9382-b8d830b19937", + "as": "ItemReadme" + }, + "use_selection3": { + "use": "217416f6-24cf-41c0-b18e-11086111d447", + "as": "MainReadme" + }, + "use_selection4": { + "use": "d1de5d5b-bf29-4031-8094-76c4f6c75900", + "as": "Git" + }, + "use_selection5": { + "use": "95d0e03f-24fd-4412-bc2e-f0899fcc3205", + "as": "default" + }, + "use_selection6": { + "use": "ce8cf834-6bac-44fb-941c-861f7e046cc0", + "as": "default" + }, + "use_selection7": { + "use": "0a59c65c-9daf-4bc9-baf4-e063ff9e6a8a", + "as": "default" + }, + "use_selection8": { + "use": "1f28cb53-60d9-4db1-b517-3c7dc6b429ef", + "as": "default" + }, + "use_selection9": { + "use": "30c5b4c2-f75f-4d15-869a-f8bfedd87358", + "as": "default" + }, + "use_selection10": { + "use": "9c513baf-b279-43fd-ae29-a585c8cbc4f0", + "as": "default" + } + }, + "extendsinterfaces": null, + "namespace": "[[[NamespacePrefix]]]\\Joomla\\[[[ComponentNamespace]]].Power.Remote.Set", + "description": "Set Power based on global unique ids to remote repository\r\n\r\n@since 5.0.2", + "licensing_template": "\/**\r\n * @package Joomla.Component.Builder\r\n *\r\n * @created 4th September, 2022\r\n * @author Llewellyn van der Merwe \r\n * @git Joomla Component Builder \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/d05c22be-9641-47fb-8a7b-063c43e7f1bf/README.md b/src/d05c22be-9641-47fb-8a7b-063c43e7f1bf/README.md new file mode 100644 index 0000000..340318c --- /dev/null +++ b/src/d05c22be-9641-47fb-8a7b-063c43e7f1bf/README.md @@ -0,0 +1,181 @@ +``` +██████╗ ██████╗ ██╗ ██╗███████╗██████╗ +██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗ +██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝ +██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗ +██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║ +╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝ +``` +# class Structure (Details) +> namespace: **VDM\Joomla\Componentbuilder\Compiler\Joomlaplugin\JoomlaFive** + +```uml +@startuml +class Structure #Gold { + # Plugin $plugin + # Component $component + # Config $config + # Registry $registry + # Dispenser $dispenser + # Event $event + # Counter $counter + # Folder $folder + # File $file + # Files $files + # Placeholder $placeholder + # string $NamespacePrefix + # string $ComponentNamespace + + __construct(Plugin $plugin, Component $component, ...) + + build() : void + # getXML(object $plugin) : string + # pluginPath(object $plugin) : void + # setMainClassFile(object $plugin) : void + # setServiceProviderClassFile(object $plugin) : void + # setMainXmlFile(object $plugin) : void + # setInstallScript(object $plugin) : void + # setReadme(object $plugin) : void + # setForms(object $plugin) : void + # setSQL(object $plugin) : void + # setFiles(object $plugin) : void + # setFolders(object $plugin) : void + # setUrls(object $plugin) : void +} + +note right of Structure::__construct + Constructor. + + since: 3.2.0 + + arguments: + Plugin $plugin + Component $component + Config $config + Registry $registry + Dispenser $dispenser + Event $event + Counter $counter + Folder $folder + File $file + Files $files + Placeholder $placeholder +end note + +note left of Structure::build + Build the Plugins files, folders, url's and config + + since: 3.2.0 + return: void +end note + +note right of Structure::getXML + get the plugin xml template + + since: 3.2.0 + return: string +end note + +note left of Structure::pluginPath + set the plugin path + + since: 3.2.0 + return: void +end note + +note right of Structure::setMainClassFile + set the main class path + + since: 3.2.0 + return: void +end note + +note left of Structure::setServiceProviderClassFile + set the service provider path + + since: 3.2.0 + return: void +end note + +note right of Structure::setMainXmlFile + set the main xml file + + since: 3.2.0 + return: void +end note + +note left of Structure::setInstallScript + set the install script file + + since: 3.2.0 + return: void +end note + +note right of Structure::setReadme + set the readme file + + since: 3.2.0 + return: void +end note + +note left of Structure::setForms + set the form files and folders + + since: 3.2.0 + return: void +end note + +note right of Structure::setSQL + set the sql stuff + + since: 3.2.0 + return: void +end note + +note left of Structure::setFiles + set the files + + since: 3.2.0 + return: void +end note + +note right of Structure::setFolders + set the folders + + since: 3.2.0 + return: void +end note + +note left of Structure::setUrls + set the urls + + since: 3.2.0 + return: void +end note + +@enduml +``` + +The Power feature in JCB allows you to write PHP classes and their implementations, making it easy to include them in your Joomla project. JCB handles linking, autoloading, namespacing, and folder structure creation for you. + +By using the SPK (Super Power Key) in your custom code (replacing the class name in your code with the SPK), JCB will automatically pull the power from the repository into your project. This makes it available in your JCB instance, allowing you to edit it and include the class in your generated Joomla component. + +JCB uses placeholders like [[[`NamespacePrefix`]]] and [[[`ComponentNamespace`]]] in namespacing to prevent collisions and improve reusability across different JCB systems. You can also set the **JCB powers path** globally or per component under the **Dynamic Integration** tab, providing flexibility and easy maintainability. + +To add this specific Power to your project in JCB: + +> simply use this SPK +``` +Super---d05c22be_9641_47fb_8a7b_063c43e7f1bf---Power +``` +> remember to replace the `---` with `___` to activate this Power in your code + +--- +``` + ██╗ ██████╗██████╗ + ██║██╔════╝██╔══██╗ + ██║██║ ██████╔╝ +██ ██║██║ ██╔══██╗ +╚█████╔╝╚██████╗██████╔╝ + ╚════╝ ╚═════╝╚═════╝ +``` +> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder) + diff --git a/src/d05c22be-9641-47fb-8a7b-063c43e7f1bf/code.php b/src/d05c22be-9641-47fb-8a7b-063c43e7f1bf/code.php new file mode 100644 index 0000000..a3c3707 --- /dev/null +++ b/src/d05c22be-9641-47fb-8a7b-063c43e7f1bf/code.php @@ -0,0 +1,830 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Componentbuilder\Compiler\Joomlaplugin\JoomlaFive; + + +use VDM\Joomla\Componentbuilder\Compiler\Interfaces\PluginDataInterface as Plugin; +use VDM\Joomla\Componentbuilder\Compiler\Component; +use VDM\Joomla\Componentbuilder\Compiler\Config; +use VDM\Joomla\Componentbuilder\Compiler\Registry; +use VDM\Joomla\Componentbuilder\Compiler\Customcode\Dispenser; +use VDM\Joomla\Componentbuilder\Compiler\Interfaces\EventInterface as Event; +use VDM\Joomla\Componentbuilder\Compiler\Utilities\Counter; +use VDM\Joomla\Componentbuilder\Compiler\Utilities\Folder; +use VDM\Joomla\Componentbuilder\Compiler\Utilities\File; +use VDM\Joomla\Componentbuilder\Compiler\Utilities\Files; +use VDM\Joomla\Componentbuilder\Compiler\Placeholder; +use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent; +use VDM\Joomla\Componentbuilder\Compiler\Utilities\Placefix; +use VDM\Joomla\Componentbuilder\Compiler\Utilities\Line; +use VDM\Joomla\Utilities\ArrayHelper; +use VDM\Joomla\Utilities\ObjectHelper; +use VDM\Joomla\Utilities\StringHelper; +use VDM\Joomla\Utilities\FileHelper; +use VDM\Joomla\Componentbuilder\Interfaces\Plugin\StructureInterface; + + +/** + * Joomla 5 Plugin Builder Class + * + * @since 5.0.2 + */ +class Structure implements StructureInterface +{ + /** + * The Data Class. + * + * @var Plugin + * @since 3.2.0 + */ + protected Plugin $plugin; + + /** + * The Component Class. + * + * @var Component + * @since 3.2.0 + */ + protected Component $component; + + /** + * The Config Class. + * + * @var Config + * @since 3.2.0 + */ + protected Config $config; + + /** + * The Registry Class. + * + * @var Registry + * @since 3.2.0 + */ + protected Registry $registry; + + /** + * The Dispenser Class. + * + * @var Dispenser + * @since 3.2.0 + */ + protected Dispenser $dispenser; + + /** + * The EventInterface Class. + * + * @var Event + * @since 3.2.0 + */ + protected Event $event; + + /** + * The Counter Class. + * + * @var Counter + * @since 3.2.0 + */ + protected Counter $counter; + + /** + * The Folder Class. + * + * @var Folder + * @since 3.2.0 + */ + protected Folder $folder; + + /** + * The File Class. + * + * @var File + * @since 3.2.0 + */ + protected File $file; + + /** + * The Files Class. + * + * @var Files + * @since 3.2.0 + */ + protected Files $files; + + /** + * The Placeholder Class. + * + * @var Placeholder + * @since 5.0.0 + */ + protected Placeholder $placeholder; + + /** + * The Namespace Prefix + * + * @var string + * @since 5.0.0 + */ + protected string $NamespacePrefix; + + /** + * The Component Namespace (in code) + * + * @var string + * @since 3.2.0 + */ + protected string $ComponentNamespace; + + /** + * Constructor. + * + * @param Plugin $plugin The Data Class. + * @param Component $component The Component Class. + * @param Config $config The Config Class. + * @param Registry $registry The Registry Class. + * @param Dispenser $dispenser The Dispenser Class. + * @param Event $event The EventInterface Class. + * @param Counter $counter The Counter Class. + * @param Folder $folder The Folder Class. + * @param File $file The File Class. + * @param Files $files The Files Class. + * @param Placeholder $placeholder The Placeholder Class. + * + * @since 3.2.0 + */ + public function __construct(Plugin $plugin, Component $component, Config $config, + Registry $registry, Dispenser $dispenser, Event $event, + Counter $counter, Folder $folder, File $file, + Files $files, Placeholder $placeholder) + { + $this->plugin = $plugin; + $this->component = $component; + $this->config = $config; + $this->registry = $registry; + $this->dispenser = $dispenser; + $this->event = $event; + $this->counter = $counter; + $this->folder = $folder; + $this->file = $file; + $this->files = $files; + $this->placeholder = $placeholder; + + // set some global values + $this->NamespacePrefix = $this->placeholder->get('NamespacePrefix'); + $this->ComponentNamespace = $this->placeholder->get('ComponentNamespace'); + } + + /** + * Build the Plugins files, folders, url's and config + * + * @return void + * @since 3.2.0 + */ + public function build() + { + if ($this->plugin->exists()) + { + // for plugin event TODO change event api signatures + $component_context = $this->config->component_context; + $plugins = $this->plugin->get(); + + // Trigger Event: jcb_ce_onBeforeSetPlugins + $this->event->trigger( + 'jcb_ce_onBeforeBuildPlugins', + array(&$component_context, &$plugins) + ); + + foreach ($plugins as $plugin) + { + if (ObjectHelper::check($plugin) + && isset($plugin->folder_name) + && StringHelper::check($plugin->folder_name)) + { + // plugin path + $this->pluginPath($plugin); + + // create src folder + $this->folder->create($plugin->folder_path . '/src'); + + // set the plugin paths + $this->registry->set('dynamic_paths.' . $plugin->key, $plugin->folder_path); + + // make sure there is no old build + $this->folder->remove($plugin->folder_path); + + // creat the main component folder + $this->folder->create($plugin->folder_path); + + // set main class file + $this->setMainClassFile($plugin); + + // set service provider class file + $this->setServiceProviderClassFile($plugin); + + // set main xml file + $this->setMainXmlFile($plugin); + + // set install script if needed + $this->setInstallScript($plugin); + + // set readme if found + $this->setReadme($plugin); + + // set fields & rules folders if needed + if (isset($plugin->fields_rules_paths) + && $plugin->fields_rules_paths == 2) + { + // create fields folder + $this->folder->create($plugin->folder_path . '/src/Field'); + + // create rules folder + $this->folder->create($plugin->folder_path . '/src/Rule'); + } + + // set forms folder if needed + $this->setForms($plugin); + + // set SQL stuff if needed + $this->setSQL($plugin); + + // create the language folder path + $this->folder->create($plugin->folder_path . '/language'); + + // also create the lang tag folder path + $this->folder->create( + $plugin->folder_path . '/language/' . $this->config->get('lang_tag', 'en-GB') + ); + + // check if this plugin has files + $this->setFiles($plugin); + + // check if this plugin has folders + $this->setFolders($plugin); + + // check if this plugin has urls + $this->setUrls($plugin); + } + } + } + } + + /** + * get the plugin xml template + * + * @param object $plugin The plugin object + * + * @return string + * @since 3.2.0 + */ + protected function getXML(object $plugin): string + { + $xml = ''; + $xml .= PHP_EOL . ''; + $xml .= PHP_EOL . Indent::_(1) . '' . $plugin->lang_prefix + . ''; + $xml .= PHP_EOL . Indent::_(1) . '' . Placefix::_h('BUILDDATE') . ''; + $xml .= PHP_EOL . Indent::_(1) . '' . Placefix::_h('AUTHOR') . ''; + $xml .= PHP_EOL . Indent::_(1) . '' . Placefix::_h('AUTHOREMAIL') . ''; + $xml .= PHP_EOL . Indent::_(1) . '' . Placefix::_h('AUTHORWEBSITE') . ''; + $xml .= PHP_EOL . Indent::_(1) . '' . Placefix::_h('COPYRIGHT') . ''; + $xml .= PHP_EOL . Indent::_(1) . '' . Placefix::_h('LICENSE') . ''; + $xml .= PHP_EOL . Indent::_(1) . '' . $plugin->plugin_version + . ''; + $xml .= PHP_EOL . Indent::_(1) . '' . "{$this->NamespacePrefix}\\Plugin\\{$plugin->group_namespace}\\{$plugin->namespace}" + . ''; + $xml .= PHP_EOL . Indent::_(1) . '' . $plugin->lang_prefix + . '_XML_DESCRIPTION'; + $xml .= Placefix::_h('MAINXML'); + $xml .= PHP_EOL . ''; + + return $xml; + } + + /** + * set the plugin path + * + * @param object $plugin The plugin object + * + * @return void + * @since 3.2.0 + */ + protected function pluginPath(object &$plugin): void + { + $plugin->folder_path = $this->config->get('compiler_path', JPATH_COMPONENT_ADMINISTRATOR . '/compiler') . '/' + . $plugin->folder_name; + } + + /** + * set the main class path + * + * @param object $plugin The plugin object + * + * @return void + * @since 3.2.0 + */ + protected function setMainClassFile(object $plugin): void + { + // create extension folder + $this->folder->create($plugin->folder_path . '/src/Extension'); + + $file_details = [ + 'path' => $plugin->folder_path . '/src/Extension/' . $plugin->class_file_name . '.php', + 'name' => $plugin->class_file_name . '.php', + 'zip' => 'src/Extension/' . $plugin->class_file_name . '.php' + ]; + + $this->file->write( + $file_details['path'], + 'NamespacePrefix}\\Plugin\\{$plugin->group_namespace}\\{$plugin->namespace}\\Extension;" . + PHP_EOL . PHP_EOL . Placefix::_h('EXTENSION_CLASS_HEADER') . + PHP_EOL . PHP_EOL . '// No direct access to this file' . PHP_EOL . + "defined('_JEXEC') or die('Restricted access');" . + PHP_EOL . PHP_EOL . + Placefix::_h('EXTENSION_CLASS') + ); + + $this->files->appendArray($plugin->key, $file_details); + + // count the file created + $this->counter->file++; + } + + /** + * set the service provider path + * + * @param object $plugin The plugin object + * + * @return void + * @since 3.2.0 + */ + protected function setServiceProviderClassFile(object $plugin): void + { + // create services folder + $this->folder->create($plugin->folder_path . '/services'); + + $file_details = [ + 'path' => $plugin->folder_path . '/services/provider.php', + 'name' => 'provider.php', + 'zip' => 'services/provider.php' + ]; + + $this->file->write( + $file_details['path'], + 'files->appendArray($plugin->key, $file_details); + + // count the file created + $this->counter->file++; + } + + /** + * set the main xml file + * + * @param object $plugin The plugin object + * + * @return void + * @since 3.2.0 + */ + protected function setMainXmlFile(object $plugin): void + { + $file_details = [ + 'path' => $plugin->folder_path . '/' . $plugin->file_name . '.xml', + 'name' => $plugin->file_name . '.xml', + 'zip' => $plugin->file_name . '.xml' + ]; + + $this->file->write( + $file_details['path'], + $this->getXML($plugin) + ); + + $this->files->appendArray($plugin->key, $file_details); + + // count the file created + $this->counter->file++; + } + + /** + * set the install script file + * + * @param object $plugin The plugin object + * + * @return void + * @since 3.2.0 + */ + protected function setInstallScript(object $plugin): void + { + if ($plugin->add_install_script) + { + $file_details = [ + 'path' => $plugin->folder_path . '/script.php', + 'name' => 'script.php', + 'zip' => 'script.php' + ]; + + $this->file->write( + $file_details['path'], + 'files->appendArray($plugin->key, $file_details); + + // count the file created + $this->counter->file++; + } + } + + /** + * set the readme file + * + * @param object $plugin The plugin object + * + * @return void + * @since 3.2.0 + */ + protected function setReadme(object $plugin): void + { + if ($plugin->addreadme) + { + $file_details = [ + 'path' => $plugin->folder_path . '/README.md', + 'name' => 'README.md', + 'zip' => 'README.md' + ]; + + $this->file->write($file_details['path'], $plugin->readme); + $this->files->appendArray($plugin->key, $file_details); + + // count the file created + $this->counter->file++; + } + } + + /** + * set the form files and folders + * + * @param object $plugin The plugin object + * + * @return void + * @since 3.2.0 + */ + protected function setForms(object $plugin): void + { + if (isset($plugin->form_files) + && ArrayHelper::check($plugin->form_files)) + { + $Group = ucfirst((string) $plugin->group); + $FileName = $plugin->file_name; + + // create forms folder + $this->folder->create($plugin->folder_path . '/forms'); + + // set the template files + foreach ($plugin->form_files as $file => $fields) + { + // set file details + $file_details = [ + 'path' => $plugin->folder_path . '/forms/' . $file . '.xml', + 'name' => $file . '.xml', + 'zip' => 'forms/' . $file . '.xml' + ]; + + // build basic XML + $xml = ''; + $xml .= PHP_EOL . ''; + + // search if we must add the component path + $add_component_path = false; + foreach ($fields as $field_name => $fieldsets) + { + if (!$add_component_path) + { + foreach ($fieldsets as $fieldset => $field) + { + if (!$add_component_path + && isset($plugin->fieldsets_paths[$file . $field_name . $fieldset]) + && $plugin->fieldsets_paths[$file. $field_name . $fieldset] == 1) + { + $add_component_path = true; + } + } + } + } + + // only add if part of the component field types path is required + if ($add_component_path) + { + $xml .= PHP_EOL . ''; + } + else + { + $xml .= PHP_EOL . '
'; + } + + // add the fields + foreach ($fields as $field_name => $fieldsets) + { + // check if we have an double fields naming set + $field_name_inner = ''; + $field_name_outer = $field_name; + if (strpos((string)$field_name, '.') !== false) + { + $field_names = explode('.', (string)$field_name); + if (count((array)$field_names) == 2) + { + $field_name_outer = $field_names[0]; + $field_name_inner = $field_names[1]; + } + } + $xml .= PHP_EOL . Indent::_(1) + . ''; + foreach ($fieldsets as $fieldset => $field) + { + // default to the field set name + $label = $fieldset; + if (isset($plugin->fieldsets_label[$file . $field_name . $fieldset])) + { + $label = $plugin->fieldsets_label[$file . $field_name . $fieldset]; + } + + // add path to plugin rules and custom fields + if (isset($plugin->fieldsets_paths[$file . $field_name . $fieldset]) + && ($plugin->fieldsets_paths[$file . $field_name . $fieldset] == 2 + || $plugin->fieldsets_paths[$file . $field_name . $fieldset] == 3)) + { + if (!isset($plugin->add_rule_path[$file . $field_name . $fieldset])) + { + $plugin->add_rule_path[$file . $field_name . $fieldset] = + "{$this->NamespacePrefix}\\Plugin\\{$Group}\\{$FileName}\\Rule"; + } + + if (!isset($plugin->add_field_path[$file . $field_name . $fieldset])) + { + $plugin->add_field_path[$file . $field_name . $fieldset] = + "{$this->NamespacePrefix}\\Plugin\\{$Group}\\{$FileName}\\Field"; + } + } + + // add path to plugin rules and custom fields + if (isset($plugin->add_rule_path[$file . $field_name . $fieldset]) + || isset($plugin->add_field_path[$file . $field_name . $fieldset])) + { + $xml .= PHP_EOL . Indent::_(1) . ''; + + $xml .= PHP_EOL . Indent::_(1) . '
add_rule_path[$file . $field_name . $fieldset])) + { + $xml .= PHP_EOL . Indent::_(2) + . 'addrulepath="' . $plugin->add_rule_path[$file . $field_name . $fieldset] . '"'; + } + + if (isset($plugin->add_field_path[$file . $field_name . $fieldset])) + { + $xml .= PHP_EOL . Indent::_(2) + . 'addfieldpath="' . $plugin->add_field_path[$file . $field_name . $fieldset] . '"'; + } + + $xml .= PHP_EOL . Indent::_(1) . '>'; + } + else + { + $xml .= PHP_EOL . Indent::_(1) . '
'; + } + + // check if we have an inner field set + if (StringHelper::check($field_name_inner)) + { + $xml .= PHP_EOL . Indent::_(1) + . ''; + } + + // add the placeholder of the fields + $xml .= Placefix::_h('FIELDSET_' . $file + . $field_name . $fieldset); + + // check if we have an inner field set + if (StringHelper::check($field_name_inner)) + { + $xml .= PHP_EOL . Indent::_(1) + . ''; + } + $xml .= PHP_EOL . Indent::_(1) + . '
'; + } + $xml .= PHP_EOL . Indent::_(1) . ''; + } + $xml .= PHP_EOL . ''; + + // add xml to file + $this->file->write($file_details['path'], $xml); + $this->files->appendArray($plugin->key, $file_details); + + // count the file created + $this->counter->file++; + } + } + } + + /** + * set the sql stuff + * + * @param object $plugin The plugin object + * + * @return void + * @since 3.2.0 + */ + protected function setSQL(object $plugin): void + { + if ($plugin->add_sql || $plugin->add_sql_uninstall) + { + // create SQL folder + $this->folder->create($plugin->folder_path . '/sql'); + + // create mysql folder + $this->folder->create( + $plugin->folder_path . '/sql/mysql' + ); + + // now set the install file + if ($plugin->add_sql) + { + $this->file->write( + $plugin->folder_path . '/sql/mysql/install.sql', + $plugin->sql + ); + + // count the file created + $this->counter->file++; + } + + // now set the uninstall file + if ($plugin->add_sql_uninstall) + { + $this->file->write( + $plugin->folder_path + . '/sql/mysql/uninstall.sql', + $plugin->sql_uninstall + ); + + // count the file created + $this->counter->file++; + } + } + } + + /** + * set the files + * + * @param object $plugin The plugin object + * + * @return void + * @since 3.2.0 + */ + protected function setFiles(object $plugin): void + { + if (isset($plugin->files) && ArrayHelper::check($plugin->files)) + { + // add to component files + foreach ($plugin->files as $file) + { + // set the path finder + $file['target_type'] = $plugin->target_type; + $file['target_id'] = $plugin->id; + + $this->component->appendArray('files', $file); + } + } + } + + /** + * set the folders + * + * @param object $plugin The plugin object + * + * @return void + * @since 3.2.0 + */ + protected function setFolders(object $plugin): void + { + if (isset($plugin->folders) && ArrayHelper::check($plugin->folders)) + { + // add to component folders + foreach ($plugin->folders as $folder) + { + // set the path finder + $folder['target_type'] = $plugin->target_type; + $folder['target_id'] = $plugin->id; + + $this->component->appendArray('folders', $folder); + } + } + } + + /** + * set the urls + * + * @param object $plugin The plugin object + * + * @return void + * @since 3.2.0 + */ + protected function setUrls(object &$plugin): void + { + if (isset($plugin->urls) && ArrayHelper::check($plugin->urls)) + { + // add to component urls + foreach ($plugin->urls as &$url) + { + // should we add the local folder + if (isset($url['type']) && $url['type'] > 1 + && isset($url['url']) + && StringHelper::check($url['url'])) + { + // set file name + $fileName = basename((string)$url['url']); + + // get the file contents + $data = FileHelper::getContent( + $url['url'] + ); + + // build sub path + if (strpos($fileName, '.js') !== false) + { + $path = '/js'; + } + elseif (strpos($fileName, '.css') !== false) + { + $path = '/css'; + } + else + { + $path = ''; + } + + // create sub media folder path if not set + $this->folder->create( + $plugin->folder_path . $path + ); + + // set the path to plugin file + $url['path'] = $plugin->folder_path . $path + . '/' . $fileName; // we need this for later + + // write data to path + $this->file->write($url['path'], $data); + + // count the file created + $this->counter->file++; + } + } + } + } +} + diff --git a/src/d05c22be-9641-47fb-8a7b-063c43e7f1bf/code.power b/src/d05c22be-9641-47fb-8a7b-063c43e7f1bf/code.power new file mode 100644 index 0000000..f72bd3a --- /dev/null +++ b/src/d05c22be-9641-47fb-8a7b-063c43e7f1bf/code.power @@ -0,0 +1,786 @@ + /** + * The Data Class. + * + * @var Plugin + * @since 3.2.0 + */ + protected Plugin $plugin; + + /** + * The Component Class. + * + * @var Component + * @since 3.2.0 + */ + protected Component $component; + + /** + * The Config Class. + * + * @var Config + * @since 3.2.0 + */ + protected Config $config; + + /** + * The Registry Class. + * + * @var Registry + * @since 3.2.0 + */ + protected Registry $registry; + + /** + * The Dispenser Class. + * + * @var Dispenser + * @since 3.2.0 + */ + protected Dispenser $dispenser; + + /** + * The EventInterface Class. + * + * @var Event + * @since 3.2.0 + */ + protected Event $event; + + /** + * The Counter Class. + * + * @var Counter + * @since 3.2.0 + */ + protected Counter $counter; + + /** + * The Folder Class. + * + * @var Folder + * @since 3.2.0 + */ + protected Folder $folder; + + /** + * The File Class. + * + * @var File + * @since 3.2.0 + */ + protected File $file; + + /** + * The Files Class. + * + * @var Files + * @since 3.2.0 + */ + protected Files $files; + + /** + * The Placeholder Class. + * + * @var Placeholder + * @since 5.0.0 + */ + protected Placeholder $placeholder; + + /** + * The Namespace Prefix + * + * @var string + * @since 5.0.0 + */ + protected string $NamespacePrefix; + + /** + * The Component Namespace (in code) + * + * @var string + * @since 3.2.0 + */ + protected string $ComponentNamespace; + + /** + * Constructor. + * + * @param Plugin $plugin The Data Class. + * @param Component $component The Component Class. + * @param Config $config The Config Class. + * @param Registry $registry The Registry Class. + * @param Dispenser $dispenser The Dispenser Class. + * @param Event $event The EventInterface Class. + * @param Counter $counter The Counter Class. + * @param Folder $folder The Folder Class. + * @param File $file The File Class. + * @param Files $files The Files Class. + * @param Placeholder $placeholder The Placeholder Class. + * + * @since 3.2.0 + */ + public function __construct(Plugin $plugin, Component $component, Config $config, + Registry $registry, Dispenser $dispenser, Event $event, + Counter $counter, Folder $folder, File $file, + Files $files, Placeholder $placeholder) + { + $this->plugin = $plugin; + $this->component = $component; + $this->config = $config; + $this->registry = $registry; + $this->dispenser = $dispenser; + $this->event = $event; + $this->counter = $counter; + $this->folder = $folder; + $this->file = $file; + $this->files = $files; + $this->placeholder = $placeholder; + + // set some global values + $this->NamespacePrefix = $this->placeholder->get('NamespacePrefix'); + $this->ComponentNamespace = $this->placeholder->get('ComponentNamespace'); + } + + /** + * Build the Plugins files, folders, url's and config + * + * @return void + * @since 3.2.0 + */ + public function build() + { + if ($this->plugin->exists()) + { + // for plugin event TODO change event api signatures + $component_context = $this->config->component_context; + $plugins = $this->plugin->get(); + + // Trigger Event: jcb_ce_onBeforeSetPlugins + $this->event->trigger( + 'jcb_ce_onBeforeBuildPlugins', + array(&$component_context, &$plugins) + ); + + foreach ($plugins as $plugin) + { + if (ObjectHelper::check($plugin) + && isset($plugin->folder_name) + && StringHelper::check($plugin->folder_name)) + { + // plugin path + $this->pluginPath($plugin); + + // create src folder + $this->folder->create($plugin->folder_path . '/src'); + + // set the plugin paths + $this->registry->set('dynamic_paths.' . $plugin->key, $plugin->folder_path); + + // make sure there is no old build + $this->folder->remove($plugin->folder_path); + + // creat the main component folder + $this->folder->create($plugin->folder_path); + + // set main class file + $this->setMainClassFile($plugin); + + // set service provider class file + $this->setServiceProviderClassFile($plugin); + + // set main xml file + $this->setMainXmlFile($plugin); + + // set install script if needed + $this->setInstallScript($plugin); + + // set readme if found + $this->setReadme($plugin); + + // set fields & rules folders if needed + if (isset($plugin->fields_rules_paths) + && $plugin->fields_rules_paths == 2) + { + // create fields folder + $this->folder->create($plugin->folder_path . '/src/Field'); + + // create rules folder + $this->folder->create($plugin->folder_path . '/src/Rule'); + } + + // set forms folder if needed + $this->setForms($plugin); + + // set SQL stuff if needed + $this->setSQL($plugin); + + // create the language folder path + $this->folder->create($plugin->folder_path . '/language'); + + // also create the lang tag folder path + $this->folder->create( + $plugin->folder_path . '/language/' . $this->config->get('lang_tag', 'en-GB') + ); + + // check if this plugin has files + $this->setFiles($plugin); + + // check if this plugin has folders + $this->setFolders($plugin); + + // check if this plugin has urls + $this->setUrls($plugin); + } + } + } + } + + /** + * get the plugin xml template + * + * @param object $plugin The plugin object + * + * @return string + * @since 3.2.0 + */ + protected function getXML(object $plugin): string + { + $xml = ''; + $xml .= PHP_EOL . ''; + $xml .= PHP_EOL . Indent::_(1) . '' . $plugin->lang_prefix + . ''; + $xml .= PHP_EOL . Indent::_(1) . '' . Placefix::_h('BUILDDATE') . ''; + $xml .= PHP_EOL . Indent::_(1) . '' . Placefix::_h('AUTHOR') . ''; + $xml .= PHP_EOL . Indent::_(1) . '' . Placefix::_h('AUTHOREMAIL') . ''; + $xml .= PHP_EOL . Indent::_(1) . '' . Placefix::_h('AUTHORWEBSITE') . ''; + $xml .= PHP_EOL . Indent::_(1) . '' . Placefix::_h('COPYRIGHT') . ''; + $xml .= PHP_EOL . Indent::_(1) . '' . Placefix::_h('LICENSE') . ''; + $xml .= PHP_EOL . Indent::_(1) . '' . $plugin->plugin_version + . ''; + $xml .= PHP_EOL . Indent::_(1) . '' . "{$this->NamespacePrefix}\\Plugin\\{$plugin->group_namespace}\\{$plugin->namespace}" + . ''; + $xml .= PHP_EOL . Indent::_(1) . '' . $plugin->lang_prefix + . '_XML_DESCRIPTION'; + $xml .= Placefix::_h('MAINXML'); + $xml .= PHP_EOL . ''; + + return $xml; + } + + /** + * set the plugin path + * + * @param object $plugin The plugin object + * + * @return void + * @since 3.2.0 + */ + protected function pluginPath(object &$plugin): void + { + $plugin->folder_path = $this->config->get('compiler_path', JPATH_COMPONENT_ADMINISTRATOR . '/compiler') . '/' + . $plugin->folder_name; + } + + /** + * set the main class path + * + * @param object $plugin The plugin object + * + * @return void + * @since 3.2.0 + */ + protected function setMainClassFile(object $plugin): void + { + // create extension folder + $this->folder->create($plugin->folder_path . '/src/Extension'); + + $file_details = [ + 'path' => $plugin->folder_path . '/src/Extension/' . $plugin->class_file_name . '.php', + 'name' => $plugin->class_file_name . '.php', + 'zip' => 'src/Extension/' . $plugin->class_file_name . '.php' + ]; + + $this->file->write( + $file_details['path'], + 'NamespacePrefix}\\Plugin\\{$plugin->group_namespace}\\{$plugin->namespace}\\Extension;" . + PHP_EOL . PHP_EOL . Placefix::_h('EXTENSION_CLASS_HEADER') . + PHP_EOL . PHP_EOL . '// No direct access to this file' . PHP_EOL . + "defined('_JEXEC') or die('Restricted access');" . + PHP_EOL . PHP_EOL . + Placefix::_h('EXTENSION_CLASS') + ); + + $this->files->appendArray($plugin->key, $file_details); + + // count the file created + $this->counter->file++; + } + + /** + * set the service provider path + * + * @param object $plugin The plugin object + * + * @return void + * @since 3.2.0 + */ + protected function setServiceProviderClassFile(object $plugin): void + { + // create services folder + $this->folder->create($plugin->folder_path . '/services'); + + $file_details = [ + 'path' => $plugin->folder_path . '/services/provider.php', + 'name' => 'provider.php', + 'zip' => 'services/provider.php' + ]; + + $this->file->write( + $file_details['path'], + 'files->appendArray($plugin->key, $file_details); + + // count the file created + $this->counter->file++; + } + + /** + * set the main xml file + * + * @param object $plugin The plugin object + * + * @return void + * @since 3.2.0 + */ + protected function setMainXmlFile(object $plugin): void + { + $file_details = [ + 'path' => $plugin->folder_path . '/' . $plugin->file_name . '.xml', + 'name' => $plugin->file_name . '.xml', + 'zip' => $plugin->file_name . '.xml' + ]; + + $this->file->write( + $file_details['path'], + $this->getXML($plugin) + ); + + $this->files->appendArray($plugin->key, $file_details); + + // count the file created + $this->counter->file++; + } + + /** + * set the install script file + * + * @param object $plugin The plugin object + * + * @return void + * @since 3.2.0 + */ + protected function setInstallScript(object $plugin): void + { + if ($plugin->add_install_script) + { + $file_details = [ + 'path' => $plugin->folder_path . '/script.php', + 'name' => 'script.php', + 'zip' => 'script.php' + ]; + + $this->file->write( + $file_details['path'], + 'files->appendArray($plugin->key, $file_details); + + // count the file created + $this->counter->file++; + } + } + + /** + * set the readme file + * + * @param object $plugin The plugin object + * + * @return void + * @since 3.2.0 + */ + protected function setReadme(object $plugin): void + { + if ($plugin->addreadme) + { + $file_details = [ + 'path' => $plugin->folder_path . '/README.md', + 'name' => 'README.md', + 'zip' => 'README.md' + ]; + + $this->file->write($file_details['path'], $plugin->readme); + $this->files->appendArray($plugin->key, $file_details); + + // count the file created + $this->counter->file++; + } + } + + /** + * set the form files and folders + * + * @param object $plugin The plugin object + * + * @return void + * @since 3.2.0 + */ + protected function setForms(object $plugin): void + { + if (isset($plugin->form_files) + && ArrayHelper::check($plugin->form_files)) + { + $Group = ucfirst((string) $plugin->group); + $FileName = $plugin->file_name; + + // create forms folder + $this->folder->create($plugin->folder_path . '/forms'); + + // set the template files + foreach ($plugin->form_files as $file => $fields) + { + // set file details + $file_details = [ + 'path' => $plugin->folder_path . '/forms/' . $file . '.xml', + 'name' => $file . '.xml', + 'zip' => 'forms/' . $file . '.xml' + ]; + + // build basic XML + $xml = ''; + $xml .= PHP_EOL . ''; + + // search if we must add the component path + $add_component_path = false; + foreach ($fields as $field_name => $fieldsets) + { + if (!$add_component_path) + { + foreach ($fieldsets as $fieldset => $field) + { + if (!$add_component_path + && isset($plugin->fieldsets_paths[$file . $field_name . $fieldset]) + && $plugin->fieldsets_paths[$file. $field_name . $fieldset] == 1) + { + $add_component_path = true; + } + } + } + } + + // only add if part of the component field types path is required + if ($add_component_path) + { + $xml .= PHP_EOL . ''; + } + else + { + $xml .= PHP_EOL . '
'; + } + + // add the fields + foreach ($fields as $field_name => $fieldsets) + { + // check if we have an double fields naming set + $field_name_inner = ''; + $field_name_outer = $field_name; + if (strpos((string)$field_name, '.') !== false) + { + $field_names = explode('.', (string)$field_name); + if (count((array)$field_names) == 2) + { + $field_name_outer = $field_names[0]; + $field_name_inner = $field_names[1]; + } + } + $xml .= PHP_EOL . Indent::_(1) + . ''; + foreach ($fieldsets as $fieldset => $field) + { + // default to the field set name + $label = $fieldset; + if (isset($plugin->fieldsets_label[$file . $field_name . $fieldset])) + { + $label = $plugin->fieldsets_label[$file . $field_name . $fieldset]; + } + + // add path to plugin rules and custom fields + if (isset($plugin->fieldsets_paths[$file . $field_name . $fieldset]) + && ($plugin->fieldsets_paths[$file . $field_name . $fieldset] == 2 + || $plugin->fieldsets_paths[$file . $field_name . $fieldset] == 3)) + { + if (!isset($plugin->add_rule_path[$file . $field_name . $fieldset])) + { + $plugin->add_rule_path[$file . $field_name . $fieldset] = + "{$this->NamespacePrefix}\\Plugin\\{$Group}\\{$FileName}\\Rule"; + } + + if (!isset($plugin->add_field_path[$file . $field_name . $fieldset])) + { + $plugin->add_field_path[$file . $field_name . $fieldset] = + "{$this->NamespacePrefix}\\Plugin\\{$Group}\\{$FileName}\\Field"; + } + } + + // add path to plugin rules and custom fields + if (isset($plugin->add_rule_path[$file . $field_name . $fieldset]) + || isset($plugin->add_field_path[$file . $field_name . $fieldset])) + { + $xml .= PHP_EOL . Indent::_(1) . ''; + + $xml .= PHP_EOL . Indent::_(1) . '
add_rule_path[$file . $field_name . $fieldset])) + { + $xml .= PHP_EOL . Indent::_(2) + . 'addrulepath="' . $plugin->add_rule_path[$file . $field_name . $fieldset] . '"'; + } + + if (isset($plugin->add_field_path[$file . $field_name . $fieldset])) + { + $xml .= PHP_EOL . Indent::_(2) + . 'addfieldpath="' . $plugin->add_field_path[$file . $field_name . $fieldset] . '"'; + } + + $xml .= PHP_EOL . Indent::_(1) . '>'; + } + else + { + $xml .= PHP_EOL . Indent::_(1) . '
'; + } + + // check if we have an inner field set + if (StringHelper::check($field_name_inner)) + { + $xml .= PHP_EOL . Indent::_(1) + . ''; + } + + // add the placeholder of the fields + $xml .= Placefix::_h('FIELDSET_' . $file + . $field_name . $fieldset); + + // check if we have an inner field set + if (StringHelper::check($field_name_inner)) + { + $xml .= PHP_EOL . Indent::_(1) + . ''; + } + $xml .= PHP_EOL . Indent::_(1) + . '
'; + } + $xml .= PHP_EOL . Indent::_(1) . ''; + } + $xml .= PHP_EOL . ''; + + // add xml to file + $this->file->write($file_details['path'], $xml); + $this->files->appendArray($plugin->key, $file_details); + + // count the file created + $this->counter->file++; + } + } + } + + /** + * set the sql stuff + * + * @param object $plugin The plugin object + * + * @return void + * @since 3.2.0 + */ + protected function setSQL(object $plugin): void + { + if ($plugin->add_sql || $plugin->add_sql_uninstall) + { + // create SQL folder + $this->folder->create($plugin->folder_path . '/sql'); + + // create mysql folder + $this->folder->create( + $plugin->folder_path . '/sql/mysql' + ); + + // now set the install file + if ($plugin->add_sql) + { + $this->file->write( + $plugin->folder_path . '/sql/mysql/install.sql', + $plugin->sql + ); + + // count the file created + $this->counter->file++; + } + + // now set the uninstall file + if ($plugin->add_sql_uninstall) + { + $this->file->write( + $plugin->folder_path + . '/sql/mysql/uninstall.sql', + $plugin->sql_uninstall + ); + + // count the file created + $this->counter->file++; + } + } + } + + /** + * set the files + * + * @param object $plugin The plugin object + * + * @return void + * @since 3.2.0 + */ + protected function setFiles(object $plugin): void + { + if (isset($plugin->files) && ArrayHelper::check($plugin->files)) + { + // add to component files + foreach ($plugin->files as $file) + { + // set the path finder + $file['target_type'] = $plugin->target_type; + $file['target_id'] = $plugin->id; + + $this->component->appendArray('files', $file); + } + } + } + + /** + * set the folders + * + * @param object $plugin The plugin object + * + * @return void + * @since 3.2.0 + */ + protected function setFolders(object $plugin): void + { + if (isset($plugin->folders) && ArrayHelper::check($plugin->folders)) + { + // add to component folders + foreach ($plugin->folders as $folder) + { + // set the path finder + $folder['target_type'] = $plugin->target_type; + $folder['target_id'] = $plugin->id; + + $this->component->appendArray('folders', $folder); + } + } + } + + /** + * set the urls + * + * @param object $plugin The plugin object + * + * @return void + * @since 3.2.0 + */ + protected function setUrls(object &$plugin): void + { + if (isset($plugin->urls) && ArrayHelper::check($plugin->urls)) + { + // add to component urls + foreach ($plugin->urls as &$url) + { + // should we add the local folder + if (isset($url['type']) && $url['type'] > 1 + && isset($url['url']) + && StringHelper::check($url['url'])) + { + // set file name + $fileName = basename((string)$url['url']); + + // get the file contents + $data = FileHelper::getContent( + $url['url'] + ); + + // build sub path + if (strpos($fileName, '.js') !== false) + { + $path = '/js'; + } + elseif (strpos($fileName, '.css') !== false) + { + $path = '/css'; + } + else + { + $path = ''; + } + + // create sub media folder path if not set + $this->folder->create( + $plugin->folder_path . $path + ); + + // set the path to plugin file + $url['path'] = $plugin->folder_path . $path + . '/' . $fileName; // we need this for later + + // write data to path + $this->file->write($url['path'], $data); + + // count the file created + $this->counter->file++; + } + } + } + } \ No newline at end of file diff --git a/src/d05c22be-9641-47fb-8a7b-063c43e7f1bf/settings.json b/src/d05c22be-9641-47fb-8a7b-063c43e7f1bf/settings.json new file mode 100644 index 0000000..40e9322 --- /dev/null +++ b/src/d05c22be-9641-47fb-8a7b-063c43e7f1bf/settings.json @@ -0,0 +1,94 @@ +{ + "add_head": "0", + "add_licensing_template": "2", + "extends": "", + "guid": "d05c22be-9641-47fb-8a7b-063c43e7f1bf", + "implements": [ + "ef66b17c-ffae-414a-9067-20a63ba2bec5" + ], + "load_selection": null, + "name": "Structure", + "power_version": "1.0.0", + "system_name": "JCB.Compiler.Joomlaplugin.J5.Structure", + "type": "class", + "use_selection": { + "use_selection0": { + "use": "8cc85656-a925-4a46-a49b-83c72167fd6a", + "as": "Plugin" + }, + "use_selection1": { + "use": "e2472b22-a329-44d8-b4a2-ae3ba99e17a0", + "as": "default" + }, + "use_selection2": { + "use": "fa4bf18e-301e-42e3-91fb-6e0096c07adc", + "as": "default" + }, + "use_selection3": { + "use": "e5d9804f-0eb0-4ee9-b406-ad4e8cdbc1f6", + "as": "default" + }, + "use_selection4": { + "use": "f1dc6430-fb54-452e-aa53-ce32ae93db88", + "as": "default" + }, + "use_selection5": { + "use": "20ed72b0-fcac-4344-aee1-8a65e3bf221d", + "as": "Event" + }, + "use_selection6": { + "use": "e6d871a6-bbe7-497d-af01-68f6bb9a87f4", + "as": "default" + }, + "use_selection7": { + "use": "6bbb6ffe-3f09-4c21-aa9d-c93159afa1e1", + "as": "default" + }, + "use_selection8": { + "use": "5c75b455-3d4c-452a-867e-e90424a64c88", + "as": "default" + }, + "use_selection9": { + "use": "1d967151-7c20-4ca7-9400-65233cdcd4db", + "as": "default" + }, + "use_selection10": { + "use": "06453ada-e370-49f0-b262-e3f5a8ed0c2c", + "as": "default" + }, + "use_selection11": { + "use": "a68c010b-e92e-47d5-8a44-d23cfddeb6c6", + "as": "default" + }, + "use_selection12": { + "use": "500f3a7f-c16d-4dd4-81b2-2df6776b5388", + "as": "default" + }, + "use_selection13": { + "use": "4e6ff11d-bebf-42f5-8fd7-b2f882857222", + "as": "default" + }, + "use_selection14": { + "use": "0a59c65c-9daf-4bc9-baf4-e063ff9e6a8a", + "as": "default" + }, + "use_selection15": { + "use": "91004529-94a9-4590-b842-e7c6b624ecf5", + "as": "default" + }, + "use_selection16": { + "use": "1f28cb53-60d9-4db1-b517-3c7dc6b429ef", + "as": "default" + }, + "use_selection17": { + "use": "a223b31e-ea1d-4cdf-92ae-5f9becffaff0", + "as": "default" + } + }, + "extendsinterfaces": null, + "namespace": "[[[NamespacePrefix]]]\\Joomla\\[[[ComponentNamespace]]].Compiler.Joomlaplugin.JoomlaFive.Structure", + "description": "Joomla 5 Plugin Builder Class\r\n\r\n@since 5.0.2", + "licensing_template": "\/**\r\n * @package Joomla.Component.Builder\r\n *\r\n * @created 4th September, 2022\r\n * @author Llewellyn van der Merwe \r\n * @git Joomla Component Builder \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/d33b9278-c409-4aec-a047-b72f56712391/README.md b/src/d33b9278-c409-4aec-a047-b72f56712391/README.md index b18cb1c..96ccec0 100644 --- a/src/d33b9278-c409-4aec-a047-b72f56712391/README.md +++ b/src/d33b9278-c409-4aec-a047-b72f56712391/README.md @@ -6,12 +6,12 @@ ██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║ ╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝ ``` -# class Extractor (Details) +# final class Extractor (Details) > namespace: **VDM\Joomla\Componentbuilder\Compiler\Language** ```uml @startuml -class Extractor #Gold { +class Extractor << (F,LightGreen) >> #RoyalBlue { + array $langKeys + array $langMismatch + array $langMatch diff --git a/src/d33b9278-c409-4aec-a047-b72f56712391/code.php b/src/d33b9278-c409-4aec-a047-b72f56712391/code.php index 57a0bd7..364d69d 100644 --- a/src/d33b9278-c409-4aec-a047-b72f56712391/code.php +++ b/src/d33b9278-c409-4aec-a047-b72f56712391/code.php @@ -25,7 +25,7 @@ use VDM\Joomla\Utilities\GetHelper; * * @since 3.2.0 */ -class Extractor +final class Extractor { /** * The lang keys for extensions diff --git a/src/d33b9278-c409-4aec-a047-b72f56712391/settings.json b/src/d33b9278-c409-4aec-a047-b72f56712391/settings.json index 451e6f0..cba5e4c 100644 --- a/src/d33b9278-c409-4aec-a047-b72f56712391/settings.json +++ b/src/d33b9278-c409-4aec-a047-b72f56712391/settings.json @@ -8,7 +8,7 @@ "name": "Extractor", "power_version": "1.0.0", "system_name": "JCB.Compiler.Language.Extractor", - "type": "class", + "type": "final class", "use_selection": { "use_selection0": { "use": "fa4bf18e-301e-42e3-91fb-6e0096c07adc", diff --git a/src/d42e1fac-3c05-4a22-8878-2abd43019811/code.php b/src/d42e1fac-3c05-4a22-8878-2abd43019811/code.php index a9acfa5..017f341 100644 --- a/src/d42e1fac-3c05-4a22-8878-2abd43019811/code.php +++ b/src/d42e1fac-3c05-4a22-8878-2abd43019811/code.php @@ -360,10 +360,10 @@ final class InstallScript implements GetScriptInterface $script .= PHP_EOL . Indent::_(2) . '$jversion = new JVersion();'; $script .= PHP_EOL . Indent::_(2) - . "if (!\$jversion->isCompatible('3.8.0'))"; + . "if (!\$jversion->isCompatible('4.0.0'))"; $script .= PHP_EOL . Indent::_(2) . '{'; $script .= PHP_EOL . Indent::_(3) - . "\$app->enqueueMessage('Please upgrade to at least Joomla! 3.8.0 before continuing!', 'error');"; + . "\$app->enqueueMessage('Please upgrade to at least Joomla! 4.0.0 before continuing!', 'error');"; $script .= PHP_EOL . Indent::_(3) . 'return false;'; $script .= PHP_EOL . Indent::_(2) . '}' . PHP_EOL; } diff --git a/src/d42e1fac-3c05-4a22-8878-2abd43019811/code.power b/src/d42e1fac-3c05-4a22-8878-2abd43019811/code.power index 391c370..7454778 100644 --- a/src/d42e1fac-3c05-4a22-8878-2abd43019811/code.power +++ b/src/d42e1fac-3c05-4a22-8878-2abd43019811/code.power @@ -331,10 +331,10 @@ $script .= PHP_EOL . Indent::_(2) . '$jversion = new JVersion();'; $script .= PHP_EOL . Indent::_(2) - . "if (!\$jversion->isCompatible('3.8.0'))"; + . "if (!\$jversion->isCompatible('4.0.0'))"; $script .= PHP_EOL . Indent::_(2) . '{'; $script .= PHP_EOL . Indent::_(3) - . "\$app->enqueueMessage('Please upgrade to at least Joomla! 3.8.0 before continuing!', 'error');"; + . "\$app->enqueueMessage('Please upgrade to at least Joomla! 4.0.0 before continuing!', 'error');"; $script .= PHP_EOL . Indent::_(3) . 'return false;'; $script .= PHP_EOL . Indent::_(2) . '}' . PHP_EOL; } diff --git a/src/d6ae90a5-44b4-4ce4-aedc-86c90a242912/README.md b/src/d6ae90a5-44b4-4ce4-aedc-86c90a242912/README.md new file mode 100644 index 0000000..717b6b1 --- /dev/null +++ b/src/d6ae90a5-44b4-4ce4-aedc-86c90a242912/README.md @@ -0,0 +1,52 @@ +``` +██████╗ ██████╗ ██╗ ██╗███████╗██████╗ +██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗ +██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝ +██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗ +██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║ +╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝ +``` +# interface ProviderInterface (Details) +> namespace: **VDM\Joomla\Componentbuilder\Compiler\Interfaces\Architecture\Plugin** + +```uml +@startuml +interface ProviderInterface #Lavender { + + get(object $plugin) : string +} + +note right of ProviderInterface::get + Get the updated placeholder content for the given plugin. + + since: 5.0.2 + return: string +end note + +@enduml +``` + +The Power feature in JCB allows you to write PHP classes and their implementations, making it easy to include them in your Joomla project. JCB handles linking, autoloading, namespacing, and folder structure creation for you. + +By using the SPK (Super Power Key) in your custom code (replacing the class name in your code with the SPK), JCB will automatically pull the power from the repository into your project. This makes it available in your JCB instance, allowing you to edit it and include the class in your generated Joomla component. + +JCB uses placeholders like [[[`NamespacePrefix`]]] and [[[`ComponentNamespace`]]] in namespacing to prevent collisions and improve reusability across different JCB systems. You can also set the **JCB powers path** globally or per component under the **Dynamic Integration** tab, providing flexibility and easy maintainability. + +To add this specific Power to your project in JCB: + +> simply use this SPK +``` +Super---d6ae90a5_44b4_4ce4_aedc_86c90a242912---Power +``` +> remember to replace the `---` with `___` to activate this Power in your code + +--- +``` + ██╗ ██████╗██████╗ + ██║██╔════╝██╔══██╗ + ██║██║ ██████╔╝ +██ ██║██║ ██╔══██╗ +╚█████╔╝╚██████╗██████╔╝ + ╚════╝ ╚═════╝╚═════╝ +``` +> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder) + diff --git a/src/d6ae90a5-44b4-4ce4-aedc-86c90a242912/code.php b/src/d6ae90a5-44b4-4ce4-aedc-86c90a242912/code.php new file mode 100644 index 0000000..0a97529 --- /dev/null +++ b/src/d6ae90a5-44b4-4ce4-aedc-86c90a242912/code.php @@ -0,0 +1,33 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Componentbuilder\Compiler\Interfaces\Architecture\Plugin; + + +/** + * Plugin Provider Interface + * + * @since 5.0.2 + */ +interface ProviderInterface +{ + /** + * Get the updated placeholder content for the given plugin. + * + * @param object $plugin The plugin object containing the necessary data. + * + * @return string The updated placeholder content. + * + * @since 5.0.2 + */ + public function get(object $plugin): string; +} + diff --git a/src/d6ae90a5-44b4-4ce4-aedc-86c90a242912/code.power b/src/d6ae90a5-44b4-4ce4-aedc-86c90a242912/code.power new file mode 100644 index 0000000..4ed6345 --- /dev/null +++ b/src/d6ae90a5-44b4-4ce4-aedc-86c90a242912/code.power @@ -0,0 +1,10 @@ + /** + * Get the updated placeholder content for the given plugin. + * + * @param object $plugin The plugin object containing the necessary data. + * + * @return string The updated placeholder content. + * + * @since 5.0.2 + */ + public function get(object $plugin): string; \ No newline at end of file diff --git a/src/d6ae90a5-44b4-4ce4-aedc-86c90a242912/settings.json b/src/d6ae90a5-44b4-4ce4-aedc-86c90a242912/settings.json new file mode 100644 index 0000000..add4dda --- /dev/null +++ b/src/d6ae90a5-44b4-4ce4-aedc-86c90a242912/settings.json @@ -0,0 +1,19 @@ +{ + "add_head": "0", + "add_licensing_template": "2", + "extends": "", + "guid": "d6ae90a5-44b4-4ce4-aedc-86c90a242912", + "implements": null, + "load_selection": null, + "name": "ProviderInterface", + "power_version": "1.0.0", + "system_name": "JCB.Interfaces.Architecture.Plugin.Provider", + "type": "interface", + "use_selection": null, + "extendsinterfaces": null, + "namespace": "[[[NamespacePrefix]]]\\Joomla\\[[[ComponentNamespace]]].Compiler.Interfaces.Architecture.Plugin.ProviderInterface", + "description": "Plugin Provider Interface\r\n\r\n@since 5.0.2", + "licensing_template": "\/**\r\n * @package Joomla.Component.Builder\r\n *\r\n * @created 4th September, 2022\r\n * @author Llewellyn van der Merwe \r\n * @git Joomla Component Builder \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/d910d8b8-4c23-4f3e-8cda-438f2d2bd7ac/code.php b/src/d910d8b8-4c23-4f3e-8cda-438f2d2bd7ac/code.php index 41613ad..3a4cf02 100644 --- a/src/d910d8b8-4c23-4f3e-8cda-438f2d2bd7ac/code.php +++ b/src/d910d8b8-4c23-4f3e-8cda-438f2d2bd7ac/code.php @@ -44,6 +44,7 @@ use VDM\Joomla\Componentbuilder\Compiler\Service\BuilderLZ; use VDM\Joomla\Componentbuilder\Compiler\Service\Creator; use VDM\Joomla\Componentbuilder\Compiler\Service\ArchitectureController; use VDM\Joomla\Componentbuilder\Compiler\Service\ArchitectureModel; +use VDM\Joomla\Componentbuilder\Compiler\Service\ArchitecturePlugin; use VDM\Joomla\Componentbuilder\Service\Gitea; use VDM\Joomla\Gitea\Service\Utilities as GiteaUtilities; use VDM\Joomla\Gitea\Service\Settings as GiteaSettings; @@ -143,6 +144,7 @@ abstract class Factory extends ExtendingFactory implements FactoryInterface ->registerServiceProvider(new Creator()) ->registerServiceProvider(new ArchitectureController()) ->registerServiceProvider(new ArchitectureModel()) + ->registerServiceProvider(new ArchitecturePlugin()) ->registerServiceProvider(new Gitea()) ->registerServiceProvider(new GiteaUtilities()) ->registerServiceProvider(new GiteaSettings()) diff --git a/src/d910d8b8-4c23-4f3e-8cda-438f2d2bd7ac/code.power b/src/d910d8b8-4c23-4f3e-8cda-438f2d2bd7ac/code.power index 380fc20..812b6f7 100644 --- a/src/d910d8b8-4c23-4f3e-8cda-438f2d2bd7ac/code.power +++ b/src/d910d8b8-4c23-4f3e-8cda-438f2d2bd7ac/code.power @@ -75,6 +75,7 @@ ->registerServiceProvider(new Creator()) ->registerServiceProvider(new ArchitectureController()) ->registerServiceProvider(new ArchitectureModel()) + ->registerServiceProvider(new ArchitecturePlugin()) ->registerServiceProvider(new Gitea()) ->registerServiceProvider(new GiteaUtilities()) ->registerServiceProvider(new GiteaSettings()) diff --git a/src/d910d8b8-4c23-4f3e-8cda-438f2d2bd7ac/settings.json b/src/d910d8b8-4c23-4f3e-8cda-438f2d2bd7ac/settings.json index 5bfa2c1..0459361 100644 --- a/src/d910d8b8-4c23-4f3e-8cda-438f2d2bd7ac/settings.json +++ b/src/d910d8b8-4c23-4f3e-8cda-438f2d2bd7ac/settings.json @@ -136,6 +136,10 @@ "use": "bbd36fbf-d905-47e8-8e67-9ea6ec734712", "as": "default" }, + "use_selection42": { + "use": "98ac432d-df19-4c40-bb12-8104ea4362c8", + "as": "default" + }, "use_selection31": { "use": "71acf8d6-32b8-4173-8277-eb9cda29fd64", "as": "default" diff --git a/src/e7fff971-b031-42bf-8009-ef554e30854d/code.php b/src/e7fff971-b031-42bf-8009-ef554e30854d/code.php index 15b9004..d246479 100644 --- a/src/e7fff971-b031-42bf-8009-ef554e30854d/code.php +++ b/src/e7fff971-b031-42bf-8009-ef554e30854d/code.php @@ -351,7 +351,7 @@ final class Settings implements SettingsInterface $this->config->get('footable', false)) { $this->addImportViewFolder(); - $this->addPhpSpreadsheetFolder(); + // $this->addPhpSpreadsheetFolder(); // soon $this->addUikitFolder(); $this->addFooTableFolder(); } diff --git a/src/e7fff971-b031-42bf-8009-ef554e30854d/code.power b/src/e7fff971-b031-42bf-8009-ef554e30854d/code.power index 94e562f..67a6493 100644 --- a/src/e7fff971-b031-42bf-8009-ef554e30854d/code.power +++ b/src/e7fff971-b031-42bf-8009-ef554e30854d/code.power @@ -315,7 +315,7 @@ $this->config->get('footable', false)) { $this->addImportViewFolder(); - $this->addPhpSpreadsheetFolder(); + // $this->addPhpSpreadsheetFolder(); // soon $this->addUikitFolder(); $this->addFooTableFolder(); } diff --git a/src/ec808f55-6703-46c0-8a6d-33c9d4e0e9fa/README.md b/src/ec808f55-6703-46c0-8a6d-33c9d4e0e9fa/README.md new file mode 100644 index 0000000..754b415 --- /dev/null +++ b/src/ec808f55-6703-46c0-8a6d-33c9d4e0e9fa/README.md @@ -0,0 +1,94 @@ +``` +██████╗ ██████╗ ██╗ ██╗███████╗██████╗ +██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗ +██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝ +██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗ +██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║ +╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝ +``` +# final class Extension (Details) +> namespace: **VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaFour\Plugin** + +```uml +@startuml +class Extension << (F,LightGreen) >> #RoyalBlue { + # Placeholder $placeholder + # Builder $builder + # Parser $parser + + __construct(Placeholder $placeholder, Builder $builder, ...) + + get(object $plugin) : string + # addNeededMethods(string $code) : bool + # addGetSubscribedEvents(array $methods) : ?string + # getSubscribedEvents(array $methods) : bool +} + +note right of Extension::__construct + Constructor. + + since: 5.0.2 + + arguments: + Placeholder $placeholder + Builder $builder + Parser $parser +end note + +note right of Extension::get + Get the updated placeholder content for the given plugin. + + since: 5.0.2 + return: string +end note + +note right of Extension::addNeededMethods + Ensures that the required methods are present in the plugin code. +This method checks the plugin's code for the presence of required methods, +particularly the method that indicates implementation of the SubscriberInterface. +If the necessary method is missing, it adds it to the code. + + since: 5.0.2 + return: bool +end note + +note right of Extension::addGetSubscribedEvents + Add the getSubscribedEvents method + + since: 5.0.2 + return: ?string +end note + +note right of Extension::getSubscribedEvents + Check if the getSubscribedEvents is set + + since: 5.0.2 + return: bool +end note + +@enduml +``` + +The Power feature in JCB allows you to write PHP classes and their implementations, making it easy to include them in your Joomla project. JCB handles linking, autoloading, namespacing, and folder structure creation for you. + +By using the SPK (Super Power Key) in your custom code (replacing the class name in your code with the SPK), JCB will automatically pull the power from the repository into your project. This makes it available in your JCB instance, allowing you to edit it and include the class in your generated Joomla component. + +JCB uses placeholders like [[[`NamespacePrefix`]]] and [[[`ComponentNamespace`]]] in namespacing to prevent collisions and improve reusability across different JCB systems. You can also set the **JCB powers path** globally or per component under the **Dynamic Integration** tab, providing flexibility and easy maintainability. + +To add this specific Power to your project in JCB: + +> simply use this SPK +``` +Super---ec808f55_6703_46c0_8a6d_33c9d4e0e9fa---Power +``` +> remember to replace the `---` with `___` to activate this Power in your code + +--- +``` + ██╗ ██████╗██████╗ + ██║██╔════╝██╔══██╗ + ██║██║ ██████╔╝ +██ ██║██║ ██╔══██╗ +╚█████╔╝╚██████╗██████╔╝ + ╚════╝ ╚═════╝╚═════╝ +``` +> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder) + diff --git a/src/ec808f55-6703-46c0-8a6d-33c9d4e0e9fa/code.php b/src/ec808f55-6703-46c0-8a6d-33c9d4e0e9fa/code.php new file mode 100644 index 0000000..777087c --- /dev/null +++ b/src/ec808f55-6703-46c0-8a6d-33c9d4e0e9fa/code.php @@ -0,0 +1,215 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaFour\Plugin; + + +use VDM\Joomla\Componentbuilder\Compiler\Placeholder; +use VDM\Joomla\Componentbuilder\Compiler\Builder\ContentOne as Builder; +use VDM\Joomla\Componentbuilder\Power\Parser; +use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent; +use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Architecture\Plugin\ExtensionInterface; + + +/** + * Plugin Extension Class for Joomla 4 + * + * @since 5.0.2 + */ +final class Extension implements ExtensionInterface +{ + /** + * The Placeholder Class. + * + * @var Placeholder + * @since 5.0.2 + */ + protected Placeholder $placeholder; + + /** + * The ContentOne Class. + * + * @var Builder + * @since 5.0.2 + */ + protected Builder $builder; + + /** + * The Parser Class. + * + * @var Parser + * @since 5.0.2 + */ + protected Parser $parser; + + /** + * Constructor. + * + * @param Placeholder $placeholder The Placeholder Class. + * @param Builder $builder The Content One Class. + * @param Parser $parser The Parser Class. + * + * @since 5.0.2 + */ + public function __construct(Placeholder $placeholder, Builder $builder, Parser $parser) + { + $this->placeholder = $placeholder; + $this->builder = $builder; + $this->parser = $parser; + } + + /** + * Get the updated placeholder content for the given plugin. + * + * @param object $plugin The plugin object containing the necessary data. + * + * @return string The updated placeholder content. + * + * @since 5.0.2 + */ + public function get(object $plugin): string + { + $add_subscriber_interface = $this->addNeededMethods($plugin->main_class_code); + + $extension = []; + $extension[] = $plugin->comment . PHP_EOL . 'final class '; + $extension[] = $plugin->class_name . ' extends ' . $plugin->extends; + if ($add_subscriber_interface) + { + $extension[] = ' implements Joomla__' . '_c06c5116_6b9d_487c_9b09_5094ec4506a3___Power'; + } + $extension[] = PHP_EOL . '{' . PHP_EOL; + $extension[] = $plugin->main_class_code; + $extension[] = PHP_EOL . '}' . PHP_EOL; + + return $this->placeholder->update( + implode('', $extension), + $this->builder->allActive() + ); + } + + /** + * Ensures that the required methods are present in the plugin code. + * + * This method checks the plugin's code for the presence of required methods, + * particularly the method that indicates implementation of the SubscriberInterface. + * If the necessary method is missing, it adds it to the code. + * + * @param string $code The main code of the plugin, passed by reference. + * + * @return bool Returns true if the SubscriberInterface implementation is added or already present, false otherwise. + * + * @since 5.0.2 + */ + protected function addNeededMethods(string &$code): bool + { + // Parse the code to extract its structure, particularly its methods. + $code_structure = $this->parser->code($code); + + if (empty($code_structure['methods'])) + { + return false; + } + + // Check if methods are defined and if getSubscribedEvents is not present. + if (!$this->getSubscribedEvents($code_structure['methods'])) + { + // Attempt to add the getSubscribedEvents method. + $method = $this->addGetSubscribedEvents($code_structure['methods']); + if ($method !== null) + { + // Append the new method to the code and indicate that the interface must be added. + $code .= $method; + + return true; + } + + // Return false if the event method could not be added. + return false; + } + + // Return true if getSubscribedEvents is already present. + return true; + } + + /** + * Add the getSubscribedEvents method + * + * @param array $methods The plugin methods. + * + * @return string|null The getSubscribedEvents code + * + * @since 5.0.2 + */ + protected function addGetSubscribedEvents(array $methods): ?string + { + $events = []; + $counter = 0; + foreach ($methods as $method) + { + if ($method['access'] === 'public' && !$method['static'] && !$method['abstract']) + { + $events[$method['name']] = Indent::_(3) . "'{$method['name']}' => '{$method['name']}'"; + + // autoloaded when method start with 'on' + // so we can ignore adding the getSubscribedEvents + if (substr($method['name'], 0, 2) === 'on') + { + $counter++; + } + } + } + + if ($events === [] || $counter == count($events)) + { + return null; + } + + $method = []; + $method[] = PHP_EOL . PHP_EOL . Indent::_(1) . '/**'; + $method[] = Indent::_(1) . ' * Returns an array of events this subscriber will listen to.'; + $method[] = Indent::_(1) . ' *'; + $method[] = Indent::_(1) . ' * @return array'; + $method[] = Indent::_(1) . ' *'; + $method[] = Indent::_(1) . ' * @since 5.0.0'; + $method[] = Indent::_(1) . ' */'; + $method[] = Indent::_(1) . 'public static function getSubscribedEvents(): array'; + $method[] = Indent::_(1) . '{'; + $method[] = Indent::_(2) . 'return ['; + $method[] = implode(',' . PHP_EOL, $events); + $method[] = Indent::_(2) . '];'; + $method[] = Indent::_(1) . '}'; + + return implode(PHP_EOL, $method); + } + + /** + * Check if the getSubscribedEvents is set + * + * @param array $methods The plugin methods. + * + * @return bool + * + * @since 5.0.2 + */ + protected function getSubscribedEvents(array $methods): bool + { + foreach ($methods as $method) + { + if ($method['name'] === 'getSubscribedEvents' && $method['static'] && !$method['abstract']) + { + return true; + } + } + return false; + } +} + diff --git a/src/ec808f55-6703-46c0-8a6d-33c9d4e0e9fa/code.power b/src/ec808f55-6703-46c0-8a6d-33c9d4e0e9fa/code.power new file mode 100644 index 0000000..a70193c --- /dev/null +++ b/src/ec808f55-6703-46c0-8a6d-33c9d4e0e9fa/code.power @@ -0,0 +1,185 @@ + /** + * The Placeholder Class. + * + * @var Placeholder + * @since 5.0.2 + */ + protected Placeholder $placeholder; + + /** + * The ContentOne Class. + * + * @var Builder + * @since 5.0.2 + */ + protected Builder $builder; + + /** + * The Parser Class. + * + * @var Parser + * @since 5.0.2 + */ + protected Parser $parser; + + /** + * Constructor. + * + * @param Placeholder $placeholder The Placeholder Class. + * @param Builder $builder The Content One Class. + * @param Parser $parser The Parser Class. + * + * @since 5.0.2 + */ + public function __construct(Placeholder $placeholder, Builder $builder, Parser $parser) + { + $this->placeholder = $placeholder; + $this->builder = $builder; + $this->parser = $parser; + } + + /** + * Get the updated placeholder content for the given plugin. + * + * @param object $plugin The plugin object containing the necessary data. + * + * @return string The updated placeholder content. + * + * @since 5.0.2 + */ + public function get(object $plugin): string + { + $add_subscriber_interface = $this->addNeededMethods($plugin->main_class_code); + + $extension = []; + $extension[] = $plugin->comment . PHP_EOL . 'final class '; + $extension[] = $plugin->class_name . ' extends ' . $plugin->extends; + if ($add_subscriber_interface) + { + $extension[] = ' implements Joomla__' . '_c06c5116_6b9d_487c_9b09_5094ec4506a3___Power'; + } + $extension[] = PHP_EOL . '{' . PHP_EOL; + $extension[] = $plugin->main_class_code; + $extension[] = PHP_EOL . '}' . PHP_EOL; + + return $this->placeholder->update( + implode('', $extension), + $this->builder->allActive() + ); + } + + /** + * Ensures that the required methods are present in the plugin code. + * + * This method checks the plugin's code for the presence of required methods, + * particularly the method that indicates implementation of the SubscriberInterface. + * If the necessary method is missing, it adds it to the code. + * + * @param string $code The main code of the plugin, passed by reference. + * + * @return bool Returns true if the SubscriberInterface implementation is added or already present, false otherwise. + * + * @since 5.0.2 + */ + protected function addNeededMethods(string &$code): bool + { + // Parse the code to extract its structure, particularly its methods. + $code_structure = $this->parser->code($code); + + if (empty($code_structure['methods'])) + { + return false; + } + + // Check if methods are defined and if getSubscribedEvents is not present. + if (!$this->getSubscribedEvents($code_structure['methods'])) + { + // Attempt to add the getSubscribedEvents method. + $method = $this->addGetSubscribedEvents($code_structure['methods']); + if ($method !== null) + { + // Append the new method to the code and indicate that the interface must be added. + $code .= $method; + + return true; + } + + // Return false if the event method could not be added. + return false; + } + + // Return true if getSubscribedEvents is already present. + return true; + } + + /** + * Add the getSubscribedEvents method + * + * @param array $methods The plugin methods. + * + * @return string|null The getSubscribedEvents code + * + * @since 5.0.2 + */ + protected function addGetSubscribedEvents(array $methods): ?string + { + $events = []; + $counter = 0; + foreach ($methods as $method) + { + if ($method['access'] === 'public' && !$method['static'] && !$method['abstract']) + { + $events[$method['name']] = Indent::_(3) . "'{$method['name']}' => '{$method['name']}'"; + + // autoloaded when method start with 'on' + // so we can ignore adding the getSubscribedEvents + if (substr($method['name'], 0, 2) === 'on') + { + $counter++; + } + } + } + + if ($events === [] || $counter == count($events)) + { + return null; + } + + $method = []; + $method[] = PHP_EOL . PHP_EOL . Indent::_(1) . '/**'; + $method[] = Indent::_(1) . ' * Returns an array of events this subscriber will listen to.'; + $method[] = Indent::_(1) . ' *'; + $method[] = Indent::_(1) . ' * @return array'; + $method[] = Indent::_(1) . ' *'; + $method[] = Indent::_(1) . ' * @since 5.0.0'; + $method[] = Indent::_(1) . ' */'; + $method[] = Indent::_(1) . 'public static function getSubscribedEvents(): array'; + $method[] = Indent::_(1) . '{'; + $method[] = Indent::_(2) . 'return ['; + $method[] = implode(',' . PHP_EOL, $events); + $method[] = Indent::_(2) . '];'; + $method[] = Indent::_(1) . '}'; + + return implode(PHP_EOL, $method); + } + + /** + * Check if the getSubscribedEvents is set + * + * @param array $methods The plugin methods. + * + * @return bool + * + * @since 5.0.2 + */ + protected function getSubscribedEvents(array $methods): bool + { + foreach ($methods as $method) + { + if ($method['name'] === 'getSubscribedEvents' && $method['static'] && !$method['abstract']) + { + return true; + } + } + return false; + } \ No newline at end of file diff --git a/src/ec808f55-6703-46c0-8a6d-33c9d4e0e9fa/settings.json b/src/ec808f55-6703-46c0-8a6d-33c9d4e0e9fa/settings.json new file mode 100644 index 0000000..ae791e3 --- /dev/null +++ b/src/ec808f55-6703-46c0-8a6d-33c9d4e0e9fa/settings.json @@ -0,0 +1,38 @@ +{ + "add_head": "0", + "add_licensing_template": "2", + "extends": "", + "guid": "ec808f55-6703-46c0-8a6d-33c9d4e0e9fa", + "implements": [ + "914db7f5-82d8-4d3b-a1c1-eb476b1898c2" + ], + "load_selection": null, + "name": "Extension", + "power_version": "1.0.0", + "system_name": "JCB.Architecture.J4.Plugin.Extension", + "type": "final class", + "use_selection": { + "use_selection0": { + "use": "06453ada-e370-49f0-b262-e3f5a8ed0c2c", + "as": "default" + }, + "use_selection1": { + "use": "adfbe68a-6d22-43e5-aee8-2787e8c47e75", + "as": "Builder" + }, + "use_selection2": { + "use": "95d0e03f-24fd-4412-bc2e-f0899fcc3205", + "as": "default" + }, + "use_selection3": { + "use": "a68c010b-e92e-47d5-8a44-d23cfddeb6c6", + "as": "default" + } + }, + "extendsinterfaces": null, + "namespace": "[[[NamespacePrefix]]]\\Joomla\\[[[ComponentNamespace]]].Compiler.Architecture.JoomlaFour.Plugin.Extension", + "description": "Plugin Extension Class for Joomla 4\r\n\r\n@since 5.0.2", + "licensing_template": "\/**\r\n * @package Joomla.Component.Builder\r\n *\r\n * @created 4th September, 2022\r\n * @author Llewellyn van der Merwe \r\n * @git Joomla Component Builder \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/ed9591cb-0a03-400a-bf47-eaf78ab19b9d/settings.json b/src/ed9591cb-0a03-400a-bf47-eaf78ab19b9d/settings.json index e34003a..f3de077 100644 --- a/src/ed9591cb-0a03-400a-bf47-eaf78ab19b9d/settings.json +++ b/src/ed9591cb-0a03-400a-bf47-eaf78ab19b9d/settings.json @@ -30,7 +30,7 @@ } }, "extendsinterfaces": null, - "namespace": "VDM\\Joomla\\Componentbuilder.Compiler.Service.Extension", + "namespace": "[[[NamespacePrefix]]]\\Joomla\\[[[ComponentNamespace]]].Compiler.Service.Extension", "description": "Extension Script Service Provider\r\n\r\n@since 3.2.0", "implements_custom": "ServiceProviderInterface", "licensing_template": "\/**\r\n * @package Joomla.Component.Builder\r\n *\r\n * @created 4th September, 2022\r\n * @author Llewellyn van der Merwe \r\n * @git Joomla Component Builder \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", diff --git a/src/ef66b17c-ffae-414a-9067-20a63ba2bec5/README.md b/src/ef66b17c-ffae-414a-9067-20a63ba2bec5/README.md new file mode 100644 index 0000000..8268637 --- /dev/null +++ b/src/ef66b17c-ffae-414a-9067-20a63ba2bec5/README.md @@ -0,0 +1,52 @@ +``` +██████╗ ██████╗ ██╗ ██╗███████╗██████╗ +██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗ +██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝ +██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗ +██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║ +╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝ +``` +# interface StructureInterface (Details) +> namespace: **VDM\Joomla\Componentbuilder\Interfaces\Plugin** + +```uml +@startuml +interface StructureInterface #Lavender { + + build() : void +} + +note right of StructureInterface::build + Build the Plug-ins files, folders, url's and configure + + since: 5.0.0 + return: void +end note + +@enduml +``` + +The Power feature in JCB allows you to write PHP classes and their implementations, making it easy to include them in your Joomla project. JCB handles linking, autoloading, namespacing, and folder structure creation for you. + +By using the SPK (Super Power Key) in your custom code (replacing the class name in your code with the SPK), JCB will automatically pull the power from the repository into your project. This makes it available in your JCB instance, allowing you to edit it and include the class in your generated Joomla component. + +JCB uses placeholders like [[[`NamespacePrefix`]]] and [[[`ComponentNamespace`]]] in namespacing to prevent collisions and improve reusability across different JCB systems. You can also set the **JCB powers path** globally or per component under the **Dynamic Integration** tab, providing flexibility and easy maintainability. + +To add this specific Power to your project in JCB: + +> simply use this SPK +``` +Super---ef66b17c_ffae_414a_9067_20a63ba2bec5---Power +``` +> remember to replace the `---` with `___` to activate this Power in your code + +--- +``` + ██╗ ██████╗██████╗ + ██║██╔════╝██╔══██╗ + ██║██║ ██████╔╝ +██ ██║██║ ██╔══██╗ +╚█████╔╝╚██████╗██████╔╝ + ╚════╝ ╚═════╝╚═════╝ +``` +> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder) + diff --git a/src/ef66b17c-ffae-414a-9067-20a63ba2bec5/code.php b/src/ef66b17c-ffae-414a-9067-20a63ba2bec5/code.php new file mode 100644 index 0000000..f61d449 --- /dev/null +++ b/src/ef66b17c-ffae-414a-9067-20a63ba2bec5/code.php @@ -0,0 +1,30 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Componentbuilder\Interfaces\Plugin; + + +/** + * Structure Interface + * + * @since 5.0.0 + */ +interface StructureInterface +{ + /** + * Build the Plug-ins files, folders, url's and configure + * + * @return void + * @since 5.0.0 + */ + public function build(); +} + diff --git a/src/ef66b17c-ffae-414a-9067-20a63ba2bec5/code.power b/src/ef66b17c-ffae-414a-9067-20a63ba2bec5/code.power new file mode 100644 index 0000000..d066155 --- /dev/null +++ b/src/ef66b17c-ffae-414a-9067-20a63ba2bec5/code.power @@ -0,0 +1,7 @@ + /** + * Build the Plug-ins files, folders, url's and configure + * + * @return void + * @since 5.0.0 + */ + public function build(); \ No newline at end of file diff --git a/src/ef66b17c-ffae-414a-9067-20a63ba2bec5/settings.json b/src/ef66b17c-ffae-414a-9067-20a63ba2bec5/settings.json new file mode 100644 index 0000000..bafb8ee --- /dev/null +++ b/src/ef66b17c-ffae-414a-9067-20a63ba2bec5/settings.json @@ -0,0 +1,19 @@ +{ + "add_head": "0", + "add_licensing_template": "2", + "extends": "", + "guid": "ef66b17c-ffae-414a-9067-20a63ba2bec5", + "implements": null, + "load_selection": null, + "name": "StructureInterface", + "power_version": "1.0.0", + "system_name": "JCB.Interfaces.Plugin.StructureInterface", + "type": "interface", + "use_selection": null, + "extendsinterfaces": null, + "namespace": "[[[NamespacePrefix]]]\\Joomla\\[[[ComponentNamespace]]].Interfaces.Plugin.StructureInterface", + "description": "Structure Interface\r\n\r\n@since 5.0.0", + "licensing_template": "\/**\r\n * @package Joomla.Component.Builder\r\n *\r\n * @created 4th September, 2022\r\n * @author Llewellyn van der Merwe \r\n * @git Joomla Component Builder \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/ef97b03e-1018-447a-8d7e-30401b0257bb/code.php b/src/ef97b03e-1018-447a-8d7e-30401b0257bb/code.php index 5362e49..7a15ea8 100644 --- a/src/ef97b03e-1018-447a-8d7e-30401b0257bb/code.php +++ b/src/ef97b03e-1018-447a-8d7e-30401b0257bb/code.php @@ -13,7 +13,7 @@ namespace VDM\Joomla\Componentbuilder\Compiler\Model; use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler; -use VDM\Joomla\Componentbuilder\Compiler\Joomlaplugin\Data as Plugin; +use VDM\Joomla\Componentbuilder\Compiler\Interfaces\PluginDataInterface as Plugin; use VDM\Joomla\Utilities\ArrayHelper; use VDM\Joomla\Utilities\JsonHelper; diff --git a/src/ef97b03e-1018-447a-8d7e-30401b0257bb/settings.json b/src/ef97b03e-1018-447a-8d7e-30401b0257bb/settings.json index 1d9e097..55ba361 100644 --- a/src/ef97b03e-1018-447a-8d7e-30401b0257bb/settings.json +++ b/src/ef97b03e-1018-447a-8d7e-30401b0257bb/settings.json @@ -15,7 +15,7 @@ "as": "Compiler" }, "use_selection1": { - "use": "766a9524-37df-4604-91a7-b98a6150ee26", + "use": "8cc85656-a925-4a46-a49b-83c72167fd6a", "as": "Plugin" }, "use_selection2": { diff --git a/super-powers.json b/super-powers.json index 4fb5d24..81d53bd 100644 --- a/super-powers.json +++ b/super-powers.json @@ -65,9 +65,20 @@ "spk": "Super---037c7274_fb16_455d_989a_bf1da022620b---Power", "guid": "037c7274-fb16-455d-989a-bf1da022620b" }, + "03b75302-98ba-47ac-859f-1f49b738f66c": { + "name": "Infusion", + "type": "final class", + "namespace": "VDM\\Joomla\\Componentbuilder\\Compiler\\Joomlaplugin\\JoomlaThree", + "code": "src\/03b75302-98ba-47ac-859f-1f49b738f66c\/code.php", + "power": "src\/03b75302-98ba-47ac-859f-1f49b738f66c\/code.power", + "settings": "src\/03b75302-98ba-47ac-859f-1f49b738f66c\/settings.json", + "path": "src\/03b75302-98ba-47ac-859f-1f49b738f66c", + "spk": "Super---03b75302_98ba_47ac_859f_1f49b738f66c---Power", + "guid": "03b75302-98ba-47ac-859f-1f49b738f66c" + }, "0419081e-4cb3-4c65-8c6a-ffe941fb0f1c": { "name": "Infusion", - "type": "class", + "type": "final class", "namespace": "VDM\\Joomla\\Componentbuilder\\Compiler\\Power", "code": "src\/0419081e-4cb3-4c65-8c6a-ffe941fb0f1c\/code.php", "power": "src\/0419081e-4cb3-4c65-8c6a-ffe941fb0f1c\/code.power", @@ -98,6 +109,17 @@ "spk": "Super---05448890_e324_41a0_b6db_d804bfc241cc---Power", "guid": "05448890-e324-41a0-b6db-d804bfc241cc" }, + "058cfcd7-1f84-4cc6-8bcc-7672f316881d": { + "name": "Set", + "type": "final class", + "namespace": "VDM\\Joomla\\Componentbuilder\\Compiler\\Language", + "code": "src\/058cfcd7-1f84-4cc6-8bcc-7672f316881d\/code.php", + "power": "src\/058cfcd7-1f84-4cc6-8bcc-7672f316881d\/code.power", + "settings": "src\/058cfcd7-1f84-4cc6-8bcc-7672f316881d\/settings.json", + "path": "src\/058cfcd7-1f84-4cc6-8bcc-7672f316881d", + "spk": "Super---058cfcd7_1f84_4cc6_8bcc_7672f316881d---Power", + "guid": "058cfcd7-1f84-4cc6-8bcc-7672f316881d" + }, "05c49a1f-ba5b-4be1-b3d0-4a74c42f7a46": { "name": "Data", "type": "class", @@ -153,6 +175,17 @@ "spk": "Super---0a524af3_f647_4f62_a422_d7d36ebe749b---Power", "guid": "0a524af3-f647-4f62-a422-d7d36ebe749b" }, + "0b0e574c-aab4-4eaf-96d8-d7210d8ed93e": { + "name": "Purge", + "type": "final class", + "namespace": "VDM\\Joomla\\Componentbuilder\\Compiler\\Language", + "code": "src\/0b0e574c-aab4-4eaf-96d8-d7210d8ed93e\/code.php", + "power": "src\/0b0e574c-aab4-4eaf-96d8-d7210d8ed93e\/code.power", + "settings": "src\/0b0e574c-aab4-4eaf-96d8-d7210d8ed93e\/settings.json", + "path": "src\/0b0e574c-aab4-4eaf-96d8-d7210d8ed93e", + "spk": "Super---0b0e574c_aab4_4eaf_96d8_d7210d8ed93e---Power", + "guid": "0b0e574c-aab4-4eaf-96d8-d7210d8ed93e" + }, "0b45357f-b077-4337-92f3-65c1e19d36cd": { "name": "HiddenFields", "type": "final class", @@ -329,6 +362,17 @@ "spk": "Super---163fa7ca_21bd_4e7f_a618_26fe10b870fe---Power", "guid": "163fa7ca-21bd-4e7f-a618-26fe10b870fe" }, + "174f5c9c-5e03-4261-94ca-279ca76c710d": { + "name": "Data", + "type": "final class", + "namespace": "VDM\\Joomla\\Componentbuilder\\Compiler\\Joomlaplugin\\JoomlaFive", + "code": "src\/174f5c9c-5e03-4261-94ca-279ca76c710d\/code.php", + "power": "src\/174f5c9c-5e03-4261-94ca-279ca76c710d\/code.power", + "settings": "src\/174f5c9c-5e03-4261-94ca-279ca76c710d\/settings.json", + "path": "src\/174f5c9c-5e03-4261-94ca-279ca76c710d", + "spk": "Super---174f5c9c_5e03_4261_94ca_279ca76c710d---Power", + "guid": "174f5c9c-5e03-4261-94ca-279ca76c710d" + }, "17a728e9-d6cf-4060-9efb-241b0ff2f981": { "name": "Historycomponent", "type": "class", @@ -428,6 +472,17 @@ "spk": "Super---1cef0266_99e2_40d8_919f_c2ce32226b0a---Power", "guid": "1cef0266-99e2-40d8-919f-c2ce32226b0a" }, + "1d051a2f-0691-45a8-b3d9-d0c1adcd73bc": { + "name": "Insert", + "type": "final class", + "namespace": "VDM\\Joomla\\Componentbuilder\\Compiler\\Language", + "code": "src\/1d051a2f-0691-45a8-b3d9-d0c1adcd73bc\/code.php", + "power": "src\/1d051a2f-0691-45a8-b3d9-d0c1adcd73bc\/code.power", + "settings": "src\/1d051a2f-0691-45a8-b3d9-d0c1adcd73bc\/settings.json", + "path": "src\/1d051a2f-0691-45a8-b3d9-d0c1adcd73bc", + "spk": "Super---1d051a2f_0691_45a8_b3d9_d0c1adcd73bc---Power", + "guid": "1d051a2f-0691-45a8-b3d9-d0c1adcd73bc" + }, "1d0fd857-12ec-4f47-ab1c-124d85748e24": { "name": "Updateserver", "type": "class", @@ -582,6 +637,17 @@ "spk": "Super---23f2ca33_440a_4941_8e9a_4bc67522c0cb---Power", "guid": "23f2ca33-440a-4941-8e9a-4bc67522c0cb" }, + "23f459a4-7c2a-4cbf-b0a6-8a11954140a9": { + "name": "FieldsetExtension", + "type": "final class", + "namespace": "VDM\\Joomla\\Componentbuilder\\Compiler\\Creator", + "code": "src\/23f459a4-7c2a-4cbf-b0a6-8a11954140a9\/code.php", + "power": "src\/23f459a4-7c2a-4cbf-b0a6-8a11954140a9\/code.power", + "settings": "src\/23f459a4-7c2a-4cbf-b0a6-8a11954140a9\/settings.json", + "path": "src\/23f459a4-7c2a-4cbf-b0a6-8a11954140a9", + "spk": "Super---23f459a4_7c2a_4cbf_b0a6_8a11954140a9---Power", + "guid": "23f459a4-7c2a-4cbf-b0a6-8a11954140a9" + }, "24da9672-e47f-4bb1-b6c0-0ebfc17f0957": { "name": "CoreRule", "type": "final class", @@ -626,6 +692,17 @@ "spk": "Super---25c7ca86_6088_4f5f_b9fe_13504779c6ba---Power", "guid": "25c7ca86-6088-4f5f-b9fe-13504779c6ba" }, + "263f0227-3cc2-4a88-9818-edb20081c30c": { + "name": "Multilingual", + "type": "final class", + "namespace": "VDM\\Joomla\\Componentbuilder\\Compiler\\Language", + "code": "src\/263f0227-3cc2-4a88-9818-edb20081c30c\/code.php", + "power": "src\/263f0227-3cc2-4a88-9818-edb20081c30c\/code.power", + "settings": "src\/263f0227-3cc2-4a88-9818-edb20081c30c\/settings.json", + "path": "src\/263f0227-3cc2-4a88-9818-edb20081c30c", + "spk": "Super---263f0227_3cc2_4a88_9818_edb20081c30c---Power", + "guid": "263f0227-3cc2-4a88-9818-edb20081c30c" + }, "268b85ef-49f3-4c39-8187-bb12e38d19ee": { "name": "Dynamicpath", "type": "class", @@ -648,6 +725,17 @@ "spk": "Super---274a78d1_24c2_4486_b560_b86e9ae72872---Power", "guid": "274a78d1-24c2-4486-b560-b86e9ae72872" }, + "28c8eed4-58cf-4d40-9053-ad77b6edfa9d": { + "name": "Extension", + "type": "final class", + "namespace": "VDM\\Joomla\\Componentbuilder\\Compiler\\Architecture\\JoomlaFive\\Plugin", + "code": "src\/28c8eed4-58cf-4d40-9053-ad77b6edfa9d\/code.php", + "power": "src\/28c8eed4-58cf-4d40-9053-ad77b6edfa9d\/code.power", + "settings": "src\/28c8eed4-58cf-4d40-9053-ad77b6edfa9d\/settings.json", + "path": "src\/28c8eed4-58cf-4d40-9053-ad77b6edfa9d", + "spk": "Super---28c8eed4_58cf_4d40_9053_ad77b6edfa9d---Power", + "guid": "28c8eed4-58cf-4d40-9053-ad77b6edfa9d" + }, "28cac2bb-df04-454f-b4d6-923b573eb94e": { "name": "ModelWhmcsField", "type": "final class", @@ -890,6 +978,17 @@ "spk": "Super---33f5131e_4a5b_414b_95dd_d22227c2666d---Power", "guid": "33f5131e-4a5b-414b-95dd-d22227c2666d" }, + "344d36be-3949-4848-8cb0-e3d3d9d05c36": { + "name": "Translation", + "type": "final class", + "namespace": "VDM\\Joomla\\Componentbuilder\\Compiler\\Language", + "code": "src\/344d36be-3949-4848-8cb0-e3d3d9d05c36\/code.php", + "power": "src\/344d36be-3949-4848-8cb0-e3d3d9d05c36\/code.power", + "settings": "src\/344d36be-3949-4848-8cb0-e3d3d9d05c36\/settings.json", + "path": "src\/344d36be-3949-4848-8cb0-e3d3d9d05c36", + "spk": "Super---344d36be_3949_4848_8cb0_e3d3d9d05c36---Power", + "guid": "344d36be-3949-4848-8cb0-e3d3d9d05c36" + }, "3468b447-a929-4c28-84a1-f2c3a27e3127": { "name": "ModelExpertFieldInitiator", "type": "final class", @@ -901,6 +1000,17 @@ "spk": "Super---3468b447_a929_4c28_84a1_f2c3a27e3127---Power", "guid": "3468b447-a929-4c28-84a1-f2c3a27e3127" }, + "34daa4c8-45c3-4249-baa3-1bedf8ed3ebc": { + "name": "Structure", + "type": "class", + "namespace": "VDM\\Joomla\\Componentbuilder\\Compiler\\Joomlaplugin\\JoomlaFour", + "code": "src\/34daa4c8-45c3-4249-baa3-1bedf8ed3ebc\/code.php", + "power": "src\/34daa4c8-45c3-4249-baa3-1bedf8ed3ebc\/code.power", + "settings": "src\/34daa4c8-45c3-4249-baa3-1bedf8ed3ebc\/settings.json", + "path": "src\/34daa4c8-45c3-4249-baa3-1bedf8ed3ebc", + "spk": "Super---34daa4c8_45c3_4249_baa3_1bedf8ed3ebc---Power", + "guid": "34daa4c8-45c3-4249-baa3-1bedf8ed3ebc" + }, "34df20ec-67db-4e7e-be61-fb94d360c408": { "name": "CanDelete", "type": "final class", @@ -934,6 +1044,17 @@ "spk": "Super---355bf21a_f859_4528_9110_bcd2c6d05ea7---Power", "guid": "355bf21a-f859-4528-9110-bcd2c6d05ea7" }, + "361e08c0-5916-4b77-b6a2-c16a769bbc40": { + "name": "Data", + "type": "final class", + "namespace": "VDM\\Joomla\\Componentbuilder\\Compiler\\Joomlaplugin\\JoomlaFour", + "code": "src\/361e08c0-5916-4b77-b6a2-c16a769bbc40\/code.php", + "power": "src\/361e08c0-5916-4b77-b6a2-c16a769bbc40\/code.power", + "settings": "src\/361e08c0-5916-4b77-b6a2-c16a769bbc40\/settings.json", + "path": "src\/361e08c0-5916-4b77-b6a2-c16a769bbc40", + "spk": "Super---361e08c0_5916_4b77_b6a2_c16a769bbc40---Power", + "guid": "361e08c0-5916-4b77-b6a2-c16a769bbc40" + }, "369ae3f5-90db-43b9-aba9-ce5c83311c4e": { "name": "ServiceProvider", "type": "final class", @@ -967,6 +1088,17 @@ "spk": "Super---3730a000_ab64_477d_8b0f_70eaf71b517a---Power", "guid": "3730a000-ab64-477d-8b0f-70eaf71b517a" }, + "375543cd-5f2a-4893-982e-a73eaa55360d": { + "name": "Update", + "type": "final class", + "namespace": "VDM\\Joomla\\Componentbuilder\\Compiler\\Language", + "code": "src\/375543cd-5f2a-4893-982e-a73eaa55360d\/code.php", + "power": "src\/375543cd-5f2a-4893-982e-a73eaa55360d\/code.power", + "settings": "src\/375543cd-5f2a-4893-982e-a73eaa55360d\/settings.json", + "path": "src\/375543cd-5f2a-4893-982e-a73eaa55360d", + "spk": "Super---375543cd_5f2a_4893_982e_a73eaa55360d---Power", + "guid": "375543cd-5f2a-4893-982e-a73eaa55360d" + }, "38e1ca3e-1908-459a-be87-9f83b292058f": { "name": "JoomlaPower", "type": "class", @@ -1066,6 +1198,17 @@ "spk": "Super---402239e6_ceec_4ee0_af62_22d462417bf6---Power", "guid": "402239e6-ceec-4ee0-af62-22d462417bf6" }, + "40e17114-2193-4a61-9233-47b5f4193665": { + "name": "InfusionInterface", + "type": "interface", + "namespace": "VDM\\Joomla\\Componentbuilder\\Interfaces\\Plugin", + "code": "src\/40e17114-2193-4a61-9233-47b5f4193665\/code.php", + "power": "src\/40e17114-2193-4a61-9233-47b5f4193665\/code.power", + "settings": "src\/40e17114-2193-4a61-9233-47b5f4193665\/settings.json", + "path": "src\/40e17114-2193-4a61-9233-47b5f4193665", + "spk": "Super---40e17114_2193_4a61_9233_47b5f4193665---Power", + "guid": "40e17114-2193-4a61-9233-47b5f4193665" + }, "425b1107-933d-4436-87ac-63540ec101c5": { "name": "AllowAdd", "type": "final class", @@ -1222,7 +1365,7 @@ }, "4ad7020e-39ab-49ba-977b-de6084944502": { "name": "Fieldset", - "type": "class", + "type": "final class", "namespace": "VDM\\Joomla\\Componentbuilder\\Compiler\\Language", "code": "src\/4ad7020e-39ab-49ba-977b-de6084944502\/code.php", "power": "src\/4ad7020e-39ab-49ba-977b-de6084944502\/code.power", @@ -1374,6 +1517,17 @@ "spk": "Super---53cf9828_7ad4_4856_aac1_7c4c67bd3121---Power", "guid": "53cf9828-7ad4-4856-aac1-7c4c67bd3121" }, + "54e05f58-6538-42ec-ba46-b136f33e7cc7": { + "name": "MainXML", + "type": "final class", + "namespace": "VDM\\Joomla\\Componentbuilder\\Compiler\\Architecture\\JoomlaThree\\Plugin", + "code": "src\/54e05f58-6538-42ec-ba46-b136f33e7cc7\/code.php", + "power": "src\/54e05f58-6538-42ec-ba46-b136f33e7cc7\/code.power", + "settings": "src\/54e05f58-6538-42ec-ba46-b136f33e7cc7\/settings.json", + "path": "src\/54e05f58-6538-42ec-ba46-b136f33e7cc7", + "spk": "Super---54e05f58_6538_42ec_ba46_b136f33e7cc7---Power", + "guid": "54e05f58-6538-42ec-ba46-b136f33e7cc7" + }, "54ec57f6-2fc3-42e5-975e-1fabeacb845d": { "name": "UikitComp", "type": "final class", @@ -1583,6 +1737,17 @@ "spk": "Super---6034587d_82a3_4b19_ac58_40507f79122a---Power", "guid": "6034587d-82a3-4b19-ac58-40507f79122a" }, + "60c3ccc5-36dc-4480-b5c4-252c37212f61": { + "name": "Provider", + "type": "final class", + "namespace": "VDM\\Joomla\\Componentbuilder\\Compiler\\Architecture\\JoomlaFour\\Plugin", + "code": "src\/60c3ccc5-36dc-4480-b5c4-252c37212f61\/code.php", + "power": "src\/60c3ccc5-36dc-4480-b5c4-252c37212f61\/code.power", + "settings": "src\/60c3ccc5-36dc-4480-b5c4-252c37212f61\/settings.json", + "path": "src\/60c3ccc5-36dc-4480-b5c4-252c37212f61", + "spk": "Super---60c3ccc5_36dc_4480_b5c4_252c37212f61---Power", + "guid": "60c3ccc5-36dc-4480-b5c4-252c37212f61" + }, "63782f74-7b03-4745-aa40-0adf8ed4e704": { "name": "History", "type": "class", @@ -1594,6 +1759,17 @@ "spk": "Super---63782f74_7b03_4745_aa40_0adf8ed4e704---Power", "guid": "63782f74-7b03-4745-aa40-0adf8ed4e704" }, + "63865266-62e0-40bd-820c-e95449d12982": { + "name": "Provider", + "type": "final class", + "namespace": "VDM\\Joomla\\Componentbuilder\\Compiler\\Architecture\\JoomlaFive\\Plugin", + "code": "src\/63865266-62e0-40bd-820c-e95449d12982\/code.php", + "power": "src\/63865266-62e0-40bd-820c-e95449d12982\/code.power", + "settings": "src\/63865266-62e0-40bd-820c-e95449d12982\/settings.json", + "path": "src\/63865266-62e0-40bd-820c-e95449d12982", + "spk": "Super---63865266_62e0_40bd_820c_e95449d12982---Power", + "guid": "63865266-62e0-40bd-820c-e95449d12982" + }, "63dabe82-0f4a-4ade-9851-8518ade23de2": { "name": "Settings", "type": "final class", @@ -1737,6 +1913,17 @@ "spk": "Super---6dced3d9_7d10_4ea1_bcf6_a5e6af4b9c96---Power", "guid": "6dced3d9-7d10-4ea1-bcf6-a5e6af4b9c96" }, + "6dd2d394-8dde-4eb7-8505-cd7d345c49e3": { + "name": "Provider", + "type": "final class", + "namespace": "VDM\\Joomla\\Componentbuilder\\Compiler\\Architecture\\JoomlaThree\\Plugin", + "code": "src\/6dd2d394-8dde-4eb7-8505-cd7d345c49e3\/code.php", + "power": "src\/6dd2d394-8dde-4eb7-8505-cd7d345c49e3\/code.power", + "settings": "src\/6dd2d394-8dde-4eb7-8505-cd7d345c49e3\/settings.json", + "path": "src\/6dd2d394-8dde-4eb7-8505-cd7d345c49e3", + "spk": "Super---6dd2d394_8dde_4eb7_8505_cd7d345c49e3---Power", + "guid": "6dd2d394-8dde-4eb7-8505-cd7d345c49e3" + }, "6dfbf568-f3cd-4ea7-af04-6859447b5462": { "name": "Historyadminview", "type": "class", @@ -1860,8 +2047,8 @@ }, "766a9524-37df-4604-91a7-b98a6150ee26": { "name": "Data", - "type": "class", - "namespace": "VDM\\Joomla\\Componentbuilder\\Compiler\\Joomlaplugin", + "type": "final class", + "namespace": "VDM\\Joomla\\Componentbuilder\\Compiler\\Joomlaplugin\\JoomlaThree", "code": "src\/766a9524-37df-4604-91a7-b98a6150ee26\/code.php", "power": "src\/766a9524-37df-4604-91a7-b98a6150ee26\/code.power", "settings": "src\/766a9524-37df-4604-91a7-b98a6150ee26\/settings.json", @@ -1979,6 +2166,17 @@ "spk": "Super---7f515c18_d019_4d2d_9852_b2dc970985b3---Power", "guid": "7f515c18-d019-4d2d-9852-b2dc970985b3" }, + "7f75b300-534c-4f63-a368-6f4abc4cea58": { + "name": "Infusion", + "type": "final class", + "namespace": "VDM\\Joomla\\Componentbuilder\\Compiler\\Joomlaplugin\\JoomlaFive", + "code": "src\/7f75b300-534c-4f63-a368-6f4abc4cea58\/code.php", + "power": "src\/7f75b300-534c-4f63-a368-6f4abc4cea58\/code.power", + "settings": "src\/7f75b300-534c-4f63-a368-6f4abc4cea58\/settings.json", + "path": "src\/7f75b300-534c-4f63-a368-6f4abc4cea58", + "spk": "Super---7f75b300_534c_4f63_a368_6f4abc4cea58---Power", + "guid": "7f75b300-534c-4f63-a368-6f4abc4cea58" + }, "81212121-ad5c-43c5-b046-f2650864f690": { "name": "AccessSwitchList", "type": "final class", @@ -2023,6 +2221,17 @@ "spk": "Super---84c11075_570a_4907_9be0_9305e0fabe3c---Power", "guid": "84c11075-570a-4907-9be0-9305e0fabe3c" }, + "84fe58db-d64d-42c6-9b41-f80bcff34c7f": { + "name": "Infusion", + "type": "final class", + "namespace": "VDM\\Joomla\\Componentbuilder\\Compiler\\Joomlaplugin\\JoomlaFour", + "code": "src\/84fe58db-d64d-42c6-9b41-f80bcff34c7f\/code.php", + "power": "src\/84fe58db-d64d-42c6-9b41-f80bcff34c7f\/code.power", + "settings": "src\/84fe58db-d64d-42c6-9b41-f80bcff34c7f\/settings.json", + "path": "src\/84fe58db-d64d-42c6-9b41-f80bcff34c7f", + "spk": "Super---84fe58db_d64d_42c6_9b41_f80bcff34c7f---Power", + "guid": "84fe58db-d64d-42c6-9b41-f80bcff34c7f" + }, "8561f1f6-96c7-4e54-8869-0132116d57ce": { "name": "CheckBox", "type": "final class", @@ -2177,9 +2386,20 @@ "spk": "Super---8ca30d59_e56a_4cdd_bd8c_d9aad28f5903---Power", "guid": "8ca30d59-e56a-4cdd-bd8c-d9aad28f5903" }, + "8cc85656-a925-4a46-a49b-83c72167fd6a": { + "name": "PluginDataInterface", + "type": "interface", + "namespace": "VDM\\Joomla\\Componentbuilder\\Compiler\\Interfaces", + "code": "src\/8cc85656-a925-4a46-a49b-83c72167fd6a\/code.php", + "power": "src\/8cc85656-a925-4a46-a49b-83c72167fd6a\/code.power", + "settings": "src\/8cc85656-a925-4a46-a49b-83c72167fd6a\/settings.json", + "path": "src\/8cc85656-a925-4a46-a49b-83c72167fd6a", + "spk": "Super---8cc85656_a925_4a46_a49b_83c72167fd6a---Power", + "guid": "8cc85656-a925-4a46-a49b-83c72167fd6a" + }, "8eee7df5-2775-41a9-9372-c46c5939a252": { "name": "Language", - "type": "class", + "type": "final class", "namespace": "VDM\\Joomla\\Componentbuilder\\Compiler", "code": "src\/8eee7df5-2775-41a9-9372-c46c5939a252\/code.php", "power": "src\/8eee7df5-2775-41a9-9372-c46c5939a252\/code.power", @@ -2243,6 +2463,17 @@ "spk": "Super---9127e428_5dee_46cb_b3a9_ab5b91ea6df3---Power", "guid": "9127e428-5dee-46cb-b3a9-ab5b91ea6df3" }, + "914db7f5-82d8-4d3b-a1c1-eb476b1898c2": { + "name": "ExtensionInterface", + "type": "interface", + "namespace": "VDM\\Joomla\\Componentbuilder\\Compiler\\Interfaces\\Architecture\\Plugin", + "code": "src\/914db7f5-82d8-4d3b-a1c1-eb476b1898c2\/code.php", + "power": "src\/914db7f5-82d8-4d3b-a1c1-eb476b1898c2\/code.power", + "settings": "src\/914db7f5-82d8-4d3b-a1c1-eb476b1898c2\/settings.json", + "path": "src\/914db7f5-82d8-4d3b-a1c1-eb476b1898c2", + "spk": "Super---914db7f5_82d8_4d3b_a1c1_eb476b1898c2---Power", + "guid": "914db7f5-82d8-4d3b-a1c1-eb476b1898c2" + }, "92cc3144-1d3d-45b2-b49f-c7d356950033": { "name": "Customtabs", "type": "final class", @@ -2353,6 +2584,17 @@ "spk": "Super---961a2a2e_9f95_4b5f_b1c0_62ee783f9c66---Power", "guid": "961a2a2e-9f95-4b5f-b1c0-62ee783f9c66" }, + "97177ca9-a51a-4d24-81e1-8747b6e7d76c": { + "name": "MainXMLInterface", + "type": "interface", + "namespace": "VDM\\Joomla\\Componentbuilder\\Interfaces\\Architecture\\Plugin", + "code": "src\/97177ca9-a51a-4d24-81e1-8747b6e7d76c\/code.php", + "power": "src\/97177ca9-a51a-4d24-81e1-8747b6e7d76c\/code.power", + "settings": "src\/97177ca9-a51a-4d24-81e1-8747b6e7d76c\/settings.json", + "path": "src\/97177ca9-a51a-4d24-81e1-8747b6e7d76c", + "spk": "Super---97177ca9_a51a_4d24_81e1_8747b6e7d76c---Power", + "guid": "97177ca9-a51a-4d24-81e1-8747b6e7d76c" + }, "972c4de9-6f6f-463b-8eea-cc7cbdb96aba": { "name": "ItemsMethodListString", "type": "final class", @@ -2397,6 +2639,17 @@ "spk": "Super---98419ff3_6628_4539_8365_37f88378bced---Power", "guid": "98419ff3-6628-4539-8365-37f88378bced" }, + "98ac432d-df19-4c40-bb12-8104ea4362c8": { + "name": "ArchitecturePlugin", + "type": "class", + "namespace": "VDM\\Joomla\\Componentbuilder\\Compiler\\Service", + "code": "src\/98ac432d-df19-4c40-bb12-8104ea4362c8\/code.php", + "power": "src\/98ac432d-df19-4c40-bb12-8104ea4362c8\/code.power", + "settings": "src\/98ac432d-df19-4c40-bb12-8104ea4362c8\/settings.json", + "path": "src\/98ac432d-df19-4c40-bb12-8104ea4362c8", + "spk": "Super---98ac432d_df19_4c40_bb12_8104ea4362c8---Power", + "guid": "98ac432d-df19-4c40-bb12-8104ea4362c8" + }, "992a842f-1ba9-4a5c-b214-042459ffe038": { "name": "AllowEditInterface", "type": "interface", @@ -2595,6 +2848,17 @@ "spk": "Super---a5734b9e_a72d_494c_bc72_c3bc7506015f---Power", "guid": "a5734b9e-a72d-494c-bc72-c3bc7506015f" }, + "a5f658ff-3962-475d-8cf8-c91da562bf49": { + "name": "Extension", + "type": "final class", + "namespace": "VDM\\Joomla\\Componentbuilder\\Compiler\\Architecture\\JoomlaThree\\Plugin", + "code": "src\/a5f658ff-3962-475d-8cf8-c91da562bf49\/code.php", + "power": "src\/a5f658ff-3962-475d-8cf8-c91da562bf49\/code.power", + "settings": "src\/a5f658ff-3962-475d-8cf8-c91da562bf49\/settings.json", + "path": "src\/a5f658ff-3962-475d-8cf8-c91da562bf49", + "spk": "Super---a5f658ff_3962_475d_8cf8_c91da562bf49---Power", + "guid": "a5f658ff-3962-475d-8cf8-c91da562bf49" + }, "a601888d-12b6-427f-94ae-95004206e24e": { "name": "PermissionGlobalAction", "type": "final class", @@ -2661,6 +2925,17 @@ "spk": "Super---a7101bbc_3c81_4b52_a4aa_522291f7594b---Power", "guid": "a7101bbc-3c81-4b52-a4aa-522291f7594b" }, + "a7124f78-21c5-400e-984d-4c5463cb2315": { + "name": "MainXML", + "type": "final class", + "namespace": "VDM\\Joomla\\Componentbuilder\\Compiler\\Architecture\\JoomlaFive\\Plugin", + "code": "src\/a7124f78-21c5-400e-984d-4c5463cb2315\/code.php", + "power": "src\/a7124f78-21c5-400e-984d-4c5463cb2315\/code.power", + "settings": "src\/a7124f78-21c5-400e-984d-4c5463cb2315\/settings.json", + "path": "src\/a7124f78-21c5-400e-984d-4c5463cb2315", + "spk": "Super---a7124f78_21c5_400e_984d_4c5463cb2315---Power", + "guid": "a7124f78-21c5-400e-984d-4c5463cb2315" + }, "a74ac3b7-bb79-4639-8f14-54a8021be68b": { "name": "Customcode", "type": "class", @@ -2694,6 +2969,17 @@ "spk": "Super---a85451d3_a5c5_446a_90ae_0cf715a16d94---Power", "guid": "a85451d3-a5c5-446a-90ae-0cf715a16d94" }, + "a8c6158a-6fd2-476b-a5ea-c81f1ecd2356": { + "name": "Multilingual", + "type": "final class", + "namespace": "VDM\\Joomla\\Componentbuilder\\Compiler\\Builder", + "code": "src\/a8c6158a-6fd2-476b-a5ea-c81f1ecd2356\/code.php", + "power": "src\/a8c6158a-6fd2-476b-a5ea-c81f1ecd2356\/code.power", + "settings": "src\/a8c6158a-6fd2-476b-a5ea-c81f1ecd2356\/settings.json", + "path": "src\/a8c6158a-6fd2-476b-a5ea-c81f1ecd2356", + "spk": "Super---a8c6158a_6fd2_476b_a5ea_c81f1ecd2356---Power", + "guid": "a8c6158a-6fd2-476b-a5ea-c81f1ecd2356" + }, "a8d9583a-6ddb-4aac-b0d1-4c2d2d1c8c74": { "name": "ConfigFieldsetsGroupControl", "type": "final class", @@ -2719,7 +3005,7 @@ "a900b836-f2eb-4f13-8f28-b7cac839c7ff": { "name": "Structure", "type": "class", - "namespace": "VDM\\Joomla\\Componentbuilder\\Compiler\\Joomlaplugin", + "namespace": "VDM\\Joomla\\Componentbuilder\\Compiler\\Joomlaplugin\\JoomlaThree", "code": "src\/a900b836-f2eb-4f13-8f28-b7cac839c7ff\/code.php", "power": "src\/a900b836-f2eb-4f13-8f28-b7cac839c7ff\/code.power", "settings": "src\/a900b836-f2eb-4f13-8f28-b7cac839c7ff\/settings.json", @@ -2826,6 +3112,17 @@ "spk": "Super---af5beb21_214a_44f6_9090_7ea24c22e649---Power", "guid": "af5beb21-214a-44f6-9090-7ea24c22e649" }, + "af6d0e6a-61d2-4250-9e2f-bed5591e2786": { + "name": "MainXML", + "type": "final class", + "namespace": "VDM\\Joomla\\Componentbuilder\\Compiler\\Architecture\\JoomlaFour\\Plugin", + "code": "src\/af6d0e6a-61d2-4250-9e2f-bed5591e2786\/code.php", + "power": "src\/af6d0e6a-61d2-4250-9e2f-bed5591e2786\/code.power", + "settings": "src\/af6d0e6a-61d2-4250-9e2f-bed5591e2786\/settings.json", + "path": "src\/af6d0e6a-61d2-4250-9e2f-bed5591e2786", + "spk": "Super---af6d0e6a_61d2_4250_9e2f_bed5591e2786---Power", + "guid": "af6d0e6a-61d2-4250-9e2f-bed5591e2786" + }, "b0b26749-5e2c-4b56-8982-48172f2531fa": { "name": "ModelMediumField", "type": "final class", @@ -3222,6 +3519,17 @@ "spk": "Super---ca111518_e47c_4049_b1b2_cb010f23866f---Power", "guid": "ca111518-e47c-4049-b1b2-cb010f23866f" }, + "caf559ee-8337-4f07-9e4a-394d4e06afdc": { + "name": "Set", + "type": "final class", + "namespace": "VDM\\Joomla\\Componentbuilder\\Power\\Remote", + "code": "src\/caf559ee-8337-4f07-9e4a-394d4e06afdc\/code.php", + "power": "src\/caf559ee-8337-4f07-9e4a-394d4e06afdc\/code.power", + "settings": "src\/caf559ee-8337-4f07-9e4a-394d4e06afdc\/settings.json", + "path": "src\/caf559ee-8337-4f07-9e4a-394d4e06afdc", + "spk": "Super---caf559ee_8337_4f07_9e4a_394d4e06afdc---Power", + "guid": "caf559ee-8337-4f07-9e4a-394d4e06afdc" + }, "cb11e8d9-69c2-4095-831c-59908ea402e7": { "name": "Data", "type": "class", @@ -3332,9 +3640,20 @@ "spk": "Super---cfe62a32_8818_4bfb_8751_2f1e109b5336---Power", "guid": "cfe62a32-8818-4bfb-8751-2f1e109b5336" }, + "d05c22be-9641-47fb-8a7b-063c43e7f1bf": { + "name": "Structure", + "type": "class", + "namespace": "VDM\\Joomla\\Componentbuilder\\Compiler\\Joomlaplugin\\JoomlaFive", + "code": "src\/d05c22be-9641-47fb-8a7b-063c43e7f1bf\/code.php", + "power": "src\/d05c22be-9641-47fb-8a7b-063c43e7f1bf\/code.power", + "settings": "src\/d05c22be-9641-47fb-8a7b-063c43e7f1bf\/settings.json", + "path": "src\/d05c22be-9641-47fb-8a7b-063c43e7f1bf", + "spk": "Super---d05c22be_9641_47fb_8a7b_063c43e7f1bf---Power", + "guid": "d05c22be-9641-47fb-8a7b-063c43e7f1bf" + }, "d33b9278-c409-4aec-a047-b72f56712391": { "name": "Extractor", - "type": "class", + "type": "final class", "namespace": "VDM\\Joomla\\Componentbuilder\\Compiler\\Language", "code": "src\/d33b9278-c409-4aec-a047-b72f56712391\/code.php", "power": "src\/d33b9278-c409-4aec-a047-b72f56712391\/code.power", @@ -3431,6 +3750,17 @@ "spk": "Super---d6592c9b_93a6_41b3_83c7_c43a0a80cb83---Power", "guid": "d6592c9b-93a6-41b3-83c7-c43a0a80cb83" }, + "d6ae90a5-44b4-4ce4-aedc-86c90a242912": { + "name": "ProviderInterface", + "type": "interface", + "namespace": "VDM\\Joomla\\Componentbuilder\\Compiler\\Interfaces\\Architecture\\Plugin", + "code": "src\/d6ae90a5-44b4-4ce4-aedc-86c90a242912\/code.php", + "power": "src\/d6ae90a5-44b4-4ce4-aedc-86c90a242912\/code.power", + "settings": "src\/d6ae90a5-44b4-4ce4-aedc-86c90a242912\/settings.json", + "path": "src\/d6ae90a5-44b4-4ce4-aedc-86c90a242912", + "spk": "Super---d6ae90a5_44b4_4ce4_aedc_86c90a242912---Power", + "guid": "d6ae90a5-44b4-4ce4-aedc-86c90a242912" + }, "d7ba2d5d-10b6-470d-978d-9f91ea65ee75": { "name": "Field", "type": "class", @@ -3816,6 +4146,17 @@ "spk": "Super---ec7bdbf9_8377_446e_9f40_64e23ae96b59---Power", "guid": "ec7bdbf9-8377-446e-9f40-64e23ae96b59" }, + "ec808f55-6703-46c0-8a6d-33c9d4e0e9fa": { + "name": "Extension", + "type": "final class", + "namespace": "VDM\\Joomla\\Componentbuilder\\Compiler\\Architecture\\JoomlaFour\\Plugin", + "code": "src\/ec808f55-6703-46c0-8a6d-33c9d4e0e9fa\/code.php", + "power": "src\/ec808f55-6703-46c0-8a6d-33c9d4e0e9fa\/code.power", + "settings": "src\/ec808f55-6703-46c0-8a6d-33c9d4e0e9fa\/settings.json", + "path": "src\/ec808f55-6703-46c0-8a6d-33c9d4e0e9fa", + "spk": "Super---ec808f55_6703_46c0_8a6d_33c9d4e0e9fa---Power", + "guid": "ec808f55-6703-46c0-8a6d-33c9d4e0e9fa" + }, "ed314bd8-c995-4282-bcaa-5e0a68ac401b": { "name": "ConfigFieldsetsCustomfield", "type": "final class", @@ -3849,6 +4190,17 @@ "spk": "Super---eeb03266_22fd_45bb_953a_961bb6be3a54---Power", "guid": "eeb03266-22fd-45bb-953a-961bb6be3a54" }, + "ef66b17c-ffae-414a-9067-20a63ba2bec5": { + "name": "StructureInterface", + "type": "interface", + "namespace": "VDM\\Joomla\\Componentbuilder\\Interfaces\\Plugin", + "code": "src\/ef66b17c-ffae-414a-9067-20a63ba2bec5\/code.php", + "power": "src\/ef66b17c-ffae-414a-9067-20a63ba2bec5\/code.power", + "settings": "src\/ef66b17c-ffae-414a-9067-20a63ba2bec5\/settings.json", + "path": "src\/ef66b17c-ffae-414a-9067-20a63ba2bec5", + "spk": "Super---ef66b17c_ffae_414a_9067_20a63ba2bec5---Power", + "guid": "ef66b17c-ffae-414a-9067-20a63ba2bec5" + }, "ef687e42-dc25-4423-9dd4-ec6e9743cfb0": { "name": "DispenserInterface", "type": "interface",