Compare commits
1 Commits
Author | SHA1 | Date | |
---|---|---|---|
9eb4af5027
|
15
CHANGELOG.md
15
CHANGELOG.md
@@ -1,10 +1,6 @@
|
||||
# v5.1.2-alpha3
|
||||
# v5.1.2-alpha4
|
||||
|
||||
- Migrates view HTML classes to use getModel() directly instead of the deprecated magic get() calls to model methods.
|
||||
- Refactores event handling (contentPrepare, titlePrepare, contentBeforeDisplay, contentAfterDisplay) to use Joomla 5’s native event dispatcher via the model’s new getDispatcher() method.
|
||||
- Updates table classes to properly support NULL values, both in the store() method and in table variable definitions. #1245
|
||||
- Extractes the setAutoCheckIn() and setCheckInCall() logic into a dedicated CheckInNow class for cleaner design.
|
||||
- Replace all direct $app->input property calls with the recommended $app->getInput() method across the entire codebase.
|
||||
- Add Joomla 6 build option
|
||||
|
||||
# v5.1.2-alpha
|
||||
|
||||
@@ -12,7 +8,12 @@
|
||||
- Add native module builder for Joomla 4/5
|
||||
- Refactor dynamic get methods into dedicated classes
|
||||
- Move Joomla DB handling into compiler injector flow
|
||||
- Fix auto-check(in) method for Joomla 4/5 compatibility
|
||||
- Fix auto-check(in) method for Joomla 4/5 compatibility
|
||||
- Migrates view HTML classes to use getModel() directly instead of the deprecated magic get() calls to model methods.
|
||||
- Refactores event handling (contentPrepare, titlePrepare, contentBeforeDisplay, contentAfterDisplay) to use Joomla 5's native event dispatcher via the model’s new getDispatcher() method.
|
||||
- Updates table classes to properly support NULL values, both in the store() method and in table variable definitions. #1245
|
||||
- Extractes the setAutoCheckIn() and setCheckInCall() logic into a dedicated CheckInNow class for cleaner design.
|
||||
- Replace all direct $app->input property calls with the recommended $app->getInput() method across the entire codebase.
|
||||
|
||||
# v5.1.1
|
||||
|
||||
|
@@ -3292,7 +3292,7 @@ class Com_ComponentbuilderInstallerScript implements InstallerScriptInterface
|
||||
echo '<div style="background-color: #fff;" class="alert alert-info"><a target="_blank" href="https://dev.vdm.io" title="Component Builder">
|
||||
<img src="components/com_componentbuilder/assets/images/vdm-component.jpg"/>
|
||||
</a>
|
||||
<h3>Upgrade to Version 5.1.2-alpha3 Was Successful! Let us know if anything is not working as expected.</h3></div>';
|
||||
<h3>Upgrade to Version 5.1.2-alpha4 Was Successful! Let us know if anything is not working as expected.</h3></div>';
|
||||
|
||||
// Add/Update component in the action logs extensions table.
|
||||
$this->setActionLogsExtensions();
|
||||
|
@@ -9,7 +9,7 @@ This is a professional-grade [Joomla 5.x](https://extensions.joomla.org/extensio
|
||||
|
||||
JCB generates native Joomla components, plugins, and modules for Joomla 3.x, 4.x, and 5.x - and is already prepared for Joomla 6. Every compiled project is tailored for the specific version without needing backward compatibility plugins. With integrated version-aware compiling, smart boilerplating, and Git-powered project syncing, JCB is much more than a code generator-it's a **full-stack development pipeline for Joomla extensions**.
|
||||
|
||||
You can install this component easily. The latest release (**5.1.2-alpha3**) is available on [Releases](https://git.vdm.dev/joomla/pkg-component-builder/releases) and updated frequently with full source access.
|
||||
You can install this component easily. The latest release (**5.1.2-alpha4**) is available on [Releases](https://git.vdm.dev/joomla/pkg-component-builder/releases) and updated frequently with full source access.
|
||||
|
||||
Upgrades are seamless through Joomla's built-in extension update mechanism.
|
||||
|
||||
@@ -229,9 +229,9 @@ JCB is developed by developers for developers. Its purpose is to democratize hig
|
||||
* **Company:** [Vast Development Method](https://dev.vdm.io)
|
||||
* **Author:** [Llewellyn van der Merwe](mailto:joomla@vdm.io)
|
||||
* **Component:** [Component Builder](https://git.vdm.dev/joomla/Component-Builder)
|
||||
* **Created:** 30th April, 2015 · **Last Build:** 3rd September, 2025 · **Version:** 5.1.2-alpha3
|
||||
* **Created:** 30th April, 2015 · **Last Build:** 9th September, 2025 · **Version:** 5.1.2-alpha4
|
||||
* **License:** GNU General Public License version 2 or later; see LICENSE.txt · **Copyright:** Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* **Lines:** 1156347 · **Fields:** 2091 · **Files:** 7831 · **Folders:** 740
|
||||
* **Lines:** 1197549 · **Fields:** 2091 · **Files:** 7998 · **Folders:** 752
|
||||
|
||||
> Generated with [JCB](https://www.joomlacomponentbuilder.com) — The Smartest Way to Build Joomla Extensions.
|
||||
|
||||
|
@@ -9,7 +9,7 @@ This is a professional-grade [Joomla 5.x](https://extensions.joomla.org/extensio
|
||||
|
||||
JCB generates native Joomla components, plugins, and modules for Joomla 3.x, 4.x, and 5.x - and is already prepared for Joomla 6. Every compiled project is tailored for the specific version without needing backward compatibility plugins. With integrated version-aware compiling, smart boilerplating, and Git-powered project syncing, JCB is much more than a code generator-it's a **full-stack development pipeline for Joomla extensions**.
|
||||
|
||||
You can install this component easily. The latest release (**5.1.2-alpha3**) is available on [Releases](https://git.vdm.dev/joomla/pkg-component-builder/releases) and updated frequently with full source access.
|
||||
You can install this component easily. The latest release (**5.1.2-alpha4**) is available on [Releases](https://git.vdm.dev/joomla/pkg-component-builder/releases) and updated frequently with full source access.
|
||||
|
||||
Upgrades are seamless through Joomla's built-in extension update mechanism.
|
||||
|
||||
@@ -229,9 +229,9 @@ JCB is developed by developers for developers. Its purpose is to democratize hig
|
||||
* **Company:** [Vast Development Method](https://dev.vdm.io)
|
||||
* **Author:** [Llewellyn van der Merwe](mailto:joomla@vdm.io)
|
||||
* **Component:** [Component Builder](https://git.vdm.dev/joomla/Component-Builder)
|
||||
* **Created:** 30th April, 2015 · **Last Build:** 3rd September, 2025 · **Version:** 5.1.2-alpha3
|
||||
* **Created:** 30th April, 2015 · **Last Build:** 9th September, 2025 · **Version:** 5.1.2-alpha4
|
||||
* **License:** GNU General Public License version 2 or later; see LICENSE.txt · **Copyright:** Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* **Lines:** 1156347 · **Fields:** 2091 · **Files:** 7831 · **Folders:** 740
|
||||
* **Lines:** 1197549 · **Fields:** 2091 · **Files:** 7998 · **Folders:** 752
|
||||
|
||||
> Generated with [JCB](https://www.joomlacomponentbuilder.com) — The Smartest Way to Build Joomla Extensions.
|
||||
|
||||
|
@@ -640,10 +640,10 @@
|
||||
type="number"
|
||||
name="preferred_joomla_version"
|
||||
label="COM_COMPONENTBUILDER_JOOMLA_COMPONENT_PREFERRED_JOOMLA_VERSION_LABEL"
|
||||
default="3"
|
||||
default="5"
|
||||
class="text_area"
|
||||
min="3"
|
||||
max="5"
|
||||
max="6"
|
||||
step="1"
|
||||
/>
|
||||
<!-- Sql Field. Type: Textarea. (joomla) -->
|
||||
|
@@ -3294,7 +3294,7 @@ COM_COMPONENTBUILDER_COMPONENT_UPDATES_UPDATE_STATE_DESCRIPTION="Set the release
|
||||
COM_COMPONENTBUILDER_COMPONENT_UPDATES_UPDATE_STATE_HINT="stable"
|
||||
COM_COMPONENTBUILDER_COMPONENT_UPDATES_UPDATE_STATE_LABEL="Release State"
|
||||
COM_COMPONENTBUILDER_COMPONENT_UPDATES_UPDATE_TARGET_VERSION_DESCRIPTION="Set the release target version"
|
||||
COM_COMPONENTBUILDER_COMPONENT_UPDATES_UPDATE_TARGET_VERSION_HINT="5\.[0123]"
|
||||
COM_COMPONENTBUILDER_COMPONENT_UPDATES_UPDATE_TARGET_VERSION_HINT="5\.[01234]"
|
||||
COM_COMPONENTBUILDER_COMPONENT_UPDATES_UPDATE_TARGET_VERSION_LABEL="Update Server Release Target Version"
|
||||
COM_COMPONENTBUILDER_COMPONENT_UPDATES_URL_DESCRIPTION="Enter Download Link"
|
||||
COM_COMPONENTBUILDER_COMPONENT_UPDATES_URL_HINT="http://www.example.com/file.zip"
|
||||
@@ -6911,6 +6911,7 @@ COM_COMPONENTBUILDER_JOOMLA_POWER_SYSTEM_NAME_LABEL="System Name"
|
||||
COM_COMPONENTBUILDER_JOOMLA_POWER_SYSTEM_NAME_MESSAGE="Error! Please add some text here."
|
||||
COM_COMPONENTBUILDER_JOOMLA_POWER_VERSION_DESC="A count of the number of times this Joomla Power has been revised."
|
||||
COM_COMPONENTBUILDER_JOOMLA_POWER_VERSION_LABEL="Version"
|
||||
COM_COMPONENTBUILDER_JOOMLA_SIX="Joomla 6"
|
||||
COM_COMPONENTBUILDER_JOOMLA_SOCIAL_FEED="Joomla! Social Feed"
|
||||
COM_COMPONENTBUILDER_JOOMLA_THREE="Joomla 3"
|
||||
COM_COMPONENTBUILDER_JOOMLA_VERSION="Joomla Version"
|
||||
|
File diff suppressed because one or more lines are too long
@@ -28,6 +28,7 @@ use Joomla\CMS\Layout\LayoutHelper;
|
||||
use VDM\Joomla\Utilities\ArrayHelper;
|
||||
use VDM\Joomla\Utilities\FormHelper;
|
||||
use VDM\Joomla\Utilities\StringHelper;
|
||||
use Joomla\CMS\Version;
|
||||
|
||||
// No direct access to this file
|
||||
\defined('_JEXEC') or die;
|
||||
@@ -341,12 +342,13 @@ class HtmlView extends BaseHtmlView
|
||||
'label' => 'COM_COMPONENTBUILDER_JOOMLA_VERSION',
|
||||
'class' => 'list_class',
|
||||
'description' => 'COM_COMPONENTBUILDER_WHAT_VERSION_OF_JOOMLA_WOULD_YOU_LIKE_TO_TARGET',
|
||||
'default' => '3'];
|
||||
'default' => (string) Version::MAJOR_VERSION];
|
||||
// start the joomla versions options
|
||||
$options = [
|
||||
'3' => 'COM_COMPONENTBUILDER_JOOMLA_THREE',
|
||||
'4' => 'COM_COMPONENTBUILDER_JOOMLA_FOUR',
|
||||
'5' => 'COM_COMPONENTBUILDER_JOOMLA_FIVE'
|
||||
'5' => 'COM_COMPONENTBUILDER_JOOMLA_FIVE',
|
||||
'6' => 'COM_COMPONENTBUILDER_JOOMLA_SIX'
|
||||
];
|
||||
|
||||
// add to form
|
||||
|
@@ -1,15 +1,15 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<extension type="component" version="5.0" method="upgrade">
|
||||
<name>COM_COMPONENTBUILDER</name>
|
||||
<creationDate>3rd September, 2025</creationDate>
|
||||
<creationDate>9th September, 2025</creationDate>
|
||||
<author>Llewellyn van der Merwe</author>
|
||||
<authorEmail>joomla@vdm.io</authorEmail>
|
||||
<authorUrl>https://dev.vdm.io</authorUrl>
|
||||
<copyright>Copyright (C) 2015 Vast Development Method. All rights reserved.</copyright>
|
||||
<license>GNU General Public License version 2 or later; see LICENSE.txt</license>
|
||||
<version>5.1.2-alpha3</version>
|
||||
<version>5.1.2-alpha4</version>
|
||||
<description>< is highly advanced tool that is truly able to build extremely complex components in a fraction of the time.
|
||||
|
||||
|
@@ -152,7 +152,7 @@
|
||||
<version>5.1.2-alpha</version>
|
||||
<infourl title="Component Builder!">https://dev.vdm.io</infourl>
|
||||
<downloads>
|
||||
<downloadurl type="full" format="zip">https://github.com/joomengine/pkg-component-builder/archive/refs/tags/v5.1.2-alpha3.zip</downloadurl>
|
||||
<downloadurl type="full" format="zip">https://github.com/joomengine/pkg-component-builder/archive/refs/tags/v5.1.2-alpha4.zip</downloadurl>
|
||||
</downloads>
|
||||
<tags>
|
||||
<tag>alpha</tag>
|
||||
@@ -167,10 +167,10 @@
|
||||
<element>pkg_component_builder</element>
|
||||
<type>package</type>
|
||||
<client>admininstrator</client>
|
||||
<version>5.1.2-alpha3</version>
|
||||
<version>5.1.2-alpha4</version>
|
||||
<infourl title="Component Builder!">https://dev.vdm.io</infourl>
|
||||
<downloads>
|
||||
<downloadurl type="full" format="zip">https://github.com/joomengine/pkg-component-builder/archive/refs/tags/v5.1.2-alpha3.zip</downloadurl>
|
||||
<downloadurl type="full" format="zip">https://github.com/joomengine/pkg-component-builder/archive/refs/tags/v5.1.2-alpha4.zip</downloadurl>
|
||||
</downloads>
|
||||
<tags>
|
||||
<tag>alpha</tag>
|
||||
|
@@ -0,0 +1,128 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaSix\ComHelperClass;
|
||||
|
||||
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Line;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Architecture\ComHelperClass\CreateUserInterface;
|
||||
|
||||
|
||||
/**
|
||||
* Helper Class Create User Class for Joomla 6
|
||||
*
|
||||
* @since 5.1.2
|
||||
*/
|
||||
final class CreateUser implements CreateUserInterface
|
||||
{
|
||||
/**
|
||||
* Generates the method definition for creating or updating a user based on the provided parameters.
|
||||
*
|
||||
* This method returns a string representation of a PHP function that includes various
|
||||
* steps for handling user creation and updates, depending on the mode (site registration or admin registration).
|
||||
*
|
||||
* @param $add Determines whether to generate the user creation method or not.
|
||||
* If true, the method will be generated and returned as a string.
|
||||
*
|
||||
* @since 5.1.2
|
||||
* @return string The generated method code as a string if $add is true.
|
||||
* Returns an empty string if $add is false.
|
||||
*/
|
||||
public function get($add): string
|
||||
{
|
||||
if ($add)
|
||||
{
|
||||
$method = [];
|
||||
$method[] = PHP_EOL . PHP_EOL . Indent::_(1) . "/**";
|
||||
$method[] = Indent::_(1) . " * Save user details by either creating a new user or updating an existing user.";
|
||||
$method[] = Indent::_(1) . " *";
|
||||
$method[] = Indent::_(1)
|
||||
. " * @param array \$credentials ['name' => string, 'username' => string, 'email' => string, 'password' => string, 'password2' => string]";
|
||||
$method[] = Indent::_(1) . " * @param int \$autologin";
|
||||
$method[] = Indent::_(1)
|
||||
. " * @param array \$params ['useractivation' => int, 'sendpassword' => int, 'allowUserRegistration' => int]";
|
||||
$method[] = Indent::_(1)
|
||||
. " * @param array \$mode 1 = Site Registrations; 0 = Admin Registration; 2 = Custom Helper Method Called registerUser";
|
||||
$method[] = Indent::_(1) . " *";
|
||||
$method[] = Indent::_(1) . " * @return int User ID on success";
|
||||
$method[] = Indent::_(1) . " *";
|
||||
$method[] = Indent::_(1) . " * @throws \InvalidArgumentException If required credentials are missing.";
|
||||
$method[] = Indent::_(1) . " * @throws \RuntimeException If the user update or creation fails.";
|
||||
$method[] = Indent::_(1) . " * @throws Super__"."_1c10a5f1_204d_4f17_ad9f_0e0684f2030d___Power If the user is not found.";
|
||||
$method[] = Indent::_(1) . " *";
|
||||
$method[] = Indent::_(1) . " * @since 3.0.0";
|
||||
$method[] = Indent::_(1) . " * @deprecated 4.3 Use Super__"."_7832a726_87b6_4e95_887e_7b725d3fab8f___Power::create(\$credentials, \$autologin, \$params, \$mode);";
|
||||
$method[] = Indent::_(1) . " */";
|
||||
$method[] = Indent::_(1)
|
||||
. "public static function createUser(\$credentials, \$autologin = 0,";
|
||||
$method[] = Indent::_(2) . "\$params = [";
|
||||
$method[] = Indent::_(3)
|
||||
. "'useractivation' => 0, 'sendpassword' => 1";
|
||||
$method[] = Indent::_(2) . "], \$mode = 1";
|
||||
$method[] = Indent::_(1) . ")";
|
||||
$method[] = Indent::_(1) . "{";
|
||||
$method[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
|
||||
. " Create a user with the UserHelper class (Super---7832a726_87b6_4e95_887e_7b725d3fab8f---Power)";
|
||||
$method[] = Indent::_(2)
|
||||
. "return Super__"."_7832a726_87b6_4e95_887e_7b725d3fab8f___Power::create(\$credentials, \$autologin, \$params, \$mode);";
|
||||
$method[] = Indent::_(1) . "}";
|
||||
|
||||
$method[] = PHP_EOL . PHP_EOL . Indent::_(1) . "/**";
|
||||
$method[] = Indent::_(1) . " * Update the given component params.";
|
||||
$method[] = Indent::_(1) . " *";
|
||||
$method[] = Indent::_(1) . " * @param string|null \$option The optional extension element name.";
|
||||
$method[] = Indent::_(1) . " * @param string \$target The parameter name to be updated.";
|
||||
$method[] = Indent::_(1) . " * @param mixed \$value The value to set for the parameter.";
|
||||
$method[] = Indent::_(1) . " *";
|
||||
$method[] = Indent::_(1) . " * @since 3.0.0";
|
||||
$method[] = Indent::_(1) . " * @deprecated 4.3 Use Super__"."_640b5352_fb09_425f_a26e_cd44eda03f15___Power::setParams(\$target, \$value, \$option);";
|
||||
$method[] = Indent::_(1) . " */";
|
||||
$method[] = PHP_EOL . Indent::_(1)
|
||||
. "public static function setParams(\$option, \$target, \$value)";
|
||||
$method[] = Indent::_(1) . "{";
|
||||
$method[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
|
||||
. " Sets a parameter value for the given target in the specified option's params";
|
||||
$method[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
|
||||
. " (Super---640b5352_fb09_425f_a26e_cd44eda03f15---Power)";
|
||||
$method[] = Indent::_(2)
|
||||
. "return Super__"."_640b5352_fb09_425f_a26e_cd44eda03f15___Power::setParams(\$target, \$value, \$option);";
|
||||
$method[] = Indent::_(1) . "}";
|
||||
|
||||
$method[] = PHP_EOL . Indent::_(1) . "/**";
|
||||
$method[] = Indent::_(1) . " * Update user details";
|
||||
$method[] = Indent::_(1) . " *";
|
||||
$method[] = Indent::_(1) . " * @param array \$userDetails Array containing user details to be updated";
|
||||
$method[] = Indent::_(1) . " *";
|
||||
$method[] = Indent::_(1) . " * @return int Updated user ID on success.";
|
||||
$method[] = Indent::_(1) . " *";
|
||||
$method[] = Indent::_(1) . " * @throws \RuntimeException If user update fails.";
|
||||
$method[] = Indent::_(1) . " *";
|
||||
$method[] = Indent::_(1) . " * @since 3.0.0";
|
||||
$method[] = Indent::_(1) . " * @deprecated 4.3 Use Super__"."_7832a726_87b6_4e95_887e_7b725d3fab8f___Power::update(\$userDetails);";
|
||||
$method[] = Indent::_(1) . " */";
|
||||
$method[] = Indent::_(1)
|
||||
. "public static function updateUser(\$userDetails): int";
|
||||
$method[] = Indent::_(1) . "{";
|
||||
$method[] = Indent::_(2)
|
||||
. "//" . Line::_(__Line__, __Class__)
|
||||
. " Update user details with the UserHelper class (Super---7832a726_87b6_4e95_887e_7b725d3fab8f---Power)";
|
||||
$method[] = Indent::_(2) . "return Super__"."_7832a726_87b6_4e95_887e_7b725d3fab8f___Power::update(\$userDetails);";
|
||||
$method[] = Indent::_(1) . "}";
|
||||
|
||||
// return the help method
|
||||
return implode(PHP_EOL, $method);
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
@@ -0,0 +1,129 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaSix\Controller;
|
||||
|
||||
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Config;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Creator\Permission;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Customcode\Dispenser;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Line;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Architecture\Controller\AllowAddInterface;
|
||||
|
||||
|
||||
/**
|
||||
* Controller Allow Add Class for Joomla 6
|
||||
*
|
||||
* @since 5.1.2
|
||||
*/
|
||||
final class AllowAdd implements AllowAddInterface
|
||||
{
|
||||
/**
|
||||
* The Component code name.
|
||||
*
|
||||
* @var String
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected String $component;
|
||||
|
||||
/**
|
||||
* The Permission Class.
|
||||
*
|
||||
* @var Permission
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected Permission $permission;
|
||||
|
||||
/**
|
||||
* The Dispenser Class.
|
||||
*
|
||||
* @var Dispenser
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected Dispenser $dispenser;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param Config $config The Config Class.
|
||||
* @param Permission $permission The Permission Class.
|
||||
* @param Dispenser $dispenser The Dispenser Class.
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function __construct(Config $config, Permission $permission,
|
||||
Dispenser $dispenser)
|
||||
{
|
||||
$this->component = $config->component_code_name;
|
||||
$this->permission = $permission;
|
||||
$this->dispenser = $dispenser;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Allow Add Function Code
|
||||
*
|
||||
* @param string $nameSingleCode The single code name of the view.
|
||||
*
|
||||
* @since 3.2.0
|
||||
* @return string The allow add method code
|
||||
*/
|
||||
public function get(string $nameSingleCode): string
|
||||
{
|
||||
$allow = [];
|
||||
|
||||
// prepare custom permission script
|
||||
$custom_allow = $this->dispenser->get(
|
||||
'php_allowadd', $nameSingleCode, '', null, true
|
||||
);
|
||||
|
||||
$allow[] = PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__, __Class__)
|
||||
. " Get user object.";
|
||||
$allow[] = Indent::_(2) . "\$user = \$this->app->getIdentity();";
|
||||
// check if the item has permissions.
|
||||
if ($this->permission->globalExist($nameSingleCode, 'core.access'))
|
||||
{
|
||||
$allow[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
|
||||
. " Access check.";
|
||||
$allow[] = Indent::_(2) . "\$access = \$user->authorise('"
|
||||
. $this->permission->getGlobal($nameSingleCode, 'core.access')
|
||||
. "', 'com_" . $this->component . "');";
|
||||
$allow[] = Indent::_(2) . "if (!\$access)";
|
||||
$allow[] = Indent::_(2) . "{";
|
||||
$allow[] = Indent::_(3) . "return false;";
|
||||
$allow[] = Indent::_(2) . "}";
|
||||
}
|
||||
|
||||
// load custom permission script
|
||||
$allow[] = $custom_allow;
|
||||
|
||||
// check if the item has permissions.
|
||||
if ($this->permission->globalExist($nameSingleCode, 'core.create'))
|
||||
{
|
||||
// setup the default script
|
||||
$allow[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
|
||||
. " In the absence of better information, revert to the component permissions.";
|
||||
$allow[] = Indent::_(2) . "return \$user->authorise('"
|
||||
. $this->permission->getGlobal($nameSingleCode, 'core.create')
|
||||
. "', \$this->option);";
|
||||
}
|
||||
else
|
||||
{
|
||||
// setup the default script
|
||||
$allow[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
|
||||
. " In the absence of better information, revert to the component permissions.";
|
||||
$allow[] = Indent::_(2) . "return parent::allowAdd(\$data);";
|
||||
}
|
||||
|
||||
return implode(PHP_EOL, $allow);
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,300 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaSix\Controller;
|
||||
|
||||
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Config;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Creator\Permission;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Customcode\Dispenser;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Builder\Category;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Builder\CategoryOtherName;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Line;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Architecture\Controller\AllowEditInterface;
|
||||
|
||||
|
||||
/**
|
||||
* Controller Allow Edit Class for Joomla 6
|
||||
*
|
||||
* @since 5.1.2
|
||||
*/
|
||||
final class AllowEdit implements AllowEditInterface
|
||||
{
|
||||
/**
|
||||
* The Component code name.
|
||||
*
|
||||
* @var String
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected String $component;
|
||||
|
||||
/**
|
||||
* The Permission Class.
|
||||
*
|
||||
* @var Permission
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected Permission $permission;
|
||||
|
||||
/**
|
||||
* The Dispenser Class.
|
||||
*
|
||||
* @var Dispenser
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected Dispenser $dispenser;
|
||||
|
||||
/**
|
||||
* The Category Class.
|
||||
*
|
||||
* @var Category
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected Category $category;
|
||||
|
||||
/**
|
||||
* The CategoryOtherName Class.
|
||||
*
|
||||
* @var CategoryOtherName
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected CategoryOtherName $categoryothername;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param Config $config The Config Class.
|
||||
* @param Permission $permission The Permission Class.
|
||||
* @param Dispenser $dispenser The Dispenser Class.
|
||||
* @param Category $category The Category Class.
|
||||
* @param CategoryOtherName $categoryothername The CategoryOtherName Class.
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function __construct(Config $config, Permission $permission,
|
||||
Dispenser $dispenser, Category $category,
|
||||
CategoryOtherName $categoryothername)
|
||||
{
|
||||
$this->component = $config->component_code_name;
|
||||
$this->permission = $permission;
|
||||
$this->dispenser = $dispenser;
|
||||
$this->category = $category;
|
||||
$this->categoryothername = $categoryothername;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Allow Edit Function Code
|
||||
*
|
||||
* @param string $nameSingleCode The single code name of the view.
|
||||
* @param string $nameListCode The list code name of the view.
|
||||
*
|
||||
* @since 3.2.0
|
||||
* @return string The allow edit method code
|
||||
*/
|
||||
public function get(string $nameSingleCode, string $nameListCode): string
|
||||
{
|
||||
$allow = [];
|
||||
|
||||
// prepare custom permission script
|
||||
$customAllow = $this->dispenser->get(
|
||||
'php_allowedit', $nameSingleCode
|
||||
);
|
||||
|
||||
if ($this->category->exists("{$nameListCode}"))
|
||||
{
|
||||
// check if category has another name
|
||||
$otherViews = $this->categoryothername->
|
||||
get($nameListCode . '.views', $nameListCode);
|
||||
$otherView = $this->categoryothername->
|
||||
get($nameListCode . '.view', $nameSingleCode);
|
||||
// setup the category script
|
||||
$allow[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
|
||||
. " get user object.";
|
||||
$allow[] = Indent::_(2) . "\$user = \$this->app->getIdentity();";
|
||||
$allow[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
|
||||
. " get record id.";
|
||||
$allow[] = Indent::_(2)
|
||||
. "\$recordId = (int) isset(\$data[\$key]) ? \$data[\$key] : 0;";
|
||||
// load custom permission script
|
||||
$allow[] = $customAllow;
|
||||
// check if the item has permissions.
|
||||
if ($this->permission->globalExist($otherView, 'core.access'))
|
||||
{
|
||||
$allow[] = PHP_EOL . Indent::_(2) . "//" . Line::_(
|
||||
__LINE__,__CLASS__
|
||||
) . " Access check.";
|
||||
$allow[] = Indent::_(2) . "\$access = (\$user->authorise('"
|
||||
. $this->permission->getGlobal($otherView, 'core.access')
|
||||
. "', 'com_" . $this->component . "." . $otherView
|
||||
. ".' . (int) \$recordId) && \$user->authorise('"
|
||||
. $this->permission->getGlobal($otherView, 'core.access')
|
||||
. "', 'com_" . $this->component . "'));";
|
||||
$allow[] = Indent::_(2) . "if (!\$access)";
|
||||
$allow[] = Indent::_(2) . "{";
|
||||
$allow[] = Indent::_(3) . "return false;";
|
||||
$allow[] = Indent::_(2) . "}";
|
||||
}
|
||||
$allow[] = PHP_EOL . Indent::_(2) . "if (\$recordId)";
|
||||
$allow[] = Indent::_(2) . "{";
|
||||
$allow[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__)
|
||||
. " The record has been set. Check the record permissions.";
|
||||
// check if the item has permissions.
|
||||
$allow[] = Indent::_(3) . "\$permission = \$user->authorise('"
|
||||
. $this->permission->getAction($otherView, 'core.edit') . "', 'com_" . $this->component . "."
|
||||
. $otherView . ".' . (int) \$recordId);";
|
||||
$allow[] = Indent::_(3) . "if (!\$permission)";
|
||||
$allow[] = Indent::_(3) . "{";
|
||||
// check if the item has permissions.
|
||||
$allow[] = Indent::_(4) . "if (\$user->authorise('"
|
||||
. $this->permission->getAction($otherView, 'core.edit.own') . "', 'com_" . $this->component . "."
|
||||
. $otherView . ".' . \$recordId))";
|
||||
$allow[] = Indent::_(4) . "{";
|
||||
$allow[] = Indent::_(5) . "//" . Line::_(__Line__, __Class__)
|
||||
. " Fallback on edit.own. Now test the owner is the user.";
|
||||
$allow[] = Indent::_(5)
|
||||
. "\$ownerId = (int) isset(\$data['created_by']) ? \$data['created_by'] : 0;";
|
||||
$allow[] = Indent::_(5) . "if (empty(\$ownerId))";
|
||||
$allow[] = Indent::_(5) . "{";
|
||||
$allow[] = Indent::_(6) . "//" . Line::_(__Line__, __Class__)
|
||||
. " Need to do a lookup from the model.";
|
||||
$allow[] = Indent::_(6)
|
||||
. "\$record = \$this->getModel()->getItem(\$recordId);";
|
||||
$allow[] = PHP_EOL . Indent::_(6) . "if (empty(\$record))";
|
||||
$allow[] = Indent::_(6) . "{";
|
||||
$allow[] = Indent::_(7) . "return false;";
|
||||
$allow[] = Indent::_(6) . "}";
|
||||
$allow[] = Indent::_(6) . "\$ownerId = \$record->created_by;";
|
||||
$allow[] = Indent::_(5) . "}";
|
||||
$allow[] = PHP_EOL . Indent::_(5) . "//" . Line::_(__Line__, __Class__)
|
||||
. " If the owner matches 'me' then do the test.";
|
||||
$allow[] = Indent::_(5) . "if (\$ownerId == \$user->id)";
|
||||
$allow[] = Indent::_(5) . "{";
|
||||
// check if the item has permissions.
|
||||
$allow[] = Indent::_(6) . "if (\$user->authorise('"
|
||||
. $this->permission->getGlobal($otherView, 'core.edit.own') . "', 'com_" . $this->component . "'))";
|
||||
$allow[] = Indent::_(6) . "{";
|
||||
$allow[] = Indent::_(7) . "return true;";
|
||||
$allow[] = Indent::_(6) . "}";
|
||||
$allow[] = Indent::_(5) . "}";
|
||||
$allow[] = Indent::_(4) . "}";
|
||||
$allow[] = Indent::_(4) . "return false;";
|
||||
$allow[] = Indent::_(3) . "}";
|
||||
$allow[] = Indent::_(2) . "}";
|
||||
if ($this->permission->globalExist($otherView, 'core.edit'))
|
||||
{
|
||||
$allow[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
|
||||
. " Since there is no permission, revert to the component permissions.";
|
||||
$allow[] = Indent::_(2) . "return \$user->authorise('"
|
||||
. $this->permission->getGlobal($otherView, 'core.edit') . "', \$this->option);";
|
||||
}
|
||||
else
|
||||
{
|
||||
$allow[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
|
||||
. " Since there is no permission, revert to the component permissions.";
|
||||
$allow[] = Indent::_(2)
|
||||
. "return parent::allowEdit(\$data, \$key);";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// setup the category script
|
||||
$allow[] = PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__, __Class__)
|
||||
. " get user object.";
|
||||
$allow[] = Indent::_(2) . "\$user = \$this->app->getIdentity();";
|
||||
$allow[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
|
||||
. " get record id.";
|
||||
$allow[] = Indent::_(2)
|
||||
. "\$recordId = (int) isset(\$data[\$key]) ? \$data[\$key] : 0;";
|
||||
// load custom permission script
|
||||
$allow[] = $customAllow;
|
||||
// check if the item has permissions.
|
||||
if ($this->permission->actionExist($nameSingleCode, 'core.access'))
|
||||
{
|
||||
$allow[] = PHP_EOL . Indent::_(2) . "//" . Line::_(
|
||||
__LINE__,__CLASS__
|
||||
) . " Access check.";
|
||||
$allow[] = Indent::_(2) . "\$access = (\$user->authorise('"
|
||||
. $this->permission->getAction($nameSingleCode, 'core.access') . "', 'com_" . $this->component . "."
|
||||
. $nameSingleCode
|
||||
. ".' . (int) \$recordId) && \$user->authorise('"
|
||||
. $this->permission->getAction($nameSingleCode, 'core.access') . "', 'com_" . $this->component . "'));";
|
||||
$allow[] = Indent::_(2) . "if (!\$access)";
|
||||
$allow[] = Indent::_(2) . "{";
|
||||
$allow[] = Indent::_(3) . "return false;";
|
||||
$allow[] = Indent::_(2) . "}";
|
||||
}
|
||||
$allow[] = PHP_EOL . Indent::_(2) . "if (\$recordId)";
|
||||
$allow[] = Indent::_(2) . "{";
|
||||
$allow[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__)
|
||||
. " The record has been set. Check the record permissions.";
|
||||
// check if the item has permissions.
|
||||
$allow[] = Indent::_(3) . "\$permission = \$user->authorise('"
|
||||
. $this->permission->getAction($nameSingleCode, 'core.edit') . "', 'com_" . $this->component . "."
|
||||
. $nameSingleCode . ".' . (int) \$recordId);";
|
||||
$allow[] = Indent::_(3) . "if (!\$permission)";
|
||||
$allow[] = Indent::_(3) . "{";
|
||||
// check if the item has permissions.
|
||||
$allow[] = Indent::_(4) . "if (\$user->authorise('"
|
||||
. $this->permission->getAction($nameSingleCode, 'core.edit.own') . "', 'com_" . $this->component . "."
|
||||
. $nameSingleCode . ".' . \$recordId))";
|
||||
$allow[] = Indent::_(4) . "{";
|
||||
$allow[] = Indent::_(5) . "//" . Line::_(__Line__, __Class__)
|
||||
. " Now test the owner is the user.";
|
||||
$allow[] = Indent::_(5)
|
||||
. "\$ownerId = (int) isset(\$data['created_by']) ? \$data['created_by'] : 0;";
|
||||
$allow[] = Indent::_(5) . "if (empty(\$ownerId))";
|
||||
$allow[] = Indent::_(5) . "{";
|
||||
$allow[] = Indent::_(6) . "//" . Line::_(__Line__, __Class__)
|
||||
. " Need to do a lookup from the model.";
|
||||
$allow[] = Indent::_(6)
|
||||
. "\$record = \$this->getModel()->getItem(\$recordId);";
|
||||
$allow[] = PHP_EOL . Indent::_(6) . "if (empty(\$record))";
|
||||
$allow[] = Indent::_(6) . "{";
|
||||
$allow[] = Indent::_(7) . "return false;";
|
||||
$allow[] = Indent::_(6) . "}";
|
||||
$allow[] = Indent::_(6) . "\$ownerId = \$record->created_by;";
|
||||
$allow[] = Indent::_(5) . "}";
|
||||
$allow[] = PHP_EOL . Indent::_(5) . "//" . Line::_(__Line__, __Class__)
|
||||
. " If the owner matches 'me' then allow.";
|
||||
$allow[] = Indent::_(5) . "if (\$ownerId == \$user->id)";
|
||||
$allow[] = Indent::_(5) . "{";
|
||||
// check if the item has permissions.
|
||||
$allow[] = Indent::_(6) . "if (\$user->authorise('"
|
||||
. $this->permission->getGlobal($nameSingleCode, 'core.edit.own') . "', 'com_" . $this->component . "'))";
|
||||
$allow[] = Indent::_(6) . "{";
|
||||
$allow[] = Indent::_(7) . "return true;";
|
||||
$allow[] = Indent::_(6) . "}";
|
||||
$allow[] = Indent::_(5) . "}";
|
||||
$allow[] = Indent::_(4) . "}";
|
||||
$allow[] = Indent::_(4) . "return false;";
|
||||
$allow[] = Indent::_(3) . "}";
|
||||
$allow[] = Indent::_(2) . "}";
|
||||
if ($this->permission->globalExist($nameSingleCode, 'core.edit'))
|
||||
{
|
||||
$allow[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
|
||||
. " Since there is no permission, revert to the component permissions.";
|
||||
$allow[] = Indent::_(2) . "return \$user->authorise('"
|
||||
. $this->permission->getGlobal($nameSingleCode, 'core.edit') . "', \$this->option);";
|
||||
}
|
||||
else
|
||||
{
|
||||
$allow[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
|
||||
. " Since there is no permission, revert to the component permissions.";
|
||||
$allow[] = Indent::_(2)
|
||||
. "return parent::allowEdit(\$data, \$key);";
|
||||
}
|
||||
}
|
||||
|
||||
return implode(PHP_EOL, $allow);
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,243 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaSix\Controller;
|
||||
|
||||
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Creator\Permission;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Customcode\Dispenser;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Builder\Category;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Builder\CategoryOtherName;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Line;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Architecture\Controller\AllowEditViewsInterface;
|
||||
|
||||
|
||||
/**
|
||||
* Controller Allow Edit Views Class for Joomla 6
|
||||
*
|
||||
* @since 5.1.2
|
||||
*/
|
||||
final class AllowEditViews implements AllowEditViewsInterface
|
||||
{
|
||||
/**
|
||||
* The Permission Class.
|
||||
*
|
||||
* @var Permission
|
||||
* @since 5.0.2
|
||||
*/
|
||||
protected Permission $permission;
|
||||
|
||||
/**
|
||||
* The Dispenser Class.
|
||||
*
|
||||
* @var Dispenser
|
||||
* @since 5.0.2
|
||||
*/
|
||||
protected Dispenser $dispenser;
|
||||
|
||||
/**
|
||||
* The Category Class.
|
||||
*
|
||||
* @var Category
|
||||
* @since 5.0.2
|
||||
*/
|
||||
protected Category $category;
|
||||
|
||||
/**
|
||||
* The CategoryOtherName Class.
|
||||
*
|
||||
* @var CategoryOtherName
|
||||
* @since 5.0.2
|
||||
*/
|
||||
protected CategoryOtherName $categoryothername;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param Permission $permission The Permission Class.
|
||||
* @param Dispenser $dispenser The Dispenser Class.
|
||||
* @param Category $category The Category Class.
|
||||
* @param CategoryOtherName $categoryothername The CategoryOtherName Class.
|
||||
*
|
||||
* @since 5.0.2
|
||||
*/
|
||||
public function __construct(Permission $permission,
|
||||
Dispenser $dispenser, Category $category,
|
||||
CategoryOtherName $categoryothername)
|
||||
{
|
||||
$this->permission = $permission;
|
||||
$this->dispenser = $dispenser;
|
||||
$this->category = $category;
|
||||
$this->categoryothername = $categoryothername;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Array Code
|
||||
*
|
||||
* @param array $views
|
||||
*
|
||||
* @since 5.0.2
|
||||
* @return string The array of Code (string)
|
||||
*/
|
||||
public function getArray(array $views): string
|
||||
{
|
||||
$allow = [];
|
||||
foreach ($views as $nameSingleCode => $nameListCode)
|
||||
{
|
||||
$allow[] = $this->getViewArray($nameSingleCode, $nameListCode);
|
||||
}
|
||||
|
||||
if ($allow === [])
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
return PHP_EOL . Indent::_(2) . implode("," . PHP_EOL . Indent::_(2), $allow);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Custom Function Code
|
||||
*
|
||||
* @param array $views
|
||||
*
|
||||
* @since 5.0.2
|
||||
* @return string The functions of Code (string)
|
||||
*/
|
||||
public function getFunctions(array $views): string
|
||||
{
|
||||
$allow = [];
|
||||
foreach ($views as $nameSingleCode => $nameListCode)
|
||||
{
|
||||
if (($function = $this->getViewFunction($nameSingleCode, $nameListCode)) !== null)
|
||||
{
|
||||
$allow[] = $function;
|
||||
}
|
||||
}
|
||||
|
||||
if ($allow === [])
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
return PHP_EOL . PHP_EOL . implode(PHP_EOL . PHP_EOL, $allow);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get View Permissions Array Code
|
||||
*
|
||||
* @param string $nameSingleCode The single code name of the view.
|
||||
* @param string $nameListCode The list code name of the view.
|
||||
*
|
||||
* @since 3.2.0
|
||||
* @return string The allow edit method code
|
||||
*/
|
||||
protected function getViewArray(string $nameSingleCode, string $nameListCode): string
|
||||
{
|
||||
$allow = [];
|
||||
|
||||
// prepare custom permission script
|
||||
$customAllow = $this->dispenser->get(
|
||||
'php_allowedit', $nameSingleCode
|
||||
);
|
||||
|
||||
if ($customAllow !== '')
|
||||
{
|
||||
$allow[] = Indent::_(3) . "'function' => 'allowEdit_{$nameSingleCode}'";
|
||||
}
|
||||
|
||||
if ($this->category->exists("{$nameListCode}"))
|
||||
{
|
||||
// check if category has another name
|
||||
$otherView = $this->categoryothername->
|
||||
get($nameListCode . '.view', $nameSingleCode);
|
||||
|
||||
// check if the item has permissions.
|
||||
if ($this->permission->globalExist($otherView, 'core.access'))
|
||||
{
|
||||
$access = $this->permission->getGlobal($otherView, 'core.access');
|
||||
$allow[] = Indent::_(3) . "'access' => '{$access}'";
|
||||
}
|
||||
$edit = $this->permission->getAction($otherView, 'core.edit');
|
||||
$allow[] = Indent::_(3) . "'edit' => '{$edit}'";
|
||||
|
||||
$edit_own = $this->permission->getAction($otherView, 'core.edit.own');
|
||||
$allow[] = Indent::_(3) . "'edit.own' => '{$edit_own}'";
|
||||
}
|
||||
else
|
||||
{
|
||||
// check if the item has permissions.
|
||||
if ($this->permission->actionExist($nameSingleCode, 'core.access'))
|
||||
{
|
||||
$access = $this->permission->getAction($nameSingleCode, 'core.access');
|
||||
$allow[] = Indent::_(3) . "'access' => '{$access}'";
|
||||
}
|
||||
$edit = $this->permission->getAction($nameSingleCode, 'core.edit');
|
||||
$allow[] = Indent::_(3) . "'edit' => '{$edit}'";
|
||||
|
||||
$edit_own = $this->permission->getAction($nameSingleCode, 'core.edit.own');
|
||||
$allow[] = Indent::_(3) . "'edit.own' => '{$edit_own}'";
|
||||
}
|
||||
|
||||
return "'{$nameSingleCode}' => [" . PHP_EOL . implode(',' . PHP_EOL, $allow) . PHP_EOL . Indent::_(2) . ']';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get View Permissions Function Code
|
||||
*
|
||||
* @param string $nameSingleCode The single code name of the view.
|
||||
* @param string $nameListCode The list code name of the view.
|
||||
*
|
||||
* @since 3.2.0
|
||||
* @return string|null The allow edit method code
|
||||
*/
|
||||
protected function getViewFunction(string $nameSingleCode, string $nameListCode): ?string
|
||||
{
|
||||
$allow = [];
|
||||
|
||||
// prepare custom permission script
|
||||
$customAllow = $this->dispenser->get(
|
||||
'php_allowedit', $nameSingleCode
|
||||
);
|
||||
|
||||
if ($customAllow !== '')
|
||||
{
|
||||
// setup the function
|
||||
$allow[] = Indent::_(1) . '/**';
|
||||
$allow[] = Indent::_(1) . " * Method to check if you can edit an existing {$nameSingleCode} record.";
|
||||
$allow[] = Indent::_(1) . ' *';
|
||||
$allow[] = Indent::_(1) . ' * @param array $data An array of input data.';
|
||||
$allow[] = Indent::_(1) . ' * @param string $key The name of the key for the primary key.';
|
||||
$allow[] = Indent::_(1) . ' *';
|
||||
$allow[] = Indent::_(1) . ' * @return boolean';
|
||||
$allow[] = Indent::_(1) . ' *';
|
||||
$allow[] = Indent::_(1) . ' * @since 5.0.2';
|
||||
$allow[] = Indent::_(1) . ' */';
|
||||
$allow[] = Indent::_(1) . "protected function allowEdit_{$nameSingleCode}(\$data = [], \$key = 'id')";
|
||||
$allow[] = Indent::_(1) . '{';
|
||||
$allow[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
|
||||
. " get user object.";
|
||||
$allow[] = Indent::_(2) . "\$user = \$this->identity;";
|
||||
$allow[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
|
||||
. " get record id.";
|
||||
$allow[] = Indent::_(2)
|
||||
. "\$recordId = (int) isset(\$data[\$key]) ? \$data[\$key] : 0;";
|
||||
// load custom permission script
|
||||
$allow[] = $customAllow;
|
||||
$allow[] = Indent::_(1) . '}';
|
||||
|
||||
return implode(PHP_EOL, $allow);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
@@ -0,0 +1,87 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaSix\Model;
|
||||
|
||||
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Config;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Creator\Permission;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Line;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Architecture\Model\CanDeleteInterface;
|
||||
|
||||
|
||||
/**
|
||||
* Model Can Delete Class for Joomla 6
|
||||
*
|
||||
* @since 5.1.2
|
||||
*/
|
||||
final class CanDelete implements CanDeleteInterface
|
||||
{
|
||||
/**
|
||||
* The Component code name.
|
||||
*
|
||||
* @var String
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected String $component;
|
||||
|
||||
/**
|
||||
* The Permission Class.
|
||||
*
|
||||
* @var Permission
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected Permission $permission;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param Config $config The Config Class.
|
||||
* @param Permission $permission The Permission Class.
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function __construct(Config $config, Permission $permission)
|
||||
{
|
||||
$this->component = $config->component_code_name;
|
||||
$this->permission = $permission;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Can Delete Function Code
|
||||
*
|
||||
* @param string $nameSingleCode The single code name of the view.
|
||||
*
|
||||
* @since 3.2.0
|
||||
* @return string The can delete method code
|
||||
*/
|
||||
public function get(string $nameSingleCode): string
|
||||
{
|
||||
$allow = [];
|
||||
|
||||
// setup the default script
|
||||
$allow[] = PHP_EOL . Indent::_(2) . "if (empty(\$record->id) || (\$record->published != -2))";
|
||||
$allow[] = Indent::_(2) . "{";
|
||||
$allow[] = Indent::_(3) . "return false;";
|
||||
$allow[] = Indent::_(2) . "}" . PHP_EOL;
|
||||
|
||||
// check if the item has permissions.
|
||||
$allow[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
|
||||
. " The record has been set. Check the record permissions.";
|
||||
$allow[] = Indent::_(2) . "return \$this->getCurrentUser()->authorise('"
|
||||
. $this->permission->getAction($nameSingleCode, 'core.delete') . "', 'com_" . $this->component . "."
|
||||
. $nameSingleCode . ".' . (int) \$record->id);";
|
||||
|
||||
return implode(PHP_EOL, $allow);
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,108 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaSix\Model;
|
||||
|
||||
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Config;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Creator\Permission;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Line;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Architecture\Model\CanEditStateInterface;
|
||||
|
||||
|
||||
/**
|
||||
* Model Can Edit State Class for Joomla 6
|
||||
*
|
||||
* @since 5.1.2
|
||||
*/
|
||||
final class CanEditState implements CanEditStateInterface
|
||||
{
|
||||
/**
|
||||
* The Component code name.
|
||||
*
|
||||
* @var String
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected String $component;
|
||||
|
||||
/**
|
||||
* The Permission Class.
|
||||
*
|
||||
* @var Permission
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected Permission $permission;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param Config $config The Config Class.
|
||||
* @param Permission $permission The Permission Class.
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function __construct(Config $config, Permission $permission)
|
||||
{
|
||||
$this->component = $config->component_code_name;
|
||||
$this->permission = $permission;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Can Edit State Function Code
|
||||
*
|
||||
* @param string $nameSingleCode The single code name of the view.
|
||||
*
|
||||
* @since 3.2.0
|
||||
* @return string The can edit state method code
|
||||
*/
|
||||
public function get(string $nameSingleCode): string
|
||||
{
|
||||
$allow = [];
|
||||
|
||||
// setup the default script
|
||||
$allow[] = PHP_EOL . Indent::_(2) . "\$user = \$this->getCurrentUser();";
|
||||
$allow[] = Indent::_(2)
|
||||
. "\$recordId = \$record->id ?? 0;";
|
||||
$allow[] = PHP_EOL . Indent::_(2) . "if (\$recordId)";
|
||||
$allow[] = Indent::_(2) . "{";
|
||||
$allow[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__)
|
||||
. " The record has been set. Check the record permissions.";
|
||||
// check if the item has permissions.
|
||||
$allow[] = Indent::_(3) . "\$permission = \$user->authorise('"
|
||||
. $this->permission->getAction($nameSingleCode, 'core.edit.state')
|
||||
. "', 'com_" . $this->component . "." . $nameSingleCode . ".' . (int) \$recordId);";
|
||||
$allow[] = Indent::_(3)
|
||||
. "if (!\$permission && !is_null(\$permission))";
|
||||
$allow[] = Indent::_(3) . "{";
|
||||
$allow[] = Indent::_(4) . "return false;";
|
||||
$allow[] = Indent::_(3) . "}";
|
||||
$allow[] = Indent::_(2) . "}";
|
||||
if ($this->permission->globalExist($nameSingleCode, 'core.edit.state'))
|
||||
{
|
||||
$allow[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
|
||||
. " In the absence of better information, revert to the component permissions.";
|
||||
$allow[] = Indent::_(2) . "return \$user->authorise('"
|
||||
. $this->permission->getGlobal($nameSingleCode, 'core.edit.state') . "', 'com_" . $this->component
|
||||
. "');";
|
||||
}
|
||||
else
|
||||
{
|
||||
$allow[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
|
||||
. " In the absence of better information, revert to the component permissions.";
|
||||
$allow[] = Indent::_(2)
|
||||
. "return parent::canEditState(\$record);";
|
||||
}
|
||||
|
||||
return implode(PHP_EOL, $allow);
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,109 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaSix\Model;
|
||||
|
||||
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Line;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Architecture\Model\CheckInNowInterface;
|
||||
|
||||
|
||||
/**
|
||||
* Check In Now Method for Joomla 6
|
||||
*
|
||||
* @since 5.1.2
|
||||
*/
|
||||
final class CheckInNow implements CheckInNowInterface
|
||||
{
|
||||
/**
|
||||
* Get the generated call snippet that invokes the check-in method.
|
||||
*
|
||||
* @return string The code that calls the generated method.
|
||||
* @since 5.1.2
|
||||
*/
|
||||
public function getCall(): string
|
||||
{
|
||||
$call = PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__, __Class__) . " Check in items";
|
||||
$call .= PHP_EOL . Indent::_(2) . "\$this->checkInNow();" . PHP_EOL;
|
||||
|
||||
return $call;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the full `checkInNow()` method code for the given view/table.
|
||||
*
|
||||
* @param string $view The view/table suffix (e.g. 'items').
|
||||
* @param string $component The component name (without 'com_').
|
||||
*
|
||||
* @return string The full method code as a string.
|
||||
* @since 5.1.2
|
||||
*/
|
||||
public function getMethod($view, $component): string
|
||||
{
|
||||
$checkin = PHP_EOL . PHP_EOL . Indent::_(1) . "/**";
|
||||
$checkin .= PHP_EOL . Indent::_(1) . " * Build an SQL query to check in all items left checked out longer then a set time.";
|
||||
$checkin .= PHP_EOL . Indent::_(1) . " *";
|
||||
$checkin .= PHP_EOL . Indent::_(1) . " * @return void";
|
||||
$checkin .= PHP_EOL . Indent::_(1) . " * @throws \DateMalformedStringException";
|
||||
$checkin .= PHP_EOL . Indent::_(1) . " * @since 3.2.0";
|
||||
$checkin .= PHP_EOL . Indent::_(1) . " */";
|
||||
$checkin .= PHP_EOL . Indent::_(1) . "protected function checkInNow(): void";
|
||||
$checkin .= PHP_EOL . Indent::_(1) . "{";
|
||||
$checkin .= PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__, __Class__) . " Get set check in time";
|
||||
$checkin .= PHP_EOL . Indent::_(2) . "\$time = Joomla__"."_aeb8e463_291f_4445_9ac4_34b637c12dbd___Power::getParams('com_" . $component . "')->get('check_in');";
|
||||
$checkin .= PHP_EOL . PHP_EOL . Indent::_(2) . "if (\$time)";
|
||||
$checkin .= PHP_EOL . Indent::_(2) . "{";
|
||||
$checkin .= PHP_EOL . Indent::_(3) . "//" . Line::_(__LINE__,__CLASS__) . " Get a db connection.";
|
||||
$checkin .= PHP_EOL . Indent::_(3) . "\$db = \$this->getDatabase();";
|
||||
$checkin .= PHP_EOL . Indent::_(3) . "//" . Line::_(__Line__, __Class__) . " Reset query.";
|
||||
$checkin .= PHP_EOL . Indent::_(3) . "\$query = \$db->getQuery(true);";
|
||||
$checkin .= PHP_EOL . Indent::_(3) . "\$query->select('*');";
|
||||
$checkin .= PHP_EOL . Indent::_(3) . "\$query->from(\$db->quoteName('#__" . $component . "_" . $view . "'));";
|
||||
$checkin .= PHP_EOL . Indent::_(3) . "//" . Line::_(__Line__, __Class__) . " Only select items that are checked out.";
|
||||
|
||||
$checkin .= PHP_EOL . Indent::_(3) . "\$query->where($db->quoteName('checked_out') . ' >= 0');";
|
||||
|
||||
$checkin .= PHP_EOL . Indent::_(3) . "//" . Line::_(__Line__, __Class__) . " Query only to see if we have a rows";
|
||||
$checkin .= PHP_EOL . Indent::_(3) . "\$db->setQuery(\$query, 0, 1);";
|
||||
$checkin .= PHP_EOL . Indent::_(3) . "\$db->execute();";
|
||||
$checkin .= PHP_EOL . Indent::_(3) . "if (\$db->getNumRows())";
|
||||
$checkin .= PHP_EOL . Indent::_(3) . "{";
|
||||
$checkin .= PHP_EOL . Indent::_(4) . "//" . Line::_(__Line__, __Class__) . " Get target date in the past.";
|
||||
$checkin .= PHP_EOL . Indent::_(4) . "\$date = Joomla__"."_39403062_84fb_46e0_bac4_0023f766e827___Power::getDate()->modify(\$time)->toSql();";
|
||||
$checkin .= PHP_EOL . Indent::_(4) . "//" . Line::_(__Line__, __Class__) . " Reset query.";
|
||||
$checkin .= PHP_EOL . Indent::_(4) . "\$query = \$db->getQuery(true);";
|
||||
$checkin .= PHP_EOL . PHP_EOL . Indent::_(4) . "//" . Line::_(__LINE__,__CLASS__) . " Fields to update.";
|
||||
$checkin .= PHP_EOL . Indent::_(4) . "\$fields = [";
|
||||
|
||||
$checkin .= PHP_EOL . Indent::_(5) . "\$db->quoteName('checked_out_time') . ' = NULL',";
|
||||
$checkin .= PHP_EOL . Indent::_(5) . "\$db->quoteName('checked_out') . ' = NULL'";
|
||||
|
||||
$checkin .= PHP_EOL . Indent::_(4) . "];";
|
||||
$checkin .= PHP_EOL . PHP_EOL . Indent::_(4) . "//" . Line::_(__LINE__,__CLASS__) . " Conditions for which records should be updated.";
|
||||
$checkin .= PHP_EOL . Indent::_(4) . "\$conditions = [";
|
||||
|
||||
$checkin .= PHP_EOL . Indent::_(5) . "\$db->quoteName('checked_out') . ' = 0 OR ' . \$db->quoteName('checked_out') . ' > 0',";
|
||||
|
||||
$checkin .= PHP_EOL . Indent::_(5) . "\$db->quoteName('checked_out_time') . ' < ' . \$db->quote(\$date)";
|
||||
$checkin .= PHP_EOL . Indent::_(4) . "];";
|
||||
$checkin .= PHP_EOL . PHP_EOL . Indent::_(4) . "//" . Line::_(__LINE__,__CLASS__) . " Check table.";
|
||||
$checkin .= PHP_EOL . Indent::_(4) . "\$query->update(\$db->quoteName('#__" . $component . "_" . $view . "'))->set(\$fields)->where(\$conditions); ";
|
||||
$checkin .= PHP_EOL . PHP_EOL . Indent::_(4) . "\$db->setQuery(\$query);";
|
||||
$checkin .= PHP_EOL . PHP_EOL . Indent::_(4) . "\$db->execute();";
|
||||
$checkin .= PHP_EOL . Indent::_(3) . "}";
|
||||
$checkin .= PHP_EOL . Indent::_(2) . "}";
|
||||
$checkin .= PHP_EOL . Indent::_(1) . "}";
|
||||
|
||||
return $checkin;
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
@@ -0,0 +1,170 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaSix\Module;
|
||||
|
||||
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Placeholder;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Builder\ContentOne as Builder;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Architecture\Module\LibraryInterface as Library;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Line;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Architecture\Module\DispatcherInterface;
|
||||
|
||||
|
||||
/**
|
||||
* Module Dispatcher Class for Joomla 6
|
||||
*
|
||||
* @since 5.1.2
|
||||
*/
|
||||
final class Dispatcher implements DispatcherInterface
|
||||
{
|
||||
/**
|
||||
* The Placeholder Class.
|
||||
*
|
||||
* @var Placeholder
|
||||
* @since 5.1.2
|
||||
*/
|
||||
protected Placeholder $placeholder;
|
||||
|
||||
/**
|
||||
* The ContentOne Class.
|
||||
*
|
||||
* @var Builder
|
||||
* @since 5.1.2
|
||||
*/
|
||||
protected Builder $builder;
|
||||
|
||||
/**
|
||||
* The Library Class.
|
||||
*
|
||||
* @var Library
|
||||
* @since 5.1.2
|
||||
*/
|
||||
protected Library $library;
|
||||
|
||||
/**
|
||||
* The Namespace Prefix
|
||||
*
|
||||
* @var string
|
||||
* @since 5.0.0
|
||||
*/
|
||||
protected string $NamespacePrefix;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param Placeholder $placeholder The Placeholder Class.
|
||||
* @param Builder $builder The ContentOne Class.
|
||||
* @param Library $library The Library Class.
|
||||
*
|
||||
* @since 5.1.2
|
||||
*/
|
||||
public function __construct(Placeholder $placeholder, Builder $builder, Library $library)
|
||||
{
|
||||
$this->placeholder = $placeholder;
|
||||
$this->builder = $builder;
|
||||
$this->library = $library;
|
||||
|
||||
// set some global values
|
||||
$this->NamespacePrefix = $this->placeholder->get('NamespacePrefix');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the updated placeholder content for the given module.
|
||||
*
|
||||
* @param object $module The module object containing the necessary data.
|
||||
*
|
||||
* @return string The updated placeholder content.
|
||||
* @since 5.1.2
|
||||
*/
|
||||
public function get(object $module): string
|
||||
{
|
||||
$dispatcher = [];
|
||||
$dispatcher[] = "/**";
|
||||
$dispatcher[] = " *" . Line::_(__LINE__, __CLASS__) . " Dispatcher class for {$module->official_name}";
|
||||
$dispatcher[] = " *";
|
||||
$dispatcher[] = " * @since 5.3.0";
|
||||
$dispatcher[] = " */";
|
||||
|
||||
$library = $this->library->get($module);
|
||||
|
||||
if (empty($module->layout_data) && empty($module->add_class_helper) && empty($module->custom_get) && empty($library))
|
||||
{
|
||||
$dispatcher[] = "class Dispatcher extends AbstractModuleDispatcher {}";
|
||||
return implode(PHP_EOL, $dispatcher). PHP_EOL;
|
||||
}
|
||||
|
||||
if ($module->add_class_helper == 1 || $module->custom_get)
|
||||
{
|
||||
$dispatcher[] = "class Dispatcher extends AbstractModuleDispatcher implements HelperFactoryAwareInterface";
|
||||
$dispatcher[] = "{";
|
||||
$dispatcher[] = Indent::_(1) . "use HelperFactoryAwareTrait;";
|
||||
}
|
||||
else
|
||||
{
|
||||
$dispatcher[] = "class Dispatcher extends AbstractModuleDispatcher";
|
||||
$dispatcher[] = "{";
|
||||
}
|
||||
|
||||
$dispatcher[] = "";
|
||||
$dispatcher[] = Indent::_(1) . "/**";
|
||||
$dispatcher[] = Indent::_(1) . " *" . Line::_(__LINE__, __CLASS__) . " Returns the layout data.";
|
||||
$dispatcher[] = Indent::_(1) . " *";
|
||||
$dispatcher[] = Indent::_(1) . " * @return array";
|
||||
$dispatcher[] = Indent::_(1) . " *";
|
||||
$dispatcher[] = Indent::_(1) . " * @since 5.3.0";
|
||||
$dispatcher[] = Indent::_(1) . " */";
|
||||
$dispatcher[] = Indent::_(1) . "protected function getLayoutData(): array";
|
||||
$dispatcher[] = Indent::_(1) . "{";
|
||||
$dispatcher[] = Indent::_(2) . "\$data = parent::getLayoutData();";
|
||||
$dispatcher[] = "";
|
||||
|
||||
if ($module->add_class_helper == 1)
|
||||
{
|
||||
$dispatcher[] = Indent::_(2) . "\$data['helper'] = \$this->getHelperFactory()->getHelper('{$module->class_helper_name}', \$data);";
|
||||
}
|
||||
elseif ($module->add_class_helper == 2)
|
||||
{
|
||||
$dispatcher[] = Indent::_(2) . "\$data['helper'] = \\{$this->NamespacePrefix}\\Module\\{$module->namespace}\\{$module->target_client_namespace}\\Helper\\{$module->class_helper_name}::class;";
|
||||
}
|
||||
|
||||
if ($module->custom_get)
|
||||
{
|
||||
$dispatcher[] = Indent::_(2) . "\$data['data'] = \$this->getHelperFactory()->getHelper('{$module->class_data_name}', \$data);";
|
||||
}
|
||||
|
||||
// load the libraries
|
||||
if (!empty($library))
|
||||
{
|
||||
$dispatcher[] = "";
|
||||
$dispatcher[] = Indent::_(2) . $library;
|
||||
}
|
||||
|
||||
// load the custom code here
|
||||
if (!empty($module->layout_data))
|
||||
{
|
||||
$dispatcher[] = "";
|
||||
$dispatcher[] = $module->layout_data;
|
||||
}
|
||||
|
||||
$dispatcher[] = "";
|
||||
$dispatcher[] = Indent::_(2) . "return \$data;";
|
||||
$dispatcher[] = Indent::_(1) . "}";
|
||||
$dispatcher[] = "}";
|
||||
|
||||
return $this->placeholder->update(
|
||||
implode(PHP_EOL, $dispatcher). PHP_EOL,
|
||||
$this->builder->allActive()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,151 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaSix\Module;
|
||||
|
||||
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Placeholder;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Builder\ContentOne;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Architecture\Module\HelperInterface;
|
||||
|
||||
|
||||
/**
|
||||
* Module Helper Code Joomla 6
|
||||
*
|
||||
* @since 5.1.2
|
||||
*/
|
||||
final class Helper implements HelperInterface
|
||||
{
|
||||
/**
|
||||
* The Placeholder Class.
|
||||
*
|
||||
* @var Placeholder
|
||||
* @since 5.1.2
|
||||
*/
|
||||
protected Placeholder $placeholder;
|
||||
|
||||
/**
|
||||
* The ContentOne Class.
|
||||
*
|
||||
* @var ContentOne
|
||||
* @since 5.1.2
|
||||
*/
|
||||
protected ContentOne $contentone;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param Placeholder $placeholder The Placeholder Class.
|
||||
* @param ContentOne $contentone The ContentOne Class.
|
||||
*
|
||||
* @since 5.1.2
|
||||
*/
|
||||
public function __construct(Placeholder $placeholder, ContentOne $contentone)
|
||||
{
|
||||
$this->placeholder = $placeholder;
|
||||
$this->contentone = $contentone;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Module Helper Class code
|
||||
*
|
||||
* @param object $module The module object
|
||||
*
|
||||
* @return string The helper class code
|
||||
* @since 5.1.2
|
||||
*/
|
||||
public function get(object $module): string
|
||||
{
|
||||
$type = trim((string) ($module->class_helper_type ?? 'class'));
|
||||
$name = trim((string) ($module->class_helper_name ?? 'Helper'));
|
||||
$body = (string) ($module->class_helper_code ?? '');
|
||||
$implements = '';
|
||||
|
||||
if ($this->usesDatabaseFeatures($body))
|
||||
{
|
||||
$implements = ' implements DatabaseAwareInterface';
|
||||
|
||||
if (!str_contains($body, 'use DatabaseAwareTrait;'))
|
||||
{
|
||||
$body = Indent::_(1) . 'use DatabaseAwareTrait;' . PHP_EOL . PHP_EOL . $body;
|
||||
}
|
||||
}
|
||||
|
||||
$code = PHP_EOL . $type . ' ' . $name . $implements . PHP_EOL . '{' . PHP_EOL . $body . PHP_EOL . '}' . PHP_EOL;
|
||||
|
||||
return $this->placeholder->update($code, $this->contentone->allActive());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Module Helper Header code
|
||||
*
|
||||
* @param object $module The module object
|
||||
*
|
||||
* @return string The helper header code
|
||||
* @since 5.1.2
|
||||
*/
|
||||
public function header(object $module): string
|
||||
{
|
||||
$code = (string) trim($module->class_helper_header ?? '');
|
||||
$body = trim((string) ($module->class_helper_code ?? ''));
|
||||
|
||||
if ($this->usesDatabaseFeatures($body))
|
||||
{
|
||||
if ($code === '')
|
||||
{
|
||||
$code = 'use Joomla\\Database\\DatabaseAwareInterface;' .
|
||||
PHP_EOL . 'use Joomla\\Database\\DatabaseAwareTrait;';
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!str_contains($code, '\\DatabaseAwareInterface;'))
|
||||
{
|
||||
$code .= PHP_EOL . 'use Joomla\\Database\\DatabaseAwareInterface;';
|
||||
}
|
||||
|
||||
if (!str_contains($code, '\\DatabaseAwareTrait;'))
|
||||
{
|
||||
$code .= PHP_EOL . 'use Joomla\\Database\\DatabaseAwareTrait;';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($code === '')
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
return $this->placeholder->update(
|
||||
PHP_EOL . $code, $this->contentone->allActive()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the helper body uses database features.
|
||||
*
|
||||
* @param string $body The helper class body.
|
||||
*
|
||||
* @return bool
|
||||
* @since 5.1.2
|
||||
*/
|
||||
protected function usesDatabaseFeatures(string $body): bool
|
||||
{
|
||||
if ($body === '')
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return str_contains($body, '$this->getDatabase(')
|
||||
|| str_contains($body, 'use DatabaseAwareTrait;');
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,154 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaSix\Module;
|
||||
|
||||
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Builder\LibraryManager;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Library\Document;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Registry;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Placeholder;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Builder\ContentOne;
|
||||
use VDM\Joomla\Utilities\StringHelper;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Line;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Architecture\Module\LibraryInterface;
|
||||
|
||||
|
||||
/**
|
||||
* Module Library Joomla 6
|
||||
*
|
||||
* @since 5.1.2
|
||||
*/
|
||||
final class Library implements LibraryInterface
|
||||
{
|
||||
/**
|
||||
* The LibraryManager Class.
|
||||
*
|
||||
* @var LibraryManager
|
||||
* @since 5.1.2
|
||||
*/
|
||||
protected LibraryManager $librarymanager;
|
||||
|
||||
/**
|
||||
* The Document Class.
|
||||
*
|
||||
* @var Document
|
||||
* @since 5.1.2
|
||||
*/
|
||||
protected Document $document;
|
||||
|
||||
/**
|
||||
* The Registry Class.
|
||||
*
|
||||
* @var Registry
|
||||
* @since 5.1.2
|
||||
*/
|
||||
protected Registry $registry;
|
||||
|
||||
/**
|
||||
* The Placeholder Class.
|
||||
*
|
||||
* @var Placeholder
|
||||
* @since 5.1.2
|
||||
*/
|
||||
protected Placeholder $placeholder;
|
||||
|
||||
/**
|
||||
* The ContentOne Class.
|
||||
*
|
||||
* @var ContentOne
|
||||
* @since 5.1.2
|
||||
*/
|
||||
protected ContentOne $contentone;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param LibraryManager $librarymanager The LibraryManager Class.
|
||||
* @param Document $document The Document Class.
|
||||
* @param Registry $registry The Registry Class.
|
||||
* @param Placeholder $placeholder The Placeholder Class.
|
||||
* @param ContentOne $contentone The ContentOne Class.
|
||||
*
|
||||
* @since 5.1.2
|
||||
*/
|
||||
public function __construct(LibraryManager $librarymanager, Document $document,
|
||||
Registry $registry, Placeholder $placeholder,
|
||||
ContentOne $contentone)
|
||||
{
|
||||
$this->librarymanager = $librarymanager;
|
||||
$this->document = $document;
|
||||
$this->registry = $registry;
|
||||
$this->placeholder = $placeholder;
|
||||
$this->contentone = $contentone;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the module's library loading code.
|
||||
*
|
||||
* @param object $module The module object
|
||||
*
|
||||
* @return string The generated code to load libraries into the document.
|
||||
* @since 5.1.2
|
||||
*/
|
||||
public function get(object $module): string
|
||||
{
|
||||
$data = $this->librarymanager->get($module->key . '.' . $module->code_name);
|
||||
|
||||
if ($data === null)
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
$code = '// ' . Line::_(__LINE__, __CLASS__) . ' get the document object' . PHP_EOL;
|
||||
$code .= '$document = $this->app->getDocument();';
|
||||
|
||||
$found = false;
|
||||
|
||||
foreach ($data as $id => $item)
|
||||
{
|
||||
$library = $this->registry->get("builder.libraries.{$id}");
|
||||
|
||||
if (!is_object($library))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!empty($library->document) && StringHelper::check($library->document))
|
||||
{
|
||||
$code .= PHP_EOL . $library->document;
|
||||
$found = true;
|
||||
}
|
||||
elseif (isset($library->how))
|
||||
{
|
||||
$code .= $this->document->get($id);
|
||||
$found = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$found)
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
// Normalize and inject placeholders
|
||||
$lines = explode(PHP_EOL, $code);
|
||||
$trimmed = array_map('trim', $lines);
|
||||
$normalized = str_replace('$this->document->', '$document->', implode(PHP_EOL . Indent::_(2), $trimmed));
|
||||
|
||||
return $this->placeholder->update(
|
||||
$this->placeholder->update_($normalized),
|
||||
$this->contentone->allActive()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,570 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaSix\Module;
|
||||
|
||||
|
||||
use Joomla\Filesystem\Folder;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Config;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Language;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Language\Set;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Language\Purge;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Language\Translation;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Language\Multilingual;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\EventInterface as Event;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Creator\FieldsetExtension;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Builder\ContentOne;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Builder\Languages;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Builder\Multilingual as BuilderMultilingual;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Counter;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Utilities\File;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Line;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent;
|
||||
use VDM\Joomla\Utilities\ArrayHelper;
|
||||
use VDM\Joomla\Utilities\StringHelper;
|
||||
use VDM\Joomla\Componentbuilder\Interfaces\Architecture\Module\MainXMLInterface;
|
||||
|
||||
|
||||
/**
|
||||
* Joomla 6 Module Main XML Class
|
||||
*
|
||||
* @since 5.1.2
|
||||
*/
|
||||
final class MainXML implements MainXMLInterface
|
||||
{
|
||||
/**
|
||||
* The Config Class.
|
||||
*
|
||||
* @var Config
|
||||
* @since 5.1.2
|
||||
*/
|
||||
protected Config $config;
|
||||
|
||||
/**
|
||||
* The Language Class.
|
||||
*
|
||||
* @var Language
|
||||
* @since 5.1.2
|
||||
*/
|
||||
protected Language $language;
|
||||
|
||||
/**
|
||||
* The Set Class.
|
||||
*
|
||||
* @var Set
|
||||
* @since 5.1.2
|
||||
*/
|
||||
protected Set $set;
|
||||
|
||||
/**
|
||||
* The Purge Class.
|
||||
*
|
||||
* @var Purge
|
||||
* @since 5.1.2
|
||||
*/
|
||||
protected Purge $purge;
|
||||
|
||||
/**
|
||||
* The Translation Class.
|
||||
*
|
||||
* @var Translation
|
||||
* @since 5.1.2
|
||||
*/
|
||||
protected Translation $translation;
|
||||
|
||||
/**
|
||||
* The Multilingual Class.
|
||||
*
|
||||
* @var Multilingual
|
||||
* @since 5.1.2
|
||||
*/
|
||||
protected Multilingual $multilingual;
|
||||
|
||||
/**
|
||||
* The EventInterface Class.
|
||||
*
|
||||
* @var Event
|
||||
* @since 5.1.2
|
||||
*/
|
||||
protected Event $event;
|
||||
|
||||
/**
|
||||
* The FieldsetExtension Class.
|
||||
*
|
||||
* @var FieldsetExtension
|
||||
* @since 5.1.2
|
||||
*/
|
||||
protected FieldsetExtension $fieldsetextension;
|
||||
|
||||
/**
|
||||
* The ContentOne Class.
|
||||
*
|
||||
* @var ContentOne
|
||||
* @since 5.1.2
|
||||
*/
|
||||
protected ContentOne $contentone;
|
||||
|
||||
/**
|
||||
* The Languages Class.
|
||||
*
|
||||
* @var Languages
|
||||
* @since 5.1.2
|
||||
*/
|
||||
protected Languages $languages;
|
||||
|
||||
/**
|
||||
* The Multilingual Class.
|
||||
*
|
||||
* @var BuilderMultilingual
|
||||
* @since 5.1.2
|
||||
*/
|
||||
protected BuilderMultilingual $buildermultilingual;
|
||||
|
||||
/**
|
||||
* The Counter Class.
|
||||
*
|
||||
* @var Counter
|
||||
* @since 5.1.2
|
||||
*/
|
||||
protected Counter $counter;
|
||||
|
||||
/**
|
||||
* The File Class.
|
||||
*
|
||||
* @var File
|
||||
* @since 5.1.2
|
||||
*/
|
||||
protected File $file;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param Config $config The Config Class.
|
||||
* @param Language $language The Language Class.
|
||||
* @param Set $set The Set Class.
|
||||
* @param Purge $purge The Purge Class.
|
||||
* @param Translation $translation The Translation Class.
|
||||
* @param Multilingual $multilingual The Multilingual Class.
|
||||
* @param Event $event The EventInterface Class.
|
||||
* @param FieldsetExtension $fieldsetextension The FieldsetExtension Class.
|
||||
* @param ContentOne $contentone The ContentOne Class.
|
||||
* @param Languages $languages The Languages Class.
|
||||
* @param BuilderMultilingual $buildermultilingual The Multilingual Class.
|
||||
* @param Counter $counter The Counter Class.
|
||||
* @param File $file The File Class.
|
||||
*
|
||||
* @since 5.1.2
|
||||
*/
|
||||
public function __construct(Config $config, Language $language, Set $set, Purge $purge,
|
||||
Translation $translation, Multilingual $multilingual,
|
||||
Event $event, FieldsetExtension $fieldsetextension,
|
||||
ContentOne $contentone, Languages $languages,
|
||||
BuilderMultilingual $buildermultilingual,
|
||||
Counter $counter, File $file)
|
||||
{
|
||||
$this->config = $config;
|
||||
$this->language = $language;
|
||||
$this->set = $set;
|
||||
$this->purge = $purge;
|
||||
$this->translation = $translation;
|
||||
$this->multilingual = $multilingual;
|
||||
$this->event = $event;
|
||||
$this->fieldsetextension = $fieldsetextension;
|
||||
$this->contentone = $contentone;
|
||||
$this->languages = $languages;
|
||||
$this->buildermultilingual = $buildermultilingual;
|
||||
$this->counter = $counter;
|
||||
$this->file = $file;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates the main XML for the module.
|
||||
*
|
||||
* @param object $module The module object.
|
||||
*
|
||||
* @return string The generated XML.
|
||||
* @since 5.1.2
|
||||
*/
|
||||
public function get(object $module): string
|
||||
{
|
||||
$config_fields = $this->buildConfigFields($module);
|
||||
$add_component_path = $this->shouldAddComponentPath($module);
|
||||
$language_files = $this->generateLanguageFiles($module);
|
||||
|
||||
$xml = $this->generateScriptAndSqlXml($module);
|
||||
$xml .= $this->generateLanguageXml($module, $language_files);
|
||||
$xml .= $this->generateFileXml($module, $language_files);
|
||||
$xml .= $this->generateConfigXml($module, $config_fields, $add_component_path);
|
||||
$xml .= $this->generateUpdateServerXml($module);
|
||||
|
||||
return $xml;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build configuration fields XML.
|
||||
*
|
||||
* @param object $module The module object.
|
||||
*
|
||||
* @return array The configuration fields.
|
||||
* @since 5.1.2
|
||||
*/
|
||||
protected function buildConfigFields(object $module): array
|
||||
{
|
||||
$configFields = [];
|
||||
if (!isset($module->config_fields) || !ArrayHelper::check($module->config_fields))
|
||||
{
|
||||
return $configFields;
|
||||
}
|
||||
|
||||
$dbKey = 'yyy';
|
||||
$addScriptsField = true;
|
||||
|
||||
foreach ($module->config_fields as $fieldName => $fieldsets)
|
||||
{
|
||||
foreach ($fieldsets as $fieldset => $fields)
|
||||
{
|
||||
$xmlFields = $this->fieldsetextension->get($module, $fields, $dbKey);
|
||||
|
||||
if ($addScriptsField && $module->add_scripts_field)
|
||||
{
|
||||
$xmlFields .= PHP_EOL . Indent::_(2) . '<field type="modadminvvvvvvvdm" />';
|
||||
$addScriptsField = false;
|
||||
}
|
||||
|
||||
if (isset($xmlFields) && StringHelper::check($xmlFields))
|
||||
{
|
||||
$configFields["{$fieldName}{$fieldset}"] = $xmlFields;
|
||||
}
|
||||
$dbKey++;
|
||||
}
|
||||
}
|
||||
|
||||
return $configFields;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the component path should be added.
|
||||
*
|
||||
* @param object $module The module object.
|
||||
*
|
||||
* @return bool True if the component path should be added, false otherwise.
|
||||
* @since 5.1.2
|
||||
*/
|
||||
protected function shouldAddComponentPath(object $module): bool
|
||||
{
|
||||
if (!isset($module->config_fields) || !ArrayHelper::check($module->config_fields) ||
|
||||
!isset($module->fieldsets_paths) || !ArrayHelper::check($module->fieldsets_paths))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach ($module->config_fields as $fieldName => $fieldsets)
|
||||
{
|
||||
foreach ($fieldsets as $fieldset => $fields)
|
||||
{
|
||||
if (isset($module->fieldsets_paths["{$fieldName}{$fieldset}"]) &&
|
||||
$module->fieldsets_paths["{$fieldName}{$fieldset}"] == 1)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate XML for script and SQL files.
|
||||
*
|
||||
* @param object $module The module object.
|
||||
*
|
||||
* @return string The XML for script and SQL files.
|
||||
* @since 5.1.2
|
||||
*/
|
||||
protected function generateScriptAndSqlXml(object $module): string
|
||||
{
|
||||
$xml = '';
|
||||
|
||||
if ($module->add_install_script)
|
||||
{
|
||||
$xml .= PHP_EOL . PHP_EOL . Indent::_(1) . '<!--' . Line::_(
|
||||
__LINE__,__CLASS__
|
||||
) . ' Scripts to run on installation -->';
|
||||
$xml .= PHP_EOL . Indent::_(1) . '<scriptfile>script.php</scriptfile>';
|
||||
}
|
||||
|
||||
if ($module->add_sql)
|
||||
{
|
||||
$xml .= PHP_EOL . PHP_EOL . Indent::_(1) . '<!--' . Line::_(
|
||||
__LINE__,__CLASS__
|
||||
) . ' Runs on install -->';
|
||||
$xml .= PHP_EOL . Indent::_(1) . '<install>';
|
||||
$xml .= PHP_EOL . Indent::_(2) . '<sql>';
|
||||
$xml .= PHP_EOL . Indent::_(3) . '<file driver="mysql" charset="utf8">sql/mysql/install.sql</file>';
|
||||
$xml .= PHP_EOL . Indent::_(2) . '</sql>';
|
||||
$xml .= PHP_EOL . Indent::_(1) . '</install>';
|
||||
}
|
||||
|
||||
if ($module->add_sql_uninstall)
|
||||
{
|
||||
$xml .= PHP_EOL . PHP_EOL . Indent::_(1) . '<!--' . Line::_(
|
||||
__LINE__,__CLASS__
|
||||
) . ' Runs on uninstall -->';
|
||||
$xml .= PHP_EOL . Indent::_(1) . '<uninstall>';
|
||||
$xml .= PHP_EOL . Indent::_(2) . '<sql>';
|
||||
$xml .= PHP_EOL . Indent::_(3) . '<file driver="mysql" charset="utf8">sql/mysql/uninstall.sql</file>';
|
||||
$xml .= PHP_EOL . Indent::_(2) . '</sql>';
|
||||
$xml .= PHP_EOL . Indent::_(1) . '</uninstall>';
|
||||
}
|
||||
|
||||
return $xml;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate XML for language files.
|
||||
*
|
||||
* @param object $module The module object.
|
||||
* @param array $languageFiles The language files.
|
||||
*
|
||||
* @return string The XML for language files.
|
||||
* @since 5.1.2
|
||||
*/
|
||||
protected function generateLanguageXml(object $module, array $languageFiles): string
|
||||
{
|
||||
$xml = '';
|
||||
|
||||
if (ArrayHelper::check($languageFiles))
|
||||
{
|
||||
$xml .= PHP_EOL . PHP_EOL . Indent::_(1) . '<!--' . Line::_(
|
||||
__LINE__, __CLASS__
|
||||
) . ' Language files -->';
|
||||
$xml .= PHP_EOL . Indent::_(1) . '<languages folder="language">';
|
||||
|
||||
foreach ($languageFiles as $tag)
|
||||
{
|
||||
$xml .= PHP_EOL . Indent::_(2) . "<language tag=\"{$tag}\">{$tag}/{$module->file_name}.ini</language>";
|
||||
$xml .= PHP_EOL . Indent::_(2) . "<language tag=\"{$tag}\">{$tag}/{$module->file_name}.sys.ini</language>";
|
||||
}
|
||||
|
||||
$xml .= PHP_EOL . Indent::_(1) . '</languages>';
|
||||
}
|
||||
|
||||
return $xml;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate the XML for the files.
|
||||
*
|
||||
* @param object $module The module object.
|
||||
* @param array $languageFiles The language files.
|
||||
*
|
||||
* @return string The XML for the files.
|
||||
* @since 5.1.2
|
||||
*/
|
||||
protected function generateFileXml(object $module, array $languageFiles): string
|
||||
{
|
||||
$files = Folder::files($module->folder_path);
|
||||
$folders = Folder::folders($module->folder_path);
|
||||
$ignore = ['services', 'sql', 'language', 'script.php', "{$module->file_name}.xml", "{$module->file_name}.php"];
|
||||
|
||||
$xml = PHP_EOL . PHP_EOL . Indent::_(1) . '<!--' . Line::_(
|
||||
__LINE__, __CLASS__
|
||||
) . ' Module files -->';
|
||||
|
||||
$xml .= PHP_EOL . Indent::_(1) . '<files>';
|
||||
$xml .= PHP_EOL . Indent::_(2) . "<folder module=\"{$module->file_name}\">services</folder>";
|
||||
|
||||
foreach ($files as $file)
|
||||
{
|
||||
if (!in_array($file, $ignore))
|
||||
{
|
||||
$xml .= PHP_EOL . Indent::_(2) . "<filename>{$file}</filename>";
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($languageFiles))
|
||||
{
|
||||
$xml .= PHP_EOL . Indent::_(2) . '<folder>language</folder>';
|
||||
}
|
||||
|
||||
if ($module->add_sql || $module->add_sql_uninstall)
|
||||
{
|
||||
$xml .= PHP_EOL . Indent::_(2) . '<folder>sql</folder>';
|
||||
}
|
||||
|
||||
foreach ($folders as $folder)
|
||||
{
|
||||
if (!in_array($folder, $ignore))
|
||||
{
|
||||
$xml .= PHP_EOL . Indent::_(2) . "<folder>{$folder}</folder>";
|
||||
}
|
||||
}
|
||||
|
||||
$xml .= PHP_EOL . Indent::_(1) . '</files>';
|
||||
|
||||
return $xml;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate XML for configuration fields.
|
||||
*
|
||||
* @param object $module The module object.
|
||||
* @param array $configFields The configuration fields.
|
||||
* @param bool $addComponentPath Whether to add the component path.
|
||||
*
|
||||
* @return string The XML for configuration fields.
|
||||
* @since 5.1.2
|
||||
*/
|
||||
protected function generateConfigXml(object $module, array $configFields, bool $addComponentPath): string
|
||||
{
|
||||
if (!isset($module->config_fields) || !ArrayHelper::check($configFields))
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
$xml = PHP_EOL . PHP_EOL . Indent::_(1) . '<!--' . Line::_(
|
||||
__LINE__, __CLASS__
|
||||
) . ' Config parameters -->';
|
||||
$xml .= $addComponentPath ? PHP_EOL . Indent::_(1) . '<config' : PHP_EOL . Indent::_(1) . '<config>';
|
||||
|
||||
if ($addComponentPath)
|
||||
{
|
||||
$namespace = $this->config->namespace_prefix . '\\Component\\' . $this->contentone->get('ComponentNamespace') . '\\Administrator';
|
||||
$xml .= PHP_EOL . Indent::_(3) . "addruleprefix=\"{$namespace}\\Rule\"";
|
||||
$xml .= PHP_EOL . Indent::_(3) . "addfieldprefix=\"{$namespace}\\Field\">";
|
||||
$xml .= PHP_EOL . Indent::_(1) . '>';
|
||||
}
|
||||
|
||||
foreach ($module->config_fields as $fieldName => $fieldsets)
|
||||
{
|
||||
$xml .= PHP_EOL . Indent::_(1) . "<fields name=\"{$fieldName}\">";
|
||||
|
||||
foreach ($fieldsets as $fieldset => $fields)
|
||||
{
|
||||
$label = $module->fieldsets_label["{$fieldName}{$fieldset}"] ?? $fieldset;
|
||||
|
||||
$xml .= PHP_EOL . Indent::_(1) . "<fieldset name=\"{$fieldset}\" label=\"{$label}\">";
|
||||
|
||||
if (isset($configFields["{$fieldName}{$fieldset}"]))
|
||||
{
|
||||
$xml .= $configFields["{$fieldName}{$fieldset}"];
|
||||
}
|
||||
|
||||
$xml .= PHP_EOL . Indent::_(1) . '</fieldset>';
|
||||
}
|
||||
|
||||
$xml .= PHP_EOL . Indent::_(1) . '</fields>';
|
||||
}
|
||||
|
||||
$xml .= PHP_EOL . Indent::_(1) . '</config>';
|
||||
|
||||
return $xml;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate XML for update servers.
|
||||
*
|
||||
* @param object $module The module object.
|
||||
*
|
||||
* @return string The XML for update servers.
|
||||
* @since 5.1.2
|
||||
*/
|
||||
protected function generateUpdateServerXml(object $module): string
|
||||
{
|
||||
$xml = '';
|
||||
|
||||
if ($module->add_update_server)
|
||||
{
|
||||
$xml .= PHP_EOL . PHP_EOL . Indent::_(1) . '<!--' . Line::_(
|
||||
__LINE__, __CLASS__
|
||||
) . ' Update servers -->';
|
||||
$xml .= PHP_EOL . Indent::_(1) . '<updateservers>';
|
||||
$xml .= PHP_EOL . Indent::_(2) . "<server type=\"extension\" priority=\"1\" name=\"{$module->official_name}\">{$module->update_server_url}</server>";
|
||||
$xml .= PHP_EOL . Indent::_(1) . '</updateservers>';
|
||||
}
|
||||
|
||||
return $xml;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate language files.
|
||||
*
|
||||
* @param object $module The module object.
|
||||
*
|
||||
* @return array The language files.
|
||||
* @since 5.1.2
|
||||
*/
|
||||
protected function generateLanguageFiles(object $module): array
|
||||
{
|
||||
$languageFiles = [];
|
||||
|
||||
if (!$this->language->exist($module->key))
|
||||
{
|
||||
return $languageFiles;
|
||||
}
|
||||
|
||||
$langContent = $this->language->getTarget($module->key);
|
||||
$this->event->trigger('jcb_ce_onBeforeBuildModuleLang', [&$module, &$langContent]);
|
||||
|
||||
$values = array_unique($langContent);
|
||||
$this->buildermultilingual->set('modules', $this->multilingual->get($values));
|
||||
|
||||
$langTag = $this->config->get('lang_tag', 'en-GB');
|
||||
$this->languages->set("modules.{$langTag}.all", $langContent);
|
||||
$this->language->setTarget($module->key, null);
|
||||
|
||||
$this->set->execute($values, $module->guid, 'modules');
|
||||
$this->purge->execute($values, $module->guid, 'modules');
|
||||
|
||||
$this->event->trigger('jcb_ce_onBeforeBuildModuleLangFiles', [&$module]);
|
||||
|
||||
if ($this->languages->IsArray('modules'))
|
||||
{
|
||||
foreach ($this->languages->get('modules') as $tag => $areas)
|
||||
{
|
||||
$tag = trim($tag);
|
||||
foreach ($areas as $area => $languageStrings)
|
||||
{
|
||||
$fileName = "{$module->file_name}.ini";
|
||||
$fileSysName = "{$module->file_name}.sys.ini";
|
||||
$total = count($values);
|
||||
if ($this->translation->check($tag, $languageStrings, $total, $fileName))
|
||||
{
|
||||
$lang = array_map(
|
||||
fn($langString, $placeholder) => "{$placeholder}=\"{$langString}\"",
|
||||
array_values($languageStrings),
|
||||
array_keys($languageStrings)
|
||||
);
|
||||
|
||||
$path = "{$module->folder_path}/language/{$tag}/";
|
||||
|
||||
if (!is_dir($path))
|
||||
{
|
||||
Folder::create($path);
|
||||
$this->counter->folder++;
|
||||
}
|
||||
|
||||
$this->file->write($path . $fileName, implode(PHP_EOL, $lang));
|
||||
$this->file->write($path . $fileSysName, implode(PHP_EOL, $lang));
|
||||
|
||||
$this->counter->line += count($lang);
|
||||
unset($lang);
|
||||
|
||||
$languageFiles[$tag] = $tag;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $languageFiles;
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,114 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaSix\Module;
|
||||
|
||||
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Placeholder;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Builder\ContentOne as Builder;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Line;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Architecture\Module\ProviderInterface;
|
||||
|
||||
|
||||
/**
|
||||
* Module Provider Class for Joomla 6
|
||||
*
|
||||
* @since 5.1.2
|
||||
*/
|
||||
final class Provider implements ProviderInterface
|
||||
{
|
||||
/**
|
||||
* The Placeholder Class.
|
||||
*
|
||||
* @var Placeholder
|
||||
* @since 5.1.2
|
||||
*/
|
||||
protected Placeholder $placeholder;
|
||||
|
||||
/**
|
||||
* The ContentOne Class.
|
||||
*
|
||||
* @var Builder
|
||||
* @since 5.1.2
|
||||
*/
|
||||
protected Builder $builder;
|
||||
|
||||
/**
|
||||
* The Namespace Prefix
|
||||
*
|
||||
* @var string
|
||||
* @since 5.1.2
|
||||
*/
|
||||
protected string $NamespacePrefix;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param Placeholder $placeholder The Placeholder Class.
|
||||
* @param Builder $builder The Content One Class.
|
||||
*
|
||||
* @since 5.1.2
|
||||
*/
|
||||
public function __construct(Placeholder $placeholder, Builder $builder)
|
||||
{
|
||||
$this->placeholder = $placeholder;
|
||||
$this->builder = $builder;
|
||||
|
||||
// set some global values
|
||||
$this->NamespacePrefix = $this->placeholder->get('NamespacePrefix');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the updated provider for the given module.
|
||||
*
|
||||
* @param object $module The module object containing the necessary data.
|
||||
*
|
||||
* @return string The provider content.
|
||||
*
|
||||
* @since 5.1.2
|
||||
*/
|
||||
public function get(object $module): string
|
||||
{
|
||||
$provider = [];
|
||||
$provider[] = "/**";
|
||||
$provider[] = " *" . Line::_(__Line__, __Class__) . " The {$module->official_name} module service provider";
|
||||
$provider[] = " *";
|
||||
$provider[] = " * @since 5.4.0";
|
||||
$provider[] = " */";
|
||||
$provider[] = "return new class () implements ServiceProviderInterface {";
|
||||
$provider[] = Indent::_(1) . "/**";
|
||||
$provider[] = Indent::_(1) . " *" . Line::_(__Line__, __Class__) . " Registers the service provider with a DI container.";
|
||||
$provider[] = Indent::_(1) . " *";
|
||||
$provider[] = Indent::_(1) . " * @param Container \$container The DI container.";
|
||||
$provider[] = Indent::_(1) . " *";
|
||||
$provider[] = Indent::_(1) . " * @return void";
|
||||
$provider[] = Indent::_(1) . " * @since 5.4.0";
|
||||
$provider[] = Indent::_(1) . " */";
|
||||
$provider[] = Indent::_(1) . "public function register(Container \$container)";
|
||||
$provider[] = Indent::_(1) . "{";
|
||||
$provider[] = Indent::_(2) . "\$container->registerServiceProvider(new ModuleDispatcherFactory('\\\\{$this->NamespacePrefix}\\\\Module\\\\{$module->namespace}'));";
|
||||
if ($module->add_class_helper == 1 || $module->custom_get)
|
||||
{
|
||||
$provider[] = Indent::_(2) . "\$container->registerServiceProvider(new HelperFactory('\\\\{$this->NamespacePrefix}\\\\Module\\\\{$module->namespace}\\\\{$module->target_client_namespace}\\\\Helper'));";
|
||||
}
|
||||
$provider[] = '';
|
||||
$provider[] = Indent::_(2) . "\$container->registerServiceProvider(new Module());";
|
||||
$provider[] = Indent::_(1) . "}";
|
||||
$provider[] = "};";
|
||||
|
||||
return $this->placeholder->update(
|
||||
implode(PHP_EOL, $provider). PHP_EOL,
|
||||
$this->builder->allActive()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,242 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaSix\Module;
|
||||
|
||||
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Config;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\HeaderInterface as Header;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Customcode\DispenserInterface as Dispenser;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Builder\TemplateData;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Placeholder;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Builder\ContentOne;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Builder\ContentMulti;
|
||||
use VDM\Joomla\Utilities\StringHelper;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Architecture\Module\TemplateInterface;
|
||||
|
||||
|
||||
/**
|
||||
* Module Template Joomla 6
|
||||
*
|
||||
* @since 5.1.2
|
||||
*/
|
||||
final class Template implements TemplateInterface
|
||||
{
|
||||
/**
|
||||
* The Config Class.
|
||||
*
|
||||
* @var Config
|
||||
* @since 5.1.2
|
||||
*/
|
||||
protected Config $config;
|
||||
|
||||
/**
|
||||
* The Header Class.
|
||||
*
|
||||
* @var Header
|
||||
* @since 5.1.2
|
||||
*/
|
||||
protected Header $header;
|
||||
|
||||
/**
|
||||
* The Dispenser Class.
|
||||
*
|
||||
* @var Dispenser
|
||||
* @since 5.1.2
|
||||
*/
|
||||
protected Dispenser $dispenser;
|
||||
|
||||
/**
|
||||
* The TemplateData Class.
|
||||
*
|
||||
* @var TemplateData
|
||||
* @since 5.1.2
|
||||
*/
|
||||
protected TemplateData $templatedata;
|
||||
|
||||
/**
|
||||
* The Placeholder Class.
|
||||
*
|
||||
* @var Placeholder
|
||||
* @since 5.1.2
|
||||
*/
|
||||
protected Placeholder $placeholder;
|
||||
|
||||
/**
|
||||
* The ContentOne Class.
|
||||
*
|
||||
* @var ContentOne
|
||||
* @since 5.1.2
|
||||
*/
|
||||
protected ContentOne $contentone;
|
||||
|
||||
/**
|
||||
* The ContentMulti Class.
|
||||
*
|
||||
* @var ContentMulti
|
||||
* @since 5.1.2
|
||||
*/
|
||||
protected ContentMulti $contentmulti;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param Config $config The Config Class.
|
||||
* @param Header $header The Header Class.
|
||||
* @param Dispenser $dispenser The Dispenser Class.
|
||||
* @param TemplateData $templatedata The TemplateData Class.
|
||||
* @param Placeholder $placeholder The Placeholder Class.
|
||||
* @param ContentOne $contentone The ContentOne Class.
|
||||
* @param ContentMulti $contentmulti The ContentMulti Class.
|
||||
*
|
||||
* @since 5.1.2
|
||||
*/
|
||||
public function __construct(Config $config, Header $header, Dispenser $dispenser,
|
||||
TemplateData $templatedata, Placeholder $placeholder,
|
||||
ContentOne $contentone, ContentMulti $contentmulti)
|
||||
{
|
||||
$this->config = $config;
|
||||
$this->header = $header;
|
||||
$this->dispenser = $dispenser;
|
||||
$this->templatedata = $templatedata;
|
||||
$this->placeholder = $placeholder;
|
||||
$this->contentone = $contentone;
|
||||
$this->contentmulti = $contentmulti;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the updated placeholder default template content for the given module.
|
||||
*
|
||||
* @param object $module The module object containing the necessary data.
|
||||
* @param string $key The dispenser key for this given module.
|
||||
*
|
||||
* @return string The updated placeholder content.
|
||||
* @since 5.1.2
|
||||
*/
|
||||
public function default(object $module, string $key): string
|
||||
{
|
||||
// add any css from the fields
|
||||
$default = $this->dispenser->get(
|
||||
'css_views',
|
||||
$key,
|
||||
PHP_EOL . '<style>',
|
||||
'',
|
||||
true,
|
||||
null,
|
||||
PHP_EOL . '</style>' . PHP_EOL
|
||||
);
|
||||
|
||||
// now add the body
|
||||
$body = trim((string) ($module->default ?? ''));
|
||||
if (!empty($body))
|
||||
{
|
||||
$default .= PHP_EOL . $body . PHP_EOL;
|
||||
}
|
||||
|
||||
// add any JavaScript from the fields
|
||||
$default .= $this->dispenser->get(
|
||||
'views_footer',
|
||||
$key,
|
||||
PHP_EOL . '<script type="text/javascript">',
|
||||
'',
|
||||
true,
|
||||
null,
|
||||
PHP_EOL . '</script>' . PHP_EOL
|
||||
);
|
||||
|
||||
// return the default content for the model default area
|
||||
return $this->placeholder->update(
|
||||
$default,
|
||||
$this->contentone->allActive()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the updated placeholder default header template content for the given module.
|
||||
*
|
||||
* @param object $module The module object containing the necessary data.
|
||||
*
|
||||
* @return string The updated placeholder content.
|
||||
* @since 5.1.2
|
||||
*/
|
||||
public function header(object $module): string
|
||||
{
|
||||
// first add the header
|
||||
$add_default_header = (int) ($module->add_default_header ?? 0);
|
||||
$default = $add_default_header === 1 ? trim((string) ($module->default_header ?? '')) : '';
|
||||
|
||||
if (empty($default))
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
// return the header for the model default area
|
||||
return PHP_EOL . PHP_EOL . $this->placeholder->update($default, $this->contentone->allActive());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the updated placeholder extra template content for the given module.
|
||||
*
|
||||
* @param object $module The module object containing the necessary data.
|
||||
*
|
||||
* @return void
|
||||
* @since 5.1.2
|
||||
*/
|
||||
public function extra(object $module): void
|
||||
{
|
||||
// Build the data key and fetch template data once
|
||||
$data = $this->templatedata->get($module->key . '.' . $module->code_name);
|
||||
|
||||
// Nothing to do if there's no data
|
||||
if (!is_array($data) || $data === [])
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Cache these to avoid repeated calls
|
||||
$activePlaceholders = $this->contentone->allActive();
|
||||
|
||||
// --- HEADER (text) ---
|
||||
$header = (string) ($this->header->get('module.extra.template.header', $module->class_name) ?? '');
|
||||
if ($header !== '')
|
||||
{
|
||||
$header = PHP_EOL . PHP_EOL . $this->placeholder->update($header, $activePlaceholders);
|
||||
}
|
||||
|
||||
foreach ($data as $template => $item)
|
||||
{
|
||||
$target = StringHelper::safe("MODDEFAULT_HEADER_{$template}", 'U');
|
||||
$key = $module->key . '|' . $target;
|
||||
$this->contentmulti->set($key, $header);
|
||||
|
||||
// --- HEADER CODE (php_view) ---
|
||||
$phpView = trim((string) ($item['php_view'] ?? ''));
|
||||
$headerCode = ($phpView === '')
|
||||
? ''
|
||||
: PHP_EOL . $this->placeholder->update($phpView, $activePlaceholders);
|
||||
|
||||
$target = StringHelper::safe("MODDEFAULT_HEADER_CODE_{$template}", 'U');
|
||||
$key = $module->key . '|' . $target;
|
||||
$this->contentmulti->set($key, $headerCode);
|
||||
|
||||
// --- BODY (html) ---
|
||||
$html = (string) ($item['html'] ?? '');
|
||||
$body = ($html === '')
|
||||
? PHP_EOL
|
||||
: PHP_EOL . $this->placeholder->update($html, $activePlaceholders);
|
||||
|
||||
$target = StringHelper::safe("MODDEFAULT_{$template}", 'U');
|
||||
$key = $module->key . '|' . $target;
|
||||
$this->contentmulti->set($key, $body);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
@@ -0,0 +1,246 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaSix\Plugin;
|
||||
|
||||
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Placeholder;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Builder\ContentOne as Builder;
|
||||
use VDM\Joomla\Componentbuilder\Power\Parser;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Architecture\Plugin\ExtensionInterface;
|
||||
|
||||
|
||||
/**
|
||||
* Plugin Extension Class for Joomla 6
|
||||
*
|
||||
* @since 5.1.2
|
||||
*/
|
||||
final class Extension implements ExtensionInterface
|
||||
{
|
||||
/**
|
||||
* The Placeholder Class.
|
||||
*
|
||||
* @var Placeholder
|
||||
* @since 5.0.2
|
||||
*/
|
||||
protected Placeholder $placeholder;
|
||||
|
||||
/**
|
||||
* The ContentOne Class.
|
||||
*
|
||||
* @var Builder
|
||||
* @since 5.0.2
|
||||
*/
|
||||
protected Builder $builder;
|
||||
|
||||
/**
|
||||
* The Parser Class.
|
||||
*
|
||||
* @var Parser
|
||||
* @since 5.0.2
|
||||
*/
|
||||
protected Parser $parser;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param Placeholder $placeholder The Placeholder Class.
|
||||
* @param Builder $builder The Content One Class.
|
||||
* @param Parser $parser The Parser Class.
|
||||
*
|
||||
* @since 5.0.2
|
||||
*/
|
||||
public function __construct(Placeholder $placeholder, Builder $builder, Parser $parser)
|
||||
{
|
||||
$this->placeholder = $placeholder;
|
||||
$this->builder = $builder;
|
||||
$this->parser = $parser;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the updated placeholder content for the given plugin.
|
||||
*
|
||||
* @param object $plugin The plugin object containing the necessary data.
|
||||
*
|
||||
* @return string The updated placeholder content.
|
||||
*
|
||||
* @since 5.0.2
|
||||
*/
|
||||
public function get(object $plugin): string
|
||||
{
|
||||
$add_subscriber_interface = $this->addNeededMethods($plugin->main_class_code);
|
||||
|
||||
$extension = [];
|
||||
$extension[] = $plugin->comment . PHP_EOL . 'final class ';
|
||||
$extension[] = $plugin->class_name . ' extends ' . $plugin->extends;
|
||||
if ($add_subscriber_interface)
|
||||
{
|
||||
$extension[] = ' implements Joomla__' . '_c06c5116_6b9d_487c_9b09_5094ec4506a3___Power';
|
||||
}
|
||||
$extension[] = PHP_EOL . '{' . PHP_EOL;
|
||||
$extension[] = $plugin->main_class_code;
|
||||
$extension[] = PHP_EOL . '}' . PHP_EOL;
|
||||
|
||||
return $this->placeholder->update(
|
||||
implode('', $extension),
|
||||
$this->builder->allActive()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures that the required methods are present in the plugin code.
|
||||
*
|
||||
* This method checks the plugin's code for the presence of required methods,
|
||||
* particularly the method that indicates implementation of the SubscriberInterface.
|
||||
* If the necessary method is missing, it adds it to the code.
|
||||
*
|
||||
* @param string $code The main code of the plugin, passed by reference.
|
||||
*
|
||||
* @return bool Returns true if the SubscriberInterface implementation is added or already present, false otherwise.
|
||||
*
|
||||
* @since 5.0.2
|
||||
*/
|
||||
protected function addNeededMethods(string &$code): bool
|
||||
{
|
||||
// Parse the code to extract its structure, particularly its methods.
|
||||
$code_structure = $this->parser->code($code);
|
||||
|
||||
if (empty($code_structure['methods']))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check if methods are defined and if getSubscribedEvents is not present.
|
||||
if (!$this->getSubscribedEvents($code_structure['methods']))
|
||||
{
|
||||
// Attempt to add the getSubscribedEvents method.
|
||||
$method = $this->addGetSubscribedEvents($code_structure['methods']);
|
||||
if ($method !== null)
|
||||
{
|
||||
// Append the new method to the code and indicate that the interface must be added.
|
||||
$code .= $method;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Return false if the event method could not be added.
|
||||
return false;
|
||||
}
|
||||
|
||||
// Return true if getSubscribedEvents is already present.
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the getSubscribedEvents method
|
||||
*
|
||||
* @param array $methods The plugin methods.
|
||||
*
|
||||
* @return string|null The getSubscribedEvents code
|
||||
*
|
||||
* @since 5.0.2
|
||||
*/
|
||||
protected function addGetSubscribedEvents(array $methods): ?string
|
||||
{
|
||||
$events = [];
|
||||
$counter = 0;
|
||||
foreach ($methods as $method)
|
||||
{
|
||||
if ($this->validEventName($method))
|
||||
{
|
||||
$events[$method['name']] = Indent::_(3) . "'{$method['name']}' => '{$method['name']}'";
|
||||
|
||||
// autoloaded when method start with 'on'
|
||||
// so we can ignore adding the getSubscribedEvents
|
||||
if (substr($method['name'], 0, 2) === 'on')
|
||||
{
|
||||
$counter++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($events === [] || $counter == count($events))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
$method = [];
|
||||
$method[] = PHP_EOL . PHP_EOL . Indent::_(1) . '/**';
|
||||
$method[] = Indent::_(1) . ' * Returns an array of events this subscriber will listen to.';
|
||||
$method[] = Indent::_(1) . ' *';
|
||||
$method[] = Indent::_(1) . ' * @return array';
|
||||
$method[] = Indent::_(1) . ' *';
|
||||
$method[] = Indent::_(1) . ' * @since 5.0.0';
|
||||
$method[] = Indent::_(1) . ' */';
|
||||
$method[] = Indent::_(1) . 'public static function getSubscribedEvents(): array';
|
||||
$method[] = Indent::_(1) . '{';
|
||||
$method[] = Indent::_(2) . 'return [';
|
||||
$method[] = implode(',' . PHP_EOL, $events);
|
||||
$method[] = Indent::_(2) . '];';
|
||||
$method[] = Indent::_(1) . '}';
|
||||
|
||||
return implode(PHP_EOL, $method);
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates if a method name is a valid event name for a Joomla plugin.
|
||||
*
|
||||
* The method must meet the following criteria:
|
||||
* - It must be public, not static, and not abstract.
|
||||
* - It must not be a magic method (i.e., should not start with '__').
|
||||
*
|
||||
* @param array $method The method details, including 'name', 'access', 'static', and 'abstract'.
|
||||
*
|
||||
* @return bool Returns true if the method is a valid event name, otherwise false.
|
||||
*
|
||||
* @since 5.0.2
|
||||
*/
|
||||
protected function validEventName(array $method): bool
|
||||
{
|
||||
// Check if the method is public, static, and not abstract
|
||||
if ($method['access'] !== 'public' || $method['static'] || $method['abstract'])
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check if the method is a magic method (starts with '__')
|
||||
if (substr($method['name'], 0, 2) === '__')
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// If all checks pass, the method is a valid event name
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the getSubscribedEvents is set
|
||||
*
|
||||
* @param array $methods The plugin methods.
|
||||
*
|
||||
* @return bool
|
||||
*
|
||||
* @since 5.0.2
|
||||
*/
|
||||
protected function getSubscribedEvents(array $methods): bool
|
||||
{
|
||||
foreach ($methods as $method)
|
||||
{
|
||||
if ($method['name'] === 'getSubscribedEvents' && $method['static'] && !$method['abstract'])
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,570 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaSix\Plugin;
|
||||
|
||||
|
||||
use Joomla\Filesystem\Folder;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Config;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Language;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Language\Set;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Language\Purge;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Language\Translation;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Language\Multilingual;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\EventInterface as Event;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Creator\FieldsetExtension;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Builder\ContentOne;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Builder\Languages;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Builder\Multilingual as BuilderMultilingual;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Counter;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Utilities\File;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Line;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent;
|
||||
use VDM\Joomla\Utilities\ArrayHelper;
|
||||
use VDM\Joomla\Utilities\StringHelper;
|
||||
use VDM\Joomla\Componentbuilder\Interfaces\Architecture\Plugin\MainXMLInterface;
|
||||
|
||||
|
||||
/**
|
||||
* Joomla 6 Plugin Main XML Class
|
||||
*
|
||||
* @since 5.1.2
|
||||
*/
|
||||
final class MainXML implements MainXMLInterface
|
||||
{
|
||||
/**
|
||||
* The Config Class.
|
||||
*
|
||||
* @var Config
|
||||
* @since 5.0.2
|
||||
*/
|
||||
protected Config $config;
|
||||
|
||||
/**
|
||||
* The Language Class.
|
||||
*
|
||||
* @var Language
|
||||
* @since 5.0.2
|
||||
*/
|
||||
protected Language $language;
|
||||
|
||||
/**
|
||||
* The Set Class.
|
||||
*
|
||||
* @var Set
|
||||
* @since 5.0.2
|
||||
*/
|
||||
protected Set $set;
|
||||
|
||||
/**
|
||||
* The Purge Class.
|
||||
*
|
||||
* @var Purge
|
||||
* @since 5.0.2
|
||||
*/
|
||||
protected Purge $purge;
|
||||
|
||||
/**
|
||||
* The Translation Class.
|
||||
*
|
||||
* @var Translation
|
||||
* @since 5.0.2
|
||||
*/
|
||||
protected Translation $translation;
|
||||
|
||||
/**
|
||||
* The Multilingual Class.
|
||||
*
|
||||
* @var Multilingual
|
||||
* @since 5.0.2
|
||||
*/
|
||||
protected Multilingual $multilingual;
|
||||
|
||||
/**
|
||||
* The EventInterface Class.
|
||||
*
|
||||
* @var Event
|
||||
* @since 5.0.2
|
||||
*/
|
||||
protected Event $event;
|
||||
|
||||
/**
|
||||
* The FieldsetExtension Class.
|
||||
*
|
||||
* @var FieldsetExtension
|
||||
* @since 5.0.2
|
||||
*/
|
||||
protected FieldsetExtension $fieldsetextension;
|
||||
|
||||
/**
|
||||
* The ContentOne Class.
|
||||
*
|
||||
* @var ContentOne
|
||||
* @since 5.0.2
|
||||
*/
|
||||
protected ContentOne $contentone;
|
||||
|
||||
/**
|
||||
* The Languages Class.
|
||||
*
|
||||
* @var Languages
|
||||
* @since 5.0.2
|
||||
*/
|
||||
protected Languages $languages;
|
||||
|
||||
/**
|
||||
* The Multilingual Class.
|
||||
*
|
||||
* @var BuilderMultilingual
|
||||
* @since 5.0.2
|
||||
*/
|
||||
protected BuilderMultilingual $buildermultilingual;
|
||||
|
||||
/**
|
||||
* The Counter Class.
|
||||
*
|
||||
* @var Counter
|
||||
* @since 5.0.2
|
||||
*/
|
||||
protected Counter $counter;
|
||||
|
||||
/**
|
||||
* The File Class.
|
||||
*
|
||||
* @var File
|
||||
* @since 5.0.2
|
||||
*/
|
||||
protected File $file;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param Config $config The Config Class.
|
||||
* @param Language $language The Language Class.
|
||||
* @param Set $set The Set Class.
|
||||
* @param Purge $purge The Purge Class.
|
||||
* @param Translation $translation The Translation Class.
|
||||
* @param Multilingual $multilingual The Multilingual Class.
|
||||
* @param Event $event The EventInterface Class.
|
||||
* @param FieldsetExtension $fieldsetextension The FieldsetExtension Class.
|
||||
* @param ContentOne $contentone The ContentOne Class.
|
||||
* @param Languages $languages The Languages Class.
|
||||
* @param BuilderMultilingual $buildermultilingual The Multilingual Class.
|
||||
* @param Counter $counter The Counter Class.
|
||||
* @param File $file The File Class.
|
||||
*
|
||||
* @since 5.0.2
|
||||
*/
|
||||
public function __construct(Config $config, Language $language, Set $set, Purge $purge,
|
||||
Translation $translation, Multilingual $multilingual,
|
||||
Event $event, FieldsetExtension $fieldsetextension,
|
||||
ContentOne $contentone, Languages $languages,
|
||||
BuilderMultilingual $buildermultilingual,
|
||||
Counter $counter, File $file)
|
||||
{
|
||||
$this->config = $config;
|
||||
$this->language = $language;
|
||||
$this->set = $set;
|
||||
$this->purge = $purge;
|
||||
$this->translation = $translation;
|
||||
$this->multilingual = $multilingual;
|
||||
$this->event = $event;
|
||||
$this->fieldsetextension = $fieldsetextension;
|
||||
$this->contentone = $contentone;
|
||||
$this->languages = $languages;
|
||||
$this->buildermultilingual = $buildermultilingual;
|
||||
$this->counter = $counter;
|
||||
$this->file = $file;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates the main XML for the plugin.
|
||||
*
|
||||
* @param object $plugin The plugin object.
|
||||
*
|
||||
* @return string The generated XML.
|
||||
* @since 5.0.2
|
||||
*/
|
||||
public function get(object $plugin): string
|
||||
{
|
||||
$config_fields = $this->buildConfigFields($plugin);
|
||||
$add_component_path = $this->shouldAddComponentPath($plugin);
|
||||
$language_files = $this->generateLanguageFiles($plugin);
|
||||
|
||||
$xml = $this->generateScriptAndSqlXml($plugin);
|
||||
$xml .= $this->generateLanguageXml($plugin, $language_files);
|
||||
$xml .= $this->generateFileXml($plugin, $language_files);
|
||||
$xml .= $this->generateConfigXml($plugin, $config_fields, $add_component_path);
|
||||
$xml .= $this->generateUpdateServerXml($plugin);
|
||||
|
||||
return $xml;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build configuration fields XML.
|
||||
*
|
||||
* @param object $plugin The plugin object.
|
||||
*
|
||||
* @return array The configuration fields.
|
||||
* @since 5.0.2
|
||||
*/
|
||||
protected function buildConfigFields(object $plugin): array
|
||||
{
|
||||
$configFields = [];
|
||||
if (!isset($plugin->config_fields) || !ArrayHelper::check($plugin->config_fields))
|
||||
{
|
||||
return $configFields;
|
||||
}
|
||||
|
||||
$dbKey = 'yy';
|
||||
|
||||
foreach ($plugin->config_fields as $fieldName => $fieldsets)
|
||||
{
|
||||
foreach ($fieldsets as $fieldset => $fields)
|
||||
{
|
||||
$xmlFields = $this->fieldsetextension->get($plugin, $fields, $dbKey);
|
||||
if (isset($xmlFields) && StringHelper::check($xmlFields))
|
||||
{
|
||||
$configFields["{$fieldName}{$fieldset}"] = $xmlFields;
|
||||
}
|
||||
$dbKey++;
|
||||
}
|
||||
}
|
||||
|
||||
return $configFields;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the component path should be added.
|
||||
*
|
||||
* @param object $plugin The plugin object.
|
||||
*
|
||||
* @return bool True if the component path should be added, false otherwise.
|
||||
* @since 5.0.2
|
||||
*/
|
||||
protected function shouldAddComponentPath(object $plugin): bool
|
||||
{
|
||||
if (!isset($plugin->config_fields) || !ArrayHelper::check($plugin->config_fields) ||
|
||||
!isset($plugin->fieldsets_paths) || !ArrayHelper::check($plugin->fieldsets_paths))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach ($plugin->config_fields as $fieldName => $fieldsets)
|
||||
{
|
||||
foreach ($fieldsets as $fieldset => $fields)
|
||||
{
|
||||
if (isset($plugin->fieldsets_paths["{$fieldName}{$fieldset}"]) &&
|
||||
$plugin->fieldsets_paths["{$fieldName}{$fieldset}"] == 1)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate XML for script and SQL files.
|
||||
*
|
||||
* @param object $plugin The plugin object.
|
||||
*
|
||||
* @return string The XML for script and SQL files.
|
||||
* @since 5.0.2
|
||||
*/
|
||||
protected function generateScriptAndSqlXml(object $plugin): string
|
||||
{
|
||||
$xml = '';
|
||||
|
||||
if ($plugin->add_install_script)
|
||||
{
|
||||
$xml .= PHP_EOL . PHP_EOL . Indent::_(1) . '<!--' . Line::_(
|
||||
__LINE__,__CLASS__
|
||||
) . ' Scripts to run on installation -->';
|
||||
$xml .= PHP_EOL . Indent::_(1) . '<scriptfile>script.php</scriptfile>';
|
||||
}
|
||||
|
||||
if ($plugin->add_sql)
|
||||
{
|
||||
$xml .= PHP_EOL . PHP_EOL . Indent::_(1) . '<!--' . Line::_(
|
||||
__LINE__,__CLASS__
|
||||
) . ' Runs on install -->';
|
||||
$xml .= PHP_EOL . Indent::_(1) . '<install>';
|
||||
$xml .= PHP_EOL . Indent::_(2) . '<sql>';
|
||||
$xml .= PHP_EOL . Indent::_(3) . '<file driver="mysql" charset="utf8">sql/mysql/install.sql</file>';
|
||||
$xml .= PHP_EOL . Indent::_(2) . '</sql>';
|
||||
$xml .= PHP_EOL . Indent::_(1) . '</install>';
|
||||
}
|
||||
|
||||
if ($plugin->add_sql_uninstall)
|
||||
{
|
||||
$xml .= PHP_EOL . PHP_EOL . Indent::_(1) . '<!--' . Line::_(
|
||||
__LINE__,__CLASS__
|
||||
) . ' Runs on uninstall -->';
|
||||
$xml .= PHP_EOL . Indent::_(1) . '<uninstall>';
|
||||
$xml .= PHP_EOL . Indent::_(2) . '<sql>';
|
||||
$xml .= PHP_EOL . Indent::_(3) . '<file driver="mysql" charset="utf8">sql/mysql/uninstall.sql</file>';
|
||||
$xml .= PHP_EOL . Indent::_(2) . '</sql>';
|
||||
$xml .= PHP_EOL . Indent::_(1) . '</uninstall>';
|
||||
}
|
||||
|
||||
return $xml;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate XML for language files.
|
||||
*
|
||||
* @param object $plugin The plugin object.
|
||||
* @param array $languageFiles The language files.
|
||||
*
|
||||
* @return string The XML for language files.
|
||||
* @since 5.0.2
|
||||
*/
|
||||
protected function generateLanguageXml(object $plugin, array $languageFiles): string
|
||||
{
|
||||
$xml = '';
|
||||
|
||||
if (ArrayHelper::check($languageFiles))
|
||||
{
|
||||
$xml .= PHP_EOL . PHP_EOL . Indent::_(1) . '<!--' . Line::_(
|
||||
__LINE__,__CLASS__
|
||||
) . ' Language files -->';
|
||||
$xml .= PHP_EOL . Indent::_(1) . '<languages folder="language">';
|
||||
|
||||
foreach ($languageFiles as $addTag)
|
||||
{
|
||||
$xml .= PHP_EOL . Indent::_(2) . '<language tag="'
|
||||
. $addTag . '">' . $addTag . '/plg_'
|
||||
. strtolower((string) $plugin->group) . '_' .
|
||||
(string) $plugin->file_name
|
||||
. '.ini</language>';
|
||||
$xml .= PHP_EOL . Indent::_(2) . '<language tag="'
|
||||
. $addTag . '">' . $addTag . '/plg_'
|
||||
. strtolower((string) $plugin->group) . '_' .
|
||||
(string) $plugin->file_name
|
||||
. '.sys.ini</language>';
|
||||
}
|
||||
$xml .= PHP_EOL . Indent::_(1) . '</languages>';
|
||||
}
|
||||
|
||||
return $xml;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate the XML for the files.
|
||||
*
|
||||
* @param object $plugin The plugin object.
|
||||
* @param array $languageFiles The language files.
|
||||
*
|
||||
* @return string The XML for the files.
|
||||
* @since 5.0.2
|
||||
*/
|
||||
protected function generateFileXml(object $plugin, array $languageFiles): string
|
||||
{
|
||||
$files = Folder::files($plugin->folder_path);
|
||||
$folders = Folder::folders($plugin->folder_path);
|
||||
$ignore = ['sql', 'language', 'script.php', "{$plugin->file_name}.xml"];
|
||||
|
||||
$xml = PHP_EOL . PHP_EOL . Indent::_(1) . '<!--' . Line::_(
|
||||
__LINE__,__CLASS__
|
||||
) . ' Plugin files -->';
|
||||
$xml .= PHP_EOL . Indent::_(1) . '<files>';
|
||||
$xml .= PHP_EOL . Indent::_(2) . "<folder plugin=\"{$plugin->context_name}\">services</folder>";
|
||||
|
||||
foreach ($files as $file)
|
||||
{
|
||||
if (!in_array($file, $ignore))
|
||||
{
|
||||
$xml .= PHP_EOL . Indent::_(2) . "<filename>{$file}</filename>";
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($languageFiles))
|
||||
{
|
||||
// $xml .= PHP_EOL . Indent::_(2) . '<folder>language</folder>';
|
||||
}
|
||||
|
||||
if ($plugin->add_sql || $plugin->add_sql_uninstall)
|
||||
{
|
||||
$xml .= PHP_EOL . Indent::_(2) . '<folder>sql</folder>';
|
||||
}
|
||||
|
||||
foreach ($folders as $folder)
|
||||
{
|
||||
if (!in_array($folder, $ignore))
|
||||
{
|
||||
$xml .= PHP_EOL . Indent::_(2) . "<folder>{$folder}</folder>";
|
||||
}
|
||||
}
|
||||
|
||||
$xml .= PHP_EOL . Indent::_(1) . '</files>';
|
||||
|
||||
return $xml;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate XML for configuration fields.
|
||||
*
|
||||
* @param object $plugin The plugin object.
|
||||
* @param array $configFields The configuration fields.
|
||||
* @param bool $addComponentPath Whether to add the component path.
|
||||
*
|
||||
* @return string The XML for configuration fields.
|
||||
* @since 5.0.2
|
||||
*/
|
||||
protected function generateConfigXml(object $plugin, array $configFields, bool $addComponentPath): string
|
||||
{
|
||||
if (!isset($plugin->config_fields) || !ArrayHelper::check($configFields))
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
$xml = PHP_EOL . PHP_EOL . Indent::_(1) . '<!--' . Line::_(
|
||||
__LINE__,__CLASS__
|
||||
) . ' Config parameters -->';
|
||||
$xml .= $addComponentPath ? PHP_EOL . Indent::_(1) . '<config' : PHP_EOL . Indent::_(1) . '<config>';
|
||||
|
||||
if ($addComponentPath)
|
||||
{
|
||||
$namespace = $this->config->namespace_prefix . '\\Component\\' . $this->contentone->get('ComponentNamespace') . '\\Administrator';
|
||||
$xml .= PHP_EOL . Indent::_(3) . "addruleprefix=\"{$namespace}\\Rule\"";
|
||||
$xml .= PHP_EOL . Indent::_(3) . "addfieldprefix=\"{$namespace}\\Field\">";
|
||||
$xml .= PHP_EOL . Indent::_(1) . '>';
|
||||
}
|
||||
|
||||
foreach ($plugin->config_fields as $fieldName => $fieldsets)
|
||||
{
|
||||
$xml .= PHP_EOL . Indent::_(1) . "<fields name=\"{$fieldName}\">";
|
||||
|
||||
foreach ($fieldsets as $fieldset => $fields)
|
||||
{
|
||||
$label = $plugin->fieldsets_label["{$fieldName}{$fieldset}"] ?? $fieldset;
|
||||
|
||||
$xml .= PHP_EOL . Indent::_(1) . "<fieldset name=\"{$fieldset}\" label=\"{$label}\">";
|
||||
|
||||
if (isset($configFields["{$fieldName}{$fieldset}"]))
|
||||
{
|
||||
$xml .= $configFields["{$fieldName}{$fieldset}"];
|
||||
}
|
||||
|
||||
$xml .= PHP_EOL . Indent::_(1) . '</fieldset>';
|
||||
}
|
||||
|
||||
$xml .= PHP_EOL . Indent::_(1) . '</fields>';
|
||||
}
|
||||
|
||||
$xml .= PHP_EOL . Indent::_(1) . '</config>';
|
||||
|
||||
return $xml;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate XML for update servers.
|
||||
*
|
||||
* @param object $plugin The plugin object.
|
||||
*
|
||||
* @return string The XML for update servers.
|
||||
* @since 5.0.2
|
||||
*/
|
||||
protected function generateUpdateServerXml(object $plugin): string
|
||||
{
|
||||
$xml = '';
|
||||
|
||||
if ($plugin->add_update_server)
|
||||
{
|
||||
$xml = PHP_EOL . PHP_EOL . Indent::_(1) . '<!--' . Line::_(
|
||||
__LINE__,__CLASS__
|
||||
) . ' Update servers -->';
|
||||
$xml .= PHP_EOL . Indent::_(1) . '<updateservers>';
|
||||
$xml .= PHP_EOL . Indent::_(2) . '<server type="extension" priority="1" name="' . $plugin->official_name . '">' . $plugin->update_server_url . '</server>';
|
||||
$xml .= PHP_EOL . Indent::_(1) . '</updateservers>';
|
||||
}
|
||||
|
||||
return $xml;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate language files.
|
||||
*
|
||||
* @param object $plugin The plugin object.
|
||||
*
|
||||
* @return array The language files.
|
||||
* @since 5.0.2
|
||||
*/
|
||||
protected function generateLanguageFiles(object $plugin): array
|
||||
{
|
||||
$languageFiles = [];
|
||||
|
||||
if (!$this->language->exist($plugin->key))
|
||||
{
|
||||
return $languageFiles;
|
||||
}
|
||||
|
||||
$langContent = $this->language->getTarget($plugin->key);
|
||||
$this->event->trigger('jcb_ce_onBeforeBuildPluginLang', [&$plugin, &$langContent]);
|
||||
|
||||
$values = array_unique($langContent);
|
||||
$this->buildermultilingual->set('plugins', $this->multilingual->get($values));
|
||||
|
||||
$langTag = $this->config->get('lang_tag', 'en-GB');
|
||||
$this->languages->set("plugins.{$langTag}.all", $langContent);
|
||||
$this->language->setTarget($plugin->key, null);
|
||||
|
||||
$this->set->execute($values, $plugin->guid, 'plugins');
|
||||
$this->purge->execute($values, $plugin->guid, 'plugins');
|
||||
|
||||
$this->event->trigger('jcb_ce_onBeforeBuildPluginLangFiles', [&$plugin]);
|
||||
|
||||
if ($this->languages->IsArray('plugins'))
|
||||
{
|
||||
foreach ($this->languages->get('plugins') as $tag => $areas)
|
||||
{
|
||||
$tag = trim($tag);
|
||||
foreach ($areas as $area => $languageStrings)
|
||||
{
|
||||
$fileName = "plg_" . strtolower((string)$plugin->group) . '_' . $plugin->file_name . '.ini';
|
||||
$total = count($values);
|
||||
if ($this->translation->check($tag, $languageStrings, $total, $fileName))
|
||||
{
|
||||
$lang = array_map(
|
||||
fn($langString, $placeholder) => "{$placeholder}=\"{$langString}\"",
|
||||
array_values($languageStrings),
|
||||
array_keys($languageStrings)
|
||||
);
|
||||
|
||||
$path = "{$plugin->folder_path}/language/{$tag}/";
|
||||
|
||||
if (!is_dir($path))
|
||||
{
|
||||
Folder::create($path);
|
||||
$this->counter->folder++;
|
||||
}
|
||||
|
||||
$this->file->write($path . $fileName, implode(PHP_EOL, $lang));
|
||||
$this->file->write(
|
||||
$path . 'plg_' . strtolower((string)$plugin->group) . '_' . $plugin->file_name . '.sys.ini',
|
||||
implode(PHP_EOL, $lang)
|
||||
);
|
||||
|
||||
$this->counter->line += count($lang);
|
||||
unset($lang);
|
||||
|
||||
$languageFiles[$tag] = $tag;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $languageFiles;
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,106 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaSix\Plugin;
|
||||
|
||||
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Placeholder;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Builder\ContentOne as Builder;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Line;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Architecture\Plugin\ProviderInterface;
|
||||
|
||||
|
||||
/**
|
||||
* Plugin Provider Class for Joomla 6
|
||||
*
|
||||
* @since 5.1.2
|
||||
*/
|
||||
final class Provider implements ProviderInterface
|
||||
{
|
||||
/**
|
||||
* The Placeholder Class.
|
||||
*
|
||||
* @var Placeholder
|
||||
* @since 5.0.2
|
||||
*/
|
||||
protected Placeholder $placeholder;
|
||||
|
||||
/**
|
||||
* The ContentOne Class.
|
||||
*
|
||||
* @var Builder
|
||||
* @since 5.0.2
|
||||
*/
|
||||
protected Builder $builder;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param Placeholder $placeholder The Placeholder Class.
|
||||
* @param Builder $builder The Content One Class.
|
||||
*
|
||||
* @since 5.0.2
|
||||
*/
|
||||
public function __construct(Placeholder $placeholder, Builder $builder)
|
||||
{
|
||||
$this->placeholder = $placeholder;
|
||||
$this->builder = $builder;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the updated provider for the given plugin.
|
||||
*
|
||||
* @param object $plugin The plugin object containing the necessary data.
|
||||
*
|
||||
* @return string The provider content.
|
||||
*
|
||||
* @since 5.0.2
|
||||
*/
|
||||
public function get(object $plugin): string
|
||||
{
|
||||
$group = strtolower((string) $plugin->group);
|
||||
|
||||
$provider = [];
|
||||
$provider[] = PHP_EOL . PHP_EOL . "return new class () implements ServiceProviderInterface {";
|
||||
$provider[] = Indent::_(1) . "/**";
|
||||
$provider[] = Indent::_(1) . "*" . Line::_(__Line__, __Class__)
|
||||
. " Registers the service provider with a DI container.";
|
||||
$provider[] = Indent::_(1) . "*";
|
||||
$provider[] = Indent::_(1) . "* @param Container \$container The DI container.";
|
||||
$provider[] = Indent::_(1) . "*";
|
||||
$provider[] = Indent::_(1) . "* @return void";
|
||||
$provider[] = Indent::_(1) . "* @since 4.3.0";
|
||||
$provider[] = Indent::_(1) . "*/";
|
||||
$provider[] = Indent::_(1) . "public function register(Container \$container)";
|
||||
$provider[] = Indent::_(1) . "{";
|
||||
$provider[] = Indent::_(2) . "\$container->set(";
|
||||
$provider[] = Indent::_(3) . "PluginInterface::class,";
|
||||
$provider[] = Indent::_(3) . "function (Container \$container) {";
|
||||
$provider[] = Indent::_(4) . "\$plugin = new {$plugin->class_name}(";
|
||||
$provider[] = Indent::_(5) . "\$container->get(DispatcherInterface::class),";
|
||||
$provider[] = Indent::_(5) . "(array) PluginHelper::getPlugin('{$group}', '{$plugin->context_name}')";
|
||||
$provider[] = Indent::_(4) . ");";
|
||||
$provider[] = Indent::_(4) . "\$plugin->setApplication(Factory::getApplication());";
|
||||
$provider[] = $plugin->service_provider ?? ''; // to add extra plug-in suff
|
||||
$provider[] = Indent::_(4) . "return \$plugin;";
|
||||
$provider[] = Indent::_(3) . "}";
|
||||
$provider[] = Indent::_(2) . ");";
|
||||
$provider[] = Indent::_(1) . "}";
|
||||
$provider[] = "};";
|
||||
|
||||
return $this->placeholder->update(
|
||||
implode(PHP_EOL, $provider). PHP_EOL,
|
||||
$this->builder->allActive()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
@@ -0,0 +1,748 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Componentbuilder\Compiler\Component\JoomlaSix;
|
||||
|
||||
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Config;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Registry;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\EventInterface;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Placeholder;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Component;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Paths;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Dynamicpath;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Pathfix;
|
||||
use VDM\Joomla\Utilities\FileHelper;
|
||||
use VDM\Joomla\Utilities\JsonHelper;
|
||||
use VDM\Joomla\Utilities\StringHelper;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Component\SettingsInterface;
|
||||
|
||||
|
||||
/**
|
||||
* Compiler Component Joomla 6 Settings
|
||||
*
|
||||
* @since 5.1.2
|
||||
*/
|
||||
final class Settings implements SettingsInterface
|
||||
{
|
||||
/**
|
||||
* The standard folders
|
||||
*
|
||||
* @var array
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected array $standardFolders = [
|
||||
'site',
|
||||
'admin',
|
||||
'media'
|
||||
];
|
||||
|
||||
/**
|
||||
* The standard root files
|
||||
*
|
||||
* @var array
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected array $standardRootFiles = [
|
||||
'access.xml',
|
||||
'config.xml',
|
||||
'controller.php',
|
||||
'index.html',
|
||||
'README.txt'
|
||||
];
|
||||
|
||||
/**
|
||||
* Compiler Joomla Version Data
|
||||
*
|
||||
* @var object|null
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected ?object $data = null;
|
||||
|
||||
/**
|
||||
* Compiler Config
|
||||
*
|
||||
* @var Config
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected Config $config;
|
||||
|
||||
/**
|
||||
* The compiler registry
|
||||
*
|
||||
* @var Registry
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected Registry $registry;
|
||||
|
||||
/**
|
||||
* Compiler Event
|
||||
*
|
||||
* @var EventInterface
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected EventInterface $event;
|
||||
|
||||
/**
|
||||
* Compiler Placeholder
|
||||
*
|
||||
* @var Placeholder
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected Placeholder $placeholder;
|
||||
|
||||
/**
|
||||
* Compiler Component
|
||||
*
|
||||
* @var Component
|
||||
* @since 3.2.0
|
||||
**/
|
||||
protected Component $component;
|
||||
|
||||
/**
|
||||
* Compiler Utilities Paths
|
||||
*
|
||||
* @var Paths
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected Paths $paths;
|
||||
|
||||
/**
|
||||
* Compiler Component Dynamic Path
|
||||
*
|
||||
* @var Dynamicpath
|
||||
* @since 3.2.0
|
||||
**/
|
||||
protected Dynamicpath $dynamicpath;
|
||||
|
||||
/**
|
||||
* Compiler Component Pathfix
|
||||
*
|
||||
* @var Pathfix
|
||||
* @since 3.2.0
|
||||
**/
|
||||
protected Pathfix $pathfix;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param Config|null $config The compiler config object.
|
||||
* @param Registry|null $registry The compiler registry object.
|
||||
* @param EventInterface|null $event The compiler event api object.
|
||||
* @param Placeholder|null $placeholder The compiler placeholder object.
|
||||
* @param Component|null $component The component class.
|
||||
* @param Paths|null $paths The compiler paths object.
|
||||
* @param Dynamicpath|null $dynamicpath The compiler dynamic path object.
|
||||
* @param Pathfix|null $pathfix The compiler path fixing object.
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function __construct(?Config $config = null, ?Registry $registry = null,
|
||||
?EventInterface $event = null, ?Placeholder $placeholder = null,
|
||||
?Component $component = null, ?Paths $paths = null,
|
||||
?Dynamicpath $dynamicpath = null, ?Pathfix $pathfix = null)
|
||||
{
|
||||
$this->config = $config ?: Compiler::_('Config');
|
||||
$this->registry = $registry ?: Compiler::_('Registry');
|
||||
$this->event = $event ?: Compiler::_('Event');
|
||||
$this->placeholder = $placeholder ?: Compiler::_('Placeholder');
|
||||
$this->component = $component ?: Compiler::_('Component');
|
||||
$this->paths = $paths ?: Compiler::_('Utilities.Paths');
|
||||
$this->dynamicpath = $dynamicpath ?: Compiler::_('Utilities.Dynamicpath');
|
||||
$this->pathfix = $pathfix ?: Compiler::_('Utilities.Pathfix');
|
||||
|
||||
// add component endpoint file to stander list of root files
|
||||
$this->standardRootFiles[] = $this->component->get('name_code') . '.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if data set is loaded
|
||||
*
|
||||
* @return bool
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function exists(): bool
|
||||
{
|
||||
if (!$this->isSet())
|
||||
{
|
||||
// load the data
|
||||
$this->data = $this->get();
|
||||
|
||||
if (!$this->isSet())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Joomla - Folder Structure to Create
|
||||
*
|
||||
* @return object The version related structure
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function structure(): object
|
||||
{
|
||||
return $this->data->create;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Joomla - Move Multiple Structure
|
||||
*
|
||||
* @return object The version related multiple structure
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function multiple(): object
|
||||
{
|
||||
return $this->data->move->dynamic;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Joomla - Move Single Structure
|
||||
*
|
||||
* @return object The version related single structure
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function single(): object
|
||||
{
|
||||
return $this->data->move->static;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if Folder is a Standard Folder
|
||||
*
|
||||
* @param string $folder The folder name
|
||||
*
|
||||
* @return bool true if the folder exists
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function standardFolder(string $folder): bool
|
||||
{
|
||||
return in_array($folder, $this->standardFolders);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if File is a Standard Root File
|
||||
*
|
||||
* @param string $file The file name
|
||||
*
|
||||
* @return bool true if the file exists
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function standardRootFile(string $file): bool
|
||||
{
|
||||
return in_array($file, $this->standardRootFiles);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if Data is Set
|
||||
*
|
||||
* @return bool
|
||||
* @since 3.2.0
|
||||
*/
|
||||
private function isSet(): bool
|
||||
{
|
||||
return is_object($this->data) &&
|
||||
isset($this->data->create) &&
|
||||
isset($this->data->move) &&
|
||||
isset($this->data->move->static) &&
|
||||
isset($this->data->move->dynamic);
|
||||
}
|
||||
|
||||
/**
|
||||
* get the Joomla Version Data
|
||||
*
|
||||
* @return object|null The version data
|
||||
* @since 3.2.0
|
||||
*/
|
||||
private function get(): ?object
|
||||
{
|
||||
// override option
|
||||
$customSettings = $this->paths->template_path . '/settings_' .
|
||||
$this->config->component_code_name . '.json';
|
||||
|
||||
// get the data
|
||||
$version_data = $this->readJsonFile($customSettings);
|
||||
|
||||
if (is_null($version_data) || !$this->isValidData($version_data))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
$this->loadExtraFolders();
|
||||
$this->loadExtraFiles();
|
||||
|
||||
$this->addFolders($version_data);
|
||||
$this->addFiles($version_data);
|
||||
|
||||
// Trigger Event: jcb_ce_onAfterSetJoomlaVersionData
|
||||
$this->event->trigger(
|
||||
'jcb_ce_onAfterSetJoomlaVersionData', [&$version_data]
|
||||
);
|
||||
|
||||
return $version_data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read the Json file data
|
||||
*
|
||||
* @param string $filePath
|
||||
*
|
||||
* @return object|null The version data
|
||||
* @since 3.2.0
|
||||
*/
|
||||
private function readJsonFile(string $filePath): ?object
|
||||
{
|
||||
if (FileHelper::exists($filePath))
|
||||
{
|
||||
$jsonContent = FileHelper::getContent($filePath);
|
||||
}
|
||||
else
|
||||
{
|
||||
$jsonContent = FileHelper::getContent($this->paths->template_path . '/settings.json');
|
||||
}
|
||||
|
||||
if (JsonHelper::check($jsonContent))
|
||||
{
|
||||
return json_decode((string) $jsonContent);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if this is valid data
|
||||
*
|
||||
* @param object $versionData
|
||||
*
|
||||
* @return bool
|
||||
* @since 3.2.0
|
||||
*/
|
||||
private function isValidData(object $versionData): bool
|
||||
{
|
||||
return isset($versionData->create) &&
|
||||
isset($versionData->move) &&
|
||||
isset($versionData->move->static) &&
|
||||
isset($versionData->move->dynamic);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add Extra/Dynamic folders
|
||||
*
|
||||
* @return void
|
||||
* @since 3.2.0
|
||||
*/
|
||||
private function loadExtraFolders()
|
||||
{
|
||||
if ($this->component->isArray('folders') ||
|
||||
$this->config->get('add_eximport', false) ||
|
||||
$this->config->get('uikit', 0) ||
|
||||
$this->config->get('footable', false))
|
||||
{
|
||||
$this->addImportViewFolder();
|
||||
// $this->addPhpSpreadsheetFolder(); // soon
|
||||
$this->addUikitFolder();
|
||||
$this->addFooTableFolder();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add Import and Export Folder
|
||||
*
|
||||
* @return void
|
||||
* @since 3.2.0
|
||||
*/
|
||||
private function addImportViewFolder()
|
||||
{
|
||||
if ($this->config->get('add_eximport', false))
|
||||
{
|
||||
// soon
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add Php Spreadsheet Folder
|
||||
*
|
||||
* @return void
|
||||
* @since 3.2.0
|
||||
*/
|
||||
private function addPhpSpreadsheetFolder()
|
||||
{
|
||||
// move the phpspreadsheet Folder (TODO we must move this to a library package)
|
||||
if ($this->config->get('add_eximport', false))
|
||||
{
|
||||
$this->component->appendArray('folders', [
|
||||
'folderpath' => 'JPATH_LIBRARIES/phpspreadsheet/vendor',
|
||||
'path' => '/libraries/phpspreadsheet/',
|
||||
'rename' => 0
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add Uikit Folders
|
||||
*
|
||||
* @return void
|
||||
* @since 3.2.0
|
||||
*/
|
||||
private function addUikitFolder()
|
||||
{
|
||||
$uikit = $this->config->get('uikit', 0);
|
||||
if (2 == $uikit || 1 == $uikit)
|
||||
{
|
||||
// move the UIKIT Folder into place
|
||||
$this->component->appendArray('folders', [
|
||||
'folder' => 'uikit-v2',
|
||||
'path' => 'media',
|
||||
'rename' => 0
|
||||
]);
|
||||
}
|
||||
if (2 == $uikit || 3 == $uikit)
|
||||
{
|
||||
// move the UIKIT-3 Folder into place
|
||||
$this->component->appendArray('folders', [
|
||||
'folder' => 'uikit-v3',
|
||||
'path' => 'media',
|
||||
'rename' => 0
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add Foo Table Folder
|
||||
*
|
||||
* @return void
|
||||
* @since 3.2.0
|
||||
*/
|
||||
private function addFooTableFolder()
|
||||
{
|
||||
if (!$this->config->get('footable', false))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$footable_version = $this->config->get('footable_version', 2);
|
||||
|
||||
if (2 == $footable_version)
|
||||
{
|
||||
// move the footable folder into place
|
||||
$this->component->appendArray('folders', [
|
||||
'folder' => 'footable-v2',
|
||||
'path' => 'media',
|
||||
'rename' => 0
|
||||
]);
|
||||
}
|
||||
elseif (3 == $footable_version)
|
||||
{
|
||||
// move the footable folder into place
|
||||
$this->component->appendArray('folders', [
|
||||
'folder' => 'footable-v3',
|
||||
'path' => 'media',
|
||||
'rename' => 0
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add Extra/Dynamic files
|
||||
*
|
||||
* @return void
|
||||
* @since 3.2.0
|
||||
*/
|
||||
private function loadExtraFiles()
|
||||
{
|
||||
if ($this->component->isArray('files') ||
|
||||
$this->config->get('google_chart', false))
|
||||
{
|
||||
$this->addGoogleChartFiles();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add Google Chart Files
|
||||
*
|
||||
* @return void
|
||||
* @since 3.2.0
|
||||
*/
|
||||
private function addGoogleChartFiles()
|
||||
{
|
||||
if ($this->config->get('google_chart', false))
|
||||
{
|
||||
// move the google chart files
|
||||
$this->component->appendArray('files', [
|
||||
'file' => 'google.jsapi.js',
|
||||
'path' => 'media/js',
|
||||
'rename' => 0
|
||||
]);
|
||||
$this->component->appendArray('files', [
|
||||
'file' => 'chartbuilder.php',
|
||||
'path' => 'admin/helpers',
|
||||
'rename' => 0
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add Folders
|
||||
*
|
||||
* @param object $versionData
|
||||
*
|
||||
* @return void
|
||||
* @since 3.2.0
|
||||
*/
|
||||
private function addFolders(object &$versionData)
|
||||
{
|
||||
if (!$this->component->isArray('folders'))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// pointer tracker
|
||||
$pointer_tracker = 'h';
|
||||
foreach ($this->component->get('folders') as $custom)
|
||||
{
|
||||
// check type of target type
|
||||
$_target_type = 'c0mp0n3nt';
|
||||
if (isset($custom['target_type']))
|
||||
{
|
||||
$_target_type = $custom['target_type'];
|
||||
}
|
||||
|
||||
// for good practice
|
||||
$this->pathfix->set(
|
||||
$custom, ['path', 'folder', 'folderpath']
|
||||
);
|
||||
|
||||
// fix custom path
|
||||
if (isset($custom['path'])
|
||||
&& StringHelper::check($custom['path']))
|
||||
{
|
||||
$custom['path'] = trim((string) $custom['path'], '/');
|
||||
}
|
||||
|
||||
// by default custom path is true
|
||||
$customPath = 'custom';
|
||||
|
||||
// set full path if this is a full path folder
|
||||
if (!isset($custom['folder']) && isset($custom['folderpath']))
|
||||
{
|
||||
// update the dynamic path
|
||||
$custom['folderpath'] = $this->dynamicpath->update(
|
||||
$custom['folderpath']
|
||||
);
|
||||
|
||||
// set the folder path with / if does not have a drive/windows full path
|
||||
$custom['folder'] = (preg_match(
|
||||
'/^[a-z]:/i', $custom['folderpath']
|
||||
)) ? trim($custom['folderpath'], '/')
|
||||
: '/' . trim($custom['folderpath'], '/');
|
||||
|
||||
// remove the file path
|
||||
unset($custom['folderpath']);
|
||||
|
||||
// triget fullpath
|
||||
$customPath = 'full';
|
||||
}
|
||||
|
||||
// make sure we use the correct name
|
||||
$pathArray = (array) explode('/', (string) $custom['path']);
|
||||
$lastFolder = end($pathArray);
|
||||
|
||||
// only rename folder if last has folder name
|
||||
if (isset($custom['rename']) && $custom['rename'] == 1)
|
||||
{
|
||||
$custom['path'] = str_replace(
|
||||
'/' . $lastFolder, '', (string) $custom['path']
|
||||
);
|
||||
$rename = 'new';
|
||||
$newname = $lastFolder;
|
||||
}
|
||||
elseif ('full' === $customPath)
|
||||
{
|
||||
// make sure we use the correct name
|
||||
$folderArray = (array) explode('/', (string) $custom['folder']);
|
||||
$lastFolder = end($folderArray);
|
||||
$rename = 'new';
|
||||
$newname = $lastFolder;
|
||||
}
|
||||
else
|
||||
{
|
||||
$rename = false;
|
||||
$newname = '';
|
||||
}
|
||||
|
||||
// insure we have no duplicates
|
||||
$key_pointer = StringHelper::safe(
|
||||
$custom['folder']
|
||||
) . '_f' . $pointer_tracker;
|
||||
|
||||
$pointer_tracker++;
|
||||
|
||||
// fix custom path
|
||||
$custom['path'] = ltrim((string) $custom['path'], '/');
|
||||
|
||||
// set new folder to object
|
||||
$versionData->move->static->{$key_pointer} = new \stdClass();
|
||||
$versionData->move->static->{$key_pointer}->naam = str_replace('//', '/', (string) $custom['folder']);
|
||||
$versionData->move->static->{$key_pointer}->path = $_target_type . '/' . $custom['path'];
|
||||
$versionData->move->static->{$key_pointer}->rename = $rename;
|
||||
$versionData->move->static->{$key_pointer}->newName = $newname;
|
||||
$versionData->move->static->{$key_pointer}->type = 'folder';
|
||||
$versionData->move->static->{$key_pointer}->custom = $customPath;
|
||||
|
||||
// set the target if type and id is found
|
||||
if (isset($custom['target_id']) && isset($custom['target_type']))
|
||||
{
|
||||
$versionData->move->static->{$key_pointer}->_target = [
|
||||
'key' => $custom['target_id'] . '_' . $custom['target_type'],
|
||||
'type' => $custom['target_type']
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
$this->component->remove('folders');
|
||||
}
|
||||
|
||||
/**
|
||||
* Add Files
|
||||
*
|
||||
* @param object $versionData
|
||||
*
|
||||
* @return void
|
||||
* @since 3.2.0
|
||||
*/
|
||||
private function addFiles(object &$versionData)
|
||||
{
|
||||
if (!$this->component->isArray('files')) {
|
||||
return;
|
||||
}
|
||||
|
||||
// pointer tracker
|
||||
$pointer_tracker = 'h';
|
||||
foreach ($this->component->get('files') as $custom)
|
||||
{
|
||||
// check type of target type
|
||||
$_target_type = 'c0mp0n3nt';
|
||||
if (isset($custom['target_type']))
|
||||
{
|
||||
$_target_type = $custom['target_type'];
|
||||
}
|
||||
|
||||
// for good practice
|
||||
$this->pathfix->set(
|
||||
$custom, ['path', 'file', 'filepath']
|
||||
);
|
||||
|
||||
// by default custom path is true
|
||||
$customPath = 'custom';
|
||||
|
||||
// set full path if this is a full path file
|
||||
if (!isset($custom['file']) && isset($custom['filepath']))
|
||||
{
|
||||
// update the dynamic path
|
||||
$custom['filepath'] = $this->dynamicpath->update(
|
||||
$custom['filepath']
|
||||
);
|
||||
|
||||
// set the file path with / if does not have a drive/windows full path
|
||||
$custom['file'] = (preg_match('/^[a-z]:/i', $custom['filepath']))
|
||||
? trim($custom['filepath'], '/') : '/' . trim($custom['filepath'], '/');
|
||||
|
||||
// remove the file path
|
||||
unset($custom['filepath']);
|
||||
|
||||
// triget fullpath
|
||||
$customPath = 'full';
|
||||
}
|
||||
|
||||
// make sure we have not duplicates
|
||||
$key_pointer = StringHelper::safe(
|
||||
$custom['file']
|
||||
) . '_g' . $pointer_tracker;
|
||||
|
||||
$pointer_tracker++;
|
||||
|
||||
// set new file to object
|
||||
$versionData->move->static->{$key_pointer} = new \stdClass();
|
||||
$versionData->move->static->{$key_pointer}->naam = str_replace('//', '/', (string) $custom['file']);
|
||||
|
||||
// update the dynamic component name placholders in file names
|
||||
$custom['path'] = $this->placeholder->update_(
|
||||
$custom['path']
|
||||
);
|
||||
|
||||
// get the path info
|
||||
$pathInfo = pathinfo((string) $custom['path']);
|
||||
if (isset($pathInfo['extension']) && $pathInfo['extension'])
|
||||
{
|
||||
$pathInfo['dirname'] = trim($pathInfo['dirname'], '/');
|
||||
|
||||
// set the info
|
||||
$versionData->move->static->{$key_pointer}->path = $_target_type . '/' . $pathInfo['dirname'];
|
||||
$versionData->move->static->{$key_pointer}->rename = 'new';
|
||||
$versionData->move->static->{$key_pointer}->newName = $pathInfo['basename'];
|
||||
}
|
||||
elseif ('full' === $customPath)
|
||||
{
|
||||
// fix custom path
|
||||
$custom['path'] = ltrim((string) $custom['path'], '/');
|
||||
|
||||
// get file array
|
||||
$fileArray = (array) explode('/', (string) $custom['file']);
|
||||
|
||||
// set the info
|
||||
$versionData->move->static->{$key_pointer}->path = $_target_type . '/' . $custom['path'];
|
||||
$versionData->move->static->{$key_pointer}->rename = 'new';
|
||||
$versionData->move->static->{$key_pointer}->newName = end($fileArray);
|
||||
}
|
||||
else
|
||||
{
|
||||
// fix custom path
|
||||
$custom['path'] = ltrim((string) $custom['path'], '/');
|
||||
|
||||
// set the info
|
||||
$versionData->move->static->{$key_pointer}->path = $_target_type . '/' . $custom['path'];
|
||||
$versionData->move->static->{$key_pointer}->rename = false;
|
||||
}
|
||||
|
||||
$versionData->move->static->{$key_pointer}->type = 'file';
|
||||
$versionData->move->static->{$key_pointer}->custom = $customPath;
|
||||
|
||||
// set the target if type and id is found
|
||||
if (isset($custom['target_id'])
|
||||
&& isset($custom['target_type']))
|
||||
{
|
||||
$versionData->move->static->{$key_pointer}->_target = [
|
||||
'key' => $custom['target_id'] . '_' . $custom['target_type'],
|
||||
'type' => $custom['target_type']
|
||||
];
|
||||
}
|
||||
|
||||
// check if file should be updated
|
||||
if (!isset($custom['notnew']) || $custom['notnew'] == 0
|
||||
|| $custom['notnew'] != 1)
|
||||
{
|
||||
$this->registry->appendArray('files.not.new', $key_pointer);
|
||||
}
|
||||
else
|
||||
{
|
||||
// update the file content
|
||||
$this->registry->set('update.file.content.' . $key_pointer, true);
|
||||
}
|
||||
}
|
||||
|
||||
$this->component->remove('files');
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
@@ -383,7 +383,7 @@ class Config extends ComponentConfig
|
||||
*/
|
||||
protected function getJoomlaversion(): int
|
||||
{
|
||||
return $this->input->post->get('joomla_version', 3, 'INT');
|
||||
return $this->input->post->get('joomla_version', 5, 'INT');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -397,7 +397,8 @@ class Config extends ComponentConfig
|
||||
return [
|
||||
3 => ['folder_key' => 3, 'xml_version' => '3.10'],
|
||||
4 => ['folder_key' => 4, 'xml_version' => '4.0'],
|
||||
5 => ['folder_key' => 4, 'xml_version' => '5.0'] // for now we build 4 and 5 from same templates ;)
|
||||
5 => ['folder_key' => 4, 'xml_version' => '5.0'], // for now we build 4 and 5 from same templates ;),
|
||||
6 => ['folder_key' => 4, 'xml_version' => '6.0'] // for now we build 4 and 6 from same templates ;)
|
||||
];
|
||||
}
|
||||
|
||||
|
@@ -0,0 +1,528 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Componentbuilder\Compiler\Extension\JoomlaSix;
|
||||
|
||||
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Extension\InstallInterface;
|
||||
use VDM\Joomla\Utilities\ArrayHelper;
|
||||
use VDM\Joomla\Utilities\StringHelper;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Line;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\GetScriptInterface;
|
||||
|
||||
|
||||
/**
|
||||
* Loading the Extension Installation Script Class
|
||||
*
|
||||
* @since 5.1.2
|
||||
*/
|
||||
final class InstallScript implements GetScriptInterface
|
||||
{
|
||||
/**
|
||||
* The extension
|
||||
*
|
||||
* @var InstallInterface|Object
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected object $extension;
|
||||
|
||||
/**
|
||||
* The methods
|
||||
*
|
||||
* @var array
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected array $methods = ['php_script', 'php_preflight', 'php_postflight', 'php_method'];
|
||||
|
||||
/**
|
||||
* The types
|
||||
*
|
||||
* @var array
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected array $types = ['construct', 'install', 'update', 'uninstall', 'discover_install'];
|
||||
|
||||
/**
|
||||
* The construct bucket
|
||||
*
|
||||
* @var array
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected array $construct = [];
|
||||
|
||||
/**
|
||||
* The install bucket
|
||||
*
|
||||
* @var array
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected array $install = [];
|
||||
|
||||
/**
|
||||
* The update bucket
|
||||
*
|
||||
* @var array
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected array $update = [];
|
||||
|
||||
/**
|
||||
* The uninstall bucket
|
||||
*
|
||||
* @var array
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected array $uninstall = [];
|
||||
|
||||
/**
|
||||
* The preflight switch
|
||||
*
|
||||
* @var bool
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected bool $preflightActive = false;
|
||||
|
||||
/**
|
||||
* The preflight bucket
|
||||
*
|
||||
* @var array
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected array $preflightBucket = ['install' => [], 'uninstall' => [], 'discover_install' => [], 'update' => []];
|
||||
|
||||
/**
|
||||
* The postflight switch
|
||||
*
|
||||
* @var bool
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected bool $postflightActive = false;
|
||||
|
||||
/**
|
||||
* The postflight bucket
|
||||
*
|
||||
* @var array
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected array $postflightBucket = ['install' => [], 'uninstall' => [], 'discover_install' => [], 'update' => []];
|
||||
|
||||
/**
|
||||
* The paths of the old plugin class files
|
||||
*
|
||||
* @var array
|
||||
* @since 5.0.2
|
||||
*/
|
||||
protected array $removeFilePaths = [];
|
||||
|
||||
/**
|
||||
* The paths of the old plugin folders
|
||||
*
|
||||
* @var array
|
||||
* @since 5.0.2
|
||||
*/
|
||||
protected array $removeFolderPaths = [];
|
||||
|
||||
/**
|
||||
* get install script
|
||||
*
|
||||
* @param Object $extension The extension object
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function get(object $extension): string
|
||||
{
|
||||
// purge the object
|
||||
$this->rest();
|
||||
|
||||
// set the remove path
|
||||
$this->removeFilePaths = $extension->remove_file_paths ?? [];
|
||||
$this->removeFolderPaths = $extension->remove_folder_paths ?? [];
|
||||
|
||||
// loop over methods and types
|
||||
foreach ($this->methods as $method)
|
||||
{
|
||||
foreach ($this->types as $type)
|
||||
{
|
||||
if (isset($extension->{'add_' . $method . '_' . $type})
|
||||
&& $extension->{'add_' . $method . '_' . $type} == 1
|
||||
&& StringHelper::check(
|
||||
$extension->{$method . '_' . $type}
|
||||
))
|
||||
{
|
||||
// add to the main methods
|
||||
if ('php_method' === $method || 'php_script' === $method)
|
||||
{
|
||||
$this->{$type}[] = $extension->{$method . '_' . $type};
|
||||
}
|
||||
else
|
||||
{
|
||||
// get the flight key
|
||||
$flight = str_replace('php_', '', (string) $method);
|
||||
// load the script to our bucket
|
||||
$this->{$flight . 'Bucket'}[$type][] = $extension->{$method . '_' . $type};
|
||||
// show that the method is active
|
||||
$this->{$flight . 'Active'} = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->extension = $extension;
|
||||
|
||||
// return the class
|
||||
return $this->build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset all bucket at the start of each build
|
||||
*
|
||||
* @return void
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected function rest(): void
|
||||
{
|
||||
$this->removeFilePaths = [];
|
||||
$this->removeFolderPaths = [];
|
||||
$this->construct = [];
|
||||
$this->install = [];
|
||||
$this->update = [];
|
||||
$this->uninstall = [];
|
||||
$this->preflightActive = false;
|
||||
$this->preflightBucket = ['install' => [], 'uninstall' => [], 'discover_install' => [], 'update' => []];
|
||||
$this->postflightActive = false;
|
||||
$this->postflightBucket = ['install' => [], 'uninstall' => [], 'discover_install' => [], 'update' => []];
|
||||
}
|
||||
|
||||
/**
|
||||
* build the install class
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected function build(): string
|
||||
{
|
||||
// start build
|
||||
$script = $this->head();
|
||||
|
||||
// load constructor if set
|
||||
$script .= $this->construct();
|
||||
|
||||
// load install method if set
|
||||
$script .= $this->main('install');
|
||||
|
||||
// load update method if set
|
||||
$script .= $this->main('update');
|
||||
|
||||
// load uninstall method if set
|
||||
$script .= $this->main('uninstall');
|
||||
|
||||
// load preflight method if set
|
||||
$script .= $this->flight('preflight');
|
||||
|
||||
// load postflight method if set
|
||||
$script .= $this->flight('postflight');
|
||||
|
||||
// load remove files method
|
||||
$script .= $this->removeFiles();
|
||||
|
||||
// close the class
|
||||
$script .= PHP_EOL . '}' . PHP_EOL;
|
||||
|
||||
return $script;
|
||||
}
|
||||
|
||||
/**
|
||||
* get install script head
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected function head(): string
|
||||
{
|
||||
// get the extension
|
||||
$extension = $this->extension;
|
||||
|
||||
// start build
|
||||
$script = PHP_EOL . 'use Joomla\CMS\Factory;';
|
||||
$script .= PHP_EOL . 'use Joomla\CMS\Version;';
|
||||
$script .= PHP_EOL . 'use Joomla\CMS\Installer\InstallerAdapter;';
|
||||
$script .= PHP_EOL . 'use Joomla\CMS\Language\Text;';
|
||||
$script .= PHP_EOL . 'use Joomla\Filesystem\File;';
|
||||
$script .= PHP_EOL . 'use Joomla\Filesystem\Folder;' . PHP_EOL;
|
||||
$script .= PHP_EOL . '/**';
|
||||
$script .= PHP_EOL . ' * ' . $extension->official_name
|
||||
. ' script file.';
|
||||
$script .= PHP_EOL . ' *';
|
||||
$script .= PHP_EOL . ' * @package ' . $extension->class_name;
|
||||
$script .= PHP_EOL . ' */';
|
||||
$script .= PHP_EOL . 'class ' . $extension->installer_class_name;
|
||||
$script .= PHP_EOL . '{';
|
||||
|
||||
return $script;
|
||||
}
|
||||
|
||||
/**
|
||||
* get constructor
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected function construct(): string
|
||||
{
|
||||
// the __construct script
|
||||
$script = PHP_EOL . Indent::_(1) . '/**';
|
||||
$script .= PHP_EOL . Indent::_(1) . ' *' . Line::_(__Line__, __Class__)
|
||||
.' The CMS Application.';
|
||||
$script .= PHP_EOL . Indent::_(1) . ' *';
|
||||
$script .= PHP_EOL . Indent::_(1) . ' * @since 4.4.2';
|
||||
$script .= PHP_EOL . Indent::_(1) . ' */';
|
||||
$script .= PHP_EOL . Indent::_(1) . 'protected $app;';
|
||||
|
||||
$script .= PHP_EOL . PHP_EOL . Indent::_(1) . '/**';
|
||||
$script .= PHP_EOL . Indent::_(1) . ' *' . Line::_(__Line__, __Class__)
|
||||
.' A list of files to be deleted';
|
||||
$script .= PHP_EOL . Indent::_(1) . ' *';
|
||||
$script .= PHP_EOL . Indent::_(1) . ' * @var array';
|
||||
$script .= PHP_EOL . Indent::_(1) . ' * @since 3.6';
|
||||
$script .= PHP_EOL . Indent::_(1) . ' */';
|
||||
$script .= PHP_EOL . Indent::_(1) . 'protected array $deleteFiles = [];';
|
||||
|
||||
$script .= PHP_EOL . PHP_EOL . Indent::_(1) . '/**';
|
||||
$script .= PHP_EOL . Indent::_(1) . ' *' . Line::_(__Line__, __Class__)
|
||||
.' A list of folders to be deleted';
|
||||
$script .= PHP_EOL . Indent::_(1) . ' *';
|
||||
$script .= PHP_EOL . Indent::_(1) . ' * @var array';
|
||||
$script .= PHP_EOL . Indent::_(1) . ' * @since 3.6';
|
||||
$script .= PHP_EOL . Indent::_(1) . ' */';
|
||||
$script .= PHP_EOL . Indent::_(1) . 'protected array $deleteFolders = [];';
|
||||
|
||||
$script .= PHP_EOL . PHP_EOL . Indent::_(1) . '/**';
|
||||
$script .= PHP_EOL . Indent::_(1) . ' * Constructor';
|
||||
$script .= PHP_EOL . Indent::_(1) . ' *';
|
||||
$script .= PHP_EOL . Indent::_(1)
|
||||
. ' * @param InstallerAdapter $adapter The object responsible for running this script';
|
||||
$script .= PHP_EOL . Indent::_(1) . ' */';
|
||||
$script .= PHP_EOL . Indent::_(1)
|
||||
. 'public function __construct($adapter)';
|
||||
$script .= PHP_EOL . Indent::_(1) . '{';
|
||||
|
||||
$script .= PHP_EOL . Indent::_(2) . '//' . Line::_(__Line__, __Class__)
|
||||
. ' get application';
|
||||
$script .= PHP_EOL . Indent::_(2)
|
||||
. '$this->app = Factory::getApplication();' . PHP_EOL;
|
||||
|
||||
if (ArrayHelper::check($this->construct))
|
||||
{
|
||||
$script .= PHP_EOL . implode(PHP_EOL . PHP_EOL, $this->construct);
|
||||
}
|
||||
|
||||
// check if custom remove file is set
|
||||
if ($this->removeFilePaths !== [] && strpos($script, '$this->deleteFiles') === false)
|
||||
{
|
||||
// add the default delete files
|
||||
foreach ($this->removeFilePaths as $filePath)
|
||||
{
|
||||
$script .= PHP_EOL . Indent::_(2) . "if (is_file(JPATH_ROOT . '$filePath'))";
|
||||
$script .= PHP_EOL . Indent::_(2) . "{";
|
||||
$script .= PHP_EOL . Indent::_(3) . "\$this->deleteFiles[] = '$filePath';";
|
||||
$script .= PHP_EOL . Indent::_(2) . "}";
|
||||
}
|
||||
}
|
||||
|
||||
// check if custom remove file is set
|
||||
if ($this->removeFolderPaths !== [] && strpos($script, '$this->deleteFolders') === false)
|
||||
{
|
||||
// add the default delete folders
|
||||
foreach ($this->removeFolderPaths as $folderPath)
|
||||
{
|
||||
$script .= PHP_EOL . Indent::_(2) . "if (is_dir(JPATH_ROOT . '$folderPath'))";
|
||||
$script .= PHP_EOL . Indent::_(2) . "{";
|
||||
$script .= PHP_EOL . Indent::_(3) . "\$this->deleteFolders[] = '$folderPath';";
|
||||
$script .= PHP_EOL . Indent::_(2) . "}";
|
||||
}
|
||||
}
|
||||
|
||||
// close the function
|
||||
$script .= PHP_EOL . Indent::_(1) . '}';
|
||||
|
||||
// add remove files
|
||||
$this->preflightBucket['bottom'][] = Indent::_(2) . '//' . Line::_(__Line__, __Class__)
|
||||
.' remove old files and folders';
|
||||
$this->preflightBucket['bottom'][] = Indent::_(2) . '$this->removeFiles();';
|
||||
|
||||
return $script;
|
||||
}
|
||||
|
||||
/**
|
||||
* build main methods
|
||||
*
|
||||
* @param string $name the method being called
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected function main(string $name): string
|
||||
{
|
||||
// return empty string if not set
|
||||
if (!ArrayHelper::check($this->{$name}))
|
||||
{
|
||||
return '';
|
||||
}
|
||||
// load the install method
|
||||
$script = PHP_EOL . PHP_EOL . Indent::_(1) . '/**';
|
||||
$script .= PHP_EOL . Indent::_(1) . " * Called on $name";
|
||||
$script .= PHP_EOL . Indent::_(1) . ' *';
|
||||
$script .= PHP_EOL . Indent::_(1)
|
||||
. ' * @param InstallerAdapter $adapter The object responsible for running this script';
|
||||
$script .= PHP_EOL . Indent::_(1) . ' *';
|
||||
$script .= PHP_EOL . Indent::_(1)
|
||||
. ' * @return boolean True on success';
|
||||
$script .= PHP_EOL . Indent::_(1) . ' */';
|
||||
$script .= PHP_EOL . Indent::_(1) . 'public function '
|
||||
. $name . '($adapter)';
|
||||
$script .= PHP_EOL . Indent::_(1) . '{';
|
||||
$script .= PHP_EOL . implode(PHP_EOL . PHP_EOL, $this->{$name});
|
||||
// return true
|
||||
if ('uninstall' !== $name)
|
||||
{
|
||||
$script .= PHP_EOL . Indent::_(2) . 'return true;';
|
||||
}
|
||||
// close the function
|
||||
$script .= PHP_EOL . Indent::_(1) . '}';
|
||||
|
||||
return $script;
|
||||
}
|
||||
|
||||
/**
|
||||
* build flight methods
|
||||
*
|
||||
* @param string $name the method being called
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected function flight(string $name): string
|
||||
{
|
||||
// the pre/post function types
|
||||
$script = PHP_EOL . PHP_EOL . Indent::_(1) . '/**';
|
||||
$script .= PHP_EOL . Indent::_(1)
|
||||
. ' * Called before any type of action';
|
||||
$script .= PHP_EOL . Indent::_(1) . ' *';
|
||||
$script .= PHP_EOL . Indent::_(1)
|
||||
. ' * @param string $route Which action is happening (install|uninstall|discover_install|update)';
|
||||
$script .= PHP_EOL . Indent::_(1)
|
||||
. ' * @param InstallerAdapter $adapter The object responsible for running this script';
|
||||
$script .= PHP_EOL . Indent::_(1) . ' *';
|
||||
$script .= PHP_EOL . Indent::_(1)
|
||||
. ' * @return boolean True on success';
|
||||
$script .= PHP_EOL . Indent::_(1) . ' */';
|
||||
$script .= PHP_EOL . Indent::_(1) . 'public function '
|
||||
. $name . '($route, $adapter)';
|
||||
$script .= PHP_EOL . Indent::_(1) . '{';
|
||||
$script .= PHP_EOL . Indent::_(2) . '//' . Line::_(__Line__, __Class__)
|
||||
. ' set application to local method var, just use $this->app in future [we will drop $app in J6]';
|
||||
$script .= PHP_EOL . Indent::_(2)
|
||||
. '$app = $this->app;' . PHP_EOL;
|
||||
|
||||
// add the default version check (TODO) must make this dynamic
|
||||
if ('preflight' === $name)
|
||||
{
|
||||
$script .= PHP_EOL . Indent::_(2) . '//' . Line::_(__Line__, __Class__)
|
||||
.' the default for both install and update';
|
||||
$script .= PHP_EOL . Indent::_(2)
|
||||
. '$jversion = new Version();';
|
||||
$script .= PHP_EOL . Indent::_(2)
|
||||
. "if (!\$jversion->isCompatible('5.0.0'))";
|
||||
$script .= PHP_EOL . Indent::_(2) . '{';
|
||||
$script .= PHP_EOL . Indent::_(3)
|
||||
. "\$app->enqueueMessage('Please upgrade to at least Joomla! 5.0.0 before continuing!', 'error');";
|
||||
$script .= PHP_EOL . Indent::_(3) . 'return false;';
|
||||
$script .= PHP_EOL . Indent::_(2) . '}' . PHP_EOL;
|
||||
}
|
||||
|
||||
if (!empty($this->{$name . 'Active'}))
|
||||
{
|
||||
// now add the scripts
|
||||
foreach ($this->{$name . 'Bucket'} as $route => $_script)
|
||||
{
|
||||
if (ArrayHelper::check($_script) && $route !== 'bottom')
|
||||
{
|
||||
// set the if and script
|
||||
$script .= PHP_EOL . Indent::_(2) . "if ('" . $route
|
||||
. "' === \$route)";
|
||||
$script .= PHP_EOL . Indent::_(2) . '{';
|
||||
$script .= PHP_EOL . implode(
|
||||
PHP_EOL . PHP_EOL, $_script
|
||||
);
|
||||
$script .= PHP_EOL . Indent::_(2) . '}' . PHP_EOL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($this->{$name . 'Bucket'}['bottom']) && ArrayHelper::check($this->{$name . 'Bucket'}['bottom']))
|
||||
{
|
||||
$script .= PHP_EOL . implode(
|
||||
PHP_EOL , $this->{$name . 'Bucket'}['bottom']
|
||||
) . PHP_EOL;
|
||||
}
|
||||
|
||||
// return true
|
||||
$script .= PHP_EOL . Indent::_(2) . 'return true;';
|
||||
// close the function
|
||||
$script .= PHP_EOL . Indent::_(1) . '}';
|
||||
|
||||
return $script;
|
||||
}
|
||||
|
||||
/**
|
||||
* build remove files methods
|
||||
*
|
||||
* @return string
|
||||
* @since 5.0.2
|
||||
*/
|
||||
protected function removeFiles(): string
|
||||
{
|
||||
$script = PHP_EOL . PHP_EOL . Indent::_(1) . '/**';
|
||||
$script .= PHP_EOL . Indent::_(1) . ' * Remove the files and folders in the given array from';
|
||||
$script .= PHP_EOL . Indent::_(1) . ' *';
|
||||
$script .= PHP_EOL . Indent::_(1) . ' * @return void';
|
||||
$script .= PHP_EOL . Indent::_(1) . ' * @since 5.0.2';
|
||||
$script .= PHP_EOL . Indent::_(1) . ' */';
|
||||
$script .= PHP_EOL . Indent::_(1) . 'protected function removeFiles()';
|
||||
$script .= PHP_EOL . Indent::_(1) . '{';
|
||||
$script .= PHP_EOL . Indent::_(2) . 'if (!empty($this->deleteFiles))';
|
||||
$script .= PHP_EOL . Indent::_(2) . '{';
|
||||
$script .= PHP_EOL . Indent::_(3) . 'foreach ($this->deleteFiles as $file)';
|
||||
$script .= PHP_EOL . Indent::_(3) . '{';
|
||||
$script .= PHP_EOL . Indent::_(4) . 'if (is_file(JPATH_ROOT . $file) && !File::delete(JPATH_ROOT . $file))';
|
||||
$script .= PHP_EOL . Indent::_(4) . '{';
|
||||
$script .= PHP_EOL . Indent::_(5) . 'echo Text::sprintf(\'JLIB_INSTALLER_ERROR_FILE_FOLDER\', $file) . \'<br>\';';
|
||||
$script .= PHP_EOL . Indent::_(4) . '}';
|
||||
$script .= PHP_EOL . Indent::_(3) . '}';
|
||||
$script .= PHP_EOL . Indent::_(2) . '}';
|
||||
$script .= PHP_EOL . PHP_EOL . Indent::_(2) . 'if (!empty($this->deleteFolders))';
|
||||
$script .= PHP_EOL . Indent::_(2) . '{';
|
||||
$script .= PHP_EOL . Indent::_(3) . 'foreach ($this->deleteFolders as $folder)';
|
||||
$script .= PHP_EOL . Indent::_(3) . '{';
|
||||
$script .= PHP_EOL . Indent::_(4) . 'if (is_dir(JPATH_ROOT . $folder) && !Folder::delete(JPATH_ROOT . $folder))';
|
||||
$script .= PHP_EOL . Indent::_(4) . '{';
|
||||
$script .= PHP_EOL . Indent::_(5) . 'echo Text::sprintf(\'JLIB_INSTALLER_ERROR_FILE_FOLDER\', $folder) . \'<br>\';';
|
||||
$script .= PHP_EOL . Indent::_(4) . '}';
|
||||
$script .= PHP_EOL . Indent::_(3) . '}';
|
||||
$script .= PHP_EOL . Indent::_(2) . '}';
|
||||
$script .= PHP_EOL . Indent::_(1) . '}';
|
||||
|
||||
return $script;
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
@@ -0,0 +1,129 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Componentbuilder\Compiler\Field\JoomlaSix;
|
||||
|
||||
|
||||
use Joomla\Filesystem\Folder;
|
||||
use VDM\Joomla\Utilities\ArrayHelper;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Field\CoreFieldInterface;
|
||||
|
||||
|
||||
/**
|
||||
* Core Joomla 6 Fields
|
||||
*
|
||||
* @since 5.1.2
|
||||
*/
|
||||
final class CoreField implements CoreFieldInterface
|
||||
{
|
||||
/**
|
||||
* Local Core Joomla Fields
|
||||
*
|
||||
* @var array|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
protected array $fields = [];
|
||||
|
||||
/**
|
||||
* Local Core Joomla Fields Path
|
||||
*
|
||||
* @var array
|
||||
* @since 3.2.0
|
||||
**/
|
||||
protected array $paths = [];
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
// set the path to the form validation fields
|
||||
$this->paths[] = JPATH_LIBRARIES . '/src/Form/Field';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Array of Existing Validation Field Names
|
||||
*
|
||||
* @param bool $lowercase Switch to set fields lowercase
|
||||
*
|
||||
* @return array
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function get(bool $lowercase = false): array
|
||||
{
|
||||
if ($this->fields === [])
|
||||
{
|
||||
// check if the path exist
|
||||
foreach ($this->paths as $path)
|
||||
{
|
||||
$this->set($path);
|
||||
}
|
||||
}
|
||||
|
||||
// return fields if found
|
||||
if ($this->fields !== [])
|
||||
{
|
||||
// check if the names should be all lowercase
|
||||
if ($lowercase)
|
||||
{
|
||||
return array_map(
|
||||
fn($item): string => strtolower((string) $item),
|
||||
$this->fields
|
||||
);
|
||||
}
|
||||
|
||||
return $this->fields;
|
||||
}
|
||||
|
||||
// return empty array
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the fields found in a path
|
||||
*
|
||||
* @param string $path The path to load fields from
|
||||
* @return void
|
||||
* @since 3.2.0
|
||||
*/
|
||||
private function set(string $path): void
|
||||
{
|
||||
// Check if the path exists
|
||||
if (!is_dir($path))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Load all PHP files in this path
|
||||
$fields = Folder::files($path, '\.php$', true, true);
|
||||
|
||||
// Process the files to extract field names
|
||||
$processedFields = array_map(function ($name) {
|
||||
$fileName = basename($name);
|
||||
|
||||
// Remove 'Field.php' if it exists or just '.php' otherwise
|
||||
if (substr($fileName, -9) === 'Field.php')
|
||||
{
|
||||
return str_replace('Field.php', '', $fileName);
|
||||
}
|
||||
else
|
||||
{
|
||||
return str_replace('.php', '', $fileName);
|
||||
}
|
||||
}, $fields);
|
||||
|
||||
// Merge with existing fields and remove duplicates
|
||||
$this->fields = array_unique(array_merge($processedFields, $this->fields));
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,125 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Componentbuilder\Compiler\Field\JoomlaSix;
|
||||
|
||||
|
||||
use Joomla\Filesystem\Folder;
|
||||
use VDM\Joomla\Utilities\ArrayHelper;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Field\CoreRuleInterface;
|
||||
|
||||
|
||||
/**
|
||||
* Core Joomla 6 Field Rules
|
||||
*
|
||||
* @since 5.1.2
|
||||
*/
|
||||
final class CoreRule implements CoreRuleInterface
|
||||
{
|
||||
/**
|
||||
* Local Core Joomla Rules
|
||||
*
|
||||
* @var array
|
||||
* @since 3.2.0
|
||||
**/
|
||||
protected array $rules = [];
|
||||
|
||||
/**
|
||||
* Local Core Joomla Rules Path
|
||||
*
|
||||
* @var string
|
||||
* @since 3.2.0
|
||||
**/
|
||||
protected string $path;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
// set the path to the form validation rules
|
||||
$this->path = JPATH_LIBRARIES . '/src/Form/Rule';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Array of Existing Validation Rule Names
|
||||
*
|
||||
* @param bool $lowercase Switch to set rules lowercase
|
||||
*
|
||||
* @return array
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function get(bool $lowercase = false): array
|
||||
{
|
||||
if ($this->rules === [])
|
||||
{
|
||||
$this->set($this->path);
|
||||
}
|
||||
|
||||
// return rules if found
|
||||
if ($this->rules !== [])
|
||||
{
|
||||
// check if the names should be all lowercase
|
||||
if ($lowercase)
|
||||
{
|
||||
return array_map(
|
||||
fn($item): string => strtolower((string) $item),
|
||||
$this->rules
|
||||
);
|
||||
}
|
||||
|
||||
return $this->rules;
|
||||
}
|
||||
|
||||
// return empty array
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the rules found in a path
|
||||
*
|
||||
* @param string $path The path to load rules from
|
||||
* @return void
|
||||
* @since 3.2.0
|
||||
*/
|
||||
private function set(string $path): void
|
||||
{
|
||||
// Check if the path exists
|
||||
if (!is_dir($path))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Load all PHP files in this path
|
||||
$rules = Folder::files($path, '\.php$', true, true);
|
||||
|
||||
// Process the files to extract rule names
|
||||
$processedRules = array_map(function ($name) {
|
||||
$fileName = basename($name);
|
||||
|
||||
// Remove 'Rule.php' if it exists or just '.php' otherwise
|
||||
if (substr($fileName, -8) === 'Rule.php')
|
||||
{
|
||||
return str_replace('Rule.php', '', $fileName);
|
||||
}
|
||||
else
|
||||
{
|
||||
return str_replace('.php', '', $fileName);
|
||||
}
|
||||
}, $rules);
|
||||
|
||||
// Merge with existing rules and remove duplicates
|
||||
$this->rules = array_unique(array_merge($processedRules, $this->rules));
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,349 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Componentbuilder\Compiler\Field\JoomlaSix;
|
||||
|
||||
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Config;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Placeholder;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Creator\Permission;
|
||||
use VDM\Joomla\Utilities\StringHelper;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Placefix;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Line;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Field\InputButtonInterface;
|
||||
|
||||
|
||||
/**
|
||||
* Joomla 6 Compiler Field Input Button
|
||||
*
|
||||
* @since 5.1.2
|
||||
*/
|
||||
final class InputButton implements InputButtonInterface
|
||||
{
|
||||
/**
|
||||
* The Config Class.
|
||||
*
|
||||
* @var Config
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected Config $config;
|
||||
|
||||
/**
|
||||
* The Placeholder Class.
|
||||
*
|
||||
* @var Placeholder
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected Placeholder $placeholder;
|
||||
|
||||
/**
|
||||
* The Permission Class.
|
||||
*
|
||||
* @var Permission
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected Permission $permission;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param Config $config The Config Class.
|
||||
* @param Placeholder $placeholder The Placeholder Class.
|
||||
* @param Permission $permission The Permission Class.
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function __construct(Config $config, Placeholder $placeholder,
|
||||
Permission $permission)
|
||||
{
|
||||
$this->config = $config;
|
||||
$this->placeholder = $placeholder;
|
||||
$this->permission = $permission;
|
||||
}
|
||||
|
||||
/**
|
||||
* get Add Button To List Field Input (getInput tweak)
|
||||
*
|
||||
* @param array $fieldData The field custom data
|
||||
*
|
||||
* @return string of getInput class on success empty string otherwise
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function get(array $fieldData): string
|
||||
{
|
||||
// make sure hte view values are set
|
||||
if (isset($fieldData['add_button'])
|
||||
&& ($fieldData['add_button'] === 'true'
|
||||
|| 1 == $fieldData['add_button'])
|
||||
&& isset($fieldData['view'])
|
||||
&& isset($fieldData['views'])
|
||||
&& StringHelper::check($fieldData['view'])
|
||||
&& StringHelper::check($fieldData['views']))
|
||||
{
|
||||
// set local component
|
||||
$local_component = "com_" . $this->config->component_code_name;
|
||||
// check that the component value is set
|
||||
if (!isset($fieldData['component'])
|
||||
|| !StringHelper::check(
|
||||
$fieldData['component']
|
||||
))
|
||||
{
|
||||
$fieldData['component'] = $local_component;
|
||||
}
|
||||
// check that the component has the com_ value in it
|
||||
if (strpos((string) $fieldData['component'], 'com_') === false
|
||||
|| strpos((string) $fieldData['component'], '=') !== false)
|
||||
{
|
||||
$fieldData['component'] = "com_" . $fieldData['component'];
|
||||
}
|
||||
// make sure the component is update if # # # or [ [ [ component placeholder is used
|
||||
if (strpos((string) $fieldData['component'], (string) Placefix::h()) !== false
|
||||
|| strpos((string) $fieldData['component'], (string) Placefix::b()) !== false) // should not be needed... but
|
||||
{
|
||||
$fieldData['component'] = $this->placeholder->update_(
|
||||
$fieldData['component']
|
||||
);
|
||||
}
|
||||
// get core permissions
|
||||
$coreLoad = false;
|
||||
// add ref tags
|
||||
$refLoad = true;
|
||||
// fall back on the field component
|
||||
$component = $fieldData['component'];
|
||||
// check if we should add ref tags (since it only works well on local views)
|
||||
if ($local_component !== $component)
|
||||
{
|
||||
// do not add ref tags
|
||||
$refLoad = false;
|
||||
}
|
||||
// start building the add buttons/s
|
||||
$addButton = array();
|
||||
$addButton[] = PHP_EOL . PHP_EOL . Indent::_(1) . "/**";
|
||||
$addButton[] = Indent::_(1) . " * Override to add new button";
|
||||
$addButton[] = Indent::_(1) . " *";
|
||||
$addButton[] = Indent::_(1)
|
||||
. " * @return string The field input markup.";
|
||||
$addButton[] = Indent::_(1) . " *";
|
||||
$addButton[] = Indent::_(1) . " * @since 3.2";
|
||||
$addButton[] = Indent::_(1) . " */";
|
||||
$addButton[] = Indent::_(1) . "protected function getInput()";
|
||||
$addButton[] = Indent::_(1) . "{";
|
||||
$addButton[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
|
||||
. " see if we should add buttons";
|
||||
$addButton[] = Indent::_(2)
|
||||
. "\$set_button = \$this->getAttribute('button');";
|
||||
$addButton[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
|
||||
. " get html";
|
||||
$addButton[] = Indent::_(2) . "\$html = parent::getInput();";
|
||||
$addButton[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
|
||||
. " if true set button";
|
||||
$addButton[] = Indent::_(2) . "if (\$set_button === 'true')";
|
||||
$addButton[] = Indent::_(2) . "{";
|
||||
$addButton[] = Indent::_(3) . "\$button = array();";
|
||||
$addButton[] = Indent::_(3) . "\$script = array();";
|
||||
$addButton[] = Indent::_(3)
|
||||
. "\$button_code_name = \$this->getAttribute('name');";
|
||||
$addButton[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__)
|
||||
. " get the input from url";
|
||||
$addButton[] = Indent::_(3) . "\$app = Joomla__"."_39403062_84fb_46e0_bac4_0023f766e827___Power::getApplication();";
|
||||
$addButton[] = Indent::_(3) . "\$jinput = method_exists(\$app, 'getInput') ? \$app->getInput() : \$app->input;";
|
||||
$addButton[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__)
|
||||
. " get the view name & id";
|
||||
$addButton[] = Indent::_(3)
|
||||
. "\$values = \$jinput->getArray(array(";
|
||||
$addButton[] = Indent::_(4) . "'id' => 'int',";
|
||||
$addButton[] = Indent::_(4) . "'view' => 'word'";
|
||||
$addButton[] = Indent::_(3) . "));";
|
||||
$addButton[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__)
|
||||
. " check if new item";
|
||||
$addButton[] = Indent::_(3) . "\$ref = '';";
|
||||
$addButton[] = Indent::_(3) . "\$refJ = '';";
|
||||
if ($refLoad)
|
||||
{
|
||||
$addButton[] = Indent::_(3)
|
||||
. "if (!is_null(\$values['id']) && strlen(\$values['view']))";
|
||||
$addButton[] = Indent::_(3) . "{";
|
||||
$addButton[] = Indent::_(4) . "//" . Line::_(__Line__, __Class__)
|
||||
. " only load referral if not new item.";
|
||||
$addButton[] = Indent::_(4)
|
||||
. "\$ref = '&ref=' . \$values['view'] . '&refid=' . \$values['id'];";
|
||||
$addButton[] = Indent::_(4)
|
||||
. "\$refJ = '&ref=' . \$values['view'] . '&refid=' . \$values['id'];";
|
||||
$addButton[] = Indent::_(4) . "//" . Line::_(__Line__, __Class__)
|
||||
. " get the return value.";
|
||||
$addButton[] = Indent::_(4)
|
||||
. "\$_uri = (string) Joomla__"."_eecc143e_b5cf_4c33_ba4d_97da1df61422___Power::getInstance();";
|
||||
$addButton[] = Indent::_(4)
|
||||
. "\$_return = urlencode(base64_encode(\$_uri));";
|
||||
$addButton[] = Indent::_(4) . "//" . Line::_(__Line__, __Class__)
|
||||
. " load return value.";
|
||||
$addButton[] = Indent::_(4)
|
||||
. "\$ref .= '&return=' . \$_return;";
|
||||
$addButton[] = Indent::_(4)
|
||||
. "\$refJ .= '&return=' . \$_return;";
|
||||
$addButton[] = Indent::_(3) . "}";
|
||||
}
|
||||
else
|
||||
{
|
||||
$addButton[] = Indent::_(3)
|
||||
. "if (!is_null(\$values['id']) && strlen(\$values['view']))";
|
||||
$addButton[] = Indent::_(3) . "{";
|
||||
$addButton[] = Indent::_(4) . "//" . Line::_(__Line__, __Class__)
|
||||
. " only load field details if not new item.";
|
||||
$addButton[] = Indent::_(4)
|
||||
. "\$ref = '&field=' . \$values['view'] . '&field_id=' . \$values['id'];";
|
||||
$addButton[] = Indent::_(4)
|
||||
. "\$refJ = '&field=' . \$values['view'] . '&field_id=' . \$values['id'];";
|
||||
$addButton[] = Indent::_(4) . "//" . Line::_(__Line__, __Class__)
|
||||
. " get the return value.";
|
||||
$addButton[] = Indent::_(4)
|
||||
. "\$_uri = (string) Joomla__"."_eecc143e_b5cf_4c33_ba4d_97da1df61422___Power::getInstance();";
|
||||
$addButton[] = Indent::_(4)
|
||||
. "\$_return = urlencode(base64_encode(\$_uri));";
|
||||
$addButton[] = Indent::_(4) . "//" . Line::_(__Line__, __Class__)
|
||||
. " load return value.";
|
||||
$addButton[] = Indent::_(4)
|
||||
. "\$ref = '&return=' . \$_return;";
|
||||
$addButton[] = Indent::_(4)
|
||||
. "\$refJ = '&return=' . \$_return;";
|
||||
$addButton[] = Indent::_(3) . "}";
|
||||
}
|
||||
$addButton[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__)
|
||||
. " get button label";
|
||||
$addButton[] = Indent::_(3)
|
||||
. "\$button_label = trim(\$button_code_name);";
|
||||
$addButton[] = Indent::_(3)
|
||||
. "\$button_label = preg_replace('/_+/', ' ', \$button_label);";
|
||||
$addButton[] = Indent::_(3)
|
||||
. "\$button_label = preg_replace('/\s+/', ' ', \$button_label);";
|
||||
$addButton[] = Indent::_(3)
|
||||
. "\$button_label = preg_replace(\"/[^A-Za-z ]/\", '', \$button_label);";
|
||||
$addButton[] = Indent::_(3)
|
||||
. "\$button_label = ucfirst(strtolower(\$button_label));";
|
||||
$addButton[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__)
|
||||
. " get user object";
|
||||
$addButton[] = Indent::_(3) . "\$user = Joomla__"."_39403062_84fb_46e0_bac4_0023f766e827___Power::getApplication()->getIdentity();";
|
||||
$addButton[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__)
|
||||
. " only add if user allowed to create " . $fieldData['view'];
|
||||
// check if the item has permissions.
|
||||
$addButton[] = Indent::_(3) . "if (\$user->authorise('"
|
||||
. $this->permission->getGlobal($fieldData['view'], 'core.create')
|
||||
. "', '" . $component . "') && \$app->isClient('administrator')) // TODO for now only in admin area.";
|
||||
$addButton[] = Indent::_(3) . "{";
|
||||
$addButton[] = Indent::_(4) . "//" . Line::_(__Line__, __Class__)
|
||||
. " build Create button";
|
||||
$addButton[] = Indent::_(4)
|
||||
. "\$button[] = '<a id=\"'.\$button_code_name.'Create\" class=\"btn btn-small btn-success hasTooltip\" title=\"'.Text:"
|
||||
. ":sprintf('" . $this->config->lang_prefix
|
||||
. "_CREATE_NEW_S', \$button_label).'\" style=\"border-radius: 0px 4px 4px 0px;\"";
|
||||
$addButton[] = Indent::_(5) . "href=\"index.php?option="
|
||||
. $fieldData['component'] . "&view=" . $fieldData['view']
|
||||
. "&layout=edit'.\$ref.'\" >";
|
||||
$addButton[] = Indent::_(5)
|
||||
. "<span class=\"icon-new icon-white\"></span></a>';";
|
||||
$addButton[] = Indent::_(3) . "}";
|
||||
$addButton[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__)
|
||||
. " only add if user allowed to edit " . $fieldData['view'];
|
||||
// check if the item has permissions.
|
||||
$addButton[] = Indent::_(3) . "if (\$user->authorise('"
|
||||
. $this->permission->getGlobal($fieldData['view'], 'core.edit')
|
||||
. "', '" . $component . "') && \$app->isClient('administrator')) // TODO for now only in admin area.";
|
||||
$addButton[] = Indent::_(3) . "{";
|
||||
$addButton[] = Indent::_(4) . "//" . Line::_(__Line__, __Class__)
|
||||
. " build edit button";
|
||||
$addButton[] = Indent::_(4)
|
||||
. "\$button[] = '<a id=\"'.\$button_code_name.'Edit\" class=\"btn btn-small btn-outline-success button-select hasTooltip\" title=\"'.Text:"
|
||||
. ":sprintf('" . $this->config->lang_prefix
|
||||
. "_EDIT_S', \$button_label).'\" style=\"display: none; border-radius: 0px 4px 4px 0px;\" href=\"#\" >";
|
||||
$addButton[] = Indent::_(5)
|
||||
. "<span class=\"icon-edit\"></span></a>';";
|
||||
|
||||
$addButton[] = Indent::_(4) . "//" . Line::_(__Line__, __Class__)
|
||||
. " build script";
|
||||
$addButton[] = Indent::_(4) . "\$script[] = \"";
|
||||
$addButton[] = Indent::_(5) . "document.addEventListener('DOMContentLoaded', function() {";
|
||||
$addButton[] = Indent::_(6)
|
||||
. "let \".\$button_code_name.\"Field = document.getElementById('jform_\".\$button_code_name.\"');";
|
||||
$addButton[] = Indent::_(6)
|
||||
. "if (!\".\$button_code_name.\"Field) { return; }";
|
||||
$addButton[] = Indent::_(6)
|
||||
. "\".\$button_code_name.\"Field.addEventListener('change', function(e) {";
|
||||
$addButton[] = Indent::_(7) . "e.preventDefault();";
|
||||
$addButton[] = Indent::_(7)
|
||||
. "let \".\$button_code_name.\"Value = this.value;";
|
||||
$addButton[] = Indent::_(7)
|
||||
. "\".\$button_code_name.\"Button(\".\$button_code_name.\"Value);";
|
||||
$addButton[] = Indent::_(6) . "});";
|
||||
$addButton[] = Indent::_(6)
|
||||
. "let \".\$button_code_name.\"Value = \".\$button_code_name.\"Field.value;";
|
||||
$addButton[] = Indent::_(6)
|
||||
. "\".\$button_code_name.\"Button(\".\$button_code_name.\"Value);";
|
||||
$addButton[] = Indent::_(5) . "});";
|
||||
$addButton[] = Indent::_(5)
|
||||
. "function \".\$button_code_name.\"Button(value) {";
|
||||
$addButton[] = Indent::_(6)
|
||||
. "var createButton = document.getElementById('\".\$button_code_name.\"Create');";
|
||||
$addButton[] = Indent::_(6)
|
||||
. "var editButton = document.getElementById('\".\$button_code_name.\"Edit');";
|
||||
$addButton[] = Indent::_(6)
|
||||
. "if (value > 0) {"; // TODO not ideal since value may not be an (int)
|
||||
$addButton[] = Indent::_(7) . "// hide the create button";
|
||||
$addButton[] = Indent::_(7)
|
||||
. "createButton.style.display = 'none';";
|
||||
$addButton[] = Indent::_(7) . "// show edit button";
|
||||
$addButton[] = Indent::_(7)
|
||||
. "editButton.style.display = 'block';";
|
||||
$addButton[] = Indent::_(7) . "let url = 'index.php?option="
|
||||
. $fieldData['component'] . "&view=" . $fieldData['views']
|
||||
. "&task=" . $fieldData['view']
|
||||
. ".edit&id='+value+'\".\$refJ.\"';"; // TODO this value may not be the ID
|
||||
$addButton[] = Indent::_(7)
|
||||
. "editButton.setAttribute('href', url);";
|
||||
$addButton[] = Indent::_(6) . "} else {";
|
||||
$addButton[] = Indent::_(7) . "// show the create button";
|
||||
$addButton[] = Indent::_(7)
|
||||
. "createButton.style.display = 'block';";
|
||||
$addButton[] = Indent::_(7) . "// hide edit button";
|
||||
$addButton[] = Indent::_(7)
|
||||
. "editButton.style.display = 'none';";
|
||||
$addButton[] = Indent::_(6) . "}";
|
||||
$addButton[] = Indent::_(5) . "}\";";
|
||||
|
||||
$addButton[] = Indent::_(3) . "}";
|
||||
$addButton[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__)
|
||||
. " check if button was created for " . $fieldData['view']
|
||||
. " field.";
|
||||
$addButton[] = Indent::_(3)
|
||||
. "if (is_array(\$button) && count(\$button) > 0)";
|
||||
$addButton[] = Indent::_(3) . "{";
|
||||
$addButton[] = Indent::_(4) . "//" . Line::_(__Line__, __Class__)
|
||||
. " Load the needed script.";
|
||||
$addButton[] = Indent::_(4)
|
||||
. "\$document = Joomla__"."_39403062_84fb_46e0_bac4_0023f766e827___Power::getApplication()->getDocument();";
|
||||
$addButton[] = Indent::_(4)
|
||||
. "\$document->addScriptDeclaration(implode(' ',\$script));";
|
||||
$addButton[] = Indent::_(4) . "//" . Line::_(__Line__, __Class__)
|
||||
. " return the button attached to input field.";
|
||||
$addButton[] = Indent::_(4)
|
||||
. "return '<div class=\"input-group\">' .\$html . implode('',\$button).'</div>';";
|
||||
$addButton[] = Indent::_(3) . "}";
|
||||
$addButton[] = Indent::_(2) . "}";
|
||||
$addButton[] = Indent::_(2) . "return \$html;";
|
||||
$addButton[] = Indent::_(1) . "}";
|
||||
|
||||
return implode(PHP_EOL, $addButton);
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
@@ -0,0 +1,108 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Componentbuilder\Compiler\JoomlaSix;
|
||||
|
||||
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\Plugin\PluginHelper;
|
||||
use Joomla\Event\DispatcherInterface;
|
||||
use Joomla\Registry\Registry;
|
||||
use VDM\Joomla\Utilities\Component\Helper;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\EventInterface;
|
||||
|
||||
|
||||
/**
|
||||
* Compiler Events
|
||||
*
|
||||
* @since 5.1.2
|
||||
*/
|
||||
class Event implements EventInterface
|
||||
{
|
||||
/**
|
||||
* event plug-in trigger switch
|
||||
*
|
||||
* @var boolean
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected $activePlugins = false;
|
||||
|
||||
/**
|
||||
* The dispatcher to get events
|
||||
*
|
||||
* @since 5.0.2
|
||||
*/
|
||||
protected $dispatcher;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param Registry|null $params The component parameters
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function __construct(?Registry $params = null)
|
||||
{
|
||||
// Set the params
|
||||
$params = $params ?: Helper::getParams('com_componentbuilder');
|
||||
// get active plugins
|
||||
if (($plugins = $params->get('compiler_plugin', false))
|
||||
!== false)
|
||||
{
|
||||
foreach ($plugins as $plugin)
|
||||
{
|
||||
// get possible plugins
|
||||
if (PluginHelper::isEnabled('extension', $plugin))
|
||||
{
|
||||
// Import the appropriate plugin group.
|
||||
PluginHelper::importPlugin('extension', $plugin);
|
||||
// activate events
|
||||
$this->activePlugins = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->dispatcher = Factory::getContainer()->get(DispatcherInterface::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Trigger an event
|
||||
*
|
||||
* @param string $event The event to trigger
|
||||
* @param mixed $data The values to pass to the event/plugin
|
||||
*
|
||||
* @return void
|
||||
* @throws \Exception
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function trigger(string $event, $data = null)
|
||||
{
|
||||
// only execute if plugins were loaded (active)
|
||||
if ($this->activePlugins)
|
||||
{
|
||||
try
|
||||
{
|
||||
$data ??= [];
|
||||
$listeners = $this->dispatcher->getListeners($event);
|
||||
foreach ($listeners as $listener)
|
||||
{
|
||||
// Call the listener with the unpacked arguments
|
||||
$listener(...$data);
|
||||
}
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
throw new \Exception("Error processing event '$event': " . $e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,651 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Componentbuilder\Compiler\JoomlaSix;
|
||||
|
||||
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Config;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\EventInterface as Event;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Placeholder;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Language;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Builder\UikitComp;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Builder\AdminFilterType;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Builder\Category;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Builder\AccessSwitchList;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Builder\Filter;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Builder\Tags;
|
||||
use VDM\Joomla\Utilities\ArrayHelper;
|
||||
use VDM\Joomla\Utilities\StringHelper;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\HeaderInterface;
|
||||
|
||||
|
||||
/**
|
||||
* Build headers for all Joomla 6 files
|
||||
*
|
||||
* @since 5.1.2
|
||||
*/
|
||||
final class Header implements HeaderInterface
|
||||
{
|
||||
/**
|
||||
* The Config Class.
|
||||
*
|
||||
* @var Config
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected Config $config;
|
||||
|
||||
/**
|
||||
* The EventInterface Class.
|
||||
*
|
||||
* @var Event
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected Event $event;
|
||||
|
||||
/**
|
||||
* The Placeholder Class.
|
||||
*
|
||||
* @var Placeholder
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected Placeholder $placeholder;
|
||||
|
||||
/**
|
||||
* The Language Class.
|
||||
*
|
||||
* @var Language
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected Language $language;
|
||||
|
||||
/**
|
||||
* The UikitComp Class.
|
||||
*
|
||||
* @var UikitComp
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected UikitComp $uikitcomp;
|
||||
|
||||
/**
|
||||
* The AdminFilterType Class.
|
||||
*
|
||||
* @var AdminFilterType
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected AdminFilterType $adminfiltertype;
|
||||
|
||||
/**
|
||||
* The Category Class.
|
||||
*
|
||||
* @var Category
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected Category $category;
|
||||
|
||||
/**
|
||||
* The AccessSwitchList Class.
|
||||
*
|
||||
* @var AccessSwitchList
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected AccessSwitchList $accessswitchlist;
|
||||
|
||||
/**
|
||||
* The Filter Class.
|
||||
*
|
||||
* @var Filter
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected Filter $filter;
|
||||
|
||||
/**
|
||||
* The Tags Class.
|
||||
*
|
||||
* @var Tags
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected Tags $tags;
|
||||
|
||||
/**
|
||||
* The Header Context array
|
||||
*
|
||||
* @var array
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected array $headers = [];
|
||||
|
||||
/**
|
||||
* List of disallowed context strings.
|
||||
*
|
||||
* @var array<string>
|
||||
* @since 5.1.2
|
||||
*/
|
||||
protected array $disallowedContexts = [
|
||||
'admin.helper',
|
||||
'site.helper',
|
||||
'plugin.extension.header',
|
||||
'plugin.provider.header',
|
||||
'module.provider.header',
|
||||
'module.dispatcher.header',
|
||||
'module.dynamicgets.header',
|
||||
'module.helper.header',
|
||||
'module.default.template.header',
|
||||
'module.extra.template.header',
|
||||
];
|
||||
|
||||
/**
|
||||
* The Namespace Prefix
|
||||
*
|
||||
* @var string
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected string $NamespacePrefix;
|
||||
|
||||
/**
|
||||
* The Component Name (in code)
|
||||
*
|
||||
* @var string
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected string $ComponentName;
|
||||
|
||||
/**
|
||||
* The Component Namespace (in code)
|
||||
*
|
||||
* @var string
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected string $ComponentNamespace;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param Config $config The Config Class.
|
||||
* @param Event $event The EventInterface Class.
|
||||
* @param Placeholder $placeholder The Placeholder Class.
|
||||
* @param Language $language The Language Class.
|
||||
* @param UikitComp $uikitcomp The UikitComp Class.
|
||||
* @param AdminFilterType $adminfiltertype The AdminFilterType Class.
|
||||
* @param Category $category The Category Class.
|
||||
* @param AccessSwitchList $accessswitchlist The AccessSwitchList Class.
|
||||
* @param Filter $filter The Filter Class.
|
||||
* @param Tags $tags The Tags Class.
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function __construct(Config $config, Event $event, Placeholder $placeholder,
|
||||
Language $language, UikitComp $uikitcomp,
|
||||
AdminFilterType $adminfiltertype, Category $category,
|
||||
AccessSwitchList $accessswitchlist, Filter $filter,
|
||||
Tags $tags)
|
||||
{
|
||||
$this->config = $config;
|
||||
$this->event = $event;
|
||||
$this->placeholder = $placeholder;
|
||||
$this->language = $language;
|
||||
$this->uikitcomp = $uikitcomp;
|
||||
$this->adminfiltertype = $adminfiltertype;
|
||||
$this->category = $category;
|
||||
$this->accessswitchlist = $accessswitchlist;
|
||||
$this->filter = $filter;
|
||||
$this->tags = $tags;
|
||||
|
||||
// set some global values
|
||||
$this->NamespacePrefix = $this->placeholder->get('NamespacePrefix');
|
||||
$this->ComponentName = $this->placeholder->get('Component');
|
||||
$this->ComponentNamespace = $this->placeholder->get('ComponentNamespace');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the headers for a file
|
||||
*
|
||||
* @param string $context The name of the context
|
||||
* @param string $codeName The view, views, or layout code name
|
||||
*
|
||||
* @return string The header string to place in the header of the file
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function get(string $context, string $codeName): string
|
||||
{
|
||||
// get static headers
|
||||
$headers = $this->getHeaders($context);
|
||||
|
||||
// add to all except the helper classes
|
||||
if ($this->isAllowedContext($context))
|
||||
{
|
||||
$target = 'Administrator';
|
||||
if ($this->config->get('build_target', 'admin') === 'site')
|
||||
{
|
||||
$target = 'Site';
|
||||
}
|
||||
|
||||
$headers[] = "use {$this->NamespacePrefix}\\Component\\{$this->ComponentNamespace}\\{$target}\\Helper\\{$this->ComponentName}Helper;";
|
||||
|
||||
// we will add more as needed
|
||||
switch ($context)
|
||||
{
|
||||
case 'site.view.model':
|
||||
case 'site.views.model':
|
||||
case 'site.view.html':
|
||||
case 'site.views.html':
|
||||
$headers[] = "use {$this->NamespacePrefix}\\Component\\{$this->ComponentNamespace}\\Site\\Helper\\RouteHelper;";
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// get dynamic headers
|
||||
switch ($context)
|
||||
{
|
||||
case 'admin.view.html':
|
||||
case 'admin.views.html':
|
||||
case 'custom.admin.view.html':
|
||||
case 'custom.admin.views.html':
|
||||
case 'site.admin.view.html':
|
||||
case 'site.view.html':
|
||||
case 'site.views.html':
|
||||
if ((2 == $this->config->uikit || 1 == $this->config->uikit)
|
||||
&& $this->uikitcomp->exists($codeName))
|
||||
{
|
||||
$headers[] = 'use Joomla\Filesystem\File;';
|
||||
}
|
||||
break;
|
||||
|
||||
case 'admin.view':
|
||||
case 'custom.admin.view':
|
||||
case 'custom.admin.views':
|
||||
case 'site.admin.view':
|
||||
$headers[] = '';
|
||||
$headers[] = '/** @var Joomla\CMS\WebAsset\WebAssetManager $wa */';
|
||||
$headers[] = '$wa = $this->getDocument()->getWebAssetManager();';
|
||||
$headers[] = '$wa->useScript(\'keepalive\')->useScript(\'form.validate\');';
|
||||
$headers[] = 'Html::_(\'bootstrap.tooltip\');';
|
||||
break;
|
||||
|
||||
case 'admin.view.model':
|
||||
case 'site.admin.view.model':
|
||||
case 'custom.admin.view.model':
|
||||
case 'site.view.model':
|
||||
case 'admin.views.model':
|
||||
case 'site.views.model':
|
||||
$headers[] = 'use Joomla\CMS\Helper\TagsHelper;';
|
||||
break;
|
||||
|
||||
case 'plugin.provider.header':
|
||||
$headers[] = "use {$this->NamespacePrefix}\\Plugin\\[[[PluginGroupNamespace]]]\\[[[PluginNamespace]]]\\Extension\\{$codeName};";
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
// Trigger Event: jcb_ce_setClassHeader
|
||||
$this->event->trigger(
|
||||
'jcb_ce_setClassHeader', [&$context, &$codeName, &$headers]
|
||||
);
|
||||
|
||||
// return the headers
|
||||
return $this->placeholder->update_(implode(PHP_EOL, $headers));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the headers for a file
|
||||
*
|
||||
* @param string $context The name of the context
|
||||
*
|
||||
* @return array The header string to place in the header of the file
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected function getHeaders(string $context): array
|
||||
{
|
||||
if (isset($this->headers[$context]))
|
||||
{
|
||||
return $this->headers[$context];
|
||||
}
|
||||
|
||||
// set the defaults
|
||||
$headers = [];
|
||||
$headers[] = 'use Joomla\CMS\Factory;';
|
||||
$headers[] = 'use Joomla\CMS\Language\Text;';
|
||||
|
||||
switch ($context)
|
||||
{
|
||||
case 'admin.component':
|
||||
$headers[] = 'use Joomla\CMS\Access\Exception\NotAllowed;';
|
||||
$headers[] = 'use Joomla\CMS\HTML\HTMLHelper as Html;';
|
||||
$headers[] = 'use Joomla\CMS\MVC\Controller\BaseController;';
|
||||
break;
|
||||
|
||||
case 'admin.helper':
|
||||
case 'site.helper':
|
||||
$headers[] = 'use Joomla\CMS\Access\Access;';
|
||||
$headers[] = 'use Joomla\CMS\Access\Rules as AccessRules;';
|
||||
$headers[] = 'use Joomla\CMS\Component\ComponentHelper;';
|
||||
$headers[] = 'use Joomla\Filesystem\File;';
|
||||
$headers[] = 'use Joomla\CMS\Language\Language;';
|
||||
$headers[] = 'use Joomla\CMS\MVC\Model\BaseDatabaseModel;';
|
||||
$headers[] = 'use Joomla\CMS\Object\CMSObject;';
|
||||
$headers[] = 'use Joomla\CMS\Session\Session;';
|
||||
$headers[] = 'use Joomla\CMS\Table\Table;';
|
||||
$headers[] = 'use Joomla\CMS\Uri\Uri;';
|
||||
$headers[] = 'use Joomla\CMS\Version;';
|
||||
$headers[] = 'use Joomla\Database\DatabaseInterface;';
|
||||
$headers[] = 'use Joomla\Registry\Registry;';
|
||||
$headers[] = 'use Joomla\String\StringHelper;';
|
||||
$headers[] = 'use Joomla\Utilities\ArrayHelper;';
|
||||
break;
|
||||
|
||||
case 'admin.layout':
|
||||
case 'site.layout':
|
||||
case 'custom.admin.layout':
|
||||
case 'override.layout':
|
||||
$headers[] = 'use Joomla\CMS\HTML\HTMLHelper as Html;';
|
||||
$headers[] = 'use Joomla\CMS\Layout\LayoutHelper;';
|
||||
break;
|
||||
|
||||
case 'admin.view':
|
||||
case 'custom.admin.view':
|
||||
case 'custom.admin.views':
|
||||
case 'site.admin.view':
|
||||
$headers[] = 'use Joomla\CMS\HTML\HTMLHelper as Html;';
|
||||
$headers[] = 'use Joomla\CMS\Layout\LayoutHelper;';
|
||||
$headers[] = 'use Joomla\CMS\Router\Route;';
|
||||
break;
|
||||
|
||||
case 'admin.view.controller':
|
||||
$headers[] = 'use Joomla\CMS\Form\FormFactoryInterface;';
|
||||
$headers[] = 'use Joomla\CMS\Application\CMSApplication;';
|
||||
$headers[] = 'use Joomla\CMS\MVC\Factory\MVCFactoryInterface;';
|
||||
$headers[] = 'use Joomla\Input\Input;';
|
||||
case 'site.admin.view.controller':
|
||||
$headers[] = 'use Joomla\CMS\Versioning\VersionableControllerTrait;';
|
||||
case 'site.view.controller':
|
||||
$headers[] = 'use Joomla\CMS\MVC\Controller\FormController;';
|
||||
$headers[] = 'use Joomla\CMS\MVC\Model\BaseDatabaseModel;';
|
||||
$headers[] = 'use Joomla\Utilities\ArrayHelper;';
|
||||
$headers[] = 'use Joomla\CMS\Router\Route;';
|
||||
$headers[] = 'use Joomla\CMS\Session\Session;';
|
||||
$headers[] = 'use Joomla\CMS\Uri\Uri;';
|
||||
break;
|
||||
|
||||
case 'admin.view.html':
|
||||
case 'admin.views.html':
|
||||
case 'site.admin.view.html':
|
||||
$headers[] = 'use Joomla\CMS\Toolbar\Toolbar;';
|
||||
$headers[] = 'use Joomla\CMS\Form\FormHelper;';
|
||||
$headers[] = 'use Joomla\CMS\Session\Session;';
|
||||
$headers[] = 'use Joomla\CMS\Uri\Uri;';
|
||||
$headers[] = 'use Joomla\CMS\User\User;';
|
||||
$headers[] = 'use Joomla\CMS\Component\ComponentHelper;';
|
||||
$headers[] = 'use Joomla\CMS\HTML\HTMLHelper as Html;';
|
||||
$headers[] = 'use Joomla\CMS\Layout\FileLayout;';
|
||||
$headers[] = 'use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;';
|
||||
$headers[] = 'use Joomla\CMS\Plugin\PluginHelper;';
|
||||
$headers[] = 'use Joomla\CMS\Toolbar\ToolbarHelper;';
|
||||
$headers[] = 'use Joomla\CMS\Document\Document;';
|
||||
break;
|
||||
|
||||
case 'site.view.html':
|
||||
case 'site.views.html':
|
||||
$headers[] = 'use Joomla\CMS\Toolbar\Toolbar;';
|
||||
$headers[] = 'use Joomla\CMS\Component\ComponentHelper;';
|
||||
$headers[] = 'use Joomla\CMS\HTML\HTMLHelper as Html;';
|
||||
$headers[] = 'use Joomla\CMS\Layout\FileLayout;';
|
||||
$headers[] = 'use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;';
|
||||
$headers[] = 'use Joomla\CMS\Plugin\PluginHelper;';
|
||||
$headers[] = 'use Joomla\CMS\Toolbar\ToolbarHelper;';
|
||||
$headers[] = 'use Joomla\CMS\Document\Document;';
|
||||
$headers[] = "use {$this->NamespacePrefix}\\Component\\{$this->ComponentNamespace}\\Site\\Helper\\HeaderCheck;";
|
||||
break;
|
||||
|
||||
case 'custom.admin.view.html':
|
||||
case 'custom.admin.views.html':
|
||||
$target = 'Administrator';
|
||||
if ($this->config->get('build_target', 'admin') === 'site')
|
||||
{
|
||||
$target = 'Site';
|
||||
}
|
||||
$headers[] = 'use Joomla\CMS\Component\ComponentHelper;';
|
||||
$headers[] = 'use Joomla\CMS\HTML\HTMLHelper as Html;';
|
||||
$headers[] = 'use Joomla\CMS\Layout\FileLayout;';
|
||||
$headers[] = 'use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;';
|
||||
$headers[] = 'use Joomla\CMS\Plugin\PluginHelper;';
|
||||
$headers[] = 'use Joomla\CMS\Toolbar\ToolbarHelper;';
|
||||
$headers[] = 'use Joomla\CMS\User\User;';
|
||||
$headers[] = 'use Joomla\CMS\Document\Document;';
|
||||
$headers[] = "use {$this->NamespacePrefix}\\Component\\{$this->ComponentNamespace}\\{$target}\\Helper\\HeaderCheck;";
|
||||
break;
|
||||
|
||||
case 'admin.view.model':
|
||||
case 'site.admin.view.model':
|
||||
$headers[] = 'use Joomla\CMS\Application\CMSApplicationInterface;';
|
||||
$headers[] = 'use Joomla\CMS\Component\ComponentHelper;';
|
||||
$headers[] = 'use Joomla\CMS\Form\Form;';
|
||||
$headers[] = 'use Joomla\CMS\Filter\InputFilter;';
|
||||
$headers[] = 'use Joomla\CMS\Filter\OutputFilter;';
|
||||
$headers[] = 'use Joomla\CMS\MVC\Model\AdminModel;';
|
||||
$headers[] = 'use Joomla\CMS\MVC\Factory\MVCFactoryInterface;';
|
||||
$headers[] = 'use Joomla\CMS\Table\Table;';
|
||||
$headers[] = 'use Joomla\CMS\UCM\UCMType;';
|
||||
$headers[] = 'use Joomla\CMS\Versioning\VersionableModelTrait;';
|
||||
$headers[] = 'use Joomla\CMS\User\User;';
|
||||
$headers[] = 'use Joomla\Registry\Registry;';
|
||||
$headers[] = 'use Joomla\String\StringHelper;';
|
||||
$headers[] = 'use Joomla\Utilities\ArrayHelper;';
|
||||
$headers[] = 'use Joomla\Input\Input;';
|
||||
break;
|
||||
|
||||
case 'admin.views.modal':
|
||||
$headers[] = 'use Joomla\CMS\Session\Session;';
|
||||
case 'admin.views':
|
||||
$headers[] = 'use Joomla\CMS\HTML\HTMLHelper as Html;';
|
||||
$headers[] = 'use Joomla\CMS\Layout\LayoutHelper;';
|
||||
$headers[] = 'use Joomla\CMS\Router\Route;';
|
||||
break;
|
||||
|
||||
case 'admin.views.controller':
|
||||
case 'custom.admin.views.controller':
|
||||
case 'dashboard.controller':
|
||||
$headers[] = 'use Joomla\CMS\MVC\Controller\AdminController;';
|
||||
$headers[] = 'use Joomla\Utilities\ArrayHelper;';
|
||||
$headers[] = 'use Joomla\CMS\Router\Route;';
|
||||
$headers[] = 'use Joomla\CMS\Session\Session;';
|
||||
break;
|
||||
|
||||
case 'ajax.admin.model':
|
||||
case 'ajax.site.model':
|
||||
$headers[] = 'use Joomla\CMS\Application\CMSApplicationInterface;';
|
||||
$headers[] = 'use Joomla\CMS\Component\ComponentHelper;';
|
||||
$headers[] = 'use Joomla\CMS\HTML\HTMLHelper as Html;';
|
||||
$headers[] = 'use Joomla\CMS\Layout\LayoutHelper;';
|
||||
$headers[] = 'use Joomla\CMS\MVC\Model\ListModel;';
|
||||
$headers[] = 'use Joomla\CMS\MVC\Factory\MVCFactoryInterface;';
|
||||
$headers[] = 'use Joomla\CMS\Plugin\PluginHelper;';
|
||||
$headers[] = 'use Joomla\CMS\User\User;';
|
||||
$headers[] = 'use Joomla\Utilities\ArrayHelper;';
|
||||
$headers[] = 'use Joomla\Input\Input;';
|
||||
$headers[] = 'use Joomla\CMS\Router\Route;';
|
||||
$headers[] = 'use Joomla\CMS\Session\Session;';
|
||||
$headers[] = 'use Joomla\CMS\Uri\Uri;';
|
||||
$headers[] = 'use Joomla\Registry\Registry;';
|
||||
break;
|
||||
|
||||
case 'dashboard.model':
|
||||
$headers[] = 'use Joomla\CMS\HTML\HTMLHelper as Html;';
|
||||
$headers[] = 'use Joomla\CMS\Session\Session;';
|
||||
$headers[] = 'use Joomla\CMS\Uri\Uri;';
|
||||
case 'admin.views.model':
|
||||
case 'custom.admin.views.model':
|
||||
case 'site.views.model':
|
||||
$headers[] = 'use Joomla\CMS\Application\CMSApplicationInterface;';
|
||||
$headers[] = 'use Joomla\CMS\Component\ComponentHelper;';
|
||||
$headers[] = 'use Joomla\CMS\MVC\Model\ListModel;';
|
||||
$headers[] = 'use Joomla\CMS\MVC\Factory\MVCFactoryInterface;';
|
||||
$headers[] = 'use Joomla\CMS\Plugin\PluginHelper;';
|
||||
$headers[] = 'use Joomla\CMS\Router\Route;';
|
||||
$headers[] = 'use Joomla\CMS\User\User;';
|
||||
$headers[] = 'use Joomla\Utilities\ArrayHelper;';
|
||||
$headers[] = 'use Joomla\Input\Input;';
|
||||
break;
|
||||
|
||||
case 'custom.admin.view.controller':
|
||||
case 'import.controller':
|
||||
case 'import.custom.controller':
|
||||
$headers[] = 'use Joomla\CMS\MVC\Controller\BaseController;';
|
||||
$headers[] = 'use Joomla\CMS\Router\Route;';
|
||||
$headers[] = 'use Joomla\CMS\Session\Session;';
|
||||
$headers[] = 'use Joomla\Utilities\ArrayHelper;';
|
||||
break;
|
||||
|
||||
case 'custom.admin.view.model':
|
||||
case 'site.view.model':
|
||||
$headers[] = 'use Joomla\CMS\Application\CMSApplicationInterface;';
|
||||
$headers[] = 'use Joomla\CMS\Component\ComponentHelper;';
|
||||
$headers[] = 'use Joomla\CMS\MVC\Model\ItemModel;';
|
||||
$headers[] = 'use Joomla\CMS\MVC\Factory\MVCFactoryInterface;';
|
||||
$headers[] = 'use Joomla\CMS\Plugin\PluginHelper;';
|
||||
$headers[] = 'use Joomla\CMS\Router\Route;';
|
||||
$headers[] = 'use Joomla\CMS\Uri\Uri;';
|
||||
$headers[] = 'use Joomla\CMS\User\User;';
|
||||
$headers[] = 'use Joomla\Input\Input;';
|
||||
$headers[] = 'use Joomla\Utilities\ArrayHelper;';
|
||||
|
||||
break;
|
||||
case 'import.custom.model':
|
||||
case 'import.model':
|
||||
$headers[] = 'use Joomla\Filesystem\File;';
|
||||
$headers[] = 'use Joomla\Filesystem\Folder;';
|
||||
$headers[] = 'use Joomla\Filesystem\Path;';
|
||||
$headers[] = 'use Joomla\CMS\Filter\OutputFilter;';
|
||||
$headers[] = 'use Joomla\CMS\Installer\InstallerHelper;';
|
||||
$headers[] = 'use Joomla\CMS\MVC\Model\BaseDatabaseModel;';
|
||||
$headers[] = 'use Joomla\String\StringHelper;';
|
||||
$headers[] = 'use Joomla\Utilities\ArrayHelper;';
|
||||
$headers[] = 'use PhpOffice\PhpSpreadsheet\IOFactory;';
|
||||
break;
|
||||
|
||||
case 'dashboard.view':
|
||||
$headers[] = 'use Joomla\CMS\HTML\HTMLHelper as Html;';
|
||||
break;
|
||||
|
||||
case 'dashboard.view.html':
|
||||
$headers[] = 'use Joomla\CMS\HTML\HTMLHelper as Html;';
|
||||
$headers[] = 'use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;';
|
||||
$headers[] = 'use Joomla\CMS\Toolbar\ToolbarHelper;';
|
||||
$headers[] = 'use Joomla\CMS\Document\Document;';
|
||||
break;
|
||||
|
||||
case 'site.router':
|
||||
$headers[] = 'use Joomla\CMS\Application\SiteApplication;';
|
||||
$headers[] = 'use Joomla\CMS\Categories\CategoryFactoryInterface;';
|
||||
$headers[] = 'use Joomla\CMS\Component\ComponentHelper;';
|
||||
$headers[] = 'use Joomla\CMS\Component\Router\RouterView;';
|
||||
$headers[] = 'use Joomla\CMS\Component\Router\RouterViewConfiguration;';
|
||||
$headers[] = 'use Joomla\CMS\Component\Router\Rules\MenuRules;';
|
||||
$headers[] = 'use Joomla\CMS\Component\Router\Rules\NomenuRules;';
|
||||
$headers[] = 'use Joomla\CMS\Component\Router\Rules\StandardRules;';
|
||||
$headers[] = 'use Joomla\CMS\Menu\AbstractMenu;';
|
||||
$headers[] = 'use Joomla\Database\DatabaseInterface;';
|
||||
$headers[] = 'use Joomla\Database\ParameterType;';
|
||||
$headers[] = 'use Joomla\Registry\Registry;';
|
||||
break;
|
||||
|
||||
case 'site.view':
|
||||
case 'site.views':
|
||||
$headers[] = 'use Joomla\CMS\Router\Route;';
|
||||
$headers[] = 'use Joomla\CMS\Layout\LayoutHelper;';
|
||||
$headers[] = 'use Joomla\CMS\HTML\HTMLHelper as Html;';
|
||||
break;
|
||||
|
||||
case 'form.custom.field':
|
||||
$headers[] = 'use Joomla\CMS\HTML\HTMLHelper as Html;';
|
||||
$headers[] = 'use Joomla\CMS\Component\ComponentHelper;';
|
||||
$headers[] = 'use Joomla\CMS\Form\Field\###FORM_EXTENDS###;';
|
||||
break;
|
||||
|
||||
case 'module.provider.header':
|
||||
$headers = [];
|
||||
$headers[] = 'use Joomla\CMS\Extension\Service\Provider\HelperFactory;';
|
||||
$headers[] = 'use Joomla\CMS\Extension\Service\Provider\Module;';
|
||||
$headers[] = 'use Joomla\CMS\Extension\Service\Provider\ModuleDispatcherFactory;';
|
||||
$headers[] = 'use Joomla\DI\ServiceProviderInterface;';
|
||||
$headers[] = 'use Joomla\DI\Container;';
|
||||
break;
|
||||
case 'module.dispatcher.header':
|
||||
$headers = [];
|
||||
$headers[] = 'use Joomla\CMS\Dispatcher\AbstractModuleDispatcher;';
|
||||
$headers[] = 'use Joomla\CMS\Helper\HelperFactoryAwareInterface;';
|
||||
$headers[] = 'use Joomla\CMS\Helper\HelperFactoryAwareTrait;';
|
||||
break;
|
||||
case 'module.dynamicgets.header':
|
||||
$headers = [];
|
||||
$headers[] = 'use Joomla\CMS\Application\CMSApplicationInterface;';
|
||||
$headers[] = 'use Joomla\Database\DatabaseAwareInterface;';
|
||||
$headers[] = 'use Joomla\Database\DatabaseAwareTrait;';
|
||||
$headers[] = 'use Joomla\Registry\Registry;';
|
||||
$headers[] = 'use Joomla\Input\Input;';
|
||||
break;
|
||||
|
||||
case 'plugin.extension.header':
|
||||
$headers = [];
|
||||
break;
|
||||
case 'plugin.provider.header':
|
||||
$headers = [];
|
||||
$headers[] = 'use Joomla\CMS\Factory;';
|
||||
$headers[] = 'use Joomla\CMS\Plugin\PluginHelper;';
|
||||
$headers[] = 'use Joomla\CMS\Extension\PluginInterface;';
|
||||
$headers[] = 'use Joomla\Event\DispatcherInterface;';
|
||||
$headers[] = 'use Joomla\DI\ServiceProviderInterface;';
|
||||
$headers[] = 'use Joomla\DI\Container;';
|
||||
break;
|
||||
|
||||
case 'api.view.controller':
|
||||
case 'api.views.controller':
|
||||
$headers = [];
|
||||
$headers[] = 'use Joomla\CMS\Factory;';
|
||||
$headers[] = 'use Joomla\CMS\MVC\Controller\ApiController;';
|
||||
break;
|
||||
|
||||
case 'api.view.json':
|
||||
case 'api.views.json':
|
||||
$headers = [];
|
||||
$headers[] = 'use Joomla\CMS\Factory;';
|
||||
$headers[] = 'use Joomla\CMS\MVC\View\JsonApiView as BaseApiView;';
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
$this->headers[$context] = $headers;
|
||||
|
||||
return $headers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the given context is allowed.
|
||||
*
|
||||
* Returns true if the context is not in the disallowed list,
|
||||
* false if the context is disallowed.
|
||||
*
|
||||
* @param string $context The context string to evaluate.
|
||||
*
|
||||
* @return bool True if allowed, false if disallowed.
|
||||
* @since 5.1.2
|
||||
*/
|
||||
protected function isAllowedContext(string $context): bool
|
||||
{
|
||||
return !in_array($context, $this->disallowedContexts, true);
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,212 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Componentbuilder\Compiler\JoomlaSix;
|
||||
|
||||
|
||||
use Joomla\Database\DatabaseInterface;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Config;
|
||||
use VDM\Joomla\Utilities\JsonHelper;
|
||||
use VDM\Joomla\Utilities\ArrayHelper;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\HistoryInterface;
|
||||
|
||||
|
||||
/**
|
||||
* Compiler History
|
||||
*
|
||||
* @since 5.1.2
|
||||
*/
|
||||
final class History implements HistoryInterface
|
||||
{
|
||||
/**
|
||||
* History Item Object
|
||||
*
|
||||
* @var object|null
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected ?object $tmp;
|
||||
|
||||
/**
|
||||
* Compiler Config
|
||||
*
|
||||
* @var Config
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected Config $config;
|
||||
|
||||
/**
|
||||
* Joomla Database Class.
|
||||
*
|
||||
* @var DatabaseInterface
|
||||
* @since 5.1.2
|
||||
**/
|
||||
protected DatabaseInterface $db;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param Config $config The compiler config object.
|
||||
* @param DatabaseInterface $db The Joomla Database Class.
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function __construct(Config $config, DatabaseInterface $db)
|
||||
{
|
||||
$this->config = $config;
|
||||
$this->db = $db;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Item History object
|
||||
*
|
||||
* @param string $type The type of item
|
||||
* @param int $id The item ID
|
||||
*
|
||||
* @return ?object The history
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function get(string $type, int $id): ?object
|
||||
{
|
||||
// quick class object to store old history object
|
||||
$this->tmp = null;
|
||||
// Create a new query object.
|
||||
$query = $this->db->getQuery(true);
|
||||
|
||||
$query->select('h.*');
|
||||
$query->from('#__history AS h');
|
||||
$query->where(
|
||||
$this->db->quoteName('h.item_id') . ' = ' . $this->db->quote('com_componentbuilder.' . $type . '.' . (int) $id)
|
||||
);
|
||||
$query->order('h.save_date DESC');
|
||||
$this->db->setQuery($query, 0, 1);
|
||||
$this->db->execute();
|
||||
if ($this->db->getNumRows())
|
||||
{
|
||||
// new version of this item found
|
||||
// so we need to mark it as the last compiled version
|
||||
$newActive = $this->db->loadObject();
|
||||
// set the new version watch
|
||||
$this->set($newActive, 1);
|
||||
}
|
||||
// Get last compiled verion
|
||||
$query = $this->db->getQuery(true);
|
||||
|
||||
$query->select('h.*');
|
||||
$query->from('#__history AS h');
|
||||
$query->where(
|
||||
$this->db->quoteName('h.item_id') . ' = ' . $this->db->quote('com_componentbuilder.' . $type . '.' . (int) $id)
|
||||
);
|
||||
$query->where('h.keep_forever = 1');
|
||||
$query->where('h.version_note LIKE ' . $this->db->quote('%component%'));
|
||||
// make sure it does not return the active version
|
||||
if (isset($newActive) && isset($newActive->version_id))
|
||||
{
|
||||
$query->where('h.version_id != ' . (int) $newActive->version_id);
|
||||
}
|
||||
$query->order('h.save_date DESC');
|
||||
$this->db->setQuery($query);
|
||||
$this->db->execute();
|
||||
if ($this->db->getNumRows())
|
||||
{
|
||||
// the old active version was found
|
||||
// so we may need to do an SQL update
|
||||
// and unmark the old compiled version
|
||||
$oldActives = $this->db->loadObjectList();
|
||||
foreach ($oldActives as $oldActive)
|
||||
{
|
||||
// remove old version watch
|
||||
$this->set($oldActive, 0);
|
||||
}
|
||||
}
|
||||
|
||||
// return the last used history record or null.
|
||||
return $this->tmp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Item History Watch
|
||||
*
|
||||
* @param Object $object The history object
|
||||
* @param int $action The action to take
|
||||
* 0 = remove watch
|
||||
* 1 = add watch
|
||||
*
|
||||
* @return bool
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected function set(object $object, int $action): bool
|
||||
{
|
||||
// check the note
|
||||
if (JsonHelper::check($object->version_note))
|
||||
{
|
||||
$version_note = json_decode((string) $object->version_note, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
$version_note = array('component' => []);
|
||||
}
|
||||
// set watch
|
||||
switch ($action)
|
||||
{
|
||||
case 0:
|
||||
// remove watch
|
||||
if (isset($version_note['component'])
|
||||
&& ($key = array_search(
|
||||
$this->config->component_id, $version_note['component']
|
||||
)) !== false)
|
||||
{
|
||||
// last version that was used to build/compile
|
||||
$this->tmp = json_decode((string) $object->version_data);
|
||||
// remove it from this component
|
||||
unset($version_note['component'][$key]);
|
||||
}
|
||||
else
|
||||
{
|
||||
// since it was not found, no need to update anything
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
// add watch
|
||||
if (!in_array($this->config->component_id, $version_note['component']))
|
||||
{
|
||||
$version_note['component'][] = $this->config->component_id;
|
||||
}
|
||||
else
|
||||
{
|
||||
// since it is there already, no need to update anything
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
// check if we need to still keep this locked
|
||||
if (isset($version_note['component'])
|
||||
&& ArrayHelper::check($version_note['component']))
|
||||
{
|
||||
// insure component ids are only added once per item
|
||||
$version_note['component'] = array_unique(
|
||||
$version_note['component']
|
||||
);
|
||||
// we may change this, little risky (but since JCB does not have history notes it should be okay for now)
|
||||
$object->version_note = json_encode($version_note);
|
||||
$object->keep_forever = '1';
|
||||
}
|
||||
else
|
||||
{
|
||||
$object->version_note = '';
|
||||
$object->keep_forever = '0';
|
||||
}
|
||||
|
||||
// run the update
|
||||
return $this->db->updateObject('#__history', $object, 'version_id');
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,435 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Componentbuilder\Compiler\Joomlamodule\JoomlaSix;
|
||||
|
||||
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Config;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Architecture\Module\ProviderInterface as Provider;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Architecture\Module\DispatcherInterface as Dispatcher;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Architecture\Module\TemplateInterface as Template;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Architecture\Module\HelperInterface as Helper;
|
||||
use VDM\Joomla\Componentbuilder\Interfaces\Architecture\Module\MainXMLInterface as MainXML;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\ModuleDataInterface as Data;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\HeaderInterface as Header;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\EventInterface as Event;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\GetScriptInterface as InstallScript;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Builder\ContentMulti;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Creator\FieldsetExtension;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Dynamicget\Methods;
|
||||
use VDM\Joomla\Utilities\ObjectHelper;
|
||||
use VDM\Joomla\Utilities\ArrayHelper;
|
||||
use VDM\Joomla\Componentbuilder\Interfaces\Module\InfusionInterface;
|
||||
|
||||
|
||||
/**
|
||||
* Joomla 6 module Infusion Class
|
||||
*
|
||||
* @since 5.1.2
|
||||
*/
|
||||
final class Infusion implements InfusionInterface
|
||||
{
|
||||
/**
|
||||
* The Config Class.
|
||||
*
|
||||
* @var Config
|
||||
* @since 5.1.2
|
||||
*/
|
||||
protected Config $config;
|
||||
|
||||
/**
|
||||
* The Provider Class.
|
||||
*
|
||||
* @var Provider
|
||||
* @since 5.1.2
|
||||
*/
|
||||
protected Provider $provider;
|
||||
|
||||
/**
|
||||
* The Dispatcher Class.
|
||||
*
|
||||
* @var Dispatcher
|
||||
* @since 5.1.2
|
||||
*/
|
||||
protected Dispatcher $dispatcher;
|
||||
|
||||
/**
|
||||
* The Template Class.
|
||||
*
|
||||
* @var Template
|
||||
* @since 5.1.2
|
||||
*/
|
||||
protected Template $template;
|
||||
|
||||
/**
|
||||
* The Helper Class.
|
||||
*
|
||||
* @var Helper
|
||||
* @since 5.1.2
|
||||
*/
|
||||
protected Helper $helper;
|
||||
|
||||
/**
|
||||
* The MainXML Class.
|
||||
*
|
||||
* @var MainXML
|
||||
* @since 5.1.2
|
||||
*/
|
||||
protected MainXML $mainxml;
|
||||
|
||||
/**
|
||||
* The ModuleData Class.
|
||||
*
|
||||
* @var Data
|
||||
* @since 5.1.2
|
||||
*/
|
||||
protected Data $data;
|
||||
|
||||
/**
|
||||
* The Header Class.
|
||||
*
|
||||
* @var Header
|
||||
* @since 5.1.2
|
||||
*/
|
||||
protected Header $header;
|
||||
|
||||
/**
|
||||
* The Event Class.
|
||||
*
|
||||
* @var Event
|
||||
* @since 5.1.2
|
||||
*/
|
||||
protected Event $event;
|
||||
|
||||
/**
|
||||
* The Install Class.
|
||||
*
|
||||
* @var InstallScript
|
||||
* @since 5.1.2
|
||||
*/
|
||||
protected InstallScript $installscript;
|
||||
|
||||
/**
|
||||
* The ContentMulti Class.
|
||||
*
|
||||
* @var ContentMulti
|
||||
* @since 5.1.2
|
||||
*/
|
||||
protected ContentMulti $contentmulti;
|
||||
|
||||
/**
|
||||
* The FieldsetExtension Class.
|
||||
*
|
||||
* @var FieldsetExtension
|
||||
* @since 5.1.2
|
||||
*/
|
||||
protected FieldsetExtension $fieldsetextension;
|
||||
|
||||
/**
|
||||
* The Methods Class.
|
||||
*
|
||||
* @var Methods
|
||||
* @since 5.1.2
|
||||
*/
|
||||
protected Methods $methods;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param Config $config The Config Class.
|
||||
* @param Provider $provider The Provider Class.
|
||||
* @param Dispatcher $dispatcher The Dispatcher Class.
|
||||
* @param Template $template The Template Class.
|
||||
* @param Helper $helper The Helper Class.
|
||||
* @param MainXML $mainxml The MainXML Class.
|
||||
* @param Data $data The ModuleData Class.
|
||||
* @param Header $header The Header Class.
|
||||
* @param Event $event The Event Class.
|
||||
* @param InstallScript $installscript The GetScript Class.
|
||||
* @param ContentMulti $contentmulti The ContentMulti Class.
|
||||
* @param FieldsetExtension $fieldsetextension The FieldsetExtension Class.
|
||||
* @param Methods $methods The Methods Class.
|
||||
*
|
||||
* @since 5.1.2
|
||||
*/
|
||||
public function __construct(Config $config, Provider $provider, Dispatcher $dispatcher,
|
||||
Template $template, Helper $helper, MainXML $mainxml,
|
||||
Data $data, Header $header, Event $event,
|
||||
InstallScript $installscript, ContentMulti $contentmulti,
|
||||
FieldsetExtension $fieldsetextension, Methods $methods)
|
||||
{
|
||||
$this->config = $config;
|
||||
$this->provider = $provider;
|
||||
$this->dispatcher = $dispatcher;
|
||||
$this->template = $template;
|
||||
$this->helper = $helper;
|
||||
$this->mainxml = $mainxml;
|
||||
$this->data = $data;
|
||||
$this->header = $header;
|
||||
$this->event = $event;
|
||||
$this->installscript = $installscript;
|
||||
$this->contentmulti = $contentmulti;
|
||||
$this->fieldsetextension = $fieldsetextension;
|
||||
$this->methods = $methods;
|
||||
}
|
||||
|
||||
/**
|
||||
* Infuse the module data into the content.
|
||||
*
|
||||
* @return void
|
||||
* @since 5.1.2
|
||||
*/
|
||||
public function set(): void
|
||||
{
|
||||
if (!$this->data->exists())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ($this->data->get() as $module)
|
||||
{
|
||||
if (!ObjectHelper::check($module))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$this->triggerBeforeInfusionEvent($module);
|
||||
$this->setModuleConfiguration($module);
|
||||
$this->setProviderCode($module);
|
||||
$this->setDispatcherCode($module);
|
||||
$this->setDynamicGets($module);
|
||||
$this->setHelperCode($module);
|
||||
$this->setDefaultTemplates($module);
|
||||
$this->setInstallScript($module);
|
||||
$this->setFieldsets($module);
|
||||
$this->setMainXml($module);
|
||||
$this->triggerAfterInfusionEvent($module);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set core configuration from module data.
|
||||
*
|
||||
* @param object $module
|
||||
*
|
||||
* @return void
|
||||
* @since 5.1.2
|
||||
*/
|
||||
protected function setModuleConfiguration(object $module): void
|
||||
{
|
||||
$this->config->build_target = $module->key;
|
||||
$this->config->lang_target = $module->key;
|
||||
$this->config->set('lang_prefix', $module->lang_prefix);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the provider provider code.
|
||||
*
|
||||
* @param object $module The module object being processed.
|
||||
*
|
||||
* @return void
|
||||
* @since 5.1.2
|
||||
*/
|
||||
protected function setProviderCode($module): void
|
||||
{
|
||||
$header = trim((string) ($this->header->get('module.provider.header', $module->class_name) ?? ''));
|
||||
if ($header !== '')
|
||||
{
|
||||
$header = PHP_EOL . PHP_EOL . $header;
|
||||
}
|
||||
$this->contentmulti->set("{$module->key}|PROVIDER_CLASS_HEADER", $header);
|
||||
|
||||
$providerContent = $this->provider->get($module);
|
||||
$this->contentmulti->set("{$module->key}|PROVIDER_CLASS", $providerContent);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set dispatcher-generated module code.
|
||||
*
|
||||
* @param object $module
|
||||
*
|
||||
* @return void
|
||||
* @since 5.1.2
|
||||
*/
|
||||
protected function setDispatcherCode(object $module): void
|
||||
{
|
||||
$header = trim((string) ($this->header->get('module.dispatcher.header', $module->class_name) ?? ''));
|
||||
if ($header !== '')
|
||||
{
|
||||
$header = PHP_EOL . PHP_EOL . $header;
|
||||
}
|
||||
$this->contentmulti->set("{$module->key}|DISPATCHER_CLASS_HEADER", $header);
|
||||
|
||||
$code = $this->dispatcher->get($module);
|
||||
$this->contentmulti->set("{$module->key}|DISPATCHER_CLASS", $code);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set dynamically generated get methods (dynamicGets).
|
||||
*
|
||||
* @param object $module
|
||||
*
|
||||
* @return void
|
||||
* @since 5.1.2
|
||||
*/
|
||||
protected function setDynamicGets(object $module): void
|
||||
{
|
||||
if ($module->custom_get)
|
||||
{
|
||||
$header = trim((string) ($this->header->get('module.dynamicgets.header', $module->class_name) ?? ''));
|
||||
if ($header !== '')
|
||||
{
|
||||
$header = PHP_EOL . PHP_EOL . $header;
|
||||
}
|
||||
$this->contentmulti->set("{$module->key}|DYNAMICGETS_HEADER", $header);
|
||||
|
||||
$code = $this->methods->get($module, $module->key);
|
||||
$this->contentmulti->set("{$module->key}|DYNAMICGETS", $code);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set helper class code if enabled.
|
||||
*
|
||||
* @param object $module
|
||||
*
|
||||
* @return void
|
||||
* @since 5.1.2
|
||||
*/
|
||||
protected function setHelperCode(object $module): void
|
||||
{
|
||||
if ($module->add_class_helper >= 1)
|
||||
{
|
||||
$header = trim((string) ($this->header->get('module.helper.header', $module->class_name) ?? ''));
|
||||
$header .= $this->helper->header($module);
|
||||
if (!empty($header))
|
||||
{
|
||||
$header = PHP_EOL . PHP_EOL . trim($header);
|
||||
}
|
||||
$this->contentmulti->set("{$module->key}|HELPER_CLASS_HEADER", $header);
|
||||
|
||||
$code = $this->helper->get($module);
|
||||
$this->contentmulti->set("{$module->key}|HELPER_CLASS", $code);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set default and extra templates.
|
||||
*
|
||||
* @param object $module
|
||||
*
|
||||
* @return void
|
||||
* @since 5.1.2
|
||||
*/
|
||||
protected function setDefaultTemplates(object $module): void
|
||||
{
|
||||
$header = trim((string) ($this->header->get('module.default.template.header', $module->class_name) ?? ''));
|
||||
if ($header !== '')
|
||||
{
|
||||
$header = PHP_EOL . PHP_EOL . $header;
|
||||
}
|
||||
$this->contentmulti->set("{$module->key}|MODDEFAULT_HEADER", $header);
|
||||
|
||||
$header_code = $this->template->header($module);
|
||||
$this->contentmulti->set("{$module->key}|MODDEFAULT_HEADER_CODE", $header_code);
|
||||
|
||||
$code = $this->template->default($module, $module->key);
|
||||
$this->contentmulti->set("{$module->key}|MODDEFAULT", $code);
|
||||
|
||||
$this->template->extra($module);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set install script content if required.
|
||||
*
|
||||
* @param object $module
|
||||
*
|
||||
* @return void
|
||||
* @since 5.1.2
|
||||
*/
|
||||
protected function setInstallScript(object $module): void
|
||||
{
|
||||
if ($module->add_install_script)
|
||||
{
|
||||
$this->contentmulti->set("{$module->key}|INSTALLCLASS",
|
||||
$this->installscript->get($module));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set all fieldset content based on form files.
|
||||
*
|
||||
* @param object $module
|
||||
*
|
||||
* @return void
|
||||
* @since 5.1.2
|
||||
*/
|
||||
protected function setFieldsets(object $module): void
|
||||
{
|
||||
if (!isset($module->form_files) || !ArrayHelper::check($module->form_files))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ($module->form_files as $file => $files)
|
||||
{
|
||||
foreach ($files as $field_name => $fieldsets)
|
||||
{
|
||||
foreach ($fieldsets as $fieldset => $fields)
|
||||
{
|
||||
$key = "{$module->key}|FIELDSET_{$file}{$field_name}{$fieldset}";
|
||||
$content = $this->fieldsetextension->get($module, $fields);
|
||||
$this->contentmulti->set($key, $content);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set main XML configuration content.
|
||||
*
|
||||
* @param object $module
|
||||
*
|
||||
* @return void
|
||||
* @since 5.1.2
|
||||
*/
|
||||
protected function setMainXml(object $module): void
|
||||
{
|
||||
$this->contentmulti->set("{$module->key}|MAINXML", $this->mainxml->get($module));
|
||||
}
|
||||
|
||||
/**
|
||||
* Trigger before-infusion event.
|
||||
*
|
||||
* @param object $module
|
||||
*
|
||||
* @return void
|
||||
* @since 5.1.2
|
||||
*/
|
||||
protected function triggerBeforeInfusionEvent(object &$module): void
|
||||
{
|
||||
$this->event->trigger('jcb_ce_onBeforeInfuseModuleData', [&$module]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Trigger after-infusion event.
|
||||
*
|
||||
* @param object $module
|
||||
*
|
||||
* @return void
|
||||
* @since 5.1.2
|
||||
*/
|
||||
protected function triggerAfterInfusionEvent(object &$module): void
|
||||
{
|
||||
$this->event->trigger('jcb_ce_onAfterInfuseModuleData', [&$module]);
|
||||
}
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,392 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Componentbuilder\Compiler\Joomlaplugin\JoomlaSix;
|
||||
|
||||
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Config;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Placeholder;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\HeaderInterface as Header;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\EventInterface as Event;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\PluginDataInterface as Data;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\GetScriptInterface as InstallScript;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Architecture\Plugin\ExtensionInterface as Extension;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Architecture\Plugin\ProviderInterface as Provider;
|
||||
use VDM\Joomla\Componentbuilder\Interfaces\Architecture\Plugin\MainXMLInterface as MainXML;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Builder\ContentMulti;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Builder\ContentOne;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Creator\FieldsetExtension;
|
||||
use VDM\Joomla\Utilities\ObjectHelper;
|
||||
use VDM\Joomla\Utilities\ArrayHelper;
|
||||
use VDM\Joomla\Componentbuilder\Interfaces\Plugin\InfusionInterface;
|
||||
|
||||
|
||||
/**
|
||||
* Joomla 6 Plugin Infusion Class
|
||||
*
|
||||
* @since 5.1.2
|
||||
*/
|
||||
final class Infusion implements InfusionInterface
|
||||
{
|
||||
/**
|
||||
* The Config Class.
|
||||
*
|
||||
* @var Config
|
||||
* @since 5.0.2
|
||||
*/
|
||||
protected Config $config;
|
||||
|
||||
/**
|
||||
* The Placeholder Class.
|
||||
*
|
||||
* @var Placeholder
|
||||
* @since 5.0.2
|
||||
*/
|
||||
protected Placeholder $placeholder;
|
||||
|
||||
/**
|
||||
* The Header Class.
|
||||
*
|
||||
* @var Header
|
||||
* @since 5.0.2
|
||||
*/
|
||||
protected Header $header;
|
||||
|
||||
/**
|
||||
* The Event Class.
|
||||
*
|
||||
* @var Event
|
||||
* @since 5.0.2
|
||||
*/
|
||||
protected Event $event;
|
||||
|
||||
/**
|
||||
* The PluginData Class.
|
||||
*
|
||||
* @var Data
|
||||
* @since 5.0.2
|
||||
*/
|
||||
protected Data $data;
|
||||
|
||||
/**
|
||||
* The GetScript Class.
|
||||
*
|
||||
* @var InstallScript
|
||||
* @since 5.0.2
|
||||
*/
|
||||
protected InstallScript $installscript;
|
||||
|
||||
/**
|
||||
* The Extension Class.
|
||||
*
|
||||
* @var Extension
|
||||
* @since 5.0.2
|
||||
*/
|
||||
protected Extension $extension;
|
||||
|
||||
/**
|
||||
* The Provider Class.
|
||||
*
|
||||
* @var Provider
|
||||
* @since 5.0.2
|
||||
*/
|
||||
protected Provider $provider;
|
||||
|
||||
/**
|
||||
* The MainXML Class.
|
||||
*
|
||||
* @var MainXML
|
||||
* @since 5.0.2
|
||||
*/
|
||||
protected MainXML $mainxml;
|
||||
|
||||
/**
|
||||
* The Content Multi Class.
|
||||
*
|
||||
* @var ContentMulti
|
||||
* @since 5.0.2
|
||||
*/
|
||||
protected ContentMulti $contentmulti;
|
||||
|
||||
/**
|
||||
* The Content One Class.
|
||||
*
|
||||
* @var ContentOne
|
||||
* @since 5.0.2
|
||||
*/
|
||||
protected ContentOne $contentone;
|
||||
|
||||
/**
|
||||
* The Fieldset Extension Class.
|
||||
*
|
||||
* @var FieldsetExtension
|
||||
* @since 5.0.2
|
||||
*/
|
||||
protected FieldsetExtension $fieldsetextension;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param Config $config The Config Class.
|
||||
* @param Placeholder $placeholder The Placeholder Class.
|
||||
* @param Header $header The HeaderInterface Class.
|
||||
* @param Event $event The EventInterface Class.
|
||||
* @param Data $data The PluginDataInterface Class.
|
||||
* @param InstallScript $installscript The GetScriptInterface Class.
|
||||
* @param Extension $extension The ExtensionInterface Class.
|
||||
* @param Provider $provider The ProviderInterface Class.
|
||||
* @param MainXML $mainxml The MainXMLInterface Class.
|
||||
* @param ContentMulti $contentmulti The ContentMulti Class.
|
||||
* @param ContentOne $contentone The ContentOne Class.
|
||||
* @param FieldsetExtension $fieldsetextension The FieldsetExtension Class.
|
||||
*
|
||||
* @since 5.0.2
|
||||
*/
|
||||
public function __construct(Config $config, Placeholder $placeholder, Header $header,
|
||||
Event $event, Data $data, InstallScript $installscript,
|
||||
Extension $extension, Provider $provider,
|
||||
MainXML $mainxml, ContentMulti $contentmulti,
|
||||
ContentOne $contentone, FieldsetExtension $fieldsetextension)
|
||||
{
|
||||
$this->config = $config;
|
||||
$this->placeholder = $placeholder;
|
||||
$this->header = $header;
|
||||
$this->event = $event;
|
||||
$this->data = $data;
|
||||
$this->installscript = $installscript;
|
||||
$this->extension = $extension;
|
||||
$this->provider = $provider;
|
||||
$this->mainxml = $mainxml;
|
||||
$this->contentmulti = $contentmulti;
|
||||
$this->contentone = $contentone;
|
||||
$this->fieldsetextension = $fieldsetextension;
|
||||
}
|
||||
|
||||
/**
|
||||
* Infuse the plugin data into the content.
|
||||
*
|
||||
* This method processes each plugin in the data set, triggering events
|
||||
* before and after infusion, setting placeholders, and adding content
|
||||
* such as headers, classes, and XML configurations.
|
||||
*
|
||||
* @return void
|
||||
* @since 5.0.2
|
||||
*/
|
||||
public function set(): void
|
||||
{
|
||||
if (!$this->data->exists())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ($this->data->get() as $plugin)
|
||||
{
|
||||
if (!ObjectHelper::check($plugin))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$this->triggerBeforeInfusionEvent($plugin);
|
||||
$this->setPlaceholders($plugin);
|
||||
$this->buildPluginContent($plugin);
|
||||
$this->triggerAfterInfusionEvent($plugin);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Trigger the event before infusing the plugin data.
|
||||
*
|
||||
* @param object $plugin The plugin object being processed.
|
||||
*
|
||||
* @return void
|
||||
* @since 5.0.2
|
||||
*/
|
||||
protected function triggerBeforeInfusionEvent(&$plugin): void
|
||||
{
|
||||
$this->event->trigger('jcb_ce_onBeforeInfusePluginData', [&$plugin]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set placeholders based on plugin data.
|
||||
*
|
||||
* @param object $plugin The plugin object being processed.
|
||||
*
|
||||
* @return void
|
||||
* @since 5.0.2
|
||||
*/
|
||||
protected function setPlaceholders($plugin): void
|
||||
{
|
||||
$this->placeholder->set('PluginGroupNamespace', $plugin->group_namespace ?? '');
|
||||
$this->placeholder->set('PluginNamespace', $plugin->namespace ?? '');
|
||||
|
||||
$this->config->build_target = $plugin->key;
|
||||
$this->config->lang_target = $plugin->key;
|
||||
$this->config->set('lang_prefix', $plugin->lang_prefix);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build and set the content related to the plugin.
|
||||
*
|
||||
* @param object $plugin The plugin object being processed.
|
||||
*
|
||||
* @return void
|
||||
* @since 5.0.2
|
||||
*/
|
||||
protected function buildPluginContent($plugin): void
|
||||
{
|
||||
$this->setExtensionClassHeader($plugin);
|
||||
$this->setExtensionClass($plugin);
|
||||
$this->setProviderClassHeader($plugin);
|
||||
$this->setProviderClass($plugin);
|
||||
|
||||
if ($plugin->add_install_script)
|
||||
{
|
||||
$this->setInstallClass($plugin);
|
||||
}
|
||||
|
||||
if (isset($plugin->form_files) && ArrayHelper::check($plugin->form_files))
|
||||
{
|
||||
$this->setFieldsets($plugin);
|
||||
}
|
||||
|
||||
$this->setMainXml($plugin);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the extension class header content.
|
||||
*
|
||||
* @param object $plugin The plugin object being processed.
|
||||
*
|
||||
* @return void
|
||||
* @since 5.0.2
|
||||
*/
|
||||
protected function setExtensionClassHeader($plugin): void
|
||||
{
|
||||
$headerContent = trim(
|
||||
$this->header->get('plugin.extension.header', $plugin->class_name)
|
||||
. PHP_EOL . ($plugin->header ?? '')
|
||||
);
|
||||
|
||||
$this->contentmulti->set("{$plugin->key}|EXTENSION_CLASS_HEADER",
|
||||
$this->placeholder->update($headerContent, $this->contentone->allActive())
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the extension class content.
|
||||
*
|
||||
* @param object $plugin The plugin object being processed.
|
||||
*
|
||||
* @return void
|
||||
* @since 5.0.2
|
||||
*/
|
||||
protected function setExtensionClass($plugin): void
|
||||
{
|
||||
$extensionContent = $this->extension->get($plugin);
|
||||
$this->contentmulti->set("{$plugin->key}|EXTENSION_CLASS", $extensionContent);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the provider class header content.
|
||||
*
|
||||
* @param object $plugin The plugin object being processed.
|
||||
*
|
||||
* @return void
|
||||
* @since 5.0.2
|
||||
*/
|
||||
protected function setProviderClassHeader($plugin): void
|
||||
{
|
||||
$providerHeader = $this->header->get('plugin.provider.header', $plugin->class_name);
|
||||
$this->contentmulti->set("{$plugin->key}|PROVIDER_CLASS_HEADER", $providerHeader);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the provider class content.
|
||||
*
|
||||
* @param object $plugin The plugin object being processed.
|
||||
*
|
||||
* @return void
|
||||
* @since 5.0.2
|
||||
*/
|
||||
protected function setProviderClass($plugin): void
|
||||
{
|
||||
$providerContent = $this->provider->get($plugin);
|
||||
$this->contentmulti->set("{$plugin->key}|PROVIDER_CLASS", $providerContent);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the install script content, if needed.
|
||||
*
|
||||
* @param object $plugin The plugin object being processed.
|
||||
*
|
||||
* @return void
|
||||
* @since 5.0.2
|
||||
*/
|
||||
protected function setInstallClass($plugin): void
|
||||
{
|
||||
$installContent = $this->installscript->get($plugin);
|
||||
$this->contentmulti->set("{$plugin->key}|INSTALL_CLASS", $installContent);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set fieldset content based on form files.
|
||||
*
|
||||
* @param object $plugin The plugin object being processed.
|
||||
*
|
||||
* @return void
|
||||
* @since 5.0.2
|
||||
*/
|
||||
protected function setFieldsets($plugin): void
|
||||
{
|
||||
foreach ($plugin->form_files as $file => $files)
|
||||
{
|
||||
foreach ($files as $field_name => $fieldsets)
|
||||
{
|
||||
foreach ($fieldsets as $fieldset => $fields)
|
||||
{
|
||||
$fieldsetContent = $this->fieldsetextension->get($plugin, $fields);
|
||||
$this->contentmulti->set(
|
||||
"{$plugin->key}|FIELDSET_{$file}{$field_name}{$fieldset}",
|
||||
$fieldsetContent
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the main XML content for the plugin.
|
||||
*
|
||||
* @param object $plugin The plugin object being processed.
|
||||
*
|
||||
* @return void
|
||||
* @since 5.0.2
|
||||
*/
|
||||
protected function setMainXml($plugin): void
|
||||
{
|
||||
$mainXmlContent = $this->mainxml->get($plugin);
|
||||
$this->contentmulti->set("{$plugin->key}|MAINXML", $mainXmlContent);
|
||||
}
|
||||
|
||||
/**
|
||||
* Trigger the event after infusing the plugin data.
|
||||
*
|
||||
* @param object $plugin The plugin object being processed.
|
||||
*
|
||||
* @return void
|
||||
* @since 5.0.2
|
||||
*/
|
||||
protected function triggerAfterInfusionEvent(&$plugin): void
|
||||
{
|
||||
$this->event->trigger('jcb_ce_onAfterInfusePluginData', [&$plugin]);
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,827 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Componentbuilder\Compiler\Joomlaplugin\JoomlaSix;
|
||||
|
||||
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\PluginDataInterface 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 as Event;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Counter;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Folder;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Utilities\File;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Files;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Placeholder;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Placefix;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Line;
|
||||
use VDM\Joomla\Utilities\ArrayHelper;
|
||||
use VDM\Joomla\Utilities\ObjectHelper;
|
||||
use VDM\Joomla\Utilities\StringHelper;
|
||||
use VDM\Joomla\Utilities\FileHelper;
|
||||
use VDM\Joomla\Componentbuilder\Interfaces\Plugin\StructureInterface;
|
||||
|
||||
|
||||
/**
|
||||
* Joomla 6 Plugin Builder Class
|
||||
*
|
||||
* @since 5.1.2
|
||||
*/
|
||||
final class Structure implements StructureInterface
|
||||
{
|
||||
/**
|
||||
* The Data Class.
|
||||
*
|
||||
* @var Plugin
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected Plugin $plugin;
|
||||
|
||||
/**
|
||||
* The Component Class.
|
||||
*
|
||||
* @var Component
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected Component $component;
|
||||
|
||||
/**
|
||||
* The Config Class.
|
||||
*
|
||||
* @var Config
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected Config $config;
|
||||
|
||||
/**
|
||||
* The Registry Class.
|
||||
*
|
||||
* @var Registry
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected Registry $registry;
|
||||
|
||||
/**
|
||||
* The Dispenser Class.
|
||||
*
|
||||
* @var Dispenser
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected Dispenser $dispenser;
|
||||
|
||||
/**
|
||||
* The EventInterface Class.
|
||||
*
|
||||
* @var Event
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected Event $event;
|
||||
|
||||
/**
|
||||
* The Counter Class.
|
||||
*
|
||||
* @var Counter
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected Counter $counter;
|
||||
|
||||
/**
|
||||
* The Folder Class.
|
||||
*
|
||||
* @var Folder
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected Folder $folder;
|
||||
|
||||
/**
|
||||
* The File Class.
|
||||
*
|
||||
* @var File
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected File $file;
|
||||
|
||||
/**
|
||||
* The Files Class.
|
||||
*
|
||||
* @var Files
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected Files $files;
|
||||
|
||||
/**
|
||||
* The Placeholder Class.
|
||||
*
|
||||
* @var Placeholder
|
||||
* @since 5.0.0
|
||||
*/
|
||||
protected Placeholder $placeholder;
|
||||
|
||||
/**
|
||||
* The Namespace Prefix
|
||||
*
|
||||
* @var string
|
||||
* @since 5.0.0
|
||||
*/
|
||||
protected string $NamespacePrefix;
|
||||
|
||||
/**
|
||||
* The Component Namespace (in code)
|
||||
*
|
||||
* @var string
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected string $ComponentNamespace;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @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.
|
||||
* @param Placeholder $placeholder The Placeholder Class.
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function __construct(Plugin $plugin, Component $component, Config $config,
|
||||
Registry $registry, Dispenser $dispenser, Event $event,
|
||||
Counter $counter, Folder $folder, File $file,
|
||||
Files $files, Placeholder $placeholder)
|
||||
{
|
||||
$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;
|
||||
$this->placeholder = $placeholder;
|
||||
|
||||
// set some global values
|
||||
$this->NamespacePrefix = $this->placeholder->get('NamespacePrefix');
|
||||
$this->ComponentNamespace = $this->placeholder->get('ComponentNamespace');
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the Plugins files, folders, url's and config
|
||||
*
|
||||
* @return void
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function build()
|
||||
{
|
||||
if ($this->plugin->exists())
|
||||
{
|
||||
// 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))
|
||||
{
|
||||
// plugin path
|
||||
$this->pluginPath($plugin);
|
||||
|
||||
// create src folder
|
||||
$this->folder->create($plugin->folder_path . '/src');
|
||||
|
||||
// set the plugin paths
|
||||
$this->registry->set('dynamic_paths.' . $plugin->key, $plugin->folder_path);
|
||||
|
||||
// make sure there is no old build
|
||||
$this->folder->remove($plugin->folder_path);
|
||||
|
||||
// creat the main component folder
|
||||
$this->folder->create($plugin->folder_path);
|
||||
|
||||
// set main class file
|
||||
$this->setMainClassFile($plugin);
|
||||
|
||||
// set service provider class file
|
||||
$this->setServiceProviderClassFile($plugin);
|
||||
|
||||
// set main xml file
|
||||
$this->setMainXmlFile($plugin);
|
||||
|
||||
// set install script if needed
|
||||
$this->setInstallScript($plugin);
|
||||
|
||||
// set readme if found
|
||||
$this->setReadme($plugin);
|
||||
|
||||
// set fields & rules folders if needed
|
||||
if (isset($plugin->fields_rules_paths)
|
||||
&& $plugin->fields_rules_paths == 2)
|
||||
{
|
||||
// create rules folder
|
||||
$this->folder->create($plugin->folder_path . '/src/Rule');
|
||||
|
||||
// create fields folder
|
||||
$this->folder->create($plugin->folder_path . '/src/Field');
|
||||
}
|
||||
|
||||
// set forms folder if needed
|
||||
$this->setForms($plugin);
|
||||
|
||||
// set SQL stuff if needed
|
||||
$this->setSQL($plugin);
|
||||
|
||||
// create the language folder path
|
||||
$this->folder->create($plugin->folder_path . '/language');
|
||||
|
||||
// also create the lang tag folder path
|
||||
$this->folder->create(
|
||||
$plugin->folder_path . '/language/' . $this->config->get('lang_tag', 'en-GB')
|
||||
);
|
||||
|
||||
// check if this plugin has files
|
||||
$this->setFiles($plugin);
|
||||
|
||||
// check if this plugin has folders
|
||||
$this->setFolders($plugin);
|
||||
|
||||
// check if this plugin has urls
|
||||
$this->setUrls($plugin);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get the plugin xml template
|
||||
*
|
||||
* @param object $plugin The plugin object
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected function getXML(object $plugin): string
|
||||
{
|
||||
$xml = '<?xml version="1.0" encoding="utf-8"?>';
|
||||
$xml .= PHP_EOL . '<extension type="plugin" version="'
|
||||
. $this->config->joomla_versions[$this->config->joomla_version]['xml_version'] . '" group="'
|
||||
. $plugin->group . '" method="upgrade">';
|
||||
$xml .= PHP_EOL . Indent::_(1) . '<name>' . $plugin->lang_prefix
|
||||
. '</name>';
|
||||
$xml .= PHP_EOL . Indent::_(1) . '<creationDate>' . Placefix::_h('BUILDDATE') . '</creationDate>';
|
||||
$xml .= PHP_EOL . Indent::_(1) . '<author>' . Placefix::_h('AUTHOR') . '</author>';
|
||||
$xml .= PHP_EOL . Indent::_(1) . '<authorEmail>' . Placefix::_h('AUTHOREMAIL') . '</authorEmail>';
|
||||
$xml .= PHP_EOL . Indent::_(1) . '<authorUrl>' . Placefix::_h('AUTHORWEBSITE') . '</authorUrl>';
|
||||
$xml .= PHP_EOL . Indent::_(1) . '<copyright>' . Placefix::_h('COPYRIGHT') . '</copyright>';
|
||||
$xml .= PHP_EOL . Indent::_(1) . '<license>' . Placefix::_h('LICENSE') . '</license>';
|
||||
$xml .= PHP_EOL . Indent::_(1) . '<version>' . $plugin->plugin_version
|
||||
. '</version>';
|
||||
$xml .= PHP_EOL . Indent::_(1) . '<namespace path="src">' . "{$this->NamespacePrefix}\\Plugin\\{$plugin->group_namespace}\\{$plugin->namespace}"
|
||||
. '</namespace>';
|
||||
$xml .= PHP_EOL . Indent::_(1) . '<description>' . $plugin->lang_prefix
|
||||
. '_XML_DESCRIPTION</description>';
|
||||
$xml .= Placefix::_h('MAINXML');
|
||||
$xml .= PHP_EOL . '</extension>';
|
||||
|
||||
return $xml;
|
||||
}
|
||||
|
||||
/**
|
||||
* set the plugin path
|
||||
*
|
||||
* @param object $plugin The plugin object
|
||||
*
|
||||
* @return void
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected function pluginPath(object &$plugin): void
|
||||
{
|
||||
$plugin->folder_path = $this->config->get('compiler_path', JPATH_ADMINISTRATOR . '/components/com_componentbuilder/compiler') . '/'
|
||||
. $plugin->folder_name;
|
||||
}
|
||||
|
||||
/**
|
||||
* set the main class path
|
||||
*
|
||||
* @param object $plugin The plugin object
|
||||
*
|
||||
* @return void
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected function setMainClassFile(object $plugin): void
|
||||
{
|
||||
// create extension folder
|
||||
$this->folder->create($plugin->folder_path . '/src/Extension');
|
||||
|
||||
$file_details = [
|
||||
'path' => $plugin->folder_path . '/src/Extension/' . $plugin->class_file_name . '.php',
|
||||
'name' => $plugin->class_file_name . '.php',
|
||||
'zip' => 'src/Extension/' . $plugin->class_file_name . '.php'
|
||||
];
|
||||
|
||||
$this->file->write(
|
||||
$file_details['path'],
|
||||
'<?php' . PHP_EOL . '// Plugin main class template' .
|
||||
PHP_EOL . Placefix::_h('BOM') . PHP_EOL .
|
||||
"namespace {$this->NamespacePrefix}\\Plugin\\{$plugin->group_namespace}\\{$plugin->namespace}\\Extension;" .
|
||||
PHP_EOL . PHP_EOL . Placefix::_h('EXTENSION_CLASS_HEADER') .
|
||||
PHP_EOL . PHP_EOL . '// No direct access to this file' . PHP_EOL .
|
||||
"defined('_JEXEC') or die('Restricted access');" .
|
||||
PHP_EOL . PHP_EOL .
|
||||
Placefix::_h('EXTENSION_CLASS')
|
||||
);
|
||||
|
||||
$this->files->appendArray($plugin->key, $file_details);
|
||||
|
||||
// count the file created
|
||||
$this->counter->file++;
|
||||
}
|
||||
|
||||
/**
|
||||
* set the service provider path
|
||||
*
|
||||
* @param object $plugin The plugin object
|
||||
*
|
||||
* @return void
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected function setServiceProviderClassFile(object $plugin): void
|
||||
{
|
||||
// create services folder
|
||||
$this->folder->create($plugin->folder_path . '/services');
|
||||
|
||||
$file_details = [
|
||||
'path' => $plugin->folder_path . '/services/provider.php',
|
||||
'name' => 'provider.php',
|
||||
'zip' => 'services/provider.php'
|
||||
];
|
||||
|
||||
$this->file->write(
|
||||
$file_details['path'],
|
||||
'<?php' . PHP_EOL . '// Plugin services provider class template' .
|
||||
PHP_EOL . Placefix::_h('BOM') . PHP_EOL .
|
||||
PHP_EOL . '// No direct access to this file' . PHP_EOL .
|
||||
"defined('_JEXEC') or die('Restricted access');" .
|
||||
PHP_EOL . PHP_EOL .
|
||||
Placefix::_h('PROVIDER_CLASS_HEADER') .
|
||||
Placefix::_h('PROVIDER_CLASS')
|
||||
);
|
||||
|
||||
$this->files->appendArray($plugin->key, $file_details);
|
||||
|
||||
// count the file created
|
||||
$this->counter->file++;
|
||||
}
|
||||
|
||||
/**
|
||||
* set the main xml file
|
||||
*
|
||||
* @param object $plugin The plugin object
|
||||
*
|
||||
* @return void
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected function setMainXmlFile(object $plugin): void
|
||||
{
|
||||
$file_details = [
|
||||
'path' => $plugin->folder_path . '/' . $plugin->file_name . '.xml',
|
||||
'name' => $plugin->file_name . '.xml',
|
||||
'zip' => $plugin->file_name . '.xml'
|
||||
];
|
||||
|
||||
$this->file->write(
|
||||
$file_details['path'],
|
||||
$this->getXML($plugin)
|
||||
);
|
||||
|
||||
$this->files->appendArray($plugin->key, $file_details);
|
||||
|
||||
// count the file created
|
||||
$this->counter->file++;
|
||||
}
|
||||
|
||||
/**
|
||||
* set the install script file
|
||||
*
|
||||
* @param object $plugin The plugin object
|
||||
*
|
||||
* @return void
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected function setInstallScript(object $plugin): void
|
||||
{
|
||||
if ($plugin->add_install_script)
|
||||
{
|
||||
$file_details = [
|
||||
'path' => $plugin->folder_path . '/script.php',
|
||||
'name' => 'script.php',
|
||||
'zip' => 'script.php'
|
||||
];
|
||||
|
||||
$this->file->write(
|
||||
$file_details['path'],
|
||||
'<?php' . PHP_EOL . '// Script template' .
|
||||
PHP_EOL . Placefix::_h('BOM') . PHP_EOL .
|
||||
PHP_EOL . '// No direct access to this file' . PHP_EOL .
|
||||
"defined('_JEXEC') or die('Restricted access');" . PHP_EOL .
|
||||
Placefix::_h('INSTALL_CLASS')
|
||||
);
|
||||
|
||||
$this->files->appendArray($plugin->key, $file_details);
|
||||
|
||||
// count the file created
|
||||
$this->counter->file++;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* set the readme file
|
||||
*
|
||||
* @param object $plugin The plugin object
|
||||
*
|
||||
* @return void
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected function setReadme(object $plugin): void
|
||||
{
|
||||
if ($plugin->addreadme)
|
||||
{
|
||||
$file_details = [
|
||||
'path' => $plugin->folder_path . '/README.md',
|
||||
'name' => 'README.md',
|
||||
'zip' => 'README.md'
|
||||
];
|
||||
|
||||
$this->file->write($file_details['path'], $plugin->readme);
|
||||
$this->files->appendArray($plugin->key, $file_details);
|
||||
|
||||
// count the file created
|
||||
$this->counter->file++;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* set the form files and folders
|
||||
*
|
||||
* @param object $plugin The plugin object
|
||||
*
|
||||
* @return void
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected function setForms(object $plugin): void
|
||||
{
|
||||
if (isset($plugin->form_files)
|
||||
&& ArrayHelper::check($plugin->form_files))
|
||||
{
|
||||
// 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 version="1.0" encoding="utf-8"?>';
|
||||
$xml .= PHP_EOL . '<!--' . Line::_(__Line__, __Class__)
|
||||
. ' default paths of ' . $file
|
||||
. ' form points to ' . $this->config->component_code_name
|
||||
. ' -->';
|
||||
|
||||
// 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 . '<form';
|
||||
|
||||
$xml .= PHP_EOL . Indent::_(1)
|
||||
. 'addruleprefix="' . $this->NamespacePrefix
|
||||
. '\Component\\' . $this->ComponentNamespace
|
||||
. '\Administrator\Rule"';
|
||||
$xml .= PHP_EOL . Indent::_(1)
|
||||
.'addfieldprefix="' . $this->NamespacePrefix
|
||||
. '\Component\\' . $this->ComponentNamespace
|
||||
. '\Administrator\Field"';
|
||||
|
||||
$xml .= PHP_EOL . '>';
|
||||
}
|
||||
else
|
||||
{
|
||||
$xml .= PHP_EOL . '<form>';
|
||||
}
|
||||
|
||||
// add the fields
|
||||
foreach ($fields as $field_name => $fieldsets)
|
||||
{
|
||||
// check if we have an double fields naming set
|
||||
$field_name_inner = '';
|
||||
$field_name_outer = $field_name;
|
||||
if (strpos((string)$field_name, '.') !== false)
|
||||
{
|
||||
$field_names = explode('.', (string)$field_name);
|
||||
if (count((array)$field_names) == 2)
|
||||
{
|
||||
$field_name_outer = $field_names[0];
|
||||
$field_name_inner = $field_names[1];
|
||||
}
|
||||
}
|
||||
$xml .= PHP_EOL . Indent::_(1)
|
||||
. '<fields name="' . $field_name_outer
|
||||
. '">';
|
||||
foreach ($fieldsets as $fieldset => $field)
|
||||
{
|
||||
// default to the field set name
|
||||
$label = $fieldset;
|
||||
if (isset($plugin->fieldsets_label[$file . $field_name . $fieldset]))
|
||||
{
|
||||
$label = $plugin->fieldsets_label[$file . $field_name . $fieldset];
|
||||
}
|
||||
|
||||
// add path to plugin rules and custom fields
|
||||
if (isset($plugin->fieldsets_paths[$file . $field_name . $fieldset])
|
||||
&& ($plugin->fieldsets_paths[$file . $field_name . $fieldset] == 2
|
||||
|| $plugin->fieldsets_paths[$file . $field_name . $fieldset] == 3))
|
||||
{
|
||||
if (!isset($plugin->add_rule_path[$file . $field_name . $fieldset]))
|
||||
{
|
||||
$plugin->add_rule_path[$file . $field_name . $fieldset] =
|
||||
"{$this->NamespacePrefix}\\Plugin\\{$plugin->group_namespace}\\{$plugin->namespace}\\Rule";
|
||||
}
|
||||
|
||||
if (!isset($plugin->add_field_path[$file . $field_name . $fieldset]))
|
||||
{
|
||||
$plugin->add_field_path[$file . $field_name . $fieldset] =
|
||||
"{$this->NamespacePrefix}\\Plugin\\{$plugin->group_namespace}\\{$plugin->namespace}\\Field";
|
||||
}
|
||||
}
|
||||
|
||||
// add path to plugin rules and custom fields
|
||||
if (isset($plugin->add_rule_path[$file . $field_name . $fieldset])
|
||||
|| isset($plugin->add_field_path[$file . $field_name . $fieldset]))
|
||||
{
|
||||
$xml .= PHP_EOL . Indent::_(1) . '<!--'
|
||||
. Line::_(__Line__, __Class__) . ' default paths of '
|
||||
. $fieldset . ' fieldset points to the plugin -->';
|
||||
|
||||
$xml .= PHP_EOL . Indent::_(1) . '<fieldset name="'
|
||||
. $fieldset . '" label="' . $label . '"';
|
||||
|
||||
if (isset($plugin->add_rule_path[$file . $field_name . $fieldset]))
|
||||
{
|
||||
$xml .= PHP_EOL . Indent::_(2)
|
||||
. 'addruleprefix="' . $plugin->add_rule_path[$file . $field_name . $fieldset] . '"';
|
||||
}
|
||||
|
||||
if (isset($plugin->add_field_path[$file . $field_name . $fieldset]))
|
||||
{
|
||||
$xml .= PHP_EOL . Indent::_(2)
|
||||
. 'addfieldprefix="' . $plugin->add_field_path[$file . $field_name . $fieldset] . '"';
|
||||
}
|
||||
|
||||
$xml .= PHP_EOL . Indent::_(1) . '>';
|
||||
}
|
||||
else
|
||||
{
|
||||
$xml .= PHP_EOL . Indent::_(1) . '<fieldset name="'
|
||||
. $fieldset . '" label="' . $label . '">';
|
||||
}
|
||||
|
||||
// check if we have an inner field set
|
||||
if (StringHelper::check($field_name_inner))
|
||||
{
|
||||
$xml .= PHP_EOL . Indent::_(1)
|
||||
. '<fields name="'
|
||||
. $field_name_inner . '">';
|
||||
}
|
||||
|
||||
// add the placeholder of the fields
|
||||
$xml .= Placefix::_h('FIELDSET_' . $file
|
||||
. $field_name . $fieldset);
|
||||
|
||||
// check if we have an inner field set
|
||||
if (StringHelper::check($field_name_inner))
|
||||
{
|
||||
$xml .= PHP_EOL . Indent::_(1)
|
||||
. '</fields>';
|
||||
}
|
||||
$xml .= PHP_EOL . Indent::_(1)
|
||||
. '</fieldset>';
|
||||
}
|
||||
$xml .= PHP_EOL . Indent::_(1) . '</fields>';
|
||||
}
|
||||
$xml .= PHP_EOL . '</form>';
|
||||
|
||||
// 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++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
@@ -0,0 +1,240 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Componentbuilder\Compiler\Model\JoomlaSix;
|
||||
|
||||
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Config;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Builder\CustomTabs as BuilderCustomTabs;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Language;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Placeholder;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Customcode;
|
||||
use VDM\Joomla\Utilities\JsonHelper;
|
||||
use VDM\Joomla\Utilities\ArrayHelper;
|
||||
use VDM\Joomla\Utilities\StringHelper;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Model\CustomtabsInterface;
|
||||
|
||||
|
||||
/**
|
||||
* Joomla 6 Model Custom Tabs Class
|
||||
*
|
||||
* @since 5.1.2
|
||||
*/
|
||||
final class Customtabs implements CustomtabsInterface
|
||||
{
|
||||
/**
|
||||
* The Config Class.
|
||||
*
|
||||
* @var Config
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected Config $config;
|
||||
|
||||
/**
|
||||
* The CustomTabs Class.
|
||||
*
|
||||
* @var BuilderCustomTabs
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected BuilderCustomTabs $buildercustomtabs;
|
||||
|
||||
/**
|
||||
* The Language Class.
|
||||
*
|
||||
* @var Language
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected Language $language;
|
||||
|
||||
/**
|
||||
* The Placeholder Class.
|
||||
*
|
||||
* @var Placeholder
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected Placeholder $placeholder;
|
||||
|
||||
/**
|
||||
* The Customcode Class.
|
||||
*
|
||||
* @var Customcode
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected Customcode $customcode;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param Config $config The Config Class.
|
||||
* @param BuilderCustomTabs $buildercustomtabs The CustomTabs Class.
|
||||
* @param Language $language The Language Class.
|
||||
* @param Placeholder $placeholder The Placeholder Class.
|
||||
* @param Customcode $customcode The Customcode Class.
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function __construct(Config $config, BuilderCustomTabs $buildercustomtabs, Language $language, Placeholder $placeholder, Customcode $customcode)
|
||||
{
|
||||
$this->config = $config;
|
||||
$this->buildercustomtabs = $buildercustomtabs;
|
||||
$this->language = $language;
|
||||
$this->placeholder = $placeholder;
|
||||
$this->customcode = $customcode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set custom tabs
|
||||
*
|
||||
* @param object $item The view data
|
||||
*
|
||||
* @return void
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function set(object &$item)
|
||||
{
|
||||
$item->customtabs = (isset($item->customtabs)
|
||||
&& JsonHelper::check($item->customtabs))
|
||||
? json_decode((string) $item->customtabs, true) : null;
|
||||
|
||||
if (ArrayHelper::check($item->customtabs))
|
||||
{
|
||||
// get the name
|
||||
$name = $item->name_single_code;
|
||||
|
||||
// setup custom tabs to global data sets
|
||||
$this->buildercustomtabs->set($name,
|
||||
array_map(
|
||||
function ($tab) use (&$name) {
|
||||
|
||||
// set the view name
|
||||
$tab['view'] = $name;
|
||||
|
||||
// load the dynamic data
|
||||
$tab['html'] = $this->placeholder->update_(
|
||||
$this->customcode->update($tab['html'])
|
||||
);
|
||||
|
||||
// set the tab name
|
||||
$tab['name'] = (isset($tab['name'])
|
||||
&& StringHelper::check(
|
||||
$tab['name']
|
||||
)) ? $tab['name'] : 'Tab';
|
||||
|
||||
// set lang
|
||||
$tab['lang'] = $this->config->lang_prefix . '_'
|
||||
. StringHelper::safe(
|
||||
$tab['view'], 'U'
|
||||
) . '_' . StringHelper::safe(
|
||||
$tab['name'], 'U'
|
||||
);
|
||||
$this->language->set(
|
||||
'both', $tab['lang'], $tab['name']
|
||||
);
|
||||
|
||||
// set code name
|
||||
$tab['code'] = StringHelper::safe(
|
||||
$tab['name']
|
||||
);
|
||||
|
||||
// check if the permissions for the tab should be added
|
||||
$_tab = '';
|
||||
if (isset($tab['permission'])
|
||||
&& $tab['permission'] == 1)
|
||||
{
|
||||
$_tab = Indent::_(1);
|
||||
}
|
||||
|
||||
// check if the php of the tab is set, if not load it now
|
||||
if (strpos((string) $tab['html'], 'uitab.addTab') === false
|
||||
&& strpos((string) $tab['html'], 'uitab.endTab')
|
||||
=== false)
|
||||
{
|
||||
// add the tab
|
||||
$tmp = PHP_EOL . $_tab . Indent::_(1)
|
||||
. "<?php echo Html::_('uitab.addTab', '"
|
||||
. $tab['view'] . "Tab', '" . $tab['code']
|
||||
. "', JT" . "ext::_('" . $tab['lang']
|
||||
. "', true)); ?>";
|
||||
$tmp .= PHP_EOL . $_tab . Indent::_(2)
|
||||
. '<div class="row">';
|
||||
$tmp .= PHP_EOL . $_tab . Indent::_(3)
|
||||
. '<div class="col-md-12">';
|
||||
$tmp .= PHP_EOL . $_tab . Indent::_(4) . implode(
|
||||
PHP_EOL . $_tab . Indent::_(4),
|
||||
(array) explode(PHP_EOL, trim((string) $tab['html']))
|
||||
);
|
||||
$tmp .= PHP_EOL . $_tab . Indent::_(3) . '</div>';
|
||||
$tmp .= PHP_EOL . $_tab . Indent::_(2) . '</div>';
|
||||
$tmp .= PHP_EOL . $_tab . Indent::_(1)
|
||||
. "<?php echo Html::_('uitab.endTab'); ?>";
|
||||
|
||||
// update html
|
||||
$tab['html'] = $tmp;
|
||||
}
|
||||
else
|
||||
{
|
||||
$tab['html'] = PHP_EOL . $_tab . Indent::_(1)
|
||||
. implode(
|
||||
PHP_EOL . $_tab . Indent::_(1),
|
||||
(array) explode(PHP_EOL, trim((string) $tab['html']))
|
||||
);
|
||||
}
|
||||
|
||||
// add the permissions if needed
|
||||
if (isset($tab['permission'])
|
||||
&& $tab['permission'] == 1)
|
||||
{
|
||||
$tmp = PHP_EOL . Indent::_(1)
|
||||
. "<?php if (\$this->canDo->get('"
|
||||
. $tab['view'] . "." . $tab['code']
|
||||
. ".viewtab')) : ?>";
|
||||
$tmp .= $tab['html'];
|
||||
$tmp .= PHP_EOL . Indent::_(1) . "<?php endif; ?>";
|
||||
// update html
|
||||
$tab['html'] = $tmp;
|
||||
// set lang for permissions
|
||||
$tab['lang_permission'] = $tab['lang']
|
||||
. '_TAB_PERMISSION';
|
||||
$tab['lang_permission_desc'] = $tab['lang']
|
||||
. '_TAB_PERMISSION_DESC';
|
||||
$tab['lang_permission_title']
|
||||
= $this->placeholder->get('Views') . ' View '
|
||||
. $tab['name'] . ' Tab';
|
||||
$this->language->set(
|
||||
'both', $tab['lang_permission'],
|
||||
$tab['lang_permission_title']
|
||||
);
|
||||
$this->language->set(
|
||||
'both', $tab['lang_permission_desc'],
|
||||
'Allow the users in this group to view '
|
||||
. $tab['name'] . ' Tab of '
|
||||
. $this->placeholder->get('views')
|
||||
);
|
||||
// set the sort key
|
||||
$tab['sortKey']
|
||||
= StringHelper::safe(
|
||||
$tab['lang_permission_title']
|
||||
);
|
||||
}
|
||||
|
||||
// return tab
|
||||
return $tab;
|
||||
|
||||
}, array_values($item->customtabs)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
unset($item->customtabs);
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
@@ -15,6 +15,7 @@ namespace VDM\Joomla\Componentbuilder\Compiler\Service;
|
||||
use Joomla\DI\Container;
|
||||
use Joomla\DI\ServiceProviderInterface;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Architecture\ComHelperClass\CreateUserInterface;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaSix\ComHelperClass\CreateUser as J6CreateUser;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaFive\ComHelperClass\CreateUser as J5CreateUser;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaFour\ComHelperClass\CreateUser as J4CreateUser;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaThree\ComHelperClass\CreateUser as J3CreateUser;
|
||||
@@ -48,6 +49,9 @@ class ArchitectureComHelperClass implements ServiceProviderInterface
|
||||
$container->alias(CreateUserInterface::class, 'Architecture.ComHelperClass.CreateUser')
|
||||
->share('Architecture.ComHelperClass.CreateUser', [$this, 'getCreateUser'], true);
|
||||
|
||||
$container->alias(J6CreateUser::class, 'Architecture.ComHelperClass.J6.CreateUser')
|
||||
->share('Architecture.ComHelperClass.J6.CreateUser', [$this, 'getJ6CreateUser'], true);
|
||||
|
||||
$container->alias(J5CreateUser::class, 'Architecture.ComHelperClass.J5.CreateUser')
|
||||
->share('Architecture.ComHelperClass.J5.CreateUser', [$this, 'getJ5CreateUser'], true);
|
||||
|
||||
@@ -76,6 +80,19 @@ class ArchitectureComHelperClass implements ServiceProviderInterface
|
||||
return $container->get('Architecture.ComHelperClass.J' . $this->targetVersion . '.CreateUser');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The CreateUser Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return J6CreateUser
|
||||
* @since 5.1.2
|
||||
*/
|
||||
public function getJ6CreateUser(Container $container): J6CreateUser
|
||||
{
|
||||
return new J6CreateUser();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The CreateUser Class.
|
||||
*
|
||||
|
@@ -15,14 +15,17 @@ namespace VDM\Joomla\Componentbuilder\Compiler\Service;
|
||||
use Joomla\DI\Container;
|
||||
use Joomla\DI\ServiceProviderInterface;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Architecture\Controller\AllowAddInterface;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaSix\Controller\AllowAdd as J6ControllerAllowAdd;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaFive\Controller\AllowAdd as J5ControllerAllowAdd;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaFour\Controller\AllowAdd as J4ControllerAllowAdd;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaThree\Controller\AllowAdd as J3ControllerAllowAdd;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Architecture\Controller\AllowEditInterface;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaSix\Controller\AllowEdit as J6ControllerAllowEdit;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaFive\Controller\AllowEdit as J5ControllerAllowEdit;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaFour\Controller\AllowEdit as J4ControllerAllowEdit;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaThree\Controller\AllowEdit as J3ControllerAllowEdit;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Architecture\Controller\AllowEditViewsInterface;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaSix\Controller\AllowEditViews as J6ControllerAllowEditViews;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaFive\Controller\AllowEditViews as J5ControllerAllowEditViews;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaFour\Controller\AllowEditViews as J4ControllerAllowEditViews;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaThree\Controller\AllowEditViews as J3ControllerAllowEditViews;
|
||||
@@ -56,6 +59,9 @@ class ArchitectureController implements ServiceProviderInterface
|
||||
$container->alias(AllowAddInterface::class, 'Architecture.Controller.AllowAdd')
|
||||
->share('Architecture.Controller.AllowAdd', [$this, 'getAllowAdd'], true);
|
||||
|
||||
$container->alias(J6ControllerAllowAdd::class, 'Architecture.Controller.J6.AllowAdd')
|
||||
->share('Architecture.Controller.J6.AllowAdd', [$this, 'getJ6ControllerAllowAdd'], true);
|
||||
|
||||
$container->alias(J5ControllerAllowAdd::class, 'Architecture.Controller.J5.AllowAdd')
|
||||
->share('Architecture.Controller.J5.AllowAdd', [$this, 'getJ5ControllerAllowAdd'], true);
|
||||
|
||||
@@ -68,6 +74,9 @@ class ArchitectureController implements ServiceProviderInterface
|
||||
$container->alias(AllowEditInterface::class, 'Architecture.Controller.AllowEdit')
|
||||
->share('Architecture.Controller.AllowEdit', [$this, 'getAllowEdit'], true);
|
||||
|
||||
$container->alias(J6ControllerAllowEdit::class, 'Architecture.Controller.J6.AllowEdit')
|
||||
->share('Architecture.Controller.J6.AllowEdit', [$this, 'getJ6ControllerAllowEdit'], true);
|
||||
|
||||
$container->alias(J5ControllerAllowEdit::class, 'Architecture.Controller.J5.AllowEdit')
|
||||
->share('Architecture.Controller.J5.AllowEdit', [$this, 'getJ5ControllerAllowEdit'], true);
|
||||
|
||||
@@ -80,6 +89,9 @@ class ArchitectureController implements ServiceProviderInterface
|
||||
$container->alias(AllowEditViewsInterface::class, 'Architecture.Controller.AllowEditViews')
|
||||
->share('Architecture.Controller.AllowEditViews', [$this, 'getAllowEditViews'], true);
|
||||
|
||||
$container->alias(J6ControllerAllowEditViews::class, 'Architecture.Controller.J6.AllowEditViews')
|
||||
->share('Architecture.Controller.J6.AllowEditViews', [$this, 'getJ6ControllerAllowEditViews'], true);
|
||||
|
||||
$container->alias(J5ControllerAllowEditViews::class, 'Architecture.Controller.J5.AllowEditViews')
|
||||
->share('Architecture.Controller.J5.AllowEditViews', [$this, 'getJ5ControllerAllowEditViews'], true);
|
||||
|
||||
@@ -108,6 +120,23 @@ class ArchitectureController implements ServiceProviderInterface
|
||||
return $container->get('Architecture.Controller.J' . $this->targetVersion . '.AllowAdd');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The AllowAdd Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return J6ControllerAllowAdd
|
||||
* @since 5.1.2
|
||||
*/
|
||||
public function getJ6ControllerAllowAdd(Container $container): J6ControllerAllowAdd
|
||||
{
|
||||
return new J6ControllerAllowAdd(
|
||||
$container->get('Config'),
|
||||
$container->get('Compiler.Creator.Permission'),
|
||||
$container->get('Customcode.Dispenser')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The AllowAdd Class.
|
||||
*
|
||||
@@ -177,13 +206,32 @@ class ArchitectureController implements ServiceProviderInterface
|
||||
return $container->get('Architecture.Controller.J' . $this->targetVersion . '.AllowEdit');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The AllowEdit Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return J6ControllerAllowEdit
|
||||
* @since 5.1.2
|
||||
*/
|
||||
public function getJ6ControllerAllowEdit(Container $container): J6ControllerAllowEdit
|
||||
{
|
||||
return new J6ControllerAllowEdit(
|
||||
$container->get('Config'),
|
||||
$container->get('Compiler.Creator.Permission'),
|
||||
$container->get('Customcode.Dispenser'),
|
||||
$container->get('Compiler.Builder.Category'),
|
||||
$container->get('Compiler.Builder.Category.Other.Name')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The AllowEdit Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return J5ControllerAllowEdit
|
||||
* @since 3.2.0
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function getJ5ControllerAllowEdit(Container $container): J5ControllerAllowEdit
|
||||
{
|
||||
@@ -202,7 +250,7 @@ class ArchitectureController implements ServiceProviderInterface
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return J4ControllerAllowEdit
|
||||
* @since 3.2.0
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function getJ4ControllerAllowEdit(Container $container): J4ControllerAllowEdit
|
||||
{
|
||||
@@ -252,6 +300,24 @@ class ArchitectureController implements ServiceProviderInterface
|
||||
return $container->get('Architecture.Controller.J' . $this->targetVersion . '.AllowEditViews');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The AllowEditViews Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return J6ControllerAllowEdit
|
||||
* @since 5.1.2
|
||||
*/
|
||||
public function getJ6ControllerAllowEditViews(Container $container): J6ControllerAllowEditViews
|
||||
{
|
||||
return new J6ControllerAllowEditViews(
|
||||
$container->get('Compiler.Creator.Permission'),
|
||||
$container->get('Customcode.Dispenser'),
|
||||
$container->get('Compiler.Builder.Category'),
|
||||
$container->get('Compiler.Builder.Category.Other.Name')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The AllowEditViews Class.
|
||||
*
|
||||
|
@@ -15,14 +15,17 @@ namespace VDM\Joomla\Componentbuilder\Compiler\Service;
|
||||
use Joomla\DI\Container;
|
||||
use Joomla\DI\ServiceProviderInterface;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Architecture\Model\CanDeleteInterface;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaSix\Model\CanDelete as J6ModelCanDelete;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaFive\Model\CanDelete as J5ModelCanDelete;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaFour\Model\CanDelete as J4ModelCanDelete;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaThree\Model\CanDelete as J3ModelCanDelete;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Architecture\Model\CanEditStateInterface;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaSix\Model\CanEditState as J6ModelCanEditState;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaFive\Model\CanEditState as J5ModelCanEditState;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaFour\Model\CanEditState as J4ModelCanEditState;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaThree\Model\CanEditState as J3ModelCanEditState;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Architecture\Model\CheckInNowInterface;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaSix\Model\CheckInNow as J6CheckInNow;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaFive\Model\CheckInNow as J5CheckInNow;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaFour\Model\CheckInNow as J4CheckInNow;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaThree\Model\CheckInNow as J3CheckInNow;
|
||||
@@ -62,6 +65,9 @@ class ArchitectureModel implements ServiceProviderInterface
|
||||
$container->alias(J5ModelCanDelete::class, 'Architecture.Model.J5.CanDelete')
|
||||
->share('Architecture.Model.J5.CanDelete', [$this, 'getJ5ModelCanDelete'], true);
|
||||
|
||||
$container->alias(J6ModelCanDelete::class, 'Architecture.Model.J6.CanDelete')
|
||||
->share('Architecture.Model.J6.CanDelete', [$this, 'getJ6ModelCanDelete'], true);
|
||||
|
||||
$container->alias(CanDeleteInterface::class, 'Architecture.Model.CanDelete')
|
||||
->share('Architecture.Model.CanDelete', [$this, 'getModelCanDelete'], true);
|
||||
|
||||
@@ -74,12 +80,18 @@ class ArchitectureModel implements ServiceProviderInterface
|
||||
$container->alias(J5ModelCanEditState::class, 'Architecture.Model.J5.CanEditState')
|
||||
->share('Architecture.Model.J5.CanEditState', [$this, 'getJ5ModelCanEditState'], true);
|
||||
|
||||
$container->alias(J6ModelCanEditState::class, 'Architecture.Model.J6.CanEditState')
|
||||
->share('Architecture.Model.J6.CanEditState', [$this, 'getJ6ModelCanEditState'], true);
|
||||
|
||||
$container->alias(CanEditStateInterface::class, 'Architecture.Model.CanEditState')
|
||||
->share('Architecture.Model.CanEditState', [$this, 'getModelCanEditState'], true);
|
||||
|
||||
$container->alias(CheckInNowInterface::class, 'Architecture.Model.CheckInNow')
|
||||
->share('Architecture.Model.CheckInNow', [$this, 'getCheckInNow'], true);
|
||||
|
||||
$container->alias(J6CheckInNow::class, 'Architecture.Model.J6.CheckInNow')
|
||||
->share('Architecture.Model.J6.CheckInNow', [$this, 'getJ6CheckInNow'], true);
|
||||
|
||||
$container->alias(J5CheckInNow::class, 'Architecture.Model.J5.CheckInNow')
|
||||
->share('Architecture.Model.J5.CheckInNow', [$this, 'getJ5CheckInNow'], true);
|
||||
|
||||
@@ -108,6 +120,22 @@ class ArchitectureModel implements ServiceProviderInterface
|
||||
return $container->get('Architecture.Model.J' . $this->targetVersion . '.CanDelete');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The Model CanDelete Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return J6ModelCanDelete
|
||||
* @since 5.1.2
|
||||
*/
|
||||
public function getJ6ModelCanDelete(Container $container): J6ModelCanDelete
|
||||
{
|
||||
return new J6ModelCanDelete(
|
||||
$container->get('Config'),
|
||||
$container->get('Compiler.Creator.Permission')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The Model CanDelete Class.
|
||||
*
|
||||
@@ -174,6 +202,22 @@ class ArchitectureModel implements ServiceProviderInterface
|
||||
return $container->get('Architecture.Model.J' . $this->targetVersion . '.CanEditState');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The Model Can Edit State Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return J6ModelCanEditState
|
||||
* @since 5.1.2
|
||||
*/
|
||||
public function getJ6ModelCanEditState(Container $container): J6ModelCanEditState
|
||||
{
|
||||
return new J6ModelCanEditState(
|
||||
$container->get('Config'),
|
||||
$container->get('Compiler.Creator.Permission')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The Model Can Edit State Class.
|
||||
*
|
||||
@@ -240,6 +284,20 @@ class ArchitectureModel implements ServiceProviderInterface
|
||||
return $container->get('Architecture.Model.J' . $this->targetVersion . '.CheckInNow');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The Model CheckInNow Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return J6CheckInNow
|
||||
* @since 5.1.2
|
||||
*/
|
||||
public function getJ6CheckInNow(Container $container): J6CheckInNow
|
||||
{
|
||||
return new J6CheckInNow();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get The Model CheckInNow Class.
|
||||
*
|
||||
|
@@ -15,26 +15,32 @@ namespace VDM\Joomla\Componentbuilder\Compiler\Service;
|
||||
use Joomla\DI\Container;
|
||||
use Joomla\DI\ServiceProviderInterface;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Architecture\Module\LibraryInterface as Library;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaSix\Module\Library as J6Library;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaFive\Module\Library as J5Library;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaFour\Module\Library as J4Library;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaThree\Module\Library as J3Library;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Architecture\Module\TemplateInterface as Template;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaSix\Module\Template as J6Template;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaFive\Module\Template as J5Template;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaFour\Module\Template as J4Template;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaThree\Module\Template as J3Template;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Architecture\Module\HelperInterface as Helper;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaSix\Module\Helper as J6Helper;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaFive\Module\Helper as J5Helper;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaFour\Module\Helper as J4Helper;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaThree\Module\Helper as J3Helper;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Architecture\Module\DispatcherInterface as Dispatcher;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaSix\Module\Dispatcher as J6Dispatcher;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaFive\Module\Dispatcher as J5Dispatcher;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaFour\Module\Dispatcher as J4Dispatcher;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaThree\Module\Dispatcher as J3Dispatcher;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Architecture\Module\ProviderInterface as Provider;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaSix\Module\Provider as J6Provider;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaFive\Module\Provider as J5Provider;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaFour\Module\Provider as J4Provider;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaThree\Module\Provider as J3Provider;
|
||||
use VDM\Joomla\Componentbuilder\Interfaces\Architecture\Module\MainXMLInterface as MainXML;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaSix\Module\MainXML as J6MainXML;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaFive\Module\MainXML as J5MainXML;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaFour\Module\MainXML as J4MainXML;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaThree\Module\MainXML as J3MainXML;
|
||||
@@ -68,6 +74,9 @@ class ArchitectureModule implements ServiceProviderInterface
|
||||
$container->alias(Library::class, 'Architecture.Module.Library')
|
||||
->share('Architecture.Module.Library', [$this, 'getLibrary'], true);
|
||||
|
||||
$container->alias(J6Library::class, 'Architecture.Module.J6.Library')
|
||||
->share('Architecture.Module.J6.Library', [$this, 'getJ6Library'], true);
|
||||
|
||||
$container->alias(J5Library::class, 'Architecture.Module.J5.Library')
|
||||
->share('Architecture.Module.J5.Library', [$this, 'getJ5Library'], true);
|
||||
|
||||
@@ -80,6 +89,9 @@ class ArchitectureModule implements ServiceProviderInterface
|
||||
$container->alias(Template::class, 'Architecture.Module.Template')
|
||||
->share('Architecture.Module.Template', [$this, 'getTemplate'], true);
|
||||
|
||||
$container->alias(J6Template::class, 'Architecture.Module.J6.Template')
|
||||
->share('Architecture.Module.J6.Template', [$this, 'getJ6Template'], true);
|
||||
|
||||
$container->alias(J5Template::class, 'Architecture.Module.J5.Template')
|
||||
->share('Architecture.Module.J5.Template', [$this, 'getJ5Template'], true);
|
||||
|
||||
@@ -92,6 +104,9 @@ class ArchitectureModule implements ServiceProviderInterface
|
||||
$container->alias(Helper::class, 'Architecture.Module.Helper')
|
||||
->share('Architecture.Module.Helper', [$this, 'getHelper'], true);
|
||||
|
||||
$container->alias(J6Helper::class, 'Architecture.Module.J6.Helper')
|
||||
->share('Architecture.Module.J6.Helper', [$this, 'getJ6Helper'], true);
|
||||
|
||||
$container->alias(J5Helper::class, 'Architecture.Module.J5.Helper')
|
||||
->share('Architecture.Module.J5.Helper', [$this, 'getJ5Helper'], true);
|
||||
|
||||
@@ -104,6 +119,9 @@ class ArchitectureModule implements ServiceProviderInterface
|
||||
$container->alias(Dispatcher::class, 'Architecture.Module.Dispatcher')
|
||||
->share('Architecture.Module.Dispatcher', [$this, 'getDispatcher'], true);
|
||||
|
||||
$container->alias(J6Dispatcher::class, 'Architecture.Module.J6.Dispatcher')
|
||||
->share('Architecture.Module.J6.Dispatcher', [$this, 'getJ6Dispatcher'], true);
|
||||
|
||||
$container->alias(J5Dispatcher::class, 'Architecture.Module.J5.Dispatcher')
|
||||
->share('Architecture.Module.J5.Dispatcher', [$this, 'getJ5Dispatcher'], true);
|
||||
|
||||
@@ -116,6 +134,9 @@ class ArchitectureModule implements ServiceProviderInterface
|
||||
$container->alias(Provider::class, 'Architecture.Module.Provider')
|
||||
->share('Architecture.Module.Provider', [$this, 'getProvider'], true);
|
||||
|
||||
$container->alias(J6Provider::class, 'Architecture.Module.J6.Provider')
|
||||
->share('Architecture.Module.J6.Provider', [$this, 'getJ6Provider'], true);
|
||||
|
||||
$container->alias(J5Provider::class, 'Architecture.Module.J5.Provider')
|
||||
->share('Architecture.Module.J5.Provider', [$this, 'getJ5Provider'], true);
|
||||
|
||||
@@ -128,6 +149,9 @@ class ArchitectureModule implements ServiceProviderInterface
|
||||
$container->alias(MainXML::class, 'Architecture.Module.MainXML')
|
||||
->share('Architecture.Module.MainXML', [$this, 'getMainXML'], true);
|
||||
|
||||
$container->alias(J6MainXML::class, 'Architecture.Module.J6.MainXML')
|
||||
->share('Architecture.Module.J6.MainXML', [$this, 'getJ6MainXML'], true);
|
||||
|
||||
$container->alias(J5MainXML::class, 'Architecture.Module.J5.MainXML')
|
||||
->share('Architecture.Module.J5.MainXML', [$this, 'getJ5MainXML'], true);
|
||||
|
||||
@@ -156,6 +180,25 @@ class ArchitectureModule implements ServiceProviderInterface
|
||||
return $container->get('Architecture.Module.J' . $this->targetVersion . '.Library');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The Library Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return J6Library
|
||||
* @since 5.1.2
|
||||
*/
|
||||
public function getJ6Library(Container $container): J6Library
|
||||
{
|
||||
return new J6Library(
|
||||
$container->get('Compiler.Builder.Library.Manager'),
|
||||
$container->get('Library.Document'),
|
||||
$container->get('Registry'),
|
||||
$container->get('Placeholder'),
|
||||
$container->get('Compiler.Builder.Content.One')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The Library Class.
|
||||
*
|
||||
@@ -231,6 +274,27 @@ class ArchitectureModule implements ServiceProviderInterface
|
||||
return $container->get('Architecture.Module.J' . $this->targetVersion . '.Template');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The Template Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return J6Template
|
||||
* @since 5.1.2
|
||||
*/
|
||||
public function getJ6Template(Container $container): J6Template
|
||||
{
|
||||
return new J6Template(
|
||||
$container->get('Config'),
|
||||
$container->get('Header'),
|
||||
$container->get('Customcode.Dispenser'),
|
||||
$container->get('Compiler.Builder.Template.Data'),
|
||||
$container->get('Placeholder'),
|
||||
$container->get('Compiler.Builder.Content.One'),
|
||||
$container->get('Compiler.Builder.Content.Multi')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The Template Class.
|
||||
*
|
||||
@@ -311,6 +375,22 @@ class ArchitectureModule implements ServiceProviderInterface
|
||||
return $container->get('Architecture.Module.J' . $this->targetVersion . '.Helper');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The Helper Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return J6Helper
|
||||
* @since 5.1.2
|
||||
*/
|
||||
public function getJ6Helper(Container $container): J6Helper
|
||||
{
|
||||
return new J6Helper(
|
||||
$container->get('Placeholder'),
|
||||
$container->get('Compiler.Builder.Content.One')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The Helper Class.
|
||||
*
|
||||
@@ -377,6 +457,23 @@ class ArchitectureModule implements ServiceProviderInterface
|
||||
return $container->get('Architecture.Module.J' . $this->targetVersion . '.Dispatcher');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The Dispatcher Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return J6Dispatcher
|
||||
* @since 5.1.2
|
||||
*/
|
||||
public function getJ6Dispatcher(Container $container): J6Dispatcher
|
||||
{
|
||||
return new J6Dispatcher(
|
||||
$container->get('Placeholder'),
|
||||
$container->get('Compiler.Builder.Content.One'),
|
||||
$container->get('Architecture.Module.Library')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The Dispatcher Class.
|
||||
*
|
||||
@@ -446,6 +543,22 @@ class ArchitectureModule implements ServiceProviderInterface
|
||||
return $container->get('Architecture.Module.J' . $this->targetVersion . '.Provider');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The Provider Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return J6Provider
|
||||
* @since 5.1.2
|
||||
*/
|
||||
public function getJ6Provider(Container $container): J6Provider
|
||||
{
|
||||
return new J6Provider(
|
||||
$container->get('Placeholder'),
|
||||
$container->get('Compiler.Builder.Content.One')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The Provider Class.
|
||||
*
|
||||
@@ -512,6 +625,33 @@ class ArchitectureModule implements ServiceProviderInterface
|
||||
return $container->get('Architecture.Module.J' . $this->targetVersion . '.MainXML');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The MainXML Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return J6MainXML
|
||||
* @since 5.1.2
|
||||
*/
|
||||
public function getJ6MainXML(Container $container): J6MainXML
|
||||
{
|
||||
return new J6MainXML(
|
||||
$container->get('Config'),
|
||||
$container->get('Language'),
|
||||
$container->get('Language.Set'),
|
||||
$container->get('Language.Purge'),
|
||||
$container->get('Language.Translation'),
|
||||
$container->get('Language.Multilingual'),
|
||||
$container->get('Event'),
|
||||
$container->get('Compiler.Creator.Fieldset.Extension'),
|
||||
$container->get('Compiler.Builder.Content.One'),
|
||||
$container->get('Compiler.Builder.Languages'),
|
||||
$container->get('Compiler.Builder.Multilingual'),
|
||||
$container->get('Utilities.Counter'),
|
||||
$container->get('Utilities.File')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The MainXML Class.
|
||||
*
|
||||
|
@@ -15,14 +15,17 @@ namespace VDM\Joomla\Componentbuilder\Compiler\Service;
|
||||
use Joomla\DI\Container;
|
||||
use Joomla\DI\ServiceProviderInterface;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Architecture\Plugin\ExtensionInterface as Extension;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaSix\Plugin\Extension as J6Extension;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaFive\Plugin\Extension as J5Extension;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaFour\Plugin\Extension as J4Extension;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaThree\Plugin\Extension as J3Extension;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Architecture\Plugin\ProviderInterface as Provider;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaSix\Plugin\Provider as J6Provider;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaFive\Plugin\Provider as J5Provider;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaFour\Plugin\Provider as J4Provider;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaThree\Plugin\Provider as J3Provider;
|
||||
use VDM\Joomla\Componentbuilder\Interfaces\Architecture\Plugin\MainXMLInterface as MainXML;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaSix\Plugin\MainXML as J6MainXML;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaFive\Plugin\MainXML as J5MainXML;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaFour\Plugin\MainXML as J4MainXML;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaThree\Plugin\MainXML as J3MainXML;
|
||||
@@ -56,6 +59,9 @@ class ArchitecturePlugin implements ServiceProviderInterface
|
||||
$container->alias(Extension::class, 'Architecture.Plugin.Extension')
|
||||
->share('Architecture.Plugin.Extension', [$this, 'getExtension'], true);
|
||||
|
||||
$container->alias(J6Extension::class, 'Architecture.Plugin.J6.Extension')
|
||||
->share('Architecture.Plugin.J6.Extension', [$this, 'getJ6Extension'], true);
|
||||
|
||||
$container->alias(J5Extension::class, 'Architecture.Plugin.J5.Extension')
|
||||
->share('Architecture.Plugin.J5.Extension', [$this, 'getJ5Extension'], true);
|
||||
|
||||
@@ -68,6 +74,9 @@ class ArchitecturePlugin implements ServiceProviderInterface
|
||||
$container->alias(Provider::class, 'Architecture.Plugin.Provider')
|
||||
->share('Architecture.Plugin.Provider', [$this, 'getProvider'], true);
|
||||
|
||||
$container->alias(J6Provider::class, 'Architecture.Plugin.J6.Provider')
|
||||
->share('Architecture.Plugin.J6.Provider', [$this, 'getJ6Provider'], true);
|
||||
|
||||
$container->alias(J5Provider::class, 'Architecture.Plugin.J5.Provider')
|
||||
->share('Architecture.Plugin.J5.Provider', [$this, 'getJ5Provider'], true);
|
||||
|
||||
@@ -80,6 +89,9 @@ class ArchitecturePlugin implements ServiceProviderInterface
|
||||
$container->alias(MainXML::class, 'Architecture.Plugin.MainXML')
|
||||
->share('Architecture.Plugin.MainXML', [$this, 'getMainXML'], true);
|
||||
|
||||
$container->alias(J6MainXML::class, 'Architecture.Plugin.J6.MainXML')
|
||||
->share('Architecture.Plugin.J6.MainXML', [$this, 'getJ6MainXML'], true);
|
||||
|
||||
$container->alias(J5MainXML::class, 'Architecture.Plugin.J5.MainXML')
|
||||
->share('Architecture.Plugin.J5.MainXML', [$this, 'getJ5MainXML'], true);
|
||||
|
||||
@@ -108,6 +120,23 @@ class ArchitecturePlugin implements ServiceProviderInterface
|
||||
return $container->get('Architecture.Plugin.J' . $this->targetVersion . '.Extension');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The Extension Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return J6Extension
|
||||
* @since 5.1.2
|
||||
*/
|
||||
public function getJ6Extension(Container $container): J6Extension
|
||||
{
|
||||
return new J6Extension(
|
||||
$container->get('Placeholder'),
|
||||
$container->get('Compiler.Builder.Content.One'),
|
||||
$container->get('Power.Parser')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The Extension Class.
|
||||
*
|
||||
@@ -176,6 +205,22 @@ class ArchitecturePlugin implements ServiceProviderInterface
|
||||
return $container->get('Architecture.Plugin.J' . $this->targetVersion . '.Provider');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The Provider Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return J6Provider
|
||||
* @since 5.1.2
|
||||
*/
|
||||
public function getJ6Provider(Container $container): J6Provider
|
||||
{
|
||||
return new J6Provider(
|
||||
$container->get('Placeholder'),
|
||||
$container->get('Compiler.Builder.Content.One')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The Provider Class.
|
||||
*
|
||||
@@ -242,6 +287,33 @@ class ArchitecturePlugin implements ServiceProviderInterface
|
||||
return $container->get('Architecture.Plugin.J' . $this->targetVersion . '.MainXML');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The MainXML Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return J6MainXML
|
||||
* @since 5.1.2
|
||||
*/
|
||||
public function getJ6MainXML(Container $container): J6MainXML
|
||||
{
|
||||
return new J6MainXML(
|
||||
$container->get('Config'),
|
||||
$container->get('Language'),
|
||||
$container->get('Language.Set'),
|
||||
$container->get('Language.Purge'),
|
||||
$container->get('Language.Translation'),
|
||||
$container->get('Language.Multilingual'),
|
||||
$container->get('Event'),
|
||||
$container->get('Compiler.Creator.Fieldset.Extension'),
|
||||
$container->get('Compiler.Builder.Content.One'),
|
||||
$container->get('Compiler.Builder.Languages'),
|
||||
$container->get('Compiler.Builder.Multilingual'),
|
||||
$container->get('Utilities.Counter'),
|
||||
$container->get('Utilities.File')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The MainXML Class.
|
||||
*
|
||||
|
@@ -18,6 +18,7 @@ use VDM\Joomla\Componentbuilder\Compiler\Component as CompilerComponent;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Component\JoomlaThree\Settings as J3Settings;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Component\JoomlaFour\Settings as J4Settings;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Component\JoomlaFive\Settings as J5Settings;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Component\JoomlaSix\Settings as J6Settings;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Component\Dashboard;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Component\Placeholder;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Component\Data;
|
||||
@@ -64,6 +65,9 @@ class Component implements ServiceProviderInterface
|
||||
$container->alias(J5Settings::class, 'Component.J5.Settings')
|
||||
->share('Component.J5.Settings', [$this, 'getJ5Settings'], true);
|
||||
|
||||
$container->alias(J6Settings::class, 'Component.J6.Settings')
|
||||
->share('Component.J6.Settings', [$this, 'getJ6Settings'], true);
|
||||
|
||||
$container->alias(Dashboard::class, 'Component.Dashboard')
|
||||
->share('Component.Dashboard', [$this, 'getDashboard'], true);
|
||||
|
||||
@@ -167,6 +171,28 @@ class Component implements ServiceProviderInterface
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The Settings Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return J6Settings
|
||||
* @since 5.1.2
|
||||
*/
|
||||
public function getJ6Settings(Container $container): J6Settings
|
||||
{
|
||||
return new J6Settings(
|
||||
$container->get('Config'),
|
||||
$container->get('Registry'),
|
||||
$container->get('Event'),
|
||||
$container->get('Placeholder'),
|
||||
$container->get('Component'),
|
||||
$container->get('Utilities.Paths'),
|
||||
$container->get('Utilities.Dynamicpath'),
|
||||
$container->get('Utilities.Pathfix')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The Dashboard Class.
|
||||
*
|
||||
|
@@ -19,6 +19,7 @@ use VDM\Joomla\Componentbuilder\Compiler\Interfaces\EventInterface;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\JoomlaThree\Event as J3Event;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\JoomlaFour\Event as J4Event;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\JoomlaFive\Event as J5Event;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\JoomlaSix\Event as J6Event;
|
||||
|
||||
|
||||
/**
|
||||
@@ -55,6 +56,9 @@ class Event implements ServiceProviderInterface
|
||||
$container->alias(J5Event::class, 'J5.Event')
|
||||
->share('J5.Event', [$this, 'getJ5Event'], true);
|
||||
|
||||
$container->alias(J6Event::class, 'J6.Event')
|
||||
->share('J6.Event', [$this, 'getJ6Event'], true);
|
||||
|
||||
$container->alias(EventInterface::class, 'Event')
|
||||
->share('Event', [$this, 'getEvent'], true);
|
||||
}
|
||||
@@ -114,6 +118,19 @@ class Event implements ServiceProviderInterface
|
||||
public function getJ5Event(Container $container): J5Event
|
||||
{
|
||||
return new J5Event();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Joomla 6 Event
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return J6Event
|
||||
* @since 5.1.2
|
||||
*/
|
||||
public function getJ6Event(Container $container): J6Event
|
||||
{
|
||||
return new J6Event();
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -18,6 +18,7 @@ use VDM\Joomla\Componentbuilder\Compiler\Interfaces\GetScriptInterface;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Extension\JoomlaThree\InstallScript as J3InstallScript;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Extension\JoomlaFour\InstallScript as J4InstallScript;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Extension\JoomlaFive\InstallScript as J5InstallScript;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Extension\JoomlaSix\InstallScript as J6InstallScript;
|
||||
|
||||
|
||||
/**
|
||||
@@ -56,6 +57,9 @@ class Extension implements ServiceProviderInterface
|
||||
|
||||
$container->alias(J5InstallScript::class, 'J5.Extension.InstallScript')
|
||||
->share('J5.Extension.InstallScript', [$this, 'getJ5ExtensionInstallScript'], true);
|
||||
|
||||
$container->alias(J6InstallScript::class, 'J6.Extension.InstallScript')
|
||||
->share('J6.Extension.InstallScript', [$this, 'getJ6ExtensionInstallScript'], true);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -97,6 +101,19 @@ class Extension implements ServiceProviderInterface
|
||||
return new J5InstallScript();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Joomla 6 Extension Install Script
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return J6InstallScript
|
||||
* @since 5.1.2
|
||||
*/
|
||||
public function getJ6ExtensionInstallScript(Container $container): J6InstallScript
|
||||
{
|
||||
return new J6InstallScript();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Joomla Extension Install Script
|
||||
*
|
||||
@@ -113,7 +130,6 @@ class Extension implements ServiceProviderInterface
|
||||
}
|
||||
|
||||
return $container->get('J' . $this->targetVersion . '.Extension.InstallScript');
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -29,9 +29,11 @@ use VDM\Joomla\Componentbuilder\Compiler\Field\DatabaseName;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Field\JoomlaThree\CoreField as J3CoreField;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Field\JoomlaFour\CoreField as J4CoreField;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Field\JoomlaFive\CoreField as J5CoreField;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Field\JoomlaSix\CoreField as J6CoreField;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Field\JoomlaThree\InputButton as J3InputButton;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Field\JoomlaFour\InputButton as J4InputButton;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Field\JoomlaFive\InputButton as J5InputButton;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Field\JoomlaSix\InputButton as J6InputButton;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Field\CoreFieldInterface as CoreField;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Field\InputButtonInterface as InputButton;
|
||||
|
||||
@@ -111,6 +113,9 @@ class Field implements ServiceProviderInterface
|
||||
$container->alias(J5CoreField::class, 'J5.Field.Core.Field')
|
||||
->share('J5.Field.Core.Field', [$this, 'getJ5CoreField'], true);
|
||||
|
||||
$container->alias(J6CoreField::class, 'J6.Field.Core.Field')
|
||||
->share('J6.Field.Core.Field', [$this, 'getJ6CoreField'], true);
|
||||
|
||||
$container->alias(J3InputButton::class, 'J3.Field.Input.Button')
|
||||
->share('J3.Field.Input.Button', [$this, 'getJ3InputButton'], true);
|
||||
|
||||
@@ -120,6 +125,9 @@ class Field implements ServiceProviderInterface
|
||||
$container->alias(J5InputButton::class, 'J5.Field.Input.Button')
|
||||
->share('J5.Field.Input.Button', [$this, 'getJ5InputButton'], true);
|
||||
|
||||
$container->alias(J6InputButton::class, 'J6.Field.Input.Button')
|
||||
->share('J6.Field.Input.Button', [$this, 'getJ6InputButton'], true);
|
||||
|
||||
$container->alias(CoreField::class, 'Field.Core.Field')
|
||||
->share('Field.Core.Field', [$this, 'getCoreField'], true);
|
||||
|
||||
@@ -354,6 +362,19 @@ class Field implements ServiceProviderInterface
|
||||
return new J5CoreField();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The CoreField Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return J6CoreField
|
||||
* @since 5.1.2
|
||||
*/
|
||||
public function getJ6CoreField(Container $container): J6CoreField
|
||||
{
|
||||
return new J6CoreField();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The J3InputButton Class.
|
||||
*
|
||||
@@ -405,6 +426,23 @@ class Field implements ServiceProviderInterface
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The J6InputButton Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return J6InputButton
|
||||
* @since 5.1.2
|
||||
*/
|
||||
public function getJ6InputButton(Container $container): J6InputButton
|
||||
{
|
||||
return new J6InputButton(
|
||||
$container->get('Config'),
|
||||
$container->get('Placeholder'),
|
||||
$container->get('Compiler.Creator.Permission')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The CoreFieldInterface Class.
|
||||
*
|
||||
|
@@ -18,6 +18,7 @@ use VDM\Joomla\Componentbuilder\Compiler\Interfaces\HeaderInterface;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\JoomlaThree\Header as J3Header;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\JoomlaFour\Header as J4Header;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\JoomlaFive\Header as J5Header;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\JoomlaSix\Header as J6Header;
|
||||
|
||||
|
||||
/**
|
||||
@@ -54,6 +55,9 @@ class Header implements ServiceProviderInterface
|
||||
$container->alias(J5Header::class, 'J5.Header')
|
||||
->share('J5.Header', [$this, 'getJ5Header'], true);
|
||||
|
||||
$container->alias(J6Header::class, 'J6.Header')
|
||||
->share('J6.Header', [$this, 'getJ6Header'], true);
|
||||
|
||||
$container->alias(HeaderInterface::class, 'Header')
|
||||
->share('Header', [$this, 'getHeader'], true);
|
||||
}
|
||||
@@ -146,6 +150,30 @@ class Header implements ServiceProviderInterface
|
||||
$container->get('Compiler.Builder.Filter'),
|
||||
$container->get('Compiler.Builder.Tags')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The Header Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return J6Header
|
||||
* @since 5.1.2
|
||||
*/
|
||||
public function getJ6Header(Container $container): J6Header
|
||||
{
|
||||
return new J6Header(
|
||||
$container->get('Config'),
|
||||
$container->get('Event'),
|
||||
$container->get('Placeholder'),
|
||||
$container->get('Language'),
|
||||
$container->get('Compiler.Builder.Uikit.Comp'),
|
||||
$container->get('Compiler.Builder.Admin.Filter.Type'),
|
||||
$container->get('Compiler.Builder.Category'),
|
||||
$container->get('Compiler.Builder.Access.Switch.List'),
|
||||
$container->get('Compiler.Builder.Filter'),
|
||||
$container->get('Compiler.Builder.Tags')
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -19,6 +19,7 @@ use VDM\Joomla\Componentbuilder\Compiler\Interfaces\HistoryInterface;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\JoomlaThree\History as J3History;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\JoomlaFour\History as J4History;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\JoomlaFive\History as J5History;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\JoomlaSix\History as J6History;
|
||||
|
||||
|
||||
/**
|
||||
@@ -55,6 +56,9 @@ class History implements ServiceProviderInterface
|
||||
$container->alias(J5History::class, 'J5.History')
|
||||
->share('J5.History', [$this, 'getJ5History'], true);
|
||||
|
||||
$container->alias(J6History::class, 'J6.History')
|
||||
->share('J6.History', [$this, 'getJ6History'], true);
|
||||
|
||||
$container->alias(HistoryInterface::class, 'History')
|
||||
->share('History', [$this, 'getHistory'], true);
|
||||
}
|
||||
@@ -123,6 +127,22 @@ class History implements ServiceProviderInterface
|
||||
$container->get('Config'),
|
||||
$container->get('Joomla.Database')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Joomla 6 History
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return J6History
|
||||
* @since 5.1.2
|
||||
*/
|
||||
public function getJ6History(Container $container): J6History
|
||||
{
|
||||
return new J6History(
|
||||
$container->get('Config'),
|
||||
$container->get('Joomla.Database')
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -18,14 +18,17 @@ use VDM\Joomla\Componentbuilder\Compiler\Interfaces\ModuleDataInterface as Data;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Joomlamodule\JoomlaThree\Data as J3Data;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Joomlamodule\JoomlaFour\Data as J4Data;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Joomlamodule\JoomlaFive\Data as J5Data;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Joomlamodule\JoomlaSix\Data as J6Data;
|
||||
use VDM\Joomla\Componentbuilder\Interfaces\Module\StructureInterface as Structure;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Joomlamodule\JoomlaThree\Structure as J3Structure;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Joomlamodule\JoomlaFour\Structure as J4Structure;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Joomlamodule\JoomlaFive\Structure as J5Structure;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Joomlamodule\JoomlaSix\Structure as J6Structure;
|
||||
use VDM\Joomla\Componentbuilder\Interfaces\Module\InfusionInterface as Infusion;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Joomlamodule\JoomlaThree\Infusion as J3Infusion;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Joomlamodule\JoomlaFour\Infusion as J4Infusion;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Joomlamodule\JoomlaFive\Infusion as J5Infusion;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Joomlamodule\JoomlaSix\Infusion as J6Infusion;
|
||||
|
||||
|
||||
/**
|
||||
@@ -65,6 +68,9 @@ class Joomlamodule implements ServiceProviderInterface
|
||||
$container->alias(J5Data::class, 'Joomlamodule.J5.Data')
|
||||
->share('Joomlamodule.J5.Data', [$this, 'getJ5Data'], true);
|
||||
|
||||
$container->alias(J6Data::class, 'Joomlamodule.J6.Data')
|
||||
->share('Joomlamodule.J6.Data', [$this, 'getJ6Data'], true);
|
||||
|
||||
$container->alias(Structure::class, 'Joomlamodule.Structure')
|
||||
->share('Joomlamodule.Structure', [$this, 'getStructure'], true);
|
||||
|
||||
@@ -77,6 +83,9 @@ class Joomlamodule implements ServiceProviderInterface
|
||||
$container->alias(J5Structure::class, 'Joomlamodule.J5.Structure')
|
||||
->share('Joomlamodule.J5.Structure', [$this, 'getJ5Structure'], true);
|
||||
|
||||
$container->alias(J6Structure::class, 'Joomlamodule.J6.Structure')
|
||||
->share('Joomlamodule.J6.Structure', [$this, 'getJ6Structure'], true);
|
||||
|
||||
$container->alias(Infusion::class, 'Joomlamodule.Infusion')
|
||||
->share('Joomlamodule.Infusion', [$this, 'getInfusion'], true);
|
||||
|
||||
@@ -88,6 +97,9 @@ class Joomlamodule implements ServiceProviderInterface
|
||||
|
||||
$container->alias(J5Infusion::class, 'Joomlamodule.J5.Infusion')
|
||||
->share('Joomlamodule.J5.Infusion', [$this, 'getJ5Infusion'], true);
|
||||
|
||||
$container->alias(J6Infusion::class, 'Joomlamodule.J6.Infusion')
|
||||
->share('Joomlamodule.J6.Infusion', [$this, 'getJ6Infusion'], true);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -186,6 +198,32 @@ class Joomlamodule implements ServiceProviderInterface
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The Data Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return J6Data
|
||||
* @since 5.1.2
|
||||
*/
|
||||
public function getJ6Data(Container $container): J6Data
|
||||
{
|
||||
return new J6Data(
|
||||
$container->get('Config'),
|
||||
$container->get('Customcode'),
|
||||
$container->get('Customcode.Gui'),
|
||||
$container->get('Placeholder'),
|
||||
$container->get('Language'),
|
||||
$container->get('Field'),
|
||||
$container->get('Field.Name'),
|
||||
$container->get('Model.Filesfolders'),
|
||||
$container->get('Model.Libraries'),
|
||||
$container->get('Dynamicget.Data'),
|
||||
$container->get('Templatelayout.Data'),
|
||||
$container->get('Joomla.Database')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The StructureInterface Class.
|
||||
*
|
||||
@@ -281,6 +319,32 @@ class Joomlamodule implements ServiceProviderInterface
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The Structure Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return J6Structure
|
||||
* @since 5.1.2
|
||||
*/
|
||||
public function getJ6Structure(Container $container): J6Structure
|
||||
{
|
||||
return new J6Structure(
|
||||
$container->get('Joomlamodule.Data'),
|
||||
$container->get('Component'),
|
||||
$container->get('Config'),
|
||||
$container->get('Registry'),
|
||||
$container->get('Customcode.Dispenser'),
|
||||
$container->get('Event'),
|
||||
$container->get('Utilities.Counter'),
|
||||
$container->get('Utilities.Folder'),
|
||||
$container->get('Utilities.File'),
|
||||
$container->get('Utilities.Files'),
|
||||
$container->get('Compiler.Builder.Template.Data'),
|
||||
$container->get('Placeholder')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The InfusionInterface Class.
|
||||
*
|
||||
@@ -377,6 +441,33 @@ class Joomlamodule implements ServiceProviderInterface
|
||||
$container->get('Compiler.Creator.Fieldset.Extension'),
|
||||
$container->get('Dynamicget.Methods')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The Infusion Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return J6Infusion
|
||||
* @since 5.1.2
|
||||
*/
|
||||
public function getJ6Infusion(Container $container): J6Infusion
|
||||
{
|
||||
return new J6Infusion(
|
||||
$container->get('Config'),
|
||||
$container->get('Architecture.Module.Provider'),
|
||||
$container->get('Architecture.Module.Dispatcher'),
|
||||
$container->get('Architecture.Module.Template'),
|
||||
$container->get('Architecture.Module.Helper'),
|
||||
$container->get('Architecture.Module.MainXML'),
|
||||
$container->get('Joomlamodule.Data'),
|
||||
$container->get('Header'),
|
||||
$container->get('Event'),
|
||||
$container->get('Extension.InstallScript'),
|
||||
$container->get('Compiler.Builder.Content.Multi'),
|
||||
$container->get('Compiler.Creator.Fieldset.Extension'),
|
||||
$container->get('Dynamicget.Methods')
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -17,14 +17,17 @@ use Joomla\DI\ServiceProviderInterface;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Joomlaplugin\JoomlaThree\Data as J3PluginData;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Joomlaplugin\JoomlaFour\Data as J4PluginData;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Joomlaplugin\JoomlaFive\Data as J5PluginData;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Joomlaplugin\JoomlaSix\Data as J6PluginData;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\PluginDataInterface as PluginData;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Joomlaplugin\JoomlaThree\Structure as J3Structure;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Joomlaplugin\JoomlaFour\Structure as J4Structure;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Joomlaplugin\JoomlaFive\Structure as J5Structure;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Joomlaplugin\JoomlaSix\Structure as J6Structure;
|
||||
use VDM\Joomla\Componentbuilder\Interfaces\Plugin\StructureInterface as Structure;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Joomlaplugin\JoomlaThree\Infusion as J3Infusion;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Joomlaplugin\JoomlaFour\Infusion as J4Infusion;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Joomlaplugin\JoomlaFive\Infusion as J5Infusion;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Joomlaplugin\JoomlaSix\Infusion as J6Infusion;
|
||||
use VDM\Joomla\Componentbuilder\Interfaces\Plugin\InfusionInterface as Infusion;
|
||||
|
||||
|
||||
@@ -62,6 +65,9 @@ class Joomlaplugin implements ServiceProviderInterface
|
||||
$container->alias(J5PluginData::class, 'Joomlaplugin.J5.Data')
|
||||
->share('Joomlaplugin.J5.Data', [$this, 'getJ5PluginData'], true);
|
||||
|
||||
$container->alias(J6PluginData::class, 'Joomlaplugin.J6.Data')
|
||||
->share('Joomlaplugin.J6.Data', [$this, 'getJ6PluginData'], true);
|
||||
|
||||
$container->alias(PluginData::class, 'Joomlaplugin.Data')
|
||||
->share('Joomlaplugin.Data', [$this, 'getPluginData'], true);
|
||||
|
||||
@@ -74,6 +80,9 @@ class Joomlaplugin implements ServiceProviderInterface
|
||||
$container->alias(J5Structure::class, 'Joomlaplugin.J5.Structure')
|
||||
->share('Joomlaplugin.J5.Structure', [$this, 'getJ5Structure'], true);
|
||||
|
||||
$container->alias(J6Structure::class, 'Joomlaplugin.J6.Structure')
|
||||
->share('Joomlaplugin.J6.Structure', [$this, 'getJ6Structure'], true);
|
||||
|
||||
$container->alias(Structure::class, 'Joomlaplugin.Structure')
|
||||
->share('Joomlaplugin.Structure', [$this, 'getStructure'], true);
|
||||
|
||||
@@ -86,6 +95,9 @@ class Joomlaplugin implements ServiceProviderInterface
|
||||
$container->alias(J5Infusion::class, 'Joomlaplugin.J5.Infusion')
|
||||
->share('Joomlaplugin.J5.Infusion', [$this, 'getJ5Infusion'], true);
|
||||
|
||||
$container->alias(J6Infusion::class, 'Joomlaplugin.J6.Infusion')
|
||||
->share('Joomlaplugin.J6.Infusion', [$this, 'getJ6Infusion'], true);
|
||||
|
||||
$container->alias(Infusion::class, 'Joomlaplugin.Infusion')
|
||||
->share('Joomlaplugin.Infusion', [$this, 'getInfusion'], true);
|
||||
}
|
||||
@@ -177,6 +189,29 @@ class Joomlaplugin implements ServiceProviderInterface
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The PluginData Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return J6PluginData
|
||||
* @since 5.1.2
|
||||
*/
|
||||
public function getJ6PluginData(Container $container): J6PluginData
|
||||
{
|
||||
return new J6PluginData(
|
||||
$container->get('Config'),
|
||||
$container->get('Customcode'),
|
||||
$container->get('Customcode.Gui'),
|
||||
$container->get('Placeholder'),
|
||||
$container->get('Language'),
|
||||
$container->get('Field'),
|
||||
$container->get('Field.Name'),
|
||||
$container->get('Model.Filesfolders'),
|
||||
$container->get('Joomla.Database')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Joomla Plugin Structure Builder
|
||||
*
|
||||
@@ -200,7 +235,7 @@ class Joomlaplugin implements ServiceProviderInterface
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Structure
|
||||
* @return J3Structure
|
||||
* @since 5.0.2
|
||||
*/
|
||||
public function getJ3Structure(Container $container): J3Structure
|
||||
@@ -224,7 +259,7 @@ class Joomlaplugin implements ServiceProviderInterface
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Structure
|
||||
* @return J4Structure
|
||||
* @since 5.0.2
|
||||
*/
|
||||
public function getJ4Structure(Container $container): J4Structure
|
||||
@@ -249,7 +284,7 @@ class Joomlaplugin implements ServiceProviderInterface
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Structure
|
||||
* @return J5Structure
|
||||
* @since 5.0.2
|
||||
*/
|
||||
public function getJ5Structure(Container $container): J5Structure
|
||||
@@ -269,6 +304,31 @@ class Joomlaplugin implements ServiceProviderInterface
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Joomla 6 Plugin Structure Builder
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return J6Structure
|
||||
* @since 5.1.2
|
||||
*/
|
||||
public function getJ6Structure(Container $container): J6Structure
|
||||
{
|
||||
return new J6Structure(
|
||||
$container->get('Joomlaplugin.Data'),
|
||||
$container->get('Component'),
|
||||
$container->get('Config'),
|
||||
$container->get('Registry'),
|
||||
$container->get('Customcode.Dispenser'),
|
||||
$container->get('Event'),
|
||||
$container->get('Utilities.Counter'),
|
||||
$container->get('Utilities.Folder'),
|
||||
$container->get('Utilities.File'),
|
||||
$container->get('Utilities.Files'),
|
||||
$container->get('Placeholder')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The InfusionInterface Class.
|
||||
*
|
||||
@@ -361,6 +421,32 @@ class Joomlaplugin implements ServiceProviderInterface
|
||||
$container->get('Compiler.Builder.Content.One'),
|
||||
$container->get('Compiler.Creator.Fieldset.Extension')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The Infusion Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return J6Infusion
|
||||
* @since 5.1.2
|
||||
*/
|
||||
public function getJ6Infusion(Container $container): J6Infusion
|
||||
{
|
||||
return new J6Infusion(
|
||||
$container->get('Config'),
|
||||
$container->get('Placeholder'),
|
||||
$container->get('Header'),
|
||||
$container->get('Event'),
|
||||
$container->get('Joomlaplugin.Data'),
|
||||
$container->get('Extension.InstallScript'),
|
||||
$container->get('Architecture.Plugin.Extension'),
|
||||
$container->get('Architecture.Plugin.Provider'),
|
||||
$container->get('Architecture.Plugin.MainXML'),
|
||||
$container->get('Compiler.Builder.Content.Multi'),
|
||||
$container->get('Compiler.Builder.Content.One'),
|
||||
$container->get('Compiler.Creator.Fieldset.Extension')
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -48,6 +48,7 @@ use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Model\CustomtabsInterface as
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Model\JoomlaThree\Customtabs as CustomtabsJ3;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Model\JoomlaFour\Customtabs as CustomtabsJ4;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Model\JoomlaFive\Customtabs as CustomtabsJ5;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Model\JoomlaSix\Customtabs as CustomtabsJ6;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Model\Adminviews;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Model\Sqltweaking;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Model\Sqldump;
|
||||
@@ -186,6 +187,9 @@ class Model implements ServiceProviderInterface
|
||||
$container->alias(CustomtabsJ5::class, 'Model.J5.Customtabs')
|
||||
->share('Model.J5.Customtabs', [$this, 'getCustomtabsJ5'], true);
|
||||
|
||||
$container->alias(CustomtabsJ6::class, 'Model.J6.Customtabs')
|
||||
->share('Model.J6.Customtabs', [$this, 'getCustomtabsJ6'], true);
|
||||
|
||||
$container->alias(Adminviews::class, 'Model.Adminviews')
|
||||
->share('Model.Adminviews', [$this, 'getAdminviews'], true);
|
||||
|
||||
@@ -781,6 +785,25 @@ class Model implements ServiceProviderInterface
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The CustomtabsJ6 Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return CustomtabsJ6
|
||||
* @since 5.1.2
|
||||
*/
|
||||
public function getCustomtabsJ6(Container $container): CustomtabsJ6
|
||||
{
|
||||
return new CustomtabsJ6(
|
||||
$container->get('Config'),
|
||||
$container->get('Compiler.Builder.Custom.Tabs'),
|
||||
$container->get('Language'),
|
||||
$container->get('Placeholder'),
|
||||
$container->get('Customcode')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The Adminviews Class.
|
||||
*
|
||||
|
@@ -25,7 +25,7 @@ use VDM\Joomla\Abstraction\FunctionRegistry;
|
||||
class Config extends FunctionRegistry
|
||||
{
|
||||
/**
|
||||
* Hold a JInput object for easier access to the input variables.
|
||||
* Hold a Input object for easier access to the input variables.
|
||||
*
|
||||
* @var Input
|
||||
* @since 3.2.0
|
||||
@@ -42,7 +42,7 @@ class Config extends FunctionRegistry
|
||||
*/
|
||||
public function __construct(?Input $input = null)
|
||||
{
|
||||
$this->input = $input ?: Factory::getApplication()->input;
|
||||
$this->input = $input ?: Factory::getApplication()->getInput();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -18,6 +18,7 @@ use Joomla\CMS\Version;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Field\JoomlaThree\CoreRule as J3CoreRule;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Field\JoomlaFour\CoreRule as J4CoreRule;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Field\JoomlaFive\CoreRule as J5CoreRule;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Field\JoomlaSix\CoreRule as J6CoreRule;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Field\CoreRuleInterface as CoreRule;
|
||||
|
||||
|
||||
@@ -55,6 +56,9 @@ class CoreRules implements ServiceProviderInterface
|
||||
$container->alias(J5CoreRule::class, 'J5.Field.Core.Rule')
|
||||
->share('J5.Field.Core.Rule', [$this, 'getJ5CoreRule'], true);
|
||||
|
||||
$container->alias(J6CoreRule::class, 'J6.Field.Core.Rule')
|
||||
->share('J6.Field.Core.Rule', [$this, 'getJ6CoreRule'], true);
|
||||
|
||||
$container->alias(CoreRule::class, 'Field.Core.Rule')
|
||||
->share('Field.Core.Rule', [$this, 'getCoreRule'], true);
|
||||
}
|
||||
@@ -98,6 +102,19 @@ class CoreRules implements ServiceProviderInterface
|
||||
return new J5CoreRule();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The CoreRule Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return J6CoreRule
|
||||
* @since 5.1.2
|
||||
*/
|
||||
public function getJ6CoreRule(Container $container): J6CoreRule
|
||||
{
|
||||
return new J6CoreRule();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The CoreRuleInterface Class.
|
||||
*
|
||||
|
@@ -97,7 +97,8 @@ abstract class UploadHelper
|
||||
public static function get(string $field, string $type, string $filter = null, string $path = null): ?array
|
||||
{
|
||||
// Get the uploaded file information.
|
||||
$input = Factory::getApplication()->input;
|
||||
$app = Factory::getApplication();
|
||||
$input = method_exists($app, 'getInput') ? $app->getInput() : $app->input;
|
||||
|
||||
// set the default filter
|
||||
if (empty($filter))
|
||||
|
Reference in New Issue
Block a user