update 2023-10-24 10:36:32

This commit is contained in:
Robot 2023-10-24 10:36:39 +02:00
parent 1ba2cdbd9d
commit 3e3cd1e212
Signed by: Robot
GPG Key ID: 14DECD44E7E1BB95
38 changed files with 4094 additions and 2434 deletions

View File

@ -109,8 +109,8 @@ class Power implements ServiceProviderInterface
{
return new Superpower(
$container->get('Power.Grep'),
$container->get('Power.Insert'),
$container->get('Power.Update')
$container->get('Power.Database.Insert'),
$container->get('Power.Database.Update')
);
}

View File

@ -79,8 +79,8 @@
{
return new Superpower(
$container->get('Power.Grep'),
$container->get('Power.Insert'),
$container->get('Power.Update')
$container->get('Power.Database.Insert'),
$container->get('Power.Database.Update')
);
}

View File

@ -16,36 +16,55 @@ class Structure #Gold {
# Config $config
# Registry $registry
# Dispenser $dispenser
# EventInterface $event
# Event $event
# Counter $counter
# Folder $folder
# File $file
# Files $files
+ __construct(?Module $module = null, ?Component $component = null, ...)
# TemplateData $templatedata
+ __construct(Module $module, Component $component, ...)
+ build() : void
# getXML(object $module) : string
# getCustomScriptField(array $fieldScriptBucket) : string
# modulePath(object $module) : void
# setMainModFile(object $module) : void
# setCustomGet(object $module) : void
# setHelperFile(object $module) : void
# setMainXmlFile(object $module) : void
# setDefaultFile(object $module) : void
# setTemplateFiles(object $module) : void
# setInstallScript(object $module) : void
# setReadme(object $module) : void
# setCssJsForm(object $module) : void
# setCssForm(object $module, string $targetPath, ...) : void
# setJsForm(object $module, string $targetPath, ...) : void
# setForms(object $module) : void
# setSQL(object $module) : void
# setFiles(object $module) : void
# setFolders(object $module) : void
# setUrls(object $module) : void
}
note right of Structure::__construct
Constructor
Constructor.
since: 3.2.0
arguments:
?Module $module = null
?Component $component = null
?Config $config = null
?Registry $registry = null
?Dispenser $dispenser = null
?EventInterface $event = null
?Counter $counter = null
?Folder $folder = null
?File $file = null
?Files $files = null
Module $module
Component $component
Config $config
Registry $registry
Dispenser $dispenser
Event $event
Counter $counter
Folder $folder
File $file
Files $files
TemplateData $templatedata
end note
note right of Structure::build
note left of Structure::build
Build the Modules files, folders, url's and config
since: 3.2.0
@ -59,13 +78,142 @@ note right of Structure::getXML
return: string
end note
note right of Structure::getCustomScriptField
note left of Structure::getCustomScriptField
get the module admin custom script field
since: 3.2.0
return: string
end note
note right of Structure::modulePath
Set the module path
since: 3.2.0
return: void
end note
note left of Structure::setMainModFile
Set the main module file
since: 3.2.0
return: void
end note
note right of Structure::setCustomGet
Set the custom get file
since: 3.2.0
return: void
end note
note left of Structure::setHelperFile
Set the helper file
since: 3.2.0
return: void
end note
note right of Structure::setMainXmlFile
Set the main XML file
since: 3.2.0
return: void
end note
note left of Structure::setDefaultFile
Set the main default template file
since: 3.2.0
return: void
end note
note right of Structure::setTemplateFiles
Set the additional template files
since: 3.2.0
return: void
end note
note left of Structure::setInstallScript
Set the install script file
since: 3.2.0
return: void
end note
note right of Structure::setReadme
Set the readme file
since: 3.2.0
return: void
end note
note left of Structure::setCssJsForm
Set the css and javascript in form
since: 3.2.0
return: void
end note
note right of Structure::setCssForm
Set the css in form
since: 3.2.0
return: void
arguments:
object $module
string $targetPath
array $bucket
end note
note left of Structure::setJsForm
Set the javascript in form
since: 3.2.0
return: void
arguments:
object $module
string $targetPath
array $bucket
end note
note right of Structure::setForms
Set the form folders and files as needed
since: 3.2.0
return: void
end note
note left of Structure::setSQL
Set the sql stuff
since: 3.2.0
return: void
end note
note right of Structure::setFiles
Set the files
since: 3.2.0
return: void
end note
note left of Structure::setFolders
Set the folders
since: 3.2.0
return: void
end note
note right of Structure::setUrls
Set the urls
since: 3.2.0
return: void
end note
@enduml
```

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -11,61 +11,61 @@
"type": "class",
"use_selection": {
"use_selection0": {
"use": "d910d8b8-4c23-4f3e-8cda-438f2d2bd7ac",
"as": "Compiler"
},
"use_selection1": {
"use": "cb11e8d9-69c2-4095-831c-59908ea402e7",
"as": "Module"
},
"use_selection2": {
"use_selection1": {
"use": "e2472b22-a329-44d8-b4a2-ae3ba99e17a0",
"as": "default"
},
"use_selection3": {
"use_selection2": {
"use": "fa4bf18e-301e-42e3-91fb-6e0096c07adc",
"as": "default"
},
"use_selection4": {
"use_selection3": {
"use": "e5d9804f-0eb0-4ee9-b406-ad4e8cdbc1f6",
"as": "default"
},
"use_selection5": {
"use_selection4": {
"use": "f1dc6430-fb54-452e-aa53-ce32ae93db88",
"as": "default"
},
"use_selection6": {
"use_selection5": {
"use": "20ed72b0-fcac-4344-aee1-8a65e3bf221d",
"as": "default"
"as": "Event"
},
"use_selection7": {
"use_selection6": {
"use": "e6d871a6-bbe7-497d-af01-68f6bb9a87f4",
"as": "default"
},
"use_selection8": {
"use_selection7": {
"use": "6bbb6ffe-3f09-4c21-aa9d-c93159afa1e1",
"as": "default"
},
"use_selection9": {
"use_selection8": {
"use": "5c75b455-3d4c-452a-867e-e90424a64c88",
"as": "default"
},
"use_selection10": {
"use_selection9": {
"use": "1d967151-7c20-4ca7-9400-65233cdcd4db",
"as": "default"
},
"use_selection11": {
"use_selection10": {
"use": "a68c010b-e92e-47d5-8a44-d23cfddeb6c6",
"as": "default"
},
"use_selection12": {
"use_selection11": {
"use": "500f3a7f-c16d-4dd4-81b2-2df6776b5388",
"as": "default"
},
"use_selection13": {
"use_selection12": {
"use": "4e6ff11d-bebf-42f5-8fd7-b2f882857222",
"as": "default"
},
"use_selection13": {
"use": "8591f6db-dd3c-4a63-9b3f-574c0ec74ade",
"as": "default"
},
"use_selection14": {
"use": "0a59c65c-9daf-4bc9-baf4-e063ff9e6a8a",
"as": "default"

View File

@ -24,14 +24,14 @@ note right of Joomlamodule::register
end note
note right of Joomlamodule::getData
Get the Joomla Module Data
Get The Data Class.
since: 3.2.0
return: Data
end note
note right of Joomlamodule::getStructure
Get the Joomla Module Structure Builder
Get The Structure Class.
since: 3.2.0
return: Structure

View File

@ -43,7 +43,7 @@ class Joomlamodule implements ServiceProviderInterface
}
/**
* Get the Joomla Module Data
* Get The Data Class.
*
* @param Container $container The DI container.
*
@ -62,12 +62,13 @@ class Joomlamodule implements ServiceProviderInterface
$container->get('Field.Name'),
$container->get('Model.Filesfolders'),
$container->get('Model.Libraries'),
$container->get('Dynamicget.Data')
$container->get('Dynamicget.Data'),
$container->get('Templatelayout.Data')
);
}
/**
* Get the Joomla Module Structure Builder
* Get The Structure Class.
*
* @param Container $container The DI container.
*
@ -86,9 +87,9 @@ class Joomlamodule implements ServiceProviderInterface
$container->get('Utilities.Counter'),
$container->get('Utilities.Folder'),
$container->get('Utilities.File'),
$container->get('Utilities.Files')
$container->get('Utilities.Files'),
$container->get('Compiler.Builder.Template.Data')
);
}
}

View File

@ -16,7 +16,7 @@
}
/**
* Get the Joomla Module Data
* Get The Data Class.
*
* @param Container $container The DI container.
*
@ -35,12 +35,13 @@
$container->get('Field.Name'),
$container->get('Model.Filesfolders'),
$container->get('Model.Libraries'),
$container->get('Dynamicget.Data')
$container->get('Dynamicget.Data'),
$container->get('Templatelayout.Data')
);
}
/**
* Get the Joomla Module Structure Builder
* Get The Structure Class.
*
* @param Container $container The DI container.
*
@ -59,6 +60,7 @@
$container->get('Utilities.Counter'),
$container->get('Utilities.Folder'),
$container->get('Utilities.File'),
$container->get('Utilities.Files')
$container->get('Utilities.Files'),
$container->get('Compiler.Builder.Template.Data')
);
}

View File

@ -15,6 +15,8 @@ class Super << (F,LightGreen) >> #RoyalBlue {
# Insert $insert
# Update $update
+ __construct(Grep $grep, Insert $insert, ...)
+ init() : bool
+ reset(array $powers) : bool
+ load(string $guid, array $order = ['remote', 'local'], ...) : bool
- insert(object $power) : bool
- update(object $power) : bool
@ -32,6 +34,20 @@ note right of Super::__construct
Update $update
end note
note right of Super::init
Init all power not found in database
since: 3.2.0
return: bool
end note
note right of Super::reset
Reset the powers
since: 3.2.0
return: bool
end note
note right of Super::load
Load a superpower

View File

@ -65,6 +65,58 @@ final class Super
$this->update = $update;
}
/**
* Init all power not found in database
*
* @return bool
* @since 3.2.0
*/
public function init(): bool
{
if (($powers = $this->grep->getRemotePowersGuid()) !== null)
{
foreach($powers as $guid)
{
if ($this->action($guid) === 'insert' && ($power = $this->grep->get($guid, ['remote'])) !== null)
{
$this->insert($power);
}
}
return true;
}
return false;
}
/**
* 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
{
if ($powers === [])
{
return false;
}
$success = true;
foreach($powers as $guid)
{
if (!$this->load($guid, ['remote']))
{
$success = false;
}
}
return $success;
}
/**
* Load a superpower
*

View File

@ -38,6 +38,58 @@
$this->update = $update;
}
/**
* Init all power not found in database
*
* @return bool
* @since 3.2.0
*/
public function init(): bool
{
if (($powers = $this->grep->getRemotePowersGuid()) !== null)
{
foreach($powers as $guid)
{
if ($this->action($guid) === 'insert' && ($power = $this->grep->get($guid, ['remote'])) !== null)
{
$this->insert($power);
}
}
return true;
}
return false;
}
/**
* 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
{
if ($powers === [])
{
return false;
}
$success = true;
foreach($powers as $guid)
{
if (!$this->load($guid, ['remote']))
{
$success = false;
}
}
return $success;
}
/**
* Load a superpower
*

View File

@ -10,15 +10,15 @@
"system_name": "JCB.Power.Super",
"type": "final class",
"use_selection": {
"use_selection2": {
"use_selection0": {
"use": "6784dd52-0909-451a-a872-9a942a023c68",
"as": "default"
},
"use_selection0": {
"use_selection1": {
"use": "380bb7a3-cdcc-4336-a699-5070cbf521a5",
"as": "default"
},
"use_selection1": {
"use_selection2": {
"use": "e543c123-b1d9-4a0b-83b2-a9d371da5ff3",
"as": "default"
},

View File

@ -33,12 +33,18 @@ class Createdate
*/
public function get(&$item): string
{
if (isset($item['settings']->created)
if (is_array($item) && isset($item['settings']) && isset($item['settings']->created)
&& StringHelper::check($item['settings']->created))
{
// first set the main date
$date = strtotime((string) $item['settings']->created);
}
elseif (is_object($item) && isset($item->created)
&& StringHelper::check($item->created))
{
// first set the main date
$date = strtotime((string) $item->created);
}
else
{
// first set the main date

View File

@ -8,12 +8,18 @@
*/
public function get(&$item): string
{
if (isset($item['settings']->created)
if (is_array($item) && isset($item['settings']) && isset($item['settings']->created)
&& StringHelper::check($item['settings']->created))
{
// first set the main date
$date = strtotime((string) $item['settings']->created);
}
elseif (is_object($item) && isset($item->created)
&& StringHelper::check($item->created))
{
// first set the main date
$date = strtotime((string) $item->created);
}
else
{
// first set the main date

View File

@ -16,6 +16,7 @@ class Grep << (F,LightGreen) >> #RoyalBlue {
# Contents $contents
# CMSApplication $app
+ __construct(string $path, array $paths, ...)
+ getRemotePowersGuid() : ?array
+ get(string $guid, array $order = ['local', 'remote']) : ?object
- searchLocal(string $guid) : ?object
- searchRemote(string $guid) : ?object
@ -40,63 +41,70 @@ note right of Grep::__construct
?CMSApplication $app = null
end note
note left of Grep::get
note left of Grep::getRemotePowersGuid
Get all remote powers GUID's
since: 3.2.0
return: ?array
end note
note right of Grep::get
Get a power
since: 3.2.0
return: ?object
end note
note right of Grep::searchLocal
note left of Grep::searchLocal
Search for a local power
since: 3.2.0
return: ?object
end note
note left of Grep::searchRemote
note right of Grep::searchRemote
Search for a remote power
since: 3.2.0
return: ?object
end note
note right of Grep::getLocal
note left of Grep::getLocal
Get a local power
since: 3.2.0
return: ?object
end note
note left of Grep::getRemote
note right of Grep::getRemote
Get a remote power
since: 3.2.0
return: ?object
end note
note right of Grep::init
note left of Grep::init
Set path details
since: 3.2.0
return: void
end note
note left of Grep::localIndex
note right of Grep::localIndex
Load the local repository index of powers
since: 3.2.0
return: void
end note
note right of Grep::remoteIndex
note left of Grep::remoteIndex
Load the remote repository index of powers
since: 3.2.0
return: void
end note
note left of Grep::loadRemoteFile
note right of Grep::loadRemoteFile
Load the remote file
since: 3.2.0
@ -109,7 +117,7 @@ note left of Grep::loadRemoteFile
?string $branch
end note
note right of Grep::getFunctionName
note left of Grep::getFunctionName
Get function name
since: 3.2.0

View File

@ -86,6 +86,34 @@ final class Grep
$this->init();
}
/**
* Get all remote powers GUID's
*
* @return array|null
* @since 3.2.0
*/
public function getRemotePowersGuid(): ?array
{
if (!is_array($this->paths) || $this->paths === [])
{
return null;
}
$powers = [];
foreach ($this->paths as $path)
{
// Get local index
$this->remoteIndex($path);
if (isset($path->index) && is_object($path->index))
{
$powers = array_merge($powers, array_keys((array) $path->index));
}
}
return empty($powers) ? null : array_unique($powers);
}
/**
* Get a power
*
@ -316,10 +344,10 @@ final class Grep
{
$path->index = $this->contents->get($path->owner, $path->repo, 'super-powers.json', $path->branch);
}
catch (\DomainException $e)
catch (\Exception $e)
{
$this->app->enqueueMessage(
Text::sprintf('COM_COMPONENTBUILDER_PSUPER_POWERB_REPOSITORY_AT_BGITVDMDEVSB_GAVE_THE_FOLLOWING_ERRORBR_SP', $path->path, $e->getMessage()),
Text::sprintf('COM_COMPONENTBUILDER_PSUPER_POWERB_REPOSITORY_AT_BSSB_GAVE_THE_FOLLOWING_ERRORBR_SP', $this->contents->api(), $path->path, $e->getMessage()),
'Error'
);
@ -344,10 +372,10 @@ final class Grep
{
$data = $this->contents->get($owner, $repo, $path, $branch);
}
catch (\DomainException $e)
catch (\Exception $e)
{
$this->app->enqueueMessage(
Text::sprintf('COM_COMPONENTBUILDER_PFILE_AT_BGITEAREMOTESB_GAVE_THE_FOLLOWING_ERRORBR_SP', $path, $e->getMessage()),
Text::sprintf('COM_COMPONENTBUILDER_PFILE_AT_BSSB_GAVE_THE_FOLLOWING_ERRORBR_SP', $this->contents->api(), $path, $e->getMessage()),
'Error'
);

View File

@ -51,6 +51,34 @@
$this->init();
}
/**
* Get all remote powers GUID's
*
* @return array|null
* @since 3.2.0
*/
public function getRemotePowersGuid(): ?array
{
if (!is_array($this->paths) || $this->paths === [])
{
return null;
}
$powers = [];
foreach ($this->paths as $path)
{
// Get local index
$this->remoteIndex($path);
if (isset($path->index) && is_object($path->index))
{
$powers = array_merge($powers, array_keys((array) $path->index));
}
}
return empty($powers) ? null : array_unique($powers);
}
/**
* Get a power
*
@ -281,10 +309,10 @@
{
$path->index = $this->contents->get($path->owner, $path->repo, 'super-powers.json', $path->branch);
}
catch (\DomainException $e)
catch (\Exception $e)
{
$this->app->enqueueMessage(
Text::sprintf('<p>Super Power</b> repository at <b>git.vdm.dev/%s</b> gave the following error!<br />%s</p>', $path->path, $e->getMessage()),
Text::sprintf('<p>Super Power</b> repository at <b>%s/%s</b> gave the following error!<br />%s</p>', $this->contents->api(), $path->path, $e->getMessage()),
'Error'
);
@ -309,10 +337,10 @@
{
$data = $this->contents->get($owner, $repo, $path, $branch);
}
catch (\DomainException $e)
catch (\Exception $e)
{
$this->app->enqueueMessage(
Text::sprintf('<p>File at <b>gitea.remote/%s</b> gave the following error!<br />%s</p>', $path, $e->getMessage()),
Text::sprintf('<p>File at <b>%s/%s</b> gave the following error!<br />%s</p>', $this->contents->api(), $path, $e->getMessage()),
'Error'
);

View File

@ -12,7 +12,7 @@
@startuml
interface Cryptinterface #Lavender {
+ encrypt(string $string, string $key) : string
+ decrypt(string $string, string $key) : string
+ decrypt(string $string, string $key) : ?string
}
note right of Cryptinterface::encrypt
@ -26,7 +26,7 @@ note right of Cryptinterface::decrypt
Decrypt a string as needed
since: 3.2.0
return: string
return: ?string
end note
@enduml

View File

@ -34,10 +34,10 @@ interface Cryptinterface
* @param string $string The string to decrypt
* @param string $key The decryption key
*
* @return string
* @return string|null
* @since 3.2.0
**/
public function decrypt(string $string, string $key): string;
public function decrypt(string $string, string $key): ?string;
}

View File

@ -15,7 +15,7 @@
* @param string $string The string to decrypt
* @param string $key The decryption key
*
* @return string
* @return string|null
* @since 3.2.0
**/
public function decrypt(string $string, string $key): string;
public function decrypt(string $string, string $key): ?string;

View File

@ -13,9 +13,11 @@
class Modifieddate #Gold {
# array $last
+ get(array $item) : string
# getDate(array $item) : int
# getModified(array $item) : int
# getKey(array $item) : string
# getDate(array|object $item) : int
# getModified(array|object $item) : int
# getKey(array|object $item) : string
# getKeyFromArray(array $item) : string
# getKeyFromObject(object $item) : string
}
note right of Modifieddate::get
@ -46,6 +48,20 @@ note right of Modifieddate::getKey
return: string
end note
note right of Modifieddate::getKeyFromArray
Get the key for an item (array)
since: 3.2.0
return: string
end note
note right of Modifieddate::getKeyFromObject
Get the key for an item (object)
since: 3.2.0
return: string
end note
@enduml
```

View File

@ -60,19 +60,25 @@ class Modifieddate
/**
* Get the last modified date of an item
*
* @param array $item The item data
* @param array|object $item The item data
*
* @return int The modified date as int
* @since 3.2.0
*/
protected function getDate(array $item): int
protected function getDate($item): int
{
if (isset($item['settings']) && isset($item['settings']->modified)
if (is_array($item) && isset($item['settings']) && isset($item['settings']->modified)
&& StringHelper::check($item['settings']->modified)
&& '0000-00-00 00:00:00' !== $item['settings']->modified)
{
return strtotime((string) $item['settings']->modified);
}
elseif (is_object($item) && isset($item->modified)
&& StringHelper::check($item->modified)
&& '0000-00-00 00:00:00' !== $item->modified)
{
return strtotime((string) $item->modified);
}
return strtotime("now");
}
@ -80,17 +86,17 @@ class Modifieddate
/**
* Get the last modified date of an item's sub items
*
* @param array $item The item data
* @param array|object $item The item data
*
* @return int The modified date as int
* @since 3.2.0
*/
protected function getModified(array $item): int
protected function getModified($item): int
{
$date = 0;
// if not settings is found
if (!isset($item['settings']) || !ObjectHelper::check($item['settings']))
if (!is_array($item) || !isset($item['settings']) || !ObjectHelper::check($item['settings']))
{
return $date;
}
@ -128,12 +134,34 @@ class Modifieddate
/**
* Get the key for an item
*
* @param array|object $item The item data
*
* @return string The key
* @since 3.2.0
*/
protected function getKey($item): string
{
if (is_array($item))
{
return $this->getKeyFromArray($item);
}
elseif (is_object($item))
{
return $this->getKeyFromObject($item);
}
return 'error';
}
/**
* Get the key for an item (array)
*
* @param array $item The item data
*
* @return string The key
* @since 3.2.0
*/
protected function getKey(array $item): string
protected function getKeyFromArray(array $item): string
{
if (isset($item['adminview']))
{
@ -151,5 +179,22 @@ class Modifieddate
return 'error';
}
/**
* Get the key for an item (object)
*
* @param object $item The item data
*
* @return string The key
* @since 3.2.0
*/
protected function getKeyFromObject(object $item): string
{
if (isset($item->key))
{
return $item->key;
}
return 'error';
}
}

View File

@ -33,19 +33,25 @@
/**
* Get the last modified date of an item
*
* @param array $item The item data
* @param array|object $item The item data
*
* @return int The modified date as int
* @since 3.2.0
*/
protected function getDate(array $item): int
protected function getDate($item): int
{
if (isset($item['settings']) && isset($item['settings']->modified)
if (is_array($item) && isset($item['settings']) && isset($item['settings']->modified)
&& StringHelper::check($item['settings']->modified)
&& '0000-00-00 00:00:00' !== $item['settings']->modified)
{
return strtotime((string) $item['settings']->modified);
}
elseif (is_object($item) && isset($item->modified)
&& StringHelper::check($item->modified)
&& '0000-00-00 00:00:00' !== $item->modified)
{
return strtotime((string) $item->modified);
}
return strtotime("now");
}
@ -53,17 +59,17 @@
/**
* Get the last modified date of an item's sub items
*
* @param array $item The item data
* @param array|object $item The item data
*
* @return int The modified date as int
* @since 3.2.0
*/
protected function getModified(array $item): int
protected function getModified($item): int
{
$date = 0;
// if not settings is found
if (!isset($item['settings']) || !ObjectHelper::check($item['settings']))
if (!is_array($item) || !isset($item['settings']) || !ObjectHelper::check($item['settings']))
{
return $date;
}
@ -101,12 +107,34 @@
/**
* Get the key for an item
*
* @param array|object $item The item data
*
* @return string The key
* @since 3.2.0
*/
protected function getKey($item): string
{
if (is_array($item))
{
return $this->getKeyFromArray($item);
}
elseif (is_object($item))
{
return $this->getKeyFromObject($item);
}
return 'error';
}
/**
* Get the key for an item (array)
*
* @param array $item The item data
*
* @return string The key
* @since 3.2.0
*/
protected function getKey(array $item): string
protected function getKeyFromArray(array $item): string
{
if (isset($item['adminview']))
{
@ -123,3 +151,21 @@
return 'error';
}
/**
* Get the key for an item (object)
*
* @param object $item The item data
*
* @return string The key
* @since 3.2.0
*/
protected function getKeyFromObject(object $item): string
{
if (isset($item->key))
{
return $item->key;
}
return 'error';
}

View File

@ -16,35 +16,45 @@ class Structure #Gold {
# Config $config
# Registry $registry
# Dispenser $dispenser
# EventInterface $event
# Event $event
# Counter $counter
# Folder $folder
# File $file
# Files $files
+ __construct(?Plugin $plugin = null, ?Component $component = null, ...)
+ __construct(Plugin $plugin, Component $component, ...)
+ build() : void
# getXML($plugin) : string
# getXML(object $plugin) : string
# pluginPath(object $plugin) : void
# setMainClassFile(object $plugin) : void
# setMainXmlFile(mixed $plugin) : void
# setInstallScript(object $plugin) : void
# setReadme(object $plugin) : void
# setForms(object $plugin) : void
# setSQL(object $plugin) : void
# setFiles(object $plugin) : void
# setFolders(object $plugin) : void
# setUrls(object $plugin) : void
}
note right of Structure::__construct
Constructor
Constructor.
since: 3.2.0
arguments:
?Plugin $plugin = null
?Component $component = null
?Config $config = null
?Registry $registry = null
?Dispenser $dispenser = null
?EventInterface $event = null
?Counter $counter = null
?Folder $folder = null
?File $file = null
?Files $files = null
Plugin $plugin
Component $component
Config $config
Registry $registry
Dispenser $dispenser
Event $event
Counter $counter
Folder $folder
File $file
Files $files
end note
note right of Structure::build
note left of Structure::build
Build the Plugins files, folders, url's and config
since: 3.2.0
@ -58,6 +68,76 @@ note right of Structure::getXML
return: string
end note
note left of Structure::pluginPath
set the plugin path
since: 3.2.0
return: void
end note
note right of Structure::setMainClassFile
set the main class path
since: 3.2.0
return: void
end note
note left of Structure::setMainXmlFile
set the main xml file
since: 3.2.0
return: void
end note
note right of Structure::setInstallScript
set the install script file
since: 3.2.0
return: void
end note
note left of Structure::setReadme
set the readme file
since: 3.2.0
return: void
end note
note right of Structure::setForms
set the form files and folders
since: 3.2.0
return: void
end note
note left of Structure::setSQL
set the sql stuff
since: 3.2.0
return: void
end note
note right of Structure::setFiles
set the files
since: 3.2.0
return: void
end note
note left of Structure::setFolders
set the folders
since: 3.2.0
return: void
end note
note right of Structure::setUrls
set the urls
since: 3.2.0
return: void
end note
@enduml
```

View File

@ -12,13 +12,12 @@
namespace VDM\Joomla\Componentbuilder\Compiler\Joomlaplugin;
use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler;
use VDM\Joomla\Componentbuilder\Compiler\Joomlaplugin\Data as Plugin;
use VDM\Joomla\Componentbuilder\Compiler\Component;
use VDM\Joomla\Componentbuilder\Compiler\Config;
use VDM\Joomla\Componentbuilder\Compiler\Registry;
use VDM\Joomla\Componentbuilder\Compiler\Customcode\Dispenser;
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\EventInterface;
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\EventInterface as Event;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Counter;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Folder;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\File;
@ -40,7 +39,7 @@ use VDM\Joomla\Utilities\FileHelper;
class Structure
{
/**
* Compiler Joomla Plugin Data Class
* The Data Class.
*
* @var Plugin
* @since 3.2.0
@ -48,15 +47,15 @@ class Structure
protected Plugin $plugin;
/**
* Compiler Component
* The Component Class.
*
* @var Component
* @since 3.2.0
**/
*/
protected Component $component;
/**
* Compiler Config
* The Config Class.
*
* @var Config
* @since 3.2.0
@ -64,7 +63,7 @@ class Structure
protected Config $config;
/**
* The compiler registry
* The Registry Class.
*
* @var Registry
* @since 3.2.0
@ -72,7 +71,7 @@ class Structure
protected Registry $registry;
/**
* Compiler Customcode Dispenser
* The Dispenser Class.
*
* @var Dispenser
* @since 3.2.0
@ -80,15 +79,15 @@ class Structure
protected Dispenser $dispenser;
/**
* Compiler Event
* The EventInterface Class.
*
* @var EventInterface
* @var Event
* @since 3.2.0
*/
protected EventInterface $event;
protected Event $event;
/**
* Compiler Counter
* The Counter Class.
*
* @var Counter
* @since 3.2.0
@ -96,7 +95,7 @@ class Structure
protected Counter $counter;
/**
* Compiler Utilities Folder
* The Folder Class.
*
* @var Folder
* @since 3.2.0
@ -104,7 +103,7 @@ class Structure
protected Folder $folder;
/**
* Compiler Utilities File
* The File Class.
*
* @var File
* @since 3.2.0
@ -112,7 +111,7 @@ class Structure
protected File $file;
/**
* Compiler Utilities Files
* The Files Class.
*
* @var Files
* @since 3.2.0
@ -120,37 +119,36 @@ class Structure
protected Files $files;
/**
* Constructor
* Constructor.
*
* @param Plugin|null $plugin The compiler Joomla plugin data object.
* @param Component|null $component The component class.
* @param Config|null $config The compiler config object.
* @param Registry|null $registry The compiler registry object.
* @param Dispenser|null $dispenser The compiler customcode dispenser object.
* @param EventInterface|null $event The compiler event api object.
* @param Counter|null $counter The compiler counter object.
* @param Folder|null $folder The compiler folder object.
* @param File|null $file The compiler file object.
* @param Files|null $files The compiler files object.
* @param Plugin $plugin The Data Class.
* @param Component $component The Component Class.
* @param Config $config The Config Class.
* @param Registry $registry The Registry Class.
* @param Dispenser $dispenser The Dispenser Class.
* @param Event $event The EventInterface Class.
* @param Counter $counter The Counter Class.
* @param Folder $folder The Folder Class.
* @param File $file The File Class.
* @param Files $files The Files Class.
*
* @since 3.2.0
*/
public function __construct(?Plugin $plugin = null, ?Component $component = null,
?Config $config = null, ?Registry $registry = null,
?Dispenser $dispenser = null, ?EventInterface $event = null,
?Counter $counter = null, ?Folder $folder = null,
?File $file = null, ?Files $files = null)
public function __construct(Plugin $plugin, Component $component, Config $config,
Registry $registry, Dispenser $dispenser, Event $event,
Counter $counter, Folder $folder, File $file,
Files $files)
{
$this->plugin = $plugin ?: Compiler::_('Joomlaplugin.Data');
$this->component = $component ?: Compiler::_('Component');
$this->config = $config ?: Compiler::_('Config');
$this->registry = $registry ?: Compiler::_('Registry');
$this->dispenser = $dispenser ?: Compiler::_('Customcode.Dispenser');
$this->event = $event ?: Compiler::_('Event');
$this->counter = $counter ?: Compiler::_('Utilities.Counter');
$this->folder = $folder ?: Compiler::_('Utilities.Folder');
$this->file = $file ?: Compiler::_('Utilities.File');
$this->files = $files ?: Compiler::_('Utilities.Files');
$this->plugin = $plugin;
$this->component = $component;
$this->config = $config;
$this->registry = $registry;
$this->dispenser = $dispenser;
$this->event = $event;
$this->counter = $counter;
$this->folder = $folder;
$this->file = $file;
$this->files = $files;
}
/**
@ -166,22 +164,21 @@ class Structure
// for plugin event TODO change event api signatures
$component_context = $this->config->component_context;
$plugins = $this->plugin->get();
// Trigger Event: jcb_ce_onBeforeSetPlugins
$this->event->trigger(
'jcb_ce_onBeforeBuildPlugins',
array(&$component_context, &$plugins)
);
foreach ($plugins as $plugin)
{
if (ObjectHelper::check($plugin)
&& isset($plugin->folder_name)
&& StringHelper::check(
$plugin->folder_name
))
&& StringHelper::check($plugin->folder_name))
{
// plugin path
$plugin->folder_path = $this->config->get('compiler_path', JPATH_COMPONENT_ADMINISTRATOR . '/compiler') . '/'
. $plugin->folder_name;
$this->pluginPath($plugin);
// set the plugin paths
$this->registry->set('dynamic_paths.' . $plugin->key, $plugin->folder_path);
@ -193,74 +190,16 @@ class Structure
$this->folder->create($plugin->folder_path);
// set main class file
$fileDetails = array('path' => $plugin->folder_path . '/'
. $plugin->file_name . '.php',
'name' => $plugin->file_name . '.php',
'zip' => $plugin->file_name . '.php');
$this->file->write(
$fileDetails['path'],
'<?php' . PHP_EOL . '// Plugin main class template' .
PHP_EOL . Placefix::_h('BOM') . PHP_EOL .
PHP_EOL . '// No direct access to this file' . PHP_EOL .
"defined('_JEXEC') or die('Restricted access');"
. PHP_EOL .
Placefix::_h('MAINCLASS')
);
$this->files->appendArray($plugin->key, $fileDetails);
// count the file created
$this->counter->file++;
$this->setMainClassFile($plugin);
// set main xml file
$fileDetails = array('path' => $plugin->folder_path . '/'
. $plugin->file_name . '.xml',
'name' => $plugin->file_name . '.xml',
'zip' => $plugin->file_name . '.xml');
$this->file->write(
$fileDetails['path'],
$this->getXML($plugin)
);
$this->files->appendArray($plugin->key, $fileDetails);
// count the file created
$this->counter->file++;
$this->setMainXmlFile($plugin);
// set install script if needed
if ($plugin->add_install_script)
{
$fileDetails = [
'path' => $plugin->folder_path . '/script.php',
'name' => 'script.php',
'zip' => 'script.php'
];
$this->file->write(
$fileDetails['path'],
'<?php' . PHP_EOL . '// Script template' .
PHP_EOL . Placefix::_h('BOM') . PHP_EOL .
PHP_EOL . '// No direct access to this file' . PHP_EOL .
"defined('_JEXEC') or die('Restricted access');" . PHP_EOL .
Placefix::_h('INSTALLCLASS')
);
$this->files->appendArray($plugin->key, $fileDetails);
// count the file created
$this->counter->file++;
}
$this->setInstallScript($plugin);
// set readme if found
if ($plugin->addreadme)
{
$fileDetails = [
'path' => $plugin->folder_path . '/README.md',
'name' => 'README.md',
'zip' => 'README.md'
];
$this->file->write($fileDetails['path'], $plugin->readme);
$this->files->appendArray($plugin->key, $fileDetails);
// count the file created
$this->counter->file++;
}
$this->setReadme($plugin);
// set fields & rules folders if needed
if (isset($plugin->fields_rules_paths)
@ -274,10 +213,209 @@ class Structure
}
// set forms folder if needed
$this->setForms($plugin);
// set SQL stuff if needed
$this->setSQL($plugin);
// creat the language folder path
$this->folder->create($plugin->folder_path . '/language');
// also creat the lang tag folder path
$this->folder->create(
$plugin->folder_path . '/language/' . $this->config->get('lang_tag', 'en-GB')
);
// check if this plugin has files
$this->setFiles($plugin);
// check if this plugin has folders
$this->setFolders($plugin);
// check if this plugin has urls
$this->setUrls($plugin);
}
}
}
}
/**
* get the plugin xml template
*
* @param object $plugin The plugin object
*
* @return string
* @since 3.2.0
*/
protected function getXML(object $plugin): string
{
$xml = '<?xml version="1.0" encoding="utf-8"?>';
$xml .= PHP_EOL . '<extension type="plugin" version="'
. $this->config->joomla_versions[$this->config->joomla_version]['xml_version'] . '" group="'
. strtolower((string) $plugin->group) . '" method="upgrade">';
$xml .= PHP_EOL . Indent::_(1) . '<name>' . $plugin->lang_prefix
. '</name>';
$xml .= PHP_EOL . Indent::_(1) . '<creationDate>' . Placefix::_h('BUILDDATE') . '</creationDate>';
$xml .= PHP_EOL . Indent::_(1) . '<author>' . Placefix::_h('AUTHOR') . '</author>';
$xml .= PHP_EOL . Indent::_(1) . '<authorEmail>' . Placefix::_h('AUTHOREMAIL') . '</authorEmail>';
$xml .= PHP_EOL . Indent::_(1) . '<authorUrl>' . Placefix::_h('AUTHORWEBSITE') . '</authorUrl>';
$xml .= PHP_EOL . Indent::_(1) . '<copyright>' . Placefix::_h('COPYRIGHT') . '</copyright>';
$xml .= PHP_EOL . Indent::_(1) . '<license>' . Placefix::_h('LICENSE') . '</license>';
$xml .= PHP_EOL . Indent::_(1) . '<version>' . $plugin->plugin_version
. '</version>';
$xml .= PHP_EOL . Indent::_(1) . '<description>' . $plugin->lang_prefix
. '_XML_DESCRIPTION</description>';
$xml .= Placefix::_h('MAINXML');
$xml .= PHP_EOL . '</extension>';
return $xml;
}
/**
* set the plugin path
*
* @param object $plugin The plugin object
*
* @return void
* @since 3.2.0
*/
protected function pluginPath(object &$plugin): void
{
$plugin->folder_path = $this->config->get('compiler_path', JPATH_COMPONENT_ADMINISTRATOR . '/compiler') . '/'
. $plugin->folder_name;
}
/**
* set the main class path
*
* @param object $plugin The plugin object
*
* @return void
* @since 3.2.0
*/
protected function setMainClassFile(object $plugin): void
{
$file_details = [
'path' => $plugin->folder_path . '/' . $plugin->file_name . '.php',
'name' => $plugin->file_name . '.php',
'zip' => $plugin->file_name . '.php'
];
$this->file->write(
$file_details['path'],
'<?php' . PHP_EOL . '// Plugin main class template' .
PHP_EOL . Placefix::_h('BOM') . PHP_EOL .
PHP_EOL . '// No direct access to this file' . PHP_EOL .
"defined('_JEXEC') or die('Restricted access');"
. PHP_EOL .
Placefix::_h('MAINCLASS')
);
$this->files->appendArray($plugin->key, $file_details);
// count the file created
$this->counter->file++;
}
/**
* set the main xml file
*
* @param object $plugin The plugin object
*
* @return void
* @since 3.2.0
*/
protected function setMainXmlFile(mixed $plugin): void
{
$file_details = [
'path' => $plugin->folder_path . '/' . $plugin->file_name . '.xml',
'name' => $plugin->file_name . '.xml',
'zip' => $plugin->file_name . '.xml'
];
$this->file->write(
$file_details['path'],
$this->getXML($plugin)
);
$this->files->appendArray($plugin->key, $file_details);
// count the file created
$this->counter->file++;
}
/**
* set the install script file
*
* @param object $plugin The plugin object
*
* @return void
* @since 3.2.0
*/
protected function setInstallScript(object $plugin): void
{
if ($plugin->add_install_script)
{
$file_details = [
'path' => $plugin->folder_path . '/script.php',
'name' => 'script.php',
'zip' => 'script.php'
];
$this->file->write(
$file_details['path'],
'<?php' . PHP_EOL . '// Script template' .
PHP_EOL . Placefix::_h('BOM') . PHP_EOL .
PHP_EOL . '// No direct access to this file' . PHP_EOL .
"defined('_JEXEC') or die('Restricted access');" . PHP_EOL .
Placefix::_h('INSTALLCLASS')
);
$this->files->appendArray($plugin->key, $file_details);
// count the file created
$this->counter->file++;
}
}
/**
* set the readme file
*
* @param object $plugin The plugin object
*
* @return void
* @since 3.2.0
*/
protected function setReadme(object $plugin): void
{
if ($plugin->addreadme)
{
$file_details = [
'path' => $plugin->folder_path . '/README.md',
'name' => 'README.md',
'zip' => 'README.md'
];
$this->file->write($file_details['path'], $plugin->readme);
$this->files->appendArray($plugin->key, $file_details);
// count the file created
$this->counter->file++;
}
}
/**
* set the form files and folders
*
* @param object $plugin The plugin object
*
* @return void
* @since 3.2.0
*/
protected function setForms(object $plugin): void
{
if (isset($plugin->form_files)
&& ArrayHelper::check(
$plugin->form_files
))
&& ArrayHelper::check($plugin->form_files))
{
// create forms folder
$this->folder->create($plugin->folder_path . '/forms');
@ -286,7 +424,7 @@ class Structure
foreach ($plugin->form_files as $file => $fields)
{
// set file details
$fileDetails = [
$file_details = [
'path' => $plugin->folder_path . '/forms/' . $file . '.xml',
'name' => $file . '.xml',
'zip' => 'forms/' . $file . '.xml'
@ -308,12 +446,8 @@ class Structure
foreach ($fieldsets as $fieldset => $field)
{
if (!$add_component_path
&& isset(
$plugin->fieldsets_paths[$file
. $field_name . $fieldset]
)
&& $plugin->fieldsets_paths[$file
. $field_name . $fieldset] == 1)
&& isset($plugin->fieldsets_paths[$file . $field_name . $fieldset])
&& $plugin->fieldsets_paths[$file. $field_name . $fieldset] == 1)
{
$add_component_path = true;
}
@ -346,10 +480,10 @@ class Structure
// check if we have an double fields naming set
$field_name_inner = '';
$field_name_outer = $field_name;
if (strpos((string) $field_name, '.') !== false)
if (strpos((string)$field_name, '.') !== false)
{
$field_names = explode('.', (string) $field_name);
if (count((array) $field_names) == 2)
$field_names = explode('.', (string)$field_name);
if (count((array)$field_names) == 2)
{
$field_name_outer = $field_names[0];
$field_name_inner = $field_names[1];
@ -375,16 +509,15 @@ class Structure
if (!isset($plugin->add_rule_path[$file . $field_name . $fieldset]))
{
$plugin->add_rule_path[$file . $field_name . $fieldset] =
'/plugins/' . strtolower((string) $plugin->group
) . '/' . strtolower((string) $plugin->code_name)
. '/rules';
'/plugins/' . strtolower((string)$plugin->group) . '/'
. strtolower((string)$plugin->code_name) . '/rules';
}
if (!isset($plugin->add_field_path[$file . $field_name . $fieldset]))
{
$plugin->add_field_path[$file . $field_name . $fieldset] =
'/plugins/' . strtolower((string) $plugin->group
) . '/' . strtolower((string) $plugin->code_name)
'/plugins/' . strtolower((string)$plugin->group
) . '/' . strtolower((string)$plugin->code_name)
. '/fields';
}
}
@ -421,9 +554,7 @@ class Structure
}
// check if we have an inner field set
if (StringHelper::check(
$field_name_inner
))
if (StringHelper::check($field_name_inner))
{
$xml .= PHP_EOL . Indent::_(1)
. '<fields name="'
@ -432,12 +563,10 @@ class Structure
// add the placeholder of the fields
$xml .= Placefix::_h('FIELDSET_' . $file
. $field_name . $fieldset );
. $field_name . $fieldset);
// check if we have an inner field set
if (StringHelper::check(
$field_name_inner
))
if (StringHelper::check($field_name_inner))
{
$xml .= PHP_EOL . Indent::_(1)
. '</fields>';
@ -450,15 +579,25 @@ class Structure
$xml .= PHP_EOL . '</form>';
// add xml to file
$this->file->write($fileDetails['path'], $xml);
$this->files->appendArray($plugin->key, $fileDetails);
$this->file->write($file_details['path'], $xml);
$this->files->appendArray($plugin->key, $file_details);
// count the file created
$this->counter->file++;
}
}
}
// set SQL stuff if needed
/**
* set the sql stuff
*
* @param object $plugin The plugin object
*
* @return void
* @since 3.2.0
*/
protected function setSQL(object $plugin): void
{
if ($plugin->add_sql || $plugin->add_sql_uninstall)
{
// create SQL folder
@ -494,18 +633,19 @@ class Structure
$this->counter->file++;
}
}
}
// creat the language folder path
$this->folder->create($plugin->folder_path . '/language');
// also creat the lang tag folder path
$this->folder->create(
$plugin->folder_path . '/language/' . $this->config->get('lang_tag', 'en-GB')
);
// check if this lib has files
if (isset($plugin->files)
&& ArrayHelper::check($plugin->files))
/**
* set the files
*
* @param object $plugin The plugin object
*
* @return void
* @since 3.2.0
*/
protected function setFiles(object $plugin): void
{
if (isset($plugin->files) && ArrayHelper::check($plugin->files))
{
// add to component files
foreach ($plugin->files as $file)
@ -513,13 +653,23 @@ class Structure
// set the path finder
$file['target_type'] = $plugin->target_type;
$file['target_id'] = $plugin->id;
$this->component->appendArray('files', $file);
}
}
}
// check if this lib has folders
if (isset($plugin->folders)
&& ArrayHelper::check($plugin->folders))
/**
* set the folders
*
* @param object $plugin The plugin object
*
* @return void
* @since 3.2.0
*/
protected function setFolders(object $plugin): void
{
if (isset($plugin->folders) && ArrayHelper::check($plugin->folders))
{
// add to component folders
foreach ($plugin->folders as $folder)
@ -527,26 +677,34 @@ class Structure
// set the path finder
$folder['target_type'] = $plugin->target_type;
$folder['target_id'] = $plugin->id;
$this->component->appendArray('folders', $folder);
}
}
}
// check if this plugin has urls
if (isset($plugin->urls)
&& ArrayHelper::check($plugin->urls))
/**
* set the urls
*
* @param object $plugin The plugin object
*
* @return void
* @since 3.2.0
*/
protected function setUrls(object &$plugin): void
{
if (isset($plugin->urls) && ArrayHelper::check($plugin->urls))
{
// add to component urls
foreach ($plugin->urls as $n => &$url)
foreach ($plugin->urls as &$url)
{
// should we add the local folder
if (isset($url['type']) && $url['type'] > 1
&& isset($url['url'])
&& StringHelper::check(
$url['url']
))
&& StringHelper::check($url['url']))
{
// set file name
$fileName = basename((string) $url['url']);
$fileName = basename((string)$url['url']);
// get the file contents
$data = FileHelper::getContent(
@ -567,7 +725,7 @@ class Structure
$path = '';
}
// create sub media media folder path if not set
// create sub media folder path if not set
$this->folder->create(
$plugin->folder_path . $path
);
@ -585,41 +743,5 @@ class Structure
}
}
}
}
}
}
/**
* get the plugin xml template
*
* @param object $module The plugin object
*
* @return string
* @since 3.2.0
*/
protected function getXML(object &$plugin): string
{
$xml = '<?xml version="1.0" encoding="utf-8"?>';
$xml .= PHP_EOL . '<extension type="plugin" version="'
. $this->config->joomla_versions[$this->config->joomla_version]['xml_version'] . '" group="'
. strtolower((string) $plugin->group) . '" method="upgrade">';
$xml .= PHP_EOL . Indent::_(1) . '<name>' . $plugin->lang_prefix
. '</name>';
$xml .= PHP_EOL . Indent::_(1) . '<creationDate>' . Placefix::_h('BUILDDATE') . '</creationDate>';
$xml .= PHP_EOL . Indent::_(1) . '<author>' . Placefix::_h('AUTHOR') . '</author>';
$xml .= PHP_EOL . Indent::_(1) . '<authorEmail>' . Placefix::_h('AUTHOREMAIL') . '</authorEmail>';
$xml .= PHP_EOL . Indent::_(1) . '<authorUrl>' . Placefix::_h('AUTHORWEBSITE') . '</authorUrl>';
$xml .= PHP_EOL . Indent::_(1) . '<copyright>' . Placefix::_h('COPYRIGHT') . '</copyright>';
$xml .= PHP_EOL . Indent::_(1) . '<license>' . Placefix::_h('LICENSE') . '</license>';
$xml .= PHP_EOL . Indent::_(1) . '<version>' . $plugin->plugin_version
. '</version>';
$xml .= PHP_EOL . Indent::_(1) . '<description>' . $plugin->lang_prefix
. '_XML_DESCRIPTION</description>';
$xml .= Placefix::_h('MAINXML');
$xml .= PHP_EOL . '</extension>';
return $xml;
}
}

View File

@ -1,5 +1,5 @@
/**
* Compiler Joomla Plugin Data Class
* The Data Class.
*
* @var Plugin
* @since 3.2.0
@ -7,15 +7,15 @@
protected Plugin $plugin;
/**
* Compiler Component
* The Component Class.
*
* @var Component
* @since 3.2.0
**/
*/
protected Component $component;
/**
* Compiler Config
* The Config Class.
*
* @var Config
* @since 3.2.0
@ -23,7 +23,7 @@
protected Config $config;
/**
* The compiler registry
* The Registry Class.
*
* @var Registry
* @since 3.2.0
@ -31,7 +31,7 @@
protected Registry $registry;
/**
* Compiler Customcode Dispenser
* The Dispenser Class.
*
* @var Dispenser
* @since 3.2.0
@ -39,15 +39,15 @@
protected Dispenser $dispenser;
/**
* Compiler Event
* The EventInterface Class.
*
* @var EventInterface
* @var Event
* @since 3.2.0
*/
protected EventInterface $event;
protected Event $event;
/**
* Compiler Counter
* The Counter Class.
*
* @var Counter
* @since 3.2.0
@ -55,7 +55,7 @@
protected Counter $counter;
/**
* Compiler Utilities Folder
* The Folder Class.
*
* @var Folder
* @since 3.2.0
@ -63,7 +63,7 @@
protected Folder $folder;
/**
* Compiler Utilities File
* The File Class.
*
* @var File
* @since 3.2.0
@ -71,7 +71,7 @@
protected File $file;
/**
* Compiler Utilities Files
* The Files Class.
*
* @var Files
* @since 3.2.0
@ -79,37 +79,36 @@
protected Files $files;
/**
* Constructor
* Constructor.
*
* @param Plugin|null $plugin The compiler Joomla plugin data object.
* @param Component|null $component The component class.
* @param Config|null $config The compiler config object.
* @param Registry|null $registry The compiler registry object.
* @param Dispenser|null $dispenser The compiler customcode dispenser object.
* @param EventInterface|null $event The compiler event api object.
* @param Counter|null $counter The compiler counter object.
* @param Folder|null $folder The compiler folder object.
* @param File|null $file The compiler file object.
* @param Files|null $files The compiler files object.
* @param Plugin $plugin The Data Class.
* @param Component $component The Component Class.
* @param Config $config The Config Class.
* @param Registry $registry The Registry Class.
* @param Dispenser $dispenser The Dispenser Class.
* @param Event $event The EventInterface Class.
* @param Counter $counter The Counter Class.
* @param Folder $folder The Folder Class.
* @param File $file The File Class.
* @param Files $files The Files Class.
*
* @since 3.2.0
*/
public function __construct(?Plugin $plugin = null, ?Component $component = null,
?Config $config = null, ?Registry $registry = null,
?Dispenser $dispenser = null, ?EventInterface $event = null,
?Counter $counter = null, ?Folder $folder = null,
?File $file = null, ?Files $files = null)
public function __construct(Plugin $plugin, Component $component, Config $config,
Registry $registry, Dispenser $dispenser, Event $event,
Counter $counter, Folder $folder, File $file,
Files $files)
{
$this->plugin = $plugin ?: Compiler::_('Joomlaplugin.Data');
$this->component = $component ?: Compiler::_('Component');
$this->config = $config ?: Compiler::_('Config');
$this->registry = $registry ?: Compiler::_('Registry');
$this->dispenser = $dispenser ?: Compiler::_('Customcode.Dispenser');
$this->event = $event ?: Compiler::_('Event');
$this->counter = $counter ?: Compiler::_('Utilities.Counter');
$this->folder = $folder ?: Compiler::_('Utilities.Folder');
$this->file = $file ?: Compiler::_('Utilities.File');
$this->files = $files ?: Compiler::_('Utilities.Files');
$this->plugin = $plugin;
$this->component = $component;
$this->config = $config;
$this->registry = $registry;
$this->dispenser = $dispenser;
$this->event = $event;
$this->counter = $counter;
$this->folder = $folder;
$this->file = $file;
$this->files = $files;
}
/**
@ -125,22 +124,21 @@
// for plugin event TODO change event api signatures
$component_context = $this->config->component_context;
$plugins = $this->plugin->get();
// Trigger Event: jcb_ce_onBeforeSetPlugins
$this->event->trigger(
'jcb_ce_onBeforeBuildPlugins',
array(&$component_context, &$plugins)
);
foreach ($plugins as $plugin)
{
if (ObjectHelper::check($plugin)
&& isset($plugin->folder_name)
&& StringHelper::check(
$plugin->folder_name
))
&& StringHelper::check($plugin->folder_name))
{
// plugin path
$plugin->folder_path = $this->config->get('compiler_path', JPATH_COMPONENT_ADMINISTRATOR . '/compiler') . '/'
. $plugin->folder_name;
$this->pluginPath($plugin);
// set the plugin paths
$this->registry->set('dynamic_paths.' . $plugin->key, $plugin->folder_path);
@ -152,74 +150,16 @@
$this->folder->create($plugin->folder_path);
// set main class file
$fileDetails = array('path' => $plugin->folder_path . '/'
. $plugin->file_name . '.php',
'name' => $plugin->file_name . '.php',
'zip' => $plugin->file_name . '.php');
$this->file->write(
$fileDetails['path'],
'<?php' . PHP_EOL . '// Plugin main class template' .
PHP_EOL . Placefix::_h('BOM') . PHP_EOL .
PHP_EOL . '// No direct access to this file' . PHP_EOL .
"defined('_JEXEC') or die('Restricted access');"
. PHP_EOL .
Placefix::_h('MAINCLASS')
);
$this->files->appendArray($plugin->key, $fileDetails);
// count the file created
$this->counter->file++;
$this->setMainClassFile($plugin);
// set main xml file
$fileDetails = array('path' => $plugin->folder_path . '/'
. $plugin->file_name . '.xml',
'name' => $plugin->file_name . '.xml',
'zip' => $plugin->file_name . '.xml');
$this->file->write(
$fileDetails['path'],
$this->getXML($plugin)
);
$this->files->appendArray($plugin->key, $fileDetails);
// count the file created
$this->counter->file++;
$this->setMainXmlFile($plugin);
// set install script if needed
if ($plugin->add_install_script)
{
$fileDetails = [
'path' => $plugin->folder_path . '/script.php',
'name' => 'script.php',
'zip' => 'script.php'
];
$this->file->write(
$fileDetails['path'],
'<?php' . PHP_EOL . '// Script template' .
PHP_EOL . Placefix::_h('BOM') . PHP_EOL .
PHP_EOL . '// No direct access to this file' . PHP_EOL .
"defined('_JEXEC') or die('Restricted access');" . PHP_EOL .
Placefix::_h('INSTALLCLASS')
);
$this->files->appendArray($plugin->key, $fileDetails);
// count the file created
$this->counter->file++;
}
$this->setInstallScript($plugin);
// set readme if found
if ($plugin->addreadme)
{
$fileDetails = [
'path' => $plugin->folder_path . '/README.md',
'name' => 'README.md',
'zip' => 'README.md'
];
$this->file->write($fileDetails['path'], $plugin->readme);
$this->files->appendArray($plugin->key, $fileDetails);
// count the file created
$this->counter->file++;
}
$this->setReadme($plugin);
// set fields & rules folders if needed
if (isset($plugin->fields_rules_paths)
@ -233,10 +173,209 @@
}
// set forms folder if needed
$this->setForms($plugin);
// set SQL stuff if needed
$this->setSQL($plugin);
// creat the language folder path
$this->folder->create($plugin->folder_path . '/language');
// also creat the lang tag folder path
$this->folder->create(
$plugin->folder_path . '/language/' . $this->config->get('lang_tag', 'en-GB')
);
// check if this plugin has files
$this->setFiles($plugin);
// check if this plugin has folders
$this->setFolders($plugin);
// check if this plugin has urls
$this->setUrls($plugin);
}
}
}
}
/**
* get the plugin xml template
*
* @param object $plugin The plugin object
*
* @return string
* @since 3.2.0
*/
protected function getXML(object $plugin): string
{
$xml = '<?xml version="1.0" encoding="utf-8"?>';
$xml .= PHP_EOL . '<extension type="plugin" version="'
. $this->config->joomla_versions[$this->config->joomla_version]['xml_version'] . '" group="'
. strtolower((string) $plugin->group) . '" method="upgrade">';
$xml .= PHP_EOL . Indent::_(1) . '<name>' . $plugin->lang_prefix
. '</name>';
$xml .= PHP_EOL . Indent::_(1) . '<creationDate>' . Placefix::_h('BUILDDATE') . '</creationDate>';
$xml .= PHP_EOL . Indent::_(1) . '<author>' . Placefix::_h('AUTHOR') . '</author>';
$xml .= PHP_EOL . Indent::_(1) . '<authorEmail>' . Placefix::_h('AUTHOREMAIL') . '</authorEmail>';
$xml .= PHP_EOL . Indent::_(1) . '<authorUrl>' . Placefix::_h('AUTHORWEBSITE') . '</authorUrl>';
$xml .= PHP_EOL . Indent::_(1) . '<copyright>' . Placefix::_h('COPYRIGHT') . '</copyright>';
$xml .= PHP_EOL . Indent::_(1) . '<license>' . Placefix::_h('LICENSE') . '</license>';
$xml .= PHP_EOL . Indent::_(1) . '<version>' . $plugin->plugin_version
. '</version>';
$xml .= PHP_EOL . Indent::_(1) . '<description>' . $plugin->lang_prefix
. '_XML_DESCRIPTION</description>';
$xml .= Placefix::_h('MAINXML');
$xml .= PHP_EOL . '</extension>';
return $xml;
}
/**
* set the plugin path
*
* @param object $plugin The plugin object
*
* @return void
* @since 3.2.0
*/
protected function pluginPath(object &$plugin): void
{
$plugin->folder_path = $this->config->get('compiler_path', JPATH_COMPONENT_ADMINISTRATOR . '/compiler') . '/'
. $plugin->folder_name;
}
/**
* set the main class path
*
* @param object $plugin The plugin object
*
* @return void
* @since 3.2.0
*/
protected function setMainClassFile(object $plugin): void
{
$file_details = [
'path' => $plugin->folder_path . '/' . $plugin->file_name . '.php',
'name' => $plugin->file_name . '.php',
'zip' => $plugin->file_name . '.php'
];
$this->file->write(
$file_details['path'],
'<?php' . PHP_EOL . '// Plugin main class template' .
PHP_EOL . Placefix::_h('BOM') . PHP_EOL .
PHP_EOL . '// No direct access to this file' . PHP_EOL .
"defined('_JEXEC') or die('Restricted access');"
. PHP_EOL .
Placefix::_h('MAINCLASS')
);
$this->files->appendArray($plugin->key, $file_details);
// count the file created
$this->counter->file++;
}
/**
* set the main xml file
*
* @param object $plugin The plugin object
*
* @return void
* @since 3.2.0
*/
protected function setMainXmlFile(mixed $plugin): void
{
$file_details = [
'path' => $plugin->folder_path . '/' . $plugin->file_name . '.xml',
'name' => $plugin->file_name . '.xml',
'zip' => $plugin->file_name . '.xml'
];
$this->file->write(
$file_details['path'],
$this->getXML($plugin)
);
$this->files->appendArray($plugin->key, $file_details);
// count the file created
$this->counter->file++;
}
/**
* set the install script file
*
* @param object $plugin The plugin object
*
* @return void
* @since 3.2.0
*/
protected function setInstallScript(object $plugin): void
{
if ($plugin->add_install_script)
{
$file_details = [
'path' => $plugin->folder_path . '/script.php',
'name' => 'script.php',
'zip' => 'script.php'
];
$this->file->write(
$file_details['path'],
'<?php' . PHP_EOL . '// Script template' .
PHP_EOL . Placefix::_h('BOM') . PHP_EOL .
PHP_EOL . '// No direct access to this file' . PHP_EOL .
"defined('_JEXEC') or die('Restricted access');" . PHP_EOL .
Placefix::_h('INSTALLCLASS')
);
$this->files->appendArray($plugin->key, $file_details);
// count the file created
$this->counter->file++;
}
}
/**
* set the readme file
*
* @param object $plugin The plugin object
*
* @return void
* @since 3.2.0
*/
protected function setReadme(object $plugin): void
{
if ($plugin->addreadme)
{
$file_details = [
'path' => $plugin->folder_path . '/README.md',
'name' => 'README.md',
'zip' => 'README.md'
];
$this->file->write($file_details['path'], $plugin->readme);
$this->files->appendArray($plugin->key, $file_details);
// count the file created
$this->counter->file++;
}
}
/**
* set the form files and folders
*
* @param object $plugin The plugin object
*
* @return void
* @since 3.2.0
*/
protected function setForms(object $plugin): void
{
if (isset($plugin->form_files)
&& ArrayHelper::check(
$plugin->form_files
))
&& ArrayHelper::check($plugin->form_files))
{
// create forms folder
$this->folder->create($plugin->folder_path . '/forms');
@ -245,7 +384,7 @@
foreach ($plugin->form_files as $file => $fields)
{
// set file details
$fileDetails = [
$file_details = [
'path' => $plugin->folder_path . '/forms/' . $file . '.xml',
'name' => $file . '.xml',
'zip' => 'forms/' . $file . '.xml'
@ -267,12 +406,8 @@
foreach ($fieldsets as $fieldset => $field)
{
if (!$add_component_path
&& isset(
$plugin->fieldsets_paths[$file
. $field_name . $fieldset]
)
&& $plugin->fieldsets_paths[$file
. $field_name . $fieldset] == 1)
&& isset($plugin->fieldsets_paths[$file . $field_name . $fieldset])
&& $plugin->fieldsets_paths[$file. $field_name . $fieldset] == 1)
{
$add_component_path = true;
}
@ -305,10 +440,10 @@
// check if we have an double fields naming set
$field_name_inner = '';
$field_name_outer = $field_name;
if (strpos((string) $field_name, '.') !== false)
if (strpos((string)$field_name, '.') !== false)
{
$field_names = explode('.', (string) $field_name);
if (count((array) $field_names) == 2)
$field_names = explode('.', (string)$field_name);
if (count((array)$field_names) == 2)
{
$field_name_outer = $field_names[0];
$field_name_inner = $field_names[1];
@ -334,16 +469,15 @@
if (!isset($plugin->add_rule_path[$file . $field_name . $fieldset]))
{
$plugin->add_rule_path[$file . $field_name . $fieldset] =
'/plugins/' . strtolower((string) $plugin->group
) . '/' . strtolower((string) $plugin->code_name)
. '/rules';
'/plugins/' . strtolower((string)$plugin->group) . '/'
. strtolower((string)$plugin->code_name) . '/rules';
}
if (!isset($plugin->add_field_path[$file . $field_name . $fieldset]))
{
$plugin->add_field_path[$file . $field_name . $fieldset] =
'/plugins/' . strtolower((string) $plugin->group
) . '/' . strtolower((string) $plugin->code_name)
'/plugins/' . strtolower((string)$plugin->group
) . '/' . strtolower((string)$plugin->code_name)
. '/fields';
}
}
@ -380,9 +514,7 @@
}
// check if we have an inner field set
if (StringHelper::check(
$field_name_inner
))
if (StringHelper::check($field_name_inner))
{
$xml .= PHP_EOL . Indent::_(1)
. '<fields name="'
@ -391,12 +523,10 @@
// add the placeholder of the fields
$xml .= Placefix::_h('FIELDSET_' . $file
. $field_name . $fieldset );
. $field_name . $fieldset);
// check if we have an inner field set
if (StringHelper::check(
$field_name_inner
))
if (StringHelper::check($field_name_inner))
{
$xml .= PHP_EOL . Indent::_(1)
. '</fields>';
@ -409,15 +539,25 @@
$xml .= PHP_EOL . '</form>';
// add xml to file
$this->file->write($fileDetails['path'], $xml);
$this->files->appendArray($plugin->key, $fileDetails);
$this->file->write($file_details['path'], $xml);
$this->files->appendArray($plugin->key, $file_details);
// count the file created
$this->counter->file++;
}
}
}
// set SQL stuff if needed
/**
* set the sql stuff
*
* @param object $plugin The plugin object
*
* @return void
* @since 3.2.0
*/
protected function setSQL(object $plugin): void
{
if ($plugin->add_sql || $plugin->add_sql_uninstall)
{
// create SQL folder
@ -453,18 +593,19 @@
$this->counter->file++;
}
}
}
// creat the language folder path
$this->folder->create($plugin->folder_path . '/language');
// also creat the lang tag folder path
$this->folder->create(
$plugin->folder_path . '/language/' . $this->config->get('lang_tag', 'en-GB')
);
// check if this lib has files
if (isset($plugin->files)
&& ArrayHelper::check($plugin->files))
/**
* set the files
*
* @param object $plugin The plugin object
*
* @return void
* @since 3.2.0
*/
protected function setFiles(object $plugin): void
{
if (isset($plugin->files) && ArrayHelper::check($plugin->files))
{
// add to component files
foreach ($plugin->files as $file)
@ -472,13 +613,23 @@
// set the path finder
$file['target_type'] = $plugin->target_type;
$file['target_id'] = $plugin->id;
$this->component->appendArray('files', $file);
}
}
}
// check if this lib has folders
if (isset($plugin->folders)
&& ArrayHelper::check($plugin->folders))
/**
* set the folders
*
* @param object $plugin The plugin object
*
* @return void
* @since 3.2.0
*/
protected function setFolders(object $plugin): void
{
if (isset($plugin->folders) && ArrayHelper::check($plugin->folders))
{
// add to component folders
foreach ($plugin->folders as $folder)
@ -486,26 +637,34 @@
// set the path finder
$folder['target_type'] = $plugin->target_type;
$folder['target_id'] = $plugin->id;
$this->component->appendArray('folders', $folder);
}
}
}
// check if this plugin has urls
if (isset($plugin->urls)
&& ArrayHelper::check($plugin->urls))
/**
* set the urls
*
* @param object $plugin The plugin object
*
* @return void
* @since 3.2.0
*/
protected function setUrls(object &$plugin): void
{
if (isset($plugin->urls) && ArrayHelper::check($plugin->urls))
{
// add to component urls
foreach ($plugin->urls as $n => &$url)
foreach ($plugin->urls as &$url)
{
// should we add the local folder
if (isset($url['type']) && $url['type'] > 1
&& isset($url['url'])
&& StringHelper::check(
$url['url']
))
&& StringHelper::check($url['url']))
{
// set file name
$fileName = basename((string) $url['url']);
$fileName = basename((string)$url['url']);
// get the file contents
$data = FileHelper::getContent(
@ -526,7 +685,7 @@
$path = '';
}
// create sub media media folder path if not set
// create sub media folder path if not set
$this->folder->create(
$plugin->folder_path . $path
);
@ -544,38 +703,3 @@
}
}
}
}
}
}
/**
* get the plugin xml template
*
* @param object $module The plugin object
*
* @return string
* @since 3.2.0
*/
protected function getXML(object &$plugin): string
{
$xml = '<?xml version="1.0" encoding="utf-8"?>';
$xml .= PHP_EOL . '<extension type="plugin" version="'
. $this->config->joomla_versions[$this->config->joomla_version]['xml_version'] . '" group="'
. strtolower((string) $plugin->group) . '" method="upgrade">';
$xml .= PHP_EOL . Indent::_(1) . '<name>' . $plugin->lang_prefix
. '</name>';
$xml .= PHP_EOL . Indent::_(1) . '<creationDate>' . Placefix::_h('BUILDDATE') . '</creationDate>';
$xml .= PHP_EOL . Indent::_(1) . '<author>' . Placefix::_h('AUTHOR') . '</author>';
$xml .= PHP_EOL . Indent::_(1) . '<authorEmail>' . Placefix::_h('AUTHOREMAIL') . '</authorEmail>';
$xml .= PHP_EOL . Indent::_(1) . '<authorUrl>' . Placefix::_h('AUTHORWEBSITE') . '</authorUrl>';
$xml .= PHP_EOL . Indent::_(1) . '<copyright>' . Placefix::_h('COPYRIGHT') . '</copyright>';
$xml .= PHP_EOL . Indent::_(1) . '<license>' . Placefix::_h('LICENSE') . '</license>';
$xml .= PHP_EOL . Indent::_(1) . '<version>' . $plugin->plugin_version
. '</version>';
$xml .= PHP_EOL . Indent::_(1) . '<description>' . $plugin->lang_prefix
. '_XML_DESCRIPTION</description>';
$xml .= Placefix::_h('MAINXML');
$xml .= PHP_EOL . '</extension>';
return $xml;
}

View File

@ -11,74 +11,70 @@
"type": "class",
"use_selection": {
"use_selection0": {
"use": "d910d8b8-4c23-4f3e-8cda-438f2d2bd7ac",
"as": "Compiler"
},
"use_selection1": {
"use": "766a9524-37df-4604-91a7-b98a6150ee26",
"as": "Plugin"
},
"use_selection2": {
"use_selection1": {
"use": "e2472b22-a329-44d8-b4a2-ae3ba99e17a0",
"as": "default"
},
"use_selection3": {
"use_selection2": {
"use": "fa4bf18e-301e-42e3-91fb-6e0096c07adc",
"as": "default"
},
"use_selection4": {
"use_selection3": {
"use": "e5d9804f-0eb0-4ee9-b406-ad4e8cdbc1f6",
"as": "default"
},
"use_selection5": {
"use_selection4": {
"use": "f1dc6430-fb54-452e-aa53-ce32ae93db88",
"as": "default"
},
"use_selection6": {
"use_selection5": {
"use": "20ed72b0-fcac-4344-aee1-8a65e3bf221d",
"as": "default"
"as": "Event"
},
"use_selection7": {
"use_selection6": {
"use": "e6d871a6-bbe7-497d-af01-68f6bb9a87f4",
"as": "default"
},
"use_selection8": {
"use_selection7": {
"use": "6bbb6ffe-3f09-4c21-aa9d-c93159afa1e1",
"as": "default"
},
"use_selection9": {
"use_selection8": {
"use": "5c75b455-3d4c-452a-867e-e90424a64c88",
"as": "default"
},
"use_selection10": {
"use_selection9": {
"use": "1d967151-7c20-4ca7-9400-65233cdcd4db",
"as": "default"
},
"use_selection11": {
"use_selection10": {
"use": "a68c010b-e92e-47d5-8a44-d23cfddeb6c6",
"as": "default"
},
"use_selection12": {
"use_selection11": {
"use": "500f3a7f-c16d-4dd4-81b2-2df6776b5388",
"as": "default"
},
"use_selection13": {
"use_selection12": {
"use": "4e6ff11d-bebf-42f5-8fd7-b2f882857222",
"as": "default"
},
"use_selection14": {
"use_selection13": {
"use": "0a59c65c-9daf-4bc9-baf4-e063ff9e6a8a",
"as": "default"
},
"use_selection15": {
"use_selection14": {
"use": "91004529-94a9-4590-b842-e7c6b624ecf5",
"as": "default"
},
"use_selection16": {
"use_selection15": {
"use": "1f28cb53-60d9-4db1-b517-3c7dc6b429ef",
"as": "default"
},
"use_selection17": {
"use_selection16": {
"use": "a223b31e-ea1d-4cdf-92ae-5f9becffaff0",
"as": "default"
}

View File

@ -18,7 +18,11 @@ class Config #Gold {
# getAddcustomgiteaurl() : int
# getCustomgiteaurl() : ?string
# getCustomgiteatoken() : ?string
# getSuperpowerscoreorganisation() : string
# getSuperpowersinitrepos() : array
# getTmppath() : string
# getAddsuperpowers() : bool
# getAddownpowers() : bool
# getLocalpowersrepositorypath() : string
# getApprovedpaths() : array
}
@ -62,6 +66,20 @@ note right of Config::getCustomgiteatoken
return: ?string
end note
note left of Config::getSuperpowerscoreorganisation
Get super power core organisation
since: 3.2.0
return: string
end note
note right of Config::getSuperpowersinitrepos
Get super power init repos
since: 3.2.0
return: array
end note
note left of Config::getTmppath
get temporary path
@ -69,6 +87,20 @@ note left of Config::getTmppath
return: string
end note
note right of Config::getAddsuperpowers
Get switch to add super powers
since: 3.2.0
return: bool
end note
note left of Config::getAddownpowers
Get switch to add own super powers
since: 3.2.0
return: bool
end note
note right of Config::getLocalpowersrepositorypath
Get local super powers repository path

View File

@ -111,6 +111,66 @@ class Config extends BaseConfig
return null;
}
/**
* Get super power core organisation
*
* @return string The super power core organisation
* @since 3.2.0
*/
protected function getSuperpowerscoreorganisation(): string
{
// the VDM default organisation is [joomla]
$organisation = 'joomla';
if ($this->add_custom_gitea_url == 2)
{
return $this->params->get('super_powers_core_organisation', $organisation);
}
return $organisation;
}
/**
* Get super power init repos
*
* @return array The init repositories on Gitea
* @since 3.2.0
*/
protected function getSuperpowersinitrepos(): array
{
// some defaults repos we need by JCB
$repos = [];
// only add custom init with custom gitea
$paths = null;
if ($this->add_custom_gitea_url == 2)
{
$paths = $this->params->get('super_powers_init_repos');
}
if (!empty($paths) && is_array($paths))
{
foreach ($paths as $path)
{
$owner = $path->owner ?? null;
$repo = $path->repo ?? null;
if ($owner !== null && $repo !== null)
{
// we make sure to get only the objects
$repos = ["{$owner}.{$repo}" => $path] + $repos;
}
}
}
else
{
$repos[$this->super_powers_core_organisation . '.super-powers'] = (object) ['owner' => $this->super_powers_core_organisation, 'repo' => 'super-powers', 'branch' => 'master'];
$repos[$this->super_powers_core_organisation . '.gitea'] = (object) ['owner' => $this->super_powers_core_organisation, 'repo' => 'gitea', 'branch' => 'master'];
$repos[$this->super_powers_core_organisation . '.openai'] = (object) ['owner' => $this->super_powers_core_organisation, 'repo' => 'openai', 'branch' => 'master'];
}
return $repos;
}
/**
* get temporary path
*
@ -123,6 +183,33 @@ class Config extends BaseConfig
return $this->config->get('tmp_path');
}
/**
* Get switch to add super powers
*
* @return bool Switch to add super powers
* @since 3.2.0
*/
protected function getAddsuperpowers(): bool
{
return (bool) $this->params->get('powers_repository', 0);
}
/**
* Get switch to add own super powers
*
* @return bool Switch to add own super powers
* @since 3.2.0
*/
protected function getAddownpowers(): bool
{
if ($this->add_super_powers)
{
return (bool) $this->params->get('super_powers_repositories', 0);
}
return false;
}
/**
* Get local super powers repository path
*
@ -138,18 +225,7 @@ class Config extends BaseConfig
return $default;
}
$global = $this->params->get('local_powers_repository_path', $default);
if (!$this->show_advanced_options)
{
return $global;
}
$value = $this->input->post->get('powers_repository', 2, 'INT');
return $value == 1
? $this->input->post->get('local_powers_repository_path', $global, 'PATH')
: $global;
return $this->params->get('local_powers_repository_path', $default);
}
/**
@ -160,29 +236,31 @@ class Config extends BaseConfig
*/
protected function getApprovedpaths(): array
{
$default = (object) ['owner' => 'joomla', 'repo' => 'super-powers', 'branch' => 'master'];
// some defaults repos we need by JCB
$approved = $this->super_powers_init_repos;
if (!$this->add_own_powers)
{
return [$default];
return array_values($approved);
}
$paths = $this->params->get('approved_paths');
$approved = [];
if (!empty($paths))
{
foreach ($paths as $path)
{
$owner = $path->owner ?? null;
$repo = $path->repo ?? null;
if ($owner !== null && $repo !== null)
{
// we make sure to get only the objects
$approved[] = $path;
$approved = ["{$owner}.{$repo}" => $path] + $approved;
}
}
}
// finally we add the default
$approved[] = $default;
return $approved;
return array_values($approved);
}
}

View File

@ -77,6 +77,66 @@
return null;
}
/**
* Get super power core organisation
*
* @return string The super power core organisation
* @since 3.2.0
*/
protected function getSuperpowerscoreorganisation(): string
{
// the VDM default organisation is [joomla]
$organisation = 'joomla';
if ($this->add_custom_gitea_url == 2)
{
return $this->params->get('super_powers_core_organisation', $organisation);
}
return $organisation;
}
/**
* Get super power init repos
*
* @return array The init repositories on Gitea
* @since 3.2.0
*/
protected function getSuperpowersinitrepos(): array
{
// some defaults repos we need by JCB
$repos = [];
// only add custom init with custom gitea
$paths = null;
if ($this->add_custom_gitea_url == 2)
{
$paths = $this->params->get('super_powers_init_repos');
}
if (!empty($paths) && is_array($paths))
{
foreach ($paths as $path)
{
$owner = $path->owner ?? null;
$repo = $path->repo ?? null;
if ($owner !== null && $repo !== null)
{
// we make sure to get only the objects
$repos = ["{$owner}.{$repo}" => $path] + $repos;
}
}
}
else
{
$repos[$this->super_powers_core_organisation . '.super-powers'] = (object) ['owner' => $this->super_powers_core_organisation, 'repo' => 'super-powers', 'branch' => 'master'];
$repos[$this->super_powers_core_organisation . '.gitea'] = (object) ['owner' => $this->super_powers_core_organisation, 'repo' => 'gitea', 'branch' => 'master'];
$repos[$this->super_powers_core_organisation . '.openai'] = (object) ['owner' => $this->super_powers_core_organisation, 'repo' => 'openai', 'branch' => 'master'];
}
return $repos;
}
/**
* get temporary path
*
@ -89,6 +149,33 @@
return $this->config->get('tmp_path');
}
/**
* Get switch to add super powers
*
* @return bool Switch to add super powers
* @since 3.2.0
*/
protected function getAddsuperpowers(): bool
{
return (bool) $this->params->get('powers_repository', 0);
}
/**
* Get switch to add own super powers
*
* @return bool Switch to add own super powers
* @since 3.2.0
*/
protected function getAddownpowers(): bool
{
if ($this->add_super_powers)
{
return (bool) $this->params->get('super_powers_repositories', 0);
}
return false;
}
/**
* Get local super powers repository path
*
@ -104,18 +191,7 @@
return $default;
}
$global = $this->params->get('local_powers_repository_path', $default);
if (!$this->show_advanced_options)
{
return $global;
}
$value = $this->input->post->get('powers_repository', 2, 'INT');
return $value == 1
? $this->input->post->get('local_powers_repository_path', $global, 'PATH')
: $global;
return $this->params->get('local_powers_repository_path', $default);
}
/**
@ -126,27 +202,29 @@
*/
protected function getApprovedpaths(): array
{
$default = (object) ['owner' => 'joomla', 'repo' => 'super-powers', 'branch' => 'master'];
// some defaults repos we need by JCB
$approved = $this->super_powers_init_repos;
if (!$this->add_own_powers)
{
return [$default];
return array_values($approved);
}
$paths = $this->params->get('approved_paths');
$approved = [];
if (!empty($paths))
{
foreach ($paths as $path)
{
$owner = $path->owner ?? null;
$repo = $path->repo ?? null;
if ($owner !== null && $repo !== null)
{
// we make sure to get only the objects
$approved[] = $path;
$approved = ["{$owner}.{$repo}" => $path] + $approved;
}
}
}
// finally we add the default
$approved[] = $default;
return $approved;
return array_values($approved);
}

View File

@ -18,33 +18,34 @@ class Data #Gold {
# Placeholder $placeholder
# Language $language
# Field $field
# FieldName $fieldName
# Filesfolders $filesFolders
# Fieldname $fieldname
# Filesfolders $filesfolders
# Libraries $libraries
# Dynamicget $dynamic
# \JDatabaseDriver $db
+ __construct(?Config $config = null, ?Customcode $customcode = null, ...)
# Dynamicget $dynamicget
# Templatelayout $templatelayout
+ __construct(Config $config, Customcode $customcode, ...)
+ get(int $id = null) : object|array|null
+ exists(int $id = null) : bool
+ set(int $id) : bool
}
note right of Data::__construct
Constructor
Constructor.
since: 3.2.0
arguments:
?Config $config = null
?Customcode $customcode = null
?Gui $gui = null
?Placeholder $placeholder = null
?Language $language = null
?Field $field = null
?FieldName $fieldName = null
?Filesfolders $filesFolders = null
?Libraries $libraries = null
?Dynamicget $dynamic = null
Config $config
Customcode $customcode
Gui $gui
Placeholder $placeholder
Language $language
Field $field
Fieldname $fieldname
Filesfolders $filesfolders
Libraries $libraries
Dynamicget $dynamicget
Templatelayout $templatelayout
?\JDatabaseDriver $db = null
end note

View File

@ -14,17 +14,17 @@ namespace VDM\Joomla\Componentbuilder\Compiler\Joomlamodule;
use Joomla\CMS\Factory;
use Joomla\CMS\Filter\OutputFilter;
use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler;
use VDM\Joomla\Componentbuilder\Compiler\Config;
use VDM\Joomla\Componentbuilder\Compiler\Customcode;
use VDM\Joomla\Componentbuilder\Compiler\Customcode\Gui;
use VDM\Joomla\Componentbuilder\Compiler\Placeholder;
use VDM\Joomla\Componentbuilder\Compiler\Language;
use VDM\Joomla\Componentbuilder\Compiler\Field;
use VDM\Joomla\Componentbuilder\Compiler\Field\Name as FieldName;
use VDM\Joomla\Componentbuilder\Compiler\Field\Name as Fieldname;
use VDM\Joomla\Componentbuilder\Compiler\Model\Filesfolders;
use VDM\Joomla\Componentbuilder\Compiler\Model\Libraries;
use VDM\Joomla\Componentbuilder\Compiler\Dynamicget\Data as Dynamicget;
use VDM\Joomla\Componentbuilder\Compiler\Templatelayout\Data as Templatelayout;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Utilities\String\ClassfunctionHelper;
use VDM\Joomla\Utilities\JsonHelper;
@ -48,7 +48,7 @@ class Data
protected array $data = [];
/**
* Compiler Config
* The Config Class.
*
* @var Config
* @since 3.2.0
@ -56,7 +56,7 @@ class Data
protected Config $config;
/**
* Compiler Customcode
* The Customcode Class.
*
* @var Customcode
* @since 3.2.0
@ -64,31 +64,31 @@ class Data
protected Customcode $customcode;
/**
* Compiler Customcode in Gui
* The Gui Class.
*
* @var Gui
* @since 3.2.0
**/
*/
protected Gui $gui;
/**
* Compiler Placeholder
* The Placeholder Class.
*
* @var Placeholder
* @since 3.2.0
**/
*/
protected Placeholder $placeholder;
/**
* Compiler Language
* The Language Class.
*
* @var Language
* @since 3.2.0
**/
*/
protected Language $language;
/**
* Compiler Field
* The Field Class.
*
* @var Field
* @since 3.2.0
@ -96,23 +96,23 @@ class Data
protected Field $field;
/**
* Compiler field name
* The Name Class.
*
* @var FieldName
* @var Fieldname
* @since 3.2.0
*/
protected FieldName $fieldName;
protected Fieldname $fieldname;
/**
* Compiler Files Folders
* The Filesfolders Class.
*
* @var Filesfolders
* @since 3.2.0
*/
protected Filesfolders $filesFolders;
protected Filesfolders $filesfolders;
/**
* Compiler Libraries Model
* The Libraries Class.
*
* @var Libraries
* @since 3.2.0
@ -120,54 +120,57 @@ class Data
protected Libraries $libraries;
/**
* Compiler Dynamic Get Data
* The Data Class.
*
* @var Dynamicget
* @since 3.2.0
*/
protected Dynamicget $dynamic;
protected Dynamicget $dynamicget;
/**
* Database object to query local DB
* The Data Class.
*
* @var \JDatabaseDriver
* @var Templatelayout
* @since 3.2.0
**/
protected \JDatabaseDriver $db;
*/
protected Templatelayout $templatelayout;
/**
* Constructor
* Constructor.
*
* @param Config|null $config The compiler config object.
* @param Customcode|null $customcode The compiler customcode object.
* @param Gui|null $gui The compiler customcode gui.
* @param Placeholder|null $placeholder The compiler placeholder object.
* @param Language|null $language The compiler Language object.
* @param Field|null $field The compiler field data object.
* @param FieldName|null $fieldName The compiler field name object.
* @param Filesfolders|null $filesFolders The compiler files folders object.
* @param Libraries|null $libraries The compiler libraries model object.
* @param Dynamicget|null $dynamic The compiler dynamic get data object.
* @param Config $config The Config Class.
* @param Customcode $customcode The Customcode Class.
* @param Gui $gui The Gui Class.
* @param Placeholder $placeholder The Placeholder Class.
* @param Language $language The Language Class.
* @param Field $field The Field Class.
* @param Fieldname $fieldname The Name Class.
* @param Filesfolders $filesfolders The Filesfolders Class.
* @param Libraries $libraries The Libraries Class.
* @param Dynamicget $dynamicget The Data Class.
* @param Templatelayout $templatelayout The Data Class.
* @param \JDatabaseDriver|null $db The database object.
*
* @since 3.2.0
*/
public function __construct(?Config $config = null, ?Customcode $customcode = null,
?Gui $gui = null, ?Placeholder $placeholder = null,
?Language $language = null, ?Field $field = null, ?FieldName $fieldName = null,
?Filesfolders $filesFolders = null, ?Libraries $libraries = null,
?Dynamicget $dynamic = null, ?\JDatabaseDriver $db = null)
public function __construct(Config $config, Customcode $customcode, Gui $gui,
Placeholder $placeholder, Language $language,
Field $field, Fieldname $fieldname,
Filesfolders $filesfolders, Libraries $libraries,
Dynamicget $dynamicget, Templatelayout $templatelayout,
?\JDatabaseDriver $db = null)
{
$this->config = $config ?: Compiler::_('Config');
$this->customcode = $customcode ?: Compiler::_('Customcode');
$this->gui = $gui ?: Compiler::_('Customcode.Gui');
$this->placeholder = $placeholder ?: Compiler::_('Placeholder');
$this->language = $language ?: Compiler::_('Language');
$this->field = $field ?: Compiler::_('Field');
$this->fieldName = $fieldName ?: Compiler::_('Field.Name');
$this->filesFolders = $filesFolders ?: Compiler::_('Model.Filesfolders');
$this->libraries = $libraries ?: Compiler::_('Model.Libraries');
$this->dynamic = $dynamic ?: Compiler::_('Dynamicget.Data');
$this->config = $config;
$this->customcode = $customcode;
$this->gui = $gui;
$this->placeholder = $placeholder;
$this->language = $language;
$this->field = $field;
$this->fieldname = $fieldname;
$this->filesfolders = $filesfolders;
$this->libraries = $libraries;
$this->dynamicget = $dynamicget;
$this->templatelayout = $templatelayout;
$this->db = $db ?: Factory::getDbo();
}
@ -520,6 +523,11 @@ class Data
),
$guiMapper
);
// check if we have template or layouts to load
$this->templatelayout->set(
$module->mod_code , $module->code_name
);
}
else
{
@ -570,6 +578,11 @@ class Data
),
$guiMapper
);
// check if we have template or layouts to load
$this->templatelayout->set(
$module->default , $module->code_name
);
}
else
{
@ -760,7 +773,7 @@ class Data
foreach ($form['fields'] as $field)
{
// so first we lock the field name in
$this->fieldName->get(
$this->fieldname->get(
$field, $module->key, $unique
);
// add the fields to the global form file builder
@ -787,7 +800,7 @@ class Data
foreach ($form['fields'] as $field)
{
// so first we lock the field name in
$this->fieldName->get(
$this->fieldname->get(
$field, $module->key, $unique
);
// add the fields to the config builder
@ -807,7 +820,7 @@ class Data
unset($module->fields);
// set files and folders
$this->filesFolders->set($module);
$this->filesfolders->set($module);
// set libraries
$this->libraries->set($module->code_name, $module);
@ -920,7 +933,7 @@ class Data
else
{
$module->{$server} = 0;
// only change this for sales server (update server can be added loacaly to the zip file)
// only change this for sales server (update server can be added locally to the zip file)
if ('sales_server' === $server)
{
$module->{'add_' . $server} = 0;
@ -952,6 +965,5 @@ class Data
return false;
}
}

View File

@ -7,7 +7,7 @@
protected array $data = [];
/**
* Compiler Config
* The Config Class.
*
* @var Config
* @since 3.2.0
@ -15,7 +15,7 @@
protected Config $config;
/**
* Compiler Customcode
* The Customcode Class.
*
* @var Customcode
* @since 3.2.0
@ -23,31 +23,31 @@
protected Customcode $customcode;
/**
* Compiler Customcode in Gui
* The Gui Class.
*
* @var Gui
* @since 3.2.0
**/
*/
protected Gui $gui;
/**
* Compiler Placeholder
* The Placeholder Class.
*
* @var Placeholder
* @since 3.2.0
**/
*/
protected Placeholder $placeholder;
/**
* Compiler Language
* The Language Class.
*
* @var Language
* @since 3.2.0
**/
*/
protected Language $language;
/**
* Compiler Field
* The Field Class.
*
* @var Field
* @since 3.2.0
@ -55,23 +55,23 @@
protected Field $field;
/**
* Compiler field name
* The Name Class.
*
* @var FieldName
* @var Fieldname
* @since 3.2.0
*/
protected FieldName $fieldName;
protected Fieldname $fieldname;
/**
* Compiler Files Folders
* The Filesfolders Class.
*
* @var Filesfolders
* @since 3.2.0
*/
protected Filesfolders $filesFolders;
protected Filesfolders $filesfolders;
/**
* Compiler Libraries Model
* The Libraries Class.
*
* @var Libraries
* @since 3.2.0
@ -79,54 +79,57 @@
protected Libraries $libraries;
/**
* Compiler Dynamic Get Data
* The Data Class.
*
* @var Dynamicget
* @since 3.2.0
*/
protected Dynamicget $dynamic;
protected Dynamicget $dynamicget;
/**
* Database object to query local DB
* The Data Class.
*
* @var \JDatabaseDriver
* @var Templatelayout
* @since 3.2.0
**/
protected \JDatabaseDriver $db;
*/
protected Templatelayout $templatelayout;
/**
* Constructor
* Constructor.
*
* @param Config|null $config The compiler config object.
* @param Customcode|null $customcode The compiler customcode object.
* @param Gui|null $gui The compiler customcode gui.
* @param Placeholder|null $placeholder The compiler placeholder object.
* @param Language|null $language The compiler Language object.
* @param Field|null $field The compiler field data object.
* @param FieldName|null $fieldName The compiler field name object.
* @param Filesfolders|null $filesFolders The compiler files folders object.
* @param Libraries|null $libraries The compiler libraries model object.
* @param Dynamicget|null $dynamic The compiler dynamic get data object.
* @param Config $config The Config Class.
* @param Customcode $customcode The Customcode Class.
* @param Gui $gui The Gui Class.
* @param Placeholder $placeholder The Placeholder Class.
* @param Language $language The Language Class.
* @param Field $field The Field Class.
* @param Fieldname $fieldname The Name Class.
* @param Filesfolders $filesfolders The Filesfolders Class.
* @param Libraries $libraries The Libraries Class.
* @param Dynamicget $dynamicget The Data Class.
* @param Templatelayout $templatelayout The Data Class.
* @param \JDatabaseDriver|null $db The database object.
*
* @since 3.2.0
*/
public function __construct(?Config $config = null, ?Customcode $customcode = null,
?Gui $gui = null, ?Placeholder $placeholder = null,
?Language $language = null, ?Field $field = null, ?FieldName $fieldName = null,
?Filesfolders $filesFolders = null, ?Libraries $libraries = null,
?Dynamicget $dynamic = null, ?\JDatabaseDriver $db = null)
public function __construct(Config $config, Customcode $customcode, Gui $gui,
Placeholder $placeholder, Language $language,
Field $field, Fieldname $fieldname,
Filesfolders $filesfolders, Libraries $libraries,
Dynamicget $dynamicget, Templatelayout $templatelayout,
?\JDatabaseDriver $db = null)
{
$this->config = $config ?: Compiler::_('Config');
$this->customcode = $customcode ?: Compiler::_('Customcode');
$this->gui = $gui ?: Compiler::_('Customcode.Gui');
$this->placeholder = $placeholder ?: Compiler::_('Placeholder');
$this->language = $language ?: Compiler::_('Language');
$this->field = $field ?: Compiler::_('Field');
$this->fieldName = $fieldName ?: Compiler::_('Field.Name');
$this->filesFolders = $filesFolders ?: Compiler::_('Model.Filesfolders');
$this->libraries = $libraries ?: Compiler::_('Model.Libraries');
$this->dynamic = $dynamic ?: Compiler::_('Dynamicget.Data');
$this->config = $config;
$this->customcode = $customcode;
$this->gui = $gui;
$this->placeholder = $placeholder;
$this->language = $language;
$this->field = $field;
$this->fieldname = $fieldname;
$this->filesfolders = $filesfolders;
$this->libraries = $libraries;
$this->dynamicget = $dynamicget;
$this->templatelayout = $templatelayout;
$this->db = $db ?: Factory::getDbo();
}
@ -479,6 +482,11 @@
),
$guiMapper
);
// check if we have template or layouts to load
$this->templatelayout->set(
$module->mod_code , $module->code_name
);
}
else
{
@ -529,6 +537,11 @@
),
$guiMapper
);
// check if we have template or layouts to load
$this->templatelayout->set(
$module->default , $module->code_name
);
}
else
{
@ -719,7 +732,7 @@
foreach ($form['fields'] as $field)
{
// so first we lock the field name in
$this->fieldName->get(
$this->fieldname->get(
$field, $module->key, $unique
);
// add the fields to the global form file builder
@ -746,7 +759,7 @@
foreach ($form['fields'] as $field)
{
// so first we lock the field name in
$this->fieldName->get(
$this->fieldname->get(
$field, $module->key, $unique
);
// add the fields to the config builder
@ -766,7 +779,7 @@
unset($module->fields);
// set files and folders
$this->filesFolders->set($module);
$this->filesfolders->set($module);
// set libraries
$this->libraries->set($module->code_name, $module);
@ -879,7 +892,7 @@
else
{
$module->{$server} = 0;
// only change this for sales server (update server can be added loacaly to the zip file)
// only change this for sales server (update server can be added locally to the zip file)
if ('sales_server' === $server)
{
$module->{'add_' . $server} = 0;

View File

@ -11,49 +11,49 @@
"type": "class",
"use_selection": {
"use_selection0": {
"use": "d910d8b8-4c23-4f3e-8cda-438f2d2bd7ac",
"as": "Compiler"
},
"use_selection1": {
"use": "fa4bf18e-301e-42e3-91fb-6e0096c07adc",
"as": "default"
},
"use_selection2": {
"use_selection1": {
"use": "313b43c4-98c3-4f62-9177-2d73ec8eba31",
"as": "default"
},
"use_selection3": {
"use_selection2": {
"use": "1bd48df2-4f7e-4581-9fe9-4b54e59105e3",
"as": "default"
},
"use_selection4": {
"use_selection3": {
"use": "06453ada-e370-49f0-b262-e3f5a8ed0c2c",
"as": "default"
},
"use_selection5": {
"use_selection4": {
"use": "8eee7df5-2775-41a9-9372-c46c5939a252",
"as": "default"
},
"use_selection6": {
"use_selection5": {
"use": "d7ba2d5d-10b6-470d-978d-9f91ea65ee75",
"as": "default"
},
"use_selection7": {
"use_selection6": {
"use": "9387215f-a965-4421-acf3-5e8f9d11382f",
"as": "FieldName"
"as": "Fieldname"
},
"use_selection8": {
"use_selection7": {
"use": "f4578c04-a81e-4218-b80d-b0612196eaf0",
"as": "default"
},
"use_selection9": {
"use_selection8": {
"use": "59895f37-50c8-4af3-9dad-230e18841953",
"as": "default"
},
"use_selection10": {
"use_selection9": {
"use": "05c49a1f-ba5b-4be1-b3d0-4a74c42f7a46",
"as": "Dynamicget"
},
"use_selection10": {
"use": "39ea8150-f124-4e47-909d-641bf1c96d5e",
"as": "Templatelayout"
},
"use_selection11": {
"use": "0a59c65c-9daf-4bc9-baf4-e063ff9e6a8a",
"as": "default"

View File

@ -18,6 +18,8 @@ class Config #Gold {
# getAddcustomgiteaurl() : int
# getCustomgiteaurl() : ?string
# getCustomgiteatoken() : ?string
# getSuperpowerscoreorganisation() : string
# getSuperpowerscorerepos() : array
# getAddcontributors() : bool
# getAddajax() : bool
# getAddsiteajax() : bool
@ -118,6 +120,20 @@ note right of Config::getCustomgiteatoken
return: ?string
end note
note left of Config::getSuperpowerscoreorganisation
Get super power core organisation
since: 3.2.0
return: string
end note
note right of Config::getSuperpowerscorerepos
Get super power core repos
since: 3.2.0
return: array
end note
note left of Config::getAddcontributors
get add contributors switch

View File

@ -111,6 +111,73 @@ class Config extends BaseConfig
return null;
}
/**
* Get super power core organisation
*
* @return string The super power core organisation
* @since 3.2.0
*/
protected function getSuperpowerscoreorganisation(): string
{
// the VDM default organisation is [joomla]
$organisation = 'joomla';
if ($this->add_custom_gitea_url == 2)
{
return $this->params->get('super_powers_core_organisation', $organisation);
}
return $organisation;
}
/**
* Get super power core repos
*
* @return array The core repositories on Gitea
* @since 3.2.0
*/
protected function getSuperpowerscorerepos(): array
{
// some defaults repos we need by JCB
$repos = [];
// only add custom init with custom gitea
$paths = null;
if ($this->add_custom_gitea_url == 2)
{
$paths = $this->params->get('super_powers_core_repos');
}
if (!empty($paths) && is_array($paths))
{
foreach ($paths as $path)
{
$owner = $path->owner ?? null;
$repo = $path->repo ?? null;
if ($owner !== null && $repo !== null)
{
// we make sure to get only the objects
$repos = ["{$owner}.{$repo}" => $path] + $repos;
}
}
}
else
{
$repos[$this->super_powers_core_organisation . '.super-powers'] = (object) ['owner' => $this->super_powers_core_organisation, 'repo' => 'super-powers', 'branch' => 'master'];
$repos[$this->super_powers_core_organisation . '.jcb-compiler'] = (object) ['owner' => $this->super_powers_core_organisation, 'repo' => 'jcb-compiler', 'branch' => 'master'];
$repos[$this->super_powers_core_organisation . '.jcb-packager'] = (object) ['owner' => $this->super_powers_core_organisation, 'repo' => 'jcb-packager', 'branch' => 'master'];
$repos[$this->super_powers_core_organisation . '.phpseclib'] = (object) ['owner' => $this->super_powers_core_organisation, 'repo' => 'phpseclib', 'branch' => 'master'];
$repos[$this->super_powers_core_organisation . '.search'] = (object) ['owner' => $this->super_powers_core_organisation, 'repo' => 'search', 'branch' => 'master'];
$repos[$this->super_powers_core_organisation . '.gitea'] = (object) ['owner' => $this->super_powers_core_organisation, 'repo' => 'gitea', 'branch' => 'master'];
$repos[$this->super_powers_core_organisation . '.openai'] = (object) ['owner' => $this->super_powers_core_organisation, 'repo' => 'openai', 'branch' => 'master'];
$repos[$this->super_powers_core_organisation . '.minify'] = (object) ['owner' => $this->super_powers_core_organisation, 'repo' => 'minify', 'branch' => 'master'];
$repos[$this->super_powers_core_organisation . '.psr'] = (object) ['owner' => $this->super_powers_core_organisation, 'repo' => 'psr', 'branch' => 'master'];
$repos[$this->super_powers_core_organisation . '.fof'] = (object) ['owner' => $this->super_powers_core_organisation, 'repo' => 'fof', 'branch' => 'master'];
}
return $repos;
}
/**
* get add contributors switch
*
@ -630,20 +697,11 @@ class Config extends BaseConfig
protected function getApprovedpaths(): array
{
// some defaults repos we need by JCB
$approved = [];
$approved['joomla.super-powers'] = (object) ['owner' => 'joomla', 'repo' => 'super-powers', 'branch' => 'master'];
$approved['joomla.jcb-compiler'] = (object) ['owner' => 'joomla', 'repo' => 'jcb-compiler', 'branch' => 'master'];
$approved['joomla.phpseclib'] = (object) ['owner' => 'joomla', 'repo' => 'phpseclib', 'branch' => 'master'];
$approved['joomla.search'] = (object) ['owner' => 'joomla', 'repo' => 'search', 'branch' => 'master'];
$approved['joomla.gitea'] = (object) ['owner' => 'joomla', 'repo' => 'gitea', 'branch' => 'master'];
$approved['joomla.openai'] = (object) ['owner' => 'joomla', 'repo' => 'openai', 'branch' => 'master'];
$approved['joomla.minify'] = (object) ['owner' => 'joomla', 'repo' => 'minify', 'branch' => 'master'];
$approved['joomla.psr'] = (object) ['owner' => 'joomla', 'repo' => 'psr', 'branch' => 'master'];
$approved['joomla.fof'] = (object) ['owner' => 'joomla', 'repo' => 'fof', 'branch' => 'master'];
$approved = $this->super_powers_core_repos;
if (!$this->add_own_powers)
{
return $approved;
return array_values($approved);
}
$paths = $this->params->get('approved_paths');
@ -762,6 +820,7 @@ class Config extends BaseConfig
{
// get posted value
$value = $this->input->post->get('add_placeholders', 2, 'INT');
// get global value
if ($value > 1)
{
@ -780,6 +839,7 @@ class Config extends BaseConfig
{
// get posted value
$value = $this->input->post->get('powers', 2, 'INT');
// get global value
if ($value > 1)
{
@ -946,6 +1006,5 @@ class Config extends BaseConfig
{
return 2; // default is version 2
}
}

View File

@ -77,6 +77,73 @@
return null;
}
/**
* Get super power core organisation
*
* @return string The super power core organisation
* @since 3.2.0
*/
protected function getSuperpowerscoreorganisation(): string
{
// the VDM default organisation is [joomla]
$organisation = 'joomla';
if ($this->add_custom_gitea_url == 2)
{
return $this->params->get('super_powers_core_organisation', $organisation);
}
return $organisation;
}
/**
* Get super power core repos
*
* @return array The core repositories on Gitea
* @since 3.2.0
*/
protected function getSuperpowerscorerepos(): array
{
// some defaults repos we need by JCB
$repos = [];
// only add custom init with custom gitea
$paths = null;
if ($this->add_custom_gitea_url == 2)
{
$paths = $this->params->get('super_powers_core_repos');
}
if (!empty($paths) && is_array($paths))
{
foreach ($paths as $path)
{
$owner = $path->owner ?? null;
$repo = $path->repo ?? null;
if ($owner !== null && $repo !== null)
{
// we make sure to get only the objects
$repos = ["{$owner}.{$repo}" => $path] + $repos;
}
}
}
else
{
$repos[$this->super_powers_core_organisation . '.super-powers'] = (object) ['owner' => $this->super_powers_core_organisation, 'repo' => 'super-powers', 'branch' => 'master'];
$repos[$this->super_powers_core_organisation . '.jcb-compiler'] = (object) ['owner' => $this->super_powers_core_organisation, 'repo' => 'jcb-compiler', 'branch' => 'master'];
$repos[$this->super_powers_core_organisation . '.jcb-packager'] = (object) ['owner' => $this->super_powers_core_organisation, 'repo' => 'jcb-packager', 'branch' => 'master'];
$repos[$this->super_powers_core_organisation . '.phpseclib'] = (object) ['owner' => $this->super_powers_core_organisation, 'repo' => 'phpseclib', 'branch' => 'master'];
$repos[$this->super_powers_core_organisation . '.search'] = (object) ['owner' => $this->super_powers_core_organisation, 'repo' => 'search', 'branch' => 'master'];
$repos[$this->super_powers_core_organisation . '.gitea'] = (object) ['owner' => $this->super_powers_core_organisation, 'repo' => 'gitea', 'branch' => 'master'];
$repos[$this->super_powers_core_organisation . '.openai'] = (object) ['owner' => $this->super_powers_core_organisation, 'repo' => 'openai', 'branch' => 'master'];
$repos[$this->super_powers_core_organisation . '.minify'] = (object) ['owner' => $this->super_powers_core_organisation, 'repo' => 'minify', 'branch' => 'master'];
$repos[$this->super_powers_core_organisation . '.psr'] = (object) ['owner' => $this->super_powers_core_organisation, 'repo' => 'psr', 'branch' => 'master'];
$repos[$this->super_powers_core_organisation . '.fof'] = (object) ['owner' => $this->super_powers_core_organisation, 'repo' => 'fof', 'branch' => 'master'];
}
return $repos;
}
/**
* get add contributors switch
*
@ -596,20 +663,11 @@
protected function getApprovedpaths(): array
{
// some defaults repos we need by JCB
$approved = [];
$approved['joomla.super-powers'] = (object) ['owner' => 'joomla', 'repo' => 'super-powers', 'branch' => 'master'];
$approved['joomla.jcb-compiler'] = (object) ['owner' => 'joomla', 'repo' => 'jcb-compiler', 'branch' => 'master'];
$approved['joomla.phpseclib'] = (object) ['owner' => 'joomla', 'repo' => 'phpseclib', 'branch' => 'master'];
$approved['joomla.search'] = (object) ['owner' => 'joomla', 'repo' => 'search', 'branch' => 'master'];
$approved['joomla.gitea'] = (object) ['owner' => 'joomla', 'repo' => 'gitea', 'branch' => 'master'];
$approved['joomla.openai'] = (object) ['owner' => 'joomla', 'repo' => 'openai', 'branch' => 'master'];
$approved['joomla.minify'] = (object) ['owner' => 'joomla', 'repo' => 'minify', 'branch' => 'master'];
$approved['joomla.psr'] = (object) ['owner' => 'joomla', 'repo' => 'psr', 'branch' => 'master'];
$approved['joomla.fof'] = (object) ['owner' => 'joomla', 'repo' => 'fof', 'branch' => 'master'];
$approved = $this->super_powers_core_repos;
if (!$this->add_own_powers)
{
return $approved;
return array_values($approved);
}
$paths = $this->params->get('approved_paths');
@ -728,6 +786,7 @@
{
// get posted value
$value = $this->input->post->get('add_placeholders', 2, 'INT');
// get global value
if ($value > 1)
{
@ -746,6 +805,7 @@
{
// get posted value
$value = $this->input->post->get('powers', 2, 'INT');
// get global value
if ($value > 1)
{