Update 2024-07-27 22:00:10
This commit is contained in:
parent
b156152e5e
commit
8559278b19
@ -495,6 +495,7 @@ This repository contains an index (see below) of all the approved powers within
|
||||
|
||||
- **final class AllowAdd** | [Details](src/005fce79-1b62-4a93-8d5e-8c89fee1afc6) | [Code](src/005fce79-1b62-4a93-8d5e-8c89fee1afc6/code.php) | [Settings](src/005fce79-1b62-4a93-8d5e-8c89fee1afc6/settings.json) | SPK: `Super---005fce79_1b62_4a93_8d5e_8c89fee1afc6---Power`
|
||||
- **final class AllowEdit** | [Details](src/e85175fd-e297-46df-a497-27f7a37190fd) | [Code](src/e85175fd-e297-46df-a497-27f7a37190fd/code.php) | [Settings](src/e85175fd-e297-46df-a497-27f7a37190fd/settings.json) | SPK: `Super---e85175fd_e297_46df_a497_27f7a37190fd---Power`
|
||||
- **final class AllowEditViews** | [Details](src/7ecd7318-8bea-4321-8f13-626da1ab01c7) | [Code](src/7ecd7318-8bea-4321-8f13-626da1ab01c7/code.php) | [Settings](src/7ecd7318-8bea-4321-8f13-626da1ab01c7/settings.json) | SPK: `Super---7ecd7318_8bea_4321_8f13_626da1ab01c7---Power`
|
||||
- **Namespace**: [VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaFive\Model](#vdm-joomla-componentbuilder-compiler-architecture-joomlafive-model)
|
||||
|
||||
- **final class CanDelete** | [Details](src/34df20ec-67db-4e7e-be61-fb94d360c408) | [Code](src/34df20ec-67db-4e7e-be61-fb94d360c408/code.php) | [Settings](src/34df20ec-67db-4e7e-be61-fb94d360c408/settings.json) | SPK: `Super---34df20ec_67db_4e7e_be61_fb94d360c408---Power`
|
||||
@ -503,6 +504,7 @@ This repository contains an index (see below) of all the approved powers within
|
||||
|
||||
- **final class AllowAdd** | [Details](src/425b1107-933d-4436-87ac-63540ec101c5) | [Code](src/425b1107-933d-4436-87ac-63540ec101c5/code.php) | [Settings](src/425b1107-933d-4436-87ac-63540ec101c5/settings.json) | SPK: `Super---425b1107_933d_4436_87ac_63540ec101c5---Power`
|
||||
- **final class AllowEdit** | [Details](src/ddf31f4b-96ba-46e7-8100-f48e1cefe533) | [Code](src/ddf31f4b-96ba-46e7-8100-f48e1cefe533/code.php) | [Settings](src/ddf31f4b-96ba-46e7-8100-f48e1cefe533/settings.json) | SPK: `Super---ddf31f4b_96ba_46e7_8100_f48e1cefe533---Power`
|
||||
- **final class AllowEditViews** | [Details](src/c2453304-c9ac-4d67-a045-fbda68876434) | [Code](src/c2453304-c9ac-4d67-a045-fbda68876434/code.php) | [Settings](src/c2453304-c9ac-4d67-a045-fbda68876434/settings.json) | SPK: `Super---c2453304_c9ac_4d67_a045_fbda68876434---Power`
|
||||
- **Namespace**: [VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaFour\Model](#vdm-joomla-componentbuilder-compiler-architecture-joomlafour-model)
|
||||
|
||||
- **final class CanDelete** | [Details](src/2a69a8ab-cea0-4c75-92d5-9495cb740e0f) | [Code](src/2a69a8ab-cea0-4c75-92d5-9495cb740e0f/code.php) | [Settings](src/2a69a8ab-cea0-4c75-92d5-9495cb740e0f/settings.json) | SPK: `Super---2a69a8ab_cea0_4c75_92d5_9495cb740e0f---Power`
|
||||
@ -511,6 +513,7 @@ This repository contains an index (see below) of all the approved powers within
|
||||
|
||||
- **final class AllowAdd** | [Details](src/f21388dc-5ddc-4970-a3c2-55f075024762) | [Code](src/f21388dc-5ddc-4970-a3c2-55f075024762/code.php) | [Settings](src/f21388dc-5ddc-4970-a3c2-55f075024762/settings.json) | SPK: `Super---f21388dc_5ddc_4970_a3c2_55f075024762---Power`
|
||||
- **final class AllowEdit** | [Details](src/8faaed82-522d-4f78-bd43-0ab3f7c72e5f) | [Code](src/8faaed82-522d-4f78-bd43-0ab3f7c72e5f/code.php) | [Settings](src/8faaed82-522d-4f78-bd43-0ab3f7c72e5f/settings.json) | SPK: `Super---8faaed82_522d_4f78_bd43_0ab3f7c72e5f---Power`
|
||||
- **final class AllowEditViews** | [Details](src/bdb74844-7cba-4227-a01c-355eba5fd031) | [Code](src/bdb74844-7cba-4227-a01c-355eba5fd031/code.php) | [Settings](src/bdb74844-7cba-4227-a01c-355eba5fd031/settings.json) | SPK: `Super---bdb74844_7cba_4227_a01c_355eba5fd031---Power`
|
||||
- **Namespace**: [VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaThree\Model](#vdm-joomla-componentbuilder-compiler-architecture-joomlathree-model)
|
||||
|
||||
- **final class CanDelete** | [Details](src/23766738-d0a4-4d0a-8555-7e4c97c0cddd) | [Code](src/23766738-d0a4-4d0a-8555-7e4c97c0cddd/code.php) | [Settings](src/23766738-d0a4-4d0a-8555-7e4c97c0cddd/settings.json) | SPK: `Super---23766738_d0a4_4d0a_8555_7e4c97c0cddd---Power`
|
||||
@ -519,6 +522,7 @@ This repository contains an index (see below) of all the approved powers within
|
||||
|
||||
- **interface AllowAddInterface** | [Details](src/c9700450-4f44-4455-bc86-6a7660daadee) | [Code](src/c9700450-4f44-4455-bc86-6a7660daadee/code.php) | [Settings](src/c9700450-4f44-4455-bc86-6a7660daadee/settings.json) | SPK: `Super---c9700450_4f44_4455_bc86_6a7660daadee---Power`
|
||||
- **interface AllowEditInterface** | [Details](src/992a842f-1ba9-4a5c-b214-042459ffe038) | [Code](src/992a842f-1ba9-4a5c-b214-042459ffe038/code.php) | [Settings](src/992a842f-1ba9-4a5c-b214-042459ffe038/settings.json) | SPK: `Super---992a842f_1ba9_4a5c_b214_042459ffe038---Power`
|
||||
- **interface AllowEditViewsInterface** | [Details](src/025d5903-cfdf-4624-aebb-10d02075e265) | [Code](src/025d5903-cfdf-4624-aebb-10d02075e265/code.php) | [Settings](src/025d5903-cfdf-4624-aebb-10d02075e265/settings.json) | SPK: `Super---025d5903_cfdf_4624_aebb_10d02075e265---Power`
|
||||
- **Namespace**: [VDM\Joomla\Componentbuilder\Compiler\Interfaces\Architecture\Model](#vdm-joomla-componentbuilder-compiler-interfaces-architecture-model)
|
||||
|
||||
- **interface CanDeleteInterface** | [Details](src/e00a7d1d-6d80-41c5-bf13-32d41bc5bf91) | [Code](src/e00a7d1d-6d80-41c5-bf13-32d41bc5bf91/code.php) | [Settings](src/e00a7d1d-6d80-41c5-bf13-32d41bc5bf91/settings.json) | SPK: `Super---e00a7d1d_6d80_41c5_bf13_32d41bc5bf91---Power`
|
||||
|
60
src/025d5903-cfdf-4624-aebb-10d02075e265/README.md
Normal file
60
src/025d5903-cfdf-4624-aebb-10d02075e265/README.md
Normal file
@ -0,0 +1,60 @@
|
||||
```
|
||||
██████╗ ██████╗ ██╗ ██╗███████╗██████╗
|
||||
██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗
|
||||
██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝
|
||||
██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗
|
||||
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
|
||||
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
|
||||
```
|
||||
# interface AllowEditViewsInterface (Details)
|
||||
> namespace: **VDM\Joomla\Componentbuilder\Compiler\Interfaces\Architecture\Controller**
|
||||
|
||||
```uml
|
||||
@startuml
|
||||
interface AllowEditViewsInterface #Lavender {
|
||||
+ getArray(array $views) : string
|
||||
+ getFunctions(array $views) : string
|
||||
}
|
||||
|
||||
note right of AllowEditViewsInterface::getArray
|
||||
Get Array Code
|
||||
|
||||
since: 5.0.2
|
||||
return: string
|
||||
end note
|
||||
|
||||
note right of AllowEditViewsInterface::getFunctions
|
||||
Get Custom Function Code
|
||||
|
||||
since: 5.0.2
|
||||
return: string
|
||||
end note
|
||||
|
||||
@enduml
|
||||
```
|
||||
|
||||
The Power feature in JCB allows you to write PHP classes and their implementations, making it easy to include them in your Joomla project. JCB handles linking, autoloading, namespacing, and folder structure creation for you.
|
||||
|
||||
By using the SPK (Super Power Key) in your custom code (replacing the class name in your code with the SPK), JCB will automatically pull the power from the repository into your project. This makes it available in your JCB instance, allowing you to edit it and include the class in your generated Joomla component.
|
||||
|
||||
JCB uses placeholders like [[[`NamespacePrefix`]]] and [[[`ComponentNamespace`]]] in namespacing to prevent collisions and improve reusability across different JCB systems. You can also set the **JCB powers path** globally or per component under the **Dynamic Integration** tab, providing flexibility and easy maintainability.
|
||||
|
||||
To add this specific Power to your project in JCB:
|
||||
|
||||
> simply use this SPK
|
||||
```
|
||||
Super---025d5903_cfdf_4624_aebb_10d02075e265---Power
|
||||
```
|
||||
> remember to replace the `---` with `___` to activate this Power in your code
|
||||
|
||||
---
|
||||
```
|
||||
██╗ ██████╗██████╗
|
||||
██║██╔════╝██╔══██╗
|
||||
██║██║ ██████╔╝
|
||||
██ ██║██║ ██╔══██╗
|
||||
╚█████╔╝╚██████╗██████╔╝
|
||||
╚════╝ ╚═════╝╚═════╝
|
||||
```
|
||||
> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder)
|
||||
|
42
src/025d5903-cfdf-4624-aebb-10d02075e265/code.php
Normal file
42
src/025d5903-cfdf-4624-aebb-10d02075e265/code.php
Normal file
@ -0,0 +1,42 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Componentbuilder\Compiler\Interfaces\Architecture\Controller;
|
||||
|
||||
|
||||
/**
|
||||
* Controller Allow Edit Views Interface
|
||||
*
|
||||
* @since 5.0.2
|
||||
*/
|
||||
interface AllowEditViewsInterface
|
||||
{
|
||||
/**
|
||||
* Get Array Code
|
||||
*
|
||||
* @param array $views
|
||||
*
|
||||
* @since 5.0.2
|
||||
* @return string The array of Code (string)
|
||||
*/
|
||||
public function getArray(array $views): string;
|
||||
|
||||
/**
|
||||
* Get Custom Function Code
|
||||
*
|
||||
* @param array $views
|
||||
*
|
||||
* @since 5.0.2
|
||||
* @return string The functions of Code (string)
|
||||
*/
|
||||
public function getFunctions(array $views): string;
|
||||
}
|
||||
|
19
src/025d5903-cfdf-4624-aebb-10d02075e265/code.power
Normal file
19
src/025d5903-cfdf-4624-aebb-10d02075e265/code.power
Normal file
@ -0,0 +1,19 @@
|
||||
/**
|
||||
* Get Array Code
|
||||
*
|
||||
* @param array $views
|
||||
*
|
||||
* @since 5.0.2
|
||||
* @return string The array of Code (string)
|
||||
*/
|
||||
public function getArray(array $views): string;
|
||||
|
||||
/**
|
||||
* Get Custom Function Code
|
||||
*
|
||||
* @param array $views
|
||||
*
|
||||
* @since 5.0.2
|
||||
* @return string The functions of Code (string)
|
||||
*/
|
||||
public function getFunctions(array $views): string;
|
19
src/025d5903-cfdf-4624-aebb-10d02075e265/settings.json
Normal file
19
src/025d5903-cfdf-4624-aebb-10d02075e265/settings.json
Normal file
@ -0,0 +1,19 @@
|
||||
{
|
||||
"add_head": "0",
|
||||
"add_licensing_template": "2",
|
||||
"extends": "",
|
||||
"guid": "025d5903-cfdf-4624-aebb-10d02075e265",
|
||||
"implements": null,
|
||||
"load_selection": null,
|
||||
"name": "AllowEditViewsInterface",
|
||||
"power_version": "1.0.0",
|
||||
"system_name": "JCB.Interfaces.Architecture.Controller.AllowEditVi",
|
||||
"type": "interface",
|
||||
"use_selection": null,
|
||||
"extendsinterfaces": null,
|
||||
"namespace": "[[[NamespacePrefix]]]\\Joomla\\[[[ComponentNamespace]]].Compiler.Interfaces.Architecture.Controller.AllowEditViewsInterface",
|
||||
"description": "Controller Allow Edit Views Interface\r\n\r\n@since 5.0.2",
|
||||
"licensing_template": "\/**\r\n * @package Joomla.Component.Builder\r\n *\r\n * @created 4th September, 2022\r\n * @author Llewellyn van der Merwe <https:\/\/dev.vdm.io>\r\n * @git Joomla Component Builder <https:\/\/git.vdm.dev\/joomla\/Component-Builder>\r\n * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.\r\n * @license GNU General Public License version 2 or later; see LICENSE.txt\r\n *\/\r\n",
|
||||
"head": "",
|
||||
"composer": ""
|
||||
}
|
@ -367,6 +367,7 @@ final class Header implements HeaderInterface
|
||||
$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;';
|
||||
@ -402,6 +403,7 @@ final class Header implements HeaderInterface
|
||||
$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;
|
||||
|
@ -331,6 +331,7 @@
|
||||
$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;';
|
||||
@ -366,6 +367,7 @@
|
||||
$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;
|
||||
|
@ -52,11 +52,11 @@
|
||||
"use": "8ca30d59-e56a-4cdd-bd8c-d9aad28f5903",
|
||||
"as": "default"
|
||||
},
|
||||
"use_selection11": {
|
||||
"use_selection10": {
|
||||
"use": "0a59c65c-9daf-4bc9-baf4-e063ff9e6a8a",
|
||||
"as": "default"
|
||||
},
|
||||
"use_selection12": {
|
||||
"use_selection11": {
|
||||
"use": "1f28cb53-60d9-4db1-b517-3c7dc6b429ef",
|
||||
"as": "default"
|
||||
}
|
||||
|
@ -22,6 +22,10 @@ class ArchitectureController #Gold {
|
||||
+ getJ5ControllerAllowEdit(Container $container) : J5ControllerAllowEdit
|
||||
+ getJ4ControllerAllowEdit(Container $container) : J4ControllerAllowEdit
|
||||
+ getJ3ControllerAllowEdit(Container $container) : J3ControllerAllowEdit
|
||||
+ getAllowEditViews(Container $container) : AllowEditViewsInterface
|
||||
+ getJ5ControllerAllowEditViews(Container $container) : J5ControllerAllowEditViews
|
||||
+ getJ4ControllerAllowEditViews(Container $container) : J4ControllerAllowEditViews
|
||||
+ getJ3ControllerAllowEditViews(Container $container) : J3ControllerAllowEditViews
|
||||
}
|
||||
|
||||
note right of ArchitectureController::register
|
||||
@ -86,6 +90,34 @@ note right of ArchitectureController::getJ3ControllerAllowEdit
|
||||
since: 3.2.0
|
||||
return: J3ControllerAllowEdit
|
||||
end note
|
||||
|
||||
note left of ArchitectureController::getAllowEditViews
|
||||
Get The AllowEditViewsInterface Class.
|
||||
|
||||
since: 5.0.2
|
||||
return: AllowEditViewsInterface
|
||||
end note
|
||||
|
||||
note right of ArchitectureController::getJ5ControllerAllowEditViews
|
||||
Get The AllowEditViews Class.
|
||||
|
||||
since: 5.0.2
|
||||
return: J5ControllerAllowEditViews
|
||||
end note
|
||||
|
||||
note left of ArchitectureController::getJ4ControllerAllowEditViews
|
||||
Get The AllowEditViews Class.
|
||||
|
||||
since: 5.0.2
|
||||
return: J4ControllerAllowEditViews
|
||||
end note
|
||||
|
||||
note right of ArchitectureController::getJ3ControllerAllowEditViews
|
||||
Get The AllowEditViews Class.
|
||||
|
||||
since: 5.0.2
|
||||
return: J3ControllerAllowEditViews
|
||||
end note
|
||||
|
||||
@enduml
|
||||
```
|
||||
|
@ -22,6 +22,10 @@ use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Architecture\Controller\Allo
|
||||
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\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;
|
||||
|
||||
|
||||
/**
|
||||
@ -72,6 +76,18 @@ class ArchitectureController implements ServiceProviderInterface
|
||||
|
||||
$container->alias(J3ControllerAllowEdit::class, 'Architecture.Controller.J3.AllowEdit')
|
||||
->share('Architecture.Controller.J3.AllowEdit', [$this, 'getJ3ControllerAllowEdit'], true);
|
||||
|
||||
$container->alias(AllowEditViewsInterface::class, 'Architecture.Controller.AllowEditViews')
|
||||
->share('Architecture.Controller.AllowEditViews', [$this, 'getAllowEditViews'], true);
|
||||
|
||||
$container->alias(J5ControllerAllowEditViews::class, 'Architecture.Controller.J5.AllowEditViews')
|
||||
->share('Architecture.Controller.J5.AllowEditViews', [$this, 'getJ5ControllerAllowEditViews'], true);
|
||||
|
||||
$container->alias(J4ControllerAllowEditViews::class, 'Architecture.Controller.J4.AllowEditViews')
|
||||
->share('Architecture.Controller.J4.AllowEditViews', [$this, 'getJ4ControllerAllowEditViews'], true);
|
||||
|
||||
$container->alias(J3ControllerAllowEditViews::class, 'Architecture.Controller.J3.AllowEditViews')
|
||||
->share('Architecture.Controller.J3.AllowEditViews', [$this, 'getJ3ControllerAllowEditViews'], true);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -216,6 +232,78 @@ class ArchitectureController implements ServiceProviderInterface
|
||||
$container->get('Compiler.Builder.Category'),
|
||||
$container->get('Compiler.Builder.Category.Other.Name')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The AllowEditViewsInterface Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return AllowEditViewsInterface
|
||||
* @since 5.0.2
|
||||
*/
|
||||
public function getAllowEditViews(Container $container): AllowEditViewsInterface
|
||||
{
|
||||
if (empty($this->targetVersion))
|
||||
{
|
||||
$this->targetVersion = $container->get('Config')->joomla_version;
|
||||
}
|
||||
|
||||
return $container->get('Architecture.Controller.J' . $this->targetVersion . '.AllowEditViews');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The AllowEditViews Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return J5ControllerAllowEdit
|
||||
* @since 5.0.2
|
||||
*/
|
||||
public function getJ5ControllerAllowEditViews(Container $container): J5ControllerAllowEditViews
|
||||
{
|
||||
return new J5ControllerAllowEditViews(
|
||||
$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.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return J4ControllerAllowEditViews
|
||||
* @since 5.0.2
|
||||
*/
|
||||
public function getJ4ControllerAllowEditViews(Container $container): J4ControllerAllowEditViews
|
||||
{
|
||||
return new J4ControllerAllowEditViews(
|
||||
$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.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return J3ControllerAllowEditViews
|
||||
* @since 5.0.2
|
||||
*/
|
||||
public function getJ3ControllerAllowEditViews(Container $container): J3ControllerAllowEditViews
|
||||
{
|
||||
return new J3ControllerAllowEditViews(
|
||||
$container->get('Compiler.Creator.Permission'),
|
||||
$container->get('Customcode.Dispenser'),
|
||||
$container->get('Compiler.Builder.Category'),
|
||||
$container->get('Compiler.Builder.Category.Other.Name')
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -39,6 +39,18 @@
|
||||
|
||||
$container->alias(J3ControllerAllowEdit::class, 'Architecture.Controller.J3.AllowEdit')
|
||||
->share('Architecture.Controller.J3.AllowEdit', [$this, 'getJ3ControllerAllowEdit'], true);
|
||||
|
||||
$container->alias(AllowEditViewsInterface::class, 'Architecture.Controller.AllowEditViews')
|
||||
->share('Architecture.Controller.AllowEditViews', [$this, 'getAllowEditViews'], true);
|
||||
|
||||
$container->alias(J5ControllerAllowEditViews::class, 'Architecture.Controller.J5.AllowEditViews')
|
||||
->share('Architecture.Controller.J5.AllowEditViews', [$this, 'getJ5ControllerAllowEditViews'], true);
|
||||
|
||||
$container->alias(J4ControllerAllowEditViews::class, 'Architecture.Controller.J4.AllowEditViews')
|
||||
->share('Architecture.Controller.J4.AllowEditViews', [$this, 'getJ4ControllerAllowEditViews'], true);
|
||||
|
||||
$container->alias(J3ControllerAllowEditViews::class, 'Architecture.Controller.J3.AllowEditViews')
|
||||
->share('Architecture.Controller.J3.AllowEditViews', [$this, 'getJ3ControllerAllowEditViews'], true);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -183,4 +195,76 @@
|
||||
$container->get('Compiler.Builder.Category'),
|
||||
$container->get('Compiler.Builder.Category.Other.Name')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The AllowEditViewsInterface Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return AllowEditViewsInterface
|
||||
* @since 5.0.2
|
||||
*/
|
||||
public function getAllowEditViews(Container $container): AllowEditViewsInterface
|
||||
{
|
||||
if (empty($this->targetVersion))
|
||||
{
|
||||
$this->targetVersion = $container->get('Config')->joomla_version;
|
||||
}
|
||||
|
||||
return $container->get('Architecture.Controller.J' . $this->targetVersion . '.AllowEditViews');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The AllowEditViews Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return J5ControllerAllowEdit
|
||||
* @since 5.0.2
|
||||
*/
|
||||
public function getJ5ControllerAllowEditViews(Container $container): J5ControllerAllowEditViews
|
||||
{
|
||||
return new J5ControllerAllowEditViews(
|
||||
$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.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return J4ControllerAllowEditViews
|
||||
* @since 5.0.2
|
||||
*/
|
||||
public function getJ4ControllerAllowEditViews(Container $container): J4ControllerAllowEditViews
|
||||
{
|
||||
return new J4ControllerAllowEditViews(
|
||||
$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.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return J3ControllerAllowEditViews
|
||||
* @since 5.0.2
|
||||
*/
|
||||
public function getJ3ControllerAllowEditViews(Container $container): J3ControllerAllowEditViews
|
||||
{
|
||||
return new J3ControllerAllowEditViews(
|
||||
$container->get('Compiler.Creator.Permission'),
|
||||
$container->get('Customcode.Dispenser'),
|
||||
$container->get('Compiler.Builder.Category'),
|
||||
$container->get('Compiler.Builder.Category.Other.Name')
|
||||
);
|
||||
}
|
@ -16,33 +16,49 @@
|
||||
"use": "c9700450-4f44-4455-bc86-6a7660daadee",
|
||||
"as": "default"
|
||||
},
|
||||
"use_selection6": {
|
||||
"use_selection1": {
|
||||
"use": "005fce79-1b62-4a93-8d5e-8c89fee1afc6",
|
||||
"as": "J5ControllerAllowAdd"
|
||||
},
|
||||
"use_selection1": {
|
||||
"use_selection2": {
|
||||
"use": "425b1107-933d-4436-87ac-63540ec101c5",
|
||||
"as": "J4ControllerAllowAdd"
|
||||
},
|
||||
"use_selection2": {
|
||||
"use_selection3": {
|
||||
"use": "f21388dc-5ddc-4970-a3c2-55f075024762",
|
||||
"as": "J3ControllerAllowAdd"
|
||||
},
|
||||
"use_selection3": {
|
||||
"use_selection4": {
|
||||
"use": "992a842f-1ba9-4a5c-b214-042459ffe038",
|
||||
"as": "default"
|
||||
},
|
||||
"use_selection7": {
|
||||
"use_selection5": {
|
||||
"use": "e85175fd-e297-46df-a497-27f7a37190fd",
|
||||
"as": "J5ControllerAllowEdit"
|
||||
},
|
||||
"use_selection4": {
|
||||
"use_selection6": {
|
||||
"use": "ddf31f4b-96ba-46e7-8100-f48e1cefe533",
|
||||
"as": "J4ControllerAllowEdit"
|
||||
},
|
||||
"use_selection5": {
|
||||
"use_selection7": {
|
||||
"use": "8faaed82-522d-4f78-bd43-0ab3f7c72e5f",
|
||||
"as": "J3ControllerAllowEdit"
|
||||
},
|
||||
"use_selection8": {
|
||||
"use": "025d5903-cfdf-4624-aebb-10d02075e265",
|
||||
"as": "default"
|
||||
},
|
||||
"use_selection9": {
|
||||
"use": "7ecd7318-8bea-4321-8f13-626da1ab01c7",
|
||||
"as": "J5ControllerAllowEditViews"
|
||||
},
|
||||
"use_selection10": {
|
||||
"use": "c2453304-c9ac-4d67-a045-fbda68876434",
|
||||
"as": "J4ControllerAllowEditViews"
|
||||
},
|
||||
"use_selection11": {
|
||||
"use": "bdb74844-7cba-4227-a01c-355eba5fd031",
|
||||
"as": "J3ControllerAllowEditViews"
|
||||
}
|
||||
},
|
||||
"extendsinterfaces": null,
|
||||
|
@ -15,14 +15,19 @@ class Autoloader #Gold {
|
||||
# Power $power
|
||||
# Config $config
|
||||
# Content $content
|
||||
# string $installerhelper
|
||||
# string $helper
|
||||
+ __construct(Power $power, Config $config, ...)
|
||||
+ setFiles() : void
|
||||
+ set() : void
|
||||
- getHelperAutoloader() : string
|
||||
- getAutoloaderCode() : string
|
||||
- getAutoloaderFile(int $tabSpace, string $area = 'JPATH_ADMINISTRATOR') : ?string
|
||||
- getAutoloader(int $tabSpace) : ?string
|
||||
- getComposer(int $tabSpace) : ?string
|
||||
- getAutoloader() : ?string
|
||||
- getComposer() : ?string
|
||||
- getAutoloaderInstallArray() : string
|
||||
- getAutoloaderInstallerCode() : string
|
||||
- getInstallerAutoloader() : ?string
|
||||
- getInstallerComposer() : ?string
|
||||
}
|
||||
|
||||
note right of Autoloader::__construct
|
||||
@ -36,7 +41,7 @@ note right of Autoloader::__construct
|
||||
Content $content
|
||||
end note
|
||||
|
||||
note right of Autoloader::setFiles
|
||||
note left of Autoloader::setFiles
|
||||
Set the autoloader into the active content array
|
||||
|
||||
since: 3.2.0
|
||||
@ -50,8 +55,8 @@ note right of Autoloader::set
|
||||
return: void
|
||||
end note
|
||||
|
||||
note right of Autoloader::getHelperAutoloader
|
||||
Get helper autoloader code
|
||||
note left of Autoloader::getAutoloaderCode
|
||||
Get autoloader code
|
||||
|
||||
since: 3.2.0
|
||||
return: string
|
||||
@ -64,7 +69,7 @@ note right of Autoloader::getAutoloaderFile
|
||||
return: ?string
|
||||
end note
|
||||
|
||||
note right of Autoloader::getAutoloader
|
||||
note left of Autoloader::getAutoloader
|
||||
Get autoloader code
|
||||
|
||||
since: 3.2.0
|
||||
@ -77,6 +82,34 @@ note right of Autoloader::getComposer
|
||||
since: 3.2.0
|
||||
return: ?string
|
||||
end note
|
||||
|
||||
note left of Autoloader::getAutoloaderInstallArray
|
||||
Get autoloaders for install file
|
||||
|
||||
since: 5.0.2
|
||||
return: string
|
||||
end note
|
||||
|
||||
note right of Autoloader::getAutoloaderInstallerCode
|
||||
Get installer autoloader code
|
||||
|
||||
since: 5.0.2
|
||||
return: string
|
||||
end note
|
||||
|
||||
note left of Autoloader::getInstallerAutoloader
|
||||
Get autoloader code
|
||||
|
||||
since: 3.2.0
|
||||
return: ?string
|
||||
end note
|
||||
|
||||
note right of Autoloader::getInstallerComposer
|
||||
Get the composer autoloader routine (NOT READY)
|
||||
|
||||
since: 3.2.0
|
||||
return: ?string
|
||||
end note
|
||||
|
||||
@enduml
|
||||
```
|
||||
|
@ -51,6 +51,14 @@ class Autoloader
|
||||
*/
|
||||
protected Content $content;
|
||||
|
||||
/**
|
||||
* Installer Class Autoloader
|
||||
*
|
||||
* @var string
|
||||
* @since 5.0.2
|
||||
**/
|
||||
protected string $installerhelper = '';
|
||||
|
||||
/**
|
||||
* Helper Class Autoloader
|
||||
*
|
||||
@ -77,6 +85,7 @@ class Autoloader
|
||||
// reset all autoloaders power placeholders
|
||||
$this->content->set('ADMIN_POWER_HELPER', '');
|
||||
$this->content->set('SITE_POWER_HELPER', '');
|
||||
$this->content->set('INSTALLER_POWER_HELPER', '');
|
||||
$this->content->set('PLUGIN_POWER_AUTOLOADER', '');
|
||||
$this->content->set('SITE_PLUGIN_POWER_AUTOLOADER', '');
|
||||
$this->content->set('POWER_AUTOLOADER', '');
|
||||
@ -89,6 +98,7 @@ class Autoloader
|
||||
$this->content->set('SITE_TWO_POWER_AUTOLOADER', '');
|
||||
$this->content->set('SITE_THREE_POWER_AUTOLOADER', '');
|
||||
$this->content->set('SITE_FOUR_POWER_AUTOLOADER', '');
|
||||
$this->content->set('INSTALLER_POWER_AUTOLOADER_ARRAY', '');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -118,6 +128,9 @@ class Autoloader
|
||||
// to add to custom files
|
||||
$this->content->add('POWER_AUTOLOADER', $this->getAutoloaderFile(0));
|
||||
$this->content->add('SITE_POWER_AUTOLOADER', $this->getAutoloaderFile(0, 'JPATH_SITE'));
|
||||
|
||||
// to add to install file
|
||||
$this->content->add('INSTALLER_POWER_AUTOLOADER_ARRAY', $this->getAutoloaderInstallArray());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -147,20 +160,23 @@ class Autoloader
|
||||
uksort($this->power->namespace, fn($a, $b) => strlen((string) $b) - strlen((string) $a));
|
||||
|
||||
// load to admin helper class
|
||||
$this->content->add('ADMIN_POWER_HELPER', $this->getHelperAutoloader());
|
||||
$this->content->add('ADMIN_POWER_HELPER', $this->getAutoloaderCode());
|
||||
|
||||
// load to site helper class if needed
|
||||
$this->content->add('SITE_POWER_HELPER', $this->getHelperAutoloader());
|
||||
$this->content->add('SITE_POWER_HELPER', $this->getAutoloaderCode());
|
||||
|
||||
// load to installer helper class if needed
|
||||
$this->content->add('INSTALLER_POWER_HELPER', $this->getAutoloaderInstallerCode());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get helper autoloader code
|
||||
* Get autoloader code
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
*/
|
||||
private function getHelperAutoloader(): string
|
||||
private function getAutoloaderCode(): string
|
||||
{
|
||||
// check if it was already build
|
||||
if (!empty($this->helper))
|
||||
@ -172,13 +188,13 @@ class Autoloader
|
||||
$code = [];
|
||||
|
||||
// add the composer stuff here
|
||||
if (($script = $this->getComposer(0)) !== null)
|
||||
if (($script = $this->getComposer()) !== null)
|
||||
{
|
||||
$code[] = $script;
|
||||
}
|
||||
|
||||
// get the helper autoloader
|
||||
if (($script = $this->getAutoloader(0)) !== null)
|
||||
if (($script = $this->getAutoloader()) !== null)
|
||||
{
|
||||
$code[] = $script;
|
||||
}
|
||||
@ -203,7 +219,7 @@ class Autoloader
|
||||
*/
|
||||
private function getAutoloaderFile(int $tabSpace, string $area = 'JPATH_ADMINISTRATOR'): ?string
|
||||
{
|
||||
// we start building the autoloaded file loader
|
||||
// we start building the autoloader file loader
|
||||
$autoload_file = [];
|
||||
$autoload_file[] = Indent::_($tabSpace) . '//'
|
||||
. Line::_(__Line__, __Class__) . " The power autoloader for this project ($area) area.";
|
||||
@ -221,23 +237,21 @@ class Autoloader
|
||||
/**
|
||||
* Get autoloader code
|
||||
*
|
||||
* @param int $tabSpace The dynamic tab spacer
|
||||
*
|
||||
* @return string|null
|
||||
* @since 3.2.0
|
||||
*/
|
||||
private function getAutoloader(int $tabSpace): ?string
|
||||
private function getAutoloader(): ?string
|
||||
{
|
||||
if (($size = ArrayHelper::check($this->power->namespace)) > 0)
|
||||
{
|
||||
// we start building the spl_autoload_register function call
|
||||
$autoload_method = [];
|
||||
$autoload_method[] = Indent::_($tabSpace) . '//'
|
||||
$autoload_method[] = '//'
|
||||
. Line::_(__Line__, __Class__) . ' register additional namespace';
|
||||
$autoload_method[] = Indent::_($tabSpace) . 'spl_autoload_register(function ($class) {';
|
||||
$autoload_method[] = Indent::_($tabSpace) . Indent::_(1) . '//'
|
||||
$autoload_method[] = 'spl_autoload_register(function ($class) {';
|
||||
$autoload_method[] = Indent::_(1) . '//'
|
||||
. Line::_(__Line__, __Class__) . ' project-specific base directories and namespace prefix';
|
||||
$autoload_method[] = Indent::_($tabSpace) . Indent::_(1) . '$search = [';
|
||||
$autoload_method[] = Indent::_(1) . '$search = [';
|
||||
|
||||
// counter to manage the comma in the actual array
|
||||
$counter = 1;
|
||||
@ -246,63 +260,63 @@ class Autoloader
|
||||
// don't add the ending comma on last value
|
||||
if ($size == $counter)
|
||||
{
|
||||
$autoload_method[] = Indent::_($tabSpace) . Indent::_(2) . "'" . $this->config->get('jcb_powers_path', 'libraries/jcb_powers') . "/$base_dir' => '" . implode('\\\\', $prefix) . "'";
|
||||
$autoload_method[] = Indent::_(2) . "'" . $this->config->get('jcb_powers_path', 'libraries/jcb_powers') . "/$base_dir' => '" . implode('\\\\', $prefix) . "'";
|
||||
}
|
||||
else
|
||||
{
|
||||
$autoload_method[] = Indent::_($tabSpace) . Indent::_(2) . "'" . $this->config->get('jcb_powers_path', 'libraries/jcb_powers') . "/$base_dir' => '" . implode('\\\\', $prefix) . "',";
|
||||
$autoload_method[] = Indent::_(2) . "'" . $this->config->get('jcb_powers_path', 'libraries/jcb_powers') . "/$base_dir' => '" . implode('\\\\', $prefix) . "',";
|
||||
}
|
||||
$counter++;
|
||||
}
|
||||
$autoload_method[] = Indent::_($tabSpace) . Indent::_(1) . '];';
|
||||
$autoload_method[] = Indent::_($tabSpace) . Indent::_(1) . '// Start the search and load if found';
|
||||
$autoload_method[] = Indent::_($tabSpace) . Indent::_(1) . '$found = false;';
|
||||
$autoload_method[] = Indent::_($tabSpace) . Indent::_(1) . '$found_base_dir = "";';
|
||||
$autoload_method[] = Indent::_($tabSpace) . Indent::_(1) . '$found_len = 0;';
|
||||
$autoload_method[] = Indent::_($tabSpace) . Indent::_(1) . 'foreach ($search as $base_dir => $prefix)';
|
||||
$autoload_method[] = Indent::_($tabSpace) . Indent::_(1) . '{';
|
||||
$autoload_method[] = Indent::_($tabSpace) . Indent::_(2) . '//'
|
||||
$autoload_method[] = Indent::_(1) . '];';
|
||||
$autoload_method[] = Indent::_(1) . '// Start the search and load if found';
|
||||
$autoload_method[] = Indent::_(1) . '$found = false;';
|
||||
$autoload_method[] = Indent::_(1) . '$found_base_dir = "";';
|
||||
$autoload_method[] = Indent::_(1) . '$found_len = 0;';
|
||||
$autoload_method[] = Indent::_(1) . 'foreach ($search as $base_dir => $prefix)';
|
||||
$autoload_method[] = Indent::_(1) . '{';
|
||||
$autoload_method[] = Indent::_(2) . '//'
|
||||
. Line::_(__Line__, __Class__) . ' does the class use the namespace prefix?';
|
||||
$autoload_method[] = Indent::_($tabSpace) . Indent::_(2) . '$len = strlen($prefix);';
|
||||
$autoload_method[] = Indent::_($tabSpace) . Indent::_(2) . 'if (strncmp($prefix, $class, $len) === 0)';
|
||||
$autoload_method[] = Indent::_($tabSpace) . Indent::_(2) . '{';
|
||||
$autoload_method[] = Indent::_($tabSpace) . Indent::_(3) . '//'
|
||||
$autoload_method[] = Indent::_(2) . '$len = strlen($prefix);';
|
||||
$autoload_method[] = Indent::_(2) . 'if (strncmp($prefix, $class, $len) === 0)';
|
||||
$autoload_method[] = Indent::_(2) . '{';
|
||||
$autoload_method[] = Indent::_(3) . '//'
|
||||
. Line::_(__Line__, __Class__) . ' we have a match so load the values';
|
||||
$autoload_method[] = Indent::_($tabSpace) . Indent::_(3) . '$found = true;';
|
||||
$autoload_method[] = Indent::_($tabSpace) . Indent::_(3) . '$found_base_dir = $base_dir;';
|
||||
$autoload_method[] = Indent::_($tabSpace) . Indent::_(3) . '$found_len = $len;';
|
||||
$autoload_method[] = Indent::_($tabSpace) . Indent::_(3) . '//'
|
||||
$autoload_method[] = Indent::_(3) . '$found = true;';
|
||||
$autoload_method[] = Indent::_(3) . '$found_base_dir = $base_dir;';
|
||||
$autoload_method[] = Indent::_(3) . '$found_len = $len;';
|
||||
$autoload_method[] = Indent::_(3) . '//'
|
||||
. Line::_(__Line__, __Class__) . ' done here';
|
||||
$autoload_method[] = Indent::_($tabSpace) . Indent::_(3) . 'break;';
|
||||
$autoload_method[] = Indent::_($tabSpace) . Indent::_(2) . '}';
|
||||
$autoload_method[] = Indent::_($tabSpace) . Indent::_(1) . '}';
|
||||
$autoload_method[] = Indent::_(3) . 'break;';
|
||||
$autoload_method[] = Indent::_(2) . '}';
|
||||
$autoload_method[] = Indent::_(1) . '}';
|
||||
|
||||
$autoload_method[] = Indent::_($tabSpace) . Indent::_(1) . '//'
|
||||
$autoload_method[] = Indent::_(1) . '//'
|
||||
. Line::_(__Line__, __Class__) . ' check if we found a match';
|
||||
$autoload_method[] = Indent::_($tabSpace) . Indent::_(1) . 'if (!$found)';
|
||||
$autoload_method[] = Indent::_($tabSpace) . Indent::_(1) . '{';
|
||||
$autoload_method[] = Indent::_(1) . 'if (!$found)';
|
||||
$autoload_method[] = Indent::_(1) . '{';
|
||||
|
||||
$autoload_method[] = Indent::_($tabSpace) . Indent::_(2) . '//'
|
||||
$autoload_method[] = Indent::_(2) . '//'
|
||||
. Line::_(__Line__, __Class__) . ' not found so move to the next registered autoloader';
|
||||
$autoload_method[] = Indent::_($tabSpace) . Indent::_(2) . 'return;';
|
||||
$autoload_method[] = Indent::_(2) . 'return;';
|
||||
|
||||
$autoload_method[] = Indent::_($tabSpace) . Indent::_(1) . '}';
|
||||
$autoload_method[] = Indent::_(1) . '}';
|
||||
|
||||
$autoload_method[] = Indent::_($tabSpace) . Indent::_(1) . '//'
|
||||
$autoload_method[] = Indent::_(1) . '//'
|
||||
. Line::_(__Line__, __Class__) . ' get the relative class name';
|
||||
$autoload_method[] = Indent::_($tabSpace) . Indent::_(1) . '$relative_class = substr($class, $found_len);';
|
||||
$autoload_method[] = Indent::_($tabSpace) . Indent::_(1) . '//'
|
||||
$autoload_method[] = Indent::_(1) . '$relative_class = substr($class, $found_len);';
|
||||
$autoload_method[] = Indent::_(1) . '//'
|
||||
. Line::_(__Line__, __Class__) . ' replace the namespace prefix with the base directory, replace namespace';
|
||||
$autoload_method[] = Indent::_($tabSpace) . Indent::_(1) . '// separators with directory separators in the relative class name, append';
|
||||
$autoload_method[] = Indent::_($tabSpace) . Indent::_(1) . '// with .php';
|
||||
$autoload_method[] = Indent::_($tabSpace) . Indent::_(1) . "\$file = JPATH_ROOT . '/' . \$found_base_dir . '/src' . str_replace('\\\\', '/', \$relative_class) . '.php';";
|
||||
$autoload_method[] = Indent::_($tabSpace) . Indent::_(1) . '//'
|
||||
$autoload_method[] = Indent::_(1) . '// separators with directory separators in the relative class name, append';
|
||||
$autoload_method[] = Indent::_(1) . '// with .php';
|
||||
$autoload_method[] = Indent::_(1) . "\$file = JPATH_ROOT . '/' . \$found_base_dir . '/src' . str_replace('\\\\', '/', \$relative_class) . '.php';";
|
||||
$autoload_method[] = Indent::_(1) . '//'
|
||||
. Line::_(__Line__, __Class__) . ' if the file exists, require it';
|
||||
$autoload_method[] = Indent::_($tabSpace) . Indent::_(1) . 'if (file_exists($file))';
|
||||
$autoload_method[] = Indent::_($tabSpace) . Indent::_(1) . '{';
|
||||
$autoload_method[] = Indent::_($tabSpace) . Indent::_(2) . 'require $file;';
|
||||
$autoload_method[] = Indent::_($tabSpace) . Indent::_(1) . '}';
|
||||
$autoload_method[] = Indent::_($tabSpace) . '});';
|
||||
$autoload_method[] = Indent::_(1) . 'if (file_exists($file))';
|
||||
$autoload_method[] = Indent::_(1) . '{';
|
||||
$autoload_method[] = Indent::_(2) . 'require $file;';
|
||||
$autoload_method[] = Indent::_(1) . '}';
|
||||
$autoload_method[] = '});';
|
||||
|
||||
return implode(PHP_EOL, $autoload_method);
|
||||
}
|
||||
@ -313,12 +327,10 @@ class Autoloader
|
||||
/**
|
||||
* Get the composer autoloader routine
|
||||
*
|
||||
* @param int $tabSpace The dynamic tab spacer
|
||||
*
|
||||
* @return string|null
|
||||
* @since 3.2.0
|
||||
*/
|
||||
private function getComposer(int $tabSpace): ?string
|
||||
private function getComposer(): ?string
|
||||
{
|
||||
if (ArrayHelper::check($this->power->composer))
|
||||
{
|
||||
@ -332,11 +344,11 @@ class Autoloader
|
||||
// don't add the ending comma on last value
|
||||
if (empty($add_once[$access_point]))
|
||||
{
|
||||
$composer_routine[] = Indent::_($tabSpace) . "\$composer_autoloader = JPATH_LIBRARIES . '/$access_point';";
|
||||
$composer_routine[] = Indent::_($tabSpace) . 'if (file_exists($composer_autoloader))';
|
||||
$composer_routine[] = Indent::_($tabSpace) . "{";
|
||||
$composer_routine[] = Indent::_($tabSpace) . Indent::_(1) . 'require_once $composer_autoloader;';
|
||||
$composer_routine[] = Indent::_($tabSpace) . "}";
|
||||
$composer_routine[] = "\$composer_autoloader = JPATH_LIBRARIES . '/$access_point';";
|
||||
$composer_routine[] = 'if (file_exists($composer_autoloader))';
|
||||
$composer_routine[] = "{";
|
||||
$composer_routine[] = Indent::_(1) . 'require_once $composer_autoloader;';
|
||||
$composer_routine[] = "}";
|
||||
|
||||
$add_once[$access_point] = true;
|
||||
}
|
||||
@ -345,12 +357,209 @@ class Autoloader
|
||||
// this is just about the [autoloader or autoloaders] in the comment ;)
|
||||
if (count($add_once) == 1)
|
||||
{
|
||||
array_unshift($composer_routine, Indent::_($tabSpace) . '//'
|
||||
array_unshift($composer_routine, '//'
|
||||
. Line::_(__Line__, __Class__) . ' add the autoloader for the composer classes');
|
||||
}
|
||||
else
|
||||
{
|
||||
array_unshift($composer_routine, Indent::_($tabSpace) . '//'
|
||||
array_unshift($composer_routine, '//'
|
||||
. Line::_(__Line__, __Class__) . ' add the autoloaders for the composer classes');
|
||||
}
|
||||
|
||||
return implode(PHP_EOL, $composer_routine);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get autoloaders for install file
|
||||
*
|
||||
* @return string
|
||||
* @since 5.0.2
|
||||
*/
|
||||
private function getAutoloaderInstallArray(): string
|
||||
{
|
||||
// we start building the autoloader file loader
|
||||
$autoload_file = [];
|
||||
$autoload_file[] = PHP_EOL . Indent::_(3) . "__DIR__ . '/" .
|
||||
$this->config->get('component_installer_autoloader_path', 'ERROR') . "',";
|
||||
$autoload_file[] = Indent::_(3) . "JPATH_ADMINISTRATOR . '/components/com_"
|
||||
. $this->config->get('component_code_name', 'ERROR') . '/'
|
||||
. $this->config->get('component_autoloader_path', 'ERROR') . "'" . PHP_EOL . Indent::_(2);
|
||||
|
||||
return implode(PHP_EOL, $autoload_file);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get installer autoloader code
|
||||
*
|
||||
* @return string
|
||||
* @since 5.0.2
|
||||
*/
|
||||
private function getAutoloaderInstallerCode(): string
|
||||
{
|
||||
// check if it was already build
|
||||
if (!empty($this->installerhelper))
|
||||
{
|
||||
return $this->installerhelper;
|
||||
}
|
||||
|
||||
// load the code
|
||||
$code = [];
|
||||
|
||||
// add the composer stuff here
|
||||
// if (($script = $this->getInstallerComposer()) !== null)
|
||||
// {
|
||||
// $code[] = $script;
|
||||
// }
|
||||
|
||||
// get the helper autoloader
|
||||
if (($script = $this->getInstallerAutoloader()) !== null)
|
||||
{
|
||||
$code[] = $script;
|
||||
}
|
||||
|
||||
// if we have any
|
||||
if (!empty($code))
|
||||
{
|
||||
$this->installerhelper = PHP_EOL . PHP_EOL . implode(PHP_EOL . PHP_EOL, $code);
|
||||
}
|
||||
|
||||
return $this->installerhelper;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get autoloader code
|
||||
*
|
||||
*
|
||||
* @return string|null
|
||||
* @since 3.2.0
|
||||
*/
|
||||
private function getInstallerAutoloader(): ?string
|
||||
{
|
||||
if (($size = ArrayHelper::check($this->power->namespace)) > 0)
|
||||
{
|
||||
// we start building the spl_autoload_register function call
|
||||
$autoload_method = [];
|
||||
$autoload_method[] = '//'
|
||||
. Line::_(__Line__, __Class__) . ' register additional namespace';
|
||||
$autoload_method[] = 'spl_autoload_register(function ($class) {';
|
||||
$autoload_method[] = Indent::_(1) . '//'
|
||||
. Line::_(__Line__, __Class__) . ' project-specific base directories and namespace prefix';
|
||||
$autoload_method[] = Indent::_(1) . '$search = [';
|
||||
|
||||
// counter to manage the comma in the actual array
|
||||
$counter = 1;
|
||||
foreach ($this->power->namespace as $base_dir => $prefix)
|
||||
{
|
||||
// don't add the ending comma on last value
|
||||
if ($size == $counter)
|
||||
{
|
||||
$autoload_method[] = Indent::_(2) . "'" . $this->config->get('jcb_powers_path', 'libraries/jcb_powers') . "/$base_dir' => '" . implode('\\\\', $prefix) . "'";
|
||||
}
|
||||
else
|
||||
{
|
||||
$autoload_method[] = Indent::_(2) . "'" . $this->config->get('jcb_powers_path', 'libraries/jcb_powers') . "/$base_dir' => '" . implode('\\\\', $prefix) . "',";
|
||||
}
|
||||
$counter++;
|
||||
}
|
||||
$autoload_method[] = Indent::_(1) . '];';
|
||||
$autoload_method[] = Indent::_(1) . '// Start the search and load if found';
|
||||
$autoload_method[] = Indent::_(1) . '$found = false;';
|
||||
$autoload_method[] = Indent::_(1) . '$found_base_dir = "";';
|
||||
$autoload_method[] = Indent::_(1) . '$found_len = 0;';
|
||||
$autoload_method[] = Indent::_(1) . 'foreach ($search as $base_dir => $prefix)';
|
||||
$autoload_method[] = Indent::_(1) . '{';
|
||||
$autoload_method[] = Indent::_(2) . '//'
|
||||
. Line::_(__Line__, __Class__) . ' does the class use the namespace prefix?';
|
||||
$autoload_method[] = Indent::_(2) . '$len = strlen($prefix);';
|
||||
$autoload_method[] = Indent::_(2) . 'if (strncmp($prefix, $class, $len) === 0)';
|
||||
$autoload_method[] = Indent::_(2) . '{';
|
||||
$autoload_method[] = Indent::_(3) . '//'
|
||||
. Line::_(__Line__, __Class__) . ' we have a match so load the values';
|
||||
$autoload_method[] = Indent::_(3) . '$found = true;';
|
||||
$autoload_method[] = Indent::_(3) . '$found_base_dir = $base_dir;';
|
||||
$autoload_method[] = Indent::_(3) . '$found_len = $len;';
|
||||
$autoload_method[] = Indent::_(3) . '//'
|
||||
. Line::_(__Line__, __Class__) . ' done here';
|
||||
$autoload_method[] = Indent::_(3) . 'break;';
|
||||
$autoload_method[] = Indent::_(2) . '}';
|
||||
$autoload_method[] = Indent::_(1) . '}';
|
||||
|
||||
$autoload_method[] = Indent::_(1) . '//'
|
||||
. Line::_(__Line__, __Class__) . ' check if we found a match';
|
||||
$autoload_method[] = Indent::_(1) . 'if (!$found)';
|
||||
$autoload_method[] = Indent::_(1) . '{';
|
||||
|
||||
$autoload_method[] = Indent::_(2) . '//'
|
||||
. Line::_(__Line__, __Class__) . ' not found so move to the next registered autoloader';
|
||||
$autoload_method[] = Indent::_(2) . 'return;';
|
||||
|
||||
$autoload_method[] = Indent::_(1) . '}';
|
||||
|
||||
$autoload_method[] = Indent::_(1) . '//'
|
||||
. Line::_(__Line__, __Class__) . ' get the relative class name';
|
||||
$autoload_method[] = Indent::_(1) . '$relative_class = substr($class, $found_len);';
|
||||
$autoload_method[] = Indent::_(1) . '//'
|
||||
. Line::_(__Line__, __Class__) . ' replace the namespace prefix with the base directory, replace namespace';
|
||||
$autoload_method[] = Indent::_(1) . '// separators with directory separators in the relative class name, append';
|
||||
$autoload_method[] = Indent::_(1) . '// with .php';
|
||||
$autoload_method[] = Indent::_(1) . "\$file = __DIR__ . '/' . \$found_base_dir . '/src' . str_replace('\\\\', '/', \$relative_class) . '.php';";
|
||||
$autoload_method[] = Indent::_(1) . '//'
|
||||
. Line::_(__Line__, __Class__) . ' if the file exists, require it';
|
||||
$autoload_method[] = Indent::_(1) . 'if (file_exists($file))';
|
||||
$autoload_method[] = Indent::_(1) . '{';
|
||||
$autoload_method[] = Indent::_(2) . 'require $file;';
|
||||
$autoload_method[] = Indent::_(1) . '}';
|
||||
$autoload_method[] = '});';
|
||||
|
||||
return implode(PHP_EOL, $autoload_method);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the composer autoloader routine (NOT READY)
|
||||
*
|
||||
*
|
||||
* @return string|null
|
||||
* @since 3.2.0
|
||||
*/
|
||||
private function getInstallerComposer(): ?string
|
||||
{
|
||||
if (ArrayHelper::check($this->power->composer))
|
||||
{
|
||||
// load the composer routine
|
||||
$composer_routine = [];
|
||||
|
||||
// counter to manage the comma in the actual array
|
||||
$add_once = [];
|
||||
foreach ($this->power->composer as $access_point)
|
||||
{
|
||||
// don't add the ending comma on last value
|
||||
if (empty($add_once[$access_point]))
|
||||
{
|
||||
$composer_routine[] = "\$composer_autoloader = __DIR__ . '/libraries/$access_point';";
|
||||
$composer_routine[] = 'if (file_exists($composer_autoloader))';
|
||||
$composer_routine[] = "{";
|
||||
$composer_routine[] = Indent::_(1) . 'require_once $composer_autoloader;';
|
||||
$composer_routine[] = "}";
|
||||
|
||||
$add_once[$access_point] = true;
|
||||
}
|
||||
}
|
||||
|
||||
// this is just about the [autoloader or autoloaders] in the comment ;)
|
||||
if (count($add_once) == 1)
|
||||
{
|
||||
array_unshift($composer_routine, '//'
|
||||
. Line::_(__Line__, __Class__) . ' add the autoloader for the composer classes');
|
||||
}
|
||||
else
|
||||
{
|
||||
array_unshift($composer_routine, '//'
|
||||
. Line::_(__Line__, __Class__) . ' add the autoloaders for the composer classes');
|
||||
}
|
||||
|
||||
|
@ -22,6 +22,14 @@
|
||||
*/
|
||||
protected Content $content;
|
||||
|
||||
/**
|
||||
* Installer Class Autoloader
|
||||
*
|
||||
* @var string
|
||||
* @since 5.0.2
|
||||
**/
|
||||
protected string $installerhelper = '';
|
||||
|
||||
/**
|
||||
* Helper Class Autoloader
|
||||
*
|
||||
@ -48,6 +56,7 @@
|
||||
// reset all autoloaders power placeholders
|
||||
$this->content->set('ADMIN_POWER_HELPER', '');
|
||||
$this->content->set('SITE_POWER_HELPER', '');
|
||||
$this->content->set('INSTALLER_POWER_HELPER', '');
|
||||
$this->content->set('PLUGIN_POWER_AUTOLOADER', '');
|
||||
$this->content->set('SITE_PLUGIN_POWER_AUTOLOADER', '');
|
||||
$this->content->set('POWER_AUTOLOADER', '');
|
||||
@ -60,6 +69,7 @@
|
||||
$this->content->set('SITE_TWO_POWER_AUTOLOADER', '');
|
||||
$this->content->set('SITE_THREE_POWER_AUTOLOADER', '');
|
||||
$this->content->set('SITE_FOUR_POWER_AUTOLOADER', '');
|
||||
$this->content->set('INSTALLER_POWER_AUTOLOADER_ARRAY', '');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -89,6 +99,9 @@
|
||||
// to add to custom files
|
||||
$this->content->add('POWER_AUTOLOADER', $this->getAutoloaderFile(0));
|
||||
$this->content->add('SITE_POWER_AUTOLOADER', $this->getAutoloaderFile(0, 'JPATH_SITE'));
|
||||
|
||||
// to add to install file
|
||||
$this->content->add('INSTALLER_POWER_AUTOLOADER_ARRAY', $this->getAutoloaderInstallArray());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -118,20 +131,23 @@
|
||||
uksort($this->power->namespace, fn($a, $b) => strlen((string) $b) - strlen((string) $a));
|
||||
|
||||
// load to admin helper class
|
||||
$this->content->add('ADMIN_POWER_HELPER', $this->getHelperAutoloader());
|
||||
$this->content->add('ADMIN_POWER_HELPER', $this->getAutoloaderCode());
|
||||
|
||||
// load to site helper class if needed
|
||||
$this->content->add('SITE_POWER_HELPER', $this->getHelperAutoloader());
|
||||
$this->content->add('SITE_POWER_HELPER', $this->getAutoloaderCode());
|
||||
|
||||
// load to installer helper class if needed
|
||||
$this->content->add('INSTALLER_POWER_HELPER', $this->getAutoloaderInstallerCode());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get helper autoloader code
|
||||
* Get autoloader code
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
*/
|
||||
private function getHelperAutoloader(): string
|
||||
private function getAutoloaderCode(): string
|
||||
{
|
||||
// check if it was already build
|
||||
if (!empty($this->helper))
|
||||
@ -143,13 +159,13 @@
|
||||
$code = [];
|
||||
|
||||
// add the composer stuff here
|
||||
if (($script = $this->getComposer(0)) !== null)
|
||||
if (($script = $this->getComposer()) !== null)
|
||||
{
|
||||
$code[] = $script;
|
||||
}
|
||||
|
||||
// get the helper autoloader
|
||||
if (($script = $this->getAutoloader(0)) !== null)
|
||||
if (($script = $this->getAutoloader()) !== null)
|
||||
{
|
||||
$code[] = $script;
|
||||
}
|
||||
@ -174,7 +190,7 @@
|
||||
*/
|
||||
private function getAutoloaderFile(int $tabSpace, string $area = 'JPATH_ADMINISTRATOR'): ?string
|
||||
{
|
||||
// we start building the autoloaded file loader
|
||||
// we start building the autoloader file loader
|
||||
$autoload_file = [];
|
||||
$autoload_file[] = Indent::_($tabSpace) . '//'
|
||||
. Line::_(__Line__, __Class__) . " The power autoloader for this project ($area) area.";
|
||||
@ -192,23 +208,21 @@
|
||||
/**
|
||||
* Get autoloader code
|
||||
*
|
||||
* @param int $tabSpace The dynamic tab spacer
|
||||
*
|
||||
* @return string|null
|
||||
* @since 3.2.0
|
||||
*/
|
||||
private function getAutoloader(int $tabSpace): ?string
|
||||
private function getAutoloader(): ?string
|
||||
{
|
||||
if (($size = ArrayHelper::check($this->power->namespace)) > 0)
|
||||
{
|
||||
// we start building the spl_autoload_register function call
|
||||
$autoload_method = [];
|
||||
$autoload_method[] = Indent::_($tabSpace) . '//'
|
||||
$autoload_method[] = '//'
|
||||
. Line::_(__Line__, __Class__) . ' register additional namespace';
|
||||
$autoload_method[] = Indent::_($tabSpace) . 'spl_autoload_register(function ($class) {';
|
||||
$autoload_method[] = Indent::_($tabSpace) . Indent::_(1) . '//'
|
||||
$autoload_method[] = 'spl_autoload_register(function ($class) {';
|
||||
$autoload_method[] = Indent::_(1) . '//'
|
||||
. Line::_(__Line__, __Class__) . ' project-specific base directories and namespace prefix';
|
||||
$autoload_method[] = Indent::_($tabSpace) . Indent::_(1) . '$search = [';
|
||||
$autoload_method[] = Indent::_(1) . '$search = [';
|
||||
|
||||
// counter to manage the comma in the actual array
|
||||
$counter = 1;
|
||||
@ -217,63 +231,63 @@
|
||||
// don't add the ending comma on last value
|
||||
if ($size == $counter)
|
||||
{
|
||||
$autoload_method[] = Indent::_($tabSpace) . Indent::_(2) . "'" . $this->config->get('jcb_powers_path', 'libraries/jcb_powers') . "/$base_dir' => '" . implode('\\\\', $prefix) . "'";
|
||||
$autoload_method[] = Indent::_(2) . "'" . $this->config->get('jcb_powers_path', 'libraries/jcb_powers') . "/$base_dir' => '" . implode('\\\\', $prefix) . "'";
|
||||
}
|
||||
else
|
||||
{
|
||||
$autoload_method[] = Indent::_($tabSpace) . Indent::_(2) . "'" . $this->config->get('jcb_powers_path', 'libraries/jcb_powers') . "/$base_dir' => '" . implode('\\\\', $prefix) . "',";
|
||||
$autoload_method[] = Indent::_(2) . "'" . $this->config->get('jcb_powers_path', 'libraries/jcb_powers') . "/$base_dir' => '" . implode('\\\\', $prefix) . "',";
|
||||
}
|
||||
$counter++;
|
||||
}
|
||||
$autoload_method[] = Indent::_($tabSpace) . Indent::_(1) . '];';
|
||||
$autoload_method[] = Indent::_($tabSpace) . Indent::_(1) . '// Start the search and load if found';
|
||||
$autoload_method[] = Indent::_($tabSpace) . Indent::_(1) . '$found = false;';
|
||||
$autoload_method[] = Indent::_($tabSpace) . Indent::_(1) . '$found_base_dir = "";';
|
||||
$autoload_method[] = Indent::_($tabSpace) . Indent::_(1) . '$found_len = 0;';
|
||||
$autoload_method[] = Indent::_($tabSpace) . Indent::_(1) . 'foreach ($search as $base_dir => $prefix)';
|
||||
$autoload_method[] = Indent::_($tabSpace) . Indent::_(1) . '{';
|
||||
$autoload_method[] = Indent::_($tabSpace) . Indent::_(2) . '//'
|
||||
$autoload_method[] = Indent::_(1) . '];';
|
||||
$autoload_method[] = Indent::_(1) . '// Start the search and load if found';
|
||||
$autoload_method[] = Indent::_(1) . '$found = false;';
|
||||
$autoload_method[] = Indent::_(1) . '$found_base_dir = "";';
|
||||
$autoload_method[] = Indent::_(1) . '$found_len = 0;';
|
||||
$autoload_method[] = Indent::_(1) . 'foreach ($search as $base_dir => $prefix)';
|
||||
$autoload_method[] = Indent::_(1) . '{';
|
||||
$autoload_method[] = Indent::_(2) . '//'
|
||||
. Line::_(__Line__, __Class__) . ' does the class use the namespace prefix?';
|
||||
$autoload_method[] = Indent::_($tabSpace) . Indent::_(2) . '$len = strlen($prefix);';
|
||||
$autoload_method[] = Indent::_($tabSpace) . Indent::_(2) . 'if (strncmp($prefix, $class, $len) === 0)';
|
||||
$autoload_method[] = Indent::_($tabSpace) . Indent::_(2) . '{';
|
||||
$autoload_method[] = Indent::_($tabSpace) . Indent::_(3) . '//'
|
||||
$autoload_method[] = Indent::_(2) . '$len = strlen($prefix);';
|
||||
$autoload_method[] = Indent::_(2) . 'if (strncmp($prefix, $class, $len) === 0)';
|
||||
$autoload_method[] = Indent::_(2) . '{';
|
||||
$autoload_method[] = Indent::_(3) . '//'
|
||||
. Line::_(__Line__, __Class__) . ' we have a match so load the values';
|
||||
$autoload_method[] = Indent::_($tabSpace) . Indent::_(3) . '$found = true;';
|
||||
$autoload_method[] = Indent::_($tabSpace) . Indent::_(3) . '$found_base_dir = $base_dir;';
|
||||
$autoload_method[] = Indent::_($tabSpace) . Indent::_(3) . '$found_len = $len;';
|
||||
$autoload_method[] = Indent::_($tabSpace) . Indent::_(3) . '//'
|
||||
$autoload_method[] = Indent::_(3) . '$found = true;';
|
||||
$autoload_method[] = Indent::_(3) . '$found_base_dir = $base_dir;';
|
||||
$autoload_method[] = Indent::_(3) . '$found_len = $len;';
|
||||
$autoload_method[] = Indent::_(3) . '//'
|
||||
. Line::_(__Line__, __Class__) . ' done here';
|
||||
$autoload_method[] = Indent::_($tabSpace) . Indent::_(3) . 'break;';
|
||||
$autoload_method[] = Indent::_($tabSpace) . Indent::_(2) . '}';
|
||||
$autoload_method[] = Indent::_($tabSpace) . Indent::_(1) . '}';
|
||||
$autoload_method[] = Indent::_(3) . 'break;';
|
||||
$autoload_method[] = Indent::_(2) . '}';
|
||||
$autoload_method[] = Indent::_(1) . '}';
|
||||
|
||||
$autoload_method[] = Indent::_($tabSpace) . Indent::_(1) . '//'
|
||||
$autoload_method[] = Indent::_(1) . '//'
|
||||
. Line::_(__Line__, __Class__) . ' check if we found a match';
|
||||
$autoload_method[] = Indent::_($tabSpace) . Indent::_(1) . 'if (!$found)';
|
||||
$autoload_method[] = Indent::_($tabSpace) . Indent::_(1) . '{';
|
||||
$autoload_method[] = Indent::_(1) . 'if (!$found)';
|
||||
$autoload_method[] = Indent::_(1) . '{';
|
||||
|
||||
$autoload_method[] = Indent::_($tabSpace) . Indent::_(2) . '//'
|
||||
$autoload_method[] = Indent::_(2) . '//'
|
||||
. Line::_(__Line__, __Class__) . ' not found so move to the next registered autoloader';
|
||||
$autoload_method[] = Indent::_($tabSpace) . Indent::_(2) . 'return;';
|
||||
$autoload_method[] = Indent::_(2) . 'return;';
|
||||
|
||||
$autoload_method[] = Indent::_($tabSpace) . Indent::_(1) . '}';
|
||||
$autoload_method[] = Indent::_(1) . '}';
|
||||
|
||||
$autoload_method[] = Indent::_($tabSpace) . Indent::_(1) . '//'
|
||||
$autoload_method[] = Indent::_(1) . '//'
|
||||
. Line::_(__Line__, __Class__) . ' get the relative class name';
|
||||
$autoload_method[] = Indent::_($tabSpace) . Indent::_(1) . '$relative_class = substr($class, $found_len);';
|
||||
$autoload_method[] = Indent::_($tabSpace) . Indent::_(1) . '//'
|
||||
$autoload_method[] = Indent::_(1) . '$relative_class = substr($class, $found_len);';
|
||||
$autoload_method[] = Indent::_(1) . '//'
|
||||
. Line::_(__Line__, __Class__) . ' replace the namespace prefix with the base directory, replace namespace';
|
||||
$autoload_method[] = Indent::_($tabSpace) . Indent::_(1) . '// separators with directory separators in the relative class name, append';
|
||||
$autoload_method[] = Indent::_($tabSpace) . Indent::_(1) . '// with .php';
|
||||
$autoload_method[] = Indent::_($tabSpace) . Indent::_(1) . "\$file = JPATH_ROOT . '/' . \$found_base_dir . '/src' . str_replace('\\\\', '/', \$relative_class) . '.php';";
|
||||
$autoload_method[] = Indent::_($tabSpace) . Indent::_(1) . '//'
|
||||
$autoload_method[] = Indent::_(1) . '// separators with directory separators in the relative class name, append';
|
||||
$autoload_method[] = Indent::_(1) . '// with .php';
|
||||
$autoload_method[] = Indent::_(1) . "\$file = JPATH_ROOT . '/' . \$found_base_dir . '/src' . str_replace('\\\\', '/', \$relative_class) . '.php';";
|
||||
$autoload_method[] = Indent::_(1) . '//'
|
||||
. Line::_(__Line__, __Class__) . ' if the file exists, require it';
|
||||
$autoload_method[] = Indent::_($tabSpace) . Indent::_(1) . 'if (file_exists($file))';
|
||||
$autoload_method[] = Indent::_($tabSpace) . Indent::_(1) . '{';
|
||||
$autoload_method[] = Indent::_($tabSpace) . Indent::_(2) . 'require $file;';
|
||||
$autoload_method[] = Indent::_($tabSpace) . Indent::_(1) . '}';
|
||||
$autoload_method[] = Indent::_($tabSpace) . '});';
|
||||
$autoload_method[] = Indent::_(1) . 'if (file_exists($file))';
|
||||
$autoload_method[] = Indent::_(1) . '{';
|
||||
$autoload_method[] = Indent::_(2) . 'require $file;';
|
||||
$autoload_method[] = Indent::_(1) . '}';
|
||||
$autoload_method[] = '});';
|
||||
|
||||
return implode(PHP_EOL, $autoload_method);
|
||||
}
|
||||
@ -284,12 +298,10 @@
|
||||
/**
|
||||
* Get the composer autoloader routine
|
||||
*
|
||||
* @param int $tabSpace The dynamic tab spacer
|
||||
*
|
||||
* @return string|null
|
||||
* @since 3.2.0
|
||||
*/
|
||||
private function getComposer(int $tabSpace): ?string
|
||||
private function getComposer(): ?string
|
||||
{
|
||||
if (ArrayHelper::check($this->power->composer))
|
||||
{
|
||||
@ -303,11 +315,11 @@
|
||||
// don't add the ending comma on last value
|
||||
if (empty($add_once[$access_point]))
|
||||
{
|
||||
$composer_routine[] = Indent::_($tabSpace) . "\$composer_autoloader = JPATH_LIBRARIES . '/$access_point';";
|
||||
$composer_routine[] = Indent::_($tabSpace) . 'if (file_exists($composer_autoloader))';
|
||||
$composer_routine[] = Indent::_($tabSpace) . "{";
|
||||
$composer_routine[] = Indent::_($tabSpace) . Indent::_(1) . 'require_once $composer_autoloader;';
|
||||
$composer_routine[] = Indent::_($tabSpace) . "}";
|
||||
$composer_routine[] = "\$composer_autoloader = JPATH_LIBRARIES . '/$access_point';";
|
||||
$composer_routine[] = 'if (file_exists($composer_autoloader))';
|
||||
$composer_routine[] = "{";
|
||||
$composer_routine[] = Indent::_(1) . 'require_once $composer_autoloader;';
|
||||
$composer_routine[] = "}";
|
||||
|
||||
$add_once[$access_point] = true;
|
||||
}
|
||||
@ -316,12 +328,209 @@
|
||||
// this is just about the [autoloader or autoloaders] in the comment ;)
|
||||
if (count($add_once) == 1)
|
||||
{
|
||||
array_unshift($composer_routine, Indent::_($tabSpace) . '//'
|
||||
array_unshift($composer_routine, '//'
|
||||
. Line::_(__Line__, __Class__) . ' add the autoloader for the composer classes');
|
||||
}
|
||||
else
|
||||
{
|
||||
array_unshift($composer_routine, Indent::_($tabSpace) . '//'
|
||||
array_unshift($composer_routine, '//'
|
||||
. Line::_(__Line__, __Class__) . ' add the autoloaders for the composer classes');
|
||||
}
|
||||
|
||||
return implode(PHP_EOL, $composer_routine);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get autoloaders for install file
|
||||
*
|
||||
* @return string
|
||||
* @since 5.0.2
|
||||
*/
|
||||
private function getAutoloaderInstallArray(): string
|
||||
{
|
||||
// we start building the autoloader file loader
|
||||
$autoload_file = [];
|
||||
$autoload_file[] = PHP_EOL . Indent::_(3) . "__DIR__ . '/" .
|
||||
$this->config->get('component_installer_autoloader_path', 'ERROR') . "',";
|
||||
$autoload_file[] = Indent::_(3) . "JPATH_ADMINISTRATOR . '/components/com_"
|
||||
. $this->config->get('component_code_name', 'ERROR') . '/'
|
||||
. $this->config->get('component_autoloader_path', 'ERROR') . "'" . PHP_EOL . Indent::_(2);
|
||||
|
||||
return implode(PHP_EOL, $autoload_file);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get installer autoloader code
|
||||
*
|
||||
* @return string
|
||||
* @since 5.0.2
|
||||
*/
|
||||
private function getAutoloaderInstallerCode(): string
|
||||
{
|
||||
// check if it was already build
|
||||
if (!empty($this->installerhelper))
|
||||
{
|
||||
return $this->installerhelper;
|
||||
}
|
||||
|
||||
// load the code
|
||||
$code = [];
|
||||
|
||||
// add the composer stuff here
|
||||
// if (($script = $this->getInstallerComposer()) !== null)
|
||||
// {
|
||||
// $code[] = $script;
|
||||
// }
|
||||
|
||||
// get the helper autoloader
|
||||
if (($script = $this->getInstallerAutoloader()) !== null)
|
||||
{
|
||||
$code[] = $script;
|
||||
}
|
||||
|
||||
// if we have any
|
||||
if (!empty($code))
|
||||
{
|
||||
$this->installerhelper = PHP_EOL . PHP_EOL . implode(PHP_EOL . PHP_EOL, $code);
|
||||
}
|
||||
|
||||
return $this->installerhelper;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get autoloader code
|
||||
*
|
||||
*
|
||||
* @return string|null
|
||||
* @since 3.2.0
|
||||
*/
|
||||
private function getInstallerAutoloader(): ?string
|
||||
{
|
||||
if (($size = ArrayHelper::check($this->power->namespace)) > 0)
|
||||
{
|
||||
// we start building the spl_autoload_register function call
|
||||
$autoload_method = [];
|
||||
$autoload_method[] = '//'
|
||||
. Line::_(__Line__, __Class__) . ' register additional namespace';
|
||||
$autoload_method[] = 'spl_autoload_register(function ($class) {';
|
||||
$autoload_method[] = Indent::_(1) . '//'
|
||||
. Line::_(__Line__, __Class__) . ' project-specific base directories and namespace prefix';
|
||||
$autoload_method[] = Indent::_(1) . '$search = [';
|
||||
|
||||
// counter to manage the comma in the actual array
|
||||
$counter = 1;
|
||||
foreach ($this->power->namespace as $base_dir => $prefix)
|
||||
{
|
||||
// don't add the ending comma on last value
|
||||
if ($size == $counter)
|
||||
{
|
||||
$autoload_method[] = Indent::_(2) . "'" . $this->config->get('jcb_powers_path', 'libraries/jcb_powers') . "/$base_dir' => '" . implode('\\\\', $prefix) . "'";
|
||||
}
|
||||
else
|
||||
{
|
||||
$autoload_method[] = Indent::_(2) . "'" . $this->config->get('jcb_powers_path', 'libraries/jcb_powers') . "/$base_dir' => '" . implode('\\\\', $prefix) . "',";
|
||||
}
|
||||
$counter++;
|
||||
}
|
||||
$autoload_method[] = Indent::_(1) . '];';
|
||||
$autoload_method[] = Indent::_(1) . '// Start the search and load if found';
|
||||
$autoload_method[] = Indent::_(1) . '$found = false;';
|
||||
$autoload_method[] = Indent::_(1) . '$found_base_dir = "";';
|
||||
$autoload_method[] = Indent::_(1) . '$found_len = 0;';
|
||||
$autoload_method[] = Indent::_(1) . 'foreach ($search as $base_dir => $prefix)';
|
||||
$autoload_method[] = Indent::_(1) . '{';
|
||||
$autoload_method[] = Indent::_(2) . '//'
|
||||
. Line::_(__Line__, __Class__) . ' does the class use the namespace prefix?';
|
||||
$autoload_method[] = Indent::_(2) . '$len = strlen($prefix);';
|
||||
$autoload_method[] = Indent::_(2) . 'if (strncmp($prefix, $class, $len) === 0)';
|
||||
$autoload_method[] = Indent::_(2) . '{';
|
||||
$autoload_method[] = Indent::_(3) . '//'
|
||||
. Line::_(__Line__, __Class__) . ' we have a match so load the values';
|
||||
$autoload_method[] = Indent::_(3) . '$found = true;';
|
||||
$autoload_method[] = Indent::_(3) . '$found_base_dir = $base_dir;';
|
||||
$autoload_method[] = Indent::_(3) . '$found_len = $len;';
|
||||
$autoload_method[] = Indent::_(3) . '//'
|
||||
. Line::_(__Line__, __Class__) . ' done here';
|
||||
$autoload_method[] = Indent::_(3) . 'break;';
|
||||
$autoload_method[] = Indent::_(2) . '}';
|
||||
$autoload_method[] = Indent::_(1) . '}';
|
||||
|
||||
$autoload_method[] = Indent::_(1) . '//'
|
||||
. Line::_(__Line__, __Class__) . ' check if we found a match';
|
||||
$autoload_method[] = Indent::_(1) . 'if (!$found)';
|
||||
$autoload_method[] = Indent::_(1) . '{';
|
||||
|
||||
$autoload_method[] = Indent::_(2) . '//'
|
||||
. Line::_(__Line__, __Class__) . ' not found so move to the next registered autoloader';
|
||||
$autoload_method[] = Indent::_(2) . 'return;';
|
||||
|
||||
$autoload_method[] = Indent::_(1) . '}';
|
||||
|
||||
$autoload_method[] = Indent::_(1) . '//'
|
||||
. Line::_(__Line__, __Class__) . ' get the relative class name';
|
||||
$autoload_method[] = Indent::_(1) . '$relative_class = substr($class, $found_len);';
|
||||
$autoload_method[] = Indent::_(1) . '//'
|
||||
. Line::_(__Line__, __Class__) . ' replace the namespace prefix with the base directory, replace namespace';
|
||||
$autoload_method[] = Indent::_(1) . '// separators with directory separators in the relative class name, append';
|
||||
$autoload_method[] = Indent::_(1) . '// with .php';
|
||||
$autoload_method[] = Indent::_(1) . "\$file = __DIR__ . '/' . \$found_base_dir . '/src' . str_replace('\\\\', '/', \$relative_class) . '.php';";
|
||||
$autoload_method[] = Indent::_(1) . '//'
|
||||
. Line::_(__Line__, __Class__) . ' if the file exists, require it';
|
||||
$autoload_method[] = Indent::_(1) . 'if (file_exists($file))';
|
||||
$autoload_method[] = Indent::_(1) . '{';
|
||||
$autoload_method[] = Indent::_(2) . 'require $file;';
|
||||
$autoload_method[] = Indent::_(1) . '}';
|
||||
$autoload_method[] = '});';
|
||||
|
||||
return implode(PHP_EOL, $autoload_method);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the composer autoloader routine (NOT READY)
|
||||
*
|
||||
*
|
||||
* @return string|null
|
||||
* @since 3.2.0
|
||||
*/
|
||||
private function getInstallerComposer(): ?string
|
||||
{
|
||||
if (ArrayHelper::check($this->power->composer))
|
||||
{
|
||||
// load the composer routine
|
||||
$composer_routine = [];
|
||||
|
||||
// counter to manage the comma in the actual array
|
||||
$add_once = [];
|
||||
foreach ($this->power->composer as $access_point)
|
||||
{
|
||||
// don't add the ending comma on last value
|
||||
if (empty($add_once[$access_point]))
|
||||
{
|
||||
$composer_routine[] = "\$composer_autoloader = __DIR__ . '/libraries/$access_point';";
|
||||
$composer_routine[] = 'if (file_exists($composer_autoloader))';
|
||||
$composer_routine[] = "{";
|
||||
$composer_routine[] = Indent::_(1) . 'require_once $composer_autoloader;';
|
||||
$composer_routine[] = "}";
|
||||
|
||||
$add_once[$access_point] = true;
|
||||
}
|
||||
}
|
||||
|
||||
// this is just about the [autoloader or autoloaders] in the comment ;)
|
||||
if (count($add_once) == 1)
|
||||
{
|
||||
array_unshift($composer_routine, '//'
|
||||
. Line::_(__Line__, __Class__) . ' add the autoloader for the composer classes');
|
||||
}
|
||||
else
|
||||
{
|
||||
array_unshift($composer_routine, '//'
|
||||
. Line::_(__Line__, __Class__) . ' add the autoloaders for the composer classes');
|
||||
}
|
||||
|
||||
|
93
src/7ecd7318-8bea-4321-8f13-626da1ab01c7/README.md
Normal file
93
src/7ecd7318-8bea-4321-8f13-626da1ab01c7/README.md
Normal file
@ -0,0 +1,93 @@
|
||||
```
|
||||
██████╗ ██████╗ ██╗ ██╗███████╗██████╗
|
||||
██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗
|
||||
██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝
|
||||
██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗
|
||||
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
|
||||
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
|
||||
```
|
||||
# final class AllowEditViews (Details)
|
||||
> namespace: **VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaFive\Controller**
|
||||
|
||||
```uml
|
||||
@startuml
|
||||
class AllowEditViews << (F,LightGreen) >> #RoyalBlue {
|
||||
# Permission $permission
|
||||
# Dispenser $dispenser
|
||||
# Category $category
|
||||
# CategoryOtherName $categoryothername
|
||||
+ __construct(Permission $permission, Dispenser $dispenser, ...)
|
||||
+ getArray(array $views) : string
|
||||
+ getFunctions(array $views) : string
|
||||
# getViewArray(string $nameSingleCode, string $nameListCode) : string
|
||||
# getViewFunction(string $nameSingleCode, string $nameListCode) : ?string
|
||||
}
|
||||
|
||||
note right of AllowEditViews::__construct
|
||||
Constructor.
|
||||
|
||||
since: 5.0.2
|
||||
|
||||
arguments:
|
||||
Permission $permission
|
||||
Dispenser $dispenser
|
||||
Category $category
|
||||
CategoryOtherName $categoryothername
|
||||
end note
|
||||
|
||||
note right of AllowEditViews::getArray
|
||||
Get Array Code
|
||||
|
||||
since: 5.0.2
|
||||
return: string
|
||||
end note
|
||||
|
||||
note right of AllowEditViews::getFunctions
|
||||
Get Custom Function Code
|
||||
|
||||
since: 5.0.2
|
||||
return: string
|
||||
end note
|
||||
|
||||
note right of AllowEditViews::getViewArray
|
||||
Get View Permissions Array Code
|
||||
|
||||
since: 3.2.0
|
||||
return: string
|
||||
end note
|
||||
|
||||
note right of AllowEditViews::getViewFunction
|
||||
Get View Permissions Function Code
|
||||
|
||||
since: 3.2.0
|
||||
return: ?string
|
||||
end note
|
||||
|
||||
@enduml
|
||||
```
|
||||
|
||||
The Power feature in JCB allows you to write PHP classes and their implementations, making it easy to include them in your Joomla project. JCB handles linking, autoloading, namespacing, and folder structure creation for you.
|
||||
|
||||
By using the SPK (Super Power Key) in your custom code (replacing the class name in your code with the SPK), JCB will automatically pull the power from the repository into your project. This makes it available in your JCB instance, allowing you to edit it and include the class in your generated Joomla component.
|
||||
|
||||
JCB uses placeholders like [[[`NamespacePrefix`]]] and [[[`ComponentNamespace`]]] in namespacing to prevent collisions and improve reusability across different JCB systems. You can also set the **JCB powers path** globally or per component under the **Dynamic Integration** tab, providing flexibility and easy maintainability.
|
||||
|
||||
To add this specific Power to your project in JCB:
|
||||
|
||||
> simply use this SPK
|
||||
```
|
||||
Super---7ecd7318_8bea_4321_8f13_626da1ab01c7---Power
|
||||
```
|
||||
> remember to replace the `---` with `___` to activate this Power in your code
|
||||
|
||||
---
|
||||
```
|
||||
██╗ ██████╗██████╗
|
||||
██║██╔════╝██╔══██╗
|
||||
██║██║ ██████╔╝
|
||||
██ ██║██║ ██╔══██╗
|
||||
╚█████╔╝╚██████╗██████╔╝
|
||||
╚════╝ ╚═════╝╚═════╝
|
||||
```
|
||||
> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder)
|
||||
|
243
src/7ecd7318-8bea-4321-8f13-626da1ab01c7/code.php
Normal file
243
src/7ecd7318-8bea-4321-8f13-626da1ab01c7/code.php
Normal file
@ -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\JoomlaFive\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 5
|
||||
*
|
||||
* @since 5.0.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;
|
||||
}
|
||||
}
|
||||
|
211
src/7ecd7318-8bea-4321-8f13-626da1ab01c7/code.power
Normal file
211
src/7ecd7318-8bea-4321-8f13-626da1ab01c7/code.power
Normal file
@ -0,0 +1,211 @@
|
||||
/**
|
||||
* 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;
|
||||
}
|
46
src/7ecd7318-8bea-4321-8f13-626da1ab01c7/settings.json
Normal file
46
src/7ecd7318-8bea-4321-8f13-626da1ab01c7/settings.json
Normal file
@ -0,0 +1,46 @@
|
||||
{
|
||||
"add_head": "0",
|
||||
"add_licensing_template": "2",
|
||||
"extends": "",
|
||||
"guid": "7ecd7318-8bea-4321-8f13-626da1ab01c7",
|
||||
"implements": [
|
||||
"025d5903-cfdf-4624-aebb-10d02075e265"
|
||||
],
|
||||
"load_selection": null,
|
||||
"name": "AllowEditViews",
|
||||
"power_version": "1.0.0",
|
||||
"system_name": "JCB.Architecture.J5.Controller.AllowEditViews",
|
||||
"type": "final class",
|
||||
"use_selection": {
|
||||
"use_selection0": {
|
||||
"use": "7f01622a-74c9-4e67-b111-3eb488035206",
|
||||
"as": "default"
|
||||
},
|
||||
"use_selection1": {
|
||||
"use": "f1dc6430-fb54-452e-aa53-ce32ae93db88",
|
||||
"as": "default"
|
||||
},
|
||||
"use_selection2": {
|
||||
"use": "007177eb-d39d-4093-8840-07a38811c502",
|
||||
"as": "default"
|
||||
},
|
||||
"use_selection3": {
|
||||
"use": "a1e551a9-8369-48c9-a076-4e5beb65e0df",
|
||||
"as": "default"
|
||||
},
|
||||
"use_selection4": {
|
||||
"use": "a68c010b-e92e-47d5-8a44-d23cfddeb6c6",
|
||||
"as": "default"
|
||||
},
|
||||
"use_selection5": {
|
||||
"use": "4e6ff11d-bebf-42f5-8fd7-b2f882857222",
|
||||
"as": "default"
|
||||
}
|
||||
},
|
||||
"extendsinterfaces": null,
|
||||
"namespace": "[[[NamespacePrefix]]]\\Joomla\\[[[ComponentNamespace]]].Compiler.Architecture.JoomlaFive.Controller.AllowEditViews",
|
||||
"description": "Controller Allow Edit Views Class for Joomla 5\r\n\r\n@since 5.0.2",
|
||||
"licensing_template": "\/**\r\n * @package Joomla.Component.Builder\r\n *\r\n * @created 4th September, 2022\r\n * @author Llewellyn van der Merwe <https:\/\/dev.vdm.io>\r\n * @git Joomla Component Builder <https:\/\/git.vdm.dev\/joomla\/Component-Builder>\r\n * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.\r\n * @license GNU General Public License version 2 or later; see LICENSE.txt\r\n *\/\r\n",
|
||||
"head": "",
|
||||
"composer": ""
|
||||
}
|
@ -106,7 +106,7 @@ final class AllowEdit implements AllowEditInterface
|
||||
|
||||
// prepare custom permission script
|
||||
$customAllow = $this->dispenser->get(
|
||||
'php_allowedit', $nameSingleCode, '', null, true
|
||||
'php_allowedit', $nameSingleCode
|
||||
);
|
||||
|
||||
if ($this->category->exists("{$nameListCode}"))
|
||||
|
@ -75,7 +75,7 @@
|
||||
|
||||
// prepare custom permission script
|
||||
$customAllow = $this->dispenser->get(
|
||||
'php_allowedit', $nameSingleCode, '', null, true
|
||||
'php_allowedit', $nameSingleCode
|
||||
);
|
||||
|
||||
if ($this->category->exists("{$nameListCode}"))
|
||||
|
@ -367,6 +367,7 @@ final class Header implements HeaderInterface
|
||||
$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;';
|
||||
@ -402,6 +403,7 @@ final class Header implements HeaderInterface
|
||||
$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;
|
||||
|
@ -331,6 +331,7 @@
|
||||
$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;';
|
||||
@ -366,6 +367,7 @@
|
||||
$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;
|
||||
|
@ -52,11 +52,11 @@
|
||||
"use": "8ca30d59-e56a-4cdd-bd8c-d9aad28f5903",
|
||||
"as": "default"
|
||||
},
|
||||
"use_selection11": {
|
||||
"use_selection10": {
|
||||
"use": "0a59c65c-9daf-4bc9-baf4-e063ff9e6a8a",
|
||||
"as": "default"
|
||||
},
|
||||
"use_selection12": {
|
||||
"use_selection11": {
|
||||
"use": "1f28cb53-60d9-4db1-b517-3c7dc6b429ef",
|
||||
"as": "default"
|
||||
}
|
||||
|
93
src/bdb74844-7cba-4227-a01c-355eba5fd031/README.md
Normal file
93
src/bdb74844-7cba-4227-a01c-355eba5fd031/README.md
Normal file
@ -0,0 +1,93 @@
|
||||
```
|
||||
██████╗ ██████╗ ██╗ ██╗███████╗██████╗
|
||||
██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗
|
||||
██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝
|
||||
██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗
|
||||
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
|
||||
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
|
||||
```
|
||||
# final class AllowEditViews (Details)
|
||||
> namespace: **VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaThree\Controller**
|
||||
|
||||
```uml
|
||||
@startuml
|
||||
class AllowEditViews << (F,LightGreen) >> #RoyalBlue {
|
||||
# Permission $permission
|
||||
# Dispenser $dispenser
|
||||
# Category $category
|
||||
# CategoryOtherName $categoryothername
|
||||
+ __construct(Permission $permission, Dispenser $dispenser, ...)
|
||||
+ getArray(array $views) : string
|
||||
+ getFunctions(array $views) : string
|
||||
# getViewArray(string $nameSingleCode, string $nameListCode) : string
|
||||
# getViewFunction(string $nameSingleCode, string $nameListCode) : ?string
|
||||
}
|
||||
|
||||
note right of AllowEditViews::__construct
|
||||
Constructor.
|
||||
|
||||
since: 5.0.2
|
||||
|
||||
arguments:
|
||||
Permission $permission
|
||||
Dispenser $dispenser
|
||||
Category $category
|
||||
CategoryOtherName $categoryothername
|
||||
end note
|
||||
|
||||
note right of AllowEditViews::getArray
|
||||
Get Array Code
|
||||
|
||||
since: 5.0.2
|
||||
return: string
|
||||
end note
|
||||
|
||||
note right of AllowEditViews::getFunctions
|
||||
Get Custom Function Code
|
||||
|
||||
since: 5.0.2
|
||||
return: string
|
||||
end note
|
||||
|
||||
note right of AllowEditViews::getViewArray
|
||||
Get View Permissions Array Code
|
||||
|
||||
since: 3.2.0
|
||||
return: string
|
||||
end note
|
||||
|
||||
note right of AllowEditViews::getViewFunction
|
||||
Get View Permissions Function Code
|
||||
|
||||
since: 3.2.0
|
||||
return: ?string
|
||||
end note
|
||||
|
||||
@enduml
|
||||
```
|
||||
|
||||
The Power feature in JCB allows you to write PHP classes and their implementations, making it easy to include them in your Joomla project. JCB handles linking, autoloading, namespacing, and folder structure creation for you.
|
||||
|
||||
By using the SPK (Super Power Key) in your custom code (replacing the class name in your code with the SPK), JCB will automatically pull the power from the repository into your project. This makes it available in your JCB instance, allowing you to edit it and include the class in your generated Joomla component.
|
||||
|
||||
JCB uses placeholders like [[[`NamespacePrefix`]]] and [[[`ComponentNamespace`]]] in namespacing to prevent collisions and improve reusability across different JCB systems. You can also set the **JCB powers path** globally or per component under the **Dynamic Integration** tab, providing flexibility and easy maintainability.
|
||||
|
||||
To add this specific Power to your project in JCB:
|
||||
|
||||
> simply use this SPK
|
||||
```
|
||||
Super---bdb74844_7cba_4227_a01c_355eba5fd031---Power
|
||||
```
|
||||
> remember to replace the `---` with `___` to activate this Power in your code
|
||||
|
||||
---
|
||||
```
|
||||
██╗ ██████╗██████╗
|
||||
██║██╔════╝██╔══██╗
|
||||
██║██║ ██████╔╝
|
||||
██ ██║██║ ██╔══██╗
|
||||
╚█████╔╝╚██████╗██████╔╝
|
||||
╚════╝ ╚═════╝╚═════╝
|
||||
```
|
||||
> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder)
|
||||
|
218
src/bdb74844-7cba-4227-a01c-355eba5fd031/code.php
Normal file
218
src/bdb74844-7cba-4227-a01c-355eba5fd031/code.php
Normal file
@ -0,0 +1,218 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaThree\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 3
|
||||
*
|
||||
* @since 5.0.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
|
||||
{
|
||||
return ''; // not used for now in Joomla 3
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Custom Function Code
|
||||
*
|
||||
* @param array $views
|
||||
*
|
||||
* @since 5.0.2
|
||||
* @return string The functions of Code (string)
|
||||
*/
|
||||
public function getFunctions(array $views): string
|
||||
{
|
||||
return ''; // not used for now in Joomla 3
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
}
|
||||
|
186
src/bdb74844-7cba-4227-a01c-355eba5fd031/code.power
Normal file
186
src/bdb74844-7cba-4227-a01c-355eba5fd031/code.power
Normal file
@ -0,0 +1,186 @@
|
||||
/**
|
||||
* 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
|
||||
{
|
||||
return ''; // not used for now in Joomla 3
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Custom Function Code
|
||||
*
|
||||
* @param array $views
|
||||
*
|
||||
* @since 5.0.2
|
||||
* @return string The functions of Code (string)
|
||||
*/
|
||||
public function getFunctions(array $views): string
|
||||
{
|
||||
return ''; // not used for now in Joomla 3
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
46
src/bdb74844-7cba-4227-a01c-355eba5fd031/settings.json
Normal file
46
src/bdb74844-7cba-4227-a01c-355eba5fd031/settings.json
Normal file
@ -0,0 +1,46 @@
|
||||
{
|
||||
"add_head": "0",
|
||||
"add_licensing_template": "2",
|
||||
"extends": "",
|
||||
"guid": "bdb74844-7cba-4227-a01c-355eba5fd031",
|
||||
"implements": [
|
||||
"025d5903-cfdf-4624-aebb-10d02075e265"
|
||||
],
|
||||
"load_selection": null,
|
||||
"name": "AllowEditViews",
|
||||
"power_version": "1.0.0",
|
||||
"system_name": "JCB.Architecture.J3.Controller.AllowEditViews",
|
||||
"type": "final class",
|
||||
"use_selection": {
|
||||
"use_selection0": {
|
||||
"use": "7f01622a-74c9-4e67-b111-3eb488035206",
|
||||
"as": "default"
|
||||
},
|
||||
"use_selection1": {
|
||||
"use": "f1dc6430-fb54-452e-aa53-ce32ae93db88",
|
||||
"as": "default"
|
||||
},
|
||||
"use_selection2": {
|
||||
"use": "007177eb-d39d-4093-8840-07a38811c502",
|
||||
"as": "default"
|
||||
},
|
||||
"use_selection3": {
|
||||
"use": "a1e551a9-8369-48c9-a076-4e5beb65e0df",
|
||||
"as": "default"
|
||||
},
|
||||
"use_selection4": {
|
||||
"use": "a68c010b-e92e-47d5-8a44-d23cfddeb6c6",
|
||||
"as": "default"
|
||||
},
|
||||
"use_selection5": {
|
||||
"use": "4e6ff11d-bebf-42f5-8fd7-b2f882857222",
|
||||
"as": "default"
|
||||
}
|
||||
},
|
||||
"extendsinterfaces": null,
|
||||
"namespace": "[[[NamespacePrefix]]]\\Joomla\\[[[ComponentNamespace]]].Compiler.Architecture.JoomlaThree.Controller.AllowEditViews",
|
||||
"description": "Controller Allow Edit Views Class for Joomla 3\r\n\r\n@since 5.0.2",
|
||||
"licensing_template": "\/**\r\n * @package Joomla.Component.Builder\r\n *\r\n * @created 4th September, 2022\r\n * @author Llewellyn van der Merwe <https:\/\/dev.vdm.io>\r\n * @git Joomla Component Builder <https:\/\/git.vdm.dev\/joomla\/Component-Builder>\r\n * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.\r\n * @license GNU General Public License version 2 or later; see LICENSE.txt\r\n *\/\r\n",
|
||||
"head": "",
|
||||
"composer": ""
|
||||
}
|
93
src/c2453304-c9ac-4d67-a045-fbda68876434/README.md
Normal file
93
src/c2453304-c9ac-4d67-a045-fbda68876434/README.md
Normal file
@ -0,0 +1,93 @@
|
||||
```
|
||||
██████╗ ██████╗ ██╗ ██╗███████╗██████╗
|
||||
██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗
|
||||
██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝
|
||||
██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗
|
||||
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
|
||||
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
|
||||
```
|
||||
# final class AllowEditViews (Details)
|
||||
> namespace: **VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaFour\Controller**
|
||||
|
||||
```uml
|
||||
@startuml
|
||||
class AllowEditViews << (F,LightGreen) >> #RoyalBlue {
|
||||
# Permission $permission
|
||||
# Dispenser $dispenser
|
||||
# Category $category
|
||||
# CategoryOtherName $categoryothername
|
||||
+ __construct(Permission $permission, Dispenser $dispenser, ...)
|
||||
+ getArray(array $views) : string
|
||||
+ getFunctions(array $views) : string
|
||||
# getViewArray(string $nameSingleCode, string $nameListCode) : string
|
||||
# getViewFunction(string $nameSingleCode, string $nameListCode) : ?string
|
||||
}
|
||||
|
||||
note right of AllowEditViews::__construct
|
||||
Constructor.
|
||||
|
||||
since: 5.0.2
|
||||
|
||||
arguments:
|
||||
Permission $permission
|
||||
Dispenser $dispenser
|
||||
Category $category
|
||||
CategoryOtherName $categoryothername
|
||||
end note
|
||||
|
||||
note right of AllowEditViews::getArray
|
||||
Get Array Code
|
||||
|
||||
since: 5.0.2
|
||||
return: string
|
||||
end note
|
||||
|
||||
note right of AllowEditViews::getFunctions
|
||||
Get Custom Function Code
|
||||
|
||||
since: 5.0.2
|
||||
return: string
|
||||
end note
|
||||
|
||||
note right of AllowEditViews::getViewArray
|
||||
Get View Permissions Array Code
|
||||
|
||||
since: 3.2.0
|
||||
return: string
|
||||
end note
|
||||
|
||||
note right of AllowEditViews::getViewFunction
|
||||
Get View Permissions Function Code
|
||||
|
||||
since: 3.2.0
|
||||
return: ?string
|
||||
end note
|
||||
|
||||
@enduml
|
||||
```
|
||||
|
||||
The Power feature in JCB allows you to write PHP classes and their implementations, making it easy to include them in your Joomla project. JCB handles linking, autoloading, namespacing, and folder structure creation for you.
|
||||
|
||||
By using the SPK (Super Power Key) in your custom code (replacing the class name in your code with the SPK), JCB will automatically pull the power from the repository into your project. This makes it available in your JCB instance, allowing you to edit it and include the class in your generated Joomla component.
|
||||
|
||||
JCB uses placeholders like [[[`NamespacePrefix`]]] and [[[`ComponentNamespace`]]] in namespacing to prevent collisions and improve reusability across different JCB systems. You can also set the **JCB powers path** globally or per component under the **Dynamic Integration** tab, providing flexibility and easy maintainability.
|
||||
|
||||
To add this specific Power to your project in JCB:
|
||||
|
||||
> simply use this SPK
|
||||
```
|
||||
Super---c2453304_c9ac_4d67_a045_fbda68876434---Power
|
||||
```
|
||||
> remember to replace the `---` with `___` to activate this Power in your code
|
||||
|
||||
---
|
||||
```
|
||||
██╗ ██████╗██████╗
|
||||
██║██╔════╝██╔══██╗
|
||||
██║██║ ██████╔╝
|
||||
██ ██║██║ ██╔══██╗
|
||||
╚█████╔╝╚██████╗██████╔╝
|
||||
╚════╝ ╚═════╝╚═════╝
|
||||
```
|
||||
> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder)
|
||||
|
243
src/c2453304-c9ac-4d67-a045-fbda68876434/code.php
Normal file
243
src/c2453304-c9ac-4d67-a045-fbda68876434/code.php
Normal file
@ -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\JoomlaFour\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 4
|
||||
*
|
||||
* @since 5.0.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;
|
||||
}
|
||||
}
|
||||
|
211
src/c2453304-c9ac-4d67-a045-fbda68876434/code.power
Normal file
211
src/c2453304-c9ac-4d67-a045-fbda68876434/code.power
Normal file
@ -0,0 +1,211 @@
|
||||
/**
|
||||
* 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;
|
||||
}
|
46
src/c2453304-c9ac-4d67-a045-fbda68876434/settings.json
Normal file
46
src/c2453304-c9ac-4d67-a045-fbda68876434/settings.json
Normal file
@ -0,0 +1,46 @@
|
||||
{
|
||||
"add_head": "0",
|
||||
"add_licensing_template": "2",
|
||||
"extends": "",
|
||||
"guid": "c2453304-c9ac-4d67-a045-fbda68876434",
|
||||
"implements": [
|
||||
"025d5903-cfdf-4624-aebb-10d02075e265"
|
||||
],
|
||||
"load_selection": null,
|
||||
"name": "AllowEditViews",
|
||||
"power_version": "1.0.0",
|
||||
"system_name": "JCB.Architecture.J4.Controller.AllowEditViews",
|
||||
"type": "final class",
|
||||
"use_selection": {
|
||||
"use_selection0": {
|
||||
"use": "7f01622a-74c9-4e67-b111-3eb488035206",
|
||||
"as": "default"
|
||||
},
|
||||
"use_selection1": {
|
||||
"use": "f1dc6430-fb54-452e-aa53-ce32ae93db88",
|
||||
"as": "default"
|
||||
},
|
||||
"use_selection2": {
|
||||
"use": "007177eb-d39d-4093-8840-07a38811c502",
|
||||
"as": "default"
|
||||
},
|
||||
"use_selection3": {
|
||||
"use": "a1e551a9-8369-48c9-a076-4e5beb65e0df",
|
||||
"as": "default"
|
||||
},
|
||||
"use_selection4": {
|
||||
"use": "a68c010b-e92e-47d5-8a44-d23cfddeb6c6",
|
||||
"as": "default"
|
||||
},
|
||||
"use_selection5": {
|
||||
"use": "4e6ff11d-bebf-42f5-8fd7-b2f882857222",
|
||||
"as": "default"
|
||||
}
|
||||
},
|
||||
"extendsinterfaces": null,
|
||||
"namespace": "[[[NamespacePrefix]]]\\Joomla\\[[[ComponentNamespace]]].Compiler.Architecture.JoomlaFour.Controller.AllowEditViews",
|
||||
"description": "Controller Allow Edit Views Class for Joomla 4\r\n\r\n@since 5.0.2",
|
||||
"licensing_template": "\/**\r\n * @package Joomla.Component.Builder\r\n *\r\n * @created 4th September, 2022\r\n * @author Llewellyn van der Merwe <https:\/\/dev.vdm.io>\r\n * @git Joomla Component Builder <https:\/\/git.vdm.dev\/joomla\/Component-Builder>\r\n * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.\r\n * @license GNU General Public License version 2 or later; see LICENSE.txt\r\n *\/\r\n",
|
||||
"head": "",
|
||||
"composer": ""
|
||||
}
|
@ -106,7 +106,7 @@ final class AllowEdit implements AllowEditInterface
|
||||
|
||||
// prepare custom permission script
|
||||
$customAllow = $this->dispenser->get(
|
||||
'php_allowedit', $nameSingleCode, '', null, true
|
||||
'php_allowedit', $nameSingleCode
|
||||
);
|
||||
|
||||
if ($this->category->exists("{$nameListCode}"))
|
||||
|
@ -75,7 +75,7 @@
|
||||
|
||||
// prepare custom permission script
|
||||
$customAllow = $this->dispenser->get(
|
||||
'php_allowedit', $nameSingleCode, '', null, true
|
||||
'php_allowedit', $nameSingleCode
|
||||
);
|
||||
|
||||
if ($this->category->exists("{$nameListCode}"))
|
||||
|
@ -106,7 +106,7 @@ final class AllowEdit implements AllowEditInterface
|
||||
|
||||
// prepare custom permission script
|
||||
$customAllow = $this->dispenser->get(
|
||||
'php_allowedit', $nameSingleCode, '', null, true
|
||||
'php_allowedit', $nameSingleCode
|
||||
);
|
||||
|
||||
if ($this->category->exists("{$nameListCode}"))
|
||||
|
@ -75,7 +75,7 @@
|
||||
|
||||
// prepare custom permission script
|
||||
$customAllow = $this->dispenser->get(
|
||||
'php_allowedit', $nameSingleCode, '', null, true
|
||||
'php_allowedit', $nameSingleCode
|
||||
);
|
||||
|
||||
if ($this->category->exists("{$nameListCode}"))
|
||||
|
@ -30,6 +30,7 @@ class Config #Gold {
|
||||
# getComponentcontext() : string
|
||||
# getComponentcodenamelength() : int
|
||||
# getComponentautoloaderpath() : string
|
||||
# getComponentinstallerautoloaderpath() : string
|
||||
# getAddnamespaceprefix() : bool
|
||||
# getNamespaceprefix() : string
|
||||
# getJoomlaversion() : int
|
||||
@ -207,413 +208,420 @@ note left of Config::getComponentautoloaderpath
|
||||
return: string
|
||||
end note
|
||||
|
||||
note right of Config::getAddnamespaceprefix
|
||||
note right of Config::getComponentinstallerautoloaderpath
|
||||
get component installer autoloader path
|
||||
|
||||
since: 5.0.2
|
||||
return: string
|
||||
end note
|
||||
|
||||
note left of Config::getAddnamespaceprefix
|
||||
get add namespace prefix
|
||||
|
||||
since: 3.2.0
|
||||
return: bool
|
||||
end note
|
||||
|
||||
note left of Config::getNamespaceprefix
|
||||
note right of Config::getNamespaceprefix
|
||||
get namespace prefix
|
||||
|
||||
since: 3.2.0
|
||||
return: string
|
||||
end note
|
||||
|
||||
note right of Config::getJoomlaversion
|
||||
note left of Config::getJoomlaversion
|
||||
get posted Joomla version
|
||||
|
||||
since: 3.2.0
|
||||
return: int
|
||||
end note
|
||||
|
||||
note left of Config::getJoomlaversions
|
||||
note right of Config::getJoomlaversions
|
||||
get Joomla versions
|
||||
|
||||
since: 3.2.0
|
||||
return: array
|
||||
end note
|
||||
|
||||
note right of Config::getJoomlaversionname
|
||||
note left of Config::getJoomlaversionname
|
||||
get posted Joomla version name
|
||||
|
||||
since: 3.2.0
|
||||
return: string
|
||||
end note
|
||||
|
||||
note left of Config::getSetjoomlafields
|
||||
note right of Config::getSetjoomlafields
|
||||
set joomla fields
|
||||
|
||||
since: 3.2.0
|
||||
return: bool
|
||||
end note
|
||||
|
||||
note right of Config::getShowadvancedoptions
|
||||
note left of Config::getShowadvancedoptions
|
||||
get show advanced options switch
|
||||
|
||||
since: 3.2.0
|
||||
return: bool
|
||||
end note
|
||||
|
||||
note left of Config::getIndentationvalue
|
||||
note right of Config::getIndentationvalue
|
||||
get indentation value
|
||||
|
||||
since: 3.2.0
|
||||
return: string
|
||||
end note
|
||||
|
||||
note right of Config::getAddbuilddate
|
||||
note left of Config::getAddbuilddate
|
||||
get add build date switch
|
||||
|
||||
since: 3.2.0
|
||||
return: int
|
||||
end note
|
||||
|
||||
note left of Config::getBuilddate
|
||||
note right of Config::getBuilddate
|
||||
get build date
|
||||
|
||||
since: 3.2.0
|
||||
return: string
|
||||
end note
|
||||
|
||||
note right of Config::getBackup
|
||||
note left of Config::getBackup
|
||||
get posted backup switch
|
||||
|
||||
since: 3.2.0
|
||||
return: int
|
||||
end note
|
||||
|
||||
note left of Config::getRepository
|
||||
note right of Config::getRepository
|
||||
get posted repository switch
|
||||
|
||||
since: 3.2.0
|
||||
return: int
|
||||
end note
|
||||
|
||||
note right of Config::getDebuglinenr
|
||||
note left of Config::getDebuglinenr
|
||||
get posted debuglinenr switch
|
||||
|
||||
since: 3.2.0
|
||||
return: int
|
||||
end note
|
||||
|
||||
note left of Config::getMinify
|
||||
note right of Config::getMinify
|
||||
get posted minify switch
|
||||
|
||||
since: 3.2.0
|
||||
return: int
|
||||
end note
|
||||
|
||||
note right of Config::getRemovelinebreaks
|
||||
note left of Config::getRemovelinebreaks
|
||||
get posted remove line breaks switch
|
||||
|
||||
since: 3.2.0
|
||||
return: bool
|
||||
end note
|
||||
|
||||
note left of Config::getTidy
|
||||
note right of Config::getTidy
|
||||
get system tidy state
|
||||
|
||||
since: 3.2.0
|
||||
return: bool
|
||||
end note
|
||||
|
||||
note right of Config::getSettidywarning
|
||||
note left of Config::getSettidywarning
|
||||
add tidy warning
|
||||
|
||||
since: 3.2.0
|
||||
return: bool
|
||||
end note
|
||||
|
||||
note left of Config::getSettaghistory
|
||||
note right of Config::getSettaghistory
|
||||
get history tag switch
|
||||
|
||||
since: 3.2.0
|
||||
return: bool
|
||||
end note
|
||||
|
||||
note right of Config::getPercentagelanguageadd
|
||||
note left of Config::getPercentagelanguageadd
|
||||
get percentage when a language should be added
|
||||
|
||||
since: 3.2.0
|
||||
return: int
|
||||
end note
|
||||
|
||||
note left of Config::getLangtag
|
||||
note right of Config::getLangtag
|
||||
get language tag
|
||||
|
||||
since: 3.2.0
|
||||
return: string
|
||||
end note
|
||||
|
||||
note right of Config::getLangprefix
|
||||
note left of Config::getLangprefix
|
||||
get language prefix
|
||||
|
||||
since: 3.2.0
|
||||
return: string
|
||||
end note
|
||||
|
||||
note left of Config::getLangtarget
|
||||
note right of Config::getLangtarget
|
||||
get language target
|
||||
|
||||
since: 3.2.0
|
||||
return: string
|
||||
end note
|
||||
|
||||
note right of Config::getLangstringtargets
|
||||
note left of Config::getLangstringtargets
|
||||
get language string targets
|
||||
|
||||
since: 3.2.0
|
||||
return: array
|
||||
end note
|
||||
|
||||
note left of Config::getLangstringkeytargets
|
||||
note right of Config::getLangstringkeytargets
|
||||
get language string targets (by key name)
|
||||
|
||||
since: 3.2.0
|
||||
return: array
|
||||
end note
|
||||
|
||||
note right of Config::getFieldbuildertype
|
||||
note left of Config::getFieldbuildertype
|
||||
get field builder type
|
||||
|
||||
since: 3.2.0
|
||||
return: int
|
||||
end note
|
||||
|
||||
note left of Config::getDefaultfields
|
||||
note right of Config::getDefaultfields
|
||||
get default fields
|
||||
|
||||
since: 3.2.0
|
||||
return: array
|
||||
end note
|
||||
|
||||
note right of Config::getTmppath
|
||||
note left of Config::getTmppath
|
||||
get temporary path
|
||||
|
||||
since: 3.2.0
|
||||
return: string
|
||||
end note
|
||||
|
||||
note left of Config::getCompilerpath
|
||||
note right of Config::getCompilerpath
|
||||
get compiler path
|
||||
|
||||
since: 3.2.0
|
||||
return: string
|
||||
end note
|
||||
|
||||
note right of Config::getJcbpowerspath
|
||||
note left of Config::getJcbpowerspath
|
||||
get jcb powers path
|
||||
|
||||
since: 3.2.0
|
||||
return: string
|
||||
end note
|
||||
|
||||
note left of Config::getPowerlibraryfolder
|
||||
note right of Config::getPowerlibraryfolder
|
||||
get jcb powers path
|
||||
|
||||
since: 3.2.0
|
||||
return: string
|
||||
end note
|
||||
|
||||
note right of Config::getLocalpowersrepositorypath
|
||||
note left of Config::getLocalpowersrepositorypath
|
||||
Get local super powers repository path
|
||||
|
||||
since: 3.2.0
|
||||
return: string
|
||||
end note
|
||||
|
||||
note left of Config::getApprovedpaths
|
||||
note right of Config::getApprovedpaths
|
||||
Get super power approved paths
|
||||
|
||||
since: 3.2.0
|
||||
return: array
|
||||
end note
|
||||
|
||||
note right of Config::getJoomlapowerscoreorganisation
|
||||
note left of Config::getJoomlapowerscoreorganisation
|
||||
Get super power core organisation
|
||||
|
||||
since: 3.2.0
|
||||
return: string
|
||||
end note
|
||||
|
||||
note left of Config::getJoomlapowersinitrepos
|
||||
note right of Config::getJoomlapowersinitrepos
|
||||
Get Joomla power init repos
|
||||
|
||||
since: 3.2.0
|
||||
return: array
|
||||
end note
|
||||
|
||||
note right of Config::getLocaljoomlapowersrepositorypath
|
||||
note left of Config::getLocaljoomlapowersrepositorypath
|
||||
Get local joomla super powers repository path
|
||||
|
||||
since: 3.2.0
|
||||
return: string
|
||||
end note
|
||||
|
||||
note left of Config::getApprovedjoomlapaths
|
||||
note right of Config::getApprovedjoomlapaths
|
||||
Get joomla power approved paths
|
||||
|
||||
since: 3.2.0
|
||||
return: array
|
||||
end note
|
||||
|
||||
note right of Config::getBompath
|
||||
note left of Config::getBompath
|
||||
get bom path
|
||||
|
||||
since: 3.2.0
|
||||
return: string
|
||||
end note
|
||||
|
||||
note left of Config::getCustomfolderpath
|
||||
note right of Config::getCustomfolderpath
|
||||
get custom folder path
|
||||
|
||||
since: 3.2.0
|
||||
return: string
|
||||
end note
|
||||
|
||||
note right of Config::getAddassetstablefix
|
||||
note left of Config::getAddassetstablefix
|
||||
get switch to add assets table fix
|
||||
|
||||
since: 3.2.0
|
||||
return: int
|
||||
end note
|
||||
|
||||
note left of Config::getAddassetstablenamefix
|
||||
note right of Config::getAddassetstablenamefix
|
||||
get switch to add assets table name fix
|
||||
|
||||
since: 3.2.0
|
||||
return: bool
|
||||
end note
|
||||
|
||||
note right of Config::getAccessworsecase
|
||||
note left of Config::getAccessworsecase
|
||||
get access worse case size
|
||||
|
||||
since: 3.2.0
|
||||
return: int
|
||||
end note
|
||||
|
||||
note left of Config::getMysqltablekeys
|
||||
note right of Config::getMysqltablekeys
|
||||
get mysql table keys
|
||||
|
||||
since: 3.2.0
|
||||
return: array
|
||||
end note
|
||||
|
||||
note right of Config::getAddplaceholders
|
||||
note left of Config::getAddplaceholders
|
||||
get switch add placeholders
|
||||
|
||||
since: 3.2.0
|
||||
return: bool
|
||||
end note
|
||||
|
||||
note left of Config::getAddpower
|
||||
note right of Config::getAddpower
|
||||
get switch add power
|
||||
|
||||
since: 3.2.0
|
||||
return: bool
|
||||
end note
|
||||
|
||||
note right of Config::getAddsuperpowers
|
||||
note left of Config::getAddsuperpowers
|
||||
Get switch to add super powers
|
||||
|
||||
since: 3.2.0
|
||||
return: bool
|
||||
end note
|
||||
|
||||
note left of Config::getAddownpowers
|
||||
note right of Config::getAddownpowers
|
||||
Get switch to add own super powers
|
||||
|
||||
since: 3.2.0
|
||||
return: bool
|
||||
end note
|
||||
|
||||
note right of Config::getBuildtarget
|
||||
note left of Config::getBuildtarget
|
||||
get switch build target switch
|
||||
|
||||
since: 3.2.0
|
||||
return: string
|
||||
end note
|
||||
|
||||
note left of Config::getCryptiontypes
|
||||
note right of Config::getCryptiontypes
|
||||
get encryption types
|
||||
|
||||
since: 3.2.0
|
||||
return: array
|
||||
end note
|
||||
|
||||
note right of Config::getBasicencryption
|
||||
note left of Config::getBasicencryption
|
||||
get basic encryption switch
|
||||
|
||||
since: 3.2.0
|
||||
return: bool
|
||||
end note
|
||||
|
||||
note left of Config::getMediumencryption
|
||||
note right of Config::getMediumencryption
|
||||
get medium encryption switch
|
||||
|
||||
since: 3.2.0
|
||||
return: bool
|
||||
end note
|
||||
|
||||
note right of Config::getWhmcsencryption
|
||||
note left of Config::getWhmcsencryption
|
||||
get whmcs encryption switch
|
||||
|
||||
since: 3.2.0
|
||||
return: bool
|
||||
end note
|
||||
|
||||
note left of Config::getRemovesitefolder
|
||||
note right of Config::getRemovesitefolder
|
||||
Should we remove the site folder
|
||||
|
||||
since: 3.2.0
|
||||
return: bool
|
||||
end note
|
||||
|
||||
note right of Config::getRemovesiteeditfolder
|
||||
note left of Config::getRemovesiteeditfolder
|
||||
Should we remove the site edit folder
|
||||
|
||||
since: 3.2.0
|
||||
return: bool
|
||||
end note
|
||||
|
||||
note left of Config::getUikit
|
||||
note right of Config::getUikit
|
||||
The Uikit switch
|
||||
|
||||
since: 3.2.0
|
||||
return: int
|
||||
end note
|
||||
|
||||
note right of Config::getGooglechart
|
||||
note left of Config::getGooglechart
|
||||
The google chart switch
|
||||
|
||||
since: 3.2.0
|
||||
return: bool
|
||||
end note
|
||||
|
||||
note left of Config::getFootable
|
||||
note right of Config::getFootable
|
||||
The footable switch
|
||||
|
||||
since: 3.2.0
|
||||
return: bool
|
||||
end note
|
||||
|
||||
note right of Config::getFootableversion
|
||||
note left of Config::getFootableversion
|
||||
The footable version
|
||||
|
||||
since: 3.2.0
|
||||
return: int
|
||||
end note
|
||||
|
||||
note left of Config::getPermissionstrictperfield
|
||||
note right of Config::getPermissionstrictperfield
|
||||
The Permission Strict Per Field Switch
|
||||
|
||||
since: 3.2.0
|
||||
return: bool
|
||||
end note
|
||||
|
||||
note right of Config::getExporttextonly
|
||||
note left of Config::getExporttextonly
|
||||
The Export Text Only Switch
|
||||
|
||||
since: 3.2.0
|
||||
|
@ -303,6 +303,24 @@ class Config extends BaseConfig
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get component installer autoloader path
|
||||
*
|
||||
* @return string The component installer autoloader path
|
||||
* @since 5.0.2
|
||||
*/
|
||||
protected function getComponentinstallerautoloaderpath(): string
|
||||
{
|
||||
if ($this->joomla_version == 3)
|
||||
{
|
||||
return 'script_powerloader.php';
|
||||
}
|
||||
else
|
||||
{
|
||||
return ucfirst($this->component_codename) . 'InstallerPowerloader.php';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get add namespace prefix
|
||||
*
|
||||
|
@ -267,6 +267,24 @@
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get component installer autoloader path
|
||||
*
|
||||
* @return string The component installer autoloader path
|
||||
* @since 5.0.2
|
||||
*/
|
||||
protected function getComponentinstallerautoloaderpath(): string
|
||||
{
|
||||
if ($this->joomla_version == 3)
|
||||
{
|
||||
return 'script_powerloader.php';
|
||||
}
|
||||
else
|
||||
{
|
||||
return ucfirst($this->component_codename) . 'InstallerPowerloader.php';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get add namespace prefix
|
||||
*
|
||||
|
@ -32,6 +32,17 @@
|
||||
"spk": "Super---01411bb1_fdd6_4cca_84d7_1b62d93c70c1---Power",
|
||||
"guid": "01411bb1-fdd6-4cca-84d7-1b62d93c70c1"
|
||||
},
|
||||
"025d5903-cfdf-4624-aebb-10d02075e265": {
|
||||
"name": "AllowEditViewsInterface",
|
||||
"type": "interface",
|
||||
"namespace": "VDM\\Joomla\\Componentbuilder\\Compiler\\Interfaces\\Architecture\\Controller",
|
||||
"code": "src\/025d5903-cfdf-4624-aebb-10d02075e265\/code.php",
|
||||
"power": "src\/025d5903-cfdf-4624-aebb-10d02075e265\/code.power",
|
||||
"settings": "src\/025d5903-cfdf-4624-aebb-10d02075e265\/settings.json",
|
||||
"path": "src\/025d5903-cfdf-4624-aebb-10d02075e265",
|
||||
"spk": "Super---025d5903_cfdf_4624_aebb_10d02075e265---Power",
|
||||
"guid": "025d5903-cfdf-4624-aebb-10d02075e265"
|
||||
},
|
||||
"02bc072b-1e89-46c1-9732-4da77b1a9ac9": {
|
||||
"name": "Power",
|
||||
"type": "class",
|
||||
@ -1935,6 +1946,17 @@
|
||||
"spk": "Super---7c07c9d6_34cd_4491_934a_ef0a83f414c0---Power",
|
||||
"guid": "7c07c9d6-34cd-4491-934a-ef0a83f414c0"
|
||||
},
|
||||
"7ecd7318-8bea-4321-8f13-626da1ab01c7": {
|
||||
"name": "AllowEditViews",
|
||||
"type": "final class",
|
||||
"namespace": "VDM\\Joomla\\Componentbuilder\\Compiler\\Architecture\\JoomlaFive\\Controller",
|
||||
"code": "src\/7ecd7318-8bea-4321-8f13-626da1ab01c7\/code.php",
|
||||
"power": "src\/7ecd7318-8bea-4321-8f13-626da1ab01c7\/code.power",
|
||||
"settings": "src\/7ecd7318-8bea-4321-8f13-626da1ab01c7\/settings.json",
|
||||
"path": "src\/7ecd7318-8bea-4321-8f13-626da1ab01c7",
|
||||
"spk": "Super---7ecd7318_8bea_4321_8f13_626da1ab01c7---Power",
|
||||
"guid": "7ecd7318-8bea-4321-8f13-626da1ab01c7"
|
||||
},
|
||||
"7f01622a-74c9-4e67-b111-3eb488035206": {
|
||||
"name": "Permission",
|
||||
"type": "final class",
|
||||
@ -2969,6 +2991,17 @@
|
||||
"spk": "Super---bcf1e767_1566_440d_9f67_5c1bada934fa---Power",
|
||||
"guid": "bcf1e767-1566-440d-9f67-5c1bada934fa"
|
||||
},
|
||||
"bdb74844-7cba-4227-a01c-355eba5fd031": {
|
||||
"name": "AllowEditViews",
|
||||
"type": "final class",
|
||||
"namespace": "VDM\\Joomla\\Componentbuilder\\Compiler\\Architecture\\JoomlaThree\\Controller",
|
||||
"code": "src\/bdb74844-7cba-4227-a01c-355eba5fd031\/code.php",
|
||||
"power": "src\/bdb74844-7cba-4227-a01c-355eba5fd031\/code.power",
|
||||
"settings": "src\/bdb74844-7cba-4227-a01c-355eba5fd031\/settings.json",
|
||||
"path": "src\/bdb74844-7cba-4227-a01c-355eba5fd031",
|
||||
"spk": "Super---bdb74844_7cba_4227_a01c_355eba5fd031---Power",
|
||||
"guid": "bdb74844-7cba-4227-a01c-355eba5fd031"
|
||||
},
|
||||
"be4ccfae-65a9-401e-bdbe-637d8c226954": {
|
||||
"name": "Config",
|
||||
"type": "class",
|
||||
@ -3035,6 +3068,17 @@
|
||||
"spk": "Super---c20a63e0_0eeb_4424_9d08_b1bf0f049dfe---Power",
|
||||
"guid": "c20a63e0-0eeb-4424-9d08-b1bf0f049dfe"
|
||||
},
|
||||
"c2453304-c9ac-4d67-a045-fbda68876434": {
|
||||
"name": "AllowEditViews",
|
||||
"type": "final class",
|
||||
"namespace": "VDM\\Joomla\\Componentbuilder\\Compiler\\Architecture\\JoomlaFour\\Controller",
|
||||
"code": "src\/c2453304-c9ac-4d67-a045-fbda68876434\/code.php",
|
||||
"power": "src\/c2453304-c9ac-4d67-a045-fbda68876434\/code.power",
|
||||
"settings": "src\/c2453304-c9ac-4d67-a045-fbda68876434\/settings.json",
|
||||
"path": "src\/c2453304-c9ac-4d67-a045-fbda68876434",
|
||||
"spk": "Super---c2453304_c9ac_4d67_a045_fbda68876434---Power",
|
||||
"guid": "c2453304-c9ac-4d67-a045-fbda68876434"
|
||||
},
|
||||
"c600f58c-3fe2-4d2d-b711-2660eab6effe": {
|
||||
"name": "InputButtonInterface",
|
||||
"type": "interface",
|
||||
|
Loading…
Reference in New Issue
Block a user