Release of v5.1.1-alpha5
Refactor initialization flow to accommodate future scalability and integration with all designated areas. Refactor the Creator Builders class. Refactor the FieldString and FieldXML classes.
This commit is contained in:
@@ -109,35 +109,47 @@ final class Response
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the error message from the return object
|
||||
* Extract an error message from a response object.
|
||||
*
|
||||
* @param JoomlaResponse $response The response.
|
||||
* @param JoomlaResponse $response The response object.
|
||||
*
|
||||
* @return string
|
||||
* @return string The extracted error message, or an empty string.
|
||||
* @since 3.2.0
|
||||
**/
|
||||
*/
|
||||
protected function error($response): string
|
||||
{
|
||||
// do we have a json string
|
||||
if (isset($response->body) && JsonHelper::check($response->body))
|
||||
// JSON decode helpers
|
||||
$decodeJson = static fn($value) => JsonHelper::check($value) ? json_decode($value, true) : null;
|
||||
$decodeJsonObject = static fn($value) => JsonHelper::check($value) ? json_decode($value) : null;
|
||||
|
||||
// Try decoding from body
|
||||
if (!empty($response->body))
|
||||
{
|
||||
$error = json_decode($response->body);
|
||||
}
|
||||
else
|
||||
{
|
||||
return '';
|
||||
$errorData = $decodeJsonObject($response->body);
|
||||
|
||||
if (is_object($errorData))
|
||||
{
|
||||
return $errorData->error ?? $errorData->message ?? '';
|
||||
}
|
||||
}
|
||||
|
||||
// check
|
||||
if (isset($error->error))
|
||||
// Try decoding from errors
|
||||
if (!empty($response->errors))
|
||||
{
|
||||
return $error->error;
|
||||
}
|
||||
elseif (isset($error->message))
|
||||
{
|
||||
return $error->message;
|
||||
$errorArray = $decodeJson($response->errors);
|
||||
|
||||
if (is_array($errorArray))
|
||||
{
|
||||
if (!empty($response->message) && StringHelper::check($response->message))
|
||||
{
|
||||
array_unshift($errorArray, $response->message);
|
||||
}
|
||||
|
||||
return implode("\n", $errorArray);
|
||||
}
|
||||
}
|
||||
|
||||
// Fallback
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
@@ -16,9 +16,10 @@ use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\Filesystem\Folder;
|
||||
use Joomla\CMS\Application\CMSApplication;
|
||||
use VDM\Joomla\Gitea\Repository\Contents;
|
||||
use VDM\Joomla\Interfaces\Git\ApiInterface as Api;
|
||||
use VDM\Joomla\Interfaces\Remote\ConfigInterface as Config;
|
||||
use VDM\Joomla\Interfaces\Git\Repository\ContentsInterface as Contents;
|
||||
use VDM\Joomla\Componentbuilder\Network\Resolve;
|
||||
use VDM\Joomla\Interfaces\Git\ApiInterface as Api;
|
||||
use VDM\Joomla\Utilities\FileHelper;
|
||||
use VDM\Joomla\Utilities\JsonHelper;
|
||||
use VDM\Joomla\Interfaces\GrepInterface;
|
||||
@@ -27,9 +28,9 @@ use VDM\Joomla\Interfaces\GrepInterface;
|
||||
/**
|
||||
* Global Resource Empowerment Platform
|
||||
*
|
||||
* The Grep feature will try to find your power in the repositories listed in the global
|
||||
* Options of JCB in the super powers tab, and if it can't be found there will try the global core
|
||||
* Super powers of JCB. All searches are performed according the [algorithm:cascading]
|
||||
* The Grep feature will try to find your power in the repositories
|
||||
* linked to this [area], and if it can't be found there will try the global core
|
||||
* Super Powers of JCB. All searches are performed according the [algorithm:cascading]
|
||||
* See documentation for more details: https://git.vdm.dev/joomla/super-powers/wiki
|
||||
*
|
||||
* @since 3.2.1
|
||||
@@ -60,14 +61,6 @@ abstract class Grep implements GrepInterface
|
||||
**/
|
||||
protected ?string $target = null;
|
||||
|
||||
/**
|
||||
* Order of global search
|
||||
*
|
||||
* @var array
|
||||
* @since 3.2.1
|
||||
**/
|
||||
protected array $order = ['local', 'remote'];
|
||||
|
||||
/**
|
||||
* The target branch field name ['read_branch', 'write_branch']
|
||||
*
|
||||
@@ -76,6 +69,14 @@ abstract class Grep implements GrepInterface
|
||||
**/
|
||||
protected string $branch_field = 'read_branch';
|
||||
|
||||
/**
|
||||
* Order of global search
|
||||
*
|
||||
* @var array
|
||||
* @since 3.2.1
|
||||
**/
|
||||
protected array $order = ['local', 'remote'];
|
||||
|
||||
/**
|
||||
* The target default branch name
|
||||
*
|
||||
@@ -84,14 +85,6 @@ abstract class Grep implements GrepInterface
|
||||
**/
|
||||
protected ?string $branch_name = null;
|
||||
|
||||
/**
|
||||
* The index file path
|
||||
*
|
||||
* @var string
|
||||
* @since 3.2.2
|
||||
*/
|
||||
protected string $index_path = 'index.json';
|
||||
|
||||
/**
|
||||
* The VDM global API base
|
||||
*
|
||||
@@ -116,6 +109,14 @@ abstract class Grep implements GrepInterface
|
||||
*/
|
||||
protected Resolve $resolve;
|
||||
|
||||
/**
|
||||
* The ConfigInterface Class.
|
||||
*
|
||||
* @var Config
|
||||
* @since 5.1.1
|
||||
*/
|
||||
protected Config $config;
|
||||
|
||||
/**
|
||||
* Joomla Application object
|
||||
*
|
||||
@@ -127,24 +128,26 @@ abstract class Grep implements GrepInterface
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param Contents $contents The Gitea Repository Contents object.
|
||||
* @param Resolve $resolve The Resolve Class.
|
||||
* @param array $paths The approved paths
|
||||
* @param string|null $path The local path
|
||||
* @param CMSApplication|null $app The CMS Application object.
|
||||
* @param Config $config The Config Class.
|
||||
* @param Contents $contents The Contents Class.
|
||||
* @param Resolve $resolve The Resolve Class.
|
||||
* @param array $paths The approved paths
|
||||
* @param string|null $path The local path
|
||||
* @param CMSApplication|null $app The Application Class.
|
||||
*
|
||||
* @throws \Exception
|
||||
* @since 3.2.0
|
||||
* @since 3.2.1
|
||||
*/
|
||||
public function __construct(
|
||||
Contents $contents, Resolve $resolve,
|
||||
array $paths, ?string $path = null,
|
||||
public function __construct(Config $config, Contents $contents,
|
||||
Resolve $resolve, array $paths, ?string $path = null,
|
||||
?CMSApplication $app = null)
|
||||
{
|
||||
$this->config = $config;
|
||||
$this->contents = $contents;
|
||||
$this->resolve = $resolve;
|
||||
|
||||
$this->paths = $paths;
|
||||
$this->path = $path;
|
||||
|
||||
$this->app = $app ?: Factory::getApplication();
|
||||
|
||||
$this->initializeInstances();
|
||||
@@ -172,6 +175,146 @@ abstract class Grep implements GrepInterface
|
||||
return $this->searchAllRepos($guid, $order);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the path/repo object
|
||||
*
|
||||
* @param string $guid The target repository guid.
|
||||
*
|
||||
* @return object|null
|
||||
* @since 5.1.1
|
||||
*/
|
||||
public function getPath(string $guid): ?object
|
||||
{
|
||||
if (!is_array($this->paths) || $this->paths === [] || empty($guid))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
foreach ($this->paths as $path)
|
||||
{
|
||||
if (!isset($path->guid) || $guid !== $path->guid)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
return $path;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all the available repos
|
||||
*
|
||||
* @return array|null
|
||||
* @since 5.1.1
|
||||
*/
|
||||
public function getPaths(): ?array
|
||||
{
|
||||
if (!is_array($this->paths) || $this->paths === [])
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return $this->paths;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all paths + indexes (the active set)
|
||||
*
|
||||
* @return array|null
|
||||
* @since 5.1.1
|
||||
*/
|
||||
public function getPathsIndexes(): ?array
|
||||
{
|
||||
if (!is_array($this->paths) || $this->paths === [])
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
$powers = [];
|
||||
foreach ($this->paths as $path)
|
||||
{
|
||||
// Get remote index
|
||||
$this->indexRemote($path);
|
||||
|
||||
if (isset($path->index) && is_object($path->index))
|
||||
{
|
||||
$powers[] = $path;
|
||||
}
|
||||
}
|
||||
|
||||
return $powers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the a path + indexes
|
||||
*
|
||||
* @param string $guid The unique identifier for the repo.
|
||||
*
|
||||
* @return object|null
|
||||
* @since 5.1.1
|
||||
*/
|
||||
public function getPathIndexes(string $guid): ?object
|
||||
{
|
||||
if (!is_array($this->paths) || $this->paths === [] || empty($guid))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
foreach ($this->paths as $path)
|
||||
{
|
||||
if (!isset($path->guid) || $guid !== $path->guid)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// Get remote index
|
||||
$this->indexRemote($path);
|
||||
|
||||
if (isset($path->index) && is_object($path->index))
|
||||
{
|
||||
return $path;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the index of a repo
|
||||
*
|
||||
* @param string $guid The unique identifier for the repo.
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.2
|
||||
*/
|
||||
public function getRemoteIndex(string $guid): ?object
|
||||
{
|
||||
if (!is_array($this->paths) || $this->paths === [] || empty($guid))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
foreach ($this->paths as $path)
|
||||
{
|
||||
if (!isset($path->guid) || $guid !== $path->guid)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// Get remote index
|
||||
$this->indexRemote($path);
|
||||
|
||||
if (isset($path->index) && is_object($path->index))
|
||||
{
|
||||
return $path->index;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if an item exists in any repo or in a specific repo.
|
||||
*
|
||||
@@ -194,34 +337,6 @@ abstract class Grep implements GrepInterface
|
||||
return $this->itemExistsInAllRepos($guid, $order);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all remote GUID's
|
||||
*
|
||||
* @return array|null
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function getRemoteGuid(): ?array
|
||||
{
|
||||
if (!is_array($this->paths) || $this->paths === [])
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
$powers = [];
|
||||
foreach ($this->paths as $path)
|
||||
{
|
||||
// Get remote index
|
||||
$this->indexRemote($path);
|
||||
|
||||
if (isset($path->index) && is_object($path->index))
|
||||
{
|
||||
$powers = array_merge($powers, array_keys((array) $path->index));
|
||||
}
|
||||
}
|
||||
|
||||
return empty($powers) ? null : array_unique($powers);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the branch field
|
||||
*
|
||||
@@ -258,41 +373,7 @@ abstract class Grep implements GrepInterface
|
||||
*/
|
||||
public function setIndexPath(string $indexPath): void
|
||||
{
|
||||
$this->index_path = $indexPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the index of a repo
|
||||
*
|
||||
* @param string $guid The unique identifier for the repo.
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.2
|
||||
*/
|
||||
public function getRemoteIndex(string $guid): ?object
|
||||
{
|
||||
if (!is_array($this->paths) || $this->paths === [] || empty($guid))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
foreach ($this->paths as $path)
|
||||
{
|
||||
if (!isset($path->guid) || $guid !== $path->guid)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// Get remote index
|
||||
$this->indexRemote($path);
|
||||
|
||||
if (isset($path->index) && is_object($path->index))
|
||||
{
|
||||
return $path->index;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
$this->config->setIndexPath($indexPath);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -506,7 +587,29 @@ abstract class Grep implements GrepInterface
|
||||
*/
|
||||
protected function getIndexPath(): string
|
||||
{
|
||||
return $this->index_path;
|
||||
return $this->config->getIndexPath();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the settings path
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.2
|
||||
*/
|
||||
protected function getSettingsPath(): string
|
||||
{
|
||||
return $this->config->getSettingsPath();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get GUID field
|
||||
*
|
||||
* @return string
|
||||
* @since 5.1.1
|
||||
*/
|
||||
protected function getGuidField(): string
|
||||
{
|
||||
return $this->config->getGuidField();
|
||||
}
|
||||
|
||||
/**
|
||||
|
411
libraries/vendor_jcb/VDM.Joomla/src/Abstraction/Remote/Base.php
Normal file
411
libraries/vendor_jcb/VDM.Joomla/src/Abstraction/Remote/Base.php
Normal file
@@ -0,0 +1,411 @@
|
||||
<?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\Abstraction\Remote;
|
||||
|
||||
|
||||
use VDM\Joomla\Interfaces\Remote\ConfigInterface as Config;
|
||||
use VDM\Joomla\Interfaces\Remote\BaseInterface;
|
||||
|
||||
|
||||
/**
|
||||
* Remote Base Shared by get and set methods
|
||||
*
|
||||
* @since 5.1.1
|
||||
*/
|
||||
abstract class Base implements BaseInterface
|
||||
{
|
||||
/**
|
||||
* The Base Configure Class.
|
||||
*
|
||||
* @var Config
|
||||
* @since 5.1.1
|
||||
*/
|
||||
protected Config $config;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param Config $config The configure class.
|
||||
*
|
||||
* @since 5.1.1
|
||||
*/
|
||||
public function __construct(Config $config)
|
||||
{
|
||||
$this->config = $config;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the current active table
|
||||
*
|
||||
* @param string $table The table that should be active
|
||||
*
|
||||
* @return self
|
||||
* @since 3.2.2
|
||||
*/
|
||||
public function table(string $table): self
|
||||
{
|
||||
$this->config->table($table);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current active table
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.2
|
||||
*/
|
||||
public function getTable(): string
|
||||
{
|
||||
return $this->config->getTable();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the current active area
|
||||
*
|
||||
* @param string $area The area that should be active
|
||||
*
|
||||
* @return self
|
||||
* @since 3.2.2
|
||||
*/
|
||||
public function area(string $area): self
|
||||
{
|
||||
$this->config->area($area);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current active area
|
||||
*
|
||||
* @return string|null
|
||||
* @since 3.2.2
|
||||
*/
|
||||
public function getArea(): ?string
|
||||
{
|
||||
return $this->config->getArea();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the settings path
|
||||
*
|
||||
* @param string $settingsPath The repository settings path
|
||||
*
|
||||
* @return self
|
||||
* @since 3.2.2
|
||||
*/
|
||||
public function setSettingsPath(string $settingsPath): self
|
||||
{
|
||||
$this->config->setSettingsPath($settingsPath);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the settings path
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.2
|
||||
*/
|
||||
public function getSettingsPath(): string
|
||||
{
|
||||
return $this->config->getSettingsPath();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the index path
|
||||
*
|
||||
* @param string $indexPath The repository index path
|
||||
*
|
||||
* @return void
|
||||
* @since 3.2.2
|
||||
*/
|
||||
public function setIndexPath(string $indexPath): void
|
||||
{
|
||||
$this->config->setIndexPath($indexPath);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the index path
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.2
|
||||
*/
|
||||
public function getIndexPath(): string
|
||||
{
|
||||
return $this->config->getIndexPath();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get core placeholders
|
||||
*
|
||||
* @return array
|
||||
* @since 5.1.1
|
||||
*/
|
||||
public function getPlaceholders(): array
|
||||
{
|
||||
return $this->config->getPlaceholders();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get index map
|
||||
*
|
||||
* @return array
|
||||
* @since 5.1.1
|
||||
*/
|
||||
public function getIndexMap(): array
|
||||
{
|
||||
return $this->config->getIndexMap();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get index header
|
||||
*
|
||||
* @return array
|
||||
* @since 5.1.1
|
||||
*/
|
||||
public function getIndexHeader(): array
|
||||
{
|
||||
return $this->config->getIndexHeader();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get src path
|
||||
*
|
||||
* @return string
|
||||
* @since 5.1.1
|
||||
*/
|
||||
public function getSrcPath(): string
|
||||
{
|
||||
return $this->config->getSrcPath();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get map
|
||||
*
|
||||
* @return array
|
||||
* @since 5.1.1
|
||||
*/
|
||||
public function getMap(): array
|
||||
{
|
||||
return $this->config->getMap();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the table title name field
|
||||
*
|
||||
* @return string
|
||||
* @since 5.1.1
|
||||
*/
|
||||
public function getTitleName(): string
|
||||
{
|
||||
return $this->config->getTitleName();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get GUID field
|
||||
*
|
||||
* @return string
|
||||
* @since 5.1.1
|
||||
*/
|
||||
public function getGuidField(): string
|
||||
{
|
||||
return $this->config->getGuidField();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get main readme path
|
||||
*
|
||||
* @return string
|
||||
* @since 5.1.1
|
||||
*/
|
||||
public function getMainReadmePath(): string
|
||||
{
|
||||
return $this->config->getMainReadmePath();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Prefix Key
|
||||
*
|
||||
* @return string
|
||||
* @since 5.1.1
|
||||
*/
|
||||
public function getPrefixKey(): string
|
||||
{
|
||||
return $this->config->getPrefixKey();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Suffix Key
|
||||
*
|
||||
* @return string
|
||||
* @since 5.1.1
|
||||
*/
|
||||
public function getSuffixKey(): string
|
||||
{
|
||||
return $this->config->getSuffixKey();
|
||||
}
|
||||
|
||||
/**
|
||||
* Map a single item to its properties
|
||||
*
|
||||
* @param object $item The item to be mapped
|
||||
*
|
||||
* @return object
|
||||
* @since 3.2.2
|
||||
*/
|
||||
public function mapItem(object $item): object
|
||||
{
|
||||
$power = [];
|
||||
$mapper = $this->getMap();
|
||||
foreach ($mapper as $key => $map)
|
||||
{
|
||||
$methodName = "mapItemValue_{$key}";
|
||||
if (method_exists($this, $methodName))
|
||||
{
|
||||
$this->{$methodName}($item, $power);
|
||||
}
|
||||
else
|
||||
{
|
||||
$power[$key] = $item->{$map} ?? null;
|
||||
}
|
||||
}
|
||||
|
||||
return (object) $power;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get index values
|
||||
*
|
||||
* @param object $item The item
|
||||
*
|
||||
* @return array|null
|
||||
* @since 3.2.2
|
||||
*/
|
||||
public function getIndexItem(object $item): ?array
|
||||
{
|
||||
$index_map = $this->getIndexMap();
|
||||
if (empty($index_map))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
$index_item = [];
|
||||
foreach ($index_map as $key => $function_name)
|
||||
{
|
||||
if (method_exists($this, $function_name))
|
||||
{
|
||||
$index_item[$key] = $this->{$function_name}($item);
|
||||
}
|
||||
}
|
||||
|
||||
return $index_item ?? null;
|
||||
}
|
||||
|
||||
//// index_map_ (area) /////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* Get the item name for the index values
|
||||
*
|
||||
* @param object $item
|
||||
*
|
||||
* @return string|null
|
||||
* @since 3.2.2
|
||||
*/
|
||||
protected function index_map_IndexName(object $item): ?string
|
||||
{
|
||||
$field = $this->getTitleName();
|
||||
return $item->{$field} ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the item Short Description for the index values
|
||||
*
|
||||
* @param object $item
|
||||
*
|
||||
* @return string|null
|
||||
* @since 5.0.3
|
||||
*/
|
||||
protected function index_map_ShortDescription(object $item): ?string
|
||||
{
|
||||
return $item->short_description ?? $item->description ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the item settings path for the index values
|
||||
*
|
||||
* @param object $item
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.2
|
||||
*/
|
||||
protected function index_map_IndexSettingsPath(object $item): string
|
||||
{
|
||||
$src_path = $this->getSrcPath();
|
||||
$settings_path = $this->getSettingsPath();
|
||||
|
||||
$key = $this->index_map_IndexGUID($item);
|
||||
|
||||
return "{$src_path}/{$key}/{$settings_path}";
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the item path for the index values
|
||||
*
|
||||
* @param object $item
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.2
|
||||
*/
|
||||
protected function index_map_IndexPath(object $item): string
|
||||
{
|
||||
$src_path = $this->getSrcPath();
|
||||
|
||||
$key = $this->index_map_IndexGUID($item);
|
||||
|
||||
return "{$src_path}/{$key}";
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the item [POWER KEY] for the index values
|
||||
*
|
||||
* @param object $item
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.2
|
||||
*/
|
||||
protected function index_map_IndexKey(object $item): string
|
||||
{
|
||||
$prefix_key = $this->getPrefixKey();
|
||||
$suffix_key = $this->getSuffixKey();
|
||||
|
||||
$key = $this->index_map_IndexGUID($item);
|
||||
$key = str_replace('-', '_', $key);
|
||||
|
||||
return "{$prefix_key}{$key}{$suffix_key}";
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the item GUID for the index values
|
||||
*
|
||||
* @param object $item
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.2
|
||||
*/
|
||||
protected function index_map_IndexGUID(object $item): string
|
||||
{
|
||||
$guid_field = $this->getGuidField();
|
||||
return $item->{$guid_field} ?? 'error';
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,417 @@
|
||||
<?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\Abstraction\Remote;
|
||||
|
||||
|
||||
use VDM\Joomla\Componentbuilder\Power\Interfaces\TableInterface as Table;
|
||||
use VDM\Joomla\Interfaces\Remote\ConfigInterface;
|
||||
|
||||
|
||||
/**
|
||||
* Remote Base Config Shared by get and set methods
|
||||
*
|
||||
* @since 5.2.1
|
||||
*/
|
||||
abstract class Config implements ConfigInterface
|
||||
{
|
||||
/**
|
||||
* The Table Class.
|
||||
*
|
||||
* @var Table
|
||||
* @since 5.2.1
|
||||
*/
|
||||
protected Table $core;
|
||||
|
||||
/**
|
||||
* Table Name
|
||||
*
|
||||
* @var string
|
||||
* @since 3.2.1
|
||||
*/
|
||||
protected string $table;
|
||||
|
||||
/**
|
||||
* Area Name
|
||||
*
|
||||
* @var string|null
|
||||
* @since 3.2.2
|
||||
*/
|
||||
protected ?string $area = null;
|
||||
|
||||
/**
|
||||
* Prefix Key
|
||||
*
|
||||
* @var string
|
||||
* @since 3.2.2
|
||||
*/
|
||||
protected string $prefix_key = 'Super---';
|
||||
|
||||
/**
|
||||
* Suffix Key
|
||||
*
|
||||
* @var string
|
||||
* @since 3.2.2
|
||||
*/
|
||||
protected string $suffix_key = '---Power';
|
||||
|
||||
/**
|
||||
* The main readme file path
|
||||
*
|
||||
* @var string
|
||||
* @since 5.2.1
|
||||
*/
|
||||
protected string $main_readme_path = 'README.md';
|
||||
|
||||
/**
|
||||
* The index file path (index of all items)
|
||||
*
|
||||
* @var string
|
||||
* @since 3.2.2
|
||||
*/
|
||||
protected string $index_path = 'index.json';
|
||||
|
||||
/**
|
||||
* The item (files) source path
|
||||
*
|
||||
* @var string
|
||||
* @since 5.2.1
|
||||
*/
|
||||
protected string $src_path = 'src';
|
||||
|
||||
/**
|
||||
* The item settings file path (item data)
|
||||
*
|
||||
* @var string
|
||||
* @since 3.2.2
|
||||
*/
|
||||
protected string $settings_path = 'item.json';
|
||||
|
||||
/**
|
||||
* The item guid=unique field
|
||||
*
|
||||
* @var string
|
||||
* @since 5.2.1
|
||||
*/
|
||||
protected string $guid_field = 'guid';
|
||||
|
||||
/**
|
||||
* The ignore fields
|
||||
*
|
||||
* @var array
|
||||
* @since 5.2.1
|
||||
*/
|
||||
protected array $ignore = [];
|
||||
|
||||
/**
|
||||
* The item map
|
||||
*
|
||||
* @var array
|
||||
* @since 3.2.2
|
||||
*/
|
||||
protected array $map = [];
|
||||
|
||||
/**
|
||||
* The index map
|
||||
* must always have: [name,path,guid]
|
||||
* you can add more
|
||||
*
|
||||
* @var array
|
||||
* @since 5.0.3
|
||||
*/
|
||||
protected array $index_map = [
|
||||
'name' => 'index_map_IndexName',
|
||||
'path' => 'index_map_IndexPath',
|
||||
'guid' => 'index_map_IndexGUID'
|
||||
];
|
||||
|
||||
/**
|
||||
* The index header
|
||||
* mapping the index map to a table
|
||||
* must always have: [name,path,guid,local]
|
||||
* with [name] always first
|
||||
* with [path,guid,local] always last
|
||||
* you can add more in between
|
||||
*
|
||||
* @var array
|
||||
* @since 5.2.1
|
||||
*/
|
||||
protected array $index_header = [
|
||||
'name',
|
||||
'path',
|
||||
'guid',
|
||||
'local'
|
||||
];
|
||||
|
||||
/**
|
||||
* Core Placeholders
|
||||
*
|
||||
* @var array
|
||||
* @since 5.0.3
|
||||
*/
|
||||
protected array $placeholders = [
|
||||
'[['.'[NamespacePrefix]]]' => 'VDM',
|
||||
'[['.'[ComponentNamespace]]]' => 'Componentbuilder',
|
||||
'[['.'[Component]]]' => 'Componentbuilder',
|
||||
'[['.'[component]]]' => 'componentbuilder'
|
||||
];
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param Table $core The Core Table Class.
|
||||
*
|
||||
* @since 5.2.1
|
||||
*/
|
||||
public function __construct(Table $core)
|
||||
{
|
||||
$this->core = $core;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get core placeholders
|
||||
*
|
||||
* @return array
|
||||
* @since 5.2.1
|
||||
*/
|
||||
public function getPlaceholders(): array
|
||||
{
|
||||
return $this->placeholders;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the current active table
|
||||
*
|
||||
* @param string $table The table that should be active
|
||||
*
|
||||
* @return self
|
||||
* @since 3.2.2
|
||||
*/
|
||||
public function table(string $table): self
|
||||
{
|
||||
$this->table = $table;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current active table
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.2
|
||||
*/
|
||||
public function getTable(): string
|
||||
{
|
||||
return $this->table;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the current active area
|
||||
*
|
||||
* @param string $area The area that should be active
|
||||
*
|
||||
* @return self
|
||||
* @since 3.2.2
|
||||
*/
|
||||
public function area(string $area): self
|
||||
{
|
||||
$this->area = ucfirst(str_replace('_', ' ', $area));
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current active area
|
||||
*
|
||||
* @return string|null
|
||||
* @since 3.2.2
|
||||
*/
|
||||
public function getArea(): ?string
|
||||
{
|
||||
return $this->area;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the settings path
|
||||
*
|
||||
* @param string $settingsPath The repository settings path
|
||||
*
|
||||
* @return self
|
||||
* @since 3.2.2
|
||||
*/
|
||||
public function setSettingsPath(string $settingsPath): self
|
||||
{
|
||||
$this->settings_path = $settingsPath;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the settings path
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.2
|
||||
*/
|
||||
public function getSettingsPath(): string
|
||||
{
|
||||
return $this->settings_path;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the index path
|
||||
*
|
||||
* @param string $indexPath The repository index path
|
||||
*
|
||||
* @return void
|
||||
* @since 3.2.2
|
||||
*/
|
||||
public function setIndexPath(string $indexPath): void
|
||||
{
|
||||
$this->index_path = $indexPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the index path
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.2
|
||||
*/
|
||||
public function getIndexPath(): string
|
||||
{
|
||||
return $this->index_path;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get index map
|
||||
*
|
||||
* @return array
|
||||
* @since 5.2.1
|
||||
*/
|
||||
public function getIndexMap(): array
|
||||
{
|
||||
return $this->index_map;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get index header
|
||||
*
|
||||
* @return array
|
||||
* @since 5.2.1
|
||||
*/
|
||||
public function getIndexHeader(): array
|
||||
{
|
||||
return $this->index_header;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get src path
|
||||
*
|
||||
* @return string
|
||||
* @since 5.2.1
|
||||
*/
|
||||
public function getSrcPath(): string
|
||||
{
|
||||
return $this->src_path;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get main readme path
|
||||
*
|
||||
* @return string
|
||||
* @since 5.2.1
|
||||
*/
|
||||
public function getMainReadmePath(): string
|
||||
{
|
||||
return $this->main_readme_path;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get map
|
||||
*
|
||||
* Builds (and caches) an associative map of the table’s field names,
|
||||
* automatically removing any fields defined in $this->ignore.
|
||||
*
|
||||
* @return array Associative array in the form ['field' => 'field']
|
||||
* @since 5.2.1
|
||||
*/
|
||||
public function getMap(): array
|
||||
{
|
||||
// Only build once – cached in $this->map.
|
||||
if (empty($this->map))
|
||||
{
|
||||
// Fetch raw field list from the core service.
|
||||
$map = $this->core->fields($this->getTable());
|
||||
|
||||
if ($map)
|
||||
{
|
||||
// Ensure $this->ignore is an array; default to empty otherwise.
|
||||
$ignore = is_array($this->ignore ?? null) ? $this->ignore : [];
|
||||
|
||||
// Remove ignored fields, preserving the original order.
|
||||
$map = array_values(array_diff($map, $ignore));
|
||||
|
||||
// Convert to the required ['field' => 'field'] structure.
|
||||
$this->map = array_combine($map, $map);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->map = [];
|
||||
}
|
||||
}
|
||||
|
||||
return $this->map;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the table title name field
|
||||
*
|
||||
* @return string
|
||||
* @since 5.2.1
|
||||
*/
|
||||
public function getTitleName(): string
|
||||
{
|
||||
return $this->core->titleName($this->getTable());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get GUID field
|
||||
*
|
||||
* @return string
|
||||
* @since 5.2.1
|
||||
*/
|
||||
public function getGuidField(): string
|
||||
{
|
||||
return $this->guid_field;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Prefix Key
|
||||
*
|
||||
* @return string
|
||||
* @since 5.2.1
|
||||
*/
|
||||
public function getPrefixKey(): string
|
||||
{
|
||||
return $this->prefix_key;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Suffix Key
|
||||
*
|
||||
* @return string
|
||||
* @since 5.2.1
|
||||
*/
|
||||
public function getSuffixKey(): string
|
||||
{
|
||||
return $this->suffix_key;
|
||||
}
|
||||
}
|
||||
|
@@ -12,9 +12,11 @@
|
||||
namespace VDM\Joomla\Abstraction\Remote;
|
||||
|
||||
|
||||
use VDM\Joomla\Interfaces\Remote\ConfigInterface as Config;
|
||||
use VDM\Joomla\Interfaces\GrepInterface as Grep;
|
||||
use VDM\Joomla\Interfaces\Data\ItemInterface as Item;
|
||||
use VDM\Joomla\Interfaces\Remote\GetInterface;
|
||||
use VDM\Joomla\Abstraction\Remote\Base;
|
||||
|
||||
|
||||
/**
|
||||
@@ -22,13 +24,13 @@ use VDM\Joomla\Interfaces\Remote\GetInterface;
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
abstract class Get implements GetInterface
|
||||
abstract class Get extends Base implements GetInterface
|
||||
{
|
||||
/**
|
||||
* The Grep Class.
|
||||
*
|
||||
* @var Grep
|
||||
* @since 3.2.0
|
||||
* @since 3.2.2
|
||||
*/
|
||||
protected Grep $grep;
|
||||
|
||||
@@ -40,71 +42,159 @@ abstract class Get implements GetInterface
|
||||
*/
|
||||
protected Item $item;
|
||||
|
||||
/**
|
||||
* Table Name
|
||||
*
|
||||
* @var string
|
||||
* @since 3.2.1
|
||||
*/
|
||||
protected string $table;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param Grep $grep The GrepInterface Class.
|
||||
* @param Item $item The ItemInterface Class.
|
||||
* @param string|null $table The table name.
|
||||
* @param Config $config The Config Class.
|
||||
* @param Grep $grep The Grep Class.
|
||||
* @param Item $item The ItemInterface Class.
|
||||
* @param string|null $table The table name.
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function __construct(Grep $grep, Item $item, ?string $table = null)
|
||||
public function __construct(Config $config, Grep $grep, Item $item, ?string $table = null)
|
||||
{
|
||||
parent::__construct($config);
|
||||
|
||||
$this->grep = $grep;
|
||||
$this->item = $item;
|
||||
if ($table !== null)
|
||||
{
|
||||
$this->table = $table;
|
||||
$this->table($table);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the current active table
|
||||
* Initializes and categorizes items by checking their existence in the local database
|
||||
* and optionally retrieving them from a remote repository if not found locally.
|
||||
*
|
||||
* @param string $table The table that should be active
|
||||
* This method processes an array of unique identifiers (`$items`) and checks each item:
|
||||
* - If found in the local database: categorized under 'local'.
|
||||
* - If not found locally and not available remotely: categorized under 'not_found'.
|
||||
* - If retrieved from the remote repository: categorized under 'added' and stored locally.
|
||||
*
|
||||
* @return self
|
||||
* @since 3.2.2
|
||||
* @param array $items An array of item identifiers (GUIDs) to initialize and validate.
|
||||
* @param object|null $repo The repository object to search. If null, all repos will be searched.
|
||||
*
|
||||
* @return array{
|
||||
* local: array<string, string>,
|
||||
* not_found: array<string, string>,
|
||||
* added: array<string, string>
|
||||
* } Associative arrays indexed by GUIDs indicating the status of each item:
|
||||
* - 'local': Items already present in the local database.
|
||||
* - 'not_found': Items not found locally or remotely.
|
||||
* - 'added': Items successfully retrieved from the remote repository and stored.
|
||||
*
|
||||
* @since 5.1.1
|
||||
*/
|
||||
public function table(string $table): self
|
||||
public function init(array $items, ?object $repo = null): array
|
||||
{
|
||||
$this->table = $table;
|
||||
$done = [];
|
||||
$logger = [
|
||||
'local' => [],
|
||||
'not_found' => [],
|
||||
'added' => []
|
||||
];
|
||||
$guid_field = $this->getGuidField();
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Init all items not found in database
|
||||
*
|
||||
* @return bool
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function init(): bool
|
||||
{
|
||||
if (($items = $this->grep->getRemoteGuid()) !== null)
|
||||
foreach ($items as $guid)
|
||||
{
|
||||
foreach($items as $guid)
|
||||
if (isset($done[$guid]))
|
||||
{
|
||||
if ($this->item->table($this->getTable())->value($guid) === null &&
|
||||
($item = $this->grep->get($guid, ['remote'])) !== null)
|
||||
{
|
||||
$this->item->set($item);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
$done[$guid] = $guid;
|
||||
|
||||
// Check if item exists in the local database
|
||||
if ($this->item->table($this->getTable())->value($guid, $guid_field) !== null)
|
||||
{
|
||||
$logger['local'][$guid] = $guid;
|
||||
continue;
|
||||
}
|
||||
|
||||
return true;
|
||||
// Attempt to fetch the item from the remote repository
|
||||
$item = $this->grep->get($guid, ['remote'], $repo);
|
||||
|
||||
if ($item === null)
|
||||
{
|
||||
$logger['not_found'][$guid] = $guid;
|
||||
continue;
|
||||
}
|
||||
|
||||
// pass item to the inspector to get all dependencies
|
||||
// $item = $this->model->init($item);
|
||||
|
||||
// Store the retrieved remote item into the local structure
|
||||
$this->item->set($item, $guid_field);
|
||||
|
||||
$logger['added'][$guid] = $guid;
|
||||
}
|
||||
|
||||
return false;
|
||||
return $logger;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the path/repo object
|
||||
*
|
||||
* @param string $guid The target repository guid.
|
||||
*
|
||||
* @return object|null
|
||||
* @since 5.1.1
|
||||
*/
|
||||
public function path(string $guid): ?object
|
||||
{
|
||||
return $this->grep->getPath($guid);
|
||||
}
|
||||
|
||||
/**
|
||||
* get all the available paths for this area
|
||||
*
|
||||
* @return array|null
|
||||
* @since 5.1.1
|
||||
*/
|
||||
public function paths(): ?array
|
||||
{
|
||||
return $this->grep->getPaths();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all available items for the given repository, or all repositories if none specified.
|
||||
*
|
||||
* @param string|null $repo The target repository to list (optional).
|
||||
*
|
||||
* @return array|null An array of indexed path objects or null if not found.
|
||||
* @since 5.1.1
|
||||
*/
|
||||
public function list(?string $repo = null): ?array
|
||||
{
|
||||
$guid_field = $this->getGuidField();
|
||||
$table = $this->item->table($this->getTable());
|
||||
|
||||
if ($repo === null)
|
||||
{
|
||||
$paths = $this->grep->getPathsIndexes();
|
||||
}
|
||||
else
|
||||
{
|
||||
$singlePath = $this->grep->getPathIndexes($repo);
|
||||
$paths = $singlePath !== null ? [$singlePath] : null;
|
||||
}
|
||||
|
||||
if ($paths === null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
foreach ($paths as &$path)
|
||||
{
|
||||
foreach ($path->index as &$item)
|
||||
{
|
||||
$guid = $item->{$guid_field};
|
||||
$item->local = $table->value($guid, $guid_field) !== null;
|
||||
}
|
||||
}
|
||||
|
||||
return $paths;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -113,7 +203,7 @@ abstract class Get implements GetInterface
|
||||
* @param array $items The global unique ids of the items
|
||||
*
|
||||
* @return bool
|
||||
* @since 3.2.0
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function reset(array $items): bool
|
||||
{
|
||||
@@ -138,32 +228,25 @@ abstract class Get implements GetInterface
|
||||
/**
|
||||
* Load an item
|
||||
*
|
||||
* @param string $guid The global unique id of the item
|
||||
* @param array $order The search order
|
||||
* @param string|null $action The action to load power
|
||||
* @param string $guid The global unique id of the item
|
||||
* @param array $order The search order
|
||||
* @param object|null $repo The repository object to search. If null, all repos will be searched.
|
||||
*
|
||||
* @return bool
|
||||
* @since 3.2.0
|
||||
* @since 3.2.0
|
||||
* @since 5.1.1 We added the repo object
|
||||
*/
|
||||
public function item(string $guid, array $order = ['remote', 'local'], ?string $action = null): bool
|
||||
public function item(string $guid, array $order = ['remote', 'local'], ?object $repo = null): bool
|
||||
{
|
||||
if (($item = $this->grep->get($guid, $order)) !== null)
|
||||
$guid_field = $this->getGuidField();
|
||||
if (($item = $this->grep->get($guid, $order, $repo)) !== null)
|
||||
{
|
||||
return $this->item->table($this->getTable())->set($item);
|
||||
// pass item to the model to set the direct children
|
||||
// $item = $this->model->getItem($item);
|
||||
return $this->item->table($this->getTable())->set($item, $guid_field);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current active table
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.2
|
||||
*/
|
||||
public function getTable(): string
|
||||
{
|
||||
return $this->table;
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -12,13 +12,17 @@
|
||||
namespace VDM\Joomla\Abstraction\Remote;
|
||||
|
||||
|
||||
use Joomla\CMS\Language\Text;
|
||||
use VDM\Joomla\Interfaces\Remote\ConfigInterface as Config;
|
||||
use VDM\Joomla\Interfaces\GrepInterface as Grep;
|
||||
use VDM\Joomla\Interfaces\Data\ItemsInterface as Items;
|
||||
use VDM\Joomla\Interfaces\Readme\ItemInterface as ItemReadme;
|
||||
use VDM\Joomla\Interfaces\Readme\MainInterface as MainReadme;
|
||||
use VDM\Joomla\Interfaces\Git\Repository\ContentsInterface as Git;
|
||||
use VDM\Joomla\Componentbuilder\Package\MessageBus;
|
||||
use VDM\Joomla\Utilities\ObjectHelper;
|
||||
use VDM\Joomla\Interfaces\Remote\SetInterface;
|
||||
use VDM\Joomla\Abstraction\Remote\Base;
|
||||
|
||||
|
||||
/**
|
||||
@@ -26,7 +30,7 @@ use VDM\Joomla\Interfaces\Remote\SetInterface;
|
||||
*
|
||||
* @since 3.2.2
|
||||
*/
|
||||
abstract class Set implements SetInterface
|
||||
abstract class Set extends Base implements SetInterface
|
||||
{
|
||||
/**
|
||||
* The Grep Class.
|
||||
@@ -68,6 +72,14 @@ abstract class Set implements SetInterface
|
||||
*/
|
||||
protected Git $git;
|
||||
|
||||
/**
|
||||
* The Message Bus Class.
|
||||
*
|
||||
* @var MessageBus
|
||||
* @since 5.2.1
|
||||
*/
|
||||
protected MessageBus $messages;
|
||||
|
||||
/**
|
||||
* All active repos
|
||||
*
|
||||
@@ -76,38 +88,6 @@ abstract class Set implements SetInterface
|
||||
**/
|
||||
public array $repos;
|
||||
|
||||
/**
|
||||
* Table Name
|
||||
*
|
||||
* @var string
|
||||
* @since 3.2.2
|
||||
*/
|
||||
protected string $table;
|
||||
|
||||
/**
|
||||
* Area Name
|
||||
*
|
||||
* @var string
|
||||
* @since 3.2.2
|
||||
*/
|
||||
protected string $area;
|
||||
|
||||
/**
|
||||
* The item map
|
||||
*
|
||||
* @var array
|
||||
* @since 3.2.2
|
||||
*/
|
||||
protected array $map;
|
||||
|
||||
/**
|
||||
* The index map
|
||||
*
|
||||
* @var array
|
||||
* @since 3.2.2
|
||||
*/
|
||||
protected array $index_map;
|
||||
|
||||
/**
|
||||
* The repo main settings
|
||||
*
|
||||
@@ -116,51 +96,6 @@ abstract class Set implements SetInterface
|
||||
*/
|
||||
protected array $settings;
|
||||
|
||||
/**
|
||||
* Prefix Key
|
||||
*
|
||||
* @var string
|
||||
* @since 3.2.2
|
||||
*/
|
||||
protected string $prefix_key = 'Super---';
|
||||
|
||||
/**
|
||||
* Suffix Key
|
||||
*
|
||||
* @var string
|
||||
* @since 3.2.2
|
||||
*/
|
||||
protected string $suffix_key = '---Power';
|
||||
|
||||
/**
|
||||
* The item settings file path
|
||||
*
|
||||
* @var string
|
||||
* @since 3.2.2
|
||||
*/
|
||||
protected string $settings_path = 'item.json';
|
||||
|
||||
/**
|
||||
* The index settings file path
|
||||
*
|
||||
* @var string
|
||||
* @since 3.2.2
|
||||
*/
|
||||
protected string $index_settings_path = 'index.json';
|
||||
|
||||
/**
|
||||
* Core Placeholders
|
||||
*
|
||||
* @var array
|
||||
* @since 5.0.3
|
||||
*/
|
||||
protected array $placeholders = [
|
||||
'[['.'[NamespacePrefix]]]' => 'VDM',
|
||||
'[['.'[ComponentNamespace]]]' => 'Componentbuilder',
|
||||
'[['.'[Component]]]' => 'Componentbuilder',
|
||||
'[['.'[component]]]' => 'componentbuilder'
|
||||
];
|
||||
|
||||
/**
|
||||
* Repo Placeholders
|
||||
*
|
||||
@@ -172,115 +107,58 @@ abstract class Set implements SetInterface
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param array $repos The active repos
|
||||
* @param Config $config The Config Class.
|
||||
* @param Grep $grep The Grep Class.
|
||||
* @param Items $items The Items Class.
|
||||
* @param ItemReadme $itemReadme The Item Readme Class.
|
||||
* @param MainReadme $mainReadme The Main Readme Class.
|
||||
* @param Git $git The Contents Class.
|
||||
* @param MessageBus $messages The MessageBus Class.
|
||||
* @param array $repos The active repos.
|
||||
* @param string|null $table The table name.
|
||||
* @param string|null $settingsPath The settings path.
|
||||
* @param string|null $settingsIndexPath The index settings path.
|
||||
* @param string|null $indexPath The index path.
|
||||
*
|
||||
* @since 3.2.2
|
||||
*/
|
||||
public function __construct(array $repos, Grep $grep, Items $items,
|
||||
ItemReadme $itemReadme, MainReadme $mainReadme, Git $git,
|
||||
?string $table = null, ?string $settingsPath = null, ?string $settingsIndexPath = null)
|
||||
public function __construct(Config $config, Grep $grep, Items $items, ItemReadme $itemReadme,
|
||||
MainReadme $mainReadme, Git $git, MessageBus $messages, array $repos, ?string $table = null,
|
||||
?string $settingsPath = null, ?string $indexPath = null)
|
||||
{
|
||||
$this->repos = $repos;
|
||||
parent::__construct($config);
|
||||
|
||||
$this->grep = $grep;
|
||||
$this->items = $items;
|
||||
$this->itemReadme = $itemReadme;
|
||||
$this->mainReadme = $mainReadme;
|
||||
$this->git = $git;
|
||||
$this->messages = $messages;
|
||||
$this->repos = $repos;
|
||||
|
||||
if ($table !== null)
|
||||
{
|
||||
$this->table = $table;
|
||||
$this->table($table);
|
||||
}
|
||||
|
||||
if ($settingsPath !== null)
|
||||
{
|
||||
$this->settings_path = $settingsPath;
|
||||
$this->setSettingsPath($settingsPath);
|
||||
}
|
||||
|
||||
if ($settingsIndexPath !== null)
|
||||
if ($indexPath !== null)
|
||||
{
|
||||
$this->setIndexSettingsPath($settingsIndexPath);
|
||||
$this->setIndexPath($indexPath);
|
||||
}
|
||||
|
||||
if (empty($this->area))
|
||||
if ($this->getArea() === null)
|
||||
{
|
||||
$this->area = ucfirst(str_replace('_', ' ', $this->table));
|
||||
$this->area(ucfirst(str_replace('_', ' ', $this->getTable())));
|
||||
}
|
||||
|
||||
// set the branch to writing
|
||||
$this->grep->setBranchField('write_branch');
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the current active table
|
||||
*
|
||||
* @param string $table The table that should be active
|
||||
*
|
||||
* @return self
|
||||
* @since 3.2.2
|
||||
*/
|
||||
public function table(string $table): self
|
||||
{
|
||||
$this->table = $table;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the current active area
|
||||
*
|
||||
* @param string $area The area that should be active
|
||||
*
|
||||
* @return self
|
||||
* @since 3.2.2
|
||||
*/
|
||||
public function area(string $area): self
|
||||
{
|
||||
$this->area = ucfirst(str_replace('_', ' ', $area));
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the settings path
|
||||
*
|
||||
* @param string $settingsPath The repository settings path
|
||||
*
|
||||
* @return self
|
||||
* @since 3.2.2
|
||||
*/
|
||||
public function setSettingsPath(string $settingsPath): self
|
||||
{
|
||||
$this->settings_path = $settingsPath;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the index settings path
|
||||
*
|
||||
* @param string $settingsIndexPath The repository index settings path
|
||||
*
|
||||
* @return self
|
||||
* @since 3.2.2
|
||||
*/
|
||||
public function setIndexSettingsPath(string $settingsIndexPath): self
|
||||
{
|
||||
$this->index_settings_path = $settingsIndexPath;
|
||||
|
||||
$this->grep->setIndexPath($settingsIndexPath);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Save items remotely
|
||||
*
|
||||
@@ -305,9 +183,13 @@ abstract class Set implements SetInterface
|
||||
throw new \Exception("At least one valid local [{$this->getArea()}] must exist for the push function to operate correctly.");
|
||||
}
|
||||
|
||||
$counter = 0;
|
||||
foreach ($items as $item)
|
||||
{
|
||||
$this->save($item);
|
||||
if ($this->save($item))
|
||||
{
|
||||
$counter++;
|
||||
}
|
||||
}
|
||||
|
||||
// update the repos main readme and index settings
|
||||
@@ -319,7 +201,7 @@ abstract class Set implements SetInterface
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
return $counter === count($items);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -340,10 +222,10 @@ abstract class Set implements SetInterface
|
||||
* @param object $item
|
||||
* @param object $repo
|
||||
*
|
||||
* @return void
|
||||
* @return bool
|
||||
* @since 3.2.2
|
||||
*/
|
||||
abstract protected function createItem(object $item, object $repo): void;
|
||||
abstract protected function createItem(object $item, object $repo): bool;
|
||||
|
||||
/**
|
||||
* update an existing item readme
|
||||
@@ -368,28 +250,6 @@ abstract class Set implements SetInterface
|
||||
*/
|
||||
abstract protected function createItemReadme(object $item, object $repo): void;
|
||||
|
||||
/**
|
||||
* Get the current active table
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.2
|
||||
*/
|
||||
protected function getTable(): string
|
||||
{
|
||||
return $this->table;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current active area
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.2
|
||||
*/
|
||||
protected function getArea(): string
|
||||
{
|
||||
return $this->area;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update/Create the repo main readme and index
|
||||
*
|
||||
@@ -418,19 +278,27 @@ abstract class Set implements SetInterface
|
||||
|
||||
$this->grep->loadApi($this->git, $repo->base ?? null, $repo->token ?? null);
|
||||
|
||||
$this->updateIndexMainFile(
|
||||
$repo,
|
||||
$this->getIndexSettingsPath(),
|
||||
json_encode($settings, JSON_PRETTY_PRINT),
|
||||
'Update main index file'
|
||||
);
|
||||
$indexPath = $this->getIndexPath();
|
||||
if (!empty($indexPath))
|
||||
{
|
||||
$this->setMainRepoFile(
|
||||
$repo,
|
||||
$indexPath,
|
||||
json_encode($settings, JSON_PRETTY_PRINT),
|
||||
'Update main index file', 'Create main index file'
|
||||
);
|
||||
}
|
||||
|
||||
$this->updateIndexMainFile(
|
||||
$repo,
|
||||
'README.md',
|
||||
$this->mainReadme->get($settings),
|
||||
'Update main readme file'
|
||||
);
|
||||
$mainReadmePath = $this->getMainReadmePath();
|
||||
if (!empty($mainReadmePath))
|
||||
{
|
||||
$this->setMainRepoFile(
|
||||
$repo,
|
||||
$mainReadmePath,
|
||||
$this->mainReadme->get($settings),
|
||||
'Update main readme file', 'Create main readme file'
|
||||
);
|
||||
}
|
||||
|
||||
$this->git->reset_();
|
||||
}
|
||||
@@ -487,13 +355,14 @@ abstract class Set implements SetInterface
|
||||
* @param object $repo
|
||||
* @param string $path
|
||||
* @param string $content
|
||||
* @param string $message
|
||||
* @param string $updateMessage
|
||||
* @param string $createMessage
|
||||
*
|
||||
* @return void
|
||||
* @since 3.2.2
|
||||
*/
|
||||
protected function updateIndexMainFile(object $repo, string $path,
|
||||
string $content, string $message): void
|
||||
protected function setMainRepoFile(object $repo, string $path,
|
||||
string $content, string $updateMessage, string $createMessage): void
|
||||
{
|
||||
$meta = $this->git->metadata(
|
||||
$repo->organisation,
|
||||
@@ -504,14 +373,34 @@ abstract class Set implements SetInterface
|
||||
|
||||
if ($meta !== null && isset($meta->sha))
|
||||
{
|
||||
// Calculate the new SHA from the current content
|
||||
$newSha = sha1("blob " . strlen($content) . "\0" . $content);
|
||||
|
||||
// Check if the new SHA matches the existing SHA
|
||||
if ($meta->sha === $newSha)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$this->git->update(
|
||||
$repo->organisation,
|
||||
$repo->repository,
|
||||
$path,
|
||||
$content,
|
||||
$message,
|
||||
$meta->sha,
|
||||
$repo->write_branch
|
||||
$repo->organisation, // The owner name.
|
||||
$repo->repository, // The repository name.
|
||||
$path, // The file path.
|
||||
$content, // The file content.
|
||||
$updateMessage, // The commit message.
|
||||
$meta->sha, // The previous sha value.
|
||||
$repo->write_branch // The branch name.
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->git->create(
|
||||
$repo->organisation, // The owner name.
|
||||
$repo->repository, // The repository name.
|
||||
$path, // The file path.
|
||||
$content, // The file content.
|
||||
$createMessage, // The commit message.
|
||||
$repo->write_branch // The branch name.
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -526,93 +415,90 @@ abstract class Set implements SetInterface
|
||||
*/
|
||||
protected function getLocalItems(array $guids): ?array
|
||||
{
|
||||
return $this->items->table($this->getTable())->get($guids);
|
||||
}
|
||||
|
||||
/**
|
||||
* Map a single item to its properties
|
||||
*
|
||||
* @param object $item The item to be mapped
|
||||
*
|
||||
* @return object
|
||||
* @since 3.2.2
|
||||
*/
|
||||
protected function mapItem(object $item): object
|
||||
{
|
||||
$power = [];
|
||||
|
||||
foreach ($this->map as $key => $map)
|
||||
{
|
||||
$methodName = "mapItemValue_{$key}";
|
||||
if (method_exists($this, $methodName))
|
||||
{
|
||||
$this->{$methodName}($item, $power);
|
||||
}
|
||||
else
|
||||
{
|
||||
$power[$key] = $item->{$map} ?? null;
|
||||
}
|
||||
}
|
||||
|
||||
return (object) $power;
|
||||
$guid_field = $this->getGuidField();
|
||||
return $this->items->table($this->getTable())->get($guids, $guid_field);
|
||||
}
|
||||
|
||||
/**
|
||||
* Save an item remotely
|
||||
*
|
||||
* @param object $item The item to save
|
||||
* @param object $rawItem The item to save
|
||||
*
|
||||
* @return void
|
||||
* @return bool
|
||||
* @since 3.2.2
|
||||
*/
|
||||
protected function save(object $item): void
|
||||
protected function save(object $rawItem): bool
|
||||
{
|
||||
if (empty($item->guid))
|
||||
$index_item = null;
|
||||
$item = $this->mapItem($rawItem);
|
||||
$area = $this->getArea();
|
||||
$item_id = $rawItem->id ?? '_no_id_found_';
|
||||
$item_name = $this->index_map_IndexName($item);
|
||||
|
||||
$guid_field = $this->getGuidField();
|
||||
if (empty($item->{$guid_field}))
|
||||
{
|
||||
return;
|
||||
$this->messages->add('error', Text::sprintf('COM_COMPONENTBUILDER_S_ITEM_S_ID_S_MISSING_THE_S_KEY_VALUE', $area, $item_name, $item_id, $guid_field));
|
||||
return false;
|
||||
}
|
||||
|
||||
$index_item = null;
|
||||
// pass item to the inspector to set all dependencies
|
||||
// $item = $this->model->setItem($item);
|
||||
|
||||
$at_least_once = false;
|
||||
$not_approved = true;
|
||||
foreach ($this->repos as $key => $repo)
|
||||
{
|
||||
if (empty($repo->write_branch) || $repo->write_branch === 'default' || !$this->targetRepo($item, $repo))
|
||||
if (empty($repo->write_branch) || $repo->write_branch === 'default' || !$this->targetRepo($rawItem, $repo))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$item = $this->mapItem($item);
|
||||
$not_approved = false;
|
||||
|
||||
$this->setRepoPlaceholders($repo);
|
||||
|
||||
$this->grep->loadApi($this->git, $repo->base ?? null, $repo->token ?? null);
|
||||
|
||||
if (($existing = $this->grep->get($item->guid, ['remote'], $repo)) !== null)
|
||||
if (($existing = $this->grep->get($item->{$guid_field}, ['remote'], $repo)) !== null)
|
||||
{
|
||||
if ($this->updateItem($item, $existing, $repo))
|
||||
{
|
||||
$this->updateItemReadme($item, $existing, $repo);
|
||||
$at_least_once = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
elseif ($this->createItem($item, $repo))
|
||||
{
|
||||
$this->createItem($item, $repo);
|
||||
|
||||
$this->createItemReadme($item, $repo);
|
||||
|
||||
$index_item ??= $this->getIndexItem($item);
|
||||
|
||||
$at_least_once = true;
|
||||
|
||||
if (!isset($this->settings[$key]))
|
||||
{
|
||||
$this->settings[$key] = ['repo' => $repo, 'items' => [$item->guid => $index_item]];
|
||||
$this->settings[$key] = ['repo' => $repo, 'items' => [$item->{$guid_field} => $index_item]];
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->settings[$key]['items'][$item->guid] = $index_item;
|
||||
$this->settings[$key]['items'][$item->{$guid_field}] = $index_item;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$repo_name = $this->getRepoName($repo);
|
||||
$this->messages->add('error', Text::sprintf('COM_COMPONENTBUILDER_S_ITEM_S_ID_S_COULD_NOT_BE_CREATED_OR_FOUND_IN_REPOS', $area, $item_name, $item_id, $repo_name));
|
||||
}
|
||||
|
||||
$this->git->reset_();
|
||||
}
|
||||
|
||||
if (!$at_least_once && $not_approved)
|
||||
{
|
||||
$this->messages->add('warning', Text::sprintf('COM_COMPONENTBUILDER_S_ITEM_S_ID_S_IS_NOT_APPROVED_AND_THEREFORE_NOT_LINKED_TO_ANY_REPOSITORY', $area, $item_name, $item_id));
|
||||
}
|
||||
|
||||
return $at_least_once;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -625,7 +511,7 @@ abstract class Set implements SetInterface
|
||||
*/
|
||||
protected function setRepoPlaceholders(object $repo): void
|
||||
{
|
||||
$this->repoPlaceholders = $this->placeholders;
|
||||
$this->repoPlaceholders = $this->getPlaceholders();
|
||||
if (!empty($repo->placeholders) && is_array($repo->placeholders))
|
||||
{
|
||||
foreach ($repo->placeholders as $key => $value)
|
||||
@@ -652,33 +538,6 @@ abstract class Set implements SetInterface
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get index values
|
||||
*
|
||||
* @param object $item The item
|
||||
*
|
||||
* @return array|null
|
||||
* @since 3.2.2
|
||||
*/
|
||||
protected function getIndexItem(object $item): ?array
|
||||
{
|
||||
if (empty($this->index_map))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
$index_item = [];
|
||||
foreach ($this->index_map as $key => $function_name)
|
||||
{
|
||||
if (method_exists($this, $function_name))
|
||||
{
|
||||
$index_item[$key] = $this->{$function_name}($item);
|
||||
}
|
||||
}
|
||||
|
||||
return $index_item ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
* check that we have an active repo towards which we can write data
|
||||
*
|
||||
@@ -712,6 +571,23 @@ abstract class Set implements SetInterface
|
||||
return true; // for more control in children classes
|
||||
}
|
||||
|
||||
/**
|
||||
* get the name of the repo
|
||||
*
|
||||
* @param object $repo The current repo
|
||||
*
|
||||
* @return string
|
||||
* @since 5.2.1
|
||||
*/
|
||||
protected function getRepoName(object $repo): string
|
||||
{
|
||||
$base = $repo->base ?? '[core]';
|
||||
$organisation = $repo->organisation ?? '[organisation]';
|
||||
$repository = $repo->repository ?? '[repository]';
|
||||
|
||||
return "{$base}/{$organisation}/{$repository}";
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if two objects are equal by comparing their properties and values.
|
||||
*
|
||||
@@ -729,95 +605,6 @@ abstract class Set implements SetInterface
|
||||
protected function areObjectsEqual(?object $obj1, ?object $obj2): bool
|
||||
{
|
||||
return ObjectHelper::equal($obj1, $obj2); // basic comparison
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the settings path
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.2
|
||||
*/
|
||||
protected function getSettingsPath(): string
|
||||
{
|
||||
return $this->settings_path;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the index settings path
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.2
|
||||
*/
|
||||
protected function getIndexSettingsPath(): string
|
||||
{
|
||||
return $this->index_settings_path;
|
||||
}
|
||||
|
||||
//// index_map_ (area) /////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* Get the item name for the index values
|
||||
*
|
||||
* @param object $item
|
||||
*
|
||||
* @return string|null
|
||||
* @since 3.2.2
|
||||
*/
|
||||
protected function index_map_IndexName(object $item): ?string
|
||||
{
|
||||
return $item->system_name ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the item settings path for the index values
|
||||
*
|
||||
* @param object $item
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.2
|
||||
*/
|
||||
protected function index_map_IndexSettingsPath(object $item): string
|
||||
{
|
||||
return "src/{$item->guid}/" . $this->getSettingsPath();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the item path for the index values
|
||||
*
|
||||
* @param object $item
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.2
|
||||
*/
|
||||
protected function index_map_IndexPath(object $item): string
|
||||
{
|
||||
return "src/{$item->guid}";
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the item JPK for the index values
|
||||
*
|
||||
* @param object $item
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.2
|
||||
*/
|
||||
protected function index_map_IndexKey(object $item): string
|
||||
{
|
||||
return $this->prefix_key . str_replace('-', '_', $item->guid) . $this->suffix_key;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the item GUID for the index values
|
||||
*
|
||||
* @param object $item
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.2
|
||||
*/
|
||||
protected function index_map_IndexGUID(object $item): string
|
||||
{
|
||||
return $item->guid;
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -15,7 +15,6 @@ namespace VDM\Joomla\Componentbuilder\Compiler\Component;
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\Application\CMSApplication;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Registry;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Component;
|
||||
use VDM\Joomla\Utilities\StringHelper;
|
||||
@@ -30,9 +29,9 @@ use VDM\Joomla\Utilities\ArrayHelper;
|
||||
final class Dashboard
|
||||
{
|
||||
/**
|
||||
* The compiler registry
|
||||
* Compiler Registry
|
||||
*
|
||||
* @var Registry
|
||||
* @var Registry
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected Registry $registry;
|
||||
@@ -40,34 +39,54 @@ final class Dashboard
|
||||
/**
|
||||
* Compiler Component
|
||||
*
|
||||
* @var Component
|
||||
* @var Component
|
||||
* @since 3.2.0
|
||||
**/
|
||||
*/
|
||||
protected Component $component;
|
||||
|
||||
/**
|
||||
* Application object.
|
||||
* Joomla Application
|
||||
*
|
||||
* @var CMSApplication
|
||||
* @var CMSApplication
|
||||
* @since 3.2.0
|
||||
**/
|
||||
*/
|
||||
protected CMSApplication $app;
|
||||
|
||||
/**
|
||||
* Supported Dashboard Target Types
|
||||
*
|
||||
* @var array<string, array<string, string>>
|
||||
* @since 5.1.1
|
||||
*/
|
||||
protected const DASHBOARD_TARGETS = [
|
||||
'A' => [
|
||||
'viewsKey' => 'admin_views',
|
||||
'typeKey' => 'adminview',
|
||||
'name' => 'admin view',
|
||||
'settingsKey' => 'name_list',
|
||||
],
|
||||
'C' => [
|
||||
'viewsKey' => 'custom_admin_views',
|
||||
'typeKey' => 'customadminview',
|
||||
'name' => 'custom admin view',
|
||||
'settingsKey' => 'code',
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param Registry|null $registry The compiler registry object.
|
||||
* @param Component|null $component The component class.
|
||||
* @param CMSApplication|null $app The app object.
|
||||
* @param Registry $registry The registry instance.
|
||||
* @param Component $component The component instance.
|
||||
* @param CMSApplication|null $app The application instance.
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function __construct(?Registry $registry = null, ?Component $component = null,
|
||||
?CMSApplication $app = null)
|
||||
public function __construct(Registry $registry, Component $component, ?CMSApplication $app = null)
|
||||
{
|
||||
$this->registry = $registry ?: Compiler::_('Registry');
|
||||
$this->component = $component ?: Compiler::_('Component');
|
||||
$this->app = $app ?: Factory::getApplication();
|
||||
$this->registry = $registry;
|
||||
$this->component = $component;
|
||||
$this->app = $app ?? Factory::getApplication();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -76,137 +95,157 @@ final class Dashboard
|
||||
* @return void
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function set()
|
||||
public function set(): void
|
||||
{
|
||||
// only add the dynamic dashboard if all checks out
|
||||
if ($this->component->get('dashboard_type', 0) == 2
|
||||
&& ($dashboard_ = $this->component->get('dashboard')) !== null
|
||||
&& StringHelper::check($dashboard_)
|
||||
&& strpos((string) $dashboard_, '_') !== false)
|
||||
if (!$this->isDynamicDashboardEnabled())
|
||||
{
|
||||
// set the default view
|
||||
$getter = explode('_', (string) $dashboard_);
|
||||
if (count((array) $getter) == 2 && is_numeric($getter[1]))
|
||||
return;
|
||||
}
|
||||
|
||||
$rawDashboard = (string) $this->component->get('dashboard');
|
||||
|
||||
if (!$this->isValidDashboardFormat($rawDashboard))
|
||||
{
|
||||
$this->notifyInvalidDashboard($rawDashboard);
|
||||
return;
|
||||
}
|
||||
|
||||
[$targetKey, $identifier] = explode('_', $rawDashboard, 2);
|
||||
$targetKey = strtoupper($targetKey);
|
||||
|
||||
if (!isset(self::DASHBOARD_TARGETS[$targetKey]))
|
||||
{
|
||||
$this->notifyInvalidDashboard($rawDashboard);
|
||||
return;
|
||||
}
|
||||
|
||||
$this->handleDashboardTarget($targetKey, $identifier, $rawDashboard);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if dynamic dashboard is enabled.
|
||||
*
|
||||
* @return bool
|
||||
* @since 5.1.1
|
||||
*/
|
||||
protected function isDynamicDashboardEnabled(): bool
|
||||
{
|
||||
return (int) $this->component->get('dashboard_type', 0) === 2
|
||||
&& $this->component->get('dashboard') !== null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate the dashboard format (e.g., "A_23" or "C_abcd1234").
|
||||
*
|
||||
* @param string $dashboard The dashboard value.
|
||||
*
|
||||
* @return bool
|
||||
* @since 5.1.1
|
||||
*/
|
||||
protected function isValidDashboardFormat(string $dashboard): bool
|
||||
{
|
||||
return StringHelper::check($dashboard) && strpos($dashboard, '_') !== false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the dashboard target and attempt to set it in the registry.
|
||||
*
|
||||
* @param string $key The dashboard type key (e.g. A or C).
|
||||
* @param string $identifier The numeric ID or GUID string.
|
||||
* @param string $rawDashboard The original dashboard string value.
|
||||
*
|
||||
* @return void
|
||||
* @since 5.1.1
|
||||
*/
|
||||
protected function handleDashboardTarget(string $key, string $identifier, string $rawDashboard): void
|
||||
{
|
||||
$target = self::DASHBOARD_TARGETS[$key];
|
||||
|
||||
$views = $this->component->get($target['viewsKey']);
|
||||
|
||||
if (!ArrayHelper::check($views))
|
||||
{
|
||||
$this->notifyDashboardNotFound($target['name'], $rawDashboard, $target['viewsKey']);
|
||||
return;
|
||||
}
|
||||
|
||||
$matchedView = $this->findViewByIdentifier((array) $views, $target['typeKey'], $identifier);
|
||||
|
||||
if ($matchedView !== null && isset($matchedView['settings']->{$target['settingsKey']}))
|
||||
{
|
||||
$this->registry->set('build.dashboard', StringHelper::safe($matchedView['settings']->{$target['settingsKey']}));
|
||||
$this->registry->set('build.dashboard.type', $target['viewsKey']);
|
||||
|
||||
$this->component->remove('dashboard_tab');
|
||||
$this->component->remove('php_dashboard_methods');
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->notifyDashboardNotFound($target['name'], $rawDashboard, $target['viewsKey']);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Find a matching view by numeric ID or GUID.
|
||||
*
|
||||
* @param array<string, mixed> $views List of views to search.
|
||||
* @param string $field Field name to match (e.g. adminview or customadminview).
|
||||
* @param string $identifier ID or GUID string.
|
||||
*
|
||||
* @return array<string, mixed>|null
|
||||
* @since 5.1.1
|
||||
*/
|
||||
protected function findViewByIdentifier(array $views, string $field, string $identifier): ?array
|
||||
{
|
||||
foreach ($views as $view)
|
||||
{
|
||||
if (isset($view[$field]) && (string) $view[$field] === $identifier)
|
||||
{
|
||||
// the pointers
|
||||
$t = StringHelper::safe($getter[0], 'U');
|
||||
$id = (int) $getter[1];
|
||||
|
||||
// the dynamic stuff
|
||||
$targets = array('A' => 'admin_views',
|
||||
'C' => 'custom_admin_views');
|
||||
$names = array('A' => 'admin view',
|
||||
'C' => 'custom admin view');
|
||||
$types = array('A' => 'adminview', 'C' => 'customadminview');
|
||||
$keys = array('A' => 'name_list', 'C' => 'code');
|
||||
|
||||
// check the target values
|
||||
if (isset($targets[$t]) && $id > 0)
|
||||
{
|
||||
// set the type name
|
||||
$type_names = StringHelper::safe(
|
||||
$targets[$t], 'w'
|
||||
);
|
||||
// set the dynamic dash
|
||||
if (($target_ = $this->component->get($targets[$t])) !== null
|
||||
&& ArrayHelper::check($target_))
|
||||
{
|
||||
// search the target views
|
||||
$dashboard = (array) array_filter(
|
||||
$target_,
|
||||
function ($view) use ($id, $t, $types) {
|
||||
if (isset($view[$types[$t]])
|
||||
&& $id == $view[$types[$t]])
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
);
|
||||
|
||||
// set dashboard
|
||||
if (ArrayHelper::check($dashboard))
|
||||
{
|
||||
$dashboard = array_values($dashboard)[0];
|
||||
}
|
||||
|
||||
// check if view was found (this should be true)
|
||||
if (isset($dashboard['settings'])
|
||||
&& isset($dashboard['settings']->{$keys[$t]}))
|
||||
{
|
||||
$this->registry->set('build.dashboard',
|
||||
StringHelper::safe(
|
||||
$dashboard['settings']->{$keys[$t]}
|
||||
)
|
||||
);
|
||||
$this->registry->set('build.dashboard.type',
|
||||
$targets[$t]
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
// set massage that something is wrong
|
||||
$this->app->enqueueMessage(
|
||||
Text::_('COM_COMPONENTBUILDER_HR_HTHREEDASHBOARD_ERRORHTHREE'),
|
||||
'Error'
|
||||
);
|
||||
$this->app->enqueueMessage(
|
||||
Text::sprintf('COM_COMPONENTBUILDER_THE_BSB_BSB_IS_NOT_AVAILABLE_IN_YOUR_COMPONENT_PLEASE_INSURE_TO_ONLY_USED_S_FOR_A_DYNAMIC_DASHBOARD_THAT_ARE_STILL_LINKED_TO_YOUR_COMPONENT',
|
||||
$names[$t], $dashboard_,
|
||||
$type_names
|
||||
), 'Error'
|
||||
);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// set massage that something is wrong
|
||||
$this->app->enqueueMessage(
|
||||
Text::_('COM_COMPONENTBUILDER_HR_HTHREEDASHBOARD_ERRORHTHREE'), 'Error'
|
||||
);
|
||||
$this->app->enqueueMessage(
|
||||
Text::sprintf('COM_COMPONENTBUILDER_THE_BSB_BSB_IS_NOT_AVAILABLE_IN_YOUR_COMPONENT_PLEASE_INSURE_TO_ONLY_USED_S_FOR_A_DYNAMIC_DASHBOARD_THAT_ARE_STILL_LINKED_TO_YOUR_COMPONENT',
|
||||
$names[$t], $dashboard_,
|
||||
$type_names
|
||||
), 'Error'
|
||||
);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// the target value is wrong
|
||||
$this->app->enqueueMessage(
|
||||
Text::_('COM_COMPONENTBUILDER_HR_HTHREEDASHBOARD_ERRORHTHREE'), 'Error'
|
||||
);
|
||||
$this->app->enqueueMessage(
|
||||
Text::sprintf('COM_COMPONENTBUILDER_THE_BSB_VALUE_FOR_THE_DYNAMIC_DASHBOARD_IS_INVALID',
|
||||
$dashboard_
|
||||
), 'Error'
|
||||
);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// the target value is wrong
|
||||
$this->app->enqueueMessage(
|
||||
Text::_('COM_COMPONENTBUILDER_HR_HTHREEDASHBOARD_ERRORHTHREE'), 'Error'
|
||||
);
|
||||
$this->app->enqueueMessage(
|
||||
Text::sprintf('COM_COMPONENTBUILDER_THE_BSB_VALUE_FOR_THE_DYNAMIC_DASHBOARD_IS_INVALID',
|
||||
$dashboard_
|
||||
), 'Error'
|
||||
);
|
||||
}
|
||||
|
||||
// if default was changed to dynamic dashboard the remove default tab and methods
|
||||
if ($this->registry->get('build.dashboard'))
|
||||
{
|
||||
// dynamic dashboard is used
|
||||
$this->component->remove('dashboard_tab');
|
||||
$this->component->remove('php_dashboard_methods');
|
||||
return $view;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Notify that the dashboard configuration is invalid.
|
||||
*
|
||||
* @param string $dashboard The invalid dashboard value.
|
||||
*
|
||||
* @return void
|
||||
* @since 5.1.1
|
||||
*/
|
||||
protected function notifyInvalidDashboard(string $dashboard): void
|
||||
{
|
||||
$this->app->enqueueMessage(Text::_('COM_COMPONENTBUILDER_HR_HTHREEDASHBOARD_ERRORHTHREE'), 'Error');
|
||||
$this->app->enqueueMessage(
|
||||
Text::sprintf('COM_COMPONENTBUILDER_THE_BSB_VALUE_FOR_THE_DYNAMIC_DASHBOARD_IS_INVALID', $dashboard),
|
||||
'Error'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Notify that the configured dashboard target is not found.
|
||||
*
|
||||
* @param string $name Name of the dashboard type.
|
||||
* @param string $dashboard Dashboard value.
|
||||
* @param string $typeKey The internal registry key (e.g. admin_views).
|
||||
*
|
||||
* @return void
|
||||
* @since 5.1.1
|
||||
*/
|
||||
protected function notifyDashboardNotFound(string $name, string $dashboard, string $typeKey): void
|
||||
{
|
||||
$this->app->enqueueMessage(Text::_('COM_COMPONENTBUILDER_HR_HTHREEDASHBOARD_ERRORHTHREE'), 'Error');
|
||||
$this->app->enqueueMessage(
|
||||
Text::sprintf('COM_COMPONENTBUILDER_THE_BSB_BSB_IS_NOT_AVAILABLE_IN_YOUR_COMPONENT_PLEASE_INSURE_TO_ONLY_USED_S_FOR_A_DYNAMIC_DASHBOARD_THAT_ARE_STILL_LINKED_TO_YOUR_COMPONENT',
|
||||
$name,
|
||||
$dashboard,
|
||||
StringHelper::safe($typeKey, 'w')
|
||||
),
|
||||
'Error'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -674,6 +674,7 @@ class Config extends ComponentConfig
|
||||
// these strings are used to search for language strings in all content
|
||||
return [
|
||||
'jjt' => 'Joomla' . '.JText._(',
|
||||
'jjtn' => 'Joomla' . '.Text._(',
|
||||
'js' => 'Text:' . ':script(',
|
||||
't' => 'Text:' . ':_(', // namespace and J version will be found
|
||||
'ts' => 'Text:' . ':sprintf(', // namespace and J version will be found
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -356,7 +356,7 @@ class Compiler extends Infusion
|
||||
. StringHelper::safe($string, 'U');
|
||||
$this->app->enqueueMessage(
|
||||
Text::sprintf(
|
||||
'The <b>Joomla.JText._('%s')</b> language constant for <b>%s</b> does not have a corresponding <code>Text::script('%s')</code> decalaration, please add it.',
|
||||
'The <b>Joomla.Text._('%s')</b> language constant for <b>%s</b> does not have a corresponding <code>Text::script('%s')</code> decalaration, please add it.',
|
||||
$constant, $string, $string
|
||||
), 'Warning'
|
||||
);
|
||||
|
@@ -454,6 +454,7 @@ class Get
|
||||
public $langStringTargets
|
||||
= array(
|
||||
'Joomla' . '.JText._(',
|
||||
'Joomla' . '.Text._(',
|
||||
'JText:' . ':script(',
|
||||
'Text:' . ':_(', // namespace and J version will be found
|
||||
'Text:' . ':sprintf(', // namespace and J version will be found
|
||||
|
@@ -13342,7 +13342,7 @@ class Interpretation extends Fields
|
||||
$fadein[] = Indent::_(1) . "loadingDiv.id = 'loading';";
|
||||
$fadein[] = Indent::_(1) . "loadingDiv.style.cssText = \"background: rgba(255, 255, 255, .8) url('components/com_"
|
||||
. CFactory::_('Config')->component_code_name
|
||||
. "/assets/images/import.gif') 50% 15% no-repeat; top: \" + (outerDiv.getBoundingClientRect().top + window.pageYOffset) + \"px; left: \" + (outerDiv.getBoundingClientRect().left + window.pageXOffset) + \"px; width: \" + outerDiv.offsetWidth + \"px; height: \" + outerDiv.offsetHeight + \"px; position: fixed; opacity: 0.80; -ms-filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=80); filter: alpha(opacity=80); display: none;\";";
|
||||
. "/assets/images/ajax.gif') 50% 35% no-repeat; top: \" + (outerDiv.getBoundingClientRect().top + window.pageYOffset) + \"px; left: \" + (outerDiv.getBoundingClientRect().left + window.pageXOffset) + \"px; width: \" + outerDiv.offsetWidth + \"px; height: \" + outerDiv.offsetHeight + \"px; position: fixed; opacity: 0.80; -ms-filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=80); filter: alpha(opacity=80); display: none;\";";
|
||||
$fadein[] = Indent::_(1) . "outerDiv.appendChild(loadingDiv);";
|
||||
$fadein[] = Indent::_(1) . "loadingDiv.style.display = 'block';";
|
||||
$fadein[] = Indent::_(1) . "// when page is ready remove and show";
|
||||
|
@@ -38,8 +38,8 @@ interface Fieldtypeinterface
|
||||
* @return mixed The field (two return types based of field_builder_type selected Object->xml or String)
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function get(string $setType, array &$fieldAttributes, string &$name,
|
||||
string &$typeName, string &$langView, string &$nameSingleCode, string &$nameListCode,
|
||||
public function get(string $setType, array &$fieldAttributes, string $name,
|
||||
string $typeName, string $langView, string $nameSingleCode, string $nameListCode,
|
||||
array $placeholders, ?array &$optionArray, ?array $custom = null, string $taber = '');
|
||||
}
|
||||
|
||||
|
@@ -19,7 +19,7 @@ use VDM\Joomla\Componentbuilder\Compiler\Config;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Placeholder;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Customcode;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Customcode\Gui;
|
||||
use VDM\Joomla\Componentbuilder\JoomlaPower\Remote\Get as SuperPower;
|
||||
use VDM\Joomla\Interfaces\Remote\GetInterface as SuperPower;
|
||||
use VDM\Joomla\Utilities\ArrayHelper;
|
||||
use VDM\Joomla\Utilities\JsonHelper;
|
||||
use VDM\Joomla\Utilities\GuidHelper;
|
||||
@@ -379,7 +379,7 @@ final class JoomlaPower implements PowerInterface
|
||||
*/
|
||||
private function handlePowerNotFound(string $guid): bool
|
||||
{
|
||||
if (empty($this->retry[$guid]) && $this->superpower->item($guid, ['remote', 'local']))
|
||||
if (empty($this->retry[$guid]) && $this->setSuperPowers($guid))
|
||||
{
|
||||
// Retry loading the power
|
||||
unset($this->state[$guid]);
|
||||
@@ -529,16 +529,16 @@ final class JoomlaPower implements PowerInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the super powers of this power
|
||||
* Set the super power of this power
|
||||
*
|
||||
* @param string $guid The global unique id of the power
|
||||
*
|
||||
* @return void
|
||||
* @since 3.2.1
|
||||
* @return bool
|
||||
* @since 5.1.1
|
||||
*/
|
||||
private function setSuperPowers(string $guid): void
|
||||
private function setSuperPowers(string $guid): bool
|
||||
{
|
||||
// soon
|
||||
return $this->superpower->item($guid, ['remote', 'local']);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -198,6 +198,7 @@ final class Extractor
|
||||
{
|
||||
// need some special treatment here
|
||||
if ($lang_string_target === 'Joomla' . '.JText._('
|
||||
|| $lang_string_target === 'Joomla' . '.Text._('
|
||||
|| $lang_string_target === 'JText:' . ':script('
|
||||
|| $lang_string_target === 'Text:' . ':script('
|
||||
|| $lang_string_target === 'Joomla__' . '_ba6326ef_cb79_4348_80f4_ab086082e3c5___Power:' . ':script('
|
||||
|
@@ -776,7 +776,8 @@ class Creator implements ServiceProviderInterface
|
||||
$container->get('Field.ModalSelect'),
|
||||
$container->get('Utilities.Xml'),
|
||||
$container->get('Compiler.Creator.Custom.Field.Type.File'),
|
||||
$container->get('Utilities.Counter')
|
||||
$container->get('Utilities.Counter'),
|
||||
$container->get('Compiler.Builder.Component.Fields')
|
||||
);
|
||||
}
|
||||
|
||||
@@ -800,7 +801,8 @@ class Creator implements ServiceProviderInterface
|
||||
$container->get('Field.Attributes'),
|
||||
$container->get('Field.ModalSelect'),
|
||||
$container->get('Compiler.Creator.Custom.Field.Type.File'),
|
||||
$container->get('Utilities.Counter')
|
||||
$container->get('Utilities.Counter'),
|
||||
$container->get('Compiler.Builder.Component.Fields')
|
||||
);
|
||||
}
|
||||
|
||||
|
@@ -16,7 +16,8 @@ use Joomla\DI\Container;
|
||||
use Joomla\DI\ServiceProviderInterface;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\JoomlaPower as Powers;
|
||||
use VDM\Joomla\Componentbuilder\JoomlaPower\Grep;
|
||||
use VDM\Joomla\Componentbuilder\JoomlaPower\Remote\Get;
|
||||
use VDM\Joomla\Componentbuilder\JoomlaPower\Remote\Config;
|
||||
use VDM\Joomla\Componentbuilder\Power\Remote\Get;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\JoomlaPower\Extractor;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\JoomlaPower\Injector;
|
||||
|
||||
@@ -41,6 +42,9 @@ class JoomlaPower implements ServiceProviderInterface
|
||||
$container->alias(Powers::class, 'Joomla.Power')
|
||||
->share('Joomla.Power', [$this, 'getPowers'], true);
|
||||
|
||||
$container->alias(Config::class, 'Joomla.Power.Remote.Config')
|
||||
->share('Joomla.Power.Remote.Config', [$this, 'getRemoteConfig'], true);
|
||||
|
||||
$container->alias(Get::class, 'Joomla.Power.Remote.Get')
|
||||
->share('Joomla.Power.Remote.Get', [$this, 'getRemoteGet'], true);
|
||||
|
||||
@@ -73,6 +77,21 @@ class JoomlaPower implements ServiceProviderInterface
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The Remote Config Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Config
|
||||
* @since 5.1.1
|
||||
*/
|
||||
public function getRemoteConfig(Container $container): Config
|
||||
{
|
||||
return new Config(
|
||||
$container->get('Power.Table')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Remote Get
|
||||
*
|
||||
@@ -84,6 +103,7 @@ class JoomlaPower implements ServiceProviderInterface
|
||||
public function getRemoteGet(Container $container): Get
|
||||
{
|
||||
return new Get(
|
||||
$container->get('Joomla.Power.Remote.Config'),
|
||||
$container->get('Joomla.Power.Grep'),
|
||||
$container->get('Data.Item')
|
||||
);
|
||||
@@ -100,6 +120,7 @@ class JoomlaPower implements ServiceProviderInterface
|
||||
public function getGrep(Container $container): Grep
|
||||
{
|
||||
return new Grep(
|
||||
$container->get('Joomla.Power.Remote.Config'),
|
||||
$container->get('Gitea.Repository.Contents'),
|
||||
$container->get('Network.Resolve'),
|
||||
$container->get('Config')->approved_joomla_paths
|
||||
|
@@ -15,6 +15,8 @@ namespace VDM\Joomla\Componentbuilder\Compiler\Service;
|
||||
use Joomla\DI\Container;
|
||||
use Joomla\DI\ServiceProviderInterface;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Power as Powers;
|
||||
use VDM\Joomla\Componentbuilder\Power\Table;
|
||||
use VDM\Joomla\Componentbuilder\Power\Remote\Config;
|
||||
use VDM\Joomla\Componentbuilder\Power\Remote\Get;
|
||||
use VDM\Joomla\Componentbuilder\Power\Grep;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Power\Autoloader;
|
||||
@@ -48,6 +50,12 @@ class Power implements ServiceProviderInterface
|
||||
$container->alias(Powers::class, 'Power')
|
||||
->share('Power', [$this, 'getPowers'], true);
|
||||
|
||||
$container->alias(Table::class, 'Power.Table')
|
||||
->share('Power.Table', [$this, 'getPowerTable'], true);
|
||||
|
||||
$container->alias(Config::class, 'Power.Remote.Config')
|
||||
->share('Power.Remote.Config', [$this, 'getRemoteConfig'], true);
|
||||
|
||||
$container->alias(Get::class, 'Power.Remote.Get')
|
||||
->share('Power.Remote.Get', [$this, 'getRemoteGet'], true);
|
||||
|
||||
@@ -101,6 +109,34 @@ class Power implements ServiceProviderInterface
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The Power Table Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Table
|
||||
* @since 5.1.1
|
||||
*/
|
||||
public function getPowerTable(Container $container): Table
|
||||
{
|
||||
return new Table();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The Remote Config Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Config
|
||||
* @since 5.1.1
|
||||
*/
|
||||
public function getRemoteConfig(Container $container): Config
|
||||
{
|
||||
return new Config(
|
||||
$container->get('Power.Table')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The Remote Get Class.
|
||||
*
|
||||
@@ -112,6 +148,7 @@ class Power implements ServiceProviderInterface
|
||||
public function getRemoteGet(Container $container): Get
|
||||
{
|
||||
return new Get(
|
||||
$container->get('Power.Remote.Config'),
|
||||
$container->get('Power.Grep'),
|
||||
$container->get('Data.Item')
|
||||
);
|
||||
@@ -128,6 +165,7 @@ class Power implements ServiceProviderInterface
|
||||
public function getGrep(Container $container): Grep
|
||||
{
|
||||
return new Grep(
|
||||
$container->get('Power.Remote.Config'),
|
||||
$container->get('Gitea.Repository.Contents'),
|
||||
$container->get('Network.Resolve'),
|
||||
$container->get('Config')->approved_paths,
|
||||
|
@@ -36,7 +36,7 @@ final class Guid
|
||||
'linkedTable' => 'fieldtype',
|
||||
'linkedColumn' => 'id',
|
||||
'array' => false,
|
||||
'valueType' => 1,
|
||||
'valueType' => 5,
|
||||
],
|
||||
[
|
||||
'table' => 'dynamic_get',
|
||||
@@ -455,6 +455,14 @@ final class Guid
|
||||
'array' => false,
|
||||
'valueType' => 1,
|
||||
],
|
||||
[
|
||||
'table' => 'joomla_component',
|
||||
'column' => 'dashboard',
|
||||
'linkedTables' => ['A' => 'admin_view', 'C' => 'custom_admin_view'],
|
||||
'linkedColumn' => 'id',
|
||||
'array' => false,
|
||||
'valueType' => 4
|
||||
],
|
||||
[
|
||||
'table' => 'joomla_module',
|
||||
'column' => 'libraries',
|
||||
@@ -704,7 +712,7 @@ final class Guid
|
||||
// try to load the update the tables with the schema class
|
||||
try
|
||||
{
|
||||
$messages = $this->migrator->process($this->config);
|
||||
$messages = $this->migrator->process($this->config, $this);
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
|
@@ -20,9 +20,9 @@ use VDM\Joomla\Abstraction\Grep as ExtendingGrep;
|
||||
/**
|
||||
* Global Resource Empowerment Platform
|
||||
*
|
||||
* The Grep feature will try to find your joomla power in the repositories listed in the global
|
||||
* Options of JCB in the super powers tab, and if it can't be found there will try the global core
|
||||
* Super powers of JCB. All searches are performed according the [algorithm:cascading]
|
||||
* The Grep feature will try to find your power in the repositories
|
||||
* linked to this [area], and if it can't be found there will try the global core
|
||||
* Super Powers of JCB. All searches are performed according the [algorithm:cascading]
|
||||
* See documentation for more details: https://git.vdm.dev/joomla/super-powers/wiki
|
||||
*
|
||||
* @since 5.0.3
|
||||
@@ -84,19 +84,25 @@ final class Grep extends ExtendingGrep implements GrepInterface
|
||||
// get the branch name
|
||||
$branch = $this->getBranchName($path);
|
||||
|
||||
// get the guid_field key
|
||||
$guid_field = $this->getGuidField();
|
||||
|
||||
// get the settings path
|
||||
$settings_path = $this->getSettingsPath();
|
||||
|
||||
// load the base and token if set
|
||||
$this->loadApi($this->contents, $path->base ?? null, $path->token ?? null);
|
||||
|
||||
// get the settings
|
||||
if (($power = $this->loadRemoteFile($path->organisation, $path->repository, $path->index->{$guid}->path . '/item.json', $branch)) !== null &&
|
||||
isset($power->guid))
|
||||
if (($power = $this->loadRemoteFile($path->organisation, $path->repository, $path->index->{$guid}->path . '/' . $settings_path, $branch)) !== null &&
|
||||
isset($power->{$guid_field}))
|
||||
{
|
||||
// set the git details in params
|
||||
$path_guid = $path->guid ?? null;
|
||||
if ($path_guid !== null)
|
||||
{
|
||||
// get the Settings meta
|
||||
if (($meta = $this->contents->metadata($path->organisation, $path->repository, $path->index->{$guid}->path . '/item.json', $branch)) !== null &&
|
||||
if (($meta = $this->contents->metadata($path->organisation, $path->repository, $path->index->{$guid}->path . '/' . $settings_path, $branch)) !== null &&
|
||||
isset($meta->sha))
|
||||
{
|
||||
if (isset($power->params) && is_object($power->params) &&
|
||||
|
@@ -34,12 +34,19 @@ final class Item implements ItemInterface
|
||||
{
|
||||
// build readme
|
||||
$readme = ["```
|
||||
██╗ ██████╗ ██████╗ ███╗ ███╗██╗ █████╗ ███████╗██╗███████╗██╗ ██████╗ ████████╗██╗ ██╗██████╗ ███████╗
|
||||
██║██╔═══██╗██╔═══██╗████╗ ████║██║ ██╔══██╗ ██╔════╝██║██╔════╝██║ ██╔══██╗ ╚══██╔══╝╚██╗ ██╔╝██╔══██╗██╔════╝
|
||||
██║██║ ██║██║ ██║██╔████╔██║██║ ███████║ █████╗ ██║█████╗ ██║ ██║ ██║ ██║ ╚████╔╝ ██████╔╝█████╗
|
||||
██ ██║██║ ██║██║ ██║██║╚██╔╝██║██║ ██╔══██║ ██╔══╝ ██║██╔══╝ ██║ ██║ ██║ ██║ ╚██╔╝ ██╔═══╝ ██╔══╝
|
||||
╚█████╔╝╚██████╔╝╚██████╔╝██║ ╚═╝ ██║███████╗██║ ██║ ██║ ██║███████╗███████╗██████╔╝ ██║ ██║ ██║ ███████╗
|
||||
╚════╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝ ╚═╝ ╚═╝╚══════╝╚══════╝╚═════╝ ╚═╝ ╚═╝ ╚═╝ ╚══════╝
|
||||
██╗ ██████╗ ██████╗ ███╗ ███╗██╗ █████╗
|
||||
██║██╔═══██╗██╔═══██╗████╗ ████║██║ ██╔══██╗
|
||||
██║██║ ██║██║ ██║██╔████╔██║██║ ███████║
|
||||
██ ██║██║ ██║██║ ██║██║╚██╔╝██║██║ ██╔══██║
|
||||
╚█████╔╝╚██████╔╝╚██████╔╝██║ ╚═╝ ██║███████╗██║ ██║
|
||||
╚════╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
|
||||
|
||||
███████╗██╗███████╗██╗ ██████╗ ████████╗██╗ ██╗██████╗ ███████╗
|
||||
██╔════╝██║██╔════╝██║ ██╔══██╗ ╚══██╔══╝╚██╗ ██╔╝██╔══██╗██╔════╝
|
||||
█████╗ ██║█████╗ ██║ ██║ ██║ ██║ ╚████╔╝ ██████╔╝█████╗
|
||||
██╔══╝ ██║██╔══╝ ██║ ██║ ██║ ██║ ╚██╔╝ ██╔═══╝ ██╔══╝
|
||||
██║ ██║███████╗███████╗██████╔╝ ██║ ██║ ██║ ███████╗
|
||||
╚═╝ ╚═╝╚══════╝╚══════╝╚═════╝ ╚═╝ ╚═╝ ╚═╝ ╚══════╝
|
||||
```"];
|
||||
// system name
|
||||
$readme[] = "# " . $item->name;
|
||||
@@ -53,7 +60,7 @@ final class Item implements ItemInterface
|
||||
$readme[] = "\n" . $item->short_description;
|
||||
}
|
||||
|
||||
$readme[] = "\nThe Joomla! field types within this repository provide an essential mechanism for integrating Joomla-related field type into the Joomla Component Builder (JCB). Each field type is meticulously designed to ensure compatibility and ease of use within the JCB framework, allowing developers to effortlessly incorporate and manage custom fields in their components. By utilizing the reset functionality, users can seamlessly update individual field types to align with the latest versions maintained in our core repository, ensuring that their projects benefit from the most up-to-date features and fixes. Additionally, for those who prefer a more personalized approach, the repository can be forked, enabling developers to maintain and distribute their customized field types independently from the broader JCB community. This level of flexibility underscores the open-source nature of JCB, offering you the freedom to adapt and extend your components according to your specific needs, while still benefiting from a robust, community-driven ecosystem.";
|
||||
$readme[] = "\nThe Joomla! field type within this repository provide an essential mechanism for integrating Joomla-related field type into the Joomla Component Builder (JCB). Each field type is meticulously designed to ensure compatibility and ease of use within the JCB framework, allowing developers to effortlessly incorporate and manage custom fields in their components. By utilizing the reset functionality, users can seamlessly update individual field types to align with the latest versions maintained in our core repository, ensuring that their projects benefit from the most up-to-date features and fixes.\n\nAdditionally, for those who prefer a more personalized approach, the repository can be forked, enabling developers to maintain and distribute their customized field types independently from the broader JCB community. This level of flexibility underscores the open-source nature of JCB, offering you the freedom to adapt and extend your components according to your specific needs, while still benefiting from a robust, community-driven ecosystem.";
|
||||
|
||||
// yes you can remove this, but why?
|
||||
$readme[] = "\n---\n```
|
||||
|
@@ -0,0 +1,154 @@
|
||||
<?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\Fieldtype\Remote;
|
||||
|
||||
|
||||
use VDM\Joomla\Interfaces\Remote\ConfigInterface;
|
||||
use VDM\Joomla\Abstraction\Remote\Config as ExtendingConfig;
|
||||
|
||||
|
||||
/**
|
||||
* Base Configure values for the remote classes
|
||||
*
|
||||
* @since 5.1.1
|
||||
*/
|
||||
final class Config extends ExtendingConfig implements ConfigInterface
|
||||
{
|
||||
/**
|
||||
* Table Name
|
||||
*
|
||||
* @var string
|
||||
* @since 5.0.3
|
||||
*/
|
||||
protected string $table = 'fieldtype';
|
||||
|
||||
/**
|
||||
* Area Name
|
||||
*
|
||||
* @var string|null
|
||||
* @since 5.0.3
|
||||
*/
|
||||
protected ?string $area = 'Field Type';
|
||||
|
||||
/**
|
||||
* Prefix Key
|
||||
*
|
||||
* @var string
|
||||
* @since 3.2.2
|
||||
*/
|
||||
protected string $prefix_key = '';
|
||||
|
||||
/**
|
||||
* Suffix Key
|
||||
*
|
||||
* @var string
|
||||
* @since 3.2.2
|
||||
*/
|
||||
protected string $suffix_key = '';
|
||||
|
||||
/**
|
||||
* The main readme file path
|
||||
*
|
||||
* @var string
|
||||
* @since 5.1.1
|
||||
*/
|
||||
// [DEFAULT] protected string $main_readme_path = 'README.md';
|
||||
|
||||
/**
|
||||
* The index file path (index of all items)
|
||||
*
|
||||
* @var string
|
||||
* @since 3.2.2
|
||||
*/
|
||||
// [DEFAULT] protected string $index_path = 'index.json';
|
||||
|
||||
/**
|
||||
* The item (files) source path
|
||||
*
|
||||
* @var string
|
||||
* @since 5.1.1
|
||||
*/
|
||||
// [DEFAULT] protected string $src_path = 'src';
|
||||
|
||||
/**
|
||||
* The item settings file path
|
||||
*
|
||||
* @var string
|
||||
* @since 3.2.2
|
||||
*/
|
||||
// [DEFAULT] protected string $settings_path = 'item.json';
|
||||
|
||||
/**
|
||||
* The item guid=unique field
|
||||
*
|
||||
* @var string
|
||||
* @since 5.1.1
|
||||
*/
|
||||
// [DEFAULT] protected string $guid_field = 'guid';
|
||||
|
||||
/**
|
||||
* The item map
|
||||
*
|
||||
* @var array
|
||||
* @since 5.0.3
|
||||
protected array $map = [];
|
||||
[DEFAULT] */
|
||||
|
||||
/**
|
||||
* The index map
|
||||
* must always have: [name,path,guid]
|
||||
* you can add more
|
||||
*
|
||||
* @var array
|
||||
* @since 5.0.3
|
||||
*/
|
||||
protected array $index_map = [
|
||||
'name' => 'index_map_IndexName',
|
||||
'desc' => 'index_map_ShortDescription',
|
||||
'settings' => 'index_map_IndexSettingsPath',
|
||||
'path' => 'index_map_IndexPath',
|
||||
'guid' => 'index_map_IndexGUID'
|
||||
];
|
||||
|
||||
/**
|
||||
* The index header
|
||||
* mapping the index map to a table
|
||||
* must always have: [name,path,guid,local]
|
||||
* with [name] always first
|
||||
* with [path,guid,local] always last
|
||||
* you can add more in between
|
||||
*
|
||||
* @var array
|
||||
* @since 5.1.1
|
||||
*/
|
||||
protected array $index_header = [
|
||||
'name',
|
||||
'desc',
|
||||
'path',
|
||||
'guid',
|
||||
'local'
|
||||
];
|
||||
|
||||
/**
|
||||
* Core Placeholders
|
||||
*
|
||||
* @var array
|
||||
* @since 5.0.3
|
||||
protected array $placeholders = [
|
||||
'[['.'[NamespacePrefix]]]' => 'VDM',
|
||||
'[['.'[ComponentNamespace]]]' => 'Componentbuilder',
|
||||
'[['.'[Component]]]' => 'Componentbuilder',
|
||||
'[['.'[component]]]' => 'componentbuilder'
|
||||
];
|
||||
[DEFAULT] */
|
||||
}
|
||||
|
@@ -12,6 +12,7 @@
|
||||
namespace VDM\Joomla\Componentbuilder\Fieldtype\Remote;
|
||||
|
||||
|
||||
use Joomla\CMS\Language\Text;
|
||||
use VDM\Joomla\Interfaces\Remote\SetInterface;
|
||||
use VDM\Joomla\Abstraction\Remote\Set as ExtendingSet;
|
||||
|
||||
@@ -23,67 +24,6 @@ use VDM\Joomla\Abstraction\Remote\Set as ExtendingSet;
|
||||
*/
|
||||
final class Set extends ExtendingSet implements SetInterface
|
||||
{
|
||||
/**
|
||||
* Table Name
|
||||
*
|
||||
* @var string
|
||||
* @since 5.0.3
|
||||
*/
|
||||
protected string $table = 'fieldtype';
|
||||
|
||||
/**
|
||||
* Area Name
|
||||
*
|
||||
* @var string
|
||||
* @since 5.0.3
|
||||
*/
|
||||
protected string $area = 'Joomla Field Type';
|
||||
|
||||
/**
|
||||
* Prefix Key
|
||||
*
|
||||
* @var string
|
||||
* @since 5.0.3
|
||||
*/
|
||||
protected string $prefix_key = '';
|
||||
|
||||
/**
|
||||
* The item map
|
||||
*
|
||||
* @var array
|
||||
* @since 5.0.3
|
||||
*/
|
||||
protected array $map = [
|
||||
'name' => 'name',
|
||||
'short_description' => 'short_description',
|
||||
'description' => 'description',
|
||||
'properties' => 'properties',
|
||||
'has_defaults' => 'has_defaults',
|
||||
'datatype' => 'datatype',
|
||||
'datalenght' => 'datalenght',
|
||||
'datalenght_other' => 'datalenght_other',
|
||||
'datadefault' => 'datadefault',
|
||||
'datadefault_other' => 'datadefault_other',
|
||||
'indexes' => 'indexes',
|
||||
'null_switch' => 'null_switch',
|
||||
'store' => 'store',
|
||||
'guid' => 'guid'
|
||||
];
|
||||
|
||||
/**
|
||||
* The index map
|
||||
*
|
||||
* @var array
|
||||
* @since 5.0.3
|
||||
*/
|
||||
protected array $index_map = [
|
||||
'name' => 'index_map_IndexName',
|
||||
'desc' => 'index_map_ShortDescription',
|
||||
'settings' => 'index_map_IndexSettingsPath',
|
||||
'path' => 'index_map_IndexPath',
|
||||
'guid' => 'index_map_IndexGUID'
|
||||
];
|
||||
|
||||
/**
|
||||
* update an existing item (if changed)
|
||||
*
|
||||
@@ -96,25 +36,36 @@ final class Set extends ExtendingSet implements SetInterface
|
||||
*/
|
||||
protected function updateItem(object $item, object $existing, object $repo): bool
|
||||
{
|
||||
// make sure there was a change
|
||||
$sha = $existing->params->source[$repo->guid . '-settings'] ?? null;
|
||||
$existing = $this->mapItem($existing);
|
||||
$area = $this->getArea();
|
||||
$item_name = $this->index_map_IndexName($item);
|
||||
$repo_name = $this->getRepoName($repo);
|
||||
|
||||
if ($sha === null || $this->areObjectsEqual($item, $existing))
|
||||
{
|
||||
$this->messages->add('warning', Text::sprintf('COM_COMPONENTBUILDER_S_ITEM_S_DETAILS_IN_REPOS_DID_NOT_CHANGE_SO_NO_UPDATE_WAS_MADE', $area, $item_name, $repo_name));
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->git->update(
|
||||
$result = $this->git->update(
|
||||
$repo->organisation, // The owner name.
|
||||
$repo->repository, // The repository name.
|
||||
'src/' . $item->guid . '/' . $this->getSettingsPath(), // The file path.
|
||||
$this->index_map_IndexSettingsPath($item), // The file path.
|
||||
json_encode($item, JSON_PRETTY_PRINT), // The file content.
|
||||
'Update ' . $item->name, // The commit message.
|
||||
$sha, // The blob SHA of the old file.
|
||||
$repo->write_branch // The branch name.
|
||||
);
|
||||
|
||||
return true;
|
||||
$success = is_object($result);
|
||||
|
||||
if (!$success)
|
||||
{
|
||||
$this->messages->add('warning', Text::sprintf('COM_COMPONENTBUILDER_S_ITEM_S_DETAILS_IN_REPOS_FAILED_TO_UPDATE', $area, $item_name, $repo_name));
|
||||
}
|
||||
|
||||
return $success;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -123,19 +74,21 @@ final class Set extends ExtendingSet implements SetInterface
|
||||
* @param object $item
|
||||
* @param object $repo
|
||||
*
|
||||
* @return void
|
||||
* @return bool
|
||||
* @since 5.0.3
|
||||
*/
|
||||
protected function createItem(object $item, object $repo): void
|
||||
protected function createItem(object $item, object $repo): bool
|
||||
{
|
||||
$this->git->create(
|
||||
$result = $this->git->create(
|
||||
$repo->organisation, // The owner name.
|
||||
$repo->repository, // The repository name.
|
||||
'src/' . $item->guid . '/' . $this->getSettingsPath(), // The file path.
|
||||
$this->index_map_IndexSettingsPath($item), // The file path.
|
||||
json_encode($item, JSON_PRETTY_PRINT), // The file content.
|
||||
'Create ' . $item->name, // The commit message.
|
||||
$repo->write_branch // The branch name.
|
||||
);
|
||||
|
||||
return is_object($result);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -160,7 +113,7 @@ final class Set extends ExtendingSet implements SetInterface
|
||||
$this->git->update(
|
||||
$repo->organisation, // The owner name.
|
||||
$repo->repository, // The repository name.
|
||||
'src/' . $item->guid . '/README.md', // The file path.
|
||||
$this->index_map_IndexPath($item) . '/README.md', // The file path.
|
||||
$this->itemReadme->get($item), // The file content.
|
||||
'Update ' . $item->name . ' readme file', // The commit message.
|
||||
$sha, // The blob SHA of the old file.
|
||||
@@ -182,20 +135,22 @@ final class Set extends ExtendingSet implements SetInterface
|
||||
$this->git->create(
|
||||
$repo->organisation, // The owner name.
|
||||
$repo->repository, // The repository name.
|
||||
'src/' . $item->guid . '/README.md', // The file path.
|
||||
$this->index_map_IndexPath($item) . '/README.md', // The file path.
|
||||
$this->itemReadme->get($item), // The file content.
|
||||
'Create ' . $item->name . ' readme file', // The commit message.
|
||||
$repo->write_branch // The branch name.
|
||||
);
|
||||
}
|
||||
|
||||
//// index_map_ (area) /////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* Get the item name for the index values
|
||||
*
|
||||
* @param object $item
|
||||
*
|
||||
* @return string|null
|
||||
* @since 5.0.3
|
||||
* @since 3.2.2
|
||||
*/
|
||||
protected function index_map_IndexName(object $item): ?string
|
||||
{
|
||||
@@ -212,7 +167,7 @@ final class Set extends ExtendingSet implements SetInterface
|
||||
*/
|
||||
protected function index_map_ShortDescription(object $item): ?string
|
||||
{
|
||||
return $item->short_description ?? null;
|
||||
return $item->short_description ?? $item->description ?? null;
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -15,9 +15,11 @@ namespace VDM\Joomla\Componentbuilder\Fieldtype\Service;
|
||||
use Joomla\DI\Container;
|
||||
use Joomla\DI\ServiceProviderInterface;
|
||||
use VDM\Joomla\Componentbuilder\Fieldtype\Config;
|
||||
use VDM\Joomla\Componentbuilder\Table;
|
||||
use VDM\Joomla\Componentbuilder\Power\Table;
|
||||
use VDM\Joomla\Componentbuilder\Package\MessageBus;
|
||||
use VDM\Joomla\Componentbuilder\Fieldtype\Grep;
|
||||
use VDM\Joomla\Componentbuilder\Fieldtype\Remote\Get;
|
||||
use VDM\Joomla\Componentbuilder\Fieldtype\Remote\Config as RemoteConfig;
|
||||
use VDM\Joomla\Componentbuilder\Power\Remote\Get;
|
||||
use VDM\Joomla\Componentbuilder\Fieldtype\Remote\Set;
|
||||
use VDM\Joomla\Componentbuilder\Fieldtype\Readme\Item as ItemReadme;
|
||||
use VDM\Joomla\Componentbuilder\Fieldtype\Readme\Main as MainReadme;
|
||||
@@ -43,12 +45,18 @@ class Fieldtype implements ServiceProviderInterface
|
||||
$container->alias(Config::class, 'Config')
|
||||
->share('Config', [$this, 'getConfig'], true);
|
||||
|
||||
$container->alias(Table::class, 'Table')
|
||||
->share('Table', [$this, 'getTable'], true);
|
||||
$container->alias(Table::class, 'Power.Table')->alias('Table', 'Power.Table')
|
||||
->share('Power.Table', [$this, 'getPowerTable'], true);
|
||||
|
||||
$container->alias(MessageBus::class, 'Power.Message')
|
||||
->share('Power.Message', [$this, 'getMessageBus'], true);
|
||||
|
||||
$container->alias(Grep::class, 'Joomla.Fieldtype.Grep')
|
||||
->share('Joomla.Fieldtype.Grep', [$this, 'getGrep'], true);
|
||||
|
||||
$container->alias(RemoteConfig::class, 'Joomla.Fieldtype.Remote.Config')
|
||||
->share('Joomla.Fieldtype.Remote.Config', [$this, 'getRemoteConfig'], true);
|
||||
|
||||
$container->alias(Get::class, 'Joomla.Fieldtype.Remote.Get')
|
||||
->share('Joomla.Fieldtype.Remote.Get', [$this, 'getRemoteGet'], true);
|
||||
|
||||
@@ -76,18 +84,31 @@ class Fieldtype implements ServiceProviderInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The Table Class.
|
||||
* Get The Power Table Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Table
|
||||
* @since 3.2.1
|
||||
* @since 5.2.1
|
||||
*/
|
||||
public function getTable(Container $container): Table
|
||||
public function getPowerTable(Container $container): Table
|
||||
{
|
||||
return new Table();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The Message Bus Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return MessageBus
|
||||
* @since 5.2.1
|
||||
*/
|
||||
public function getMessageBus(Container $container): MessageBus
|
||||
{
|
||||
return new MessageBus();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The Grep Class.
|
||||
*
|
||||
@@ -99,12 +120,28 @@ class Fieldtype implements ServiceProviderInterface
|
||||
public function getGrep(Container $container): Grep
|
||||
{
|
||||
return new Grep(
|
||||
$container->get('Joomla.Fieldtype.Remote.Config'),
|
||||
$container->get('Gitea.Repository.Contents'),
|
||||
$container->get('Network.Resolve'),
|
||||
$container->get('Config')->approved_joomla_paths
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The Remote Config Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return RemoteConfig
|
||||
* @since 5.2.1
|
||||
*/
|
||||
public function getRemoteConfig(Container $container): RemoteConfig
|
||||
{
|
||||
return new RemoteConfig(
|
||||
$container->get('Power.Table')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The Remote Get Class.
|
||||
*
|
||||
@@ -116,6 +153,7 @@ class Fieldtype implements ServiceProviderInterface
|
||||
public function getRemoteGet(Container $container): Get
|
||||
{
|
||||
return new Get(
|
||||
$container->get('Joomla.Fieldtype.Remote.Config'),
|
||||
$container->get('Joomla.Fieldtype.Grep'),
|
||||
$container->get('Data.Item')
|
||||
);
|
||||
@@ -132,12 +170,14 @@ class Fieldtype implements ServiceProviderInterface
|
||||
public function getRemoteSet(Container $container): Set
|
||||
{
|
||||
return new Set(
|
||||
$container->get('Config')->approved_joomla_paths,
|
||||
$container->get('Joomla.Fieldtype.Remote.Config'),
|
||||
$container->get('Joomla.Fieldtype.Grep'),
|
||||
$container->get('Data.Items'),
|
||||
$container->get('Joomla.Fieldtype.Readme.Item'),
|
||||
$container->get('Joomla.Fieldtype.Readme.Main'),
|
||||
$container->get('Gitea.Repository.Contents')
|
||||
$container->get('Gitea.Repository.Contents'),
|
||||
$container->get('Power.Message'),
|
||||
$container->get('Config')->approved_joomla_paths
|
||||
);
|
||||
}
|
||||
|
||||
|
@@ -20,9 +20,9 @@ use VDM\Joomla\Abstraction\Grep as ExtendingGrep;
|
||||
/**
|
||||
* Global Resource Empowerment Platform
|
||||
*
|
||||
* The Grep feature will try to find your joomla power in the repositories listed in the global
|
||||
* Options of JCB in the super powers tab, and if it can't be found there will try the global core
|
||||
* Super powers of JCB. All searches are performed according the [algorithm:cascading]
|
||||
* The Grep feature will try to find your power in the repositories
|
||||
* linked to this [area], and if it can't be found there will try the global core
|
||||
* Super Powers of JCB. All searches are performed according the [algorithm:cascading]
|
||||
* See documentation for more details: https://git.vdm.dev/joomla/super-powers/wiki
|
||||
*
|
||||
* @since 3.2.1
|
||||
@@ -84,19 +84,25 @@ final class Grep extends ExtendingGrep implements GrepInterface
|
||||
// get the branch name
|
||||
$branch = $this->getBranchName($path);
|
||||
|
||||
// get the guid_field key
|
||||
$guid_field = $this->getGuidField();
|
||||
|
||||
// get the settings path
|
||||
$settings_path = $this->getSettingsPath();
|
||||
|
||||
// load the base and token if set
|
||||
$this->loadApi($this->contents, $path->base ?? null, $path->token ?? null);
|
||||
|
||||
// get the settings
|
||||
if (($power = $this->loadRemoteFile($path->organisation, $path->repository, $path->index->{$guid}->path . '/item.json', $branch)) !== null &&
|
||||
isset($power->guid))
|
||||
if (($power = $this->loadRemoteFile($path->organisation, $path->repository, $path->index->{$guid}->path . '/' . $settings_path, $branch)) !== null &&
|
||||
isset($power->{$guid_field}))
|
||||
{
|
||||
// set the git details in params
|
||||
$path_guid = $path->guid ?? null;
|
||||
if ($path_guid !== null)
|
||||
{
|
||||
// get the Settings meta
|
||||
if (($meta = $this->contents->metadata($path->organisation, $path->repository, $path->index->{$guid}->path . '/item.json', $branch)) !== null &&
|
||||
if (($meta = $this->contents->metadata($path->organisation, $path->repository, $path->index->{$guid}->path . '/' . $settings_path, $branch)) !== null &&
|
||||
isset($meta->sha))
|
||||
{
|
||||
if (isset($power->params) && is_object($power->params) &&
|
||||
|
@@ -0,0 +1,154 @@
|
||||
<?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\JoomlaPower\Remote;
|
||||
|
||||
|
||||
use VDM\Joomla\Interfaces\Remote\ConfigInterface;
|
||||
use VDM\Joomla\Abstraction\Remote\Config as ExtendingConfig;
|
||||
|
||||
|
||||
/**
|
||||
* Base Configure values for the remote classes
|
||||
*
|
||||
* @since 5.1.1
|
||||
*/
|
||||
final class Config extends ExtendingConfig implements ConfigInterface
|
||||
{
|
||||
/**
|
||||
* Table Name
|
||||
*
|
||||
* @var string
|
||||
* @since 5.0.3
|
||||
*/
|
||||
protected string $table = 'joomla_power';
|
||||
|
||||
/**
|
||||
* Area Name
|
||||
*
|
||||
* @var string|null
|
||||
* @since 5.0.3
|
||||
*/
|
||||
protected ?string $area = 'Joomla Power';
|
||||
|
||||
/**
|
||||
* Prefix Key
|
||||
*
|
||||
* @var string
|
||||
* @since 3.2.2
|
||||
*/
|
||||
protected string $prefix_key = 'Joomla---';
|
||||
|
||||
/**
|
||||
* Suffix Key
|
||||
*
|
||||
* @var string
|
||||
* @since 3.2.2
|
||||
*/
|
||||
// [DEFAULT] protected string $suffix_key = '---Power';
|
||||
|
||||
/**
|
||||
* The main readme file path
|
||||
*
|
||||
* @var string
|
||||
* @since 5.1.1
|
||||
*/
|
||||
// [DEFAULT] protected string $main_readme_path = 'README.md';
|
||||
|
||||
/**
|
||||
* The index file path (index of all items)
|
||||
*
|
||||
* @var string
|
||||
* @since 3.2.2
|
||||
*/
|
||||
// [DEFAULT] protected string $index_path = 'index.json';
|
||||
|
||||
/**
|
||||
* The item (files) source path
|
||||
*
|
||||
* @var string
|
||||
* @since 5.1.1
|
||||
*/
|
||||
// [DEFAULT] protected string $src_path = 'src';
|
||||
|
||||
/**
|
||||
* The item settings file path
|
||||
*
|
||||
* @var string
|
||||
* @since 3.2.2
|
||||
*/
|
||||
// [DEFAULT] protected string $settings_path = 'item.json';
|
||||
|
||||
/**
|
||||
* The item guid=unique field
|
||||
*
|
||||
* @var string
|
||||
* @since 5.1.1
|
||||
*/
|
||||
// [DEFAULT] protected string $guid_field = 'guid';
|
||||
|
||||
/**
|
||||
* The item map
|
||||
*
|
||||
* @var array
|
||||
* @since 5.0.3
|
||||
protected array $map = [];
|
||||
[DEFAULT] */
|
||||
|
||||
/**
|
||||
* The index map
|
||||
* must always have: [name,path,guid]
|
||||
* you can add more
|
||||
*
|
||||
* @var array
|
||||
* @since 5.0.3
|
||||
*/
|
||||
protected array $index_map = [
|
||||
'name' => 'index_map_IndexName',
|
||||
'settings' => 'index_map_IndexSettingsPath',
|
||||
'path' => 'index_map_IndexPath',
|
||||
'jpk' => 'index_map_IndexKey',
|
||||
'guid' => 'index_map_IndexGUID'
|
||||
];
|
||||
|
||||
/**
|
||||
* The index header
|
||||
* mapping the index map to a table
|
||||
* must always have: [name,path,guid,local]
|
||||
* with [name] always first
|
||||
* with [path,guid,local] always last
|
||||
* you can add more in between
|
||||
*
|
||||
* @var array
|
||||
* @since 5.1.1
|
||||
*/
|
||||
protected array $index_header = [
|
||||
'name',
|
||||
'jpk',
|
||||
'path',
|
||||
'guid',
|
||||
'local'
|
||||
];
|
||||
|
||||
/**
|
||||
* Core Placeholders
|
||||
*
|
||||
* @var array
|
||||
* @since 5.0.3
|
||||
protected array $placeholders = [
|
||||
'[['.'[NamespacePrefix]]]' => 'VDM',
|
||||
'[['.'[ComponentNamespace]]]' => 'Componentbuilder',
|
||||
'[['.'[Component]]]' => 'Componentbuilder',
|
||||
'[['.'[component]]]' => 'componentbuilder'
|
||||
];
|
||||
[DEFAULT] */
|
||||
}
|
||||
|
@@ -12,6 +12,7 @@
|
||||
namespace VDM\Joomla\Componentbuilder\JoomlaPower\Remote;
|
||||
|
||||
|
||||
use Joomla\CMS\Language\Text;
|
||||
use VDM\Joomla\Interfaces\Remote\SetInterface;
|
||||
use VDM\Joomla\Abstraction\Remote\Set as ExtendingSet;
|
||||
|
||||
@@ -23,57 +24,6 @@ use VDM\Joomla\Abstraction\Remote\Set as ExtendingSet;
|
||||
*/
|
||||
final class Set extends ExtendingSet implements SetInterface
|
||||
{
|
||||
/**
|
||||
* Table Name
|
||||
*
|
||||
* @var string
|
||||
* @since 3.2.2
|
||||
*/
|
||||
protected string $table = 'joomla_power';
|
||||
|
||||
/**
|
||||
* Area Name
|
||||
*
|
||||
* @var string
|
||||
* @since 3.2.2
|
||||
*/
|
||||
protected string $area = 'Joomla Power';
|
||||
|
||||
/**
|
||||
* Prefix Key
|
||||
*
|
||||
* @var string
|
||||
* @since 3.2.2
|
||||
*/
|
||||
protected string $prefix_key = 'Joomla---';
|
||||
|
||||
/**
|
||||
* The item map
|
||||
*
|
||||
* @var array
|
||||
* @since 3.2.2
|
||||
*/
|
||||
protected array $map = [
|
||||
'system_name' => 'system_name',
|
||||
'settings' => 'settings',
|
||||
'guid' => 'guid',
|
||||
'description' => 'description'
|
||||
];
|
||||
|
||||
/**
|
||||
* The index map
|
||||
*
|
||||
* @var array
|
||||
* @since 3.2.2
|
||||
*/
|
||||
protected array $index_map = [
|
||||
'name' => 'index_map_IndexName',
|
||||
'settings' => 'index_map_IndexSettingsPath',
|
||||
'path' => 'index_map_IndexPath',
|
||||
'jpk' => 'index_map_IndexKey',
|
||||
'guid' => 'index_map_IndexGUID'
|
||||
];
|
||||
|
||||
/**
|
||||
* update an existing item (if changed)
|
||||
*
|
||||
@@ -86,25 +36,36 @@ final class Set extends ExtendingSet implements SetInterface
|
||||
*/
|
||||
protected function updateItem(object $item, object $existing, object $repo): bool
|
||||
{
|
||||
// make sure there was a change
|
||||
$sha = $existing->params->source[$repo->guid . '-settings'] ?? null;
|
||||
$existing = $this->mapItem($existing);
|
||||
$area = $this->getArea();
|
||||
$item_name = $this->index_map_IndexName($item);
|
||||
$repo_name = $this->getRepoName($repo);
|
||||
|
||||
if ($sha === null || $this->areObjectsEqual($item, $existing))
|
||||
{
|
||||
$this->messages->add('warning', Text::sprintf('COM_COMPONENTBUILDER_S_ITEM_S_DETAILS_IN_REPOS_DID_NOT_CHANGE_SO_NO_UPDATE_WAS_MADE', $area, $item_name, $repo_name));
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->git->update(
|
||||
$result = $this->git->update(
|
||||
$repo->organisation, // The owner name.
|
||||
$repo->repository, // The repository name.
|
||||
'src/' . $item->guid . '/' . $this->getSettingsPath(), // The file path.
|
||||
$this->index_map_IndexSettingsPath($item), // The file path.
|
||||
json_encode($item, JSON_PRETTY_PRINT), // The file content.
|
||||
'Update ' . $item->system_name, // The commit message.
|
||||
$sha, // The blob SHA of the old file.
|
||||
$repo->write_branch // The branch name.
|
||||
);
|
||||
|
||||
return true;
|
||||
$success = is_object($result);
|
||||
|
||||
if (!$success)
|
||||
{
|
||||
$this->messages->add('warning', Text::sprintf('COM_COMPONENTBUILDER_S_ITEM_S_DETAILS_IN_REPOS_FAILED_TO_UPDATE', $area, $item_name, $repo_name));
|
||||
}
|
||||
|
||||
return $success;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -113,19 +74,21 @@ final class Set extends ExtendingSet implements SetInterface
|
||||
* @param object $item
|
||||
* @param object $repo
|
||||
*
|
||||
* @return void
|
||||
* @return bool
|
||||
* @since 3.2.2
|
||||
*/
|
||||
protected function createItem(object $item, object $repo): void
|
||||
protected function createItem(object $item, object $repo): bool
|
||||
{
|
||||
$this->git->create(
|
||||
$result = $this->git->create(
|
||||
$repo->organisation, // The owner name.
|
||||
$repo->repository, // The repository name.
|
||||
'src/' . $item->guid . '/' . $this->getSettingsPath(), // The file path.
|
||||
$this->index_map_IndexSettingsPath($item), // The file path.
|
||||
json_encode($item, JSON_PRETTY_PRINT), // The file content.
|
||||
'Create ' . $item->system_name, // The commit message.
|
||||
$repo->write_branch // The branch name.
|
||||
);
|
||||
|
||||
return is_object($result);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -150,7 +113,7 @@ final class Set extends ExtendingSet implements SetInterface
|
||||
$this->git->update(
|
||||
$repo->organisation, // The owner name.
|
||||
$repo->repository, // The repository name.
|
||||
'src/' . $item->guid . '/README.md', // The file path.
|
||||
$this->index_map_IndexPath($item) . '/README.md', // The file path.
|
||||
$this->itemReadme->get($item), // The file content.
|
||||
'Update ' . $item->system_name . ' readme file', // The commit message.
|
||||
$sha, // The blob SHA of the old file.
|
||||
@@ -172,7 +135,7 @@ final class Set extends ExtendingSet implements SetInterface
|
||||
$this->git->create(
|
||||
$repo->organisation, // The owner name.
|
||||
$repo->repository, // The repository name.
|
||||
'src/' . $item->guid . '/README.md', // The file path.
|
||||
$this->index_map_IndexPath($item) . '/README.md', // The file path.
|
||||
$this->itemReadme->get($item), // The file content.
|
||||
'Create ' . $item->system_name . ' readme file', // The commit message.
|
||||
$repo->write_branch // The branch name.
|
||||
|
@@ -15,9 +15,11 @@ namespace VDM\Joomla\Componentbuilder\JoomlaPower\Service;
|
||||
use Joomla\DI\Container;
|
||||
use Joomla\DI\ServiceProviderInterface;
|
||||
use VDM\Joomla\Componentbuilder\JoomlaPower\Config;
|
||||
use VDM\Joomla\Componentbuilder\Table;
|
||||
use VDM\Joomla\Componentbuilder\Power\Table;
|
||||
use VDM\Joomla\Componentbuilder\Package\MessageBus;
|
||||
use VDM\Joomla\Componentbuilder\JoomlaPower\Grep;
|
||||
use VDM\Joomla\Componentbuilder\JoomlaPower\Remote\Get;
|
||||
use VDM\Joomla\Componentbuilder\JoomlaPower\Remote\Config as RemoteConfig;
|
||||
use VDM\Joomla\Componentbuilder\Power\Remote\Get;
|
||||
use VDM\Joomla\Componentbuilder\JoomlaPower\Remote\Set;
|
||||
use VDM\Joomla\Componentbuilder\JoomlaPower\Readme\Item as ItemReadme;
|
||||
use VDM\Joomla\Componentbuilder\JoomlaPower\Readme\Main as MainReadme;
|
||||
@@ -43,12 +45,18 @@ class JoomlaPower implements ServiceProviderInterface
|
||||
$container->alias(Config::class, 'Config')
|
||||
->share('Config', [$this, 'getConfig'], true);
|
||||
|
||||
$container->alias(Table::class, 'Table')
|
||||
->share('Table', [$this, 'getTable'], true);
|
||||
$container->alias(Table::class, 'Power.Table')->alias('Table', 'Power.Table')
|
||||
->share('Power.Table', [$this, 'getPowerTable'], true);
|
||||
|
||||
$container->alias(MessageBus::class, 'Power.Message')
|
||||
->share('Power.Message', [$this, 'getMessageBus'], true);
|
||||
|
||||
$container->alias(Grep::class, 'Joomla.Power.Grep')
|
||||
->share('Joomla.Power.Grep', [$this, 'getGrep'], true);
|
||||
|
||||
$container->alias(RemoteConfig::class, 'Joomla.Power.Remote.Config')
|
||||
->share('Joomla.Power.Remote.Config', [$this, 'getRemoteConfig'], true);
|
||||
|
||||
$container->alias(Get::class, 'Joomla.Power.Remote.Get')
|
||||
->share('Joomla.Power.Remote.Get', [$this, 'getRemoteGet'], true);
|
||||
|
||||
@@ -76,18 +84,31 @@ class JoomlaPower implements ServiceProviderInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The Table Class.
|
||||
* Get The Power Table Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Table
|
||||
* @since 3.2.1
|
||||
* @since 5.1.1
|
||||
*/
|
||||
public function getTable(Container $container): Table
|
||||
public function getPowerTable(Container $container): Table
|
||||
{
|
||||
return new Table();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The Message Bus Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return MessageBus
|
||||
* @since 5.2.1
|
||||
*/
|
||||
public function getMessageBus(Container $container): MessageBus
|
||||
{
|
||||
return new MessageBus();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The Grep Class.
|
||||
*
|
||||
@@ -99,12 +120,28 @@ class JoomlaPower implements ServiceProviderInterface
|
||||
public function getGrep(Container $container): Grep
|
||||
{
|
||||
return new Grep(
|
||||
$container->get('Joomla.Power.Remote.Config'),
|
||||
$container->get('Gitea.Repository.Contents'),
|
||||
$container->get('Network.Resolve'),
|
||||
$container->get('Config')->approved_joomla_paths
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The Remote Config Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return RemoteConfig
|
||||
* @since 5.1.1
|
||||
*/
|
||||
public function getRemoteConfig(Container $container): RemoteConfig
|
||||
{
|
||||
return new RemoteConfig(
|
||||
$container->get('Power.Table')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The Remote Get Class.
|
||||
*
|
||||
@@ -116,6 +153,7 @@ class JoomlaPower implements ServiceProviderInterface
|
||||
public function getRemoteGet(Container $container): Get
|
||||
{
|
||||
return new Get(
|
||||
$container->get('Joomla.Power.Remote.Config'),
|
||||
$container->get('Joomla.Power.Grep'),
|
||||
$container->get('Data.Item')
|
||||
);
|
||||
@@ -132,12 +170,14 @@ class JoomlaPower implements ServiceProviderInterface
|
||||
public function getRemoteSet(Container $container): Set
|
||||
{
|
||||
return new Set(
|
||||
$container->get('Config')->approved_joomla_paths,
|
||||
$container->get('Joomla.Power.Remote.Config'),
|
||||
$container->get('Joomla.Power.Grep'),
|
||||
$container->get('Data.Items'),
|
||||
$container->get('Joomla.Power.Readme.Item'),
|
||||
$container->get('Joomla.Power.Readme.Main'),
|
||||
$container->get('Gitea.Repository.Contents')
|
||||
$container->get('Gitea.Repository.Contents'),
|
||||
$container->get('Power.Message'),
|
||||
$container->get('Config')->approved_joomla_paths
|
||||
);
|
||||
}
|
||||
|
||||
|
@@ -0,0 +1,80 @@
|
||||
<?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\AdminView\Readme;
|
||||
|
||||
|
||||
use VDM\Joomla\Interfaces\Readme\ItemInterface;
|
||||
|
||||
|
||||
/**
|
||||
* Compiler Admin View Item Readme
|
||||
*
|
||||
* @since 5.1.1
|
||||
*/
|
||||
final class Item implements ItemInterface
|
||||
{
|
||||
/**
|
||||
* Get an item readme
|
||||
*
|
||||
* @param object $item An item details.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.2
|
||||
*/
|
||||
public function get(object $item): string
|
||||
{
|
||||
// build readme
|
||||
$readme = ["```
|
||||
██╗ ██████╗ ██████╗ ███╗ ███╗██╗ █████╗
|
||||
██║██╔═══██╗██╔═══██╗████╗ ████║██║ ██╔══██╗
|
||||
██║██║ ██║██║ ██║██╔████╔██║██║ ███████║
|
||||
██ ██║██║ ██║██║ ██║██║╚██╔╝██║██║ ██╔══██║
|
||||
╚█████╔╝╚██████╔╝╚██████╔╝██║ ╚═╝ ██║███████╗██║ ██║
|
||||
╚════╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
|
||||
|
||||
█████╗ ██████╗ ███╗ ███╗██╗███╗ ██╗ ██╗ ██╗██╗███████╗██╗ ██╗
|
||||
██╔══██╗██╔══██╗████╗ ████║██║████╗ ██║ ██║ ██║██║██╔════╝██║ ██║
|
||||
███████║██║ ██║██╔████╔██║██║██╔██╗ ██║ ██║ ██║██║█████╗ ██║ █╗ ██║
|
||||
██╔══██║██║ ██║██║╚██╔╝██║██║██║╚██╗██║ ╚██╗ ██╔╝██║██╔══╝ ██║███╗██║
|
||||
██║ ██║██████╔╝██║ ╚═╝ ██║██║██║ ╚████║ ╚████╔╝ ██║███████╗╚███╔███╔╝
|
||||
╚═╝ ╚═╝╚═════╝ ╚═╝ ╚═╝╚═╝╚═╝ ╚═══╝ ╚═══╝ ╚═╝╚══════╝ ╚══╝╚══╝
|
||||
```"];
|
||||
// system name
|
||||
$readme[] = "# " . $item->name;
|
||||
|
||||
if (!empty($item->description))
|
||||
{
|
||||
$readme[] = "\n" . $item->description;
|
||||
}
|
||||
elseif (!empty($item->short_description))
|
||||
{
|
||||
$readme[] = "\n" . $item->short_description;
|
||||
}
|
||||
|
||||
$readme[] = "\nThe Joomla Admin View is a self‑contained backend form for a single record: it unites Fields to load existing data, validate user edits, and handle CRUD on data in the system, serving as the conduit that writes changes directly to the component’s database tables in Joomla Component Builder (JCB). By using the \"reset\" button, you can instantly synchronize this Admin View with the authoritative version hosted in our core repository, ensuring your Components always benefit from the latest refinements, performance optimizations, and security enhancements.\n\n Want something more fitting to your specific needs? Fork the repo, use the view as a blueprint and point JCB to your branch. Whether you’re layering in complex filters, interactive fields, or custom coded functionality; you stay in charge while still enjoying JCB’s effortless deployment workflow.\n
|
||||
\n
|
||||
\"This flexible approach embraces JCB’s open-source model, giving you the freedom to adapt your components to your exact needs while staying connected to a powerful and community-driven ecosystem.\"\n";
|
||||
|
||||
// yes you can remove this, but why?
|
||||
$readme[] = "\n---\n```
|
||||
██╗ ██████╗██████╗
|
||||
██║██╔════╝██╔══██╗
|
||||
██║██║ ██████╔╝
|
||||
██ ██║██║ ██╔══██╗
|
||||
╚█████╔╝╚██████╗██████╔╝
|
||||
╚════╝ ╚═════╝╚═════╝
|
||||
```\n> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder)\n\n";
|
||||
|
||||
return implode("\n", $readme);
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,234 @@
|
||||
<?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\AdminView\Readme;
|
||||
|
||||
|
||||
use VDM\Joomla\Interfaces\Readme\MainInterface;
|
||||
|
||||
|
||||
/**
|
||||
* Admin View Main Readme
|
||||
*
|
||||
* @since 5.1.1
|
||||
*/
|
||||
final class Main implements MainInterface
|
||||
{
|
||||
/**
|
||||
* Get Main Readme
|
||||
*
|
||||
* @param array $items All items of this repository.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function get(array $items): string
|
||||
{
|
||||
// build readme
|
||||
$readme = ["```
|
||||
██╗ ██████╗ ██████╗ ███╗ ███╗██╗ █████╗
|
||||
██║██╔═══██╗██╔═══██╗████╗ ████║██║ ██╔══██╗
|
||||
██║██║ ██║██║ ██║██╔████╔██║██║ ███████║
|
||||
██ ██║██║ ██║██║ ██║██║╚██╔╝██║██║ ██╔══██║
|
||||
╚█████╔╝╚██████╔╝╚██████╔╝██║ ╚═╝ ██║███████╗██║ ██║
|
||||
╚════╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
|
||||
|
||||
█████╗ ██████╗ ███╗ ███╗██╗███╗ ██╗ ██╗ ██╗██╗███████╗██╗ ██╗███████╗
|
||||
██╔══██╗██╔══██╗████╗ ████║██║████╗ ██║ ██║ ██║██║██╔════╝██║ ██║██╔════╝
|
||||
███████║██║ ██║██╔████╔██║██║██╔██╗ ██║ ██║ ██║██║█████╗ ██║ █╗ ██║███████╗
|
||||
██╔══██║██║ ██║██║╚██╔╝██║██║██║╚██╗██║ ╚██╗ ██╔╝██║██╔══╝ ██║███╗██║╚════██║
|
||||
██║ ██║██████╔╝██║ ╚═╝ ██║██║██║ ╚████║ ╚████╔╝ ██║███████╗╚███╔███╔╝███████║
|
||||
╚═╝ ╚═╝╚═════╝ ╚═╝ ╚═╝╚═╝╚═╝ ╚═══╝ ╚═══╝ ╚═╝╚══════╝ ╚══╝╚══╝ ╚══════╝
|
||||
```"];
|
||||
|
||||
// default description of admin views
|
||||
$readme[] = "\n### What are Joomla Admin Views?\nThe Joomla admin views provide a robust interface layer that assembles backend fields, and PHP logic, enabling seamless management of component data within Joomla Component Builder (JCB). Acting as the central hub for listing, editing, and persisting records, these views standardize how components interact with the database and ensure administrators enjoy a consistent, intuitive control panel across the entire JCB ecosystem.\n
|
||||
\n
|
||||
Whenever you need to update Admin Views in any JCB project, simply select the desired views and click the \"reset\" button. The selected views is synchronized with the original version stored in this repository, bringing the latest design tweaks, security fixes, and performance boosts.\n
|
||||
\n
|
||||
If your project calls for more distinctive Admin View, or component‑specific business logic. Simply fork the repository and point JCB to your copy. This lets you maintain and evolve Admin Views independently of the main JCB community while preserving the convenience of JCB’s one‑click update mechanism.\n
|
||||
\n
|
||||
\"We believe this approach empowers you to extend and customize JCB to fit your unique requirements, exemplifying the true spirit of freedom in software development. We trust you will find this capability both useful and aligned with the expectations of how open-source software should function.\"\n";
|
||||
|
||||
// get the readme body
|
||||
$readme[] = $this->readmeBuilder($items);
|
||||
|
||||
// yes you can remove this, but why?
|
||||
$readme[] = "\n---\n```
|
||||
██╗ ██████╗ ██████╗ ███╗ ███╗██╗ █████╗
|
||||
██║██╔═══██╗██╔═══██╗████╗ ████║██║ ██╔══██╗
|
||||
██║██║ ██║██║ ██║██╔████╔██║██║ ███████║
|
||||
██ ██║██║ ██║██║ ██║██║╚██╔╝██║██║ ██╔══██║
|
||||
╚█████╔╝╚██████╔╝╚██████╔╝██║ ╚═╝ ██║███████╗██║ ██║
|
||||
╚════╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
|
||||
██████╗ ██████╗ ███╗ ███╗██████╗ ██████╗ ███╗ ██╗███████╗███╗ ██╗████████╗
|
||||
██╔════╝██╔═══██╗████╗ ████║██╔══██╗██╔═══██╗████╗ ██║██╔════╝████╗ ██║╚══██╔══╝
|
||||
██║ ██║ ██║██╔████╔██║██████╔╝██║ ██║██╔██╗ ██║█████╗ ██╔██╗ ██║ ██║
|
||||
██║ ██║ ██║██║╚██╔╝██║██╔═══╝ ██║ ██║██║╚██╗██║██╔══╝ ██║╚██╗██║ ██║
|
||||
╚██████╗╚██████╔╝██║ ╚═╝ ██║██║ ╚██████╔╝██║ ╚████║███████╗██║ ╚████║ ██║
|
||||
╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═════╝ ╚═╝ ╚═══╝╚══════╝╚═╝ ╚═══╝ ╚═╝
|
||||
██████╗ ██╗ ██╗██╗██╗ ██████╗ ███████╗██████╗
|
||||
██╔══██╗██║ ██║██║██║ ██╔══██╗██╔════╝██╔══██╗
|
||||
██████╔╝██║ ██║██║██║ ██║ ██║█████╗ ██████╔╝
|
||||
██╔══██╗██║ ██║██║██║ ██║ ██║██╔══╝ ██╔══██╗
|
||||
██████╔╝╚██████╔╝██║███████╗██████╔╝███████╗██║ ██║
|
||||
╚═════╝ ╚═════╝ ╚═╝╚══════╝╚═════╝ ╚══════╝╚═╝ ╚═╝
|
||||
```\n> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder)\n\n";
|
||||
|
||||
return implode("\n", $readme);
|
||||
}
|
||||
|
||||
/**
|
||||
* The readme builder
|
||||
*
|
||||
* @param array $classes The powers.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
*/
|
||||
private function readmeBuilder(array &$items): string
|
||||
{
|
||||
$classes = [];
|
||||
foreach ($items as $guid => $power)
|
||||
{
|
||||
// add to the sort bucket
|
||||
$classes[] = [
|
||||
'name' => $power['name'],
|
||||
'link' => $this->indexLinkPower($power)
|
||||
];
|
||||
}
|
||||
|
||||
return $this->readmeModel($classes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sort and model the readme classes
|
||||
*
|
||||
* @param array $classes The powers.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
*/
|
||||
private function readmeModel(array &$classes): string
|
||||
{
|
||||
$this->sortClasses($classes);
|
||||
|
||||
return $this->generateIndex($classes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate the index string for classes
|
||||
*
|
||||
* @param array $classes The sorted classes
|
||||
*
|
||||
* @return string The index string
|
||||
*/
|
||||
private function generateIndex(array &$classes): string
|
||||
{
|
||||
$result = "# Index of Joomla! Field Types\n";
|
||||
|
||||
foreach ($classes as $class)
|
||||
{
|
||||
// Add the class details
|
||||
$result .= "\n - " . $class['link'];
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sort the flattened array using a single sorting function
|
||||
*
|
||||
* @param array $classes The classes to sort
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
private function sortClasses(array &$classes): void
|
||||
{
|
||||
usort($classes, function ($a, $b) {
|
||||
return $this->compareName($a, $b);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Compare the name of two classes
|
||||
*
|
||||
* @param array $a First class
|
||||
* @param array $b Second class
|
||||
*
|
||||
* @return int Comparison result
|
||||
* @since 3.2.0
|
||||
*/
|
||||
private function compareName(array $a, array $b): int
|
||||
{
|
||||
return strcmp($a['name'], $b['name']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the Link to the power in this repository
|
||||
*
|
||||
* @param array $power The power details.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
*/
|
||||
private function indexLinkPower(array &$power): string
|
||||
{
|
||||
$name = $power['name'] ?? 'error';
|
||||
return '**' . $name . "** | "
|
||||
. $this->linkPowerRepo($power) . ' | '
|
||||
. $this->linkPowerSettings($power) . ' | '
|
||||
. $this->linkPowerDesc($power);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the Link to the power in this repository
|
||||
*
|
||||
* @param array $power The power details.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
*/
|
||||
private function linkPowerRepo(array &$power): string
|
||||
{
|
||||
$path = $power['path'] ?? 'error';
|
||||
return '[Details](' . $path . ')';
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the Link to the power settings in this repository
|
||||
*
|
||||
* @param array $power The power details.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
*/
|
||||
private function linkPowerSettings(array &$power): string
|
||||
{
|
||||
$settings = $power['settings'] ?? 'error';
|
||||
return '[Settings](' . $settings . ')';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the short description
|
||||
*
|
||||
* @param array $power The power details.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
*/
|
||||
private function linkPowerDesc(array &$power): string
|
||||
{
|
||||
$jpk = $power['desc'] ?? '';
|
||||
return $jpk;
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,151 @@
|
||||
<?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\AdminView\Remote;
|
||||
|
||||
|
||||
use VDM\Joomla\Interfaces\Remote\ConfigInterface;
|
||||
use VDM\Joomla\Abstraction\Remote\Config as ExtendingConfig;
|
||||
|
||||
|
||||
/**
|
||||
* Base Configure values for the remote classes
|
||||
*
|
||||
* @since 5.1.1
|
||||
*/
|
||||
final class Config extends ExtendingConfig implements ConfigInterface
|
||||
{
|
||||
/**
|
||||
* Table Name
|
||||
*
|
||||
* @var string
|
||||
* @since 5.0.3
|
||||
*/
|
||||
protected string $table = 'admin_view';
|
||||
|
||||
/**
|
||||
* Area Name
|
||||
*
|
||||
* @var string|null
|
||||
* @since 3.2.2
|
||||
*/
|
||||
protected ?string $area = 'Admin View';
|
||||
|
||||
/**
|
||||
* Prefix Key
|
||||
*
|
||||
* @var string
|
||||
* @since 3.2.2
|
||||
*/
|
||||
protected string $prefix_key = '';
|
||||
|
||||
/**
|
||||
* Suffix Key
|
||||
*
|
||||
* @var string
|
||||
* @since 3.2.2
|
||||
*/
|
||||
protected string $suffix_key = '';
|
||||
|
||||
/**
|
||||
* The main readme file path
|
||||
*
|
||||
* @var string
|
||||
* @since 5.1.1
|
||||
*/
|
||||
protected string $main_readme_path = 'src/admin_view/README.md';
|
||||
|
||||
/**
|
||||
* The index file path (index of all items)
|
||||
*
|
||||
* @var string
|
||||
* @since 3.2.2
|
||||
*/
|
||||
protected string $index_path = 'admin-view-index.json';
|
||||
|
||||
/**
|
||||
* The item settings file path
|
||||
*
|
||||
* @var string
|
||||
* @since 3.2.2
|
||||
*/
|
||||
// [DEFAULT] protected string $settings_path = 'item.json';
|
||||
|
||||
/**
|
||||
* The item (files) source path
|
||||
*
|
||||
* @var string
|
||||
* @since 5.1.1
|
||||
*/
|
||||
protected string $src_path = 'src/admin_view';
|
||||
|
||||
/**
|
||||
* The item guid=unique field
|
||||
*
|
||||
* @var string
|
||||
* @since 5.1.1
|
||||
*/
|
||||
// [DEFAULT] protected string $guid_field = 'guid';
|
||||
|
||||
/**
|
||||
* The item map
|
||||
*
|
||||
* @var array
|
||||
* @since 5.0.3
|
||||
protected array $map = [];
|
||||
[DEFAULT] */
|
||||
|
||||
/**
|
||||
* The index map
|
||||
* must always have: [name,path,guid]
|
||||
* you can add more
|
||||
*
|
||||
* @var array
|
||||
* @since 5.0.3
|
||||
protected array $index_map = [
|
||||
'name' => 'index_map_IndexName',
|
||||
'path' => 'index_map_IndexPath',
|
||||
'guid' => 'index_map_IndexGUID'
|
||||
];
|
||||
[DEFAULT] */
|
||||
|
||||
/**
|
||||
* The index header
|
||||
* mapping the index map to a table
|
||||
* must always have: [name,path,guid,local]
|
||||
* with [name] always first
|
||||
* with [path,guid,local] always last
|
||||
* you can add more in between
|
||||
*
|
||||
* @var array
|
||||
* @since 5.1.1
|
||||
protected array $index_header = [
|
||||
'name',
|
||||
'path',
|
||||
'guid',
|
||||
'local'
|
||||
];
|
||||
[DEFAULT] */
|
||||
|
||||
/**
|
||||
* Core Placeholders
|
||||
*
|
||||
* @var array
|
||||
* @since 5.0.3
|
||||
protected array $placeholders = [
|
||||
'[['.'[NamespacePrefix]]]' => 'VDM',
|
||||
'[['.'[ComponentNamespace]]]' => 'Componentbuilder',
|
||||
'[['.'[Component]]]' => 'Componentbuilder',
|
||||
'[['.'[component]]]' => 'componentbuilder'
|
||||
];
|
||||
[DEFAULT] */
|
||||
}
|
||||
|
@@ -0,0 +1,80 @@
|
||||
<?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\Component\Readme;
|
||||
|
||||
|
||||
use VDM\Joomla\Interfaces\Readme\ItemInterface;
|
||||
|
||||
|
||||
/**
|
||||
* Compiler Component Item Readme
|
||||
*
|
||||
* @since 5.2.1
|
||||
*/
|
||||
final class Item implements ItemInterface
|
||||
{
|
||||
/**
|
||||
* Get an item readme
|
||||
*
|
||||
* @param object $item An item details.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.2
|
||||
*/
|
||||
public function get(object $item): string
|
||||
{
|
||||
// build readme
|
||||
$readme = ["```
|
||||
██╗ ██████╗ ██████╗ ███╗ ███╗██╗ █████╗
|
||||
██║██╔═══██╗██╔═══██╗████╗ ████║██║ ██╔══██╗
|
||||
██║██║ ██║██║ ██║██╔████╔██║██║ ███████║
|
||||
██ ██║██║ ██║██║ ██║██║╚██╔╝██║██║ ██╔══██║
|
||||
╚█████╔╝╚██████╔╝╚██████╔╝██║ ╚═╝ ██║███████╗██║ ██║
|
||||
╚════╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
|
||||
|
||||
██████╗ ██████╗ ███╗ ███╗██████╗ ██████╗ ███╗ ██╗███████╗███╗ ██╗████████╗
|
||||
██╔════╝██╔═══██╗████╗ ████║██╔══██╗██╔═══██╗████╗ ██║██╔════╝████╗ ██║╚══██╔══╝
|
||||
██║ ██║ ██║██╔████╔██║██████╔╝██║ ██║██╔██╗ ██║█████╗ ██╔██╗ ██║ ██║
|
||||
██║ ██║ ██║██║╚██╔╝██║██╔═══╝ ██║ ██║██║╚██╗██║██╔══╝ ██║╚██╗██║ ██║
|
||||
╚██████╗╚██████╔╝██║ ╚═╝ ██║██║ ╚██████╔╝██║ ╚████║███████╗██║ ╚████║ ██║
|
||||
╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═════╝ ╚═╝ ╚═══╝╚══════╝╚═╝ ╚═══╝ ╚═╝
|
||||
```"];
|
||||
// system name
|
||||
$readme[] = "# " . $item->name;
|
||||
|
||||
if (!empty($item->description))
|
||||
{
|
||||
$readme[] = "\n" . $item->description;
|
||||
}
|
||||
elseif (!empty($item->short_description))
|
||||
{
|
||||
$readme[] = "\n" . $item->short_description;
|
||||
}
|
||||
|
||||
$readme[] = "\nThe Joomla component generated by JCB is a complete mini‑application bundled into one installable extension: it carries its own manifest, database schema, models, controllers, admin and site views, routing rules, language strings, ACL policies, helper classes, and assets. On installation it creates its tables, registers menus, wires itself to Joomla’s event system, and serves bespoke dashboards and frontend pages that handle every CRUD workflow. By encapsulating every layer—from data storage and validation to presentation and access control—within a single, self‑sufficient package, the component becomes the authoritative hub for its entire feature set inside the Joomla ecosystem. By using the \"reset\" button, you can instantly synchronize this Joomla Component with the authoritative version hosted in our core repository, ensuring your Component always benefit from the latest refinements, performance optimizations, and security enhancements.\n\n Want to simply utilize this Comonent for something more unique and fitting to your requirements? Fork the repo, modify the Component, and point JCB to your branch. Whether you’re wiring advanced admin views, sculpting intricate data relationships, or embedding dynamic dashboards, you stay in charge while still enjoying JCB’s effortless deployment workflow.\n
|
||||
\n
|
||||
\"This flexible approach embraces JCB’s open-source model, giving you the freedom to adapt your components to your exact needs while staying connected to a powerful and community-driven ecosystem.\"\n";
|
||||
|
||||
// yes you can remove this, but why?
|
||||
$readme[] = "\n---\n```
|
||||
██╗ ██████╗██████╗
|
||||
██║██╔════╝██╔══██╗
|
||||
██║██║ ██████╔╝
|
||||
██ ██║██║ ██╔══██╗
|
||||
╚█████╔╝╚██████╗██████╔╝
|
||||
╚════╝ ╚═════╝╚═════╝
|
||||
```\n> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder)\n\n";
|
||||
|
||||
return implode("\n", $readme);
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,234 @@
|
||||
<?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\Component\Readme;
|
||||
|
||||
|
||||
use VDM\Joomla\Interfaces\Readme\MainInterface;
|
||||
|
||||
|
||||
/**
|
||||
* Component Main Readme
|
||||
*
|
||||
* @since 5.2.1
|
||||
*/
|
||||
final class Main implements MainInterface
|
||||
{
|
||||
/**
|
||||
* Get Main Readme
|
||||
*
|
||||
* @param array $items All items of this repository.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function get(array $items): string
|
||||
{
|
||||
// build readme
|
||||
$readme = ["```
|
||||
██╗ ██████╗ ██████╗ ███╗ ███╗██╗ █████╗
|
||||
██║██╔═══██╗██╔═══██╗████╗ ████║██║ ██╔══██╗
|
||||
██║██║ ██║██║ ██║██╔████╔██║██║ ███████║
|
||||
██ ██║██║ ██║██║ ██║██║╚██╔╝██║██║ ██╔══██║
|
||||
╚█████╔╝╚██████╔╝╚██████╔╝██║ ╚═╝ ██║███████╗██║ ██║
|
||||
╚════╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
|
||||
|
||||
██████╗ ██████╗ ███╗ ███╗██████╗ ██████╗ ███╗ ██╗███████╗███╗ ██╗████████╗███████╗
|
||||
██╔════╝██╔═══██╗████╗ ████║██╔══██╗██╔═══██╗████╗ ██║██╔════╝████╗ ██║╚══██╔══╝██╔════╝
|
||||
██║ ██║ ██║██╔████╔██║██████╔╝██║ ██║██╔██╗ ██║█████╗ ██╔██╗ ██║ ██║ ███████╗
|
||||
██║ ██║ ██║██║╚██╔╝██║██╔═══╝ ██║ ██║██║╚██╗██║██╔══╝ ██║╚██╗██║ ██║ ╚════██║
|
||||
╚██████╗╚██████╔╝██║ ╚═╝ ██║██║ ╚██████╔╝██║ ╚████║███████╗██║ ╚████║ ██║ ███████║
|
||||
╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═════╝ ╚═╝ ╚═══╝╚══════╝╚═╝ ╚═══╝ ╚═╝ ╚══════╝
|
||||
```"];
|
||||
|
||||
// default description of components
|
||||
$readme[] = "\n### What are Joomla Components?\nJoomla components are the full‑scale applications generated by JCB: they bundle database tables, fields, admin and site views, controllers, routing, language strings, and Custom PHP functions into a single extension that delivers complete business logic and user interfaces to both the backend and the frontend of a Joomla site. Acting as the top‑level container, components orchestrate every lower‑level element—fields, views, helpers, scripts—so they work together as a cohesive, installable solution.\n
|
||||
\n
|
||||
Whenever you need to update Components in JCB, simply select the desired Components and click the \"reset\" button. The selected Components is synchronized with the original version stored in this repository, bringing the latest design tweaks, security fixes, and performance boosts.\n
|
||||
\n
|
||||
If your project calls for more distinctive Components, or specific business logic. Simply fork the repository and point JCB to your copy. This lets you maintain and evolve Components independently of the main JCB community while preserving the convenience of JCB’s one‑click update mechanism.\n
|
||||
\n
|
||||
\"We believe this approach empowers you to extend and customize JCB to fit your unique requirements, exemplifying the true spirit of freedom in software development. We trust you will find this capability both useful and aligned with the expectations of how open-source software should function.\"\n";
|
||||
|
||||
// get the readme body
|
||||
$readme[] = $this->readmeBuilder($items);
|
||||
|
||||
// yes you can remove this, but why?
|
||||
$readme[] = "\n---\n```
|
||||
██╗ ██████╗ ██████╗ ███╗ ███╗██╗ █████╗
|
||||
██║██╔═══██╗██╔═══██╗████╗ ████║██║ ██╔══██╗
|
||||
██║██║ ██║██║ ██║██╔████╔██║██║ ███████║
|
||||
██ ██║██║ ██║██║ ██║██║╚██╔╝██║██║ ██╔══██║
|
||||
╚█████╔╝╚██████╔╝╚██████╔╝██║ ╚═╝ ██║███████╗██║ ██║
|
||||
╚════╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
|
||||
██████╗ ██████╗ ███╗ ███╗██████╗ ██████╗ ███╗ ██╗███████╗███╗ ██╗████████╗
|
||||
██╔════╝██╔═══██╗████╗ ████║██╔══██╗██╔═══██╗████╗ ██║██╔════╝████╗ ██║╚══██╔══╝
|
||||
██║ ██║ ██║██╔████╔██║██████╔╝██║ ██║██╔██╗ ██║█████╗ ██╔██╗ ██║ ██║
|
||||
██║ ██║ ██║██║╚██╔╝██║██╔═══╝ ██║ ██║██║╚██╗██║██╔══╝ ██║╚██╗██║ ██║
|
||||
╚██████╗╚██████╔╝██║ ╚═╝ ██║██║ ╚██████╔╝██║ ╚████║███████╗██║ ╚████║ ██║
|
||||
╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═════╝ ╚═╝ ╚═══╝╚══════╝╚═╝ ╚═══╝ ╚═╝
|
||||
██████╗ ██╗ ██╗██╗██╗ ██████╗ ███████╗██████╗
|
||||
██╔══██╗██║ ██║██║██║ ██╔══██╗██╔════╝██╔══██╗
|
||||
██████╔╝██║ ██║██║██║ ██║ ██║█████╗ ██████╔╝
|
||||
██╔══██╗██║ ██║██║██║ ██║ ██║██╔══╝ ██╔══██╗
|
||||
██████╔╝╚██████╔╝██║███████╗██████╔╝███████╗██║ ██║
|
||||
╚═════╝ ╚═════╝ ╚═╝╚══════╝╚═════╝ ╚══════╝╚═╝ ╚═╝
|
||||
```\n> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder)\n\n";
|
||||
|
||||
return implode("\n", $readme);
|
||||
}
|
||||
|
||||
/**
|
||||
* The readme builder
|
||||
*
|
||||
* @param array $classes The powers.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
*/
|
||||
private function readmeBuilder(array &$items): string
|
||||
{
|
||||
$classes = [];
|
||||
foreach ($items as $guid => $power)
|
||||
{
|
||||
// add to the sort bucket
|
||||
$classes[] = [
|
||||
'name' => $power['name'],
|
||||
'link' => $this->indexLinkPower($power)
|
||||
];
|
||||
}
|
||||
|
||||
return $this->readmeModel($classes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sort and model the readme classes
|
||||
*
|
||||
* @param array $classes The powers.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
*/
|
||||
private function readmeModel(array &$classes): string
|
||||
{
|
||||
$this->sortClasses($classes);
|
||||
|
||||
return $this->generateIndex($classes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate the index string for classes
|
||||
*
|
||||
* @param array $classes The sorted classes
|
||||
*
|
||||
* @return string The index string
|
||||
*/
|
||||
private function generateIndex(array &$classes): string
|
||||
{
|
||||
$result = "# Index of Joomla! Field Types\n";
|
||||
|
||||
foreach ($classes as $class)
|
||||
{
|
||||
// Add the class details
|
||||
$result .= "\n - " . $class['link'];
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sort the flattened array using a single sorting function
|
||||
*
|
||||
* @param array $classes The classes to sort
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
private function sortClasses(array &$classes): void
|
||||
{
|
||||
usort($classes, function ($a, $b) {
|
||||
return $this->compareName($a, $b);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Compare the name of two classes
|
||||
*
|
||||
* @param array $a First class
|
||||
* @param array $b Second class
|
||||
*
|
||||
* @return int Comparison result
|
||||
* @since 3.2.0
|
||||
*/
|
||||
private function compareName(array $a, array $b): int
|
||||
{
|
||||
return strcmp($a['name'], $b['name']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the Link to the power in this repository
|
||||
*
|
||||
* @param array $power The power details.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
*/
|
||||
private function indexLinkPower(array &$power): string
|
||||
{
|
||||
$name = $power['name'] ?? 'error';
|
||||
return '**' . $name . "** | "
|
||||
. $this->linkPowerRepo($power) . ' | '
|
||||
. $this->linkPowerSettings($power) . ' | '
|
||||
. $this->linkPowerDesc($power);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the Link to the power in this repository
|
||||
*
|
||||
* @param array $power The power details.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
*/
|
||||
private function linkPowerRepo(array &$power): string
|
||||
{
|
||||
$path = $power['path'] ?? 'error';
|
||||
return '[Details](' . $path . ')';
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the Link to the power settings in this repository
|
||||
*
|
||||
* @param array $power The power details.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
*/
|
||||
private function linkPowerSettings(array &$power): string
|
||||
{
|
||||
$settings = $power['settings'] ?? 'error';
|
||||
return '[Settings](' . $settings . ')';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the short description
|
||||
*
|
||||
* @param array $power The power details.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
*/
|
||||
private function linkPowerDesc(array &$power): string
|
||||
{
|
||||
$jpk = $power['desc'] ?? '';
|
||||
return $jpk;
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
@@ -0,0 +1,151 @@
|
||||
<?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\Component\Remote;
|
||||
|
||||
|
||||
use VDM\Joomla\Interfaces\Remote\ConfigInterface;
|
||||
use VDM\Joomla\Abstraction\Remote\Config as ExtendingConfig;
|
||||
|
||||
|
||||
/**
|
||||
* Base Configure values for the remote classes
|
||||
*
|
||||
* @since 5.2.1
|
||||
*/
|
||||
final class Config extends ExtendingConfig implements ConfigInterface
|
||||
{
|
||||
/**
|
||||
* Table Name
|
||||
*
|
||||
* @var string
|
||||
* @since 5.2.1
|
||||
*/
|
||||
protected string $table = 'joomla_component';
|
||||
|
||||
/**
|
||||
* Area Name
|
||||
*
|
||||
* @var string|null
|
||||
* @since 5.2.1
|
||||
*/
|
||||
protected ?string $area = 'Component';
|
||||
|
||||
/**
|
||||
* Prefix Key
|
||||
*
|
||||
* @var string
|
||||
* @since 5.2.1
|
||||
*/
|
||||
protected string $prefix_key = '';
|
||||
|
||||
/**
|
||||
* Suffix Key
|
||||
*
|
||||
* @var string
|
||||
* @since 5.2.1
|
||||
*/
|
||||
protected string $suffix_key = '';
|
||||
|
||||
/**
|
||||
* The main readme file path
|
||||
*
|
||||
* @var string
|
||||
* @since 5.2.1
|
||||
*/
|
||||
protected string $main_readme_path = 'src/README.md';
|
||||
|
||||
/**
|
||||
* The index file path (index of all items)
|
||||
*
|
||||
* @var string
|
||||
* @since 5.2.1
|
||||
*/
|
||||
protected string $index_path = 'component-index.json';
|
||||
|
||||
/**
|
||||
* The item settings file path
|
||||
*
|
||||
* @var string
|
||||
* @since 3.2.2
|
||||
*/
|
||||
// [DEFAULT] protected string $settings_path = 'item.json';
|
||||
|
||||
/**
|
||||
* The item (files) source path
|
||||
*
|
||||
* @var string
|
||||
* @since 5.2.1
|
||||
*/
|
||||
protected string $src_path = 'src/joomla_component';
|
||||
|
||||
/**
|
||||
* The item guid=unique field
|
||||
*
|
||||
* @var string
|
||||
* @since 5.2.1
|
||||
*/
|
||||
// [DEFAULT] protected string $guid_field = 'guid';
|
||||
|
||||
/**
|
||||
* The item map
|
||||
*
|
||||
* @var array
|
||||
* @since 5.0.3
|
||||
protected array $map = [];
|
||||
[DEFAULT] */
|
||||
|
||||
/**
|
||||
* The index map
|
||||
* must always have: [name,path,guid]
|
||||
* you can add more
|
||||
*
|
||||
* @var array
|
||||
* @since 5.0.3
|
||||
protected array $index_map = [
|
||||
'name' => 'index_map_IndexName',
|
||||
'path' => 'index_map_IndexPath',
|
||||
'guid' => 'index_map_IndexGUID'
|
||||
];
|
||||
[DEFAULT] */
|
||||
|
||||
/**
|
||||
* The index header
|
||||
* mapping the index map to a table
|
||||
* must always have: [name,path,guid,local]
|
||||
* with [name] always first
|
||||
* with [path,guid,local] always last
|
||||
* you can add more in between
|
||||
*
|
||||
* @var array
|
||||
* @since 5.1.1
|
||||
protected array $index_header = [
|
||||
'name',
|
||||
'path',
|
||||
'guid',
|
||||
'local'
|
||||
];
|
||||
[DEFAULT] */
|
||||
|
||||
/**
|
||||
* Core Placeholders
|
||||
*
|
||||
* @var array
|
||||
* @since 5.0.3
|
||||
protected array $placeholders = [
|
||||
'[['.'[NamespacePrefix]]]' => 'VDM',
|
||||
'[['.'[ComponentNamespace]]]' => 'Componentbuilder',
|
||||
'[['.'[Component]]]' => 'Componentbuilder',
|
||||
'[['.'[component]]]' => 'componentbuilder'
|
||||
];
|
||||
[DEFAULT] */
|
||||
}
|
||||
|
@@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
@@ -0,0 +1,148 @@
|
||||
<?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\Registry\Registry as JoomlaRegistry;
|
||||
use Joomla\CMS\Factory as JoomlaFactory;
|
||||
use VDM\Joomla\Utilities\GetHelper;
|
||||
use VDM\Joomla\Utilities\StringHelper;
|
||||
use VDM\Joomla\Componentbuilder\Utilities\RepoHelper;
|
||||
use VDM\Joomla\Componentbuilder\Abstraction\ComponentConfig;
|
||||
|
||||
|
||||
/**
|
||||
* Compiler Configurations
|
||||
*
|
||||
* All these functions are accessed via the direct name without the get:
|
||||
* example: $this->component_code_name calls: $this->getComponentcodename()
|
||||
*
|
||||
* All values once called are cached, yet can be updated directly:
|
||||
* example: $this->component_code_name = 'new_code_name'; // be warned!
|
||||
*
|
||||
* @since 5.2.1
|
||||
*/
|
||||
class Config extends ComponentConfig
|
||||
{
|
||||
/**
|
||||
* The Global Joomla Configuration
|
||||
*
|
||||
* @var JoomlaRegistry
|
||||
* @since 5.2.1
|
||||
*/
|
||||
protected JoomlaRegistry $config;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param Input|null $input Input
|
||||
* @param Registry|null $params The component parameters
|
||||
* @param Registry|null $config The Joomla configuration
|
||||
*
|
||||
* @throws \Exception
|
||||
* @since 5.2.1
|
||||
*/
|
||||
public function __construct(?Input $input = null, ?JoomlaRegistry $params = null, ?JoomlaRegistry $config = null)
|
||||
{
|
||||
parent::__construct($input, $params);
|
||||
|
||||
$this->config = $config ?: JoomlaFactory::getConfig();
|
||||
}
|
||||
|
||||
/**
|
||||
* get Gitea Username
|
||||
*
|
||||
* @return string the access token
|
||||
* @since 5.2.1
|
||||
*/
|
||||
protected function getGiteausername(): ?string
|
||||
{
|
||||
return $this->params->get('gitea_username');
|
||||
}
|
||||
|
||||
/**
|
||||
* get Gitea Access Token
|
||||
*
|
||||
* @return string the access token
|
||||
* @since 5.2.1
|
||||
*/
|
||||
protected function getGiteatoken(): ?string
|
||||
{
|
||||
return $this->params->get('gitea_token');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get template core organisation
|
||||
*
|
||||
* @return string The template core organisation
|
||||
* @since 5.2.1
|
||||
*/
|
||||
protected function getPackagecoreorganisation(): string
|
||||
{
|
||||
// the VDM default organisation is [joomla]
|
||||
$organisation = 'joomla';
|
||||
|
||||
return $this->params->get('package_core_organisation', $organisation);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Template init repos
|
||||
*
|
||||
* @return array The init repositories on Gitea
|
||||
* @since 5.2.1
|
||||
*/
|
||||
protected function getPackageinitrepos(): array
|
||||
{
|
||||
// some defaults repos we need by JCB
|
||||
$repos = [];
|
||||
// get the users own power repo (can overwrite all)
|
||||
if (!empty($this->gitea_username))
|
||||
{
|
||||
$repos[$this->gitea_username . '.package'] = (object) ['organisation' => $this->gitea_username, 'repository' => 'package', 'read_branch' => 'master'];
|
||||
}
|
||||
$repos[$this->package_core_organisation . '.package'] = (object) ['organisation' => $this->package_core_organisation, 'repository' => 'package', 'read_branch' => 'master'];
|
||||
|
||||
return $repos;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get joomla template approved paths
|
||||
*
|
||||
* @return array The approved paths to the repositories on Gitea
|
||||
* @since 5.2.1
|
||||
*/
|
||||
protected function getApprovedpackagepaths(): array
|
||||
{
|
||||
// some defaults repos we need by JCB
|
||||
$approved = $this->package_init_repos;
|
||||
|
||||
$paths = RepoHelper::get(4); // JCB Packages = 4
|
||||
|
||||
|
||||
if ($paths !== null)
|
||||
{
|
||||
foreach ($paths as $path)
|
||||
{
|
||||
$owner = $path->organisation ?? null;
|
||||
$repo = $path->repository ?? null;
|
||||
if ($owner !== null && $repo !== null)
|
||||
{
|
||||
// we make sure to get only the objects
|
||||
$approved = ["{$owner}.{$repo}" => $path] + $approved;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return array_values($approved);
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,76 @@
|
||||
<?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\CustomAdminView\Readme;
|
||||
|
||||
|
||||
use VDM\Joomla\Interfaces\Readme\ItemInterface;
|
||||
|
||||
|
||||
/**
|
||||
* Custom Admin View Get Item Readme
|
||||
*
|
||||
* @since 5.1.1
|
||||
*/
|
||||
final class Item implements ItemInterface
|
||||
{
|
||||
/**
|
||||
* Get an item readme
|
||||
*
|
||||
* @param object $item An item details.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.2
|
||||
*/
|
||||
public function get(object $item): string
|
||||
{
|
||||
// build readme
|
||||
$readme = ["```
|
||||
██╗ ██████╗ ██████╗ ███╗ ███╗██╗ █████╗
|
||||
██║██╔═══██╗██╔═══██╗████╗ ████║██║ ██╔══██╗
|
||||
██║██║ ██║██║ ██║██╔████╔██║██║ ███████║
|
||||
██ ██║██║ ██║██║ ██║██║╚██╔╝██║██║ ██╔══██║
|
||||
╚█████╔╝╚██████╔╝╚██████╔╝██║ ╚═╝ ██║███████╗██║ ██║
|
||||
╚════╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
|
||||
|
||||
██████╗██╗ ██╗███████╗████████╗ ██████╗ ███╗ ███╗ █████╗ ██████╗ ███╗ ███╗██╗███╗ ██╗ ██╗ ██╗██╗███████╗██╗ ██╗
|
||||
██╔════╝██║ ██║██╔════╝╚══██╔══╝██╔═══██╗████╗ ████║ ██╔══██╗██╔══██╗████╗ ████║██║████╗ ██║ ██║ ██║██║██╔════╝██║ ██║
|
||||
██║ ██║ ██║███████╗ ██║ ██║ ██║██╔████╔██║ ███████║██║ ██║██╔████╔██║██║██╔██╗ ██║ ██║ ██║██║█████╗ ██║ █╗ ██║
|
||||
██║ ██║ ██║╚════██║ ██║ ██║ ██║██║╚██╔╝██║ ██╔══██║██║ ██║██║╚██╔╝██║██║██║╚██╗██║ ╚██╗ ██╔╝██║██╔══╝ ██║███╗██║
|
||||
╚██████╗╚██████╔╝███████║ ██║ ╚██████╔╝██║ ╚═╝ ██║ ██║ ██║██████╔╝██║ ╚═╝ ██║██║██║ ╚████║ ╚████╔╝ ██║███████╗╚███╔███╔╝
|
||||
╚═════╝ ╚═════╝ ╚══════╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝╚═════╝ ╚═╝ ╚═╝╚═╝╚═╝ ╚═══╝ ╚═══╝ ╚═╝╚══════╝ ╚══╝╚══╝
|
||||
```"];
|
||||
// system name
|
||||
$readme[] = "# " . $item->name;
|
||||
|
||||
if (!empty($item->description))
|
||||
{
|
||||
$readme[] = "\n" . $item->description;
|
||||
}
|
||||
|
||||
$readme[] = "\nThe Joomla! Custom Admin View contained in this repository delivers a customization option similar to a Site View, for integrating a hand‑crafted back‑end interface—complete with its own markup, PHP logic, Dynamic Gets, Templates, and Layouts—directly into components built with Joomla Component Builder (JCB). Each view is packaged for full compatibility with the JCB workflow, giving developers a hassle‑free way to present and manage data in the Joomla administrator without relying exclusively on auto‑generated tables. By using the \"reset\" button, you can instantly synchronize this Custom Admin View with the authoritative version hosted in our core repository, ensuring your components always benefit from the latest UI refinements, performance optimizations, and security enhancements.\n\n If you need to tailor the view—adding new filters, integrating dashboards, adjusting layouts, or incorporating additional Templates—you’re welcome to fork this repository and point your JCB instance to your fork. This lets you evolve the view on your own schedule while still enjoying the convenience of JCB’s view‑management tooling.\n
|
||||
\n
|
||||
\"This flexible approach embraces JCB’s open-source model, giving you the freedom to adapt your components to your exact needs while staying connected to a powerful and community-driven ecosystem.\"\n";
|
||||
|
||||
// yes you can remove this, but why?
|
||||
$readme[] = "\n---\n```
|
||||
██╗ ██████╗██████╗
|
||||
██║██╔════╝██╔══██╗
|
||||
██║██║ ██████╔╝
|
||||
██ ██║██║ ██╔══██╗
|
||||
╚█████╔╝╚██████╗██████╔╝
|
||||
╚════╝ ╚═════╝╚═════╝
|
||||
```\n> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder)\n\n";
|
||||
|
||||
return implode("\n", $readme);
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,234 @@
|
||||
<?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\CustomAdminView\Readme;
|
||||
|
||||
|
||||
use VDM\Joomla\Interfaces\Readme\MainInterface;
|
||||
|
||||
|
||||
/**
|
||||
* Custom Admin View Main Readme
|
||||
*
|
||||
* @since 5.1.1
|
||||
*/
|
||||
final class Main implements MainInterface
|
||||
{
|
||||
/**
|
||||
* Get Main Readme
|
||||
*
|
||||
* @param array $items All items of this repository.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function get(array $items): string
|
||||
{
|
||||
// build readme
|
||||
$readme = ["```
|
||||
██╗ ██████╗ ██████╗ ███╗ ███╗██╗ █████╗
|
||||
██║██╔═══██╗██╔═══██╗████╗ ████║██║ ██╔══██╗
|
||||
██║██║ ██║██║ ██║██╔████╔██║██║ ███████║
|
||||
██ ██║██║ ██║██║ ██║██║╚██╔╝██║██║ ██╔══██║
|
||||
╚█████╔╝╚██████╔╝╚██████╔╝██║ ╚═╝ ██║███████╗██║ ██║
|
||||
╚════╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
|
||||
|
||||
██████╗██╗ ██╗███████╗████████╗ ██████╗ ███╗ ███╗ █████╗ ██████╗ ███╗ ███╗██╗███╗ ██╗ ██╗ ██╗██╗███████╗██╗ ██╗███████╗
|
||||
██╔════╝██║ ██║██╔════╝╚══██╔══╝██╔═══██╗████╗ ████║ ██╔══██╗██╔══██╗████╗ ████║██║████╗ ██║ ██║ ██║██║██╔════╝██║ ██║██╔════╝
|
||||
██║ ██║ ██║███████╗ ██║ ██║ ██║██╔████╔██║ ███████║██║ ██║██╔████╔██║██║██╔██╗ ██║ ██║ ██║██║█████╗ ██║ █╗ ██║███████╗
|
||||
██║ ██║ ██║╚════██║ ██║ ██║ ██║██║╚██╔╝██║ ██╔══██║██║ ██║██║╚██╔╝██║██║██║╚██╗██║ ╚██╗ ██╔╝██║██╔══╝ ██║███╗██║╚════██║
|
||||
╚██████╗╚██████╔╝███████║ ██║ ╚██████╔╝██║ ╚═╝ ██║ ██║ ██║██████╔╝██║ ╚═╝ ██║██║██║ ╚████║ ╚████╔╝ ██║███████╗╚███╔███╔╝███████║
|
||||
╚═════╝ ╚═════╝ ╚══════╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝╚═════╝ ╚═╝ ╚═╝╚═╝╚═╝ ╚═══╝ ╚═══╝ ╚═╝╚══════╝ ╚══╝╚══╝ ╚══════╝
|
||||
```"];
|
||||
|
||||
// default description of custom admin views
|
||||
$readme[] = "\n### What are Joomla Custom Admin Views?\nJoomla Custom Admin Views give you a blank canvas within Joomla Component Builder (JCB) to paint the perfect back‑end experience. Just like with a Site View, Rather than settling for auto‑generated tables and field mappings, you compose each view with your own markup, PHP logic, Dynamic Gets, Templates, and Layouts—achieving pixel‑level precision over how data is retrieved, displayed, and managed inside the Joomla administrator.\n
|
||||
\n
|
||||
Whenever you need to update Custom Admin Views in any JCB project, simply select the desired Custom Admin Views and click the \"reset\" button. This action will automatically synchronize the Custom Admin Views with its corresponding version hosted in our core repository, ensuring you always have the latest updates.\n
|
||||
\n
|
||||
Should you wish to tailor a Custom Admin View to your specific workflow—adding new filters, integrating dashboards, or overhauling the UI—you can fork this repository and point your JCB instance to your fork. This lets you maintain and evolve Custom Admin Views independently of the main JCB community while preserving the convenience of JCB’s one‑click update mechanism.\n
|
||||
\n
|
||||
\"We believe this approach empowers you to extend and customize JCB to fit your unique requirements, exemplifying the true spirit of freedom in software development. We trust you will find this capability both useful and aligned with the expectations of how open-source software should function.\"\n";
|
||||
|
||||
// get the readme body
|
||||
$readme[] = $this->readmeBuilder($items);
|
||||
|
||||
// yes you can remove this, but why?
|
||||
$readme[] = "\n---\n```
|
||||
██╗ ██████╗ ██████╗ ███╗ ███╗██╗ █████╗
|
||||
██║██╔═══██╗██╔═══██╗████╗ ████║██║ ██╔══██╗
|
||||
██║██║ ██║██║ ██║██╔████╔██║██║ ███████║
|
||||
██ ██║██║ ██║██║ ██║██║╚██╔╝██║██║ ██╔══██║
|
||||
╚█████╔╝╚██████╔╝╚██████╔╝██║ ╚═╝ ██║███████╗██║ ██║
|
||||
╚════╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
|
||||
██████╗ ██████╗ ███╗ ███╗██████╗ ██████╗ ███╗ ██╗███████╗███╗ ██╗████████╗
|
||||
██╔════╝██╔═══██╗████╗ ████║██╔══██╗██╔═══██╗████╗ ██║██╔════╝████╗ ██║╚══██╔══╝
|
||||
██║ ██║ ██║██╔████╔██║██████╔╝██║ ██║██╔██╗ ██║█████╗ ██╔██╗ ██║ ██║
|
||||
██║ ██║ ██║██║╚██╔╝██║██╔═══╝ ██║ ██║██║╚██╗██║██╔══╝ ██║╚██╗██║ ██║
|
||||
╚██████╗╚██████╔╝██║ ╚═╝ ██║██║ ╚██████╔╝██║ ╚████║███████╗██║ ╚████║ ██║
|
||||
╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═════╝ ╚═╝ ╚═══╝╚══════╝╚═╝ ╚═══╝ ╚═╝
|
||||
██████╗ ██╗ ██╗██╗██╗ ██████╗ ███████╗██████╗
|
||||
██╔══██╗██║ ██║██║██║ ██╔══██╗██╔════╝██╔══██╗
|
||||
██████╔╝██║ ██║██║██║ ██║ ██║█████╗ ██████╔╝
|
||||
██╔══██╗██║ ██║██║██║ ██║ ██║██╔══╝ ██╔══██╗
|
||||
██████╔╝╚██████╔╝██║███████╗██████╔╝███████╗██║ ██║
|
||||
╚═════╝ ╚═════╝ ╚═╝╚══════╝╚═════╝ ╚══════╝╚═╝ ╚═╝
|
||||
```\n> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder)\n\n";
|
||||
|
||||
return implode("\n", $readme);
|
||||
}
|
||||
|
||||
/**
|
||||
* The readme builder
|
||||
*
|
||||
* @param array $classes The powers.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
*/
|
||||
private function readmeBuilder(array &$items): string
|
||||
{
|
||||
$classes = [];
|
||||
foreach ($items as $guid => $power)
|
||||
{
|
||||
// add to the sort bucket
|
||||
$classes[] = [
|
||||
'name' => $power['name'],
|
||||
'link' => $this->indexLinkPower($power)
|
||||
];
|
||||
}
|
||||
|
||||
return $this->readmeModel($classes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sort and model the readme classes
|
||||
*
|
||||
* @param array $classes The powers.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
*/
|
||||
private function readmeModel(array &$classes): string
|
||||
{
|
||||
$this->sortClasses($classes);
|
||||
|
||||
return $this->generateIndex($classes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate the index string for classes
|
||||
*
|
||||
* @param array $classes The sorted classes
|
||||
*
|
||||
* @return string The index string
|
||||
*/
|
||||
private function generateIndex(array &$classes): string
|
||||
{
|
||||
$result = "# Index of Joomla! Field Types\n";
|
||||
|
||||
foreach ($classes as $class)
|
||||
{
|
||||
// Add the class details
|
||||
$result .= "\n - " . $class['link'];
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sort the flattened array using a single sorting function
|
||||
*
|
||||
* @param array $classes The classes to sort
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
private function sortClasses(array &$classes): void
|
||||
{
|
||||
usort($classes, function ($a, $b) {
|
||||
return $this->compareName($a, $b);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Compare the name of two classes
|
||||
*
|
||||
* @param array $a First class
|
||||
* @param array $b Second class
|
||||
*
|
||||
* @return int Comparison result
|
||||
* @since 3.2.0
|
||||
*/
|
||||
private function compareName(array $a, array $b): int
|
||||
{
|
||||
return strcmp($a['name'], $b['name']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the Link to the power in this repository
|
||||
*
|
||||
* @param array $power The power details.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
*/
|
||||
private function indexLinkPower(array &$power): string
|
||||
{
|
||||
$name = $power['name'] ?? 'error';
|
||||
return '**' . $name . "** | "
|
||||
. $this->linkPowerRepo($power) . ' | '
|
||||
. $this->linkPowerSettings($power) . ' | '
|
||||
. $this->linkPowerDesc($power);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the Link to the power in this repository
|
||||
*
|
||||
* @param array $power The power details.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
*/
|
||||
private function linkPowerRepo(array &$power): string
|
||||
{
|
||||
$path = $power['path'] ?? 'error';
|
||||
return '[Details](' . $path . ')';
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the Link to the power settings in this repository
|
||||
*
|
||||
* @param array $power The power details.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
*/
|
||||
private function linkPowerSettings(array &$power): string
|
||||
{
|
||||
$settings = $power['settings'] ?? 'error';
|
||||
return '[Settings](' . $settings . ')';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the short description
|
||||
*
|
||||
* @param array $power The power details.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
*/
|
||||
private function linkPowerDesc(array &$power): string
|
||||
{
|
||||
$jpk = $power['desc'] ?? '';
|
||||
return $jpk;
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
@@ -0,0 +1,151 @@
|
||||
<?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\CustomAdminView\Remote;
|
||||
|
||||
|
||||
use VDM\Joomla\Interfaces\Remote\ConfigInterface;
|
||||
use VDM\Joomla\Abstraction\Remote\Config as ExtendingConfig;
|
||||
|
||||
|
||||
/**
|
||||
* Base Configure values for the remote classes
|
||||
*
|
||||
* @since 5.1.1
|
||||
*/
|
||||
final class Config extends ExtendingConfig implements ConfigInterface
|
||||
{
|
||||
/**
|
||||
* Table Name
|
||||
*
|
||||
* @var string
|
||||
* @since 5.0.3
|
||||
*/
|
||||
protected string $table = 'custom_admin_view';
|
||||
|
||||
/**
|
||||
* Area Name
|
||||
*
|
||||
* @var string|null
|
||||
* @since 3.2.2
|
||||
*/
|
||||
protected ?string $area = 'Custom Admin View';
|
||||
|
||||
/**
|
||||
* Prefix Key
|
||||
*
|
||||
* @var string
|
||||
* @since 3.2.2
|
||||
*/
|
||||
protected string $prefix_key = '';
|
||||
|
||||
/**
|
||||
* Suffix Key
|
||||
*
|
||||
* @var string
|
||||
* @since 3.2.2
|
||||
*/
|
||||
protected string $suffix_key = '';
|
||||
|
||||
/**
|
||||
* The main readme file path
|
||||
*
|
||||
* @var string
|
||||
* @since 5.1.1
|
||||
*/
|
||||
protected string $main_readme_path = 'src/custom_admin_view/README.md';
|
||||
|
||||
/**
|
||||
* The index file path (index of all items)
|
||||
*
|
||||
* @var string
|
||||
* @since 3.2.2
|
||||
*/
|
||||
protected string $index_path = 'custom-admin-view-index.json';
|
||||
|
||||
/**
|
||||
* The item (files) source path
|
||||
*
|
||||
* @var string
|
||||
* @since 5.1.1
|
||||
*/
|
||||
protected string $src_path = 'src/custom_admin_view';
|
||||
|
||||
/**
|
||||
* The item settings file path
|
||||
*
|
||||
* @var string
|
||||
* @since 3.2.2
|
||||
*/
|
||||
// [DEFAULT] protected string $settings_path = 'item.json';
|
||||
|
||||
/**
|
||||
* The item guid=unique field
|
||||
*
|
||||
* @var string
|
||||
* @since 5.1.1
|
||||
*/
|
||||
// [DEFAULT] protected string $guid_field = 'guid';
|
||||
|
||||
/**
|
||||
* The item map
|
||||
*
|
||||
* @var array
|
||||
* @since 5.0.3
|
||||
protected array $map = [];
|
||||
[DEFAULT] */
|
||||
|
||||
/**
|
||||
* The index map
|
||||
* must always have: [name,path,guid]
|
||||
* you can add more
|
||||
*
|
||||
* @var array
|
||||
* @since 5.0.3
|
||||
protected array $index_map = [
|
||||
'name' => 'index_map_IndexName',
|
||||
'path' => 'index_map_IndexPath',
|
||||
'guid' => 'index_map_IndexGUID'
|
||||
];
|
||||
[DEFAULT] */
|
||||
|
||||
/**
|
||||
* The index header
|
||||
* mapping the index map to a table
|
||||
* must always have: [name,path,guid,local]
|
||||
* with [name] always first
|
||||
* with [path,guid,local] always last
|
||||
* you can add more in between
|
||||
*
|
||||
* @var array
|
||||
* @since 5.1.1
|
||||
protected array $index_header = [
|
||||
'name',
|
||||
'path',
|
||||
'guid',
|
||||
'local'
|
||||
];
|
||||
[DEFAULT] */
|
||||
|
||||
/**
|
||||
* Core Placeholders
|
||||
*
|
||||
* @var array
|
||||
* @since 5.0.3
|
||||
protected array $placeholders = [
|
||||
'[['.'[NamespacePrefix]]]' => 'VDM',
|
||||
'[['.'[ComponentNamespace]]]' => 'Componentbuilder',
|
||||
'[['.'[Component]]]' => 'Componentbuilder',
|
||||
'[['.'[component]]]' => 'componentbuilder'
|
||||
];
|
||||
[DEFAULT] */
|
||||
}
|
||||
|
@@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
@@ -0,0 +1,76 @@
|
||||
<?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\CustomCode\Readme;
|
||||
|
||||
|
||||
use VDM\Joomla\Interfaces\Readme\ItemInterface;
|
||||
|
||||
|
||||
/**
|
||||
* Compiler Custom Code Item Readme
|
||||
*
|
||||
* @since 5.1.1
|
||||
*/
|
||||
final class Item implements ItemInterface
|
||||
{
|
||||
/**
|
||||
* Get an item readme
|
||||
*
|
||||
* @param object $item An item details.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.2
|
||||
*/
|
||||
public function get(object $item): string
|
||||
{
|
||||
// build readme
|
||||
$readme = ["```
|
||||
██╗ ██████╗ ██████╗ ███╗ ███╗██╗ █████╗
|
||||
██║██╔═══██╗██╔═══██╗████╗ ████║██║ ██╔══██╗
|
||||
██║██║ ██║██║ ██║██╔████╔██║██║ ███████║
|
||||
██ ██║██║ ██║██║ ██║██║╚██╔╝██║██║ ██╔══██║
|
||||
╚█████╔╝╚██████╔╝╚██████╔╝██║ ╚═╝ ██║███████╗██║ ██║
|
||||
╚════╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
|
||||
|
||||
██████╗██╗ ██╗███████╗████████╗ ██████╗ ███╗ ███╗ ██████╗ ██████╗ ██████╗ ███████╗
|
||||
██╔════╝██║ ██║██╔════╝╚══██╔══╝██╔═══██╗████╗ ████║ ██╔════╝██╔═══██╗██╔══██╗██╔════╝
|
||||
██║ ██║ ██║███████╗ ██║ ██║ ██║██╔████╔██║ ██║ ██║ ██║██║ ██║█████╗
|
||||
██║ ██║ ██║╚════██║ ██║ ██║ ██║██║╚██╔╝██║ ██║ ██║ ██║██║ ██║██╔══╝
|
||||
╚██████╗╚██████╔╝███████║ ██║ ╚██████╔╝██║ ╚═╝ ██║ ╚██████╗╚██████╔╝██████╔╝███████╗
|
||||
╚═════╝ ╚═════╝ ╚══════╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═════╝ ╚══════╝
|
||||
```"];
|
||||
// system name
|
||||
$readme[] = "# " . $item->system_name;
|
||||
|
||||
if (!empty($item->description))
|
||||
{
|
||||
$readme[] = "\n" . $item->description;
|
||||
}
|
||||
|
||||
$readme[] = "\nThe Joomla! custom‑code snippet contained in this repository offers a simple, reliable way to inject a self‑contained block of PHP, JavaScript, CSS, or markup into components built with Joomla Component Builder (JCB) through a custom‑code placeholder such as [CUSTOMCODE=getCustom]. Each snippet is packaged for seamless compatibility with the JCB workflow, so you can drop it into your components without manual wiring or asset juggling. By clicking the \"reset\" button, you can instantly synchronize this custom‑code with the authoritative version stored in our core repository, ensuring your components always take advantage of the latest refinements, security fixes, and performance improvements.\n\n Need something more tailored? Fork this repository and direct your JCB instance to your fork. Whether you’re adding component‑specific logic, stripping out unused functionality, or expanding the custom‑code’s capabilities, you stay fully in control while still leveraging JCB’s convenient custom‑code‑management tooling.\n
|
||||
\n
|
||||
\"This flexible approach embraces JCB’s open-source model, giving you the freedom to adapt your components to your exact needs while staying connected to a powerful and community-driven ecosystem.\"\n";
|
||||
|
||||
// yes you can remove this, but why?
|
||||
$readme[] = "\n---\n```
|
||||
██╗ ██████╗██████╗
|
||||
██║██╔════╝██╔══██╗
|
||||
██║██║ ██████╔╝
|
||||
██ ██║██║ ██╔══██╗
|
||||
╚█████╔╝╚██████╗██████╔╝
|
||||
╚════╝ ╚═════╝╚═════╝
|
||||
```\n> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder)\n\n";
|
||||
|
||||
return implode("\n", $readme);
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,234 @@
|
||||
<?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\CustomCode\Readme;
|
||||
|
||||
|
||||
use VDM\Joomla\Interfaces\Readme\MainInterface;
|
||||
|
||||
|
||||
/**
|
||||
* Custom Code Main Readme
|
||||
*
|
||||
* @since 5.1.1
|
||||
*/
|
||||
final class Main implements MainInterface
|
||||
{
|
||||
/**
|
||||
* Get Main Readme
|
||||
*
|
||||
* @param array $items All items of this repository.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function get(array $items): string
|
||||
{
|
||||
// build readme
|
||||
$readme = ["```
|
||||
██╗ ██████╗ ██████╗ ███╗ ███╗██╗ █████╗
|
||||
██║██╔═══██╗██╔═══██╗████╗ ████║██║ ██╔══██╗
|
||||
██║██║ ██║██║ ██║██╔████╔██║██║ ███████║
|
||||
██ ██║██║ ██║██║ ██║██║╚██╔╝██║██║ ██╔══██║
|
||||
╚█████╔╝╚██████╔╝╚██████╔╝██║ ╚═╝ ██║███████╗██║ ██║
|
||||
╚════╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
|
||||
|
||||
██████╗██╗ ██╗███████╗████████╗ ██████╗ ███╗ ███╗ ██████╗ ██████╗ ██████╗ ███████╗███████╗
|
||||
██╔════╝██║ ██║██╔════╝╚══██╔══╝██╔═══██╗████╗ ████║ ██╔════╝██╔═══██╗██╔══██╗██╔════╝██╔════╝
|
||||
██║ ██║ ██║███████╗ ██║ ██║ ██║██╔████╔██║ ██║ ██║ ██║██║ ██║█████╗ ███████╗
|
||||
██║ ██║ ██║╚════██║ ██║ ██║ ██║██║╚██╔╝██║ ██║ ██║ ██║██║ ██║██╔══╝ ╚════██║
|
||||
╚██████╗╚██████╔╝███████║ ██║ ╚██████╔╝██║ ╚═╝ ██║ ╚██████╗╚██████╔╝██████╔╝███████╗███████║
|
||||
╚═════╝ ╚═════╝ ╚══════╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═════╝ ╚══════╝╚══════╝
|
||||
```"];
|
||||
|
||||
// default description of custom codes
|
||||
$readme[] = "\n### What is Joomla Custom Codes?\nJoomla Custom Codes provide a unified way to create, manage, and inject reusable code snippets—PHP, JavaScript, CSS, or markup—into components built with Joomla Component Builder (JCB) via custom‑code placeholders (e.g. [CUSTOMCODE=getCustom]). This repository acts as the central hub for curating, versioning, and distributing these custom codes across the entire JCB ecosystem.\n
|
||||
\n
|
||||
When you need to update Custom Codes in any JCB project, simply select the desired custom-code and click the \"reset\" button. This action will automatically sync the selected custom-code with its corresponding version hosted in our core repository, ensuring you always have the latest updates.\n
|
||||
\n
|
||||
If you wish to tailor the Custom Codes to your specific needs—be it adding component‑specific logic, optimizing performance, or introducing brand‑new functionality—you can fork the repository and point your JCB instance to your fork. This allows you to maintain and update custom codes independently from the main JCB community, offering the flexibility that lies at the heart of open‑source philosophy.\n
|
||||
\n
|
||||
\"We believe this approach empowers you to extend and customize JCB to fit your unique requirements, exemplifying the true spirit of freedom in software development. We trust you will find this capability both useful and aligned with the expectations of how open-source software should function.\"\n";
|
||||
|
||||
// get the readme body
|
||||
$readme[] = $this->readmeBuilder($items);
|
||||
|
||||
// yes you can remove this, but why?
|
||||
$readme[] = "\n---\n```
|
||||
██╗ ██████╗ ██████╗ ███╗ ███╗██╗ █████╗
|
||||
██║██╔═══██╗██╔═══██╗████╗ ████║██║ ██╔══██╗
|
||||
██║██║ ██║██║ ██║██╔████╔██║██║ ███████║
|
||||
██ ██║██║ ██║██║ ██║██║╚██╔╝██║██║ ██╔══██║
|
||||
╚█████╔╝╚██████╔╝╚██████╔╝██║ ╚═╝ ██║███████╗██║ ██║
|
||||
╚════╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
|
||||
██████╗ ██████╗ ███╗ ███╗██████╗ ██████╗ ███╗ ██╗███████╗███╗ ██╗████████╗
|
||||
██╔════╝██╔═══██╗████╗ ████║██╔══██╗██╔═══██╗████╗ ██║██╔════╝████╗ ██║╚══██╔══╝
|
||||
██║ ██║ ██║██╔████╔██║██████╔╝██║ ██║██╔██╗ ██║█████╗ ██╔██╗ ██║ ██║
|
||||
██║ ██║ ██║██║╚██╔╝██║██╔═══╝ ██║ ██║██║╚██╗██║██╔══╝ ██║╚██╗██║ ██║
|
||||
╚██████╗╚██████╔╝██║ ╚═╝ ██║██║ ╚██████╔╝██║ ╚████║███████╗██║ ╚████║ ██║
|
||||
╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═════╝ ╚═╝ ╚═══╝╚══════╝╚═╝ ╚═══╝ ╚═╝
|
||||
██████╗ ██╗ ██╗██╗██╗ ██████╗ ███████╗██████╗
|
||||
██╔══██╗██║ ██║██║██║ ██╔══██╗██╔════╝██╔══██╗
|
||||
██████╔╝██║ ██║██║██║ ██║ ██║█████╗ ██████╔╝
|
||||
██╔══██╗██║ ██║██║██║ ██║ ██║██╔══╝ ██╔══██╗
|
||||
██████╔╝╚██████╔╝██║███████╗██████╔╝███████╗██║ ██║
|
||||
╚═════╝ ╚═════╝ ╚═╝╚══════╝╚═════╝ ╚══════╝╚═╝ ╚═╝
|
||||
```\n> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder)\n\n";
|
||||
|
||||
return implode("\n", $readme);
|
||||
}
|
||||
|
||||
/**
|
||||
* The readme builder
|
||||
*
|
||||
* @param array $classes The powers.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
*/
|
||||
private function readmeBuilder(array &$items): string
|
||||
{
|
||||
$classes = [];
|
||||
foreach ($items as $guid => $power)
|
||||
{
|
||||
// add to the sort bucket
|
||||
$classes[] = [
|
||||
'name' => $power['name'],
|
||||
'link' => $this->indexLinkPower($power)
|
||||
];
|
||||
}
|
||||
|
||||
return $this->readmeModel($classes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sort and model the readme classes
|
||||
*
|
||||
* @param array $classes The powers.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
*/
|
||||
private function readmeModel(array &$classes): string
|
||||
{
|
||||
$this->sortClasses($classes);
|
||||
|
||||
return $this->generateIndex($classes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate the index string for classes
|
||||
*
|
||||
* @param array $classes The sorted classes
|
||||
*
|
||||
* @return string The index string
|
||||
*/
|
||||
private function generateIndex(array &$classes): string
|
||||
{
|
||||
$result = "# Index of Joomla! Field Types\n";
|
||||
|
||||
foreach ($classes as $class)
|
||||
{
|
||||
// Add the class details
|
||||
$result .= "\n - " . $class['link'];
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sort the flattened array using a single sorting function
|
||||
*
|
||||
* @param array $classes The classes to sort
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
private function sortClasses(array &$classes): void
|
||||
{
|
||||
usort($classes, function ($a, $b) {
|
||||
return $this->compareName($a, $b);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Compare the name of two classes
|
||||
*
|
||||
* @param array $a First class
|
||||
* @param array $b Second class
|
||||
*
|
||||
* @return int Comparison result
|
||||
* @since 3.2.0
|
||||
*/
|
||||
private function compareName(array $a, array $b): int
|
||||
{
|
||||
return strcmp($a['name'], $b['name']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the Link to the power in this repository
|
||||
*
|
||||
* @param array $power The power details.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
*/
|
||||
private function indexLinkPower(array &$power): string
|
||||
{
|
||||
$name = $power['name'] ?? 'error';
|
||||
return '**' . $name . "** | "
|
||||
. $this->linkPowerRepo($power) . ' | '
|
||||
. $this->linkPowerSettings($power) . ' | '
|
||||
. $this->linkPowerDesc($power);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the Link to the power in this repository
|
||||
*
|
||||
* @param array $power The power details.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
*/
|
||||
private function linkPowerRepo(array &$power): string
|
||||
{
|
||||
$path = $power['path'] ?? 'error';
|
||||
return '[Details](' . $path . ')';
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the Link to the power settings in this repository
|
||||
*
|
||||
* @param array $power The power details.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
*/
|
||||
private function linkPowerSettings(array &$power): string
|
||||
{
|
||||
$settings = $power['settings'] ?? 'error';
|
||||
return '[Settings](' . $settings . ')';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the short description
|
||||
*
|
||||
* @param array $power The power details.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
*/
|
||||
private function linkPowerDesc(array &$power): string
|
||||
{
|
||||
$jpk = $power['desc'] ?? '';
|
||||
return $jpk;
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
@@ -0,0 +1,153 @@
|
||||
<?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\CustomCode\Remote;
|
||||
|
||||
|
||||
use VDM\Joomla\Interfaces\Remote\ConfigInterface;
|
||||
use VDM\Joomla\Abstraction\Remote\Config as ExtendingConfig;
|
||||
|
||||
|
||||
/**
|
||||
* Base Configure values for the remote classes
|
||||
*
|
||||
* @since 5.1.1
|
||||
*/
|
||||
final class Config extends ExtendingConfig implements ConfigInterface
|
||||
{
|
||||
/**
|
||||
* Table Name
|
||||
*
|
||||
* @var string
|
||||
* @since 5.0.3
|
||||
*/
|
||||
protected string $table = 'custom_code';
|
||||
|
||||
/**
|
||||
* Area Name
|
||||
*
|
||||
* @var string|null
|
||||
* @since 3.2.2
|
||||
*/
|
||||
protected ?string $area = 'Custom Code';
|
||||
|
||||
/**
|
||||
* Prefix Key
|
||||
*
|
||||
* @var string
|
||||
* @since 3.2.2
|
||||
*/
|
||||
protected string $prefix_key = '[CUSTOMCODE=';
|
||||
|
||||
/**
|
||||
* Suffix Key
|
||||
*
|
||||
* @var string
|
||||
* @since 3.2.2
|
||||
*/
|
||||
protected string $suffix_key = ']';
|
||||
|
||||
/**
|
||||
* The main readme file path
|
||||
*
|
||||
* @var string
|
||||
* @since 5.1.1
|
||||
*/
|
||||
protected string $main_readme_path = 'src/custom_code/README.md';
|
||||
|
||||
/**
|
||||
* The index file path (index of all items)
|
||||
*
|
||||
* @var string
|
||||
* @since 3.2.2
|
||||
*/
|
||||
protected string $index_path = 'custom-code-index.json';
|
||||
|
||||
/**
|
||||
* The item (files) source path
|
||||
*
|
||||
* @var string
|
||||
* @since 5.1.1
|
||||
*/
|
||||
protected string $src_path = 'src/custom_code';
|
||||
|
||||
/**
|
||||
* The item settings file path
|
||||
*
|
||||
* @var string
|
||||
* @since 3.2.2
|
||||
*/
|
||||
// [DEFAULT] protected string $settings_path = 'item.json';
|
||||
|
||||
/**
|
||||
* The item guid=unique field
|
||||
*
|
||||
* @var string
|
||||
* @since 5.1.1
|
||||
*/
|
||||
protected string $guid_field = 'function_name';
|
||||
|
||||
/**
|
||||
* The item map
|
||||
*
|
||||
* @var array
|
||||
* @since 5.0.3
|
||||
protected array $map = [];
|
||||
[DEFAULT] */
|
||||
|
||||
/**
|
||||
* The index map
|
||||
* must always have: [name,path,guid]
|
||||
* you can add more
|
||||
*
|
||||
* @var array
|
||||
* @since 5.0.3
|
||||
*/
|
||||
protected array $index_map = [
|
||||
'name' => 'index_map_IndexName',
|
||||
'desc' => 'index_map_ShortDescription',
|
||||
'path' => 'index_map_IndexPath',
|
||||
'guid' => 'index_map_IndexGUID'
|
||||
];
|
||||
|
||||
/**
|
||||
* The index header
|
||||
* mapping the index map to a table
|
||||
* must always have: [name,path,guid,local]
|
||||
* with [name] always first
|
||||
* with [path,guid,local] always last
|
||||
* you can add more in between
|
||||
*
|
||||
* @var array
|
||||
* @since 5.1.1
|
||||
*/
|
||||
protected array $index_header = [
|
||||
'name',
|
||||
'desc',
|
||||
'path',
|
||||
'guid',
|
||||
'local'
|
||||
];
|
||||
|
||||
/**
|
||||
* Core Placeholders
|
||||
*
|
||||
* @var array
|
||||
* @since 5.0.3
|
||||
protected array $placeholders = [
|
||||
'[['.'[NamespacePrefix]]]' => 'VDM',
|
||||
'[['.'[ComponentNamespace]]]' => 'Componentbuilder',
|
||||
'[['.'[Component]]]' => 'Componentbuilder',
|
||||
'[['.'[component]]]' => 'componentbuilder'
|
||||
];
|
||||
[DEFAULT] */
|
||||
}
|
||||
|
@@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
@@ -1,187 +0,0 @@
|
||||
<?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;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,127 +0,0 @@
|
||||
<?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\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;
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,675 @@
|
||||
<?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\Dependency;
|
||||
|
||||
|
||||
use VDM\Joomla\Interfaces\Remote\ConfigInterface as Config;
|
||||
use VDM\Joomla\Interfaces\Registryinterface as Tracker;
|
||||
use VDM\Joomla\Componentbuilder\Power\Interfaces\TableInterface as Table;
|
||||
use VDM\Joomla\Utilities\GetHelper;
|
||||
use VDM\Joomla\Utilities\StringHelper;
|
||||
use VDM\Joomla\Utilities\ArrayHelper;
|
||||
use VDM\Joomla\Interfaces\Remote\Dependency\ResolverInterface;
|
||||
|
||||
|
||||
/**
|
||||
* Package Dependency Resolver
|
||||
*
|
||||
* @since 5.2.1
|
||||
*/
|
||||
final class Resolver implements ResolverInterface
|
||||
{
|
||||
/**
|
||||
* The ConfigInterface Class.
|
||||
*
|
||||
* @var Config
|
||||
* @since 5.2.1
|
||||
*/
|
||||
protected Config $config;
|
||||
|
||||
/**
|
||||
* The Tracker Class.
|
||||
*
|
||||
* @var Tracker
|
||||
* @since 5.2.1
|
||||
*/
|
||||
protected Tracker $tracker;
|
||||
|
||||
/**
|
||||
* The Table Class.
|
||||
*
|
||||
* @var Table
|
||||
* @since 5.2.1
|
||||
*/
|
||||
protected Table $table;
|
||||
|
||||
/**
|
||||
* The linked fields.
|
||||
*
|
||||
* @var array
|
||||
* @since 5.2.1
|
||||
*/
|
||||
protected array $linked;
|
||||
|
||||
/**
|
||||
* The dependencies.
|
||||
*
|
||||
* @var array
|
||||
* @since 5.2.1
|
||||
*/
|
||||
protected array $dependencies;
|
||||
|
||||
/**
|
||||
* The code search.
|
||||
*
|
||||
* @var array
|
||||
* @since 5.2.1
|
||||
*/
|
||||
protected array $code;
|
||||
|
||||
/**
|
||||
* The placeholders search.
|
||||
*
|
||||
* @var array
|
||||
* @since 5.2.1
|
||||
*/
|
||||
protected array $placeholders;
|
||||
|
||||
/**
|
||||
* The template and layout alias map.
|
||||
*
|
||||
* @var array
|
||||
* @since 5.2.1
|
||||
*/
|
||||
protected array $alias_map;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param Config $config The ConfigInterface Class.
|
||||
* @param Tracker $tracker The Tracker Class.
|
||||
* @param Table $table The Table Class.
|
||||
*
|
||||
* @since 5.2.1
|
||||
*/
|
||||
public function __construct(Config $config, Tracker $tracker, Table $table)
|
||||
{
|
||||
$this->config = $config;
|
||||
$this->tracker = $tracker;
|
||||
$this->table = $table;
|
||||
|
||||
$this->setTableLinkedFields();
|
||||
$this->setTableDependencies();
|
||||
$this->setTableSearch();
|
||||
$this->setAliasMap();
|
||||
}
|
||||
|
||||
/**
|
||||
* Inspect an item and extract all the dependencies
|
||||
*
|
||||
* This method inspects the item and loads all dependencies
|
||||
*
|
||||
* @param object $item The data item to inspect.
|
||||
*
|
||||
* @return void
|
||||
* @since 5.2.1
|
||||
*/
|
||||
public function extract(object $item): void
|
||||
{
|
||||
$this->extractLinkedFields($item);
|
||||
$this->extractDependencies($item);
|
||||
$this->extractDynamicContent($item);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set all the linked fields of this table
|
||||
*
|
||||
* @return void
|
||||
* @since 5.2.1
|
||||
*/
|
||||
protected function setTableLinkedFields(): void
|
||||
{
|
||||
$this->linked = $this->table->linked($this->config->getTable());
|
||||
}
|
||||
|
||||
/**
|
||||
* Set all the dependencies of this table
|
||||
*
|
||||
* @return void
|
||||
* @since 5.2.1
|
||||
*/
|
||||
protected function setTableDependencies(): void
|
||||
{
|
||||
$this->dependencies = $this->table->dependencies($this->config->getTable());
|
||||
}
|
||||
|
||||
/**
|
||||
* Set all the related table search fields
|
||||
*
|
||||
* @return void
|
||||
* @since 5.2.1
|
||||
*/
|
||||
protected function setTableSearch(): void
|
||||
{
|
||||
$this->code = $this->table->search($this->config->getTable(), 'code');
|
||||
$this->placeholders = $this->table->search($this->config->getTable(), 'placeholders');
|
||||
}
|
||||
|
||||
/**
|
||||
* Load all alias and GUID's of template and layout tables
|
||||
*
|
||||
* @return void
|
||||
* @since 5.2.1
|
||||
*/
|
||||
protected function setAliasMap(): void
|
||||
{
|
||||
// now check if key is found
|
||||
foreach(['template', 'layout'] as $table)
|
||||
{
|
||||
// Create a new query object.
|
||||
$query = $this->db->getQuery(true);
|
||||
$query->select(array('a.guid', 'a.alias'));
|
||||
$query->from('#__componentbuilder_' . $table . ' AS a');
|
||||
$this->db->setQuery($query);
|
||||
$items = $this->db->loadObjectList();
|
||||
|
||||
// check if we have an array
|
||||
if (ArrayHelper::check($items))
|
||||
{
|
||||
$this->alias_map[$table] = [];
|
||||
foreach ($items as $item)
|
||||
{
|
||||
// build the key
|
||||
$k_ey = StringHelper::safe($item->alias);
|
||||
$key = preg_replace("/[^A-Za-z]/", '', (string) $k_ey);
|
||||
|
||||
// set the keys
|
||||
$this->alias_map[$table][$item->alias] = $item->guid;
|
||||
$this->alias_map[$table][$k_ey] = $item->guid;
|
||||
$this->alias_map[$table][$key] = $item->guid;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Inspects all fields with outgoing links (type 1) and records their dependencies.
|
||||
*
|
||||
* Handles both plain fields and sub-form paths (denoted by “|”). Any value
|
||||
* encountered is normalised to one-dimensional strings before recording.
|
||||
*
|
||||
* @param object $item The data item containing potential linked field values.
|
||||
*
|
||||
* @return void
|
||||
* @since 5.2.1
|
||||
*/
|
||||
protected function extractLinkedFields(object $item): void
|
||||
{
|
||||
foreach ($this->linked as $fieldName => $link)
|
||||
{
|
||||
// Decide which normaliser to employ
|
||||
$values = (strpos($fieldName, '|') === false)
|
||||
? $this->normalizeToStringArray($item->{$fieldName} ?? null)
|
||||
: $this->normalizeToSubformArray($fieldName, $item);
|
||||
|
||||
// Persist every resolved value
|
||||
foreach ($values as $value)
|
||||
{
|
||||
$this->record('parent', $link['entity'], $value, $link['table'], $link['key']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Extracts entities that depend on this item (incoming links)
|
||||
*
|
||||
* @param object $item The data item containing potential linked field values.
|
||||
*
|
||||
* @return void
|
||||
* @since 5.2.1
|
||||
*/
|
||||
protected function extractDependencies(object $item): void
|
||||
{
|
||||
foreach ($this->dependencies as $fieldName => $tables)
|
||||
{
|
||||
$values = $this->normalizeToStringArray($item->{$fieldName} ?? null);
|
||||
|
||||
foreach ($values as $value)
|
||||
{
|
||||
foreach ($tables as $link)
|
||||
{
|
||||
$this->record('child', $link['entity'], $value, $link['table'], $link['key']);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Inspects all fields for dynamic linking content.
|
||||
*
|
||||
* @param object $item The data item containing potential linked field values.
|
||||
*
|
||||
* @return void
|
||||
* @since 5.2.1
|
||||
*/
|
||||
protected function extractDynamicContent(object $item): void
|
||||
{
|
||||
foreach ($this->code as $field)
|
||||
{
|
||||
$value = $item->{$field} ?? '';
|
||||
|
||||
if (!empty($value))
|
||||
{
|
||||
$this->processCustomCode($value);
|
||||
$this->processTemplates($value);
|
||||
$this->processLayouts($value);
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($this->placeholders as $field)
|
||||
{
|
||||
$value = $item->{$field} ?? '';
|
||||
|
||||
if (!empty($value))
|
||||
{
|
||||
$this->processPlaceholders($value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Process custom code function references from value.
|
||||
*
|
||||
* @param string $value The input string to scan.
|
||||
*
|
||||
* @return void
|
||||
* @since 5.2.1
|
||||
*/
|
||||
private function processCustomCode(string $value): void
|
||||
{
|
||||
$function_names = $this->getCustomCode($value);
|
||||
|
||||
foreach ($function_names as $function_name)
|
||||
{
|
||||
$this->record(
|
||||
'parent',
|
||||
'custom_code',
|
||||
$function_name,
|
||||
'#__componentbuilder_custom_code',
|
||||
'function_name'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Process template usages from value.
|
||||
*
|
||||
* @param string $value The input string to scan.
|
||||
*
|
||||
* @return void
|
||||
* @since 5.2.1
|
||||
*/
|
||||
private function processTemplates(string $value): void
|
||||
{
|
||||
$guids = $this->getTemplates($value);
|
||||
|
||||
foreach ($guids as $guid)
|
||||
{
|
||||
$this->record(
|
||||
'parent',
|
||||
'template',
|
||||
$guid,
|
||||
'#__componentbuilder_template',
|
||||
'guid'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Process layout references from value.
|
||||
*
|
||||
* @param string $value The input string to scan.
|
||||
*
|
||||
* @return void
|
||||
* @since 5.2.1
|
||||
*/
|
||||
private function processLayouts(string $value): void
|
||||
{
|
||||
$guids = $this->getLayouts($value);
|
||||
|
||||
foreach ($guids as $guid)
|
||||
{
|
||||
$this->record(
|
||||
'parent',
|
||||
'layout',
|
||||
$guid,
|
||||
'#__componentbuilder_layout',
|
||||
'guid'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Process placeholder targets from value.
|
||||
*
|
||||
* @param string $value The input string to scan.
|
||||
*
|
||||
* @return void
|
||||
* @since 5.2.1
|
||||
*/
|
||||
private function processPlaceholders(string $value): void
|
||||
{
|
||||
foreach ($this->getPlaceholders($value) as $target)
|
||||
{
|
||||
$this->record('parent', 'placeholder', "[[[{$target}]]]", '#__componentbuilder_placeholder', 'target');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Extracts custom code function names from a string value.
|
||||
*
|
||||
* Handles both direct names and numeric IDs, including parsing
|
||||
* '+'-delimited forms where only the first token is used.
|
||||
*
|
||||
* @param string $value
|
||||
*
|
||||
* @return array
|
||||
* @since 5.2.1
|
||||
*/
|
||||
private function getCustomCode(string $value): array
|
||||
{
|
||||
if (strpos($value, '[CUSTO' . 'MCODE=') === false)
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
$results = [];
|
||||
$matches = GetHelper::allBetween($value, '[CUSTO' . 'MCODE=', ']') ?? [];
|
||||
|
||||
foreach ($matches as $raw)
|
||||
{
|
||||
$raw = trim((string) $raw);
|
||||
|
||||
if (!StringHelper::check($raw))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// Support 'id+name' format, prefer the ID
|
||||
$key = strpos($raw, '+') !== false ? trim(explode('+', $raw, 2)[0]) : $raw;
|
||||
|
||||
// Use helper lookup for numeric keys
|
||||
if (is_numeric($key))
|
||||
{
|
||||
$name = GetHelper::var('custom_code', $key, 'id', 'function_name');
|
||||
|
||||
if (StringHelper::check($name))
|
||||
{
|
||||
$results[] = $name;
|
||||
}
|
||||
}
|
||||
elseif (StringHelper::check($key))
|
||||
{
|
||||
$results[] = $key;
|
||||
}
|
||||
}
|
||||
|
||||
return array_unique($results);
|
||||
}
|
||||
|
||||
/**
|
||||
* Extracts template names (GUIDs) from a string value.
|
||||
*
|
||||
* @param string $value
|
||||
*
|
||||
* @return array
|
||||
* @since 5.2.1
|
||||
*/
|
||||
private function getTemplates(string $value): array
|
||||
{
|
||||
$templates = [];
|
||||
|
||||
$temp1 = GetHelper::allBetween($value, "\$this->load" . "Template('", "')");
|
||||
$temp2 = GetHelper::allBetween($value, '$this->load" . "Template("', '")');
|
||||
|
||||
if (!empty($temp1))
|
||||
{
|
||||
$templates = array_merge($templates, $temp1);
|
||||
}
|
||||
|
||||
if (!empty($temp2))
|
||||
{
|
||||
$templates = array_merge($templates, $temp2);
|
||||
}
|
||||
|
||||
$guids = [];
|
||||
foreach ($templates as $template)
|
||||
{
|
||||
$guid = $this->alias_map['template'][$template] ?? null;
|
||||
if ($guid !== null)
|
||||
{
|
||||
$guids[$guid] = $guid;
|
||||
}
|
||||
}
|
||||
return array_values($guids);
|
||||
}
|
||||
|
||||
/**
|
||||
* Extracts layout names (GUIDs) from a string value.
|
||||
*
|
||||
* @param string $value
|
||||
*
|
||||
* @return array
|
||||
* @since 5.2.1
|
||||
*/
|
||||
private function getLayouts(string $value): array
|
||||
{
|
||||
$layouts = [];
|
||||
|
||||
$patterns = [
|
||||
["Layout" . "Helper::render('", "',"],
|
||||
['Layout" . "Helper::render("', '",'],
|
||||
["Joomla__" . "_7ab82272_0b3d_4bb1_af35_e63a096cfe0b___Power::render('", "',"],
|
||||
['Joomla__' . '_7ab82272_0b3d_4bb1_af35_e63a096cfe0b___Power::render("', '",'],
|
||||
];
|
||||
|
||||
foreach ($patterns as [$start, $end])
|
||||
{
|
||||
$found = GetHelper::allBetween($value, $start, $end);
|
||||
if (!empty($found))
|
||||
{
|
||||
$layouts = array_merge($layouts, $found);
|
||||
}
|
||||
}
|
||||
|
||||
$guids = [];
|
||||
foreach ($layouts as $layout)
|
||||
{
|
||||
$guid = $this->alias_map['layout'][$layout] ?? null;
|
||||
if ($guid !== null)
|
||||
{
|
||||
$guids[$guid] = $guid;
|
||||
}
|
||||
}
|
||||
return array_values($guids);
|
||||
}
|
||||
|
||||
/**
|
||||
* Extracts placeholders from a string value.
|
||||
*
|
||||
* @param string $value
|
||||
*
|
||||
* @return array
|
||||
* @since 5.2.1
|
||||
*/
|
||||
private function getPlaceholders(string $value): array
|
||||
{
|
||||
return GetHelper::allBetween($value, '[[[', ']]]') ?? [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Normalizes a raw field value into an array of strings.
|
||||
*
|
||||
* Accepts strings, arrays of strings, or Traversable of strings. Any invalid or
|
||||
* non-scalar values are excluded.
|
||||
*
|
||||
* @param mixed $raw The raw value from the item field.
|
||||
*
|
||||
* @return string[] A list of clean, non-empty string values.
|
||||
* @since 5.2.1
|
||||
*/
|
||||
private function normalizeToStringArray(mixed $raw): array
|
||||
{
|
||||
return array_values(array_filter(match (true) {
|
||||
is_string($raw) => [$raw],
|
||||
is_array($raw) => $raw,
|
||||
$raw instanceof Traversable => iterator_to_array($raw),
|
||||
default => [],
|
||||
}, static fn($v) => is_string($v) && trim($v) !== ''));
|
||||
}
|
||||
|
||||
/**
|
||||
* Traverses an arbitrarily nested sub-form path and returns every value
|
||||
* found as a clean string array.
|
||||
*
|
||||
* Example field path: "contacts|0|address|street".
|
||||
* • "contacts" is the root field on <code>$item</code> (holds the sub-form rows).
|
||||
* • Intermediate numeric parts are row indexes; non-numeric parts are keys.
|
||||
*
|
||||
* @param string $fieldPath Full field name containing “|” separators.
|
||||
* @param object $item Source data object (row returned from Joomla DB).
|
||||
*
|
||||
* @return string[] One-dimensional list of normalised values.
|
||||
* @since 5.2.1
|
||||
*/
|
||||
private function normalizeToSubformArray(string $fieldPath, object $item): array
|
||||
{
|
||||
$parts = explode('|', $fieldPath);
|
||||
$coreField = array_shift($parts);
|
||||
|
||||
$subData = $item->{$coreField} ?? null;
|
||||
|
||||
// If the core field is missing or isn’t an array, nothing to do
|
||||
if (!is_array($subData))
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
// Collect every leaf value along the remaining path
|
||||
$rawValues = $this->collectSubformValues($subData, $parts);
|
||||
|
||||
// Flatten, normalise, de-duplicate
|
||||
$result = [];
|
||||
foreach ($rawValues as $value)
|
||||
{
|
||||
foreach ($this->normalizeToStringArray($value) as $v)
|
||||
{
|
||||
$result[] = $v;
|
||||
}
|
||||
}
|
||||
|
||||
return array_values(array_unique($result));
|
||||
}
|
||||
|
||||
/**
|
||||
* Recursively digs through the sub-form structure to harvest raw leaf values.
|
||||
*
|
||||
* @param mixed $data Current level (array|object|scalar).
|
||||
* @param string[] $path Remaining segments to traverse.
|
||||
*
|
||||
* @return array Collected raw values (may still be arrays/scalars at this point).
|
||||
* @since 5.2.1
|
||||
*/
|
||||
private function collectSubformValues(mixed $data, array $path): array
|
||||
{
|
||||
if ($data === null)
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
// Reached the end of the path → return whatever is here
|
||||
if ($path === [])
|
||||
{
|
||||
return [$data];
|
||||
}
|
||||
|
||||
$segment = array_shift($path);
|
||||
$collected = [];
|
||||
|
||||
// ───────────────────────────────────────────────────────────
|
||||
// ARRAY HANDLING
|
||||
// ───────────────────────────────────────────────────────────
|
||||
if (is_array($data))
|
||||
{
|
||||
// Numeric segment = address specific row
|
||||
if (is_numeric($segment))
|
||||
{
|
||||
$index = (int) $segment;
|
||||
if (array_key_exists($index, $data))
|
||||
{
|
||||
$collected = $this->collectSubformValues($data[$index], $path);
|
||||
}
|
||||
}
|
||||
// Non-numeric segment = traverse same key in *all* rows
|
||||
else
|
||||
{
|
||||
foreach ($data as $row)
|
||||
{
|
||||
if ((is_array($row) && array_key_exists($segment, $row)) ||
|
||||
(is_object($row) && property_exists($row, $segment)))
|
||||
{
|
||||
$next = is_array($row) ? $row[$segment] : $row->{$segment};
|
||||
$collected = array_merge(
|
||||
$collected,
|
||||
$this->collectSubformValues($next, $path)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ───────────────────────────────────────────────────────────
|
||||
// OBJECT HANDLING
|
||||
// ───────────────────────────────────────────────────────────
|
||||
elseif (is_object($data) && property_exists($data, $segment))
|
||||
{
|
||||
$collected = $this->collectSubformValues($data->{$segment}, $path);
|
||||
}
|
||||
|
||||
return $collected;
|
||||
}
|
||||
|
||||
/**
|
||||
* Records a child/parent in the tracker.
|
||||
*
|
||||
* @param string $target The name of the target direction (child/parent).
|
||||
* @param string $entity The name of the linked entity.
|
||||
* @param string $value The string value representing the link.
|
||||
* @param string $table The table name where the link originates.
|
||||
* @param string $key The key in the target table the link refers to.
|
||||
*
|
||||
* @return void
|
||||
* @since 5.2.1
|
||||
*/
|
||||
private function record(string $target, string $entity, string $value, string $table, string $key): void
|
||||
{
|
||||
$this->tracker->set("{$target}.{$entity}.{$key}.{$value}",
|
||||
[
|
||||
'key' => $key,
|
||||
'value' => $value,
|
||||
'entity' => $entity,
|
||||
'table' => $table
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@@ -9,26 +9,19 @@
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Componentbuilder\JoomlaPower\Remote;
|
||||
namespace VDM\Joomla\Componentbuilder\Package\Dependency;
|
||||
|
||||
|
||||
use VDM\Joomla\Interfaces\Remote\GetInterface;
|
||||
use VDM\Joomla\Abstraction\Remote\Get as ExtendingGet;
|
||||
use VDM\Joomla\Interfaces\Registryinterface;
|
||||
use VDM\Joomla\Abstraction\Registry;
|
||||
|
||||
|
||||
/**
|
||||
* Remote Get Joomla Power of JCB
|
||||
* Package Dependency Tracker
|
||||
*
|
||||
* @since 3.2.0
|
||||
* @since 5.2.1
|
||||
*/
|
||||
final class Get extends ExtendingGet implements GetInterface
|
||||
final class Tracker extends Registry implements Registryinterface
|
||||
{
|
||||
/**
|
||||
* Table Name
|
||||
*
|
||||
* @var string
|
||||
* @since 3.2.1
|
||||
*/
|
||||
protected string $table = 'joomla_power';
|
||||
}
|
||||
|
@@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
@@ -1,281 +0,0 @@
|
||||
<?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'];
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,76 @@
|
||||
<?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\DynamicGet\Readme;
|
||||
|
||||
|
||||
use VDM\Joomla\Interfaces\Readme\ItemInterface;
|
||||
|
||||
|
||||
/**
|
||||
* Compiler Dynamic Get Item Readme
|
||||
*
|
||||
* @since 5.1.1
|
||||
*/
|
||||
final class Item implements ItemInterface
|
||||
{
|
||||
/**
|
||||
* Get an item readme
|
||||
*
|
||||
* @param object $item An item details.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.2
|
||||
*/
|
||||
public function get(object $item): string
|
||||
{
|
||||
// build readme
|
||||
$readme = ["```
|
||||
██╗ ██████╗ ██████╗ ███╗ ███╗██╗ █████╗
|
||||
██║██╔═══██╗██╔═══██╗████╗ ████║██║ ██╔══██╗
|
||||
██║██║ ██║██║ ██║██╔████╔██║██║ ███████║
|
||||
██ ██║██║ ██║██║ ██║██║╚██╔╝██║██║ ██╔══██║
|
||||
╚█████╔╝╚██████╔╝╚██████╔╝██║ ╚═╝ ██║███████╗██║ ██║
|
||||
╚════╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
|
||||
|
||||
██████╗ ██╗ ██╗███╗ ██╗ █████╗ ███╗ ███╗██╗ ██████╗ ██████╗ ███████╗████████╗
|
||||
██╔══██╗╚██╗ ██╔╝████╗ ██║██╔══██╗████╗ ████║██║██╔════╝ ██╔════╝ ██╔════╝╚══██╔══╝
|
||||
██║ ██║ ╚████╔╝ ██╔██╗ ██║███████║██╔████╔██║██║██║ ██║ ███╗█████╗ ██║
|
||||
██║ ██║ ╚██╔╝ ██║╚██╗██║██╔══██║██║╚██╔╝██║██║██║ ██║ ██║██╔══╝ ██║
|
||||
██████╔╝ ██║ ██║ ╚████║██║ ██║██║ ╚═╝ ██║██║╚██████╗ ╚██████╔╝███████╗ ██║
|
||||
╚═════╝ ╚═╝ ╚═╝ ╚═══╝╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═════╝ ╚═════╝ ╚══════╝ ╚═╝
|
||||
```"];
|
||||
// system name
|
||||
$readme[] = "# " . $item->name;
|
||||
|
||||
if (!empty($item->description))
|
||||
{
|
||||
$readme[] = "\n" . $item->description;
|
||||
}
|
||||
|
||||
$readme[] = "\nThe Joomla! Dynamic Get definition contained in this repository delivers a streamlined mechanism for retrieving data—whether that’s a list of records, a single field value, or an aggregated result—from any Joomla database table and exposing it inside a site view or custom admin view created with Joomla Component Builder (JCB). Each Dynamic Get is packaged for full compatibility with the JCB workflow, giving developers a hassle‑free way to bind query results to templates, forms, or business logic without writing SQL from scratch. By using the \"reset\" button, you can instantly synchronize this Dynamic Get with the authoritative version hosted in our core repository, ensuring your components always benefit from the latest performance optimizations, security hardening, and feature enhancements.\n\n If you need to customize the Dynamic Get—perhaps to add extra filters, join additional tables, or reshape the returned data—you’re welcome to fork this repository and point your JCB instance to your fork. This lets you evolve the Dynamic Get on your own schedule while still enjoying the convenience of JCB’s query‑management tooling.\n
|
||||
\n
|
||||
\"This flexible approach embraces JCB’s open-source model, giving you the freedom to adapt your components to your exact needs while staying connected to a powerful and community-driven ecosystem.\"\n";
|
||||
|
||||
// yes you can remove this, but why?
|
||||
$readme[] = "\n---\n```
|
||||
██╗ ██████╗██████╗
|
||||
██║██╔════╝██╔══██╗
|
||||
██║██║ ██████╔╝
|
||||
██ ██║██║ ██╔══██╗
|
||||
╚█████╔╝╚██████╗██████╔╝
|
||||
╚════╝ ╚═════╝╚═════╝
|
||||
```\n> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder)\n\n";
|
||||
|
||||
return implode("\n", $readme);
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,234 @@
|
||||
<?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\DynamicGet\Readme;
|
||||
|
||||
|
||||
use VDM\Joomla\Interfaces\Readme\MainInterface;
|
||||
|
||||
|
||||
/**
|
||||
* Dynamic Get Main Readme
|
||||
*
|
||||
* @since 5.1.1
|
||||
*/
|
||||
final class Main implements MainInterface
|
||||
{
|
||||
/**
|
||||
* Get Main Readme
|
||||
*
|
||||
* @param array $items All items of this repository.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function get(array $items): string
|
||||
{
|
||||
// build readme
|
||||
$readme = ["```
|
||||
██╗ ██████╗ ██████╗ ███╗ ███╗██╗ █████╗
|
||||
██║██╔═══██╗██╔═══██╗████╗ ████║██║ ██╔══██╗
|
||||
██║██║ ██║██║ ██║██╔████╔██║██║ ███████║
|
||||
██ ██║██║ ██║██║ ██║██║╚██╔╝██║██║ ██╔══██║
|
||||
╚█████╔╝╚██████╔╝╚██████╔╝██║ ╚═╝ ██║███████╗██║ ██║
|
||||
╚════╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
|
||||
|
||||
██████╗ ██╗ ██╗███╗ ██╗ █████╗ ███╗ ███╗██╗ ██████╗ ██████╗ ███████╗████████╗███████╗
|
||||
██╔══██╗╚██╗ ██╔╝████╗ ██║██╔══██╗████╗ ████║██║██╔════╝ ██╔════╝ ██╔════╝╚══██╔══╝██╔════╝
|
||||
██║ ██║ ╚████╔╝ ██╔██╗ ██║███████║██╔████╔██║██║██║ ██║ ███╗█████╗ ██║ ███████╗
|
||||
██║ ██║ ╚██╔╝ ██║╚██╗██║██╔══██║██║╚██╔╝██║██║██║ ██║ ██║██╔══╝ ██║ ╚════██║
|
||||
██████╔╝ ██║ ██║ ╚████║██║ ██║██║ ╚═╝ ██║██║╚██████╗ ╚██████╔╝███████╗ ██║ ███████║
|
||||
╚═════╝ ╚═╝ ╚═╝ ╚═══╝╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═════╝ ╚═════╝ ╚══════╝ ╚═╝ ╚══════╝
|
||||
```"];
|
||||
|
||||
// default description of dynamic gets
|
||||
$readme[] = "\n### What are Joomla Dynamic Gets?\nJoomla Dynamic Gets offer a unified way to create, manage, and reuse data‑retrieval definitions that pull records or values from any Joomla database table or field, making the results instantly available in site views or custom admin views built with Joomla Component Builder (JCB). This repository serves as the central hub for curating, versioning, and distributing these Dynamic Gets throughout the entire JCB ecosystem.\n
|
||||
\n
|
||||
When you need to update Dynamic Gets in any JCB project, simply select the desired dynamic get and click the \"reset\" button. This action will automatically sync the selected dynamic get with its corresponding version hosted in our core repository, ensuring you always have the latest updates.\n
|
||||
\n
|
||||
If you need to tailor a Dynamic Get—perhaps to filter data differently, join additional tables, or anything in that line, you can fork the repository and point your JCB instance to your fork. This lets you maintain and evolve Dynamic Gets independently of the main JCB community while preserving the convenience of JCB’s one‑click update mechanism.\n
|
||||
\n
|
||||
\"We believe this approach empowers you to extend and customize JCB to fit your unique requirements, exemplifying the true spirit of freedom in software development. We trust you will find this capability both useful and aligned with the expectations of how open-source software should function.\"\n";
|
||||
|
||||
// get the readme body
|
||||
$readme[] = $this->readmeBuilder($items);
|
||||
|
||||
// yes you can remove this, but why?
|
||||
$readme[] = "\n---\n```
|
||||
██╗ ██████╗ ██████╗ ███╗ ███╗██╗ █████╗
|
||||
██║██╔═══██╗██╔═══██╗████╗ ████║██║ ██╔══██╗
|
||||
██║██║ ██║██║ ██║██╔████╔██║██║ ███████║
|
||||
██ ██║██║ ██║██║ ██║██║╚██╔╝██║██║ ██╔══██║
|
||||
╚█████╔╝╚██████╔╝╚██████╔╝██║ ╚═╝ ██║███████╗██║ ██║
|
||||
╚════╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
|
||||
██████╗ ██████╗ ███╗ ███╗██████╗ ██████╗ ███╗ ██╗███████╗███╗ ██╗████████╗
|
||||
██╔════╝██╔═══██╗████╗ ████║██╔══██╗██╔═══██╗████╗ ██║██╔════╝████╗ ██║╚══██╔══╝
|
||||
██║ ██║ ██║██╔████╔██║██████╔╝██║ ██║██╔██╗ ██║█████╗ ██╔██╗ ██║ ██║
|
||||
██║ ██║ ██║██║╚██╔╝██║██╔═══╝ ██║ ██║██║╚██╗██║██╔══╝ ██║╚██╗██║ ██║
|
||||
╚██████╗╚██████╔╝██║ ╚═╝ ██║██║ ╚██████╔╝██║ ╚████║███████╗██║ ╚████║ ██║
|
||||
╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═════╝ ╚═╝ ╚═══╝╚══════╝╚═╝ ╚═══╝ ╚═╝
|
||||
██████╗ ██╗ ██╗██╗██╗ ██████╗ ███████╗██████╗
|
||||
██╔══██╗██║ ██║██║██║ ██╔══██╗██╔════╝██╔══██╗
|
||||
██████╔╝██║ ██║██║██║ ██║ ██║█████╗ ██████╔╝
|
||||
██╔══██╗██║ ██║██║██║ ██║ ██║██╔══╝ ██╔══██╗
|
||||
██████╔╝╚██████╔╝██║███████╗██████╔╝███████╗██║ ██║
|
||||
╚═════╝ ╚═════╝ ╚═╝╚══════╝╚═════╝ ╚══════╝╚═╝ ╚═╝
|
||||
```\n> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder)\n\n";
|
||||
|
||||
return implode("\n", $readme);
|
||||
}
|
||||
|
||||
/**
|
||||
* The readme builder
|
||||
*
|
||||
* @param array $classes The powers.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
*/
|
||||
private function readmeBuilder(array &$items): string
|
||||
{
|
||||
$classes = [];
|
||||
foreach ($items as $guid => $power)
|
||||
{
|
||||
// add to the sort bucket
|
||||
$classes[] = [
|
||||
'name' => $power['name'],
|
||||
'link' => $this->indexLinkPower($power)
|
||||
];
|
||||
}
|
||||
|
||||
return $this->readmeModel($classes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sort and model the readme classes
|
||||
*
|
||||
* @param array $classes The powers.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
*/
|
||||
private function readmeModel(array &$classes): string
|
||||
{
|
||||
$this->sortClasses($classes);
|
||||
|
||||
return $this->generateIndex($classes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate the index string for classes
|
||||
*
|
||||
* @param array $classes The sorted classes
|
||||
*
|
||||
* @return string The index string
|
||||
*/
|
||||
private function generateIndex(array &$classes): string
|
||||
{
|
||||
$result = "# Index of Joomla! Field Types\n";
|
||||
|
||||
foreach ($classes as $class)
|
||||
{
|
||||
// Add the class details
|
||||
$result .= "\n - " . $class['link'];
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sort the flattened array using a single sorting function
|
||||
*
|
||||
* @param array $classes The classes to sort
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
private function sortClasses(array &$classes): void
|
||||
{
|
||||
usort($classes, function ($a, $b) {
|
||||
return $this->compareName($a, $b);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Compare the name of two classes
|
||||
*
|
||||
* @param array $a First class
|
||||
* @param array $b Second class
|
||||
*
|
||||
* @return int Comparison result
|
||||
* @since 3.2.0
|
||||
*/
|
||||
private function compareName(array $a, array $b): int
|
||||
{
|
||||
return strcmp($a['name'], $b['name']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the Link to the power in this repository
|
||||
*
|
||||
* @param array $power The power details.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
*/
|
||||
private function indexLinkPower(array &$power): string
|
||||
{
|
||||
$name = $power['name'] ?? 'error';
|
||||
return '**' . $name . "** | "
|
||||
. $this->linkPowerRepo($power) . ' | '
|
||||
. $this->linkPowerSettings($power) . ' | '
|
||||
. $this->linkPowerDesc($power);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the Link to the power in this repository
|
||||
*
|
||||
* @param array $power The power details.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
*/
|
||||
private function linkPowerRepo(array &$power): string
|
||||
{
|
||||
$path = $power['path'] ?? 'error';
|
||||
return '[Details](' . $path . ')';
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the Link to the power settings in this repository
|
||||
*
|
||||
* @param array $power The power details.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
*/
|
||||
private function linkPowerSettings(array &$power): string
|
||||
{
|
||||
$settings = $power['settings'] ?? 'error';
|
||||
return '[Settings](' . $settings . ')';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the short description
|
||||
*
|
||||
* @param array $power The power details.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
*/
|
||||
private function linkPowerDesc(array &$power): string
|
||||
{
|
||||
$jpk = $power['desc'] ?? '';
|
||||
return $jpk;
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
@@ -0,0 +1,151 @@
|
||||
<?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\DynamicGet\Remote;
|
||||
|
||||
|
||||
use VDM\Joomla\Interfaces\Remote\ConfigInterface;
|
||||
use VDM\Joomla\Abstraction\Remote\Config as ExtendingConfig;
|
||||
|
||||
|
||||
/**
|
||||
* Base Configure values for the remote classes
|
||||
*
|
||||
* @since 5.1.1
|
||||
*/
|
||||
final class Config extends ExtendingConfig implements ConfigInterface
|
||||
{
|
||||
/**
|
||||
* Table Name
|
||||
*
|
||||
* @var string
|
||||
* @since 5.0.3
|
||||
*/
|
||||
protected string $table = 'dynamic_get';
|
||||
|
||||
/**
|
||||
* Area Name
|
||||
*
|
||||
* @var string|null
|
||||
* @since 3.2.2
|
||||
*/
|
||||
protected ?string $area = 'Dynamic Get';
|
||||
|
||||
/**
|
||||
* Prefix Key
|
||||
*
|
||||
* @var string
|
||||
* @since 3.2.2
|
||||
*/
|
||||
protected string $prefix_key = '';
|
||||
|
||||
/**
|
||||
* Suffix Key
|
||||
*
|
||||
* @var string
|
||||
* @since 3.2.2
|
||||
*/
|
||||
protected string $suffix_key = '';
|
||||
|
||||
/**
|
||||
* The main readme file path
|
||||
*
|
||||
* @var string
|
||||
* @since 5.1.1
|
||||
*/
|
||||
protected string $main_readme_path = 'src/dynamic_get/README.md';
|
||||
|
||||
/**
|
||||
* The index file path (index of all items)
|
||||
*
|
||||
* @var string
|
||||
* @since 3.2.2
|
||||
*/
|
||||
protected string $index_path = 'dynamic-get-index.json';
|
||||
|
||||
/**
|
||||
* The item settings file path
|
||||
*
|
||||
* @var string
|
||||
* @since 3.2.2
|
||||
*/
|
||||
// [DEFAULT] protected string $settings_path = 'item.json';
|
||||
|
||||
/**
|
||||
* The item (files) source path
|
||||
*
|
||||
* @var string
|
||||
* @since 5.1.1
|
||||
*/
|
||||
protected string $src_path = 'src/dynamic_get';
|
||||
|
||||
/**
|
||||
* The item guid=unique field
|
||||
*
|
||||
* @var string
|
||||
* @since 5.1.1
|
||||
*/
|
||||
// [DEFAULT] protected string $guid_field = 'guid';
|
||||
|
||||
/**
|
||||
* The item map
|
||||
*
|
||||
* @var array
|
||||
* @since 5.0.3
|
||||
protected array $map = [];
|
||||
[DEFAULT] */
|
||||
|
||||
/**
|
||||
* The index map
|
||||
* must always have: [name,path,guid]
|
||||
* you can add more
|
||||
*
|
||||
* @var array
|
||||
* @since 5.0.3
|
||||
protected array $index_map = [
|
||||
'name' => 'index_map_IndexName',
|
||||
'path' => 'index_map_IndexPath',
|
||||
'guid' => 'index_map_IndexGUID'
|
||||
];
|
||||
[DEFAULT] */
|
||||
|
||||
/**
|
||||
* The index header
|
||||
* mapping the index map to a table
|
||||
* must always have: [name,path,guid,local]
|
||||
* with [name] always first
|
||||
* with [path,guid,local] always last
|
||||
* you can add more in between
|
||||
*
|
||||
* @var array
|
||||
* @since 5.1.1
|
||||
protected array $index_header = [
|
||||
'name',
|
||||
'path',
|
||||
'guid',
|
||||
'local'
|
||||
];
|
||||
[DEFAULT] */
|
||||
|
||||
/**
|
||||
* Core Placeholders
|
||||
*
|
||||
* @var array
|
||||
* @since 5.0.3
|
||||
protected array $placeholders = [
|
||||
'[['.'[NamespacePrefix]]]' => 'VDM',
|
||||
'[['.'[ComponentNamespace]]]' => 'Componentbuilder',
|
||||
'[['.'[Component]]]' => 'Componentbuilder',
|
||||
'[['.'[component]]]' => 'componentbuilder'
|
||||
];
|
||||
[DEFAULT] */
|
||||
}
|
||||
|
@@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
@@ -13,18 +13,34 @@ 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\Package\Service\Component;
|
||||
use VDM\Joomla\Componentbuilder\Package\Service\AdminView;
|
||||
use VDM\Joomla\Componentbuilder\Package\Service\SiteView;
|
||||
use VDM\Joomla\Componentbuilder\Package\Service\CustomAdminView;
|
||||
use VDM\Joomla\Componentbuilder\Package\Service\CustomCode;
|
||||
use VDM\Joomla\Componentbuilder\Package\Service\DynamicGet;
|
||||
use VDM\Joomla\Componentbuilder\Package\Service\Template;
|
||||
use VDM\Joomla\Componentbuilder\Package\Service\Layout;
|
||||
use VDM\Joomla\Componentbuilder\Package\Service\Library;
|
||||
use VDM\Joomla\Componentbuilder\Package\Service\Package;
|
||||
use VDM\Joomla\Componentbuilder\Package\Service\Field;
|
||||
use VDM\Joomla\Service\Database;
|
||||
use VDM\Joomla\Service\Model;
|
||||
use VDM\Joomla\Service\Data;
|
||||
use VDM\Joomla\Componentbuilder\Service\Gitea;
|
||||
use VDM\Joomla\Componentbuilder\Power\Service\Gitea as GiteaPower;
|
||||
use VDM\Joomla\Gitea\Service\Utilities as GiteaUtilities;
|
||||
use VDM\Joomla\Componentbuilder\Service\Api;
|
||||
use VDM\Joomla\Componentbuilder\Service\Network;
|
||||
use VDM\Joomla\Componentbuilder\Service\Utilities;
|
||||
use VDM\Joomla\Interfaces\FactoryInterface;
|
||||
use VDM\Joomla\Abstraction\Factory as ExtendingFactory;
|
||||
|
||||
|
||||
/**
|
||||
* Package Factory
|
||||
* Package Power Factory
|
||||
*
|
||||
* @since 3.2.0
|
||||
* @since 5.2.1
|
||||
*/
|
||||
abstract class Factory extends ExtendingFactory implements FactoryInterface
|
||||
{
|
||||
@@ -32,7 +48,7 @@ abstract class Factory extends ExtendingFactory implements FactoryInterface
|
||||
* Package Container
|
||||
*
|
||||
* @var Container|null
|
||||
* @since 5.0.3
|
||||
* @since 5.2.1
|
||||
**/
|
||||
protected static ?Container $container = null;
|
||||
|
||||
@@ -40,16 +56,31 @@ abstract class Factory extends ExtendingFactory implements FactoryInterface
|
||||
* Create a container object
|
||||
*
|
||||
* @return Container
|
||||
* @since 3.2.0
|
||||
* @since 5.2.1
|
||||
*/
|
||||
protected static function createContainer(): Container
|
||||
{
|
||||
return (new Container())
|
||||
->registerServiceProvider(new Component())
|
||||
->registerServiceProvider(new AdminView())
|
||||
->registerServiceProvider(new SiteView())
|
||||
->registerServiceProvider(new CustomAdminView())
|
||||
->registerServiceProvider(new CustomCode())
|
||||
->registerServiceProvider(new DynamicGet())
|
||||
->registerServiceProvider(new Template())
|
||||
->registerServiceProvider(new Layout())
|
||||
->registerServiceProvider(new Library())
|
||||
->registerServiceProvider(new Package())
|
||||
->registerServiceProvider(new Field())
|
||||
->registerServiceProvider(new Database())
|
||||
->registerServiceProvider(new Crypt())
|
||||
->registerServiceProvider(new Server())
|
||||
->registerServiceProvider(new Display());
|
||||
}
|
||||
|
||||
->registerServiceProvider(new Model())
|
||||
->registerServiceProvider(new Data())
|
||||
->registerServiceProvider(new Gitea())
|
||||
->registerServiceProvider(new GiteaPower())
|
||||
->registerServiceProvider(new GiteaUtilities())
|
||||
->registerServiceProvider(new Api())
|
||||
->registerServiceProvider(new Network())
|
||||
->registerServiceProvider(new Utilities());
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -0,0 +1,76 @@
|
||||
<?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\Field\Readme;
|
||||
|
||||
|
||||
use VDM\Joomla\Interfaces\Readme\ItemInterface;
|
||||
|
||||
|
||||
/**
|
||||
* Compiler Field Item Readme
|
||||
*
|
||||
* @since 5.1.1
|
||||
*/
|
||||
final class Item implements ItemInterface
|
||||
{
|
||||
/**
|
||||
* Get an item readme
|
||||
*
|
||||
* @param object $item An item details.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.2
|
||||
*/
|
||||
public function get(object $item): string
|
||||
{
|
||||
// build readme
|
||||
$readme = ["```
|
||||
██╗ ██████╗ ██████╗ ███╗ ███╗██╗ █████╗
|
||||
██║██╔═══██╗██╔═══██╗████╗ ████║██║ ██╔══██╗
|
||||
██║██║ ██║██║ ██║██╔████╔██║██║ ███████║
|
||||
██ ██║██║ ██║██║ ██║██║╚██╔╝██║██║ ██╔══██║
|
||||
╚█████╔╝╚██████╔╝╚██████╔╝██║ ╚═╝ ██║███████╗██║ ██║
|
||||
╚════╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
|
||||
|
||||
███████╗██╗███████╗██╗ ██████╗
|
||||
██╔════╝██║██╔════╝██║ ██╔══██╗
|
||||
█████╗ ██║█████╗ ██║ ██║ ██║
|
||||
██╔══╝ ██║██╔══╝ ██║ ██║ ██║
|
||||
██║ ██║███████╗███████╗██████╔╝
|
||||
╚═╝ ╚═╝╚══════╝╚══════╝╚═════╝
|
||||
```"];
|
||||
// system name
|
||||
$readme[] = "# " . $item->name;
|
||||
|
||||
if (!empty($item->description))
|
||||
{
|
||||
$readme[] = "\n" . $item->description;
|
||||
}
|
||||
|
||||
$readme[] = "\nThe Joomla Field is the heartbeat of every JCB‑built component: it defines a slice of the data schema, drives form generation, and dictates how a single piece of information is captured, validated, and stored in the database. By combining its fieldtype, datatype, and parameters into a reusable building block, the field underpins every admin view, site view, and custom admin view, making it a foundational element of the entire JCB ecosystem. By using the \"reset\" button, you can instantly synchronize this Field with the authoritative version hosted in our core repository, ensuring your Components always benefit from the latest refinements, performance optimizations, and security enhancements.\n\n If you want something more different from the provided fields. Fork the repo, tailor the field, and point JCB to your branch. Whether you’re storing different types of data, setting different parameters, you stay in charge while still enjoying JCB’s effortless deployment workflow.\n
|
||||
\n
|
||||
\"This flexible approach embraces JCB’s open-source model, giving you the freedom to adapt your components to your exact needs while staying connected to a powerful and community-driven ecosystem.\"\n";
|
||||
|
||||
// yes you can remove this, but why?
|
||||
$readme[] = "\n---\n```
|
||||
██╗ ██████╗██████╗
|
||||
██║██╔════╝██╔══██╗
|
||||
██║██║ ██████╔╝
|
||||
██ ██║██║ ██╔══██╗
|
||||
╚█████╔╝╚██████╗██████╔╝
|
||||
╚════╝ ╚═════╝╚═════╝
|
||||
```\n> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder)\n\n";
|
||||
|
||||
return implode("\n", $readme);
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,234 @@
|
||||
<?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\Field\Readme;
|
||||
|
||||
|
||||
use VDM\Joomla\Interfaces\Readme\MainInterface;
|
||||
|
||||
|
||||
/**
|
||||
* Field Main Readme
|
||||
*
|
||||
* @since 5.1.1
|
||||
*/
|
||||
final class Main implements MainInterface
|
||||
{
|
||||
/**
|
||||
* Get Main Readme
|
||||
*
|
||||
* @param array $items All items of this repository.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function get(array $items): string
|
||||
{
|
||||
// build readme
|
||||
$readme = ["```
|
||||
██╗ ██████╗ ██████╗ ███╗ ███╗██╗ █████╗
|
||||
██║██╔═══██╗██╔═══██╗████╗ ████║██║ ██╔══██╗
|
||||
██║██║ ██║██║ ██║██╔████╔██║██║ ███████║
|
||||
██ ██║██║ ██║██║ ██║██║╚██╔╝██║██║ ██╔══██║
|
||||
╚█████╔╝╚██████╔╝╚██████╔╝██║ ╚═╝ ██║███████╗██║ ██║
|
||||
╚════╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
|
||||
|
||||
███████╗██╗███████╗██╗ ██████╗ ███████╗
|
||||
██╔════╝██║██╔════╝██║ ██╔══██╗██╔════╝
|
||||
█████╗ ██║█████╗ ██║ ██║ ██║███████╗
|
||||
██╔══╝ ██║██╔══╝ ██║ ██║ ██║╚════██║
|
||||
██║ ██║███████╗███████╗██████╔╝███████║
|
||||
╚═╝ ╚═╝╚══════╝╚══════╝╚═════╝ ╚══════╝
|
||||
```"];
|
||||
|
||||
// default description of fields
|
||||
$readme[] = "\n### What are Joomla Fields?\nJoomla fields are the heartbeat of every JCB‑built component: they define the data schema, drive form generation, and dictate how information is captured, validated, and stored in the database. By combining fieldtypes, datatypes, and field parameters into reusable building blocks, fields lay the groundwork upon which all admin views, site views, and custom admin views are constructed, making them the foundation of the entire JCB ecosystem.\n
|
||||
\n
|
||||
Whenever you need to update Fields in any JCB project, simply select the desired fields and click the \"reset\" button. The selected fields is synchronized with the original version stored in this repository, bringing the latest design tweaks, security fixes, and performance boosts.\n
|
||||
\n
|
||||
If your project calls for more distinctive fields, or component‑specific business logic. Simply fork the repository and point JCB to your copy. This lets you maintain and evolve Joomla Fields independently of the main JCB community while preserving the convenience of JCB’s one‑click update mechanism.\n
|
||||
\n
|
||||
\"We believe this approach empowers you to extend and customize JCB to fit your unique requirements, exemplifying the true spirit of freedom in software development. We trust you will find this capability both useful and aligned with the expectations of how open-source software should function.\"\n";
|
||||
|
||||
// get the readme body
|
||||
$readme[] = $this->readmeBuilder($items);
|
||||
|
||||
// yes you can remove this, but why?
|
||||
$readme[] = "\n---\n```
|
||||
██╗ ██████╗ ██████╗ ███╗ ███╗██╗ █████╗
|
||||
██║██╔═══██╗██╔═══██╗████╗ ████║██║ ██╔══██╗
|
||||
██║██║ ██║██║ ██║██╔████╔██║██║ ███████║
|
||||
██ ██║██║ ██║██║ ██║██║╚██╔╝██║██║ ██╔══██║
|
||||
╚█████╔╝╚██████╔╝╚██████╔╝██║ ╚═╝ ██║███████╗██║ ██║
|
||||
╚════╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
|
||||
██████╗ ██████╗ ███╗ ███╗██████╗ ██████╗ ███╗ ██╗███████╗███╗ ██╗████████╗
|
||||
██╔════╝██╔═══██╗████╗ ████║██╔══██╗██╔═══██╗████╗ ██║██╔════╝████╗ ██║╚══██╔══╝
|
||||
██║ ██║ ██║██╔████╔██║██████╔╝██║ ██║██╔██╗ ██║█████╗ ██╔██╗ ██║ ██║
|
||||
██║ ██║ ██║██║╚██╔╝██║██╔═══╝ ██║ ██║██║╚██╗██║██╔══╝ ██║╚██╗██║ ██║
|
||||
╚██████╗╚██████╔╝██║ ╚═╝ ██║██║ ╚██████╔╝██║ ╚████║███████╗██║ ╚████║ ██║
|
||||
╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═════╝ ╚═╝ ╚═══╝╚══════╝╚═╝ ╚═══╝ ╚═╝
|
||||
██████╗ ██╗ ██╗██╗██╗ ██████╗ ███████╗██████╗
|
||||
██╔══██╗██║ ██║██║██║ ██╔══██╗██╔════╝██╔══██╗
|
||||
██████╔╝██║ ██║██║██║ ██║ ██║█████╗ ██████╔╝
|
||||
██╔══██╗██║ ██║██║██║ ██║ ██║██╔══╝ ██╔══██╗
|
||||
██████╔╝╚██████╔╝██║███████╗██████╔╝███████╗██║ ██║
|
||||
╚═════╝ ╚═════╝ ╚═╝╚══════╝╚═════╝ ╚══════╝╚═╝ ╚═╝
|
||||
```\n> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder)\n\n";
|
||||
|
||||
return implode("\n", $readme);
|
||||
}
|
||||
|
||||
/**
|
||||
* The readme builder
|
||||
*
|
||||
* @param array $classes The powers.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
*/
|
||||
private function readmeBuilder(array &$items): string
|
||||
{
|
||||
$classes = [];
|
||||
foreach ($items as $guid => $power)
|
||||
{
|
||||
// add to the sort bucket
|
||||
$classes[] = [
|
||||
'name' => $power['name'],
|
||||
'link' => $this->indexLinkPower($power)
|
||||
];
|
||||
}
|
||||
|
||||
return $this->readmeModel($classes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sort and model the readme classes
|
||||
*
|
||||
* @param array $classes The powers.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
*/
|
||||
private function readmeModel(array &$classes): string
|
||||
{
|
||||
$this->sortClasses($classes);
|
||||
|
||||
return $this->generateIndex($classes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate the index string for classes
|
||||
*
|
||||
* @param array $classes The sorted classes
|
||||
*
|
||||
* @return string The index string
|
||||
*/
|
||||
private function generateIndex(array &$classes): string
|
||||
{
|
||||
$result = "# Index of Joomla! Field Types\n";
|
||||
|
||||
foreach ($classes as $class)
|
||||
{
|
||||
// Add the class details
|
||||
$result .= "\n - " . $class['link'];
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sort the flattened array using a single sorting function
|
||||
*
|
||||
* @param array $classes The classes to sort
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
private function sortClasses(array &$classes): void
|
||||
{
|
||||
usort($classes, function ($a, $b) {
|
||||
return $this->compareName($a, $b);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Compare the name of two classes
|
||||
*
|
||||
* @param array $a First class
|
||||
* @param array $b Second class
|
||||
*
|
||||
* @return int Comparison result
|
||||
* @since 3.2.0
|
||||
*/
|
||||
private function compareName(array $a, array $b): int
|
||||
{
|
||||
return strcmp($a['name'], $b['name']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the Link to the power in this repository
|
||||
*
|
||||
* @param array $power The power details.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
*/
|
||||
private function indexLinkPower(array &$power): string
|
||||
{
|
||||
$name = $power['name'] ?? 'error';
|
||||
return '**' . $name . "** | "
|
||||
. $this->linkPowerRepo($power) . ' | '
|
||||
. $this->linkPowerSettings($power) . ' | '
|
||||
. $this->linkPowerDesc($power);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the Link to the power in this repository
|
||||
*
|
||||
* @param array $power The power details.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
*/
|
||||
private function linkPowerRepo(array &$power): string
|
||||
{
|
||||
$path = $power['path'] ?? 'error';
|
||||
return '[Details](' . $path . ')';
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the Link to the power settings in this repository
|
||||
*
|
||||
* @param array $power The power details.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
*/
|
||||
private function linkPowerSettings(array &$power): string
|
||||
{
|
||||
$settings = $power['settings'] ?? 'error';
|
||||
return '[Settings](' . $settings . ')';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the short description
|
||||
*
|
||||
* @param array $power The power details.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
*/
|
||||
private function linkPowerDesc(array &$power): string
|
||||
{
|
||||
$jpk = $power['desc'] ?? '';
|
||||
return $jpk;
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
@@ -0,0 +1,151 @@
|
||||
<?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\Field\Remote;
|
||||
|
||||
|
||||
use VDM\Joomla\Interfaces\Remote\ConfigInterface;
|
||||
use VDM\Joomla\Abstraction\Remote\Config as ExtendingConfig;
|
||||
|
||||
|
||||
/**
|
||||
* Base Configure values for the remote classes
|
||||
*
|
||||
* @since 5.2.1
|
||||
*/
|
||||
final class Config extends ExtendingConfig implements ConfigInterface
|
||||
{
|
||||
/**
|
||||
* Table Name
|
||||
*
|
||||
* @var string
|
||||
* @since 5.0.3
|
||||
*/
|
||||
protected string $table = 'field';
|
||||
|
||||
/**
|
||||
* Area Name
|
||||
*
|
||||
* @var string|null
|
||||
* @since 3.2.2
|
||||
*/
|
||||
protected ?string $area = 'Field';
|
||||
|
||||
/**
|
||||
* Prefix Key
|
||||
*
|
||||
* @var string
|
||||
* @since 3.2.2
|
||||
*/
|
||||
protected string $prefix_key = '';
|
||||
|
||||
/**
|
||||
* Suffix Key
|
||||
*
|
||||
* @var string
|
||||
* @since 3.2.2
|
||||
*/
|
||||
protected string $suffix_key = '';
|
||||
|
||||
/**
|
||||
* The main readme file path
|
||||
*
|
||||
* @var string
|
||||
* @since 5.2.1
|
||||
*/
|
||||
protected string $main_readme_path = 'src/field/README.md';
|
||||
|
||||
/**
|
||||
* The index file path (index of all items)
|
||||
*
|
||||
* @var string
|
||||
* @since 3.2.2
|
||||
*/
|
||||
protected string $index_path = 'field-index.json';
|
||||
|
||||
/**
|
||||
* The item settings file path
|
||||
*
|
||||
* @var string
|
||||
* @since 3.2.2
|
||||
*/
|
||||
// [DEFAULT] protected string $settings_path = 'item.json';
|
||||
|
||||
/**
|
||||
* The item (files) source path
|
||||
*
|
||||
* @var string
|
||||
* @since 5.2.1
|
||||
*/
|
||||
protected string $src_path = 'src/field';
|
||||
|
||||
/**
|
||||
* The item guid=unique field
|
||||
*
|
||||
* @var string
|
||||
* @since 5.2.1
|
||||
*/
|
||||
// [DEFAULT] protected string $guid_field = 'guid';
|
||||
|
||||
/**
|
||||
* The item map
|
||||
*
|
||||
* @var array
|
||||
* @since 5.0.3
|
||||
protected array $map = [];
|
||||
[DEFAULT] */
|
||||
|
||||
/**
|
||||
* The index map
|
||||
* must always have: [name,path,guid]
|
||||
* you can add more
|
||||
*
|
||||
* @var array
|
||||
* @since 5.0.3
|
||||
protected array $index_map = [
|
||||
'name' => 'index_map_IndexName',
|
||||
'path' => 'index_map_IndexPath',
|
||||
'guid' => 'index_map_IndexGUID'
|
||||
];
|
||||
[DEFAULT] */
|
||||
|
||||
/**
|
||||
* The index header
|
||||
* mapping the index map to a table
|
||||
* must always have: [name,path,guid,local]
|
||||
* with [name] always first
|
||||
* with [path,guid,local] always last
|
||||
* you can add more in between
|
||||
*
|
||||
* @var array
|
||||
* @since 5.2.1
|
||||
protected array $index_header = [
|
||||
'name',
|
||||
'path',
|
||||
'guid',
|
||||
'local'
|
||||
];
|
||||
[DEFAULT] */
|
||||
|
||||
/**
|
||||
* Core Placeholders
|
||||
*
|
||||
* @var array
|
||||
* @since 5.0.3
|
||||
protected array $placeholders = [
|
||||
'[['.'[NamespacePrefix]]]' => 'VDM',
|
||||
'[['.'[ComponentNamespace]]]' => 'Componentbuilder',
|
||||
'[['.'[Component]]]' => 'Componentbuilder',
|
||||
'[['.'[component]]]' => 'componentbuilder'
|
||||
];
|
||||
[DEFAULT] */
|
||||
}
|
||||
|
@@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
@@ -0,0 +1,165 @@
|
||||
<?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\CMS\Language\Text;
|
||||
use VDM\Joomla\Interfaces\GrepInterface;
|
||||
use VDM\Joomla\Abstraction\Grep as ExtendingGrep;
|
||||
|
||||
|
||||
/**
|
||||
* Global Resource Empowerment Platform
|
||||
*
|
||||
* The Grep feature will try to find your power in the repositories
|
||||
* linked to this [area], and if it can't be found there will try the global core
|
||||
* Super Powers of JCB. All searches are performed according the [algorithm:cascading]
|
||||
* See documentation for more details: https://git.vdm.dev/joomla/super-powers/wiki
|
||||
*
|
||||
* @since 5.2.1
|
||||
*/
|
||||
final class Grep extends ExtendingGrep implements GrepInterface
|
||||
{
|
||||
/**
|
||||
* The Grep target [network]
|
||||
*
|
||||
* @var string
|
||||
* @since 5.2.1
|
||||
**/
|
||||
protected ?string $target = 'package';
|
||||
|
||||
/**
|
||||
* Order of global search
|
||||
*
|
||||
* @var array
|
||||
* @since 5.2.1
|
||||
**/
|
||||
protected array $order = ['remote'];
|
||||
|
||||
/**
|
||||
* Search for a remote item
|
||||
*
|
||||
* @param string $guid The global unique id of the item
|
||||
*
|
||||
* @return object|null
|
||||
* @since 5.2.1
|
||||
*/
|
||||
protected function searchRemote(string $guid): ?object
|
||||
{
|
||||
// check if it exists remotely
|
||||
if (($path = $this->existsRemotely($guid)) !== null)
|
||||
{
|
||||
return $this->getRemote($path, $guid);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a remote joomla power
|
||||
*
|
||||
* @param object $path The repository path details
|
||||
* @param string $guid The global unique id of the power
|
||||
*
|
||||
* @return object|null
|
||||
* @since 5.2.1
|
||||
*/
|
||||
protected function getRemote(object $path, string $guid): ?object
|
||||
{
|
||||
$power = null;
|
||||
if (empty($path->index->{$guid}->path))
|
||||
{
|
||||
return $power;
|
||||
}
|
||||
|
||||
// get the branch name
|
||||
$branch = $this->getBranchName($path);
|
||||
|
||||
// get the guid_field key
|
||||
$guid_field = $this->getGuidField();
|
||||
|
||||
// get the settings path
|
||||
$settings_path = $this->getSettingsPath();
|
||||
|
||||
// load the base and token if set
|
||||
$this->loadApi($this->contents, $path->base ?? null, $path->token ?? null);
|
||||
|
||||
// get the settings
|
||||
if (($power = $this->loadRemoteFile($path->organisation, $path->repository, $path->index->{$guid}->path . '/' . $settings_path, $branch)) !== null &&
|
||||
isset($power->{$guid_field}))
|
||||
{
|
||||
// set the git details in params
|
||||
$path_guid = $path->guid ?? null;
|
||||
if ($path_guid !== null)
|
||||
{
|
||||
// get the Settings meta
|
||||
if (($meta = $this->contents->metadata($path->organisation, $path->repository, $path->index->{$guid}->path . '/' . $settings_path, $branch)) !== null &&
|
||||
isset($meta->sha))
|
||||
{
|
||||
if (isset($power->params) && is_object($power->params) &&
|
||||
isset($power->params->source) && is_array($power->params->source))
|
||||
{
|
||||
$power->params->source[$path_guid . '-settings'] = $meta->sha;
|
||||
}
|
||||
else
|
||||
{
|
||||
$power->params = (object) [
|
||||
'source' => [$path_guid . '-settings' => $meta->sha]
|
||||
];
|
||||
}
|
||||
}
|
||||
// get the README meta
|
||||
if (($meta = $this->contents->metadata($path->organisation, $path->repository, $path->index->{$guid}->path . '/README.md', $branch)) !== null &&
|
||||
isset($meta->sha))
|
||||
{
|
||||
if (isset($power->params) && is_object($power->params) &&
|
||||
isset($power->params->source) && is_array($power->params->source))
|
||||
{
|
||||
$power->params->source[$path_guid . '-readme'] = $meta->sha;
|
||||
}
|
||||
else
|
||||
{
|
||||
$power->params = (object) [
|
||||
'source' => [$path_guid . '-readme' => $meta->sha]
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// reset back to the global base and token
|
||||
$this->contents->reset_();
|
||||
|
||||
return $power;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set repository messages and errors based on given conditions.
|
||||
*
|
||||
* @param string $message The message to set (if error)
|
||||
* @param string $path Path value
|
||||
* @param string $repository Repository name
|
||||
* @param string $organisation Organisation name
|
||||
* @param string|null $base Base URL
|
||||
*
|
||||
* @return void
|
||||
* @since 5.2.1
|
||||
*/
|
||||
protected function setRemoteIndexMessage(string $message, string $path, string $repository, string $organisation, ?string $base): void
|
||||
{
|
||||
$this->app->enqueueMessage(
|
||||
Text::sprintf('COM_COMPONENTBUILDER_PPACKAGEB_REPOSITORY_AT_BSSB_GAVE_THE_FOLLOWING_ERRORBR_SP', $this->contents->api(), $path, $message),
|
||||
'Error'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,80 @@
|
||||
<?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\Layout\Readme;
|
||||
|
||||
|
||||
use VDM\Joomla\Interfaces\Readme\ItemInterface;
|
||||
|
||||
|
||||
/**
|
||||
* Compiler Layout Item Readme
|
||||
*
|
||||
* @since 5.1.1
|
||||
*/
|
||||
final class Item implements ItemInterface
|
||||
{
|
||||
/**
|
||||
* Get an item readme
|
||||
*
|
||||
* @param object $item An item details.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.2
|
||||
*/
|
||||
public function get(object $item): string
|
||||
{
|
||||
// build readme
|
||||
$readme = ["```
|
||||
██╗ ██████╗ ██████╗ ███╗ ███╗██╗ █████╗
|
||||
██║██╔═══██╗██╔═══██╗████╗ ████║██║ ██╔══██╗
|
||||
██║██║ ██║██║ ██║██╔████╔██║██║ ███████║
|
||||
██ ██║██║ ██║██║ ██║██║╚██╔╝██║██║ ██╔══██║
|
||||
╚█████╔╝╚██████╔╝╚██████╔╝██║ ╚═╝ ██║███████╗██║ ██║
|
||||
╚════╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
|
||||
|
||||
██╗ █████╗ ██╗ ██╗ ██████╗ ██╗ ██╗████████╗
|
||||
██║ ██╔══██╗╚██╗ ██╔╝██╔═══██╗██║ ██║╚══██╔══╝
|
||||
██║ ███████║ ╚████╔╝ ██║ ██║██║ ██║ ██║
|
||||
██║ ██╔══██║ ╚██╔╝ ██║ ██║██║ ██║ ██║
|
||||
███████╗██║ ██║ ██║ ╚██████╔╝╚██████╔╝ ██║
|
||||
╚══════╝╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═╝
|
||||
```"];
|
||||
// system name
|
||||
$readme[] = "# " . $item->name;
|
||||
|
||||
if (!empty($item->description))
|
||||
{
|
||||
$readme[] = "\n" . $item->description;
|
||||
}
|
||||
|
||||
$readme[] = "The Joomla layout within this repository offer a robust mechanism for integrating structured, reusable HTML and PHP code into Joomla Component Builder (JCB). Each layout is carefully crafted to ensure full compatibility and ease of use within the JCB framework, allowing developers to streamline interface design, enforce consistency, and accelerate custom component development.\n
|
||||
\n
|
||||
Using the reset functionality, you can quickly update any individual layout to the latest version from the official core repository, ensuring that your components benefit from the most recent improvements, features, and fixes.\n
|
||||
\n
|
||||
For developers who require more tailored solutions, this repository can be forked. By pointing your JCB instance to your custom fork, you gain full control over your layouts, allowing you to modify, maintain, and distribute them independently from the main JCB repository.\n
|
||||
\n
|
||||
This flexible approach embraces JCB’s open-source model, giving you the freedom to adapt your components to your exact needs while staying connected to a powerful and community-driven ecosystem.\n";
|
||||
|
||||
// yes you can remove this, but why?
|
||||
$readme[] = "\n---\n```
|
||||
██╗ ██████╗██████╗
|
||||
██║██╔════╝██╔══██╗
|
||||
██║██║ ██████╔╝
|
||||
██ ██║██║ ██╔══██╗
|
||||
╚█████╔╝╚██████╗██████╔╝
|
||||
╚════╝ ╚═════╝╚═════╝
|
||||
```\n> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder)\n\n";
|
||||
|
||||
return implode("\n", $readme);
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,236 @@
|
||||
<?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\Layout\Readme;
|
||||
|
||||
|
||||
use VDM\Joomla\Interfaces\Readme\MainInterface;
|
||||
|
||||
|
||||
/**
|
||||
* Layout Main Readme
|
||||
*
|
||||
* @since 5.1.1
|
||||
*/
|
||||
final class Main implements MainInterface
|
||||
{
|
||||
/**
|
||||
* Get Main Readme
|
||||
*
|
||||
* @param array $items All items of this repository.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function get(array $items): string
|
||||
{
|
||||
// build readme
|
||||
$readme = ["```
|
||||
██╗ ██████╗ ██████╗ ███╗ ███╗██╗ █████╗
|
||||
██║██╔═══██╗██╔═══██╗████╗ ████║██║ ██╔══██╗
|
||||
██║██║ ██║██║ ██║██╔████╔██║██║ ███████║
|
||||
██ ██║██║ ██║██║ ██║██║╚██╔╝██║██║ ██╔══██║
|
||||
╚█████╔╝╚██████╔╝╚██████╔╝██║ ╚═╝ ██║███████╗██║ ██║
|
||||
╚════╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
|
||||
|
||||
██╗ █████╗ ██╗ ██╗ ██████╗ ██╗ ██╗████████╗███████╗
|
||||
██║ ██╔══██╗╚██╗ ██╔╝██╔═══██╗██║ ██║╚══██╔══╝██╔════╝
|
||||
██║ ███████║ ╚████╔╝ ██║ ██║██║ ██║ ██║ ███████╗
|
||||
██║ ██╔══██║ ╚██╔╝ ██║ ██║██║ ██║ ██║ ╚════██║
|
||||
███████╗██║ ██║ ██║ ╚██████╔╝╚██████╔╝ ██║ ███████║
|
||||
╚══════╝╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═╝ ╚══════╝
|
||||
```"];
|
||||
|
||||
// default description of super powers
|
||||
$readme[] = "\n### What is Joomla Layouts?\n
|
||||
\n
|
||||
Joomla layouts provide a powerful way to structure and render reusable sections of code across components, enabling seamless integration with Joomla Component Builder (JCB). This repository serves as a centralized system for maintaining, updating, and distributing these layouts throughout the JCB ecosystem.\n
|
||||
\n
|
||||
When you need to update any layout in JCB, simply select the desired layout and click the "reset" button. This action will automatically sync the selected layout with its corresponding version hosted in our core repository, ensuring you always benefit from the latest enhancements and fixes.\n
|
||||
\n
|
||||
Moreover, if you wish to tailor the layouts to suit your specific component designs, you can fork the repository and point your JCB instance to your fork. This allows you to maintain and update layouts independently from the main JCB community, offering the flexibility that is central to the open-source philosophy.\n
|
||||
\n
|
||||
This flexible approach embraces JCB’s open-source model, giving you the freedom to adapt your components to your exact needs while staying connected to a powerful and community-driven ecosystem.\n";
|
||||
|
||||
// get the readme body
|
||||
$readme[] = $this->readmeBuilder($items);
|
||||
|
||||
// yes you can remove this, but why?
|
||||
$readme[] = "\n---\n```
|
||||
██╗ ██████╗ ██████╗ ███╗ ███╗██╗ █████╗
|
||||
██║██╔═══██╗██╔═══██╗████╗ ████║██║ ██╔══██╗
|
||||
██║██║ ██║██║ ██║██╔████╔██║██║ ███████║
|
||||
██ ██║██║ ██║██║ ██║██║╚██╔╝██║██║ ██╔══██║
|
||||
╚█████╔╝╚██████╔╝╚██████╔╝██║ ╚═╝ ██║███████╗██║ ██║
|
||||
╚════╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
|
||||
██████╗ ██████╗ ███╗ ███╗██████╗ ██████╗ ███╗ ██╗███████╗███╗ ██╗████████╗
|
||||
██╔════╝██╔═══██╗████╗ ████║██╔══██╗██╔═══██╗████╗ ██║██╔════╝████╗ ██║╚══██╔══╝
|
||||
██║ ██║ ██║██╔████╔██║██████╔╝██║ ██║██╔██╗ ██║█████╗ ██╔██╗ ██║ ██║
|
||||
██║ ██║ ██║██║╚██╔╝██║██╔═══╝ ██║ ██║██║╚██╗██║██╔══╝ ██║╚██╗██║ ██║
|
||||
╚██████╗╚██████╔╝██║ ╚═╝ ██║██║ ╚██████╔╝██║ ╚████║███████╗██║ ╚████║ ██║
|
||||
╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═════╝ ╚═╝ ╚═══╝╚══════╝╚═╝ ╚═══╝ ╚═╝
|
||||
██████╗ ██╗ ██╗██╗██╗ ██████╗ ███████╗██████╗
|
||||
██╔══██╗██║ ██║██║██║ ██╔══██╗██╔════╝██╔══██╗
|
||||
██████╔╝██║ ██║██║██║ ██║ ██║█████╗ ██████╔╝
|
||||
██╔══██╗██║ ██║██║██║ ██║ ██║██╔══╝ ██╔══██╗
|
||||
██████╔╝╚██████╔╝██║███████╗██████╔╝███████╗██║ ██║
|
||||
╚═════╝ ╚═════╝ ╚═╝╚══════╝╚═════╝ ╚══════╝╚═╝ ╚═╝
|
||||
```\n> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder)\n\n";
|
||||
|
||||
return implode("\n", $readme);
|
||||
}
|
||||
|
||||
/**
|
||||
* The readme builder
|
||||
*
|
||||
* @param array $classes The powers.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
*/
|
||||
private function readmeBuilder(array &$items): string
|
||||
{
|
||||
$classes = [];
|
||||
foreach ($items as $guid => $power)
|
||||
{
|
||||
// add to the sort bucket
|
||||
$classes[] = [
|
||||
'name' => $power['name'],
|
||||
'link' => $this->indexLinkPower($power)
|
||||
];
|
||||
}
|
||||
|
||||
return $this->readmeModel($classes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sort and model the readme classes
|
||||
*
|
||||
* @param array $classes The powers.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
*/
|
||||
private function readmeModel(array &$classes): string
|
||||
{
|
||||
$this->sortClasses($classes);
|
||||
|
||||
return $this->generateIndex($classes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate the index string for classes
|
||||
*
|
||||
* @param array $classes The sorted classes
|
||||
*
|
||||
* @return string The index string
|
||||
*/
|
||||
private function generateIndex(array &$classes): string
|
||||
{
|
||||
$result = "# Index of Joomla! Field Types\n";
|
||||
|
||||
foreach ($classes as $class)
|
||||
{
|
||||
// Add the class details
|
||||
$result .= "\n - " . $class['link'];
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sort the flattened array using a single sorting function
|
||||
*
|
||||
* @param array $classes The classes to sort
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
private function sortClasses(array &$classes): void
|
||||
{
|
||||
usort($classes, function ($a, $b) {
|
||||
return $this->compareName($a, $b);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Compare the name of two classes
|
||||
*
|
||||
* @param array $a First class
|
||||
* @param array $b Second class
|
||||
*
|
||||
* @return int Comparison result
|
||||
* @since 3.2.0
|
||||
*/
|
||||
private function compareName(array $a, array $b): int
|
||||
{
|
||||
return strcmp($a['name'], $b['name']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the Link to the power in this repository
|
||||
*
|
||||
* @param array $power The power details.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
*/
|
||||
private function indexLinkPower(array &$power): string
|
||||
{
|
||||
$name = $power['name'] ?? 'error';
|
||||
return '**' . $name . "** | "
|
||||
. $this->linkPowerRepo($power) . ' | '
|
||||
. $this->linkPowerSettings($power) . ' | '
|
||||
. $this->linkPowerDesc($power);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the Link to the power in this repository
|
||||
*
|
||||
* @param array $power The power details.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
*/
|
||||
private function linkPowerRepo(array &$power): string
|
||||
{
|
||||
$path = $power['path'] ?? 'error';
|
||||
return '[Details](' . $path . ')';
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the Link to the power settings in this repository
|
||||
*
|
||||
* @param array $power The power details.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
*/
|
||||
private function linkPowerSettings(array &$power): string
|
||||
{
|
||||
$settings = $power['settings'] ?? 'error';
|
||||
return '[Settings](' . $settings . ')';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the short description
|
||||
*
|
||||
* @param array $power The power details.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
*/
|
||||
private function linkPowerDesc(array &$power): string
|
||||
{
|
||||
$jpk = $power['desc'] ?? '';
|
||||
return $jpk;
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
@@ -0,0 +1,153 @@
|
||||
<?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\Layout\Remote;
|
||||
|
||||
|
||||
use VDM\Joomla\Interfaces\Remote\ConfigInterface;
|
||||
use VDM\Joomla\Abstraction\Remote\Config as ExtendingConfig;
|
||||
|
||||
|
||||
/**
|
||||
* Base Configure values for the remote classes
|
||||
*
|
||||
* @since 5.1.1
|
||||
*/
|
||||
final class Config extends ExtendingConfig implements ConfigInterface
|
||||
{
|
||||
/**
|
||||
* Table Name
|
||||
*
|
||||
* @var string
|
||||
* @since 5.1.1
|
||||
*/
|
||||
protected string $table = 'layout';
|
||||
|
||||
/**
|
||||
* Area Name
|
||||
*
|
||||
* @var string|null
|
||||
* @since 3.2.2
|
||||
*/
|
||||
protected ?string $area = 'Layout';
|
||||
|
||||
/**
|
||||
* Prefix Key
|
||||
*
|
||||
* @var string
|
||||
* @since 3.2.2
|
||||
*/
|
||||
protected string $prefix_key = '';
|
||||
|
||||
/**
|
||||
* Suffix Key
|
||||
*
|
||||
* @var string
|
||||
* @since 3.2.2
|
||||
*/
|
||||
protected string $suffix_key = '';
|
||||
|
||||
/**
|
||||
* The main readme file path
|
||||
*
|
||||
* @var string
|
||||
* @since 5.1.1
|
||||
*/
|
||||
protected string $main_readme_path = 'src/layout/README.md';
|
||||
|
||||
/**
|
||||
* The index file path (index of all items)
|
||||
*
|
||||
* @var string
|
||||
* @since 3.2.2
|
||||
*/
|
||||
protected string $index_path = 'layout-index.json';
|
||||
|
||||
/**
|
||||
* The item (files) source path
|
||||
*
|
||||
* @var string
|
||||
* @since 5.1.1
|
||||
*/
|
||||
protected string $src_path = 'src/layout';
|
||||
|
||||
/**
|
||||
* The item settings file path
|
||||
*
|
||||
* @var string
|
||||
* @since 3.2.2
|
||||
*/
|
||||
// [DEFAULT] protected string $settings_path = 'item.json';
|
||||
|
||||
/**
|
||||
* The item guid=unique field
|
||||
*
|
||||
* @var string
|
||||
* @since 5.1.1
|
||||
*/
|
||||
// [DEFAULT] protected string $guid_field = 'guid';
|
||||
|
||||
/**
|
||||
* The item map
|
||||
*
|
||||
* @var array
|
||||
* @since 5.0.3
|
||||
protected array $map = [];
|
||||
[DEFAULT] */
|
||||
|
||||
/**
|
||||
* The index map
|
||||
* must always have: [name,path,guid]
|
||||
* you can add more
|
||||
*
|
||||
* @var array
|
||||
* @since 5.0.3
|
||||
*/
|
||||
protected array $index_map = [
|
||||
'name' => 'index_map_IndexName',
|
||||
'description' => 'index_map_ShortDescription',
|
||||
'path' => 'index_map_IndexPath',
|
||||
'guid' => 'index_map_IndexGUID'
|
||||
];
|
||||
|
||||
/**
|
||||
* The index header
|
||||
* mapping the index map to a table
|
||||
* must always have: [name,path,guid,local]
|
||||
* with [name] always first
|
||||
* with [path,guid,local] always last
|
||||
* you can add more in between
|
||||
*
|
||||
* @var array
|
||||
* @since 5.1.1
|
||||
*/
|
||||
protected array $index_header = [
|
||||
'name',
|
||||
'description',
|
||||
'path',
|
||||
'guid',
|
||||
'local'
|
||||
];
|
||||
|
||||
/**
|
||||
* Core Placeholders
|
||||
*
|
||||
* @var array
|
||||
* @since 5.0.3
|
||||
protected array $placeholders = [
|
||||
'[['.'[NamespacePrefix]]]' => 'VDM',
|
||||
'[['.'[ComponentNamespace]]]' => 'Componentbuilder',
|
||||
'[['.'[Component]]]' => 'Componentbuilder',
|
||||
'[['.'[component]]]' => 'componentbuilder'
|
||||
];
|
||||
[DEFAULT] */
|
||||
}
|
||||
|
@@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
@@ -0,0 +1,77 @@
|
||||
<?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\Library\Readme;
|
||||
|
||||
|
||||
use VDM\Joomla\Interfaces\Readme\ItemInterface;
|
||||
|
||||
|
||||
/**
|
||||
* Compiler Library Item Readme
|
||||
*
|
||||
* @since 5.1.1
|
||||
*/
|
||||
final class Item implements ItemInterface
|
||||
{
|
||||
/**
|
||||
* Get an item readme
|
||||
*
|
||||
* @param object $item An item details.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.2
|
||||
*/
|
||||
public function get(object $item): string
|
||||
{
|
||||
// build readme
|
||||
$readme = ["```
|
||||
██╗ ██████╗ ██████╗ ███╗ ███╗██╗ █████╗
|
||||
██║██╔═══██╗██╔═══██╗████╗ ████║██║ ██╔══██╗
|
||||
██║██║ ██║██║ ██║██╔████╔██║██║ ███████║
|
||||
██ ██║██║ ██║██║ ██║██║╚██╔╝██║██║ ██╔══██║
|
||||
╚█████╔╝╚██████╔╝╚██████╔╝██║ ╚═╝ ██║███████╗██║ ██║
|
||||
╚════╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
|
||||
|
||||
██╗ ██╗██████╗ ██████╗ █████╗ ██████╗ ██╗ ██╗
|
||||
██║ ██║██╔══██╗██╔══██╗██╔══██╗██╔══██╗╚██╗ ██╔╝
|
||||
██║ ██║██████╔╝██████╔╝███████║██████╔╝ ╚████╔╝
|
||||
██║ ██║██╔══██╗██╔══██╗██╔══██║██╔══██╗ ╚██╔╝
|
||||
███████╗██║██████╔╝██║ ██║██║ ██║██║ ██║ ██║
|
||||
╚══════╝╚═╝╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝ ╚═╝
|
||||
```"];
|
||||
|
||||
// system name
|
||||
$readme[] = "# " . $item->name;
|
||||
|
||||
if (!empty($item->description))
|
||||
{
|
||||
$readme[] = "\n" . $item->description;
|
||||
}
|
||||
|
||||
$readme[] = "\nThe Joomla! library contained in this repository delivers a streamlined mechanism for integrating a specific media framework—such as Bootstrap, UIkit, or any other asset bundle—directly into components built with Joomla Component Builder (JCB). Each library is carefully packaged for full compatibility with the JCB workflow, giving developers a hassle‑free way to enqueue its CSS, JavaScript, and related resources within their projects. By utilizing the \"reset\" functionality, users can seamlessly update individual field types to align with the latest versions maintained in our core repository, ensuring that their projects benefit from the most up-to-date features and fixes.\n\n If you need to customize the library—whether that involves theme adjustments, removing unused modules, or adding proprietary extensions—you’re welcome to fork this repository and direct your JCB instance to your fork. This lets you evolve the library on your own schedule while still enjoying the convenience of JCB’s asset‑management tooling.\n
|
||||
\n
|
||||
\"This flexible approach embraces JCB’s open-source model, giving you the freedom to adapt your components to your exact needs while staying connected to a powerful and community-driven ecosystem.\"\n";
|
||||
|
||||
// yes you can remove this, but why?
|
||||
$readme[] = "\n---\n```
|
||||
██╗ ██████╗██████╗
|
||||
██║██╔════╝██╔══██╗
|
||||
██║██║ ██████╔╝
|
||||
██ ██║██║ ██╔══██╗
|
||||
╚█████╔╝╚██████╗██████╔╝
|
||||
╚════╝ ╚═════╝╚═════╝
|
||||
```\n> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder)\n\n";
|
||||
|
||||
return implode("\n", $readme);
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,234 @@
|
||||
<?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\Library\Readme;
|
||||
|
||||
|
||||
use VDM\Joomla\Interfaces\Readme\MainInterface;
|
||||
|
||||
|
||||
/**
|
||||
* Library Main Readme
|
||||
*
|
||||
* @since 5.1.1
|
||||
*/
|
||||
final class Main implements MainInterface
|
||||
{
|
||||
/**
|
||||
* Get Main Readme
|
||||
*
|
||||
* @param array $items All items of this repository.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function get(array $items): string
|
||||
{
|
||||
// build readme
|
||||
$readme = ["```
|
||||
██╗ ██████╗ ██████╗ ███╗ ███╗██╗ █████╗
|
||||
██║██╔═══██╗██╔═══██╗████╗ ████║██║ ██╔══██╗
|
||||
██║██║ ██║██║ ██║██╔████╔██║██║ ███████║
|
||||
██ ██║██║ ██║██║ ██║██║╚██╔╝██║██║ ██╔══██║
|
||||
╚█████╔╝╚██████╔╝╚██████╔╝██║ ╚═╝ ██║███████╗██║ ██║
|
||||
╚════╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
|
||||
|
||||
██╗ ██╗██████╗ ██████╗ █████╗ ██████╗ ██╗███████╗███████╗
|
||||
██║ ██║██╔══██╗██╔══██╗██╔══██╗██╔══██╗██║██╔════╝██╔════╝
|
||||
██║ ██║██████╔╝██████╔╝███████║██████╔╝██║█████╗ ███████╗
|
||||
██║ ██║██╔══██╗██╔══██╗██╔══██║██╔══██╗██║██╔══╝ ╚════██║
|
||||
███████╗██║██████╔╝██║ ██║██║ ██║██║ ██║██║███████╗███████║
|
||||
╚══════╝╚═╝╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝╚═╝╚══════╝╚══════╝
|
||||
```"];
|
||||
|
||||
// default description of libraries
|
||||
$readme[] = "\n### What is Joomla Libraries?\nThe Joomla Libraries provide a unified, version‑controlled bundle of front‑end and utility frameworks—such as Bootstrap, UIkit, Font Awesome, and others—for components built with Joomla Component Builder (JCB). This repository acts as the central hub for curating, selecting, and distributing these libraries across the entire JCB ecosystem, ensuring consistent loading and simplified maintenance.\n
|
||||
\n
|
||||
When you need to update Libraries in any JCB project, simply select the desired libraries and click the \"reset\" button. This action will automatically sync the selected library with its corresponding version hosted in our core repository, ensuring you always have the latest updates.\n
|
||||
\n
|
||||
Moreover, if you wish to tailor the Libraries to your specific needs, you can fork the repository and point your JCB instance to your fork. This allows you to maintain and update libraries independently from the main JCB community, offering the flexibility that is at the heart of open-source philosophy.\n
|
||||
\n
|
||||
\"We believe this approach empowers you to extend and customize JCB to fit your unique requirements, exemplifying the true spirit of freedom in software development. We trust you will find this capability both useful and aligned with the expectations of how open-source software should function.\"\n";
|
||||
|
||||
// get the readme body
|
||||
$readme[] = $this->readmeBuilder($items);
|
||||
|
||||
// yes you can remove this, but why?
|
||||
$readme[] = "\n---\n```
|
||||
██╗ ██████╗ ██████╗ ███╗ ███╗██╗ █████╗
|
||||
██║██╔═══██╗██╔═══██╗████╗ ████║██║ ██╔══██╗
|
||||
██║██║ ██║██║ ██║██╔████╔██║██║ ███████║
|
||||
██ ██║██║ ██║██║ ██║██║╚██╔╝██║██║ ██╔══██║
|
||||
╚█████╔╝╚██████╔╝╚██████╔╝██║ ╚═╝ ██║███████╗██║ ██║
|
||||
╚════╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
|
||||
██████╗ ██████╗ ███╗ ███╗██████╗ ██████╗ ███╗ ██╗███████╗███╗ ██╗████████╗
|
||||
██╔════╝██╔═══██╗████╗ ████║██╔══██╗██╔═══██╗████╗ ██║██╔════╝████╗ ██║╚══██╔══╝
|
||||
██║ ██║ ██║██╔████╔██║██████╔╝██║ ██║██╔██╗ ██║█████╗ ██╔██╗ ██║ ██║
|
||||
██║ ██║ ██║██║╚██╔╝██║██╔═══╝ ██║ ██║██║╚██╗██║██╔══╝ ██║╚██╗██║ ██║
|
||||
╚██████╗╚██████╔╝██║ ╚═╝ ██║██║ ╚██████╔╝██║ ╚████║███████╗██║ ╚████║ ██║
|
||||
╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═════╝ ╚═╝ ╚═══╝╚══════╝╚═╝ ╚═══╝ ╚═╝
|
||||
██████╗ ██╗ ██╗██╗██╗ ██████╗ ███████╗██████╗
|
||||
██╔══██╗██║ ██║██║██║ ██╔══██╗██╔════╝██╔══██╗
|
||||
██████╔╝██║ ██║██║██║ ██║ ██║█████╗ ██████╔╝
|
||||
██╔══██╗██║ ██║██║██║ ██║ ██║██╔══╝ ██╔══██╗
|
||||
██████╔╝╚██████╔╝██║███████╗██████╔╝███████╗██║ ██║
|
||||
╚═════╝ ╚═════╝ ╚═╝╚══════╝╚═════╝ ╚══════╝╚═╝ ╚═╝
|
||||
```\n> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder)\n\n";
|
||||
|
||||
return implode("\n", $readme);
|
||||
}
|
||||
|
||||
/**
|
||||
* The readme builder
|
||||
*
|
||||
* @param array $classes The powers.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
*/
|
||||
private function readmeBuilder(array &$items): string
|
||||
{
|
||||
$classes = [];
|
||||
foreach ($items as $guid => $power)
|
||||
{
|
||||
// add to the sort bucket
|
||||
$classes[] = [
|
||||
'name' => $power['name'],
|
||||
'link' => $this->indexLinkPower($power)
|
||||
];
|
||||
}
|
||||
|
||||
return $this->readmeModel($classes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sort and model the readme classes
|
||||
*
|
||||
* @param array $classes The powers.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
*/
|
||||
private function readmeModel(array &$classes): string
|
||||
{
|
||||
$this->sortClasses($classes);
|
||||
|
||||
return $this->generateIndex($classes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate the index string for classes
|
||||
*
|
||||
* @param array $classes The sorted classes
|
||||
*
|
||||
* @return string The index string
|
||||
*/
|
||||
private function generateIndex(array &$classes): string
|
||||
{
|
||||
$result = "# Index of Joomla! Field Types\n";
|
||||
|
||||
foreach ($classes as $class)
|
||||
{
|
||||
// Add the class details
|
||||
$result .= "\n - " . $class['link'];
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sort the flattened array using a single sorting function
|
||||
*
|
||||
* @param array $classes The classes to sort
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
private function sortClasses(array &$classes): void
|
||||
{
|
||||
usort($classes, function ($a, $b) {
|
||||
return $this->compareName($a, $b);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Compare the name of two classes
|
||||
*
|
||||
* @param array $a First class
|
||||
* @param array $b Second class
|
||||
*
|
||||
* @return int Comparison result
|
||||
* @since 3.2.0
|
||||
*/
|
||||
private function compareName(array $a, array $b): int
|
||||
{
|
||||
return strcmp($a['name'], $b['name']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the Link to the power in this repository
|
||||
*
|
||||
* @param array $power The power details.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
*/
|
||||
private function indexLinkPower(array &$power): string
|
||||
{
|
||||
$name = $power['name'] ?? 'error';
|
||||
return '**' . $name . "** | "
|
||||
. $this->linkPowerRepo($power) . ' | '
|
||||
. $this->linkPowerSettings($power) . ' | '
|
||||
. $this->linkPowerDesc($power);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the Link to the power in this repository
|
||||
*
|
||||
* @param array $power The power details.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
*/
|
||||
private function linkPowerRepo(array &$power): string
|
||||
{
|
||||
$path = $power['path'] ?? 'error';
|
||||
return '[Details](' . $path . ')';
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the Link to the power settings in this repository
|
||||
*
|
||||
* @param array $power The power details.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
*/
|
||||
private function linkPowerSettings(array &$power): string
|
||||
{
|
||||
$settings = $power['settings'] ?? 'error';
|
||||
return '[Settings](' . $settings . ')';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the short description
|
||||
*
|
||||
* @param array $power The power details.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
*/
|
||||
private function linkPowerDesc(array &$power): string
|
||||
{
|
||||
$jpk = $power['desc'] ?? '';
|
||||
return $jpk;
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
@@ -0,0 +1,152 @@
|
||||
<?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\Library\Remote;
|
||||
|
||||
|
||||
use VDM\Joomla\Interfaces\Remote\ConfigInterface;
|
||||
use VDM\Joomla\Abstraction\Remote\Config as ExtendingConfig;
|
||||
|
||||
|
||||
/**
|
||||
* Base Configure values for the remote classes
|
||||
*
|
||||
* @since 5.1.1
|
||||
*/
|
||||
final class Config extends ExtendingConfig implements ConfigInterface
|
||||
{
|
||||
/**
|
||||
* Table Name
|
||||
*
|
||||
* @var string
|
||||
* @since 5.0.3
|
||||
*/
|
||||
protected string $table = 'library';
|
||||
|
||||
/**
|
||||
* Area Name
|
||||
*
|
||||
* @var string|null
|
||||
* @since 3.2.2
|
||||
*/
|
||||
protected ?string $area = 'Library';
|
||||
|
||||
/**
|
||||
* Prefix Key
|
||||
*
|
||||
* @var string
|
||||
* @since 3.2.2
|
||||
*/
|
||||
protected string $prefix_key = '';
|
||||
|
||||
/**
|
||||
* Suffix Key
|
||||
*
|
||||
* @var string
|
||||
* @since 3.2.2
|
||||
*/
|
||||
protected string $suffix_key = '';
|
||||
|
||||
/**
|
||||
* The main readme file path
|
||||
*
|
||||
* @var string
|
||||
* @since 5.1.1
|
||||
*/
|
||||
protected string $main_readme_path = 'src/library/README.md';
|
||||
|
||||
/**
|
||||
* The index file path (index of all items)
|
||||
*
|
||||
* @var string
|
||||
* @since 3.2.2
|
||||
*/
|
||||
protected string $index_path = 'library-index.json';
|
||||
|
||||
/**
|
||||
* The item (files) source path
|
||||
*
|
||||
* @var string
|
||||
* @since 5.1.1
|
||||
*/
|
||||
protected string $src_path = 'src/library';
|
||||
|
||||
/**
|
||||
* The item settings file path
|
||||
*
|
||||
* @var string
|
||||
* @since 3.2.2
|
||||
*/
|
||||
// [DEFAULT] protected string $settings_path = 'item.json';
|
||||
|
||||
/**
|
||||
* The item guid=unique field
|
||||
*
|
||||
* @var string
|
||||
* @since 5.1.1
|
||||
*/
|
||||
// [DEFAULT] protected string $guid_field = 'guid';
|
||||
|
||||
/**
|
||||
* The item map
|
||||
*
|
||||
* @var array
|
||||
* @since 5.0.3
|
||||
protected array $map = [];
|
||||
[DEFAULT] */
|
||||
|
||||
/**
|
||||
* The index map
|
||||
* must always have: [name,path,guid]
|
||||
* you can add more
|
||||
*
|
||||
* @var array
|
||||
* @since 5.0.3
|
||||
*/
|
||||
protected array $index_map = [
|
||||
'name' => 'index_map_IndexName',
|
||||
'description' => 'index_map_ShortDescription',
|
||||
'path' => 'index_map_IndexPath',
|
||||
'guid' => 'index_map_IndexGUID'
|
||||
];
|
||||
|
||||
/**
|
||||
* The index header
|
||||
* mapping the index map to a table
|
||||
* must always have: [name,path,guid,local]
|
||||
* with [name] always first
|
||||
* with [path,guid,local] always last
|
||||
* you can add more in between
|
||||
*
|
||||
* @var array
|
||||
* @since 5.1.1
|
||||
protected array $index_header = [
|
||||
'name',
|
||||
'description',
|
||||
'path',
|
||||
'guid',
|
||||
'local'
|
||||
];
|
||||
|
||||
/**
|
||||
* Core Placeholders
|
||||
*
|
||||
* @var array
|
||||
* @since 5.0.3
|
||||
protected array $placeholders = [
|
||||
'[['.'[NamespacePrefix]]]' => 'VDM',
|
||||
'[['.'[ComponentNamespace]]]' => 'Componentbuilder',
|
||||
'[['.'[Component]]]' => 'Componentbuilder',
|
||||
'[['.'[component]]]' => 'componentbuilder'
|
||||
];
|
||||
[DEFAULT] */
|
||||
}
|
||||
|
@@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
@@ -9,26 +9,26 @@
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Componentbuilder\Fieldtype\Remote;
|
||||
namespace VDM\Joomla\Componentbuilder\Package;
|
||||
|
||||
|
||||
use VDM\Joomla\Interfaces\Remote\GetInterface;
|
||||
use VDM\Joomla\Abstraction\Remote\Get as ExtendingGet;
|
||||
use VDM\Joomla\Interfaces\Registryinterface;
|
||||
use VDM\Joomla\Abstraction\Registry;
|
||||
|
||||
|
||||
/**
|
||||
* Remote Get Field Type of JCB
|
||||
* Remote Message Bus
|
||||
*
|
||||
* @since 5.0.3
|
||||
* @since 5.2.1
|
||||
*/
|
||||
final class Get extends ExtendingGet implements GetInterface
|
||||
final class MessageBus extends Registry implements Registryinterface
|
||||
{
|
||||
/**
|
||||
* Table Name
|
||||
* Base switch to add values as string or array
|
||||
*
|
||||
* @var string
|
||||
* @since 5.0.3
|
||||
*/
|
||||
protected string $table = 'fieldtype';
|
||||
* @var boolean
|
||||
* @since 5.2.1
|
||||
**/
|
||||
protected bool $addAsArray = true;
|
||||
}
|
||||
|
@@ -0,0 +1,145 @@
|
||||
<?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\Remote\CustomCode;
|
||||
|
||||
|
||||
use VDM\Joomla\Data\Action\Load;
|
||||
use VDM\Joomla\Interfaces\Remote\ConfigInterface as Config;
|
||||
use VDM\Joomla\Interfaces\GrepInterface as Grep;
|
||||
use VDM\Joomla\Interfaces\Data\ItemsInterface as Items;
|
||||
use VDM\Joomla\Interfaces\Readme\ItemInterface as ItemReadme;
|
||||
use VDM\Joomla\Interfaces\Readme\MainInterface as MainReadme;
|
||||
use VDM\Joomla\Interfaces\Git\Repository\ContentsInterface as Git;
|
||||
use VDM\Joomla\Interfaces\Remote\SetInterface;
|
||||
use VDM\Joomla\Componentbuilder\Package\Remote\Set as ExtendingSet;
|
||||
|
||||
|
||||
/**
|
||||
* Set Custom Code based on function names to remote repository
|
||||
*
|
||||
* @since 5.2.1
|
||||
*/
|
||||
final class Set extends ExtendingSet implements SetInterface
|
||||
{
|
||||
/**
|
||||
* The Load Class.
|
||||
*
|
||||
* @var Load
|
||||
* @since 5.2.1
|
||||
*/
|
||||
protected Load $load;
|
||||
|
||||
/**
|
||||
* Cache component names
|
||||
*
|
||||
* @var array
|
||||
* @since 5.2.1
|
||||
**/
|
||||
protected array $component_names;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param Load $load The Load Class.
|
||||
* @param Config $config The Config Class.
|
||||
* @param Grep $grep The Grep Class.
|
||||
* @param Items $items The Items Class.
|
||||
* @param ItemReadme $itemReadme The Item Readme Class.
|
||||
* @param MainReadme $mainReadme The Main Readme Class.
|
||||
* @param Git $git The Contents Class.
|
||||
* @param MessageBus $messages The MessageBus Class.
|
||||
* @param array $repos The active repos.
|
||||
* @param string|null $table The table name.
|
||||
* @param string|null $settingsPath The settings path.
|
||||
* @param string|null $indexPath The index path.
|
||||
*
|
||||
* @since 5.2.1
|
||||
*/
|
||||
public function __construct(Load $load, Config $config, Grep $grep, Items $items, ItemReadme $itemReadme,
|
||||
MainReadme $mainReadme, Git $git, MessageBus $messages, array $repos, ?string $table = null,
|
||||
?string $settingsPath = null, ?string $indexPath = null)
|
||||
{
|
||||
parent::__construct($config, $grep, $items, $itemReadme, $mainReadme,
|
||||
$git, $messages, $repos, $table, $settingsPath, $indexPath);
|
||||
|
||||
$this->load = $load;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the item name for the index values
|
||||
*
|
||||
* @param object $item
|
||||
*
|
||||
* @return string|null
|
||||
* @since 5.2.1
|
||||
*/
|
||||
protected function index_map_IndexName(object $item): ?string
|
||||
{
|
||||
if ($item->target == 1)
|
||||
{
|
||||
if (isset($this->component_names[$item->component]))
|
||||
{
|
||||
$component_name = $this->component_names[$item->component] ?? '[error loading the name]';
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->component_names[$item->component] = $this->load->table('joomla_component')->value(['guid' => $item->component], 'system_name');
|
||||
$component_name = $this->component_names[$item->component] ?? '[error loading the name]';
|
||||
}
|
||||
return "Component: {$component_name}";
|
||||
}
|
||||
return $item->system_name ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the item Short Description for the index values
|
||||
*
|
||||
* @param object $item
|
||||
*
|
||||
* @return string|null
|
||||
* @since 5.2.1
|
||||
*/
|
||||
protected function index_map_ShortDescription(object $item): ?string
|
||||
{
|
||||
if ($item->target == 1)
|
||||
{
|
||||
$comment = ($item->comment_type == 1) ? 'PHP/JS' : 'HTML';
|
||||
$type = ($item->type == 1) ? 'Replacement' : 'Insertion';
|
||||
$version = $item->joomla_version ?? 5;
|
||||
return "Hash (automation) | {$comment} [{$type}] | J{$version}";
|
||||
}
|
||||
return 'JCB (manual)';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the item GUID for the index values
|
||||
*
|
||||
* @param object $item
|
||||
*
|
||||
* @return string
|
||||
* @since 5.2.1
|
||||
*/
|
||||
protected function index_map_IndexGUID(object $item): string
|
||||
{
|
||||
if ($item->target == 1)
|
||||
{
|
||||
$path = str_replace('/', '#', $item->path);
|
||||
if (!empty($path))
|
||||
{
|
||||
return $path;
|
||||
}
|
||||
}
|
||||
$guid_field = $this->getGuidField();
|
||||
return $item->{$guid_field} ?? 'error';
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
@@ -0,0 +1,145 @@
|
||||
<?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\Remote;
|
||||
|
||||
|
||||
use Joomla\CMS\Language\Text;
|
||||
use VDM\Joomla\Interfaces\Remote\SetInterface;
|
||||
use VDM\Joomla\Abstraction\Remote\Set as ExtendingSet;
|
||||
|
||||
|
||||
/**
|
||||
* Set Layout based on global unique ids to remote repository
|
||||
*
|
||||
* @since 5.2.1
|
||||
*/
|
||||
class Set extends ExtendingSet implements SetInterface
|
||||
{
|
||||
/**
|
||||
* update an existing item (if changed)
|
||||
*
|
||||
* @param object $item
|
||||
* @param object $existing
|
||||
* @param object $repo
|
||||
*
|
||||
* @return bool
|
||||
* @since 5.0.3
|
||||
*/
|
||||
protected function updateItem(object $item, object $existing, object $repo): bool
|
||||
{
|
||||
$sha = $existing->params->source[$repo->guid . '-settings'] ?? null;
|
||||
$existing = $this->mapItem($existing);
|
||||
$area = $this->getArea();
|
||||
$item_name = $this->index_map_IndexName($item);
|
||||
$repo_name = $this->getRepoName($repo);
|
||||
|
||||
if ($sha === null || $this->areObjectsEqual($item, $existing))
|
||||
{
|
||||
$this->messages->add('warning', Text::sprintf('COM_COMPONENTBUILDER_S_ITEM_S_DETAILS_IN_REPOS_DID_NOT_CHANGE_SO_NO_UPDATE_WAS_MADE', $area, $item_name, $repo_name));
|
||||
return false;
|
||||
}
|
||||
|
||||
$result = $this->git->update(
|
||||
$repo->organisation, // The owner name.
|
||||
$repo->repository, // The repository name.
|
||||
$this->index_map_IndexSettingsPath($item), // The file path.
|
||||
json_encode($item, JSON_PRETTY_PRINT), // The file content.
|
||||
'Update ' . $item->name, // The commit message.
|
||||
$sha, // The blob SHA of the old file.
|
||||
$repo->write_branch // The branch name.
|
||||
);
|
||||
|
||||
$success = is_object($result);
|
||||
|
||||
if (!$success)
|
||||
{
|
||||
$this->messages->add('warning', Text::sprintf('COM_COMPONENTBUILDER_S_ITEM_S_DETAILS_IN_REPOS_FAILED_TO_UPDATE', $area, $item_name, $repo_name));
|
||||
}
|
||||
|
||||
return $success;
|
||||
}
|
||||
|
||||
/**
|
||||
* create a new item
|
||||
*
|
||||
* @param object $item
|
||||
* @param object $repo
|
||||
*
|
||||
* @return bool
|
||||
* @since 5.0.3
|
||||
*/
|
||||
protected function createItem(object $item, object $repo): bool
|
||||
{
|
||||
$result = $this->git->create(
|
||||
$repo->organisation, // The owner name.
|
||||
$repo->repository, // The repository name.
|
||||
$this->index_map_IndexSettingsPath($item), // The file path.
|
||||
json_encode($item, JSON_PRETTY_PRINT), // The file content.
|
||||
'Create ' . $item->name, // The commit message.
|
||||
$repo->write_branch // The branch name.
|
||||
);
|
||||
|
||||
return is_object($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* update an existing item readme
|
||||
*
|
||||
* @param object $item
|
||||
* @param object $existing
|
||||
* @param object $repo
|
||||
*
|
||||
* @return void
|
||||
* @since 5.0.3
|
||||
*/
|
||||
protected function updateItemReadme(object $item, object $existing, object $repo): void
|
||||
{
|
||||
// make sure there was a change
|
||||
$sha = $existing->params->source[$repo->guid . '-readme'] ?? null;
|
||||
if ($sha === null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$this->git->update(
|
||||
$repo->organisation, // The owner name.
|
||||
$repo->repository, // The repository name.
|
||||
$this->index_map_IndexPath($item) . '/README.md', // The file path.
|
||||
$this->itemReadme->get($item), // The file content.
|
||||
'Update ' . $item->name . ' readme file', // The commit message.
|
||||
$sha, // The blob SHA of the old file.
|
||||
$repo->write_branch // The branch name.
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* create a new item readme
|
||||
*
|
||||
* @param object $item
|
||||
* @param object $repo
|
||||
*
|
||||
* @return void
|
||||
* @since 5.0.3
|
||||
*/
|
||||
protected function createItemReadme(object $item, object $repo): void
|
||||
{
|
||||
$this->git->create(
|
||||
$repo->organisation, // The owner name.
|
||||
$repo->repository, // The repository name.
|
||||
$this->index_map_IndexPath($item) . '/README.md', // The file path.
|
||||
$this->itemReadme->get($item), // The file content.
|
||||
'Create ' . $item->name . ' readme file', // The commit message.
|
||||
$repo->write_branch // The branch name.
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
@@ -0,0 +1,179 @@
|
||||
<?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\Grep;
|
||||
use VDM\Joomla\Componentbuilder\Package\AdminView\Remote\Config;
|
||||
use VDM\Joomla\Componentbuilder\Package\Dependency\Resolver;
|
||||
use VDM\Joomla\Componentbuilder\Package\Remote\Set;
|
||||
use VDM\Joomla\Componentbuilder\Package\AdminView\Readme\Item as ItemReadme;
|
||||
use VDM\Joomla\Componentbuilder\Package\AdminView\Readme\Main as MainReadme;
|
||||
|
||||
|
||||
/**
|
||||
* Admin View Service Provider
|
||||
*
|
||||
* @since 5.2.1
|
||||
*/
|
||||
class AdminView implements ServiceProviderInterface
|
||||
{
|
||||
/**
|
||||
* Registers the service provider with a DI container.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return void
|
||||
* @since 5.2.1
|
||||
*/
|
||||
public function register(Container $container)
|
||||
{
|
||||
$container->alias(Grep::class, 'AdminView.Grep')
|
||||
->share('AdminView.Grep', [$this, 'getGrep'], true);
|
||||
|
||||
$container->alias(Config::class, 'AdminView.Remote.Config')
|
||||
->share('AdminView.Remote.Config', [$this, 'getRemoteConfig'], true);
|
||||
|
||||
$container->alias(Resolver::class, 'AdminView.Resolver')
|
||||
->share('AdminView.Resolver', [$this, 'getResolver'], true);
|
||||
|
||||
$container->alias(Get::class, 'AdminView.Remote.Get')
|
||||
->share('AdminView.Remote.Get', [$this, 'getRemoteGet'], true);
|
||||
|
||||
$container->alias(Set::class, 'AdminView.Remote.Set')
|
||||
->share('AdminView.Remote.Set', [$this, 'getRemoteSet'], true);
|
||||
|
||||
$container->alias(ItemReadme::class, 'AdminView.Readme.Item')
|
||||
->share('AdminView.Readme.Item', [$this, 'getItemReadme'], true);
|
||||
|
||||
$container->alias(MainReadme::class, 'AdminView.Readme.Main')
|
||||
->share('AdminView.Readme.Main', [$this, 'getMainReadme'], true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The Grep Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Grep
|
||||
* @since 5.2.1
|
||||
*/
|
||||
public function getGrep(Container $container): Grep
|
||||
{
|
||||
return new Grep(
|
||||
$container->get('AdminView.Remote.Config'),
|
||||
$container->get('Gitea.Repository.Contents'),
|
||||
$container->get('Network.Resolve'),
|
||||
$container->get('Config')->approved_package_paths
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The Remote Config Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Config
|
||||
* @since 5.2.1
|
||||
*/
|
||||
public function getRemoteConfig(Container $container): Config
|
||||
{
|
||||
return new Config(
|
||||
$container->get('Power.Table')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The Resolver Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Resolver
|
||||
* @since 5.2.1
|
||||
*/
|
||||
public function getResolver(Container $container): Resolver
|
||||
{
|
||||
return new Resolver(
|
||||
$container->get('AdminView.Remote.Config'),
|
||||
$container->get('Power.Tracker'),
|
||||
$container->get('Power.Table')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The Remote Get Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Get
|
||||
* @since 5.2.1
|
||||
*/
|
||||
public function getRemoteGet(Container $container): Get
|
||||
{
|
||||
return new Get(
|
||||
$container->get('AdminView.Remote.Config'),
|
||||
$container->get('AdminView.Grep'),
|
||||
$container->get('Data.Item')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The Remote Set Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Set
|
||||
* @since 5.2.1
|
||||
*/
|
||||
public function getRemoteSet(Container $container): Set
|
||||
{
|
||||
return new Set(
|
||||
$container->get('AdminView.Remote.Config'),
|
||||
$container->get('AdminView.Grep'),
|
||||
$container->get('Data.Items'),
|
||||
$container->get('AdminView.Readme.Item'),
|
||||
$container->get('AdminView.Readme.Main'),
|
||||
$container->get('Gitea.Repository.Contents'),
|
||||
$container->get('Power.Message'),
|
||||
$container->get('Config')->approved_package_paths
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The Item Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return ItemReadme
|
||||
* @since 5.2.1
|
||||
*/
|
||||
public function getItemReadme(Container $container): ItemReadme
|
||||
{
|
||||
return new ItemReadme();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The Main Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return MainReadme
|
||||
* @since 5.2.1
|
||||
*/
|
||||
public function getMainReadme(Container $container): MainReadme
|
||||
{
|
||||
return new MainReadme();
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,179 @@
|
||||
<?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\Grep;
|
||||
use VDM\Joomla\Componentbuilder\Package\Component\Remote\Config;
|
||||
use VDM\Joomla\Componentbuilder\Package\Dependency\Resolver;
|
||||
use VDM\Joomla\Componentbuilder\Package\Remote\Set;
|
||||
use VDM\Joomla\Componentbuilder\Package\Component\Readme\Item as ItemReadme;
|
||||
use VDM\Joomla\Componentbuilder\Package\Component\Readme\Main as MainReadme;
|
||||
|
||||
|
||||
/**
|
||||
* Component Service Provider
|
||||
*
|
||||
* @since 5.2.1
|
||||
*/
|
||||
class Component implements ServiceProviderInterface
|
||||
{
|
||||
/**
|
||||
* Registers the service provider with a DI container.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return void
|
||||
* @since 5.2.1
|
||||
*/
|
||||
public function register(Container $container)
|
||||
{
|
||||
$container->alias(Grep::class, 'Component.Grep')
|
||||
->share('Component.Grep', [$this, 'getGrep'], true);
|
||||
|
||||
$container->alias(Config::class, 'Component.Remote.Config')
|
||||
->share('Component.Remote.Config', [$this, 'getRemoteConfig'], true);
|
||||
|
||||
$container->alias(Resolver::class, 'Component.Resolver')
|
||||
->share('Component.Resolver', [$this, 'getResolver'], true);
|
||||
|
||||
$container->alias(Get::class, 'Component.Remote.Get')
|
||||
->share('Component.Remote.Get', [$this, 'getRemoteGet'], true);
|
||||
|
||||
$container->alias(Set::class, 'Component.Remote.Set')
|
||||
->share('Component.Remote.Set', [$this, 'getRemoteSet'], true);
|
||||
|
||||
$container->alias(ItemReadme::class, 'Component.Readme.Item')
|
||||
->share('Component.Readme.Item', [$this, 'getItemReadme'], true);
|
||||
|
||||
$container->alias(MainReadme::class, 'Component.Readme.Main')
|
||||
->share('Component.Readme.Main', [$this, 'getMainReadme'], true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The Grep Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Grep
|
||||
* @since 5.2.1
|
||||
*/
|
||||
public function getGrep(Container $container): Grep
|
||||
{
|
||||
return new Grep(
|
||||
$container->get('Component.Remote.Config'),
|
||||
$container->get('Gitea.Repository.Contents'),
|
||||
$container->get('Network.Resolve'),
|
||||
$container->get('Config')->approved_package_paths
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The Remote Config Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Config
|
||||
* @since 5.2.1
|
||||
*/
|
||||
public function getRemoteConfig(Container $container): Config
|
||||
{
|
||||
return new Config(
|
||||
$container->get('Power.Table')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The Resolver Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Resolver
|
||||
* @since 5.2.1
|
||||
*/
|
||||
public function getResolver(Container $container): Resolver
|
||||
{
|
||||
return new Resolver(
|
||||
$container->get('Component.Remote.Config'),
|
||||
$container->get('Power.Tracker'),
|
||||
$container->get('Power.Table')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The Remote Get Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Get
|
||||
* @since 5.2.1
|
||||
*/
|
||||
public function getRemoteGet(Container $container): Get
|
||||
{
|
||||
return new Get(
|
||||
$container->get('Component.Remote.Config'),
|
||||
$container->get('Component.Grep'),
|
||||
$container->get('Data.Item')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The Remote Set Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Set
|
||||
* @since 5.2.1
|
||||
*/
|
||||
public function getRemoteSet(Container $container): Set
|
||||
{
|
||||
return new Set(
|
||||
$container->get('Component.Remote.Config'),
|
||||
$container->get('Component.Grep'),
|
||||
$container->get('Data.Items'),
|
||||
$container->get('Component.Readme.Item'),
|
||||
$container->get('Component.Readme.Main'),
|
||||
$container->get('Gitea.Repository.Contents'),
|
||||
$container->get('Power.Message'),
|
||||
$container->get('Config')->approved_package_paths
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The Item Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return ItemReadme
|
||||
* @since 5.2.1
|
||||
*/
|
||||
public function getItemReadme(Container $container): ItemReadme
|
||||
{
|
||||
return new ItemReadme();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The Main Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return MainReadme
|
||||
* @since 5.2.1
|
||||
*/
|
||||
public function getMainReadme(Container $container): MainReadme
|
||||
{
|
||||
return new MainReadme();
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,180 @@
|
||||
<?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\Grep;
|
||||
use VDM\Joomla\Componentbuilder\Package\CustomAdminView\Remote\Config;
|
||||
use VDM\Joomla\Componentbuilder\Package\Dependency\Resolver;
|
||||
use VDM\Joomla\Componentbuilder\Power\Remote\Get;
|
||||
use VDM\Joomla\Componentbuilder\Package\Remote\Set;
|
||||
use VDM\Joomla\Componentbuilder\Package\CustomAdminView\Readme\Item as ItemReadme;
|
||||
use VDM\Joomla\Componentbuilder\Package\CustomAdminView\Readme\Main as MainReadme;
|
||||
|
||||
|
||||
/**
|
||||
* Custom Admin View Service Provider
|
||||
*
|
||||
* @since 5.2.1
|
||||
*/
|
||||
class CustomAdminView implements ServiceProviderInterface
|
||||
{
|
||||
/**
|
||||
* Registers the service provider with a DI container.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return void
|
||||
* @since 5.2.1
|
||||
*/
|
||||
public function register(Container $container)
|
||||
{
|
||||
$container->alias(Grep::class, 'CustomAdminView.Grep')
|
||||
->share('CustomAdminView.Grep', [$this, 'getGrep'], true);
|
||||
|
||||
$container->alias(Config::class, 'CustomAdminView.Remote.Config')
|
||||
->share('CustomAdminView.Remote.Config', [$this, 'getRemoteConfig'], true);
|
||||
|
||||
$container->alias(Resolver::class, 'CustomAdminView.Resolver')
|
||||
->share('CustomAdminView.Resolver', [$this, 'getResolver'], true);
|
||||
|
||||
$container->alias(Get::class, 'CustomAdminView.Remote.Get')
|
||||
->share('CustomAdminView.Remote.Get', [$this, 'getRemoteGet'], true);
|
||||
|
||||
$container->alias(Set::class, 'CustomAdminView.Remote.Set')
|
||||
->share('CustomAdminView.Remote.Set', [$this, 'getRemoteSet'], true);
|
||||
|
||||
$container->alias(ItemReadme::class, 'CustomAdminView.Readme.Item')
|
||||
->share('CustomAdminView.Readme.Item', [$this, 'getItemReadme'], true);
|
||||
|
||||
$container->alias(MainReadme::class, 'CustomAdminView.Readme.Main')
|
||||
->share('CustomAdminView.Readme.Main', [$this, 'getMainReadme'], true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The Grep Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Grep
|
||||
* @since 5.2.1
|
||||
*/
|
||||
public function getGrep(Container $container): Grep
|
||||
{
|
||||
return new Grep(
|
||||
$container->get('CustomAdminView.Remote.Config'),
|
||||
$container->get('Gitea.Repository.Contents'),
|
||||
$container->get('Network.Resolve'),
|
||||
$container->get('Config')->approved_package_paths
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The Remote Config Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Config
|
||||
* @since 5.2.1
|
||||
*/
|
||||
public function getRemoteConfig(Container $container): Config
|
||||
{
|
||||
return new Config(
|
||||
$container->get('Power.Table')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The Resolver Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Resolver
|
||||
* @since 5.2.1
|
||||
*/
|
||||
public function getResolver(Container $container): Resolver
|
||||
{
|
||||
return new Resolver(
|
||||
$container->get('CustomAdminView.Remote.Config'),
|
||||
$container->get('Power.Tracker'),
|
||||
$container->get('Power.Table')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The Remote Get Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Get
|
||||
* @since 5.2.1
|
||||
*/
|
||||
public function getRemoteGet(Container $container): Get
|
||||
{
|
||||
return new Get(
|
||||
$container->get('CustomAdminView.Remote.Config'),
|
||||
$container->get('CustomAdminView.Grep'),
|
||||
$container->get('Data.Item')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The Remote Set Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Set
|
||||
* @since 5.2.1
|
||||
*/
|
||||
public function getRemoteSet(Container $container): Set
|
||||
{
|
||||
return new Set(
|
||||
$container->get('CustomAdminView.Remote.Config'),
|
||||
$container->get('CustomAdminView.Grep'),
|
||||
$container->get('Data.Items'),
|
||||
$container->get('CustomAdminView.Readme.Item'),
|
||||
$container->get('CustomAdminView.Readme.Main'),
|
||||
$container->get('Gitea.Repository.Contents'),
|
||||
$container->get('Power.Message'),
|
||||
$container->get('Config')->approved_package_paths
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The Item Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return ItemReadme
|
||||
* @since 5.2.1
|
||||
*/
|
||||
public function getItemReadme(Container $container): ItemReadme
|
||||
{
|
||||
return new ItemReadme();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The Main Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return MainReadme
|
||||
* @since 5.2.1
|
||||
*/
|
||||
public function getMainReadme(Container $container): MainReadme
|
||||
{
|
||||
return new MainReadme();
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,180 @@
|
||||
<?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\Grep;
|
||||
use VDM\Joomla\Componentbuilder\Package\CustomCode\Remote\Config;
|
||||
use VDM\Joomla\Componentbuilder\Package\Dependency\Resolver;
|
||||
use VDM\Joomla\Componentbuilder\Power\Remote\Get;
|
||||
use VDM\Joomla\Componentbuilder\Package\Remote\CustomCode\Set;
|
||||
use VDM\Joomla\Componentbuilder\Package\CustomCode\Readme\Item as ItemReadme;
|
||||
use VDM\Joomla\Componentbuilder\Package\CustomCode\Readme\Main as MainReadme;
|
||||
|
||||
|
||||
/**
|
||||
* Custom Code Service Provider
|
||||
*
|
||||
* @since 5.2.1
|
||||
*/
|
||||
class CustomCode implements ServiceProviderInterface
|
||||
{
|
||||
/**
|
||||
* Registers the service provider with a DI container.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return void
|
||||
* @since 5.2.1
|
||||
*/
|
||||
public function register(Container $container)
|
||||
{
|
||||
$container->alias(Grep::class, 'CustomCode.Grep')
|
||||
->share('CustomCode.Grep', [$this, 'getGrep'], true);
|
||||
|
||||
$container->alias(Config::class, 'CustomCode.Remote.Config')
|
||||
->share('CustomCode.Remote.Config', [$this, 'getRemoteConfig'], true);
|
||||
|
||||
$container->alias(Resolver::class, 'CustomCode.Resolver')
|
||||
->share('CustomCode.Resolver', [$this, 'getResolver'], true);
|
||||
|
||||
$container->alias(Get::class, 'CustomCode.Remote.Get')
|
||||
->share('CustomCode.Remote.Get', [$this, 'getRemoteGet'], true);
|
||||
|
||||
$container->alias(Set::class, 'CustomCode.Remote.Set')
|
||||
->share('CustomCode.Remote.Set', [$this, 'getRemoteSet'], true);
|
||||
|
||||
$container->alias(ItemReadme::class, 'CustomCode.Readme.Item')
|
||||
->share('CustomCode.Readme.Item', [$this, 'getItemReadme'], true);
|
||||
|
||||
$container->alias(MainReadme::class, 'CustomCode.Readme.Main')
|
||||
->share('CustomCode.Readme.Main', [$this, 'getMainReadme'], true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The Grep Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Grep
|
||||
* @since 5.2.1
|
||||
*/
|
||||
public function getGrep(Container $container): Grep
|
||||
{
|
||||
return new Grep(
|
||||
$container->get('CustomCode.Remote.Config'),
|
||||
$container->get('Gitea.Repository.Contents'),
|
||||
$container->get('Network.Resolve'),
|
||||
$container->get('Config')->approved_package_paths
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The Remote Config Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Config
|
||||
* @since 5.2.1
|
||||
*/
|
||||
public function getRemoteConfig(Container $container): Config
|
||||
{
|
||||
return new Config(
|
||||
$container->get('Power.Table')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The Resolver Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Resolver
|
||||
* @since 5.2.1
|
||||
*/
|
||||
public function getResolver(Container $container): Resolver
|
||||
{
|
||||
return new Resolver(
|
||||
$container->get('CustomCode.Remote.Config'),
|
||||
$container->get('Power.Tracker'),
|
||||
$container->get('Power.Table')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The Remote Get Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Get
|
||||
* @since 5.2.1
|
||||
*/
|
||||
public function getRemoteGet(Container $container): Get
|
||||
{
|
||||
return new Get(
|
||||
$container->get('CustomCode.Remote.Config'),
|
||||
$container->get('CustomCode.Grep'),
|
||||
$container->get('Data.Item')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The Remote Set Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Set
|
||||
* @since 5.2.1
|
||||
*/
|
||||
public function getRemoteSet(Container $container): Set
|
||||
{
|
||||
return new Set(
|
||||
$container->get('CustomCode.Remote.Config'),
|
||||
$container->get('CustomCode.Grep'),
|
||||
$container->get('Data.Items'),
|
||||
$container->get('CustomCode.Readme.Item'),
|
||||
$container->get('CustomCode.Readme.Main'),
|
||||
$container->get('Gitea.Repository.Contents'),
|
||||
$container->get('Power.Message'),
|
||||
$container->get('Config')->approved_package_paths
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The Item Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return ItemReadme
|
||||
* @since 5.2.1
|
||||
*/
|
||||
public function getItemReadme(Container $container): ItemReadme
|
||||
{
|
||||
return new ItemReadme();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The Main Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return MainReadme
|
||||
* @since 5.2.1
|
||||
*/
|
||||
public function getMainReadme(Container $container): MainReadme
|
||||
{
|
||||
return new MainReadme();
|
||||
}
|
||||
}
|
||||
|
@@ -1,112 +0,0 @@
|
||||
<?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\Database\Load;
|
||||
use VDM\Joomla\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')
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,55 +0,0 @@
|
||||
<?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();
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,181 @@
|
||||
<?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\Grep;
|
||||
use VDM\Joomla\Componentbuilder\Package\DynamicGet\Remote\Config;
|
||||
use VDM\Joomla\Componentbuilder\Package\Dependency\Resolver;
|
||||
use VDM\Joomla\Componentbuilder\Power\Remote\Get;
|
||||
use VDM\Joomla\Componentbuilder\Package\Remote\Set;
|
||||
use VDM\Joomla\Componentbuilder\Package\DynamicGet\Readme\Item as ItemReadme;
|
||||
use VDM\Joomla\Componentbuilder\Package\DynamicGet\Readme\Main as MainReadme;
|
||||
|
||||
|
||||
/**
|
||||
* Dynamic Get Service Provider
|
||||
*
|
||||
* @since 5.2.1
|
||||
*/
|
||||
class DynamicGet implements ServiceProviderInterface
|
||||
{
|
||||
/**
|
||||
* Registers the service provider with a DI container.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return void
|
||||
* @since 5.2.1
|
||||
*/
|
||||
public function register(Container $container)
|
||||
{
|
||||
$container->alias(Grep::class, 'DynamicGet.Grep')
|
||||
->share('DynamicGet.Grep', [$this, 'getGrep'], true);
|
||||
|
||||
$container->alias(Config::class, 'DynamicGet.Remote.Config')
|
||||
->share('DynamicGet.Remote.Config', [$this, 'getRemoteConfig'], true);
|
||||
|
||||
$container->alias(Resolver::class, 'DynamicGet.Resolver')
|
||||
->share('DynamicGet.Resolver', [$this, 'getResolver'], true);
|
||||
|
||||
$container->alias(Get::class, 'DynamicGet.Remote.Get')
|
||||
->share('DynamicGet.Remote.Get', [$this, 'getRemoteGet'], true);
|
||||
|
||||
$container->alias(Set::class, 'DynamicGet.Remote.Set')
|
||||
->share('DynamicGet.Remote.Set', [$this, 'getRemoteSet'], true);
|
||||
|
||||
$container->alias(ItemReadme::class, 'DynamicGet.Readme.Item')
|
||||
->share('DynamicGet.Readme.Item', [$this, 'getItemReadme'], true);
|
||||
|
||||
$container->alias(MainReadme::class, 'DynamicGet.Readme.Main')
|
||||
->share('DynamicGet.Readme.Main', [$this, 'getMainReadme'], true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The Grep Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Grep
|
||||
* @since 5.2.1
|
||||
*/
|
||||
public function getGrep(Container $container): Grep
|
||||
{
|
||||
return new Grep(
|
||||
$container->get('DynamicGet.Remote.Config'),
|
||||
$container->get('Gitea.Repository.Contents'),
|
||||
$container->get('Network.Resolve'),
|
||||
$container->get('Config')->approved_package_paths
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The Remote Config Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Config
|
||||
* @since 5.2.1
|
||||
*/
|
||||
public function getRemoteConfig(Container $container): Config
|
||||
{
|
||||
return new Config(
|
||||
$container->get('Power.Table')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The Resolver Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Resolver
|
||||
* @since 5.2.1
|
||||
*/
|
||||
public function getResolver(Container $container): Resolver
|
||||
{
|
||||
return new Resolver(
|
||||
$container->get('DynamicGet.Remote.Config'),
|
||||
$container->get('Power.Tracker'),
|
||||
$container->get('Power.Table')
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get The Remote Get Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Get
|
||||
* @since 5.2.1
|
||||
*/
|
||||
public function getRemoteGet(Container $container): Get
|
||||
{
|
||||
return new Get(
|
||||
$container->get('DynamicGet.Remote.Config'),
|
||||
$container->get('DynamicGet.Grep'),
|
||||
$container->get('Data.Item')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The Remote Set Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Set
|
||||
* @since 5.2.1
|
||||
*/
|
||||
public function getRemoteSet(Container $container): Set
|
||||
{
|
||||
return new Set(
|
||||
$container->get('DynamicGet.Remote.Config'),
|
||||
$container->get('DynamicGet.Grep'),
|
||||
$container->get('Data.Items'),
|
||||
$container->get('DynamicGet.Readme.Item'),
|
||||
$container->get('DynamicGet.Readme.Main'),
|
||||
$container->get('Gitea.Repository.Contents'),
|
||||
$container->get('Power.Message'),
|
||||
$container->get('Config')->approved_package_paths
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The Item Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return ItemReadme
|
||||
* @since 5.2.1
|
||||
*/
|
||||
public function getItemReadme(Container $container): ItemReadme
|
||||
{
|
||||
return new ItemReadme();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The Main Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return MainReadme
|
||||
* @since 5.2.1
|
||||
*/
|
||||
public function getMainReadme(Container $container): MainReadme
|
||||
{
|
||||
return new MainReadme();
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,179 @@
|
||||
<?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\Grep;
|
||||
use VDM\Joomla\Componentbuilder\Package\Field\Remote\Config;
|
||||
use VDM\Joomla\Componentbuilder\Package\Dependency\Resolver;
|
||||
use VDM\Joomla\Componentbuilder\Package\Remote\Set;
|
||||
use VDM\Joomla\Componentbuilder\Package\Field\Readme\Item as ItemReadme;
|
||||
use VDM\Joomla\Componentbuilder\Package\Field\Readme\Main as MainReadme;
|
||||
|
||||
|
||||
/**
|
||||
* Field Service Provider
|
||||
*
|
||||
* @since 5.2.1
|
||||
*/
|
||||
class Field implements ServiceProviderInterface
|
||||
{
|
||||
/**
|
||||
* Registers the service provider with a DI container.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return void
|
||||
* @since 5.2.1
|
||||
*/
|
||||
public function register(Container $container)
|
||||
{
|
||||
$container->alias(Grep::class, 'Field.Grep')
|
||||
->share('Field.Grep', [$this, 'getGrep'], true);
|
||||
|
||||
$container->alias(Config::class, 'Field.Remote.Config')
|
||||
->share('Field.Remote.Config', [$this, 'getRemoteConfig'], true);
|
||||
|
||||
$container->alias(Resolver::class, 'Field.Resolver')
|
||||
->share('Field.Resolver', [$this, 'getResolver'], true);
|
||||
|
||||
$container->alias(Get::class, 'Field.Remote.Get')
|
||||
->share('Field.Remote.Get', [$this, 'getRemoteGet'], true);
|
||||
|
||||
$container->alias(Set::class, 'Field.Remote.Set')
|
||||
->share('Field.Remote.Set', [$this, 'getRemoteSet'], true);
|
||||
|
||||
$container->alias(ItemReadme::class, 'Field.Readme.Item')
|
||||
->share('Field.Readme.Item', [$this, 'getItemReadme'], true);
|
||||
|
||||
$container->alias(MainReadme::class, 'Field.Readme.Main')
|
||||
->share('Field.Readme.Main', [$this, 'getMainReadme'], true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The Grep Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Grep
|
||||
* @since 5.2.1
|
||||
*/
|
||||
public function getGrep(Container $container): Grep
|
||||
{
|
||||
return new Grep(
|
||||
$container->get('Field.Remote.Config'),
|
||||
$container->get('Gitea.Repository.Contents'),
|
||||
$container->get('Network.Resolve'),
|
||||
$container->get('Config')->approved_package_paths
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The Remote Config Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Config
|
||||
* @since 5.2.1
|
||||
*/
|
||||
public function getRemoteConfig(Container $container): Config
|
||||
{
|
||||
return new Config(
|
||||
$container->get('Power.Table')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The Resolver Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Resolver
|
||||
* @since 5.2.1
|
||||
*/
|
||||
public function getResolver(Container $container): Resolver
|
||||
{
|
||||
return new Resolver(
|
||||
$container->get('Field.Remote.Config'),
|
||||
$container->get('Power.Tracker'),
|
||||
$container->get('Power.Table')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The Remote Get Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Get
|
||||
* @since 5.2.1
|
||||
*/
|
||||
public function getRemoteGet(Container $container): Get
|
||||
{
|
||||
return new Get(
|
||||
$container->get('Field.Remote.Config'),
|
||||
$container->get('Field.Grep'),
|
||||
$container->get('Data.Item')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The Remote Set Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Set
|
||||
* @since 5.2.1
|
||||
*/
|
||||
public function getRemoteSet(Container $container): Set
|
||||
{
|
||||
return new Set(
|
||||
$container->get('Field.Remote.Config'),
|
||||
$container->get('Field.Grep'),
|
||||
$container->get('Data.Items'),
|
||||
$container->get('Field.Readme.Item'),
|
||||
$container->get('Field.Readme.Main'),
|
||||
$container->get('Gitea.Repository.Contents'),
|
||||
$container->get('Power.Message'),
|
||||
$container->get('Config')->approved_package_paths
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The Item Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return ItemReadme
|
||||
* @since 5.2.1
|
||||
*/
|
||||
public function getItemReadme(Container $container): ItemReadme
|
||||
{
|
||||
return new ItemReadme();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The Main Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return MainReadme
|
||||
* @since 5.2.1
|
||||
*/
|
||||
public function getMainReadme(Container $container): MainReadme
|
||||
{
|
||||
return new MainReadme();
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,180 @@
|
||||
<?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\Grep;
|
||||
use VDM\Joomla\Componentbuilder\Package\Layout\Remote\Config;
|
||||
use VDM\Joomla\Componentbuilder\Package\Dependency\Resolver;
|
||||
use VDM\Joomla\Componentbuilder\Power\Remote\Get;
|
||||
use VDM\Joomla\Componentbuilder\Package\Remote\Set;
|
||||
use VDM\Joomla\Componentbuilder\Package\Layout\Readme\Item as ItemReadme;
|
||||
use VDM\Joomla\Componentbuilder\Package\Layout\Readme\Main as MainReadme;
|
||||
|
||||
|
||||
/**
|
||||
* Layout Service Provider
|
||||
*
|
||||
* @since 5.2.1
|
||||
*/
|
||||
class Layout implements ServiceProviderInterface
|
||||
{
|
||||
/**
|
||||
* Registers the service provider with a DI container.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return void
|
||||
* @since 5.2.1
|
||||
*/
|
||||
public function register(Container $container)
|
||||
{
|
||||
$container->alias(Grep::class, 'Layout.Grep')
|
||||
->share('Layout.Grep', [$this, 'getGrep'], true);
|
||||
|
||||
$container->alias(Config::class, 'Layout.Remote.Config')
|
||||
->share('Layout.Remote.Config', [$this, 'getRemoteConfig'], true);
|
||||
|
||||
$container->alias(Resolver::class, 'Layout.Resolver')
|
||||
->share('Layout.Resolver', [$this, 'getResolver'], true);
|
||||
|
||||
$container->alias(Get::class, 'Layout.Remote.Get')
|
||||
->share('Layout.Remote.Get', [$this, 'getRemoteGet'], true);
|
||||
|
||||
$container->alias(Set::class, 'Layout.Remote.Set')
|
||||
->share('Layout.Remote.Set', [$this, 'getRemoteSet'], true);
|
||||
|
||||
$container->alias(ItemReadme::class, 'Layout.Readme.Item')
|
||||
->share('Layout.Readme.Item', [$this, 'getItemReadme'], true);
|
||||
|
||||
$container->alias(MainReadme::class, 'Layout.Readme.Main')
|
||||
->share('Layout.Readme.Main', [$this, 'getMainReadme'], true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The Grep Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Grep
|
||||
* @since 5.2.1
|
||||
*/
|
||||
public function getGrep(Container $container): Grep
|
||||
{
|
||||
return new Grep(
|
||||
$container->get('Layout.Remote.Config'),
|
||||
$container->get('Gitea.Repository.Contents'),
|
||||
$container->get('Network.Resolve'),
|
||||
$container->get('Config')->approved_package_paths
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The Remote Config Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Config
|
||||
* @since 5.2.1
|
||||
*/
|
||||
public function getRemoteConfig(Container $container): Config
|
||||
{
|
||||
return new Config(
|
||||
$container->get('Power.Table')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The Resolver Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Resolver
|
||||
* @since 5.2.1
|
||||
*/
|
||||
public function getResolver(Container $container): Resolver
|
||||
{
|
||||
return new Resolver(
|
||||
$container->get('Layout.Remote.Config'),
|
||||
$container->get('Power.Tracker'),
|
||||
$container->get('Power.Table')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The Remote Get Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Get
|
||||
* @since 5.2.1
|
||||
*/
|
||||
public function getRemoteGet(Container $container): Get
|
||||
{
|
||||
return new Get(
|
||||
$container->get('Layout.Remote.Config'),
|
||||
$container->get('Layout.Grep'),
|
||||
$container->get('Data.Item')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The Remote Set Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Set
|
||||
* @since 5.2.1
|
||||
*/
|
||||
public function getRemoteSet(Container $container): Set
|
||||
{
|
||||
return new Set(
|
||||
$container->get('Layout.Remote.Config'),
|
||||
$container->get('Layout.Grep'),
|
||||
$container->get('Data.Items'),
|
||||
$container->get('Layout.Readme.Item'),
|
||||
$container->get('Layout.Readme.Main'),
|
||||
$container->get('Gitea.Repository.Contents'),
|
||||
$container->get('Power.Message'),
|
||||
$container->get('Config')->approved_package_paths
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The Item Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return ItemReadme
|
||||
* @since 5.2.1
|
||||
*/
|
||||
public function getItemReadme(Container $container): ItemReadme
|
||||
{
|
||||
return new ItemReadme();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The Main Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return MainReadme
|
||||
* @since 5.2.1
|
||||
*/
|
||||
public function getMainReadme(Container $container): MainReadme
|
||||
{
|
||||
return new MainReadme();
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,180 @@
|
||||
<?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\Grep;
|
||||
use VDM\Joomla\Componentbuilder\Package\Library\Remote\Config;
|
||||
use VDM\Joomla\Componentbuilder\Package\Dependency\Resolver;
|
||||
use VDM\Joomla\Componentbuilder\Power\Remote\Get;
|
||||
use VDM\Joomla\Componentbuilder\Package\Remote\Set;
|
||||
use VDM\Joomla\Componentbuilder\Package\Library\Readme\Item as ItemReadme;
|
||||
use VDM\Joomla\Componentbuilder\Package\Library\Readme\Main as MainReadme;
|
||||
|
||||
|
||||
/**
|
||||
* Library Service Provider
|
||||
*
|
||||
* @since 5.2.1
|
||||
*/
|
||||
class Library implements ServiceProviderInterface
|
||||
{
|
||||
/**
|
||||
* Registers the service provider with a DI container.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return void
|
||||
* @since 5.2.1
|
||||
*/
|
||||
public function register(Container $container)
|
||||
{
|
||||
$container->alias(Grep::class, 'Library.Grep')
|
||||
->share('Library.Grep', [$this, 'getGrep'], true);
|
||||
|
||||
$container->alias(Config::class, 'Library.Remote.Config')
|
||||
->share('Library.Remote.Config', [$this, 'getRemoteConfig'], true);
|
||||
|
||||
$container->alias(Resolver::class, 'Library.Resolver')
|
||||
->share('Library.Resolver', [$this, 'getResolver'], true);
|
||||
|
||||
$container->alias(Get::class, 'Library.Remote.Get')
|
||||
->share('Library.Remote.Get', [$this, 'getRemoteGet'], true);
|
||||
|
||||
$container->alias(Set::class, 'Library.Remote.Set')
|
||||
->share('Library.Remote.Set', [$this, 'getRemoteSet'], true);
|
||||
|
||||
$container->alias(ItemReadme::class, 'Library.Readme.Item')
|
||||
->share('Library.Readme.Item', [$this, 'getItemReadme'], true);
|
||||
|
||||
$container->alias(MainReadme::class, 'Library.Readme.Main')
|
||||
->share('Library.Readme.Main', [$this, 'getMainReadme'], true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The Grep Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Grep
|
||||
* @since 5.2.1
|
||||
*/
|
||||
public function getGrep(Container $container): Grep
|
||||
{
|
||||
return new Grep(
|
||||
$container->get('Library.Remote.Config'),
|
||||
$container->get('Gitea.Repository.Contents'),
|
||||
$container->get('Network.Resolve'),
|
||||
$container->get('Config')->approved_package_paths
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The Remote Config Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Config
|
||||
* @since 5.2.1
|
||||
*/
|
||||
public function getRemoteConfig(Container $container): Config
|
||||
{
|
||||
return new Config(
|
||||
$container->get('Power.Table')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The Resolver Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Resolver
|
||||
* @since 5.2.1
|
||||
*/
|
||||
public function getResolver(Container $container): Resolver
|
||||
{
|
||||
return new Resolver(
|
||||
$container->get('Library.Remote.Config'),
|
||||
$container->get('Power.Tracker'),
|
||||
$container->get('Power.Table')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The Remote Get Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Get
|
||||
* @since 5.2.1
|
||||
*/
|
||||
public function getRemoteGet(Container $container): Get
|
||||
{
|
||||
return new Get(
|
||||
$container->get('Library.Remote.Config'),
|
||||
$container->get('Library.Grep'),
|
||||
$container->get('Data.Item')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The Remote Set Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Set
|
||||
* @since 5.2.1
|
||||
*/
|
||||
public function getRemoteSet(Container $container): Set
|
||||
{
|
||||
return new Set(
|
||||
$container->get('Library.Remote.Config'),
|
||||
$container->get('Library.Grep'),
|
||||
$container->get('Data.Items'),
|
||||
$container->get('Library.Readme.Item'),
|
||||
$container->get('Library.Readme.Main'),
|
||||
$container->get('Gitea.Repository.Contents'),
|
||||
$container->get('Power.Message'),
|
||||
$container->get('Config')->approved_package_paths
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The Item Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return ItemReadme
|
||||
* @since 5.2.1
|
||||
*/
|
||||
public function getItemReadme(Container $container): ItemReadme
|
||||
{
|
||||
return new ItemReadme();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The Main Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return MainReadme
|
||||
* @since 5.2.1
|
||||
*/
|
||||
public function getMainReadme(Container $container): MainReadme
|
||||
{
|
||||
return new MainReadme();
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,105 @@
|
||||
<?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\Power\Table;
|
||||
use VDM\Joomla\Componentbuilder\Package\Config;
|
||||
use VDM\Joomla\Componentbuilder\Package\Dependency\Tracker;
|
||||
use VDM\Joomla\Componentbuilder\Package\MessageBus;
|
||||
|
||||
|
||||
/**
|
||||
* Package Service Provider
|
||||
*
|
||||
* @since 5.2.1
|
||||
*/
|
||||
class Package implements ServiceProviderInterface
|
||||
{
|
||||
/**
|
||||
* Registers the service provider with a DI container.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return void
|
||||
* @since 5.2.1
|
||||
*/
|
||||
public function register(Container $container)
|
||||
{
|
||||
$container->alias(Table::class, 'Power.Table')->alias('Table', 'Power.Table')
|
||||
->share('Power.Table', [$this, 'getPowerTable'], true);
|
||||
|
||||
$container->alias(Config::class, 'Config')
|
||||
->share('Config', [$this, 'getConfig'], true);
|
||||
|
||||
$container->alias(Tracker::class, 'Power.Tracker')
|
||||
->share('Power.Tracker', [$this, 'getPowerTracker'], true);
|
||||
|
||||
$container->alias(MessageBus::class, 'Power.Message')
|
||||
->share('Power.Message', [$this, 'getMessageBus'], true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The Power Table Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Table
|
||||
* @since 5.2.1
|
||||
*/
|
||||
public function getPowerTable(Container $container): Table
|
||||
{
|
||||
return new Table();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The Config Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Config
|
||||
* @since 5.2.1
|
||||
*/
|
||||
public function getConfig(Container $container): Config
|
||||
{
|
||||
return new Config();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The Tracker Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Tracker
|
||||
* @since 5.2.1
|
||||
*/
|
||||
public function getPowerTracker(Container $container): Tracker
|
||||
{
|
||||
return new Tracker();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The Message Bus Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return MessageBus
|
||||
* @since 5.2.1
|
||||
*/
|
||||
public function getMessageBus(Container $container): MessageBus
|
||||
{
|
||||
return new MessageBus();
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,180 @@
|
||||
<?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\Grep;
|
||||
use VDM\Joomla\Componentbuilder\Package\SiteView\Remote\Config;
|
||||
use VDM\Joomla\Componentbuilder\Package\Dependency\Resolver;
|
||||
use VDM\Joomla\Componentbuilder\Power\Remote\Get;
|
||||
use VDM\Joomla\Componentbuilder\Package\Remote\Set;
|
||||
use VDM\Joomla\Componentbuilder\Package\SiteView\Readme\Item as ItemReadme;
|
||||
use VDM\Joomla\Componentbuilder\Package\SiteView\Readme\Main as MainReadme;
|
||||
|
||||
|
||||
/**
|
||||
* Site View Service Provider
|
||||
*
|
||||
* @since 5.2.1
|
||||
*/
|
||||
class SiteView implements ServiceProviderInterface
|
||||
{
|
||||
/**
|
||||
* Registers the service provider with a DI container.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return void
|
||||
* @since 5.2.1
|
||||
*/
|
||||
public function register(Container $container)
|
||||
{
|
||||
$container->alias(Grep::class, 'SiteView.Grep')
|
||||
->share('SiteView.Grep', [$this, 'getGrep'], true);
|
||||
|
||||
$container->alias(Config::class, 'SiteView.Remote.Config')
|
||||
->share('SiteView.Remote.Config', [$this, 'getRemoteConfig'], true);
|
||||
|
||||
$container->alias(Resolver::class, 'SiteView.Resolver')
|
||||
->share('SiteView.Resolver', [$this, 'getResolver'], true);
|
||||
|
||||
$container->alias(Get::class, 'SiteView.Remote.Get')
|
||||
->share('SiteView.Remote.Get', [$this, 'getRemoteGet'], true);
|
||||
|
||||
$container->alias(Set::class, 'SiteView.Remote.Set')
|
||||
->share('SiteView.Remote.Set', [$this, 'getRemoteSet'], true);
|
||||
|
||||
$container->alias(ItemReadme::class, 'SiteView.Readme.Item')
|
||||
->share('SiteView.Readme.Item', [$this, 'getItemReadme'], true);
|
||||
|
||||
$container->alias(MainReadme::class, 'SiteView.Readme.Main')
|
||||
->share('SiteView.Readme.Main', [$this, 'getMainReadme'], true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The Grep Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Grep
|
||||
* @since 5.2.1
|
||||
*/
|
||||
public function getGrep(Container $container): Grep
|
||||
{
|
||||
return new Grep(
|
||||
$container->get('SiteView.Remote.Config'),
|
||||
$container->get('Gitea.Repository.Contents'),
|
||||
$container->get('Network.Resolve'),
|
||||
$container->get('Config')->approved_package_paths
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The Remote Config Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Config
|
||||
* @since 5.2.1
|
||||
*/
|
||||
public function getRemoteConfig(Container $container): Config
|
||||
{
|
||||
return new Config(
|
||||
$container->get('Power.Table')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The Resolver Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Resolver
|
||||
* @since 5.2.1
|
||||
*/
|
||||
public function getResolver(Container $container): Resolver
|
||||
{
|
||||
return new Resolver(
|
||||
$container->get('SiteView.Remote.Config'),
|
||||
$container->get('Power.Tracker'),
|
||||
$container->get('Power.Table')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The Remote Get Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Get
|
||||
* @since 5.2.1
|
||||
*/
|
||||
public function getRemoteGet(Container $container): Get
|
||||
{
|
||||
return new Get(
|
||||
$container->get('SiteView.Remote.Config'),
|
||||
$container->get('SiteView.Grep'),
|
||||
$container->get('Data.Item')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The Remote Set Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Set
|
||||
* @since 5.2.1
|
||||
*/
|
||||
public function getRemoteSet(Container $container): Set
|
||||
{
|
||||
return new Set(
|
||||
$container->get('SiteView.Remote.Config'),
|
||||
$container->get('SiteView.Grep'),
|
||||
$container->get('Data.Items'),
|
||||
$container->get('SiteView.Readme.Item'),
|
||||
$container->get('SiteView.Readme.Main'),
|
||||
$container->get('Gitea.Repository.Contents'),
|
||||
$container->get('Power.Message'),
|
||||
$container->get('Config')->approved_package_paths
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The Item Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return ItemReadme
|
||||
* @since 5.2.1
|
||||
*/
|
||||
public function getItemReadme(Container $container): ItemReadme
|
||||
{
|
||||
return new ItemReadme();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The Main Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return MainReadme
|
||||
* @since 5.2.1
|
||||
*/
|
||||
public function getMainReadme(Container $container): MainReadme
|
||||
{
|
||||
return new MainReadme();
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,180 @@
|
||||
<?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\Grep;
|
||||
use VDM\Joomla\Componentbuilder\Package\Template\Remote\Config;
|
||||
use VDM\Joomla\Componentbuilder\Package\Dependency\Resolver;
|
||||
use VDM\Joomla\Componentbuilder\Power\Remote\Get;
|
||||
use VDM\Joomla\Componentbuilder\Package\Remote\Set;
|
||||
use VDM\Joomla\Componentbuilder\Package\Template\Readme\Item as ItemReadme;
|
||||
use VDM\Joomla\Componentbuilder\Package\Template\Readme\Main as MainReadme;
|
||||
|
||||
|
||||
/**
|
||||
* Template Service Provider
|
||||
*
|
||||
* @since 5.2.1
|
||||
*/
|
||||
class Template implements ServiceProviderInterface
|
||||
{
|
||||
/**
|
||||
* Registers the service provider with a DI container.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return void
|
||||
* @since 5.2.1
|
||||
*/
|
||||
public function register(Container $container)
|
||||
{
|
||||
$container->alias(Grep::class, 'Template.Grep')
|
||||
->share('Template.Grep', [$this, 'getGrep'], true);
|
||||
|
||||
$container->alias(Config::class, 'Template.Remote.Config')
|
||||
->share('Template.Remote.Config', [$this, 'getRemoteConfig'], true);
|
||||
|
||||
$container->alias(Resolver::class, 'Template.Resolver')
|
||||
->share('Template.Resolver', [$this, 'getResolver'], true);
|
||||
|
||||
$container->alias(Get::class, 'Template.Remote.Get')
|
||||
->share('Template.Remote.Get', [$this, 'getRemoteGet'], true);
|
||||
|
||||
$container->alias(Set::class, 'Template.Remote.Set')
|
||||
->share('Template.Remote.Set', [$this, 'getRemoteSet'], true);
|
||||
|
||||
$container->alias(ItemReadme::class, 'Template.Readme.Item')
|
||||
->share('Template.Readme.Item', [$this, 'getItemReadme'], true);
|
||||
|
||||
$container->alias(MainReadme::class, 'Template.Readme.Main')
|
||||
->share('Template.Readme.Main', [$this, 'getMainReadme'], true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The Remote Config Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Config
|
||||
* @since 5.2.1
|
||||
*/
|
||||
public function getRemoteConfig(Container $container): Config
|
||||
{
|
||||
return new Config(
|
||||
$container->get('Power.Table')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The Resolver Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Resolver
|
||||
* @since 5.2.1
|
||||
*/
|
||||
public function getResolver(Container $container): Resolver
|
||||
{
|
||||
return new Resolver(
|
||||
$container->get('Template.Remote.Config'),
|
||||
$container->get('Power.Tracker'),
|
||||
$container->get('Power.Table')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The Grep Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Grep
|
||||
* @since 5.2.1
|
||||
*/
|
||||
public function getGrep(Container $container): Grep
|
||||
{
|
||||
return new Grep(
|
||||
$container->get('Template.Remote.Config'),
|
||||
$container->get('Gitea.Repository.Contents'),
|
||||
$container->get('Network.Resolve'),
|
||||
$container->get('Config')->approved_package_paths
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The Remote Get Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Get
|
||||
* @since 5.2.1
|
||||
*/
|
||||
public function getRemoteGet(Container $container): Get
|
||||
{
|
||||
return new Get(
|
||||
$container->get('Template.Remote.Config'),
|
||||
$container->get('Template.Grep'),
|
||||
$container->get('Data.Item')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The Remote Set Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Set
|
||||
* @since 5.2.1
|
||||
*/
|
||||
public function getRemoteSet(Container $container): Set
|
||||
{
|
||||
return new Set(
|
||||
$container->get('Template.Remote.Config'),
|
||||
$container->get('Template.Grep'),
|
||||
$container->get('Data.Items'),
|
||||
$container->get('Template.Readme.Item'),
|
||||
$container->get('Template.Readme.Main'),
|
||||
$container->get('Gitea.Repository.Contents'),
|
||||
$container->get('Power.Message'),
|
||||
$container->get('Config')->approved_package_paths
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The Item Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return ItemReadme
|
||||
* @since 5.2.1
|
||||
*/
|
||||
public function getItemReadme(Container $container): ItemReadme
|
||||
{
|
||||
return new ItemReadme();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The Main Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return MainReadme
|
||||
* @since 5.2.1
|
||||
*/
|
||||
public function getMainReadme(Container $container): MainReadme
|
||||
{
|
||||
return new MainReadme();
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,76 @@
|
||||
<?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\SiteView\Readme;
|
||||
|
||||
|
||||
use VDM\Joomla\Interfaces\Readme\ItemInterface;
|
||||
|
||||
|
||||
/**
|
||||
* Compiler Site View Item Readme
|
||||
*
|
||||
* @since 5.1.1
|
||||
*/
|
||||
final class Item implements ItemInterface
|
||||
{
|
||||
/**
|
||||
* Get an item readme
|
||||
*
|
||||
* @param object $item An item details.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.2
|
||||
*/
|
||||
public function get(object $item): string
|
||||
{
|
||||
// build readme
|
||||
$readme = ["```
|
||||
██╗ ██████╗ ██████╗ ███╗ ███╗██╗ █████╗
|
||||
██║██╔═══██╗██╔═══██╗████╗ ████║██║ ██╔══██╗
|
||||
██║██║ ██║██║ ██║██╔████╔██║██║ ███████║
|
||||
██ ██║██║ ██║██║ ██║██║╚██╔╝██║██║ ██╔══██║
|
||||
╚█████╔╝╚██████╔╝╚██████╔╝██║ ╚═╝ ██║███████╗██║ ██║
|
||||
╚════╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
|
||||
|
||||
███████╗██╗████████╗███████╗ ██╗ ██╗██╗███████╗██╗ ██╗
|
||||
██╔════╝██║╚══██╔══╝██╔════╝ ██║ ██║██║██╔════╝██║ ██║
|
||||
███████╗██║ ██║ █████╗ ██║ ██║██║█████╗ ██║ █╗ ██║
|
||||
╚════██║██║ ██║ ██╔══╝ ╚██╗ ██╔╝██║██╔══╝ ██║███╗██║
|
||||
███████║██║ ██║ ███████╗ ╚████╔╝ ██║███████╗╚███╔███╔╝
|
||||
╚══════╝╚═╝ ╚═╝ ╚══════╝ ╚═══╝ ╚═╝╚══════╝ ╚══╝╚══╝
|
||||
```"];
|
||||
// system name
|
||||
$readme[] = "# " . $item->name;
|
||||
|
||||
if (!empty($item->description))
|
||||
{
|
||||
$readme[] = "\n" . $item->description;
|
||||
}
|
||||
|
||||
$readme[] = "\nThe Joomla! Site View contained in this repository equips your component with a bespoke front‑end interface—complete with its own markup, Templates, Layouts, Dynamic Gets, and custom CSS/HTML/PHP—ready to plug straight into Joomla Component Builder (JCB). Each view is pre‑wired for the JCB pipeline, so data retrieval, rendering, and interaction flow smoothly on the public site without extra scaffolding. By using the \"reset\" button, you can instantly synchronize this Site View with the authoritative version hosted in our core repository, ensuring your Sites always benefit from the latest UI refinements, performance optimizations, and security enhancements.\n\n Want to go bespoke? Fork the repo, tailor the view, and point JCB to your branch. Whether you’re layering in complex filters, interactive charts, or head‑turning animations, you stay in charge while still enjoying JCB’s effortless deployment workflow.\n
|
||||
\n
|
||||
\"This flexible approach embraces JCB’s open-source model, giving you the freedom to adapt your components to your exact needs while staying connected to a powerful and community-driven ecosystem.\"\n";
|
||||
|
||||
// yes you can remove this, but why?
|
||||
$readme[] = "\n---\n```
|
||||
██╗ ██████╗██████╗
|
||||
██║██╔════╝██╔══██╗
|
||||
██║██║ ██████╔╝
|
||||
██ ██║██║ ██╔══██╗
|
||||
╚█████╔╝╚██████╗██████╔╝
|
||||
╚════╝ ╚═════╝╚═════╝
|
||||
```\n> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder)\n\n";
|
||||
|
||||
return implode("\n", $readme);
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,234 @@
|
||||
<?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\SiteView\Readme;
|
||||
|
||||
|
||||
use VDM\Joomla\Interfaces\Readme\MainInterface;
|
||||
|
||||
|
||||
/**
|
||||
* Site View Main Readme
|
||||
*
|
||||
* @since 5.1.1
|
||||
*/
|
||||
final class Main implements MainInterface
|
||||
{
|
||||
/**
|
||||
* Get Main Readme
|
||||
*
|
||||
* @param array $items All items of this repository.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function get(array $items): string
|
||||
{
|
||||
// build readme
|
||||
$readme = ["```
|
||||
██╗ ██████╗ ██████╗ ███╗ ███╗██╗ █████╗
|
||||
██║██╔═══██╗██╔═══██╗████╗ ████║██║ ██╔══██╗
|
||||
██║██║ ██║██║ ██║██╔████╔██║██║ ███████║
|
||||
██ ██║██║ ██║██║ ██║██║╚██╔╝██║██║ ██╔══██║
|
||||
╚█████╔╝╚██████╔╝╚██████╔╝██║ ╚═╝ ██║███████╗██║ ██║
|
||||
╚════╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
|
||||
|
||||
███████╗██╗████████╗███████╗ ██╗ ██╗██╗███████╗██╗ ██╗███████╗
|
||||
██╔════╝██║╚══██╔══╝██╔════╝ ██║ ██║██║██╔════╝██║ ██║██╔════╝
|
||||
███████╗██║ ██║ █████╗ ██║ ██║██║█████╗ ██║ █╗ ██║███████╗
|
||||
╚════██║██║ ██║ ██╔══╝ ╚██╗ ██╔╝██║██╔══╝ ██║███╗██║╚════██║
|
||||
███████║██║ ██║ ███████╗ ╚████╔╝ ██║███████╗╚███╔███╔╝███████║
|
||||
╚══════╝╚═╝ ╚═╝ ╚══════╝ ╚═══╝ ╚═╝╚══════╝ ╚══╝╚══╝ ╚══════╝
|
||||
```"];
|
||||
|
||||
// default description of site views
|
||||
$readme[] = "\n### What are Joomla Site Views?\nJoomla Site Views let you craft immersive front‑end experiences in Joomla Component Builder (JCB). Acting as the public‑facing views, each Site View blends Templates, Layouts, Dynamic Gets, and bespoke CSS/HTML/PHP, giving you pixel‑perfect control over how data is fetched, rendered, and interacted with on the website.\n
|
||||
\n
|
||||
Whenever you need to update Site Views in any JCB project, simply select the desired Site View and click the \"reset\" button. This action will automatically synchronize the Site Views with its corresponding version hosted in our core repository, ensuring you always have the latest updates.\n
|
||||
\n
|
||||
If your project calls for a unique look—extra filters, head‑turning animations, or component‑specific logic—fork the repository and point your JCB instance to your fork. This lets you maintain and evolve Site Views independently of the main JCB community while preserving the convenience of JCB’s one‑click update mechanism.\n
|
||||
\n
|
||||
\"We believe this approach empowers you to extend and customize JCB to fit your unique requirements, exemplifying the true spirit of freedom in software development. We trust you will find this capability both useful and aligned with the expectations of how open-source software should function.\"\n";
|
||||
|
||||
// get the readme body
|
||||
$readme[] = $this->readmeBuilder($items);
|
||||
|
||||
// yes you can remove this, but why?
|
||||
$readme[] = "\n---\n```
|
||||
██╗ ██████╗ ██████╗ ███╗ ███╗██╗ █████╗
|
||||
██║██╔═══██╗██╔═══██╗████╗ ████║██║ ██╔══██╗
|
||||
██║██║ ██║██║ ██║██╔████╔██║██║ ███████║
|
||||
██ ██║██║ ██║██║ ██║██║╚██╔╝██║██║ ██╔══██║
|
||||
╚█████╔╝╚██████╔╝╚██████╔╝██║ ╚═╝ ██║███████╗██║ ██║
|
||||
╚════╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
|
||||
██████╗ ██████╗ ███╗ ███╗██████╗ ██████╗ ███╗ ██╗███████╗███╗ ██╗████████╗
|
||||
██╔════╝██╔═══██╗████╗ ████║██╔══██╗██╔═══██╗████╗ ██║██╔════╝████╗ ██║╚══██╔══╝
|
||||
██║ ██║ ██║██╔████╔██║██████╔╝██║ ██║██╔██╗ ██║█████╗ ██╔██╗ ██║ ██║
|
||||
██║ ██║ ██║██║╚██╔╝██║██╔═══╝ ██║ ██║██║╚██╗██║██╔══╝ ██║╚██╗██║ ██║
|
||||
╚██████╗╚██████╔╝██║ ╚═╝ ██║██║ ╚██████╔╝██║ ╚████║███████╗██║ ╚████║ ██║
|
||||
╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═════╝ ╚═╝ ╚═══╝╚══════╝╚═╝ ╚═══╝ ╚═╝
|
||||
██████╗ ██╗ ██╗██╗██╗ ██████╗ ███████╗██████╗
|
||||
██╔══██╗██║ ██║██║██║ ██╔══██╗██╔════╝██╔══██╗
|
||||
██████╔╝██║ ██║██║██║ ██║ ██║█████╗ ██████╔╝
|
||||
██╔══██╗██║ ██║██║██║ ██║ ██║██╔══╝ ██╔══██╗
|
||||
██████╔╝╚██████╔╝██║███████╗██████╔╝███████╗██║ ██║
|
||||
╚═════╝ ╚═════╝ ╚═╝╚══════╝╚═════╝ ╚══════╝╚═╝ ╚═╝
|
||||
```\n> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder)\n\n";
|
||||
|
||||
return implode("\n", $readme);
|
||||
}
|
||||
|
||||
/**
|
||||
* The readme builder
|
||||
*
|
||||
* @param array $classes The powers.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
*/
|
||||
private function readmeBuilder(array &$items): string
|
||||
{
|
||||
$classes = [];
|
||||
foreach ($items as $guid => $power)
|
||||
{
|
||||
// add to the sort bucket
|
||||
$classes[] = [
|
||||
'name' => $power['name'],
|
||||
'link' => $this->indexLinkPower($power)
|
||||
];
|
||||
}
|
||||
|
||||
return $this->readmeModel($classes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sort and model the readme classes
|
||||
*
|
||||
* @param array $classes The powers.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
*/
|
||||
private function readmeModel(array &$classes): string
|
||||
{
|
||||
$this->sortClasses($classes);
|
||||
|
||||
return $this->generateIndex($classes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate the index string for classes
|
||||
*
|
||||
* @param array $classes The sorted classes
|
||||
*
|
||||
* @return string The index string
|
||||
*/
|
||||
private function generateIndex(array &$classes): string
|
||||
{
|
||||
$result = "# Index of Joomla! Field Types\n";
|
||||
|
||||
foreach ($classes as $class)
|
||||
{
|
||||
// Add the class details
|
||||
$result .= "\n - " . $class['link'];
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sort the flattened array using a single sorting function
|
||||
*
|
||||
* @param array $classes The classes to sort
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
private function sortClasses(array &$classes): void
|
||||
{
|
||||
usort($classes, function ($a, $b) {
|
||||
return $this->compareName($a, $b);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Compare the name of two classes
|
||||
*
|
||||
* @param array $a First class
|
||||
* @param array $b Second class
|
||||
*
|
||||
* @return int Comparison result
|
||||
* @since 3.2.0
|
||||
*/
|
||||
private function compareName(array $a, array $b): int
|
||||
{
|
||||
return strcmp($a['name'], $b['name']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the Link to the power in this repository
|
||||
*
|
||||
* @param array $power The power details.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
*/
|
||||
private function indexLinkPower(array &$power): string
|
||||
{
|
||||
$name = $power['name'] ?? 'error';
|
||||
return '**' . $name . "** | "
|
||||
. $this->linkPowerRepo($power) . ' | '
|
||||
. $this->linkPowerSettings($power) . ' | '
|
||||
. $this->linkPowerDesc($power);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the Link to the power in this repository
|
||||
*
|
||||
* @param array $power The power details.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
*/
|
||||
private function linkPowerRepo(array &$power): string
|
||||
{
|
||||
$path = $power['path'] ?? 'error';
|
||||
return '[Details](' . $path . ')';
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the Link to the power settings in this repository
|
||||
*
|
||||
* @param array $power The power details.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
*/
|
||||
private function linkPowerSettings(array &$power): string
|
||||
{
|
||||
$settings = $power['settings'] ?? 'error';
|
||||
return '[Settings](' . $settings . ')';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the short description
|
||||
*
|
||||
* @param array $power The power details.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
*/
|
||||
private function linkPowerDesc(array &$power): string
|
||||
{
|
||||
$jpk = $power['desc'] ?? '';
|
||||
return $jpk;
|
||||
}
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user