Release of v3.2.1-alpha4

Add Joomla powers for namespace dynamic management.
This commit is contained in:
2024-04-16 19:05:17 +02:00
parent 0be0df5cec
commit 3a48b5596c
101 changed files with 6844 additions and 140 deletions

View File

@ -15,9 +15,9 @@ namespace VDM\Joomla\Componentbuilder\Abstraction;
use Joomla\Registry\Registry as JoomlaRegistry;
use Joomla\CMS\Factory;
use Joomla\Input\Input;
use VDM\Joomla\Abstraction\BaseConfig as Config;
use VDM\Joomla\Utilities\Component\Helper;
use VDM\Joomla\Utilities\String\ClassfunctionHelper;
use VDM\Joomla\Abstraction\BaseConfig as ExtendingBaseConfig;
/**
@ -25,7 +25,7 @@ use VDM\Joomla\Utilities\String\ClassfunctionHelper;
*
* @since 3.2.0
*/
abstract class BaseConfig extends Config
abstract class BaseConfig extends ExtendingBaseConfig
{
/**
* Hold a JInput object for easier access to the input variables.

View File

@ -800,6 +800,62 @@ class Config extends BaseConfig
return array_values($approved);
}
/**
* Get super power core organisation
*
* @return string The super power core organisation
* @since 3.2.0
*/
protected function getJoomlapowerscoreorganisation(): string
{
// the VDM default organisation is [joomla]
$organisation = 'joomla';
return $this->params->get('joomla_powers_core_organisation', $organisation);
}
/**
* Get Joomla power init repos
*
* @return array The init repositories on Gitea
* @since 3.2.0
*/
protected function getJoomlapowersinitrepos(): array
{
// some defaults repos we need by JCB
$repos = [];
$repos[$this->joomla_powers_core_organisation . '.joomla-powers'] = (object) ['owner' => $this->joomla_powers_core_organisation, 'repo' => 'joomla-powers', 'branch' => 'master'];
return $repos;
}
/**
* Get local joomla super powers repository path
*
* @return string The path to the local repository
* @since 3.2.0
*/
protected function getLocaljoomlapowersrepositorypath(): string
{
$default = $this->tmp_path . '/joomla_powers';
return $this->params->get('local_joomla_powers_repository_path', $default);
}
/**
* Get joomla power approved paths
*
* @return array The paths to the repositories on Gitea
* @since 3.2.0
*/
protected function getApprovedjoomlapaths(): array
{
// some defaults repos we need by JCB
$approved = $this->joomla_powers_init_repos;
return array_values($approved);
}
/**
* get bom path
*

View File

@ -18,6 +18,7 @@ use VDM\Joomla\Componentbuilder\Compiler\Config;
use VDM\Joomla\Componentbuilder\Compiler\Placeholder;
use VDM\Joomla\Componentbuilder\Compiler\Language\Extractor;
use VDM\Joomla\Componentbuilder\Compiler\Power\Extractor as Power;
use VDM\Joomla\Componentbuilder\Compiler\JoomlaPower\Extractor as JoomlaPower;
use VDM\Joomla\Componentbuilder\Compiler\Customcode\External;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Placefix;
use VDM\Joomla\Utilities\StringHelper;
@ -111,6 +112,14 @@ class Customcode implements CustomcodeInterface
**/
protected Power $power;
/**
* Joomla Power Extractor
*
* @var Power
* @since 3.2.0
**/
protected JoomlaPower $joomla;
/**
* Compiler Custom Code External
*
@ -129,23 +138,25 @@ class Customcode implements CustomcodeInterface
/**
* Constructor.
*
* @param Config|null $config The compiler config object.
* @param Placeholder|null $placeholder The compiler placeholder object.
* @param Extractor|null $extractor The compiler language extractor object.
* @param Power|null $power The compiler power extractor object.
* @param External|null $external The compiler external custom code object.
* @param \JDatabaseDriver $db The Database Driver object.
* @param Config $config The compiler config object.
* @param Placeholder $placeholder The compiler placeholder object.
* @param Extractor $extractor The compiler language extractor object.
* @param Power $power The compiler power extractor object.
* @param JoomlaPower $joomla The compiler joomla power extractor object.
* @param External $external The compiler external custom code object.
* @param \JDatabaseDriver $db The Database Driver object.
*
* @since 3.2.0
*/
public function __construct(?Config $config = null, ?Placeholder $placeholder = null,
?Extractor $extractor = null, ?Power $power = null, ?External $external = null)
public function __construct(Config $config, Placeholder $placeholder,
Extractor $extractor, Power $power, JoomlaPower $joomla, External $external)
{
$this->config = $config ?: Compiler::_('Config');
$this->placeholder = $placeholder ?: Compiler::_('Placeholder');
$this->extractor = $extractor ?: Compiler::_('Language.Extractor');
$this->power = $power ?: Compiler::_('Power.Extractor');
$this->external = $external ?: Compiler::_('Customcode.External');
$this->config = $config;
$this->placeholder = $placeholder;
$this->extractor = $extractor;
$this->power = $power;
$this->joomla = $joomla;
$this->external = $external;
$this->db = Factory::getDbo();
}
@ -170,8 +181,9 @@ class Customcode implements CustomcodeInterface
)
);
// extract any found super powers
// extract any found powers
$this->power->search($string);
$this->joomla->search($string);
}
// if debug
if ($debug)

View File

@ -25,6 +25,7 @@ use VDM\Joomla\Componentbuilder\Compiler\Service\Language;
use VDM\Joomla\Componentbuilder\Compiler\Service\Placeholder;
use VDM\Joomla\Componentbuilder\Compiler\Service\Customcode;
use VDM\Joomla\Componentbuilder\Compiler\Service\Power;
use VDM\Joomla\Componentbuilder\Compiler\Service\JoomlaPower;
use VDM\Joomla\Componentbuilder\Compiler\Service\Component;
use VDM\Joomla\Componentbuilder\Compiler\Service\Adminview;
use VDM\Joomla\Componentbuilder\Compiler\Service\Library;
@ -157,6 +158,7 @@ abstract class Factory implements FactoryInterface
->registerServiceProvider(new Placeholder())
->registerServiceProvider(new Customcode())
->registerServiceProvider(new Power())
->registerServiceProvider(new JoomlaPower())
->registerServiceProvider(new Component())
->registerServiceProvider(new Adminview())
->registerServiceProvider(new Library())

View File

@ -405,7 +405,7 @@ class Compiler extends Infusion
{
CFactory::_('Power')->load($super_powers);
}
// set the autoloader for Powers
// set the autoloader for Powers (second time)
CFactory::_('Power.Autoloader')->set();
// get the bom file
$bom = FileHelper::getContent(CFactory::_('Config')->bom_path);
@ -739,7 +739,11 @@ class Compiler extends Infusion
);
// inject any super powers found
$answer = CFactory::_('Power.Injector')->power($answer);
$answer = CFactory::_('Joomla.Power.Injector')->power(
CFactory::_('Power.Injector')->power(
$answer
)
);
// add answer back to file
CFactory::_('Utilities.File')->write($path, $answer);

View File

@ -2144,6 +2144,9 @@ class Infusion extends Interpretation
);
}
// set the autoloader for Powers (first time)
CFactory::_('Power.Autoloader')->set();
// tweak system to set stuff to the module domain
$_backup_target = CFactory::_('Config')->build_target;
$_backup_lang = CFactory::_('Config')->lang_target;

View File

@ -0,0 +1,61 @@
<?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\Compiler\Interfaces\Power;
/**
* Compiler Power Extractor
* @since 3.2.1
*/
interface ExtractorInterface
{
/**
* Get Super Powers from the code string
*
* @param string $code The code
*
* @return array|null
* @since 3.2.0
*/
public function get_(): ?array;
/**
* Get Super Powers from the code string
*
* @param string $code The code
*
* @return array|null
* @since 3.2.0
*/
public function get(string $code): ?array;
/**
* Get Super Powers from the code string
*
* @param string $code The code
*
* @return array|null
* @since 3.2.0
*/
public function reverse(string $code): ?array;
/**
* Get Super Powers from the code string and load it
*
* @param string $code The code
*
* @return void
* @since 3.2.0
*/
public function search(string $code): void;
}

View File

@ -0,0 +1,31 @@
<?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\Compiler\Interfaces\Power;
/**
* Compiler Power Injector
* @since 3.2.1
*/
interface InjectorInterface
{
/**
* Inject the powers found in the code
*
* @param string $code The class code
*
* @return string The updated code
* @since 3.2.0
*/
public function power(string $code): string;
}

View File

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

View File

@ -0,0 +1,446 @@
<?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\Compiler;
use Joomla\CMS\Factory;
use Joomla\CMS\Application\CMSApplication;
use Joomla\CMS\Language\Text;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Utilities\JsonHelper;
use VDM\Joomla\Utilities\GuidHelper;
use VDM\Joomla\Utilities\String\NamespaceHelper;
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\Super as SuperPower;
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\PowerInterface;
/**
* Joomla Power
*
* @since 3.2.1
*/
final class JoomlaPower implements PowerInterface
{
/**
* All loaded powers
*
* @var array
* @since 3.2.1
**/
public array $active = [];
/**
* All power namespaces
*
* @var array
* @since 3.2.1
**/
public array $namespace = [];
/**
* All super powers of this build
*
* @var array
* @since 3.2.1
**/
public array $superpowers = [];
/**
* Old super powers found in the local repos
*
* @var array
* @since 3.2.1
**/
public array $old_superpowers = [];
/**
* The url to the power, if there is an error.
*
* @var string
* @since 3.2.1
**/
protected string $fixUrl;
/**
* The state of all loaded powers
*
* @var array
* @since 3.2.1
**/
protected array $state = [];
/**
* The state of retry to loaded powers
*
* @var array
* @since 3.2.1
**/
protected array $retry = [];
/**
* Compiler Config
*
* @var Config
* @since 3.2.1
**/
protected Config $config;
/**
* Compiler Placeholder
*
* @var Placeholder
* @since 3.2.1
**/
protected Placeholder $placeholder;
/**
* Compiler Customcode
*
* @var Customcode
* @since 3.2.1
**/
protected Customcode $customcode;
/**
* Compiler Customcode in Gui
*
* @var Gui
* @since 3.2.1
**/
protected Gui $gui;
/**
* The JCB Superpower class
*
* @var Superpower
* @since 3.2.1
**/
protected Superpower $superpower;
/**
* Database object to query local DB
*
* @since 3.2.1
**/
protected $db;
/**
* Database object to query local DB
*
* @since 3.2.1
**/
protected $app;
/**
* Constructor.
*
* @param Config $config The compiler config object.
* @param Placeholder $placeholder The compiler placeholder object.
* @param Customcode $customcode The compiler customcode object.
* @param Gui $gui The compiler customcode gui object.
* @param Superpower $superpower The JCB superpower object.
*
* @throws \Exception
* @since 3.2.1
*/
public function __construct(Config $config, Placeholder $placeholder,
Customcode $customcode, Gui $gui, Superpower $superpower)
{
$this->config = $config;
$this->placeholder = $placeholder;
$this->customcode = $customcode;
$this->gui = $gui;
$this->superpower = $superpower;
$this->db = Factory::getDbo();
$this->app = Factory::getApplication();
}
/**
* load all the powers linked to this component
*
* @param array $guids The global unique ids of the linked powers
*
* @return void
* @since 3.2.1
*/
public function load(array $guids)
{
if (ArrayHelper::check($guids))
{
foreach ($guids as $guid => $build)
{
$this->get($guid, $build);
}
}
}
/**
* Get a power
*
* @param string $guid The global unique id of the power
* @param int $build Force build switch (to override global switch)
*
* @return object|null
* @since 3.2.1
*/
public function get(string $guid, int $build = 0): ?object
{
if (($this->config->get('add_power', true) || $build == 1) && $this->set($guid))
{
return $this->active[$guid];
}
return null;
}
/**
* Set a power
*
* @param string $guid The global unique id of the power
*
* @return bool true on successful setting of a power
* @since 3.2.1
*/
private function set(string $guid): bool
{
// check if we have been here before
if ($this->isPowerSet($guid))
{
return $this->state[$guid];
}
elseif ($this->isGuidValid($guid))
{
// get the power data
$this->active[$guid] = $this->getPowerData($guid);
if (is_object($this->active[$guid]))
{
// make sure that in recursion we
// don't try to load this power again
// since during the load of a power we also load
// all powers linked to it
$this->state[$guid] = true;
// convert settings to an array
if (JsonHelper::check($this->active[$guid]->settings))
{
$this->active[$guid]->settings = $settings
= json_decode($this->active[$guid]->settings, true);
}
// set a target version
$joomla_version = $this->config->joomla_version;
if ($joomla_version && ArrayHelper::check($settings))
{
foreach ($settings as $namespace)
{
if ($joomla_version == $namespace['joomla_version'] ||
$namespace['joomla_version'] == 0)
{
$this->active[$guid]->namespace = $namespace['namespace'];
$this->active[$guid]->type = $namespace['type'] ?? 'class';
break;
}
}
$this->active[$guid]->class_name =
$this->extractLastNameFromNamespace($this->active[$guid]->namespace);
$this->active[$guid]->_namespace =
$this->removeLastNameFromNamespace($this->active[$guid]->namespace);
// set the approved super power values
$this->setSuperPowers($guid);
return true;
}
}
}
// we failed to get the power,
// so we raise an error message
// only if guid is valid
if ($this->isGuidValid($guid))
{
// now we search for it via the super power paths
if (empty($this->retry[$guid]) && $this->superpower->load($guid, ['remote', 'local']))
{
// we found it and it was loaded into the database
unset($this->state[$guid]);
unset($this->active[$guid]);
// we make sure that this retry only happen once! (just in-case...)
$this->retry[$guid] = true;
// so we try to load it again
return $this->set($guid);
}
$this->app->enqueueMessage(
Text::sprintf('COM_COMPONENTBUILDER_PJOOMLA_POWER_BGUIDSB_NOT_FOUNDP', $guid),
'Error'
);
}
// let's not try again
$this->state[$guid] = false;
return false;
}
/**
* Extracts the last part of a namespace string, which is typically the class name.
*
* @param string $namespace The namespace string to extract from.
*
* @return string|null The extracted class name.
* @since 3.2.1
*/
private function extractLastNameFromNamespace(string $namespace): ?string
{
$parts = explode('\\', $namespace);
$result = end($parts);
// Remove '\\' from the beginning and end of the resulting string
$result = trim($result, '\\');
// If the resulting string is empty, return null
return empty($result) ? null : $result;
}
/**
* Removes the last name from the namespace.
*
* @param string $namespace The namespace
*
* @return string The namespace shortened
* @since 3.2.1
*/
private function removeLastNameFromNamespace(string $namespace): string
{
// Remove '\\' from the beginning and end of the resulting string
$namespace = trim($namespace, '\\');
$parts = explode('\\', $namespace);
// Remove the last part (the class name)
array_pop($parts);
// Reassemble the namespace without the class name
return implode('\\', $parts);
}
/**
* Check if the power is already set
*
* @param string $guid The global unique id of the power
*
* @return bool true if the power is already set
* @since 3.2.1
*/
private function isPowerSet(string $guid): bool
{
return isset($this->state[$guid]);
}
/**
* Validate the GUID
*
* @param string $guid The global unique id of the power
*
* @return bool true if the GUID is valid
* @since 3.2.1
*/
private function isGuidValid(string $guid): bool
{
return GuidHelper::valid($guid);
}
/**
* Get the power data from the database
*
* @param string $guid The global unique id of the power
*
* @return object|null The power data
* @since 3.2.1
*/
private function getPowerData(string $guid): ?object
{
$query = $this->db->getQuery(true);
$query->select('a.*');
$query->from('#__componentbuilder_joomla_power AS a');
$query->where($this->db->quoteName('a.guid') . ' = ' . $this->db->quote($guid));
$this->db->setQuery($query);
$this->db->execute();
if ($this->db->getNumRows())
{
return $this->db->loadObject();
}
return null;
}
/**
* Get Clean Namespace without use or ; as part of the name space
*
* @param string $namespace The actual name space
* @param bool $removeNumbers The switch to remove numbers
*
* @return string
* @since 3.2.1
*/
private function getCleanNamespace(string $namespace): string
{
// trim possible (use) or (;) or (starting or ending \) added to the namespace
return NamespaceHelper::safe(str_replace(['use ', ';'], '', $namespace));
}
/**
* Get [use Namespace\Class;]
*
* @param string $namespace The actual name space
* @param string $as The use as name (default is none)
*
* @return string
* @since 3.2.1
*/
private function getUseNamespace(string $namespace, string $as = 'default'): string
{
// check if it has an AS option
if ($as !== 'default')
{
return 'use ' . $namespace . ' as ' . $as . ';';
}
return 'use ' . $namespace . ';';
}
/**
* Set the super powers of this power
*
* @param string $guid The global unique id of the power
*
* @return void
* @since 3.2.1
*/
private function setSuperPowers(string $guid): void
{
// soon
}
}

View File

@ -0,0 +1,118 @@
<?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\Compiler\JoomlaPower;
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Power\ExtractorInterface;
use VDM\Joomla\Componentbuilder\Compiler\Power\Extractor as ExtendingExtractor;
/**
* Compiler Joomla Power Extractor
* @since 3.2.1
*/
final class Extractor extends ExtendingExtractor implements ExtractorInterface
{
/**
* The pattern to get the powers
*
* @var string
* @since 3.2.0
**/
protected string $pattern = '/Joomla_'.'_'.'_[a-zA-Z0-9_]+_'.'_'.'_Power/';
/**
* The pattern to get the Front
*
* @var string
* @since 3.2.1
**/
protected string $_pattern = 'Joomla';
/**
* The pattern to get the Back
*
* @var string
* @since 3.2.1
**/
protected string $pattern_ = 'Power';
/**
* The Table
*
* @var string
* @since 3.2.1
**/
protected string $table = 'joomla_power';
/**
* Current Joomla Version Being Build
*
* @var int
* @since 3.2.0
**/
protected $targetVersion;
/**
* Constructor.
*
* @param int $targetVersion The targeted Joomla version.
*
* @since 3.2.1
*/
public function __construct(int $targetVersion)
{
parent::__construct();
$this->targetVersion = $targetVersion;
}
/**
* Get the complete namespace strings of the guids passed as an array.
*
* @param array $guids The guids to filter the results
*
* @return array|null The result namespaces with their guids
* @since 3.2.0
**/
protected function namespaces(array $guids): ?array
{
$query = $this->db->getQuery(true);
$query->select($this->db->quoteName(['settings', 'guid']))
->from($this->db->quoteName('#__componentbuilder_' . $this->table))
->where($this->db->quoteName('guid') . ' IN (' . implode(',', array_map([$this->db, 'quote'], $guids)) . ')');
$this->db->setQuery($query);
$this->db->execute();
if ($this->db->getNumRows())
{
$namespaces = [];
$items = $this->db->loadAssocList();
foreach ($items as $item)
{
if (JsonHelper::check($item->settings))
{
$item->settings = json_decode($item->settings, true);
echo '<pre>'; var_dump($item->settings, 'Joomla Version: ' . $this->targetVersion); exit;
}
}
if ($namespaces !== [])
{
return $namespaces;
}
}
return null;
}
}

View File

@ -0,0 +1,91 @@
<?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\Compiler\JoomlaPower;
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Power\InjectorInterface;
use VDM\Joomla\Componentbuilder\Compiler\Power\Injector as ExtendingInjector;
/**
* Compiler Joomla Power Injector
* @since 3.2.0
*/
final class Injector extends ExtendingInjector implements InjectorInterface
{
/**
* Builds the namespace statement from the power object's namespace and class name.
*
* @param object $power The power object.
*
* @return string The constructed use statement.
* @since 3.2.0
*/
protected function buildNamespaceStatment(object $power): string
{
return $power->_namespace . '\\' . $power->class_name;
}
/**
* Ensures the name for the use statement is unique, avoiding conflicts with other classes.
*
* @param string $name The current name
* @param object $power The power object containing type, namespace, and class name.
*
* @return string The unique name
* @since 3.2.0
*/
protected function getUniqueName(string $name, object $power): string
{
// set search namespace
$namespace = ($name !== $power->class_name) ? $this->buildNamespaceStatment($power) : $power->_namespace;
// check if we need to update the name
if (isset($this->other[$name]))
{
// if the name is already used
while (isset($this->other[$name]))
{
if (($tmp = $this->extractClassNameOrAlias($namespace)) !== null)
{
$name = ucfirst($tmp) . $name;
$namespace = $this->removeLastNameFromNamespace($namespace);
}
else
{
$name = 'Unique' . $name;
}
}
}
// also loop new found use statements
if (isset($this->useStatements[$name]))
{
// if the name is already used
while (isset($this->useStatements[$name]))
{
if (($tmp = $this->extractClassNameOrAlias($namespace)) !== null)
{
$name = ucfirst($tmp) . $name;
$namespace = $this->removeLastNameFromNamespace($namespace);
}
else
{
$name = 'Unique' . $name;
}
}
}
return $name;
}
}

View File

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

View File

@ -174,16 +174,18 @@ class Router
// We can only work with ID if the [main get] is a [getItem] dynamicGet for this site view.
$key = ($view['settings']->main_get->gettype == 1) ? 'id' : null;
$view_selected = $selection['view'] ?? null;
$name_selected = $selection['name'] ?? null;
// Construct the enriched view object.
return (object) [
'view' => $view['settings']->code,
'View' => $view['settings']->Code,
'stable' => ($selection['view'] === $view['settings']->code), // sanity check
'target_view' => $selection['view'],
'table' => $selection['table'],
'table_name' => $selection['name'],
'alias' => $this->getSiteViewAliasKey($selection['name'] ?? null, $adminViews),
'stable' => ($view_selected === $view['settings']->code), // sanity check
'target_view' => $view_selected,
'table' => $selection['table'] ?? null,
'table_name' => $name_selected,
'alias' => $this->getSiteViewAliasKey($name_selected, $adminViews),
'key' => $key,
'form' => false
];

View File

@ -21,6 +21,7 @@ use VDM\Joomla\Componentbuilder\Compiler\Placeholder;
use VDM\Joomla\Componentbuilder\Compiler\Language;
use VDM\Joomla\Componentbuilder\Compiler\Language\Extractor;
use VDM\Joomla\Componentbuilder\Compiler\Power\Extractor as Power;
use VDM\Joomla\Componentbuilder\Compiler\JoomlaPower\Extractor as JoomlaPower;
/**
@ -70,27 +71,36 @@ class Reverse
**/
protected Power $power;
/**
* Joomla Power Extractor
*
* @var Power
* @since 3.2.1
**/
protected JoomlaPower $joomla;
/**
* Constructor.
*
* @param Config|null $config The compiler config object.
* @param Placeholder|null $placeholder The compiler placeholder object.
* @param Language|null $language The compiler language object.
* @param Extractor|null $extractor The compiler language extractor object.
* @param Power|null $power The compiler power extractor object.
* @param Config $config The compiler config object.
* @param Placeholder $placeholder The compiler placeholder object.
* @param Language $language The compiler language object.
* @param Extractor $extractor The compiler language extractor object.
* @param Power $power The compiler power extractor object.
*
* @since 3.2.0
*/
public function __construct(
?Config $config = null, ?Placeholder $placeholder = null,
?Language $language = null, ?Extractor $extractor = null,
?Power $power = null)
Config $config, Placeholder $placeholder,
Language $language, Extractor $extractor,
Power $power, JoomlaPower $joomla)
{
$this->config = $config ?: Compiler::_('Config');
$this->placeholder = $placeholder ?: Compiler::_('Placeholder');
$this->language = $language ?: Compiler::_('Language');
$this->extractor = $extractor ?: Compiler::_('Language.Extractor');
$this->power = $power ?: Compiler::_('Power.Extractor');
$this->config = $config;
$this->placeholder = $placeholder;
$this->language = $language;
$this->extractor = $extractor;
$this->power = $power;
$this->joomla = $joomla;
}
/**
@ -138,8 +148,9 @@ class Reverse
protected function setReverse(string $updateString, string $string,
string $target, ?array $useStatements): string
{
// we have to reverse engineer to super powers
// we have to reverse engineer of powers
$updateString = $this->reverseSuperPowers($updateString, $string, $useStatements);
$updateString = $this->reverseJoomlaPowers($updateString, $string, $useStatements);
// reverse engineer the language strings
$updateString = $this->reverseLanguage($updateString, $string, $target);
@ -165,7 +176,30 @@ class Reverse
{
// only if we have use statements can we reverse engineer this
if ($useStatements !== null && ($powers = $this->power->reverse($string)) !== null &&
($reverse = $this->getReversePower($powers, $useStatements)) !== null)
($reverse = $this->getReversePower($powers, $useStatements, 'Super')) !== null)
{
return $this->placeholder->update($updateString, $reverse);
}
return $updateString;
}
/**
* Set the joomla powers keys for the reveres process
*
* @param string $updateString The string to update
* @param string $string The string to use for super power update
* @param array|null $useStatements The file use statements (needed for super powers)
*
* @return string
* @since 3.2.0
*/
protected function reverseJoomlaPowers(string $updateString, string $string,
?array $useStatements): string
{
// only if we have use statements can we reverse engineer this
if ($useStatements !== null && ($powers = $this->joomla->reverse($string)) !== null &&
($reverse = $this->getReversePower($powers, $useStatements, 'Joomla')) !== null)
{
return $this->placeholder->update($updateString, $reverse);
}
@ -178,11 +212,12 @@ class Reverse
*
* @param array $powers The powers found in the database text
* @param array $useStatements The file use statements
* @param string $target The power target type
*
* @return array|null
* @since 3.2.0
*/
protected function getReversePower(array $powers, array $useStatements): ?array
protected function getReversePower(array $powers, array $useStatements, string $target): ?array
{
$matching_statements = [];
foreach ($useStatements as $use_statement)
@ -211,7 +246,7 @@ class Reverse
{
$guid = array_search($namespace, $powers);
$matching_statements[$class_name] =
'Super_'.'_'.'_' . str_replace('-', '_', $guid) . '_'.'_'.'_Power';
$target . '_'.'_'.'_' . str_replace('-', '_', $guid) . '_'.'_'.'_Power';
}
}

View File

@ -303,7 +303,7 @@ class Power implements PowerInterface
$this->setImplements($guid, $use);
// set extend class
$this->setExtend($guid, $use);
$this->setExtend($guid, $use, $as);
// set GUI mapper
$guiMapper = [
@ -760,11 +760,12 @@ class Power implements PowerInterface
*
* @param string $guid The global unique id of the power
* @param array $use The use array
* @param array $as The use as array
*
* @return void
* @since 3.2.0
*/
private function setExtend(string $guid, array &$use)
private function setExtend(string $guid, array &$use, array &$as)
{
// does this extend something
$this->active[$guid]->extends_name = null;
@ -793,6 +794,13 @@ class Power implements PowerInterface
$this->active[$guid]->extends_name = $this->get($this->active[$guid]->extends, 1)->class_name;
// add to use
$use[] = $this->active[$guid]->extends;
// add padding if the two names are the same
if ($this->active[$guid]->extends_name === $this->active[$guid]->class_name)
{
$this->active[$guid]->extends_name = $as[$this->active[$guid]->extends]
= 'Extending' . $this->active[$guid]->class_name;
}
}
}
}

View File

@ -14,13 +14,14 @@ namespace VDM\Joomla\Componentbuilder\Compiler\Power;
use Joomla\CMS\Factory;
use VDM\Joomla\Utilities\GuidHelper;
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Power\ExtractorInterface;
/**
* Compiler Power Extractor
* @since 3.2.0
*/
final class Extractor
class Extractor implements ExtractorInterface
{
/**
* The pattern to get the powers
@ -30,6 +31,30 @@ final class Extractor
**/
protected string $pattern = '/Super_'.'_'.'_[a-zA-Z0-9_]+_'.'_'.'_Power/';
/**
* The pattern to get the Front
*
* @var string
* @since 3.2.1
**/
protected string $_pattern = 'Super';
/**
* The pattern to get the Back
*
* @var string
* @since 3.2.1
**/
protected string $pattern_ = 'Power';
/**
* The Table
*
* @var string
* @since 3.2.1
**/
protected string $table = 'power';
/**
* Powers GUID's
*
@ -122,7 +147,7 @@ final class Extractor
* @return void
* @since 3.2.0
*/
public function search(string $code)
public function search(string $code): void
{
$matches = [];
preg_match_all($this->pattern, $code, $matches);
@ -147,7 +172,7 @@ final class Extractor
{
foreach ($found as $super_power)
{
$guid = str_replace(['Super_'.'_'.'_', '_'.'_'.'_Power'], '', $super_power);
$guid = str_replace([], '', $super_power);
$guid = str_replace('_', '-', $guid);
if (GuidHelper::valid($guid))
@ -171,7 +196,7 @@ final class Extractor
foreach ($found as $super_power)
{
$guid = str_replace(['Super_'.'_'.'_', '_'.'_'.'_Power'], '', $super_power);
$guid = str_replace([$this->_pattern . '___', '___' . $this->pattern_], '', $super_power);
$guid = str_replace('_', '-', $guid);
if (GuidHelper::valid($guid))
@ -197,7 +222,7 @@ final class Extractor
foreach ($found as $super_power)
{
$guid = str_replace(['Super_'.'_'.'_', '_'.'_'.'_Power'], '', $super_power);
$guid = str_replace([$this->_pattern . '___', '___' . $this->pattern_], '', $super_power);
$guid = str_replace('_', '-', $guid);
if (GuidHelper::valid($guid))
@ -226,7 +251,7 @@ final class Extractor
. ', ".", "\\\") AS full_namespace, '
. $this->db->quoteName('guid')
)
->from($this->db->quoteName('#__componentbuilder_power'))
->from($this->db->quoteName('#__componentbuilder_' . $this->table))
->where($this->db->quoteName('guid') . ' IN (' . implode(',', array_map([$this->db, 'quote'], $guids)) . ')');
$this->db->setQuery($query);
$this->db->execute();

View File

@ -12,18 +12,18 @@
namespace VDM\Joomla\Componentbuilder\Compiler\Power;
use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler;
use VDM\Joomla\Componentbuilder\Compiler\Power;
use VDM\Joomla\Componentbuilder\Compiler\Power\Extractor;
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\PowerInterface as Power;
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Power\ExtractorInterface as Extractor;
use VDM\Joomla\Componentbuilder\Compiler\Power\Parser;
use VDM\Joomla\Componentbuilder\Compiler\Placeholder;
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Power\InjectorInterface;
/**
* Compiler Power Injector
* @since 3.2.0
*/
final class Injector
class Injector implements InjectorInterface
{
/**
* Power Objects
@ -107,13 +107,13 @@ final class Injector
*
* @since 3.2.0
*/
public function __construct(?Power $power = null, ?Extractor $extractor = null,
?Parser $parser = null, ?Placeholder $placeholder = null)
public function __construct(Power $power = null, Extractor $extractor = null,
Parser $parser = null, Placeholder $placeholder = null)
{
$this->power = $power ?: Compiler::_('Power');
$this->extractor = $extractor ?: Compiler::_('Power.Extractor');
$this->parser = $parser ?: Compiler::_('Power.Parser');
$this->placeholder = $placeholder ?: Compiler::_('Placeholder');
$this->power = $power;
$this->extractor = $extractor;
$this->parser = $parser;
$this->placeholder = $placeholder;
}
/**

View File

@ -82,6 +82,7 @@ class Customcode implements ServiceProviderInterface
$container->get('Placeholder'),
$container->get('Language.Extractor'),
$container->get('Power.Extractor'),
$container->get('Joomla.Power.Extractor'),
$container->get('Customcode.External')
);
}

View File

@ -0,0 +1,202 @@
<?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\Compiler\Service;
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\Super as Superpower;
use VDM\Joomla\Componentbuilder\Compiler\JoomlaPower\Extractor;
use VDM\Joomla\Componentbuilder\Compiler\JoomlaPower\Injector;
use VDM\Joomla\Componentbuilder\JoomlaPower\Model\Upsert;
use VDM\Joomla\Componentbuilder\JoomlaPower\Database\Insert;
use VDM\Joomla\Componentbuilder\JoomlaPower\Database\Update;
/**
* Compiler Joomla Power Service Provider
*
* @since 3.2.0
*/
class JoomlaPower 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(Powers::class, 'Joomla.Power')
->share('Joomla.Power', [$this, 'getPowers'], true);
$container->alias(Superpower::class, 'Joomlapower')
->share('Joomlapower', [$this, 'getSuperpower'], true);
$container->alias(Grep::class, 'Joomla.Power.Grep')
->share('Joomla.Power.Grep', [$this, 'getGrep'], true);
$container->alias(Extractor::class, 'Joomla.Power.Extractor')
->share('Joomla.Power.Extractor', [$this, 'getExtractor'], true);
$container->alias(Injector::class, 'Joomla.Power.Injector')
->share('Joomla.Power.Injector', [$this, 'getInjector'], true);
$container->alias(Upsert::class, 'Joomla.Power.Model.Upsert')
->share('Joomla.Power.Model.Upsert', [$this, 'getModelUpsert'], true);
$container->alias(Insert::class, 'Joomla.Power.Insert')
->share('Joomla.Power.Insert', [$this, 'getInsert'], true);
$container->alias(Update::class, 'Joomla.Power.Update')
->share('Joomla.Power.Update', [$this, 'getUpdate'], true);
}
/**
* Get the Powers
*
* @param Container $container The DI container.
*
* @return Powers
* @since 3.2.0
*/
public function getPowers(Container $container): Powers
{
return new Powers(
$container->get('Config'),
$container->get('Placeholder'),
$container->get('Customcode'),
$container->get('Customcode.Gui'),
$container->get('Joomlapower')
);
}
/**
* Get the Superpower
*
* @param Container $container The DI container.
*
* @return Superpower
* @since 3.2.0
*/
public function getSuperpower(Container $container): Superpower
{
return new Superpower(
$container->get('Joomla.Power.Grep'),
$container->get('Joomla.Power.Insert'),
$container->get('Joomla.Power.Update')
);
}
/**
* Get the Grep
*
* @param Container $container The DI container.
*
* @return Grep
* @since 3.2.0
*/
public function getGrep(Container $container): Grep
{
return new Grep(
$container->get('Config')->local_joomla_powers_repository_path,
$container->get('Config')->approved_joomla_paths,
$container->get('Gitea.Repository.Contents')
);
}
/**
* Get the Compiler Power Extractor
*
* @param Container $container The DI container.
*
* @return Extractor
* @since 3.2.0
*/
public function getExtractor(Container $container): Extractor
{
return new Extractor(
$container->get('Config')->joomla_version
);
}
/**
* Get the Compiler Power Injector
*
* @param Container $container The DI container.
*
* @return Injector
* @since 3.2.0
*/
public function getInjector(Container $container): Injector
{
return new Injector(
$container->get('Joomla.Power'),
$container->get('Joomla.Power.Extractor'),
$container->get('Power.Parser'),
$container->get('Placeholder')
);
}
/**
* Get the Power Model Upsert
*
* @param Container $container The DI container.
*
* @return Upsert
* @since 3.2.0
*/
public function getModelUpsert(Container $container): Upsert
{
return new Upsert(
$container->get('Table')
);
}
/**
* Get the Power Insert
*
* @param Container $container The DI container.
*
* @return Insert
* @since 3.2.0
*/
public function getInsert(Container $container): Insert
{
return new Insert(
$container->get('Joomla.Power.Model.Upsert'),
$container->get('Insert')
);
}
/**
* Get the Power Update
*
* @param Container $container The DI container.
*
* @return Update
* @since 3.2.0
*/
public function getUpdate(Container $container): Update
{
return new Update(
$container->get('Joomla.Power.Model.Upsert'),
$container->get('Update')
);
}
}

View File

@ -62,7 +62,7 @@ class Placeholder implements ServiceProviderInterface
*
* @param Container $container The DI container.
*
* @return Worker
* @return Reverse
* @since 3.2.0
*/
public function getPlaceholderReverse(Container $container): Reverse
@ -72,7 +72,8 @@ class Placeholder implements ServiceProviderInterface
$container->get('Placeholder'),
$container->get('Language'),
$container->get('Language.Extractor'),
$container->get('Power.Extractor')
$container->get('Power.Extractor'),
$container->get('Joomla.Power.Extractor')
);
}
}

View File

@ -0,0 +1,81 @@
<?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\Interfaces\Database;
/**
* Database Insert
*
* @since 3.2.1
*/
interface InsertInterface
{
/**
* Insert a value to a given table
* Example: $this->value(Value, 'value_key', 'GUID');
*
* @param mixed $value The field value
* @param string $field The field key
* @param string $keyValue The key value
* @param string $key The key name
*
* @return bool
* @since 3.2.0
*/
public function value($value, string $field, string $keyValue, string $key = 'guid'): bool;
/**
* Insert single row with multiple values to a given table
* Example: $this->item(Array);
*
* @param array $item The item to save
*
* @return bool
* @since 3.2.0
*/
public function row(array $item): bool;
/**
* Insert multiple rows to a given table
* Example: $this->items(Array);
*
* @param array|null $items The items updated in database (array of arrays)
*
* @return bool
* @since 3.2.0
*/
public function rows(?array $items): bool;
/**
* Insert single item with multiple values to a given table
* Example: $this->item(Object);
*
* @param object $item The item to save
*
* @return bool
* @since 3.2.0
*/
public function item(object $item): bool;
/**
* Insert multiple items to a given table
* Example: $this->items(Array);
*
* @param array|null $items The items updated in database (array of objects)
*
* @return bool
* @since 3.2.0
*/
public function items(?array $items): bool;
}

View File

@ -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\Interfaces\Database;
/**
* Database Update
*
* @since 3.2.1
*/
interface UpdateInterface
{
/**
* Update a value to a given table
* Example: $this->value(Value, 'value_key', 'GUID');
*
* @param mixed $value The field value
* @param string $field The field key
* @param string $keyValue The key value
* @param string $key The key name
*
* @return bool
* @since 3.2.0
*/
public function value($value, string $field, string $keyValue, string $key = 'guid'): bool;
/**
* Update single row with multiple values to a given table
* Example: $this->item(Array);
*
* @param array $item The item to save
*
* @return bool
* @since 3.2.0
*/
public function row(array $item): bool;
/**
* Update multiple rows to a given table
* Example: $this->items(Array);
*
* @param array|null $items The items updated in database (array of arrays)
*
* @return bool
* @since 3.2.0
*/
public function rows(?array $items): bool;
/**
* Update single item with multiple values to a given table
* Example: $this->item(Object);
*
* @param object $item The item to save
*
* @return bool
* @since 3.2.0
*/
public function item(object $item): bool;
/**
* Update multiple items to a given table
* Example: $this->items(Array);
*
* @param array|null $items The items updated in database (array of objects)
*
* @return bool
* @since 3.2.0
*/
public function items(?array $items): bool;
}

View File

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

View File

@ -0,0 +1,41 @@
<?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\Interfaces;
/**
* Global Resource Empowerment Platform
*
* @since 3.2.1
*/
interface GrepInterface
{
/**
* Get all remote powers GUID's
*
* @return array|null
* @since 3.2.0
*/
public function getRemotePowersGuid(): ?array;
/**
* Get a power
*
* @param string $guid The global unique id of the power
* @param array $order The search order
*
* @return object|null
* @since 3.2.0
*/
public function get(string $guid, array $order = ['local', 'remote']): ?object;
}

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\Interfaces;
/**
* Superpower of JCB
*
* @since 3.2.0
*/
interface SuperInterface
{
/**
* Init all power not found in database
*
* @return bool
* @since 3.2.0
*/
public function init(): bool;
/**
* Reset the powers
*
* @param array $powers The global unique ids of the powers
*
* @return bool
* @since 3.2.0
*/
public function reset(array $powers): bool;
/**
* Load a superpower
*
* @param string $guid The global unique id of the power
* @param array $order The search order
* @param string|null $action The action to load power
*
* @return bool
* @since 3.2.0
*/
public function load(string $guid, array $order = ['remote', 'local'], ?string $action = null): bool;
}

View File

@ -0,0 +1,182 @@
<?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;
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\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 3.2.0
*/
class Config extends BaseConfig
{
/**
* The Global Joomla Configuration
*
* @var JoomlaRegistry
* @since 3.2.0
*/
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 3.2.0
*/
public function __construct(?Input $input = null, ?JoomlaRegistry $params = null, ?JoomlaRegistry $config = null)
{
parent::__construct($input, $params);
$this->config = $config ?: JoomlaFactory::getConfig();
}
/**
* get Gitea Access Token
*
* @return string the access token
* @since 3.2.0
*/
protected function getGiteatoken(): ?string
{
return $this->custom_gitea_token ?? $this->params->get('gitea_token');
}
/**
* get Add Custom Gitea URL
*
* @return int the add switch
* @since 3.2.0
*/
protected function getAddcustomgiteaurl(): int
{
return $this->params->get('add_custom_gitea_url', 1);
}
/**
* get Custom Gitea URL
*
* @return string the custom gitea url
* @since 3.2.0
*/
protected function getCustomgiteaurl(): ?string
{
if ($this->add_custom_gitea_url == 2)
{
return $this->params->get('custom_gitea_url');
}
return null;
}
/**
* get Custom Gitea Access Token
*
* @return string the custom access token
* @since 3.2.0
*/
protected function getCustomgiteatoken(): ?string
{
if ($this->add_custom_gitea_url == 2)
{
return $this->params->get('custom_gitea_token');
}
return null;
}
/**
* Get super power core organisation
*
* @return string The super power core organisation
* @since 3.2.0
*/
protected function getJoomlapowerscoreorganisation(): string
{
// the VDM default organisation is [joomla]
$organisation = 'joomla';
return $this->params->get('joomla_powers_core_organisation', $organisation);
}
/**
* Get Joomla power init repos
*
* @return array The init repositories on Gitea
* @since 3.2.0
*/
protected function getJoomlapowersinitrepos(): array
{
// some defaults repos we need by JCB
$repos = [];
$repos[$this->joomla_powers_core_organisation . '.joomla-powers'] = (object) ['owner' => $this->joomla_powers_core_organisation, 'repo' => 'joomla-powers', 'branch' => 'master'];
return $repos;
}
/**
* get temporary path
*
* @return string The temporary path
* @since 3.2.0
*/
protected function getTmppath(): string
{
// get the temporary path
return $this->config->get('tmp_path');
}
/**
* Get local joomla super powers repository path
*
* @return string The path to the local repository
* @since 3.2.0
*/
protected function getLocaljoomlapowersrepositorypath(): string
{
$default = $this->tmp_path . '/joomla_powers';
return $this->params->get('local_joomla_powers_repository_path', $default);
}
/**
* Get joomla power approved paths
*
* @return array The paths to the repositories on Gitea
* @since 3.2.0
*/
protected function getApprovedjoomlapaths(): array
{
// some defaults repos we need by JCB
$approved = $this->joomla_powers_init_repos;
return array_values($approved);
}
}

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\JoomlaPower\Database;
use VDM\Joomla\Componentbuilder\Interfaces\Database\InsertInterface;
use VDM\Joomla\Componentbuilder\Power\Database\Insert as ExtendingInsert;
/**
* Joomla Power Database Insert
*
* @since 3.2.1
*/
final class Insert extends ExtendingInsert implements InsertInterface
{
/**
* Table Name
*
* @var string
* @since 3.2.1
*/
protected string $table = 'power';
}

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\JoomlaPower\Database;
use VDM\Joomla\Componentbuilder\Power\Database\LoadInterface;
use VDM\Joomla\Componentbuilder\Power\Database\Load as ExtendingLoad;
/**
* Power Database Load
*
* @since 2.0.1
*/
final class Load extends ExtendingLoad implements LoadInterface
{
/**
* Table Name
*
* @var string
* @since 3.2.1
*/
protected string $table = 'joomla_power';
}

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\JoomlaPower\Database;
use VDM\Joomla\Componentbuilder\Interfaces\Database\UpdateInterface;
use VDM\Joomla\Componentbuilder\Power\Database\Update as ExtendingUpdate;
/**
* Joomla Power Database Update
*
* @since 3.2.0
*/
final class Update extends ExtendingUpdate implements UpdateInterface
{
/**
* Table Name
*
* @var string
* @since 3.2.1
*/
protected string $table = 'joomla_power';
}

View File

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

View File

@ -0,0 +1,86 @@
<?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;
use Joomla\DI\Container;
use VDM\Joomla\Componentbuilder\JoomlaPower\Service\JoomlaPower as Power;
use VDM\Joomla\Componentbuilder\Service\Database;
use VDM\Joomla\Componentbuilder\JoomlaPower\Service\Database as PowerDatabase;
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;
/**
* Joomla Power Factory
*
* @since 3.2.0
*/
abstract class Factory implements FactoryInterface
{
/**
* Global Package Container
*
* @var Container
* @since 3.2.0
**/
protected static $container = null;
/**
* Get any class from the package container
*
* @param string $key The container class key
*
* @return Mixed
* @since 3.2.0
*/
public static function _($key)
{
return self::getContainer()->get($key);
}
/**
* Get the global package container
*
* @return Container
* @since 3.2.0
*/
public static function getContainer(): Container
{
if (!self::$container)
{
self::$container = self::createContainer();
}
return self::$container;
}
/**
* Create a container object
*
* @return Container
* @since 3.2.0
*/
protected static function createContainer(): Container
{
return (new Container())
->registerServiceProvider(new Power())
->registerServiceProvider(new Database())
->registerServiceProvider(new PowerDatabase())
->registerServiceProvider(new Gitea())
->registerServiceProvider(new GiteaPower())
->registerServiceProvider(new GiteaUtilities());
}
}

View File

@ -0,0 +1,146 @@
<?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;
use VDM\Joomla\Utilities\FileHelper;
use VDM\Joomla\Utilities\JsonHelper;
use VDM\Joomla\Componentbuilder\Interfaces\GrepInterface;
use VDM\Joomla\Componentbuilder\Power\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 the [algorithm:cascading]
* See documentation for more details: https://git.vdm.dev/joomla/super-powers/wiki
*
* @since 3.2.1
*/
final class Grep extends ExtendingGrep implements GrepInterface
{
/**
* Get a local power
*
* @param object $path The repository path details
* @param string $guid The global unique id of the power
*
* @return object|null
* @since 3.2.0
*/
private function getLocal(object $path, string $guid): ?object
{
if (empty($path->local->{$guid}->settings))
{
return null;
}
// get the settings
if (($settings = FileHelper::getContent($path->full_path . '/' . $path->local->{$guid}->settings, null)) !== null &&
JsonHelper::check($settings))
{
$power = json_decode($settings);
if (isset($power->guid))
{
return $power;
}
}
return null;
}
/**
* Get a remote power
*
* @param object $path The repository path details
* @param string $guid The global unique id of the power
*
* @return object|null
* @since 3.2.0
*/
private function getRemote(object $path, string $guid): ?object
{
if (empty($path->index->{$guid}->settings))
{
return null;
}
// get the settings
if (($power = $this->loadRemoteFile($path->owner, $path->repo, $path->index->{$guid}->settings, $path->branch)) !== null &&
isset($power->guid))
{
return $power;
}
return null;
}
/**
* Load the local repository index of powers
*
* @param object $path The repository path details
*
* @return void
* @since 3.2.0
*/
private function localIndex(object &$path)
{
if (isset($path->local) || !isset($path->full_path))
{
return;
}
if (($content = FileHelper::getContent($path->full_path . '/joomla-powers.json', null)) !== null &&
JsonHelper::check($content))
{
$path->local = json_decode($content);
return;
}
$path->local = null;
}
/**
* Load the remote repository index of powers
*
* @param object $path The repository path details
*
* @return void
* @since 3.2.0
*/
private function remoteIndex(object &$path)
{
if (isset($path->index))
{
return;
}
try
{
$path->index = $this->contents->get($path->owner, $path->repo, 'joomla-powers.json', $path->branch);
}
catch (\Exception $e)
{
$this->app->enqueueMessage(
Text::sprintf('COM_COMPONENTBUILDER_PSUPER_POWERB_REPOSITORY_AT_BSSB_GAVE_THE_FOLLOWING_ERRORBR_SP', $this->contents->api(), $path->path, $e->getMessage()),
'Error'
);
$path->index = null;
}
}
}

View File

@ -0,0 +1,37 @@
<?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\Model;
use VDM\Joomla\Interfaces\ModelInterface;
use VDM\Joomla\Componentbuilder\Power\Model\Load as ExtendingLoad;
/**
* Joomla Power Model Load
*
* @since 3.2.0
*/
final class Load extends ExtendingLoad implements ModelInterface
{
/**
* Get the current active table
*
* @return string
* @since 3.2.0
*/
protected function getTable(): string
{
return 'joomla_power';
}
}

View File

@ -0,0 +1,38 @@
<?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\Model;
use VDM\Joomla\Interfaces\ModelInterface;
use VDM\Joomla\Componentbuilder\Power\Model\Upsert as ExtendingUpsert;
/**
* Joomla Power Model Update or Insert
*
* @since 3.2.0
*/
final class Upsert extends ExtendingUpsert implements ModelInterface
{
/**
* Get the current active table
*
* @return string
* @since 3.2.0
*/
protected function getTable(): string
{
return 'joomla_power';
}
}

View File

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

View File

@ -0,0 +1,135 @@
<?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\Service;
use Joomla\DI\Container;
use Joomla\DI\ServiceProviderInterface;
use VDM\Joomla\Componentbuilder\JoomlaPower\Model\Load as ModelLoad;
use VDM\Joomla\Componentbuilder\JoomlaPower\Model\Upsert as ModelUpsert;
use VDM\Joomla\Componentbuilder\JoomlaPower\Database\Load as LoadDatabase;
use VDM\Joomla\Componentbuilder\JoomlaPower\Database\Insert as InsertDatabase;
use VDM\Joomla\Componentbuilder\JoomlaPower\Database\Update as UpdateDatabase;
/**
* 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(ModelLoad::class, 'Joomla.Power.Model.Load')
->share('Joomla.Power.Model.Load', [$this, 'getModelLoad'], true);
$container->alias(ModelUpsert::class, 'Joomla.Power.Model.Upsert')
->share('Joomla.Power.Model.Upsert', [$this, 'getModelUpsert'], true);
$container->alias(LoadDatabase::class, 'Joomla.Power.Database.Load')
->share('Joomla.Power.Database.Load', [$this, 'getLoadDatabase'], true);
$container->alias(InsertDatabase::class, 'Joomla.Power.Database.Insert')
->share('Joomla.Power.Database.Insert', [$this, 'getInsertDatabase'], true);
$container->alias(UpdateDatabase::class, 'Joomla.Power.Database.Update')
->share('Joomla.Power.Database.Update', [$this, 'getUpdateDatabase'], true);
}
/**
* Get the Power Model Load
*
* @param Container $container The DI container.
*
* @return ModelLoad
* @since 3.2.0
*/
public function getModelLoad(Container $container): ModelLoad
{
return new ModelLoad(
$container->get('Table')
);
}
/**
* Get the Power Model Update or Insert
*
* @param Container $container The DI container.
*
* @return ModelUpsert
* @since 3.2.0
*/
public function getModelUpsert(Container $container): ModelUpsert
{
return new ModelUpsert(
$container->get('Table')
);
}
/**
* Get the Load Database
*
* @param Container $container The DI container.
*
* @return LoadDatabase
* @since 3.2.0
*/
public function getLoadDatabase(Container $container): LoadDatabase
{
return new LoadDatabase(
$container->get('Joomla.Power.Model.Load'),
$container->get('Load')
);
}
/**
* Get the Insert Database
*
* @param Container $container The DI container.
*
* @return InsertDatabase
* @since 3.2.0
*/
public function getInsertDatabase(Container $container): InsertDatabase
{
return new InsertDatabase(
$container->get('Joomla.Power.Model.Upsert'),
$container->get('Insert')
);
}
/**
* Get the Update Database
*
* @param Container $container The DI container.
*
* @return UpdateDatabase
* @since 3.2.0
*/
public function getUpdateDatabase(Container $container): UpdateDatabase
{
return new UpdateDatabase(
$container->get('Joomla.Power.Model.Upsert'),
$container->get('Update')
);
}
}

View File

@ -0,0 +1,130 @@
<?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\Service;
use Joomla\DI\Container;
use Joomla\DI\ServiceProviderInterface;
use VDM\Joomla\Componentbuilder\JoomlaPower\Config;
use VDM\Joomla\Componentbuilder\Table;
use VDM\Joomla\Componentbuilder\JoomlaPower\Grep;
use VDM\Joomla\Componentbuilder\JoomlaPower\Super as Superpower;
use VDM\Joomla\Componentbuilder\Compiler\Power\Parser;
/**
* Joomla Power Service Provider
*
* @since 3.2.1
*/
class JoomlaPower 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(Config::class, 'Config')
->share('Config', [$this, 'getConfig'], true);
$container->alias(Table::class, 'Table')
->share('Table', [$this, 'getTable'], true);
$container->alias(Grep::class, 'Joomla.Power.Grep')
->share('Joomla.Power.Grep', [$this, 'getGrep'], true);
$container->alias(Superpower::class, 'Joomlapower')
->share('Joomlapower', [$this, 'getSuperpower'], true);
$container->alias(Parser::class, 'Power.Parser')
->share('Power.Parser', [$this, 'getParser'], true);
}
/**
* Get The Config Class.
*
* @param Container $container The DI container.
*
* @return Config
* @since 3.2.0
*/
public function getConfig(Container $container): Config
{
return new Config();
}
/**
* Get The Table Class.
*
* @param Container $container The DI container.
*
* @return Table
* @since 3.2.0
*/
public function getTable(Container $container): Table
{
return new Table();
}
/**
* Get The Grep Class.
*
* @param Container $container The DI container.
*
* @return Grep
* @since 3.2.0
*/
public function getGrep(Container $container): Grep
{
return new Grep(
$container->get('Config')->local_joomla_powers_repository_path,
$container->get('Config')->approved_joomla_paths,
$container->get('Gitea.Repository.Contents')
);
}
/**
* Get The Super Class.
*
* @param Container $container The DI container.
*
* @return Superpower
* @since 3.2.0
*/
public function getSuperpower(Container $container): Superpower
{
return new Superpower(
$container->get('Joomla.Power.Grep'),
$container->get('Joomla.Power.Database.Insert'),
$container->get('Joomla.Power.Database.Update')
);
}
/**
* Get The Parser Class.
*
* @param Container $container The DI container.
*
* @return Parser
* @since 3.2.0
*/
public function getParser(Container $container): Parser
{
return new Parser();
}
}

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\JoomlaPower;
use VDM\Joomla\Componentbuilder\Interfaces\SuperInterface;
use VDM\Joomla\Componentbuilder\Power\Super as ExtendingSuper;
/**
* Super Joomla Power of JCB
*
* @since 3.2.0
*/
final class Super extends ExtendingSuper implements SuperInterface
{
/**
* Table Name
*
* @var string
* @since 3.2.1
*/
protected string $table = 'joomla_power';
}

View File

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

View File

@ -12,8 +12,9 @@
namespace VDM\Joomla\Componentbuilder\Power\Database;
use VDM\Joomla\Componentbuilder\Power\Model\Upsert as Model;
use VDM\Joomla\Interfaces\ModelInterface as Model;
use VDM\Joomla\Database\Insert as Database;
use VDM\Joomla\Componentbuilder\Interfaces\Database\InsertInterface;
/**
@ -21,7 +22,7 @@ use VDM\Joomla\Database\Insert as Database;
*
* @since 3.2.0
*/
final class Insert
class Insert implements InsertInterface
{
/**
* Model
@ -39,6 +40,14 @@ final class Insert
*/
protected Database $database;
/**
* Table Name
*
* @var string
* @since 3.2.1
*/
protected string $table = 'power';
/**
* Constructor
*
@ -88,10 +97,10 @@ final class Insert
public function row(array $item): bool
{
// check if object could be modelled
if (($item = $this->model->row($item, 'power')) !== null)
if (($item = $this->model->row($item, $this->table)) !== null)
{
// Insert the column of this table
return $this->database->row($item, 'power');
return $this->database->row($item, $this->table);
}
return false;
}
@ -108,10 +117,10 @@ final class Insert
public function rows(?array $items): bool
{
// check if object could be modelled
if (($items = $this->model->rows($items, 'power')) !== null)
if (($items = $this->model->rows($items, $this->table)) !== null)
{
// Insert the column of this table
return $this->database->rows($items, 'power');
return $this->database->rows($items, $this->table);
}
return false;
}
@ -128,10 +137,10 @@ final class Insert
public function item(object $item): bool
{
// check if object could be modelled
if (($item = $this->model->item($item, 'power')) !== null)
if (($item = $this->model->item($item, $this->table)) !== null)
{
// Insert the column of this table
return $this->database->item($item, 'power');
return $this->database->item($item, $this->table);
}
return false;
}
@ -148,13 +157,12 @@ final class Insert
public function items(?array $items): bool
{
// check if object could be modelled
if (($items = $this->model->items($items, 'power')) !== null)
if (($items = $this->model->items($items, $this->table)) !== null)
{
// Update the column of this table using guid as the primary key.
return $this->database->items($items, 'power');
return $this->database->items($items, $this->table);
}
return false;
}
}
}

View File

@ -12,8 +12,9 @@
namespace VDM\Joomla\Componentbuilder\Power\Database;
use VDM\Joomla\Componentbuilder\Power\Model\Load as Model;
use VDM\Joomla\Interfaces\ModelInterface as Model;
use VDM\Joomla\Database\Load as Database;
use VDM\Joomla\Componentbuilder\Power\Database\LoadInterface;
/**
@ -21,7 +22,7 @@ use VDM\Joomla\Database\Load as Database;
*
* @since 2.0.1
*/
final class Load
class Load implements LoadInterface
{
/**
* Model Load
@ -39,6 +40,14 @@ final class Load
*/
protected Database $load;
/**
* Table Name
*
* @var string
* @since 3.2.1
*/
protected string $table = 'power';
/**
* Constructor
*
@ -74,11 +83,11 @@ final class Load
return $this->model->value(
$this->load->value(
["a.{$field}" => $field],
['a' => 'power'],
['a' => $this->table],
$this->prefix($keys)
),
$field,
'power'
$this->table
);
}
@ -101,10 +110,10 @@ final class Load
return $this->model->item(
$this->load->item(
['all' => 'a.*'],
['a' => 'power'],
['a' => $this->table],
$this->prefix($keys)
),
'power'
$this->table
);
}
@ -130,9 +139,9 @@ final class Load
{
return $this->model->items(
$this->load->items(
['all' => 'a.*'], ['a' => 'power'], $this->prefix($keys)
['all' => 'a.*'], ['a' => $this->table], $this->prefix($keys)
),
'power'
$this->table
);
}

View File

@ -0,0 +1,75 @@
<?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\Power\Database;
/**
* Power Database Load
*
* @since 2.0.1
*/
interface LoadInterface
{
/**
* Get a value from a given table
* Example: $this->value(
* [
* 'guid' => 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'
* ], 'value_key'
* );
*
* @param array $keys The item keys
* @param string $field The field key
* @param string $table The table
*
* @return mixed
* @since 2.0.1
*/
public function value(array $keys, string $field);
/**
* Get values from a given table
* Example: $this->item(
* [
* 'guid' => 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'
* ]
* );
*
* @param array $keys The item keys
* @param string $table The table
*
* @return object|null
* @since 2.0.1
*/
public function item(array $keys): ?object;
/**
* Get values from a given table
* Example: $this->items(
* [
* 'guid' => [
* 'operator' => 'IN',
* 'value' => [''xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'', ''xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'']
* ]
* ]
* );
* Example: $this->items($ids, 'table_name');
*
* @param array $keys The item keys
* @param string $table The table
*
* @return array|null
* @since 2.0.1
*/
public function items(array $keys): ?array;
}

View File

@ -12,8 +12,9 @@
namespace VDM\Joomla\Componentbuilder\Power\Database;
use VDM\Joomla\Componentbuilder\Power\Model\Upsert as Model;
use VDM\Joomla\Interfaces\ModelInterface as Model;
use VDM\Joomla\Database\Update as Database;
use VDM\Joomla\Componentbuilder\Interfaces\Database\UpdateInterface;
/**
@ -21,7 +22,7 @@ use VDM\Joomla\Database\Update as Database;
*
* @since 3.2.0
*/
final class Update
class Update implements UpdateInterface
{
/**
* Model
@ -39,6 +40,14 @@ final class Update
*/
protected Database $database;
/**
* Table Name
*
* @var string
* @since 3.2.1
*/
protected string $table = 'power';
/**
* Constructor
*
@ -88,10 +97,10 @@ final class Update
public function row(array $item): bool
{
// check if object could be modelled
if (($item = $this->model->row($item, 'power')) !== null)
if (($item = $this->model->row($item, $this->table)) !== null)
{
// Update the column of this table using guid as the primary key.
return $this->database->row($item, 'guid', 'power');
return $this->database->row($item, 'guid', $this->table);
}
return false;
}
@ -108,10 +117,10 @@ final class Update
public function rows(?array $items): bool
{
// check if object could be modelled
if (($items = $this->model->rows($items, 'power')) !== null)
if (($items = $this->model->rows($items, $this->table)) !== null)
{
// Update the column of this table using guid as the primary key.
return $this->database->rows($items, 'guid', 'power');
return $this->database->rows($items, 'guid', $this->table);
}
return false;
}
@ -128,10 +137,10 @@ final class Update
public function item(object $item): bool
{
// check if object could be modelled
if (($item = $this->model->item($item, 'power')) !== null)
if (($item = $this->model->item($item, $this->table)) !== null)
{
// Update the column of this table using guid as the primary key.
return $this->database->item($item, 'guid', 'power');
return $this->database->item($item, 'guid', $this->table);
}
return false;
}
@ -148,10 +157,10 @@ final class Update
public function items(?array $items): bool
{
// check if object could be modelled
if (($items = $this->model->items($items, 'power')) !== null)
if (($items = $this->model->items($items, $this->table)) !== null)
{
// Update the column of this table using guid as the primary key.
return $this->database->items($items, 'guid', 'power');
return $this->database->items($items, 'guid', $this->table);
}
return false;
}

View File

@ -19,6 +19,7 @@ use Joomla\CMS\Language\Text;
use VDM\Joomla\Gitea\Repository\Contents;
use VDM\Joomla\Utilities\FileHelper;
use VDM\Joomla\Utilities\JsonHelper;
use VDM\Joomla\Componentbuilder\Interfaces\GrepInterface;
/**
@ -31,7 +32,7 @@ use VDM\Joomla\Utilities\JsonHelper;
*
* @since 3.2.0
*/
final class Grep
class Grep implements GrepInterface
{
/**
* The local path

View File

@ -24,7 +24,7 @@ use VDM\Joomla\Interfaces\ModelInterface;
*
* @since 3.2.0
*/
final class Load extends AbstractionModel implements ModelInterface
class Load extends AbstractionModel implements ModelInterface
{
/**
* Model the value

View File

@ -12,11 +12,11 @@
namespace VDM\Joomla\Componentbuilder\Power\Model;
use VDM\Joomla\Abstraction\Model as AbstractionModel;
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Utilities\ObjectHelper;
use VDM\Joomla\Interfaces\ModelInterface;
use VDM\Joomla\Abstraction\Model;
/**
@ -24,7 +24,7 @@ use VDM\Joomla\Interfaces\ModelInterface;
*
* @since 3.2.0
*/
final class Upsert extends AbstractionModel implements ModelInterface
class Upsert extends Model implements ModelInterface
{
/**
* Model the value

View File

@ -12,9 +12,9 @@
namespace VDM\Joomla\Componentbuilder\Power;
use VDM\Joomla\Componentbuilder\Power\Grep;
use VDM\Joomla\Componentbuilder\Power\Database\Insert;
use VDM\Joomla\Componentbuilder\Power\Database\Update;
use VDM\Joomla\Componentbuilder\Interfaces\GrepInterface as Grep;
use VDM\Joomla\Componentbuilder\Interfaces\Database\InsertInterface as Insert;
use VDM\Joomla\Componentbuilder\Interfaces\Database\UpdateInterface as Update;
use VDM\Joomla\Utilities\GuidHelper;
@ -23,7 +23,7 @@ use VDM\Joomla\Utilities\GuidHelper;
*
* @since 3.2.0
*/
final class Super
class Super
{
/**
* The Power Search Tool
@ -49,6 +49,14 @@ final class Super
**/
protected Update $update;
/**
* Table Name
*
* @var string
* @since 3.2.1
*/
protected string $table = 'power';
/**
* Constructor.
*
@ -174,7 +182,7 @@ final class Super
*/
private function action(string $guid): string
{
if (($id = GuidHelper::item($guid, 'power')) !== null && $id > 0)
if (($id = GuidHelper::item($guid, $this->table)) !== null && $id > 0)
{
return 'update';
}

View File

@ -1638,6 +1638,44 @@ class Table extends BaseTable implements Tableinterface
'tab_name' => 'Code',
],
],
'joomla_power' => [
'system_name' => [
'name' => 'system_name',
'label' => 'COM_COMPONENTBUILDER_JOOMLA_POWER_SYSTEM_NAME_LABEL',
'type' => 'text',
'title' => true,
'list' => 'joomla_powers',
'store' => NULL,
'tab_name' => 'Joomla Power',
],
'settings' => [
'name' => 'settings',
'label' => 'COM_COMPONENTBUILDER_JOOMLA_POWER_SETTINGS_LABEL',
'type' => 'subform',
'title' => false,
'list' => 'joomla_powers',
'store' => 'json',
'tab_name' => 'Joomla Power',
],
'guid' => [
'name' => 'guid',
'label' => 'COM_COMPONENTBUILDER_JOOMLA_POWER_GUID_LABEL',
'type' => 'text',
'title' => false,
'list' => 'joomla_powers',
'store' => NULL,
'tab_name' => 'publishing',
],
'description' => [
'name' => 'description',
'label' => 'COM_COMPONENTBUILDER_JOOMLA_POWER_DESCRIPTION_LABEL',
'type' => 'textarea',
'title' => false,
'list' => 'joomla_powers',
'store' => NULL,
'tab_name' => 'Joomla Power',
],
],
'power' => [
'system_name' => [
'name' => 'system_name',