Major upgrade #3

Merged
Llewellyn merged 11 commits from dev into master 2023-08-01 07:42:01 +00:00
86 changed files with 86 additions and 9007 deletions
Showing only changes of commit 85b094e8a5 - Show all commits

104
README.md
View File

@ -1,103 +1 @@
```
███████╗██╗ ██╗██████╗ ███████╗██████╗
██╔════╝██║ ██║██╔══██╗██╔════╝██╔══██╗
███████╗██║ ██║██████╔╝█████╗ ██████╔╝
╚════██║██║ ██║██╔═══╝ ██╔══╝ ██╔══██╗
███████║╚██████╔╝██║ ███████╗██║ ██║
╚══════╝ ╚═════╝ ╚═╝ ╚══════╝╚═╝ ╚═╝
██████╗ ██████╗ ██╗ ██╗███████╗██████╗ ███████╗
██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗██╔════╝
██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝███████╗
██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗╚════██║
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║███████║
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝╚══════╝
```
### What is JCB Super Powers?
The Joomla Component Builder (JCB) Super Power features are designed to enhance JCB's functionality and streamline the development process. These Super Powers enable developers to efficiently manage and share their custom powers across multiple JCB instances through repositories hosted on [https://git.vdm.dev/[username]/[repository-name]](https://git.vdm.dev). JCB Super Powers are managed using a combination of layers, events, tasks, methods, switches, and algorithms, which work together to provide powerful customization and extensibility options. More details on JCB Super Powers can be found in the [Super Powers Documentation](https://git.vdm.dev/joomla/super-powers/wiki).
In summary, JCB Super Powers offer a flexible and efficient way to manage and share functionalities between JCB instances. By utilizing a sophisticated system of layers, events, tasks, methods, switches, and algorithms, developers can seamlessly integrate JCB core powers and their custom powers. For more information on how to work with JCB Super Powers, refer to the [Super Powers User Guide](https://git.vdm.dev/joomla/super-powers/wiki).
### What can I find here?
This repository contains an index (see below) of all the approved powers within the JCB GUI. During the compilation of a component, these powers are automatically added to the repository, ensuring a well-organized and accessible collection of functionalities.
# Index of powers
- **Namespace**: [VDM\Joomla](#vdm-joomla)
- **trait Utilities** | [Details](src/79d765b3-7319-4988-9730-446c7f347020) | [Code](src/79d765b3-7319-4988-9730-446c7f347020/code.php) | [Settings](src/79d765b3-7319-4988-9730-446c7f347020/settings.json) | Super__79d765b3_7319_4988_9730_446c7f347020__Power
- **Namespace**: [VDM\Joomla\Abstraction](#vdm-joomla-abstraction)
- **abstract class BaseConfig** | [Details](src/ffbd4e1f-a342-4080-ab7d-1de3741bf319) | [Code](src/ffbd4e1f-a342-4080-ab7d-1de3741bf319/code.php) | [Settings](src/ffbd4e1f-a342-4080-ab7d-1de3741bf319/settings.json) | Super__ffbd4e1f_a342_4080_ab7d_1de3741bf319__Power
- **abstract class BaseTable** | [Details](src/e0f6ddbe-2a35-4537-942c-faff2ebd04f6) | [Code](src/e0f6ddbe-2a35-4537-942c-faff2ebd04f6/code.php) | [Settings](src/e0f6ddbe-2a35-4537-942c-faff2ebd04f6/settings.json) | Super__e0f6ddbe_2a35_4537_942c_faff2ebd04f6__Power
- **abstract class Database** | [Details](src/6cbef8f8-4813-48e3-b05a-65e1aea95171) | [Code](src/6cbef8f8-4813-48e3-b05a-65e1aea95171/code.php) | [Settings](src/6cbef8f8-4813-48e3-b05a-65e1aea95171/settings.json) | Super__6cbef8f8_4813_48e3_b05a_65e1aea95171__Power
- **abstract class Model** | [Details](src/584747d1-3a86-453d-b7a3-a2219de8d777) | [Code](src/584747d1-3a86-453d-b7a3-a2219de8d777/code.php) | [Settings](src/584747d1-3a86-453d-b7a3-a2219de8d777/settings.json) | Super__584747d1_3a86_453d_b7a3_a2219de8d777__Power
- **Namespace**: [VDM\Joomla\Componentbuilder](#vdm-joomla-componentbuilder)
- **class Table** | [Details](src/bfd1d6d5-56c1-4fe9-9fee-1c5910e1f5d8) | [Code](src/bfd1d6d5-56c1-4fe9-9fee-1c5910e1f5d8/code.php) | [Settings](src/bfd1d6d5-56c1-4fe9-9fee-1c5910e1f5d8/settings.json) | Super__bfd1d6d5_56c1_4fe9_9fee_1c5910e1f5d8__Power
- **Namespace**: [VDM\Joomla\Database](#vdm-joomla-database)
- **final class Insert** | [Details](src/524eb8f6-38d4-47dc-92ad-98b94e099ac0) | [Code](src/524eb8f6-38d4-47dc-92ad-98b94e099ac0/code.php) | [Settings](src/524eb8f6-38d4-47dc-92ad-98b94e099ac0/settings.json) | Super__524eb8f6_38d4_47dc_92ad_98b94e099ac0__Power
- **final class Load** | [Details](src/06f8eada-d59b-441c-b287-0aea1793da5a) | [Code](src/06f8eada-d59b-441c-b287-0aea1793da5a/code.php) | [Settings](src/06f8eada-d59b-441c-b287-0aea1793da5a/settings.json) | Super__06f8eada_d59b_441c_b287_0aea1793da5a__Power
- **final class Update** | [Details](src/cce56585-58b0-4f72-a92c-e2635ea52d83) | [Code](src/cce56585-58b0-4f72-a92c-e2635ea52d83/code.php) | [Settings](src/cce56585-58b0-4f72-a92c-e2635ea52d83/settings.json) | Super__cce56585_58b0_4f72_a92c_e2635ea52d83__Power
- **Namespace**: [VDM\Joomla\Interfaces](#vdm-joomla-interfaces)
- **interface FactoryInterface** | [Details](src/caf33c5d-858c-4f9a-894f-ab302ec5445a) | [Code](src/caf33c5d-858c-4f9a-894f-ab302ec5445a/code.php) | [Settings](src/caf33c5d-858c-4f9a-894f-ab302ec5445a/settings.json) | Super__caf33c5d_858c_4f9a_894f_ab302ec5445a__Power
- **interface InsertInterface** | [Details](src/ad12ca1c-d3ce-4e7f-88c5-c6c92bdedc48) | [Code](src/ad12ca1c-d3ce-4e7f-88c5-c6c92bdedc48/code.php) | [Settings](src/ad12ca1c-d3ce-4e7f-88c5-c6c92bdedc48/settings.json) | Super__ad12ca1c_d3ce_4e7f_88c5_c6c92bdedc48__Power
- **interface LoadInterface** | [Details](src/2ad31f74-f579-499d-b98b-c4f54fd615dd) | [Code](src/2ad31f74-f579-499d-b98b-c4f54fd615dd/code.php) | [Settings](src/2ad31f74-f579-499d-b98b-c4f54fd615dd/settings.json) | Super__2ad31f74_f579_499d_b98b_c4f54fd615dd__Power
- **interface ModelInterface** | [Details](src/8aef58c1-3f70-4bd4-b9e4-3f29fcd41cff) | [Code](src/8aef58c1-3f70-4bd4-b9e4-3f29fcd41cff/code.php) | [Settings](src/8aef58c1-3f70-4bd4-b9e4-3f29fcd41cff/settings.json) | Super__8aef58c1_3f70_4bd4_b9e4_3f29fcd41cff__Power
- **interface Tableinterface** | [Details](src/2da6d6c4-eb29-4d69-8bc2-36d96e916adf) | [Code](src/2da6d6c4-eb29-4d69-8bc2-36d96e916adf/code.php) | [Settings](src/2da6d6c4-eb29-4d69-8bc2-36d96e916adf/settings.json) | Super__2da6d6c4_eb29_4d69_8bc2_36d96e916adf__Power
- **interface UpdateInterface** | [Details](src/7179fde6-1e51-4b51-8545-7ca18f74a0f4) | [Code](src/7179fde6-1e51-4b51-8545-7ca18f74a0f4/code.php) | [Settings](src/7179fde6-1e51-4b51-8545-7ca18f74a0f4/settings.json) | Super__7179fde6_1e51_4b51_8545_7ca18f74a0f4__Power
- **Namespace**: [VDM\Joomla\Utilities](#vdm-joomla-utilities)
- **abstract class ArrayHelper** | [Details](src/0a59c65c-9daf-4bc9-baf4-e063ff9e6a8a) | [Code](src/0a59c65c-9daf-4bc9-baf4-e063ff9e6a8a/code.php) | [Settings](src/0a59c65c-9daf-4bc9-baf4-e063ff9e6a8a/settings.json) | Super__0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a__Power
- **abstract class FileHelper** | [Details](src/a223b31e-ea1d-4cdf-92ae-5f9becffaff0) | [Code](src/a223b31e-ea1d-4cdf-92ae-5f9becffaff0/code.php) | [Settings](src/a223b31e-ea1d-4cdf-92ae-5f9becffaff0/settings.json) | Super__a223b31e_ea1d_4cdf_92ae_5f9becffaff0__Power
- **abstract class GetHelper** | [Details](src/db87c339-5bb6-4291-a7ef-2c48ea1b06bc) | [Code](src/db87c339-5bb6-4291-a7ef-2c48ea1b06bc/code.php) | [Settings](src/db87c339-5bb6-4291-a7ef-2c48ea1b06bc/settings.json) | Super__db87c339_5bb6_4291_a7ef_2c48ea1b06bc__Power
- **abstract class GuidHelper** | [Details](src/9c513baf-b279-43fd-ae29-a585c8cbc4f0) | [Code](src/9c513baf-b279-43fd-ae29-a585c8cbc4f0/code.php) | [Settings](src/9c513baf-b279-43fd-ae29-a585c8cbc4f0/settings.json) | Super__9c513baf_b279_43fd_ae29_a585c8cbc4f0__Power
- **abstract class JsonHelper** | [Details](src/4b225c51-d293-48e4-b3f6-5136cf5c3f18) | [Code](src/4b225c51-d293-48e4-b3f6-5136cf5c3f18/code.php) | [Settings](src/4b225c51-d293-48e4-b3f6-5136cf5c3f18/settings.json) | Super__4b225c51_d293_48e4_b3f6_5136cf5c3f18__Power
- **abstract class MathHelper** | [Details](src/152c8793-8b75-4715-996a-257b9f65451c) | [Code](src/152c8793-8b75-4715-996a-257b9f65451c/code.php) | [Settings](src/152c8793-8b75-4715-996a-257b9f65451c/settings.json) | Super__152c8793_8b75_4715_996a_257b9f65451c__Power
- **abstract class ObjectHelper** | [Details](src/91004529-94a9-4590-b842-e7c6b624ecf5) | [Code](src/91004529-94a9-4590-b842-e7c6b624ecf5/code.php) | [Settings](src/91004529-94a9-4590-b842-e7c6b624ecf5/settings.json) | Super__91004529_94a9_4590_b842_e7c6b624ecf5__Power
- **abstract class StringHelper** | [Details](src/1f28cb53-60d9-4db1-b517-3c7dc6b429ef) | [Code](src/1f28cb53-60d9-4db1-b517-3c7dc6b429ef/code.php) | [Settings](src/1f28cb53-60d9-4db1-b517-3c7dc6b429ef/settings.json) | Super__1f28cb53_60d9_4db1_b517_3c7dc6b429ef__Power
- **Namespace**: [VDM\Joomla\Componentbuilder\Abstraction](#vdm-joomla-componentbuilder-abstraction)
- **abstract class BaseRegistry** | [Details](src/b84e947d-2a13-44f7-ac0f-3902ae55ae0c) | [Code](src/b84e947d-2a13-44f7-ac0f-3902ae55ae0c/code.php) | [Settings](src/b84e947d-2a13-44f7-ac0f-3902ae55ae0c/settings.json) | Super__b84e947d_2a13_44f7_ac0f_3902ae55ae0c__Power
- **abstract class Mapper** | [Details](src/44a3367c-f9e4-406b-b396-0f452bde0f03) | [Code](src/44a3367c-f9e4-406b-b396-0f452bde0f03/code.php) | [Settings](src/44a3367c-f9e4-406b-b396-0f452bde0f03/settings.json) | Super__44a3367c_f9e4_406b_b396_0f452bde0f03__Power
- **abstract class MapperSingle** | [Details](src/c6bbc3ee-58e7-4463-adba-5c5ae839ee36) | [Code](src/c6bbc3ee-58e7-4463-adba-5c5ae839ee36/code.php) | [Settings](src/c6bbc3ee-58e7-4463-adba-5c5ae839ee36/settings.json) | Super__c6bbc3ee_58e7_4463_adba_5c5ae839ee36__Power
- **Namespace**: [VDM\Joomla\Componentbuilder\Utilities](#vdm-joomla-componentbuilder-utilities)
- **abstract class FilterHelper** | [Details](src/cddcac51-9a46-47c4-ba59-105c70453bd6) | [Code](src/cddcac51-9a46-47c4-ba59-105c70453bd6/code.php) | [Settings](src/cddcac51-9a46-47c4-ba59-105c70453bd6/settings.json) | Super__cddcac51_9a46_47c4_ba59_105c70453bd6__Power
- **abstract class FormHelper** | [Details](src/1198aecf-84c6-45d2-aea8-d531aa4afdfa) | [Code](src/1198aecf-84c6-45d2-aea8-d531aa4afdfa/code.php) | [Settings](src/1198aecf-84c6-45d2-aea8-d531aa4afdfa/settings.json) | Super__1198aecf_84c6_45d2_aea8_d531aa4afdfa__Power
- **Namespace**: [VDM\Joomla\Utilities\Component](#vdm-joomla-utilities-component)
- **abstract class Helper** | [Details](src/640b5352-fb09-425f-a26e-cd44eda03f15) | [Code](src/640b5352-fb09-425f-a26e-cd44eda03f15/code.php) | [Settings](src/640b5352-fb09-425f-a26e-cd44eda03f15/settings.json) | Super__640b5352_fb09_425f_a26e_cd44eda03f15__Power
- **Namespace**: [VDM\Joomla\Utilities\String](#vdm-joomla-utilities-string)
- **abstract class ClassfunctionHelper** | [Details](src/30c5b4c2-f75f-4d15-869a-f8bfedd87358) | [Code](src/30c5b4c2-f75f-4d15-869a-f8bfedd87358/code.php) | [Settings](src/30c5b4c2-f75f-4d15-869a-f8bfedd87358/settings.json) | Super__30c5b4c2_f75f_4d15_869a_f8bfedd87358__Power
- **abstract class FieldHelper** | [Details](src/9ef0eb24-aae4-4f5a-99af-d724db44808f) | [Code](src/9ef0eb24-aae4-4f5a-99af-d724db44808f/code.php) | [Settings](src/9ef0eb24-aae4-4f5a-99af-d724db44808f/settings.json) | Super__9ef0eb24_aae4_4f5a_99af_d724db44808f__Power
- **abstract class NamespaceHelper** | [Details](src/ce8cf834-6bac-44fb-941c-861f7e046cc0) | [Code](src/ce8cf834-6bac-44fb-941c-861f7e046cc0/code.php) | [Settings](src/ce8cf834-6bac-44fb-941c-861f7e046cc0/settings.json) | Super__ce8cf834_6bac_44fb_941c_861f7e046cc0__Power
- **abstract class PluginHelper** | [Details](src/3cf76fbf-fd95-4a33-878e-7aff6d36b7f6) | [Code](src/3cf76fbf-fd95-4a33-878e-7aff6d36b7f6/code.php) | [Settings](src/3cf76fbf-fd95-4a33-878e-7aff6d36b7f6/settings.json) | Super__3cf76fbf_fd95_4a33_878e_7aff6d36b7f6__Power
- **abstract class TypeHelper** | [Details](src/a8935cbe-7701-40dc-bfd5-675f2d600954) | [Code](src/a8935cbe-7701-40dc-bfd5-675f2d600954/code.php) | [Settings](src/a8935cbe-7701-40dc-bfd5-675f2d600954/settings.json) | Super__a8935cbe_7701_40dc_bfd5_675f2d600954__Power
---
```
██╗ ██████╗ ██████╗ ███╗ ███╗██╗ █████╗
██║██╔═══██╗██╔═══██╗████╗ ████║██║ ██╔══██╗
██║██║ ██║██║ ██║██╔████╔██║██║ ███████║
██ ██║██║ ██║██║ ██║██║╚██╔╝██║██║ ██╔══██║
╚█████╔╝╚██████╔╝╚██████╔╝██║ ╚═╝ ██║███████╗██║ ██║
╚════╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
██████╗ ██████╗ ███╗ ███╗██████╗ ██████╗ ███╗ ██╗███████╗███╗ ██╗████████╗
██╔════╝██╔═══██╗████╗ ████║██╔══██╗██╔═══██╗████╗ ██║██╔════╝████╗ ██║╚══██╔══╝
██║ ██║ ██║██╔████╔██║██████╔╝██║ ██║██╔██╗ ██║█████╗ ██╔██╗ ██║ ██║
██║ ██║ ██║██║╚██╔╝██║██╔═══╝ ██║ ██║██║╚██╗██║██╔══╝ ██║╚██╗██║ ██║
╚██████╗╚██████╔╝██║ ╚═╝ ██║██║ ╚██████╔╝██║ ╚████║███████╗██║ ╚████║ ██║
╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═════╝ ╚═╝ ╚═══╝╚══════╝╚═╝ ╚═══╝ ╚═╝
██████╗ ██╗ ██╗██╗██╗ ██████╗ ███████╗██████╗
██╔══██╗██║ ██║██║██║ ██╔══██╗██╔════╝██╔══██╗
██████╔╝██║ ██║██║██║ ██║ ██║█████╗ ██████╔╝
██╔══██╗██║ ██║██║██║ ██║ ██║██╔══╝ ██╔══██╗
██████╔╝╚██████╔╝██║███████╗██████╔╝███████╗██║ ██║
╚═════╝ ╚═════╝ ╚═╝╚══════╝╚═════╝ ╚══════╝╚═╝ ╚═╝
```
> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder)
###POWERREADME###

View File

@ -1,145 +1 @@
```
██████╗ ██████╗ ██╗ ██╗███████╗██████╗
██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗
██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝
██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
```
# final class Load (Details)
> namespace: **VDM\Joomla\Database**
```uml
@startuml
class Load << (F,LightGreen) >> #Green {
+ rows(array $select, array $tables, ...) : ?array
+ items(array $select, array $tables, ...) : ?array
+ row(array $select, array $tables, ...) : ?array
+ item(array $select, array $tables, ...) : ?object
+ value(array $select, array $tables, ...) : mixed
# many(array $select, array $tables, ...) : bool
# one(array $select, array $tables, ...) : bool
# query(array $select, array $tables, ...) : ?object
}
note right of Load::rows
Load data rows as an array of associated arrays
since: 3.2.0
return: ?array
arguments:
array $select
array $tables
?array $where = null
?array $order = null
?int $limit = null
end note
note left of Load::items
Load data rows as an array of objects
since: 3.2.0
return: ?array
arguments:
array $select
array $tables
?array $where = null
?array $order = null
?int $limit = null
end note
note right of Load::row
Load data row as an associated array
since: 3.2.0
return: ?array
arguments:
array $select
array $tables
?array $where = null
?array $order = null
end note
note left of Load::item
Load data row as an object
since: 3.2.0
return: ?object
arguments:
array $select
array $tables
?array $where = null
?array $order = null
end note
note right of Load::value
Load one value from a row
since: 3.2.0
return: mixed
arguments:
array $select
array $tables
?array $where = null
?array $order = null
end note
note left of Load::many
Load many
since: 3.2.0
return: bool
arguments:
array $select
array $tables
?array $where = null
?array $order = null
?int $limit = null
end note
note right of Load::one
Load one
since: 3.2.0
return: bool
arguments:
array $select
array $tables
?array $where = null
?array $order = null
end note
note left of Load::query
Get the query object
since: 3.2.0
return: ?object
arguments:
array $select
array $tables
?array $where = null
?array $order = null
?int $limit = null
end note
@enduml
```
---
```
██╗ ██████╗██████╗
██║██╔════╝██╔══██╗
██║██║ ██████╔╝
██ ██║██║ ██╔══██╗
╚█████╔╝╚██████╗██████╔╝
╚════╝ ╚═════╝╚═════╝
```
> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder)
###POWERREADME###

View File

@ -9,373 +9,4 @@
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace VDM\Joomla\Database;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Interfaces\LoadInterface;
use VDM\Joomla\Abstraction\Database;
/**
* Database Load
*
* @since 3.2.0
*/
final class Load extends Database implements LoadInterface
{
/**
* Load data rows as an array of associated arrays
*
* @param array $select Array of selection keys
* @param array $tables Array of tables to search
* @param array|null $where Array of where key=>value match exist
* @param array|null $order Array of how to order the data
* @param int|null $limit Limit the number of values returned
*
* @return array|null
* @since 3.2.0
**/
public function rows(array $select, array $tables, ?array $where = null,
?array $order = null, ?int $limit = null): ?array
{
// set key if found
$key = '';
if (isset($select['key']))
{
if (is_string($select['key']))
{
$key = $select['key'];
}
unset($select['key']);
}
// check if we can get many rows
if ($this->many($select, $tables, $where, $order, $limit))
{
// return associated arrays from the table records
return $this->db->loadAssocList($key);
}
// data does not exist
return null;
}
/**
* Load data rows as an array of objects
*
* @param array $select Array of selection keys
* @param array $tables Array of tables to search
* @param array|null $where Array of where key=>value match exist
* @param array|null $order Array of how to order the data
* @param int|null $limit Limit the number of values returned
*
* @return array|null
* @since 3.2.0
**/
public function items(array $select, array $tables, ?array $where = null,
?array $order = null, ?int $limit = null): ?array
{
// set key if found
$key = '';
if (isset($select['key']))
{
if (is_string($select['key']))
{
$key = $select['key'];
}
unset($select['key']);
}
// check if we can get many rows
if ($this->many($select, $tables, $where, $order, $limit))
{
// return associated arrays from the table records
return $this->db->loadObjectList($key);
}
// data does not exist
return null;
}
/**
* Load data row as an associated array
*
* @param array $select Array of selection keys
* @param array $tables Array of tables to search
* @param array|null $where Array of where key=>value match exist
* @param array|null $order Array of how to order the data
*
* @return array|null
* @since 3.2.0
**/
public function row(array $select, array $tables, ?array $where = null, ?array $order = null): ?array
{
// check if we can get one row
if ($this->one($select, $tables, $where, $order))
{
return $this->db->loadAssoc();
}
// data does not exist
return null;
}
/**
* Load data row as an object
*
* @param array $select Array of selection keys
* @param array $tables Array of tables to search
* @param array|null $where Array of where key=>value match exist
* @param array|null $order Array of how to order the data
*
* @return object|null
* @since 3.2.0
**/
public function item(array $select, array $tables, ?array $where = null, ?array $order = null): ?object
{
// check if we can get one row
if ($this->one($select, $tables, $where, $order))
{
return $this->db->loadObject();
}
// data does not exist
return null;
}
/**
* Load one value from a row
*
* @param array $select Array of selection keys
* @param array $tables Array of tables to search
* @param array|null $where Array of where key=>value match exist
* @param array|null $order Array of how to order the data
*
* @return mixed
* @since 3.2.0
**/
public function value(array $select, array $tables, ?array $where = null, ?array $order = null)
{
// check if we can get one value
if ($this->one($select, $tables, $where, $order))
{
return $this->db->loadResult();
}
// data does not exist
return null;
}
/**
* Load many
*
* @param array $select Array of selection keys
* @param array $tables Array of tables to search
* @param array|null $where Array of where key=>value match exist
* @param array|null $order Array of how to order the data
* @param int|null $limit Limit the number of values returned
*
* @return bool
* @since 3.2.0
**/
protected function many(array $select, array $tables, ?array $where = null,
?array $order = null, ?int $limit = null): bool
{
// only do check if we have the table set
if (isset($tables['a']))
{
// get the query
$query = $this->query($select, $tables, $where, $order, $limit);
// Load the items
$this->db->setQuery($query);
$this->db->execute();
// check if we have values
if ($this->db->getNumRows())
{
return true;
}
}
// data does not exist
return false;
}
/**
* Load one
*
* @param array $select Array of selection keys
* @param array $tables Array of tables to search
* @param array|null $where Array of where key=>value match exist
* @param array|null $order Array of how to order the data
*
* @return bool
* @since 3.2.0
**/
protected function one(array $select, array $tables, ?array $where = null, ?array $order = null): bool
{
// only do check if we have the table set
if (isset($tables['a']))
{
// get the query
$query = $this->query($select, $tables, $where, $order);
// Load the item
$this->db->setQuery($query, 0, 1);
$this->db->execute();
// check if we have values
if ($this->db->getNumRows())
{
return true;
}
}
// data does not exist
return false;
}
/**
* Get the query object
*
* @param array $select Array of selection keys
* @param array $tables Array of tables to search
* @param array|null $where Array of where key=>value match exist
* @param array|null $order Array of how to order the data
* @param int|null $limit Limit the number of values returned
*
* @return object|null The query object (DatabaseQuery)
* @since 3.2.0
**/
protected function query(array $select, array $tables, ?array $where = null,
?array $order = null, ?int $limit = null): ?object
{
$query = $this->db->getQuery(true);
// check if we have an all selection set
if (isset($select['all']))
{
// all selection example array: ['all' => ['a.*', 'b.*']]
if (ArrayHelper::check($select['all']))
{
foreach ($select['all'] as $select_all)
{
// set target selection
$query->select(
$select_all
);
}
}
// all selection example string: ['all' =>'a.*']
elseif (is_string($select['all']))
{
// set target selection
$query->select(
$select['all']
);
}
unset($select['all']);
}
// load the table where join
if (ArrayHelper::check($select))
{
// set target selection
$query->select(
$this->db->quoteName(
array_keys($select),
array_values($select)
)
);
}
// set main table
$query->from($this->db->quoteName($this->getTable($tables['a']), 'a'));
// remove main table
unset($tables['a']);
// load the table where join
if (ArrayHelper::check($tables))
{
foreach ($tables as $as => $table)
{
$query->join(
'LEFT', $this->db->quoteName(
$this->getTable($table['name']), $as
) . ' ON (' . $this->db->quoteName($table['join_on'])
. ' = ' . $this->db->quoteName($table['as_on']) . ')'
);
}
}
// load the table where getters
if (ArrayHelper::check($where))
{
foreach ($where as $key => $value)
{
if (ArrayHelper::check($value))
{
if (isset($value['value']) && isset($value['operator']))
{
if (ArrayHelper::check($value['value']))
{
// add the where by array
$query->where($this->db->quoteName($key) . ' ' .
$value['operator'] . ' (' .
implode(',',
array_map(
fn($val) => $this->quote($val),
$value['value']
)
)
. ')'
);
}
else
{
// add the where
$query->where($this->db->quoteName($key) . ' ' .
$value['operator'] . ' ' . $this->quote($value['value']));
}
}
else
{
// we should through an exception
// for security we just return nothing for now
return null;
}
}
else
{
// add the where
$query->where($this->db->quoteName($key) .
' = ' . $this->quote($value));
}
}
}
// load the row ordering
if (ArrayHelper::check($order))
{
foreach ($order as $key => $direction)
{
// add the ordering
$query->order($this->db->quoteName($key) .
' ' . $direction);
}
}
// only return a limited number
if (is_numeric($limit))
{
$query->setLimit($limit);
}
return $query;
}
}
###POWERCODE###

View File

@ -1,352 +1 @@
/**
* Load data rows as an array of associated arrays
*
* @param array $select Array of selection keys
* @param array $tables Array of tables to search
* @param array|null $where Array of where key=>value match exist
* @param array|null $order Array of how to order the data
* @param int|null $limit Limit the number of values returned
*
* @return array|null
* @since 3.2.0
**/
public function rows(array $select, array $tables, ?array $where = null,
?array $order = null, ?int $limit = null): ?array
{
// set key if found
$key = '';
if (isset($select['key']))
{
if (is_string($select['key']))
{
$key = $select['key'];
}
unset($select['key']);
}
// check if we can get many rows
if ($this->many($select, $tables, $where, $order, $limit))
{
// return associated arrays from the table records
return $this->db->loadAssocList($key);
}
// data does not exist
return null;
}
/**
* Load data rows as an array of objects
*
* @param array $select Array of selection keys
* @param array $tables Array of tables to search
* @param array|null $where Array of where key=>value match exist
* @param array|null $order Array of how to order the data
* @param int|null $limit Limit the number of values returned
*
* @return array|null
* @since 3.2.0
**/
public function items(array $select, array $tables, ?array $where = null,
?array $order = null, ?int $limit = null): ?array
{
// set key if found
$key = '';
if (isset($select['key']))
{
if (is_string($select['key']))
{
$key = $select['key'];
}
unset($select['key']);
}
// check if we can get many rows
if ($this->many($select, $tables, $where, $order, $limit))
{
// return associated arrays from the table records
return $this->db->loadObjectList($key);
}
// data does not exist
return null;
}
/**
* Load data row as an associated array
*
* @param array $select Array of selection keys
* @param array $tables Array of tables to search
* @param array|null $where Array of where key=>value match exist
* @param array|null $order Array of how to order the data
*
* @return array|null
* @since 3.2.0
**/
public function row(array $select, array $tables, ?array $where = null, ?array $order = null): ?array
{
// check if we can get one row
if ($this->one($select, $tables, $where, $order))
{
return $this->db->loadAssoc();
}
// data does not exist
return null;
}
/**
* Load data row as an object
*
* @param array $select Array of selection keys
* @param array $tables Array of tables to search
* @param array|null $where Array of where key=>value match exist
* @param array|null $order Array of how to order the data
*
* @return object|null
* @since 3.2.0
**/
public function item(array $select, array $tables, ?array $where = null, ?array $order = null): ?object
{
// check if we can get one row
if ($this->one($select, $tables, $where, $order))
{
return $this->db->loadObject();
}
// data does not exist
return null;
}
/**
* Load one value from a row
*
* @param array $select Array of selection keys
* @param array $tables Array of tables to search
* @param array|null $where Array of where key=>value match exist
* @param array|null $order Array of how to order the data
*
* @return mixed
* @since 3.2.0
**/
public function value(array $select, array $tables, ?array $where = null, ?array $order = null)
{
// check if we can get one value
if ($this->one($select, $tables, $where, $order))
{
return $this->db->loadResult();
}
// data does not exist
return null;
}
/**
* Load many
*
* @param array $select Array of selection keys
* @param array $tables Array of tables to search
* @param array|null $where Array of where key=>value match exist
* @param array|null $order Array of how to order the data
* @param int|null $limit Limit the number of values returned
*
* @return bool
* @since 3.2.0
**/
protected function many(array $select, array $tables, ?array $where = null,
?array $order = null, ?int $limit = null): bool
{
// only do check if we have the table set
if (isset($tables['a']))
{
// get the query
$query = $this->query($select, $tables, $where, $order, $limit);
// Load the items
$this->db->setQuery($query);
$this->db->execute();
// check if we have values
if ($this->db->getNumRows())
{
return true;
}
}
// data does not exist
return false;
}
/**
* Load one
*
* @param array $select Array of selection keys
* @param array $tables Array of tables to search
* @param array|null $where Array of where key=>value match exist
* @param array|null $order Array of how to order the data
*
* @return bool
* @since 3.2.0
**/
protected function one(array $select, array $tables, ?array $where = null, ?array $order = null): bool
{
// only do check if we have the table set
if (isset($tables['a']))
{
// get the query
$query = $this->query($select, $tables, $where, $order);
// Load the item
$this->db->setQuery($query, 0, 1);
$this->db->execute();
// check if we have values
if ($this->db->getNumRows())
{
return true;
}
}
// data does not exist
return false;
}
/**
* Get the query object
*
* @param array $select Array of selection keys
* @param array $tables Array of tables to search
* @param array|null $where Array of where key=>value match exist
* @param array|null $order Array of how to order the data
* @param int|null $limit Limit the number of values returned
*
* @return object|null The query object (DatabaseQuery)
* @since 3.2.0
**/
protected function query(array $select, array $tables, ?array $where = null,
?array $order = null, ?int $limit = null): ?object
{
$query = $this->db->getQuery(true);
// check if we have an all selection set
if (isset($select['all']))
{
// all selection example array: ['all' => ['a.*', 'b.*']]
if (ArrayHelper::check($select['all']))
{
foreach ($select['all'] as $select_all)
{
// set target selection
$query->select(
$select_all
);
}
}
// all selection example string: ['all' =>'a.*']
elseif (is_string($select['all']))
{
// set target selection
$query->select(
$select['all']
);
}
unset($select['all']);
}
// load the table where join
if (ArrayHelper::check($select))
{
// set target selection
$query->select(
$this->db->quoteName(
array_keys($select),
array_values($select)
)
);
}
// set main table
$query->from($this->db->quoteName($this->getTable($tables['a']), 'a'));
// remove main table
unset($tables['a']);
// load the table where join
if (ArrayHelper::check($tables))
{
foreach ($tables as $as => $table)
{
$query->join(
'LEFT', $this->db->quoteName(
$this->getTable($table['name']), $as
) . ' ON (' . $this->db->quoteName($table['join_on'])
. ' = ' . $this->db->quoteName($table['as_on']) . ')'
);
}
}
// load the table where getters
if (ArrayHelper::check($where))
{
foreach ($where as $key => $value)
{
if (ArrayHelper::check($value))
{
if (isset($value['value']) && isset($value['operator']))
{
if (ArrayHelper::check($value['value']))
{
// add the where by array
$query->where($this->db->quoteName($key) . ' ' .
$value['operator'] . ' (' .
implode(',',
array_map(
fn($val) => $this->quote($val),
$value['value']
)
)
. ')'
);
}
else
{
// add the where
$query->where($this->db->quoteName($key) . ' ' .
$value['operator'] . ' ' . $this->quote($value['value']));
}
}
else
{
// we should through an exception
// for security we just return nothing for now
return null;
}
}
else
{
// add the where
$query->where($this->db->quoteName($key) .
' = ' . $this->quote($value));
}
}
}
// load the row ordering
if (ArrayHelper::check($order))
{
foreach ($order as $key => $direction)
{
// add the ordering
$query->order($this->db->quoteName($key) .
' ' . $direction);
}
}
// only return a limited number
if (is_numeric($limit))
{
$query->setLimit($limit);
}
return $query;
}
###CODEPOWER###

View File

@ -1,25 +1 @@
{
"add_head": "0",
"add_licensing_template": "2",
"extends": "6cbef8f8-4813-48e3-b05a-65e1aea95171",
"guid": "06f8eada-d59b-441c-b287-0aea1793da5a",
"implements": [
"2ad31f74-f579-499d-b98b-c4f54fd615dd"
],
"load_selection": null,
"name": "Load",
"power_version": "1.0.0",
"system_name": "VDM.Database.Load",
"type": "final class",
"use_selection": {
"use_selection0": {
"use": "0a59c65c-9daf-4bc9-baf4-e063ff9e6a8a",
"as": "default"
}
},
"namespace": "VDM\\Joomla\\Database.Load",
"description": "Database Load\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 <https:\/\/dev.vdm.io>\r\n * @git Joomla Component Builder <https:\/\/git.vdm.dev\/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": ""
}
###POWERLINKER###

View File

@ -1,52 +1 @@
```
██████╗ ██████╗ ██╗ ██╗███████╗██████╗
██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗
██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝
██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
```
# abstract class ArrayHelper (Details)
> namespace: **VDM\Joomla\Utilities**
```uml
@startuml
abstract ArrayHelper #Orange {
+ {static} check($array, $removeEmptyString = false)
+ {static} merge($arrays) : ?array
+ {static} intersect($a_array, $b_array) : bool
}
note right of ArrayHelper::check
Check if have an array with a length
since: 3.2.0
end note
note right of ArrayHelper::merge
Merge an array of array's
since: 3.0.9
return: ?array
end note
note right of ArrayHelper::intersect
Check if arrays intersect
since: 3.1.1
return: bool
end note
@enduml
```
---
```
██╗ ██████╗██████╗
██║██╔════╝██╔══██╗
██║██║ ██████╔╝
██ ██║██║ ██╔══██╗
╚█████╔╝╚██████╗██████╔╝
╚════╝ ╚═════╝╚═════╝
```
> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder)
###POWERREADME###

View File

@ -9,99 +9,4 @@
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace VDM\Joomla\Utilities;
/**
* Some array tricks helper
*
* @since 3.0.9
*/
abstract class ArrayHelper
{
/**
* Check if have an array with a length
*
* @input array The array to check
*
* @returns int|false number of items in array on success
*
* @since 3.2.0
*/
public static function check($array, $removeEmptyString = false)
{
if (is_array($array) && ($nr = count((array) $array)) > 0)
{
// also make sure the empty strings are removed
if ($removeEmptyString)
{
$array = array_filter($array);
if ($array === [])
{
return false;
}
return count($array);
}
return $nr;
}
return false;
}
/**
* Merge an array of array's
*
* @input array The arrays you would like to merge
*
* @returns array|null merged array on success
*
* @since 3.0.9
*/
public static function merge($arrays): ?array
{
if(self::check($arrays))
{
$merged = [];
foreach ($arrays as $array)
{
if (self::check($array))
{
$merged = array_merge($merged, $array);
}
}
return $merged;
}
return null;
}
/**
* Check if arrays intersect
*
* @input array The first array
* @input array The second array
*
* @returns bool true if intersect else false
*
* @since 3.1.1
*/
public static function intersect($a_array, $b_array): bool
{
// flip the second array
$b_array = array_flip($b_array);
// loop the first array
foreach ($a_array as $v)
{
if (isset($b_array[$v]))
{
return true;
}
}
return false;
}
}
###POWERCODE###

View File

@ -1,83 +1 @@
/**
* Check if have an array with a length
*
* @input array The array to check
*
* @returns int|false number of items in array on success
*
* @since 3.2.0
*/
public static function check($array, $removeEmptyString = false)
{
if (is_array($array) && ($nr = count((array) $array)) > 0)
{
// also make sure the empty strings are removed
if ($removeEmptyString)
{
$array = array_filter($array);
if ($array === [])
{
return false;
}
return count($array);
}
return $nr;
}
return false;
}
/**
* Merge an array of array's
*
* @input array The arrays you would like to merge
*
* @returns array|null merged array on success
*
* @since 3.0.9
*/
public static function merge($arrays): ?array
{
if(self::check($arrays))
{
$merged = [];
foreach ($arrays as $array)
{
if (self::check($array))
{
$merged = array_merge($merged, $array);
}
}
return $merged;
}
return null;
}
/**
* Check if arrays intersect
*
* @input array The first array
* @input array The second array
*
* @returns bool true if intersect else false
*
* @since 3.1.1
*/
public static function intersect($a_array, $b_array): bool
{
// flip the second array
$b_array = array_flip($b_array);
// loop the first array
foreach ($a_array as $v)
{
if (isset($b_array[$v]))
{
return true;
}
}
return false;
}
###CODEPOWER###

View File

@ -1,18 +1 @@
{
"add_head": "0",
"add_licensing_template": "2",
"extends": "0",
"guid": "0a59c65c-9daf-4bc9-baf4-e063ff9e6a8a",
"implements": null,
"load_selection": null,
"name": "ArrayHelper",
"power_version": "1.0.0",
"system_name": "Utilities Array Helper",
"type": "abstract class",
"use_selection": null,
"namespace": "VDM\\Joomla\\Utilities.ArrayHelper",
"description": "Some array tricks helper\r\n\r\n@since 3.0.9",
"licensing_template": "\/**\r\n * @package Joomla.Component.Builder\r\n *\r\n * @created 3rd September, 2020\r\n * @author Llewellyn van der Merwe <https:\/\/dev.vdm.io>\r\n * @git Joomla Component Builder <https:\/\/git.vdm.dev\/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": ""
}
###POWERLINKER###

View File

@ -1,108 +1 @@
```
██████╗ ██████╗ ██╗ ██╗███████╗██████╗
██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗
██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝
██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
```
# abstract class StringHelper (Details)
> namespace: **VDM\Joomla\Utilities**
```uml
@startuml
abstract StringHelper #Orange {
+ static $langTag
+ {static} check($string) : bool
+ {static} shorten($string, $length = 40, ...)
+ {static} safe($string, $type = 'L', ...)
+ {static} transliterate($string)
+ {static} html($var, $charset = 'UTF-8', ...)
+ {static} numbers($string)
+ {static} number($x)
+ {static} random(int $size) : string
}
note right of StringHelper::check
Check if we have a string with a length
since: 3.0.9
return: bool
end note
note left of StringHelper::shorten
Shorten a string
since: 3.0.9
arguments:
$string
$length = 40
$addTip = true
end note
note right of StringHelper::safe
Making strings safe (various ways)
since: 3.0.9
arguments:
$string
$type = 'L'
$spacer = '_'
$replaceNumbers = true
$keepOnlyCharacters = true
end note
note left of StringHelper::transliterate
Convert none English strings to code usable string
since: 3.0.9
end note
note right of StringHelper::html
make sure a string is HTML save
since: 3.0.9
arguments:
$var
$charset = 'UTF-8'
$shorten = false
$length = 40
$addTip = true
end note
note left of StringHelper::numbers
Convert all int in a string to an English word string
since: 3.0.9
end note
note right of StringHelper::number
Convert an integer into an English word string
Thanks to Tom Nicholson <http://php.net/manual/en/function.strval.php#41988>
since: 3.0.9
end note
note left of StringHelper::random
Random Key
since: 3.0.9
return: string
end note
@enduml
```
---
```
██╗ ██████╗██████╗
██║██╔════╝██╔══██╗
██║██║ ██████╔╝
██ ██║██║ ██╔══██╗
╚█████╔╝╚██████╗██████╔╝
╚════╝ ╚═════╝╚═════╝
```
> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder)
###POWERREADME###

View File

@ -9,408 +9,4 @@
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace VDM\Joomla\Utilities;
use Joomla\CMS\Filter\InputFilter;
use Joomla\CMS\Language\Language;
use VDM\Joomla\Utilities\Component\Helper;
/**
* Some string tricks
*
* @since 3.0.9
*/
abstract class StringHelper
{
/**
* The Main Active Language
*
* @var string
*
* @since 3.0.9
*/
public static $langTag;
/**
* Check if we have a string with a length
*
* @input string $string The string to check
*
* @returns bool true on success
*
* @since 3.0.9
*/
public static function check($string): bool
{
return is_string($string) && strlen($string) > 0;
}
/**
* Shorten a string
*
* @input string The you would like to shorten
*
* @returns string on success
*
* @since 3.0.9
*/
public static function shorten($string, $length = 40, $addTip = true)
{
if (self::check($string))
{
$initial = strlen((string) $string);
$words = preg_split('/([\s\n\r]+)/', (string) $string, null, PREG_SPLIT_DELIM_CAPTURE);
$words_count = count((array)$words);
$word_length = 0;
$last_word = 0;
for (; $last_word < $words_count; ++$last_word)
{
$word_length += strlen($words[$last_word]);
if ($word_length > $length)
{
break;
}
}
$newString = implode(array_slice($words, 0, $last_word));
$final = strlen($newString);
if ($initial !== $final && $addTip)
{
$title = self::shorten($string, 400 , false);
return '<span class="hasTip" title="' . $title . '" style="cursor:help">' . trim($newString) . '...</span>';
}
elseif ($initial !== $final && !$addTip)
{
return trim($newString) . '...';
}
}
return $string;
}
/**
* Making strings safe (various ways)
*
* @input string The you would like to make safe
*
* @returns string on success
*
* @since 3.0.9
*/
public static function safe($string, $type = 'L', $spacer = '_', $replaceNumbers = true, $keepOnlyCharacters = true)
{
if ($replaceNumbers === true)
{
// remove all numbers and replace with English text version (works well only up to millions)
$string = self::numbers($string);
}
// 0nly continue if we have a string
if (self::check($string))
{
// create file name without the extension that is safe
if ($type === 'filename')
{
// make sure VDM is not in the string
$string = str_replace('VDM', 'vDm', (string) $string);
// Remove anything which isn't a word, whitespace, number
// or any of the following caracters -_()
// If you don't need to handle multi-byte characters
// you can use preg_replace rather than mb_ereg_replace
// Thanks @Łukasz Rysiak!
// $string = mb_ereg_replace("([^\w\s\d\-_\(\)])", '', $string);
$string = preg_replace("([^\w\s\d\-_\(\)])", '', $string);
// http://stackoverflow.com/a/2021729/1429677
return preg_replace('/\s+/', ' ', (string) $string);
}
// remove all other characters
$string = trim((string) $string);
$string = preg_replace('/'.$spacer.'+/', ' ', $string);
$string = preg_replace('/\s+/', ' ', $string);
// Transliterate string
$string = self::transliterate($string);
// remove all and keep only characters
if ($keepOnlyCharacters)
{
$string = preg_replace("/[^A-Za-z ]/", '', (string) $string);
}
// keep both numbers and characters
else
{
$string = preg_replace("/[^A-Za-z0-9 ]/", '', (string) $string);
}
// select final adaptations
if ($type === 'L' || $type === 'strtolower')
{
// replace white space with underscore
$string = preg_replace('/\s+/', (string) $spacer, (string) $string);
// default is to return lower
return strtolower($string);
}
elseif ($type === 'W')
{
// return a string with all first letter of each word uppercase(no underscore)
return ucwords(strtolower($string));
}
elseif ($type === 'w' || $type === 'word')
{
// return a string with all lowercase(no underscore)
return strtolower($string);
}
elseif ($type === 'Ww' || $type === 'Word')
{
// return a string with first letter of the first word uppercase and all the rest lowercase(no underscore)
return ucfirst(strtolower($string));
}
elseif ($type === 'WW' || $type === 'WORD')
{
// return a string with all the uppercase(no underscore)
return strtoupper($string);
}
elseif ($type === 'U' || $type === 'strtoupper')
{
// replace white space with underscore
$string = preg_replace('/\s+/', (string) $spacer, $string);
// return all upper
return strtoupper($string);
}
elseif ($type === 'F' || $type === 'ucfirst')
{
// replace white space with underscore
$string = preg_replace('/\s+/', (string) $spacer, $string);
// return with first character to upper
return ucfirst(strtolower($string));
}
elseif ($type === 'cA' || $type === 'cAmel' || $type === 'camelcase')
{
// convert all words to first letter uppercase
$string = ucwords(strtolower($string));
// remove white space
$string = preg_replace('/\s+/', '', $string);
// now return first letter lowercase
return lcfirst($string);
}
// return string
return $string;
}
// not a string
return '';
}
/**
* Convert none English strings to code usable string
*
* @input an string
*
* @returns a string
*
* @since 3.0.9
*/
public static function transliterate($string)
{
// set tag only once
if (!self::check(self::$langTag))
{
// get global value
self::$langTag = Helper::getParams()->get('language', 'en-GB');
}
// Transliterate on the language requested
$lang = Language::getInstance(self::$langTag);
return $lang->transliterate($string);
}
/**
* make sure a string is HTML save
*
* @input an html string
*
* @returns a string
*
* @since 3.0.9
*/
public static function html($var, $charset = 'UTF-8', $shorten = false, $length = 40, $addTip = true)
{
if (self::check($var))
{
$filter = new InputFilter();
$string = $filter->clean(
html_entity_decode(
htmlentities(
(string) $var,
ENT_COMPAT,
$charset
)
),
'HTML'
);
if ($shorten)
{
return self::shorten($string, $length, $addTip);
}
return $string;
}
else
{
return '';
}
}
/**
* Convert all int in a string to an English word string
*
* @input an string with numbers
*
* @returns a string
*
* @since 3.0.9
*/
public static function numbers($string)
{
// set numbers array
$numbers = [];
$search_replace= [];
// first get all numbers
preg_match_all('!\d+!', (string) $string, $numbers);
// check if we have any numbers
if (isset($numbers[0]) && ArrayHelper::check($numbers[0]))
{
foreach ($numbers[0] as $number)
{
$search_replace[$number] = self::number((int)$number);
}
// now replace numbers in string
$string = str_replace(array_keys($search_replace), array_values($search_replace), (string) $string);
// check if we missed any, strange if we did.
return self::numbers($string);
}
// return the string with no numbers remaining.
return $string;
}
/**
* Convert an integer into an English word string
* Thanks to Tom Nicholson <http://php.net/manual/en/function.strval.php#41988>
*
* @input an int
* @returns a string
*
* @since 3.0.9
*/
public static function number($x)
{
$nwords = array( "zero", "one", "two", "three", "four", "five", "six", "seven",
"eight", "nine", "ten", "eleven", "twelve", "thirteen",
"fourteen", "fifteen", "sixteen", "seventeen", "eighteen",
"nineteen", "twenty", 30 => "thirty", 40 => "forty",
50 => "fifty", 60 => "sixty", 70 => "seventy", 80 => "eighty",
90 => "ninety" );
if(!is_numeric($x))
{
$w = $x;
}
elseif(fmod($x, 1) != 0)
{
$w = $x;
}
else
{
if($x < 0)
{
$w = 'minus ';
$x = -$x;
}
else
{
$w = '';
// ... now $x is a non-negative integer.
}
if($x < 21) // 0 to 20
{
$w .= $nwords[$x];
}
elseif($x < 100) // 21 to 99
{
$w .= $nwords[10 * floor($x/10)];
$r = fmod($x, 10);
if($r > 0)
{
$w .= ' ' . $nwords[$r];
}
}
elseif($x < 1000) // 100 to 999
{
$w .= $nwords[floor($x/100)] .' hundred';
$r = fmod($x, 100);
if($r > 0)
{
$w .= ' and '. self::number($r);
}
}
elseif($x < 1000000) // 1000 to 999999
{
$w .= self::number(floor($x/1000)) .' thousand';
$r = fmod($x, 1000);
if($r > 0)
{
$w .= ' ';
if($r < 100)
{
$w .= 'and ';
}
$w .= self::number($r);
}
}
else // millions
{
$w .= self::number(floor($x/1000000)) .' million';
$r = fmod($x, 1000000);
if($r > 0)
{
$w .= ' ';
if($r < 100)
{
$w .= 'and ';
}
$w .= self::number($r);
}
}
}
return $w;
}
/**
* Random Key
*
* @input int $size The size of the random string
*
* @returns a string
* @since 3.0.9
*/
public static function random(int $size): string
{
$bag = "abcefghijknopqrstuwxyzABCDDEFGHIJKLLMMNOPQRSTUVVWXYZabcddefghijkllmmnopqrstuvvwxyzABCEFGHIJKNOPQRSTUWXYZ";
$key = [];
$bagsize = strlen($bag) - 1;
for ($i = 0; $i < $size; $i++)
{
$get = rand(0, $bagsize);
$key[] = $bag[$get];
}
return implode($key);
}
}
###POWERCODE###

View File

@ -1,387 +1 @@
/**
* The Main Active Language
*
* @var string
*
* @since 3.0.9
*/
public static $langTag;
/**
* Check if we have a string with a length
*
* @input string $string The string to check
*
* @returns bool true on success
*
* @since 3.0.9
*/
public static function check($string): bool
{
return is_string($string) && strlen($string) > 0;
}
/**
* Shorten a string
*
* @input string The you would like to shorten
*
* @returns string on success
*
* @since 3.0.9
*/
public static function shorten($string, $length = 40, $addTip = true)
{
if (self::check($string))
{
$initial = strlen((string) $string);
$words = preg_split('/([\s\n\r]+)/', (string) $string, null, PREG_SPLIT_DELIM_CAPTURE);
$words_count = count((array)$words);
$word_length = 0;
$last_word = 0;
for (; $last_word < $words_count; ++$last_word)
{
$word_length += strlen($words[$last_word]);
if ($word_length > $length)
{
break;
}
}
$newString = implode(array_slice($words, 0, $last_word));
$final = strlen($newString);
if ($initial !== $final && $addTip)
{
$title = self::shorten($string, 400 , false);
return '<span class="hasTip" title="' . $title . '" style="cursor:help">' . trim($newString) . '...</span>';
}
elseif ($initial !== $final && !$addTip)
{
return trim($newString) . '...';
}
}
return $string;
}
/**
* Making strings safe (various ways)
*
* @input string The you would like to make safe
*
* @returns string on success
*
* @since 3.0.9
*/
public static function safe($string, $type = 'L', $spacer = '_', $replaceNumbers = true, $keepOnlyCharacters = true)
{
if ($replaceNumbers === true)
{
// remove all numbers and replace with English text version (works well only up to millions)
$string = self::numbers($string);
}
// 0nly continue if we have a string
if (self::check($string))
{
// create file name without the extension that is safe
if ($type === 'filename')
{
// make sure VDM is not in the string
$string = str_replace('VDM', 'vDm', (string) $string);
// Remove anything which isn't a word, whitespace, number
// or any of the following caracters -_()
// If you don't need to handle multi-byte characters
// you can use preg_replace rather than mb_ereg_replace
// Thanks @Łukasz Rysiak!
// $string = mb_ereg_replace("([^\w\s\d\-_\(\)])", '', $string);
$string = preg_replace("([^\w\s\d\-_\(\)])", '', $string);
// http://stackoverflow.com/a/2021729/1429677
return preg_replace('/\s+/', ' ', (string) $string);
}
// remove all other characters
$string = trim((string) $string);
$string = preg_replace('/'.$spacer.'+/', ' ', $string);
$string = preg_replace('/\s+/', ' ', $string);
// Transliterate string
$string = self::transliterate($string);
// remove all and keep only characters
if ($keepOnlyCharacters)
{
$string = preg_replace("/[^A-Za-z ]/", '', (string) $string);
}
// keep both numbers and characters
else
{
$string = preg_replace("/[^A-Za-z0-9 ]/", '', (string) $string);
}
// select final adaptations
if ($type === 'L' || $type === 'strtolower')
{
// replace white space with underscore
$string = preg_replace('/\s+/', (string) $spacer, (string) $string);
// default is to return lower
return strtolower($string);
}
elseif ($type === 'W')
{
// return a string with all first letter of each word uppercase(no underscore)
return ucwords(strtolower($string));
}
elseif ($type === 'w' || $type === 'word')
{
// return a string with all lowercase(no underscore)
return strtolower($string);
}
elseif ($type === 'Ww' || $type === 'Word')
{
// return a string with first letter of the first word uppercase and all the rest lowercase(no underscore)
return ucfirst(strtolower($string));
}
elseif ($type === 'WW' || $type === 'WORD')
{
// return a string with all the uppercase(no underscore)
return strtoupper($string);
}
elseif ($type === 'U' || $type === 'strtoupper')
{
// replace white space with underscore
$string = preg_replace('/\s+/', (string) $spacer, $string);
// return all upper
return strtoupper($string);
}
elseif ($type === 'F' || $type === 'ucfirst')
{
// replace white space with underscore
$string = preg_replace('/\s+/', (string) $spacer, $string);
// return with first character to upper
return ucfirst(strtolower($string));
}
elseif ($type === 'cA' || $type === 'cAmel' || $type === 'camelcase')
{
// convert all words to first letter uppercase
$string = ucwords(strtolower($string));
// remove white space
$string = preg_replace('/\s+/', '', $string);
// now return first letter lowercase
return lcfirst($string);
}
// return string
return $string;
}
// not a string
return '';
}
/**
* Convert none English strings to code usable string
*
* @input an string
*
* @returns a string
*
* @since 3.0.9
*/
public static function transliterate($string)
{
// set tag only once
if (!self::check(self::$langTag))
{
// get global value
self::$langTag = Helper::getParams()->get('language', 'en-GB');
}
// Transliterate on the language requested
$lang = Language::getInstance(self::$langTag);
return $lang->transliterate($string);
}
/**
* make sure a string is HTML save
*
* @input an html string
*
* @returns a string
*
* @since 3.0.9
*/
public static function html($var, $charset = 'UTF-8', $shorten = false, $length = 40, $addTip = true)
{
if (self::check($var))
{
$filter = new InputFilter();
$string = $filter->clean(
html_entity_decode(
htmlentities(
(string) $var,
ENT_COMPAT,
$charset
)
),
'HTML'
);
if ($shorten)
{
return self::shorten($string, $length, $addTip);
}
return $string;
}
else
{
return '';
}
}
/**
* Convert all int in a string to an English word string
*
* @input an string with numbers
*
* @returns a string
*
* @since 3.0.9
*/
public static function numbers($string)
{
// set numbers array
$numbers = [];
$search_replace= [];
// first get all numbers
preg_match_all('!\d+!', (string) $string, $numbers);
// check if we have any numbers
if (isset($numbers[0]) && ArrayHelper::check($numbers[0]))
{
foreach ($numbers[0] as $number)
{
$search_replace[$number] = self::number((int)$number);
}
// now replace numbers in string
$string = str_replace(array_keys($search_replace), array_values($search_replace), (string) $string);
// check if we missed any, strange if we did.
return self::numbers($string);
}
// return the string with no numbers remaining.
return $string;
}
/**
* Convert an integer into an English word string
* Thanks to Tom Nicholson <http://php.net/manual/en/function.strval.php#41988>
*
* @input an int
* @returns a string
*
* @since 3.0.9
*/
public static function number($x)
{
$nwords = array( "zero", "one", "two", "three", "four", "five", "six", "seven",
"eight", "nine", "ten", "eleven", "twelve", "thirteen",
"fourteen", "fifteen", "sixteen", "seventeen", "eighteen",
"nineteen", "twenty", 30 => "thirty", 40 => "forty",
50 => "fifty", 60 => "sixty", 70 => "seventy", 80 => "eighty",
90 => "ninety" );
if(!is_numeric($x))
{
$w = $x;
}
elseif(fmod($x, 1) != 0)
{
$w = $x;
}
else
{
if($x < 0)
{
$w = 'minus ';
$x = -$x;
}
else
{
$w = '';
// ... now $x is a non-negative integer.
}
if($x < 21) // 0 to 20
{
$w .= $nwords[$x];
}
elseif($x < 100) // 21 to 99
{
$w .= $nwords[10 * floor($x/10)];
$r = fmod($x, 10);
if($r > 0)
{
$w .= ' ' . $nwords[$r];
}
}
elseif($x < 1000) // 100 to 999
{
$w .= $nwords[floor($x/100)] .' hundred';
$r = fmod($x, 100);
if($r > 0)
{
$w .= ' and '. self::number($r);
}
}
elseif($x < 1000000) // 1000 to 999999
{
$w .= self::number(floor($x/1000)) .' thousand';
$r = fmod($x, 1000);
if($r > 0)
{
$w .= ' ';
if($r < 100)
{
$w .= 'and ';
}
$w .= self::number($r);
}
}
else // millions
{
$w .= self::number(floor($x/1000000)) .' million';
$r = fmod($x, 1000000);
if($r > 0)
{
$w .= ' ';
if($r < 100)
{
$w .= 'and ';
}
$w .= self::number($r);
}
}
}
return $w;
}
/**
* Random Key
*
* @input int $size The size of the random string
*
* @returns a string
* @since 3.0.9
*/
public static function random(int $size): string
{
$bag = "abcefghijknopqrstuwxyzABCDDEFGHIJKLLMMNOPQRSTUVVWXYZabcddefghijkllmmnopqrstuvvwxyzABCEFGHIJKNOPQRSTUWXYZ";
$key = [];
$bagsize = strlen($bag) - 1;
for ($i = 0; $i < $size; $i++)
{
$get = rand(0, $bagsize);
$key[] = $bag[$get];
}
return implode($key);
}
###CODEPOWER###

View File

@ -1,27 +1 @@
{
"add_head": "1",
"add_licensing_template": "2",
"extends": "0",
"guid": "1f28cb53-60d9-4db1-b517-3c7dc6b429ef",
"implements": null,
"load_selection": {
"load_selection0": {
"load": "0a59c65c-9daf-4bc9-baf4-e063ff9e6a8a"
}
},
"name": "StringHelper",
"power_version": "1.0.0",
"system_name": "Utilities String Helper",
"type": "abstract class",
"use_selection": {
"use_selection0": {
"use": "640b5352-fb09-425f-a26e-cd44eda03f15",
"as": "default"
}
},
"namespace": "VDM\\Joomla\\Utilities.StringHelper",
"description": "Some string tricks\r\n\r\n@since 3.0.9",
"licensing_template": "\/**\r\n * @package Joomla.Component.Builder\r\n *\r\n * @created 3rd September, 2020\r\n * @author Llewellyn van der Merwe <https:\/\/dev.vdm.io>\r\n * @git Joomla Component Builder <https:\/\/git.vdm.dev\/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\\Filter\\InputFilter;\r\nuse Joomla\\CMS\\Language\\Language;",
"composer": ""
}
###POWERLINKER###

View File

@ -1,101 +1 @@
```
██████╗ ██████╗ ██╗ ██╗███████╗██████╗
██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗
██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝
██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
```
# interface LoadInterface (Details)
> namespace: **VDM\Joomla\Interfaces**
```uml
@startuml
interface LoadInterface #Lavender {
+ rows(array $select, array $tables, ...) : ?array
+ items(array $select, array $tables, ...) : ?array
+ row(array $select, array $tables, ...) : ?array
+ item(array $select, array $tables, ...) : ?object
+ value(array $select, array $tables, ...) : mixed
}
note right of LoadInterface::rows
Load data rows as an array of associated arrays
since: 3.2.0
return: ?array
arguments:
array $select
array $tables
?array $where = null
?array $order = null
?int $limit = null
end note
note right of LoadInterface::items
Load data rows as an array of objects
since: 3.2.0
return: ?array
arguments:
array $select
array $tables
?array $where = null
?array $order = null
?int $limit = null
end note
note right of LoadInterface::row
Load data row as an associated array
since: 3.2.0
return: ?array
arguments:
array $select
array $tables
?array $where = null
?array $order = null
end note
note right of LoadInterface::item
Load data row as an object
since: 3.2.0
return: ?object
arguments:
array $select
array $tables
?array $where = null
?array $order = null
end note
note right of LoadInterface::value
Load one value from a row
since: 3.2.0
return: mixed
arguments:
array $select
array $tables
?array $where = null
?array $order = null
end note
@enduml
```
---
```
██╗ ██████╗██████╗
██║██╔════╝██╔══██╗
██║██║ ██████╔╝
██ ██║██║ ██╔══██╗
╚█████╔╝╚██████╗██████╔╝
╚════╝ ╚═════╝╚═════╝
```
> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder)
###POWERREADME###

View File

@ -9,84 +9,4 @@
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace VDM\Joomla\Interfaces;
/**
* Database Load Interface
*
* @since 3.2.0
*/
interface LoadInterface
{
/**
* Load data rows as an array of associated arrays
*
* @param array $select Array of selection keys
* @param array $tables Array of tables to search
* @param array|null $where Array of where key=>value match exist
* @param array|null $order Array of how to order the data
* @param int|null $limit Limit the number of values returned
*
* @return array|null
* @since 3.2.0
**/
public function rows(array $select, array $tables, ?array $where = null,
?array $order = null, ?int $limit = null): ?array;
/**
* Load data rows as an array of objects
*
* @param array $select Array of selection keys
* @param array $tables Array of tables to search
* @param array|null $where Array of where key=>value match exist
* @param array|null $order Array of how to order the data
* @param int|null $limit Limit the number of values returned
*
* @return array|null
* @since 3.2.0
**/
public function items(array $select, array $tables, ?array $where = null,
?array $order = null, ?int $limit = null): ?array;
/**
* Load data row as an associated array
*
* @param array $select Array of selection keys
* @param array $tables Array of tables to search
* @param array|null $where Array of where key=>value match exist
* @param array|null $order Array of how to order the data
*
* @return array|null
* @since 3.2.0
**/
public function row(array $select, array $tables, ?array $where = null, ?array $order = null): ?array;
/**
* Load data row as an object
*
* @param array $select Array of selection keys
* @param array $tables Array of tables to search
* @param array|null $where Array of where key=>value match exist
* @param array|null $order Array of how to order the data
*
* @return object|null
* @since 3.2.0
**/
public function item(array $select, array $tables, ?array $where = null, ?array $order = null): ?object;
/**
* Load one value from a row
*
* @param array $select Array of selection keys
* @param array $tables Array of tables to search
* @param array|null $where Array of where key=>value match exist
* @param array|null $order Array of how to order the data
*
* @return mixed
* @since 3.2.0
**/
public function value(array $select, array $tables, ?array $where = null, ?array $order = null);
}
###POWERCODE###

View File

@ -1,68 +1 @@
/**
* Load data rows as an array of associated arrays
*
* @param array $select Array of selection keys
* @param array $tables Array of tables to search
* @param array|null $where Array of where key=>value match exist
* @param array|null $order Array of how to order the data
* @param int|null $limit Limit the number of values returned
*
* @return array|null
* @since 3.2.0
**/
public function rows(array $select, array $tables, ?array $where = null,
?array $order = null, ?int $limit = null): ?array;
/**
* Load data rows as an array of objects
*
* @param array $select Array of selection keys
* @param array $tables Array of tables to search
* @param array|null $where Array of where key=>value match exist
* @param array|null $order Array of how to order the data
* @param int|null $limit Limit the number of values returned
*
* @return array|null
* @since 3.2.0
**/
public function items(array $select, array $tables, ?array $where = null,
?array $order = null, ?int $limit = null): ?array;
/**
* Load data row as an associated array
*
* @param array $select Array of selection keys
* @param array $tables Array of tables to search
* @param array|null $where Array of where key=>value match exist
* @param array|null $order Array of how to order the data
*
* @return array|null
* @since 3.2.0
**/
public function row(array $select, array $tables, ?array $where = null, ?array $order = null): ?array;
/**
* Load data row as an object
*
* @param array $select Array of selection keys
* @param array $tables Array of tables to search
* @param array|null $where Array of where key=>value match exist
* @param array|null $order Array of how to order the data
*
* @return object|null
* @since 3.2.0
**/
public function item(array $select, array $tables, ?array $where = null, ?array $order = null): ?object;
/**
* Load one value from a row
*
* @param array $select Array of selection keys
* @param array $tables Array of tables to search
* @param array|null $where Array of where key=>value match exist
* @param array|null $order Array of how to order the data
*
* @return mixed
* @since 3.2.0
**/
public function value(array $select, array $tables, ?array $where = null, ?array $order = null);
###CODEPOWER###

View File

@ -1,18 +1 @@
{
"add_head": "0",
"add_licensing_template": "2",
"extends": "0",
"guid": "2ad31f74-f579-499d-b98b-c4f54fd615dd",
"implements": null,
"load_selection": null,
"name": "LoadInterface",
"power_version": "1.0.0",
"system_name": "VDM.Interfaces.LoadInterface",
"type": "interface",
"use_selection": null,
"namespace": "VDM\\Joomla\\Interfaces.LoadInterface",
"description": "Database Load Interface\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 <https:\/\/dev.vdm.io>\r\n * @git Joomla Component Builder <https:\/\/git.vdm.dev\/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": ""
}
###POWERLINKER###

View File

@ -1,89 +1 @@
```
██████╗ ██████╗ ██╗ ██╗███████╗██████╗
██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗
██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝
██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
```
# interface Tableinterface (Details)
> namespace: **VDM\Joomla\Interfaces**
```uml
@startuml
interface Tableinterface #Lavender {
+ get(string $table, ?string $field = null, ...) : mixed
+ title(string $table) : ?array
+ titleName(string $table) : string
+ tables() : array
+ exist(string $table, ?string $field = null) : bool
+ fields(string $table, bool $default = false) : ?array
}
note right of Tableinterface::get
Get any value from a item/field/column of an area/view/table
Example: $this->get('table_name', 'field_name', 'value_key');
Get an item/field/column of an area/view/table
Example: $this->get('table_name', 'field_name');
Get all items/fields/columns of an area/view/table
Example: $this->get('table_name');
Get all areas/views/tables with all their item/field/column details
Example: $this->get('All');
since: 3.2.0
return: mixed
arguments:
string $table
?string $field = null
?string $key = null
end note
note right of Tableinterface::title
Get title field from an area/view/table
since: 3.2.0
return: ?array
end note
note right of Tableinterface::titleName
Get title field name
since: 3.2.0
return: string
end note
note right of Tableinterface::tables
Get all tables
since: 3.2.0
return: array
end note
note right of Tableinterface::exist
Check if a table (and field) exist
since: 3.2.0
return: bool
end note
note right of Tableinterface::fields
Get all fields of an area/view/table
since: 3.2.0
return: ?array
end note
@enduml
```
---
```
██╗ ██████╗██████╗
██║██╔════╝██╔══██╗
██║██║ ██████╔╝
██ ██║██║ ██╔══██╗
╚█████╔╝╚██████╗██████╔╝
╚════╝ ╚═════╝╚═════╝
```
> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder)
###POWERREADME###

View File

@ -9,81 +9,4 @@
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace VDM\Joomla\Interfaces;
/**
* The VDM Core Table Interface
*/
interface Tableinterface
{
/**
* Get any value from a item/field/column of an area/view/table
* Example: $this->get('table_name', 'field_name', 'value_key');
* Get an item/field/column of an area/view/table
* Example: $this->get('table_name', 'field_name');
* Get all items/fields/columns of an area/view/table
* Example: $this->get('table_name');
* Get all areas/views/tables with all their item/field/column details
* Example: $this->get('All');
*
* @param string $table The table
* @param string|null $field The field
* @param string|null $key The value key
*
* @return mixed
* @since 3.2.0
*/
public function get(string $table, ?string $field = null, ?string $key = null);
/**
* Get title field from an area/view/table
*
* @param string $table The area
*
* @return ?array
* @since 3.2.0
*/
public function title(string $table): ?array;
/**
* Get title field name
*
* @param string $table The area
*
* @return string
* @since 3.2.0
*/
public function titleName(string $table): string;
/**
* Get all tables
*
* @return array
* @since 3.2.0
*/
public function tables(): array;
/**
* Check if a table (and field) exist
*
* @param string $table The area
* @param string|null $field The area
*
* @return bool
* @since 3.2.0
*/
public function exist(string $table, ?string $field = null): bool;
/**
* Get all fields of an area/view/table
*
* @param string $table The area
* @param bool $default Add the default fields
*
* @return array|null On success an array of fields
* @since 3.2.0
*/
public function fields(string $table, bool $default = false): ?array;
}
###POWERCODE###

View File

@ -1,68 +1 @@
/**
* Get any value from a item/field/column of an area/view/table
* Example: $this->get('table_name', 'field_name', 'value_key');
* Get an item/field/column of an area/view/table
* Example: $this->get('table_name', 'field_name');
* Get all items/fields/columns of an area/view/table
* Example: $this->get('table_name');
* Get all areas/views/tables with all their item/field/column details
* Example: $this->get('All');
*
* @param string $table The table
* @param string|null $field The field
* @param string|null $key The value key
*
* @return mixed
* @since 3.2.0
*/
public function get(string $table, ?string $field = null, ?string $key = null);
/**
* Get title field from an area/view/table
*
* @param string $table The area
*
* @return ?array
* @since 3.2.0
*/
public function title(string $table): ?array;
/**
* Get title field name
*
* @param string $table The area
*
* @return string
* @since 3.2.0
*/
public function titleName(string $table): string;
/**
* Get all tables
*
* @return array
* @since 3.2.0
*/
public function tables(): array;
/**
* Check if a table (and field) exist
*
* @param string $table The area
* @param string|null $field The area
*
* @return bool
* @since 3.2.0
*/
public function exist(string $table, ?string $field = null): bool;
/**
* Get all fields of an area/view/table
*
* @param string $table The area
* @param bool $default Add the default fields
*
* @return array|null On success an array of fields
* @since 3.2.0
*/
public function fields(string $table, bool $default = false): ?array;
###CODEPOWER###

View File

@ -1,18 +1 @@
{
"add_head": "0",
"add_licensing_template": "2",
"extends": "0",
"guid": "2da6d6c4-eb29-4d69-8bc2-36d96e916adf",
"implements": null,
"load_selection": null,
"name": "Tableinterface",
"power_version": "1.0.0",
"system_name": "VDM.Interfaces.Tableinterface",
"type": "interface",
"use_selection": null,
"namespace": "VDM\\Joomla\\Interfaces.Tableinterface",
"description": "The VDM Core Table Interface",
"licensing_template": "\/**\r\n * @package Joomla.Component.Builder\r\n *\r\n * @created 4th September, 2022\r\n * @author Llewellyn van der Merwe <https:\/\/dev.vdm.io>\r\n * @git Joomla Component Builder <https:\/\/git.vdm.dev\/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": ""
}
###POWERLINKER###

View File

@ -1,37 +1 @@
```
██████╗ ██████╗ ██╗ ██╗███████╗██████╗
██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗
██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝
██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
```
# abstract class ClassfunctionHelper (Details)
> namespace: **VDM\Joomla\Utilities\String**
```uml
@startuml
abstract ClassfunctionHelper #Orange {
+ {static} safe($name) : string
}
note right of ClassfunctionHelper::safe
Making class or function name safe
since: 3.0.9
return: string
end note
@enduml
```
---
```
██╗ ██████╗██████╗
██║██╔════╝██╔══██╗
██║██║ ██████╔╝
██ ██║██║ ██╔══██╗
╚█████╔╝╚██████╗██████╔╝
╚════╝ ╚═════╝╚═════╝
```
> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder)
###POWERREADME###

View File

@ -9,39 +9,4 @@
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace VDM\Joomla\Utilities\String;
use VDM\Joomla\Utilities\StringHelper;
/**
* Control the naming of a class and function
*
* @since 3.0.9
*/
abstract class ClassfunctionHelper
{
/**
* Making class or function name safe
*
* @input string The name you would like to make safe
*
* @returns string on success
*
* @since 3.0.9
*/
public static function safe($name): string
{
// remove numbers if the first character is a number
if (is_numeric(substr((string) $name, 0, 1)))
{
$name = StringHelper::numbers($name);
}
// remove all spaces and strange characters
return trim(preg_replace("/[^A-Za-z0-9_-]/", '', (string) $name));
}
}
###POWERCODE###

View File

@ -1,20 +1 @@
/**
* Making class or function name safe
*
* @input string The name you would like to make safe
*
* @returns string on success
*
* @since 3.0.9
*/
public static function safe($name): string
{
// remove numbers if the first character is a number
if (is_numeric(substr((string) $name, 0, 1)))
{
$name = StringHelper::numbers($name);
}
// remove all spaces and strange characters
return trim(preg_replace("/[^A-Za-z0-9_-]/", '', (string) $name));
}
###CODEPOWER###

View File

@ -1,23 +1 @@
{
"add_head": "0",
"add_licensing_template": "2",
"extends": "0",
"guid": "30c5b4c2-f75f-4d15-869a-f8bfedd87358",
"implements": null,
"load_selection": null,
"name": "ClassfunctionHelper",
"power_version": "1.0.0",
"system_name": "String Classfunction Helper",
"type": "abstract class",
"use_selection": {
"use_selection0": {
"use": "1f28cb53-60d9-4db1-b517-3c7dc6b429ef",
"as": "default"
}
},
"namespace": "VDM\\Joomla\\Utilities.String.ClassfunctionHelper",
"description": "Control the naming of a class and function\r\n\r\n@since 3.0.9",
"licensing_template": "\/**\r\n * @package Joomla.Component.Builder\r\n *\r\n * @created 3rd September, 2020\r\n * @author Llewellyn van der Merwe <https:\/\/dev.vdm.io>\r\n * @git Joomla Component Builder <https:\/\/git.vdm.dev\/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": ""
}
###POWERLINKER###

View File

@ -1,51 +1 @@
```
██████╗ ██████╗ ██╗ ██╗███████╗██████╗
██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗
██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝
██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
```
# abstract class JsonHelper (Details)
> namespace: **VDM\Joomla\Utilities**
```uml
@startuml
abstract JsonHelper #Orange {
+ {static} check($string) : bool
+ {static} string($value, $separator = ", ...)
}
note right of JsonHelper::check
Check if you have a json string
since: 3.0.9
return: bool
end note
note right of JsonHelper::string
Convert a json object to a string
since: 3.0.9
arguments:
$value
$separator = "
$table = null
$id = 'id'
$name = 'name'
end note
@enduml
```
---
```
██╗ ██████╗██████╗
██║██╔════╝██╔══██╗
██║██║ ██████╔╝
██ ██║██║ ██╔══██╗
╚█████╔╝╚██████╗██████╔╝
╚════╝ ╚═════╝╚═════╝
```
> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder)
###POWERREADME###

View File

@ -9,93 +9,4 @@
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace VDM\Joomla\Utilities;
/**
* The json checker
*
* @since 3.0.9
*/
abstract class JsonHelper
{
/**
* Check if you have a json string
*
* @input string $string The json string to check
*
* @returns bool true on success
*
* @since 3.0.9
*/
public static function check($string): bool
{
if (StringHelper::check($string))
{
json_decode((string) $string);
return (json_last_error() === JSON_ERROR_NONE);
}
return false;
}
/**
* Convert a json object to a string
*
* @input string $value The json string to convert
*
* @returns a string
*
* @since 3.0.9
*/
public static function string($value, $separator = ", ", $table = null, $id = 'id', $name = 'name')
{
// do some table foot work
$external = false;
if (is_string($table) && strpos((string) $table, '#__') !== false)
{
$external = true;
$table = str_replace('#__', '', (string) $table);
}
// check if string is JSON
$result = json_decode((string) $value, true);
if (json_last_error() === JSON_ERROR_NONE)
{
// is JSON
if (ArrayHelper::check($result))
{
if (StringHelper::check($table))
{
$names = [];
foreach ($result as $val)
{
if ($external)
{
if ($_name = GetHelper::var(null, $val, $id, $name, '=', $table))
{
$names[] = $_name;
}
}
else
{
if ($_name = GetHelper::var($table, $val, $id, $name))
{
$names[] = $_name;
}
}
}
if (ArrayHelper::check($names))
{
return (string) implode($separator, $names);
}
}
return (string) implode($separator, $result);
}
return (string) json_decode((string) $value);
}
return $value;
}
}
###POWERCODE###

View File

@ -1,77 +1 @@
/**
* Check if you have a json string
*
* @input string $string The json string to check
*
* @returns bool true on success
*
* @since 3.0.9
*/
public static function check($string): bool
{
if (StringHelper::check($string))
{
json_decode((string) $string);
return (json_last_error() === JSON_ERROR_NONE);
}
return false;
}
/**
* Convert a json object to a string
*
* @input string $value The json string to convert
*
* @returns a string
*
* @since 3.0.9
*/
public static function string($value, $separator = ", ", $table = null, $id = 'id', $name = 'name')
{
// do some table foot work
$external = false;
if (is_string($table) && strpos((string) $table, '#__') !== false)
{
$external = true;
$table = str_replace('#__', '', (string) $table);
}
// check if string is JSON
$result = json_decode((string) $value, true);
if (json_last_error() === JSON_ERROR_NONE)
{
// is JSON
if (ArrayHelper::check($result))
{
if (StringHelper::check($table))
{
$names = [];
foreach ($result as $val)
{
if ($external)
{
if ($_name = GetHelper::var(null, $val, $id, $name, '=', $table))
{
$names[] = $_name;
}
}
else
{
if ($_name = GetHelper::var($table, $val, $id, $name))
{
$names[] = $_name;
}
}
}
if (ArrayHelper::check($names))
{
return (string) implode($separator, $names);
}
}
return (string) implode($separator, $result);
}
return (string) json_decode((string) $value);
}
return $value;
}
###CODEPOWER###

View File

@ -1,28 +1 @@
{
"add_head": "0",
"add_licensing_template": "2",
"extends": "0",
"guid": "4b225c51-d293-48e4-b3f6-5136cf5c3f18",
"implements": null,
"load_selection": {
"load_selection0": {
"load": "1f28cb53-60d9-4db1-b517-3c7dc6b429ef"
},
"load_selection1": {
"load": "0a59c65c-9daf-4bc9-baf4-e063ff9e6a8a"
},
"load_selection2": {
"load": "db87c339-5bb6-4291-a7ef-2c48ea1b06bc"
}
},
"name": "JsonHelper",
"power_version": "1.0.0",
"system_name": "Utilities Json Helper",
"type": "abstract class",
"use_selection": null,
"namespace": "VDM\\Joomla\\Utilities.JsonHelper",
"description": "The json checker\r\n\r\n@since 3.0.9",
"licensing_template": "\/**\r\n * @package Joomla.Component.Builder\r\n *\r\n * @created 3rd September, 2020\r\n * @author Llewellyn van der Merwe <https:\/\/dev.vdm.io>\r\n * @git Joomla Component Builder <https:\/\/git.vdm.dev\/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": ""
}
###POWERLINKER###

View File

@ -1,110 +1 @@
```
██████╗ ██████╗ ██╗ ██╗███████╗██████╗
██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗
██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝
██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
```
# final class Insert (Details)
> namespace: **VDM\Joomla\Database**
```uml
@startuml
class Insert << (F,LightGreen) >> #Green {
# bool $defaults
+ defaults(bool $trigger = true) : void
+ rows(array $data, string $table, ...) : bool
+ items(array $data, string $table, ...) : bool
+ row(array $data, string $table) : bool
+ item(object $data, string $table) : bool
# getArrayColumns(array $data) : array
# getObjectsColumns(array $data) : array
# insert(array $data, string $table, ...) : bool
}
note right of Insert::defaults
Switch to prevent/allow defaults from being added.
since: 3.2.0
return: void
end note
note left of Insert::rows
Insert rows to the database (with remapping and filtering columns option)
since: 3.2.0
return: bool
arguments:
array $data
string $table
array $columns = []
end note
note right of Insert::items
Insert items to the database (with remapping and filtering columns option)
since: 3.2.0
return: bool
arguments:
array $data
string $table
array $columns = []
end note
note left of Insert::row
Insert row to the database
since: 3.2.0
return: bool
end note
note right of Insert::item
Insert item to the database
since: 3.2.0
return: bool
end note
note left of Insert::getArrayColumns
Get columns from data array
since: 3.2.0
return: array
end note
note right of Insert::getObjectsColumns
Get columns from data objects
since: 3.2.0
return: array
end note
note left of Insert::insert
Insert data into the database
since: 3.2.0
return: bool
arguments:
array $data
string $table
array $columns
bool $isArray
end note
@enduml
```
---
```
██╗ ██████╗██████╗
██║██╔════╝██╔══██╗
██║██║ ██████╔╝
██ ██║██║ ██╔══██╗
╚█████╔╝╚██████╗██████╔╝
╚════╝ ╚═════╝╚═════╝
```
> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder)
###POWERREADME###

View File

@ -9,282 +9,4 @@
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace VDM\Joomla\Database;
use Joomla\CMS\Date\Date;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Interfaces\InsertInterface;
use VDM\Joomla\Abstraction\Database;
/**
* Database Insert Class
*
* @since 3.2.0
*/
final class Insert extends Database implements InsertInterface
{
/**
* Switch to set the defaults
*
* @var bool
* @since 1.2.0
**/
protected bool $defaults = true;
/**
* Switch to prevent/allow defaults from being added.
*
* @param bool $trigger toggle the defaults
*
* @return void
* @since 3.2.0
**/
public function defaults(bool $trigger = true)
{
$this->defaults = $trigger;
}
/**
* Insert rows to the database (with remapping and filtering columns option)
*
* @param array $data Dataset to store in database [array of arrays (key => value)]
* @param string $table The table where the data is being added
* @param array $columns Data columns for remapping and filtering
*
* @return bool
* @since 3.2.0
**/
public function rows(array $data, string $table, array $columns = []): bool
{
if (!ArrayHelper::check($data))
{
return false;
}
if ($columns === [])
{
$columns = $this->getArrayColumns($data);
}
return ($columns === []) ? false : $this->insert($data, $table, $columns, true);
}
/**
* Insert items to the database (with remapping and filtering columns option)
*
* @param array $data Data to store in database (array of objects)
* @param string $table The table where the data is being added
* @param array $columns Data columns for remapping and filtering
*
* @return bool
* @since 3.2.0
**/
public function items(array $data, string $table, array $columns = []): bool
{
if (!ArrayHelper::check($data))
{
return false;
}
if ($columns === [])
{
$columns = $this->getObjectsColumns($data);
}
return ($columns === []) ? false : $this->insert($data, $table, $columns, false);
}
/**
* Insert row to the database
*
* @param array $data Dataset to store in database (key => value)
* @param string $table The table where the data is being added
*
* @return bool
* @since 3.2.0
**/
public function row(array $data, string $table): bool
{
return $this->rows([$data], $table);
}
/**
* Insert item to the database
*
* @param object $data Dataset to store in database (key => value)
* @param string $table The table where the data is being added
*
* @return bool
* @since 3.2.0
**/
public function item(object $data, string $table): bool
{
return $this->items([$data], $table);
}
/**
* Get columns from data array
*
* @param array $data Data array
*
* @return array
* @since 3.2.0
**/
protected function getArrayColumns(array &$data): array
{
$row = array_values($data)[0];
if (!ArrayHelper::check($row))
{
return [];
}
$columns = array_keys($row);
return array_combine($columns, $columns);
}
/**
* Get columns from data objects
*
* @param array $data Data objects
*
* @return array
* @since 3.2.0
**/
protected function getObjectsColumns(array &$data): array
{
$row = array_values($data)[0];
if (!is_object($row))
{
return [];
}
$columns = get_object_vars($row);
return array_combine(array_keys($columns), array_keys($columns));
}
/**
* Insert data into the database
*
* @param array $data Data to store in database
* @param string $table The table where the data is being added
* @param array $columns Data columns for remapping and filtering
* @param bool $isArray Whether the data is an array of arrays or an array of objects
*
* @return bool
* @since 3.2.0
**/
protected function insert(array &$data, string $table, array $columns, bool $isArray): bool
{
// set joomla default columns
$add_created = false;
$add_version = false;
$add_published = false;
// check if we should load the defaults
if ($this->defaults)
{
// get the date
$date = (new Date())->toSql();
if (!isset($columns['created']))
{
$columns['created'] = ' (o_O) ';
$add_created = true;
}
if (!isset($columns['version']))
{
$columns['version'] = ' (o_O) ';
$add_version = true;
}
if (!isset($columns['version']))
{
$columns['published'] = ' (o_O) ';
$add_published = true;
}
// the (o_O) prevents an empty value from being loaded
}
// get a query object
$query = $this->db->getQuery(true);
// set the query targets
$query->insert($this->db->quoteName($this->getTable($table)))->columns($this->db->quoteName(array_keys($columns)));
// limiting factor on the amount of rows to insert before we reset the query
$limit = 300;
// set the insert values
foreach ($data as $nr => $value)
{
// check the limit
if ($limit <= 1)
{
// execute and reset the query
$this->db->setQuery($query);
$this->db->execute();
// reset limit
$limit = 300;
// get a query object
$query = $this->db->getQuery(true);
// set the query targets
$query->insert($this->db->quoteName($this->getTable($table)))->columns($this->db->quoteName(array_keys($columns)));
}
$row = [];
foreach ($columns as $column => $key)
{
if (' (o_O) ' !== $key)
{
$row[] = ($isArray && isset($value[$key])) ? $this->quote($value[$key])
: ((!$isArray && isset($value->{$key})) ? $this->quote($value->{$key}) : '');
}
}
// set joomla default columns
if ($add_created)
{
$row[] = $this->db->quote($date);
}
if ($add_version)
{
$row[] = 1;
}
if ($add_published)
{
$row[] = 1;
}
// add to query
$query->values(implode(',', $row));
// decrement the limiter
$limit--;
// clear the data from memory
unset($data[$nr]);
}
// execute the final query
$this->db->setQuery($query);
$this->db->execute();
// always reset the default switch
$this->defaults();
return true;
}
}
###POWERCODE###

View File

@ -1,261 +1 @@
/**
* Switch to set the defaults
*
* @var bool
* @since 1.2.0
**/
protected bool $defaults = true;
/**
* Switch to prevent/allow defaults from being added.
*
* @param bool $trigger toggle the defaults
*
* @return void
* @since 3.2.0
**/
public function defaults(bool $trigger = true)
{
$this->defaults = $trigger;
}
/**
* Insert rows to the database (with remapping and filtering columns option)
*
* @param array $data Dataset to store in database [array of arrays (key => value)]
* @param string $table The table where the data is being added
* @param array $columns Data columns for remapping and filtering
*
* @return bool
* @since 3.2.0
**/
public function rows(array $data, string $table, array $columns = []): bool
{
if (!ArrayHelper::check($data))
{
return false;
}
if ($columns === [])
{
$columns = $this->getArrayColumns($data);
}
return ($columns === []) ? false : $this->insert($data, $table, $columns, true);
}
/**
* Insert items to the database (with remapping and filtering columns option)
*
* @param array $data Data to store in database (array of objects)
* @param string $table The table where the data is being added
* @param array $columns Data columns for remapping and filtering
*
* @return bool
* @since 3.2.0
**/
public function items(array $data, string $table, array $columns = []): bool
{
if (!ArrayHelper::check($data))
{
return false;
}
if ($columns === [])
{
$columns = $this->getObjectsColumns($data);
}
return ($columns === []) ? false : $this->insert($data, $table, $columns, false);
}
/**
* Insert row to the database
*
* @param array $data Dataset to store in database (key => value)
* @param string $table The table where the data is being added
*
* @return bool
* @since 3.2.0
**/
public function row(array $data, string $table): bool
{
return $this->rows([$data], $table);
}
/**
* Insert item to the database
*
* @param object $data Dataset to store in database (key => value)
* @param string $table The table where the data is being added
*
* @return bool
* @since 3.2.0
**/
public function item(object $data, string $table): bool
{
return $this->items([$data], $table);
}
/**
* Get columns from data array
*
* @param array $data Data array
*
* @return array
* @since 3.2.0
**/
protected function getArrayColumns(array &$data): array
{
$row = array_values($data)[0];
if (!ArrayHelper::check($row))
{
return [];
}
$columns = array_keys($row);
return array_combine($columns, $columns);
}
/**
* Get columns from data objects
*
* @param array $data Data objects
*
* @return array
* @since 3.2.0
**/
protected function getObjectsColumns(array &$data): array
{
$row = array_values($data)[0];
if (!is_object($row))
{
return [];
}
$columns = get_object_vars($row);
return array_combine(array_keys($columns), array_keys($columns));
}
/**
* Insert data into the database
*
* @param array $data Data to store in database
* @param string $table The table where the data is being added
* @param array $columns Data columns for remapping and filtering
* @param bool $isArray Whether the data is an array of arrays or an array of objects
*
* @return bool
* @since 3.2.0
**/
protected function insert(array &$data, string $table, array $columns, bool $isArray): bool
{
// set joomla default columns
$add_created = false;
$add_version = false;
$add_published = false;
// check if we should load the defaults
if ($this->defaults)
{
// get the date
$date = (new Date())->toSql();
if (!isset($columns['created']))
{
$columns['created'] = ' (o_O) ';
$add_created = true;
}
if (!isset($columns['version']))
{
$columns['version'] = ' (o_O) ';
$add_version = true;
}
if (!isset($columns['version']))
{
$columns['published'] = ' (o_O) ';
$add_published = true;
}
// the (o_O) prevents an empty value from being loaded
}
// get a query object
$query = $this->db->getQuery(true);
// set the query targets
$query->insert($this->db->quoteName($this->getTable($table)))->columns($this->db->quoteName(array_keys($columns)));
// limiting factor on the amount of rows to insert before we reset the query
$limit = 300;
// set the insert values
foreach ($data as $nr => $value)
{
// check the limit
if ($limit <= 1)
{
// execute and reset the query
$this->db->setQuery($query);
$this->db->execute();
// reset limit
$limit = 300;
// get a query object
$query = $this->db->getQuery(true);
// set the query targets
$query->insert($this->db->quoteName($this->getTable($table)))->columns($this->db->quoteName(array_keys($columns)));
}
$row = [];
foreach ($columns as $column => $key)
{
if (' (o_O) ' !== $key)
{
$row[] = ($isArray && isset($value[$key])) ? $this->quote($value[$key])
: ((!$isArray && isset($value->{$key})) ? $this->quote($value->{$key}) : '');
}
}
// set joomla default columns
if ($add_created)
{
$row[] = $this->db->quote($date);
}
if ($add_version)
{
$row[] = 1;
}
if ($add_published)
{
$row[] = 1;
}
// add to query
$query->values(implode(',', $row));
// decrement the limiter
$limit--;
// clear the data from memory
unset($data[$nr]);
}
// execute the final query
$this->db->setQuery($query);
$this->db->execute();
// always reset the default switch
$this->defaults();
return true;
}
###CODEPOWER###

View File

@ -1,25 +1 @@
{
"add_head": "1",
"add_licensing_template": "2",
"extends": "6cbef8f8-4813-48e3-b05a-65e1aea95171",
"guid": "524eb8f6-38d4-47dc-92ad-98b94e099ac0",
"implements": [
"ad12ca1c-d3ce-4e7f-88c5-c6c92bdedc48"
],
"load_selection": null,
"name": "Insert",
"power_version": "1.0.0",
"system_name": "VDM.Database.Insert",
"type": "final class",
"use_selection": {
"use_selection0": {
"use": "0a59c65c-9daf-4bc9-baf4-e063ff9e6a8a",
"as": "default"
}
},
"namespace": "VDM\\Joomla\\Database.Insert",
"description": "Database Insert 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 <https:\/\/dev.vdm.io>\r\n * @git Joomla Component Builder <https:\/\/git.vdm.dev\/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\\Date\\Date;",
"composer": ""
}
###POWERLINKER###

View File

@ -1,139 +1 @@
```
██████╗ ██████╗ ██╗ ██╗███████╗██████╗
██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗
██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝
██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
```
# abstract class Model (Details)
> namespace: **VDM\Joomla\Abstraction**
```uml
@startuml
abstract Model #Orange {
# array $last
# Table $table
+ __construct(Table $table)
+ {abstract} value(mixed $value, string $field, ...) : mixed
+ item(?object $item, ?string $table = null) : ?object
+ items(?array $items = null, ?string $table = null) : ?array
+ row(?array $item, ?string $table = null) : ?array
+ rows(?array $items = null, ?string $table = null) : ?array
+ last(?string $table = null) : ?int
# getTableFields(string $table, bool $default = false) : ?array
# {abstract} validateBefore(mixed $value, ?string $field = null, ...) : bool
# {abstract} validateAfter(mixed $value, ?string $field = null, ...) : bool
# {abstract} getTable() : string
}
note right of Model::__construct
Constructor
since: 3.2.0
end note
note left of Model::value
Model the value
Example: $this->value(value, 'value_key', 'table_name');
since: 3.2.0
return: mixed
arguments:
mixed $value
string $field
?string $table = null
end note
note right of Model::item
Model the values of an item
Example: $this->item(Object, 'table_name');
since: 3.2.0
return: ?object
end note
note left of Model::items
Model the values of multiple items
Example: $this->items(Array, 'table_name');
since: 3.2.0
return: ?array
end note
note right of Model::row
Model the values of an row
Example: $this->item(Array, 'table_name');
since: 3.2.0
return: ?array
end note
note left of Model::rows
Model the values of multiple rows
Example: $this->items(Array, 'table_name');
since: 3.2.0
return: ?array
end note
note right of Model::last
Get last modeled ID
Example: $this->last('table_name');
since: 3.2.0
return: ?int
end note
note left of Model::getTableFields
Get the current active table's fields (including defaults)
since: 3.2.0
return: ?array
end note
note right of Model::validateBefore
Validate before the value is modelled (basic, override in child class)
since: 3.2.0
return: bool
arguments:
mixed $value
?string $field = null
?string $table = null
end note
note left of Model::validateAfter
Validate after the value is modelled (basic, override in child class)
since: 3.2.0
return: bool
arguments:
mixed $value
?string $field = null
?string $table = null
end note
note right of Model::getTable
Get the current active table
since: 3.2.0
return: string
end note
@enduml
```
---
```
██╗ ██████╗██████╗
██║██╔════╝██╔══██╗
██║██║ ██████╔╝
██ ██║██║ ██╔══██╗
╚█████╔╝╚██████╗██████╔╝
╚════╝ ╚═════╝╚═════╝
```
> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder)
###POWERREADME###

View File

@ -9,350 +9,4 @@
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace VDM\Joomla\Abstraction;
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Interfaces\Tableinterface as Table;
/**
* Base Model
*
* @since 3.2.0
*/
abstract class Model
{
/**
* Last ID
*
* @var array
* @since 3.2.0
*/
protected array $last;
/**
* Search Table
*
* @var Table
* @since 3.2.0
*/
protected Table $table;
/**
* Constructor
*
* @param Table $table The search table object.
*
* @since 3.2.0
*/
public function __construct(Table $table)
{
$this->table = $table;
}
/**
* Model the value
* Example: $this->value(value, 'value_key', 'table_name');
*
* @param mixed $value The value to model
* @param string $field The field key
* @param string|null $table The table
*
* @return mixed
* @since 3.2.0
*/
abstract public function value($value, string $field, ?string $table = null);
/**
* Model the values of an item
* Example: $this->item(Object, 'table_name');
*
* @param object|null $item The item object
* @param string|null $table The table
*
* @return object|null
* @since 3.2.0
*/
public function item(?object $item, ?string $table = null): ?object
{
// we must have an object
if (empty($item))
{
return null;
}
// set the table name
if (empty($table))
{
$table = $this->getTable();
}
if (($fields = $this->getTableFields($table, true)) !== null)
{
// field counter
$field_number = 0;
// check if this is a valid table
$item_bucket = new \stdClass();
foreach ($fields as $field)
{
// model a value if it exists
if(isset($item->{$field}))
{
if (!$this->validateBefore($item->{$field}, $field, $table))
{
continue;
}
$item->{$field} = $this->value($item->{$field}, $field, $table);
if (!$this->validateAfter($item->{$field}, $field, $table))
{
continue;
}
$item_bucket->{$field} = $item->{$field};
$field_number++;
}
}
// all items must have more than one field or its empty (1 = key)
if ($field_number > 1)
{
return $item_bucket;
}
}
return null;
}
/**
* Model the values of multiple items
* Example: $this->items(Array, 'table_name');
*
* @param array|null $items The array of item objects
* @param string|null $table The table
*
* @return array|null
* @since 3.2.0
*/
public function items(?array $items = null, ?string $table = null): ?array
{
// check if this is a valid table
if (ArrayHelper::check($items))
{
// set the table name
if (empty($table))
{
$table = $this->getTable();
}
foreach ($items as $id => &$item)
{
// model the item
if (($item = $this->item($item, $table)) !== null)
{
// add the last ID
$this->last[$table] = $item->id ?? $this->last[$table] ?? null;
}
else
{
unset($items[$id]);
}
}
if (ArrayHelper::check($items))
{
return $items;
}
}
return null;
}
/**
* Model the values of an row
* Example: $this->item(Array, 'table_name');
*
* @param array|null $item The item array
* @param string|null $table The table
*
* @return array|null
* @since 3.2.0
*/
public function row(?array $item, ?string $table = null): ?array
{
// we must have an array
if (empty($item))
{
return null;
}
// set the table name
if (empty($table))
{
$table = $this->getTable();
}
if (($fields = $this->getTableFields($table, true)) !== null)
{
// field counter
$field_number = 0;
// check if this is a valid table
$item_bucket = [];
foreach ($fields as $field)
{
// model a value if it exists
if(isset($item[$field]))
{
if (!$this->validateBefore($item[$field], $field, $table))
{
continue;
}
$item[$field] = $this->value($item[$field], $field, $table);
if (!$this->validateAfter($item[$field], $field, $table))
{
continue;
}
$item_bucket[$field] = $item[$field];
$field_number++;
}
}
// all items must have more than one field or its empty (1 = id or guid)
if ($field_number > 1)
{
return $item_bucket;
}
}
return null;
}
/**
* Model the values of multiple rows
* Example: $this->items(Array, 'table_name');
*
* @param array|null $items The array of item array
* @param string|null $table The table
*
* @return array|null
* @since 3.2.0
*/
public function rows(?array $items = null, ?string $table = null): ?array
{
// check if this is a valid table
if (ArrayHelper::check($items))
{
// set the table name
if (empty($table))
{
$table = $this->getTable();
}
foreach ($items as $id => &$item)
{
// model the item
if (($item = $this->row($item, $table)) !== null)
{
// add the last ID
$this->last[$table] = $item['id'] ?? $this->last[$table] ?? null;
}
else
{
unset($items[$id]);
}
}
if (ArrayHelper::check($items))
{
return $items;
}
}
return null;
}
/**
* Get last modeled ID
* Example: $this->last('table_name');
*
* @param string|null $table The table
*
* @return int|null
* @since 3.2.0
*/
public function last(?string $table = null): ?int
{
// set the table name
if (empty($table))
{
$table = $this->getTable();
}
// check if this is a valid table
if ($table && isset($this->last[$table]))
{
return $this->last[$table];
}
return null;
}
/**
* Get the current active table's fields (including defaults)
*
* @param string $table The area
* @param bool $default Add the default fields
*
* @return array
* @since 3.2.0
*/
protected function getTableFields(string $table, bool $default = false): ?array
{
return $this->table->fields($table, $default);
}
/**
* Validate before the value is modelled (basic, override in child class)
*
* @param mixed $value The field value
* @param string|null $field The field key
* @param string|null $table The table
*
* @return bool
* @since 3.2.0
*/
abstract protected function validateBefore(&$value, ?string $field = null, ?string $table = null): bool;
/**
* Validate after the value is modelled (basic, override in child class)
*
* @param mixed $value The field value
* @param string|null $field The field key
* @param string|null $table The table
*
* @return bool
* @since 3.2.0
*/
abstract protected function validateAfter(&$value, ?string $field = null, ?string $table = null): bool;
/**
* Get the current active table
*
* @return string
* @since 3.2.0
*/
abstract protected function getTable(): string;
}
###POWERCODE###

View File

@ -1,330 +1 @@
/**
* Last ID
*
* @var array
* @since 3.2.0
*/
protected array $last;
/**
* Search Table
*
* @var Table
* @since 3.2.0
*/
protected Table $table;
/**
* Constructor
*
* @param Table $table The search table object.
*
* @since 3.2.0
*/
public function __construct(Table $table)
{
$this->table = $table;
}
/**
* Model the value
* Example: $this->value(value, 'value_key', 'table_name');
*
* @param mixed $value The value to model
* @param string $field The field key
* @param string|null $table The table
*
* @return mixed
* @since 3.2.0
*/
abstract public function value($value, string $field, ?string $table = null);
/**
* Model the values of an item
* Example: $this->item(Object, 'table_name');
*
* @param object|null $item The item object
* @param string|null $table The table
*
* @return object|null
* @since 3.2.0
*/
public function item(?object $item, ?string $table = null): ?object
{
// we must have an object
if (empty($item))
{
return null;
}
// set the table name
if (empty($table))
{
$table = $this->getTable();
}
if (($fields = $this->getTableFields($table, true)) !== null)
{
// field counter
$field_number = 0;
// check if this is a valid table
$item_bucket = new \stdClass();
foreach ($fields as $field)
{
// model a value if it exists
if(isset($item->{$field}))
{
if (!$this->validateBefore($item->{$field}, $field, $table))
{
continue;
}
$item->{$field} = $this->value($item->{$field}, $field, $table);
if (!$this->validateAfter($item->{$field}, $field, $table))
{
continue;
}
$item_bucket->{$field} = $item->{$field};
$field_number++;
}
}
// all items must have more than one field or its empty (1 = key)
if ($field_number > 1)
{
return $item_bucket;
}
}
return null;
}
/**
* Model the values of multiple items
* Example: $this->items(Array, 'table_name');
*
* @param array|null $items The array of item objects
* @param string|null $table The table
*
* @return array|null
* @since 3.2.0
*/
public function items(?array $items = null, ?string $table = null): ?array
{
// check if this is a valid table
if (ArrayHelper::check($items))
{
// set the table name
if (empty($table))
{
$table = $this->getTable();
}
foreach ($items as $id => &$item)
{
// model the item
if (($item = $this->item($item, $table)) !== null)
{
// add the last ID
$this->last[$table] = $item->id ?? $this->last[$table] ?? null;
}
else
{
unset($items[$id]);
}
}
if (ArrayHelper::check($items))
{
return $items;
}
}
return null;
}
/**
* Model the values of an row
* Example: $this->item(Array, 'table_name');
*
* @param array|null $item The item array
* @param string|null $table The table
*
* @return array|null
* @since 3.2.0
*/
public function row(?array $item, ?string $table = null): ?array
{
// we must have an array
if (empty($item))
{
return null;
}
// set the table name
if (empty($table))
{
$table = $this->getTable();
}
if (($fields = $this->getTableFields($table, true)) !== null)
{
// field counter
$field_number = 0;
// check if this is a valid table
$item_bucket = [];
foreach ($fields as $field)
{
// model a value if it exists
if(isset($item[$field]))
{
if (!$this->validateBefore($item[$field], $field, $table))
{
continue;
}
$item[$field] = $this->value($item[$field], $field, $table);
if (!$this->validateAfter($item[$field], $field, $table))
{
continue;
}
$item_bucket[$field] = $item[$field];
$field_number++;
}
}
// all items must have more than one field or its empty (1 = id or guid)
if ($field_number > 1)
{
return $item_bucket;
}
}
return null;
}
/**
* Model the values of multiple rows
* Example: $this->items(Array, 'table_name');
*
* @param array|null $items The array of item array
* @param string|null $table The table
*
* @return array|null
* @since 3.2.0
*/
public function rows(?array $items = null, ?string $table = null): ?array
{
// check if this is a valid table
if (ArrayHelper::check($items))
{
// set the table name
if (empty($table))
{
$table = $this->getTable();
}
foreach ($items as $id => &$item)
{
// model the item
if (($item = $this->row($item, $table)) !== null)
{
// add the last ID
$this->last[$table] = $item['id'] ?? $this->last[$table] ?? null;
}
else
{
unset($items[$id]);
}
}
if (ArrayHelper::check($items))
{
return $items;
}
}
return null;
}
/**
* Get last modeled ID
* Example: $this->last('table_name');
*
* @param string|null $table The table
*
* @return int|null
* @since 3.2.0
*/
public function last(?string $table = null): ?int
{
// set the table name
if (empty($table))
{
$table = $this->getTable();
}
// check if this is a valid table
if ($table && isset($this->last[$table]))
{
return $this->last[$table];
}
return null;
}
/**
* Get the current active table's fields (including defaults)
*
* @param string $table The area
* @param bool $default Add the default fields
*
* @return array
* @since 3.2.0
*/
protected function getTableFields(string $table, bool $default = false): ?array
{
return $this->table->fields($table, $default);
}
/**
* Validate before the value is modelled (basic, override in child class)
*
* @param mixed $value The field value
* @param string|null $field The field key
* @param string|null $table The table
*
* @return bool
* @since 3.2.0
*/
abstract protected function validateBefore(&$value, ?string $field = null, ?string $table = null): bool;
/**
* Validate after the value is modelled (basic, override in child class)
*
* @param mixed $value The field value
* @param string|null $field The field key
* @param string|null $table The table
*
* @return bool
* @since 3.2.0
*/
abstract protected function validateAfter(&$value, ?string $field = null, ?string $table = null): bool;
/**
* Get the current active table
*
* @return string
* @since 3.2.0
*/
abstract protected function getTable(): string;
###CODEPOWER###

View File

@ -1,31 +1 @@
{
"add_head": "0",
"add_licensing_template": "2",
"extends": "0",
"guid": "584747d1-3a86-453d-b7a3-a2219de8d777",
"implements": null,
"load_selection": null,
"name": "Model",
"power_version": "1.0.0",
"system_name": "VDM.Abstraction.Model",
"type": "abstract class",
"use_selection": {
"use_selection0": {
"use": "1f28cb53-60d9-4db1-b517-3c7dc6b429ef",
"as": "default"
},
"use_selection1": {
"use": "0a59c65c-9daf-4bc9-baf4-e063ff9e6a8a",
"as": "default"
},
"use_selection2": {
"use": "2da6d6c4-eb29-4d69-8bc2-36d96e916adf",
"as": "Table"
}
},
"namespace": "VDM\\Joomla\\Abstraction.Model",
"description": "Base Model\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 <https:\/\/dev.vdm.io>\r\n * @git Joomla Component Builder <https:\/\/git.vdm.dev\/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": ""
}
###POWERLINKER###

View File

@ -1,82 +1 @@
```
██████╗ ██████╗ ██╗ ██╗███████╗██████╗
██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗
██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝
██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
```
# abstract class Helper (Details)
> namespace: **VDM\Joomla\Utilities\Component**
```uml
@startuml
abstract Helper #Orange {
+ {static} getParams(?string $option = null) : Registry
+ {static} getOption(string $default = 'empty') : ?string
+ {static} getCode(?string $option = null, ?string $default = null) : ?string
+ {static} get(string $option = null, string $default = null) : ?string
+ {static} methodExists(string $method, string $option = null) : bool
+ {static} _(string $method, array $arguments = [], ...) : mixed
}
note right of Helper::getParams
Gets the parameter object for the component
since: 3.0.11
return: Registry
end note
note right of Helper::getOption
Gets the component option
since: 3.0.11
return: ?string
end note
note right of Helper::getCode
Gets the component code name
since: 3.0.11
return: ?string
end note
note right of Helper::get
Gets the component abstract helper class
since: 3.0.11
return: ?string
end note
note right of Helper::methodExists
Check if the helper class of this component has a method
since: 3.0.11
return: bool
end note
note right of Helper::_
Check if the helper class of this component has a method, and call it with the arguments
since: 3.2.0
return: mixed
arguments:
string $method
array $arguments = []
?string $option = null
end note
@enduml
```
---
```
██╗ ██████╗██████╗
██║██╔════╝██╔══██╗
██║██║ ██████╔╝
██ ██║██║ ██╔══██╗
╚█████╔╝╚██████╗██████╔╝
╚════╝ ╚═════╝╚═════╝
```
> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder)
###POWERREADME###

View File

@ -9,181 +9,4 @@
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace VDM\Joomla\Utilities\Component;
use Joomla\Input\Input;
use Joomla\CMS\Component\ComponentHelper;
use Joomla\Registry\Registry;
/**
* Some component helper
*
* @since 3.0.11
*/
abstract class Helper
{
/**
* The current option
*
* @var string
* @since 3.0.11
*/
public static string $option;
/**
* The component params list cache
*
* @var Registry[]
* @since 3.0.11
*/
protected static array $params = [];
/**
* Gets the parameter object for the component
*
* @param string|null $option The option for the component.
*
* @return Registry A Registry object.
* @see Registry
* @since 3.0.11
*/
public static function getParams(?string $option = null): Registry
{
// check that we have an option
if (empty($option))
{
$option = self::getOption();
}
// get global value
if (!isset(self::$params[$option]) || !self::$params[$option] instanceof Registry)
{
self::$params[$option] = ComponentHelper::getParams($option);
}
return self::$params[$option];
}
/**
* Gets the component option
*
* @param string|null $default The default return value if none is found
*
* @return string|null A component option
* @since 3.0.11
*/
public static function getOption(string $default = 'empty'): ?string
{
if (empty(self::$option))
{
// get the option from the url input
self::$option = (new Input)->getString('option', false);
}
if (self::$option)
{
return self::$option;
}
return $default;
}
/**
* Gets the component code name
*
* @param string|null $option The option for the component.
* @param string|null $default The default return value if none is found
*
* @return string|null A component code name
* @since 3.0.11
*/
public static function getCode(?string $option = null, ?string $default = null): ?string
{
// check that we have an option
if (empty($option))
{
$option = self::getOption();
}
// option with com_
if (is_string($option) && strpos($option, 'com_') === 0)
{
return strtolower(trim(substr($option, 4)));
}
return $default;
}
/**
* Gets the component abstract helper class
*
* @param string|null $option The option for the component.
* @param string|null $default The default return value if none is found
*
* @return string|null A component helper name
*
* @since 3.0.11
*/
public static function get(string $option = null, string $default = null): ?string
{
// check that we have an option
// and get the code name from it
if (($code_name = self::getCode($option, false)) !== false)
{
// we build the helper class name
$helper_name = '\\' . \ucfirst($code_name) . 'Helper';
// check if class exist
if (class_exists($helper_name))
{
return $helper_name;
}
}
return $default;
}
/**
* Check if the helper class of this component has a method
*
* @param string $method The method name to search for
* @param string|null $option The option for the component.
*
* @return bool true if method exist
*
* @since 3.0.11
*/
public static function methodExists(string $method, string $option = null): bool
{
// get the helper class
return ($helper = self::get($option, false)) !== false &&
method_exists($helper, $method);
}
/**
* Check if the helper class of this component has a method, and call it with the arguments
*
* @param string $method The method name to search for
* @param array $arguments The arguments for function.
* @param string|null $option The option for the component.
*
* @return mixed return whatever the method returns or null
* @since 3.2.0
*/
public static function _(string $method, array $arguments = [], ?string $option = null)
{
// get the helper class
if (($helper = self::get($option, false)) !== false &&
method_exists($helper, $method))
{
// we know this is not ideal...
// so we need to move these
// functions to their own classes
return call_user_func_array([$helper, $method], $arguments);
}
return null;
}
}
###POWERCODE###

View File

@ -1,160 +1 @@
/**
* The current option
*
* @var string
* @since 3.0.11
*/
public static string $option;
/**
* The component params list cache
*
* @var Registry[]
* @since 3.0.11
*/
protected static array $params = [];
/**
* Gets the parameter object for the component
*
* @param string|null $option The option for the component.
*
* @return Registry A Registry object.
* @see Registry
* @since 3.0.11
*/
public static function getParams(?string $option = null): Registry
{
// check that we have an option
if (empty($option))
{
$option = self::getOption();
}
// get global value
if (!isset(self::$params[$option]) || !self::$params[$option] instanceof Registry)
{
self::$params[$option] = ComponentHelper::getParams($option);
}
return self::$params[$option];
}
/**
* Gets the component option
*
* @param string|null $default The default return value if none is found
*
* @return string|null A component option
* @since 3.0.11
*/
public static function getOption(string $default = 'empty'): ?string
{
if (empty(self::$option))
{
// get the option from the url input
self::$option = (new Input)->getString('option', false);
}
if (self::$option)
{
return self::$option;
}
return $default;
}
/**
* Gets the component code name
*
* @param string|null $option The option for the component.
* @param string|null $default The default return value if none is found
*
* @return string|null A component code name
* @since 3.0.11
*/
public static function getCode(?string $option = null, ?string $default = null): ?string
{
// check that we have an option
if (empty($option))
{
$option = self::getOption();
}
// option with com_
if (is_string($option) && strpos($option, 'com_') === 0)
{
return strtolower(trim(substr($option, 4)));
}
return $default;
}
/**
* Gets the component abstract helper class
*
* @param string|null $option The option for the component.
* @param string|null $default The default return value if none is found
*
* @return string|null A component helper name
*
* @since 3.0.11
*/
public static function get(string $option = null, string $default = null): ?string
{
// check that we have an option
// and get the code name from it
if (($code_name = self::getCode($option, false)) !== false)
{
// we build the helper class name
$helper_name = '\\' . \ucfirst($code_name) . 'Helper';
// check if class exist
if (class_exists($helper_name))
{
return $helper_name;
}
}
return $default;
}
/**
* Check if the helper class of this component has a method
*
* @param string $method The method name to search for
* @param string|null $option The option for the component.
*
* @return bool true if method exist
*
* @since 3.0.11
*/
public static function methodExists(string $method, string $option = null): bool
{
// get the helper class
return ($helper = self::get($option, false)) !== false &&
method_exists($helper, $method);
}
/**
* Check if the helper class of this component has a method, and call it with the arguments
*
* @param string $method The method name to search for
* @param array $arguments The arguments for function.
* @param string|null $option The option for the component.
*
* @return mixed return whatever the method returns or null
* @since 3.2.0
*/
public static function _(string $method, array $arguments = [], ?string $option = null)
{
// get the helper class
if (($helper = self::get($option, false)) !== false &&
method_exists($helper, $method))
{
// we know this is not ideal...
// so we need to move these
// functions to their own classes
return call_user_func_array([$helper, $method], $arguments);
}
return null;
}
###CODEPOWER###

View File

@ -1,18 +1 @@
{
"add_head": "1",
"add_licensing_template": "2",
"extends": "0",
"guid": "640b5352-fb09-425f-a26e-cd44eda03f15",
"implements": null,
"load_selection": null,
"name": "Helper",
"power_version": "1.0.0",
"system_name": "Utilities Component Helper",
"type": "abstract class",
"use_selection": null,
"namespace": "VDM\\Joomla\\Utilities.Component.Helper",
"description": "Some component helper\r\n\r\n@since 3.0.11",
"licensing_template": "\/**\r\n * @package Joomla.Component.Builder\r\n *\r\n * @created 3rd September, 2020\r\n * @author Llewellyn van der Merwe <https:\/\/dev.vdm.io>\r\n * @git Joomla Component Builder <https:\/\/git.vdm.dev\/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\\Input\\Input;\r\nuse Joomla\\CMS\\Component\\ComponentHelper;\r\nuse Joomla\\Registry\\Registry;",
"composer": ""
}
###POWERLINKER###

View File

@ -1,55 +1 @@
```
██████╗ ██████╗ ██╗ ██╗███████╗██████╗
██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗
██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝
██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
```
# abstract class Database (Details)
> namespace: **VDM\Joomla\Abstraction**
```uml
@startuml
abstract Database #Orange {
# \JDatabaseDriver $db
# string $table
+ __construct(?\JDatabaseDriver $db = null)
# quote(mixed $value) : mixed
# getTable(string $table) : string
}
note right of Database::__construct
Constructor
since: 3.2.0
end note
note right of Database::quote
Set a value based on data type
since: 3.2.0
return: mixed
end note
note right of Database::getTable
Set a table name, adding the
core component as needed
since: 3.2.0
return: string
end note
@enduml
```
---
```
██╗ ██████╗██████╗
██║██╔════╝██╔══██╗
██║██║ ██████╔╝
██ ██║██║ ██╔══██╗
╚█████╔╝╚██████╗██████╔╝
╚════╝ ╚═════╝╚═════╝
```
> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder)
###POWERREADME###

View File

@ -9,110 +9,4 @@
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace VDM\Joomla\Abstraction;
use Joomla\CMS\Factory as JoomlaFactory;
use VDM\Joomla\Utilities\Component\Helper;
/**
* Database
*
* @since 3.2.0
*/
abstract class Database
{
/**
* Database object to query local DB
*
* @var \JDatabaseDriver
* @since 3.2.0
*/
protected \JDatabaseDriver $db;
/**
* Core Component Table Name
*
* @var string
* @since 3.2.0
*/
protected string $table;
/**
* Constructor
*
* @param \JDatabaseDriver|null $db The database driver
*
* @throws \Exception
* @since 3.2.0
*/
public function __construct(?\JDatabaseDriver $db = null)
{
$this->db = $db ?: JoomlaFactory::getDbo();
// set the component table
$this->table = '#__' . Helper::getCode();
}
/**
* Set a value based on data type
*
* @param mixed $value The value to set
*
* @return mixed
* @since 3.2.0
**/
protected function quote($value)
{
if ($value === null) // hmm the null does pose an issue (will keep an eye on this)
{
return 'NULL';
}
if (is_numeric($value))
{
if (filter_var($value, FILTER_VALIDATE_INT))
{
return (int) $value;
}
elseif (filter_var($value, FILTER_VALIDATE_FLOAT))
{
return (float) $value;
}
}
elseif (is_bool($value)) // not sure if this will work well (but its correct)
{
return $value ? 'TRUE' : 'FALSE';
}
// For date and datetime values
if ($value instanceof \DateTime)
{
return $this->db->quote($value->format('Y-m-d H:i:s'));
}
// For other data types, just escape it
return $this->db->quote($value);
}
/**
* Set a table name, adding the
* core component as needed
*
* @param string $table The table string
*
* @return string
* @since 3.2.0
**/
protected function getTable(string $table): string
{
if (strpos($table, '#__') === false)
{
return $this->table . '_' . $table;
}
return $table;
}
}
###POWERCODE###

View File

@ -1,91 +1 @@
/**
* Database object to query local DB
*
* @var \JDatabaseDriver
* @since 3.2.0
*/
protected \JDatabaseDriver $db;
/**
* Core Component Table Name
*
* @var string
* @since 3.2.0
*/
protected string $table;
/**
* Constructor
*
* @param \JDatabaseDriver|null $db The database driver
*
* @throws \Exception
* @since 3.2.0
*/
public function __construct(?\JDatabaseDriver $db = null)
{
$this->db = $db ?: JoomlaFactory::getDbo();
// set the component table
$this->table = '#__' . Helper::getCode();
}
/**
* Set a value based on data type
*
* @param mixed $value The value to set
*
* @return mixed
* @since 3.2.0
**/
protected function quote($value)
{
if ($value === null) // hmm the null does pose an issue (will keep an eye on this)
{
return 'NULL';
}
if (is_numeric($value))
{
if (filter_var($value, FILTER_VALIDATE_INT))
{
return (int) $value;
}
elseif (filter_var($value, FILTER_VALIDATE_FLOAT))
{
return (float) $value;
}
}
elseif (is_bool($value)) // not sure if this will work well (but its correct)
{
return $value ? 'TRUE' : 'FALSE';
}
// For date and datetime values
if ($value instanceof \DateTime)
{
return $this->db->quote($value->format('Y-m-d H:i:s'));
}
// For other data types, just escape it
return $this->db->quote($value);
}
/**
* Set a table name, adding the
* core component as needed
*
* @param string $table The table string
*
* @return string
* @since 3.2.0
**/
protected function getTable(string $table): string
{
if (strpos($table, '#__') === false)
{
return $this->table . '_' . $table;
}
return $table;
}
###CODEPOWER###

View File

@ -1,23 +1 @@
{
"add_head": "1",
"add_licensing_template": "2",
"extends": "0",
"guid": "6cbef8f8-4813-48e3-b05a-65e1aea95171",
"implements": null,
"load_selection": null,
"name": "Database",
"power_version": "1.0.0",
"system_name": "VDM.Abstraction.Database",
"type": "abstract class",
"use_selection": {
"use_selection0": {
"use": "640b5352-fb09-425f-a26e-cd44eda03f15",
"as": "default"
}
},
"namespace": "VDM\\Joomla\\Abstraction.Database",
"description": "Database\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 <https:\/\/dev.vdm.io>\r\n * @git Joomla Component Builder <https:\/\/git.vdm.dev\/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 as JoomlaFactory;",
"composer": ""
}
###POWERLINKER###

View File

@ -1,83 +1 @@
```
██████╗ ██████╗ ██╗ ██╗███████╗██████╗
██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗
██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝
██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
```
# interface UpdateInterface (Details)
> namespace: **VDM\Joomla\Interfaces**
```uml
@startuml
interface UpdateInterface #Lavender {
+ rows(array $data, string $key, ...) : bool
+ items(array $data, string $key, ...) : bool
+ row(array $data, string $key, ...) : bool
+ item(object $data, string $key, ...) : bool
}
note right of UpdateInterface::rows
Update rows in the database (with remapping and filtering columns option)
since: 3.2.0
return: bool
arguments:
array $data
string $key
string $table
array $columns = []
end note
note right of UpdateInterface::items
Update items in the database (with remapping and filtering columns option)
since: 3.2.0
return: bool
arguments:
array $data
string $key
string $table
array $columns = []
end note
note right of UpdateInterface::row
Update row in the database
since: 3.2.0
return: bool
arguments:
array $data
string $key
string $table
end note
note right of UpdateInterface::item
Update item in the database
since: 3.2.0
return: bool
arguments:
object $data
string $key
string $table
end note
@enduml
```
---
```
██╗ ██████╗██████╗
██║██╔════╝██╔══██╗
██║██║ ██████╔╝
██ ██║██║ ██╔══██╗
╚█████╔╝╚██████╗██████╔╝
╚════╝ ╚═════╝╚═════╝
```
> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder)
###POWERREADME###

View File

@ -9,64 +9,4 @@
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace VDM\Joomla\Interfaces;
/**
* Database Update Interface
*
* @since 3.2.0
*/
interface UpdateInterface
{
/**
* Update rows in the database (with remapping and filtering columns option)
*
* @param array $data Dataset to update in database [array of arrays (key => value)]
* @param string $key Dataset key column to use in updating the values in the Database
* @param string $table The table where the data is being updated
* @param array $columns Data columns for remapping and filtering
*
* @return bool
* @since 3.2.0
**/
public function rows(array $data, string $key, string $table, array $columns = []): bool;
/**
* Update items in the database (with remapping and filtering columns option)
*
* @param array $data Data to updated in database (array of objects)
* @param string $key Dataset key column to use in updating the values in the Database
* @param string $table The table where the data is being update
* @param array $columns Data columns for remapping and filtering
*
* @return bool
* @since 3.2.0
**/
public function items(array $data, string $key, string $table, array $columns = []): bool;
/**
* Update row in the database
*
* @param array $data Dataset to update in database (key => value)
* @param string $key Dataset key column to use in updating the values in the Database
* @param string $table The table where the data is being updated
*
* @return bool
* @since 3.2.0
**/
public function row(array $data, string $key, string $table): bool;
/**
* Update item in the database
*
* @param object $data Dataset to update in database (key => value)
* @param string $key Dataset key column to use in updating the values in the Database
* @param string $table The table where the data is being updated
*
* @return bool
* @since 3.2.0
**/
public function item(object $data, string $key, string $table): bool;
}
###POWERCODE###

View File

@ -1,49 +1 @@
/**
* Update rows in the database (with remapping and filtering columns option)
*
* @param array $data Dataset to update in database [array of arrays (key => value)]
* @param string $key Dataset key column to use in updating the values in the Database
* @param string $table The table where the data is being updated
* @param array $columns Data columns for remapping and filtering
*
* @return bool
* @since 3.2.0
**/
public function rows(array $data, string $key, string $table, array $columns = []): bool;
/**
* Update items in the database (with remapping and filtering columns option)
*
* @param array $data Data to updated in database (array of objects)
* @param string $key Dataset key column to use in updating the values in the Database
* @param string $table The table where the data is being update
* @param array $columns Data columns for remapping and filtering
*
* @return bool
* @since 3.2.0
**/
public function items(array $data, string $key, string $table, array $columns = []): bool;
/**
* Update row in the database
*
* @param array $data Dataset to update in database (key => value)
* @param string $key Dataset key column to use in updating the values in the Database
* @param string $table The table where the data is being updated
*
* @return bool
* @since 3.2.0
**/
public function row(array $data, string $key, string $table): bool;
/**
* Update item in the database
*
* @param object $data Dataset to update in database (key => value)
* @param string $key Dataset key column to use in updating the values in the Database
* @param string $table The table where the data is being updated
*
* @return bool
* @since 3.2.0
**/
public function item(object $data, string $key, string $table): bool;
###CODEPOWER###

View File

@ -1,18 +1 @@
{
"add_head": "0",
"add_licensing_template": "2",
"extends": "0",
"guid": "7179fde6-1e51-4b51-8545-7ca18f74a0f4",
"implements": null,
"load_selection": null,
"name": "UpdateInterface",
"power_version": "1.0.0",
"system_name": "VDM.Interfaces.UpdateInterface",
"type": "interface",
"use_selection": null,
"namespace": "VDM\\Joomla\\Interfaces.UpdateInterface",
"description": "Database Update Interface\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 <https:\/\/dev.vdm.io>\r\n * @git Joomla Component Builder <https:\/\/git.vdm.dev\/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": ""
}
###POWERLINKER###

View File

@ -1,88 +1 @@
```
██████╗ ██████╗ ██╗ ██╗███████╗██████╗
██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗
██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝
██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
```
# interface ModelInterface (Details)
> namespace: **VDM\Joomla\Interfaces**
```uml
@startuml
interface ModelInterface #Lavender {
+ value(mixed $value, string $field, ...) : mixed
+ item(object $item, ?string $table = null) : ?object
+ items(?array $items = null, ?string $table = null) : ?array
+ row(array $item, ?string $table = null) : ?array
+ rows(?array $items = null, ?string $table = null) : ?array
+ last(?string $table = null) : ?int
}
note right of ModelInterface::value
Model the value
Example: $this->value(value, 'value_key', 'table_name');
since: 3.2.0
return: mixed
arguments:
mixed $value
string $field
?string $table = null
end note
note right of ModelInterface::item
Model the values of an item
Example: $this->item(Object, 'table_name');
since: 3.2.0
return: ?object
end note
note right of ModelInterface::items
Model the values of multiple items
Example: $this->items(Array, 'table_name');
since: 3.2.0
return: ?array
end note
note right of ModelInterface::row
Model the values of an row
Example: $this->item(Array, 'table_name');
since: 3.2.0
return: ?array
end note
note right of ModelInterface::rows
Model the values of multiple rows
Example: $this->items(Array, 'table_name');
since: 3.2.0
return: ?array
end note
note right of ModelInterface::last
Get last modeled ID
Example: $this->last('table_name');
since: 3.2.0
return: ?int
end note
@enduml
```
---
```
██╗ ██████╗██████╗
██║██╔════╝██╔══██╗
██║██║ ██████╔╝
██ ██║██║ ██╔══██╗
╚█████╔╝╚██████╗██████╔╝
╚════╝ ╚═════╝╚═════╝
```
> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder)
###POWERREADME###

View File

@ -9,86 +9,4 @@
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace VDM\Joomla\Interfaces;
/**
* Model Interface
*
* @since 3.2.0
*/
interface ModelInterface
{
/**
* Model the value
* Example: $this->value(value, 'value_key', 'table_name');
*
* @param mixed $value The value to model
* @param string $field The field key
* @param string|null $table The table
*
* @return mixed
* @since 3.2.0
*/
public function value($value, string $field, ?string $table = null);
/**
* Model the values of an item
* Example: $this->item(Object, 'table_name');
*
* @param object $item The item object
* @param string|null $table The table
*
* @return object|null
* @since 3.2.0
*/
public function item(object $item, ?string $table = null): ?object;
/**
* Model the values of multiple items
* Example: $this->items(Array, 'table_name');
*
* @param array|null $items The array of item objects
* @param string|null $table The table
*
* @return array|null
* @since 3.2.0
*/
public function items(?array $items = null, ?string $table = null): ?array;
/**
* Model the values of an row
* Example: $this->item(Array, 'table_name');
*
* @param array $item The item array
* @param string|null $table The table
*
* @return array|null
* @since 3.2.0
*/
public function row(array $item, ?string $table = null): ?array;
/**
* Model the values of multiple rows
* Example: $this->items(Array, 'table_name');
*
* @param array|null $items The array of item array
* @param string|null $table The table
*
* @return array|null
* @since 3.2.0
*/
public function rows(?array $items = null, ?string $table = null): ?array;
/**
* Get last modeled ID
* Example: $this->last('table_name');
*
* @param string|null $table The table
*
* @return int|null
* @since 3.2.0
*/
public function last(?string $table = null): ?int;
}
###POWERCODE###

View File

@ -1,71 +1 @@
/**
* Model the value
* Example: $this->value(value, 'value_key', 'table_name');
*
* @param mixed $value The value to model
* @param string $field The field key
* @param string|null $table The table
*
* @return mixed
* @since 3.2.0
*/
public function value($value, string $field, ?string $table = null);
/**
* Model the values of an item
* Example: $this->item(Object, 'table_name');
*
* @param object $item The item object
* @param string|null $table The table
*
* @return object|null
* @since 3.2.0
*/
public function item(object $item, ?string $table = null): ?object;
/**
* Model the values of multiple items
* Example: $this->items(Array, 'table_name');
*
* @param array|null $items The array of item objects
* @param string|null $table The table
*
* @return array|null
* @since 3.2.0
*/
public function items(?array $items = null, ?string $table = null): ?array;
/**
* Model the values of an row
* Example: $this->item(Array, 'table_name');
*
* @param array $item The item array
* @param string|null $table The table
*
* @return array|null
* @since 3.2.0
*/
public function row(array $item, ?string $table = null): ?array;
/**
* Model the values of multiple rows
* Example: $this->items(Array, 'table_name');
*
* @param array|null $items The array of item array
* @param string|null $table The table
*
* @return array|null
* @since 3.2.0
*/
public function rows(?array $items = null, ?string $table = null): ?array;
/**
* Get last modeled ID
* Example: $this->last('table_name');
*
* @param string|null $table The table
*
* @return int|null
* @since 3.2.0
*/
public function last(?string $table = null): ?int;
###CODEPOWER###

View File

@ -1,18 +1 @@
{
"add_head": "0",
"add_licensing_template": "2",
"extends": "0",
"guid": "8aef58c1-3f70-4bd4-b9e4-3f29fcd41cff",
"implements": null,
"load_selection": null,
"name": "ModelInterface",
"power_version": "1.0.0",
"system_name": "VDM.Interfaces.ModelInterface",
"type": "interface",
"use_selection": null,
"namespace": "VDM\\Joomla\\Interfaces.ModelInterface",
"description": "Model Interface\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 <https:\/\/dev.vdm.io>\r\n * @git Joomla Component Builder <https:\/\/git.vdm.dev\/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": ""
}
###POWERLINKER###

View File

@ -1,47 +1 @@
```
██████╗ ██████╗ ██╗ ██╗███████╗██████╗
██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗
██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝
██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
```
# abstract class ObjectHelper (Details)
> namespace: **VDM\Joomla\Utilities**
```uml
@startuml
abstract ObjectHelper #Orange {
+ {static} check($object)
+ {static} equal(?object $obj1, ?object $obj2) : bool
}
note right of ObjectHelper::check
Check if have an object with a length
since: 3.0.9
end note
note right of ObjectHelper::equal
Compare two objects for equality based on their property values.
Note that this method works only for simple objects that don't
contain any nested objects or resource references. If you need
to compare more complex objects, you may need to use a
more advanced method such as serialization or reflection.
return: bool
end note
@enduml
```
---
```
██╗ ██████╗██████╗
██║██╔════╝██╔══██╗
██║██║ ██████╔╝
██ ██║██║ ██╔══██╗
╚█████╔╝╚██████╗██████╔╝
╚════╝ ╚═════╝╚═════╝
```
> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder)
###POWERREADME###

View File

@ -9,70 +9,4 @@
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace VDM\Joomla\Utilities;
/**
* Some object tricks
*
* @since 3.0.9
*/
abstract class ObjectHelper
{
/**
* Check if have an object with a length
*
* @input object The object to check
*
* @returns bool true on success
*
* @since 3.0.9
*/
public static function check($object)
{
if (is_object($object))
{
return count((array) $object) > 0;
}
return false;
}
/**
* Compare two objects for equality based on their property values.
*
* Note that this method works only for simple objects that don't
* contain any nested objects or resource references. If you need
* to compare more complex objects, you may need to use a
* more advanced method such as serialization or reflection.
*
* @param object|null $obj1 The first object to compare.
* @param object|null $obj2 The second object to compare.
*
* @return bool True if the objects have the same key-value pairs and false otherwise.
*/
public static function equal(?object $obj1, ?object $obj2): bool
{
// if any is null we return false as that means there is a none object
// we are not comparing null but objects
// but we allow null as some objects while
// not instantiate are still null
if (is_null($obj1) || is_null($obj2))
{
return false;
}
// Convert the objects to arrays of their property values using get_object_vars.
$array1 = get_object_vars($obj1);
$array2 = get_object_vars($obj2);
// Compare the arrays using array_diff_assoc to detect any differences.
$diff1 = array_diff_assoc($array1, $array2);
$diff2 = array_diff_assoc($array2, $array1);
// If the arrays have the same key-value pairs, they will have no differences, so return true.
return empty($diff1) && empty($diff2);
}
}
###POWERCODE###

View File

@ -1,54 +1 @@
/**
* Check if have an object with a length
*
* @input object The object to check
*
* @returns bool true on success
*
* @since 3.0.9
*/
public static function check($object)
{
if (is_object($object))
{
return count((array) $object) > 0;
}
return false;
}
/**
* Compare two objects for equality based on their property values.
*
* Note that this method works only for simple objects that don't
* contain any nested objects or resource references. If you need
* to compare more complex objects, you may need to use a
* more advanced method such as serialization or reflection.
*
* @param object|null $obj1 The first object to compare.
* @param object|null $obj2 The second object to compare.
*
* @return bool True if the objects have the same key-value pairs and false otherwise.
*/
public static function equal(?object $obj1, ?object $obj2): bool
{
// if any is null we return false as that means there is a none object
// we are not comparing null but objects
// but we allow null as some objects while
// not instantiate are still null
if (is_null($obj1) || is_null($obj2))
{
return false;
}
// Convert the objects to arrays of their property values using get_object_vars.
$array1 = get_object_vars($obj1);
$array2 = get_object_vars($obj2);
// Compare the arrays using array_diff_assoc to detect any differences.
$diff1 = array_diff_assoc($array1, $array2);
$diff2 = array_diff_assoc($array2, $array1);
// If the arrays have the same key-value pairs, they will have no differences, so return true.
return empty($diff1) && empty($diff2);
}
###CODEPOWER###

View File

@ -1,18 +1 @@
{
"add_head": "0",
"add_licensing_template": "2",
"extends": "0",
"guid": "91004529-94a9-4590-b842-e7c6b624ecf5",
"implements": null,
"load_selection": null,
"name": "ObjectHelper",
"power_version": "1.0.0",
"system_name": "Utilities Object Helper",
"type": "abstract class",
"use_selection": null,
"namespace": "VDM\\Joomla\\Utilities.ObjectHelper",
"description": "Some object tricks\r\n\r\n@since 3.0.9",
"licensing_template": "\/**\r\n * @package Joomla.Component.Builder\r\n *\r\n * @created 3rd September, 2020\r\n * @author Llewellyn van der Merwe <https:\/\/dev.vdm.io>\r\n * @git Joomla Component Builder <https:\/\/git.vdm.dev\/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": ""
}
###POWERLINKER###

View File

@ -1,80 +1 @@
```
██████╗ ██████╗ ██╗ ██╗███████╗██████╗
██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗
██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝
██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
```
# abstract class GuidHelper (Details)
> namespace: **VDM\Joomla\Utilities**
```uml
@startuml
abstract GuidHelper #Orange {
+ {static} get(bool $trim = true) : string
+ {static} valid(string $guid, ?string $table = null, ...) : bool
+ {static} item(string $guid, string $table, ...) : mix
# {static} validate(string $guid) : bool
}
note right of GuidHelper::get
Returns a GUIDv4 string
Thanks to Dave Pearson (and other)
https://www.php.net/manual/en/function.com-create-guid.php#119168
Uses the best cryptographically secure method
for all supported platforms with fallback to an older,
less secure version.
since: 3.0.9
return: string
end note
note right of GuidHelper::valid
Validate the Globally Unique Identifier ( and check if table already has this identifier)
since: 3.0.9
return: bool
arguments:
string $guid
?string $table = null
int $id
?string $component = null
end note
note right of GuidHelper::item
get the item by guid in a table
since: 3.0.9
return: mix
arguments:
string $guid
string $table
string|array $what = 'a.id'
?string $component = null
end note
note right of GuidHelper::validate
Validate the Globally Unique Identifier
Thanks to Lewie
https://stackoverflow.com/a/1515456/1429677
since: 3.0.9
return: bool
end note
@enduml
```
---
```
██╗ ██████╗██████╗
██║██╔════╝██╔══██╗
██║██║ ██████╔╝
██ ██║██║ ██╔══██╗
╚█████╔╝╚██████╗██████╔╝
╚════╝ ╚═════╝╚═════╝
```
> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder)
###POWERREADME###

View File

@ -9,207 +9,4 @@
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace VDM\Joomla\Utilities;
use Joomla\CMS\Factory;
use VDM\Joomla\Utilities\Component\Helper;
/**
* Global Unique ID Helper
*
* @since 3.0.9
*/
abstract class GuidHelper
{
/**
* Returns a GUIDv4 string
*
* Thanks to Dave Pearson (and other)
* https://www.php.net/manual/en/function.com-create-guid.php#119168
*
* Uses the best cryptographically secure method
* for all supported platforms with fallback to an older,
* less secure version.
*
* @param bool $trim
*
* @return string
*
* @since 3.0.9
*/
public static function get(bool $trim = true): string
{
// Windows
if (function_exists('com_create_guid'))
{
if ($trim)
{
return trim(com_create_guid(), '{}');
}
return com_create_guid();
}
// set the braces if needed
$lbrace = $trim ? "" : chr(123); // "{"
$rbrace = $trim ? "" : chr(125); // "}"
// OSX/Linux
if (function_exists('openssl_random_pseudo_bytes'))
{
$data = openssl_random_pseudo_bytes(16);
$data[6] = chr( ord($data[6]) & 0x0f | 0x40); // set version to 0100
$data[8] = chr( ord($data[8]) & 0x3f | 0x80); // set bits 6-7 to 10
return $lbrace . vsprintf('%s%s-%s-%s-%s-%s%s%s', str_split(bin2hex($data), 4)) . $lbrace;
}
// Fallback (PHP 4.2+)
mt_srand((double) microtime() * 10000);
$charid = strtolower( md5( uniqid( rand(), true)));
$hyphen = chr(45); // "-"
$guidv4 = $lbrace.
substr($charid, 0, 8). $hyphen.
substr($charid, 8, 4). $hyphen.
substr($charid, 12, 4). $hyphen.
substr($charid, 16, 4). $hyphen.
substr($charid, 20, 12).
$rbrace;
return $guidv4;
}
/**
* Validate the Globally Unique Identifier ( and check if table already has this identifier)
*
* @param string $guid
* @param string|null $table
* @param int $id
* @param string|null $component
*
* @return bool
*
* @since 3.0.9
*/
public static function valid($guid, ?string $table = null, int $id = 0, ?string $component = null): bool
{
// check if we have a string
if (self::validate($guid))
{
// check if table already has this identifier
if (StringHelper::check($table))
{
// check that we have the component code name
if (!is_string($component))
{
$component = (string) Helper::getCode();
}
// Get the database object and a new query object.
$db = Factory::getDbo();
$query = $db->getQuery(true);
$query->select('COUNT(*)')
->from('#__' . (string) $component . '_' . (string) $table)
->where($db->quoteName('guid') . ' = ' . $db->quote($guid));
// remove this item from the list
if ($id > 0)
{
$query->where($db->quoteName('id') . ' <> ' . (int) $id);
}
// Set and query the database.
$db->setQuery($query);
$duplicate = (bool) $db->loadResult();
if ($duplicate)
{
return false;
}
}
return true;
}
return false;
}
/**
* get the item by guid in a table
*
* @param string $guid
* @param string $table
* @param string|array $what
* @param string|null $component
*
* @return mix
*
* @since 3.0.9
*/
public static function item($guid, $table, $what = 'a.id', ?string $component = null)
{
// check if we have a string
// check if table already has this identifier
if (self::validate($guid) && StringHelper::check($table))
{
// check that we have the component code name
if (!is_string($component))
{
$component = (string) Helper::getCode();
}
// Get the database object and a new query object.
$db = Factory::getDbo();
$query = $db->getQuery(true);
if (ArrayHelper::check($what))
{
$query->select($db->quoteName($what));
}
else
{
$query->select($what);
}
$query->from($db->quoteName('#__' . (string) $component . '_' . (string) $table, 'a'))
->where($db->quoteName('a.guid') . ' = ' . $db->quote($guid));
// Set and query the database.
$db->setQuery($query);
$db->execute();
if ($db->getNumRows())
{
if (ArrayHelper::check($what) || $what === 'a.*')
{
return $db->loadObject();
}
else
{
return $db->loadResult();
}
}
}
return null;
}
/**
* Validate the Globally Unique Identifier
*
* Thanks to Lewie
* https://stackoverflow.com/a/1515456/1429677
*
* @param string $guid
*
* @return bool
*
* @since 3.0.9
*/
protected static function validate($guid)
{
// check if we have a string
if (StringHelper::check($guid))
{
return preg_match("/^(\{)?[a-f\d]{8}(-[a-f\d]{4}){4}[a-f\d]{8}(?(1)\})$/i", $guid);
}
return false;
}
}
###POWERCODE###

View File

@ -1,187 +1 @@
/**
* Returns a GUIDv4 string
*
* Thanks to Dave Pearson (and other)
* https://www.php.net/manual/en/function.com-create-guid.php#119168
*
* Uses the best cryptographically secure method
* for all supported platforms with fallback to an older,
* less secure version.
*
* @param bool $trim
*
* @return string
*
* @since 3.0.9
*/
public static function get(bool $trim = true): string
{
// Windows
if (function_exists('com_create_guid'))
{
if ($trim)
{
return trim(com_create_guid(), '{}');
}
return com_create_guid();
}
// set the braces if needed
$lbrace = $trim ? "" : chr(123); // "{"
$rbrace = $trim ? "" : chr(125); // "}"
// OSX/Linux
if (function_exists('openssl_random_pseudo_bytes'))
{
$data = openssl_random_pseudo_bytes(16);
$data[6] = chr( ord($data[6]) & 0x0f | 0x40); // set version to 0100
$data[8] = chr( ord($data[8]) & 0x3f | 0x80); // set bits 6-7 to 10
return $lbrace . vsprintf('%s%s-%s-%s-%s-%s%s%s', str_split(bin2hex($data), 4)) . $lbrace;
}
// Fallback (PHP 4.2+)
mt_srand((double) microtime() * 10000);
$charid = strtolower( md5( uniqid( rand(), true)));
$hyphen = chr(45); // "-"
$guidv4 = $lbrace.
substr($charid, 0, 8). $hyphen.
substr($charid, 8, 4). $hyphen.
substr($charid, 12, 4). $hyphen.
substr($charid, 16, 4). $hyphen.
substr($charid, 20, 12).
$rbrace;
return $guidv4;
}
/**
* Validate the Globally Unique Identifier ( and check if table already has this identifier)
*
* @param string $guid
* @param string|null $table
* @param int $id
* @param string|null $component
*
* @return bool
*
* @since 3.0.9
*/
public static function valid($guid, ?string $table = null, int $id = 0, ?string $component = null): bool
{
// check if we have a string
if (self::validate($guid))
{
// check if table already has this identifier
if (StringHelper::check($table))
{
// check that we have the component code name
if (!is_string($component))
{
$component = (string) Helper::getCode();
}
// Get the database object and a new query object.
$db = Factory::getDbo();
$query = $db->getQuery(true);
$query->select('COUNT(*)')
->from('#__' . (string) $component . '_' . (string) $table)
->where($db->quoteName('guid') . ' = ' . $db->quote($guid));
// remove this item from the list
if ($id > 0)
{
$query->where($db->quoteName('id') . ' <> ' . (int) $id);
}
// Set and query the database.
$db->setQuery($query);
$duplicate = (bool) $db->loadResult();
if ($duplicate)
{
return false;
}
}
return true;
}
return false;
}
/**
* get the item by guid in a table
*
* @param string $guid
* @param string $table
* @param string|array $what
* @param string|null $component
*
* @return mix
*
* @since 3.0.9
*/
public static function item($guid, $table, $what = 'a.id', ?string $component = null)
{
// check if we have a string
// check if table already has this identifier
if (self::validate($guid) && StringHelper::check($table))
{
// check that we have the component code name
if (!is_string($component))
{
$component = (string) Helper::getCode();
}
// Get the database object and a new query object.
$db = Factory::getDbo();
$query = $db->getQuery(true);
if (ArrayHelper::check($what))
{
$query->select($db->quoteName($what));
}
else
{
$query->select($what);
}
$query->from($db->quoteName('#__' . (string) $component . '_' . (string) $table, 'a'))
->where($db->quoteName('a.guid') . ' = ' . $db->quote($guid));
// Set and query the database.
$db->setQuery($query);
$db->execute();
if ($db->getNumRows())
{
if (ArrayHelper::check($what) || $what === 'a.*')
{
return $db->loadObject();
}
else
{
return $db->loadResult();
}
}
}
return null;
}
/**
* Validate the Globally Unique Identifier
*
* Thanks to Lewie
* https://stackoverflow.com/a/1515456/1429677
*
* @param string $guid
*
* @return bool
*
* @since 3.0.9
*/
protected static function validate($guid)
{
// check if we have a string
if (StringHelper::check($guid))
{
return preg_match("/^(\{)?[a-f\d]{8}(-[a-f\d]{4}){4}[a-f\d]{8}(?(1)\})$/i", $guid);
}
return false;
}
###CODEPOWER###

View File

@ -1,30 +1 @@
{
"add_head": "1",
"add_licensing_template": "2",
"extends": "0",
"guid": "9c513baf-b279-43fd-ae29-a585c8cbc4f0",
"implements": null,
"load_selection": {
"load_selection0": {
"load": "0a59c65c-9daf-4bc9-baf4-e063ff9e6a8a"
},
"load_selection1": {
"load": "1f28cb53-60d9-4db1-b517-3c7dc6b429ef"
}
},
"name": "GuidHelper",
"power_version": "1.0.0",
"system_name": "Utilities GuidHelper",
"type": "abstract class",
"use_selection": {
"use_selection0": {
"use": "640b5352-fb09-425f-a26e-cd44eda03f15",
"as": "default"
}
},
"namespace": "VDM\\Joomla\\Utilities.GuidHelper",
"description": "Global Unique ID Helper\r\n\r\n@since 3.0.9",
"licensing_template": "\/**\r\n * @package Joomla.Component.Builder\r\n *\r\n * @created 3rd September, 2020\r\n * @author Llewellyn van der Merwe <https:\/\/dev.vdm.io>\r\n * @git Joomla Component Builder <https:\/\/git.vdm.dev\/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": ""
}
###POWERLINKER###

View File

@ -1,79 +1 @@
```
██████╗ ██████╗ ██╗ ██╗███████╗██████╗
██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗
██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝
██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
```
# interface InsertInterface (Details)
> namespace: **VDM\Joomla\Interfaces**
```uml
@startuml
interface InsertInterface #Lavender {
+ defaults(bool $trigger = true) : void
+ rows(array $data, string $table, ...) : bool
+ items(array $data, string $table, ...) : bool
+ row(array $data, string $table) : bool
+ item(object $data, string $table) : bool
}
note right of InsertInterface::defaults
Switch to prevent/allow defaults from being added.
since: 3.2.0
return: void
end note
note right of InsertInterface::rows
Insert rows to the database (with remapping and filtering columns option)
since: 3.2.0
return: bool
arguments:
array $data
string $table
array $columns = []
end note
note right of InsertInterface::items
Insert items to the database (with remapping and filtering columns option)
since: 3.2.0
return: bool
arguments:
array $data
string $table
array $columns = []
end note
note right of InsertInterface::row
Insert row to the database
since: 3.2.0
return: bool
end note
note right of InsertInterface::item
Insert item to the database
since: 3.2.0
return: bool
end note
@enduml
```
---
```
██╗ ██████╗██████╗
██║██╔════╝██╔══██╗
██║██║ ██████╔╝
██ ██║██║ ██╔══██╗
╚█████╔╝╚██████╗██████╔╝
╚════╝ ╚═════╝╚═════╝
```
> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder)
###POWERREADME###

View File

@ -9,70 +9,4 @@
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace VDM\Joomla\Interfaces;
/**
* Database Insert Interface
*
* @since 3.2.0
*/
interface InsertInterface
{
/**
* Switch to prevent/allow defaults from being added.
*
* @param bool $trigger toggle the defaults
*
* @return void
* @since 3.2.0
**/
public function defaults(bool $trigger = true);
/**
* Insert rows to the database (with remapping and filtering columns option)
*
* @param array $data Dataset to store in database [array of arrays (key => value)]
* @param string $table The table where the data is being added
* @param array $columns Data columns for remapping and filtering
*
* @return bool
* @since 3.2.0
**/
public function rows(array $data, string $table, array $columns = []): bool;
/**
* Insert items to the database (with remapping and filtering columns option)
*
* @param array $data Data to store in database (array of objects)
* @param string $table The table where the data is being added
* @param array $columns Data columns for remapping and filtering
*
* @return bool
* @since 3.2.0
**/
public function items(array $data, string $table, array $columns = []): bool;
/**
* Insert row to the database
*
* @param array $data Dataset to store in database (key => value)
* @param string $table The table where the data is being added
*
* @return bool
* @since 3.2.0
**/
public function row(array $data, string $table): bool;
/**
* Insert item to the database
*
* @param object $data Dataset to store in database (key => value)
* @param string $table The table where the data is being added
*
* @return bool
* @since 3.2.0
**/
public function item(object $data, string $table): bool;
}
###POWERCODE###

View File

@ -1,55 +1 @@
/**
* Switch to prevent/allow defaults from being added.
*
* @param bool $trigger toggle the defaults
*
* @return void
* @since 3.2.0
**/
public function defaults(bool $trigger = true);
/**
* Insert rows to the database (with remapping and filtering columns option)
*
* @param array $data Dataset to store in database [array of arrays (key => value)]
* @param string $table The table where the data is being added
* @param array $columns Data columns for remapping and filtering
*
* @return bool
* @since 3.2.0
**/
public function rows(array $data, string $table, array $columns = []): bool;
/**
* Insert items to the database (with remapping and filtering columns option)
*
* @param array $data Data to store in database (array of objects)
* @param string $table The table where the data is being added
* @param array $columns Data columns for remapping and filtering
*
* @return bool
* @since 3.2.0
**/
public function items(array $data, string $table, array $columns = []): bool;
/**
* Insert row to the database
*
* @param array $data Dataset to store in database (key => value)
* @param string $table The table where the data is being added
*
* @return bool
* @since 3.2.0
**/
public function row(array $data, string $table): bool;
/**
* Insert item to the database
*
* @param object $data Dataset to store in database (key => value)
* @param string $table The table where the data is being added
*
* @return bool
* @since 3.2.0
**/
public function item(object $data, string $table): bool;
###CODEPOWER###

View File

@ -1,18 +1 @@
{
"add_head": "0",
"add_licensing_template": "2",
"extends": "0",
"guid": "ad12ca1c-d3ce-4e7f-88c5-c6c92bdedc48",
"implements": null,
"load_selection": null,
"name": "InsertInterface",
"power_version": "1.0.0",
"system_name": "JCB.Interfaces.InsertInterface",
"type": "interface",
"use_selection": null,
"namespace": "VDM\\Joomla\\Interfaces.InsertInterface",
"description": "Database Insert Interface\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 <https:\/\/dev.vdm.io>\r\n * @git Joomla Component Builder <https:\/\/git.vdm.dev\/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": ""
}
###POWERLINKER###

View File

@ -1,45 +1 @@
```
██████╗ ██████╗ ██╗ ██╗███████╗██████╗
██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗
██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝
██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
```
# interface FactoryInterface (Details)
> namespace: **VDM\Joomla\Interfaces**
```uml
@startuml
interface FactoryInterface #Lavender {
+ {static} _(string $key) : Mixed
+ {static} getContainer() : Container
}
note right of FactoryInterface::_
Get any class from the container
since: 3.2.0
return: Mixed
end note
note right of FactoryInterface::getContainer
Get the global container
since: 3.2.0
return: Container
end note
@enduml
```
---
```
██╗ ██████╗██████╗
██║██╔════╝██╔══██╗
██║██║ ██████╔╝
██ ██║██║ ██╔══██╗
╚█████╔╝╚██████╗██████╔╝
╚════╝ ╚═════╝╚═════╝
```
> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder)
###POWERREADME###

View File

@ -9,33 +9,4 @@
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace VDM\Joomla\Interfaces;
use Joomla\DI\Container;
/**
* The Container Factory Interface
*/
interface FactoryInterface
{
/**
* Get any class from the container
*
* @param string $key The container class key
*
* @return Mixed
* @since 3.2.0
*/
public static function _(string $key);
/**
* Get the global container
*
* @return Container
* @since 3.2.0
*/
public static function getContainer(): Container;
}
###POWERCODE###

View File

@ -1,17 +1 @@
/**
* Get any class from the container
*
* @param string $key The container class key
*
* @return Mixed
* @since 3.2.0
*/
public static function _(string $key);
/**
* Get the global container
*
* @return Container
* @since 3.2.0
*/
public static function getContainer(): Container;
###CODEPOWER###

View File

@ -1,18 +1 @@
{
"add_head": "1",
"add_licensing_template": "2",
"extends": "0",
"guid": "caf33c5d-858c-4f9a-894f-ab302ec5445a",
"implements": null,
"load_selection": null,
"name": "FactoryInterface",
"power_version": "1.0.0",
"system_name": "VDM.Interfaces.FactoryInterface",
"type": "interface",
"use_selection": null,
"namespace": "VDM\\Joomla\\Interfaces.FactoryInterface",
"description": "The Container Factory Interface",
"licensing_template": "\/**\r\n * @package Joomla.Component.Builder\r\n *\r\n * @created 4th September, 2022\r\n * @author Llewellyn van der Merwe <https:\/\/dev.vdm.io>\r\n * @git Joomla Component Builder <https:\/\/git.vdm.dev\/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;",
"composer": ""
}
###POWERLINKER###

View File

@ -1,83 +1 @@
```
██████╗ ██████╗ ██╗ ██╗███████╗██████╗
██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗
██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝
██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
```
# final class Update (Details)
> namespace: **VDM\Joomla\Database**
```uml
@startuml
class Update << (F,LightGreen) >> #Green {
+ rows(array $data, string $key, ...) : bool
+ items(array $data, string $key, ...) : bool
+ row(array $data, string $key, ...) : bool
+ item(object $data, string $key, ...) : bool
}
note right of Update::rows
Update rows in the database (with remapping and filtering columns option)
since: 3.2.0
return: bool
arguments:
array $data
string $key
string $table
array $columns = []
end note
note right of Update::items
Update items in the database (with remapping and filtering columns option)
since: 3.2.0
return: bool
arguments:
array $data
string $key
string $table
array $columns = []
end note
note right of Update::row
Update row in the database
since: 3.2.0
return: bool
arguments:
array $data
string $key
string $table
end note
note right of Update::item
Update item in the database
since: 3.2.0
return: bool
arguments:
object $data
string $key
string $table
end note
@enduml
```
---
```
██╗ ██████╗██████╗
██║██╔════╝██╔══██╗
██║██║ ██████╔╝
██ ██║██║ ██╔══██╗
╚█████╔╝╚██████╗██████╔╝
╚════╝ ╚═════╝╚═════╝
```
> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder)
###POWERREADME###

View File

@ -9,180 +9,4 @@
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace VDM\Joomla\Database;
use VDM\Joomla\Interfaces\UpdateInterface;
use VDM\Joomla\Abstraction\Database;
/**
* Database Update Class
*
* @since 3.2.0
*/
final class Update extends Database implements UpdateInterface
{
/**
* Update rows in the database (with remapping and filtering columns option)
*
* @param array $data Dataset to update in database [array of arrays (key => value)]
* @param string $key Dataset key column to use in updating the values in the Database
* @param string $table The table where the data is being updated
* @param array $columns Data columns for remapping and filtering
*
* @return bool
* @since 3.2.0
**/
public function rows(array $data, string $key, string $table, array $columns = []): bool
{
// set the update columns
if ($data === [] || strlen($key) == 0)
{
return false;
}
// set the update values
foreach ($data as $values)
{
if ($columns !== [])
{
// load only what is part of the columns set
$row = [];
foreach ($columns as $column => $key_)
{
if (isset($values[$key_]))
{
$row[$column] = $values[$key_];
}
}
// update the row
$this->row($row, $key, $table);
}
else
{
// update the row
$this->row((array) $values, $key, $table);
}
}
return true;
}
/**
* Update items in the database (with remapping and filtering columns option)
*
* @param array $data Data to updated in database (array of objects)
* @param string $key Dataset key column to use in updating the values in the Database
* @param string $table The table where the data is being update
* @param array $columns Data columns for remapping and filtering
*
* @return bool
* @since 3.2.0
**/
public function items(array $data, string $key, string $table, array $columns = []): bool
{
// set the update columns
if ($data === [] || strlen($key) == 0)
{
return false;
}
// set the update values
foreach ($data as $nr => $values)
{
if ($columns !== [])
{
// load only what is part of the columns set
$row = [];
foreach ($columns as $column => $key_)
{
if (isset($values->{$key_}))
{
$row[$column] = $values->{$key_};
}
}
// update the row
$this->row($row, $key, $table);
}
else
{
// update the row
$this->row((array) $values, $key, $table);
}
}
return true;
}
/**
* Update row in the database
*
* @param array $data Dataset to update in database (key => value)
* @param string $key Dataset key column to use in updating the values in the Database
* @param string $table The table where the data is being updated
*
* @return bool
* @since 3.2.0
**/
public function row(array $data, string $key, string $table): bool
{
// set the update columns
if ($data === [] || strlen($key) == 0)
{
return false;
}
// get a query object
$query = $this->db->getQuery(true);
// set the query targets
$query->update($this->db->quoteName($this->getTable($table)));
// set the update values
$key_ = null;
foreach ($data as $column => $value)
{
if ($column === $key)
{
$key_ = $value;
}
else
{
$query->set($this->db->quoteName($column) . ' = ' . $this->quote($value));
}
}
// add the key condition
if ($key_ !== null)
{
$query->where($this->db->quoteName($key) . ' = ' . $this->quote($key_));
// execute the final query
$this->db->setQuery($query);
return $this->db->execute();
}
return false;
}
/**
* Update item in the database
*
* @param object $data Dataset to update in database (key => value)
* @param string $key Dataset key column to use in updating the values in the Database
* @param string $table The table where the data is being updated
*
* @return bool
* @since 3.2.0
**/
public function item(object $data, string $key, string $table): bool
{
// convert to an array
return $this->row((array) get_object_vars($data), $key, $table);
}
}
###POWERCODE###

View File

@ -1,161 +1 @@
/**
* Update rows in the database (with remapping and filtering columns option)
*
* @param array $data Dataset to update in database [array of arrays (key => value)]
* @param string $key Dataset key column to use in updating the values in the Database
* @param string $table The table where the data is being updated
* @param array $columns Data columns for remapping and filtering
*
* @return bool
* @since 3.2.0
**/
public function rows(array $data, string $key, string $table, array $columns = []): bool
{
// set the update columns
if ($data === [] || strlen($key) == 0)
{
return false;
}
// set the update values
foreach ($data as $values)
{
if ($columns !== [])
{
// load only what is part of the columns set
$row = [];
foreach ($columns as $column => $key_)
{
if (isset($values[$key_]))
{
$row[$column] = $values[$key_];
}
}
// update the row
$this->row($row, $key, $table);
}
else
{
// update the row
$this->row((array) $values, $key, $table);
}
}
return true;
}
/**
* Update items in the database (with remapping and filtering columns option)
*
* @param array $data Data to updated in database (array of objects)
* @param string $key Dataset key column to use in updating the values in the Database
* @param string $table The table where the data is being update
* @param array $columns Data columns for remapping and filtering
*
* @return bool
* @since 3.2.0
**/
public function items(array $data, string $key, string $table, array $columns = []): bool
{
// set the update columns
if ($data === [] || strlen($key) == 0)
{
return false;
}
// set the update values
foreach ($data as $nr => $values)
{
if ($columns !== [])
{
// load only what is part of the columns set
$row = [];
foreach ($columns as $column => $key_)
{
if (isset($values->{$key_}))
{
$row[$column] = $values->{$key_};
}
}
// update the row
$this->row($row, $key, $table);
}
else
{
// update the row
$this->row((array) $values, $key, $table);
}
}
return true;
}
/**
* Update row in the database
*
* @param array $data Dataset to update in database (key => value)
* @param string $key Dataset key column to use in updating the values in the Database
* @param string $table The table where the data is being updated
*
* @return bool
* @since 3.2.0
**/
public function row(array $data, string $key, string $table): bool
{
// set the update columns
if ($data === [] || strlen($key) == 0)
{
return false;
}
// get a query object
$query = $this->db->getQuery(true);
// set the query targets
$query->update($this->db->quoteName($this->getTable($table)));
// set the update values
$key_ = null;
foreach ($data as $column => $value)
{
if ($column === $key)
{
$key_ = $value;
}
else
{
$query->set($this->db->quoteName($column) . ' = ' . $this->quote($value));
}
}
// add the key condition
if ($key_ !== null)
{
$query->where($this->db->quoteName($key) . ' = ' . $this->quote($key_));
// execute the final query
$this->db->setQuery($query);
return $this->db->execute();
}
return false;
}
/**
* Update item in the database
*
* @param object $data Dataset to update in database (key => value)
* @param string $key Dataset key column to use in updating the values in the Database
* @param string $table The table where the data is being updated
*
* @return bool
* @since 3.2.0
**/
public function item(object $data, string $key, string $table): bool
{
// convert to an array
return $this->row((array) get_object_vars($data), $key, $table);
}
###CODEPOWER###

View File

@ -1,20 +1 @@
{
"add_head": "0",
"add_licensing_template": "2",
"extends": "6cbef8f8-4813-48e3-b05a-65e1aea95171",
"guid": "cce56585-58b0-4f72-a92c-e2635ea52d83",
"implements": [
"7179fde6-1e51-4b51-8545-7ca18f74a0f4"
],
"load_selection": null,
"name": "Update",
"power_version": "1.0.0",
"system_name": "VDM.Database.Update",
"type": "final class",
"use_selection": null,
"namespace": "VDM\\Joomla\\Database.Update",
"description": "Database Update 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 <https:\/\/dev.vdm.io>\r\n * @git Joomla Component Builder <https:\/\/git.vdm.dev\/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": ""
}
###POWERLINKER###

View File

@ -1,89 +1 @@
```
██████╗ ██████╗ ██╗ ██╗███████╗██████╗
██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗
██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝
██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
```
# abstract class GetHelper (Details)
> namespace: **VDM\Joomla\Utilities**
```uml
@startuml
abstract GetHelper #Orange {
+ {static} var(?string $table = null, mixed $where = null, ...) : mixed
+ {static} vars(?string $table = null, mixed $where = null, ...) : ?array
+ {static} allBetween(string $content, string $start, ...) : ?array
+ {static} between(string $content, string $start, ...) : string
}
note right of GetHelper::var
Get a Variable
since: 3.0.9
return: mixed
arguments:
?string $table = null
mixed $where = null
string $whereString = 'user'
string $what = 'id'
string $operator = '='
?string $main = null
end note
note right of GetHelper::vars
Get array of variables
since: 3.0.9
return: ?array
arguments:
?string $table = null
mixed $where = null
string $whereString = 'user'
string $what = 'id'
string $operator = 'IN'
?string $main = null
bool $unique = true
end note
note right of GetHelper::allBetween
get all strings between two other strings
since: 3.0.9
return: ?array
arguments:
string $content
string $start
string $end
end note
note right of GetHelper::between
get a string between two other strings
since: 3.0.9
return: string
arguments:
string $content
string $start
string $end
string $default = ''
end note
@enduml
```
---
```
██╗ ██████╗██████╗
██║██╔════╝██╔══██╗
██║██║ ██████╔╝
██ ██║██║ ██╔══██╗
╚█████╔╝╚██████╗██████╔╝
╚════╝ ╚═════╝╚═════╝
```
> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder)
###POWERREADME###

View File

@ -9,245 +9,4 @@
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace VDM\Joomla\Utilities;
use Joomla\CMS\Factory;
use VDM\Joomla\Utilities\Component\Helper;
/**
* Some easy get...
*
* @since 3.0.9
*/
abstract class GetHelper
{
/**
* Get a Variable
*
* @param string|null $table The table from which to get the variable
* @param mixed $where The value where
* @param string $whereString The target/field string where/name
* @param string $what The return field
* @param string $operator The operator between $whereString/field and $where/value
* @param string $main The component in which the table is found
*
* @return mixed string/int/float
* @since 3.0.9
*/
public static function var(?string $table = null, $where = null,
string $whereString = 'user', string $what = 'id',
string $operator = '=', ?string $main = null)
{
if(empty($where))
{
$where = Factory::getUser()->id;
}
if(empty($main))
{
$main = Helper::getCode();
}
// Get a db connection.
$db = Factory::getDbo();
// Create a new query object.
$query = $db->getQuery(true);
$query->select($db->quoteName(array($what)));
if (empty($table))
{
$query->from($db->quoteName('#__' . $main));
}
else
{
$query->from($db->quoteName('#__' . $main . '_' . $table));
}
if (is_numeric($where))
{
$query->where($db->quoteName($whereString) . ' ' . $operator . ' ' . (int) $where);
}
elseif (is_string($where))
{
$query->where($db->quoteName($whereString) . ' ' . $operator . ' ' . $db->quote((string)$where));
}
else
{
return false;
}
$db->setQuery($query);
$db->execute();
if ($db->getNumRows())
{
return $db->loadResult();
}
return false;
}
/**
* Get array of variables
*
* @param string|null $table The table from which to get the variables
* @param mixed $where The value where
* @param string $whereString The target/field string where/name
* @param string $what The return field
* @param string $operator The operator between $whereString/field and $where/value
* @param string $main The component in which the table is found
* @param bool $unique The switch to return a unique array
*
* @return array|null
* @since 3.0.9
*/
public static function vars(?string $table = null, $where = null,
string $whereString = 'user', string $what = 'id', string $operator = 'IN',
?string $main = null, bool $unique = true): ?array
{
if(empty($where))
{
$where = Factory::getUser()->id;
}
if(is_null($main))
{
$main = Helper::getCode();
}
if (!ArrayHelper::check($where) && $where > 0)
{
$where = array($where);
}
if (ArrayHelper::check($where))
{
// prep main <-- why? well if $main='' is empty then $table can be categories or users
if (StringHelper::check($main))
{
$main = '_' . ltrim($main, '_');
}
// Get a db connection.
$db = Factory::getDbo();
// Create a new query object.
$query = $db->getQuery(true);
$query->select($db->quoteName(array($what)));
if (empty($table))
{
$query->from($db->quoteName('#__' . $main));
}
else
{
$query->from($db->quoteName('#_' . $main . '_' . $table));
}
// add strings to array search
if ('IN_STRINGS' === $operator || 'NOT IN_STRINGS' === $operator)
{
$query->where($db->quoteName($whereString) . ' ' . str_replace('_STRINGS', '', $operator) . ' ("' . implode('","', $where) . '")');
}
else
{
$query->where($db->quoteName($whereString) . ' ' . $operator . ' (' . implode(',', $where) . ')');
}
$db->setQuery($query);
$db->execute();
if ($db->getNumRows())
{
if ($unique)
{
return array_unique($db->loadColumn());
}
return $db->loadColumn();
}
}
return null;
}
/**
* get all strings between two other strings
*
* @param string $content The content to search
* @param string $start The starting value
* @param string $end The ending value
*
* @return array|null On success
* @since 3.0.9
*/
public static function allBetween(string $content, string $start, string $end): ?array
{
// reset bucket
$bucket = [];
for ($i = 0; ; $i++)
{
// search for string
$found = self::between($content, $start, $end);
if (StringHelper::check($found))
{
// add to bucket
$bucket[] = $found;
// build removal string
$remove = $start . $found . $end;
// remove from content
$content = str_replace($remove, '', $content);
}
else
{
break;
}
// safety catch
if ($i == 500)
{
break;
}
}
// only return unique array of values
if (ArrayHelper::check($bucket))
{
return array_unique($bucket);
}
return null;
}
/**
* get a string between two other strings
*
* @param string $content The content to search
* @param string $start The starting value
* @param string $end The ending value
* @param string $default The default value if none found
*
* @return string On success / empty string on failure
* @since 3.0.9
*/
public static function between(string $content, string $start, string $end, string $default = ''): string
{
$array = explode($start, $content);
if (isset($array[1]) && strpos($array[1], $end) !== false)
{
$array = explode($end, $array[1]);
// return string found between
return $array[0];
}
return $default;
}
}
###POWERCODE###

View File

@ -1,225 +1 @@
/**
* Get a Variable
*
* @param string|null $table The table from which to get the variable
* @param mixed $where The value where
* @param string $whereString The target/field string where/name
* @param string $what The return field
* @param string $operator The operator between $whereString/field and $where/value
* @param string $main The component in which the table is found
*
* @return mixed string/int/float
* @since 3.0.9
*/
public static function var(?string $table = null, $where = null,
string $whereString = 'user', string $what = 'id',
string $operator = '=', ?string $main = null)
{
if(empty($where))
{
$where = Factory::getUser()->id;
}
if(empty($main))
{
$main = Helper::getCode();
}
// Get a db connection.
$db = Factory::getDbo();
// Create a new query object.
$query = $db->getQuery(true);
$query->select($db->quoteName(array($what)));
if (empty($table))
{
$query->from($db->quoteName('#__' . $main));
}
else
{
$query->from($db->quoteName('#__' . $main . '_' . $table));
}
if (is_numeric($where))
{
$query->where($db->quoteName($whereString) . ' ' . $operator . ' ' . (int) $where);
}
elseif (is_string($where))
{
$query->where($db->quoteName($whereString) . ' ' . $operator . ' ' . $db->quote((string)$where));
}
else
{
return false;
}
$db->setQuery($query);
$db->execute();
if ($db->getNumRows())
{
return $db->loadResult();
}
return false;
}
/**
* Get array of variables
*
* @param string|null $table The table from which to get the variables
* @param mixed $where The value where
* @param string $whereString The target/field string where/name
* @param string $what The return field
* @param string $operator The operator between $whereString/field and $where/value
* @param string $main The component in which the table is found
* @param bool $unique The switch to return a unique array
*
* @return array|null
* @since 3.0.9
*/
public static function vars(?string $table = null, $where = null,
string $whereString = 'user', string $what = 'id', string $operator = 'IN',
?string $main = null, bool $unique = true): ?array
{
if(empty($where))
{
$where = Factory::getUser()->id;
}
if(is_null($main))
{
$main = Helper::getCode();
}
if (!ArrayHelper::check($where) && $where > 0)
{
$where = array($where);
}
if (ArrayHelper::check($where))
{
// prep main <-- why? well if $main='' is empty then $table can be categories or users
if (StringHelper::check($main))
{
$main = '_' . ltrim($main, '_');
}
// Get a db connection.
$db = Factory::getDbo();
// Create a new query object.
$query = $db->getQuery(true);
$query->select($db->quoteName(array($what)));
if (empty($table))
{
$query->from($db->quoteName('#__' . $main));
}
else
{
$query->from($db->quoteName('#_' . $main . '_' . $table));
}
// add strings to array search
if ('IN_STRINGS' === $operator || 'NOT IN_STRINGS' === $operator)
{
$query->where($db->quoteName($whereString) . ' ' . str_replace('_STRINGS', '', $operator) . ' ("' . implode('","', $where) . '")');
}
else
{
$query->where($db->quoteName($whereString) . ' ' . $operator . ' (' . implode(',', $where) . ')');
}
$db->setQuery($query);
$db->execute();
if ($db->getNumRows())
{
if ($unique)
{
return array_unique($db->loadColumn());
}
return $db->loadColumn();
}
}
return null;
}
/**
* get all strings between two other strings
*
* @param string $content The content to search
* @param string $start The starting value
* @param string $end The ending value
*
* @return array|null On success
* @since 3.0.9
*/
public static function allBetween(string $content, string $start, string $end): ?array
{
// reset bucket
$bucket = [];
for ($i = 0; ; $i++)
{
// search for string
$found = self::between($content, $start, $end);
if (StringHelper::check($found))
{
// add to bucket
$bucket[] = $found;
// build removal string
$remove = $start . $found . $end;
// remove from content
$content = str_replace($remove, '', $content);
}
else
{
break;
}
// safety catch
if ($i == 500)
{
break;
}
}
// only return unique array of values
if (ArrayHelper::check($bucket))
{
return array_unique($bucket);
}
return null;
}
/**
* get a string between two other strings
*
* @param string $content The content to search
* @param string $start The starting value
* @param string $end The ending value
* @param string $default The default value if none found
*
* @return string On success / empty string on failure
* @since 3.0.9
*/
public static function between(string $content, string $start, string $end, string $default = ''): string
{
$array = explode($start, $content);
if (isset($array[1]) && strpos($array[1], $end) !== false)
{
$array = explode($end, $array[1]);
// return string found between
return $array[0];
}
return $default;
}
###CODEPOWER###

View File

@ -1,30 +1 @@
{
"add_head": "1",
"add_licensing_template": "2",
"extends": "0",
"guid": "db87c339-5bb6-4291-a7ef-2c48ea1b06bc",
"implements": null,
"load_selection": {
"load_selection0": {
"load": "0a59c65c-9daf-4bc9-baf4-e063ff9e6a8a"
},
"load_selection1": {
"load": "1f28cb53-60d9-4db1-b517-3c7dc6b429ef"
}
},
"name": "GetHelper",
"power_version": "1.0.0",
"system_name": "Utilities GetHelper",
"type": "abstract class",
"use_selection": {
"use_selection0": {
"use": "640b5352-fb09-425f-a26e-cd44eda03f15",
"as": "default"
}
},
"namespace": "VDM\\Joomla\\Utilities.GetHelper",
"description": "Some easy get...\r\n\r\n@since 3.0.9",
"licensing_template": "\/**\r\n * @package Joomla.Component.Builder\r\n *\r\n * @created 3rd September, 2020\r\n * @author Llewellyn van der Merwe <https:\/\/dev.vdm.io>\r\n * @git Joomla Component Builder <https:\/\/git.vdm.dev\/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": ""
}
###POWERLINKER###

View File

@ -1,98 +1 @@
```
██████╗ ██████╗ ██╗ ██╗███████╗██████╗
██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗
██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝
██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
```
# abstract class BaseTable (Details)
> namespace: **VDM\Joomla\Abstraction**
```uml
@startuml
abstract BaseTable #Orange {
# array $tables
+ get(string $table, ?string $field = null, ...) : mixed
+ title(string $table) : ?array
+ titleName(string $table) : string
+ tables() : array
+ exist(string $table, ?string $field = null) : bool
+ fields(string $table, bool $default = false) : ?array
# addDefault(array $fields) : array
}
note right of BaseTable::get
Get any value from a item/field/column of an area/view/table
Example: $this->get('table_name', 'field_name', 'value_key');
Get an item/field/column of an area/view/table
Example: $this->get('table_name', 'field_name');
Get all items/fields/columns of an area/view/table
Example: $this->get('table_name');
Get all areas/views/tables with all their item/field/column details
Example: $this->get('All');
since: 3.2.0
return: mixed
arguments:
string $table
?string $field = null
?string $key = null
end note
note right of BaseTable::title
Get title field from an area/view/table
since: 3.2.0
return: ?array
end note
note right of BaseTable::titleName
Get title field name
since: 3.2.0
return: string
end note
note right of BaseTable::tables
Get all tables
since: 3.2.0
return: array
end note
note right of BaseTable::exist
Check if a table (and field) exist
since: 3.2.0
return: bool
end note
note right of BaseTable::fields
Get all fields of an area/view/table
since: 3.2.0
return: ?array
end note
note right of BaseTable::addDefault
Add the default fields
since: 3.2.0
return: array
end note
@enduml
```
---
```
██╗ ██████╗██████╗
██║██╔════╝██╔══██╗
██║██║ ██████╔╝
██ ██║██║ ██╔══██╗
╚█████╔╝╚██████╗██████╔╝
╚════╝ ╚═════╝╚═════╝
```
> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder)
###POWERREADME###

View File

@ -9,217 +9,4 @@
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace VDM\Joomla\Abstraction;
use VDM\Joomla\Interfaces\Tableinterface;
/**
* Base Table
*
* @since 3.2.0
*/
abstract class BaseTable implements Tableinterface
{
/**
* All areas/views/tables with their field details
*
* @var array
* @since 3.2.0
**/
protected array $tables;
/**
* Get any value from a item/field/column of an area/view/table
* Example: $this->get('table_name', 'field_name', 'value_key');
* Get an item/field/column of an area/view/table
* Example: $this->get('table_name', 'field_name');
* Get all items/fields/columns of an area/view/table
* Example: $this->get('table_name');
* Get all areas/views/tables with all their item/field/column details
* Example: $this->get('All');
*
* @param string $table The table
* @param string|null $field The field
* @param string|null $key The value key
*
* @return mixed
* @since 3.2.0
*/
public function get(string $table, ?string $field = null, ?string $key = null)
{
// return the item/field/column of an area/view/table
if (is_string($field) && is_string($key))
{
// return the value of a item/field/column of an area/view/table
if (isset($this->tables[$table][$field][$key]))
{
return $this->tables[$table][$field][$key];
}
return null;
}
// return the item/field/column of an area/view/table
elseif (is_string($field))
{
if (isset($this->tables[$table][$field]))
{
return $this->tables[$table][$field];
}
return null;
}
// return an area/view/table
elseif ($table !== 'All')
{
if (isset($this->tables[$table]))
{
return $this->tables[$table];
}
return null;
}
// return all
return $this->tables;
}
/**
* Get title field from an area/view/table
*
* @param string $table The area
*
* @return ?array
* @since 3.2.0
*/
public function title(string $table): ?array
{
// return the title item/field/column of an area/view/table
if (($table = $this->get($table)) !== null)
{
foreach ($table as $item)
{
if ($item['title'])
{
return $item;
}
}
}
// none found
return null;
}
/**
* Get title field name
*
* @param string $table The area
*
* @return string
* @since 3.2.0
*/
public function titleName(string $table): string
{
// return the title name of an area/view/table
if (($field = $this->title($table)) !== null)
{
return $field['name'];
}
// none found default to ID
return 'id';
}
/**
* Get all tables
*
* @return array
* @since 3.2.0
*/
public function tables(): array
{
// return all areas/views/tables
return array_keys($this->tables);
}
/**
* Check if a table (and field) exist
*
* @param string $table The area
* @param string|null $field The area
*
* @return bool
* @since 3.2.0
*/
public function exist(string $table, ?string $field = null): bool
{
if (isset($this->tables[$table]))
{
// if we have a field
if (is_string($field))
{
if (isset($this->tables[$table][$field]))
{
return true;
}
}
else
{
return true;
}
}
return false;
}
/**
* Get all fields of an area/view/table
*
* @param string $table The area
* @param bool $default Add the default fields
*
* @return array|null On success an array of fields
* @since 3.2.0
*/
public function fields(string $table, bool $default = false): ?array
{
// return all fields of an area/view/table
if (($table = $this->get($table)) !== null)
{
if ($default)
{
return $this->addDefault(array_keys($table));
}
else
{
return array_keys($table);
}
}
// none found
return null;
}
/**
* Add the default fields
*
* @param array $fields The table dynamic fields
*
* @return array Fields (with defaults added)
* @since 3.2.0
*/
protected function addDefault(array $fields): array
{
// add default fields
array_unshift($fields, 'id');
$fields[] = 'ordering';
$fields[] = 'published';
$fields[] = 'modified_by';
$fields[] = 'modified';
$fields[] = 'created_by';
$fields[] = 'created';
$fields[] = 'hits';
$fields[] = 'version';
return $fields;
}
}
###POWERCODE###

View File

@ -1,199 +1 @@
/**
* All areas/views/tables with their field details
*
* @var array
* @since 3.2.0
**/
protected array $tables;
/**
* Get any value from a item/field/column of an area/view/table
* Example: $this->get('table_name', 'field_name', 'value_key');
* Get an item/field/column of an area/view/table
* Example: $this->get('table_name', 'field_name');
* Get all items/fields/columns of an area/view/table
* Example: $this->get('table_name');
* Get all areas/views/tables with all their item/field/column details
* Example: $this->get('All');
*
* @param string $table The table
* @param string|null $field The field
* @param string|null $key The value key
*
* @return mixed
* @since 3.2.0
*/
public function get(string $table, ?string $field = null, ?string $key = null)
{
// return the item/field/column of an area/view/table
if (is_string($field) && is_string($key))
{
// return the value of a item/field/column of an area/view/table
if (isset($this->tables[$table][$field][$key]))
{
return $this->tables[$table][$field][$key];
}
return null;
}
// return the item/field/column of an area/view/table
elseif (is_string($field))
{
if (isset($this->tables[$table][$field]))
{
return $this->tables[$table][$field];
}
return null;
}
// return an area/view/table
elseif ($table !== 'All')
{
if (isset($this->tables[$table]))
{
return $this->tables[$table];
}
return null;
}
// return all
return $this->tables;
}
/**
* Get title field from an area/view/table
*
* @param string $table The area
*
* @return ?array
* @since 3.2.0
*/
public function title(string $table): ?array
{
// return the title item/field/column of an area/view/table
if (($table = $this->get($table)) !== null)
{
foreach ($table as $item)
{
if ($item['title'])
{
return $item;
}
}
}
// none found
return null;
}
/**
* Get title field name
*
* @param string $table The area
*
* @return string
* @since 3.2.0
*/
public function titleName(string $table): string
{
// return the title name of an area/view/table
if (($field = $this->title($table)) !== null)
{
return $field['name'];
}
// none found default to ID
return 'id';
}
/**
* Get all tables
*
* @return array
* @since 3.2.0
*/
public function tables(): array
{
// return all areas/views/tables
return array_keys($this->tables);
}
/**
* Check if a table (and field) exist
*
* @param string $table The area
* @param string|null $field The area
*
* @return bool
* @since 3.2.0
*/
public function exist(string $table, ?string $field = null): bool
{
if (isset($this->tables[$table]))
{
// if we have a field
if (is_string($field))
{
if (isset($this->tables[$table][$field]))
{
return true;
}
}
else
{
return true;
}
}
return false;
}
/**
* Get all fields of an area/view/table
*
* @param string $table The area
* @param bool $default Add the default fields
*
* @return array|null On success an array of fields
* @since 3.2.0
*/
public function fields(string $table, bool $default = false): ?array
{
// return all fields of an area/view/table
if (($table = $this->get($table)) !== null)
{
if ($default)
{
return $this->addDefault(array_keys($table));
}
else
{
return array_keys($table);
}
}
// none found
return null;
}
/**
* Add the default fields
*
* @param array $fields The table dynamic fields
*
* @return array Fields (with defaults added)
* @since 3.2.0
*/
protected function addDefault(array $fields): array
{
// add default fields
array_unshift($fields, 'id');
$fields[] = 'ordering';
$fields[] = 'published';
$fields[] = 'modified_by';
$fields[] = 'modified';
$fields[] = 'created_by';
$fields[] = 'created';
$fields[] = 'hits';
$fields[] = 'version';
return $fields;
}
###CODEPOWER###

View File

@ -1,20 +1 @@
{
"add_head": "0",
"add_licensing_template": "2",
"extends": "0",
"guid": "e0f6ddbe-2a35-4537-942c-faff2ebd04f6",
"implements": [
"2da6d6c4-eb29-4d69-8bc2-36d96e916adf"
],
"load_selection": null,
"name": "BaseTable",
"power_version": "1.0.0",
"system_name": "VDM.Abstraction.BaseTable",
"type": "abstract class",
"use_selection": null,
"namespace": "VDM\\Joomla\\Abstraction.BaseTable",
"description": "Base Table\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 <https:\/\/dev.vdm.io>\r\n * @git Joomla Component Builder <https:\/\/git.vdm.dev\/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": ""
}
###POWERLINKER###

View File

@ -1,66 +1 @@
```
██████╗ ██████╗ ██╗ ██╗███████╗██████╗
██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗
██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝
██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
```
# abstract class BaseConfig (Details)
> namespace: **VDM\Joomla\Abstraction**
```uml
@startuml
abstract BaseConfig #Orange {
+ __construct()
+ __set(string $key, mixed $value)
+ __get(string $key)
+ get(string $path, mixed $default = null) : mixed
+ appendArray(string $path, mixed $value) : mixed
}
note right of BaseConfig::__construct
Constructor
since: 3.2.0
end note
note right of BaseConfig::__set
setting any config value
since: 3.2.0
end note
note right of BaseConfig::__get
getting any valid value
since: 3.2.0
end note
note right of BaseConfig::get
Get a config value.
since: 3.2.0
return: mixed
end note
note right of BaseConfig::appendArray
Append value to a path in registry of an array
since: 3.2.0
return: mixed
end note
@enduml
```
---
```
██╗ ██████╗██████╗
██║██╔════╝██╔══██╗
██║██║ ██████╔╝
██ ██║██║ ██╔══██╗
╚█████╔╝╚██████╗██████╔╝
╚════╝ ╚═════╝╚═════╝
```
> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder)
###POWERREADME###

View File

@ -9,114 +9,4 @@
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace VDM\Joomla\Abstraction;
use Joomla\Registry\Registry as JoomlaRegistry;
use VDM\Joomla\Utilities\String\ClassfunctionHelper;
/**
* Config
*
* @since 3.2.0
*/
abstract class BaseConfig extends JoomlaRegistry
{
/**
* Constructor
*
* @since 3.2.0
*/
public function __construct()
{
// Instantiate the internal data object.
$this->data = new \stdClass();
}
/**
* setting any config value
*
* @param string $key The value's key/path name
* @param mixed $value Optional default value, returned if the internal value is null.
*
* @since 3.2.0
*/
public function __set(string $key, $value)
{
$this->set($key, $value);
}
/**
* getting any valid value
*
* @param string $key The value's key/path name
*
* @since 3.2.0
* @throws \InvalidArgumentException If $key is not a valid function name.
*/
public function __get(string $key)
{
// check if it has been set
if (($value = $this->get($key, '__N0T_S3T_Y3T_')) !== '__N0T_S3T_Y3T_')
{
return $value;
}
throw new \InvalidArgumentException(sprintf('Argument %s could not be found as function or path.', $key));
}
/**
* Get a config value.
*
* @param string $path Registry path (e.g. joomla_content_showauthor)
* @param mixed $default Optional default value, returned if the internal value is null.
*
* @return mixed Value of entry or null
*
* @since 3.2.0
*/
public function get($path, $default = null)
{
// function name with no underscores
$method = 'get' . ucfirst((string) ClassfunctionHelper::safe(str_replace('_', '', $path)));
// check if it has been set
if (($value = parent::get($path, '__N0T_S3T_Y3T_')) !== '__N0T_S3T_Y3T_')
{
return $value;
}
elseif (method_exists($this, $method))
{
$value = $this->{$method}($default);
$this->set($path, $value);
return $value;
}
return $default;
}
/**
* Append value to a path in registry of an array
*
* @param string $path Parent registry Path (e.g. joomla.content.showauthor)
* @param mixed $value Value of entry
*
* @return mixed The value of the that has been set.
*
* @since 3.2.0
*/
public function appendArray(string $path, $value)
{
// check if it does not exist
if (!$this->exists($path))
{
$this->set($path, []);
}
return $this->append($path, $value);
}
}
###POWERCODE###

View File

@ -1,95 +1 @@
/**
* Constructor
*
* @since 3.2.0
*/
public function __construct()
{
// Instantiate the internal data object.
$this->data = new \stdClass();
}
/**
* setting any config value
*
* @param string $key The value's key/path name
* @param mixed $value Optional default value, returned if the internal value is null.
*
* @since 3.2.0
*/
public function __set(string $key, $value)
{
$this->set($key, $value);
}
/**
* getting any valid value
*
* @param string $key The value's key/path name
*
* @since 3.2.0
* @throws \InvalidArgumentException If $key is not a valid function name.
*/
public function __get(string $key)
{
// check if it has been set
if (($value = $this->get($key, '__N0T_S3T_Y3T_')) !== '__N0T_S3T_Y3T_')
{
return $value;
}
throw new \InvalidArgumentException(sprintf('Argument %s could not be found as function or path.', $key));
}
/**
* Get a config value.
*
* @param string $path Registry path (e.g. joomla_content_showauthor)
* @param mixed $default Optional default value, returned if the internal value is null.
*
* @return mixed Value of entry or null
*
* @since 3.2.0
*/
public function get($path, $default = null)
{
// function name with no underscores
$method = 'get' . ucfirst((string) ClassfunctionHelper::safe(str_replace('_', '', $path)));
// check if it has been set
if (($value = parent::get($path, '__N0T_S3T_Y3T_')) !== '__N0T_S3T_Y3T_')
{
return $value;
}
elseif (method_exists($this, $method))
{
$value = $this->{$method}($default);
$this->set($path, $value);
return $value;
}
return $default;
}
/**
* Append value to a path in registry of an array
*
* @param string $path Parent registry Path (e.g. joomla.content.showauthor)
* @param mixed $value Value of entry
*
* @return mixed The value of the that has been set.
*
* @since 3.2.0
*/
public function appendArray(string $path, $value)
{
// check if it does not exist
if (!$this->exists($path))
{
$this->set($path, []);
}
return $this->append($path, $value);
}
###CODEPOWER###

View File

@ -1,24 +1 @@
{
"add_head": "1",
"add_licensing_template": "2",
"extends": "-1",
"guid": "ffbd4e1f-a342-4080-ab7d-1de3741bf319",
"implements": null,
"load_selection": null,
"name": "BaseConfig",
"power_version": "1.0.0",
"system_name": "VDM.Abstraction.BaseConfig",
"type": "abstract class",
"use_selection": {
"use_selection0": {
"use": "30c5b4c2-f75f-4d15-869a-f8bfedd87358",
"as": "default"
}
},
"namespace": "VDM\\Joomla\\Abstraction.BaseConfig",
"description": "Config\r\n\r\n@since 3.2.0",
"extends_custom": "JoomlaRegistry",
"licensing_template": "\/**\r\n * @package Joomla.Component.Builder\r\n *\r\n * @created 4th September, 2022\r\n * @author Llewellyn van der Merwe <https:\/\/dev.vdm.io>\r\n * @git Joomla Component Builder <https:\/\/git.vdm.dev\/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\\Registry\\Registry as JoomlaRegistry;",
"composer": ""
}
###POWERLINKER###

View File

@ -1,376 +1 @@
{
"06f8eada-d59b-441c-b287-0aea1793da5a": {
"name": "Load",
"type": "final class",
"namespace": "VDM\\Joomla\\Database",
"code": "src\/06f8eada-d59b-441c-b287-0aea1793da5a\/code.php",
"power": "src\/06f8eada-d59b-441c-b287-0aea1793da5a\/code.power",
"settings": "src\/06f8eada-d59b-441c-b287-0aea1793da5a\/settings.json",
"path": "src\/06f8eada-d59b-441c-b287-0aea1793da5a",
"spk": "Super__06f8eada_d59b_441c_b287_0aea1793da5a__Power",
"guid": "06f8eada-d59b-441c-b287-0aea1793da5a"
},
"0a59c65c-9daf-4bc9-baf4-e063ff9e6a8a": {
"name": "ArrayHelper",
"type": "abstract class",
"namespace": "VDM\\Joomla\\Utilities",
"code": "src\/0a59c65c-9daf-4bc9-baf4-e063ff9e6a8a\/code.php",
"power": "src\/0a59c65c-9daf-4bc9-baf4-e063ff9e6a8a\/code.power",
"settings": "src\/0a59c65c-9daf-4bc9-baf4-e063ff9e6a8a\/settings.json",
"path": "src\/0a59c65c-9daf-4bc9-baf4-e063ff9e6a8a",
"spk": "Super__0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a__Power",
"guid": "0a59c65c-9daf-4bc9-baf4-e063ff9e6a8a"
},
"1198aecf-84c6-45d2-aea8-d531aa4afdfa": {
"name": "FormHelper",
"type": "abstract class",
"namespace": "VDM\\Joomla\\Componentbuilder\\Utilities",
"code": "src\/1198aecf-84c6-45d2-aea8-d531aa4afdfa\/code.php",
"power": "src\/1198aecf-84c6-45d2-aea8-d531aa4afdfa\/code.power",
"settings": "src\/1198aecf-84c6-45d2-aea8-d531aa4afdfa\/settings.json",
"path": "src\/1198aecf-84c6-45d2-aea8-d531aa4afdfa",
"spk": "Super__1198aecf_84c6_45d2_aea8_d531aa4afdfa__Power",
"guid": "1198aecf-84c6-45d2-aea8-d531aa4afdfa"
},
"152c8793-8b75-4715-996a-257b9f65451c": {
"name": "MathHelper",
"type": "abstract class",
"namespace": "VDM\\Joomla\\Utilities",
"code": "src\/152c8793-8b75-4715-996a-257b9f65451c\/code.php",
"power": "src\/152c8793-8b75-4715-996a-257b9f65451c\/code.power",
"settings": "src\/152c8793-8b75-4715-996a-257b9f65451c\/settings.json",
"path": "src\/152c8793-8b75-4715-996a-257b9f65451c",
"spk": "Super__152c8793_8b75_4715_996a_257b9f65451c__Power",
"guid": "152c8793-8b75-4715-996a-257b9f65451c"
},
"1f28cb53-60d9-4db1-b517-3c7dc6b429ef": {
"name": "StringHelper",
"type": "abstract class",
"namespace": "VDM\\Joomla\\Utilities",
"code": "src\/1f28cb53-60d9-4db1-b517-3c7dc6b429ef\/code.php",
"power": "src\/1f28cb53-60d9-4db1-b517-3c7dc6b429ef\/code.power",
"settings": "src\/1f28cb53-60d9-4db1-b517-3c7dc6b429ef\/settings.json",
"path": "src\/1f28cb53-60d9-4db1-b517-3c7dc6b429ef",
"spk": "Super__1f28cb53_60d9_4db1_b517_3c7dc6b429ef__Power",
"guid": "1f28cb53-60d9-4db1-b517-3c7dc6b429ef"
},
"2ad31f74-f579-499d-b98b-c4f54fd615dd": {
"name": "LoadInterface",
"type": "interface",
"namespace": "VDM\\Joomla\\Interfaces",
"code": "src\/2ad31f74-f579-499d-b98b-c4f54fd615dd\/code.php",
"power": "src\/2ad31f74-f579-499d-b98b-c4f54fd615dd\/code.power",
"settings": "src\/2ad31f74-f579-499d-b98b-c4f54fd615dd\/settings.json",
"path": "src\/2ad31f74-f579-499d-b98b-c4f54fd615dd",
"spk": "Super__2ad31f74_f579_499d_b98b_c4f54fd615dd__Power",
"guid": "2ad31f74-f579-499d-b98b-c4f54fd615dd"
},
"2da6d6c4-eb29-4d69-8bc2-36d96e916adf": {
"name": "Tableinterface",
"type": "interface",
"namespace": "VDM\\Joomla\\Interfaces",
"code": "src\/2da6d6c4-eb29-4d69-8bc2-36d96e916adf\/code.php",
"power": "src\/2da6d6c4-eb29-4d69-8bc2-36d96e916adf\/code.power",
"settings": "src\/2da6d6c4-eb29-4d69-8bc2-36d96e916adf\/settings.json",
"path": "src\/2da6d6c4-eb29-4d69-8bc2-36d96e916adf",
"spk": "Super__2da6d6c4_eb29_4d69_8bc2_36d96e916adf__Power",
"guid": "2da6d6c4-eb29-4d69-8bc2-36d96e916adf"
},
"30c5b4c2-f75f-4d15-869a-f8bfedd87358": {
"name": "ClassfunctionHelper",
"type": "abstract class",
"namespace": "VDM\\Joomla\\Utilities\\String",
"code": "src\/30c5b4c2-f75f-4d15-869a-f8bfedd87358\/code.php",
"power": "src\/30c5b4c2-f75f-4d15-869a-f8bfedd87358\/code.power",
"settings": "src\/30c5b4c2-f75f-4d15-869a-f8bfedd87358\/settings.json",
"path": "src\/30c5b4c2-f75f-4d15-869a-f8bfedd87358",
"spk": "Super__30c5b4c2_f75f_4d15_869a_f8bfedd87358__Power",
"guid": "30c5b4c2-f75f-4d15-869a-f8bfedd87358"
},
"3cf76fbf-fd95-4a33-878e-7aff6d36b7f6": {
"name": "PluginHelper",
"type": "abstract class",
"namespace": "VDM\\Joomla\\Utilities\\String",
"code": "src\/3cf76fbf-fd95-4a33-878e-7aff6d36b7f6\/code.php",
"power": "src\/3cf76fbf-fd95-4a33-878e-7aff6d36b7f6\/code.power",
"settings": "src\/3cf76fbf-fd95-4a33-878e-7aff6d36b7f6\/settings.json",
"path": "src\/3cf76fbf-fd95-4a33-878e-7aff6d36b7f6",
"spk": "Super__3cf76fbf_fd95_4a33_878e_7aff6d36b7f6__Power",
"guid": "3cf76fbf-fd95-4a33-878e-7aff6d36b7f6"
},
"44a3367c-f9e4-406b-b396-0f452bde0f03": {
"name": "Mapper",
"type": "abstract class",
"namespace": "VDM\\Joomla\\Componentbuilder\\Abstraction",
"code": "src\/44a3367c-f9e4-406b-b396-0f452bde0f03\/code.php",
"power": "src\/44a3367c-f9e4-406b-b396-0f452bde0f03\/code.power",
"settings": "src\/44a3367c-f9e4-406b-b396-0f452bde0f03\/settings.json",
"path": "src\/44a3367c-f9e4-406b-b396-0f452bde0f03",
"spk": "Super__44a3367c_f9e4_406b_b396_0f452bde0f03__Power",
"guid": "44a3367c-f9e4-406b-b396-0f452bde0f03"
},
"4b225c51-d293-48e4-b3f6-5136cf5c3f18": {
"name": "JsonHelper",
"type": "abstract class",
"namespace": "VDM\\Joomla\\Utilities",
"code": "src\/4b225c51-d293-48e4-b3f6-5136cf5c3f18\/code.php",
"power": "src\/4b225c51-d293-48e4-b3f6-5136cf5c3f18\/code.power",
"settings": "src\/4b225c51-d293-48e4-b3f6-5136cf5c3f18\/settings.json",
"path": "src\/4b225c51-d293-48e4-b3f6-5136cf5c3f18",
"spk": "Super__4b225c51_d293_48e4_b3f6_5136cf5c3f18__Power",
"guid": "4b225c51-d293-48e4-b3f6-5136cf5c3f18"
},
"524eb8f6-38d4-47dc-92ad-98b94e099ac0": {
"name": "Insert",
"type": "final class",
"namespace": "VDM\\Joomla\\Database",
"code": "src\/524eb8f6-38d4-47dc-92ad-98b94e099ac0\/code.php",
"power": "src\/524eb8f6-38d4-47dc-92ad-98b94e099ac0\/code.power",
"settings": "src\/524eb8f6-38d4-47dc-92ad-98b94e099ac0\/settings.json",
"path": "src\/524eb8f6-38d4-47dc-92ad-98b94e099ac0",
"spk": "Super__524eb8f6_38d4_47dc_92ad_98b94e099ac0__Power",
"guid": "524eb8f6-38d4-47dc-92ad-98b94e099ac0"
},
"584747d1-3a86-453d-b7a3-a2219de8d777": {
"name": "Model",
"type": "abstract class",
"namespace": "VDM\\Joomla\\Abstraction",
"code": "src\/584747d1-3a86-453d-b7a3-a2219de8d777\/code.php",
"power": "src\/584747d1-3a86-453d-b7a3-a2219de8d777\/code.power",
"settings": "src\/584747d1-3a86-453d-b7a3-a2219de8d777\/settings.json",
"path": "src\/584747d1-3a86-453d-b7a3-a2219de8d777",
"spk": "Super__584747d1_3a86_453d_b7a3_a2219de8d777__Power",
"guid": "584747d1-3a86-453d-b7a3-a2219de8d777"
},
"640b5352-fb09-425f-a26e-cd44eda03f15": {
"name": "Helper",
"type": "abstract class",
"namespace": "VDM\\Joomla\\Utilities\\Component",
"code": "src\/640b5352-fb09-425f-a26e-cd44eda03f15\/code.php",
"power": "src\/640b5352-fb09-425f-a26e-cd44eda03f15\/code.power",
"settings": "src\/640b5352-fb09-425f-a26e-cd44eda03f15\/settings.json",
"path": "src\/640b5352-fb09-425f-a26e-cd44eda03f15",
"spk": "Super__640b5352_fb09_425f_a26e_cd44eda03f15__Power",
"guid": "640b5352-fb09-425f-a26e-cd44eda03f15"
},
"6cbef8f8-4813-48e3-b05a-65e1aea95171": {
"name": "Database",
"type": "abstract class",
"namespace": "VDM\\Joomla\\Abstraction",
"code": "src\/6cbef8f8-4813-48e3-b05a-65e1aea95171\/code.php",
"power": "src\/6cbef8f8-4813-48e3-b05a-65e1aea95171\/code.power",
"settings": "src\/6cbef8f8-4813-48e3-b05a-65e1aea95171\/settings.json",
"path": "src\/6cbef8f8-4813-48e3-b05a-65e1aea95171",
"spk": "Super__6cbef8f8_4813_48e3_b05a_65e1aea95171__Power",
"guid": "6cbef8f8-4813-48e3-b05a-65e1aea95171"
},
"7179fde6-1e51-4b51-8545-7ca18f74a0f4": {
"name": "UpdateInterface",
"type": "interface",
"namespace": "VDM\\Joomla\\Interfaces",
"code": "src\/7179fde6-1e51-4b51-8545-7ca18f74a0f4\/code.php",
"power": "src\/7179fde6-1e51-4b51-8545-7ca18f74a0f4\/code.power",
"settings": "src\/7179fde6-1e51-4b51-8545-7ca18f74a0f4\/settings.json",
"path": "src\/7179fde6-1e51-4b51-8545-7ca18f74a0f4",
"spk": "Super__7179fde6_1e51_4b51_8545_7ca18f74a0f4__Power",
"guid": "7179fde6-1e51-4b51-8545-7ca18f74a0f4"
},
"79d765b3-7319-4988-9730-446c7f347020": {
"name": "Utilities",
"type": "trait",
"namespace": "VDM\\Joomla",
"code": "src\/79d765b3-7319-4988-9730-446c7f347020\/code.php",
"power": "src\/79d765b3-7319-4988-9730-446c7f347020\/code.power",
"settings": "src\/79d765b3-7319-4988-9730-446c7f347020\/settings.json",
"path": "src\/79d765b3-7319-4988-9730-446c7f347020",
"spk": "Super__79d765b3_7319_4988_9730_446c7f347020__Power",
"guid": "79d765b3-7319-4988-9730-446c7f347020"
},
"8aef58c1-3f70-4bd4-b9e4-3f29fcd41cff": {
"name": "ModelInterface",
"type": "interface",
"namespace": "VDM\\Joomla\\Interfaces",
"code": "src\/8aef58c1-3f70-4bd4-b9e4-3f29fcd41cff\/code.php",
"power": "src\/8aef58c1-3f70-4bd4-b9e4-3f29fcd41cff\/code.power",
"settings": "src\/8aef58c1-3f70-4bd4-b9e4-3f29fcd41cff\/settings.json",
"path": "src\/8aef58c1-3f70-4bd4-b9e4-3f29fcd41cff",
"spk": "Super__8aef58c1_3f70_4bd4_b9e4_3f29fcd41cff__Power",
"guid": "8aef58c1-3f70-4bd4-b9e4-3f29fcd41cff"
},
"91004529-94a9-4590-b842-e7c6b624ecf5": {
"name": "ObjectHelper",
"type": "abstract class",
"namespace": "VDM\\Joomla\\Utilities",
"code": "src\/91004529-94a9-4590-b842-e7c6b624ecf5\/code.php",
"power": "src\/91004529-94a9-4590-b842-e7c6b624ecf5\/code.power",
"settings": "src\/91004529-94a9-4590-b842-e7c6b624ecf5\/settings.json",
"path": "src\/91004529-94a9-4590-b842-e7c6b624ecf5",
"spk": "Super__91004529_94a9_4590_b842_e7c6b624ecf5__Power",
"guid": "91004529-94a9-4590-b842-e7c6b624ecf5"
},
"9c513baf-b279-43fd-ae29-a585c8cbc4f0": {
"name": "GuidHelper",
"type": "abstract class",
"namespace": "VDM\\Joomla\\Utilities",
"code": "src\/9c513baf-b279-43fd-ae29-a585c8cbc4f0\/code.php",
"power": "src\/9c513baf-b279-43fd-ae29-a585c8cbc4f0\/code.power",
"settings": "src\/9c513baf-b279-43fd-ae29-a585c8cbc4f0\/settings.json",
"path": "src\/9c513baf-b279-43fd-ae29-a585c8cbc4f0",
"spk": "Super__9c513baf_b279_43fd_ae29_a585c8cbc4f0__Power",
"guid": "9c513baf-b279-43fd-ae29-a585c8cbc4f0"
},
"9ef0eb24-aae4-4f5a-99af-d724db44808f": {
"name": "FieldHelper",
"type": "abstract class",
"namespace": "VDM\\Joomla\\Utilities\\String",
"code": "src\/9ef0eb24-aae4-4f5a-99af-d724db44808f\/code.php",
"power": "src\/9ef0eb24-aae4-4f5a-99af-d724db44808f\/code.power",
"settings": "src\/9ef0eb24-aae4-4f5a-99af-d724db44808f\/settings.json",
"path": "src\/9ef0eb24-aae4-4f5a-99af-d724db44808f",
"spk": "Super__9ef0eb24_aae4_4f5a_99af_d724db44808f__Power",
"guid": "9ef0eb24-aae4-4f5a-99af-d724db44808f"
},
"a223b31e-ea1d-4cdf-92ae-5f9becffaff0": {
"name": "FileHelper",
"type": "abstract class",
"namespace": "VDM\\Joomla\\Utilities",
"code": "src\/a223b31e-ea1d-4cdf-92ae-5f9becffaff0\/code.php",
"power": "src\/a223b31e-ea1d-4cdf-92ae-5f9becffaff0\/code.power",
"settings": "src\/a223b31e-ea1d-4cdf-92ae-5f9becffaff0\/settings.json",
"path": "src\/a223b31e-ea1d-4cdf-92ae-5f9becffaff0",
"spk": "Super__a223b31e_ea1d_4cdf_92ae_5f9becffaff0__Power",
"guid": "a223b31e-ea1d-4cdf-92ae-5f9becffaff0"
},
"a8935cbe-7701-40dc-bfd5-675f2d600954": {
"name": "TypeHelper",
"type": "abstract class",
"namespace": "VDM\\Joomla\\Utilities\\String",
"code": "src\/a8935cbe-7701-40dc-bfd5-675f2d600954\/code.php",
"power": "src\/a8935cbe-7701-40dc-bfd5-675f2d600954\/code.power",
"settings": "src\/a8935cbe-7701-40dc-bfd5-675f2d600954\/settings.json",
"path": "src\/a8935cbe-7701-40dc-bfd5-675f2d600954",
"spk": "Super__a8935cbe_7701_40dc_bfd5_675f2d600954__Power",
"guid": "a8935cbe-7701-40dc-bfd5-675f2d600954"
},
"ad12ca1c-d3ce-4e7f-88c5-c6c92bdedc48": {
"name": "InsertInterface",
"type": "interface",
"namespace": "VDM\\Joomla\\Interfaces",
"code": "src\/ad12ca1c-d3ce-4e7f-88c5-c6c92bdedc48\/code.php",
"power": "src\/ad12ca1c-d3ce-4e7f-88c5-c6c92bdedc48\/code.power",
"settings": "src\/ad12ca1c-d3ce-4e7f-88c5-c6c92bdedc48\/settings.json",
"path": "src\/ad12ca1c-d3ce-4e7f-88c5-c6c92bdedc48",
"spk": "Super__ad12ca1c_d3ce_4e7f_88c5_c6c92bdedc48__Power",
"guid": "ad12ca1c-d3ce-4e7f-88c5-c6c92bdedc48"
},
"b84e947d-2a13-44f7-ac0f-3902ae55ae0c": {
"name": "BaseRegistry",
"type": "abstract class",
"namespace": "VDM\\Joomla\\Componentbuilder\\Abstraction",
"code": "src\/b84e947d-2a13-44f7-ac0f-3902ae55ae0c\/code.php",
"power": "src\/b84e947d-2a13-44f7-ac0f-3902ae55ae0c\/code.power",
"settings": "src\/b84e947d-2a13-44f7-ac0f-3902ae55ae0c\/settings.json",
"path": "src\/b84e947d-2a13-44f7-ac0f-3902ae55ae0c",
"spk": "Super__b84e947d_2a13_44f7_ac0f_3902ae55ae0c__Power",
"guid": "b84e947d-2a13-44f7-ac0f-3902ae55ae0c"
},
"bfd1d6d5-56c1-4fe9-9fee-1c5910e1f5d8": {
"name": "Table",
"type": "class",
"namespace": "VDM\\Joomla\\Componentbuilder",
"code": "src\/bfd1d6d5-56c1-4fe9-9fee-1c5910e1f5d8\/code.php",
"power": "src\/bfd1d6d5-56c1-4fe9-9fee-1c5910e1f5d8\/code.power",
"settings": "src\/bfd1d6d5-56c1-4fe9-9fee-1c5910e1f5d8\/settings.json",
"path": "src\/bfd1d6d5-56c1-4fe9-9fee-1c5910e1f5d8",
"spk": "Super__bfd1d6d5_56c1_4fe9_9fee_1c5910e1f5d8__Power",
"guid": "bfd1d6d5-56c1-4fe9-9fee-1c5910e1f5d8"
},
"c6bbc3ee-58e7-4463-adba-5c5ae839ee36": {
"name": "MapperSingle",
"type": "abstract class",
"namespace": "VDM\\Joomla\\Componentbuilder\\Abstraction",
"code": "src\/c6bbc3ee-58e7-4463-adba-5c5ae839ee36\/code.php",
"power": "src\/c6bbc3ee-58e7-4463-adba-5c5ae839ee36\/code.power",
"settings": "src\/c6bbc3ee-58e7-4463-adba-5c5ae839ee36\/settings.json",
"path": "src\/c6bbc3ee-58e7-4463-adba-5c5ae839ee36",
"spk": "Super__c6bbc3ee_58e7_4463_adba_5c5ae839ee36__Power",
"guid": "c6bbc3ee-58e7-4463-adba-5c5ae839ee36"
},
"caf33c5d-858c-4f9a-894f-ab302ec5445a": {
"name": "FactoryInterface",
"type": "interface",
"namespace": "VDM\\Joomla\\Interfaces",
"code": "src\/caf33c5d-858c-4f9a-894f-ab302ec5445a\/code.php",
"power": "src\/caf33c5d-858c-4f9a-894f-ab302ec5445a\/code.power",
"settings": "src\/caf33c5d-858c-4f9a-894f-ab302ec5445a\/settings.json",
"path": "src\/caf33c5d-858c-4f9a-894f-ab302ec5445a",
"spk": "Super__caf33c5d_858c_4f9a_894f_ab302ec5445a__Power",
"guid": "caf33c5d-858c-4f9a-894f-ab302ec5445a"
},
"cce56585-58b0-4f72-a92c-e2635ea52d83": {
"name": "Update",
"type": "final class",
"namespace": "VDM\\Joomla\\Database",
"code": "src\/cce56585-58b0-4f72-a92c-e2635ea52d83\/code.php",
"power": "src\/cce56585-58b0-4f72-a92c-e2635ea52d83\/code.power",
"settings": "src\/cce56585-58b0-4f72-a92c-e2635ea52d83\/settings.json",
"path": "src\/cce56585-58b0-4f72-a92c-e2635ea52d83",
"spk": "Super__cce56585_58b0_4f72_a92c_e2635ea52d83__Power",
"guid": "cce56585-58b0-4f72-a92c-e2635ea52d83"
},
"cddcac51-9a46-47c4-ba59-105c70453bd6": {
"name": "FilterHelper",
"type": "abstract class",
"namespace": "VDM\\Joomla\\Componentbuilder\\Utilities",
"code": "src\/cddcac51-9a46-47c4-ba59-105c70453bd6\/code.php",
"power": "src\/cddcac51-9a46-47c4-ba59-105c70453bd6\/code.power",
"settings": "src\/cddcac51-9a46-47c4-ba59-105c70453bd6\/settings.json",
"path": "src\/cddcac51-9a46-47c4-ba59-105c70453bd6",
"spk": "Super__cddcac51_9a46_47c4_ba59_105c70453bd6__Power",
"guid": "cddcac51-9a46-47c4-ba59-105c70453bd6"
},
"ce8cf834-6bac-44fb-941c-861f7e046cc0": {
"name": "NamespaceHelper",
"type": "abstract class",
"namespace": "VDM\\Joomla\\Utilities\\String",
"code": "src\/ce8cf834-6bac-44fb-941c-861f7e046cc0\/code.php",
"power": "src\/ce8cf834-6bac-44fb-941c-861f7e046cc0\/code.power",
"settings": "src\/ce8cf834-6bac-44fb-941c-861f7e046cc0\/settings.json",
"path": "src\/ce8cf834-6bac-44fb-941c-861f7e046cc0",
"spk": "Super__ce8cf834_6bac_44fb_941c_861f7e046cc0__Power",
"guid": "ce8cf834-6bac-44fb-941c-861f7e046cc0"
},
"db87c339-5bb6-4291-a7ef-2c48ea1b06bc": {
"name": "GetHelper",
"type": "abstract class",
"namespace": "VDM\\Joomla\\Utilities",
"code": "src\/db87c339-5bb6-4291-a7ef-2c48ea1b06bc\/code.php",
"power": "src\/db87c339-5bb6-4291-a7ef-2c48ea1b06bc\/code.power",
"settings": "src\/db87c339-5bb6-4291-a7ef-2c48ea1b06bc\/settings.json",
"path": "src\/db87c339-5bb6-4291-a7ef-2c48ea1b06bc",
"spk": "Super__db87c339_5bb6_4291_a7ef_2c48ea1b06bc__Power",
"guid": "db87c339-5bb6-4291-a7ef-2c48ea1b06bc"
},
"e0f6ddbe-2a35-4537-942c-faff2ebd04f6": {
"name": "BaseTable",
"type": "abstract class",
"namespace": "VDM\\Joomla\\Abstraction",
"code": "src\/e0f6ddbe-2a35-4537-942c-faff2ebd04f6\/code.php",
"power": "src\/e0f6ddbe-2a35-4537-942c-faff2ebd04f6\/code.power",
"settings": "src\/e0f6ddbe-2a35-4537-942c-faff2ebd04f6\/settings.json",
"path": "src\/e0f6ddbe-2a35-4537-942c-faff2ebd04f6",
"spk": "Super__e0f6ddbe_2a35_4537_942c_faff2ebd04f6__Power",
"guid": "e0f6ddbe-2a35-4537-942c-faff2ebd04f6"
},
"ffbd4e1f-a342-4080-ab7d-1de3741bf319": {
"name": "BaseConfig",
"type": "abstract class",
"namespace": "VDM\\Joomla\\Abstraction",
"code": "src\/ffbd4e1f-a342-4080-ab7d-1de3741bf319\/code.php",
"power": "src\/ffbd4e1f-a342-4080-ab7d-1de3741bf319\/code.power",
"settings": "src\/ffbd4e1f-a342-4080-ab7d-1de3741bf319\/settings.json",
"path": "src\/ffbd4e1f-a342-4080-ab7d-1de3741bf319",
"spk": "Super__ffbd4e1f_a342_4080_ab7d_1de3741bf319__Power",
"guid": "ffbd4e1f-a342-4080-ab7d-1de3741bf319"
}
}
###POWERINDEX###