Release of v5.0.3-alpha3

Fix usergrouplist compiler triggers. #1100. Add field type power integration [init, reset, push].
This commit is contained in:
2024-08-23 20:00:42 +02:00
parent 045e6df2e2
commit fc8fabe298
43 changed files with 1674 additions and 135 deletions

View File

@ -1116,7 +1116,7 @@ final class Builders
break;
}
// just a heads-up for usergroups set to multiple
if ($typeName === 'usergroup')
if ($typeName === 'usergroup' || $typeName === 'usergrouplist')
{
$this->sitefielddata->set(
$nameSingleCode, $name, 'json', $typeName

View File

@ -138,7 +138,7 @@ final class ConfigFieldsetsGroupControl
{
$this->configfieldsets->add('component', Indent::_(2) . '<field name="'
. $selector . '"');
$this->configfieldsets->add('component', Indent::_(3) . 'type="usergroup"');
$this->configfieldsets->add('component', Indent::_(3) . 'type="usergrouplist"');
$this->configfieldsets->add('component', Indent::_(3) . 'label="' . $label . '"');
$this->configfieldsets->add('component', Indent::_(3) . 'description="'
. $lang . '_TARGET_GROUP_DESC"');

View File

@ -36,13 +36,13 @@ final class Groups
'color', 'combo', 'componentlayout', 'contentlanguage', 'contenttype', 'databaseconnection', 'components',
'editor', 'editors', 'email', 'file', 'file', 'filelist', 'folderlist', 'groupedlist', 'headertag', 'helpsite', 'hidden', 'imagelist',
'integer', 'language', 'list', 'media', 'menu', 'modal_menu', 'menuitem', 'meter', 'modulelayout', 'moduleorder', 'moduleposition',
'moduletag', 'note', 'number', 'password', 'plugins', 'predefinedlist', 'radio', 'range', 'repeatable', 'rules',
'moduletag', 'note', 'number', 'password', 'plugins', 'predefinedlist', 'radio', 'range', 'repeatable', 'rules', 'usergrouplist',
'sessionhandler', 'spacer', 'sql', 'subform', 'tag', 'tel', 'templatestyle', 'text', 'textarea', 'timezone', 'url', 'user', 'usergroup'
],
'plain' => [
'cachehandler', 'calendar', 'checkbox', 'chromestyle', 'color', 'componentlayout', 'contenttype', 'editor', 'editors', 'captcha',
'email', 'file', 'headertag', 'helpsite', 'hidden', 'integer', 'language', 'media', 'menu', 'modal_menu', 'menuitem', 'meter', 'modulelayout', 'templatestyle',
'moduleorder', 'moduletag', 'number', 'password', 'range', 'rules', 'tag', 'tel', 'text', 'textarea', 'timezone', 'url', 'user', 'usergroup'
'moduleorder', 'moduletag', 'number', 'password', 'range', 'rules', 'tag', 'tel', 'text', 'textarea', 'timezone', 'url', 'user', 'usergroup' , 'usergrouplist'
],
'option' => [
'accesslevel', 'category', 'checkboxes', 'combo', 'contentlanguage', 'databaseconnection', 'components',

View File

@ -18062,7 +18062,7 @@ class Interpretation extends Fields
. "\$query = \$db->getQuery(true);";
// check if usergroup as we change to an object query
if ($filter['type'] === 'usergroup')
if ($filter['type'] === 'usergroup' || $filter['type'] === 'usergrouplist')
{
$function[] = PHP_EOL . Indent::_(2) . "//"
. Line::_(__Line__, __Class__) . " Select the text.";
@ -18139,7 +18139,7 @@ class Interpretation extends Fields
. $nameListCode . "');";
}
// check if usergroup as we change to an object query
if ($filter['type'] !== 'usergroup')
if ($filter['type'] !== 'usergroup' && $filter['type'] !== 'usergrouplist')
{
$function[] = Indent::_(3)
. "\$_results = array_unique(\$_results);";
@ -18197,7 +18197,7 @@ class Interpretation extends Fields
}
else
{
if ($filter['type'] === 'usergroup')
if ($filter['type'] === 'usergroup' || $filter['type'] === 'usergrouplist')
{
$function[] = Indent::_(4) . "//" . Line::_(
__LINE__,__CLASS__
@ -20677,7 +20677,7 @@ class Interpretation extends Fields
break;
}
if ($item['type'] === 'usergroup' && !$export
if (($item['type'] === 'usergroup' || $item['type'] === 'usergrouplist') && !$export
&& $item['method'] != 6)
{
$fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(3) . "//"
@ -20704,7 +20704,7 @@ class Interpretation extends Fields
. $item['name'] . "Names);";
$fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(3) . "}";
}
/* elseif ($item['type'] === 'usergroup' && $export)
/* elseif (($item['type'] === 'usergroup' || $item['type'] === 'usergrouplist') && $export)
{
$fix .= PHP_EOL.Indent::_(1).$tab.Indent::_(3) . "//".Line::_(__Line__, __Class__)." decode ".$item['name'];
$fix .= PHP_EOL.Indent::_(1).$tab.Indent::_(3) . "\$".$item['name']."Array = ".$decode."(\$item->".$item['name'].$suffix_decode.");";

View File

@ -0,0 +1,147 @@
<?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;
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\BaseConfig;
/**
* 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.0.3
*/
class Config extends BaseConfig
{
/**
* The Global Joomla Configuration
*
* @var JoomlaRegistry
* @since 5.0.3
*/
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.0.3
*/
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.0.3
*/
protected function getGiteausername(): ?string
{
return $this->params->get('gitea_username');
}
/**
* get Gitea Access Token
*
* @return string the access token
* @since 5.0.3
*/
protected function getGiteatoken(): ?string
{
return $this->params->get('gitea_token');
}
/**
* Get fieldtype core organisation
*
* @return string The fieldtype core organisation
* @since 5.0.3
*/
protected function getJoomlafieldtypecoreorganisation(): string
{
// the VDM default organisation is [joomla]
$organisation = 'joomla';
return $this->params->get('joomla_fieldtype_core_organisation', $organisation);
}
/**
* Get Joomla fieldtype init repos
*
* @return array The init repositories on Gitea
* @since 5.0.3
*/
protected function getJoomlafieldtypeinitrepos(): 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 . '.joomla-fieldtypes'] = (object) ['organisation' => $this->gitea_username, 'repository' => 'joomla-fieldtypes', 'read_branch' => 'master'];
}
$repos[$this->joomla_fieldtype_core_organisation . '.joomla-fieldtypes'] = (object) ['organisation' => $this->joomla_fieldtype_core_organisation, 'repository' => 'joomla-fieldtypes', 'read_branch' => 'master'];
return $repos;
}
/**
* Get joomla fieldtype approved paths
*
* @return array The approved paths to the repositories on Gitea
* @since 5.0.3
*/
protected function getApprovedjoomlapaths(): array
{
// some defaults repos we need by JCB
$approved = $this->joomla_fieldtype_init_repos;
$paths = RepoHelper::get(3); // Joomla Field Type = 3
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);
}
}

View File

@ -0,0 +1,52 @@
<?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;
use Joomla\DI\Container;
use VDM\Joomla\Componentbuilder\Fieldtype\Service\Fieldtype as Power;
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\Interfaces\FactoryInterface;
use VDM\Joomla\Abstraction\Factory as ExtendingFactory;
/**
* Field Type Power Factory
*
* @since 5.0.3
*/
abstract class Factory extends ExtendingFactory implements FactoryInterface
{
/**
* Create a container object
*
* @return Container
* @since 5.0.3
*/
protected static function createContainer(): Container
{
return (new Container())
->registerServiceProvider(new Power())
->registerServiceProvider(new Database())
->registerServiceProvider(new Model())
->registerServiceProvider(new Data())
->registerServiceProvider(new Gitea())
->registerServiceProvider(new GiteaPower())
->registerServiceProvider(new GiteaUtilities());
}
}

View File

@ -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\Fieldtype;
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 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]
* See documentation for more details: https://git.vdm.dev/joomla/super-powers/wiki
*
* @since 5.0.3
*/
final class Grep extends ExtendingGrep implements GrepInterface
{
/**
* Order of global search
*
* @var array
* @since 5.0.3
**/
protected array $order = ['remote'];
/**
* Search for a remote item
*
* @param string $guid The global unique id of the item
*
* @return object|null
* @since 5.0.3
*/
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.0.3
*/
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);
// load the base and token if set
$this->contents->load_($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))
{
// 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 &&
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.0.3
*/
protected function setRemoteIndexMessage(string $message, string $path, string $repository, string $organisation, ?string $base): void
{
$this->app->enqueueMessage(
Text::sprintf('COM_COMPONENTBUILDER_PJOOMLA_FIELD_TYPEB_REPOSITORY_AT_BSSB_GAVE_THE_FOLLOWING_ERRORBR_SP', $this->contents->api(), $path, $message),
'Error'
);
}
}

View File

@ -0,0 +1,71 @@
<?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\Readme;
use VDM\Joomla\Interfaces\Readme\ItemInterface;
/**
* Compiler Field Type Item Readme
*
* @since 5.0.3
*/
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! 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.";
// 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);
}
}

View File

@ -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\Fieldtype\Readme;
use VDM\Joomla\Interfaces\Readme\MainInterface;
/**
* Field Type Main Readme
*
* @since 5.0.3
*/
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 JCB Joomla Field Types?\nThe Joomla field types provide a powerful way to map Joomla-related field types, enabling seamless integration with Joomla Component Builder (JCB). This repository serves as a centralized system for maintaining, updating, and distributing these field types throughout the JCB ecosystem.\n
\n
When you need to update any field type in JCB, simply select the desired field type and click the \"reset\" button. This action will automatically sync the selected field type 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 field types to your specific needs, you can fork the repository and point your JCB instance to your fork. This allows you to maintain and update field types 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;
}
}

View File

@ -0,0 +1 @@
<html><body bgcolor="#FFFFFF"></body></html>

View File

@ -0,0 +1,34 @@
<?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\GetInterface;
use VDM\Joomla\Abstraction\Remote\Get as ExtendingGet;
/**
* Remote Get Field Type of JCB
*
* @since 5.0.3
*/
final class Get extends ExtendingGet implements GetInterface
{
/**
* Table Name
*
* @var string
* @since 5.0.3
*/
protected string $table = 'fieldtype';
}

View File

@ -0,0 +1,218 @@
<?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\SetInterface;
use VDM\Joomla\Abstraction\Remote\Set as ExtendingSet;
/**
* Set Field Type based on global unique ids to remote repository
*
* @since 5.0.3
*/
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)
*
* @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
{
// make sure there was a change
$sha = $existing->params->source[$repo->guid . '-settings'] ?? null;
$existing = $this->mapItem($existing);
if ($sha === null || $this->areObjectsEqual($item, $existing))
{
return false;
}
$this->git->update(
$repo->organisation, // The owner name.
$repo->repository, // The repository name.
'src/' . $item->guid . '/' . $this->getSettingsPath(), // 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;
}
/**
* create a new item
*
* @param object $item
* @param object $repo
*
* @return void
* @since 5.0.3
*/
protected function createItem(object $item, object $repo): void
{
$this->git->create(
$repo->organisation, // The owner name.
$repo->repository, // The repository name.
'src/' . $item->guid . '/' . $this->getSettingsPath(), // The file path.
json_encode($item, JSON_PRETTY_PRINT), // The file content.
'Create ' . $item->name, // The commit message.
$repo->write_branch // The branch name.
);
}
/**
* 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.
'src/' . $item->guid . '/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.
'src/' . $item->guid . '/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.
);
}
/**
* Get the item name for the index values
*
* @param object $item
*
* @return string|null
* @since 5.0.3
*/
protected function index_map_IndexName(object $item): ?string
{
return $item->name ?? 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 ?? null;
}
}

View File

@ -0,0 +1 @@
<html><body bgcolor="#FFFFFF"></body></html>

View File

@ -0,0 +1,169 @@
<?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\Service;
use Joomla\DI\Container;
use Joomla\DI\ServiceProviderInterface;
use VDM\Joomla\Componentbuilder\Fieldtype\Config;
use VDM\Joomla\Componentbuilder\Table;
use VDM\Joomla\Componentbuilder\Fieldtype\Grep;
use VDM\Joomla\Componentbuilder\Fieldtype\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;
/**
* Field Type Service Provider
*
* @since 5.0.3
*/
class Fieldtype implements ServiceProviderInterface
{
/**
* Registers the service provider with a DI container.
*
* @param Container $container The DI container.
*
* @return void
* @since 3.2.1
*/
public function register(Container $container)
{
$container->alias(Config::class, 'Config')
->share('Config', [$this, 'getConfig'], true);
$container->alias(Table::class, 'Table')
->share('Table', [$this, 'getTable'], true);
$container->alias(Grep::class, 'Joomla.Fieldtype.Grep')
->share('Joomla.Fieldtype.Grep', [$this, 'getGrep'], true);
$container->alias(Get::class, 'Joomla.Fieldtype.Remote.Get')
->share('Joomla.Fieldtype.Remote.Get', [$this, 'getRemoteGet'], true);
$container->alias(Set::class, 'Joomla.Fieldtype.Remote.Set')
->share('Joomla.Fieldtype.Remote.Set', [$this, 'getRemoteSet'], true);
$container->alias(ItemReadme::class, 'Joomla.Fieldtype.Readme.Item')
->share('Joomla.Fieldtype.Readme.Item', [$this, 'getItemReadme'], true);
$container->alias(MainReadme::class, 'Joomla.Fieldtype.Readme.Main')
->share('Joomla.Fieldtype.Readme.Main', [$this, 'getMainReadme'], true);
}
/**
* Get The Config Class.
*
* @param Container $container The DI container.
*
* @return Config
* @since 3.2.1
*/
public function getConfig(Container $container): Config
{
return new Config();
}
/**
* Get The Table Class.
*
* @param Container $container The DI container.
*
* @return Table
* @since 3.2.1
*/
public function getTable(Container $container): Table
{
return new Table();
}
/**
* Get The Grep Class.
*
* @param Container $container The DI container.
*
* @return Grep
* @since 3.2.1
*/
public function getGrep(Container $container): Grep
{
return new Grep(
$container->get('Gitea.Repository.Contents'),
$container->get('Config')->approved_joomla_paths
);
}
/**
* Get The Remote Get Class.
*
* @param Container $container The DI container.
*
* @return Get
* @since 3.2.1
*/
public function getRemoteGet(Container $container): Get
{
return new Get(
$container->get('Joomla.Fieldtype.Grep'),
$container->get('Data.Item')
);
}
/**
* Get The Remote Set Class.
*
* @param Container $container The DI container.
*
* @return Set
* @since 3.2.2
*/
public function getRemoteSet(Container $container): Set
{
return new Set(
$container->get('Config')->approved_joomla_paths,
$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')
);
}
/**
* Get The Item Class.
*
* @param Container $container The DI container.
*
* @return ItemReadme
* @since 3.2.1
*/
public function getItemReadme(Container $container): ItemReadme
{
return new ItemReadme();
}
/**
* Get The Main Class.
*
* @param Container $container The DI container.
*
* @return MainReadme
* @since 3.2.1
*/
public function getMainReadme(Container $container): MainReadme
{
return new MainReadme();
}
}

View File

@ -0,0 +1 @@
<html><body bgcolor="#FFFFFF"></body></html>

View File

@ -0,0 +1 @@
<html><body bgcolor="#FFFFFF"></body></html>