diff --git a/src/02bc072b-1e89-46c1-9732-4da77b1a9ac9/code.php b/src/02bc072b-1e89-46c1-9732-4da77b1a9ac9/code.php
index f316dc4..b307743 100644
--- a/src/02bc072b-1e89-46c1-9732-4da77b1a9ac9/code.php
+++ b/src/02bc072b-1e89-46c1-9732-4da77b1a9ac9/code.php
@@ -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')
);
}
diff --git a/src/02bc072b-1e89-46c1-9732-4da77b1a9ac9/code.power b/src/02bc072b-1e89-46c1-9732-4da77b1a9ac9/code.power
index c815fa9..b05bc5b 100644
--- a/src/02bc072b-1e89-46c1-9732-4da77b1a9ac9/code.power
+++ b/src/02bc072b-1e89-46c1-9732-4da77b1a9ac9/code.power
@@ -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')
);
}
diff --git a/src/071c7cff-4c88-4b80-bd99-066c572dcb71/README.md b/src/071c7cff-4c88-4b80-bd99-066c572dcb71/README.md
index db27df1..5b921b6 100644
--- a/src/071c7cff-4c88-4b80-bd99-066c572dcb71/README.md
+++ b/src/071c7cff-4c88-4b80-bd99-066c572dcb71/README.md
@@ -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,12 +78,141 @@ 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
```
diff --git a/src/071c7cff-4c88-4b80-bd99-066c572dcb71/code.php b/src/071c7cff-4c88-4b80-bd99-066c572dcb71/code.php
index d3d0d14..8379e6e 100644
--- a/src/071c7cff-4c88-4b80-bd99-066c572dcb71/code.php
+++ b/src/071c7cff-4c88-4b80-bd99-066c572dcb71/code.php
@@ -12,13 +12,12 @@
namespace VDM\Joomla\Componentbuilder\Compiler\Joomlamodule;
-use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler;
use VDM\Joomla\Componentbuilder\Compiler\Joomlamodule\Data as Module;
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;
@@ -26,6 +25,7 @@ use VDM\Joomla\Componentbuilder\Compiler\Utilities\Files;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Placefix;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Line;
+use VDM\Joomla\Componentbuilder\Compiler\Builder\TemplateData;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Utilities\ObjectHelper;
use VDM\Joomla\Utilities\StringHelper;
@@ -40,117 +40,126 @@ use VDM\Joomla\Utilities\FileHelper;
class Structure
{
/**
- * Compiler Joomla Module Data Class
+ * The Data Class.
*
- * @var Module
+ * @var Module
* @since 3.2.0
*/
protected Module $module;
/**
- * Compiler Component
+ * The Component Class.
*
- * @var Component
+ * @var Component
* @since 3.2.0
- **/
+ */
protected Component $component;
/**
- * Compiler Config
+ * The Config Class.
*
- * @var Config
+ * @var Config
* @since 3.2.0
*/
protected Config $config;
/**
- * The compiler registry
+ * The Registry Class.
*
- * @var Registry
+ * @var Registry
* @since 3.2.0
*/
protected Registry $registry;
/**
- * Compiler Customcode Dispenser
+ * The Dispenser Class.
*
- * @var Dispenser
+ * @var Dispenser
* @since 3.2.0
*/
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
+ * @var Counter
* @since 3.2.0
*/
protected Counter $counter;
/**
- * Compiler Utilities Folder
+ * The Folder Class.
*
- * @var Folder
+ * @var Folder
* @since 3.2.0
*/
protected Folder $folder;
/**
- * Compiler Utilities File
+ * The File Class.
*
- * @var File
+ * @var File
* @since 3.2.0
*/
protected File $file;
/**
- * Compiler Utilities Files
+ * The Files Class.
*
- * @var Files
+ * @var Files
* @since 3.2.0
*/
protected Files $files;
/**
- * Constructor
+ * The TemplateData Class.
*
- * @param Module|null $module The compiler Joomla module 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.
+ * @var TemplateData
+ * @since 3.2.0
+ */
+ protected TemplateData $templatedata;
+
+ /**
+ * Constructor.
+ *
+ * @param Module $module 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.
+ * @param TemplateData $templatedata The TemplateData Class.
*
* @since 3.2.0
*/
- public function __construct(?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)
+ public function __construct(Module $module, Component $component, Config $config,
+ Registry $registry, Dispenser $dispenser, Event $event,
+ Counter $counter, Folder $folder, File $file,
+ Files $files, TemplateData $templatedata)
{
- $this->module = $module ?: Compiler::_('Joomlamodule.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->module = $module;
+ $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;
+ $this->templatedata = $templatedata;
}
/**
@@ -166,6 +175,7 @@ class Structure
// for plugin event TODO change event api signatures
$component_context = $this->config->component_context;
$modules = $this->module->get();
+
// Trigger Event: jcb_ce_onBeforeSetModules
$this->event->trigger(
'jcb_ce_onBeforeBuildModules',
@@ -176,13 +186,10 @@ class Structure
{
if (ObjectHelper::check($module)
&& isset($module->folder_name)
- && StringHelper::check(
- $module->folder_name
- ))
+ && StringHelper::check($module->folder_name))
{
// module path
- $module->folder_path = $this->config->get('compiler_path', JPATH_COMPONENT_ADMINISTRATOR . '/compiler') . '/'
- . $module->folder_name;
+ $this->modulePath($module);
// set the module paths
$this->registry->set('dynamic_paths.' . $module->key, $module->folder_path);
@@ -190,279 +197,38 @@ class Structure
// make sure there is no old build
$this->folder->remove($module->folder_path);
- // creat the main module folder
+ // create the main module folder
$this->folder->create($module->folder_path);
- // set main mod file
- $fileDetails = array('path' => $module->folder_path . '/'
- . $module->file_name . '.php',
- 'name' => $module->file_name . '.php',
- 'zip' => $module->file_name . '.php');
- $this->file->write(
- $fileDetails['path'],
- 'files->appendArray($module->key, $fileDetails);
+ // create the main module file
+ $this->setMainModFile($module);
- // count the file created
- $this->counter->file++;
-
- // set custom_get
- if ($module->custom_get)
- {
- $fileDetails = array(
- 'path' => $module->folder_path . '/data.php',
- 'name' => 'data.php',
- 'zip' => 'data.php'
- );
- $this->file->write(
- $fileDetails['path'],
- 'official_name . ' Data'
- . PHP_EOL .
- ' */' . PHP_EOL .
- "class " . $module->class_data_name
- . ' extends \JObject' . PHP_EOL .
- "{" . Placefix::_h('DYNAMICGETS') . "}"
- . PHP_EOL
- );
- $this->files->appendArray($module->key, $fileDetails);
-
- // count the file created
- $this->counter->file++;
- }
+ // creat the custom get file
+ $this->setCustomGet($module);
// set helper file
- if ($module->add_class_helper >= 1)
- {
- $fileDetails = array('path' => $module->folder_path
- . '/helper.php',
- 'name' => 'helper.php',
- 'zip' => 'helper.php');
- $this->file->write(
- $fileDetails['path'],
- 'files->appendArray($module->key, $fileDetails);
-
- // count the file created
- $this->counter->file++;
- }
+ $this->setHelperFile($module);
// set main xml file
- $fileDetails = array('path' => $module->folder_path . '/'
- . $module->file_name . '.xml',
- 'name' => $module->file_name . '.xml',
- 'zip' => $module->file_name . '.xml');
- $this->file->write(
- $fileDetails['path'],
- $this->getXML($module)
- );
- $this->files->appendArray($module->key, $fileDetails);
-
- // count the file created
- $this->counter->file++;
+ $this->setMainXmlFile($module);
// set tmpl folder
$this->folder->create($module->folder_path . '/tmpl');
// set default file
- $fileDetails = array('path' => $module->folder_path
- . '/tmpl/default.php',
- 'name' => 'default.php',
- 'zip' => 'tmpl/default.php');
- $this->file->write(
- $fileDetails['path'],
- 'files->appendArray($module->key, $fileDetails);
+ $this->setDefaultFile($module);
- // count the file created
- $this->counter->file++;
+ // set custom default files
+ $this->setTemplateFiles($module);
// set install script if needed
- if ($module->add_install_script)
- {
- $fileDetails = [
- 'path' => $module->folder_path . '/script.php',
- 'name' => 'script.php',
- 'zip' => 'script.php'
- ];
- $this->file->write(
- $fileDetails['path'],
- 'files->appendArray($module->key, $fileDetails);
-
- // count the file created
- $this->counter->file++;
- }
+ $this->setInstallScript($module);
// set readme if found
- if ($module->addreadme)
- {
- $fileDetails = [
- 'path' => $module->folder_path . '/README.md',
- 'name' => 'README.md',
- 'zip' => 'README.md'
- ];
- $this->file->write($fileDetails['path'], $module->readme);
- $this->files->appendArray($module->key, $fileDetails);
+ $this->setReadme($module);
- // count the file created
- $this->counter->file++;
- }
-
- // set the folders target path
- $target_path = '';
- if ($module->target_client === 'administrator')
- {
- $target_path = '/administrator';
- }
-
- // check if we have custom fields needed for scripts
- $module->add_scripts_field = false;
- $field_script_bucket = [];
-
- // add any css from the fields
- if (($css = $this->dispenser->get(
- 'css_view', $module->key
- )) !== null
- && StringHelper::check($css))
- {
- // make sure this script does not have PHP
- if (strpos((string) $css, 'add_scripts_field = true;
-
- // create the css folder
- $this->folder->create($module->folder_path . '/css');
-
- // add the CSS file
- $fileDetails = [
- 'path' => $module->folder_path . '/css/mod_admin.css',
- 'name' => 'mod_admin.css',
- 'zip' => 'mod_admin.css'
- ];
- $this->file->write(
- $fileDetails['path'],
- Placefix::_h('BOM') . PHP_EOL
- . PHP_EOL . $css
- );
- $this->files->appendArray($module->key, $fileDetails);
-
- // count the file created
- $this->counter->file++;
-
- // add the field script
- $field_script_bucket[] = Indent::_(2) . "//"
- . Line::_(__Line__, __Class__) . " Custom CSS";
- $field_script_bucket[] = Indent::_(2)
- . "\$document->addStyleSheet('" . $target_path
- . "/modules/" . $module->folder_name
- . "/css/mod_admin.css', ['version' => 'auto', 'relative' => true]);";
- }
- }
-
- // add any JavaScript from the fields
- if (($javascript = $this->dispenser->get(
- 'view_footer', $module->key
- )) !== null
- && StringHelper::check($javascript))
- {
- // make sure this script does not have PHP
- if (strpos((string) $javascript, 'add_scripts_field = true;
-
- // add the JavaScript file
- $this->folder->create($module->folder_path . '/js');
-
- // add the CSS file
- $fileDetails = [
- 'path' => $module->folder_path . '/js/mod_admin.js',
- 'name' => 'mod_admin.js',
- 'zip' => 'mod_admin.js'
- ];
- $this->file->write(
- $fileDetails['path'],
- Placefix::_h('BOM') . PHP_EOL
- . PHP_EOL . $javascript
- );
- $this->files->appendArray($module->key, $fileDetails);
-
- // count the file created
- $this->counter->file++;
-
- // add the field script
- $field_script_bucket[] = Indent::_(2) . "//"
- . Line::_(__Line__, __Class__) . " Custom JS";
- $field_script_bucket[] = Indent::_(2)
- . "\$document->addScript('" . $target_path
- . "/modules/" . $module->folder_name
- . "/js/mod_admin.js', ['version' => 'auto', 'relative' => true]);";
- }
- }
-
- // set fields folders if needed
- if ($module->add_scripts_field
- || (isset($module->fields_rules_paths)
- && $module->fields_rules_paths == 2))
- {
- // create fields folder
- $this->folder->create($module->folder_path . '/fields');
-
- // add the custom script field
- if ($module->add_scripts_field)
- {
- $fileDetails = [
- 'path' => $module->folder_path
- . '/fields/modadminvvvvvvvdm.php',
- 'name' => 'modadminvvvvvvvdm.php',
- 'zip' => 'modadminvvvvvvvdm.php'
- ];
- $this->file->write(
- $fileDetails['path'],
- $this->getCustomScriptField(
- $field_script_bucket
- )
- );
- $this->files->appendArray($module->key, $fileDetails);
-
- // count the file created
- $this->counter->file++;
- }
- }
+ // set the CSS and JavaScript in form
+ $this->setCssJsForm($module);
// set rules folders if needed
if (isset($module->fields_rules_paths)
@@ -472,334 +238,28 @@ class Structure
$this->folder->create($module->folder_path . '/rules');
}
- // set forms folder if needed
- if (isset($module->form_files)
- && ArrayHelper::check(
- $module->form_files
- ))
- {
- // create forms folder
- $this->folder->create($module->folder_path . '/forms');
-
- // set the template files
- foreach ($module->form_files as $file => $fields)
- {
- // set file details
- $fileDetails = [
- 'path' => $module->folder_path . '/forms/' . $file . '.xml',
- 'name' => $file . '.xml',
- 'zip' => 'forms/' . $file . '.xml'
- ];
-
- // build basic XML
- $xml = '';
- $xml .= PHP_EOL . '';
-
- // search if we must add the component path
- $add_component_path = false;
- foreach ($fields as $field_name => $fieldsets)
- {
- if (!$add_component_path)
- {
- foreach ($fieldsets as $fieldset => $field)
- {
- if (!$add_component_path
- && isset(
- $module->fieldsets_paths[$file
- . $field_name . $fieldset]
- )
- && $module->fieldsets_paths[$file
- . $field_name . $fieldset] == 1)
- {
- $add_component_path = true;
- }
- }
- }
- }
-
- // only add if part of the component field types path is required
- if ($add_component_path)
- {
- $xml .= PHP_EOL . '
';
-
- // add xml to file
- $this->file->write($fileDetails['path'], $xml);
- $this->files->appendArray($module->key, $fileDetails);
-
- // count the file created
- $this->counter->file++;
- }
- }
+ // set forms folder/files if needed
+ $this->setForms($module);
// set SQL stuff if needed
- if ($module->add_sql || $module->add_sql_uninstall)
- {
- // create SQL folder
- $this->folder->create($module->folder_path . '/sql');
+ $this->setSQL($module);
- // create mysql folder
- $this->folder->create(
- $module->folder_path . '/sql/mysql'
- );
-
- // now set the install file
- if ($module->add_sql)
- {
- $this->file->write(
- $module->folder_path . '/sql/mysql/install.sql',
- $module->sql
- );
-
- // count the file created
- $this->counter->file++;
- }
-
- // now set the uninstall file
- if ($module->add_sql_uninstall)
- {
- $this->file->write(
- $module->folder_path
- . '/sql/mysql/uninstall.sql',
- $module->sql_uninstall
- );
-
- // count the file created
- $this->counter->file++;
- }
- }
-
- // creat the language folder
+ // create the language folder
$this->folder->create($module->folder_path . '/language');
+
// also create the lang tag folder
$this->folder->create(
$module->folder_path . '/language/' . $this->config->get('lang_tag', 'en-GB')
);
- // check if this lib has files
- if (isset($module->files)
- && ArrayHelper::check($module->files))
- {
- // add to component files
- foreach ($module->files as $file)
- {
- // set the pathfinder
- $file['target_type'] = $module->target_type;
- $file['target_id'] = $module->id;
- $this->component->appendArray('files', $file);
- }
- }
+ // check if this module has files
+ $this->setFiles($module);
- // check if this lib has folders
- if (isset($module->folders)
- && ArrayHelper::check($module->folders))
- {
- // add to component folders
- foreach ($module->folders as $folder)
- {
- // set the pathfinder
- $folder['target_type'] = $module->target_type;
- $folder['target_id'] = $module->id;
- $this->component->appendArray('folders', $folder);
- }
- }
+ // check if this module has folders
+ $this->setFolders($module);
// check if this module has urls
- if (isset($module->urls)
- && ArrayHelper::check($module->urls))
- {
- // add to component urls
- foreach ($module->urls as $n => &$url)
- {
- // should we add the local folder
- if (isset($url['type']) && $url['type'] > 1
- && isset($url['url'])
- && StringHelper::check(
- $url['url']
- ))
- {
- // set file name
- $fileName = basename((string) $url['url']);
-
- // get the file contents
- $data = FileHelper::getContent(
- $url['url']
- );
-
- // build sub path
- if (strpos($fileName, '.js') !== false)
- {
- $path = '/js';
- }
- elseif (strpos($fileName, '.css') !== false)
- {
- $path = '/css';
- }
- else
- {
- $path = '';
- }
-
- // create sub media path if not set
- $this->folder->create(
- $module->folder_path . $path
- );
-
- // set the path to module file
- $url['path'] = $module->folder_path . $path
- . '/' . $fileName; // we need this for later
-
- // write data to path
- $this->file->write($url['path'], $data);
-
- // count the file created
- $this->counter->file++;
- }
- }
- }
+ $this->setUrls($module);
}
}
}
@@ -879,6 +339,813 @@ class Structure
return implode(PHP_EOL, $form_field_class);
}
-
+
+ /**
+ * Set the module path
+ *
+ * @param object $module
+ *
+ * @return void
+ * @since 3.2.0
+ */
+ protected function modulePath(object &$module): void
+ {
+ $module->folder_path = $this->config->get('compiler_path', JPATH_COMPONENT_ADMINISTRATOR . '/compiler') . '/'
+ . $module->folder_name;
+ }
+
+ /**
+ * Set the main module file
+ *
+ * @param object $module
+ *
+ * @return void
+ * @since 3.2.0
+ */
+ protected function setMainModFile(object $module): void
+ {
+ // set main mod file
+ $file_details = [
+ 'path' => $module->folder_path . '/' . $module->file_name . '.php',
+ 'name' => $module->file_name . '.php',
+ 'zip' => $module->file_name . '.php'
+ ];
+
+ $this->file->write(
+ $file_details['path'],
+ 'files->appendArray($module->key, $file_details);
+
+ // count the file created
+ $this->counter->file++;
+ }
+
+ /**
+ * Set the custom get file
+ *
+ * @param object $module
+ *
+ * @return void
+ * @since 3.2.0
+ */
+ protected function setCustomGet(object $module): void
+ {
+ if ($module->custom_get)
+ {
+ $file_details = [
+ 'path' => $module->folder_path . '/data.php',
+ 'name' => 'data.php',
+ 'zip' => 'data.php'
+ ];
+
+ $this->file->write(
+ $file_details['path'],
+ 'official_name . ' Data'
+ . PHP_EOL . ' */' . PHP_EOL . "class " . $module->class_data_name
+ . ' extends \JObject' . PHP_EOL . "{" . Placefix::_h('DYNAMICGETS') . "}"
+ . PHP_EOL
+ );
+
+ $this->files->appendArray($module->key, $file_details);
+
+ // count the file created
+ $this->counter->file++;
+ }
+ }
+
+ /**
+ * Set the helper file
+ *
+ * @param object $module
+ *
+ * @return void
+ * @since 3.2.0
+ */
+ protected function setHelperFile(object $module): void
+ {
+ if ($module->add_class_helper >= 1)
+ {
+ $file_details = [
+ 'path' => $module->folder_path . '/helper.php',
+ 'name' => 'helper.php',
+ 'zip' => 'helper.php'
+ ];
+
+ $this->file->write(
+ $file_details['path'],
+ 'files->appendArray($module->key, $file_details);
+
+ // count the file created
+ $this->counter->file++;
+ }
+ }
+
+ /**
+ * Set the main XML file
+ *
+ * @param object $module
+ *
+ * @return void
+ * @since 3.2.0
+ */
+ protected function setMainXmlFile(object $module): void
+ {
+ $file_details = [
+ 'path' => $module->folder_path . '/' . $module->file_name . '.xml',
+ 'name' => $module->file_name . '.xml',
+ 'zip' => $module->file_name . '.xml'
+ ];
+
+ $this->file->write(
+ $file_details['path'],
+ $this->getXML($module)
+ );
+
+ $this->files->appendArray($module->key, $file_details);
+
+ // count the file created
+ $this->counter->file++;
+ }
+
+ /**
+ * Set the main default template file
+ *
+ * @param object $module
+ *
+ * @return void
+ * @since 3.2.0
+ */
+ protected function setDefaultFile(object $module): void
+ {
+ $file_details = [
+ 'path' => $module->folder_path . '/tmpl/default.php',
+ 'name' => 'default.php',
+ 'zip' => 'tmpl/default.php'
+ ];
+
+ $this->file->write(
+ $file_details['path'],
+ 'files->appendArray($module->key, $file_details);
+
+ // count the file created
+ $this->counter->file++;
+ }
+
+ /**
+ * Set the additional template files
+ *
+ * @param object $module
+ *
+ * @return void
+ * @since 3.2.0
+ */
+ protected function setTemplateFiles(object $module): void
+ {
+ if (($data_ = $this->templatedata->
+ get($module->key . '.' . $module->code_name)) !== null)
+ {
+ foreach ($data_ as $template => $data)
+ {
+ $file_details = [
+ 'path' => $module->folder_path . "/tmpl/default_{$template}.php",
+ 'name' => "default_{$template}.php",
+ 'zip' => "tmpl/default_{$template}.php"
+ ];
+
+ $this->file->write(
+ $file_details['path'],
+ 'files->appendArray($module->key, $file_details);
+
+ // count the file created
+ $this->counter->file++;
+ }
+ }
+ }
+
+ /**
+ * Set the install script file
+ *
+ * @param object $module
+ *
+ * @return void
+ * @since 3.2.0
+ */
+ protected function setInstallScript(object $module): void
+ {
+ if ($module->add_install_script)
+ {
+ $file_details = [
+ 'path' => $module->folder_path . '/script.php',
+ 'name' => 'script.php',
+ 'zip' => 'script.php'
+ ];
+
+ $this->file->write(
+ $file_details['path'],
+ 'files->appendArray($module->key, $file_details);
+
+ // count the file created
+ $this->counter->file++;
+ }
+ }
+
+ /**
+ * Set the readme file
+ *
+ * @param object $module
+ *
+ * @return void
+ * @since 3.2.0
+ */
+ protected function setReadme(object $module): void
+ {
+ if ($module->addreadme)
+ {
+ $file_details = [
+ 'path' => $module->folder_path . '/README.md',
+ 'name' => 'README.md',
+ 'zip' => 'README.md'
+ ];
+
+ $this->file->write($file_details['path'], $module->readme);
+ $this->files->appendArray($module->key, $file_details);
+
+ // count the file created
+ $this->counter->file++;
+ }
+ }
+
+ /**
+ * Set the css and javascript in form
+ *
+ * @param object $module
+ *
+ * @return void
+ * @since 3.2.0
+ */
+ protected function setCssJsForm(object $module): void
+ {
+ // set the folders target path
+ $target_path = '';
+ if ($module->target_client === 'administrator')
+ {
+ $target_path = '/administrator';
+ }
+
+ // check if we have custom fields needed for scripts
+ $module->add_scripts_field = false;
+ $field_script_bucket = [];
+
+ // add any css from the fields
+ $this->setCssForm($module, $target_path, $field_script_bucket);
+
+ // add any JavaScript from the fields
+ $this->setJsForm($module, $target_path, $field_script_bucket);
+
+ // set fields folders if needed
+ if ($module->add_scripts_field
+ || (isset($module->fields_rules_paths)
+ && $module->fields_rules_paths == 2))
+ {
+ // create fields folder
+ $this->folder->create($module->folder_path . '/fields');
+
+ // add the custom script field
+ if ($module->add_scripts_field)
+ {
+ $file_details = [
+ 'path' => $module->folder_path . '/fields/modadminvvvvvvvdm.php',
+ 'name' => 'modadminvvvvvvvdm.php',
+ 'zip' => 'modadminvvvvvvvdm.php'
+ ];
+
+ $this->file->write(
+ $file_details['path'],
+ $this->getCustomScriptField(
+ $field_script_bucket
+ )
+ );
+
+ $this->files->appendArray($module->key, $file_details);
+
+ // count the file created
+ $this->counter->file++;
+ }
+ }
+ }
+
+ /**
+ * Set the css in form
+ *
+ * @param object $module
+ * @param string $targetPath
+ * @param array $bucket
+ *
+ * @return void
+ * @since 3.2.0
+ */
+ protected function setCssForm(object &$module, string $targetPath, array &$bucket): void
+ {
+ if (($css = $this->dispenser->get(
+ 'css_view', $module->key
+ )) !== null && StringHelper::check($css))
+ {
+ // make sure this script does not have PHP
+ if (strpos((string) $css, 'add_scripts_field = true;
+
+ // create the css folder
+ $this->folder->create($module->folder_path . '/css');
+
+ // add the CSS file
+ $file_details = [
+ 'path' => $module->folder_path . '/css/mod_admin.css',
+ 'name' => 'mod_admin.css',
+ 'zip' => 'mod_admin.css'
+ ];
+
+ $this->file->write(
+ $file_details['path'],
+ Placefix::_h('BOM') . PHP_EOL
+ . PHP_EOL . $css
+ );
+
+ $this->files->appendArray($module->key, $file_details);
+
+ // count the file created
+ $this->counter->file++;
+
+ // add the field script
+ $bucket[] = Indent::_(2) . "//"
+ . Line::_(__Line__, __Class__) . " Custom CSS";
+ $bucket[] = Indent::_(2)
+ . "\$document->addStyleSheet('" . $targetPath
+ . "/modules/" . $module->folder_name
+ . "/css/mod_admin.css', ['version' => 'auto', 'relative' => true]);";
+ }
+ }
+ }
+
+ /**
+ * Set the javascript in form
+ *
+ * @param object $module
+ * @param string $targetPath
+ * @param array $bucket
+ *
+ * @return void
+ * @since 3.2.0
+ */
+ protected function setJsForm(object &$module, string $targetPath, array &$bucket): void
+ {
+ if (($javascript = $this->dispenser->get(
+ 'view_footer', $module->key
+ )) !== null
+ && StringHelper::check($javascript))
+ {
+ // make sure this script does not have PHP
+ if (strpos((string) $javascript, 'add_scripts_field = true;
+
+ // add the JavaScript file
+ $this->folder->create($module->folder_path . '/js');
+
+ // add the CSS file
+ $file_details = [
+ 'path' => $module->folder_path . '/js/mod_admin.js',
+ 'name' => 'mod_admin.js',
+ 'zip' => 'mod_admin.js'
+ ];
+
+ $this->file->write(
+ $file_details['path'],
+ Placefix::_h('BOM') . PHP_EOL
+ . PHP_EOL . $javascript
+ );
+
+ $this->files->appendArray($module->key, $file_details);
+
+ // count the file created
+ $this->counter->file++;
+
+ // add the field script
+ $bucket[] = Indent::_(2) . "//"
+ . Line::_(__Line__, __Class__) . " Custom JS";
+ $bucket[] = Indent::_(2)
+ . "\$document->addScript('" . $targetPath
+ . "/modules/" . $module->folder_name
+ . "/js/mod_admin.js', ['version' => 'auto', 'relative' => true]);";
+ }
+ }
+ }
+
+ /**
+ * Set the form folders and files as needed
+ *
+ * @param object $module
+ *
+ * @return void
+ * @since 3.2.0
+ */
+ protected function setForms(object &$module): void
+ {
+ if (isset($module->form_files)
+ && ArrayHelper::check(
+ $module->form_files
+ ))
+ {
+ // create forms folder
+ $this->folder->create($module->folder_path . '/forms');
+
+ // set the template files
+ foreach ($module->form_files as $file => $fields)
+ {
+ // set file details
+ $file_details = [
+ 'path' => $module->folder_path . '/forms/' . $file . '.xml',
+ 'name' => $file . '.xml',
+ 'zip' => 'forms/' . $file . '.xml'
+ ];
+
+ // build basic XML
+ $xml = '';
+ $xml .= PHP_EOL . '';
+
+ // search if we must add the component path
+ $add_component_path = false;
+ foreach ($fields as $field_name => $fieldsets)
+ {
+ if (!$add_component_path)
+ {
+ foreach ($fieldsets as $fieldset => $field)
+ {
+ if (!$add_component_path
+ && isset(
+ $module->fieldsets_paths[$file
+ . $field_name . $fieldset]
+ )
+ && $module->fieldsets_paths[$file
+ . $field_name . $fieldset] == 1)
+ {
+ $add_component_path = true;
+ }
+ }
+ }
+ }
+
+ // only add if part of the component field types path is required
+ if ($add_component_path)
+ {
+ $xml .= PHP_EOL . '';
+
+ // add xml to file
+ $this->file->write($file_details['path'], $xml);
+ $this->files->appendArray($module->key, $file_details);
+
+ // count the file created
+ $this->counter->file++;
+ }
+ }
+ }
+
+ /**
+ * Set the sql stuff
+ *
+ * @param object $module
+ *
+ * @return void
+ * @since 3.2.0
+ */
+ protected function setSQL(object $module): void
+ {
+ if ($module->add_sql || $module->add_sql_uninstall)
+ {
+ // create SQL folder
+ $this->folder->create($module->folder_path . '/sql');
+
+ // create mysql folder
+ $this->folder->create(
+ $module->folder_path . '/sql/mysql'
+ );
+
+ // now set the install file
+ if ($module->add_sql)
+ {
+ $this->file->write(
+ $module->folder_path . '/sql/mysql/install.sql',
+ $module->sql
+ );
+
+ // count the file created
+ $this->counter->file++;
+ }
+
+ // now set the uninstall file
+ if ($module->add_sql_uninstall)
+ {
+ $this->file->write(
+ $module->folder_path
+ . '/sql/mysql/uninstall.sql',
+ $module->sql_uninstall
+ );
+
+ // count the file created
+ $this->counter->file++;
+ }
+ }
+ }
+
+ /**
+ * Set the files
+ *
+ * @param object $module
+ *
+ * @return void
+ * @since 3.2.0
+ */
+ protected function setFiles(object $module): void
+ {
+ if (isset($module->files)
+ && ArrayHelper::check($module->files))
+ {
+ // add to component files
+ foreach ($module->files as $file)
+ {
+ // set the pathfinder
+ $file['target_type'] = $module->target_type;
+ $file['target_id'] = $module->id;
+
+ $this->component->appendArray('files', $file);
+ }
+ }
+ }
+
+ /**
+ * Set the folders
+ *
+ * @param object $module
+ *
+ * @return void
+ * @since 3.2.0
+ */
+ protected function setFolders(object $module): void
+ {
+ if (isset($module->folders)
+ && ArrayHelper::check($module->folders))
+ {
+ // add to component folders
+ foreach ($module->folders as $folder)
+ {
+ // set the pathfinder
+ $folder['target_type'] = $module->target_type;
+ $folder['target_id'] = $module->id;
+
+ $this->component->appendArray('folders', $folder);
+ }
+ }
+ }
+
+ /**
+ * Set the urls
+ *
+ * @param object $module
+ *
+ * @return void
+ * @since 3.2.0
+ */
+ protected function setUrls(object &$module): void
+ {
+ if (isset($module->urls)
+ && ArrayHelper::check($module->urls))
+ {
+ // add to component urls
+ foreach ($module->urls as &$url)
+ {
+ // should we add the local folder
+ if (isset($url['type']) && $url['type'] > 1
+ && isset($url['url'])
+ && StringHelper::check(
+ $url['url']
+ ))
+ {
+ // set file name
+ $fileName = basename((string)$url['url']);
+
+ // get the file contents
+ $data = FileHelper::getContent(
+ $url['url']
+ );
+
+ // build sub path
+ if (strpos($fileName, '.js') !== false)
+ {
+ $path = '/js';
+ }
+ elseif (strpos($fileName, '.css') !== false)
+ {
+ $path = '/css';
+ }
+ else
+ {
+ $path = '';
+ }
+
+ // create sub media path if not set
+ $this->folder->create(
+ $module->folder_path . $path
+ );
+
+ // set the path to module file
+ $url['path'] = $module->folder_path . $path
+ . '/' . $fileName; // we need this for later
+
+ // write data to path
+ $this->file->write($url['path'], $data);
+
+ // count the file created
+ $this->counter->file++;
+ }
+ }
+ }
+ }
}
diff --git a/src/071c7cff-4c88-4b80-bd99-066c572dcb71/code.power b/src/071c7cff-4c88-4b80-bd99-066c572dcb71/code.power
index 4976c44..44a1d5c 100644
--- a/src/071c7cff-4c88-4b80-bd99-066c572dcb71/code.power
+++ b/src/071c7cff-4c88-4b80-bd99-066c572dcb71/code.power
@@ -1,115 +1,124 @@
/**
- * Compiler Joomla Module Data Class
+ * The Data Class.
*
- * @var Module
+ * @var Module
* @since 3.2.0
*/
protected Module $module;
/**
- * Compiler Component
+ * The Component Class.
*
- * @var Component
+ * @var Component
* @since 3.2.0
- **/
+ */
protected Component $component;
/**
- * Compiler Config
+ * The Config Class.
*
- * @var Config
+ * @var Config
* @since 3.2.0
*/
protected Config $config;
/**
- * The compiler registry
+ * The Registry Class.
*
- * @var Registry
+ * @var Registry
* @since 3.2.0
*/
protected Registry $registry;
/**
- * Compiler Customcode Dispenser
+ * The Dispenser Class.
*
- * @var Dispenser
+ * @var Dispenser
* @since 3.2.0
*/
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
+ * @var Counter
* @since 3.2.0
*/
protected Counter $counter;
/**
- * Compiler Utilities Folder
+ * The Folder Class.
*
- * @var Folder
+ * @var Folder
* @since 3.2.0
*/
protected Folder $folder;
/**
- * Compiler Utilities File
+ * The File Class.
*
- * @var File
+ * @var File
* @since 3.2.0
*/
protected File $file;
/**
- * Compiler Utilities Files
+ * The Files Class.
*
- * @var Files
+ * @var Files
* @since 3.2.0
*/
protected Files $files;
/**
- * Constructor
+ * The TemplateData Class.
*
- * @param Module|null $module The compiler Joomla module 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.
+ * @var TemplateData
+ * @since 3.2.0
+ */
+ protected TemplateData $templatedata;
+
+ /**
+ * Constructor.
+ *
+ * @param Module $module 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.
+ * @param TemplateData $templatedata The TemplateData Class.
*
* @since 3.2.0
*/
- public function __construct(?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)
+ public function __construct(Module $module, Component $component, Config $config,
+ Registry $registry, Dispenser $dispenser, Event $event,
+ Counter $counter, Folder $folder, File $file,
+ Files $files, TemplateData $templatedata)
{
- $this->module = $module ?: Compiler::_('Joomlamodule.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->module = $module;
+ $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;
+ $this->templatedata = $templatedata;
}
/**
@@ -125,6 +134,7 @@
// for plugin event TODO change event api signatures
$component_context = $this->config->component_context;
$modules = $this->module->get();
+
// Trigger Event: jcb_ce_onBeforeSetModules
$this->event->trigger(
'jcb_ce_onBeforeBuildModules',
@@ -135,13 +145,10 @@
{
if (ObjectHelper::check($module)
&& isset($module->folder_name)
- && StringHelper::check(
- $module->folder_name
- ))
+ && StringHelper::check($module->folder_name))
{
// module path
- $module->folder_path = $this->config->get('compiler_path', JPATH_COMPONENT_ADMINISTRATOR . '/compiler') . '/'
- . $module->folder_name;
+ $this->modulePath($module);
// set the module paths
$this->registry->set('dynamic_paths.' . $module->key, $module->folder_path);
@@ -149,279 +156,38 @@
// make sure there is no old build
$this->folder->remove($module->folder_path);
- // creat the main module folder
+ // create the main module folder
$this->folder->create($module->folder_path);
- // set main mod file
- $fileDetails = array('path' => $module->folder_path . '/'
- . $module->file_name . '.php',
- 'name' => $module->file_name . '.php',
- 'zip' => $module->file_name . '.php');
- $this->file->write(
- $fileDetails['path'],
- 'files->appendArray($module->key, $fileDetails);
+ // create the main module file
+ $this->setMainModFile($module);
- // count the file created
- $this->counter->file++;
-
- // set custom_get
- if ($module->custom_get)
- {
- $fileDetails = array(
- 'path' => $module->folder_path . '/data.php',
- 'name' => 'data.php',
- 'zip' => 'data.php'
- );
- $this->file->write(
- $fileDetails['path'],
- 'official_name . ' Data'
- . PHP_EOL .
- ' */' . PHP_EOL .
- "class " . $module->class_data_name
- . ' extends \JObject' . PHP_EOL .
- "{" . Placefix::_h('DYNAMICGETS') . "}"
- . PHP_EOL
- );
- $this->files->appendArray($module->key, $fileDetails);
-
- // count the file created
- $this->counter->file++;
- }
+ // creat the custom get file
+ $this->setCustomGet($module);
// set helper file
- if ($module->add_class_helper >= 1)
- {
- $fileDetails = array('path' => $module->folder_path
- . '/helper.php',
- 'name' => 'helper.php',
- 'zip' => 'helper.php');
- $this->file->write(
- $fileDetails['path'],
- 'files->appendArray($module->key, $fileDetails);
-
- // count the file created
- $this->counter->file++;
- }
+ $this->setHelperFile($module);
// set main xml file
- $fileDetails = array('path' => $module->folder_path . '/'
- . $module->file_name . '.xml',
- 'name' => $module->file_name . '.xml',
- 'zip' => $module->file_name . '.xml');
- $this->file->write(
- $fileDetails['path'],
- $this->getXML($module)
- );
- $this->files->appendArray($module->key, $fileDetails);
-
- // count the file created
- $this->counter->file++;
+ $this->setMainXmlFile($module);
// set tmpl folder
$this->folder->create($module->folder_path . '/tmpl');
// set default file
- $fileDetails = array('path' => $module->folder_path
- . '/tmpl/default.php',
- 'name' => 'default.php',
- 'zip' => 'tmpl/default.php');
- $this->file->write(
- $fileDetails['path'],
- 'files->appendArray($module->key, $fileDetails);
+ $this->setDefaultFile($module);
- // count the file created
- $this->counter->file++;
+ // set custom default files
+ $this->setTemplateFiles($module);
// set install script if needed
- if ($module->add_install_script)
- {
- $fileDetails = [
- 'path' => $module->folder_path . '/script.php',
- 'name' => 'script.php',
- 'zip' => 'script.php'
- ];
- $this->file->write(
- $fileDetails['path'],
- 'files->appendArray($module->key, $fileDetails);
-
- // count the file created
- $this->counter->file++;
- }
+ $this->setInstallScript($module);
// set readme if found
- if ($module->addreadme)
- {
- $fileDetails = [
- 'path' => $module->folder_path . '/README.md',
- 'name' => 'README.md',
- 'zip' => 'README.md'
- ];
- $this->file->write($fileDetails['path'], $module->readme);
- $this->files->appendArray($module->key, $fileDetails);
+ $this->setReadme($module);
- // count the file created
- $this->counter->file++;
- }
-
- // set the folders target path
- $target_path = '';
- if ($module->target_client === 'administrator')
- {
- $target_path = '/administrator';
- }
-
- // check if we have custom fields needed for scripts
- $module->add_scripts_field = false;
- $field_script_bucket = [];
-
- // add any css from the fields
- if (($css = $this->dispenser->get(
- 'css_view', $module->key
- )) !== null
- && StringHelper::check($css))
- {
- // make sure this script does not have PHP
- if (strpos((string) $css, 'add_scripts_field = true;
-
- // create the css folder
- $this->folder->create($module->folder_path . '/css');
-
- // add the CSS file
- $fileDetails = [
- 'path' => $module->folder_path . '/css/mod_admin.css',
- 'name' => 'mod_admin.css',
- 'zip' => 'mod_admin.css'
- ];
- $this->file->write(
- $fileDetails['path'],
- Placefix::_h('BOM') . PHP_EOL
- . PHP_EOL . $css
- );
- $this->files->appendArray($module->key, $fileDetails);
-
- // count the file created
- $this->counter->file++;
-
- // add the field script
- $field_script_bucket[] = Indent::_(2) . "//"
- . Line::_(__Line__, __Class__) . " Custom CSS";
- $field_script_bucket[] = Indent::_(2)
- . "\$document->addStyleSheet('" . $target_path
- . "/modules/" . $module->folder_name
- . "/css/mod_admin.css', ['version' => 'auto', 'relative' => true]);";
- }
- }
-
- // add any JavaScript from the fields
- if (($javascript = $this->dispenser->get(
- 'view_footer', $module->key
- )) !== null
- && StringHelper::check($javascript))
- {
- // make sure this script does not have PHP
- if (strpos((string) $javascript, 'add_scripts_field = true;
-
- // add the JavaScript file
- $this->folder->create($module->folder_path . '/js');
-
- // add the CSS file
- $fileDetails = [
- 'path' => $module->folder_path . '/js/mod_admin.js',
- 'name' => 'mod_admin.js',
- 'zip' => 'mod_admin.js'
- ];
- $this->file->write(
- $fileDetails['path'],
- Placefix::_h('BOM') . PHP_EOL
- . PHP_EOL . $javascript
- );
- $this->files->appendArray($module->key, $fileDetails);
-
- // count the file created
- $this->counter->file++;
-
- // add the field script
- $field_script_bucket[] = Indent::_(2) . "//"
- . Line::_(__Line__, __Class__) . " Custom JS";
- $field_script_bucket[] = Indent::_(2)
- . "\$document->addScript('" . $target_path
- . "/modules/" . $module->folder_name
- . "/js/mod_admin.js', ['version' => 'auto', 'relative' => true]);";
- }
- }
-
- // set fields folders if needed
- if ($module->add_scripts_field
- || (isset($module->fields_rules_paths)
- && $module->fields_rules_paths == 2))
- {
- // create fields folder
- $this->folder->create($module->folder_path . '/fields');
-
- // add the custom script field
- if ($module->add_scripts_field)
- {
- $fileDetails = [
- 'path' => $module->folder_path
- . '/fields/modadminvvvvvvvdm.php',
- 'name' => 'modadminvvvvvvvdm.php',
- 'zip' => 'modadminvvvvvvvdm.php'
- ];
- $this->file->write(
- $fileDetails['path'],
- $this->getCustomScriptField(
- $field_script_bucket
- )
- );
- $this->files->appendArray($module->key, $fileDetails);
-
- // count the file created
- $this->counter->file++;
- }
- }
+ // set the CSS and JavaScript in form
+ $this->setCssJsForm($module);
// set rules folders if needed
if (isset($module->fields_rules_paths)
@@ -431,334 +197,28 @@
$this->folder->create($module->folder_path . '/rules');
}
- // set forms folder if needed
- if (isset($module->form_files)
- && ArrayHelper::check(
- $module->form_files
- ))
- {
- // create forms folder
- $this->folder->create($module->folder_path . '/forms');
-
- // set the template files
- foreach ($module->form_files as $file => $fields)
- {
- // set file details
- $fileDetails = [
- 'path' => $module->folder_path . '/forms/' . $file . '.xml',
- 'name' => $file . '.xml',
- 'zip' => 'forms/' . $file . '.xml'
- ];
-
- // build basic XML
- $xml = '';
- $xml .= PHP_EOL . '';
-
- // search if we must add the component path
- $add_component_path = false;
- foreach ($fields as $field_name => $fieldsets)
- {
- if (!$add_component_path)
- {
- foreach ($fieldsets as $fieldset => $field)
- {
- if (!$add_component_path
- && isset(
- $module->fieldsets_paths[$file
- . $field_name . $fieldset]
- )
- && $module->fieldsets_paths[$file
- . $field_name . $fieldset] == 1)
- {
- $add_component_path = true;
- }
- }
- }
- }
-
- // only add if part of the component field types path is required
- if ($add_component_path)
- {
- $xml .= PHP_EOL . '';
-
- // add xml to file
- $this->file->write($fileDetails['path'], $xml);
- $this->files->appendArray($module->key, $fileDetails);
-
- // count the file created
- $this->counter->file++;
- }
- }
+ // set forms folder/files if needed
+ $this->setForms($module);
// set SQL stuff if needed
- if ($module->add_sql || $module->add_sql_uninstall)
- {
- // create SQL folder
- $this->folder->create($module->folder_path . '/sql');
+ $this->setSQL($module);
- // create mysql folder
- $this->folder->create(
- $module->folder_path . '/sql/mysql'
- );
-
- // now set the install file
- if ($module->add_sql)
- {
- $this->file->write(
- $module->folder_path . '/sql/mysql/install.sql',
- $module->sql
- );
-
- // count the file created
- $this->counter->file++;
- }
-
- // now set the uninstall file
- if ($module->add_sql_uninstall)
- {
- $this->file->write(
- $module->folder_path
- . '/sql/mysql/uninstall.sql',
- $module->sql_uninstall
- );
-
- // count the file created
- $this->counter->file++;
- }
- }
-
- // creat the language folder
+ // create the language folder
$this->folder->create($module->folder_path . '/language');
+
// also create the lang tag folder
$this->folder->create(
$module->folder_path . '/language/' . $this->config->get('lang_tag', 'en-GB')
);
- // check if this lib has files
- if (isset($module->files)
- && ArrayHelper::check($module->files))
- {
- // add to component files
- foreach ($module->files as $file)
- {
- // set the pathfinder
- $file['target_type'] = $module->target_type;
- $file['target_id'] = $module->id;
- $this->component->appendArray('files', $file);
- }
- }
+ // check if this module has files
+ $this->setFiles($module);
- // check if this lib has folders
- if (isset($module->folders)
- && ArrayHelper::check($module->folders))
- {
- // add to component folders
- foreach ($module->folders as $folder)
- {
- // set the pathfinder
- $folder['target_type'] = $module->target_type;
- $folder['target_id'] = $module->id;
- $this->component->appendArray('folders', $folder);
- }
- }
+ // check if this module has folders
+ $this->setFolders($module);
// check if this module has urls
- if (isset($module->urls)
- && ArrayHelper::check($module->urls))
- {
- // add to component urls
- foreach ($module->urls as $n => &$url)
- {
- // should we add the local folder
- if (isset($url['type']) && $url['type'] > 1
- && isset($url['url'])
- && StringHelper::check(
- $url['url']
- ))
- {
- // set file name
- $fileName = basename((string) $url['url']);
-
- // get the file contents
- $data = FileHelper::getContent(
- $url['url']
- );
-
- // build sub path
- if (strpos($fileName, '.js') !== false)
- {
- $path = '/js';
- }
- elseif (strpos($fileName, '.css') !== false)
- {
- $path = '/css';
- }
- else
- {
- $path = '';
- }
-
- // create sub media path if not set
- $this->folder->create(
- $module->folder_path . $path
- );
-
- // set the path to module file
- $url['path'] = $module->folder_path . $path
- . '/' . $fileName; // we need this for later
-
- // write data to path
- $this->file->write($url['path'], $data);
-
- // count the file created
- $this->counter->file++;
- }
- }
- }
+ $this->setUrls($module);
}
}
}
@@ -838,3 +298,811 @@
return implode(PHP_EOL, $form_field_class);
}
+
+ /**
+ * Set the module path
+ *
+ * @param object $module
+ *
+ * @return void
+ * @since 3.2.0
+ */
+ protected function modulePath(object &$module): void
+ {
+ $module->folder_path = $this->config->get('compiler_path', JPATH_COMPONENT_ADMINISTRATOR . '/compiler') . '/'
+ . $module->folder_name;
+ }
+
+ /**
+ * Set the main module file
+ *
+ * @param object $module
+ *
+ * @return void
+ * @since 3.2.0
+ */
+ protected function setMainModFile(object $module): void
+ {
+ // set main mod file
+ $file_details = [
+ 'path' => $module->folder_path . '/' . $module->file_name . '.php',
+ 'name' => $module->file_name . '.php',
+ 'zip' => $module->file_name . '.php'
+ ];
+
+ $this->file->write(
+ $file_details['path'],
+ 'files->appendArray($module->key, $file_details);
+
+ // count the file created
+ $this->counter->file++;
+ }
+
+ /**
+ * Set the custom get file
+ *
+ * @param object $module
+ *
+ * @return void
+ * @since 3.2.0
+ */
+ protected function setCustomGet(object $module): void
+ {
+ if ($module->custom_get)
+ {
+ $file_details = [
+ 'path' => $module->folder_path . '/data.php',
+ 'name' => 'data.php',
+ 'zip' => 'data.php'
+ ];
+
+ $this->file->write(
+ $file_details['path'],
+ 'official_name . ' Data'
+ . PHP_EOL . ' */' . PHP_EOL . "class " . $module->class_data_name
+ . ' extends \JObject' . PHP_EOL . "{" . Placefix::_h('DYNAMICGETS') . "}"
+ . PHP_EOL
+ );
+
+ $this->files->appendArray($module->key, $file_details);
+
+ // count the file created
+ $this->counter->file++;
+ }
+ }
+
+ /**
+ * Set the helper file
+ *
+ * @param object $module
+ *
+ * @return void
+ * @since 3.2.0
+ */
+ protected function setHelperFile(object $module): void
+ {
+ if ($module->add_class_helper >= 1)
+ {
+ $file_details = [
+ 'path' => $module->folder_path . '/helper.php',
+ 'name' => 'helper.php',
+ 'zip' => 'helper.php'
+ ];
+
+ $this->file->write(
+ $file_details['path'],
+ 'files->appendArray($module->key, $file_details);
+
+ // count the file created
+ $this->counter->file++;
+ }
+ }
+
+ /**
+ * Set the main XML file
+ *
+ * @param object $module
+ *
+ * @return void
+ * @since 3.2.0
+ */
+ protected function setMainXmlFile(object $module): void
+ {
+ $file_details = [
+ 'path' => $module->folder_path . '/' . $module->file_name . '.xml',
+ 'name' => $module->file_name . '.xml',
+ 'zip' => $module->file_name . '.xml'
+ ];
+
+ $this->file->write(
+ $file_details['path'],
+ $this->getXML($module)
+ );
+
+ $this->files->appendArray($module->key, $file_details);
+
+ // count the file created
+ $this->counter->file++;
+ }
+
+ /**
+ * Set the main default template file
+ *
+ * @param object $module
+ *
+ * @return void
+ * @since 3.2.0
+ */
+ protected function setDefaultFile(object $module): void
+ {
+ $file_details = [
+ 'path' => $module->folder_path . '/tmpl/default.php',
+ 'name' => 'default.php',
+ 'zip' => 'tmpl/default.php'
+ ];
+
+ $this->file->write(
+ $file_details['path'],
+ 'files->appendArray($module->key, $file_details);
+
+ // count the file created
+ $this->counter->file++;
+ }
+
+ /**
+ * Set the additional template files
+ *
+ * @param object $module
+ *
+ * @return void
+ * @since 3.2.0
+ */
+ protected function setTemplateFiles(object $module): void
+ {
+ if (($data_ = $this->templatedata->
+ get($module->key . '.' . $module->code_name)) !== null)
+ {
+ foreach ($data_ as $template => $data)
+ {
+ $file_details = [
+ 'path' => $module->folder_path . "/tmpl/default_{$template}.php",
+ 'name' => "default_{$template}.php",
+ 'zip' => "tmpl/default_{$template}.php"
+ ];
+
+ $this->file->write(
+ $file_details['path'],
+ 'files->appendArray($module->key, $file_details);
+
+ // count the file created
+ $this->counter->file++;
+ }
+ }
+ }
+
+ /**
+ * Set the install script file
+ *
+ * @param object $module
+ *
+ * @return void
+ * @since 3.2.0
+ */
+ protected function setInstallScript(object $module): void
+ {
+ if ($module->add_install_script)
+ {
+ $file_details = [
+ 'path' => $module->folder_path . '/script.php',
+ 'name' => 'script.php',
+ 'zip' => 'script.php'
+ ];
+
+ $this->file->write(
+ $file_details['path'],
+ 'files->appendArray($module->key, $file_details);
+
+ // count the file created
+ $this->counter->file++;
+ }
+ }
+
+ /**
+ * Set the readme file
+ *
+ * @param object $module
+ *
+ * @return void
+ * @since 3.2.0
+ */
+ protected function setReadme(object $module): void
+ {
+ if ($module->addreadme)
+ {
+ $file_details = [
+ 'path' => $module->folder_path . '/README.md',
+ 'name' => 'README.md',
+ 'zip' => 'README.md'
+ ];
+
+ $this->file->write($file_details['path'], $module->readme);
+ $this->files->appendArray($module->key, $file_details);
+
+ // count the file created
+ $this->counter->file++;
+ }
+ }
+
+ /**
+ * Set the css and javascript in form
+ *
+ * @param object $module
+ *
+ * @return void
+ * @since 3.2.0
+ */
+ protected function setCssJsForm(object $module): void
+ {
+ // set the folders target path
+ $target_path = '';
+ if ($module->target_client === 'administrator')
+ {
+ $target_path = '/administrator';
+ }
+
+ // check if we have custom fields needed for scripts
+ $module->add_scripts_field = false;
+ $field_script_bucket = [];
+
+ // add any css from the fields
+ $this->setCssForm($module, $target_path, $field_script_bucket);
+
+ // add any JavaScript from the fields
+ $this->setJsForm($module, $target_path, $field_script_bucket);
+
+ // set fields folders if needed
+ if ($module->add_scripts_field
+ || (isset($module->fields_rules_paths)
+ && $module->fields_rules_paths == 2))
+ {
+ // create fields folder
+ $this->folder->create($module->folder_path . '/fields');
+
+ // add the custom script field
+ if ($module->add_scripts_field)
+ {
+ $file_details = [
+ 'path' => $module->folder_path . '/fields/modadminvvvvvvvdm.php',
+ 'name' => 'modadminvvvvvvvdm.php',
+ 'zip' => 'modadminvvvvvvvdm.php'
+ ];
+
+ $this->file->write(
+ $file_details['path'],
+ $this->getCustomScriptField(
+ $field_script_bucket
+ )
+ );
+
+ $this->files->appendArray($module->key, $file_details);
+
+ // count the file created
+ $this->counter->file++;
+ }
+ }
+ }
+
+ /**
+ * Set the css in form
+ *
+ * @param object $module
+ * @param string $targetPath
+ * @param array $bucket
+ *
+ * @return void
+ * @since 3.2.0
+ */
+ protected function setCssForm(object &$module, string $targetPath, array &$bucket): void
+ {
+ if (($css = $this->dispenser->get(
+ 'css_view', $module->key
+ )) !== null && StringHelper::check($css))
+ {
+ // make sure this script does not have PHP
+ if (strpos((string) $css, 'add_scripts_field = true;
+
+ // create the css folder
+ $this->folder->create($module->folder_path . '/css');
+
+ // add the CSS file
+ $file_details = [
+ 'path' => $module->folder_path . '/css/mod_admin.css',
+ 'name' => 'mod_admin.css',
+ 'zip' => 'mod_admin.css'
+ ];
+
+ $this->file->write(
+ $file_details['path'],
+ Placefix::_h('BOM') . PHP_EOL
+ . PHP_EOL . $css
+ );
+
+ $this->files->appendArray($module->key, $file_details);
+
+ // count the file created
+ $this->counter->file++;
+
+ // add the field script
+ $bucket[] = Indent::_(2) . "//"
+ . Line::_(__Line__, __Class__) . " Custom CSS";
+ $bucket[] = Indent::_(2)
+ . "\$document->addStyleSheet('" . $targetPath
+ . "/modules/" . $module->folder_name
+ . "/css/mod_admin.css', ['version' => 'auto', 'relative' => true]);";
+ }
+ }
+ }
+
+ /**
+ * Set the javascript in form
+ *
+ * @param object $module
+ * @param string $targetPath
+ * @param array $bucket
+ *
+ * @return void
+ * @since 3.2.0
+ */
+ protected function setJsForm(object &$module, string $targetPath, array &$bucket): void
+ {
+ if (($javascript = $this->dispenser->get(
+ 'view_footer', $module->key
+ )) !== null
+ && StringHelper::check($javascript))
+ {
+ // make sure this script does not have PHP
+ if (strpos((string) $javascript, 'add_scripts_field = true;
+
+ // add the JavaScript file
+ $this->folder->create($module->folder_path . '/js');
+
+ // add the CSS file
+ $file_details = [
+ 'path' => $module->folder_path . '/js/mod_admin.js',
+ 'name' => 'mod_admin.js',
+ 'zip' => 'mod_admin.js'
+ ];
+
+ $this->file->write(
+ $file_details['path'],
+ Placefix::_h('BOM') . PHP_EOL
+ . PHP_EOL . $javascript
+ );
+
+ $this->files->appendArray($module->key, $file_details);
+
+ // count the file created
+ $this->counter->file++;
+
+ // add the field script
+ $bucket[] = Indent::_(2) . "//"
+ . Line::_(__Line__, __Class__) . " Custom JS";
+ $bucket[] = Indent::_(2)
+ . "\$document->addScript('" . $targetPath
+ . "/modules/" . $module->folder_name
+ . "/js/mod_admin.js', ['version' => 'auto', 'relative' => true]);";
+ }
+ }
+ }
+
+ /**
+ * Set the form folders and files as needed
+ *
+ * @param object $module
+ *
+ * @return void
+ * @since 3.2.0
+ */
+ protected function setForms(object &$module): void
+ {
+ if (isset($module->form_files)
+ && ArrayHelper::check(
+ $module->form_files
+ ))
+ {
+ // create forms folder
+ $this->folder->create($module->folder_path . '/forms');
+
+ // set the template files
+ foreach ($module->form_files as $file => $fields)
+ {
+ // set file details
+ $file_details = [
+ 'path' => $module->folder_path . '/forms/' . $file . '.xml',
+ 'name' => $file . '.xml',
+ 'zip' => 'forms/' . $file . '.xml'
+ ];
+
+ // build basic XML
+ $xml = '';
+ $xml .= PHP_EOL . '';
+
+ // search if we must add the component path
+ $add_component_path = false;
+ foreach ($fields as $field_name => $fieldsets)
+ {
+ if (!$add_component_path)
+ {
+ foreach ($fieldsets as $fieldset => $field)
+ {
+ if (!$add_component_path
+ && isset(
+ $module->fieldsets_paths[$file
+ . $field_name . $fieldset]
+ )
+ && $module->fieldsets_paths[$file
+ . $field_name . $fieldset] == 1)
+ {
+ $add_component_path = true;
+ }
+ }
+ }
+ }
+
+ // only add if part of the component field types path is required
+ if ($add_component_path)
+ {
+ $xml .= PHP_EOL . '';
+
+ // add xml to file
+ $this->file->write($file_details['path'], $xml);
+ $this->files->appendArray($module->key, $file_details);
+
+ // count the file created
+ $this->counter->file++;
+ }
+ }
+ }
+
+ /**
+ * Set the sql stuff
+ *
+ * @param object $module
+ *
+ * @return void
+ * @since 3.2.0
+ */
+ protected function setSQL(object $module): void
+ {
+ if ($module->add_sql || $module->add_sql_uninstall)
+ {
+ // create SQL folder
+ $this->folder->create($module->folder_path . '/sql');
+
+ // create mysql folder
+ $this->folder->create(
+ $module->folder_path . '/sql/mysql'
+ );
+
+ // now set the install file
+ if ($module->add_sql)
+ {
+ $this->file->write(
+ $module->folder_path . '/sql/mysql/install.sql',
+ $module->sql
+ );
+
+ // count the file created
+ $this->counter->file++;
+ }
+
+ // now set the uninstall file
+ if ($module->add_sql_uninstall)
+ {
+ $this->file->write(
+ $module->folder_path
+ . '/sql/mysql/uninstall.sql',
+ $module->sql_uninstall
+ );
+
+ // count the file created
+ $this->counter->file++;
+ }
+ }
+ }
+
+ /**
+ * Set the files
+ *
+ * @param object $module
+ *
+ * @return void
+ * @since 3.2.0
+ */
+ protected function setFiles(object $module): void
+ {
+ if (isset($module->files)
+ && ArrayHelper::check($module->files))
+ {
+ // add to component files
+ foreach ($module->files as $file)
+ {
+ // set the pathfinder
+ $file['target_type'] = $module->target_type;
+ $file['target_id'] = $module->id;
+
+ $this->component->appendArray('files', $file);
+ }
+ }
+ }
+
+ /**
+ * Set the folders
+ *
+ * @param object $module
+ *
+ * @return void
+ * @since 3.2.0
+ */
+ protected function setFolders(object $module): void
+ {
+ if (isset($module->folders)
+ && ArrayHelper::check($module->folders))
+ {
+ // add to component folders
+ foreach ($module->folders as $folder)
+ {
+ // set the pathfinder
+ $folder['target_type'] = $module->target_type;
+ $folder['target_id'] = $module->id;
+
+ $this->component->appendArray('folders', $folder);
+ }
+ }
+ }
+
+ /**
+ * Set the urls
+ *
+ * @param object $module
+ *
+ * @return void
+ * @since 3.2.0
+ */
+ protected function setUrls(object &$module): void
+ {
+ if (isset($module->urls)
+ && ArrayHelper::check($module->urls))
+ {
+ // add to component urls
+ foreach ($module->urls as &$url)
+ {
+ // should we add the local folder
+ if (isset($url['type']) && $url['type'] > 1
+ && isset($url['url'])
+ && StringHelper::check(
+ $url['url']
+ ))
+ {
+ // set file name
+ $fileName = basename((string)$url['url']);
+
+ // get the file contents
+ $data = FileHelper::getContent(
+ $url['url']
+ );
+
+ // build sub path
+ if (strpos($fileName, '.js') !== false)
+ {
+ $path = '/js';
+ }
+ elseif (strpos($fileName, '.css') !== false)
+ {
+ $path = '/css';
+ }
+ else
+ {
+ $path = '';
+ }
+
+ // create sub media path if not set
+ $this->folder->create(
+ $module->folder_path . $path
+ );
+
+ // set the path to module file
+ $url['path'] = $module->folder_path . $path
+ . '/' . $fileName; // we need this for later
+
+ // write data to path
+ $this->file->write($url['path'], $data);
+
+ // count the file created
+ $this->counter->file++;
+ }
+ }
+ }
+ }
\ No newline at end of file
diff --git a/src/071c7cff-4c88-4b80-bd99-066c572dcb71/settings.json b/src/071c7cff-4c88-4b80-bd99-066c572dcb71/settings.json
index ace1dd0..b9b0bb7 100644
--- a/src/071c7cff-4c88-4b80-bd99-066c572dcb71/settings.json
+++ b/src/071c7cff-4c88-4b80-bd99-066c572dcb71/settings.json
@@ -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"
diff --git a/src/295186de-5954-4a65-a4c1-2f79ef305743/README.md b/src/295186de-5954-4a65-a4c1-2f79ef305743/README.md
index 0069a53..3a755af 100644
--- a/src/295186de-5954-4a65-a4c1-2f79ef305743/README.md
+++ b/src/295186de-5954-4a65-a4c1-2f79ef305743/README.md
@@ -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
diff --git a/src/295186de-5954-4a65-a4c1-2f79ef305743/code.php b/src/295186de-5954-4a65-a4c1-2f79ef305743/code.php
index dc10916..1aaccae 100644
--- a/src/295186de-5954-4a65-a4c1-2f79ef305743/code.php
+++ b/src/295186de-5954-4a65-a4c1-2f79ef305743/code.php
@@ -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')
);
- }
-
+ }
}
diff --git a/src/295186de-5954-4a65-a4c1-2f79ef305743/code.power b/src/295186de-5954-4a65-a4c1-2f79ef305743/code.power
index dd57761..6258067 100644
--- a/src/295186de-5954-4a65-a4c1-2f79ef305743/code.power
+++ b/src/295186de-5954-4a65-a4c1-2f79ef305743/code.power
@@ -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')
);
- }
+ }
\ No newline at end of file
diff --git a/src/3ab0eba9-f37b-4b37-aec1-2e78067f2aff/README.md b/src/3ab0eba9-f37b-4b37-aec1-2e78067f2aff/README.md
index a000dbe..878071f 100644
--- a/src/3ab0eba9-f37b-4b37-aec1-2e78067f2aff/README.md
+++ b/src/3ab0eba9-f37b-4b37-aec1-2e78067f2aff/README.md
@@ -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
diff --git a/src/3ab0eba9-f37b-4b37-aec1-2e78067f2aff/code.php b/src/3ab0eba9-f37b-4b37-aec1-2e78067f2aff/code.php
index 58cf874..30d9fa3 100644
--- a/src/3ab0eba9-f37b-4b37-aec1-2e78067f2aff/code.php
+++ b/src/3ab0eba9-f37b-4b37-aec1-2e78067f2aff/code.php
@@ -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
*
diff --git a/src/3ab0eba9-f37b-4b37-aec1-2e78067f2aff/code.power b/src/3ab0eba9-f37b-4b37-aec1-2e78067f2aff/code.power
index 5fd0bc4..133ae8f 100644
--- a/src/3ab0eba9-f37b-4b37-aec1-2e78067f2aff/code.power
+++ b/src/3ab0eba9-f37b-4b37-aec1-2e78067f2aff/code.power
@@ -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
*
diff --git a/src/3ab0eba9-f37b-4b37-aec1-2e78067f2aff/settings.json b/src/3ab0eba9-f37b-4b37-aec1-2e78067f2aff/settings.json
index 6020cb9..8d2199a 100644
--- a/src/3ab0eba9-f37b-4b37-aec1-2e78067f2aff/settings.json
+++ b/src/3ab0eba9-f37b-4b37-aec1-2e78067f2aff/settings.json
@@ -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"
},
diff --git a/src/53cf9828-7ad4-4856-aac1-7c4c67bd3121/code.php b/src/53cf9828-7ad4-4856-aac1-7c4c67bd3121/code.php
index ae78161..ed522e1 100644
--- a/src/53cf9828-7ad4-4856-aac1-7c4c67bd3121/code.php
+++ b/src/53cf9828-7ad4-4856-aac1-7c4c67bd3121/code.php
@@ -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
diff --git a/src/53cf9828-7ad4-4856-aac1-7c4c67bd3121/code.power b/src/53cf9828-7ad4-4856-aac1-7c4c67bd3121/code.power
index 2a4c105..1e9ad35 100644
--- a/src/53cf9828-7ad4-4856-aac1-7c4c67bd3121/code.power
+++ b/src/53cf9828-7ad4-4856-aac1-7c4c67bd3121/code.power
@@ -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
diff --git a/src/6784dd52-0909-451a-a872-9a942a023c68/README.md b/src/6784dd52-0909-451a-a872-9a942a023c68/README.md
index 70c95cf..add5e24 100644
--- a/src/6784dd52-0909-451a-a872-9a942a023c68/README.md
+++ b/src/6784dd52-0909-451a-a872-9a942a023c68/README.md
@@ -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
diff --git a/src/6784dd52-0909-451a-a872-9a942a023c68/code.php b/src/6784dd52-0909-451a-a872-9a942a023c68/code.php
index 3db88b5..709036f 100644
--- a/src/6784dd52-0909-451a-a872-9a942a023c68/code.php
+++ b/src/6784dd52-0909-451a-a872-9a942a023c68/code.php
@@ -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'
);
diff --git a/src/6784dd52-0909-451a-a872-9a942a023c68/code.power b/src/6784dd52-0909-451a-a872-9a942a023c68/code.power
index d5e52a2..2feb4f0 100644
--- a/src/6784dd52-0909-451a-a872-9a942a023c68/code.power
+++ b/src/6784dd52-0909-451a-a872-9a942a023c68/code.power
@@ -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('Super Power repository at git.vdm.dev/%s gave the following error!
%s
', $path->path, $e->getMessage()),
+ Text::sprintf('Super Power repository at %s/%s gave the following error!
%s
', $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('File at gitea.remote/%s gave the following error!
%s
', $path, $e->getMessage()),
+ Text::sprintf('File at %s/%s gave the following error!
%s
', $this->contents->api(), $path, $e->getMessage()),
'Error'
);
diff --git a/src/81de8f57-dd9c-4a17-964f-848cd4a0743b/README.md b/src/81de8f57-dd9c-4a17-964f-848cd4a0743b/README.md
index 2b94eb5..0bc185d 100644
--- a/src/81de8f57-dd9c-4a17-964f-848cd4a0743b/README.md
+++ b/src/81de8f57-dd9c-4a17-964f-848cd4a0743b/README.md
@@ -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
diff --git a/src/81de8f57-dd9c-4a17-964f-848cd4a0743b/code.php b/src/81de8f57-dd9c-4a17-964f-848cd4a0743b/code.php
index 572b90a..83a8a95 100644
--- a/src/81de8f57-dd9c-4a17-964f-848cd4a0743b/code.php
+++ b/src/81de8f57-dd9c-4a17-964f-848cd4a0743b/code.php
@@ -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;
}
diff --git a/src/81de8f57-dd9c-4a17-964f-848cd4a0743b/code.power b/src/81de8f57-dd9c-4a17-964f-848cd4a0743b/code.power
index 0c1470e..6bddf2b 100644
--- a/src/81de8f57-dd9c-4a17-964f-848cd4a0743b/code.power
+++ b/src/81de8f57-dd9c-4a17-964f-848cd4a0743b/code.power
@@ -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;
diff --git a/src/9127e428-5dee-46cb-b3a9-ab5b91ea6df3/README.md b/src/9127e428-5dee-46cb-b3a9-ab5b91ea6df3/README.md
index 36c8087..98a667c 100644
--- a/src/9127e428-5dee-46cb-b3a9-ab5b91ea6df3/README.md
+++ b/src/9127e428-5dee-46cb-b3a9-ab5b91ea6df3/README.md
@@ -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
@@ -45,6 +47,20 @@ note right of Modifieddate::getKey
since: 3.2.0
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
```
diff --git a/src/9127e428-5dee-46cb-b3a9-ab5b91ea6df3/code.php b/src/9127e428-5dee-46cb-b3a9-ab5b91ea6df3/code.php
index 754056c..fc30b2c 100644
--- a/src/9127e428-5dee-46cb-b3a9-ab5b91ea6df3/code.php
+++ b/src/9127e428-5dee-46cb-b3a9-ab5b91ea6df3/code.php
@@ -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']))
{
@@ -150,6 +178,23 @@ 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';
+ }
}
diff --git a/src/9127e428-5dee-46cb-b3a9-ab5b91ea6df3/code.power b/src/9127e428-5dee-46cb-b3a9-ab5b91ea6df3/code.power
index 5adf567..35c9838 100644
--- a/src/9127e428-5dee-46cb-b3a9-ab5b91ea6df3/code.power
+++ b/src/9127e428-5dee-46cb-b3a9-ab5b91ea6df3/code.power
@@ -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';
+ }
\ No newline at end of file
diff --git a/src/a900b836-f2eb-4f13-8f28-b7cac839c7ff/README.md b/src/a900b836-f2eb-4f13-8f28-b7cac839c7ff/README.md
index 68e7e5b..dad654e 100644
--- a/src/a900b836-f2eb-4f13-8f28-b7cac839c7ff/README.md
+++ b/src/a900b836-f2eb-4f13-8f28-b7cac839c7ff/README.md
@@ -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
@@ -57,6 +67,76 @@ note right of Structure::getXML
since: 3.2.0
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
```
diff --git a/src/a900b836-f2eb-4f13-8f28-b7cac839c7ff/code.php b/src/a900b836-f2eb-4f13-8f28-b7cac839c7ff/code.php
index f8f2cbc..0ef0974 100644
--- a/src/a900b836-f2eb-4f13-8f28-b7cac839c7ff/code.php
+++ b/src/a900b836-f2eb-4f13-8f28-b7cac839c7ff/code.php
@@ -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,117 +39,116 @@ use VDM\Joomla\Utilities\FileHelper;
class Structure
{
/**
- * Compiler Joomla Plugin Data Class
+ * The Data Class.
*
- * @var Plugin
+ * @var Plugin
* @since 3.2.0
*/
protected Plugin $plugin;
/**
- * Compiler Component
+ * The Component Class.
*
- * @var Component
+ * @var Component
* @since 3.2.0
- **/
+ */
protected Component $component;
/**
- * Compiler Config
+ * The Config Class.
*
- * @var Config
+ * @var Config
* @since 3.2.0
*/
protected Config $config;
/**
- * The compiler registry
+ * The Registry Class.
*
- * @var Registry
+ * @var Registry
* @since 3.2.0
*/
protected Registry $registry;
/**
- * Compiler Customcode Dispenser
+ * The Dispenser Class.
*
- * @var Dispenser
+ * @var Dispenser
* @since 3.2.0
*/
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
+ * @var Counter
* @since 3.2.0
*/
protected Counter $counter;
/**
- * Compiler Utilities Folder
+ * The Folder Class.
*
- * @var Folder
+ * @var Folder
* @since 3.2.0
*/
protected Folder $folder;
/**
- * Compiler Utilities File
+ * The File Class.
*
- * @var File
+ * @var File
* @since 3.2.0
*/
protected File $file;
/**
- * Compiler Utilities Files
+ * The Files Class.
*
- * @var Files
+ * @var Files
* @since 3.2.0
*/
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'],
- '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'],
- '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,226 +213,10 @@ class Structure
}
// set forms folder if needed
- if (isset($plugin->form_files)
- && ArrayHelper::check(
- $plugin->form_files
- ))
- {
- // create forms folder
- $this->folder->create($plugin->folder_path . '/forms');
-
- // set the template files
- foreach ($plugin->form_files as $file => $fields)
- {
- // set file details
- $fileDetails = [
- 'path' => $plugin->folder_path . '/forms/' . $file . '.xml',
- 'name' => $file . '.xml',
- 'zip' => 'forms/' . $file . '.xml'
- ];
-
- // build basic XML
- $xml = '';
- $xml .= PHP_EOL . '';
-
- // search if we must add the component path
- $add_component_path = false;
- foreach ($fields as $field_name => $fieldsets)
- {
- if (!$add_component_path)
- {
- 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)
- {
- $add_component_path = true;
- }
- }
- }
- }
-
- // only add if part of the component field types path is required
- if ($add_component_path)
- {
- $xml .= PHP_EOL . '';
-
- // add xml to file
- $this->file->write($fileDetails['path'], $xml);
- $this->files->appendArray($plugin->key, $fileDetails);
-
- // count the file created
- $this->counter->file++;
- }
- }
+ $this->setForms($plugin);
// set SQL stuff if needed
- if ($plugin->add_sql || $plugin->add_sql_uninstall)
- {
- // create SQL folder
- $this->folder->create($plugin->folder_path . '/sql');
-
- // create mysql folder
- $this->folder->create(
- $plugin->folder_path . '/sql/mysql'
- );
-
- // now set the install file
- if ($plugin->add_sql)
- {
- $this->file->write(
- $plugin->folder_path . '/sql/mysql/install.sql',
- $plugin->sql
- );
-
- // count the file created
- $this->counter->file++;
- }
-
- // now set the uninstall file
- if ($plugin->add_sql_uninstall)
- {
- $this->file->write(
- $plugin->folder_path
- . '/sql/mysql/uninstall.sql',
- $plugin->sql_uninstall
- );
-
- // count the file created
- $this->counter->file++;
- }
- }
+ $this->setSQL($plugin);
// creat the language folder path
$this->folder->create($plugin->folder_path . '/language');
@@ -503,87 +226,14 @@ class Structure
$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))
- {
- // add to component files
- foreach ($plugin->files as $file)
- {
- // set the path finder
- $file['target_type'] = $plugin->target_type;
- $file['target_id'] = $plugin->id;
- $this->component->appendArray('files', $file);
- }
- }
+ // check if this plugin has files
+ $this->setFiles($plugin);
- // check if this lib has folders
- if (isset($plugin->folders)
- && ArrayHelper::check($plugin->folders))
- {
- // add to component folders
- foreach ($plugin->folders as $folder)
- {
- // 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 folders
+ $this->setFolders($plugin);
// check if this plugin has urls
- if (isset($plugin->urls)
- && ArrayHelper::check($plugin->urls))
- {
- // add to component urls
- foreach ($plugin->urls as $n => &$url)
- {
- // should we add the local folder
- if (isset($url['type']) && $url['type'] > 1
- && isset($url['url'])
- && StringHelper::check(
- $url['url']
- ))
- {
- // set file name
- $fileName = basename((string) $url['url']);
-
- // get the file contents
- $data = FileHelper::getContent(
- $url['url']
- );
-
- // build sub path
- if (strpos($fileName, '.js') !== false)
- {
- $path = '/js';
- }
- elseif (strpos($fileName, '.css') !== false)
- {
- $path = '/css';
- }
- else
- {
- $path = '';
- }
-
- // create sub media media folder path if not set
- $this->folder->create(
- $plugin->folder_path . $path
- );
-
- // set the path to plugin file
- $url['path'] = $plugin->folder_path . $path
- . '/' . $fileName; // we need this for later
-
- // write data to path
- $this->file->write($url['path'], $data);
-
- // count the file created
- $this->counter->file++;
- }
- }
- }
+ $this->setUrls($plugin);
}
}
}
@@ -592,12 +242,12 @@ class Structure
/**
* get the plugin xml template
*
- * @param object $module The plugin object
+ * @param object $plugin The plugin object
*
* @return string
* @since 3.2.0
*/
- protected function getXML(object &$plugin): string
+ protected function getXML(object $plugin): string
{
$xml = '';
$xml .= PHP_EOL . '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'],
+ '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))
+ {
+ // create forms folder
+ $this->folder->create($plugin->folder_path . '/forms');
+
+ // set the template files
+ foreach ($plugin->form_files as $file => $fields)
+ {
+ // set file details
+ $file_details = [
+ 'path' => $plugin->folder_path . '/forms/' . $file . '.xml',
+ 'name' => $file . '.xml',
+ 'zip' => 'forms/' . $file . '.xml'
+ ];
+
+ // build basic XML
+ $xml = '';
+ $xml .= PHP_EOL . '';
+
+ // search if we must add the component path
+ $add_component_path = false;
+ foreach ($fields as $field_name => $fieldsets)
+ {
+ if (!$add_component_path)
+ {
+ 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)
+ {
+ $add_component_path = true;
+ }
+ }
+ }
+ }
+
+ // only add if part of the component field types path is required
+ if ($add_component_path)
+ {
+ $xml .= PHP_EOL . '';
+
+ // add xml to file
+ $this->file->write($file_details['path'], $xml);
+ $this->files->appendArray($plugin->key, $file_details);
+
+ // count the file created
+ $this->counter->file++;
+ }
+ }
+ }
+
+ /**
+ * 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
+ $this->folder->create($plugin->folder_path . '/sql');
+
+ // create mysql folder
+ $this->folder->create(
+ $plugin->folder_path . '/sql/mysql'
+ );
+
+ // now set the install file
+ if ($plugin->add_sql)
+ {
+ $this->file->write(
+ $plugin->folder_path . '/sql/mysql/install.sql',
+ $plugin->sql
+ );
+
+ // count the file created
+ $this->counter->file++;
+ }
+
+ // now set the uninstall file
+ if ($plugin->add_sql_uninstall)
+ {
+ $this->file->write(
+ $plugin->folder_path
+ . '/sql/mysql/uninstall.sql',
+ $plugin->sql_uninstall
+ );
+
+ // count the file created
+ $this->counter->file++;
+ }
+ }
+ }
+
+ /**
+ * 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)
+ {
+ // set the path finder
+ $file['target_type'] = $plugin->target_type;
+ $file['target_id'] = $plugin->id;
+
+ $this->component->appendArray('files', $file);
+ }
+ }
+ }
+
+ /**
+ * 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)
+ {
+ // set the path finder
+ $folder['target_type'] = $plugin->target_type;
+ $folder['target_id'] = $plugin->id;
+
+ $this->component->appendArray('folders', $folder);
+ }
+ }
+ }
+
+ /**
+ * 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 &$url)
+ {
+ // should we add the local folder
+ if (isset($url['type']) && $url['type'] > 1
+ && isset($url['url'])
+ && StringHelper::check($url['url']))
+ {
+ // set file name
+ $fileName = basename((string)$url['url']);
+
+ // get the file contents
+ $data = FileHelper::getContent(
+ $url['url']
+ );
+
+ // build sub path
+ if (strpos($fileName, '.js') !== false)
+ {
+ $path = '/js';
+ }
+ elseif (strpos($fileName, '.css') !== false)
+ {
+ $path = '/css';
+ }
+ else
+ {
+ $path = '';
+ }
+
+ // create sub media folder path if not set
+ $this->folder->create(
+ $plugin->folder_path . $path
+ );
+
+ // set the path to plugin file
+ $url['path'] = $plugin->folder_path . $path
+ . '/' . $fileName; // we need this for later
+
+ // write data to path
+ $this->file->write($url['path'], $data);
+
+ // count the file created
+ $this->counter->file++;
+ }
+ }
+ }
+ }
}
diff --git a/src/a900b836-f2eb-4f13-8f28-b7cac839c7ff/code.power b/src/a900b836-f2eb-4f13-8f28-b7cac839c7ff/code.power
index 606d8ac..3016069 100644
--- a/src/a900b836-f2eb-4f13-8f28-b7cac839c7ff/code.power
+++ b/src/a900b836-f2eb-4f13-8f28-b7cac839c7ff/code.power
@@ -1,115 +1,114 @@
/**
- * Compiler Joomla Plugin Data Class
+ * The Data Class.
*
- * @var Plugin
+ * @var Plugin
* @since 3.2.0
*/
protected Plugin $plugin;
/**
- * Compiler Component
+ * The Component Class.
*
- * @var Component
+ * @var Component
* @since 3.2.0
- **/
+ */
protected Component $component;
/**
- * Compiler Config
+ * The Config Class.
*
- * @var Config
+ * @var Config
* @since 3.2.0
*/
protected Config $config;
/**
- * The compiler registry
+ * The Registry Class.
*
- * @var Registry
+ * @var Registry
* @since 3.2.0
*/
protected Registry $registry;
/**
- * Compiler Customcode Dispenser
+ * The Dispenser Class.
*
- * @var Dispenser
+ * @var Dispenser
* @since 3.2.0
*/
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
+ * @var Counter
* @since 3.2.0
*/
protected Counter $counter;
/**
- * Compiler Utilities Folder
+ * The Folder Class.
*
- * @var Folder
+ * @var Folder
* @since 3.2.0
*/
protected Folder $folder;
/**
- * Compiler Utilities File
+ * The File Class.
*
- * @var File
+ * @var File
* @since 3.2.0
*/
protected File $file;
/**
- * Compiler Utilities Files
+ * The Files Class.
*
- * @var Files
+ * @var Files
* @since 3.2.0
*/
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'],
- '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'],
- '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,226 +173,10 @@
}
// set forms folder if needed
- if (isset($plugin->form_files)
- && ArrayHelper::check(
- $plugin->form_files
- ))
- {
- // create forms folder
- $this->folder->create($plugin->folder_path . '/forms');
-
- // set the template files
- foreach ($plugin->form_files as $file => $fields)
- {
- // set file details
- $fileDetails = [
- 'path' => $plugin->folder_path . '/forms/' . $file . '.xml',
- 'name' => $file . '.xml',
- 'zip' => 'forms/' . $file . '.xml'
- ];
-
- // build basic XML
- $xml = '';
- $xml .= PHP_EOL . '';
-
- // search if we must add the component path
- $add_component_path = false;
- foreach ($fields as $field_name => $fieldsets)
- {
- if (!$add_component_path)
- {
- 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)
- {
- $add_component_path = true;
- }
- }
- }
- }
-
- // only add if part of the component field types path is required
- if ($add_component_path)
- {
- $xml .= PHP_EOL . '';
-
- // add xml to file
- $this->file->write($fileDetails['path'], $xml);
- $this->files->appendArray($plugin->key, $fileDetails);
-
- // count the file created
- $this->counter->file++;
- }
- }
+ $this->setForms($plugin);
// set SQL stuff if needed
- if ($plugin->add_sql || $plugin->add_sql_uninstall)
- {
- // create SQL folder
- $this->folder->create($plugin->folder_path . '/sql');
-
- // create mysql folder
- $this->folder->create(
- $plugin->folder_path . '/sql/mysql'
- );
-
- // now set the install file
- if ($plugin->add_sql)
- {
- $this->file->write(
- $plugin->folder_path . '/sql/mysql/install.sql',
- $plugin->sql
- );
-
- // count the file created
- $this->counter->file++;
- }
-
- // now set the uninstall file
- if ($plugin->add_sql_uninstall)
- {
- $this->file->write(
- $plugin->folder_path
- . '/sql/mysql/uninstall.sql',
- $plugin->sql_uninstall
- );
-
- // count the file created
- $this->counter->file++;
- }
- }
+ $this->setSQL($plugin);
// creat the language folder path
$this->folder->create($plugin->folder_path . '/language');
@@ -462,87 +186,14 @@
$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))
- {
- // add to component files
- foreach ($plugin->files as $file)
- {
- // set the path finder
- $file['target_type'] = $plugin->target_type;
- $file['target_id'] = $plugin->id;
- $this->component->appendArray('files', $file);
- }
- }
+ // check if this plugin has files
+ $this->setFiles($plugin);
- // check if this lib has folders
- if (isset($plugin->folders)
- && ArrayHelper::check($plugin->folders))
- {
- // add to component folders
- foreach ($plugin->folders as $folder)
- {
- // 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 folders
+ $this->setFolders($plugin);
// check if this plugin has urls
- if (isset($plugin->urls)
- && ArrayHelper::check($plugin->urls))
- {
- // add to component urls
- foreach ($plugin->urls as $n => &$url)
- {
- // should we add the local folder
- if (isset($url['type']) && $url['type'] > 1
- && isset($url['url'])
- && StringHelper::check(
- $url['url']
- ))
- {
- // set file name
- $fileName = basename((string) $url['url']);
-
- // get the file contents
- $data = FileHelper::getContent(
- $url['url']
- );
-
- // build sub path
- if (strpos($fileName, '.js') !== false)
- {
- $path = '/js';
- }
- elseif (strpos($fileName, '.css') !== false)
- {
- $path = '/css';
- }
- else
- {
- $path = '';
- }
-
- // create sub media media folder path if not set
- $this->folder->create(
- $plugin->folder_path . $path
- );
-
- // set the path to plugin file
- $url['path'] = $plugin->folder_path . $path
- . '/' . $fileName; // we need this for later
-
- // write data to path
- $this->file->write($url['path'], $data);
-
- // count the file created
- $this->counter->file++;
- }
- }
- }
+ $this->setUrls($plugin);
}
}
}
@@ -551,12 +202,12 @@
/**
* get the plugin xml template
*
- * @param object $module The plugin object
+ * @param object $plugin The plugin object
*
* @return string
* @since 3.2.0
*/
- protected function getXML(object &$plugin): string
+ protected function getXML(object $plugin): string
{
$xml = '';
$xml .= PHP_EOL . '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'],
+ '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))
+ {
+ // create forms folder
+ $this->folder->create($plugin->folder_path . '/forms');
+
+ // set the template files
+ foreach ($plugin->form_files as $file => $fields)
+ {
+ // set file details
+ $file_details = [
+ 'path' => $plugin->folder_path . '/forms/' . $file . '.xml',
+ 'name' => $file . '.xml',
+ 'zip' => 'forms/' . $file . '.xml'
+ ];
+
+ // build basic XML
+ $xml = '';
+ $xml .= PHP_EOL . '';
+
+ // search if we must add the component path
+ $add_component_path = false;
+ foreach ($fields as $field_name => $fieldsets)
+ {
+ if (!$add_component_path)
+ {
+ 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)
+ {
+ $add_component_path = true;
+ }
+ }
+ }
+ }
+
+ // only add if part of the component field types path is required
+ if ($add_component_path)
+ {
+ $xml .= PHP_EOL . '';
+
+ // add xml to file
+ $this->file->write($file_details['path'], $xml);
+ $this->files->appendArray($plugin->key, $file_details);
+
+ // count the file created
+ $this->counter->file++;
+ }
+ }
+ }
+
+ /**
+ * 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
+ $this->folder->create($plugin->folder_path . '/sql');
+
+ // create mysql folder
+ $this->folder->create(
+ $plugin->folder_path . '/sql/mysql'
+ );
+
+ // now set the install file
+ if ($plugin->add_sql)
+ {
+ $this->file->write(
+ $plugin->folder_path . '/sql/mysql/install.sql',
+ $plugin->sql
+ );
+
+ // count the file created
+ $this->counter->file++;
+ }
+
+ // now set the uninstall file
+ if ($plugin->add_sql_uninstall)
+ {
+ $this->file->write(
+ $plugin->folder_path
+ . '/sql/mysql/uninstall.sql',
+ $plugin->sql_uninstall
+ );
+
+ // count the file created
+ $this->counter->file++;
+ }
+ }
+ }
+
+ /**
+ * 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)
+ {
+ // set the path finder
+ $file['target_type'] = $plugin->target_type;
+ $file['target_id'] = $plugin->id;
+
+ $this->component->appendArray('files', $file);
+ }
+ }
+ }
+
+ /**
+ * 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)
+ {
+ // set the path finder
+ $folder['target_type'] = $plugin->target_type;
+ $folder['target_id'] = $plugin->id;
+
+ $this->component->appendArray('folders', $folder);
+ }
+ }
+ }
+
+ /**
+ * 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 &$url)
+ {
+ // should we add the local folder
+ if (isset($url['type']) && $url['type'] > 1
+ && isset($url['url'])
+ && StringHelper::check($url['url']))
+ {
+ // set file name
+ $fileName = basename((string)$url['url']);
+
+ // get the file contents
+ $data = FileHelper::getContent(
+ $url['url']
+ );
+
+ // build sub path
+ if (strpos($fileName, '.js') !== false)
+ {
+ $path = '/js';
+ }
+ elseif (strpos($fileName, '.css') !== false)
+ {
+ $path = '/css';
+ }
+ else
+ {
+ $path = '';
+ }
+
+ // create sub media folder path if not set
+ $this->folder->create(
+ $plugin->folder_path . $path
+ );
+
+ // set the path to plugin file
+ $url['path'] = $plugin->folder_path . $path
+ . '/' . $fileName; // we need this for later
+
+ // write data to path
+ $this->file->write($url['path'], $data);
+
+ // count the file created
+ $this->counter->file++;
+ }
+ }
+ }
+ }
\ No newline at end of file
diff --git a/src/a900b836-f2eb-4f13-8f28-b7cac839c7ff/settings.json b/src/a900b836-f2eb-4f13-8f28-b7cac839c7ff/settings.json
index a2d07a3..ec76ad2 100644
--- a/src/a900b836-f2eb-4f13-8f28-b7cac839c7ff/settings.json
+++ b/src/a900b836-f2eb-4f13-8f28-b7cac839c7ff/settings.json
@@ -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"
}
diff --git a/src/be4ccfae-65a9-401e-bdbe-637d8c226954/README.md b/src/be4ccfae-65a9-401e-bdbe-637d8c226954/README.md
index 5062a56..8205194 100644
--- a/src/be4ccfae-65a9-401e-bdbe-637d8c226954/README.md
+++ b/src/be4ccfae-65a9-401e-bdbe-637d8c226954/README.md
@@ -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
diff --git a/src/be4ccfae-65a9-401e-bdbe-637d8c226954/code.php b/src/be4ccfae-65a9-401e-bdbe-637d8c226954/code.php
index be5dae8..8e00853 100644
--- a/src/be4ccfae-65a9-401e-bdbe-637d8c226954/code.php
+++ b/src/be4ccfae-65a9-401e-bdbe-637d8c226954/code.php
@@ -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)
{
- // we make sure to get only the objects
- $approved[] = $path;
+ $owner = $path->owner ?? null;
+ $repo = $path->repo ?? null;
+ if ($owner !== null && $repo !== null)
+ {
+ // we make sure to get only the objects
+ $approved = ["{$owner}.{$repo}" => $path] + $approved;
+ }
}
}
- // finally we add the default
- $approved[] = $default;
-
- return $approved;
+ return array_values($approved);
}
}
diff --git a/src/be4ccfae-65a9-401e-bdbe-637d8c226954/code.power b/src/be4ccfae-65a9-401e-bdbe-637d8c226954/code.power
index 534a725..8565070 100644
--- a/src/be4ccfae-65a9-401e-bdbe-637d8c226954/code.power
+++ b/src/be4ccfae-65a9-401e-bdbe-637d8c226954/code.power
@@ -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)
{
- // we make sure to get only the objects
- $approved[] = $path;
+ $owner = $path->owner ?? null;
+ $repo = $path->repo ?? null;
+ if ($owner !== null && $repo !== null)
+ {
+ // we make sure to get only the objects
+ $approved = ["{$owner}.{$repo}" => $path] + $approved;
+ }
}
}
- // finally we add the default
- $approved[] = $default;
-
- return $approved;
+ return array_values($approved);
}
\ No newline at end of file
diff --git a/src/cb11e8d9-69c2-4095-831c-59908ea402e7/README.md b/src/cb11e8d9-69c2-4095-831c-59908ea402e7/README.md
index b8bc711..ec47f8b 100644
--- a/src/cb11e8d9-69c2-4095-831c-59908ea402e7/README.md
+++ b/src/cb11e8d9-69c2-4095-831c-59908ea402e7/README.md
@@ -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
diff --git a/src/cb11e8d9-69c2-4095-831c-59908ea402e7/code.php b/src/cb11e8d9-69c2-4095-831c-59908ea402e7/code.php
index 8cc3fbe..66e329d 100644
--- a/src/cb11e8d9-69c2-4095-831c-59908ea402e7/code.php
+++ b/src/cb11e8d9-69c2-4095-831c-59908ea402e7/code.php
@@ -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,126 +48,129 @@ class Data
protected array $data = [];
/**
- * Compiler Config
+ * The Config Class.
*
- * @var Config
+ * @var Config
* @since 3.2.0
*/
protected Config $config;
/**
- * Compiler Customcode
+ * The Customcode Class.
*
- * @var Customcode
+ * @var Customcode
* @since 3.2.0
*/
protected Customcode $customcode;
/**
- * Compiler Customcode in Gui
+ * The Gui Class.
*
- * @var Gui
+ * @var Gui
* @since 3.2.0
- **/
+ */
protected Gui $gui;
/**
- * Compiler Placeholder
+ * The Placeholder Class.
*
- * @var Placeholder
+ * @var Placeholder
* @since 3.2.0
- **/
+ */
protected Placeholder $placeholder;
/**
- * Compiler Language
+ * The Language Class.
*
- * @var Language
+ * @var Language
* @since 3.2.0
- **/
+ */
protected Language $language;
/**
- * Compiler Field
+ * The Field Class.
*
- * @var Field
+ * @var Field
* @since 3.2.0
*/
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
+ * @var Filesfolders
* @since 3.2.0
*/
- protected Filesfolders $filesFolders;
+ protected Filesfolders $filesfolders;
/**
- * Compiler Libraries Model
+ * The Libraries Class.
*
- * @var Libraries
+ * @var Libraries
* @since 3.2.0
*/
protected Libraries $libraries;
/**
- * Compiler Dynamic Get Data
+ * The Data Class.
*
- * @var Dynamicget
+ * @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;
@@ -951,7 +964,6 @@ class Data
}
return false;
- }
-
+ }
}
diff --git a/src/cb11e8d9-69c2-4095-831c-59908ea402e7/code.power b/src/cb11e8d9-69c2-4095-831c-59908ea402e7/code.power
index 4a071f2..06e72b9 100644
--- a/src/cb11e8d9-69c2-4095-831c-59908ea402e7/code.power
+++ b/src/cb11e8d9-69c2-4095-831c-59908ea402e7/code.power
@@ -7,126 +7,129 @@
protected array $data = [];
/**
- * Compiler Config
+ * The Config Class.
*
- * @var Config
+ * @var Config
* @since 3.2.0
*/
protected Config $config;
/**
- * Compiler Customcode
+ * The Customcode Class.
*
- * @var Customcode
+ * @var Customcode
* @since 3.2.0
*/
protected Customcode $customcode;
/**
- * Compiler Customcode in Gui
+ * The Gui Class.
*
- * @var Gui
+ * @var Gui
* @since 3.2.0
- **/
+ */
protected Gui $gui;
/**
- * Compiler Placeholder
+ * The Placeholder Class.
*
- * @var Placeholder
+ * @var Placeholder
* @since 3.2.0
- **/
+ */
protected Placeholder $placeholder;
/**
- * Compiler Language
+ * The Language Class.
*
- * @var Language
+ * @var Language
* @since 3.2.0
- **/
+ */
protected Language $language;
/**
- * Compiler Field
+ * The Field Class.
*
- * @var Field
+ * @var Field
* @since 3.2.0
*/
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
+ * @var Filesfolders
* @since 3.2.0
*/
- protected Filesfolders $filesFolders;
+ protected Filesfolders $filesfolders;
/**
- * Compiler Libraries Model
+ * The Libraries Class.
*
- * @var Libraries
+ * @var Libraries
* @since 3.2.0
*/
protected Libraries $libraries;
/**
- * Compiler Dynamic Get Data
+ * The Data Class.
*
- * @var Dynamicget
+ * @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;
@@ -910,4 +923,4 @@
}
return false;
- }
+ }
\ No newline at end of file
diff --git a/src/cb11e8d9-69c2-4095-831c-59908ea402e7/settings.json b/src/cb11e8d9-69c2-4095-831c-59908ea402e7/settings.json
index 27ff2cb..296331b 100644
--- a/src/cb11e8d9-69c2-4095-831c-59908ea402e7/settings.json
+++ b/src/cb11e8d9-69c2-4095-831c-59908ea402e7/settings.json
@@ -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"
diff --git a/src/fa4bf18e-301e-42e3-91fb-6e0096c07adc/README.md b/src/fa4bf18e-301e-42e3-91fb-6e0096c07adc/README.md
index 55aacb3..5cf05db 100644
--- a/src/fa4bf18e-301e-42e3-91fb-6e0096c07adc/README.md
+++ b/src/fa4bf18e-301e-42e3-91fb-6e0096c07adc/README.md
@@ -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
diff --git a/src/fa4bf18e-301e-42e3-91fb-6e0096c07adc/code.php b/src/fa4bf18e-301e-42e3-91fb-6e0096c07adc/code.php
index e08f68c..4759597 100644
--- a/src/fa4bf18e-301e-42e3-91fb-6e0096c07adc/code.php
+++ b/src/fa4bf18e-301e-42e3-91fb-6e0096c07adc/code.php
@@ -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)
{
@@ -945,7 +1005,6 @@ class Config extends BaseConfig
protected function getFootableversion(): int
{
return 2; // default is version 2
- }
-
+ }
}
diff --git a/src/fa4bf18e-301e-42e3-91fb-6e0096c07adc/code.power b/src/fa4bf18e-301e-42e3-91fb-6e0096c07adc/code.power
index e2d622e..7eaac24 100644
--- a/src/fa4bf18e-301e-42e3-91fb-6e0096c07adc/code.power
+++ b/src/fa4bf18e-301e-42e3-91fb-6e0096c07adc/code.power
@@ -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)
{
@@ -911,4 +971,4 @@
protected function getFootableversion(): int
{
return 2; // default is version 2
- }
+ }
\ No newline at end of file