first commit

This commit is contained in:
Llewellyn van der Merwe 2023-04-15 16:53:53 +02:00
commit 4fe34f3818
Signed by: Llewellyn
GPG Key ID: A9201372263741E7
26 changed files with 2325 additions and 0 deletions

167
README.md Normal file
View File

@ -0,0 +1,167 @@
```
███████╗██╗ ██╗██████╗ ███████╗██████╗
██╔════╝██║ ██║██╔══██╗██╔════╝██╔══██╗
███████╗██║ ██║██████╔╝█████╗ ██████╔╝
╚════██║██║ ██║██╔═══╝ ██╔══╝ ██╔══██╗
███████║╚██████╔╝██║ ███████╗██║ ██║
╚══════╝ ╚═════╝ ╚═╝ ╚══════╝╚═╝ ╚═╝
██████╗ ██████╗ ██╗ ██╗███████╗██████╗ ███████╗
██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗██╔════╝
██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝███████╗
██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗╚════██║
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║███████║
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝╚══════╝
```
### 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\Componentbuilder\Package](#vdm-joomla-componentbuilder-package)
- **abstract class Factory** | [Details](src/ec804df5-a384-48d7-b709-ae091ddc328a) | [Code](src/ec804df5-a384-48d7-b709-ae091ddc328a/code.php) | [Settings](src/ec804df5-a384-48d7-b709-ae091ddc328a/settings.json) | [ec804df5-a384-48d7-b709-ae091ddc328a](src/ec804df5-a384-48d7-b709-ae091ddc328a)
- **Namespace**: [VDM\Joomla\Componentbuilder\Package\Database](#vdm-joomla-componentbuilder-package-database)
- **class Insert** | [Details](src/f68aafc4-beec-4bf0-b528-4e2c525f5b7b) | [Code](src/f68aafc4-beec-4bf0-b528-4e2c525f5b7b/code.php) | [Settings](src/f68aafc4-beec-4bf0-b528-4e2c525f5b7b/settings.json) | [f68aafc4-beec-4bf0-b528-4e2c525f5b7b](src/f68aafc4-beec-4bf0-b528-4e2c525f5b7b)
- **class Load** | [Details](src/12234620-f54f-4914-a51a-24f5707cb8a6) | [Code](src/12234620-f54f-4914-a51a-24f5707cb8a6/code.php) | [Settings](src/12234620-f54f-4914-a51a-24f5707cb8a6/settings.json) | [12234620-f54f-4914-a51a-24f5707cb8a6](src/12234620-f54f-4914-a51a-24f5707cb8a6)
- **Namespace**: [VDM\Joomla\Componentbuilder\Package\Display](#vdm-joomla-componentbuilder-package-display)
- **class Details** | [Details](src/2e64007d-acac-438c-b719-3e1875784f47) | [Code](src/2e64007d-acac-438c-b719-3e1875784f47/code.php) | [Settings](src/2e64007d-acac-438c-b719-3e1875784f47/settings.json) | [2e64007d-acac-438c-b719-3e1875784f47](src/2e64007d-acac-438c-b719-3e1875784f47)
- **Namespace**: [VDM\Joomla\Componentbuilder\Package\Service](#vdm-joomla-componentbuilder-package-service)
- **class Database** | [Details](src/97c8b20c-a35d-47e7-b801-b9c54443e876) | [Code](src/97c8b20c-a35d-47e7-b801-b9c54443e876/code.php) | [Settings](src/97c8b20c-a35d-47e7-b801-b9c54443e876/settings.json) | [97c8b20c-a35d-47e7-b801-b9c54443e876](src/97c8b20c-a35d-47e7-b801-b9c54443e876)
- **class Display** | [Details](src/7d1aeda3-2598-46a6-bec2-7d4c5a65d99c) | [Code](src/7d1aeda3-2598-46a6-bec2-7d4c5a65d99c/code.php) | [Settings](src/7d1aeda3-2598-46a6-bec2-7d4c5a65d99c/settings.json) | [7d1aeda3-2598-46a6-bec2-7d4c5a65d99c](src/7d1aeda3-2598-46a6-bec2-7d4c5a65d99c)
# Class Diagrams
## VDM Joomla Componentbuilder Package
> namespace VDM\Joomla\Componentbuilder\Package
```uml
@startuml
namespace VDM\Joomla\Componentbuilder\Package #Olive {
abstract Factory #Orange {
# static $container
+ {static} _() : Mixed
+ {static} getContainer() : Container
# {static} createContainer() : Container
}
}
@enduml
```
## VDM Joomla Componentbuilder Package Database
> namespace VDM\Joomla\Componentbuilder\Package\Database
```uml
@startuml
namespace VDM\Joomla\Componentbuilder\Package\Database #LightGreen {
class Insert #Gold {
# Config $config
# Table $table
# Model $model
# \JDatabaseDriver $db
+ __construct()
+ value() : bool
+ item() : bool
+ items() : bool
}
class Load #Gold {
# Table $table
# Database $load
+ __construct()
+ value() : mixed
+ item() : ?object
+ items() : ?array
}
}
@enduml
```
## VDM Joomla Componentbuilder Package Display
> namespace VDM\Joomla\Componentbuilder\Package\Display
```uml
@startuml
namespace VDM\Joomla\Componentbuilder\Package\Display #LightGreen {
class Details #Gold {
- array $owner
+ owner() : string
+ hasOwner() : bool
+ components() : string
- getInfoValue() : ?string
- hasKey() : bool
}
}
@enduml
```
## VDM Joomla Componentbuilder Package Service
> namespace VDM\Joomla\Componentbuilder\Package\Service
```uml
@startuml
namespace VDM\Joomla\Componentbuilder\Package\Service #LightGreen {
class Database #Gold {
+ register() : void
+ getLoad() : Load
+ getInsert() : Insert
+ getDatabaseLoad() : LoadDatabase
+ getDatabaseInsert() : InsertDatabase
}
class Display #Gold {
+ register() : void
+ getDetails() : Details
}
}
@enduml
```
---
```
██╗ ██████╗ ██████╗ ███╗ ███╗██╗ █████╗
██║██╔═══██╗██╔═══██╗████╗ ████║██║ ██╔══██╗
██║██║ ██║██║ ██║██╔████╔██║██║ ███████║
██ ██║██║ ██║██║ ██║██║╚██╔╝██║██║ ██╔══██║
╚█████╔╝╚██████╔╝╚██████╔╝██║ ╚═╝ ██║███████╗██║ ██║
╚════╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
██████╗ ██████╗ ███╗ ███╗██████╗ ██████╗ ███╗ ██╗███████╗███╗ ██╗████████╗
██╔════╝██╔═══██╗████╗ ████║██╔══██╗██╔═══██╗████╗ ██║██╔════╝████╗ ██║╚══██╔══╝
██║ ██║ ██║██╔████╔██║██████╔╝██║ ██║██╔██╗ ██║█████╗ ██╔██╗ ██║ ██║
██║ ██║ ██║██║╚██╔╝██║██╔═══╝ ██║ ██║██║╚██╗██║██╔══╝ ██║╚██╗██║ ██║
╚██████╗╚██████╔╝██║ ╚═╝ ██║██║ ╚██████╔╝██║ ╚████║███████╗██║ ╚████║ ██║
╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═════╝ ╚═╝ ╚═══╝╚══════╝╚═╝ ╚═══╝ ╚═╝
██████╗ ██╗ ██╗██╗██╗ ██████╗ ███████╗██████╗
██╔══██╗██║ ██║██║██║ ██╔══██╗██╔════╝██╔══██╗
██████╔╝██║ ██║██║██║ ██║ ██║█████╗ ██████╔╝
██╔══██╗██║ ██║██║██║ ██║ ██║██╔══╝ ██╔══██╗
██████╔╝╚██████╔╝██║███████╗██████╔╝███████╗██║ ██║
╚═════╝ ╚═════╝ ╚═╝╚══════╝╚═════╝ ╚══════╝╚═╝ ╚═╝
```
> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder)

View File

@ -0,0 +1,70 @@
```
██████╗ ██████╗ ██╗ ██╗███████╗██████╗
██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗
██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝
██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
```
# class Load (Details)
> namespace: **VDM\Joomla\Componentbuilder\Package\Database**
```uml
@startuml
class Load #Gold {
# Table $table
# Database $load
+ __construct(?Table $table = null, ?Database $load = null)
+ value(int $id, string $field, ...) : mixed
+ item(int $id, ?string $table) : ?object
+ items(array $ids, string $table) : ?array
}
note right of Load::__construct
Constructor
since: 3.2.0
end note
note right of Load::value
Get a value from a given table
Example: $this->value(23, 'value_key', 'table_name');
since: 3.2.0
return: mixed
arguments:
int $id
string $field
string $table
end note
note right of Load::item
Get values from a given table
Example: $this->item(23, 'table_name');
since: 3.2.0
return: ?object
end note
note right of Load::items
Get values from a given table
Example: $this->items($ids, 'table_name');
since: 3.2.0
return: ?array
end note
@enduml
```
---
```
██╗ ██████╗██████╗
██║██╔════╝██╔══██╗
██║██║ ██████╔╝
██ ██║██║ ██╔══██╗
╚█████╔╝╚██████╗██████╔╝
╚════╝ ╚═════╝╚═════╝
```
> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder)

View File

@ -0,0 +1,128 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Package\Database;
use VDM\Joomla\Componentbuilder\Package\Factory;
use VDM\Joomla\Componentbuilder\Table;
use VDM\Joomla\Componentbuilder\Database\Load as Database;
/**
* Package Database Load
*
* @since 3.2.0
*/
class Load
{
/**
* Search Table
*
* @var Table
* @since 3.2.0
*/
protected Table $table;
/**
* Database Load
*
* @var Database
* @since 3.2.0
*/
protected Database $load;
/**
* Constructor
*
* @param Table|null $table The core table object.
* @param Database|null $load The database object.
*
* @since 3.2.0
*/
public function __construct(?Table $table = null, ?Database $load = null)
{
$this->table = $table ?: Factory::_('Table');
$this->load = $load ?: Factory::_('Load');
}
/**
* Get a value from a given table
* Example: $this->value(23, 'value_key', 'table_name');
*
* @param int $id The item ID
* @param string $field The field key
* @param string $table The table
*
* @return mixed
* @since 3.2.0
*/
public function value(int $id, string $field, string $table)
{
// check if this is a valid table
if ($id > 0 && $this->table->exist($table, $field))
{
return $this->load->value(
["a.${field}" => $field], ['a' => $table], ['a.id' => $id]
);
}
return null;
}
/**
* Get values from a given table
* Example: $this->item(23, 'table_name');
*
* @param int $id The item ID
* @param string $table The table
*
* @return object|null
* @since 3.2.0
*/
public function item(int $id, ?string $table): ?object
{
// check if this is a valid table
if ($id > 0 && $this->table->exist($table))
{
return $this->load->item(
['all' => 'a.*'], ['a' => $table], ['a.id' => $id]
);
}
return null;
}
/**
* Get values from a given table
* Example: $this->items($ids, 'table_name');
*
* @param array $ids The item ids
* @param string $table The table
*
* @return array|null
* @since 3.2.0
*/
public function items(array $ids, string $table): ?array
{
// check if this is a valid table
if ($this->table->exist($table))
{
return $this->load->items(
['all' => 'a.*'], ['a' => $table], ['a.id' => $ids]
);
}
return null;
}
}

View File

@ -0,0 +1,99 @@
/**
* Search Table
*
* @var Table
* @since 3.2.0
*/
protected Table $table;
/**
* Database Load
*
* @var Database
* @since 3.2.0
*/
protected Database $load;
/**
* Constructor
*
* @param Table|null $table The core table object.
* @param Database|null $load The database object.
*
* @since 3.2.0
*/
public function __construct(?Table $table = null, ?Database $load = null)
{
$this->table = $table ?: Factory::_('Table');
$this->load = $load ?: Factory::_('Load');
}
/**
* Get a value from a given table
* Example: $this->value(23, 'value_key', 'table_name');
*
* @param int $id The item ID
* @param string $field The field key
* @param string $table The table
*
* @return mixed
* @since 3.2.0
*/
public function value(int $id, string $field, string $table)
{
// check if this is a valid table
if ($id > 0 && $this->table->exist($table, $field))
{
return $this->load->value(
["a.${field}" => $field], ['a' => $table], ['a.id' => $id]
);
}
return null;
}
/**
* Get values from a given table
* Example: $this->item(23, 'table_name');
*
* @param int $id The item ID
* @param string $table The table
*
* @return object|null
* @since 3.2.0
*/
public function item(int $id, ?string $table): ?object
{
// check if this is a valid table
if ($id > 0 && $this->table->exist($table))
{
return $this->load->item(
['all' => 'a.*'], ['a' => $table], ['a.id' => $id]
);
}
return null;
}
/**
* Get values from a given table
* Example: $this->items($ids, 'table_name');
*
* @param array $ids The item ids
* @param string $table The table
*
* @return array|null
* @since 3.2.0
*/
public function items(array $ids, string $table): ?array
{
// check if this is a valid table
if ($this->table->exist($table))
{
return $this->load->items(
['all' => 'a.*'], ['a' => $table], ['a.id' => $ids]
);
}
return null;
}

View File

@ -0,0 +1,31 @@
{
"add_head": "0",
"add_licensing_template": "2",
"extends": "0",
"guid": "12234620-f54f-4914-a51a-24f5707cb8a6",
"implements": null,
"load_selection": null,
"name": "Load",
"power_version": "1.0.0",
"system_name": "JCB.Package.Database.Load",
"type": "class",
"use_selection": {
"use_selection0": {
"use": "ec804df5-a384-48d7-b709-ae091ddc328a",
"as": "default"
},
"use_selection1": {
"use": "bfd1d6d5-56c1-4fe9-9fee-1c5910e1f5d8",
"as": "default"
},
"use_selection2": {
"use": "06f8eada-d59b-441c-b287-0aea1793da5a",
"as": "Database"
}
},
"namespace": "VDM\\Joomla\\Componentbuilder.Package.Database.Load",
"description": "Package 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": ""
}

View File

@ -0,0 +1,70 @@
```
██████╗ ██████╗ ██╗ ██╗███████╗██████╗
██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗
██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝
██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
```
# class Details (Details)
> namespace: **VDM\Joomla\Componentbuilder\Package\Display**
```uml
@startuml
class Details #Gold {
- array $owner
+ owner(array $info, bool $trust = false) : string
+ hasOwner(array $info) : bool
+ components(array $info) : string
- getInfoValue(string $key, array $info) : ?string
- hasKey(array $info) : bool
}
note right of Details::owner
get the JCB package owner details display
since: 3.2.0
return: string
end note
note right of Details::hasOwner
Check if info details has owner values set
since: 3.2.0
return: bool
end note
note right of Details::components
get the JCB package components details display
since: 3.2.0
return: string
end note
note right of Details::getInfoValue
get the value from INFO array
since: 3.2.0
return: ?string
end note
note right of Details::hasKey
Check if the JCB package has a key
since: 3.2.0
return: bool
end note
@enduml
```
---
```
██╗ ██████╗██████╗
██║██╔════╝██╔══██╗
██║██║ ██████╔╝
██ ██║██║ ██╔══██╗
╚█████╔╝╚██████╗██████╔╝
╚════╝ ╚═════╝╚═════╝
```
> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder)

View File

@ -0,0 +1,281 @@
<?php
/**
* @package FrameworkOnFramework
* @subpackage encrypt
* @copyright Copyright (C) 2010-2016 Nicholas K. Dionysopoulos / Akeeba Ltd. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
* @note This file has been modified by the Joomla! Project and no longer reflects the original work of its author.
*/
namespace VDM\Joomla\Componentbuilder\Package\Display;
use Joomla\CMS\Language\Text;
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Utilities\ArrayHelper;
/**
* Package Display Details Class
*
* @since 3.2.0
*/
class Details
{
/**
* The Owner details template
*
* @var array
* @since 3.2.0
*/
private array $owner = [
'company' => 'COM_COMPONENTBUILDER_DTCOMPANYDTDDSDD',
'owner' => 'COM_COMPONENTBUILDER_DTOWNERDTDDSDD',
'email' => 'COM_COMPONENTBUILDER_DTEMAILDTDDSDD',
'website' => 'COM_COMPONENTBUILDER_DTWEBSITEDTDDSDD',
'license' => 'COM_COMPONENTBUILDER_DTLICENSEDTDDSDD',
'copyright' => 'COM_COMPONENTBUILDER_DTCOPYRIGHTDTDDSDD'
];
/**
* The Component details template
*
* @var array
* @since 3.2.0
*/
private array $component = [
'ul' => [
'companyname' => 'COM_COMPONENTBUILDER_ICOMPANYI_BSB',
'author' => 'COM_COMPONENTBUILDER_IAUTHORI_BSB',
'email' => 'COM_COMPONENTBUILDER_IEMAILI_BSB',
'website' => 'COM_COMPONENTBUILDER_IWEBSITEI_BSB',
],
'other' => [
'license' => 'COM_COMPONENTBUILDER_HFOUR_CLASSNAVHEADERLICENSEHFOURPSP',
'copyright' => 'COM_COMPONENTBUILDER_HFOUR_CLASSNAVHEADERCOPYRIGHTHFOURPSP'
]
];
/**
* get the JCB package owner details display
*
* @param array $info The package info object
* @param bool $trust The trust switch
*
* @return string
* @since 3.2.0
**/
public function owner(array $info, $trust = false): string
{
$hasOwner = false;
$ownerDetails = '<h2 class="module-title nav-header">' . Text::_('COM_COMPONENTBUILDER_PACKAGE_OWNER_DETAILS') . '</h2>';
$ownerDetails .= '<dl class="uk-description-list-horizontal">';
// load the list items
foreach ($this->owner as $key => $dd)
{
if ($value = $this->getInfoValue($key, $info))
{
$ownerDetails .= Text::sprintf($dd, $value);
// check if we have a owner/source name
if (('owner' === $key || 'company' === $key) && !$hasOwner)
{
$hasOwner = true;
$owner = $value;
}
}
}
$ownerDetails .= '</dl>';
// provide some details to how the user can get a key
if ($hasOwner && isset($info['getKeyFrom']['buy_link']) && StringHelper::check($info['getKeyFrom']['buy_link']))
{
$ownerDetails .= '<hr />';
$ownerDetails .= Text::sprintf('COM_COMPONENTBUILDER_BGET_THE_KEY_FROMB_A_SSA', 'class="btn btn-primary" href="' . $info['getKeyFrom']['buy_link'] . '" target="_blank" title="get a key from ' . $owner . '"', $owner);
}
// add more custom links
elseif ($hasOwner && isset($info['getKeyFrom']['buy_links']) && ArrayHelper::check($info['getKeyFrom']['buy_links']))
{
$buttons = array();
foreach ($info['getKeyFrom']['buy_links'] as $keyName => $link)
{
$buttons[] = Text::sprintf('COM_COMPONENTBUILDER_BGET_THE_KEY_FROM_SB_FOR_A_SSA', $owner, 'class="btn btn-primary" href="' . $link . '" target="_blank" title="get a key from ' . $owner . '"', $keyName);
}
$ownerDetails .= '<hr />';
$ownerDetails .= implode('<br />', $buttons);
}
// return the owner details
if (!$hasOwner)
{
$ownerDetails = '<h2>' . Text::_('COM_COMPONENTBUILDER_PACKAGE_OWNER_DETAILS_NOT_FOUND') . '</h2>';
if (!$trust)
{
$ownerDetails .= '<p style="color: #922924;">' . Text::_('COM_COMPONENTBUILDER_BE_CAUTIOUS_DO_NOT_CONTINUE_UNLESS_YOU_TRUST_THE_ORIGIN_OF_THIS_PACKAGE') . '</p>';
}
}
return '<div>'.$ownerDetails.'</div>';
}
/**
* Check if info details has owner values set
*
* @param array $info The package info object
*
* @return bool
* @since 3.2.0
**/
public function hasOwner(array &$info): bool
{
if ($this->getInfoValue('owner', $info) || $this->getInfoValue('company', $info))
{
return true;
}
return false;
}
/**
* get the JCB package components details display
*
* @param array $info The package info object
*
* @return string
* @since 3.2.0
**/
public function components(array &$info): string
{
// check if these components need a key
$needKey = $this->hasKey($info);
if (isset($info['name']) && ArrayHelper::check($info['name']))
{
$cAmount = count((array) $info['name']);
$class2 = ($cAmount == 1) ? 'span12' : 'span6';
$counter = 1;
$display = array();
foreach ($info['name'] as $key => $value)
{
// set the name
$name = $value . ' v' . $info['component_version'][$key];
if ($cAmount > 1 && $counter == 3)
{
$display[] = '</div>';
$counter = 1;
}
if ($cAmount > 1 && $counter == 1)
{
$display[] = '<div>';
}
$display[] = '<div class="well well-small ' . $class2 . '">';
$display[] = '<h3>';
$display[] = $name;
if ($needKey)
{
$display[] = ' - <em>' . Text::sprintf('COM_COMPONENTBUILDER_PAIDLOCKED') . '</em>';
}
else
{
$display[] = ' - <em>' . Text::sprintf('COM_COMPONENTBUILDER_FREEOPEN') . '</em>';
}
$display[] = '</h3><h4>';
$display[] = $info['short_description'][$key];
$display[] = '</h4>';
$display[] = '<ul class="uk-list uk-list-striped">';
// load the list items
foreach ($this->component['ul'] as $li => $value)
{
if (isset($info[$li]) && isset($info[$li][$key]))
{
$display[] = '<li>'.Text::sprintf($value, $info[$li][$key]).'</li>';
}
}
$display[] = '</ul>';
// if we have a source link we add it
if (isset($info['joomla_source_link']) && ArrayHelper::check($info['joomla_source_link']) && isset($info['joomla_source_link'][$key]) && StringHelper::check($info['joomla_source_link'][$key]))
{
$display[] = '<a class="uk-button uk-button-mini uk-width-1-1 uk-margin-small-bottom" href="' .
$info['joomla_source_link'][$key] . '" target="_blank" title="' . Text::_('COM_COMPONENTBUILDER_SOURCE_CODE_FOR_JOOMLA_COMPONENT') . ' ('. $name . ')">' . Text::_('COM_COMPONENTBUILDER_SOURCE_CODE') . '</a>';
}
// load other
foreach ($this->component['other'] as $other => $value)
{
if (isset($info[$other]) && isset($info[$other][$key]))
{
$display[] = Text::sprintf($value, $info[$other][$key]);
}
}
$display[] = '</div>';
$counter++;
}
// close the div if needed
if ($cAmount > 1)
{
$display[] = '</div>';
}
return implode(PHP_EOL, $display);
}
return '<div>' . Text::_('COM_COMPONENTBUILDER_NO_COMPONENT_DETAILS_FOUND_SO_IT_IS_NOT_SAFE_TO_CONTINUE') . '</div>';
}
/**
* get the value from INFO array
*
* @param string $key The value key
* @param array $info The package info object
*
* @return string|null
* @since 3.2.0
**/
private function getInfoValue(string $key, array &$info): ?string
{
$source = (isset($info['source']) && isset($info['source'][$key])) ? 'source' : ((isset($info['getKeyFrom']) && isset($info['getKeyFrom'][$key])) ? 'getKeyFrom' : null);
if ($source && StringHelper::check($info[$source][$key]))
{
return $info[$source][$key];
}
return null;
}
/**
* Check if the JCB package has a key
*
* @param array $info The package info object
*
* @return bool
* @since 3.2.0
**/
private function hasKey(array &$info): bool
{
// check the package key status
if (!isset($info['key']))
{
if (isset($info['getKeyFrom']) && isset($info['getKeyFrom']['owner']))
{
// has a key
$info['key'] = true;
}
else
{
// does not have a key
$info['key'] = false;
}
}
return (bool) $info['key'];
}
}

View File

@ -0,0 +1,254 @@
/**
* The Owner details template
*
* @var array
* @since 3.2.0
*/
private array $owner = [
'company' => JustTEXT::_('<dt>Company</dt><dd>%s</dd>'),
'owner' => JustTEXT::_('<dt>Owner</dt><dd>%s</dd>'),
'email' => JustTEXT::_('<dt>Email</dt><dd>%s</dd>'),
'website' => JustTEXT::_('<dt>Website</dt><dd>%s</dd>'),
'license' => JustTEXT::_('<dt>License</dt><dd>%s</dd>'),
'copyright' => JustTEXT::_('<dt>Copyright</dt><dd>%s</dd>')
];
/**
* The Component details template
*
* @var array
* @since 3.2.0
*/
private array $component = [
'ul' => [
'companyname' => JustTEXT::_('<i>Company:</i> <b>%s</b>'),
'author' => JustTEXT::_('<i>Author:</i> <b>%s</b>'),
'email' => JustTEXT::_('<i>Email:</i> <b>%s</b>'),
'website' => JustTEXT::_('<i>Website:</i> <b>%s</b>'),
],
'other' => [
'license' => JustTEXT::_('<h4 class="nav-header">License</h4><p>%s</p>'),
'copyright' => JustTEXT::_('<h4 class="nav-header">Copyright</h4><p>%s</p>')
]
];
/**
* get the JCB package owner details display
*
* @param array $info The package info object
* @param bool $trust The trust switch
*
* @return string
* @since 3.2.0
**/
public function owner(array $info, $trust = false): string
{
$hasOwner = false;
$ownerDetails = '<h2 class="module-title nav-header">' . Text::_('Package Owner Details') . '</h2>';
$ownerDetails .= '<dl class="uk-description-list-horizontal">';
// load the list items
foreach ($this->owner as $key => $dd)
{
if ($value = $this->getInfoValue($key, $info))
{
$ownerDetails .= Text::sprintf($dd, $value);
// check if we have a owner/source name
if (('owner' === $key || 'company' === $key) && !$hasOwner)
{
$hasOwner = true;
$owner = $value;
}
}
}
$ownerDetails .= '</dl>';
// provide some details to how the user can get a key
if ($hasOwner && isset($info['getKeyFrom']['buy_link']) && StringHelper::check($info['getKeyFrom']['buy_link']))
{
$ownerDetails .= '<hr />';
$ownerDetails .= Text::sprintf('<b>Get the key from</b> <a %s>%s</a>', 'class="btn btn-primary" href="' . $info['getKeyFrom']['buy_link'] . '" target="_blank" title="get a key from ' . $owner . '"', $owner);
}
// add more custom links
elseif ($hasOwner && isset($info['getKeyFrom']['buy_links']) && ArrayHelper::check($info['getKeyFrom']['buy_links']))
{
$buttons = array();
foreach ($info['getKeyFrom']['buy_links'] as $keyName => $link)
{
$buttons[] = Text::sprintf('<b>Get the key from %s</b> for <a %s>%s</a>', $owner, 'class="btn btn-primary" href="' . $link . '" target="_blank" title="get a key from ' . $owner . '"', $keyName);
}
$ownerDetails .= '<hr />';
$ownerDetails .= implode('<br />', $buttons);
}
// return the owner details
if (!$hasOwner)
{
$ownerDetails = '<h2>' . Text::_('Package owner details not found!') . '</h2>';
if (!$trust)
{
$ownerDetails .= '<p style="color: #922924;">' . Text::_('Be cautious! Do not continue unless you trust the origin of this package!') . '</p>';
}
}
return '<div>'.$ownerDetails.'</div>';
}
/**
* Check if info details has owner values set
*
* @param array $info The package info object
*
* @return bool
* @since 3.2.0
**/
public function hasOwner(array &$info): bool
{
if ($this->getInfoValue('owner', $info) || $this->getInfoValue('company', $info))
{
return true;
}
return false;
}
/**
* get the JCB package components details display
*
* @param array $info The package info object
*
* @return string
* @since 3.2.0
**/
public function components(array &$info): string
{
// check if these components need a key
$needKey = $this->hasKey($info);
if (isset($info['name']) && ArrayHelper::check($info['name']))
{
$cAmount = count((array) $info['name']);
$class2 = ($cAmount == 1) ? 'span12' : 'span6';
$counter = 1;
$display = array();
foreach ($info['name'] as $key => $value)
{
// set the name
$name = $value . ' v' . $info['component_version'][$key];
if ($cAmount > 1 && $counter == 3)
{
$display[] = '</div>';
$counter = 1;
}
if ($cAmount > 1 && $counter == 1)
{
$display[] = '<div>';
}
$display[] = '<div class="well well-small ' . $class2 . '">';
$display[] = '<h3>';
$display[] = $name;
if ($needKey)
{
$display[] = ' - <em>' . Text::sprintf('Paid/Locked') . '</em>';
}
else
{
$display[] = ' - <em>' . Text::sprintf('Free/Open') . '</em>';
}
$display[] = '</h3><h4>';
$display[] = $info['short_description'][$key];
$display[] = '</h4>';
$display[] = '<ul class="uk-list uk-list-striped">';
// load the list items
foreach ($this->component['ul'] as $li => $value)
{
if (isset($info[$li]) && isset($info[$li][$key]))
{
$display[] = '<li>'.Text::sprintf($value, $info[$li][$key]).'</li>';
}
}
$display[] = '</ul>';
// if we have a source link we add it
if (isset($info['joomla_source_link']) && ArrayHelper::check($info['joomla_source_link']) && isset($info['joomla_source_link'][$key]) && StringHelper::check($info['joomla_source_link'][$key]))
{
$display[] = '<a class="uk-button uk-button-mini uk-width-1-1 uk-margin-small-bottom" href="' .
$info['joomla_source_link'][$key] . '" target="_blank" title="' . Text::_('Source Code for Joomla Component') . ' ('. $name . ')">' . Text::_('source code') . '</a>';
}
// load other
foreach ($this->component['other'] as $other => $value)
{
if (isset($info[$other]) && isset($info[$other][$key]))
{
$display[] = Text::sprintf($value, $info[$other][$key]);
}
}
$display[] = '</div>';
$counter++;
}
// close the div if needed
if ($cAmount > 1)
{
$display[] = '</div>';
}
return implode(PHP_EOL, $display);
}
return '<div>' . Text::_('No component details found, so it is not safe to continue!') . '</div>';
}
/**
* get the value from INFO array
*
* @param string $key The value key
* @param array $info The package info object
*
* @return string|null
* @since 3.2.0
**/
private function getInfoValue(string $key, array &$info): ?string
{
$source = (isset($info['source']) && isset($info['source'][$key])) ? 'source' : ((isset($info['getKeyFrom']) && isset($info['getKeyFrom'][$key])) ? 'getKeyFrom' : null);
if ($source && StringHelper::check($info[$source][$key]))
{
return $info[$source][$key];
}
return null;
}
/**
* Check if the JCB package has a key
*
* @param array $info The package info object
*
* @return bool
* @since 3.2.0
**/
private function hasKey(array &$info): bool
{
// check the package key status
if (!isset($info['key']))
{
if (isset($info['getKeyFrom']) && isset($info['getKeyFrom']['owner']))
{
// has a key
$info['key'] = true;
}
else
{
// does not have a key
$info['key'] = false;
}
}
return (bool) $info['key'];
}

View File

@ -0,0 +1,27 @@
{
"add_head": "1",
"add_licensing_template": "2",
"extends": "0",
"guid": "2e64007d-acac-438c-b719-3e1875784f47",
"implements": null,
"load_selection": null,
"name": "Details",
"power_version": "1.0.0",
"system_name": "JCB.Package.Display.Details",
"type": "class",
"use_selection": {
"use_selection0": {
"use": "1f28cb53-60d9-4db1-b517-3c7dc6b429ef",
"as": "default"
},
"use_selection1": {
"use": "0a59c65c-9daf-4bc9-baf4-e063ff9e6a8a",
"as": "default"
}
},
"namespace": "VDM\\Joomla\\Componentbuilder.Package.Display.Details",
"description": "Package Display Details Class\r\n\r\n@since 3.2.0",
"licensing_template": "\/**\r\n * @package FrameworkOnFramework\r\n * @subpackage encrypt\r\n * @copyright Copyright (C) 2010-2016 Nicholas K. Dionysopoulos \/ Akeeba Ltd. All rights reserved.\r\n * @license GNU General Public License version 2 or later; see LICENSE.txt\r\n * @note\tThis file has been modified by the Joomla! Project and no longer reflects the original work of its author.\r\n *\/\r\n",
"head": "use Joomla\\CMS\\Language\\Text;",
"composer": ""
}

View File

@ -0,0 +1,45 @@
```
██████╗ ██████╗ ██╗ ██╗███████╗██████╗
██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗
██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝
██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
```
# class Display (Details)
> namespace: **VDM\Joomla\Componentbuilder\Package\Service**
```uml
@startuml
class Display #Gold {
+ register(Container $container) : void
+ getDetails(Container $container) : Details
}
note right of Display::register
Registers the service provider with a DI container.
since: 3.2.0
return: void
end note
note right of Display::getDetails
Get the Display Details
since: 3.2.0
return: Details
end note
@enduml
```
---
```
██╗ ██████╗██████╗
██║██╔════╝██╔══██╗
██║██║ ██████╔╝
██ ██║██║ ██╔══██╗
╚█████╔╝╚██████╗██████╔╝
╚════╝ ╚═════╝╚═════╝
```
> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder)

View File

@ -0,0 +1,55 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Package\Service;
use Joomla\DI\Container;
use Joomla\DI\ServiceProviderInterface;
use VDM\Joomla\Componentbuilder\Package\Display\Details;
/**
* Display Service Provider
*
* @since 3.2.0
*/
class Display implements ServiceProviderInterface
{
/**
* Registers the service provider with a DI container.
*
* @param Container $container The DI container.
*
* @return void
* @since 3.2.0
*/
public function register(Container $container)
{
$container->alias(Details::class, 'Display.Details')
->share('Display.Details', [$this, 'getDetails'], true);
}
/**
* Get the Display Details
*
* @param Container $container The DI container.
*
* @return Details
* @since 3.2.0
*/
public function getDetails(Container $container): Details
{
return new Details();
}
}

View File

@ -0,0 +1,26 @@
/**
* Registers the service provider with a DI container.
*
* @param Container $container The DI container.
*
* @return void
* @since 3.2.0
*/
public function register(Container $container)
{
$container->alias(Details::class, 'Display.Details')
->share('Display.Details', [$this, 'getDetails'], true);
}
/**
* Get the Display Details
*
* @param Container $container The DI container.
*
* @return Details
* @since 3.2.0
*/
public function getDetails(Container $container): Details
{
return new Details();
}

View File

@ -0,0 +1,26 @@
{
"add_head": "1",
"add_licensing_template": "2",
"extends": "0",
"guid": "7d1aeda3-2598-46a6-bec2-7d4c5a65d99c",
"implements": [
"-1"
],
"load_selection": null,
"name": "Display",
"power_version": "1.0.0",
"system_name": "JCB.Package.Service.Display",
"type": "class",
"use_selection": {
"use_selection0": {
"use": "2e64007d-acac-438c-b719-3e1875784f47",
"as": "default"
}
},
"namespace": "VDM\\Joomla\\Componentbuilder.Package.Service.Display",
"description": "Display Service Provider\r\n\r\n@since 3.2.0",
"implements_custom": "ServiceProviderInterface",
"licensing_template": "\/**\r\n * @package Joomla.Component.Builder\r\n *\r\n * @created 4th September, 2022\r\n * @author Llewellyn van der Merwe <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;\r\nuse Joomla\\DI\\ServiceProviderInterface;",
"composer": ""
}

View File

@ -0,0 +1,69 @@
```
██████╗ ██████╗ ██╗ ██╗███████╗██████╗
██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗
██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝
██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
```
# class Database (Details)
> namespace: **VDM\Joomla\Componentbuilder\Package\Service**
```uml
@startuml
class Database #Gold {
+ register(Container $container) : void
+ getLoad(Container $container) : Load
+ getInsert(Container $container) : Insert
+ getDatabaseLoad(Container $container) : LoadDatabase
+ getDatabaseInsert(Container $container) : InsertDatabase
}
note right of Database::register
Registers the service provider with a DI container.
since: 3.2.0
return: void
end note
note right of Database::getLoad
Get the Core Load Database
since: 3.2.0
return: Load
end note
note right of Database::getInsert
Get the Core Insert Database
since: 3.2.0
return: Insert
end note
note right of Database::getDatabaseLoad
Get the Load Database
since: 3.2.0
return: LoadDatabase
end note
note right of Database::getDatabaseInsert
Get the Insert Database
since: 3.2.0
return: InsertDatabase
end note
@enduml
```
---
```
██╗ ██████╗██████╗
██║██╔════╝██╔══██╗
██║██║ ██████╔╝
██ ██║██║ ██╔══██╗
╚█████╔╝╚██████╗██████╔╝
╚════╝ ╚═════╝╚═════╝
```
> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder)

View File

@ -0,0 +1,112 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Package\Service;
use Joomla\DI\Container;
use Joomla\DI\ServiceProviderInterface;
use VDM\Joomla\Componentbuilder\Database\Load;
use VDM\Joomla\Componentbuilder\Database\Insert;
use VDM\Joomla\Componentbuilder\Package\Database\Load as LoadDatabase;
use VDM\Joomla\Componentbuilder\Package\Database\Insert as InsertDatabase;
/**
* Database Service Provider
*
* @since 3.2.0
*/
class Database implements ServiceProviderInterface
{
/**
* Registers the service provider with a DI container.
*
* @param Container $container The DI container.
*
* @return void
* @since 3.2.0
*/
public function register(Container $container)
{
$container->alias(Load::class, 'Load')
->share('Load', [$this, 'getLoad'], true);
$container->alias(Insert::class, 'Insert')
->share('Insert', [$this, 'getInsert'], true);
$container->alias(LoadDatabase::class, 'Load.Database')
->share('Load.Database', [$this, 'getDatabaseLoad'], true);
$container->alias(InsertDatabase::class, 'Insert.Database')
->share('Insert.Database', [$this, 'getDatabaseInsert'], true);
}
/**
* Get the Core Load Database
*
* @param Container $container The DI container.
*
* @return Load
* @since 3.2.0
*/
public function getLoad(Container $container): Load
{
return new Load();
}
/**
* Get the Core Insert Database
*
* @param Container $container The DI container.
*
* @return Insert
* @since 3.2.0
*/
public function getInsert(Container $container): Insert
{
return new Insert();
}
/**
* Get the Load Database
*
* @param Container $container The DI container.
*
* @return LoadDatabase
* @since 3.2.0
*/
public function getDatabaseLoad(Container $container): LoadDatabase
{
return new LoadDatabase(
$container->get('Table'),
$container->get('Load')
);
}
/**
* Get the Insert Database
*
* @param Container $container The DI container.
*
* @return InsertDatabase
* @since 3.2.0
*/
public function getDatabaseInsert(Container $container): InsertDatabase
{
return new InsertDatabase(
$container->get('Table'),
$container->get('Insert')
);
}
}

View File

@ -0,0 +1,80 @@
/**
* Registers the service provider with a DI container.
*
* @param Container $container The DI container.
*
* @return void
* @since 3.2.0
*/
public function register(Container $container)
{
$container->alias(Load::class, 'Load')
->share('Load', [$this, 'getLoad'], true);
$container->alias(Insert::class, 'Insert')
->share('Insert', [$this, 'getInsert'], true);
$container->alias(LoadDatabase::class, 'Load.Database')
->share('Load.Database', [$this, 'getDatabaseLoad'], true);
$container->alias(InsertDatabase::class, 'Insert.Database')
->share('Insert.Database', [$this, 'getDatabaseInsert'], true);
}
/**
* Get the Core Load Database
*
* @param Container $container The DI container.
*
* @return Load
* @since 3.2.0
*/
public function getLoad(Container $container): Load
{
return new Load();
}
/**
* Get the Core Insert Database
*
* @param Container $container The DI container.
*
* @return Insert
* @since 3.2.0
*/
public function getInsert(Container $container): Insert
{
return new Insert();
}
/**
* Get the Load Database
*
* @param Container $container The DI container.
*
* @return LoadDatabase
* @since 3.2.0
*/
public function getDatabaseLoad(Container $container): LoadDatabase
{
return new LoadDatabase(
$container->get('Table'),
$container->get('Load')
);
}
/**
* Get the Insert Database
*
* @param Container $container The DI container.
*
* @return InsertDatabase
* @since 3.2.0
*/
public function getDatabaseInsert(Container $container): InsertDatabase
{
return new InsertDatabase(
$container->get('Table'),
$container->get('Insert')
);
}

View File

@ -0,0 +1,38 @@
{
"add_head": "1",
"add_licensing_template": "2",
"extends": "0",
"guid": "97c8b20c-a35d-47e7-b801-b9c54443e876",
"implements": [
"-1"
],
"load_selection": null,
"name": "Database",
"power_version": "1.0.0",
"system_name": "JCB.Package.Service.Database",
"type": "class",
"use_selection": {
"use_selection0": {
"use": "06f8eada-d59b-441c-b287-0aea1793da5a",
"as": "default"
},
"use_selection1": {
"use": "524eb8f6-38d4-47dc-92ad-98b94e099ac0",
"as": "default"
},
"use_selection2": {
"use": "12234620-f54f-4914-a51a-24f5707cb8a6",
"as": "LoadDatabase"
},
"use_selection3": {
"use": "f68aafc4-beec-4bf0-b528-4e2c525f5b7b",
"as": "InsertDatabase"
}
},
"namespace": "VDM\\Joomla\\Componentbuilder.Package.Service.Database",
"description": "Database Service Provider\r\n\r\n@since 3.2.0",
"implements_custom": "ServiceProviderInterface",
"licensing_template": "\/**\r\n * @package Joomla.Component.Builder\r\n *\r\n * @created 4th September, 2022\r\n * @author Llewellyn van der Merwe <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;\r\nuse Joomla\\DI\\ServiceProviderInterface;",
"composer": ""
}

View File

@ -0,0 +1,54 @@
```
██████╗ ██████╗ ██╗ ██╗███████╗██████╗
██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗
██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝
██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
```
# abstract class Factory (Details)
> namespace: **VDM\Joomla\Componentbuilder\Package**
```uml
@startuml
abstract Factory #Orange {
# static $container
+ {static} _(string $key) : Mixed
+ {static} getContainer() : Container
# {static} createContainer() : Container
}
note right of Factory::_
Get any class from the package container
since: 3.2.0
return: Mixed
end note
note right of Factory::getContainer
Get the global package container
since: 3.2.0
return: Container
end note
note right of Factory::createContainer
Create a container object
since: 3.2.0
return: Container
end note
@enduml
```
---
```
██╗ ██████╗██████╗
██║██╔════╝██╔══██╗
██║██║ ██████╔╝
██ ██║██║ ██╔══██╗
╚█████╔╝╚██████╗██████╔╝
╚════╝ ╚═════╝╚═════╝
```
> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder)

View File

@ -0,0 +1,83 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Package;
use Joomla\DI\Container;
use VDM\Joomla\Componentbuilder\Service\Crypt;
use VDM\Joomla\Componentbuilder\Package\Service\Database;
use VDM\Joomla\Componentbuilder\Service\Server;
use VDM\Joomla\Componentbuilder\Package\Service\Display;
use VDM\Joomla\Componentbuilder\Interfaces\FactoryInterface;
/**
* Package Factory
*
* @since 3.2.0
*/
abstract class Factory implements FactoryInterface
{
/**
* Global Package Container
*
* @var Container
* @since 3.2.0
**/
protected static $container = null;
/**
* Get any class from the package container
*
* @param string $key The container class key
*
* @return Mixed
* @since 3.2.0
*/
public static function _($key)
{
return self::getContainer()->get($key);
}
/**
* Get the global package container
*
* @return Container
* @since 3.2.0
*/
public static function getContainer(): Container
{
if (!self::$container)
{
self::$container = self::createContainer();
}
return self::$container;
}
/**
* Create a container object
*
* @return Container
* @since 3.2.0
*/
protected static function createContainer(): Container
{
return (new Container())
->registerServiceProvider(new Database())
->registerServiceProvider(new Crypt())
->registerServiceProvider(new Server())
->registerServiceProvider(new Display());
}
}

View File

@ -0,0 +1,51 @@
/**
* Global Package Container
*
* @var Container
* @since 3.2.0
**/
protected static $container = null;
/**
* Get any class from the package container
*
* @param string $key The container class key
*
* @return Mixed
* @since 3.2.0
*/
public static function _($key)
{
return self::getContainer()->get($key);
}
/**
* Get the global package container
*
* @return Container
* @since 3.2.0
*/
public static function getContainer(): Container
{
if (!self::$container)
{
self::$container = self::createContainer();
}
return self::$container;
}
/**
* Create a container object
*
* @return Container
* @since 3.2.0
*/
protected static function createContainer(): Container
{
return (new Container())
->registerServiceProvider(new Database())
->registerServiceProvider(new Crypt())
->registerServiceProvider(new Server())
->registerServiceProvider(new Display());
}

View File

@ -0,0 +1,37 @@
{
"add_head": "1",
"add_licensing_template": "2",
"extends": "0",
"guid": "ec804df5-a384-48d7-b709-ae091ddc328a",
"implements": [
"caf33c5d-858c-4f9a-894f-ab302ec5445a"
],
"load_selection": null,
"name": "Factory",
"power_version": "1.0.0",
"system_name": "JCB.Package.Factory",
"type": "abstract class",
"use_selection": {
"use_selection0": {
"use": "4d8f38ef-8f3a-463d-8678-0bf087ac6815",
"as": "default"
},
"use_selection1": {
"use": "97c8b20c-a35d-47e7-b801-b9c54443e876",
"as": "default"
},
"use_selection2": {
"use": "42ceff0b-226d-42ff-9ffa-3d5935890337",
"as": "default"
},
"use_selection3": {
"use": "7d1aeda3-2598-46a6-bec2-7d4c5a65d99c",
"as": "default"
}
},
"namespace": "VDM\\Joomla\\Componentbuilder.Package.Factory",
"description": "Package Factory\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\\DI\\Container;",
"composer": ""
}

View File

@ -0,0 +1,79 @@
```
██████╗ ██████╗ ██╗ ██╗███████╗██████╗
██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗
██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝
██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
```
# class Insert (Details)
> namespace: **VDM\Joomla\Componentbuilder\Package\Database**
```uml
@startuml
class Insert #Gold {
# Config $config
# Table $table
# Model $model
# \JDatabaseDriver $db
+ __construct(?Config $config = null, ?Table $table = null, ...)
+ value(mixed $value, int $id, ...) : bool
+ item(object $item, ?string $table = null) : bool
+ items(?array $items, string $table = null) : bool
}
note right of Insert::__construct
Constructor
since: 3.2.0
arguments:
?Config $config = null
?Table $table = null
?Model $model = null
?\JDatabaseDriver $db = null
end note
note right of Insert::value
Set values to a given table
Example: $this->value(Value, 23, 'value_key', 'table_name');
since: 3.2.0
return: bool
arguments:
mixed $value
int $id
string $field
?string $table = null
end note
note right of Insert::item
Set values to a given table
Example: $this->item(Object, 23, 'table_name');
since: 3.2.0
return: bool
end note
note right of Insert::items
Set values to a given table
Example: $this->items(Array, 'table_name');
since: 3.2.0
return: bool
end note
@enduml
```
---
```
██╗ ██████╗██████╗
██║██╔════╝██╔══██╗
██║██║ ██████╔╝
██ ██║██║ ██╔══██╗
╚█████╔╝╚██████╗██████╔╝
╚════╝ ╚═════╝╚═════╝
```
> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder)

View File

@ -0,0 +1,187 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Package\Database;
use Joomla\CMS\Factory as JoomlaFactory;
use VDM\Joomla\Componentbuilder\Search\Factory;
use VDM\Joomla\Componentbuilder\Search\Config;
use VDM\Joomla\Componentbuilder\Table;
use VDM\Joomla\Componentbuilder\Search\Model\Insert as Model;
use VDM\Joomla\Utilities\ArrayHelper;
/**
* Package Database Insert
*
* @since 3.2.0
*/
class Insert
{
/**
* Search Config
*
* @var Config
* @since 3.2.0
*/
protected Config $config;
/**
* Search Table
*
* @var Table
* @since 3.2.0
*/
protected Table $table;
/**
* Search Model
*
* @var Model
* @since 3.2.0
*/
protected Model $model;
/**
* Database object to query local DB
*
* @var \JDatabaseDriver
* @since 3.2.0
**/
protected \JDatabaseDriver $db;
/**
* Constructor
*
* @param Config|null $config The search config object.
* @param Table|null $table The search table object.
* @param Model|null $model The search get model object.
* @param \JDatabaseDriver|null $db The database object.
*
* @since 3.2.0
*/
public function __construct(?Config $config = null, ?Table $table = null,
?Model $model = null, ?\JDatabaseDriver $db = null)
{
$this->config = $config ?: Factory::_('Config');
$this->table = $table ?: Factory::_('Table');
$this->model = $model ?: Factory::_('Set.Model');
$this->db = $db ?: JoomlaFactory::getDbo();
}
/**
* Set values to a given table
* Example: $this->value(Value, 23, 'value_key', 'table_name');
*
* @param mixed $value The field value
* @param int $id The item ID
* @param string $field The field key
* @param string|null $table The table
*
* @return bool
* @since 3.2.0
*/
public function value($value, int $id, string $field, ?string $table = null): bool
{
// load the table
if (empty($table))
{
$table = $this->config->table_name;
}
// check if this is a valid field and table
if ($id > 0 && ($name = $this->table->get($table, $field, 'name')) !== null)
{
// build the object
$item = new \stdClass();
$item->id = $id;
$item->{$name} = $this->model->value($value, $name, $table);
// Update the column of this table using id as the primary key.
return $this->db->updateObject('#__componentbuilder_' . $table, $item, 'id');
}
return false;
}
/**
* Set values to a given table
* Example: $this->item(Object, 23, 'table_name');
*
* @param object $item The item to save
* @param string|null $table The table
*
* @return bool
* @since 3.2.0
*/
public function item(object $item, ?string $table = null): bool
{
// load the table
if (empty($table))
{
$table = $this->config->table_name;
}
// check if this is a valid table
if (($fields = $this->table->fields($table)) !== null)
{
// model the item values
foreach ($fields as $field)
{
if (isset($item->{$field}))
{
$item->{$field} = $this->model->value($item->{$field}, $field, $table);
}
}
// Update the column of this table using id as the primary key.
return $this->db->updateObject('#__componentbuilder_' . $table, $item, 'id');
}
return false;
}
/**
* Set values to a given table
* Example: $this->items(Array, 'table_name');
*
* @param array|null $items The items being saved
* @param string|null $table The table
*
* @return bool
* @since 3.2.0
*/
public function items(?array $items, string $table = null): bool
{
// load the table
if (empty($table))
{
$table = $this->config->table_name;
}
// check if this is a valid table
if (ArrayHelper::check($items))
{
$success = true;
foreach ($items as $item)
{
if (!$this->item($item, $table))
{
$success = false;
break;
}
}
return $success;
}
return false;
}
}

View File

@ -0,0 +1,155 @@
/**
* Search Config
*
* @var Config
* @since 3.2.0
*/
protected Config $config;
/**
* Search Table
*
* @var Table
* @since 3.2.0
*/
protected Table $table;
/**
* Search Model
*
* @var Model
* @since 3.2.0
*/
protected Model $model;
/**
* Database object to query local DB
*
* @var \JDatabaseDriver
* @since 3.2.0
**/
protected \JDatabaseDriver $db;
/**
* Constructor
*
* @param Config|null $config The search config object.
* @param Table|null $table The search table object.
* @param Model|null $model The search get model object.
* @param \JDatabaseDriver|null $db The database object.
*
* @since 3.2.0
*/
public function __construct(?Config $config = null, ?Table $table = null,
?Model $model = null, ?\JDatabaseDriver $db = null)
{
$this->config = $config ?: Factory::_('Config');
$this->table = $table ?: Factory::_('Table');
$this->model = $model ?: Factory::_('Set.Model');
$this->db = $db ?: JoomlaFactory::getDbo();
}
/**
* Set values to a given table
* Example: $this->value(Value, 23, 'value_key', 'table_name');
*
* @param mixed $value The field value
* @param int $id The item ID
* @param string $field The field key
* @param string|null $table The table
*
* @return bool
* @since 3.2.0
*/
public function value($value, int $id, string $field, ?string $table = null): bool
{
// load the table
if (empty($table))
{
$table = $this->config->table_name;
}
// check if this is a valid field and table
if ($id > 0 && ($name = $this->table->get($table, $field, 'name')) !== null)
{
// build the object
$item = new \stdClass();
$item->id = $id;
$item->{$name} = $this->model->value($value, $name, $table);
// Update the column of this table using id as the primary key.
return $this->db->updateObject('#__componentbuilder_' . $table, $item, 'id');
}
return false;
}
/**
* Set values to a given table
* Example: $this->item(Object, 23, 'table_name');
*
* @param object $item The item to save
* @param string|null $table The table
*
* @return bool
* @since 3.2.0
*/
public function item(object $item, ?string $table = null): bool
{
// load the table
if (empty($table))
{
$table = $this->config->table_name;
}
// check if this is a valid table
if (($fields = $this->table->fields($table)) !== null)
{
// model the item values
foreach ($fields as $field)
{
if (isset($item->{$field}))
{
$item->{$field} = $this->model->value($item->{$field}, $field, $table);
}
}
// Update the column of this table using id as the primary key.
return $this->db->updateObject('#__componentbuilder_' . $table, $item, 'id');
}
return false;
}
/**
* Set values to a given table
* Example: $this->items(Array, 'table_name');
*
* @param array|null $items The items being saved
* @param string|null $table The table
*
* @return bool
* @since 3.2.0
*/
public function items(?array $items, string $table = null): bool
{
// load the table
if (empty($table))
{
$table = $this->config->table_name;
}
// check if this is a valid table
if (ArrayHelper::check($items))
{
$success = true;
foreach ($items as $item)
{
if (!$this->item($item, $table))
{
$success = false;
break;
}
}
return $success;
}
return false;
}

View File

@ -0,0 +1,39 @@
{
"add_head": "1",
"add_licensing_template": "2",
"extends": "0",
"guid": "f68aafc4-beec-4bf0-b528-4e2c525f5b7b",
"implements": null,
"load_selection": null,
"name": "Insert",
"power_version": "1.0.0",
"system_name": "JCB.Package.Database.Insert",
"type": "class",
"use_selection": {
"use_selection0": {
"use": "01a89ba8-f8bb-435c-93de-0a8f3fa9432a",
"as": "default"
},
"use_selection1": {
"use": "6e2ca779-f70e-4871-a138-0ee5eaec6a97",
"as": "default"
},
"use_selection2": {
"use": "bfd1d6d5-56c1-4fe9-9fee-1c5910e1f5d8",
"as": "default"
},
"use_selection3": {
"use": "02efe40a-7792-4c82-9444-7d0377243483",
"as": "Model"
},
"use_selection4": {
"use": "0a59c65c-9daf-4bc9-baf4-e063ff9e6a8a",
"as": "default"
}
},
"namespace": "VDM\\Joomla\\Componentbuilder.Package.Database.Insert",
"description": "Package Database Insert\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": ""
}

62
super-powers.json Normal file
View File

@ -0,0 +1,62 @@
{
"12234620-f54f-4914-a51a-24f5707cb8a6": {
"name": "Load",
"type": "class",
"namespace": "VDM\\Joomla\\Componentbuilder\\Package\\Database",
"code": "src\/12234620-f54f-4914-a51a-24f5707cb8a6\/code.php",
"power": "src\/12234620-f54f-4914-a51a-24f5707cb8a6\/code.power",
"settings": "src\/12234620-f54f-4914-a51a-24f5707cb8a6\/settings.json",
"path": "src\/12234620-f54f-4914-a51a-24f5707cb8a6",
"guid": "12234620-f54f-4914-a51a-24f5707cb8a6"
},
"f68aafc4-beec-4bf0-b528-4e2c525f5b7b": {
"name": "Insert",
"type": "class",
"namespace": "VDM\\Joomla\\Componentbuilder\\Package\\Database",
"code": "src\/f68aafc4-beec-4bf0-b528-4e2c525f5b7b\/code.php",
"power": "src\/f68aafc4-beec-4bf0-b528-4e2c525f5b7b\/code.power",
"settings": "src\/f68aafc4-beec-4bf0-b528-4e2c525f5b7b\/settings.json",
"path": "src\/f68aafc4-beec-4bf0-b528-4e2c525f5b7b",
"guid": "f68aafc4-beec-4bf0-b528-4e2c525f5b7b"
},
"97c8b20c-a35d-47e7-b801-b9c54443e876": {
"name": "Database",
"type": "class",
"namespace": "VDM\\Joomla\\Componentbuilder\\Package\\Service",
"code": "src\/97c8b20c-a35d-47e7-b801-b9c54443e876\/code.php",
"power": "src\/97c8b20c-a35d-47e7-b801-b9c54443e876\/code.power",
"settings": "src\/97c8b20c-a35d-47e7-b801-b9c54443e876\/settings.json",
"path": "src\/97c8b20c-a35d-47e7-b801-b9c54443e876",
"guid": "97c8b20c-a35d-47e7-b801-b9c54443e876"
},
"2e64007d-acac-438c-b719-3e1875784f47": {
"name": "Details",
"type": "class",
"namespace": "VDM\\Joomla\\Componentbuilder\\Package\\Display",
"code": "src\/2e64007d-acac-438c-b719-3e1875784f47\/code.php",
"power": "src\/2e64007d-acac-438c-b719-3e1875784f47\/code.power",
"settings": "src\/2e64007d-acac-438c-b719-3e1875784f47\/settings.json",
"path": "src\/2e64007d-acac-438c-b719-3e1875784f47",
"guid": "2e64007d-acac-438c-b719-3e1875784f47"
},
"7d1aeda3-2598-46a6-bec2-7d4c5a65d99c": {
"name": "Display",
"type": "class",
"namespace": "VDM\\Joomla\\Componentbuilder\\Package\\Service",
"code": "src\/7d1aeda3-2598-46a6-bec2-7d4c5a65d99c\/code.php",
"power": "src\/7d1aeda3-2598-46a6-bec2-7d4c5a65d99c\/code.power",
"settings": "src\/7d1aeda3-2598-46a6-bec2-7d4c5a65d99c\/settings.json",
"path": "src\/7d1aeda3-2598-46a6-bec2-7d4c5a65d99c",
"guid": "7d1aeda3-2598-46a6-bec2-7d4c5a65d99c"
},
"ec804df5-a384-48d7-b709-ae091ddc328a": {
"name": "Factory",
"type": "abstract class",
"namespace": "VDM\\Joomla\\Componentbuilder\\Package",
"code": "src\/ec804df5-a384-48d7-b709-ae091ddc328a\/code.php",
"power": "src\/ec804df5-a384-48d7-b709-ae091ddc328a\/code.power",
"settings": "src\/ec804df5-a384-48d7-b709-ae091ddc328a\/settings.json",
"path": "src\/ec804df5-a384-48d7-b709-ae091ddc328a",
"guid": "ec804df5-a384-48d7-b709-ae091ddc328a"
}
}