update 2023-05-15 14:54:07

This commit is contained in:
Robot 2023-05-15 14:54:07 +02:00
parent d0bfdca05e
commit 5d1eb3db0e
Signed by: Robot
GPG Key ID: 14DECD44E7E1BB95
6 changed files with 6094 additions and 0 deletions

View File

@ -26,6 +26,9 @@ This repository contains an index (see below) of all the approved powers within
- **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\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\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
@ -120,6 +123,29 @@ namespace VDM\Joomla #Azure {
}
@enduml
```
## VDM Joomla Componentbuilder
> namespace VDM\Joomla\Componentbuilder
```uml
@startuml
namespace VDM\Joomla\Componentbuilder #DarkCyan {
class Table #Gold {
+ get() : mixed
+ title() : ?array
+ titleName() : string
+ tables() : array
+ exist() : bool
+ fields() : ?array
# addDefault() : array
}
}
@enduml
```

View File

@ -0,0 +1,97 @@
```
██████╗ ██████╗ ██╗ ██╗███████╗██████╗
██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗
██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝
██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
```
# class Table (Details)
> namespace: **VDM\Joomla\Componentbuilder**
```uml
@startuml
class Table #Gold {
+ 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 Table::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 Table::title
Get title field from an area/view/table
since: 3.2.0
return: ?array
end note
note right of Table::titleName
Get title field name
since: 3.2.0
return: string
end note
note right of Table::tables
Get all tables
since: 3.2.0
return: array
end note
note right of Table::exist
Check if a table (and field) exist
since: 3.2.0
return: bool
end note
note right of Table::fields
Get all fields of an area/view/table
since: 3.2.0
return: ?array
end note
note right of Table::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)

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,199 @@
/**
* All areas/views/tables with their field details
*
* @var array
* @since 3.2.0
**/
protected array $tables = ###ALL_COMPONENT_FIELDS###;
/**
* 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;
}

View File

@ -0,0 +1,20 @@
{
"add_head": "0",
"add_licensing_template": "2",
"extends": "0",
"guid": "bfd1d6d5-56c1-4fe9-9fee-1c5910e1f5d8",
"implements": [
"2da6d6c4-eb29-4d69-8bc2-36d96e916adf"
],
"load_selection": null,
"name": "Table",
"power_version": "2.0.0",
"system_name": "JCB.Table",
"type": "class",
"use_selection": null,
"namespace": "VDM\\Joomla\\Componentbuilder.Table",
"description": "JCB Tables\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": ""
}

View File

@ -208,6 +208,17 @@
"spk": "Super__524eb8f6_38d4_47dc_92ad_98b94e099ac0__Power",
"guid": "524eb8f6-38d4-47dc-92ad-98b94e099ac0"
},
"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"
},
"9769f3b2-17bf-4f20-b54b-3a4ebe572b36": {
"name": "BaseConfig",
"type": "abstract class",