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