Stable release of v5.0.0-alpha1

First alpha release of Component Builder towards Joomla 5 (very unstable...).
This commit is contained in:
2024-03-09 21:52:51 +02:00
parent 3c91a5cdbb
commit 87cd4305bb
3040 changed files with 296309 additions and 269802 deletions

View File

@ -52,7 +52,7 @@ final class Http extends JoomlaHttp
// add the token if given
if (is_string($token))
{
$config['headers']['Authorization'] = 'token ' . $token;
$config['headers']['Authorization'] = $token;
$this->_token_ = $token;
}
@ -78,7 +78,7 @@ final class Http extends JoomlaHttp
);
// add the token
$headers['Authorization'] = 'token ' . $token;
$headers['Authorization'] = $token;
$this->_token_ = $token;
$this->setOption('headers', $headers);

View File

@ -12,7 +12,7 @@
namespace VDM\Joomla\Gitea\Utilities;
use Joomla\CMS\Http\Response as JoomlaResponse;
use Joomla\Http\Response as JoomlaResponse;
use VDM\Joomla\Utilities\JsonHelper;
use VDM\Joomla\Utilities\StringHelper;
@ -36,7 +36,7 @@ final class Response
* @since 3.2.0
* @throws \DomainException
**/
public function get(JoomlaResponse $response, int $expectedCode = 200, $default = null)
public function get($response, int $expectedCode = 200, $default = null)
{
// Validate the response code.
if ($response->code != $expectedCode)
@ -62,7 +62,7 @@ final class Response
* @since 3.2.0
* @throws \DomainException
**/
public function get_(JoomlaResponse $response, array $validate = [200 => null])
public function get_($response, array $validate = [200 => null])
{
// Validate the response code.
if (!isset($validate[$response->code]))
@ -86,24 +86,23 @@ final class Response
* @return mixed
* @since 3.2.0
**/
protected function body(JoomlaResponse $response, $default = null)
protected function body($response, $default = null)
{
// check that we have a body and that its JSON
if (isset($response->body) && StringHelper::check($response->body))
$body = $response->body ?? null;
// check that we have a body
if (StringHelper::check($body))
{
if (JsonHelper::check($response->body))
if (JsonHelper::check($body))
{
$body = json_decode((string) $response->body);
$body = json_decode((string) $body);
if (isset($body->content_base64))
{
$body->content = base64_decode((string) $body->content_base64);
}
return $body;
}
return $response->body;
return $body;
}
return $default;
@ -117,7 +116,7 @@ final class Response
* @return string
* @since 3.2.0
**/
protected function error(JoomlaResponse $response): string
protected function error($response): string
{
// do we have a json string
if (isset($response->body) && JsonHelper::check($response->body))
@ -140,7 +139,6 @@ final class Response
}
return '';
}
}
}

View File

@ -12,7 +12,7 @@
namespace VDM\Joomla\Openai\Utilities;
use Joomla\CMS\Http\Response as JoomlaResponse;
use Joomla\Http\Response as JoomlaResponse;
use VDM\Joomla\Utilities\JsonHelper;
use VDM\Joomla\Utilities\StringHelper;
@ -36,7 +36,7 @@ final class Response
* @since 3.2.0
* @throws \DomainException
**/
public function get(JoomlaResponse $response, int $expectedCode = 200, $default = null)
public function get($response, int $expectedCode = 200, $default = null)
{
// Validate the response code.
if ($response->code != $expectedCode)
@ -62,7 +62,7 @@ final class Response
* @since 3.2.0
* @throws \DomainException
**/
public function get_(JoomlaResponse $response, array $validate = [200 => null])
public function get_($response, array $validate = [200 => null])
{
// Validate the response code.
if (!isset($validate[$response->code]))
@ -87,17 +87,18 @@ final class Response
* @return mixed
* @since 3.2.0
**/
protected function body(JoomlaResponse $response, $default = null)
protected function body($response, $default = null)
{
// check that we have a body and that its JSON
if (isset($response->body) && StringHelper::check($response->body))
$body = $response->body ?? null;
// check that we have a body
if (StringHelper::check($body))
{
if (JsonHelper::check($response->body))
if (JsonHelper::check($body))
{
return json_decode((string) $response->body);
$body = json_decode((string) $body);
}
return $response->body;
return $body;
}
return $default;
@ -111,7 +112,7 @@ final class Response
* @return string
* @since 3.2.0
**/
protected function error(JoomlaResponse $response): string
protected function error($response): string
{
// do we have a json string
if (isset($response->body) && JsonHelper::check($response->body))

View File

@ -32,6 +32,14 @@ abstract class ActiveRegistry implements Activeregistryinterface
**/
protected array $active = [];
/**
* Base switch to add values as string or array
*
* @var boolean
* @since 3.2.0
**/
protected bool $addAsArray = false;
/**
* Check if the registry has any content.
*
@ -95,21 +103,29 @@ abstract class ActiveRegistry implements Activeregistryinterface
* Adds content into the registry. If a key exists,
* it either appends or concatenates based on the value's type.
*
* @param mixed $value The value to set.
* @param bool $asArray Determines if the new value should be treated as an array.
* @param string ...$keys The keys to determine the location.
* @param mixed $value The value to set.
* @param bool|null $asArray Determines if the new value should be treated as an array.
* Default is $addAsArray = false (if null) in base class.
* Override in child class allowed set class property $addAsArray = true.
* @param string ...$keys The keys to determine the location.
*
* @throws \InvalidArgumentException If any of the keys are not a number or string.
* @return void
* @since 3.2.0
*/
public function addActive($value, bool $asArray, string ...$keys): void
public function addActive($value, ?bool $asArray, string ...$keys): void
{
if (!$this->validActiveKeys($keys))
{
throw new \InvalidArgumentException("Keys must only be strings or numbers to add any value.");
}
// null fallback to class value
if ($asArray === null)
{
$asArray = $this->addAsArray;
}
$array = &$this->active;
foreach ($keys as $key)

View File

@ -42,7 +42,7 @@ abstract class BaseConfig extends JoomlaRegistry
*
* @since 3.2.0
*/
public function __set(string $key, $value)
public function __set($key, $value)
{
$this->set($key, $value);
}
@ -50,12 +50,12 @@ abstract class BaseConfig extends JoomlaRegistry
/**
* getting any valid value
*
* @param string $key The value's key/path name
* @param string $key The value's key/path name
*
* @since 3.2.0
* @throws \InvalidArgumentException If $key is not a valid function name.
*/
public function __get(string $key)
public function __get($key)
{
// check if it has been set
if (($value = $this->get($key, '__N0T_S3T_Y3T_')) !== '__N0T_S3T_Y3T_')

View File

@ -26,10 +26,9 @@ abstract class Database
/**
* Database object to query local DB
*
* @var \JDatabaseDriver
* @since 3.2.0
*/
protected \JDatabaseDriver $db;
protected $db;
/**
* Core Component Table Name
@ -42,14 +41,12 @@ abstract class Database
/**
* Constructor
*
* @param \JDatabaseDriver|null $db The database driver
*
* @throws \Exception
* @since 3.2.0
*/
public function __construct(?\JDatabaseDriver $db = null)
public function __construct()
{
$this->db = $db ?: JoomlaFactory::getDbo();
$this->db = JoomlaFactory::getDbo();
// set the component table
$this->table = '#__' . Helper::getCode();

View File

@ -58,15 +58,17 @@ abstract class Registry extends ActiveRegistry implements Activeregistryinterfac
* Adds content into the registry. If a key exists,
* it either appends or concatenates based on $asArray switch.
*
* @param string $path Registry path (e.g. vdm.content.builder)
* @param mixed $value Value of entry
* @param bool $asArray Determines if the new value should be treated as an array. Default is false.
* @param string $path Registry path (e.g. vdm.content.builder)
* @param mixed $value Value of entry
* @param bool|null $asArray Determines if the new value should be treated as an array.
* Default is $addAsArray = false (if null) in base class.
* Override in child class allowed set class property $addAsArray = true.
*
* @throws \InvalidArgumentException If any of the path values are not a number or string.
* @return void
* @since 3.2.0
*/
public function add(string $path, $value, bool $asArray = false): void
public function add(string $path, $value, ?bool $asArray = null): void
{
if (($keys = $this->getActiveKeys($path)) === null)
{

View File

@ -17,7 +17,7 @@ use VDM\Joomla\Componentbuilder\Compiler\Config;
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\EventInterface as Event;
use VDM\Joomla\Componentbuilder\Compiler\Placeholder;
use VDM\Joomla\Componentbuilder\Compiler\Customcode\Dispenser;
use VDM\Joomla\Componentbuilder\Compiler\Model\Customtabs;
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Model\CustomtabsInterface as Customtabs;
use VDM\Joomla\Componentbuilder\Compiler\Model\Tabs;
use VDM\Joomla\Componentbuilder\Compiler\Model\Fields;
use VDM\Joomla\Componentbuilder\Compiler\Model\Historyadminview as History;
@ -226,10 +226,9 @@ class Data
/**
* Database object to query local DB
*
* @var \JDatabaseDriver
* @since 3.2.0
**/
protected \JDatabaseDriver $db;
protected $db;
/**
* Constructor.
@ -256,14 +255,13 @@ class Data
* @param Sql $sql The Sql Class.
* @param Mysqlsettings $mysqlsettings The Mysqlsettings Class.
* @param SiteEditView $siteeditview The SiteEditView Class.
* @param \JDatabaseDriver|null $db The Database Class.
*
* @since 3.2.0
*/
public function __construct(Config $config, Event $event, Placeholder $placeholder, Dispenser $dispenser, Customtabs $customtabs, Tabs $tabs, Fields $fields,
History $history, Permissions $permissions, Conditions $conditions, Relations $relations, Linkedviews $linkedviews, Javascript $javascript,
Css $css, Php $php, Custombuttons $custombuttons, Customimportscripts $customimportscripts, Ajax $ajax, Customalias $customalias, Sql $sql,
Mysqlsettings $mysqlsettings, SiteEditView $siteeditview, ?\JDatabaseDriver $db = null)
Mysqlsettings $mysqlsettings, SiteEditView $siteeditview)
{
$this->config = $config;
$this->event = $event;
@ -287,7 +285,7 @@ class Data
$this->sql = $sql;
$this->mysqlsettings = $mysqlsettings;
$this->siteeditview = $siteeditview;
$this->db = $db ?: Factory::getDbo();
$this->db = Factory::getDbo();
}
/**
@ -357,12 +355,9 @@ class Data
$query->where($this->db->quoteName('a.id') . ' = ' . (int) $id);
// for plugin event TODO change event api signatures
$component_context = $this->config->component_context;
// Trigger Event: jcb_ce_onBeforeQueryViewData
$this->event->trigger(
'jcb_ce_onBeforeQueryViewData',
array(&$component_context, &$id, &$query, &$this->db)
'jcb_ce_onBeforeQueryViewData', [&$id, &$query, &$this->db]
);
// Reset the query using our newly populated query object.
@ -423,16 +418,10 @@ class Data
$view->name_list, 'U'
));
// for plugin event TODO change event api signatures
$placeholders = $this->placeholder->active;
$component_context = $this->config->component_context;
// Trigger Event: jcb_ce_onBeforeModelViewData
$this->event->trigger(
'jcb_ce_onBeforeModelViewData',
array(&$component_context, &$view, &$placeholders)
'jcb_ce_onBeforeModelViewData', [&$view]
);
unset($placeholders);
// add the tables
$view->addtables = (isset($view->addtables)
@ -502,13 +491,9 @@ class Data
// set mySql Table Settings
$this->mysqlsettings->set($view);
// for plugin event TODO change event api signatures
$placeholders = $this->placeholder->active;
// Trigger Event: jcb_ce_onAfterModelViewData
$this->event->trigger(
'jcb_ce_onAfterModelViewData',
array(&$component_context, &$view, &$placeholders)
'jcb_ce_onAfterModelViewData', [&$view]
);
// clear placeholders

View File

@ -82,10 +82,9 @@ class Data
/**
* Database object to query local DB
*
* @var \JDatabaseDriver
* @since 3.2.0
**/
protected \JDatabaseDriver $db;
protected $db;
/**
* Constructor
@ -102,8 +101,7 @@ class Data
*/
public function __construct(?Config $config = null, ?Registry $registry = null,
?Customcode $customcode = null, ?Gui $gui = null,
?Loader $loader = null, ?Libraries $libraries = null,
?\JDatabaseDriver $db = null)
?Loader $loader = null, ?Libraries $libraries = null)
{
$this->config = $config ?: Compiler::_('Config');
$this->registry = $registry ?: Compiler::_('Registry');
@ -111,7 +109,7 @@ class Data
$this->gui = $gui ?: Compiler::_('Customcode.Gui');
$this->loader = $loader ?: Compiler::_('Model.Loader');
$this->libraries = $libraries ?: Compiler::_('Model.Libraries');
$this->db = $db ?: Factory::getDbo();
$this->db = Factory::getDbo();
}
/**

View File

@ -0,0 +1,129 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaFive\Controller;
use VDM\Joomla\Componentbuilder\Compiler\Config;
use VDM\Joomla\Componentbuilder\Compiler\Creator\Permission;
use VDM\Joomla\Componentbuilder\Compiler\Customcode\Dispenser;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Line;
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Architecture\Controller\AllowAddInterface;
/**
* Controller Allow Add Class for Joomla 5
*
* @since 3.2.0
*/
final class AllowAdd implements AllowAddInterface
{
/**
* The Component code name.
*
* @var String
* @since 3.2.0
*/
protected String $component;
/**
* The Permission Class.
*
* @var Permission
* @since 3.2.0
*/
protected Permission $permission;
/**
* The Dispenser Class.
*
* @var Dispenser
* @since 3.2.0
*/
protected Dispenser $dispenser;
/**
* Constructor.
*
* @param Config $config The Config Class.
* @param Permission $permission The Permission Class.
* @param Dispenser $dispenser The Dispenser Class.
*
* @since 3.2.0
*/
public function __construct(Config $config, Permission $permission,
Dispenser $dispenser)
{
$this->component = $config->component_code_name;
$this->permission = $permission;
$this->dispenser = $dispenser;
}
/**
* Get Allow Add Function Code
*
* @param string $nameSingleCode The single code name of the view.
*
* @since 3.2.0
* @return string The allow add method code
*/
public function get(string $nameSingleCode): string
{
$allow = [];
// prepare custom permission script
$custom_allow = $this->dispenser->get(
'php_allowadd', $nameSingleCode, '', null, true
);
$allow[] = PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__, __Class__)
. " Get user object.";
$allow[] = Indent::_(2) . "\$user = \$this->app->getIdentity();";
// check if the item has permissions.
if ($this->permission->globalExist($nameSingleCode, 'core.access'))
{
$allow[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
. " Access check.";
$allow[] = Indent::_(2) . "\$access = \$user->authorise('"
. $this->permission->getGlobal($nameSingleCode, 'core.access')
. "', 'com_" . $this->component . "');";
$allow[] = Indent::_(2) . "if (!\$access)";
$allow[] = Indent::_(2) . "{";
$allow[] = Indent::_(3) . "return false;";
$allow[] = Indent::_(2) . "}";
}
// load custom permission script
$allow[] = $custom_allow;
// check if the item has permissions.
if ($this->permission->globalExist($nameSingleCode, 'core.create'))
{
// setup the default script
$allow[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
. " In the absence of better information, revert to the component permissions.";
$allow[] = Indent::_(2) . "return \$user->authorise('"
. $this->permission->getGlobal($nameSingleCode, 'core.create')
. "', \$this->option);";
}
else
{
// setup the default script
$allow[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
. " In the absence of better information, revert to the component permissions.";
$allow[] = Indent::_(2) . "return parent::allowAdd(\$data);";
}
return implode(PHP_EOL, $allow);
}
}

View File

@ -0,0 +1,300 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaFive\Controller;
use VDM\Joomla\Componentbuilder\Compiler\Config;
use VDM\Joomla\Componentbuilder\Compiler\Creator\Permission;
use VDM\Joomla\Componentbuilder\Compiler\Customcode\Dispenser;
use VDM\Joomla\Componentbuilder\Compiler\Builder\Category;
use VDM\Joomla\Componentbuilder\Compiler\Builder\CategoryOtherName;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Line;
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Architecture\Controller\AllowEditInterface;
/**
* Controller Allow Edit Class for Joomla 5
*
* @since 3.2.0
*/
final class AllowEdit implements AllowEditInterface
{
/**
* The Component code name.
*
* @var String
* @since 3.2.0
*/
protected String $component;
/**
* The Permission Class.
*
* @var Permission
* @since 3.2.0
*/
protected Permission $permission;
/**
* The Dispenser Class.
*
* @var Dispenser
* @since 3.2.0
*/
protected Dispenser $dispenser;
/**
* The Category Class.
*
* @var Category
* @since 3.2.0
*/
protected Category $category;
/**
* The CategoryOtherName Class.
*
* @var CategoryOtherName
* @since 3.2.0
*/
protected CategoryOtherName $categoryothername;
/**
* Constructor.
*
* @param Config $config The Config Class.
* @param Permission $permission The Permission Class.
* @param Dispenser $dispenser The Dispenser Class.
* @param Category $category The Category Class.
* @param CategoryOtherName $categoryothername The CategoryOtherName Class.
*
* @since 3.2.0
*/
public function __construct(Config $config, Permission $permission,
Dispenser $dispenser, Category $category,
CategoryOtherName $categoryothername)
{
$this->component = $config->component_code_name;
$this->permission = $permission;
$this->dispenser = $dispenser;
$this->category = $category;
$this->categoryothername = $categoryothername;
}
/**
* Get Allow Edit Function Code
*
* @param string $nameSingleCode The single code name of the view.
* @param string $nameListCode The list code name of the view.
*
* @since 3.2.0
* @return string The allow edit method code
*/
public function get(string $nameSingleCode, string $nameListCode): string
{
$allow = [];
// prepare custom permission script
$customAllow = $this->dispenser->get(
'php_allowedit', $nameSingleCode, '', null, true
);
if ($this->category->exists("{$nameListCode}"))
{
// check if category has another name
$otherViews = $this->categoryothername->
get($nameListCode . '.views', $nameListCode);
$otherView = $this->categoryothername->
get($nameListCode . '.view', $nameSingleCode);
// setup the category script
$allow[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
. " get user object.";
$allow[] = Indent::_(2) . "\$user = \$this->app->getIdentity();";
$allow[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
. " get record id.";
$allow[] = Indent::_(2)
. "\$recordId = (int) isset(\$data[\$key]) ? \$data[\$key] : 0;";
// load custom permission script
$allow[] = $customAllow;
// check if the item has permissions.
if ($this->permission->globalExist($otherView, 'core.access'))
{
$allow[] = PHP_EOL . Indent::_(2) . "//" . Line::_(
__LINE__,__CLASS__
) . " Access check.";
$allow[] = Indent::_(2) . "\$access = (\$user->authorise('"
. $this->permission->getGlobal($otherView, 'core.access')
. "', 'com_" . $this->component . "." . $otherView
. ".' . (int) \$recordId) && \$user->authorise('"
. $this->permission->getGlobal($otherView, 'core.access')
. "', 'com_" . $this->component . "'));";
$allow[] = Indent::_(2) . "if (!\$access)";
$allow[] = Indent::_(2) . "{";
$allow[] = Indent::_(3) . "return false;";
$allow[] = Indent::_(2) . "}";
}
$allow[] = PHP_EOL . Indent::_(2) . "if (\$recordId)";
$allow[] = Indent::_(2) . "{";
$allow[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__)
. " The record has been set. Check the record permissions.";
// check if the item has permissions.
$allow[] = Indent::_(3) . "\$permission = \$user->authorise('"
. $this->permission->getAction($otherView, 'core.edit') . "', 'com_" . $this->component . "."
. $otherView . ".' . (int) \$recordId);";
$allow[] = Indent::_(3) . "if (!\$permission)";
$allow[] = Indent::_(3) . "{";
// check if the item has permissions.
$allow[] = Indent::_(4) . "if (\$user->authorise('"
. $this->permission->getAction($otherView, 'core.edit.own') . "', 'com_" . $this->component . "."
. $otherView . ".' . \$recordId))";
$allow[] = Indent::_(4) . "{";
$allow[] = Indent::_(5) . "//" . Line::_(__Line__, __Class__)
. " Fallback on edit.own. Now test the owner is the user.";
$allow[] = Indent::_(5)
. "\$ownerId = (int) isset(\$data['created_by']) ? \$data['created_by'] : 0;";
$allow[] = Indent::_(5) . "if (empty(\$ownerId))";
$allow[] = Indent::_(5) . "{";
$allow[] = Indent::_(6) . "//" . Line::_(__Line__, __Class__)
. " Need to do a lookup from the model.";
$allow[] = Indent::_(6)
. "\$record = \$this->getModel()->getItem(\$recordId);";
$allow[] = PHP_EOL . Indent::_(6) . "if (empty(\$record))";
$allow[] = Indent::_(6) . "{";
$allow[] = Indent::_(7) . "return false;";
$allow[] = Indent::_(6) . "}";
$allow[] = Indent::_(6) . "\$ownerId = \$record->created_by;";
$allow[] = Indent::_(5) . "}";
$allow[] = PHP_EOL . Indent::_(5) . "//" . Line::_(__Line__, __Class__)
. " If the owner matches 'me' then do the test.";
$allow[] = Indent::_(5) . "if (\$ownerId == \$user->id)";
$allow[] = Indent::_(5) . "{";
// check if the item has permissions.
$allow[] = Indent::_(6) . "if (\$user->authorise('"
. $this->permission->getGlobal($otherView, 'core.edit.own') . "', 'com_" . $this->component . "'))";
$allow[] = Indent::_(6) . "{";
$allow[] = Indent::_(7) . "return true;";
$allow[] = Indent::_(6) . "}";
$allow[] = Indent::_(5) . "}";
$allow[] = Indent::_(4) . "}";
$allow[] = Indent::_(4) . "return false;";
$allow[] = Indent::_(3) . "}";
$allow[] = Indent::_(2) . "}";
if ($this->permission->globalExist($otherView, 'core.edit'))
{
$allow[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
. " Since there is no permission, revert to the component permissions.";
$allow[] = Indent::_(2) . "return \$user->authorise('"
. $this->permission->getGlobal($otherView, 'core.edit') . "', \$this->option);";
}
else
{
$allow[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
. " Since there is no permission, revert to the component permissions.";
$allow[] = Indent::_(2)
. "return parent::allowEdit(\$data, \$key);";
}
}
else
{
// setup the category script
$allow[] = PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__, __Class__)
. " get user object.";
$allow[] = Indent::_(2) . "\$user = \$this->app->getIdentity();";
$allow[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
. " get record id.";
$allow[] = Indent::_(2)
. "\$recordId = (int) isset(\$data[\$key]) ? \$data[\$key] : 0;";
// load custom permission script
$allow[] = $customAllow;
// check if the item has permissions.
if ($this->permission->actionExist($nameSingleCode, 'core.access'))
{
$allow[] = PHP_EOL . Indent::_(2) . "//" . Line::_(
__LINE__,__CLASS__
) . " Access check.";
$allow[] = Indent::_(2) . "\$access = (\$user->authorise('"
. $this->permission->getAction($nameSingleCode, 'core.access') . "', 'com_" . $this->component . "."
. $nameSingleCode
. ".' . (int) \$recordId) && \$user->authorise('"
. $this->permission->getAction($nameSingleCode, 'core.access') . "', 'com_" . $this->component . "'));";
$allow[] = Indent::_(2) . "if (!\$access)";
$allow[] = Indent::_(2) . "{";
$allow[] = Indent::_(3) . "return false;";
$allow[] = Indent::_(2) . "}";
}
$allow[] = PHP_EOL . Indent::_(2) . "if (\$recordId)";
$allow[] = Indent::_(2) . "{";
$allow[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__)
. " The record has been set. Check the record permissions.";
// check if the item has permissions.
$allow[] = Indent::_(3) . "\$permission = \$user->authorise('"
. $this->permission->getAction($nameSingleCode, 'core.edit') . "', 'com_" . $this->component . "."
. $nameSingleCode . ".' . (int) \$recordId);";
$allow[] = Indent::_(3) . "if (!\$permission)";
$allow[] = Indent::_(3) . "{";
// check if the item has permissions.
$allow[] = Indent::_(4) . "if (\$user->authorise('"
. $this->permission->getAction($nameSingleCode, 'core.edit.own') . "', 'com_" . $this->component . "."
. $nameSingleCode . ".' . \$recordId))";
$allow[] = Indent::_(4) . "{";
$allow[] = Indent::_(5) . "//" . Line::_(__Line__, __Class__)
. " Now test the owner is the user.";
$allow[] = Indent::_(5)
. "\$ownerId = (int) isset(\$data['created_by']) ? \$data['created_by'] : 0;";
$allow[] = Indent::_(5) . "if (empty(\$ownerId))";
$allow[] = Indent::_(5) . "{";
$allow[] = Indent::_(6) . "//" . Line::_(__Line__, __Class__)
. " Need to do a lookup from the model.";
$allow[] = Indent::_(6)
. "\$record = \$this->getModel()->getItem(\$recordId);";
$allow[] = PHP_EOL . Indent::_(6) . "if (empty(\$record))";
$allow[] = Indent::_(6) . "{";
$allow[] = Indent::_(7) . "return false;";
$allow[] = Indent::_(6) . "}";
$allow[] = Indent::_(6) . "\$ownerId = \$record->created_by;";
$allow[] = Indent::_(5) . "}";
$allow[] = PHP_EOL . Indent::_(5) . "//" . Line::_(__Line__, __Class__)
. " If the owner matches 'me' then allow.";
$allow[] = Indent::_(5) . "if (\$ownerId == \$user->id)";
$allow[] = Indent::_(5) . "{";
// check if the item has permissions.
$allow[] = Indent::_(6) . "if (\$user->authorise('"
. $this->permission->getGlobal($nameSingleCode, 'core.edit.own') . "', 'com_" . $this->component . "'))";
$allow[] = Indent::_(6) . "{";
$allow[] = Indent::_(7) . "return true;";
$allow[] = Indent::_(6) . "}";
$allow[] = Indent::_(5) . "}";
$allow[] = Indent::_(4) . "}";
$allow[] = Indent::_(4) . "return false;";
$allow[] = Indent::_(3) . "}";
$allow[] = Indent::_(2) . "}";
if ($this->permission->globalExist($nameSingleCode, 'core.edit'))
{
$allow[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
. " Since there is no permission, revert to the component permissions.";
$allow[] = Indent::_(2) . "return \$user->authorise('"
. $this->permission->getGlobal($nameSingleCode, 'core.edit') . "', \$this->option);";
}
else
{
$allow[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
. " Since there is no permission, revert to the component permissions.";
$allow[] = Indent::_(2)
. "return parent::allowEdit(\$data, \$key);";
}
}
return implode(PHP_EOL, $allow);
}
}

View File

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

View File

@ -0,0 +1,87 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaFive\Model;
use VDM\Joomla\Componentbuilder\Compiler\Config;
use VDM\Joomla\Componentbuilder\Compiler\Creator\Permission;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Line;
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Architecture\Model\CanDeleteInterface;
/**
* Model Can Delete Class for Joomla 5
*
* @since 3.2.0
*/
final class CanDelete implements CanDeleteInterface
{
/**
* The Component code name.
*
* @var String
* @since 3.2.0
*/
protected String $component;
/**
* The Permission Class.
*
* @var Permission
* @since 3.2.0
*/
protected Permission $permission;
/**
* Constructor.
*
* @param Config $config The Config Class.
* @param Permission $permission The Permission Class.
*
* @since 3.2.0
*/
public function __construct(Config $config, Permission $permission)
{
$this->component = $config->component_code_name;
$this->permission = $permission;
}
/**
* Get Can Delete Function Code
*
* @param string $nameSingleCode The single code name of the view.
*
* @since 3.2.0
* @return string The can delete method code
*/
public function get(string $nameSingleCode): string
{
$allow = [];
// setup the default script
$allow[] = PHP_EOL . Indent::_(2) . "if (empty(\$record->id) || (\$record->published != -2))";
$allow[] = Indent::_(2) . "{";
$allow[] = Indent::_(3) . "return false;";
$allow[] = Indent::_(2) . "}" . PHP_EOL;
// check if the item has permissions.
$allow[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
. " The record has been set. Check the record permissions.";
$allow[] = Indent::_(2) . "return \$this->getCurrentUser()->authorise('"
. $this->permission->getAction($nameSingleCode, 'core.delete') . "', 'com_" . $this->component . "."
. $nameSingleCode . ".' . (int) \$record->id);";
return implode(PHP_EOL, $allow);
}
}

View File

@ -0,0 +1,108 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaFive\Model;
use VDM\Joomla\Componentbuilder\Compiler\Config;
use VDM\Joomla\Componentbuilder\Compiler\Creator\Permission;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Line;
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Architecture\Model\CanEditStateInterface;
/**
* Model Can Edit State Class for Joomla 5
*
* @since 3.2.0
*/
final class CanEditState implements CanEditStateInterface
{
/**
* The Component code name.
*
* @var String
* @since 3.2.0
*/
protected String $component;
/**
* The Permission Class.
*
* @var Permission
* @since 3.2.0
*/
protected Permission $permission;
/**
* Constructor.
*
* @param Config $config The Config Class.
* @param Permission $permission The Permission Class.
*
* @since 3.2.0
*/
public function __construct(Config $config, Permission $permission)
{
$this->component = $config->component_code_name;
$this->permission = $permission;
}
/**
* Get Can Edit State Function Code
*
* @param string $nameSingleCode The single code name of the view.
*
* @since 3.2.0
* @return string The can edit state method code
*/
public function get(string $nameSingleCode): string
{
$allow = [];
// setup the default script
$allow[] = PHP_EOL . Indent::_(2) . "\$user = \$this->getCurrentUser();";
$allow[] = Indent::_(2)
. "\$recordId = \$record->id ?? 0;";
$allow[] = PHP_EOL . Indent::_(2) . "if (\$recordId)";
$allow[] = Indent::_(2) . "{";
$allow[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__)
. " The record has been set. Check the record permissions.";
// check if the item has permissions.
$allow[] = Indent::_(3) . "\$permission = \$user->authorise('"
. $this->permission->getAction($nameSingleCode, 'core.edit.state')
. "', 'com_" . $this->component . "." . $nameSingleCode . ".' . (int) \$recordId);";
$allow[] = Indent::_(3)
. "if (!\$permission && !is_null(\$permission))";
$allow[] = Indent::_(3) . "{";
$allow[] = Indent::_(4) . "return false;";
$allow[] = Indent::_(3) . "}";
$allow[] = Indent::_(2) . "}";
if ($this->permission->globalExist($nameSingleCode, 'core.edit.state'))
{
$allow[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
. " In the absence of better information, revert to the component permissions.";
$allow[] = Indent::_(2) . "return \$user->authorise('"
. $this->permission->getGlobal($nameSingleCode, 'core.edit.state') . "', 'com_" . $this->component
. "');";
}
else
{
$allow[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
. " In the absence of better information, revert to the component permissions.";
$allow[] = Indent::_(2)
. "return parent::canEditState(\$record);";
}
return implode(PHP_EOL, $allow);
}
}

View File

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

View File

@ -0,0 +1,129 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaFour\Controller;
use VDM\Joomla\Componentbuilder\Compiler\Config;
use VDM\Joomla\Componentbuilder\Compiler\Creator\Permission;
use VDM\Joomla\Componentbuilder\Compiler\Customcode\Dispenser;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Line;
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Architecture\Controller\AllowAddInterface;
/**
* Controller Allow Add Class for Joomla 4
*
* @since 3.2.0
*/
final class AllowAdd implements AllowAddInterface
{
/**
* The Component code name.
*
* @var String
* @since 3.2.0
*/
protected String $component;
/**
* The Permission Class.
*
* @var Permission
* @since 3.2.0
*/
protected Permission $permission;
/**
* The Dispenser Class.
*
* @var Dispenser
* @since 3.2.0
*/
protected Dispenser $dispenser;
/**
* Constructor.
*
* @param Config $config The Config Class.
* @param Permission $permission The Permission Class.
* @param Dispenser $dispenser The Dispenser Class.
*
* @since 3.2.0
*/
public function __construct(Config $config, Permission $permission,
Dispenser $dispenser)
{
$this->component = $config->component_code_name;
$this->permission = $permission;
$this->dispenser = $dispenser;
}
/**
* Get Allow Add Function Code
*
* @param string $nameSingleCode The single code name of the view.
*
* @since 3.2.0
* @return string The allow add method code
*/
public function get(string $nameSingleCode): string
{
$allow = [];
// prepare custom permission script
$custom_allow = $this->dispenser->get(
'php_allowadd', $nameSingleCode, '', null, true
);
$allow[] = PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__, __Class__)
. " Get user object.";
$allow[] = Indent::_(2) . "\$user = \$this->app->getIdentity();";
// check if the item has permissions.
if ($this->permission->globalExist($nameSingleCode, 'core.access'))
{
$allow[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
. " Access check.";
$allow[] = Indent::_(2) . "\$access = \$user->authorise('"
. $this->permission->getGlobal($nameSingleCode, 'core.access')
. "', 'com_" . $this->component . "');";
$allow[] = Indent::_(2) . "if (!\$access)";
$allow[] = Indent::_(2) . "{";
$allow[] = Indent::_(3) . "return false;";
$allow[] = Indent::_(2) . "}";
}
// load custom permission script
$allow[] = $custom_allow;
// check if the item has permissions.
if ($this->permission->globalExist($nameSingleCode, 'core.create'))
{
// setup the default script
$allow[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
. " In the absence of better information, revert to the component permissions.";
$allow[] = Indent::_(2) . "return \$user->authorise('"
. $this->permission->getGlobal($nameSingleCode, 'core.create')
. "', \$this->option);";
}
else
{
// setup the default script
$allow[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
. " In the absence of better information, revert to the component permissions.";
$allow[] = Indent::_(2) . "return parent::allowAdd(\$data);";
}
return implode(PHP_EOL, $allow);
}
}

View File

@ -0,0 +1,300 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaFour\Controller;
use VDM\Joomla\Componentbuilder\Compiler\Config;
use VDM\Joomla\Componentbuilder\Compiler\Creator\Permission;
use VDM\Joomla\Componentbuilder\Compiler\Customcode\Dispenser;
use VDM\Joomla\Componentbuilder\Compiler\Builder\Category;
use VDM\Joomla\Componentbuilder\Compiler\Builder\CategoryOtherName;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Line;
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Architecture\Controller\AllowEditInterface;
/**
* Controller Allow Edit Class for Joomla 4
*
* @since 3.2.0
*/
final class AllowEdit implements AllowEditInterface
{
/**
* The Component code name.
*
* @var String
* @since 3.2.0
*/
protected String $component;
/**
* The Permission Class.
*
* @var Permission
* @since 3.2.0
*/
protected Permission $permission;
/**
* The Dispenser Class.
*
* @var Dispenser
* @since 3.2.0
*/
protected Dispenser $dispenser;
/**
* The Category Class.
*
* @var Category
* @since 3.2.0
*/
protected Category $category;
/**
* The CategoryOtherName Class.
*
* @var CategoryOtherName
* @since 3.2.0
*/
protected CategoryOtherName $categoryothername;
/**
* Constructor.
*
* @param Config $config The Config Class.
* @param Permission $permission The Permission Class.
* @param Dispenser $dispenser The Dispenser Class.
* @param Category $category The Category Class.
* @param CategoryOtherName $categoryothername The CategoryOtherName Class.
*
* @since 3.2.0
*/
public function __construct(Config $config, Permission $permission,
Dispenser $dispenser, Category $category,
CategoryOtherName $categoryothername)
{
$this->component = $config->component_code_name;
$this->permission = $permission;
$this->dispenser = $dispenser;
$this->category = $category;
$this->categoryothername = $categoryothername;
}
/**
* Get Allow Edit Function Code
*
* @param string $nameSingleCode The single code name of the view.
* @param string $nameListCode The list code name of the view.
*
* @since 3.2.0
* @return string The allow edit method code
*/
public function get(string $nameSingleCode, string $nameListCode): string
{
$allow = [];
// prepare custom permission script
$customAllow = $this->dispenser->get(
'php_allowedit', $nameSingleCode, '', null, true
);
if ($this->category->exists("{$nameListCode}"))
{
// check if category has another name
$otherViews = $this->categoryothername->
get($nameListCode . '.views', $nameListCode);
$otherView = $this->categoryothername->
get($nameListCode . '.view', $nameSingleCode);
// setup the category script
$allow[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
. " get user object.";
$allow[] = Indent::_(2) . "\$user = \$this->app->getIdentity();";
$allow[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
. " get record id.";
$allow[] = Indent::_(2)
. "\$recordId = (int) isset(\$data[\$key]) ? \$data[\$key] : 0;";
// load custom permission script
$allow[] = $customAllow;
// check if the item has permissions.
if ($this->permission->globalExist($otherView, 'core.access'))
{
$allow[] = PHP_EOL . Indent::_(2) . "//" . Line::_(
__LINE__,__CLASS__
) . " Access check.";
$allow[] = Indent::_(2) . "\$access = (\$user->authorise('"
. $this->permission->getGlobal($otherView, 'core.access')
. "', 'com_" . $this->component . "." . $otherView
. ".' . (int) \$recordId) && \$user->authorise('"
. $this->permission->getGlobal($otherView, 'core.access')
. "', 'com_" . $this->component . "'));";
$allow[] = Indent::_(2) . "if (!\$access)";
$allow[] = Indent::_(2) . "{";
$allow[] = Indent::_(3) . "return false;";
$allow[] = Indent::_(2) . "}";
}
$allow[] = PHP_EOL . Indent::_(2) . "if (\$recordId)";
$allow[] = Indent::_(2) . "{";
$allow[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__)
. " The record has been set. Check the record permissions.";
// check if the item has permissions.
$allow[] = Indent::_(3) . "\$permission = \$user->authorise('"
. $this->permission->getAction($otherView, 'core.edit') . "', 'com_" . $this->component . "."
. $otherView . ".' . (int) \$recordId);";
$allow[] = Indent::_(3) . "if (!\$permission)";
$allow[] = Indent::_(3) . "{";
// check if the item has permissions.
$allow[] = Indent::_(4) . "if (\$user->authorise('"
. $this->permission->getAction($otherView, 'core.edit.own') . "', 'com_" . $this->component . "."
. $otherView . ".' . \$recordId))";
$allow[] = Indent::_(4) . "{";
$allow[] = Indent::_(5) . "//" . Line::_(__Line__, __Class__)
. " Fallback on edit.own. Now test the owner is the user.";
$allow[] = Indent::_(5)
. "\$ownerId = (int) isset(\$data['created_by']) ? \$data['created_by'] : 0;";
$allow[] = Indent::_(5) . "if (empty(\$ownerId))";
$allow[] = Indent::_(5) . "{";
$allow[] = Indent::_(6) . "//" . Line::_(__Line__, __Class__)
. " Need to do a lookup from the model.";
$allow[] = Indent::_(6)
. "\$record = \$this->getModel()->getItem(\$recordId);";
$allow[] = PHP_EOL . Indent::_(6) . "if (empty(\$record))";
$allow[] = Indent::_(6) . "{";
$allow[] = Indent::_(7) . "return false;";
$allow[] = Indent::_(6) . "}";
$allow[] = Indent::_(6) . "\$ownerId = \$record->created_by;";
$allow[] = Indent::_(5) . "}";
$allow[] = PHP_EOL . Indent::_(5) . "//" . Line::_(__Line__, __Class__)
. " If the owner matches 'me' then do the test.";
$allow[] = Indent::_(5) . "if (\$ownerId == \$user->id)";
$allow[] = Indent::_(5) . "{";
// check if the item has permissions.
$allow[] = Indent::_(6) . "if (\$user->authorise('"
. $this->permission->getGlobal($otherView, 'core.edit.own') . "', 'com_" . $this->component . "'))";
$allow[] = Indent::_(6) . "{";
$allow[] = Indent::_(7) . "return true;";
$allow[] = Indent::_(6) . "}";
$allow[] = Indent::_(5) . "}";
$allow[] = Indent::_(4) . "}";
$allow[] = Indent::_(4) . "return false;";
$allow[] = Indent::_(3) . "}";
$allow[] = Indent::_(2) . "}";
if ($this->permission->globalExist($otherView, 'core.edit'))
{
$allow[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
. " Since there is no permission, revert to the component permissions.";
$allow[] = Indent::_(2) . "return \$user->authorise('"
. $this->permission->getGlobal($otherView, 'core.edit') . "', \$this->option);";
}
else
{
$allow[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
. " Since there is no permission, revert to the component permissions.";
$allow[] = Indent::_(2)
. "return parent::allowEdit(\$data, \$key);";
}
}
else
{
// setup the category script
$allow[] = PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__, __Class__)
. " get user object.";
$allow[] = Indent::_(2) . "\$user = \$this->app->getIdentity();";
$allow[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
. " get record id.";
$allow[] = Indent::_(2)
. "\$recordId = (int) isset(\$data[\$key]) ? \$data[\$key] : 0;";
// load custom permission script
$allow[] = $customAllow;
// check if the item has permissions.
if ($this->permission->actionExist($nameSingleCode, 'core.access'))
{
$allow[] = PHP_EOL . Indent::_(2) . "//" . Line::_(
__LINE__,__CLASS__
) . " Access check.";
$allow[] = Indent::_(2) . "\$access = (\$user->authorise('"
. $this->permission->getAction($nameSingleCode, 'core.access') . "', 'com_" . $this->component . "."
. $nameSingleCode
. ".' . (int) \$recordId) && \$user->authorise('"
. $this->permission->getAction($nameSingleCode, 'core.access') . "', 'com_" . $this->component . "'));";
$allow[] = Indent::_(2) . "if (!\$access)";
$allow[] = Indent::_(2) . "{";
$allow[] = Indent::_(3) . "return false;";
$allow[] = Indent::_(2) . "}";
}
$allow[] = PHP_EOL . Indent::_(2) . "if (\$recordId)";
$allow[] = Indent::_(2) . "{";
$allow[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__)
. " The record has been set. Check the record permissions.";
// check if the item has permissions.
$allow[] = Indent::_(3) . "\$permission = \$user->authorise('"
. $this->permission->getAction($nameSingleCode, 'core.edit') . "', 'com_" . $this->component . "."
. $nameSingleCode . ".' . (int) \$recordId);";
$allow[] = Indent::_(3) . "if (!\$permission)";
$allow[] = Indent::_(3) . "{";
// check if the item has permissions.
$allow[] = Indent::_(4) . "if (\$user->authorise('"
. $this->permission->getAction($nameSingleCode, 'core.edit.own') . "', 'com_" . $this->component . "."
. $nameSingleCode . ".' . \$recordId))";
$allow[] = Indent::_(4) . "{";
$allow[] = Indent::_(5) . "//" . Line::_(__Line__, __Class__)
. " Now test the owner is the user.";
$allow[] = Indent::_(5)
. "\$ownerId = (int) isset(\$data['created_by']) ? \$data['created_by'] : 0;";
$allow[] = Indent::_(5) . "if (empty(\$ownerId))";
$allow[] = Indent::_(5) . "{";
$allow[] = Indent::_(6) . "//" . Line::_(__Line__, __Class__)
. " Need to do a lookup from the model.";
$allow[] = Indent::_(6)
. "\$record = \$this->getModel()->getItem(\$recordId);";
$allow[] = PHP_EOL . Indent::_(6) . "if (empty(\$record))";
$allow[] = Indent::_(6) . "{";
$allow[] = Indent::_(7) . "return false;";
$allow[] = Indent::_(6) . "}";
$allow[] = Indent::_(6) . "\$ownerId = \$record->created_by;";
$allow[] = Indent::_(5) . "}";
$allow[] = PHP_EOL . Indent::_(5) . "//" . Line::_(__Line__, __Class__)
. " If the owner matches 'me' then allow.";
$allow[] = Indent::_(5) . "if (\$ownerId == \$user->id)";
$allow[] = Indent::_(5) . "{";
// check if the item has permissions.
$allow[] = Indent::_(6) . "if (\$user->authorise('"
. $this->permission->getGlobal($nameSingleCode, 'core.edit.own') . "', 'com_" . $this->component . "'))";
$allow[] = Indent::_(6) . "{";
$allow[] = Indent::_(7) . "return true;";
$allow[] = Indent::_(6) . "}";
$allow[] = Indent::_(5) . "}";
$allow[] = Indent::_(4) . "}";
$allow[] = Indent::_(4) . "return false;";
$allow[] = Indent::_(3) . "}";
$allow[] = Indent::_(2) . "}";
if ($this->permission->globalExist($nameSingleCode, 'core.edit'))
{
$allow[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
. " Since there is no permission, revert to the component permissions.";
$allow[] = Indent::_(2) . "return \$user->authorise('"
. $this->permission->getGlobal($nameSingleCode, 'core.edit') . "', \$this->option);";
}
else
{
$allow[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
. " Since there is no permission, revert to the component permissions.";
$allow[] = Indent::_(2)
. "return parent::allowEdit(\$data, \$key);";
}
}
return implode(PHP_EOL, $allow);
}
}

View File

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

View File

@ -0,0 +1,87 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaFour\Model;
use VDM\Joomla\Componentbuilder\Compiler\Config;
use VDM\Joomla\Componentbuilder\Compiler\Creator\Permission;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Line;
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Architecture\Model\CanDeleteInterface;
/**
* Model Can Delete Class for Joomla 4
*
* @since 3.2.0
*/
final class CanDelete implements CanDeleteInterface
{
/**
* The Component code name.
*
* @var String
* @since 3.2.0
*/
protected String $component;
/**
* The Permission Class.
*
* @var Permission
* @since 3.2.0
*/
protected Permission $permission;
/**
* Constructor.
*
* @param Config $config The Config Class.
* @param Permission $permission The Permission Class.
*
* @since 3.2.0
*/
public function __construct(Config $config, Permission $permission)
{
$this->component = $config->component_code_name;
$this->permission = $permission;
}
/**
* Get Can Delete Function Code
*
* @param string $nameSingleCode The single code name of the view.
*
* @since 3.2.0
* @return string The can delete method code
*/
public function get(string $nameSingleCode): string
{
$allow = [];
// setup the default script
$allow[] = PHP_EOL . Indent::_(2) . "if (empty(\$record->id) || (\$record->published != -2))";
$allow[] = Indent::_(2) . "{";
$allow[] = Indent::_(3) . "return false;";
$allow[] = Indent::_(2) . "}" . PHP_EOL;
// check if the item has permissions.
$allow[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
. " The record has been set. Check the record permissions.";
$allow[] = Indent::_(2) . "return \$this->getCurrentUser()->authorise('"
. $this->permission->getAction($nameSingleCode, 'core.delete') . "', 'com_" . $this->component . "."
. $nameSingleCode . ".' . (int) \$record->id);";
return implode(PHP_EOL, $allow);
}
}

View File

@ -0,0 +1,108 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaFour\Model;
use VDM\Joomla\Componentbuilder\Compiler\Config;
use VDM\Joomla\Componentbuilder\Compiler\Creator\Permission;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Line;
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Architecture\Model\CanEditStateInterface;
/**
* Model Can Edit State Class for Joomla 4
*
* @since 3.2.0
*/
final class CanEditState implements CanEditStateInterface
{
/**
* The Component code name.
*
* @var String
* @since 3.2.0
*/
protected String $component;
/**
* The Permission Class.
*
* @var Permission
* @since 3.2.0
*/
protected Permission $permission;
/**
* Constructor.
*
* @param Config $config The Config Class.
* @param Permission $permission The Permission Class.
*
* @since 3.2.0
*/
public function __construct(Config $config, Permission $permission)
{
$this->component = $config->component_code_name;
$this->permission = $permission;
}
/**
* Get Can Edit State Function Code
*
* @param string $nameSingleCode The single code name of the view.
*
* @since 3.2.0
* @return string The can edit state method code
*/
public function get(string $nameSingleCode): string
{
$allow = [];
// setup the default script
$allow[] = PHP_EOL . Indent::_(2) . "\$user = \$this->getCurrentUser();";
$allow[] = Indent::_(2)
. "\$recordId = \$record->id ?? 0;";
$allow[] = PHP_EOL . Indent::_(2) . "if (\$recordId)";
$allow[] = Indent::_(2) . "{";
$allow[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__)
. " The record has been set. Check the record permissions.";
// check if the item has permissions.
$allow[] = Indent::_(3) . "\$permission = \$user->authorise('"
. $this->permission->getAction($nameSingleCode, 'core.edit.state')
. "', 'com_" . $this->component . "." . $nameSingleCode . ".' . (int) \$recordId);";
$allow[] = Indent::_(3)
. "if (!\$permission && !is_null(\$permission))";
$allow[] = Indent::_(3) . "{";
$allow[] = Indent::_(4) . "return false;";
$allow[] = Indent::_(3) . "}";
$allow[] = Indent::_(2) . "}";
if ($this->permission->globalExist($nameSingleCode, 'core.edit.state'))
{
$allow[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
. " In the absence of better information, revert to the component permissions.";
$allow[] = Indent::_(2) . "return \$user->authorise('"
. $this->permission->getGlobal($nameSingleCode, 'core.edit.state') . "', 'com_" . $this->component
. "');";
}
else
{
$allow[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
. " In the absence of better information, revert to the component permissions.";
$allow[] = Indent::_(2)
. "return parent::canEditState(\$record);";
}
return implode(PHP_EOL, $allow);
}
}

View File

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

View File

@ -0,0 +1,129 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaThree\Controller;
use VDM\Joomla\Componentbuilder\Compiler\Config;
use VDM\Joomla\Componentbuilder\Compiler\Creator\Permission;
use VDM\Joomla\Componentbuilder\Compiler\Customcode\Dispenser;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Line;
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Architecture\Controller\AllowAddInterface;
/**
* Controller Allow Add Class for Joomla 3
*
* @since 3.2.0
*/
final class AllowAdd implements AllowAddInterface
{
/**
* The Component code name.
*
* @var String
* @since 3.2.0
*/
protected String $component;
/**
* The Permission Class.
*
* @var Permission
* @since 3.2.0
*/
protected Permission $permission;
/**
* The Dispenser Class.
*
* @var Dispenser
* @since 3.2.0
*/
protected Dispenser $dispenser;
/**
* Constructor.
*
* @param Config $config The Config Class.
* @param Permission $permission The Permission Class.
* @param Dispenser $dispenser The Dispenser Class.
*
* @since 3.2.0
*/
public function __construct(Config $config, Permission $permission,
Dispenser $dispenser)
{
$this->component = $config->component_code_name;
$this->permission = $permission;
$this->dispenser = $dispenser;
}
/**
* Get Allow Add Function Code
*
* @param string $nameSingleCode The single code name of the view.
*
* @since 3.2.0
* @return string The allow add method code
*/
public function get(string $nameSingleCode): string
{
$allow = [];
// prepare custom permission script
$custom_allow = $this->dispenser->get(
'php_allowadd', $nameSingleCode, '', null, true
);
$allow[] = PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__, __Class__)
. " Get user object.";
$allow[] = Indent::_(2) . "\$user = Factory::getUser();";
// check if the item has permissions.
if ($this->permission->globalExist($nameSingleCode, 'core.access'))
{
$allow[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
. " Access check.";
$allow[] = Indent::_(2) . "\$access = \$user->authorise('"
. $this->permission->getGlobal($nameSingleCode, 'core.access')
. "', 'com_" . $this->component . "');";
$allow[] = Indent::_(2) . "if (!\$access)";
$allow[] = Indent::_(2) . "{";
$allow[] = Indent::_(3) . "return false;";
$allow[] = Indent::_(2) . "}";
}
// load custom permission script
$allow[] = $custom_allow;
// check if the item has permissions.
if ($this->permission->globalExist($nameSingleCode, 'core.create'))
{
// setup the default script
$allow[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
. " In the absence of better information, revert to the component permissions.";
$allow[] = Indent::_(2) . "return \$user->authorise('"
. $this->permission->getGlobal($nameSingleCode, 'core.create')
. "', \$this->option);";
}
else
{
// setup the default script
$allow[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
. " In the absence of better information, revert to the component permissions.";
$allow[] = Indent::_(2) . "return parent::allowAdd(\$data);";
}
return implode(PHP_EOL, $allow);
}
}

View File

@ -0,0 +1,300 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaThree\Controller;
use VDM\Joomla\Componentbuilder\Compiler\Config;
use VDM\Joomla\Componentbuilder\Compiler\Creator\Permission;
use VDM\Joomla\Componentbuilder\Compiler\Customcode\Dispenser;
use VDM\Joomla\Componentbuilder\Compiler\Builder\Category;
use VDM\Joomla\Componentbuilder\Compiler\Builder\CategoryOtherName;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Line;
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Architecture\Controller\AllowEditInterface;
/**
* Controller Allow Edit Class for Joomla 3
*
* @since 3.2.0
*/
final class AllowEdit implements AllowEditInterface
{
/**
* The Component code name.
*
* @var String
* @since 3.2.0
*/
protected String $component;
/**
* The Permission Class.
*
* @var Permission
* @since 3.2.0
*/
protected Permission $permission;
/**
* The Dispenser Class.
*
* @var Dispenser
* @since 3.2.0
*/
protected Dispenser $dispenser;
/**
* The Category Class.
*
* @var Category
* @since 3.2.0
*/
protected Category $category;
/**
* The CategoryOtherName Class.
*
* @var CategoryOtherName
* @since 3.2.0
*/
protected CategoryOtherName $categoryothername;
/**
* Constructor.
*
* @param Config $config The Config Class.
* @param Permission $permission The Permission Class.
* @param Dispenser $dispenser The Dispenser Class.
* @param Category $category The Category Class.
* @param CategoryOtherName $categoryothername The CategoryOtherName Class.
*
* @since 3.2.0
*/
public function __construct(Config $config, Permission $permission,
Dispenser $dispenser, Category $category,
CategoryOtherName $categoryothername)
{
$this->component = $config->component_code_name;
$this->permission = $permission;
$this->dispenser = $dispenser;
$this->category = $category;
$this->categoryothername = $categoryothername;
}
/**
* Get Allow Edit Function Code
*
* @param string $nameSingleCode The single code name of the view.
* @param string $nameListCode The list code name of the view.
*
* @since 3.2.0
* @return string The allow edit method code
*/
public function get(string $nameSingleCode, string $nameListCode): string
{
$allow = [];
// prepare custom permission script
$customAllow = $this->dispenser->get(
'php_allowedit', $nameSingleCode, '', null, true
);
if ($this->category->exists("{$nameListCode}"))
{
// check if category has another name
$otherViews = $this->categoryothername->
get($nameListCode . '.views', $nameListCode);
$otherView = $this->categoryothername->
get($nameListCode . '.view', $nameSingleCode);
// setup the category script
$allow[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
. " get user object.";
$allow[] = Indent::_(2) . "\$user = Factory::getUser();";
$allow[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
. " get record id.";
$allow[] = Indent::_(2)
. "\$recordId = (int) isset(\$data[\$key]) ? \$data[\$key] : 0;";
// load custom permission script
$allow[] = $customAllow;
// check if the item has permissions.
if ($this->permission->globalExist($otherView, 'core.access'))
{
$allow[] = PHP_EOL . Indent::_(2) . "//" . Line::_(
__LINE__,__CLASS__
) . " Access check.";
$allow[] = Indent::_(2) . "\$access = (\$user->authorise('"
. $this->permission->getGlobal($otherView, 'core.access')
. "', 'com_" . $this->component . "." . $otherView
. ".' . (int) \$recordId) && \$user->authorise('"
. $this->permission->getGlobal($otherView, 'core.access')
. "', 'com_" . $this->component . "'));";
$allow[] = Indent::_(2) . "if (!\$access)";
$allow[] = Indent::_(2) . "{";
$allow[] = Indent::_(3) . "return false;";
$allow[] = Indent::_(2) . "}";
}
$allow[] = PHP_EOL . Indent::_(2) . "if (\$recordId)";
$allow[] = Indent::_(2) . "{";
$allow[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__)
. " The record has been set. Check the record permissions.";
// check if the item has permissions.
$allow[] = Indent::_(3) . "\$permission = \$user->authorise('"
. $this->permission->getAction($otherView, 'core.edit') . "', 'com_" . $this->component . "."
. $otherView . ".' . (int) \$recordId);";
$allow[] = Indent::_(3) . "if (!\$permission)";
$allow[] = Indent::_(3) . "{";
// check if the item has permissions.
$allow[] = Indent::_(4) . "if (\$user->authorise('"
. $this->permission->getAction($otherView, 'core.edit.own') . "', 'com_" . $this->component . "."
. $otherView . ".' . \$recordId))";
$allow[] = Indent::_(4) . "{";
$allow[] = Indent::_(5) . "//" . Line::_(__Line__, __Class__)
. " Fallback on edit.own. Now test the owner is the user.";
$allow[] = Indent::_(5)
. "\$ownerId = (int) isset(\$data['created_by']) ? \$data['created_by'] : 0;";
$allow[] = Indent::_(5) . "if (empty(\$ownerId))";
$allow[] = Indent::_(5) . "{";
$allow[] = Indent::_(6) . "//" . Line::_(__Line__, __Class__)
. " Need to do a lookup from the model.";
$allow[] = Indent::_(6)
. "\$record = \$this->getModel()->getItem(\$recordId);";
$allow[] = PHP_EOL . Indent::_(6) . "if (empty(\$record))";
$allow[] = Indent::_(6) . "{";
$allow[] = Indent::_(7) . "return false;";
$allow[] = Indent::_(6) . "}";
$allow[] = Indent::_(6) . "\$ownerId = \$record->created_by;";
$allow[] = Indent::_(5) . "}";
$allow[] = PHP_EOL . Indent::_(5) . "//" . Line::_(__Line__, __Class__)
. " If the owner matches 'me' then do the test.";
$allow[] = Indent::_(5) . "if (\$ownerId == \$user->id)";
$allow[] = Indent::_(5) . "{";
// check if the item has permissions.
$allow[] = Indent::_(6) . "if (\$user->authorise('"
. $this->permission->getGlobal($otherView, 'core.edit.own') . "', 'com_" . $this->component . "'))";
$allow[] = Indent::_(6) . "{";
$allow[] = Indent::_(7) . "return true;";
$allow[] = Indent::_(6) . "}";
$allow[] = Indent::_(5) . "}";
$allow[] = Indent::_(4) . "}";
$allow[] = Indent::_(4) . "return false;";
$allow[] = Indent::_(3) . "}";
$allow[] = Indent::_(2) . "}";
if ($this->permission->globalExist($otherView, 'core.edit'))
{
$allow[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
. " Since there is no permission, revert to the component permissions.";
$allow[] = Indent::_(2) . "return \$user->authorise('"
. $this->permission->getGlobal($otherView, 'core.edit') . "', \$this->option);";
}
else
{
$allow[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
. " Since there is no permission, revert to the component permissions.";
$allow[] = Indent::_(2)
. "return parent::allowEdit(\$data, \$key);";
}
}
else
{
// setup the category script
$allow[] = PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__, __Class__)
. " get user object.";
$allow[] = Indent::_(2) . "\$user = Factory::getUser();";
$allow[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
. " get record id.";
$allow[] = Indent::_(2)
. "\$recordId = (int) isset(\$data[\$key]) ? \$data[\$key] : 0;";
// load custom permission script
$allow[] = $customAllow;
// check if the item has permissions.
if ($this->permission->actionExist($nameSingleCode, 'core.access'))
{
$allow[] = PHP_EOL . Indent::_(2) . "//" . Line::_(
__LINE__,__CLASS__
) . " Access check.";
$allow[] = Indent::_(2) . "\$access = (\$user->authorise('"
. $this->permission->getAction($nameSingleCode, 'core.access') . "', 'com_" . $this->component . "."
. $nameSingleCode
. ".' . (int) \$recordId) && \$user->authorise('"
. $this->permission->getAction($nameSingleCode, 'core.access') . "', 'com_" . $this->component . "'));";
$allow[] = Indent::_(2) . "if (!\$access)";
$allow[] = Indent::_(2) . "{";
$allow[] = Indent::_(3) . "return false;";
$allow[] = Indent::_(2) . "}";
}
$allow[] = PHP_EOL . Indent::_(2) . "if (\$recordId)";
$allow[] = Indent::_(2) . "{";
$allow[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__)
. " The record has been set. Check the record permissions.";
// check if the item has permissions.
$allow[] = Indent::_(3) . "\$permission = \$user->authorise('"
. $this->permission->getAction($nameSingleCode, 'core.edit') . "', 'com_" . $this->component . "."
. $nameSingleCode . ".' . (int) \$recordId);";
$allow[] = Indent::_(3) . "if (!\$permission)";
$allow[] = Indent::_(3) . "{";
// check if the item has permissions.
$allow[] = Indent::_(4) . "if (\$user->authorise('"
. $this->permission->getAction($nameSingleCode, 'core.edit.own') . "', 'com_" . $this->component . "."
. $nameSingleCode . ".' . \$recordId))";
$allow[] = Indent::_(4) . "{";
$allow[] = Indent::_(5) . "//" . Line::_(__Line__, __Class__)
. " Now test the owner is the user.";
$allow[] = Indent::_(5)
. "\$ownerId = (int) isset(\$data['created_by']) ? \$data['created_by'] : 0;";
$allow[] = Indent::_(5) . "if (empty(\$ownerId))";
$allow[] = Indent::_(5) . "{";
$allow[] = Indent::_(6) . "//" . Line::_(__Line__, __Class__)
. " Need to do a lookup from the model.";
$allow[] = Indent::_(6)
. "\$record = \$this->getModel()->getItem(\$recordId);";
$allow[] = PHP_EOL . Indent::_(6) . "if (empty(\$record))";
$allow[] = Indent::_(6) . "{";
$allow[] = Indent::_(7) . "return false;";
$allow[] = Indent::_(6) . "}";
$allow[] = Indent::_(6) . "\$ownerId = \$record->created_by;";
$allow[] = Indent::_(5) . "}";
$allow[] = PHP_EOL . Indent::_(5) . "//" . Line::_(__Line__, __Class__)
. " If the owner matches 'me' then allow.";
$allow[] = Indent::_(5) . "if (\$ownerId == \$user->id)";
$allow[] = Indent::_(5) . "{";
// check if the item has permissions.
$allow[] = Indent::_(6) . "if (\$user->authorise('"
. $this->permission->getGlobal($nameSingleCode, 'core.edit.own') . "', 'com_" . $this->component . "'))";
$allow[] = Indent::_(6) . "{";
$allow[] = Indent::_(7) . "return true;";
$allow[] = Indent::_(6) . "}";
$allow[] = Indent::_(5) . "}";
$allow[] = Indent::_(4) . "}";
$allow[] = Indent::_(4) . "return false;";
$allow[] = Indent::_(3) . "}";
$allow[] = Indent::_(2) . "}";
if ($this->permission->globalExist($nameSingleCode, 'core.edit'))
{
$allow[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
. " Since there is no permission, revert to the component permissions.";
$allow[] = Indent::_(2) . "return \$user->authorise('"
. $this->permission->getGlobal($nameSingleCode, 'core.edit') . "', \$this->option);";
}
else
{
$allow[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
. " Since there is no permission, revert to the component permissions.";
$allow[] = Indent::_(2)
. "return parent::allowEdit(\$data, \$key);";
}
}
return implode(PHP_EOL, $allow);
}
}

View File

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

View File

@ -0,0 +1,91 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaThree\Model;
use VDM\Joomla\Componentbuilder\Compiler\Config;
use VDM\Joomla\Componentbuilder\Compiler\Creator\Permission;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Line;
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Architecture\Model\CanDeleteInterface;
/**
* Model Can Delete Class for Joomla 3
*
* @since 3.2.0
*/
final class CanDelete implements CanDeleteInterface
{
/**
* The Component code name.
*
* @var String
* @since 3.2.0
*/
protected String $component;
/**
* The Permission Class.
*
* @var Permission
* @since 3.2.0
*/
protected Permission $permission;
/**
* Constructor.
*
* @param Config $config The Config Class.
* @param Permission $permission The Permission Class.
*
* @since 3.2.0
*/
public function __construct(Config $config, Permission $permission)
{
$this->component = $config->component_code_name;
$this->permission = $permission;
}
/**
* Get Model Can Delete Function Code
*
* @param string $nameSingleCode The single code name of the view.
*
* @since 3.2.0
* @return string The can delete method code
*/
public function get(string $nameSingleCode): string
{
$allow = [];
// setup the default script
$allow[] = PHP_EOL . Indent::_(2) . "if (!empty(\$record->id))";
$allow[] = Indent::_(2) . "{";
$allow[] = Indent::_(3) . "if (\$record->published != -2)";
$allow[] = Indent::_(3) . "{";
$allow[] = Indent::_(4) . "return;";
$allow[] = Indent::_(3) . "}";
// check if the item has permissions.
$allow[] = PHP_EOL . Indent::_(3)
. "\$user = Factory::getUser();";
$allow[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__)
. " The record has been set. Check the record permissions.";
$allow[] = Indent::_(3) . "return \$user->authorise('"
. $this->permission->getAction($nameSingleCode, 'core.delete') . "', 'com_" . $this->component . "."
. $nameSingleCode . ".' . (int) \$record->id);";
$allow[] = Indent::_(2) . "}";
$allow[] = Indent::_(2) . "return false;";
return implode(PHP_EOL, $allow);
}
}

View File

@ -0,0 +1,108 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaThree\Model;
use VDM\Joomla\Componentbuilder\Compiler\Config;
use VDM\Joomla\Componentbuilder\Compiler\Creator\Permission;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Line;
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Architecture\Model\CanEditStateInterface;
/**
* Model Can Edit State Class for Joomla 3
*
* @since 3.2.0
*/
final class CanEditState implements CanEditStateInterface
{
/**
* The Component code name.
*
* @var String
* @since 3.2.0
*/
protected String $component;
/**
* The Permission Class.
*
* @var Permission
* @since 3.2.0
*/
protected Permission $permission;
/**
* Constructor.
*
* @param Config $config The Config Class.
* @param Permission $permission The Permission Class.
*
* @since 3.2.0
*/
public function __construct(Config $config, Permission $permission)
{
$this->component = $config->component_code_name;
$this->permission = $permission;
}
/**
* Get Can Edit State Function Code
*
* @param string $nameSingleCode The single code name of the view.
*
* @since 3.2.0
* @return string The can edit state method code
*/
public function get(string $nameSingleCode): string
{
$allow = [];
// setup the default script
$allow[] = PHP_EOL . Indent::_(2) . "\$user = Factory::getUser();";
$allow[] = Indent::_(2)
. "\$recordId = \$record->id ?? 0;";
$allow[] = PHP_EOL . Indent::_(2) . "if (\$recordId)";
$allow[] = Indent::_(2) . "{";
$allow[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__)
. " The record has been set. Check the record permissions.";
// check if the item has permissions.
$allow[] = Indent::_(3) . "\$permission = \$user->authorise('"
. $this->permission->getAction($nameSingleCode, 'core.edit.state')
. "', 'com_" . $this->component . "." . $nameSingleCode . ".' . (int) \$recordId);";
$allow[] = Indent::_(3)
. "if (!\$permission && !is_null(\$permission))";
$allow[] = Indent::_(3) . "{";
$allow[] = Indent::_(4) . "return false;";
$allow[] = Indent::_(3) . "}";
$allow[] = Indent::_(2) . "}";
if ($this->permission->globalExist($nameSingleCode, 'core.edit.state'))
{
$allow[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
. " In the absence of better information, revert to the component permissions.";
$allow[] = Indent::_(2) . "return \$user->authorise('"
. $this->permission->getGlobal($nameSingleCode, 'core.edit.state') . "', 'com_" . $this->component
. "');";
}
else
{
$allow[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
. " In the absence of better information, revert to the component permissions.";
$allow[] = Indent::_(2)
. "return parent::canEditState(\$record);";
}
return implode(PHP_EOL, $allow);
}
}

View File

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

View 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\Builder;
use VDM\Joomla\Abstraction\Registry\Traits\IsArray;
use VDM\Joomla\Interfaces\Registryinterface;
use VDM\Joomla\Abstraction\Registry;
/**
* Assets Rules Builder Class
*
* @since 3.2.0
*/
final class AssetsRules extends Registry implements Registryinterface
{
/**
* Is an Array
*
* @since 3.2.0
*/
use IsArray;
/**
* Base switch to add values as string or array
*
* @var boolean
* @since 3.2.0
**/
protected bool $addAsArray = true;
}

View File

@ -0,0 +1,34 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Compiler\Builder;
use VDM\Joomla\Interfaces\Registryinterface;
use VDM\Joomla\Abstraction\Registry;
/**
* Config Field Sets Builder Class
*
* @since 3.2.0
*/
final class ConfigFieldsets extends Registry implements Registryinterface
{
/**
* Base switch to add values as string or array
*
* @var boolean
* @since 3.2.0
**/
protected bool $addAsArray = true;
}

View File

@ -0,0 +1,34 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Compiler\Builder;
use VDM\Joomla\Abstraction\Registry\Traits\IsArray;
use VDM\Joomla\Interfaces\Registryinterface;
use VDM\Joomla\Abstraction\Registry;
/**
* Config Field Sets Custom Field Builder Class
*
* @since 3.2.0
*/
final class ConfigFieldsetsCustomfield extends Registry implements Registryinterface
{
/**
* Is an Array
*
* @since 3.2.0
*/
use IsArray;
}

View File

@ -0,0 +1,27 @@
<?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\Builder;
use VDM\Joomla\Interfaces\Registryinterface;
use VDM\Joomla\Abstraction\Registry;
/**
* Contributors Builder Class
*
* @since 3.2.0
*/
final class Contributors extends Registry implements Registryinterface
{
}

View 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\Builder;
use VDM\Joomla\Abstraction\Registry\Traits\IsArray;
use VDM\Joomla\Interfaces\Registryinterface;
use VDM\Joomla\Abstraction\Registry;
/**
* Database Uninstall Builder Class
*
* @since 3.2.0
*/
final class DatabaseUninstall extends Registry implements Registryinterface
{
/**
* Is an Array
*
* @since 3.2.0
*/
use IsArray;
/**
* Base switch to add values as string or array
*
* @var boolean
* @since 3.2.0
**/
protected bool $addAsArray = true;
}

View 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\Builder;
use VDM\Joomla\Abstraction\Registry\Traits\IsArray;
use VDM\Joomla\Interfaces\Registryinterface;
use VDM\Joomla\Abstraction\Registry;
/**
* Extensions Params Builder Class
*
* @since 3.2.0
*/
final class ExtensionsParams extends Registry implements Registryinterface
{
/**
* Is an Array
*
* @since 3.2.0
*/
use IsArray;
/**
* Base switch to add values as string or array
*
* @var boolean
* @since 3.2.0
**/
protected bool $addAsArray = true;
}

View File

@ -0,0 +1,27 @@
<?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\Builder;
use VDM\Joomla\Interfaces\Registryinterface;
use VDM\Joomla\Abstraction\Registry;
/**
* Front-end Params Builder Class
*
* @since 3.2.0
*/
final class FrontendParams extends Registry implements Registryinterface
{
}

View File

@ -0,0 +1,27 @@
<?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\Builder;
use VDM\Joomla\Interfaces\Registryinterface;
use VDM\Joomla\Abstraction\Registry;
/**
* Has Menu Global Builder Class
*
* @since 3.2.0
*/
final class HasMenuGlobal extends Registry implements Registryinterface
{
}

View File

@ -0,0 +1,34 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Compiler\Builder;
use VDM\Joomla\Abstraction\Registry\Traits\IsArray;
use VDM\Joomla\Interfaces\Registryinterface;
use VDM\Joomla\Abstraction\Registry;
/**
* Language Messages Builder Class
*
* @since 3.2.0
*/
final class LanguageMessages extends Registry implements Registryinterface
{
/**
* Is an Array
*
* @since 3.2.0
*/
use IsArray;
}

View File

@ -0,0 +1,34 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Compiler\Builder;
use VDM\Joomla\Abstraction\Registry\Traits\IsArray;
use VDM\Joomla\Interfaces\Registryinterface;
use VDM\Joomla\Abstraction\Registry;
/**
* Permission Fields Builder Class
*
* @since 3.2.0
*/
final class PermissionFields extends Registry implements Registryinterface
{
/**
* Is an Array
*
* @since 3.2.0
*/
use IsArray;
}

View 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\Builder;
use VDM\Joomla\Abstraction\Registry\Traits\IsArray;
use VDM\Joomla\Interfaces\Registryinterface;
use VDM\Joomla\Abstraction\Registry;
/**
* Permission Strict Per Field Builder Class
*
* @since 3.2.0
*/
final class Request extends Registry implements Registryinterface
{
/**
* Is an Array
*
* @since 3.2.0
*/
use IsArray;
/**
* Base switch to add values as string or array
*
* @var boolean
* @since 3.2.0
**/
protected bool $addAsArray = true;
}

View File

@ -0,0 +1,27 @@
<?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\Builder;
use VDM\Joomla\Interfaces\Registryinterface;
use VDM\Joomla\Abstraction\Registry;
/**
* Database Uninstall Builder Class
*
* @since 3.2.0
*/
final class Router extends Registry implements Registryinterface
{
}

View File

@ -0,0 +1,27 @@
<?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\Builder;
use VDM\Joomla\Interfaces\Registryinterface;
use VDM\Joomla\Abstraction\Registry;
/**
* Views Default Ordering Builder Class
*
* @since 3.2.0
*/
final class ViewsDefaultOrdering extends Registry implements Registryinterface
{
}

View File

@ -45,7 +45,7 @@ final class Component extends BaseRegistry
*
* @since 3.2.0
*/
public function __get(string $path)
public function __get($path)
{
// check if it has been set
if (($value = $this->get($path, '__N0T_S3T_Y3T_')) !== '__N0T_S3T_Y3T_')

View File

@ -34,6 +34,7 @@ use VDM\Joomla\Componentbuilder\Compiler\Model\Customadminviews;
use VDM\Joomla\Componentbuilder\Compiler\Model\Updateserver;
use VDM\Joomla\Componentbuilder\Compiler\Model\Joomlamodules;
use VDM\Joomla\Componentbuilder\Compiler\Model\Joomlaplugins;
use VDM\Joomla\Componentbuilder\Compiler\Model\Router;
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Utilities\JsonHelper;
use VDM\Joomla\Utilities\ArrayHelper;
@ -207,13 +208,20 @@ final class Data
*/
protected Joomlaplugins $plugins;
/**
* The modelling Joomla Site Router
*
* @var Router
* @since 3.2.0
*/
protected Router $router;
/**
* Database object to query local DB
*
* @var \JDatabaseDriver
* @since 3.2.0
**/
protected \JDatabaseDriver $db;
protected $db;
/**
* Constructor
@ -238,7 +246,7 @@ final class Data
* @param Updateserver|null $updateserver The modelling update server object.
* @param Joomlamodules|null $modules The modelling modules object.
* @param Joomlaplugins|null $plugins The modelling plugins object.
* @param \JDatabaseDriver|null $db The database object.
* @param Router|null $router The modelling router object.
*
* @since 3.2.0
*/
@ -249,7 +257,7 @@ final class Data
?Filesfolders $filesFolders = null, ?Historycomponent $history = null, ?Whmcs $whmcs = null,
?Sqltweaking $sqltweaking = null, ?Adminviews $adminviews = null, ?Siteviews $siteviews = null,
?Customadminviews $customadminviews = null, ?Updateserver $updateserver = null,
?Joomlamodules $modules = null, ?Joomlaplugins $plugins = null, ?\JDatabaseDriver $db = null)
?Joomlamodules $modules = null, ?Joomlaplugins $plugins = null, ?Router $router = null)
{
$this->config = $config ?: Compiler::_('Config');
$this->event = $event ?: Compiler::_('Event');
@ -271,7 +279,8 @@ final class Data
$this->updateserver = $updateserver ?: Compiler::_('Model.Updateserver');
$this->modules = $modules ?: Compiler::_('Model.Joomlamodules');
$this->plugins = $plugins ?: Compiler::_('Model.Joomlaplugins');
$this->db = $db ?: Factory::getDbo();
$this->router = $router ?: Compiler::_('Model.Router');
$this->db = Factory::getDbo();
}
/**
@ -286,27 +295,34 @@ final class Data
$query = $this->db->getQuery(true);
// selection
$selection = array(
'b.addadmin_views' => 'addadmin_views',
'b.id' => 'addadmin_views_id',
'h.addconfig' => 'addconfig',
'd.addcustom_admin_views' => 'addcustom_admin_views',
'g.addcustommenus' => 'addcustommenus',
'j.addfiles' => 'addfiles',
'j.addfolders' => 'addfolders',
'j.addfilesfullpath' => 'addfilesfullpath',
'j.addfoldersfullpath' => 'addfoldersfullpath',
'c.addsite_views' => 'addsite_views',
'l.addjoomla_plugins' => 'addjoomla_plugins',
'k.addjoomla_modules' => 'addjoomla_modules',
'i.dashboard_tab' => 'dashboard_tab',
'i.php_dashboard_methods' => 'php_dashboard_methods',
'i.params' => 'dashboard_params',
'i.id' => 'component_dashboard_id',
'f.sql_tweak' => 'sql_tweak',
'e.version_update' => 'version_update',
'e.id' => 'version_update_id'
);
$selection = [
'b.addadmin_views' => 'addadmin_views',
'b.id' => 'addadmin_views_id',
'h.addconfig' => 'addconfig',
'd.addcustom_admin_views' => 'addcustom_admin_views',
'g.addcustommenus' => 'addcustommenus',
'j.addfiles' => 'addfiles',
'j.addfolders' => 'addfolders',
'j.addfilesfullpath' => 'addfilesfullpath',
'j.addfoldersfullpath' => 'addfoldersfullpath',
'c.addsite_views' => 'addsite_views',
'l.addjoomla_plugins' => 'addjoomla_plugins',
'k.addjoomla_modules' => 'addjoomla_modules',
'i.dashboard_tab' => 'dashboard_tab',
'i.php_dashboard_methods' => 'php_dashboard_methods',
'i.params' => 'dashboard_params',
'i.id' => 'component_dashboard_id',
'f.sql_tweak' => 'sql_tweak',
'e.version_update' => 'version_update',
'e.id' => 'version_update_id',
'm.mode_constructor_before_parent' => 'router_mode_constructor_before_parent',
'm.mode_constructor_after_parent' => 'router_mode_constructor_after_parent',
'm.mode_methods' => 'router_mode_methods',
'm.constructor_before_parent_code' => 'router_constructor_before_parent_code',
'm.constructor_before_parent_manual' => 'router_constructor_before_parent_manual',
'm.constructor_after_parent_code' => 'router_constructor_after_parent_code',
'm.methods_code' => 'router_methods_code'
];
$query->select('a.*');
$query->select(
$this->db->quoteName(
@ -318,7 +334,7 @@ final class Data
$query->from('#__componentbuilder_joomla_component AS a');
// jointer-map
$joiners = array(
$joiners = [
'b' => 'component_admin_views',
'c' => 'component_site_views',
'd' => 'component_custom_admin_views',
@ -328,9 +344,10 @@ final class Data
'h' => 'component_config',
'i' => 'component_dashboard',
'j' => 'component_files_folders',
'k' => 'component_modules',
'l' => 'component_plugins',
'k' => 'component_modules'
);
'm' => 'component_router'
];
// load the joins
foreach ($joiners as $as => $join)
@ -346,15 +363,9 @@ final class Data
$this->db->quoteName('a.id') . ' = ' . (int) $this->config->component_id
);
// for plugin event TODO change event api signatures
$component_context = $this->config->component_context;
$component_id = $this->config->component_id;
// Trigger Event: jcb_ce_onBeforeQueryComponentData
$this->event->trigger(
'jcb_ce_onBeforeQueryComponentData',
array(&$component_context, &$component_id, &$query,
&$this->db)
'jcb_ce_onBeforeQueryComponentData', [&$query, &$this->db]
);
// Reset the query using our newly populated query object.
@ -371,8 +382,7 @@ final class Data
// Trigger Event: jcb_ce_onBeforeModelComponentData
$this->event->trigger(
'jcb_ce_onBeforeModelComponentData',
array(&$component_context, &$component)
'jcb_ce_onBeforeModelComponentData', [&$component]
);
// load the global placeholders
@ -390,7 +400,7 @@ final class Data
// ensure version naming is correct
$this->config->set('component_version', preg_replace(
'/[^0-9.]+/', '', (string) $component->component_version
'/^v/i', '', (string) $component->component_version
)
);
@ -863,15 +873,17 @@ final class Data
// set all plugins
$this->plugins->set($component);
// set the site router
$this->router->set($component);
// Trigger Event: jcb_ce_onAfterModelComponentData
$this->event->trigger(
'jcb_ce_onAfterModelComponentData',
array(&$component_context, &$component)
[&$component]
);
// return found component data
return $component;
}
}
}

View File

@ -0,0 +1,748 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Compiler\Component\JoomlaFive;
use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler;
use VDM\Joomla\Componentbuilder\Compiler\Config;
use VDM\Joomla\Componentbuilder\Compiler\Registry;
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\EventInterface;
use VDM\Joomla\Componentbuilder\Compiler\Placeholder;
use VDM\Joomla\Componentbuilder\Compiler\Component;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Paths;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Dynamicpath;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Pathfix;
use VDM\Joomla\Utilities\FileHelper;
use VDM\Joomla\Utilities\JsonHelper;
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Component\SettingsInterface;
/**
* Compiler Component (Joomla Version) Settings
*
* @since 3.2.0
*/
final class Settings implements SettingsInterface
{
/**
* The standard folders
*
* @var array
* @since 3.2.0
*/
protected array $standardFolders = [
'site',
'admin',
'media'
];
/**
* The standard root files
*
* @var array
* @since 3.2.0
*/
protected array $standardRootFiles = [
'access.xml',
'config.xml',
'controller.php',
'index.html',
'README.txt'
];
/**
* Compiler Joomla Version Data
*
* @var object|null
* @since 3.2.0
*/
protected ?object $data = null;
/**
* Compiler Config
*
* @var Config
* @since 3.2.0
*/
protected Config $config;
/**
* The compiler registry
*
* @var Registry
* @since 3.2.0
*/
protected Registry $registry;
/**
* Compiler Event
*
* @var EventInterface
* @since 3.2.0
*/
protected EventInterface $event;
/**
* Compiler Placeholder
*
* @var Placeholder
* @since 3.2.0
*/
protected Placeholder $placeholder;
/**
* Compiler Component
*
* @var Component
* @since 3.2.0
**/
protected Component $component;
/**
* Compiler Utilities Paths
*
* @var Paths
* @since 3.2.0
*/
protected Paths $paths;
/**
* Compiler Component Dynamic Path
*
* @var Dynamicpath
* @since 3.2.0
**/
protected Dynamicpath $dynamicpath;
/**
* Compiler Component Pathfix
*
* @var Pathfix
* @since 3.2.0
**/
protected Pathfix $pathfix;
/**
* Constructor
*
* @param Config|null $config The compiler config object.
* @param Registry|null $registry The compiler registry object.
* @param EventInterface|null $event The compiler event api object.
* @param Placeholder|null $placeholder The compiler placeholder object.
* @param Component|null $component The component class.
* @param Paths|null $paths The compiler paths object.
* @param Dynamicpath|null $dynamicpath The compiler dynamic path object.
* @param Pathfix|null $pathfix The compiler path fixing object.
*
* @since 3.2.0
*/
public function __construct(?Config $config = null, ?Registry $registry = null,
?EventInterface $event = null, ?Placeholder $placeholder = null,
?Component $component = null, ?Paths $paths = null,
?Dynamicpath $dynamicpath = null, ?Pathfix $pathfix = null)
{
$this->config = $config ?: Compiler::_('Config');
$this->registry = $registry ?: Compiler::_('Registry');
$this->event = $event ?: Compiler::_('Event');
$this->placeholder = $placeholder ?: Compiler::_('Placeholder');
$this->component = $component ?: Compiler::_('Component');
$this->paths = $paths ?: Compiler::_('Utilities.Paths');
$this->dynamicpath = $dynamicpath ?: Compiler::_('Utilities.Dynamicpath');
$this->pathfix = $pathfix ?: Compiler::_('Utilities.Pathfix');
// add component endpoint file to stander list of root files
$this->standardRootFiles[] = $this->component->get('name_code') . '.php';
}
/**
* Check if data set is loaded
*
* @return bool
* @since 3.2.0
*/
public function exists(): bool
{
if (!$this->isSet())
{
// load the data
$this->data = $this->get();
if (!$this->isSet())
{
return false;
}
}
return true;
}
/**
* Get Joomla - Folder Structure to Create
*
* @return object The version related structure
* @since 3.2.0
*/
public function structure(): object
{
return $this->data->create;
}
/**
* Get Joomla - Move Multiple Structure
*
* @return object The version related multiple structure
* @since 3.2.0
*/
public function multiple(): object
{
return $this->data->move->dynamic;
}
/**
* Get Joomla - Move Single Structure
*
* @return object The version related single structure
* @since 3.2.0
*/
public function single(): object
{
return $this->data->move->static;
}
/**
* Check if Folder is a Standard Folder
*
* @param string $folder The folder name
*
* @return bool true if the folder exists
* @since 3.2.0
*/
public function standardFolder(string $folder): bool
{
return in_array($folder, $this->standardFolders);
}
/**
* Check if File is a Standard Root File
*
* @param string $file The file name
*
* @return bool true if the file exists
* @since 3.2.0
*/
public function standardRootFile(string $file): bool
{
return in_array($file, $this->standardRootFiles);
}
/**
* Check if Data is Set
*
* @return bool
* @since 3.2.0
*/
private function isSet(): bool
{
return is_object($this->data) &&
isset($this->data->create) &&
isset($this->data->move) &&
isset($this->data->move->static) &&
isset($this->data->move->dynamic);
}
/**
* get the Joomla Version Data
*
* @return object|null The version data
* @since 3.2.0
*/
private function get(): ?object
{
// override option
$customSettings = $this->paths->template_path . '/settings_' .
$this->config->component_code_name . '.json';
// get the data
$version_data = $this->readJsonFile($customSettings);
if (is_null($version_data) || !$this->isValidData($version_data))
{
return null;
}
$this->loadExtraFolders();
$this->loadExtraFiles();
$this->addFolders($version_data);
$this->addFiles($version_data);
// Trigger Event: jcb_ce_onAfterSetJoomlaVersionData
$this->event->trigger(
'jcb_ce_onAfterSetJoomlaVersionData', [&$version_data]
);
return $version_data;
}
/**
* Read the Json file data
*
* @param string $filePath
*
* @return object|null The version data
* @since 3.2.0
*/
private function readJsonFile(string $filePath): ?object
{
if (FileHelper::exists($filePath))
{
$jsonContent = FileHelper::getContent($filePath);
}
else
{
$jsonContent = FileHelper::getContent($this->paths->template_path . '/settings.json');
}
if (JsonHelper::check($jsonContent))
{
return json_decode((string) $jsonContent);
}
return null;
}
/**
* Check if this is valid data
*
* @param object $versionData
*
* @return bool
* @since 3.2.0
*/
private function isValidData(object $versionData): bool
{
return isset($versionData->create) &&
isset($versionData->move) &&
isset($versionData->move->static) &&
isset($versionData->move->dynamic);
}
/**
* Add Extra/Dynamic folders
*
* @return void
* @since 3.2.0
*/
private function loadExtraFolders()
{
if ($this->component->isArray('folders') ||
$this->config->get('add_eximport', false) ||
$this->config->get('uikit', 0) ||
$this->config->get('footable', false))
{
$this->addImportViewFolder();
$this->addPhpSpreadsheetFolder();
$this->addUikitFolder();
$this->addFooTableFolder();
}
}
/**
* Add Import and Export Folder
*
* @return void
* @since 3.2.0
*/
private function addImportViewFolder()
{
if ($this->config->get('add_eximport', false))
{
// soon
}
}
/**
* Add Php Spreadsheet Folder
*
* @return void
* @since 3.2.0
*/
private function addPhpSpreadsheetFolder()
{
// move the phpspreadsheet Folder (TODO we must move this to a library package)
if ($this->config->get('add_eximport', false))
{
$this->component->appendArray('folders', [
'folderpath' => 'JPATH_LIBRARIES/phpspreadsheet/vendor',
'path' => '/libraries/phpspreadsheet/',
'rename' => 0
]);
}
}
/**
* Add Uikit Folders
*
* @return void
* @since 3.2.0
*/
private function addUikitFolder()
{
$uikit = $this->config->get('uikit', 0);
if (2 == $uikit || 1 == $uikit)
{
// move the UIKIT Folder into place
$this->component->appendArray('folders', [
'folder' => 'uikit-v2',
'path' => 'media',
'rename' => 0
]);
}
if (2 == $uikit || 3 == $uikit)
{
// move the UIKIT-3 Folder into place
$this->component->appendArray('folders', [
'folder' => 'uikit-v3',
'path' => 'media',
'rename' => 0
]);
}
}
/**
* Add Foo Table Folder
*
* @return void
* @since 3.2.0
*/
private function addFooTableFolder()
{
if (!$this->config->get('footable', false))
{
return;
}
$footable_version = $this->config->get('footable_version', 2);
if (2 == $footable_version)
{
// move the footable folder into place
$this->component->appendArray('folders', [
'folder' => 'footable-v2',
'path' => 'media',
'rename' => 0
]);
}
elseif (3 == $footable_version)
{
// move the footable folder into place
$this->component->appendArray('folders', [
'folder' => 'footable-v3',
'path' => 'media',
'rename' => 0
]);
}
}
/**
* Add Extra/Dynamic files
*
* @return void
* @since 3.2.0
*/
private function loadExtraFiles()
{
if ($this->component->isArray('files') ||
$this->config->get('google_chart', false))
{
$this->addGoogleChartFiles();
}
}
/**
* Add Google Chart Files
*
* @return void
* @since 3.2.0
*/
private function addGoogleChartFiles()
{
if ($this->config->get('google_chart', false))
{
// move the google chart files
$this->component->appendArray('files', [
'file' => 'google.jsapi.js',
'path' => 'media/js',
'rename' => 0
]);
$this->component->appendArray('files', [
'file' => 'chartbuilder.php',
'path' => 'admin/helpers',
'rename' => 0
]);
}
}
/**
* Add Folders
*
* @param object $versionData
*
* @return void
* @since 3.2.0
*/
private function addFolders(object &$versionData)
{
if (!$this->component->isArray('folders'))
{
return;
}
// pointer tracker
$pointer_tracker = 'h';
foreach ($this->component->get('folders') as $custom)
{
// check type of target type
$_target_type = 'c0mp0n3nt';
if (isset($custom['target_type']))
{
$_target_type = $custom['target_type'];
}
// for good practice
$this->pathfix->set(
$custom, ['path', 'folder', 'folderpath']
);
// fix custom path
if (isset($custom['path'])
&& StringHelper::check($custom['path']))
{
$custom['path'] = trim((string) $custom['path'], '/');
}
// by default custom path is true
$customPath = 'custom';
// set full path if this is a full path folder
if (!isset($custom['folder']) && isset($custom['folderpath']))
{
// update the dynamic path
$custom['folderpath'] = $this->dynamicpath->update(
$custom['folderpath']
);
// set the folder path with / if does not have a drive/windows full path
$custom['folder'] = (preg_match(
'/^[a-z]:/i', $custom['folderpath']
)) ? trim($custom['folderpath'], '/')
: '/' . trim($custom['folderpath'], '/');
// remove the file path
unset($custom['folderpath']);
// triget fullpath
$customPath = 'full';
}
// make sure we use the correct name
$pathArray = (array) explode('/', (string) $custom['path']);
$lastFolder = end($pathArray);
// only rename folder if last has folder name
if (isset($custom['rename']) && $custom['rename'] == 1)
{
$custom['path'] = str_replace(
'/' . $lastFolder, '', (string) $custom['path']
);
$rename = 'new';
$newname = $lastFolder;
}
elseif ('full' === $customPath)
{
// make sure we use the correct name
$folderArray = (array) explode('/', (string) $custom['folder']);
$lastFolder = end($folderArray);
$rename = 'new';
$newname = $lastFolder;
}
else
{
$rename = false;
$newname = '';
}
// insure we have no duplicates
$key_pointer = StringHelper::safe(
$custom['folder']
) . '_f' . $pointer_tracker;
$pointer_tracker++;
// fix custom path
$custom['path'] = ltrim((string) $custom['path'], '/');
// set new folder to object
$versionData->move->static->{$key_pointer} = new \stdClass();
$versionData->move->static->{$key_pointer}->naam = str_replace('//', '/', (string) $custom['folder']);
$versionData->move->static->{$key_pointer}->path = $_target_type . '/' . $custom['path'];
$versionData->move->static->{$key_pointer}->rename = $rename;
$versionData->move->static->{$key_pointer}->newName = $newname;
$versionData->move->static->{$key_pointer}->type = 'folder';
$versionData->move->static->{$key_pointer}->custom = $customPath;
// set the target if type and id is found
if (isset($custom['target_id']) && isset($custom['target_type']))
{
$versionData->move->static->{$key_pointer}->_target = [
'key' => $custom['target_id'] . '_' . $custom['target_type'],
'type' => $custom['target_type']
];
}
}
$this->component->remove('folders');
}
/**
* Add Files
*
* @param object $versionData
*
* @return void
* @since 3.2.0
*/
private function addFiles(object &$versionData)
{
if (!$this->component->isArray('files')) {
return;
}
// pointer tracker
$pointer_tracker = 'h';
foreach ($this->component->get('files') as $custom)
{
// check type of target type
$_target_type = 'c0mp0n3nt';
if (isset($custom['target_type']))
{
$_target_type = $custom['target_type'];
}
// for good practice
$this->pathfix->set(
$custom, ['path', 'file', 'filepath']
);
// by default custom path is true
$customPath = 'custom';
// set full path if this is a full path file
if (!isset($custom['file']) && isset($custom['filepath']))
{
// update the dynamic path
$custom['filepath'] = $this->dynamicpath->update(
$custom['filepath']
);
// set the file path with / if does not have a drive/windows full path
$custom['file'] = (preg_match('/^[a-z]:/i', $custom['filepath']))
? trim($custom['filepath'], '/') : '/' . trim($custom['filepath'], '/');
// remove the file path
unset($custom['filepath']);
// triget fullpath
$customPath = 'full';
}
// make sure we have not duplicates
$key_pointer = StringHelper::safe(
$custom['file']
) . '_g' . $pointer_tracker;
$pointer_tracker++;
// set new file to object
$versionData->move->static->{$key_pointer} = new \stdClass();
$versionData->move->static->{$key_pointer}->naam = str_replace('//', '/', (string) $custom['file']);
// update the dynamic component name placholders in file names
$custom['path'] = $this->placeholder->update_(
$custom['path']
);
// get the path info
$pathInfo = pathinfo((string) $custom['path']);
if (isset($pathInfo['extension']) && $pathInfo['extension'])
{
$pathInfo['dirname'] = trim($pathInfo['dirname'], '/');
// set the info
$versionData->move->static->{$key_pointer}->path = $_target_type . '/' . $pathInfo['dirname'];
$versionData->move->static->{$key_pointer}->rename = 'new';
$versionData->move->static->{$key_pointer}->newName = $pathInfo['basename'];
}
elseif ('full' === $customPath)
{
// fix custom path
$custom['path'] = ltrim((string) $custom['path'], '/');
// get file array
$fileArray = (array) explode('/', (string) $custom['file']);
// set the info
$versionData->move->static->{$key_pointer}->path = $_target_type . '/' . $custom['path'];
$versionData->move->static->{$key_pointer}->rename = 'new';
$versionData->move->static->{$key_pointer}->newName = end($fileArray);
}
else
{
// fix custom path
$custom['path'] = ltrim((string) $custom['path'], '/');
// set the info
$versionData->move->static->{$key_pointer}->path = $_target_type . '/' . $custom['path'];
$versionData->move->static->{$key_pointer}->rename = false;
}
$versionData->move->static->{$key_pointer}->type = 'file';
$versionData->move->static->{$key_pointer}->custom = $customPath;
// set the target if type and id is found
if (isset($custom['target_id'])
&& isset($custom['target_type']))
{
$versionData->move->static->{$key_pointer}->_target = [
'key' => $custom['target_id'] . '_' . $custom['target_type'],
'type' => $custom['target_type']
];
}
// check if file should be updated
if (!isset($custom['notnew']) || $custom['notnew'] == 0
|| $custom['notnew'] != 1)
{
$this->registry->appendArray('files.not.new', $key_pointer);
}
else
{
// update the file content
$this->registry->set('update.file.content.' . $key_pointer, true);
}
}
$this->component->remove('files');
}
}

View File

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

View File

@ -0,0 +1,748 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Compiler\Component\JoomlaFour;
use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler;
use VDM\Joomla\Componentbuilder\Compiler\Config;
use VDM\Joomla\Componentbuilder\Compiler\Registry;
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\EventInterface;
use VDM\Joomla\Componentbuilder\Compiler\Placeholder;
use VDM\Joomla\Componentbuilder\Compiler\Component;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Paths;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Dynamicpath;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Pathfix;
use VDM\Joomla\Utilities\FileHelper;
use VDM\Joomla\Utilities\JsonHelper;
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Component\SettingsInterface;
/**
* Compiler Component (Joomla Version) Settings
*
* @since 3.2.0
*/
final class Settings implements SettingsInterface
{
/**
* The standard folders
*
* @var array
* @since 3.2.0
*/
protected array $standardFolders = [
'site',
'admin',
'media'
];
/**
* The standard root files
*
* @var array
* @since 3.2.0
*/
protected array $standardRootFiles = [
'access.xml',
'config.xml',
'controller.php',
'index.html',
'README.txt'
];
/**
* Compiler Joomla Version Data
*
* @var object|null
* @since 3.2.0
*/
protected ?object $data = null;
/**
* Compiler Config
*
* @var Config
* @since 3.2.0
*/
protected Config $config;
/**
* The compiler registry
*
* @var Registry
* @since 3.2.0
*/
protected Registry $registry;
/**
* Compiler Event
*
* @var EventInterface
* @since 3.2.0
*/
protected EventInterface $event;
/**
* Compiler Placeholder
*
* @var Placeholder
* @since 3.2.0
*/
protected Placeholder $placeholder;
/**
* Compiler Component
*
* @var Component
* @since 3.2.0
**/
protected Component $component;
/**
* Compiler Utilities Paths
*
* @var Paths
* @since 3.2.0
*/
protected Paths $paths;
/**
* Compiler Component Dynamic Path
*
* @var Dynamicpath
* @since 3.2.0
**/
protected Dynamicpath $dynamicpath;
/**
* Compiler Component Pathfix
*
* @var Pathfix
* @since 3.2.0
**/
protected Pathfix $pathfix;
/**
* Constructor
*
* @param Config|null $config The compiler config object.
* @param Registry|null $registry The compiler registry object.
* @param EventInterface|null $event The compiler event api object.
* @param Placeholder|null $placeholder The compiler placeholder object.
* @param Component|null $component The component class.
* @param Paths|null $paths The compiler paths object.
* @param Dynamicpath|null $dynamicpath The compiler dynamic path object.
* @param Pathfix|null $pathfix The compiler path fixing object.
*
* @since 3.2.0
*/
public function __construct(?Config $config = null, ?Registry $registry = null,
?EventInterface $event = null, ?Placeholder $placeholder = null,
?Component $component = null, ?Paths $paths = null,
?Dynamicpath $dynamicpath = null, ?Pathfix $pathfix = null)
{
$this->config = $config ?: Compiler::_('Config');
$this->registry = $registry ?: Compiler::_('Registry');
$this->event = $event ?: Compiler::_('Event');
$this->placeholder = $placeholder ?: Compiler::_('Placeholder');
$this->component = $component ?: Compiler::_('Component');
$this->paths = $paths ?: Compiler::_('Utilities.Paths');
$this->dynamicpath = $dynamicpath ?: Compiler::_('Utilities.Dynamicpath');
$this->pathfix = $pathfix ?: Compiler::_('Utilities.Pathfix');
// add component endpoint file to stander list of root files
$this->standardRootFiles[] = $this->component->get('name_code') . '.php';
}
/**
* Check if data set is loaded
*
* @return bool
* @since 3.2.0
*/
public function exists(): bool
{
if (!$this->isSet())
{
// load the data
$this->data = $this->get();
if (!$this->isSet())
{
return false;
}
}
return true;
}
/**
* Get Joomla - Folder Structure to Create
*
* @return object The version related structure
* @since 3.2.0
*/
public function structure(): object
{
return $this->data->create;
}
/**
* Get Joomla - Move Multiple Structure
*
* @return object The version related multiple structure
* @since 3.2.0
*/
public function multiple(): object
{
return $this->data->move->dynamic;
}
/**
* Get Joomla - Move Single Structure
*
* @return object The version related single structure
* @since 3.2.0
*/
public function single(): object
{
return $this->data->move->static;
}
/**
* Check if Folder is a Standard Folder
*
* @param string $folder The folder name
*
* @return bool true if the folder exists
* @since 3.2.0
*/
public function standardFolder(string $folder): bool
{
return in_array($folder, $this->standardFolders);
}
/**
* Check if File is a Standard Root File
*
* @param string $file The file name
*
* @return bool true if the file exists
* @since 3.2.0
*/
public function standardRootFile(string $file): bool
{
return in_array($file, $this->standardRootFiles);
}
/**
* Check if Data is Set
*
* @return bool
* @since 3.2.0
*/
private function isSet(): bool
{
return is_object($this->data) &&
isset($this->data->create) &&
isset($this->data->move) &&
isset($this->data->move->static) &&
isset($this->data->move->dynamic);
}
/**
* get the Joomla Version Data
*
* @return object|null The version data
* @since 3.2.0
*/
private function get(): ?object
{
// override option
$customSettings = $this->paths->template_path . '/settings_' .
$this->config->component_code_name . '.json';
// get the data
$version_data = $this->readJsonFile($customSettings);
if (is_null($version_data) || !$this->isValidData($version_data))
{
return null;
}
$this->loadExtraFolders();
$this->loadExtraFiles();
$this->addFolders($version_data);
$this->addFiles($version_data);
// Trigger Event: jcb_ce_onAfterSetJoomlaVersionData
$this->event->trigger(
'jcb_ce_onAfterSetJoomlaVersionData', [&$version_data]
);
return $version_data;
}
/**
* Read the Json file data
*
* @param string $filePath
*
* @return object|null The version data
* @since 3.2.0
*/
private function readJsonFile(string $filePath): ?object
{
if (FileHelper::exists($filePath))
{
$jsonContent = FileHelper::getContent($filePath);
}
else
{
$jsonContent = FileHelper::getContent($this->paths->template_path . '/settings.json');
}
if (JsonHelper::check($jsonContent))
{
return json_decode((string) $jsonContent);
}
return null;
}
/**
* Check if this is valid data
*
* @param object $versionData
*
* @return bool
* @since 3.2.0
*/
private function isValidData(object $versionData): bool
{
return isset($versionData->create) &&
isset($versionData->move) &&
isset($versionData->move->static) &&
isset($versionData->move->dynamic);
}
/**
* Add Extra/Dynamic folders
*
* @return void
* @since 3.2.0
*/
private function loadExtraFolders()
{
if ($this->component->isArray('folders') ||
$this->config->get('add_eximport', false) ||
$this->config->get('uikit', 0) ||
$this->config->get('footable', false))
{
$this->addImportViewFolder();
$this->addPhpSpreadsheetFolder();
$this->addUikitFolder();
$this->addFooTableFolder();
}
}
/**
* Add Import and Export Folder
*
* @return void
* @since 3.2.0
*/
private function addImportViewFolder()
{
if ($this->config->get('add_eximport', false))
{
// soon
}
}
/**
* Add Php Spreadsheet Folder
*
* @return void
* @since 3.2.0
*/
private function addPhpSpreadsheetFolder()
{
// move the phpspreadsheet Folder (TODO we must move this to a library package)
if ($this->config->get('add_eximport', false))
{
$this->component->appendArray('folders', [
'folderpath' => 'JPATH_LIBRARIES/phpspreadsheet/vendor',
'path' => '/libraries/phpspreadsheet/',
'rename' => 0
]);
}
}
/**
* Add Uikit Folders
*
* @return void
* @since 3.2.0
*/
private function addUikitFolder()
{
$uikit = $this->config->get('uikit', 0);
if (2 == $uikit || 1 == $uikit)
{
// move the UIKIT Folder into place
$this->component->appendArray('folders', [
'folder' => 'uikit-v2',
'path' => 'media',
'rename' => 0
]);
}
if (2 == $uikit || 3 == $uikit)
{
// move the UIKIT-3 Folder into place
$this->component->appendArray('folders', [
'folder' => 'uikit-v3',
'path' => 'media',
'rename' => 0
]);
}
}
/**
* Add Foo Table Folder
*
* @return void
* @since 3.2.0
*/
private function addFooTableFolder()
{
if (!$this->config->get('footable', false))
{
return;
}
$footable_version = $this->config->get('footable_version', 2);
if (2 == $footable_version)
{
// move the footable folder into place
$this->component->appendArray('folders', [
'folder' => 'footable-v2',
'path' => 'media',
'rename' => 0
]);
}
elseif (3 == $footable_version)
{
// move the footable folder into place
$this->component->appendArray('folders', [
'folder' => 'footable-v3',
'path' => 'media',
'rename' => 0
]);
}
}
/**
* Add Extra/Dynamic files
*
* @return void
* @since 3.2.0
*/
private function loadExtraFiles()
{
if ($this->component->isArray('files') ||
$this->config->get('google_chart', false))
{
$this->addGoogleChartFiles();
}
}
/**
* Add Google Chart Files
*
* @return void
* @since 3.2.0
*/
private function addGoogleChartFiles()
{
if ($this->config->get('google_chart', false))
{
// move the google chart files
$this->component->appendArray('files', [
'file' => 'google.jsapi.js',
'path' => 'media/js',
'rename' => 0
]);
$this->component->appendArray('files', [
'file' => 'chartbuilder.php',
'path' => 'admin/helpers',
'rename' => 0
]);
}
}
/**
* Add Folders
*
* @param object $versionData
*
* @return void
* @since 3.2.0
*/
private function addFolders(object &$versionData)
{
if (!$this->component->isArray('folders'))
{
return;
}
// pointer tracker
$pointer_tracker = 'h';
foreach ($this->component->get('folders') as $custom)
{
// check type of target type
$_target_type = 'c0mp0n3nt';
if (isset($custom['target_type']))
{
$_target_type = $custom['target_type'];
}
// for good practice
$this->pathfix->set(
$custom, ['path', 'folder', 'folderpath']
);
// fix custom path
if (isset($custom['path'])
&& StringHelper::check($custom['path']))
{
$custom['path'] = trim((string) $custom['path'], '/');
}
// by default custom path is true
$customPath = 'custom';
// set full path if this is a full path folder
if (!isset($custom['folder']) && isset($custom['folderpath']))
{
// update the dynamic path
$custom['folderpath'] = $this->dynamicpath->update(
$custom['folderpath']
);
// set the folder path with / if does not have a drive/windows full path
$custom['folder'] = (preg_match(
'/^[a-z]:/i', $custom['folderpath']
)) ? trim($custom['folderpath'], '/')
: '/' . trim($custom['folderpath'], '/');
// remove the file path
unset($custom['folderpath']);
// triget fullpath
$customPath = 'full';
}
// make sure we use the correct name
$pathArray = (array) explode('/', (string) $custom['path']);
$lastFolder = end($pathArray);
// only rename folder if last has folder name
if (isset($custom['rename']) && $custom['rename'] == 1)
{
$custom['path'] = str_replace(
'/' . $lastFolder, '', (string) $custom['path']
);
$rename = 'new';
$newname = $lastFolder;
}
elseif ('full' === $customPath)
{
// make sure we use the correct name
$folderArray = (array) explode('/', (string) $custom['folder']);
$lastFolder = end($folderArray);
$rename = 'new';
$newname = $lastFolder;
}
else
{
$rename = false;
$newname = '';
}
// insure we have no duplicates
$key_pointer = StringHelper::safe(
$custom['folder']
) . '_f' . $pointer_tracker;
$pointer_tracker++;
// fix custom path
$custom['path'] = ltrim((string) $custom['path'], '/');
// set new folder to object
$versionData->move->static->{$key_pointer} = new \stdClass();
$versionData->move->static->{$key_pointer}->naam = str_replace('//', '/', (string) $custom['folder']);
$versionData->move->static->{$key_pointer}->path = $_target_type . '/' . $custom['path'];
$versionData->move->static->{$key_pointer}->rename = $rename;
$versionData->move->static->{$key_pointer}->newName = $newname;
$versionData->move->static->{$key_pointer}->type = 'folder';
$versionData->move->static->{$key_pointer}->custom = $customPath;
// set the target if type and id is found
if (isset($custom['target_id']) && isset($custom['target_type']))
{
$versionData->move->static->{$key_pointer}->_target = [
'key' => $custom['target_id'] . '_' . $custom['target_type'],
'type' => $custom['target_type']
];
}
}
$this->component->remove('folders');
}
/**
* Add Files
*
* @param object $versionData
*
* @return void
* @since 3.2.0
*/
private function addFiles(object &$versionData)
{
if (!$this->component->isArray('files')) {
return;
}
// pointer tracker
$pointer_tracker = 'h';
foreach ($this->component->get('files') as $custom)
{
// check type of target type
$_target_type = 'c0mp0n3nt';
if (isset($custom['target_type']))
{
$_target_type = $custom['target_type'];
}
// for good practice
$this->pathfix->set(
$custom, ['path', 'file', 'filepath']
);
// by default custom path is true
$customPath = 'custom';
// set full path if this is a full path file
if (!isset($custom['file']) && isset($custom['filepath']))
{
// update the dynamic path
$custom['filepath'] = $this->dynamicpath->update(
$custom['filepath']
);
// set the file path with / if does not have a drive/windows full path
$custom['file'] = (preg_match('/^[a-z]:/i', $custom['filepath']))
? trim($custom['filepath'], '/') : '/' . trim($custom['filepath'], '/');
// remove the file path
unset($custom['filepath']);
// triget fullpath
$customPath = 'full';
}
// make sure we have not duplicates
$key_pointer = StringHelper::safe(
$custom['file']
) . '_g' . $pointer_tracker;
$pointer_tracker++;
// set new file to object
$versionData->move->static->{$key_pointer} = new \stdClass();
$versionData->move->static->{$key_pointer}->naam = str_replace('//', '/', (string) $custom['file']);
// update the dynamic component name placholders in file names
$custom['path'] = $this->placeholder->update_(
$custom['path']
);
// get the path info
$pathInfo = pathinfo((string) $custom['path']);
if (isset($pathInfo['extension']) && $pathInfo['extension'])
{
$pathInfo['dirname'] = trim($pathInfo['dirname'], '/');
// set the info
$versionData->move->static->{$key_pointer}->path = $_target_type . '/' . $pathInfo['dirname'];
$versionData->move->static->{$key_pointer}->rename = 'new';
$versionData->move->static->{$key_pointer}->newName = $pathInfo['basename'];
}
elseif ('full' === $customPath)
{
// fix custom path
$custom['path'] = ltrim((string) $custom['path'], '/');
// get file array
$fileArray = (array) explode('/', (string) $custom['file']);
// set the info
$versionData->move->static->{$key_pointer}->path = $_target_type . '/' . $custom['path'];
$versionData->move->static->{$key_pointer}->rename = 'new';
$versionData->move->static->{$key_pointer}->newName = end($fileArray);
}
else
{
// fix custom path
$custom['path'] = ltrim((string) $custom['path'], '/');
// set the info
$versionData->move->static->{$key_pointer}->path = $_target_type . '/' . $custom['path'];
$versionData->move->static->{$key_pointer}->rename = false;
}
$versionData->move->static->{$key_pointer}->type = 'file';
$versionData->move->static->{$key_pointer}->custom = $customPath;
// set the target if type and id is found
if (isset($custom['target_id'])
&& isset($custom['target_type']))
{
$versionData->move->static->{$key_pointer}->_target = [
'key' => $custom['target_id'] . '_' . $custom['target_type'],
'type' => $custom['target_type']
];
}
// check if file should be updated
if (!isset($custom['notnew']) || $custom['notnew'] == 0
|| $custom['notnew'] != 1)
{
$this->registry->appendArray('files.not.new', $key_pointer);
}
else
{
// update the file content
$this->registry->set('update.file.content.' . $key_pointer, true);
}
}
$this->component->remove('files');
}
}

View File

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

View File

@ -9,7 +9,7 @@
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Compiler\Component;
namespace VDM\Joomla\Componentbuilder\Compiler\Component\JoomlaThree;
use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler;
@ -24,6 +24,7 @@ use VDM\Joomla\Componentbuilder\Compiler\Utilities\Pathfix;
use VDM\Joomla\Utilities\FileHelper;
use VDM\Joomla\Utilities\JsonHelper;
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Component\SettingsInterface;
/**
@ -31,7 +32,7 @@ use VDM\Joomla\Utilities\StringHelper;
*
* @since 3.2.0
*/
final class Settings
final class Settings implements SettingsInterface
{
/**
* The standard folders
@ -285,13 +286,9 @@ final class Settings
$this->addFolders($version_data);
$this->addFiles($version_data);
// for plugin event TODO change event api signatures
$component_context = $this->config->component_context;
// Trigger Event: jcb_ce_onAfterSetJoomlaVersionData
$this->event->trigger(
'jcb_ce_onAfterSetJoomlaVersionData',
array(&$component_context, &$version_data)
'jcb_ce_onAfterSetJoomlaVersionData', [&$version_data]
);
return $version_data;
@ -750,7 +747,6 @@ final class Settings
}
$this->component->remove('files');
}
}
}

View File

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

View File

@ -49,7 +49,6 @@ final class Placeholder implements PlaceholderInterface
/**
* Database object to query local DB
*
* @var \JDatabaseDriver
* @since 3.2.0
**/
protected $db;
@ -62,10 +61,10 @@ final class Placeholder implements PlaceholderInterface
*
* @since 3.2.0
**/
public function __construct(?Config $config = null, ?\JDatabaseDriver $db = null)
public function __construct(?Config $config = null)
{
$this->config = $config ?: Compiler::_('Config');
$this->db = $db ?: Factory::getDbo();
$this->db = Factory::getDbo();
}
/**
@ -131,7 +130,7 @@ final class Placeholder implements PlaceholderInterface
{
foreach ($_placeholders as $row)
{
$bucket[$row['target']] = $row['value'];
$bucket[$row['target']] = str_replace(array_keys($bucket), array_values($bucket), $row['value']);
}
}
}

View File

@ -13,7 +13,7 @@ namespace VDM\Joomla\Componentbuilder\Compiler\Component;
use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler;
use VDM\Joomla\Componentbuilder\Compiler\Component\Settings;
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Component\SettingsInterface as Settings;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Paths;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Folder;
use VDM\Joomla\Utilities\ObjectHelper;

View File

@ -15,7 +15,7 @@ namespace VDM\Joomla\Componentbuilder\Compiler\Component;
use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler;
use VDM\Joomla\Componentbuilder\Compiler\Config;
use VDM\Joomla\Componentbuilder\Compiler\Registry;
use VDM\Joomla\Componentbuilder\Compiler\Component\Settings;
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Component\SettingsInterface as Settings;
use VDM\Joomla\Componentbuilder\Compiler\Component;
use VDM\Joomla\Componentbuilder\Compiler\Model\Createdate;
use VDM\Joomla\Componentbuilder\Compiler\Model\Modifieddate;

View File

@ -19,7 +19,8 @@ use Joomla\CMS\Filesystem\Folder;
use Joomla\CMS\Filesystem\File;
use VDM\Joomla\Componentbuilder\Compiler\Config;
use VDM\Joomla\Componentbuilder\Compiler\Registry;
use VDM\Joomla\Componentbuilder\Compiler\Component\Settings;
use VDM\Joomla\Componentbuilder\Compiler\Placeholder;
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Component\SettingsInterface as Settings;
use VDM\Joomla\Componentbuilder\Compiler\Component;
use VDM\Joomla\Componentbuilder\Compiler\Builder\ContentOne as Content;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Counter;
@ -85,7 +86,15 @@ final class Structuresingle
protected Registry $registry;
/**
* The Settings Class.
* The Placeholder Class.
*
* @var Placeholder
* @since 3.2.0
*/
protected Placeholder $placeholder;
/**
* The SettingsInterface Class.
*
* @var Settings
* @since 3.2.0
@ -143,24 +152,27 @@ final class Structuresingle
/**
* Constructor.
*
* @param Config $config The Config Class.
* @param Registry $registry The Registry Class.
* @param Settings $settings The Settings Class.
* @param Component $component The Component Class.
* @param Content $content The ContentOne Class.
* @param Counter $counter The Counter Class.
* @param Paths $paths The Paths Class.
* @param Files $files The Files Class.
* @param CMSApplication|null $app The CMS Application object.
* @param Config $config The Config Class.
* @param Registry $registry The Registry Class.
* @param Placeholder $placeholder The Placeholder Class.
* @param Settings $settings The SettingsInterface Class.
* @param Component $component The Component Class.
* @param Content $content The ContentOne Class.
* @param Counter $counter The Counter Class.
* @param Paths $paths The Paths Class.
* @param Files $files The Files Class.
* @param CMSApplication|null $app The CMS Application object.
*
* @since 3.2.0
*/
public function __construct(Config $config, Registry $registry, Settings $settings,
public function __construct(Config $config, Registry $registry,
Placeholder $placeholder, Settings $settings,
Component $component, Content $content, Counter $counter,
Paths $paths, Files $files, ?CMSApplication $app = null)
{
$this->config = $config;
$this->registry = $registry;
$this->placeholder = $placeholder;
$this->settings = $settings;
$this->component = $component;
$this->content = $content;
@ -299,21 +311,24 @@ final class Structuresingle
{
if ($details->rename === 'new')
{
$this->newName = $details->newName;
$newName = $details->newName;
}
else
{
$this->newName = str_replace(
$naam = $details->naam ?? 'error';
$newName = str_replace(
$details->rename,
$this->config->component_code_name,
(string) $details->naam
(string) $naam
);
}
}
else
{
$this->newName = $details->naam;
$newName = $details->naam ?? 'error';
}
$this->newName = $this->placeholder->update_($newName);
}
/**
@ -605,13 +620,24 @@ final class Structuresingle
// add the setDynamicF0ld3rs() method to the install scipt.php file
$this->registry->set('set_move_folders_install_script', true);
$function = 'setDynamicF0ld3rs';
$script = 'script.php';
if ($this->config->get('joomla_version', 3) != 3)
{
$function = 'moveFolders';
$script = 'ComponentnameInstallerScript.php';
}
// set message that this was done (will still add a tutorial link later)
$this->app->enqueueMessage(
Text::_('COM_COMPONENTBUILDER_HR_HTHREEDYNAMIC_FOLDERS_WERE_DETECTEDHTHREE'),
'Notice'
);
$this->app->enqueueMessage(
Text::sprintf('COM_COMPONENTBUILDER_A_METHOD_SETDYNAMICFZEROLDTHREERS_WAS_ADDED_TO_THE_INSTALL_BSCRIPTPHPB_OF_THIS_PACKAGE_TO_INSURE_THAT_THE_FOLDERS_ARE_COPIED_INTO_THE_CORRECT_PLACE_WHEN_THIS_COMPONENT_IS_INSTALLED'),
Text::sprintf('COM_COMPONENTBUILDER_A_METHOD_S_WAS_ADDED_TO_THE_INSTALL_BSB_OF_THIS_PACKAGE_TO_INSURE_THAT_THE_FOLDERS_ARE_COPIED_INTO_THE_CORRECT_PLACE_WHEN_THIS_COMPONENT_IS_INSTALLED',
$function, $script
),
'Notice'
);
}

View File

@ -293,6 +293,42 @@ class Config extends BaseConfig
return strlen((string) $this->component_code_name);
}
/**
* get add namespace prefix
*
* @return bool The add namespace prefix switch
* @since 3.2.0
*/
protected function getAddnamespaceprefix(): bool
{
// get components override switch
$value = GetHelper::var(
'joomla_component', $this->component_id, 'id', 'add_namespace_prefix'
);
return $value == 1 ? true : false;
}
/**
* get namespace prefix
*
* @return string The namespace prefix
* @since 3.2.0
*/
protected function getNamespaceprefix(): string
{
// load based on component settings
$prefix = null;
if ($this->add_namespace_prefix)
{
$prefix = GetHelper::var(
'joomla_component', $this->component_id, 'id', 'namespace_prefix'
);
}
return $prefix ?? $this->params->get('namespace_prefix', 'JCB');
}
/**
* get posted Joomla version
*
@ -301,7 +337,7 @@ class Config extends BaseConfig
*/
protected function getJoomlaversion(): int
{
return 3; // $this->input->post->get('joomla_version', 3, 'INT');
return $this->input->post->get('joomla_version', 3, 'INT');
}
/**
@ -313,8 +349,9 @@ class Config extends BaseConfig
protected function getJoomlaversions(): array
{
return [
3 => ['folder_key' => 3, 'xml_version' => 3.9], // only joomla 3
3.10 => ['folder_key' => 3, 'xml_version' => 4.0] // legacy joomla 4
3 => ['folder_key' => 3, 'xml_version' => '3.10'],
4 => ['folder_key' => 4, 'xml_version' => '4.0'],
5 => ['folder_key' => 4, 'xml_version' => '5.0'] // for now we build 4 and 5 from same templates ;)
];
}
@ -524,6 +561,18 @@ class Config extends BaseConfig
return true;
}
/**
* get percentage when a language should be added
*
* @return int The percentage value
* @since 3.2.0
*/
protected function getPercentagelanguageadd(): int
{
// get the global language
return $this->params->get('percentagelanguageadd', 50);
}
/**
* get language tag
*
@ -586,7 +635,7 @@ class Config extends BaseConfig
// these strings are used to search for language strings in all content
return [
'jjt' => 'Joomla' . '.JText._(',
'js' => 'JText:' . ':script(',
'js' => 'Text:' . ':script(',
't' => 'Text:' . ':_(', // namespace and J version will be found
'ts' => 'Text:' . ':sprintf(', // namespace and J version will be found
'jt' => 'JustTEXT:' . ':_('
@ -659,6 +708,18 @@ class Config extends BaseConfig
return $this->params->get('jcb_powers_path', 'libraries/jcb_powers');
}
/**
* get jcb powers path
*
* @return string The jcb powers path
* @since 3.2.0
*/
protected function getPowerlibraryfolder(): string
{
// get power library folder path
return trim(str_replace('libraries/', '', $this->jcb_powers_path), '/');
}
/**
* Get local super powers repository path
*
@ -1005,6 +1066,28 @@ class Config extends BaseConfig
protected function getFootableversion(): int
{
return 2; // default is version 2
}
/**
* The Permission Strict Per Field Switch
*
* @return bool Switch to control the Strict Permission Per/Field
* @since 3.2.0
*/
protected function getPermissionstrictperfield(): bool
{
return false;
}
/**
* The Export Text Only Switch
*
* @return int Switch to control the export text only
* @since 3.2.0
*/
protected function getExporttextonly(): int
{
return 0;
}
}

View File

@ -0,0 +1,709 @@
<?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\Creator;
use VDM\Joomla\Componentbuilder\Compiler\Config;
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\EventInterface as Event;
use VDM\Joomla\Componentbuilder\Compiler\Language;
use VDM\Joomla\Componentbuilder\Compiler\Component;
use VDM\Joomla\Componentbuilder\Compiler\Field\Name as FieldName;
use VDM\Joomla\Componentbuilder\Compiler\Field\TypeName;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Counter;
use VDM\Joomla\Componentbuilder\Compiler\Creator\Permission;
use VDM\Joomla\Componentbuilder\Compiler\Builder\AssetsRules;
use VDM\Joomla\Componentbuilder\Compiler\Builder\CustomTabs;
use VDM\Joomla\Componentbuilder\Compiler\Builder\PermissionViews;
use VDM\Joomla\Componentbuilder\Compiler\Builder\PermissionFields;
use VDM\Joomla\Componentbuilder\Compiler\Builder\PermissionComponent;
use VDM\Joomla\Componentbuilder\Compiler\Creator\CustomButtonPermissions;
use VDM\Joomla\Utilities\MathHelper;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Utilities\StringHelper;
/**
* Access Sections Creator Class
*
* @since 3.2.0
*/
final class AccessSections
{
/**
* The Config Class.
*
* @var Config
* @since 3.2.0
*/
protected Config $config;
/**
* The EventInterface Class.
*
* @var Event
* @since 3.2.0
*/
protected Event $event;
/**
* The Language Class.
*
* @var Language
* @since 3.2.0
*/
protected Language $language;
/**
* The Component Class.
*
* @var Component
* @since 3.2.0
*/
protected Component $component;
/**
* The Name Class.
*
* @var FieldName
* @since 3.2.0
*/
protected FieldName $fieldname;
/**
* The TypeName Class.
*
* @var TypeName
* @since 3.2.0
*/
protected TypeName $typename;
/**
* The Counter Class.
*
* @var Counter
* @since 3.2.0
*/
protected Counter $counter;
/**
* The Permission Class.
*
* @var Permission
* @since 3.2.0
*/
protected Permission $permission;
/**
* The AssetsRules Class.
*
* @var AssetsRules
* @since 3.2.0
*/
protected AssetsRules $assetsrules;
/**
* The CustomTabs Class.
*
* @var CustomTabs
* @since 3.2.0
*/
protected CustomTabs $customtabs;
/**
* The PermissionViews Class.
*
* @var PermissionViews
* @since 3.2.0
*/
protected PermissionViews $permissionviews;
/**
* The PermissionFields Class.
*
* @var PermissionFields
* @since 3.2.0
*/
protected PermissionFields $permissionfields;
/**
* The PermissionComponent Class.
*
* @var PermissionComponent
* @since 3.2.0
*/
protected PermissionComponent $permissioncomponent;
/**
* The CustomButtonPermissions Class.
*
* @var CustomButtonPermissions
* @since 3.2.0
*/
protected CustomButtonPermissions $custombuttonpermissions;
/**
* Constructor.
*
* @param Config $config The Config Class.
* @param Event $event The EventInterface Class.
* @param Language $language The Language Class.
* @param Component $component The Component Class.
* @param FieldName $fieldname The Name Class.
* @param TypeName $typename The TypeName Class.
* @param Counter $counter The Counter Class.
* @param Permission $permission The Permission Class.
* @param AssetsRules $assetsrules The AssetsRules Class.
* @param CustomTabs $customtabs The CustomTabs Class.
* @param PermissionViews $permissionviews The PermissionViews Class.
* @param PermissionFields $permissionfields The PermissionFields Class.
* @param PermissionComponent $permissioncomponent The PermissionComponent Class.
* @param CustomButtonPermissions $custombuttonpermissions The CustomButtonPermissions Class.
*
* @since 3.2.0
*/
public function __construct(Config $config, Event $event, Language $language,
Component $component, FieldName $fieldname,
TypeName $typename, Counter $counter,
Permission $permission, AssetsRules $assetsrules,
CustomTabs $customtabs, PermissionViews $permissionviews,
PermissionFields $permissionfields,
PermissionComponent $permissioncomponent,
CustomButtonPermissions $custombuttonpermissions)
{
$this->config = $config;
$this->event = $event;
$this->language = $language;
$this->component = $component;
$this->fieldname = $fieldname;
$this->typename = $typename;
$this->counter = $counter;
$this->permission = $permission;
$this->assetsrules = $assetsrules;
$this->customtabs = $customtabs;
$this->permissionviews = $permissionviews;
$this->permissionfields = $permissionfields;
$this->permissioncomponent = $permissioncomponent;
$this->custombuttonpermissions = $custombuttonpermissions;
}
/**
* Get Access Sections
*
* @return string
* @since 3.2.0
*/
public function get(): string
{
// access size counter
$this->counter->accessSize = 12; // ;)
// Trigger Event: jcb_ce_onBeforeBuildAccessSections
$this->event->trigger(
'jcb_ce_onBeforeBuildAccessSections'
);
// Get the default fields
$default_fields = $this->config->default_fields;
$this->permissioncomponent->add('->HEAD<-', [
'name' => 'core.admin',
'title' => 'JACTION_ADMIN',
'description' => 'JACTION_ADMIN_COMPONENT_DESC'
], true);
$this->permissioncomponent->add('->HEAD<-', [
'name' => 'core.options',
'title' => 'JACTION_OPTIONS',
'description' => 'JACTION_OPTIONS_COMPONENT_DESC'
], true);
$this->permissioncomponent->add('->HEAD<-', [
'name' => 'core.manage',
'title' => 'JACTION_MANAGE',
'description' => 'JACTION_MANAGE_COMPONENT_DESC'
], true);
if ($this->config->get('add_eximport', false))
{
$exportTitle = $this->config->lang_prefix . '_'
. StringHelper::safe('Export Data', 'U');
$exportDesc = $this->config->lang_prefix . '_'
. StringHelper::safe('Export Data', 'U')
. '_DESC';
$this->language->set('bothadmin', $exportTitle, 'Export Data');
$this->language->set(
'bothadmin', $exportDesc,
' Allows users in this group to export data.'
);
$this->permissioncomponent->add('->HEAD<-', [
'name' => 'core.export',
'title' => $exportTitle,
'description' => $exportDesc
], true);
// the size needs increase
$this->counter->accessSize++;
$importTitle = $this->config->lang_prefix . '_'
. StringHelper::safe('Import Data', 'U');
$importDesc = $this->config->lang_prefix . '_'
. StringHelper::safe('Import Data', 'U')
. '_DESC';
$this->language->set('bothadmin', $importTitle, 'Import Data');
$this->language->set(
'bothadmin', $importDesc,
' Allows users in this group to import data.'
);
$this->permissioncomponent->add('->HEAD<-', [
'name' => 'core.import',
'title' => $importTitle,
'description' => $importDesc
], true);
// the size needs increase
$this->counter->accessSize++;
}
// version permission
$batchTitle = $this->config->lang_prefix . '_'
. StringHelper::safe('Use Batch', 'U');
$batchDesc = $this->config->lang_prefix . '_'
. StringHelper::safe('Use Batch', 'U') . '_DESC';
$this->language->set('bothadmin', $batchTitle, 'Use Batch');
$this->language->set(
'bothadmin', $batchDesc,
' Allows users in this group to use batch copy/update method.'
);
$this->permissioncomponent->add('->HEAD<-', [
'name' => 'core.batch',
'title' => $batchTitle,
'description' => $batchDesc
], true);
// version permission
$importTitle = $this->config->lang_prefix . '_'
. StringHelper::safe('Edit Versions', 'U');
$importDesc = $this->config->lang_prefix . '_'
. StringHelper::safe('Edit Versions', 'U')
. '_DESC';
$this->language->set('bothadmin', $importTitle, 'Edit Version');
$this->language->set(
'bothadmin', $importDesc,
' Allows users in this group to edit versions.'
);
$this->permissioncomponent->add('->HEAD<-', [
'name' => 'core.version',
'title' => $importTitle,
'description' => $importDesc
], true);
// set the defaults
$this->permissioncomponent->add('->HEAD<-', [
'name' => 'core.create',
'title' => 'JACTION_CREATE',
'description' => 'JACTION_CREATE_COMPONENT_DESC'
], true);
$this->permissioncomponent->add('->HEAD<-', [
'name' => 'core.delete',
'title' => 'JACTION_DELETE',
'description' => 'JACTION_DELETE_COMPONENT_DESC'
], true);
$this->permissioncomponent->add('->HEAD<-', [
'name' => 'core.edit',
'title' => 'JACTION_EDIT',
'description' => 'JACTION_EDIT_COMPONENT_DESC'
], true);
$this->permissioncomponent->add('->HEAD<-', [
'name' => 'core.edit.state',
'title' => 'JACTION_EDITSTATE',
'description' => 'JACTION_ACCESS_EDITSTATE_DESC'
], true);
$this->permissioncomponent->add('->HEAD<-', [
'name' => 'core.edit.own',
'title' => 'JACTION_EDITOWN',
'description' => 'JACTION_EDITOWN_COMPONENT_DESC'
], true);
// set the Joomla fields
if ($this->config->get('set_joomla_fields', false))
{
$this->permissioncomponent->add('->HEAD<-', [
'name' => 'core.edit.value',
'title' => 'JACTION_EDITVALUE',
'description' => 'JACTION_EDITVALUE_COMPONENT_DESC'
], true);
// the size needs increase
$this->counter->accessSize++;
}
// new custom created by permissions
$created_byTitle = $this->config->lang_prefix . '_'
. StringHelper::safe('Edit Created By', 'U');
$created_byDesc = $this->config->lang_prefix . '_'
. StringHelper::safe('Edit Created By', 'U')
. '_DESC';
$this->language->set('bothadmin', $created_byTitle, 'Edit Created By');
$this->language->set(
'bothadmin', $created_byDesc,
' Allows users in this group to edit created by.'
);
$this->permissioncomponent->add('->HEAD<-', [
'name' => 'core.edit.created_by',
'title' => $created_byTitle,
'description' => $created_byDesc
], true);
// new custom created date permissions
$createdTitle = $this->config->lang_prefix . '_'
. StringHelper::safe('Edit Created Date', 'U');
$createdDesc = $this->config->lang_prefix . '_'
. StringHelper::safe('Edit Created Date', 'U')
. '_DESC';
$this->language->set('bothadmin', $createdTitle, 'Edit Created Date');
$this->language->set(
'bothadmin', $createdDesc,
' Allows users in this group to edit created date.'
);
$this->permissioncomponent->add('->HEAD<-', [
'name' => 'core.edit.created',
'title' => $createdTitle,
'description' => $createdDesc
], true);
// set the menu controller lookup
$menuControllers = ['access', 'submenu', 'dashboard_list', 'dashboard_add'];
// set the custom admin views permissions
if ($this->component->isArray('custom_admin_views'))
{
foreach ($this->component->get('custom_admin_views') as $custom_admin_view)
{
// new custom permissions to access this view
$customAdminName = $custom_admin_view['settings']->name;
$customAdminCode = $custom_admin_view['settings']->code;
$customAdminTitle = $this->config->lang_prefix . '_'
. StringHelper::safe(
$customAdminName . ' Access', 'U'
);
$customAdminDesc = $this->config->lang_prefix . '_'
. StringHelper::safe(
$customAdminName . ' Access', 'U'
) . '_DESC';
$sortKey = StringHelper::safe(
$customAdminName . ' Access'
);
$this->language->set(
'bothadmin', $customAdminTitle, $customAdminName . ' Access'
);
$this->language->set(
'bothadmin', $customAdminDesc,
' Allows the users in this group to access '
. StringHelper::safe($customAdminName, 'w')
. '.'
);
$this->permissioncomponent->set($sortKey, [
'name' => "$customAdminCode.access",
'title' => $customAdminTitle,
'description' => $customAdminDesc
]);
// the size needs increase
$this->counter->accessSize++;
// add the custom permissions to use the buttons of this view
$this->custombuttonpermissions->add(
$custom_admin_view['settings'], $customAdminName,
$customAdminCode
);
// add menu controll view that has menus options
foreach ($menuControllers as $menuController)
{
// add menu controll view that has menus options
if (isset($custom_admin_view[$menuController])
&& $custom_admin_view[$menuController])
{
$targetView_ = 'views.';
if ($menuController === 'dashboard_add')
{
$targetView_ = 'view.';
}
// menucontroller
$menucontrollerView['action'] = $targetView_
. $menuController;
$menucontrollerView['implementation'] = '2';
if (isset($custom_admin_view['settings']->permissions)
&& ArrayHelper::check(
$custom_admin_view['settings']->permissions
))
{
array_push(
$custom_admin_view['settings']->permissions,
$menucontrollerView
);
}
else
{
$custom_admin_view['settings']->permissions
= [];
$custom_admin_view['settings']->permissions[]
= $menucontrollerView;
}
unset($menucontrollerView);
}
}
$this->permission ->set(
$custom_admin_view, $customAdminCode, $customAdminCode,
$menuControllers, 'customAdmin'
);
}
}
// set the site views permissions
if ($this->component->isArray('site_views'))
{
foreach ($this->component->get('site_views') as $site_view)
{
// new custom permissions to access this view
$siteName = $site_view['settings']->name;
$siteCode = $site_view['settings']->code;
$siteTitle = $this->config->lang_prefix . '_'
. StringHelper::safe(
$siteName . ' Access Site', 'U'
);
$siteDesc = $this->config->lang_prefix . '_'
. StringHelper::safe(
$siteName . ' Access Site', 'U'
) . '_DESC';
$sortKey = StringHelper::safe(
$siteName . ' Access Site'
);
if (isset($site_view['access']) && $site_view['access'] == 1)
{
$this->language->set(
'bothadmin', $siteTitle, $siteName . ' (Site) Access'
);
$this->language->set(
'bothadmin', $siteDesc,
' Allows the users in this group to access site '
. StringHelper::safe($siteName, 'w')
. '.'
);
$this->permissioncomponent->set($sortKey, [
'name' => "site.$siteCode.access",
'title' => $siteTitle,
'description' => $siteDesc
]);
// the size needs increase
$this->counter->accessSize++;
// check if this site view requires access rule to default to public
if (isset($site_view['public_access'])
&& $site_view['public_access'] == 1)
{
// we use one as public group (TODO we see if we run into any issues)
$this->assetsrules->add('site', '"site.' . $siteCode
. '.access":{"1":1}');
}
}
// add the custom permissions to use the buttons of this view
$this->custombuttonpermissions->add(
$site_view['settings'], $siteName, $siteCode
);
}
}
if ($this->component->isArray('admin_views'))
{
foreach ($this->component->get('admin_views') as $view)
{
// set view name
$nameView = StringHelper::safe(
$view['settings']->name_single
);
$nameViews = StringHelper::safe(
$view['settings']->name_list
);
// add custom tab permissions if found
if (($tabs_ = $this->customtabs->get($nameView)) !== null
&& ArrayHelper::check($tabs_))
{
foreach ($tabs_ as $_customTab)
{
if (isset($_customTab['permission'])
&& $_customTab['permission'] == 1)
{
$this->permissioncomponent->set($_customTab['sortKey'], [
'name' => $_customTab['view'] . '.' . $_customTab['code'] . '.viewtab',
'title' => $_customTab['lang_permission'],
'description' => $_customTab['lang_permission_desc']
]);
// the size needs increase
$this->counter->accessSize++;
}
}
}
// add the custom permissions to use the buttons of this view
$this->custombuttonpermissions->add(
$view['settings'], $view['settings']->name_single, $nameView
);
if ($nameView != 'component')
{
// add menu controll view that has menus options
foreach ($menuControllers as $menuController)
{
// add menu controll view that has menus options
if (isset($view[$menuController])
&& $view[$menuController])
{
$targetView_ = 'views.';
if ($menuController === 'dashboard_add')
{
$targetView_ = 'view.';
}
// menucontroller
$menucontrollerView['action'] = $targetView_ . $menuController;
$menucontrollerView['implementation'] = '2';
if (isset($view['settings']->permissions)
&& ArrayHelper::check(
$view['settings']->permissions
))
{
array_push(
$view['settings']->permissions,
$menucontrollerView
);
}
else
{
$view['settings']->permissions = [];
$view['settings']->permissions[] = $menucontrollerView;
}
unset($menucontrollerView);
}
}
// check if there are fields
if (ArrayHelper::check($view['settings']->fields))
{
// field permission options
$permission_options = [1 => 'edit', 2 => 'access', 3 => 'view'];
// check the fields for their permission settings
foreach ($view['settings']->fields as $field)
{
// see if field require permissions to be set
if (isset($field['permission'])
&& ArrayHelper::check(
$field['permission']
))
{
if (ArrayHelper::check(
$field['settings']->properties
))
{
$fieldType = $this->typename->get($field);
$fieldName = $this->fieldname->get(
$field, $nameViews
);
// loop the permission options
foreach ($field['permission'] as $permission_id)
{
// set the permission key word
$permission_option = $permission_options[(int) $permission_id];
// reset the bucket
$fieldView = [];
// set the permission for this field
$fieldView['action'] = 'view.' . $permission_option . '.' . $fieldName;
$fieldView['implementation'] = '3';
// check if persmissions was already set
if (isset($view['settings']->permissions)
&& ArrayHelper::check(
$view['settings']->permissions
))
{
array_push($view['settings']->permissions, $fieldView);
}
else
{
$view['settings']->permissions = [];
$view['settings']->permissions[] = $fieldView;
}
// ensure that no default field get loaded
if (!in_array($fieldName, $default_fields))
{
// load to global field permission set
$this->permissionfields->
set("$nameView.$fieldName.$permission_option", $fieldType);
}
}
}
}
}
}
$this->permission ->set(
$view, $nameView, $nameViews, $menuControllers
);
}
}
// Trigger Event: jcb_ce_onAfterBuildAccessSections
$this->event->trigger(
'jcb_ce_onAfterBuildAccessSections'
);
/// now build the section
$component = $this->permissioncomponent->build();
// add views to the component section
$component .= $this->permissionviews->build();
// remove the fix, is not needed
if ($this->counter->accessSize < 30)
{
// since we have less than 30 actions
// we do not need the fix for this component
$this->config->set('add_assets_table_fix', 0);
}
else
{
// get the worst case column size required (can be worse I know)
// access/action size x 20 characters x 8 groups
$character_length = (int) MathHelper::bc(
'mul', $this->counter->accessSize, 20, 0
);
// set worse case
$this->config->set('access_worse_case', (int) MathHelper::bc(
'mul', $character_length, 8, 0
));
}
// return the build
return $component;
}
return false;
}
}

View File

@ -0,0 +1,80 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Compiler\Creator;
use VDM\Joomla\Componentbuilder\Compiler\Builder\CategoryCode;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent;
/**
* Access Sections Category Creator Class
*
* @since 3.2.0
*/
final class AccessSectionsCategory
{
/**
* The CategoryCode Class.
*
* @var CategoryCode
* @since 3.2.0
*/
protected CategoryCode $categorycode;
/**
* Constructor.
*
* @param CategoryCode $categorycode The CategoryCode Class.
*
* @since 3.2.0
*/
public function __construct(CategoryCode $categorycode)
{
$this->categorycode = $categorycode;
}
/**
* Get Access Sections Category
*
* @param string $nameSingleCode
* @param string $nameListCode
*
* @return string
* @since 3.2.0
*/
public function get(string $nameSingleCode, string $nameListCode): string
{
$component = '';
// check if view has category
$otherViews = $this->categorycode->getString("{$nameSingleCode}.views");
if ($otherViews !== null && $otherViews == $nameListCode)
{
$component .= PHP_EOL . Indent::_(1)
. '<section name="category.' . $otherViews . '">';
$component .= PHP_EOL . Indent::_(2)
. '<action name="core.create" title="JACTION_CREATE" description="JACTION_CREATE_COMPONENT_DESC" />';
$component .= PHP_EOL . Indent::_(2)
. '<action name="core.delete" title="JACTION_DELETE" description="COM_CATEGORIES_ACCESS_DELETE_DESC" />';
$component .= PHP_EOL . Indent::_(2)
. '<action name="core.edit" title="JACTION_EDIT" description="COM_CATEGORIES_ACCESS_EDIT_DESC" />';
$component .= PHP_EOL . Indent::_(2)
. '<action name="core.edit.state" title="JACTION_EDITSTATE" description="COM_CATEGORIES_ACCESS_EDITSTATE_DESC" />';
$component .= PHP_EOL . Indent::_(2)
. '<action name="core.edit.own" title="JACTION_EDITOWN" description="COM_CATEGORIES_ACCESS_EDITOWN_DESC" />';
$component .= PHP_EOL . Indent::_(1) . "</section>";
}
return $component;
}
}

View File

@ -0,0 +1,63 @@
<?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\Creator;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent;
/**
* Access Sections Joomla Fields Creator Class
*
* @since 3.2.0
*/
final class AccessSectionsJoomlaFields
{
/**
* Set Access Sections Joomla Fields
*
* @return string
* @since 3.2.0
*/
public function get(): string
{
$component = '';
// set all the core field permissions
$component .= PHP_EOL . Indent::_(1) . '<section name="fieldgroup">';
$component .= PHP_EOL . Indent::_(2)
. '<action name="core.create" title="JACTION_CREATE" description="COM_FIELDS_GROUP_PERMISSION_CREATE_DESC" />';
$component .= PHP_EOL . Indent::_(2)
. '<action name="core.delete" title="JACTION_DELETE" description="COM_FIELDS_GROUP_PERMISSION_DELETE_DESC" />';
$component .= PHP_EOL . Indent::_(2)
. '<action name="core.edit" title="JACTION_EDIT" description="COM_FIELDS_GROUP_PERMISSION_EDIT_DESC" />';
$component .= PHP_EOL . Indent::_(2)
. '<action name="core.edit.state" title="JACTION_EDITSTATE" description="COM_FIELDS_GROUP_PERMISSION_EDITSTATE_DESC" />';
$component .= PHP_EOL . Indent::_(2)
. '<action name="core.edit.own" title="JACTION_EDITOWN" description="COM_FIELDS_GROUP_PERMISSION_EDITOWN_DESC" />';
$component .= PHP_EOL . Indent::_(2)
. '<action name="core.edit.value" title="JACTION_EDITVALUE" description="COM_FIELDS_GROUP_PERMISSION_EDITVALUE_DESC" />';
$component .= PHP_EOL . Indent::_(1) . '</section>';
$component .= PHP_EOL . Indent::_(1) . '<section name="field">';
$component .= PHP_EOL . Indent::_(2)
. '<action name="core.delete" title="JACTION_DELETE" description="COM_FIELDS_FIELD_PERMISSION_DELETE_DESC" />';
$component .= PHP_EOL . Indent::_(2)
. '<action name="core.edit" title="JACTION_EDIT" description="COM_FIELDS_FIELD_PERMISSION_EDIT_DESC" />';
$component .= PHP_EOL . Indent::_(2)
. '<action name="core.edit.state" title="JACTION_EDITSTATE" description="COM_FIELDS_FIELD_PERMISSION_EDITSTATE_DESC" />';
$component .= PHP_EOL . Indent::_(2)
. '<action name="core.edit.value" title="JACTION_EDITVALUE" description="COM_FIELDS_FIELD_PERMISSION_EDITVALUE_DESC" />';
$component .= PHP_EOL . Indent::_(1) . '</section>';
return $component;
}
}

View File

@ -16,6 +16,7 @@ use Joomla\CMS\Factory;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Application\CMSApplication;
use VDM\Joomla\Componentbuilder\Compiler\Config;
use VDM\Joomla\Componentbuilder\Compiler\Power;
use VDM\Joomla\Componentbuilder\Compiler\Language;
use VDM\Joomla\Componentbuilder\Compiler\Placeholder;
use VDM\Joomla\Componentbuilder\Compiler\Creator\Layout;
@ -82,6 +83,14 @@ final class Builders
*/
protected Config $config;
/**
* The Power Class.
*
* @var Power
* @since 3.2.0
*/
protected Power $power;
/**
* The Language Class.
*
@ -454,6 +463,7 @@ final class Builders
* Constructor.
*
* @param Config $config The Config Class.
* @param Power $power The Power Class.
* @param Language $language The Language Class.
* @param Placeholder $placeholder The Placeholder Class.
* @param Layout $layout The Layout Class.
@ -503,7 +513,7 @@ final class Builders
*
* @since 3.2.0
*/
public function __construct(Config $config, Language $language,
public function __construct(Config $config, Power $power, Language $language,
Placeholder $placeholder, Layout $layout,
SiteFieldData $sitefielddata, Tags $tags,
DatabaseTables $databasetables,
@ -536,6 +546,7 @@ final class Builders
ComponentFields $componentfields, ?CMSApplication $app = null)
{
$this->config = $config;
$this->power = $power;
$this->language = $language;
$this->placeholder = $placeholder;
$this->layout = $layout;
@ -789,6 +800,8 @@ final class Builders
);
}
}
// extends value
$extends_field = $custom['extends'] ?? '';
// build the list values
if (($listSwitch || $listJoin) && $typeName != 'repeatable'
&& $typeName != 'subform')
@ -914,7 +927,7 @@ final class Builders
);
}
// build script switch for user
if ($custom['extends'] === 'user')
if ($extends_field === 'user')
{
$this->scriptuserswitch->set($typeName, $typeName);
}
@ -986,7 +999,7 @@ final class Builders
}
// setup checkbox for this view
if ($dbSwitch && ($typeName === 'checkbox' ||
(ArrayHelper::check($custom) && isset($custom['extends']) && $custom['extends'] === 'checkboxes')))
(ArrayHelper::check($custom) && $extends_field === 'checkboxes')))
{
$this->checkbox->add($nameSingleCode, $name, true);
}
@ -1029,6 +1042,8 @@ final class Builders
$this->sitefielddata->set(
$nameSingleCode, $name, 'basic_encryption', $typeName
);
// make sure to load FOF encryption (power)
$this->power->get('99175f6d-dba8-4086-8a65-5c4ec175e61d', 1);
// add open close method to field data
$field['store'] = 'basic_encryption';
break;
@ -1039,6 +1054,8 @@ final class Builders
$this->sitefielddata->set(
$nameSingleCode, $name, 'whmcs_encryption', $typeName
);
// make sure to load FOF encryption (power)
$this->power->get('99175f6d-dba8-4086-8a65-5c4ec175e61d', 1);
// add open close method to field data
$field['store'] = 'whmcs_encryption';
break;
@ -1049,6 +1066,8 @@ final class Builders
$this->sitefielddata->set(
$nameSingleCode, $name, 'medium_encryption', $typeName
);
// make sure to load FOF encryption (power)
$this->power->get('99175f6d-dba8-4086-8a65-5c4ec175e61d', 1);
// add open close method to field data
$field['store'] = 'medium_encryption';
break;

View File

@ -0,0 +1,388 @@
<?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\Creator;
use VDM\Joomla\Componentbuilder\Compiler\Config;
use VDM\Joomla\Componentbuilder\Compiler\Component;
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\EventInterface as Event;
use VDM\Joomla\Componentbuilder\Compiler\Placeholder;
use VDM\Joomla\Componentbuilder\Compiler\Component\Placeholder as CPlaceholder;
use VDM\Joomla\Componentbuilder\Compiler\Builder\ExtensionsParams;
use VDM\Joomla\Componentbuilder\Compiler\Builder\ConfigFieldsetsCustomfield as Customfield;
use VDM\Joomla\Componentbuilder\Compiler\Creator\FieldAsString;
use VDM\Joomla\Componentbuilder\Compiler\Creator\ConfigFieldsetsGlobal;
use VDM\Joomla\Componentbuilder\Compiler\Creator\ConfigFieldsetsSiteControl;
use VDM\Joomla\Componentbuilder\Compiler\Creator\ConfigFieldsetsGroupControl;
use VDM\Joomla\Componentbuilder\Compiler\Creator\ConfigFieldsetsUikit;
use VDM\Joomla\Componentbuilder\Compiler\Creator\ConfigFieldsetsGooglechart;
use VDM\Joomla\Componentbuilder\Compiler\Creator\ConfigFieldsetsEmailHelper;
use VDM\Joomla\Componentbuilder\Compiler\Creator\ConfigFieldsetsEncryption;
use VDM\Joomla\Componentbuilder\Compiler\Creator\ConfigFieldsetsCustomfield;
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Placefix;
use VDM\Joomla\Utilities\GetHelper;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Line;
use VDM\Joomla\Utilities\MathHelper;
/**
* Config Fieldsets Creator Class
*
* @since 3.2.0
*/
final class ConfigFieldsets
{
/**
* The Config Class.
*
* @var Config
* @since 3.2.0
*/
protected Config $config;
/**
* The Component Class.
*
* @var Component
* @since 3.2.0
*/
protected Component $component;
/**
* The EventInterface Class.
*
* @var Event
* @since 3.2.0
*/
protected Event $event;
/**
* The Placeholder Class.
*
* @var Placeholder
* @since 3.2.0
*/
protected Placeholder $placeholder;
/**
* The Placeholder Class.
*
* @var CPlaceholder
* @since 3.2.0
*/
protected CPlaceholder $cplaceholder;
/**
* The ExtensionsParams Class.
*
* @var ExtensionsParams
* @since 3.2.0
*/
protected ExtensionsParams $extensionsparams;
/**
* The ConfigFieldsetsCustomfield Class.
*
* @var Customfield
* @since 3.2.0
*/
protected Customfield $customfield;
/**
* The FieldAsString Class.
*
* @var FieldAsString
* @since 3.2.0
*/
protected FieldAsString $fieldasstring;
/**
* The ConfigFieldsetsGlobal Class.
*
* @var ConfigFieldsetsGlobal
* @since 3.2.0
*/
protected ConfigFieldsetsGlobal $configfieldsetsglobal;
/**
* The ConfigFieldsetsSiteControl Class.
*
* @var ConfigFieldsetsSiteControl
* @since 3.2.0
*/
protected ConfigFieldsetsSiteControl $configfieldsetssitecontrol;
/**
* The ConfigFieldsetsGroupControl Class.
*
* @var ConfigFieldsetsGroupControl
* @since 3.2.0
*/
protected ConfigFieldsetsGroupControl $configfieldsetsgroupcontrol;
/**
* The ConfigFieldsetsUikit Class.
*
* @var ConfigFieldsetsUikit
* @since 3.2.0
*/
protected ConfigFieldsetsUikit $configfieldsetsuikit;
/**
* The ConfigFieldsetsGooglechart Class.
*
* @var ConfigFieldsetsGooglechart
* @since 3.2.0
*/
protected ConfigFieldsetsGooglechart $configfieldsetsgooglechart;
/**
* The ConfigFieldsetsEmailHelper Class.
*
* @var ConfigFieldsetsEmailHelper
* @since 3.2.0
*/
protected ConfigFieldsetsEmailHelper $configfieldsetsemailhelper;
/**
* The ConfigFieldsetsEncryption Class.
*
* @var ConfigFieldsetsEncryption
* @since 3.2.0
*/
protected ConfigFieldsetsEncryption $configfieldsetsencryption;
/**
* The ConfigFieldsetsCustomfield Class.
*
* @var ConfigFieldsetsCustomfield
* @since 3.2.0
*/
protected ConfigFieldsetsCustomfield $configfieldsetscustomfield;
/**
* Constructor.
*
* @param Config $config The Config Class.
* @param Component $component The Component Class.
* @param Event $event The EventInterface Class.
* @param Placeholder $placeholder The Placeholder Class.
* @param CPlaceholder $cplaceholder The Placeholder Class.
* @param ExtensionsParams $extensionsparams The ExtensionsParams Class.
* @param Customfield $customfield The ConfigFieldsetsCustomfield Class.
* @param FieldAsString $fieldasstring The FieldAsString Class.
* @param ConfigFieldsetsGlobal $configfieldsetsglobal The ConfigFieldsetsGlobal Class.
* @param ConfigFieldsetsSiteControl $configfieldsetssitecontrol The ConfigFieldsetsSiteControl Class.
* @param ConfigFieldsetsGroupControl $configfieldsetsgroupcontrol The ConfigFieldsetsGroupControl Class.
* @param ConfigFieldsetsUikit $configfieldsetsuikit The ConfigFieldsetsUikit Class.
* @param ConfigFieldsetsGooglechart $configfieldsetsgooglechart The ConfigFieldsetsGooglechart Class.
* @param ConfigFieldsetsEmailHelper $configfieldsetsemailhelper The ConfigFieldsetsEmailHelper Class.
* @param ConfigFieldsetsEncryption $configfieldsetsencryption The ConfigFieldsetsEncryption Class.
* @param ConfigFieldsetsCustomfield $configfieldsetscustomfield The ConfigFieldsetsCustomfield Class.
*
* @since 3.2.0
*/
public function __construct(Config $config, Component $component, Event $event,
Placeholder $placeholder, CPlaceholder $cplaceholder,
ExtensionsParams $extensionsparams,
Customfield $customfield, FieldAsString $fieldasstring,
ConfigFieldsetsGlobal $configfieldsetsglobal,
ConfigFieldsetsSiteControl $configfieldsetssitecontrol,
ConfigFieldsetsGroupControl $configfieldsetsgroupcontrol,
ConfigFieldsetsUikit $configfieldsetsuikit,
ConfigFieldsetsGooglechart $configfieldsetsgooglechart,
ConfigFieldsetsEmailHelper $configfieldsetsemailhelper,
ConfigFieldsetsEncryption $configfieldsetsencryption,
ConfigFieldsetsCustomfield $configfieldsetscustomfield)
{
$this->config = $config;
$this->component = $component;
$this->event = $event;
$this->placeholder = $placeholder;
$this->cplaceholder = $cplaceholder;
$this->extensionsparams = $extensionsparams;
$this->customfield = $customfield;
$this->fieldasstring = $fieldasstring;
$this->configfieldsetsglobal = $configfieldsetsglobal;
$this->configfieldsetssitecontrol = $configfieldsetssitecontrol;
$this->configfieldsetsgroupcontrol = $configfieldsetsgroupcontrol;
$this->configfieldsetsuikit = $configfieldsetsuikit;
$this->configfieldsetsgooglechart = $configfieldsetsgooglechart;
$this->configfieldsetsemailhelper = $configfieldsetsemailhelper;
$this->configfieldsetsencryption = $configfieldsetsencryption;
$this->configfieldsetscustomfield = $configfieldsetscustomfield;
}
/**
* Set Config Fieldsets
*
* @param int $timer
*
* @since 1.0
*/
public function set(int $timer = 0): void
{
// main lang prefix
$lang = $this->config->lang_prefix . '_CONFIG';
if (1 == $timer) // this is before the admin views are build
{
// start loading Global params
$autorName = StringHelper::html(
$this->component->get('author')
);
$autorEmail = StringHelper::html(
$this->component->get('email')
);
$this->extensionsparams->add('component', '"autorName":"' . $autorName
. '","autorEmail":"' . $autorEmail . '"');
// set the custom fields
if ($this->component->isArray('config'))
{
// set component code name
$component = $this->config->component_code_name;
$nameSingleCode = 'config';
$nameListCode = 'configs';
// set place holders
$placeholders = [];
$placeholders[Placefix::_h('component')]
= $this->config->component_code_name;
$placeholders[Placefix::_h('Component')]
= StringHelper::safe(
$this->component->get('name_code'), 'F'
);
$placeholders[Placefix::_h('COMPONENT')]
= StringHelper::safe(
$this->component->get('name_code'), 'U'
);
$placeholders[Placefix::_h('view')]
= $nameSingleCode;
$placeholders[Placefix::_h('views')]
= $nameListCode;
$placeholders[Placefix::_('component')]
= $this->config->component_code_name;
$placeholders[Placefix::_('Component')]
= $placeholders[Placefix::_h('Component')];
$placeholders[Placefix::_('COMPONENT')]
= $placeholders[Placefix::_h('COMPONENT')];
$placeholders[Placefix::_('view')]
= $nameSingleCode;
$placeholders[Placefix::_('views')]
= $nameListCode;
// load the global placeholders
foreach ($this->cplaceholder->get() as $globalPlaceholder => $gloabalValue)
{
$placeholders[$globalPlaceholder] = $gloabalValue;
}
$view = [];
$viewType = 0;
// set the custom table key
$dbkey = 'g';
// Trigger Event: jcb_ce_onBeforeSetConfigFieldsets
$this->event->trigger(
'jcb_ce_onBeforeSetConfigFieldsets', [&$timer]
);
// build the config fields
foreach ($this->component->get('config') as $field)
{
// get the xml string
$xmlField = $this->fieldasstring->get(
$field, $view, $viewType, $lang, $nameSingleCode,
$nameListCode, $placeholders, $dbkey, false
);
// make sure the xml is set and a string
if (isset($xmlField) && StringHelper::check($xmlField))
{
$this->customfield->add($field['tabname'], $xmlField, true);
// set global params to db on install
$fieldName = StringHelper::safe(
$this->placeholder->update(
GetHelper::between(
$xmlField, 'name="', '"'
), $placeholders
)
);
$fieldDefault = $this->placeholder->update(
GetHelper::between(
$xmlField, 'default="', '"'
), $placeholders
);
if (isset($field['custom_value'])
&& StringHelper::check(
$field['custom_value']
))
{
// add array if found
if ((strpos((string) $field['custom_value'], '["') !== false)
&& (strpos((string) $field['custom_value'], '"]')
!== false))
{
// load the Global checkin defautls
$this->extensionsparams->add('component', '"' . $fieldName
. '":' . $field['custom_value']);
}
else
{
// load the Global checkin defautls
$this->extensionsparams->add('component', '"' . $fieldName
. '":"' . $field['custom_value'] . '"');
}
}
elseif (StringHelper::check($fieldDefault))
{
// load the Global checkin defautls
$this->extensionsparams->add('component', '"' . $fieldName . '":"'
. $fieldDefault . '"');
}
}
}
}
// first run we must set the global
$this->configfieldsetsglobal->set($lang, $autorName, $autorEmail);
$this->configfieldsetssitecontrol->set($lang);
}
elseif (2 == $timer) // this is after the admin views are build
{
// Trigger Event: jcb_ce_onBeforeSetConfigFieldsets
$this->event->trigger(
'jcb_ce_onBeforeSetConfigFieldsets', [&$timer]
);
// these field sets can only be added after admin view is build
$this->configfieldsetsgroupcontrol->set($lang);
// these can be added anytime really (but looks best after groups
$this->configfieldsetsuikit->set($lang);
$this->configfieldsetsgooglechart->set($lang);
$this->configfieldsetsemailhelper->set($lang);
$this->configfieldsetsencryption->set($lang);
// these are the custom settings
$this->configfieldsetscustomfield->set($lang);
}
// Trigger Event: jcb_ce_onAfterSetConfigFieldsets
$this->event->trigger(
'jcb_ce_onAfterSetConfigFieldsets', [&$timer]
);
}
}

View File

@ -0,0 +1,142 @@
<?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\Creator;
use VDM\Joomla\Componentbuilder\Compiler\Config;
use VDM\Joomla\Componentbuilder\Compiler\Language;
use VDM\Joomla\Componentbuilder\Compiler\Builder\ConfigFieldsetsCustomfield as Customfield;
use VDM\Joomla\Componentbuilder\Compiler\Builder\ConfigFieldsets;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Utilities\GetHelper;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent;
/**
* Config Fieldsets Customfield Creator Class
*
* @since 3.2.0
*/
final class ConfigFieldsetsCustomfield
{
/**
* The Config Class.
*
* @var Config
* @since 3.2.0
*/
protected Config $config;
/**
* The Language Class.
*
* @var Language
* @since 3.2.0
*/
protected Language $language;
/**
* The ConfigFieldsetsCustomfield Class.
*
* @var Customfield
* @since 3.2.0
*/
protected Customfield $customfield;
/**
* The ConfigFieldsets Class.
*
* @var ConfigFieldsets
* @since 3.2.0
*/
protected ConfigFieldsets $configfieldsets;
/**
* Constructor.
*
* @param Config $config The Config Class.
* @param Language $language The Language Class.
* @param Customfield $customfield The ConfigFieldsetsCustomfield Class.
* @param ConfigFieldsets $configfieldsets The ConfigFieldsets Class.
*
* @since 3.2.0
*/
public function __construct(Config $config, Language $language,
Customfield $customfield,
ConfigFieldsets $configfieldsets)
{
$this->config = $config;
$this->language = $language;
$this->customfield = $customfield;
$this->configfieldsets = $configfieldsets;
}
/**
* Set Custom Control Config Fieldsets
*
* @param string $lang
*
* @since 1.0
*/
public function set(string $lang): void
{
// add custom new global fields set
if ($this->customfield->isActive())
{
foreach ($this->customfield->allActive() as $tab => $tabFields)
{
$tabCode = StringHelper::safe($tab)
. '_custom_config';
$tabUpper = StringHelper::safe($tab, 'U');
$tabLower = StringHelper::safe($tab);
// remove display targeted fields
$bucket = [];
foreach ($tabFields as $tabField)
{
$display = GetHelper::between(
$tabField, 'display="', '"'
);
if (!StringHelper::check($display)
|| $display === 'config')
{
// remove this display since it is not used in Joomla
$bucket[] = str_replace(
'display="config"', '', (string) $tabField
);
}
}
// only add the tab if it has values
if (ArrayHelper::check($bucket))
{
// setup lang
$this->language->set(
$this->config->lang_target, $lang . '_' . $tabUpper, $tab
);
// start field set
$this->configfieldsets->add('component', Indent::_(1) . "<fieldset");
$this->configfieldsets->add('component', Indent::_(2) . 'name="'
. $tabCode . '"');
$this->configfieldsets->add('component', Indent::_(2) . 'label="' . $lang
. '_' . $tabUpper . '">');
// set the fields
$this->configfieldsets->add('component', implode("", $bucket));
// close field set
$this->configfieldsets->add('component', Indent::_(1) . "</fieldset>");
}
// remove after loading
$this->customfield->remove($tab);
}
}
}
}

View File

@ -0,0 +1,916 @@
<?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\Creator;
use VDM\Joomla\Componentbuilder\Compiler\Config;
use VDM\Joomla\Componentbuilder\Compiler\Language;
use VDM\Joomla\Componentbuilder\Compiler\Component;
use VDM\Joomla\Componentbuilder\Compiler\Builder\ConfigFieldsets;
use VDM\Joomla\Componentbuilder\Compiler\Builder\ConfigFieldsetsCustomfield as Customfield;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Line;
/**
* Config Fieldsets Email Helper Creator Class
*
* @since 3.2.0
*/
final class ConfigFieldsetsEmailHelper
{
/**
* The Config Class.
*
* @var Config
* @since 3.2.0
*/
protected Config $config;
/**
* The Language Class.
*
* @var Language
* @since 3.2.0
*/
protected Language $language;
/**
* The Component Class.
*
* @var Component
* @since 3.2.0
*/
protected Component $component;
/**
* The ConfigFieldsets Class.
*
* @var ConfigFieldsets
* @since 3.2.0
*/
protected ConfigFieldsets $configfieldsets;
/**
* The ConfigFieldsetsCustomfield Class.
*
* @var Customfield
* @since 3.2.0
*/
protected Customfield $customfield;
/**
* Constructor.
*
* @param Config $config The Config Class.
* @param Language $language The Language Class.
* @param Component $component The Component Class.
* @param ConfigFieldsets $configfieldsets The ConfigFieldsets Class.
* @param Customfield $customfield The ConfigFieldsetsCustomfield Class.
*
* @since 3.2.0
*/
public function __construct(Config $config, Language $language, Component $component,
ConfigFieldsets $configfieldsets,
Customfield $customfield)
{
$this->config = $config;
$this->language = $language;
$this->component = $component;
$this->configfieldsets = $configfieldsets;
$this->customfield = $customfield;
}
/**
* Set Email Helper Config Fieldsets
*
* @param string $lang
*
* @since 3.2.0
*/
public function set(string $lang): void
{
if ($this->component->get('add_email_helper'))
{
// main lang prefix
$lang = $lang . '';
// set main lang string
$this->language->set(
$this->config->lang_target, $lang . '_MAIL_CONFIGURATION', "Mail Configuration"
);
$this->language->set($this->config->lang_target, $lang . '_DKIM', "DKIM");
// start building field set for email helper functions
$this->configfieldsets->add('component', PHP_EOL . Indent::_(1) . "<fieldset");
$this->configfieldsets->add('component', Indent::_(2)
. "name=\"mail_configuration_custom_config\"");
$this->configfieldsets->add('component', Indent::_(2) . "label=\"" . $lang
. "_MAIL_CONFIGURATION\">");
// add custom Mail Configurations
if ($this->customfield->isArray('Mail Configuration'))
{
$this->configfieldsets->add('component', implode(
"", $this->customfield->get('Mail Configuration')
));
$this->customfield->remove('Mail Configuration');
}
else
{
// set all the laguage strings
$this->language->set(
$this->config->lang_target, $lang . '_MAILONLINE_LABEL', "Mailer Status"
);
$this->language->set(
$this->config->lang_target, $lang . '_MAILONLINE_DESCRIPTION',
"Warning this will stop all emails from going out."
);
$this->language->set($this->config->lang_target, $lang . '_ON', "On");
$this->language->set($this->config->lang_target, $lang . '_OFF', "Off");
$this->language->set(
$this->config->lang_target, $lang . '_MAILER_LABEL', "Mailer"
);
$this->language->set(
$this->config->lang_target, $lang . '_MAILER_DESCRIPTION',
"Select what mailer you would like to use to send emails."
);
$this->language->set($this->config->lang_target, $lang . '_GLOBAL', "Global");
$this->language->set(
$this->config->lang_target, $lang . '_PHP_MAIL', "PHP Mail"
);
$this->language->set(
$this->config->lang_target, $lang . '_SENDMAIL', "Sendmail"
);
$this->language->set($this->config->lang_target, $lang . '_SMTP', "SMTP");
$this->language->set(
$this->config->lang_target, $lang . '_EMAILFROM_LABEL', " From Email"
);
$this->language->set(
$this->config->lang_target, $lang . '_EMAILFROM_DESCRIPTION',
"The global email address that will be used to send system email."
);
$this->language->set(
$this->config->lang_target, $lang . '_EMAILFROM_HINT', "Email Address Here"
);
$this->language->set(
$this->config->lang_target, $lang . '_FROMNAME_LABEL', "From Name"
);
$this->language->set(
$this->config->lang_target, $lang . '_FROMNAME_DESCRIPTION',
"Text displayed in the header &quot;From:&quot; field when sending a site email. Usually the site name."
);
$this->language->set(
$this->config->lang_target, $lang . '_FROMNAME_HINT', "From Name Here"
);
$this->language->set(
$this->config->lang_target, $lang . '_EMAILREPLY_LABEL', " Reply to Email"
);
$this->language->set(
$this->config->lang_target, $lang . '_EMAILREPLY_DESCRIPTION',
"The global email address that will be used to set as the reply email. (leave blank for none)"
);
$this->language->set(
$this->config->lang_target, $lang . '_EMAILREPLY_HINT',
"Email Address Here"
);
$this->language->set(
$this->config->lang_target, $lang . '_REPLYNAME_LABEL', "Reply to Name"
);
$this->language->set(
$this->config->lang_target, $lang . '_REPLYNAME_DESCRIPTION',
"Text displayed in the header &quot;Reply To:&quot; field when replying to the site email. Usually the the person that receives the response. (leave blank for none)"
);
$this->language->set(
$this->config->lang_target, $lang . '_REPLYNAME_HINT', "Reply Name Here"
);
$this->language->set(
$this->config->lang_target, $lang . '_SENDMAIL_LABEL', "Sendmail Path"
);
$this->language->set(
$this->config->lang_target, $lang . '_SENDMAIL_DESCRIPTION',
"Enter the path to the sendmail program directory on your host server."
);
$this->language->set(
$this->config->lang_target, $lang . '_SENDMAIL_HINT', "/usr/sbin/sendmail"
);
$this->language->set(
$this->config->lang_target, $lang . '_SMTPAUTH_LABEL',
"SMTP Authentication"
);
$this->language->set(
$this->config->lang_target, $lang . '_SMTPAUTH_DESCRIPTION',
"Select yes if your SMTP host requires SMTP Authentication."
);
$this->language->set($this->config->lang_target, $lang . '_YES', "Yes");
$this->language->set($this->config->lang_target, $lang . '_NO', "No");
$this->language->set(
$this->config->lang_target, $lang . '_SMTPSECURE_LABEL', "SMTP Security"
);
$this->language->set(
$this->config->lang_target, $lang . '_SMTPSECURE_DESCRIPTION',
"Select the security model that your SMTP server uses."
);
$this->language->set($this->config->lang_target, $lang . '_NONE', "None");
$this->language->set($this->config->lang_target, $lang . '_SSL', "SSL");
$this->language->set($this->config->lang_target, $lang . '_TLS', "TLS");
$this->language->set(
$this->config->lang_target, $lang . '_SMTPPORT_LABEL', "SMTP Port"
);
$this->language->set(
$this->config->lang_target, $lang . '_SMTPPORT_DESCRIPTION',
"Enter the port number of your SMTP server. Use 25 for most unsecured servers and 465 for most secure servers."
);
$this->language->set(
$this->config->lang_target, $lang . '_SMTPPORT_HINT', "25"
);
$this->language->set(
$this->config->lang_target, $lang . '_SMTPUSER_LABEL', "SMTP Username"
);
$this->language->set(
$this->config->lang_target, $lang . '_SMTPUSER_DESCRIPTION',
"Enter the username for access to the SMTP host."
);
$this->language->set(
$this->config->lang_target, $lang . '_SMTPUSER_HINT', "email@demo.com"
);
$this->language->set(
$this->config->lang_target, $lang . '_SMTPPASS_LABEL', "SMTP Password"
);
$this->language->set(
$this->config->lang_target, $lang . '_SMTPPASS_DESCRIPTION',
"Enter the password for access to the SMTP host."
);
$this->language->set(
$this->config->lang_target, $lang . '_SMTPHOST_LABEL', "SMTP Host"
);
$this->language->set(
$this->config->lang_target, $lang . '_SMTPHOST_DESCRIPTION',
"Enter the name of the SMTP host."
);
$this->language->set(
$this->config->lang_target, $lang . '_SMTPHOST_HINT', "localhost"
);
// set the mailer fields
$this->configfieldsets->add('component', PHP_EOL . Indent::_(2) . "<!--"
. Line::_(__Line__, __Class__)
. " Mailonline Field. Type: Radio. (joomla) -->");
$this->configfieldsets->add('component', Indent::_(2) . "<field");
$this->configfieldsets->add('component', Indent::_(3) . "type=\"radio\"");
$this->configfieldsets->add('component', Indent::_(3) . "name=\"mailonline\"");
$this->configfieldsets->add('component', Indent::_(3) . "label=\"" . $lang
. "_MAILONLINE_LABEL\"");
$this->configfieldsets->add('component', Indent::_(3) . "description=\""
. $lang . "_MAILONLINE_DESCRIPTION\"");
$this->configfieldsets->add('component', Indent::_(3)
. "class=\"btn-group btn-group-yesno\"");
$this->configfieldsets->add('component', Indent::_(3) . "default=\"1\">");
$this->configfieldsets->add('component', Indent::_(3) . "<!--"
. Line::_(__Line__, __Class__) . " Option Set. -->");
$this->configfieldsets->add('component', Indent::_(3)
. "<option value=\"1\">");
$this->configfieldsets->add('component', Indent::_(4) . $lang
. "_ON</option>");
$this->configfieldsets->add('component', Indent::_(3)
. "<option value=\"0\">");
$this->configfieldsets->add('component', Indent::_(4) . $lang
. "_OFF</option>");
$this->configfieldsets->add('component', Indent::_(2) . "</field>");
$this->configfieldsets->add('component', Indent::_(2) . "<!--"
. Line::_(__Line__, __Class__)
. " Mailer Field. Type: List. (joomla) -->");
$this->configfieldsets->add('component', Indent::_(2) . "<field");
$this->configfieldsets->add('component', Indent::_(3) . "type=\"list\"");
$this->configfieldsets->add('component', Indent::_(3) . "name=\"mailer\"");
$this->configfieldsets->add('component', Indent::_(3) . "label=\"" . $lang
. "_MAILER_LABEL\"");
$this->configfieldsets->add('component', Indent::_(3) . "description=\""
. $lang . "_MAILER_DESCRIPTION\"");
$this->configfieldsets->add('component', Indent::_(3)
. "class=\"list_class\"");
$this->configfieldsets->add('component', Indent::_(3) . "multiple=\"false\"");
$this->configfieldsets->add('component', Indent::_(3) . "filter=\"WORD\"");
$this->configfieldsets->add('component', Indent::_(3) . "required=\"true\"");
$this->configfieldsets->add('component', Indent::_(3) . "default=\"global\">");
$this->configfieldsets->add('component', Indent::_(3) . "<!--"
. Line::_(__Line__, __Class__) . " Option Set. -->");
$this->configfieldsets->add('component', Indent::_(3)
. "<option value=\"global\">");
$this->configfieldsets->add('component', Indent::_(4) . $lang
. "_GLOBAL</option>");
$this->configfieldsets->add('component', Indent::_(3)
. "<option value=\"default\">");
$this->configfieldsets->add('component', Indent::_(4) . $lang
. "_PHP_MAIL</option>");
$this->configfieldsets->add('component', Indent::_(3)
. "<option value=\"sendmail\">");
$this->configfieldsets->add('component', Indent::_(4) . $lang
. "_SENDMAIL</option>");
$this->configfieldsets->add('component', Indent::_(3)
. "<option value=\"smtp\">");
$this->configfieldsets->add('component', Indent::_(4) . $lang
. "_SMTP</option>");
$this->configfieldsets->add('component', Indent::_(2) . "</field>");
$this->configfieldsets->add('component', Indent::_(2) . "<!--"
. Line::_(__Line__, __Class__)
. " Emailfrom Field. Type: Text. (joomla) -->");
$this->configfieldsets->add('component', Indent::_(2) . "<field");
$this->configfieldsets->add('component', Indent::_(3) . "type=\"text\"");
$this->configfieldsets->add('component', Indent::_(3) . "name=\"emailfrom\"");
$this->configfieldsets->add('component', Indent::_(3) . "label=\"" . $lang
. "_EMAILFROM_LABEL\"");
$this->configfieldsets->add('component', Indent::_(3) . "size=\"60\"");
$this->configfieldsets->add('component', Indent::_(3) . "maxlength=\"150\"");
$this->configfieldsets->add('component', Indent::_(3) . "description=\""
. $lang . "_EMAILFROM_DESCRIPTION\"");
$this->configfieldsets->add('component', Indent::_(3) . "class=\"text_area\"");
$this->configfieldsets->add('component', Indent::_(3) . "filter=\"STRING\"");
$this->configfieldsets->add('component', Indent::_(3) . "validate=\"email\"");
$this->configfieldsets->add('component', Indent::_(3)
. "message=\"Error! Please add email address here.\"");
$this->configfieldsets->add('component', Indent::_(3) . "hint=\"" . $lang
. "_EMAILFROM_HINT\"");
$this->configfieldsets->add('component', Indent::_(3)
. "showon=\"mailer:smtp,sendmail,default\"");
$this->configfieldsets->add('component', Indent::_(2) . "/>");
$this->configfieldsets->add('component', Indent::_(2) . "<!--"
. Line::_(__Line__, __Class__)
. " Fromname Field. Type: Text. (joomla) -->");
$this->configfieldsets->add('component', Indent::_(2) . "<field");
$this->configfieldsets->add('component', Indent::_(3) . "type=\"text\"");
$this->configfieldsets->add('component', Indent::_(3) . "name=\"fromname\"");
$this->configfieldsets->add('component', Indent::_(3) . "label=\"" . $lang
. "_FROMNAME_LABEL\"");
$this->configfieldsets->add('component', Indent::_(3) . "size=\"60\"");
$this->configfieldsets->add('component', Indent::_(3) . "maxlength=\"150\"");
$this->configfieldsets->add('component', Indent::_(3) . "description=\""
. $lang . "_FROMNAME_DESCRIPTION\"");
$this->configfieldsets->add('component', Indent::_(3) . "class=\"text_area\"");
$this->configfieldsets->add('component', Indent::_(3) . "filter=\"STRING\"");
$this->configfieldsets->add('component', Indent::_(3)
. "message=\"Error! Please add some name here.\"");
$this->configfieldsets->add('component', Indent::_(3) . "hint=\"" . $lang
. "_FROMNAME_HINT\"");
$this->configfieldsets->add('component', Indent::_(3)
. "showon=\"mailer:smtp,sendmail,default\"");
$this->configfieldsets->add('component', Indent::_(2) . "/>");
$this->configfieldsets->add('component', Indent::_(2) . "<!--"
. Line::_(__Line__, __Class__)
. " Email reply to Field. Type: Text. (joomla) -->");
$this->configfieldsets->add('component', Indent::_(2) . "<field");
$this->configfieldsets->add('component', Indent::_(3) . "type=\"text\"");
$this->configfieldsets->add('component', Indent::_(3) . "name=\"replyto\"");
$this->configfieldsets->add('component', Indent::_(3) . "label=\"" . $lang
. "_EMAILREPLY_LABEL\"");
$this->configfieldsets->add('component', Indent::_(3) . "size=\"60\"");
$this->configfieldsets->add('component', Indent::_(3) . "maxlength=\"150\"");
$this->configfieldsets->add('component', Indent::_(3) . "description=\""
. $lang . "_EMAILREPLY_DESCRIPTION\"");
$this->configfieldsets->add('component', Indent::_(3) . "class=\"text_area\"");
$this->configfieldsets->add('component', Indent::_(3) . "filter=\"STRING\"");
$this->configfieldsets->add('component', Indent::_(3) . "validate=\"email\"");
$this->configfieldsets->add('component', Indent::_(3)
. "message=\"Error! Please add email address here.\"");
$this->configfieldsets->add('component', Indent::_(3) . "hint=\"" . $lang
. "_EMAILREPLY_HINT\"");
$this->configfieldsets->add('component', Indent::_(3)
. "showon=\"mailer:smtp,sendmail,default\"");
$this->configfieldsets->add('component', Indent::_(2) . "/>");
$this->configfieldsets->add('component', Indent::_(2) . "<!--"
. Line::_(__Line__, __Class__)
. " Reply to name Field. Type: Text. (joomla) -->");
$this->configfieldsets->add('component', Indent::_(2) . "<field");
$this->configfieldsets->add('component', Indent::_(3) . "type=\"text\"");
$this->configfieldsets->add('component', Indent::_(3)
. "name=\"replytoname\"");
$this->configfieldsets->add('component', Indent::_(3) . "label=\"" . $lang
. "_REPLYNAME_LABEL\"");
$this->configfieldsets->add('component', Indent::_(3) . "size=\"60\"");
$this->configfieldsets->add('component', Indent::_(3) . "maxlength=\"150\"");
$this->configfieldsets->add('component', Indent::_(3) . "description=\""
. $lang . "_REPLYNAME_DESCRIPTION\"");
$this->configfieldsets->add('component', Indent::_(3) . "class=\"text_area\"");
$this->configfieldsets->add('component', Indent::_(3) . "filter=\"STRING\"");
$this->configfieldsets->add('component', Indent::_(3)
. "message=\"Error! Please add some name here.\"");
$this->configfieldsets->add('component', Indent::_(3) . "hint=\"" . $lang
. "_REPLYNAME_HINT\"");
$this->configfieldsets->add('component', Indent::_(3)
. "showon=\"mailer:smtp,sendmail,default\"");
$this->configfieldsets->add('component', Indent::_(2) . "/>");
$this->configfieldsets->add('component', Indent::_(2) . "<!--"
. Line::_(__Line__, __Class__)
. " Sendmail Field. Type: Text. (joomla) -->");
$this->configfieldsets->add('component', Indent::_(2) . "<field");
$this->configfieldsets->add('component', Indent::_(3) . "type=\"text\"");
$this->configfieldsets->add('component', Indent::_(3) . "name=\"sendmail\"");
$this->configfieldsets->add('component', Indent::_(3) . "label=\"" . $lang
. "_SENDMAIL_LABEL\"");
$this->configfieldsets->add('component', Indent::_(3) . "size=\"60\"");
$this->configfieldsets->add('component', Indent::_(3) . "maxlength=\"150\"");
$this->configfieldsets->add('component', Indent::_(3) . "description=\""
. $lang . "_SENDMAIL_DESCRIPTION\"");
$this->configfieldsets->add('component', Indent::_(3) . "class=\"text_area\"");
$this->configfieldsets->add('component', Indent::_(3) . "required=\"false\"");
$this->configfieldsets->add('component', Indent::_(3) . "filter=\"PATH\"");
$this->configfieldsets->add('component', Indent::_(3)
. "message=\"Error! Please add path to you local sendmail here.\"");
$this->configfieldsets->add('component', Indent::_(3) . "hint=\"" . $lang
. "_SENDMAIL_HINT\"");
$this->configfieldsets->add('component', Indent::_(3)
. "showon=\"mailer:sendmail\"");
$this->configfieldsets->add('component', Indent::_(2) . "/>");
$this->configfieldsets->add('component', Indent::_(2) . "<!--"
. Line::_(__Line__, __Class__)
. " Smtpauth Field. Type: Radio. (joomla) -->");
$this->configfieldsets->add('component', Indent::_(2) . "<field");
$this->configfieldsets->add('component', Indent::_(3) . "type=\"radio\"");
$this->configfieldsets->add('component', Indent::_(3) . "name=\"smtpauth\"");
$this->configfieldsets->add('component', Indent::_(3) . "label=\"" . $lang
. "_SMTPAUTH_LABEL\"");
$this->configfieldsets->add('component', Indent::_(3) . "description=\""
. $lang . "_SMTPAUTH_DESCRIPTION\"");
$this->configfieldsets->add('component', Indent::_(3)
. "class=\"btn-group btn-group-yesno\"");
$this->configfieldsets->add('component', Indent::_(3) . "default=\"0\"");
$this->configfieldsets->add('component', Indent::_(3)
. "showon=\"mailer:smtp\">");
$this->configfieldsets->add('component', Indent::_(3) . "<!--"
. Line::_(__Line__, __Class__) . " Option Set. -->");
$this->configfieldsets->add('component', Indent::_(3)
. "<option value=\"1\">");
$this->configfieldsets->add('component', Indent::_(4) . $lang
. "_YES</option>");
$this->configfieldsets->add('component', Indent::_(3)
. "<option value=\"0\">");
$this->configfieldsets->add('component', Indent::_(4) . $lang
. "_NO</option>");
$this->configfieldsets->add('component', Indent::_(2) . "</field>");
$this->configfieldsets->add('component', Indent::_(2) . "<!--"
. Line::_(__Line__, __Class__)
. " Smtpsecure Field. Type: List. (joomla) -->");
$this->configfieldsets->add('component', Indent::_(2) . "<field");
$this->configfieldsets->add('component', Indent::_(3) . "type=\"list\"");
$this->configfieldsets->add('component', Indent::_(3) . "name=\"smtpsecure\"");
$this->configfieldsets->add('component', Indent::_(3) . "label=\"" . $lang
. "_SMTPSECURE_LABEL\"");
$this->configfieldsets->add('component', Indent::_(3) . "description=\""
. $lang . "_SMTPSECURE_DESCRIPTION\"");
$this->configfieldsets->add('component', Indent::_(3)
. "class=\"list_class\"");
$this->configfieldsets->add('component', Indent::_(3) . "multiple=\"false\"");
$this->configfieldsets->add('component', Indent::_(3) . "filter=\"WORD\"");
$this->configfieldsets->add('component', Indent::_(3) . "default=\"none\"");
$this->configfieldsets->add('component', Indent::_(3)
. "showon=\"mailer:smtp\">");
$this->configfieldsets->add('component', Indent::_(3) . "<!--"
. Line::_(__Line__, __Class__) . " Option Set. -->");
$this->configfieldsets->add('component', Indent::_(3)
. "<option value=\"none\">");
$this->configfieldsets->add('component', Indent::_(4) . $lang
. "_NONE</option>");
$this->configfieldsets->add('component', Indent::_(3)
. "<option value=\"ssl\">");
$this->configfieldsets->add('component', Indent::_(4) . $lang
. "_SSL</option>");
$this->configfieldsets->add('component', Indent::_(3)
. "<option value=\"tls\">");
$this->configfieldsets->add('component', Indent::_(4) . $lang
. "_TLS</option>");
$this->configfieldsets->add('component', Indent::_(2) . "</field>");
$this->configfieldsets->add('component', Indent::_(2) . "<!--"
. Line::_(__Line__, __Class__)
. " Smtpport Field. Type: Text. (joomla) -->");
$this->configfieldsets->add('component', Indent::_(2) . "<field");
$this->configfieldsets->add('component', Indent::_(3) . "type=\"text\"");
$this->configfieldsets->add('component', Indent::_(3) . "name=\"smtpport\"");
$this->configfieldsets->add('component', Indent::_(3) . "label=\"" . $lang
. "_SMTPPORT_LABEL\"");
$this->configfieldsets->add('component', Indent::_(3) . "size=\"60\"");
$this->configfieldsets->add('component', Indent::_(3) . "maxlength=\"150\"");
$this->configfieldsets->add('component', Indent::_(3) . "default=\"25\"");
$this->configfieldsets->add('component', Indent::_(3) . "description=\""
. $lang . "_SMTPPORT_DESCRIPTION\"");
$this->configfieldsets->add('component', Indent::_(3) . "class=\"text_area\"");
$this->configfieldsets->add('component', Indent::_(3) . "filter=\"INT\"");
$this->configfieldsets->add('component', Indent::_(3)
. "message=\"Error! Please add the port number of your SMTP server here.\"");
$this->configfieldsets->add('component', Indent::_(3) . "hint=\"" . $lang
. "_SMTPPORT_HINT\"");
$this->configfieldsets->add('component', Indent::_(3)
. "showon=\"mailer:smtp\"");
$this->configfieldsets->add('component', Indent::_(2) . "/>");
$this->configfieldsets->add('component', Indent::_(2) . "<!--"
. Line::_(__Line__, __Class__)
. " Smtpuser Field. Type: Text. (joomla) -->");
$this->configfieldsets->add('component', Indent::_(2) . "<field");
$this->configfieldsets->add('component', Indent::_(3) . "type=\"text\"");
$this->configfieldsets->add('component', Indent::_(3) . "name=\"smtpuser\"");
$this->configfieldsets->add('component', Indent::_(3) . "label=\"" . $lang
. "_SMTPUSER_LABEL\"");
$this->configfieldsets->add('component', Indent::_(3) . "size=\"60\"");
$this->configfieldsets->add('component', Indent::_(3) . "maxlength=\"150\"");
$this->configfieldsets->add('component', Indent::_(3) . "description=\""
. $lang . "_SMTPUSER_DESCRIPTION\"");
$this->configfieldsets->add('component', Indent::_(3) . "class=\"text_area\"");
$this->configfieldsets->add('component', Indent::_(3) . "filter=\"STRING\"");
$this->configfieldsets->add('component', Indent::_(3)
. "message=\"Error! Please add the username for SMTP server here.\"");
$this->configfieldsets->add('component', Indent::_(3) . "hint=\"" . $lang
. "_SMTPUSER_HINT\"");
$this->configfieldsets->add('component', Indent::_(3)
. "showon=\"mailer:smtp\"");
$this->configfieldsets->add('component', Indent::_(2) . "/>");
$this->configfieldsets->add('component', Indent::_(2) . "<!--"
. Line::_(__Line__, __Class__)
. " Smtppass Field. Type: Password. (joomla) -->");
$this->configfieldsets->add('component', Indent::_(2) . "<field");
$this->configfieldsets->add('component', Indent::_(3) . "type=\"password\"");
$this->configfieldsets->add('component', Indent::_(3) . "name=\"smtppass\"");
$this->configfieldsets->add('component', Indent::_(3) . "label=\"" . $lang
. "_SMTPPASS_LABEL\"");
$this->configfieldsets->add('component', Indent::_(3) . "size=\"60\"");
$this->configfieldsets->add('component', Indent::_(3) . "description=\""
. $lang . "_SMTPPASS_DESCRIPTION\"");
$this->configfieldsets->add('component', Indent::_(3) . "class=\"text_area\"");
$this->configfieldsets->add('component', Indent::_(3) . "filter=\"raw\"");
$this->configfieldsets->add('component', Indent::_(3)
. "message=\"Error! Please add the password for SMTP server here.\"");
$this->configfieldsets->add('component', Indent::_(3)
. "showon=\"mailer:smtp\"");
$this->configfieldsets->add('component', Indent::_(2) . "/>");
$this->configfieldsets->add('component', Indent::_(2) . "<!--"
. Line::_(__Line__, __Class__)
. " Smtphost Field. Type: Text. (joomla) -->");
$this->configfieldsets->add('component', Indent::_(2) . "<field");
$this->configfieldsets->add('component', Indent::_(3) . "type=\"text\"");
$this->configfieldsets->add('component', Indent::_(3) . "name=\"smtphost\"");
$this->configfieldsets->add('component', Indent::_(3) . "label=\"" . $lang
. "_SMTPHOST_LABEL\"");
$this->configfieldsets->add('component', Indent::_(3) . "size=\"60\"");
$this->configfieldsets->add('component', Indent::_(3) . "maxlength=\"150\"");
$this->configfieldsets->add('component', Indent::_(3)
. "default=\"localhost\"");
$this->configfieldsets->add('component', Indent::_(3) . "description=\""
. $lang . "_SMTPHOST_DESCRIPTION\"");
$this->configfieldsets->add('component', Indent::_(3) . "class=\"text_area\"");
$this->configfieldsets->add('component', Indent::_(3) . "filter=\"STRING\"");
$this->configfieldsets->add('component', Indent::_(3)
. "message=\"Error! Please add the name of the SMTP host here.\"");
$this->configfieldsets->add('component', Indent::_(3) . "hint=\"" . $lang
. "_SMTPHOST_HINT\"");
$this->configfieldsets->add('component', Indent::_(3)
. "showon=\"mailer:smtp\"");
$this->configfieldsets->add('component', Indent::_(2) . "/>");
}
// close that fieldset
$this->configfieldsets->add('component', Indent::_(1) . "</fieldset>");
// start dkim field set
$this->configfieldsets->add('component', Indent::_(1) . "<fieldset");
$this->configfieldsets->add('component', Indent::_(2)
. "name=\"dkim_custom_config\"");
$this->configfieldsets->add('component', Indent::_(2) . "label=\"" . $lang
. "_DKIM\">");
// add custom DKIM fields
if ($this->customfield->isArray('DKIM'))
{
$this->configfieldsets->add('component', implode(
"", $this->customfield->get('DKIM')
));
$this->customfield->remove('DKIM');
}
else
{
$this->language->set(
$this->config->lang_target, $lang . '_DKIM_LABEL', "Enable DKIM"
);
$this->language->set(
$this->config->lang_target, $lang . '_DKIM_DESCRIPTION',
"Set this option to Yes if you want to sign your emails using DKIM."
);
$this->language->set($this->config->lang_target, $lang . '_YES', "Yes");
$this->language->set($this->config->lang_target, $lang . '_NO', "No");
$this->language->set(
$this->config->lang_target, $lang . '_DKIM_DOMAIN_LABEL', "Domain"
);
$this->language->set(
$this->config->lang_target, $lang . '_DKIM_DOMAIN_DESCRIPTION',
"Set the domain. Eg. domain.com"
);
$this->language->set(
$this->config->lang_target, $lang . '_DKIM_DOMAIN_HINT', "domain.com"
);
$this->language->set(
$this->config->lang_target, $lang . '_DKIM_SELECTOR_LABEL', "Selector"
);
$this->language->set(
$this->config->lang_target, $lang . '_DKIM_SELECTOR_DESCRIPTION',
"Set your DKIM/DNS selector."
);
$this->language->set(
$this->config->lang_target, $lang . '_DKIM_SELECTOR_HINT', "vdm"
);
$this->language->set(
$this->config->lang_target, $lang . '_DKIM_PASSPHRASE_LABEL', "Passphrase"
);
$this->language->set(
$this->config->lang_target, $lang . '_DKIM_PASSPHRASE_DESCRIPTION',
"Enter your passphrase here."
);
$this->language->set(
$this->config->lang_target, $lang . '_DKIM_IDENTITY_LABEL', "Identity"
);
$this->language->set(
$this->config->lang_target, $lang . '_DKIM_IDENTITY_DESCRIPTION',
"Set DKIM identity. This can be in the format of an email address 'you@yourdomain.com' typically used as the source of the email."
);
$this->language->set(
$this->config->lang_target, $lang . '_DKIM_IDENTITY_HINT',
"you@yourdomain.com"
);
$this->language->set(
$this->config->lang_target, $lang . '_DKIM_PRIVATE_KEY_LABEL',
"Private key"
);
$this->language->set(
$this->config->lang_target, $lang . '_DKIM_PRIVATE_KEY_DESCRIPTION',
"set private key"
);
$this->language->set(
$this->config->lang_target, $lang . '_DKIM_PUBLIC_KEY_LABEL', "Public key"
);
$this->language->set(
$this->config->lang_target, $lang . '_DKIM_PUBLIC_KEY_DESCRIPTION',
"set public key"
);
$this->language->set(
$this->config->lang_target, $lang . '_NOTE_DKIM_USE_LABEL',
"Server Configuration"
);
$this->language->set(
$this->config->lang_target, $lang . '_NOTE_DKIM_USE_DESCRIPTION', "<p>Using the below details, you need to configure your DNS by adding a TXT record on your domain: <b><span id='a_dkim_domain'></span></b></p>
<script>
document.addEventListener('DOMContentLoaded', function() {
var jformDkimDomain = document.querySelector('#jform_dkim_domain');
if (!jformDkimDomain.value) {
jformDkimDomain.value = window.location.hostname;
}
document.querySelector('#jform_dkim_key').addEventListener('click', function() {
this.select();
});
document.querySelector('#jform_dkim_value').addEventListener('click', function() {
this.select();
});
vdm_dkim();
});
function vdm_dkim() {
var jformDkimDomain = document.querySelector('#jform_dkim_domain');
document.querySelector('#a_dkim_domain').textContent = jformDkimDomain.value;
var jformDkimKey = document.querySelector('#jform_dkim_key');
jformDkimKey.value = document.querySelector('#jform_dkim_selector').value + '._domainkey';
var jformDkimPublicKey = document.querySelector('#jform_dkim_public_key').value;
var jformDkimValue = document.querySelector('#jform_dkim_value');
if (!jformDkimPublicKey) {
jformDkimValue.value = 'v=DKIM1;k=rsa;g=*;s=email;h=sha1;t=s;p=PUBLICKEY';
} else {
jformDkimValue.value = 'v=DKIM1;k=rsa;g=*;s=email;h=sha1;t=s;p=' + jformDkimPublicKey;
}
}
</script>"
);
$this->language->set(
$this->config->lang_target, $lang . '_DKIM_KEY_LABEL', "Key"
);
$this->language->set(
$this->config->lang_target, $lang . '_DKIM_KEY_DESCRIPTION',
"This is the KEY to use in the DNS record."
);
$this->language->set(
$this->config->lang_target, $lang . '_DKIM_KEY_HINT', "vdm._domainkey"
);
$this->language->set(
$this->config->lang_target, $lang . '_DKIM_VALUE_LABEL', "Value"
);
$this->language->set(
$this->config->lang_target, $lang . '_DKIM_VALUE_DESCRIPTION',
"This is the TXT value to use in the DNS. Replace the PUBLICKEY with your public key."
);
$this->language->set(
$this->config->lang_target, $lang . '_DKIM_VALUE_HINT',
"v=DKIM1;k=rsa;g=*;s=email;h=sha1;t=s;p=PUBLICKEY"
);
$this->configfieldsets->add('component', PHP_EOL . Indent::_(2) . "<!--"
. Line::_(__Line__, __Class__)
. " Dkim Field. Type: Radio. (joomla) -->");
$this->configfieldsets->add('component', Indent::_(2) . "<field");
$this->configfieldsets->add('component', Indent::_(3) . "type=\"radio\"");
$this->configfieldsets->add('component', Indent::_(3) . "name=\"dkim\"");
$this->configfieldsets->add('component', Indent::_(3) . "label=\"" . $lang
. "_DKIM_LABEL\"");
$this->configfieldsets->add('component', Indent::_(3) . "description=\""
. $lang . "_DKIM_DESCRIPTION\"");
$this->configfieldsets->add('component', Indent::_(3)
. "class=\"btn-group btn-group-yesno\"");
$this->configfieldsets->add('component', Indent::_(3) . "default=\"0\"");
$this->configfieldsets->add('component', Indent::_(3) . "required=\"true\">");
$this->configfieldsets->add('component', Indent::_(3) . "<!--"
. Line::_(__Line__, __Class__) . " Option Set. -->");
$this->configfieldsets->add('component', Indent::_(3)
. "<option value=\"1\">");
$this->configfieldsets->add('component', Indent::_(4) . $lang
. "_YES</option>");
$this->configfieldsets->add('component', Indent::_(3)
. "<option value=\"0\">");
$this->configfieldsets->add('component', Indent::_(4) . $lang
. "_NO</option>");
$this->configfieldsets->add('component', Indent::_(2) . "</field>");
$this->configfieldsets->add('component', Indent::_(2) . "<!--"
. Line::_(__Line__, __Class__)
. " Dkim_domain Field. Type: Text. (joomla) -->");
$this->configfieldsets->add('component', Indent::_(2) . "<field");
$this->configfieldsets->add('component', Indent::_(3) . "type=\"text\"");
$this->configfieldsets->add('component', Indent::_(3)
. "name=\"dkim_domain\"");
$this->configfieldsets->add('component', Indent::_(3) . "label=\"" . $lang
. "_DKIM_DOMAIN_LABEL\"");
$this->configfieldsets->add('component', Indent::_(3) . "size=\"60\"");
$this->configfieldsets->add('component', Indent::_(3) . "maxlength=\"150\"");
$this->configfieldsets->add('component', Indent::_(3) . "description=\""
. $lang . "_DKIM_DOMAIN_DESCRIPTION\"");
$this->configfieldsets->add('component', Indent::_(3) . "class=\"text_area\"");
$this->configfieldsets->add('component', Indent::_(3) . "filter=\"STRING\"");
$this->configfieldsets->add('component', Indent::_(3)
. "message=\"Error! Please add DKIM Domain here.\"");
$this->configfieldsets->add('component', Indent::_(3) . "hint=\"" . $lang
. "_DKIM_DOMAIN_HINT\"");
$this->configfieldsets->add('component', Indent::_(3) . "showon=\"dkim:1\"");
$this->configfieldsets->add('component', Indent::_(3)
. "onchange=\"vdm_dkim();\"");
$this->configfieldsets->add('component', Indent::_(2) . "/>");
$this->configfieldsets->add('component', Indent::_(2) . "<!--"
. Line::_(__Line__, __Class__)
. " Dkim_selector Field. Type: Text. (joomla) -->");
$this->configfieldsets->add('component', Indent::_(2) . "<field");
$this->configfieldsets->add('component', Indent::_(3) . "type=\"text\"");
$this->configfieldsets->add('component', Indent::_(3)
. "name=\"dkim_selector\"");
$this->configfieldsets->add('component', Indent::_(3) . "label=\"" . $lang
. "_DKIM_SELECTOR_LABEL\"");
$this->configfieldsets->add('component', Indent::_(3) . "size=\"60\"");
$this->configfieldsets->add('component', Indent::_(3) . "maxlength=\"150\"");
$this->configfieldsets->add('component', Indent::_(3) . "default=\"vdm\"");
$this->configfieldsets->add('component', Indent::_(3) . "description=\""
. $lang . "_DKIM_SELECTOR_DESCRIPTION\"");
$this->configfieldsets->add('component', Indent::_(3) . "class=\"text_area\"");
$this->configfieldsets->add('component', Indent::_(3) . "filter=\"STRING\"");
$this->configfieldsets->add('component', Indent::_(3)
. "message=\"Error! Please add DKIM/DNS selector here.\"");
$this->configfieldsets->add('component', Indent::_(3) . "hint=\"" . $lang
. "_DKIM_SELECTOR_HINT\"");
$this->configfieldsets->add('component', Indent::_(3) . "showon=\"dkim:1\"");
$this->configfieldsets->add('component', Indent::_(3)
. "onchange=\"vdm_dkim();\"");
$this->configfieldsets->add('component', Indent::_(2) . "/>");
$this->configfieldsets->add('component', Indent::_(2) . "<!--"
. Line::_(__Line__, __Class__)
. " Dkim_passphrase Field. Type: Password. (joomla) -->");
$this->configfieldsets->add('component', Indent::_(2) . "<field");
$this->configfieldsets->add('component', Indent::_(3) . "type=\"password\"");
$this->configfieldsets->add('component', Indent::_(3)
. "name=\"dkim_passphrase\"");
$this->configfieldsets->add('component', Indent::_(3) . "label=\"" . $lang
. "_DKIM_PASSPHRASE_LABEL\"");
$this->configfieldsets->add('component', Indent::_(3) . "size=\"60\"");
$this->configfieldsets->add('component', Indent::_(3) . "description=\""
. $lang . "_DKIM_PASSPHRASE_DESCRIPTION\"");
$this->configfieldsets->add('component', Indent::_(3) . "class=\"text_area\"");
$this->configfieldsets->add('component', Indent::_(3) . "filter=\"raw\"");
$this->configfieldsets->add('component', Indent::_(3)
. "message=\"Error! Please add passphrase here.\"");
$this->configfieldsets->add('component', Indent::_(3) . "showon=\"dkim:1\"");
$this->configfieldsets->add('component', Indent::_(2) . "/>");
$this->configfieldsets->add('component', Indent::_(2) . "<!--"
. Line::_(__Line__, __Class__)
. " Dkim_identity Field. Type: Text. (joomla) -->");
$this->configfieldsets->add('component', Indent::_(2) . "<field");
$this->configfieldsets->add('component', Indent::_(3) . "type=\"text\"");
$this->configfieldsets->add('component', Indent::_(3)
. "name=\"dkim_identity\"");
$this->configfieldsets->add('component', Indent::_(3) . "label=\"" . $lang
. "_DKIM_IDENTITY_LABEL\"");
$this->configfieldsets->add('component', Indent::_(3) . "size=\"60\"");
$this->configfieldsets->add('component', Indent::_(3) . "maxlength=\"150\"");
$this->configfieldsets->add('component', Indent::_(3) . "description=\""
. $lang . "_DKIM_IDENTITY_DESCRIPTION\"");
$this->configfieldsets->add('component', Indent::_(3) . "class=\"text_area\"");
$this->configfieldsets->add('component', Indent::_(3) . "filter=\"raw\"");
$this->configfieldsets->add('component', Indent::_(3)
. "message=\"Error! Please add DKIM Identity here.\"");
$this->configfieldsets->add('component', Indent::_(3) . "hint=\"" . $lang
. "_DKIM_IDENTITY_HINT\"");
$this->configfieldsets->add('component', Indent::_(3) . "showon=\"dkim:1\"");
$this->configfieldsets->add('component', Indent::_(2) . "/>");
$this->configfieldsets->add('component', Indent::_(2) . "<!--"
. Line::_(__Line__, __Class__)
. " Dkim_private_key Field. Type: Textarea. (joomla) -->");
$this->configfieldsets->add('component', Indent::_(2) . "<field");
$this->configfieldsets->add('component', Indent::_(3) . "type=\"textarea\"");
$this->configfieldsets->add('component', Indent::_(3)
. "name=\"dkim_private_key\"");
$this->configfieldsets->add('component', Indent::_(3) . "label=\"" . $lang
. "_DKIM_PRIVATE_KEY_LABEL\"");
$this->configfieldsets->add('component', Indent::_(3) . "rows=\"15\"");
$this->configfieldsets->add('component', Indent::_(3) . "cols=\"5\"");
$this->configfieldsets->add('component', Indent::_(3) . "description=\""
. $lang . "_DKIM_PRIVATE_KEY_DESCRIPTION\"");
$this->configfieldsets->add('component', Indent::_(3)
. "class=\"input-xxlarge span12\"");
$this->configfieldsets->add('component', Indent::_(3) . "showon=\"dkim:1\"");
$this->configfieldsets->add('component', Indent::_(2) . "/>");
$this->configfieldsets->add('component', Indent::_(2) . "<!--"
. Line::_(__Line__, __Class__)
. " Dkim_public_key Field. Type: Textarea. (joomla) -->");
$this->configfieldsets->add('component', Indent::_(2) . "<field");
$this->configfieldsets->add('component', Indent::_(3) . "type=\"textarea\"");
$this->configfieldsets->add('component', Indent::_(3)
. "name=\"dkim_public_key\"");
$this->configfieldsets->add('component', Indent::_(3) . "label=\"" . $lang
. "_DKIM_PUBLIC_KEY_LABEL\"");
$this->configfieldsets->add('component', Indent::_(3) . "rows=\"5\"");
$this->configfieldsets->add('component', Indent::_(3) . "cols=\"5\"");
$this->configfieldsets->add('component', Indent::_(3) . "description=\""
. $lang . "_DKIM_PUBLIC_KEY_DESCRIPTION\"");
$this->configfieldsets->add('component', Indent::_(3)
. "class=\"input-xxlarge span12\"");
$this->configfieldsets->add('component', Indent::_(3) . "showon=\"dkim:1\"");
$this->configfieldsets->add('component', Indent::_(3)
. "onchange=\"vdm_dkim();\"");
$this->configfieldsets->add('component', Indent::_(2) . "/>");
$this->configfieldsets->add('component', Indent::_(2) . "<!--"
. Line::_(__Line__, __Class__)
. " Note_dkim_use Field. Type: Note. A None Database Field. (joomla) -->");
$this->configfieldsets->add('component', Indent::_(2)
. "<field type=\"note\" name=\"note_dkim_use\" label=\""
. $lang . "_NOTE_DKIM_USE_LABEL\" description=\"" . $lang
. "_NOTE_DKIM_USE_DESCRIPTION\" heading=\"h4\" class=\"note_dkim_use\" showon=\"dkim:1\" />");
$this->configfieldsets->add('component', Indent::_(2) . "<!--"
. Line::_(__Line__, __Class__)
. " Dkim_key Field. Type: Text. (joomla) -->");
$this->configfieldsets->add('component', Indent::_(2) . "<field");
$this->configfieldsets->add('component', Indent::_(3) . "type=\"text\"");
$this->configfieldsets->add('component', Indent::_(3) . "name=\"dkim_key\"");
$this->configfieldsets->add('component', Indent::_(3) . "label=\"" . $lang
. "_DKIM_KEY_LABEL\"");
$this->configfieldsets->add('component', Indent::_(3) . "size=\"40\"");
$this->configfieldsets->add('component', Indent::_(3) . "maxlength=\"150\"");
$this->configfieldsets->add('component', Indent::_(3) . "description=\""
. $lang . "_DKIM_KEY_DESCRIPTION\"");
$this->configfieldsets->add('component', Indent::_(3) . "class=\"text_area\"");
$this->configfieldsets->add('component', Indent::_(3) . "filter=\"STRING\"");
$this->configfieldsets->add('component', Indent::_(3)
. "message=\"Error! Please add KEY here.\"");
$this->configfieldsets->add('component', Indent::_(3) . "hint=\"" . $lang
. "_DKIM_KEY_HINT\"");
$this->configfieldsets->add('component', Indent::_(3) . "showon=\"dkim:1\"");
$this->configfieldsets->add('component', Indent::_(2) . "/>");
$this->configfieldsets->add('component', Indent::_(2) . "<!--"
. Line::_(__Line__, __Class__)
. " Dkim_value Field. Type: Text. (joomla) -->");
$this->configfieldsets->add('component', Indent::_(2) . "<field");
$this->configfieldsets->add('component', Indent::_(3) . "type=\"text\"");
$this->configfieldsets->add('component', Indent::_(3) . "name=\"dkim_value\"");
$this->configfieldsets->add('component', Indent::_(3) . "label=\"" . $lang
. "_DKIM_VALUE_LABEL\"");
$this->configfieldsets->add('component', Indent::_(3) . "size=\"80\"");
$this->configfieldsets->add('component', Indent::_(3) . "maxlength=\"350\"");
$this->configfieldsets->add('component', Indent::_(3) . "description=\""
. $lang . "_DKIM_VALUE_DESCRIPTION\"");
$this->configfieldsets->add('component', Indent::_(3) . "class=\"text_area\"");
$this->configfieldsets->add('component', Indent::_(3) . "filter=\"STRING\"");
$this->configfieldsets->add('component', Indent::_(3)
. "message=\"Error! Please add TXT record here.\"");
$this->configfieldsets->add('component', Indent::_(3) . "hint=\"" . $lang
. "_DKIM_VALUE_HINT\"");
$this->configfieldsets->add('component', Indent::_(3) . "showon=\"dkim:1\"");
$this->configfieldsets->add('component', Indent::_(2) . "/>");
}
// close that fieldset
$this->configfieldsets->add('component', Indent::_(1) . "</fieldset>");
}
}
}

View File

@ -0,0 +1,414 @@
<?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\Creator;
use VDM\Joomla\Componentbuilder\Compiler\Config;
use VDM\Joomla\Componentbuilder\Compiler\Language;
use VDM\Joomla\Componentbuilder\Compiler\Component;
use VDM\Joomla\Componentbuilder\Compiler\Builder\ConfigFieldsets;
use VDM\Joomla\Componentbuilder\Compiler\Builder\ConfigFieldsetsCustomfield as Customfield;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent;
/**
* Config Fieldsets Encryption Creator Class
*
* @since 3.2.0
*/
final class ConfigFieldsetsEncryption
{
/**
* The Config Class.
*
* @var Config
* @since 3.2.0
*/
protected Config $config;
/**
* The Language Class.
*
* @var Language
* @since 3.2.0
*/
protected Language $language;
/**
* The Component Class.
*
* @var Component
* @since 3.2.0
*/
protected Component $component;
/**
* The ConfigFieldsets Class.
*
* @var ConfigFieldsets
* @since 3.2.0
*/
protected ConfigFieldsets $configfieldsets;
/**
* The ConfigFieldsetsCustomfield Class.
*
* @var Customfield
* @since 3.2.0
*/
protected Customfield $customfield;
/**
* Constructor.
*
* @param Config $config The Config Class.
* @param Language $language The Language Class.
* @param Component $component The Component Class.
* @param ConfigFieldsets $configfieldsets The ConfigFieldsets Class.
* @param Customfield $customfield The ConfigFieldsetsCustomfield Class.
*
* @since 3.2.0
*/
public function __construct(Config $config, Language $language, Component $component,
ConfigFieldsets $configfieldsets,
Customfield $customfield)
{
$this->config = $config;
$this->language = $language;
$this->component = $component;
$this->configfieldsets = $configfieldsets;
$this->customfield = $customfield;
}
/**
* Set Encryption Config Fieldsets
*
* @param string $lang
*
* @since 3.2.0
*/
public function set(string $lang): void
{
// enable the loading of dynamic field sets
$dynamicAddFields = [];
// Add encryption if needed
if ($this->config->basic_encryption
|| $this->config->whmcs_encryption
|| $this->config->medium_encryption
|| $this->component->get('add_license')
|| $this->customfield->isArray('Encryption Settings'))
{
$dynamicAddFields[] = "Encryption Settings";
// start building field set for encryption functions
$this->configfieldsets->add('component', Indent::_(1) . "<fieldset");
$this->configfieldsets->add('component', Indent::_(2)
. 'name="encryption_config"');
$this->configfieldsets->add('component', Indent::_(2) . 'label="' . $lang
. '_ENCRYPTION_LABEL"');
$this->configfieldsets->add('component', Indent::_(2) . 'description="' . $lang
. '_ENCRYPTION_DESC">');
// set tab lang
if (($this->config->basic_encryption
|| $this->config->medium_encryption
|| $this->config->whmcs_encryption)
&& $this->component->get('add_license')
&& $this->component->get('license_type', 0) == 3)
{
$this->language->set(
$this->config->lang_target, $lang . '_ENCRYPTION_LABEL',
"License & Encryption Settings"
);
$this->language->set(
$this->config->lang_target, $lang . '_ENCRYPTION_DESC',
"The license & encryption keys are set here."
);
// add the next dynamic option
$dynamicAddFields[] = "License & Encryption Settings";
}
elseif (($this->config->basic_encryption
|| $this->config->medium_encryption
|| $this->config->whmcs_encryption)
&& $this->component->get('add_license')
&& $this->component->get('license_type', 0) == 2)
{
$this->language->set(
$this->config->lang_target, $lang . '_ENCRYPTION_LABEL',
"Update & Encryption Settings"
);
$this->language->set(
$this->config->lang_target, $lang . '_ENCRYPTION_DESC',
"The update & encryption keys are set here."
);
// add the next dynamic option
$dynamicAddFields[] = "Update & Encryption Settings";
}
elseif ($this->component->get('add_license')
&& $this->component->get('license_type', 0) == 3)
{
$this->language->set(
$this->config->lang_target, $lang . '_ENCRYPTION_LABEL', "License Settings"
);
$this->language->set(
$this->config->lang_target, $lang . '_ENCRYPTION_DESC',
"The license key is set here."
);
// add the next dynamic option
$dynamicAddFields[] = "License Settings";
}
elseif ($this->component->get('add_license')
&& $this->component->get('license_type', 0) == 2)
{
$this->language->set(
$this->config->lang_target, $lang . '_ENCRYPTION_LABEL', "Update Settings"
);
$this->language->set(
$this->config->lang_target, $lang . '_ENCRYPTION_DESC',
"The update key is set here."
);
// add the next dynamic option
$dynamicAddFields[] = "Update Settings";
}
else
{
$this->language->set(
$this->config->lang_target, $lang . '_ENCRYPTION_LABEL',
"Encryption Settings"
);
$this->language->set(
$this->config->lang_target, $lang . '_ENCRYPTION_DESC',
"The encryption key for the field encryption is set here."
);
}
if ($this->config->basic_encryption)
{
// set field lang
$this->language->set(
$this->config->lang_target, $lang . '_BASIC_KEY_LABEL', "Basic Key"
);
$this->language->set(
$this->config->lang_target, $lang . '_BASIC_KEY_DESC',
"Set the basic local key here."
);
$this->language->set(
$this->config->lang_target, $lang . '_BASIC_KEY_NOTE_LABEL',
"Basic Encryption"
);
$this->language->set(
$this->config->lang_target, $lang . '_BASIC_KEY_NOTE_DESC',
"When using the basic encryption please use set a 32 character passphrase.<br />Never change this passphrase once it is set! <b>DATA WILL GET CORRUPTED IF YOU DO!</b>"
);
// set the field
$this->configfieldsets->add('component', Indent::_(2)
. '<field type="note" name="basic_key_note" class="alert alert-info" label="'
. $lang . '_BASIC_KEY_NOTE_LABEL" description="' . $lang
. '_BASIC_KEY_NOTE_DESC" />');
$this->configfieldsets->add('component', Indent::_(2)
. '<field name="basic_key"');
$this->configfieldsets->add('component', Indent::_(3) . 'type="text"');
$this->configfieldsets->add('component', Indent::_(3) . 'label="' . $lang
. '_BASIC_KEY_LABEL"');
$this->configfieldsets->add('component', Indent::_(3) . 'description="'
. $lang . '_BASIC_KEY_DESC"');
$this->configfieldsets->add('component', Indent::_(3) . 'size="60"');
$this->configfieldsets->add('component', Indent::_(3) . 'default=""');
$this->configfieldsets->add('component', Indent::_(2) . "/>");
}
if ($this->config->medium_encryption)
{
// set field lang
$this->language->set(
$this->config->lang_target, $lang . '_MEDIUM_KEY_LABEL',
"Medium Key (Path)"
);
$this->language->set(
$this->config->lang_target, $lang . '_MEDIUM_KEY_DESC',
"Set the full path to where the key file must be stored. Make sure it is behind the root folder of your website, so that it is not public accessible."
);
$this->language->set(
$this->config->lang_target, $lang . '_MEDIUM_KEY_NOTE_LABEL',
"Medium Encryption"
);
$this->language->set(
$this->config->lang_target, $lang . '_MEDIUM_KEY_NOTE_DESC',
"When using the medium encryption option, the system generates its own key and stores it in a file at the folder/path you set here.<br />Never change this key once it is set, or remove the key file! <b>DATA WILL GET CORRUPTED IF YOU DO!</b> Also make sure the full path to where the the key file should be stored, is behind the root folder of your website/system, so that it is not public accessible. Making a backup of this key file over a <b>secure connection</b> is recommended!"
);
// set the field
$this->configfieldsets->add('component', Indent::_(2)
. '<field type="note" name="medium_key_note" class="alert alert-info" label="'
. $lang . '_MEDIUM_KEY_NOTE_LABEL" description="' . $lang
. '_MEDIUM_KEY_NOTE_DESC" />');
$this->configfieldsets->add('component', Indent::_(2)
. '<field name="medium_key_path"');
$this->configfieldsets->add('component', Indent::_(3) . 'type="text"');
$this->configfieldsets->add('component', Indent::_(3) . 'label="' . $lang
. '_MEDIUM_KEY_LABEL"');
$this->configfieldsets->add('component', Indent::_(3) . 'description="'
. $lang . '_MEDIUM_KEY_DESC"');
$this->configfieldsets->add('component', Indent::_(3) . 'size="160"');
$this->configfieldsets->add('component', Indent::_(3) . 'filter="PATH"');
$this->configfieldsets->add('component', Indent::_(3)
. 'hint="/home/user/hiddenfolder123/"');
$this->configfieldsets->add('component', Indent::_(3) . 'default=""');
$this->configfieldsets->add('component', Indent::_(2) . "/>");
// set some error message if the path does not exist
$this->language->set(
$this->config->lang_target, $lang . '_MEDIUM_KEY_PATH_ERROR',
"Medium key path (for encryption of various fields) does not exist, or is not writable. Please check the path and update it in the global option of this component."
);
}
if ($this->config->whmcs_encryption
|| $this->component->get('add_license'))
{
// set field lang label and description
if ($this->component->get('add_license')
&& $this->component->get('license_type', 0) == 3)
{
$this->language->set(
$this->config->lang_target, $lang . '_WHMCS_KEY_LABEL',
$this->component->get('companyname', '') . " License Key"
);
$this->language->set(
$this->config->lang_target, $lang . '_WHMCS_KEY_DESC',
"Add the license key you recieved from "
. $this->component->get('companyname', '') . " here."
);
}
elseif ($this->component->get('add_license')
&& $this->component->get('license_type', 0) == 2)
{
$this->language->set(
$this->config->lang_target, $lang . '_WHMCS_KEY_LABEL',
$this->component->get('companyname', '') . " Update Key"
);
$this->language->set(
$this->config->lang_target, $lang . '_WHMCS_KEY_DESC',
"Add the update key you recieved from "
. $this->component->get('companyname', '') . " here."
);
}
else
{
$this->language->set(
$this->config->lang_target, $lang . '_WHMCS_KEY_LABEL',
$this->component->get('companyname', '') . " Key"
);
$this->language->set(
$this->config->lang_target, $lang . '_WHMCS_KEY_DESC',
"Add the key you recieved from "
. $this->component->get('companyname', '') . " here."
);
}
// adjust the notice based on license
if ($this->component->get('license_type',0) == 3)
{
$this->language->set(
$this->config->lang_target, $lang . '_WHMCS_KEY_NOTE_LABEL',
"Your " . $this->component->get('companyname','')
. " License Key"
);
}
elseif ($this->component->get('license_type',0) == 2)
{
$this->language->set(
$this->config->lang_target, $lang . '_WHMCS_KEY_NOTE_LABEL',
"Your " . $this->component->get('companyname','')
. " Update Key"
);
}
else
{
if ($this->config->whmcs_encryption)
{
$this->language->set(
$this->config->lang_target, $lang . '_WHMCS_KEY_NOTE_LABEL',
"Your " . $this->component->get('companyname','')
. " Field Encryption Key"
);
}
else
{
$this->language->set(
$this->config->lang_target, $lang . '_WHMCS_KEY_NOTE_LABEL',
"Your " . $this->component->get('companyname','') . " Key"
);
}
}
// add the description based on global settings
if ($this->config->whmcs_encryption)
{
$this->language->set(
$this->config->lang_target, $lang . '_WHMCS_KEY_NOTE_DESC',
"You need to get this key from <a href='"
. $this->component->get('whmcs_buy_link','')
. "' target='_blank'>"
. $this->component->get('companyname','')
. "</a>.<br />When using the "
. $this->component->get('companyname','')
. " field encryption you can never change this key once it is set! <b>DATA WILL GET CORRUPTED IF YOU DO!</b>"
);
}
else
{
$this->language->set(
$this->config->lang_target, $lang . '_WHMCS_KEY_NOTE_DESC',
"You need to get this key from <a href='"
. $this->component->get('whmcs_buy_link','')
. "' target='_blank'>"
. $this->component->get('companyname','') . "</a>."
);
}
// set the fields
$this->configfieldsets->add('component', Indent::_(2)
. '<field type="note" name="whmcs_key_note" class="alert alert-info" label="'
. $lang . '_WHMCS_KEY_NOTE_LABEL" description="' . $lang
. '_WHMCS_KEY_NOTE_DESC" />');
$this->configfieldsets->add('component', Indent::_(2)
. '<field name="whmcs_key"'); // We had to change this from license_key & advanced_key to whmcs_key
$this->configfieldsets->add('component', Indent::_(3) . 'type="text"');
$this->configfieldsets->add('component', Indent::_(3) . 'label="' . $lang
. '_WHMCS_KEY_LABEL"');
$this->configfieldsets->add('component', Indent::_(3) . 'description="'
. $lang . '_WHMCS_KEY_DESC"');
$this->configfieldsets->add('component', Indent::_(3) . 'size="60"');
$this->configfieldsets->add('component', Indent::_(3) . 'default=""');
$this->configfieldsets->add('component', Indent::_(2) . "/>");
}
// load the dynamic field sets
foreach ($dynamicAddFields as $dynamicAddField)
{
// add custom Encryption Settings fields
if ($this->customfield->isArray($dynamicAddField))
{
$this->configfieldsets->add('component', implode(
"", $this->customfield->get($dynamicAddField)
));
$this->customfield->remove($dynamicAddField);
}
}
// close that fieldset
$this->configfieldsets->add('component', Indent::_(1) . "</fieldset>");
}
}
}

View File

@ -0,0 +1,634 @@
<?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\Creator;
use VDM\Joomla\Componentbuilder\Compiler\Config;
use VDM\Joomla\Componentbuilder\Compiler\Language;
use VDM\Joomla\Componentbuilder\Compiler\Component;
use VDM\Joomla\Componentbuilder\Compiler\Builder\Contributors;
use VDM\Joomla\Componentbuilder\Compiler\Builder\ConfigFieldsets;
use VDM\Joomla\Componentbuilder\Compiler\Builder\ExtensionsParams;
use VDM\Joomla\Componentbuilder\Compiler\Builder\ConfigFieldsetsCustomfield as Customfield;
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent;
/**
* Config Fieldsets Global Creator Class
*
* @since 3.2.0
*/
final class ConfigFieldsetsGlobal
{
/**
* The Config Class.
*
* @var Config
* @since 3.2.0
*/
protected Config $config;
/**
* The Language Class.
*
* @var Language
* @since 3.2.0
*/
protected Language $language;
/**
* The Component Class.
*
* @var Component
* @since 3.2.0
*/
protected Component $component;
/**
* The Contributors Class.
*
* @var Contributors
* @since 3.2.0
*/
protected Contributors $contributors;
/**
* The ConfigFieldsets Class.
*
* @var ConfigFieldsets
* @since 3.2.0
*/
protected ConfigFieldsets $configfieldsets;
/**
* The ExtensionsParams Class.
*
* @var ExtensionsParams
* @since 3.2.0
*/
protected ExtensionsParams $extensionsparams;
/**
* The ConfigFieldsetsCustomfield Class.
*
* @var Customfield
* @since 3.2.0
*/
protected Customfield $customfield;
/**
* Constructor.
*
* @param Config $config The Config Class.
* @param Language $language The Language Class.
* @param Component $component The Component Class.
* @param Contributors $contributors The Contributors Class.
* @param ConfigFieldsets $configfieldsets The ConfigFieldsets Class.
* @param ExtensionsParams $extensionsparams The ExtensionsParams Class.
* @param Customfield $customfield The ConfigFieldsetsCustomfield Class.
*
* @since 3.2.0
*/
public function __construct(Config $config, Language $language, Component $component,
Contributors $contributors,
ConfigFieldsets $configfieldsets,
ExtensionsParams $extensionsparams,
Customfield $customfield)
{
$this->config = $config;
$this->language = $language;
$this->component = $component;
$this->contributors = $contributors;
$this->configfieldsets = $configfieldsets;
$this->extensionsparams = $extensionsparams;
$this->customfield = $customfield;
}
/**
* Set Global Config Fieldsets
*
* @param string $lang
* @param string $authorName
* @param string $authorEmail
*
* @since 3.2.0
*/
public function set(string $lang, string $authorName, string $authorEmail): void
{
// start building field set for config
$this->configfieldsets->add('component', '<fieldset');
if ($this->config->get('joomla_version', 3) == 3)
{
$this->configfieldsets->add('component', Indent::_(2)
. 'addrulepath="/administrator/components/com_' . $this->config->component_code_name
. '/models/rules"');
$this->configfieldsets->add('component', Indent::_(2)
. 'addfieldpath="/administrator/components/com_' . $this->config->component_code_name
. '/models/fields"');
}
else
{
$this->configfieldsets->add('component', Indent::_(2)
. 'addruleprefix="' . $this->config->namespace_prefix
. '\Component\\' . StringHelper::safe($this->config->component_code_name, 'F')
. '\Administrator\Rule"');
$this->configfieldsets->add('component', Indent::_(2)
. 'addfieldprefix="' . $this->config->namespace_prefix
. '\Component\\' . StringHelper::safe($this->config->component_code_name, 'F')
. '\Administrator\Field"');
}
$this->configfieldsets->add('component', Indent::_(2) . 'name="global_config"');
$this->configfieldsets->add('component', Indent::_(2) . 'label="' . $lang
. '_GLOBAL_LABEL"');
$this->configfieldsets->add('component', Indent::_(2) . 'description="' . $lang
. '_GLOBAL_DESC">');
// setup lang
$this->language->set($this->config->lang_target, $lang . '_GLOBAL_LABEL', "Global");
$this->language->set(
$this->config->lang_target, $lang . '_GLOBAL_DESC', "The Global Parameters"
);
// add auto checkin if required
if ($this->config->get('add_checkin', false))
{
$this->configfieldsets->add('component', Indent::_(2) . "<field");
$this->configfieldsets->add('component', Indent::_(3) . 'name="check_in"');
$this->configfieldsets->add('component', Indent::_(3) . 'type="list"');
$this->configfieldsets->add('component', Indent::_(3) . 'default="0"');
$this->configfieldsets->add('component', Indent::_(3) . 'label="' . $lang
. '_CHECK_TIMER_LABEL"');
$this->configfieldsets->add('component', Indent::_(3) . 'description="' . $lang
. '_CHECK_TIMER_DESC">');
$this->configfieldsets->add('component', Indent::_(3) . '<option');
$this->configfieldsets->add('component', Indent::_(4) . 'value="-5 hours">'
. $lang . '_CHECK_TIMER_OPTION_ONE</option>');
$this->configfieldsets->add('component', Indent::_(3) . '<option');
$this->configfieldsets->add('component', Indent::_(4) . 'value="-12 hours">'
. $lang . '_CHECK_TIMER_OPTION_TWO</option>');
$this->configfieldsets->add('component', Indent::_(3) . '<option');
$this->configfieldsets->add('component', Indent::_(4) . 'value="-1 day">' . $lang
. '_CHECK_TIMER_OPTION_THREE</option>');
$this->configfieldsets->add('component', Indent::_(3) . '<option');
$this->configfieldsets->add('component', Indent::_(4) . 'value="-2 day">' . $lang
. '_CHECK_TIMER_OPTION_FOUR</option>');
$this->configfieldsets->add('component', Indent::_(3) . '<option');
$this->configfieldsets->add('component', Indent::_(4) . 'value="-1 week">' . $lang
. '_CHECK_TIMER_OPTION_FIVE</option>');
$this->configfieldsets->add('component', Indent::_(3) . '<option');
$this->configfieldsets->add('component', Indent::_(4) . 'value="0">' . $lang
. '_CHECK_TIMER_OPTION_SIX</option>');
$this->configfieldsets->add('component', Indent::_(2) . "</field>");
$this->configfieldsets->add('component', Indent::_(2)
. '<field type="spacer" name="spacerAuthor" hr="true" />');
// setup lang
$this->language->set(
$this->config->lang_target, $lang . '_CHECK_TIMER_LABEL', "Check in timer"
);
$this->language->set(
$this->config->lang_target, $lang . '_CHECK_TIMER_DESC',
"Set the intervals for the auto checkin fuction of tables that checks out the items to an user."
);
$this->language->set(
$this->config->lang_target, $lang . '_CHECK_TIMER_OPTION_ONE',
"Every five hours"
);
$this->language->set(
$this->config->lang_target, $lang . '_CHECK_TIMER_OPTION_TWO',
"Every twelve hours"
);
$this->language->set(
$this->config->lang_target, $lang . '_CHECK_TIMER_OPTION_THREE', "Once a day"
);
$this->language->set(
$this->config->lang_target, $lang . '_CHECK_TIMER_OPTION_FOUR',
"Every second day"
);
$this->language->set(
$this->config->lang_target, $lang . '_CHECK_TIMER_OPTION_FIVE', "Once a week"
);
$this->language->set(
$this->config->lang_target, $lang . '_CHECK_TIMER_OPTION_SIX', "Never"
);
// load the Global checkin defautls
$this->extensionsparams->add('component', '"check_in":"-1 day"');
}
// set history control
if ($this->config->get('set_tag_history', false))
{
$this->configfieldsets->add('component', Indent::_(2) . "<field");
$this->configfieldsets->add('component', Indent::_(3) . 'name="save_history"');
$this->configfieldsets->add('component', Indent::_(3) . 'type="radio"');
$this->configfieldsets->add('component', Indent::_(3)
. 'class="btn-group btn-group-yesno"');
$this->configfieldsets->add('component', Indent::_(3) . 'default="1"');
$this->configfieldsets->add('component', Indent::_(3)
. 'label="JGLOBAL_SAVE_HISTORY_OPTIONS_LABEL"');
$this->configfieldsets->add('component', Indent::_(3)
. 'description="JGLOBAL_SAVE_HISTORY_OPTIONS_DESC"');
$this->configfieldsets->add('component', Indent::_(3) . ">");
$this->configfieldsets->add('component', Indent::_(3)
. '<option value="1">JYES</option>');
$this->configfieldsets->add('component', Indent::_(3)
. '<option value="0">JNO</option>');
$this->configfieldsets->add('component', Indent::_(2) . "</field>");
$this->configfieldsets->add('component', Indent::_(2) . "<field");
$this->configfieldsets->add('component', Indent::_(3) . 'name="history_limit"');
$this->configfieldsets->add('component', Indent::_(3) . 'type="text"');
$this->configfieldsets->add('component', Indent::_(3) . 'filter="integer"');
$this->configfieldsets->add('component', Indent::_(3)
. 'label="JGLOBAL_HISTORY_LIMIT_OPTIONS_LABEL"');
$this->configfieldsets->add('component', Indent::_(3)
. 'description="JGLOBAL_HISTORY_LIMIT_OPTIONS_DESC"');
$this->configfieldsets->add('component', Indent::_(3) . 'default="10"');
$this->configfieldsets->add('component', Indent::_(2) . "/>");
$this->configfieldsets->add('component', Indent::_(2)
. '<field type="spacer" name="spacerHistory" hr="true" />');
// load the Global checkin defautls
$this->extensionsparams->add('component', '"save_history":"1","history_limit":"10"');
}
// add custom global fields
if ($this->customfield->isArray('Global'))
{
$this->configfieldsets->add('component', implode(
"", $this->customfield->get('Global')
));
$this->customfield->remove('Global');
}
// set the author details
$this->configfieldsets->add('component', Indent::_(2) . '<field name="autorTitle"');
$this->configfieldsets->add('component', Indent::_(3) . 'type="spacer"');
$this->configfieldsets->add('component', Indent::_(3) . 'label="' . $lang
. '_AUTHOR"');
$this->configfieldsets->add('component', Indent::_(2) . "/>");
$this->configfieldsets->add('component', Indent::_(2) . '<field name="autorName"');
$this->configfieldsets->add('component', Indent::_(3) . 'type="text"');
$this->configfieldsets->add('component', Indent::_(3) . 'label="' . $lang
. '_AUTHOR_NAME_LABEL"');
$this->configfieldsets->add('component', Indent::_(3) . 'description="' . $lang
. '_AUTHOR_NAME_DESC"');
$this->configfieldsets->add('component', Indent::_(3) . 'size="60"');
$this->configfieldsets->add('component', Indent::_(3) . 'default="' . $authorName . '"');
$this->configfieldsets->add('component', Indent::_(3) . 'readonly="true"');
$this->configfieldsets->add('component', Indent::_(3) . 'class="readonly"');
$this->configfieldsets->add('component', Indent::_(2) . "/>");
$this->configfieldsets->add('component', Indent::_(2) . '<field name="autorEmail"');
$this->configfieldsets->add('component', Indent::_(3) . 'type="email"');
$this->configfieldsets->add('component', Indent::_(3) . 'label="' . $lang
. '_AUTHOR_EMAIL_LABEL"');
$this->configfieldsets->add('component', Indent::_(3) . 'description="' . $lang
. '_AUTHOR_EMAIL_DESC"');
$this->configfieldsets->add('component', Indent::_(3) . 'size="60"');
$this->configfieldsets->add('component', Indent::_(3) . 'default="' . $authorEmail . '"');
$this->configfieldsets->add('component', Indent::_(3) . 'readonly="true"');
$this->configfieldsets->add('component', Indent::_(3) . 'class="readonly"');
$this->configfieldsets->add('component', Indent::_(2) . "/>");
// setup lang
$this->language->set($this->config->lang_target, $lang . '_AUTHOR', "Author Info");
$this->language->set(
$this->config->lang_target, $lang . '_AUTHOR_NAME_LABEL', "Author Name"
);
$this->language->set(
$this->config->lang_target, $lang . '_AUTHOR_NAME_DESC',
"The name of the author of this component."
);
$this->language->set(
$this->config->lang_target, $lang . '_AUTHOR_EMAIL_LABEL', "Author Email"
);
$this->language->set(
$this->config->lang_target, $lang . '_AUTHOR_EMAIL_DESC',
"The email address of the author of this component."
);
// set if contributors were added
$langCont = $lang . '_CONTRIBUTOR';
if ($this->config->get('add_contributors', false)
&& $this->component->isArray('contributors'))
{
foreach (
$this->component->get('contributors') as $counter => $contributor
)
{
// make sure we dont use 0
$counter++;
// get the word for this number
$COUNTER = StringHelper::safe($counter, 'U');
// set the dynamic values
$cbTitle = htmlspecialchars(
(string) $contributor['title'], ENT_XML1, 'UTF-8'
);
$cbName = htmlspecialchars(
(string) $contributor['name'], ENT_XML1, 'UTF-8'
);
$cbEmail = htmlspecialchars(
(string) $contributor['email'], ENT_XML1, 'UTF-8'
);
$cbWebsite = htmlspecialchars(
(string) $contributor['website'], ENT_XML1, 'UTF-8'
); // StringHelper::html($contributor['website']);
// load to the $fieldsets
$this->configfieldsets->add('component', Indent::_(2)
. '<field type="spacer" name="spacerContributor' . $counter
. '" hr="true" />');
$this->configfieldsets->add('component', Indent::_(2)
. '<field name="contributor' . $counter . '"');
$this->configfieldsets->add('component', Indent::_(3) . 'type="spacer"');
$this->configfieldsets->add('component', Indent::_(3) . 'class="text"');
$this->configfieldsets->add('component', Indent::_(3) . 'label="' . $langCont
. '_' . $COUNTER . '"');
$this->configfieldsets->add('component', Indent::_(2) . "/>");
$this->configfieldsets->add('component', Indent::_(2)
. '<field name="titleContributor' . $counter . '"');
$this->configfieldsets->add('component', Indent::_(3) . 'type="text"');
$this->configfieldsets->add('component', Indent::_(3) . 'label="' . $langCont
. '_TITLE_LABEL"');
$this->configfieldsets->add('component', Indent::_(3) . 'description="'
. $langCont . '_TITLE_DESC"');
$this->configfieldsets->add('component', Indent::_(3) . 'size="60"');
$this->configfieldsets->add('component', Indent::_(3) . 'default="' . $cbTitle
. '"');
$this->configfieldsets->add('component', Indent::_(2) . "/>");
$this->configfieldsets->add('component', Indent::_(2)
. '<field name="nameContributor' . $counter . '"');
$this->configfieldsets->add('component', Indent::_(3) . 'type="text"');
$this->configfieldsets->add('component', Indent::_(3) . 'label="' . $langCont
. '_NAME_LABEL"');
$this->configfieldsets->add('component', Indent::_(3) . 'description="'
. $langCont . '_NAME_DESC"');
$this->configfieldsets->add('component', Indent::_(3) . 'size="60"');
$this->configfieldsets->add('component', Indent::_(3) . 'default="' . $cbName
. '"');
$this->configfieldsets->add('component', Indent::_(2) . "/>");
$this->configfieldsets->add('component', Indent::_(2)
. '<field name="emailContributor' . $counter . '"');
$this->configfieldsets->add('component', Indent::_(3) . 'type="email"');
$this->configfieldsets->add('component', Indent::_(3) . 'label="' . $langCont
. '_EMAIL_LABEL"');
$this->configfieldsets->add('component', Indent::_(3) . 'description="'
. $langCont . '_EMAIL_DESC"');
$this->configfieldsets->add('component', Indent::_(3) . 'size="60"');
$this->configfieldsets->add('component', Indent::_(3) . 'default="' . $cbEmail
. '"');
$this->configfieldsets->add('component', Indent::_(2) . "/>");
$this->configfieldsets->add('component', Indent::_(2)
. '<field name="linkContributor' . $counter . '"');
$this->configfieldsets->add('component', Indent::_(3) . 'type="url"');
$this->configfieldsets->add('component', Indent::_(3) . 'label="' . $langCont
. '_LINK_LABEL"');
$this->configfieldsets->add('component', Indent::_(3) . 'description="'
. $langCont . '_LINK_DESC"');
$this->configfieldsets->add('component', Indent::_(3) . 'size="60"');
$this->configfieldsets->add('component', Indent::_(3) . 'default="'
. $cbWebsite . '"');
$this->configfieldsets->add('component', Indent::_(2) . "/>");
$this->configfieldsets->add('component', Indent::_(2)
. '<field name="useContributor' . $counter . '"');
$this->configfieldsets->add('component', Indent::_(3) . 'type="list"');
$this->configfieldsets->add('component', Indent::_(3) . 'default="'
. (int) $contributor['use'] . '"');
$this->configfieldsets->add('component', Indent::_(3) . 'label="' . $langCont
. '_USE_LABEL"');
$this->configfieldsets->add('component', Indent::_(3) . 'description="'
. $langCont . '_USE_DESC">');
$this->configfieldsets->add('component', Indent::_(3) . '<option value="0">'
. $langCont . '_USE_NONE</option>');
$this->configfieldsets->add('component', Indent::_(3) . '<option value="1">'
. $langCont . '_USE_EMAIL</option>');
$this->configfieldsets->add('component', Indent::_(3) . '<option value="2">'
. $langCont . '_USE_WWW</option>');
$this->configfieldsets->add('component', Indent::_(2) . "</field>");
$this->configfieldsets->add('component', Indent::_(2)
. '<field name="showContributor' . $counter . '"');
$this->configfieldsets->add('component', Indent::_(3) . 'type="list"');
$this->configfieldsets->add('component', Indent::_(3) . 'default="'
. (int) $contributor['show'] . '"');
$this->configfieldsets->add('component', Indent::_(3) . 'label="' . $langCont
. '_SHOW_LABEL"');
$this->configfieldsets->add('component', Indent::_(3) . 'description="'
. $langCont . '_SHOW_DESC">');
$this->configfieldsets->add('component', Indent::_(3) . '<option value="0">'
. $langCont . '_SHOW_NONE</option>');
$this->configfieldsets->add('component', Indent::_(3) . '<option value="1">'
. $langCont . '_SHOW_BACK</option>');
$this->configfieldsets->add('component', Indent::_(3) . '<option value="2">'
. $langCont . '_SHOW_FRONT</option>');
$this->configfieldsets->add('component', Indent::_(3) . '<option value="3">'
. $langCont . '_SHOW_ALL</option>');
$this->configfieldsets->add('component', Indent::_(2) . "</field>");
// add the contributor
$this->contributors->add('bom', PHP_EOL . Indent::_(1) . "@"
. strtolower((string) $contributor['title']) . Indent::_(2)
. $contributor['name'] . ' <' . $contributor['website']
. '>');
// setup lang
$Counter = StringHelper::safe($counter, 'Ww');
$this->language->set(
$this->config->lang_target, $langCont . '_' . $COUNTER,
"Contributor " . $Counter
);
// load the Global checkin defautls
$this->extensionsparams->add('component', '"titleContributor' . $counter
. '":"' . $cbTitle . '"');
$this->extensionsparams->add('component', '"nameContributor' . $counter
. '":"' . $cbName . '"');
$this->extensionsparams->add('component', '"emailContributor' . $counter
. '":"' . $cbEmail . '"');
$this->extensionsparams->add('component', '"linkContributor' . $counter
. '":"' . $cbWebsite . '"');
$this->extensionsparams->add('component', '"useContributor' . $counter . '":"'
. (int) $contributor['use'] . '"');
$this->extensionsparams->add('component', '"showContributor' . $counter
. '":"' . (int) $contributor['show'] . '"');
}
}
// add more contributors if required
if (1 == $this->component->get('emptycontributors', 0))
{
if (isset($counter))
{
$min = $counter + 1;
unset($counter);
}
else
{
$min = 1;
}
$max = $min + $this->component->get('number') - 1;
$moreContributerFields = range($min, $max, 1);
foreach ($moreContributerFields as $counter)
{
$COUNTER = StringHelper::safe($counter, 'U');
$this->configfieldsets->add('component', Indent::_(2)
. '<field type="spacer" name="spacerContributor' . $counter
. '" hr="true" />');
$this->configfieldsets->add('component', Indent::_(2)
. '<field name="contributor' . $counter . '"');
$this->configfieldsets->add('component', Indent::_(3) . 'type="spacer"');
$this->configfieldsets->add('component', Indent::_(3) . 'class="text"');
$this->configfieldsets->add('component', Indent::_(3) . 'label="' . $langCont
. '_' . $COUNTER . '"');
$this->configfieldsets->add('component', Indent::_(2) . "/>");
$this->configfieldsets->add('component', Indent::_(2)
. '<field name="titleContributor' . $counter . '"');
$this->configfieldsets->add('component', Indent::_(3) . 'type="text"');
$this->configfieldsets->add('component', Indent::_(3) . 'label="' . $langCont
. '_TITLE_LABEL"');
$this->configfieldsets->add('component', Indent::_(3) . 'description="'
. $langCont . '_TITLE_DESC"');
$this->configfieldsets->add('component', Indent::_(3) . 'size="60"');
$this->configfieldsets->add('component', Indent::_(3) . 'default=""');
$this->configfieldsets->add('component', Indent::_(2) . "/>");
$this->configfieldsets->add('component', Indent::_(2)
. '<field name="nameContributor' . $counter . '"');
$this->configfieldsets->add('component', Indent::_(3) . 'type="text"');
$this->configfieldsets->add('component', Indent::_(3) . 'label="' . $langCont
. '_NAME_LABEL"');
$this->configfieldsets->add('component', Indent::_(3) . 'description="'
. $langCont . '_NAME_DESC"');
$this->configfieldsets->add('component', Indent::_(3) . 'size="60"');
$this->configfieldsets->add('component', Indent::_(3) . 'default=""');
$this->configfieldsets->add('component', Indent::_(2) . "/>");
$this->configfieldsets->add('component', Indent::_(2)
. '<field name="emailContributor' . $counter . '"');
$this->configfieldsets->add('component', Indent::_(3) . 'type="email"');
$this->configfieldsets->add('component', Indent::_(3) . 'label="' . $langCont
. '_EMAIL_LABEL"');
$this->configfieldsets->add('component', Indent::_(3) . 'description="'
. $langCont . '_EMAIL_DESC"');
$this->configfieldsets->add('component', Indent::_(3) . 'size="60"');
$this->configfieldsets->add('component', Indent::_(3) . 'default=""');
$this->configfieldsets->add('component', Indent::_(2) . "/>");
$this->configfieldsets->add('component', Indent::_(2)
. '<field name="linkContributor' . $counter . '"');
$this->configfieldsets->add('component', Indent::_(3) . 'type="url"');
$this->configfieldsets->add('component', Indent::_(3) . 'label="' . $langCont
. '_LINK_LABEL"');
$this->configfieldsets->add('component', Indent::_(3) . 'description="'
. $langCont . '_LINK_DESC"');
$this->configfieldsets->add('component', Indent::_(3) . 'size="60"');
$this->configfieldsets->add('component', Indent::_(3) . 'default=""');
$this->configfieldsets->add('component', Indent::_(2) . "/>");
$this->configfieldsets->add('component', Indent::_(2)
. '<field name="useContributor' . $counter . '"');
$this->configfieldsets->add('component', Indent::_(3) . 'type="list"');
$this->configfieldsets->add('component', Indent::_(3) . 'default="0"');
$this->configfieldsets->add('component', Indent::_(3) . 'label="' . $langCont
. '_USE_LABEL"');
$this->configfieldsets->add('component', Indent::_(3) . 'description="'
. $langCont . '_USE_DESC">');
$this->configfieldsets->add('component', Indent::_(3) . '<option value="0">'
. $langCont . '_USE_NONE</option>');
$this->configfieldsets->add('component', Indent::_(3) . '<option value="1">'
. $langCont . '_USE_EMAIL</option>');
$this->configfieldsets->add('component', Indent::_(3) . '<option value="2">'
. $langCont . '_USE_WWW</option>');
$this->configfieldsets->add('component', Indent::_(2) . "</field>");
$this->configfieldsets->add('component', Indent::_(2)
. '<field name="showContributor' . $counter . '"');
$this->configfieldsets->add('component', Indent::_(3) . 'type="list"');
$this->configfieldsets->add('component', Indent::_(3) . 'default="0"');
$this->configfieldsets->add('component', Indent::_(3) . 'label="' . $langCont
. '_SHOW_LABEL"');
$this->configfieldsets->add('component', Indent::_(3) . 'description="'
. $langCont . '_SHOW_DESC">');
$this->configfieldsets->add('component', Indent::_(3) . '<option value="0">'
. $langCont . '_SHOW_NONE</option>');
$this->configfieldsets->add('component', Indent::_(3) . '<option value="1">'
. $langCont . '_SHOW_BACK</option>');
$this->configfieldsets->add('component', Indent::_(3) . '<option value="2">'
. $langCont . '_SHOW_FRONT</option>');
$this->configfieldsets->add('component', Indent::_(3) . '<option value="3">'
. $langCont . '_SHOW_ALL</option>');
$this->configfieldsets->add('component', Indent::_(2) . "</field>");
// setup lang
$Counter = StringHelper::safe($counter, 'Ww');
$this->language->set(
$this->config->lang_target, $langCont . '_' . $COUNTER,
"Contributor " . $Counter
);
}
}
if ($this->config->get('add_contributors', false)
|| $this->component->get('emptycontributors', 0) == 1)
{
// setup lang
$this->language->set(
$this->config->lang_target, $langCont . '_TITLE_LABEL', "Contributor Job Title"
);
$this->language->set(
$this->config->lang_target, $langCont . '_TITLE_DESC',
"The job title that best describes the contributor's relationship to this component."
);
$this->language->set(
$this->config->lang_target, $langCont . '_NAME_LABEL', "Contributor Name"
);
$this->language->set(
$this->config->lang_target, $langCont . '_NAME_DESC',
"The name of this contributor."
);
$this->language->set(
$this->config->lang_target, $langCont . '_EMAIL_LABEL', "Contributor Email"
);
$this->language->set(
$this->config->lang_target, $langCont . '_EMAIL_DESC',
"The email of this contributor."
);
$this->language->set(
$this->config->lang_target, $langCont . '_LINK_LABEL', "Contributor Website"
);
$this->language->set(
$this->config->lang_target, $langCont . '_LINK_DESC',
"The link to this contributor's website."
);
$this->language->set($this->config->lang_target, $langCont . '_USE_LABEL', "Use");
$this->language->set(
$this->config->lang_target, $langCont . '_USE_DESC',
"How should we link to this contributor."
);
$this->language->set($this->config->lang_target, $langCont . '_USE_NONE', "None");
$this->language->set(
$this->config->lang_target, $langCont . '_USE_EMAIL', "Email"
);
$this->language->set(
$this->config->lang_target, $langCont . '_USE_WWW', "Website"
);
$this->language->set(
$this->config->lang_target, $langCont . '_SHOW_LABEL', "Show"
);
$this->language->set(
$this->config->lang_target, $langCont . '_SHOW_DESC',
"Select where you want this contributor's details to show in the component."
);
$this->language->set(
$this->config->lang_target, $langCont . '_SHOW_NONE', "Hide"
);
$this->language->set(
$this->config->lang_target, $langCont . '_SHOW_BACK', "Back-end"
);
$this->language->set(
$this->config->lang_target, $langCont . '_SHOW_FRONT', "Front-end"
);
$this->language->set(
$this->config->lang_target, $langCont . '_SHOW_ALL', "Both Front & Back-end"
);
}
// close that fieldset
$this->configfieldsets->add('component', Indent::_(1) . "</fieldset>");
}
}

View File

@ -0,0 +1,633 @@
<?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\Creator;
use VDM\Joomla\Componentbuilder\Compiler\Config;
use VDM\Joomla\Componentbuilder\Compiler\Language;
use VDM\Joomla\Componentbuilder\Compiler\Builder\ConfigFieldsets;
use VDM\Joomla\Componentbuilder\Compiler\Builder\ConfigFieldsetsCustomfield as Customfield;
use VDM\Joomla\Componentbuilder\Compiler\Builder\ExtensionsParams;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Line;
/**
* Config Fieldsets Googlechart Creator Class
*
* @since 3.2.0
*/
final class ConfigFieldsetsGooglechart
{
/**
* The Config Class.
*
* @var Config
* @since 3.2.0
*/
protected Config $config;
/**
* The Language Class.
*
* @var Language
* @since 3.2.0
*/
protected Language $language;
/**
* The ConfigFieldsets Class.
*
* @var ConfigFieldsets
* @since 3.2.0
*/
protected ConfigFieldsets $configfieldsets;
/**
* The ConfigFieldsetsCustomfield Class.
*
* @var Customfield
* @since 3.2.0
*/
protected Customfield $customfield;
/**
* The ExtensionsParams Class.
*
* @var ExtensionsParams
* @since 3.2.0
*/
protected ExtensionsParams $extensionsparams;
/**
* Constructor.
*
* @param Config $config The Config Class.
* @param Language $language The Language Class.
* @param ConfigFieldsets $configfieldsets The ConfigFieldsets Class.
* @param Customfield $customfield The ConfigFieldsetsCustomfield Class.
* @param ExtensionsParams $extensionsparams The ExtensionsParams Class.
*
* @since 3.2.0
*/
public function __construct(Config $config, Language $language,
ConfigFieldsets $configfieldsets,
Customfield $customfield,
ExtensionsParams $extensionsparams)
{
$this->config = $config;
$this->language = $language;
$this->configfieldsets = $configfieldsets;
$this->customfield = $customfield;
$this->extensionsparams = $extensionsparams;
}
/**
* Set Email Helper Config Fieldsets
*
* @param string $lang
*
* @since 3.2.0
*/
public function set(string $lang): void
{
if ($this->config->get('google_chart', false))
{
$this->configfieldsets->add('component', PHP_EOL . Indent::_(1) . "<fieldset");
$this->configfieldsets->add('component', Indent::_(2)
. "name=\"googlechart_config\"");
$this->configfieldsets->add('component', Indent::_(2) . "label=\"" . $lang
. "_CHART_SETTINGS_LABEL\"");
$this->configfieldsets->add('component', Indent::_(2) . "description=\"" . $lang
. "_CHART_SETTINGS_DESC\">");
$this->configfieldsets->add('component', Indent::_(2));
$this->configfieldsets->add('component', Indent::_(2)
. "<field type=\"note\" name=\"chart_admin_naote\" class=\"alert alert-info\" label=\""
. $lang . "_ADMIN_CHART_NOTE_LABEL\" description=\"" . $lang
. "_ADMIN_CHART_NOTE_DESC\" />");
$this->configfieldsets->add('component', Indent::_(2) . "<!--" . Line::_(
__LINE__,__CLASS__
) . " Admin_chartbackground Field. Type: Color. -->");
$this->configfieldsets->add('component', Indent::_(2) . "<field");
$this->configfieldsets->add('component', Indent::_(3) . "type=\"color\"");
$this->configfieldsets->add('component', Indent::_(3)
. "name=\"admin_chartbackground\"");
$this->configfieldsets->add('component', Indent::_(3) . "default=\"#F7F7FA\"");
$this->configfieldsets->add('component', Indent::_(3) . "label=\"" . $lang
. "_CHARTBACKGROUND_LABEL\"");
$this->configfieldsets->add('component', Indent::_(3) . "description=\"" . $lang
. "_CHARTBACKGROUND_DESC\"");
$this->configfieldsets->add('component', Indent::_(2) . "/>");
$this->configfieldsets->add('component', Indent::_(2) . "<!--" . Line::_(
__LINE__,__CLASS__
) . " Admin_mainwidth Field. Type: Text. -->");
$this->configfieldsets->add('component', Indent::_(2) . "<field");
$this->configfieldsets->add('component', Indent::_(3) . "type=\"text\"");
$this->configfieldsets->add('component', Indent::_(3)
. "name=\"admin_mainwidth\"");
$this->configfieldsets->add('component', Indent::_(3) . "label=\"" . $lang
. "_MAINWIDTH_LABEL\"");
$this->configfieldsets->add('component', Indent::_(3) . "size=\"20\"");
$this->configfieldsets->add('component', Indent::_(3) . "maxlength=\"50\"");
$this->configfieldsets->add('component', Indent::_(3) . "description=\"" . $lang
. "_MAINWIDTH_DESC\"");
$this->configfieldsets->add('component', Indent::_(3) . "class=\"text_area\"");
$this->configfieldsets->add('component', Indent::_(3) . "filter=\"INT\"");
$this->configfieldsets->add('component', Indent::_(3)
. "message=\"Error! Please add area width here.\"");
$this->configfieldsets->add('component', Indent::_(3) . "hint=\"" . $lang
. "_MAINWIDTH_HINT\"");
$this->configfieldsets->add('component', Indent::_(2) . "/>");
$this->configfieldsets->add('component', Indent::_(2) . "<!--" . Line::_(__LINE__,__CLASS__)
. " Spacer_chartadmin_hr_a Field. Type: Spacer. A None Database Field. -->");
$this->configfieldsets->add('component', Indent::_(2)
. "<field type=\"spacer\" name=\"spacer_chartadmin_hr_a\" hr=\"true\" class=\"spacer_chartadmin_hr_a\" />");
$this->configfieldsets->add('component', Indent::_(2) . "<!--" . Line::_(__LINE__,__CLASS__)
. " Admin_chartareatop Field. Type: Text. -->");
$this->configfieldsets->add('component', Indent::_(2) . "<field");
$this->configfieldsets->add('component', Indent::_(3) . "type=\"text\"");
$this->configfieldsets->add('component', Indent::_(3)
. "name=\"admin_chartareatop\"");
$this->configfieldsets->add('component', Indent::_(3) . "label=\"" . $lang
. "_CHARTAREATOP_LABEL\"");
$this->configfieldsets->add('component', Indent::_(3) . "size=\"20\"");
$this->configfieldsets->add('component', Indent::_(3) . "maxlength=\"50\"");
$this->configfieldsets->add('component', Indent::_(3) . "description=\"" . $lang
. "_CHARTAREATOP_DESC\"");
$this->configfieldsets->add('component', Indent::_(3) . "class=\"text_area\"");
$this->configfieldsets->add('component', Indent::_(3) . "filter=\"INT\"");
$this->configfieldsets->add('component', Indent::_(3)
. "message=\"Error! Please add top spacing here.\"");
$this->configfieldsets->add('component', Indent::_(3) . "hint=\"" . $lang
. "_CHARTAREATOP_HINT\"");
$this->configfieldsets->add('component', Indent::_(2) . "/>");
$this->configfieldsets->add('component', Indent::_(2) . "<!--" . Line::_(
__LINE__,__CLASS__
) . " Admin_chartarealeft Field. Type: Text. -->");
$this->configfieldsets->add('component', Indent::_(2) . "<field");
$this->configfieldsets->add('component', Indent::_(3) . "type=\"text\"");
$this->configfieldsets->add('component', Indent::_(3)
. "name=\"admin_chartarealeft\"");
$this->configfieldsets->add('component', Indent::_(3) . "label=\"" . $lang
. "_CHARTAREALEFT_LABEL\"");
$this->configfieldsets->add('component', Indent::_(3) . "size=\"20\"");
$this->configfieldsets->add('component', Indent::_(3) . "maxlength=\"50\"");
$this->configfieldsets->add('component', Indent::_(3) . "description=\"" . $lang
. "_CHARTAREALEFT_DESC\"");
$this->configfieldsets->add('component', Indent::_(3) . "class=\"text_area\"");
$this->configfieldsets->add('component', Indent::_(3) . "filter=\"INT\"");
$this->configfieldsets->add('component', Indent::_(3)
. "message=\"Error! Please add left spacing here.\"");
$this->configfieldsets->add('component', Indent::_(3) . "hint=\"" . $lang
. "_CHARTAREALEFT_HINT\"");
$this->configfieldsets->add('component', Indent::_(2) . "/>");
$this->configfieldsets->add('component', Indent::_(2) . "<!--" . Line::_(
__LINE__,__CLASS__
) . " Admin_chartareawidth Field. Type: Text. -->");
$this->configfieldsets->add('component', Indent::_(2) . "<field");
$this->configfieldsets->add('component', Indent::_(3) . "type=\"text\"");
$this->configfieldsets->add('component', Indent::_(3)
. "name=\"admin_chartareawidth\"");
$this->configfieldsets->add('component', Indent::_(3) . "label=\"" . $lang
. "_CHARTAREAWIDTH_LABEL\"");
$this->configfieldsets->add('component', Indent::_(3) . "size=\"20\"");
$this->configfieldsets->add('component', Indent::_(3) . "maxlength=\"50\"");
$this->configfieldsets->add('component', Indent::_(3) . "description=\"" . $lang
. "_CHARTAREAWIDTH_DESC\"");
$this->configfieldsets->add('component', Indent::_(3) . "class=\"text_area\"");
$this->configfieldsets->add('component', Indent::_(3) . "filter=\"INT\"");
$this->configfieldsets->add('component', Indent::_(3)
. "message=\"Error! Please add chart width here.\"");
$this->configfieldsets->add('component', Indent::_(3) . "hint=\"" . $lang
. "_CHARTAREAWIDTH_HINT\"");
$this->configfieldsets->add('component', Indent::_(2) . "/>");
$this->configfieldsets->add('component', Indent::_(2) . "<!--" . Line::_(
__LINE__,__CLASS__
)
. " Spacer_chartadmin_hr_b Field. Type: Spacer. A None Database Field. -->");
$this->configfieldsets->add('component', Indent::_(2)
. "<field type=\"spacer\" name=\"spacer_chartadmin_hr_b\" hr=\"true\" class=\"spacer_chartadmin_hr_b\" />");
$this->configfieldsets->add('component', Indent::_(2) . "<!--" . Line::_(
__LINE__,__CLASS__
) . " Admin_legendtextstylefontcolor Field. Type: Color. -->");
$this->configfieldsets->add('component', Indent::_(2) . "<field");
$this->configfieldsets->add('component', Indent::_(3) . "type=\"color\"");
$this->configfieldsets->add('component', Indent::_(3)
. "name=\"admin_legendtextstylefontcolor\"");
$this->configfieldsets->add('component', Indent::_(3) . "default=\"#63B1F2\"");
$this->configfieldsets->add('component', Indent::_(3) . "label=\"" . $lang
. "_LEGENDTEXTSTYLEFONTCOLOR_LABEL\"");
$this->configfieldsets->add('component', Indent::_(3) . "description=\"" . $lang
. "_LEGENDTEXTSTYLEFONTCOLOR_DESC\"");
$this->configfieldsets->add('component', Indent::_(2) . "/>");
$this->configfieldsets->add('component', Indent::_(2) . "<!--" . Line::_(
__LINE__,__CLASS__
) . " Admin_legendtextstylefontsize Field. Type: Text. -->");
$this->configfieldsets->add('component', Indent::_(2) . "<field");
$this->configfieldsets->add('component', Indent::_(3) . "type=\"text\"");
$this->configfieldsets->add('component', Indent::_(3)
. "name=\"admin_legendtextstylefontsize\"");
$this->configfieldsets->add('component', Indent::_(3) . "label=\"" . $lang
. "_LEGENDTEXTSTYLEFONTSIZE_LABEL\"");
$this->configfieldsets->add('component', Indent::_(3) . "size=\"20\"");
$this->configfieldsets->add('component', Indent::_(3) . "maxlength=\"50\"");
$this->configfieldsets->add('component', Indent::_(3) . "description=\"" . $lang
. "_LEGENDTEXTSTYLEFONTSIZE_DESC\"");
$this->configfieldsets->add('component', Indent::_(3) . "class=\"text_area\"");
$this->configfieldsets->add('component', Indent::_(3) . "filter=\"INT\"");
$this->configfieldsets->add('component', Indent::_(3)
. "message=\"Error! Please add size of the legend here.\"");
$this->configfieldsets->add('component', Indent::_(3) . "hint=\"" . $lang
. "_LEGENDTEXTSTYLEFONTSIZE_HINT\"");
$this->configfieldsets->add('component', Indent::_(2) . "/>");
$this->configfieldsets->add('component', Indent::_(2) . "<!--" . Line::_(
__LINE__,__CLASS__
)
. " Spacer_chartadmin_hr_c Field. Type: Spacer. A None Database Field. -->");
$this->configfieldsets->add('component', Indent::_(2)
. "<field type=\"spacer\" name=\"spacer_chartadmin_hr_c\" hr=\"true\" class=\"spacer_chartadmin_hr_c\" />");
$this->configfieldsets->add('component', Indent::_(2) . "<!--" . Line::_(
__LINE__,__CLASS__
) . " Admin_vaxistextstylefontcolor Field. Type: Color. -->");
$this->configfieldsets->add('component', Indent::_(2) . "<field");
$this->configfieldsets->add('component', Indent::_(3) . "type=\"color\"");
$this->configfieldsets->add('component', Indent::_(3)
. "name=\"admin_vaxistextstylefontcolor\"");
$this->configfieldsets->add('component', Indent::_(3) . "default=\"#63B1F2\"");
$this->configfieldsets->add('component', Indent::_(3) . "label=\"" . $lang
. "_VAXISTEXTSTYLEFONTCOLOR_LABEL\"");
$this->configfieldsets->add('component', Indent::_(3) . "description=\"" . $lang
. "_VAXISTEXTSTYLEFONTCOLOR_DESC\"");
$this->configfieldsets->add('component', Indent::_(2) . "/>");
$this->configfieldsets->add('component', Indent::_(2) . "<!--" . Line::_(
__LINE__,__CLASS__
)
. " Spacer_chartadmin_hr_d Field. Type: Spacer. A None Database Field. -->");
$this->configfieldsets->add('component', Indent::_(2)
. "<field type=\"spacer\" name=\"spacer_chartadmin_hr_d\" hr=\"true\" class=\"spacer_chartadmin_hr_d\" />");
$this->configfieldsets->add('component', Indent::_(2) . "<!--" . Line::_(
__LINE__,__CLASS__
) . " Admin_haxistextstylefontcolor Field. Type: Color. -->");
$this->configfieldsets->add('component', Indent::_(2) . "<field");
$this->configfieldsets->add('component', Indent::_(3) . "type=\"color\"");
$this->configfieldsets->add('component', Indent::_(3)
. "name=\"admin_haxistextstylefontcolor\"");
$this->configfieldsets->add('component', Indent::_(3) . "default=\"#63B1F2\"");
$this->configfieldsets->add('component', Indent::_(3) . "label=\"" . $lang
. "_HAXISTEXTSTYLEFONTCOLOR_LABEL\"");
$this->configfieldsets->add('component', Indent::_(3) . "description=\"" . $lang
. "_HAXISTEXTSTYLEFONTCOLOR_DESC\"");
$this->configfieldsets->add('component', Indent::_(2) . "/>");
$this->configfieldsets->add('component', Indent::_(2) . "<!--" . Line::_(
__LINE__,__CLASS__
)
. " Admin_haxistitletextstylefontcolor Field. Type: Color. -->");
$this->configfieldsets->add('component', Indent::_(2) . "<field");
$this->configfieldsets->add('component', Indent::_(3) . "type=\"color\"");
$this->configfieldsets->add('component', Indent::_(3)
. "name=\"admin_haxistitletextstylefontcolor\"");
$this->configfieldsets->add('component', Indent::_(3) . "default=\"#63B1F2\"");
$this->configfieldsets->add('component', Indent::_(3) . "label=\"" . $lang
. "_HAXISTITLETEXTSTYLEFONTCOLOR_LABEL\"");
$this->configfieldsets->add('component', Indent::_(3) . "description=\"" . $lang
. "_HAXISTITLETEXTSTYLEFONTCOLOR_DESC\"");
$this->configfieldsets->add('component', Indent::_(2) . "/>");
$this->configfieldsets->add('component', Indent::_(2));
$this->configfieldsets->add('component', Indent::_(2)
. "<field type=\"note\" name=\"chart_site_note\" class=\"alert alert-info\" label=\""
. $lang . "_SITE_CHART_NOTE_LABEL\" description=\"" . $lang
. "_SITE_CHART_NOTE_DESC\" />");
$this->configfieldsets->add('component', Indent::_(2));
$this->configfieldsets->add('component', Indent::_(2) . "<!--" . Line::_(
__LINE__,__CLASS__
) . " Site_chartbackground Field. Type: Color. -->");
$this->configfieldsets->add('component', Indent::_(2) . "<field");
$this->configfieldsets->add('component', Indent::_(3) . "type=\"color\"");
$this->configfieldsets->add('component', Indent::_(3)
. "name=\"site_chartbackground\"");
$this->configfieldsets->add('component', Indent::_(3) . "default=\"#F7F7FA\"");
$this->configfieldsets->add('component', Indent::_(3) . "label=\"" . $lang
. "_CHARTBACKGROUND_LABEL\"");
$this->configfieldsets->add('component', Indent::_(3) . "description=\"" . $lang
. "_CHARTBACKGROUND_DESC\"");
$this->configfieldsets->add('component', Indent::_(2) . "/>");
$this->configfieldsets->add('component', Indent::_(2) . "<!--" . Line::_(
__LINE__,__CLASS__
) . " Site_mainwidth Field. Type: Text. -->");
$this->configfieldsets->add('component', Indent::_(2) . "<field");
$this->configfieldsets->add('component', Indent::_(3) . "type=\"text\"");
$this->configfieldsets->add('component', Indent::_(3) . "name=\"site_mainwidth\"");
$this->configfieldsets->add('component', Indent::_(3) . "label=\"" . $lang
. "_MAINWIDTH_LABEL\"");
$this->configfieldsets->add('component', Indent::_(3) . "size=\"20\"");
$this->configfieldsets->add('component', Indent::_(3) . "maxlength=\"50\"");
$this->configfieldsets->add('component', Indent::_(3) . "description=\"" . $lang
. "_MAINWIDTH_DESC\"");
$this->configfieldsets->add('component', Indent::_(3) . "class=\"text_area\"");
$this->configfieldsets->add('component', Indent::_(3) . "filter=\"INT\"");
$this->configfieldsets->add('component', Indent::_(3)
. "message=\"Error! Please add area width here.\"");
$this->configfieldsets->add('component', Indent::_(3) . "hint=\"" . $lang
. "_MAINWIDTH_HINT\"");
$this->configfieldsets->add('component', Indent::_(2) . "/>");
$this->configfieldsets->add('component', Indent::_(2) . "<!--" . Line::_(
__LINE__,__CLASS__
)
. " Spacer_chartsite_hr_a Field. Type: Spacer. A None Database Field. -->");
$this->configfieldsets->add('component', Indent::_(2)
. "<field type=\"spacer\" name=\"spacer_chartsite_hr_a\" hr=\"true\" class=\"spacer_chartsite_hr_a\" />");
$this->configfieldsets->add('component', Indent::_(2) . "<!--" . Line::_(
__LINE__,__CLASS__
) . " Site_chartareatop Field. Type: Text. -->");
$this->configfieldsets->add('component', Indent::_(2) . "<field");
$this->configfieldsets->add('component', Indent::_(3) . "type=\"text\"");
$this->configfieldsets->add('component', Indent::_(3)
. "name=\"site_chartareatop\"");
$this->configfieldsets->add('component', Indent::_(3) . "label=\"" . $lang
. "_CHARTAREATOP_LABEL\"");
$this->configfieldsets->add('component', Indent::_(3) . "size=\"20\"");
$this->configfieldsets->add('component', Indent::_(3) . "maxlength=\"50\"");
$this->configfieldsets->add('component', Indent::_(3) . "description=\"" . $lang
. "_CHARTAREATOP_DESC\"");
$this->configfieldsets->add('component', Indent::_(3) . "class=\"text_area\"");
$this->configfieldsets->add('component', Indent::_(3) . "filter=\"INT\"");
$this->configfieldsets->add('component', Indent::_(3)
. "message=\"Error! Please add top spacing here.\"");
$this->configfieldsets->add('component', Indent::_(3) . "hint=\"" . $lang
. "_CHARTAREATOP_HINT\"");
$this->configfieldsets->add('component', Indent::_(2) . "/>");
$this->configfieldsets->add('component', Indent::_(2) . "<!--" . Line::_(
__LINE__,__CLASS__
) . " Site_chartarealeft Field. Type: Text. -->");
$this->configfieldsets->add('component', Indent::_(2) . "<field");
$this->configfieldsets->add('component', Indent::_(3) . "type=\"text\"");
$this->configfieldsets->add('component', Indent::_(3)
. "name=\"site_chartarealeft\"");
$this->configfieldsets->add('component', Indent::_(3) . "label=\"" . $lang
. "_CHARTAREALEFT_LABEL\"");
$this->configfieldsets->add('component', Indent::_(3) . "size=\"20\"");
$this->configfieldsets->add('component', Indent::_(3) . "maxlength=\"50\"");
$this->configfieldsets->add('component', Indent::_(3) . "description=\"" . $lang
. "_CHARTAREALEFT_DESC\"");
$this->configfieldsets->add('component', Indent::_(3) . "class=\"text_area\"");
$this->configfieldsets->add('component', Indent::_(3) . "filter=\"INT\"");
$this->configfieldsets->add('component', Indent::_(3)
. "message=\"Error! Please add left spacing here.\"");
$this->configfieldsets->add('component', Indent::_(3) . "hint=\"" . $lang
. "_CHARTAREALEFT_HINT\"");
$this->configfieldsets->add('component', Indent::_(2) . "/>");
$this->configfieldsets->add('component', Indent::_(2) . "<!--" . Line::_(
__LINE__,__CLASS__
) . " Site_chartareawidth Field. Type: Text. -->");
$this->configfieldsets->add('component', Indent::_(2) . "<field");
$this->configfieldsets->add('component', Indent::_(3) . "type=\"text\"");
$this->configfieldsets->add('component', Indent::_(3)
. "name=\"site_chartareawidth\"");
$this->configfieldsets->add('component', Indent::_(3) . "label=\"" . $lang
. "_CHARTAREAWIDTH_LABEL\"");
$this->configfieldsets->add('component', Indent::_(3) . "size=\"20\"");
$this->configfieldsets->add('component', Indent::_(3) . "maxlength=\"50\"");
$this->configfieldsets->add('component', Indent::_(3) . "description=\"" . $lang
. "_CHARTAREAWIDTH_DESC\"");
$this->configfieldsets->add('component', Indent::_(3) . "class=\"text_area\"");
$this->configfieldsets->add('component', Indent::_(3) . "filter=\"INT\"");
$this->configfieldsets->add('component', Indent::_(3)
. "message=\"Error! Please add chart width here.\"");
$this->configfieldsets->add('component', Indent::_(3) . "hint=\"" . $lang
. "_CHARTAREAWIDTH_HINT\"");
$this->configfieldsets->add('component', Indent::_(2) . "/>");
$this->configfieldsets->add('component', Indent::_(2) . "<!--" . Line::_(
__LINE__,__CLASS__
)
. " Spacer_chartsite_hr_b Field. Type: Spacer. A None Database Field. -->");
$this->configfieldsets->add('component', Indent::_(2)
. "<field type=\"spacer\" name=\"spacer_chartsite_hr_b\" hr=\"true\" class=\"spacer_chartsite_hr_b\" />");
$this->configfieldsets->add('component', Indent::_(2) . "<!--" . Line::_(
__LINE__,__CLASS__
) . " Site_legendtextstylefontcolor Field. Type: Color. -->");
$this->configfieldsets->add('component', Indent::_(2) . "<field");
$this->configfieldsets->add('component', Indent::_(3) . "type=\"color\"");
$this->configfieldsets->add('component', Indent::_(3)
. "name=\"site_legendtextstylefontcolor\"");
$this->configfieldsets->add('component', Indent::_(3) . "default=\"#63B1F2\"");
$this->configfieldsets->add('component', Indent::_(3) . "label=\"" . $lang
. "_LEGENDTEXTSTYLEFONTCOLOR_LABEL\"");
$this->configfieldsets->add('component', Indent::_(3) . "description=\"" . $lang
. "_LEGENDTEXTSTYLEFONTCOLOR_DESC\"");
$this->configfieldsets->add('component', Indent::_(2) . "/>");
$this->configfieldsets->add('component', Indent::_(2) . "<!--" . Line::_(
__LINE__,__CLASS__
) . " Site_legendtextstylefontsize Field. Type: Text. -->");
$this->configfieldsets->add('component', Indent::_(2) . "<field");
$this->configfieldsets->add('component', Indent::_(3) . "type=\"text\"");
$this->configfieldsets->add('component', Indent::_(3)
. "name=\"site_legendtextstylefontsize\"");
$this->configfieldsets->add('component', Indent::_(3) . "label=\"" . $lang
. "_LEGENDTEXTSTYLEFONTSIZE_LABEL\"");
$this->configfieldsets->add('component', Indent::_(3) . "size=\"20\"");
$this->configfieldsets->add('component', Indent::_(3) . "maxlength=\"50\"");
$this->configfieldsets->add('component', Indent::_(3) . "description=\"" . $lang
. "_LEGENDTEXTSTYLEFONTSIZE_DESC\"");
$this->configfieldsets->add('component', Indent::_(3) . "class=\"text_area\"");
$this->configfieldsets->add('component', Indent::_(3) . "filter=\"INT\"");
$this->configfieldsets->add('component', Indent::_(3)
. "message=\"Error! Please add size of the legend here.\"");
$this->configfieldsets->add('component', Indent::_(3) . "hint=\"" . $lang
. "_LEGENDTEXTSTYLEFONTSIZE_HINT\"");
$this->configfieldsets->add('component', Indent::_(2) . "/>");
$this->configfieldsets->add('component', Indent::_(2) . "<!--" . Line::_(
__LINE__,__CLASS__
)
. " Spacer_chartsite_hr_c Field. Type: Spacer. A None Database Field. -->");
$this->configfieldsets->add('component', Indent::_(2)
. "<field type=\"spacer\" name=\"spacer_chartsite_hr_c\" hr=\"true\" class=\"spacer_chartsite_hr_c\" />");
$this->configfieldsets->add('component', Indent::_(2) . "<!--" . Line::_(
__LINE__,__CLASS__
) . " Site_vaxistextstylefontcolor Field. Type: Color. -->");
$this->configfieldsets->add('component', Indent::_(2) . "<field");
$this->configfieldsets->add('component', Indent::_(3) . "type=\"color\"");
$this->configfieldsets->add('component', Indent::_(3)
. "name=\"site_vaxistextstylefontcolor\"");
$this->configfieldsets->add('component', Indent::_(3) . "default=\"#63B1F2\"");
$this->configfieldsets->add('component', Indent::_(3) . "label=\"" . $lang
. "_VAXISTEXTSTYLEFONTCOLOR_LABEL\"");
$this->configfieldsets->add('component', Indent::_(3) . "description=\"" . $lang
. "_VAXISTEXTSTYLEFONTCOLOR_DESC\"");
$this->configfieldsets->add('component', Indent::_(2) . "/>");
$this->configfieldsets->add('component', Indent::_(2) . "<!--" . Line::_(
__LINE__,__CLASS__
)
. " Spacer_chartsite_hr_d Field. Type: Spacer. A None Database Field. -->");
$this->configfieldsets->add('component', Indent::_(2)
. "<field type=\"spacer\" name=\"spacer_chartsite_hr_d\" hr=\"true\" class=\"spacer_chartsite_hr_d\" />");
$this->configfieldsets->add('component', Indent::_(2) . "<!--" . Line::_(
__LINE__,__CLASS__
) . " Site_haxistextstylefontcolor Field. Type: Color. -->");
$this->configfieldsets->add('component', Indent::_(2) . "<field");
$this->configfieldsets->add('component', Indent::_(3) . "type=\"color\"");
$this->configfieldsets->add('component', Indent::_(3)
. "name=\"site_haxistextstylefontcolor\"");
$this->configfieldsets->add('component', Indent::_(3) . "default=\"#63B1F2\"");
$this->configfieldsets->add('component', Indent::_(3) . "label=\"" . $lang
. "_HAXISTEXTSTYLEFONTCOLOR_LABEL\"");
$this->configfieldsets->add('component', Indent::_(3) . "description=\"" . $lang
. "_HAXISTEXTSTYLEFONTCOLOR_DESC\"");
$this->configfieldsets->add('component', Indent::_(2) . "/>");
$this->configfieldsets->add('component', Indent::_(2) . "<!--" . Line::_(
__LINE__,__CLASS__
)
. " Site_haxistitletextstylefontcolor Field. Type: Color. -->");
$this->configfieldsets->add('component', Indent::_(2) . "<field");
$this->configfieldsets->add('component', Indent::_(3) . "type=\"color\"");
$this->configfieldsets->add('component', Indent::_(3)
. "name=\"site_haxistitletextstylefontcolor\"");
$this->configfieldsets->add('component', Indent::_(3) . "default=\"#63B1F2\"");
$this->configfieldsets->add('component', Indent::_(3) . "label=\"" . $lang
. "_HAXISTITLETEXTSTYLEFONTCOLOR_LABEL\"");
$this->configfieldsets->add('component', Indent::_(3) . "description=\"" . $lang
. "_HAXISTITLETEXTSTYLEFONTCOLOR_DESC\"");
$this->configfieldsets->add('component', Indent::_(2) . "/>");
// add custom Encryption Settings fields
if ($this->customfield->isArray('Chart Settings'))
{
$this->configfieldsets->add('component', implode(
"", $this->customfield->get('Chart Settings')
));
$this->customfield->remove('Chart Settings');
}
$this->configfieldsets->add('component', Indent::_(1) . "</fieldset>");
// set params defaults
$this->extensionsparams->add('component',
'"admin_chartbackground":"#F7F7FA","admin_mainwidth":"1000","admin_chartareatop":"20","admin_chartarealeft":"20","admin_chartareawidth":"170","admin_legendtextstylefontcolor":"10","admin_legendtextstylefontsize":"20","admin_vaxistextstylefontcolor":"#63B1F2","admin_haxistextstylefontcolor":"#63B1F2","admin_haxistitletextstylefontcolor":"#63B1F2","site_chartbackground":"#F7F7FA","site_mainwidth":"1000","site_chartareatop":"20","site_chartarealeft":"20","site_chartareawidth":"170","site_legendtextstylefontcolor":"10","site_legendtextstylefontsize":"20","site_vaxistextstylefontcolor":"#63B1F2","site_haxistextstylefontcolor":"#63B1F2","site_haxistitletextstylefontcolor":"#63B1F2"'
);
// set field lang
$this->language->set(
$this->config->lang_target, $lang . '_CHART_SETTINGS_LABEL', "Chart Settings"
);
$this->language->set(
$this->config->lang_target, $lang . '_CHART_SETTINGS_DESC',
"The Google Chart Display Settings Are Made Here."
);
$this->language->set(
$this->config->lang_target, $lang . '_ADMIN_CHART_NOTE_LABEL', "Admin Settings"
);
$this->language->set(
$this->config->lang_target, $lang . '_ADMIN_CHART_NOTE_DESC',
"The following settings are used on the back-end of the site called (admin)."
);
$this->language->set(
$this->config->lang_target, $lang . '_SITE_CHART_NOTE_LABEL', "Site Settings"
);
$this->language->set(
$this->config->lang_target, $lang . '_SITE_CHART_NOTE_DESC',
"The following settings are used on the front-end of the site called (site)."
);
$this->language->set(
$this->config->lang_target, $lang . '_CHARTAREALEFT_DESC',
"Set in pixels the spacing from the left of the chart area to the beginning of the chart it self. Please don't add the px sign"
);
$this->language->set(
$this->config->lang_target, $lang . '_CHARTAREALEFT_HINT', "170"
);
$this->language->set(
$this->config->lang_target, $lang . '_CHARTAREALEFT_LABEL', "Left Spacing"
);
$this->language->set(
$this->config->lang_target, $lang . '_CHARTAREATOP_DESC',
"Set in pixels the spacing from the top of the chart area to the beginning of the chart it self. Please don't add the px sign"
);
$this->language->set(
$this->config->lang_target, $lang . '_CHARTAREATOP_HINT', "20"
);
$this->language->set(
$this->config->lang_target, $lang . '_CHARTAREATOP_LABEL', "Top Spacing"
);
$this->language->set(
$this->config->lang_target, $lang . '_CHARTAREAWIDTH_DESC',
"Set in % the width of the chart it self inside the chart area. Please don't add the % sign"
);
$this->language->set(
$this->config->lang_target, $lang . '_CHARTAREAWIDTH_HINT', "60"
);
$this->language->set(
$this->config->lang_target, $lang . '_CHARTAREAWIDTH_LABEL', "Chart Width"
);
$this->language->set(
$this->config->lang_target, $lang . '_CHARTBACKGROUND_DESC',
"Select the chart background color here."
);
$this->language->set(
$this->config->lang_target, $lang . '_CHARTBACKGROUND_LABEL',
"Chart Background"
);
$this->language->set(
$this->config->lang_target, $lang . '_HAXISTEXTSTYLEFONTCOLOR_DESC',
"Select the horizontal axis font color."
);
$this->language->set(
$this->config->lang_target, $lang . '_HAXISTEXTSTYLEFONTCOLOR_LABEL',
"hAxis Font Color"
);
$this->language->set(
$this->config->lang_target, $lang . '_HAXISTITLETEXTSTYLEFONTCOLOR_DESC',
"Select the horizontal axis title's font color."
);
$this->language->set(
$this->config->lang_target, $lang . '_HAXISTITLETEXTSTYLEFONTCOLOR_LABEL',
"hAxis Title Font Color"
);
$this->language->set(
$this->config->lang_target, $lang . '_LEGENDTEXTSTYLEFONTCOLOR_DESC',
"Select the legend font color."
);
$this->language->set(
$this->config->lang_target, $lang . '_LEGENDTEXTSTYLEFONTCOLOR_LABEL',
"Legend Font Color"
);
$this->language->set(
$this->config->lang_target, $lang . '_LEGENDTEXTSTYLEFONTSIZE_DESC',
"Set in pixels the font size of the legend"
);
$this->language->set(
$this->config->lang_target, $lang . '_LEGENDTEXTSTYLEFONTSIZE_HINT', "10"
);
$this->language->set(
$this->config->lang_target, $lang . '_LEGENDTEXTSTYLEFONTSIZE_LABEL',
"Legend Font Size"
);
$this->language->set(
$this->config->lang_target, $lang . '_MAINWIDTH_DESC',
"Set the width of the entire chart area"
);
$this->language->set(
$this->config->lang_target, $lang . '_MAINWIDTH_HINT', "1000"
);
$this->language->set(
$this->config->lang_target, $lang . '_MAINWIDTH_LABEL', "Chart Area Width"
);
$this->language->set(
$this->config->lang_target, $lang . '_VAXISTEXTSTYLEFONTCOLOR_DESC',
"Select the vertical axis font color."
);
$this->language->set(
$this->config->lang_target, $lang . '_VAXISTEXTSTYLEFONTCOLOR_LABEL',
"vAxis Font Color"
);
}
}
}

View File

@ -0,0 +1,163 @@
<?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\Creator;
use VDM\Joomla\Componentbuilder\Compiler\Config;
use VDM\Joomla\Componentbuilder\Compiler\Language;
use VDM\Joomla\Componentbuilder\Compiler\Builder\FieldGroupControl;
use VDM\Joomla\Componentbuilder\Compiler\Builder\ConfigFieldsets;
use VDM\Joomla\Componentbuilder\Compiler\Builder\ExtensionsParams;
use VDM\Joomla\Componentbuilder\Compiler\Builder\ConfigFieldsetsCustomfield as Customfield;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent;
/**
* Config Fieldsets Group Control Creator Class
*
* @since 3.2.0
*/
final class ConfigFieldsetsGroupControl
{
/**
* The Config Class.
*
* @var Config
* @since 3.2.0
*/
protected Config $config;
/**
* The Language Class.
*
* @var Language
* @since 3.2.0
*/
protected Language $language;
/**
* The FieldGroupControl Class.
*
* @var FieldGroupControl
* @since 3.2.0
*/
protected FieldGroupControl $fieldgroupcontrol;
/**
* The ConfigFieldsets Class.
*
* @var ConfigFieldsets
* @since 3.2.0
*/
protected ConfigFieldsets $configfieldsets;
/**
* The ExtensionsParams Class.
*
* @var ExtensionsParams
* @since 3.2.0
*/
protected ExtensionsParams $extensionsparams;
/**
* The ConfigFieldsetsCustomfield Class.
*
* @var Customfield
* @since 3.2.0
*/
protected Customfield $customfield;
/**
* Constructor.
*
* @param Config $config The Config Class.
* @param Language $language The Language Class.
* @param FieldGroupControl $fieldgroupcontrol The FieldGroupControl Class.
* @param ConfigFieldsets $configfieldsets The ConfigFieldsets Class.
* @param ExtensionsParams $extensionsparams The ExtensionsParams Class.
* @param Customfield $customfield The ConfigFieldsetsCustomfield Class.
*
* @since 3.2.0
*/
public function __construct(Config $config, Language $language,
FieldGroupControl $fieldgroupcontrol,
ConfigFieldsets $configfieldsets,
ExtensionsParams $extensionsparams,
Customfield $customfield)
{
$this->config = $config;
$this->language = $language;
$this->fieldgroupcontrol = $fieldgroupcontrol;
$this->configfieldsets = $configfieldsets;
$this->extensionsparams = $extensionsparams;
$this->customfield = $customfield;
}
/**
* Set Group Control Config Fieldsets
*
* @param string $lang
*
* @since 1.0
*/
public function set(string $lang): void
{
// start loading Group control params if needed
if ($this->fieldgroupcontrol->isActive())
{
// start building field set for config
$this->configfieldsets->add('component', Indent::_(1) . "<fieldset");
$this->configfieldsets->add('component', Indent::_(2) . 'name="group_config"');
$this->configfieldsets->add('component', Indent::_(2) . 'label="' . $lang
. '_GROUPS_LABEL"');
$this->configfieldsets->add('component', Indent::_(2) . 'description="' . $lang
. '_GROUPS_DESC">');
// setup lang
$this->language->set(
$this->config->lang_target, $lang . '_GROUPS_LABEL', "Target Groups"
);
$this->language->set(
$this->config->lang_target, $lang . '_GROUPS_DESC',
"The Parameters for the targeted groups are set here."
);
$this->language->set(
$this->config->lang_target, $lang . '_TARGET_GROUP_DESC',
"Set the group/s being targeted by this user type."
);
foreach ($this->fieldgroupcontrol->allActive() as $selector => $label)
{
$this->configfieldsets->add('component', Indent::_(2) . '<field name="'
. $selector . '"');
$this->configfieldsets->add('component', Indent::_(3) . 'type="usergroup"');
$this->configfieldsets->add('component', Indent::_(3) . 'label="' . $label . '"');
$this->configfieldsets->add('component', Indent::_(3) . 'description="'
. $lang . '_TARGET_GROUP_DESC"');
$this->configfieldsets->add('component', Indent::_(3) . 'multiple="true"');
$this->configfieldsets->add('component', Indent::_(2) . "/>");
// set params defaults
$this->extensionsparams->add('component', '"' . $selector . '":["2"]');
}
// add custom Target Groups fields
if ($this->customfield->isArray('Target Groups'))
{
$this->configfieldsets->add('component', implode(
"", $this->customfield->get('Target Groups')
));
$this->customfield->remove('Target Groups');
}
// close that fieldse
$this->configfieldsets->add('component', Indent::_(1) . "</fieldset>");
}
}
}

View File

@ -0,0 +1,225 @@
<?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\Creator;
use VDM\Joomla\Componentbuilder\Compiler\Component;
use VDM\Joomla\Componentbuilder\Compiler\Builder\ConfigFieldsets;
use VDM\Joomla\Componentbuilder\Compiler\Builder\ConfigFieldsetsCustomfield as Customfield;
use VDM\Joomla\Componentbuilder\Compiler\Builder\HasMenuGlobal;
use VDM\Joomla\Componentbuilder\Compiler\Builder\FrontendParams;
use VDM\Joomla\Componentbuilder\Compiler\Creator\Request;
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Utilities\GetHelper;
/**
* Config Fieldsets Site Control Creator Class
*
* @since 3.2.0
*/
final class ConfigFieldsetsSiteControl
{
/**
* The Component Class.
*
* @var Component
* @since 3.2.0
*/
protected Component $component;
/**
* The ConfigFieldsets Class.
*
* @var ConfigFieldsets
* @since 3.2.0
*/
protected ConfigFieldsets $configfieldsets;
/**
* The ConfigFieldsetsCustomfield Class.
*
* @var Customfield
* @since 3.2.0
*/
protected Customfield $customfield;
/**
* The HasMenuGlobal Class.
*
* @var HasMenuGlobal
* @since 3.2.0
*/
protected HasMenuGlobal $hasmenuglobal;
/**
* The FrontendParams Class.
*
* @var FrontendParams
* @since 3.2.0
*/
protected FrontendParams $frontendparams;
/**
* The Request Class.
*
* @var Request
* @since 3.2.0
*/
protected Request $request;
/**
* Constructor.
*
* @param Component $component The Component Class.
* @param ConfigFieldsets $configfieldsets The ConfigFieldsets Class.
* @param Customfield $customfield The ConfigFieldsetsCustomfield Class.
* @param HasMenuGlobal $hasmenuglobal The HasMenuGlobal Class.
* @param FrontendParams $frontendparams The FrontendParams Class.
* @param Request $request The Request Class.
*
* @since 3.2.0
*/
public function __construct(Component $component, ConfigFieldsets $configfieldsets,
Customfield $customfield, HasMenuGlobal $hasmenuglobal,
FrontendParams $frontendparams, Request $request)
{
$this->component = $component;
$this->configfieldsets = $configfieldsets;
$this->customfield = $customfield;
$this->hasmenuglobal = $hasmenuglobal;
$this->frontendparams = $frontendparams;
$this->request = $request;
}
/**
* Set Site Control Config Fieldsets
*
* @param string $lang
*
* @since 3.2.0
*/
public function set(string $lang): void
{
$front_end = [];
// do quick build of front-end views
if ($this->component->isArray('site_views'))
{
// load the names only to link the page params
foreach ($this->component->get('site_views') as $siteView)
{
// now load the view name to the front-end array
$front_end[] = $siteView['settings']->name;
}
}
// add frontend view stuff including menus
if ($this->customfield->isActive())
{
foreach ($this->customfield->allActive() as $tab => $tabFields)
{
$tabCode = StringHelper::safe($tab) . '_custom_config';
$tabUpper = StringHelper::safe($tab, 'U');
$tabLower = StringHelper::safe($tab);
// load the request id setters for menu views
$viewRequest = 'name="' . $tabLower . '_request_id';
foreach ($tabFields as $et => $id_field)
{
if (strpos((string) $id_field, $viewRequest) !== false)
{
$this->request->set(
$tabLower, $id_field, $viewRequest, 'id'
);
$this->customfield->remove("$tab.$et");
unset($tabFields[$et]);
}
elseif (strpos((string) $id_field, '_request_id') !== false)
{
// not loaded to a tab "view" name
$_viewRequest = GetHelper::between(
$id_field, 'name="', '_request_id'
);
$searchIdKe = 'name="' . $_viewRequest
. '_request_id';
$this->request->set(
$_viewRequest, $id_field, $searchIdKe, 'id'
);
$this->customfield->remove("$tab.$et");
unset($tabFields[$et]);
}
}
// load the request catid setters for menu views
$viewRequestC = 'name="' . $tabLower . '_request_catid';
foreach ($tabFields as $ci => $catid_field)
{
if (strpos((string) $catid_field, $viewRequestC) !== false)
{
$this->request->set(
$tabLower, $catid_field, $viewRequestC, 'catid'
);
$this->customfield->remove("$tab.$ci");
unset($tabFields[$ci]);
}
elseif (strpos((string) $catid_field, '_request_catid') !== false)
{
// not loaded to a tab "view" name
$_viewRequestC = GetHelper::between(
$catid_field, 'name="', '_request_catid'
);
$searchCatidKe = 'name="' . $_viewRequestC
. '_request_catid';
$this->request->set(
$_viewRequestC, $catid_field, $searchCatidKe, 'catid'
);
$this->customfield->remove("$tab.$ci");
unset($tabFields[$ci]);
}
}
// load the global menu setters for single fields
$menuSetter = $tabLower . '_menu';
$pageSettings = [];
foreach ($tabFields as $ct => $field)
{
if (strpos((string) $field, $menuSetter) !== false)
{
// set the values needed to insure route is done correclty
$this->hasmenuglobal->set($tabLower, $menuSetter);
}
elseif (strpos((string) $field, '_menu"') !== false)
{
// not loaded to a tab "view" name
$_tabLower = GetHelper::between(
$field, 'name="', '_menu"'
);
// set the values needed to insure route is done correclty
$this->hasmenuglobal->set($_tabLower, $_tabLower . '_menu');
}
else
{
$pageSettings[$ct] = $field;
}
}
// insure we load the needed params
if (in_array($tab, $front_end))
{
$this->frontendparams->set($tab, $pageSettings);
}
}
}
}
}

View File

@ -0,0 +1,367 @@
<?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\Creator;
use VDM\Joomla\Componentbuilder\Compiler\Config;
use VDM\Joomla\Componentbuilder\Compiler\Language;
use VDM\Joomla\Componentbuilder\Compiler\Builder\ConfigFieldsets;
use VDM\Joomla\Componentbuilder\Compiler\Builder\ExtensionsParams;
use VDM\Joomla\Componentbuilder\Compiler\Builder\ConfigFieldsetsCustomfield as Customfield;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Line;
/**
* Config Fieldsets Uikit Creator Class
*
* @since 3.2.0
*/
final class ConfigFieldsetsUikit
{
/**
* The Config Class.
*
* @var Config
* @since 3.2.0
*/
protected Config $config;
/**
* The Language Class.
*
* @var Language
* @since 3.2.0
*/
protected Language $language;
/**
* The ConfigFieldsets Class.
*
* @var ConfigFieldsets
* @since 3.2.0
*/
protected ConfigFieldsets $configfieldsets;
/**
* The ExtensionsParams Class.
*
* @var ExtensionsParams
* @since 3.2.0
*/
protected ExtensionsParams $extensionsparams;
/**
* The ConfigFieldsetsCustomfield Class.
*
* @var Customfield
* @since 3.2.0
*/
protected Customfield $customfield;
/**
* Constructor.
*
* @param Config $config The Config Class.
* @param Language $language The Language Class.
* @param ConfigFieldsets $configfieldsets The ConfigFieldsets Class.
* @param ExtensionsParams $extensionsparams The ExtensionsParams Class.
* @param Customfield $customfield The ConfigFieldsetsCustomfield Class.
*
* @since 3.2.0
*/
public function __construct(Config $config, Language $language,
ConfigFieldsets $configfieldsets,
ExtensionsParams $extensionsparams,
Customfield $customfield)
{
$this->config = $config;
$this->language = $language;
$this->configfieldsets = $configfieldsets;
$this->extensionsparams = $extensionsparams;
$this->customfield = $customfield;
}
/**
* Set Uikit Config Fieldsets
*
* @param string $lang
*
* @since 3.2.0
*/
public function set(string $lang): void
{
if ($this->config->uikit > 0)
{
// main lang prefix
$lang = $lang . '';
// start building field set for uikit functions
$this->configfieldsets->add('component', Indent::_(1) . "<fieldset");
$this->configfieldsets->add('component', Indent::_(2) . 'name="uikit_config"');
$this->configfieldsets->add('component', Indent::_(2) . 'label="' . $lang
. '_UIKIT_LABEL"');
$this->configfieldsets->add('component', Indent::_(2) . 'description="' . $lang
. '_UIKIT_DESC">');
// set tab lang
if (1 == $this->config->uikit)
{
$this->language->set(
$this->config->lang_target, $lang . '_UIKIT_LABEL', "Uikit2 Settings"
);
$this->language->set(
$this->config->lang_target, $lang . '_UIKIT_DESC', "<b>The Parameters for the uikit are set here.</b><br />Uikit is a lightweight and modular front-end framework
for developing fast and powerful web interfaces. For more info visit <a href='https://getuikit.com/v2/' target='_blank'>https://getuikit.com/v2/</a>"
);
}
elseif (2 == $this->config->uikit)
{
$this->language->set(
$this->config->lang_target, $lang . '_UIKIT_LABEL',
"Uikit2 and Uikit3 Settings"
);
$this->language->set(
$this->config->lang_target, $lang . '_UIKIT_DESC', "<b>The Parameters for the uikit are set here.</b><br />Uikit is a lightweight and modular front-end framework
for developing fast and powerful web interfaces. For more info visit <a href='https://getuikit.com/v2/' target='_blank'>version 2</a> or <a href='https://getuikit.com/' target='_blank'>version 3</a>"
);
}
elseif (3 == $this->config->uikit)
{
$this->language->set(
$this->config->lang_target, $lang . '_UIKIT_LABEL', "Uikit3 Settings"
);
$this->language->set(
$this->config->lang_target, $lang . '_UIKIT_DESC', "<b>The Parameters for the uikit are set here.</b><br />Uikit is a lightweight and modular front-end framework
for developing fast and powerful web interfaces. For more info visit <a href='https://getuikit.com/' target='_blank'>https://getuikit.com/</a>"
);
}
// set field lang
$this->language->set(
$this->config->lang_target, $lang . '_JQUERY_LOAD_LABEL', "Load Joomla jQuery"
);
$this->language->set(
$this->config->lang_target, $lang . '_JQUERY_LOAD_DESC',
"Would you like to load the Joomla jQuery Framework?"
);
$this->language->set($this->config->lang_target, $lang . '_JQUERY_LOAD', "Load jQuery");
$this->language->set($this->config->lang_target, $lang . '_JQUERY_REMOVE', "Remove jQuery");
// set the field
$this->configfieldsets->add('component', Indent::_(2)
. '<field name="add_jquery_framework"');
$this->configfieldsets->add('component', Indent::_(3) . 'type="radio"');
$this->configfieldsets->add('component', Indent::_(3) . 'label="' . $lang
. '_JQUERY_LOAD_LABEL"');
$this->configfieldsets->add('component', Indent::_(3) . 'description="' . $lang
. '_JQUERY_LOAD_DESC"');
$this->configfieldsets->add('component', Indent::_(3)
. 'class="btn-group btn-group-yesno"');
$this->configfieldsets->add('component', Indent::_(3) . 'default="">');
$this->configfieldsets->add('component', Indent::_(3) . '<!--' . Line::_(
__LINE__,__CLASS__
) . ' Option Set. -->');
$this->configfieldsets->add('component', Indent::_(3) . '<option value="0">');
$this->configfieldsets->add('component', Indent::_(4) . $lang
. '_JQUERY_REMOVE</option>"');
$this->configfieldsets->add('component', Indent::_(3) . '<option value="1">');
$this->configfieldsets->add('component', Indent::_(4) . $lang
. '_JQUERY_LOAD</option>"');
$this->configfieldsets->add('component', Indent::_(2) . "</field>");
// set params defaults
$this->extensionsparams->add('component', '"add_jquery_framework":"1"');
// add version selection
if (2 == $this->config->uikit)
{
// set field lang
$this->language->set(
$this->config->lang_target, $lang . '_UIKIT_VERSION_LABEL',
"Uikit Versions"
);
$this->language->set(
$this->config->lang_target, $lang . '_UIKIT_VERSION_DESC',
"Select what version you would like to use"
);
$this->language->set(
$this->config->lang_target, $lang . '_UIKIT_V2', "Version 2"
);
$this->language->set(
$this->config->lang_target, $lang . '_UIKIT_V3', "Version 3"
);
// set the field
$this->configfieldsets->add('component', Indent::_(2)
. '<field name="uikit_version"');
$this->configfieldsets->add('component', Indent::_(3) . 'type="radio"');
$this->configfieldsets->add('component', Indent::_(3) . 'label="' . $lang
. '_UIKIT_VERSION_LABEL"');
$this->configfieldsets->add('component', Indent::_(3) . 'description="'
. $lang . '_UIKIT_VERSION_DESC"');
$this->configfieldsets->add('component', Indent::_(3)
. 'class="btn-group btn-group-yesno"');
$this->configfieldsets->add('component', Indent::_(3) . 'default="2">');
$this->configfieldsets->add('component', Indent::_(3) . '<!--'
. Line::_(__Line__, __Class__) . ' Option Set. -->');
$this->configfieldsets->add('component', Indent::_(3) . '<option value="2">');
$this->configfieldsets->add('component', Indent::_(4) . $lang
. '_UIKIT_V2</option>"');
$this->configfieldsets->add('component', Indent::_(3) . '<option value="3">');
$this->configfieldsets->add('component', Indent::_(4) . $lang
. '_UIKIT_V3</option>"');
$this->configfieldsets->add('component', Indent::_(2) . "</field>");
// set params defaults
$this->extensionsparams->add('component', '"uikit_version":"2"');
}
// set field lang
$this->language->set(
$this->config->lang_target, $lang . '_UIKIT_LOAD_LABEL', "Loading Options"
);
$this->language->set(
$this->config->lang_target, $lang . '_UIKIT_LOAD_DESC',
"Set the uikit loading option."
);
$this->language->set($this->config->lang_target, $lang . '_AUTO_LOAD', "Auto");
$this->language->set($this->config->lang_target, $lang . '_FORCE_LOAD', "Force");
$this->language->set($this->config->lang_target, $lang . '_DONT_LOAD', "Not");
$this->language->set(
$this->config->lang_target, $lang . '_ONLY_EXTRA', "Only Extra"
);
// set the field
$this->configfieldsets->add('component', Indent::_(2)
. '<field name="uikit_load"');
$this->configfieldsets->add('component', Indent::_(3) . 'type="radio"');
$this->configfieldsets->add('component', Indent::_(3) . 'label="' . $lang
. '_UIKIT_LOAD_LABEL"');
$this->configfieldsets->add('component', Indent::_(3) . 'description="' . $lang
. '_UIKIT_LOAD_DESC"');
$this->configfieldsets->add('component', Indent::_(3)
. 'class="btn-group btn-group-yesno"');
$this->configfieldsets->add('component', Indent::_(3) . 'default="">');
$this->configfieldsets->add('component', Indent::_(3) . '<!--' . Line::_(
__LINE__,__CLASS__
) . ' Option Set. -->');
$this->configfieldsets->add('component', Indent::_(3) . '<option value="">');
$this->configfieldsets->add('component', Indent::_(4) . $lang
. '_AUTO_LOAD</option>"');
$this->configfieldsets->add('component', Indent::_(3) . '<option value="1">');
$this->configfieldsets->add('component', Indent::_(4) . $lang
. '_FORCE_LOAD</option>"');
if (2 == $this->config->uikit || 1 == $this->config->uikit)
{
$this->configfieldsets->add('component', Indent::_(3) . '<option value="3">');
$this->configfieldsets->add('component', Indent::_(4) . $lang
. '_ONLY_EXTRA</option>"');
}
$this->configfieldsets->add('component', Indent::_(3) . '<option value="2">');
$this->configfieldsets->add('component', Indent::_(4) . $lang
. '_DONT_LOAD</option>"');
$this->configfieldsets->add('component', Indent::_(2) . "</field>");
// set params defaults
$this->extensionsparams->add('component', '"uikit_load":"1"');
// set field lang
$this->language->set(
$this->config->lang_target, $lang . '_UIKIT_MIN_LABEL', "Load Minified"
);
$this->language->set(
$this->config->lang_target, $lang . '_UIKIT_MIN_DESC',
"Should the minified version of uikit files be loaded?"
);
$this->language->set($this->config->lang_target, $lang . '_YES', "Yes");
$this->language->set($this->config->lang_target, $lang . '_NO', "No");
// set the field
$this->configfieldsets->add('component', Indent::_(2) . '<field name="uikit_min"');
$this->configfieldsets->add('component', Indent::_(3) . 'type="radio"');
$this->configfieldsets->add('component', Indent::_(3) . 'label="' . $lang
. '_UIKIT_MIN_LABEL"');
$this->configfieldsets->add('component', Indent::_(3) . 'description="' . $lang
. '_UIKIT_MIN_DESC"');
$this->configfieldsets->add('component', Indent::_(3)
. 'class="btn-group btn-group-yesno"');
$this->configfieldsets->add('component', Indent::_(3) . 'default="">');
$this->configfieldsets->add('component', Indent::_(3) . '<!--' . Line::_(
__LINE__,__CLASS__
) . ' Option Set. -->');
$this->configfieldsets->add('component', Indent::_(3) . '<option value="">');
$this->configfieldsets->add('component', Indent::_(4) . $lang . '_NO</option>"');
$this->configfieldsets->add('component', Indent::_(3) . '<option value=".min">');
$this->configfieldsets->add('component', Indent::_(4) . $lang . '_YES</option>"');
$this->configfieldsets->add('component', Indent::_(2) . "</field>");
// set params defaults
$this->extensionsparams->add('component', '"uikit_min":""');
if (2 == $this->config->uikit || 1 == $this->config->uikit)
{
// set field lang
$this->language->set(
$this->config->lang_target, $lang . '_UIKIT_STYLE_LABEL', "css Style"
);
$this->language->set(
$this->config->lang_target, $lang . '_UIKIT_STYLE_DESC',
"Set the css style that should be used."
);
$this->language->set(
$this->config->lang_target, $lang . '_FLAT_LOAD', "Flat"
);
$this->language->set(
$this->config->lang_target, $lang . '_ALMOST_FLAT_LOAD', "Almost Flat"
);
$this->language->set(
$this->config->lang_target, $lang . '_GRADIANT_LOAD', "Gradient"
);
// set the field
$this->configfieldsets->add('component', Indent::_(2)
. '<field name="uikit_style"');
$this->configfieldsets->add('component', Indent::_(3) . 'type="radio"');
$this->configfieldsets->add('component', Indent::_(3) . 'label="' . $lang
. '_UIKIT_STYLE_LABEL"');
$this->configfieldsets->add('component', Indent::_(3) . 'description="'
. $lang . '_UIKIT_STYLE_DESC"');
$this->configfieldsets->add('component', Indent::_(3)
. 'class="btn-group btn-group-yesno"');
if (2 == $this->config->uikit)
{
$this->configfieldsets->add('component', Indent::_(3)
. 'showon="uikit_version:2"');
}
$this->configfieldsets->add('component', Indent::_(3) . 'default="">');
$this->configfieldsets->add('component', Indent::_(3) . '<!--'
. Line::_(__Line__, __Class__) . ' Option Set. -->');
$this->configfieldsets->add('component', Indent::_(3) . '<option value="">');
$this->configfieldsets->add('component', Indent::_(4) . $lang
. '_FLAT_LOAD</option>"');
$this->configfieldsets->add('component', Indent::_(3)
. '<option value=".almost-flat">');
$this->configfieldsets->add('component', Indent::_(4) . $lang
. '_ALMOST_FLAT_LOAD</option>"');
$this->configfieldsets->add('component', Indent::_(3)
. '<option value=".gradient">');
$this->configfieldsets->add('component', Indent::_(4) . $lang
. '_GRADIANT_LOAD</option>"');
$this->configfieldsets->add('component', Indent::_(2) . "</field>");
// set params defaults
$this->extensionsparams->add('component', '"uikit_style":""');
}
// add custom Uikit Settings fields
if ($this->customfield->isArray('Uikit Settings'))
{
$this->configfieldsets->add('component', implode(
"", $this->customfield->get('Uikit Settings')
));
$this->customfield->remove('Uikit Settings');
}
// close that fieldset
$this->configfieldsets->add('component', Indent::_(1) . "</fieldset>");
}
}
}

View File

@ -0,0 +1,141 @@
<?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\Creator;
use VDM\Joomla\Componentbuilder\Compiler\Config;
use VDM\Joomla\Componentbuilder\Compiler\Language;
use VDM\Joomla\Componentbuilder\Compiler\Builder\PermissionComponent;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Counter;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Utilities\StringHelper;
/**
* Custom Button Permissions Creator Class
*
* @since 3.2.0
*/
final class CustomButtonPermissions
{
/**
* The Config Class.
*
* @var Config
* @since 3.2.0
*/
protected Config $config;
/**
* The Language Class.
*
* @var Language
* @since 3.2.0
*/
protected Language $language;
/**
* The PermissionComponent Class.
*
* @var PermissionComponent
* @since 3.2.0
*/
protected PermissionComponent $permissioncomponent;
/**
* The Counter Class.
*
* @var Counter
* @since 3.2.0
*/
protected Counter $counter;
/**
* Constructor.
*
* @param Config $config The Config Class.
* @param Language $language The Language Class.
* @param PermissionComponent $permissioncomponent The PermissionComponent Class.
* @param Counter $counter The Counter Class.
*
* @since 3.2.0
*/
public function __construct(Config $config, Language $language,
PermissionComponent $permissioncomponent,
Counter $counter)
{
$this->config = $config;
$this->language = $language;
$this->permissioncomponent = $permissioncomponent;
$this->counter = $counter;
}
/**
* Add Custom Button Permissions
*
* @param object $settings The view settings
* @param string $nameView The view name
* @param string $code The view code name.
*
* @since 3.2.0
*/
public function add(object $settings, string $nameView, string $code): void
{
// add the custom permissions to use the buttons of this view
if (isset($settings->custom_buttons)
&& ArrayHelper::check($settings->custom_buttons))
{
foreach ($settings->custom_buttons as $custom_buttons)
{
$customButtonName = $custom_buttons['name'];
$customButtonCode = StringHelper::safe(
$customButtonName
);
$customButtonTitle = $this->config->lang_prefix . '_'
. StringHelper::safe(
$nameView . ' ' . $customButtonName . ' Button Access',
'U'
);
$customButtonDesc = $this->config->lang_prefix . '_'
. StringHelper::safe(
$nameView . ' ' . $customButtonName . ' Button Access',
'U'
) . '_DESC';
$sortButtonKey = StringHelper::safe(
$nameView . ' ' . $customButtonName . ' Button Access'
);
$this->language->set(
'bothadmin', $customButtonTitle,
$nameView . ' ' . $customButtonName . ' Button Access'
);
$this->language->set(
'bothadmin', $customButtonDesc,
' Allows the users in this group to access the '
. StringHelper::safe($customButtonName, 'w')
. ' button.'
);
$this->permissioncomponent->set($sortButtonKey, [
'name' => "$code.$customButtonCode",
'title' => $customButtonTitle,
'description' => $customButtonDesc
]);
// the size needs increase
$this->counter->accessSize++;
}
}
}
}

View File

@ -231,18 +231,16 @@ final class FieldsetString implements Fieldsetinterface
$dynamic_fields = '';
// set the custom table key
$dbkey = 'g';
// for plugin event TODO change event api signatures
$placeholders = $this->placeholder->active;
$component_context = $this->config->component_context;
// Trigger Event: jcb_ce_onBeforeBuildFields
$this->event->trigger(
'jcb_ce_onBeforeBuildFields',
array(&$component_context, &$dynamic_fields, &$read_only,
[&$dynamic_fields, &$read_only,
&$dbkey, &$view, &$component, &$nameSingleCode,
&$nameListCode, &$placeholders, &$lang_view,
&$lang_views)
&$nameListCode, &$lang_view,
&$lang_views]
);
unset($placeholders);
// TODO we should add the global and local view switch if field for front end
foreach ($view['settings']->fields as $field)
{
@ -252,17 +250,16 @@ final class FieldsetString implements Fieldsetinterface
true
);
}
// for plugin event TODO change event api signatures
$placeholders = $this->placeholder->active;
// Trigger Event: jcb_ce_onAfterBuildFields
$this->event->trigger(
'jcb_ce_onAfterBuildFields',
array(&$component_context, &$dynamic_fields, &$read_only,
[&$dynamic_fields, &$read_only,
&$dbkey, &$view, &$component, &$nameSingleCode,
&$nameListCode, &$placeholders, &$lang_view,
&$lang_views)
&$nameListCode, &$lang_view,
&$lang_views]
);
unset($placeholders);
// set the default fields
$field_set = array();
$field_set[] = '<fieldset name="details">';
@ -444,6 +441,7 @@ final class FieldsetString implements Fieldsetinterface
$field_set[] = Indent::_(3) . 'description="' . $lang_view
. '_VERSION_DESC"';
$field_set[] = Indent::_(3) . 'size="6"';
$field_set[] = Indent::_(3) . 'default="1"';
$field_set[] = Indent::_(3) . 'readonly="true"';
$field_set[] = Indent::_(3) . 'filter="unset"';
$field_set[] = Indent::_(2) . "/>";

View File

@ -239,18 +239,16 @@ final class FieldsetXML implements Fieldsetinterface
$dynamic_fields_xml = [];
// set the custom table key
$dbkey = 'g';
// for plugin event TODO change event api signatures
$placeholders = $this->placeholder->active;
$component_context = $this->config->component_context;
// Trigger Event: jcb_ce_onBeforeBuildFields
$this->event->trigger(
'jcb_ce_onBeforeBuildFields',
array(&$component_context, &$dynamic_fields_xml, &$read_only_xml,
[&$dynamic_fields_xml, &$read_only_xml,
&$dbkey, &$view, &$component, &$nameSingleCode,
&$nameListCode, &$placeholders, &$lang_view,
&$lang_views)
&$nameListCode, &$lang_view,
&$lang_views]
);
unset($placeholders);
// TODO we should add the global and local view switch if field for front end
foreach ($view['settings']->fields as $field)
{
@ -260,17 +258,16 @@ final class FieldsetXML implements Fieldsetinterface
true
);
}
// for plugin event TODO change event api signatures
$placeholders = $this->placeholder->active;
// Trigger Event: jcb_ce_onAfterBuildFields
$this->event->trigger(
'jcb_ce_onAfterBuildFields',
array(&$component_context, &$dynamic_fields_xml, &$read_only_xml,
[&$dynamic_fields_xml, &$read_only_xml,
&$dbkey, &$view, &$component, &$nameSingleCode,
&$nameListCode, &$placeholders, &$lang_view,
&$lang_views)
&$nameListCode, &$lang_view,
&$lang_views]
);
unset($placeholders);
// set the default fields
$main_xml = new \simpleXMLElement('<a/>');
$field_set_xml = $main_xml->addChild('fieldset');
@ -466,6 +463,7 @@ final class FieldsetXML implements Fieldsetinterface
'label' => $lang_view . '_VERSION_LABEL',
'description' => $lang_view . '_VERSION_DESC',
'size' => 6,
'default' => 1,
'readonly' => "true",
'filter' => 'unset'
];

View File

@ -0,0 +1,79 @@
<?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\Creator;
use VDM\Joomla\Componentbuilder\Compiler\Builder\Request as RequestBuilder;
use VDM\Joomla\Utilities\GetHelper;
use VDM\Joomla\Utilities\StringHelper;
/**
* Request Creator Class
*
* @since 3.2.0
*/
final class Request
{
/**
* The Request Class.
*
* @var RequestBuilder
* @since 3.2.0
*/
protected RequestBuilder $requestbuilder;
/**
* Constructor.
*
* @param RequestBuilder $requestbuilder The Request Class.
*
* @since 3.2.0
*/
public function __construct(RequestBuilder $requestbuilder)
{
$this->requestbuilder = $requestbuilder;
}
/**
* Set the request values
*
* @param string $view
* @param string $field
* @param string $search
* @param string $target
*
* @since 3.2.0
*/
public function set(string $view, string $field, string $search, string $target): void
{
$key = GetHelper::between($field, $search, '"');
if (!StringHelper::check($key))
{
// is not having special var
$key = $target;
// update field
$field = str_replace($search . '"', 'name="' . $key . '"', (string) $field);
}
else
{
// update field
$field = str_replace(
$search . $key . '"', 'name="' . $key . '"', (string) $field
);
}
// set the values needed for view requests to be made
$this->requestbuilder->set("$target.$view.$key", $field);
}
}

View File

@ -0,0 +1,263 @@
<?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\Creator;
use VDM\Joomla\Componentbuilder\Compiler\Customcode\Dispenser;
use VDM\Joomla\Componentbuilder\Compiler\Builder\Request;
use VDM\Joomla\Componentbuilder\Compiler\Builder\Router as Builder;
use VDM\Joomla\Componentbuilder\Compiler\Creator\RouterConstructorDefault as DefaultConstructor;
use VDM\Joomla\Componentbuilder\Compiler\Creator\RouterConstructorManual as ManualConstructor;
use VDM\Joomla\Componentbuilder\Compiler\Creator\RouterMethodsDefault as DefaultMethods;
use VDM\Joomla\Componentbuilder\Compiler\Creator\RouterMethodsManual as ManualMethods;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Utilities\StringHelper;
/**
* Router Creator Class
*
* @since 3.2.0
*/
final class Router
{
/**
* The Dispenser Class.
*
* @var Dispenser
* @since 3.2.0
*/
protected Dispenser $dispenser;
/**
* The Request Class.
*
* @var Request
* @since 3.2.0
*/
protected Request $request;
/**
* The Router Class.
*
* @var Builder
* @since 3.2.0
*/
protected Builder $builder;
/**
* The RouterConstructorDefault Class.
*
* @var DefaultConstructor
* @since 3.2.0
*/
protected DefaultConstructor $defaultconstructor;
/**
* The RouterConstructorManual Class.
*
* @var ManualConstructor
* @since 3.2.0
*/
protected ManualConstructor $manualconstructor;
/**
* The RouterMethodsDefault Class.
*
* @var DefaultMethods
* @since 3.2.0
*/
protected DefaultMethods $defaultmethods;
/**
* The RouterMethodsManual Class.
*
* @var ManualMethods
* @since 3.2.0
*/
protected ManualMethods $manualmethods;
/**
* The Router Build Mode Before Parent Construct.
*
* @var int|null
* @since 3.2.0
*/
protected ?int $mode_before = null;
/**
* The Router Build Mode Methods.
*
* @var int|null
* @since 3.2.0
*/
protected ?int $mode_method = null;
/**
* Constructor.
*
* @param Dispenser $dispenser The Dispenser Class.
* @param Request $request The Request Class.
* @param Builder $builder The Router Class.
* @param DefaultConstructor $defaultconstructor The RouterConstructorDefault Class.
* @param ManualConstructor $manualconstructor The RouterConstructorManual Class.
* @param DefaultMethods $defaultmethods The RouterMethodsDefault Class.
* @param ManualMethods $manualmethods The RouterMethodsManual Class.
*
* @since 3.2.0
*/
public function __construct(Dispenser $dispenser, Request $request,
Builder $builder, DefaultConstructor $defaultconstructor,
ManualConstructor $manualconstructor,
DefaultMethods $defaultmethods,
ManualMethods $manualmethods)
{
$this->dispenser = $dispenser;
$this->request = $request;
$this->builder = $builder;
$this->defaultconstructor = $defaultconstructor;
$this->manualconstructor = $manualconstructor;
$this->defaultmethods = $defaultmethods;
$this->manualmethods = $manualmethods;
}
/**
* Get Constructor Before Parent Call
*
* @return string
* @since 3.2.0
*/
public function getConstructor(): string
{
$this->init();
if ($this->mode_before == 3)
{
return $this->dispenser->get(
'_site_router_', 'constructor_before_parent',
PHP_EOL . PHP_EOL, null, true
);
}
if ($this->mode_before == 2)
{
return $this->manualconstructor->get();
}
return $this->defaultconstructor->get();
}
/**
* Get Constructor After Parent Call
*
* @return string
* @since 3.2.0
*/
public function getConstructorAfterParent(): string
{
return $this->dispenser->get(
'_site_router_', 'constructor_after_parent',
PHP_EOL . PHP_EOL, null, true
);
}
/**
* Get Methods
*
* @return string
* @since 3.2.0
*/
public function getMethods(): string
{
$this->init();
if ($this->mode_method == 0)
{
return '';
}
if ($this->mode_method == 3)
{
return $this->dispenser->get(
'_site_router_', 'methods',
PHP_EOL . PHP_EOL, null, true
);
}
if ($this->mode_before == 2 && $this->mode_method == 1)
{
return $this->manualmethods->get();
}
if ($this->mode_method == 1)
{
return $this->defaultmethods->get();
}
return '';
}
/**
* Get Constructor Before Parent Call
*
* @return void
* @since 3.2.0
*/
private function init(): void
{
if ($this->mode_before === null)
{
$this->mode_before = (int) $this->builder->get('mode_before', 0);
$this->mode_method = (int) $this->builder->get('mode_method', 0);
$this->updateKeys();
}
}
/**
* Update the keys
*
* @return void
* @since 3.2.0
*/
private function updateKeys(): void
{
if (($requests = $this->request->allActive()) === [] ||
($views = $this->builder->get('views')) === null)
{
return;
}
foreach ($views as &$router)
{
// if the key is null, and not 'id'
// then we must not update it
// since this is a list view and
// should not add an ID as key value
if ($router->key === 'id')
{
foreach ($requests as $key => $request)
{
if (isset($request[$router->view]))
{
$router->key = $key;
}
}
}
}
unset($router);
$this->request->set('views', $views);
}
}

View File

@ -0,0 +1,77 @@
<?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\Creator;
use VDM\Joomla\Componentbuilder\Compiler\Builder\Router;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Line;
/**
* Router Constructor Default Creator Class
*
* @since 3.2.0
*/
final class RouterConstructorDefault
{
/**
* The Router Class.
*
* @var Router
* @since 3.2.0
*/
protected Router $router;
/**
* Constructor.
*
* @param Router $router The Router Class.
*
* @since 3.2.0
*/
public function __construct(Router $router)
{
$this->router = $router;
}
/**
* Get Construct Code
*
* @return string
* @since 3.2.0
*/
public function get(): string
{
$views = $this->router->get('views');
if ($views !== null)
{
$code = [];
foreach ($views as $view)
{
$code[] = '';
$code[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
. " Add the ({$view->view}:view) router configuration";
$code[] = Indent::_(2) . "\${$view->view} = new RouterViewConfiguration('{$view->view}');";
// add key only if we have one see: ...Compiler\Creator\Router->updateKeys();
if (!empty($view->key) && !empty($view->alias))
{
$code[] = Indent::_(2) . "\${$view->view}->setKey('{$view->key}');";
}
$code[] = Indent::_(2) . "\$this->registerView(\${$view->view});";
}
return PHP_EOL . implode(PHP_EOL, $code);
}
return '';
}
}

View File

@ -0,0 +1,77 @@
<?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\Creator;
use VDM\Joomla\Componentbuilder\Compiler\Builder\Router;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Line;
/**
* Router Constructor Default Creator Class
*
* @since 3.2.0
*/
final class RouterConstructorManual
{
/**
* The Router Class.
*
* @var Router
* @since 3.2.0
*/
protected Router $router;
/**
* Constructor.
*
* @param Router $router The Router Class.
*
* @since 3.2.0
*/
public function __construct(Router $router)
{
$this->router = $router;
}
/**
* Get Construct Code (SOON)
*
* @return string
* @since 3.2.0
*/
public function get(): string
{
$views = $this->router->get('views');
if ($views !== null)
{
$code = [];
foreach ($views as $view)
{
$code[] = '';
$code[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
. " Add the ({$view->view}:view) router configuration";
$code[] = Indent::_(2) . "\${$view->view} = new RouterViewConfiguration('{$view->view}');";
// add key only if we have one see: ...Compiler\Creator\Router->updateKeys();
if (!empty($view->key) && !empty($view->alias))
{
$code[] = Indent::_(2) . "\${$view->view}->setKey('{$view->key}');";
}
$code[] = Indent::_(2) . "\$this->registerView(\${$view->view});";
}
return PHP_EOL . implode(PHP_EOL, $code);
}
return '';
}
}

View File

@ -0,0 +1,137 @@
<?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\Creator;
use VDM\Joomla\Componentbuilder\Compiler\Builder\Router;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Line;
/**
* Router Methods Default Creator Class
*
* @since 3.2.0
*/
final class RouterMethodsDefault
{
/**
* The Router Class.
*
* @var Router
* @since 3.2.0
*/
protected Router $router;
/**
* Constructor.
*
* @param Router $router The Router Class.
*
* @since 3.2.0
*/
public function __construct(Router $router)
{
$this->router = $router;
}
/**
* Get Methods Code
*
* @return string
* @since 3.2.0
*/
public function get(): string
{
$views = $this->router->get('views');
if ($views !== null)
{
$code = [];
foreach ($views as $view)
{
// we only add these if we can get an ID (int) value
// else you will need to use the manual or customcode options
if (empty($view->key) || empty($view->alias))
{
continue;
}
$code[] = '';
$code[] = Indent::_(1) . "/**";
$code[] = Indent::_(1) . " * Method to get the segment(s) for {$view->view}";
$code[] = Indent::_(1) . " *";
$code[] = Indent::_(1) . " * @param string \$segment Segment of the article to retrieve the ID for";
$code[] = Indent::_(1) . " * @param array \$query The request that is parsed right now";
$code[] = Indent::_(1) . " *";
$code[] = Indent::_(1) . " * @return mixed The {$view->key} of this item or false";
$code[] = Indent::_(1) . " * @since 4.4.0";
$code[] = Indent::_(1) . " */";
$code[] = Indent::_(1) . "public function get{$view->View}Id(\$segment, \$query)";
$code[] = Indent::_(1) . "{";
$code[] = Indent::_(2) . "if (\$this->noIDs)";
$code[] = Indent::_(2) . "{";
$code[] = Indent::_(3) . "\$dbquery = \$this->db->getQuery(true);";
$code[] = Indent::_(3) . "\$dbquery->select(\$this->db->quoteName('{$view->key}'))";
$code[] = Indent::_(4) . "->from(\$this->db->quoteName('{$view->table}'))";
$code[] = Indent::_(4) . "->where(";
$code[] = Indent::_(5) . "[";
$code[] = Indent::_(6) . "\$this->db->quoteName('{$view->alias}') . ' = :alias'";
$code[] = Indent::_(5) . "]";
$code[] = Indent::_(4) . ")";
$code[] = Indent::_(4) . "->bind(':alias', \$segment);";
$code[] = Indent::_(3) . "\$this->db->setQuery(\$dbquery);";
$code[] = '';
$code[] = Indent::_(3) . "return (int) \$this->db->loadResult();";
$code[] = Indent::_(2) . "}";
$code[] = '';
$code[] = Indent::_(2) . "return (int) \$segment;";
$code[] = Indent::_(1) . "}";
$code[] = '';
$code[] = Indent::_(1) . "/**";
$code[] = Indent::_(1) . " * Method to get the segment(s) for {$view->view}";
$code[] = Indent::_(1) . " *";
$code[] = Indent::_(1) . " * @param string \$id ID of the contact to retrieve the segments for";
$code[] = Indent::_(1) . " * @param array \$query The request that is built right now";
$code[] = Indent::_(1) . " *";
$code[] = Indent::_(1) . " * @return array|string The segments of this item";
$code[] = Indent::_(1) . " * @since 4.4.0";
$code[] = Indent::_(1) . " */";
$code[] = Indent::_(1) . "public function get{$view->View}Segment(\$id, \$query)";
$code[] = Indent::_(1) . "{";
$code[] = Indent::_(2) . "if (strpos(\$id, ':') === false)";
$code[] = Indent::_(2) . "{";
$code[] = Indent::_(3) . "\$id = (int) \$id;";
$code[] = Indent::_(3) . "\$dbquery = \$this->db->getQuery(true);";
$code[] = Indent::_(3) . "\$dbquery->select(\$this->db->quoteName('{$view->alias}'))";
$code[] = Indent::_(4) . "->from(\$this->db->quoteName('{$view->table}'))";
$code[] = Indent::_(4) . "->where(\$this->db->quoteName('{$view->key}') . ' = :id')";
$code[] = Indent::_(4) . "->bind(':id', \$id, ParameterType::INTEGER);";
$code[] = Indent::_(3) . "\$this->db->setQuery(\$dbquery);";
$code[] = '';
$code[] = Indent::_(3) . "\$id .= ':' . \$this->db->loadResult();";
$code[] = Indent::_(2) . "}";
$code[] = '';
$code[] = Indent::_(2) . "if (\$this->noIDs)";
$code[] = Indent::_(2) . "{";
$code[] = Indent::_(3) . "list(\$void, \$segment) = explode(':', \$id, 2);";
$code[] = '';
$code[] = Indent::_(3) . "return [\$void => \$segment];";
$code[] = Indent::_(2) . "}";
$code[] = '';
$code[] = Indent::_(2) . "return [(int) \$id => \$id];";
$code[] = Indent::_(1) . "}";
}
return PHP_EOL . implode(PHP_EOL, $code);
}
return '';
}
}

View File

@ -0,0 +1,137 @@
<?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\Creator;
use VDM\Joomla\Componentbuilder\Compiler\Builder\Router;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Line;
/**
* Router Methods Manual Creator Class
*
* @since 3.2.0
*/
final class RouterMethodsManual
{
/**
* The Router Class.
*
* @var Router
* @since 3.2.0
*/
protected Router $router;
/**
* Constructor.
*
* @param Router $router The Router Class.
*
* @since 3.2.0
*/
public function __construct(Router $router)
{
$this->router = $router;
}
/**
* Get Methods Code (SOON)
*
* @return string
* @since 3.2.0
*/
public function get(): string
{
$views = $this->router->get('views');
if ($views !== null)
{
$code = [];
foreach ($views as $view)
{
// we only add these if we can get an ID (int) value
// else you will need to use the manual or customcode options
if (empty($view->key) || empty($view->alias))
{
continue;
}
$code[] = '';
$code[] = Indent::_(1) . "/**";
$code[] = Indent::_(1) . " * Method to get the segment(s) for an {$view->view}";
$code[] = Indent::_(1) . " *";
$code[] = Indent::_(1) . " * @param string \$segment Segment of the article to retrieve the ID for";
$code[] = Indent::_(1) . " * @param array \$query The request that is parsed right now";
$code[] = Indent::_(1) . " *";
$code[] = Indent::_(1) . " * @return mixed The {$view->key} of this item or false";
$code[] = Indent::_(1) . " * @since 4.4.0";
$code[] = Indent::_(1) . " */";
$code[] = Indent::_(1) . "public function get{$view->View}Id(\$segment, \$query)";
$code[] = Indent::_(1) . "{";
$code[] = Indent::_(2) . "if (\$this->noIDs)";
$code[] = Indent::_(2) . "{";
$code[] = Indent::_(3) . "\$dbquery = \$this->db->getQuery(true);";
$code[] = Indent::_(3) . "\$dbquery->select(\$this->db->quoteName('{$view->key}'))";
$code[] = Indent::_(4) . "->from(\$this->db->quoteName('{$view->table}'))";
$code[] = Indent::_(4) . "->where(";
$code[] = Indent::_(5) . "[";
$code[] = Indent::_(6) . "\$this->db->quoteName('{$view->alias}') . ' = :alias'";
$code[] = Indent::_(5) . "]";
$code[] = Indent::_(4) . ")";
$code[] = Indent::_(4) . "->bind(':alias', \$segment);";
$code[] = Indent::_(3) . "\$this->db->setQuery(\$dbquery);";
$code[] = '';
$code[] = Indent::_(3) . "return (int) \$this->db->loadResult();";
$code[] = Indent::_(2) . "}";
$code[] = '';
$code[] = Indent::_(2) . "return (int) \$segment;";
$code[] = Indent::_(1) . "}";
$code[] = '';
$code[] = Indent::_(1) . "/**";
$code[] = Indent::_(1) . " * Method to get the segment(s) for a {$view->view}";
$code[] = Indent::_(1) . " *";
$code[] = Indent::_(1) . " * @param string \$id ID of the contact to retrieve the segments for";
$code[] = Indent::_(1) . " * @param array \$query The request that is built right now";
$code[] = Indent::_(1) . " *";
$code[] = Indent::_(1) . " * @return array|string The segments of this item";
$code[] = Indent::_(1) . " * @since 4.4.0";
$code[] = Indent::_(1) . " */";
$code[] = Indent::_(1) . "public function get{$view->View}Segment(\$id, \$query)";
$code[] = Indent::_(1) . "{";
$code[] = Indent::_(2) . "if (strpos(\$id, ':') === false)";
$code[] = Indent::_(2) . "{";
$code[] = Indent::_(3) . "\$id = (int) \$id;";
$code[] = Indent::_(3) . "\$dbquery = \$this->db->getQuery(true);";
$code[] = Indent::_(3) . "\$dbquery->select(\$this->db->quoteName('{$view->alias}'))";
$code[] = Indent::_(4) . "->from(\$this->db->quoteName('{$view->table}'))";
$code[] = Indent::_(4) . "->where(\$this->db->quoteName('{$view->key}') . ' = :id')";
$code[] = Indent::_(4) . "->bind(':id', \$id, ParameterType::INTEGER);";
$code[] = Indent::_(3) . "\$this->db->setQuery(\$dbquery);";
$code[] = '';
$code[] = Indent::_(3) . "\$id .= ':' . \$this->db->loadResult();";
$code[] = Indent::_(2) . "}";
$code[] = '';
$code[] = Indent::_(2) . "if (\$this->noIDs)";
$code[] = Indent::_(2) . "{";
$code[] = Indent::_(3) . "list(\$void, \$segment) = explode(':', \$id, 2);";
$code[] = '';
$code[] = Indent::_(3) . "return [\$void => \$segment];";
$code[] = Indent::_(2) . "}";
$code[] = '';
$code[] = Indent::_(2) . "return [(int) \$id => \$id];";
$code[] = Indent::_(1) . "}";
}
return PHP_EOL . implode(PHP_EOL, $code);
}
return '';
}
}

View File

@ -13,9 +13,6 @@ namespace VDM\Joomla\Componentbuilder\Compiler;
use Joomla\CMS\Factory;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Utilities\GetHelper;
use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler;
use VDM\Joomla\Componentbuilder\Compiler\Config;
use VDM\Joomla\Componentbuilder\Compiler\Placeholder;
@ -23,6 +20,9 @@ use VDM\Joomla\Componentbuilder\Compiler\Language\Extractor;
use VDM\Joomla\Componentbuilder\Compiler\Power\Extractor as Power;
use VDM\Joomla\Componentbuilder\Compiler\Customcode\External;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Placefix;
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Utilities\GetHelper;
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\CustomcodeInterface;
@ -122,7 +122,6 @@ class Customcode implements CustomcodeInterface
/**
* Database object to query local DB
*
* @var \JDatabaseDriver
* @since 3.2.0
**/
protected $db;
@ -140,14 +139,14 @@ class Customcode implements CustomcodeInterface
* @since 3.2.0
*/
public function __construct(?Config $config = null, ?Placeholder $placeholder = null,
?Extractor $extractor = null, ?Power $power = null, ?External $external = null, ?\JDatabaseDriver $db = null)
?Extractor $extractor = null, ?Power $power = null, ?External $external = null)
{
$this->config = $config ?: Compiler::_('Config');
$this->placeholder = $placeholder ?: Compiler::_('Placeholder');
$this->extractor = $extractor ?: Compiler::_('Language.Extractor');
$this->power = $power ?: Compiler::_('Power.Extractor');
$this->external = $external ?: Compiler::_('Customcode.External');
$this->db = $db ?: Factory::getDbo();
$this->db = Factory::getDbo();
}
/**
@ -423,6 +422,10 @@ class Customcode implements CustomcodeInterface
$query->where(
$this->db->quoteName('a.target') . ' = 1'
); // <--- to load the correct target
$query->where(
$this->db->quoteName('a.joomla_version') . ' = '
. (int) $this->config->get('joomla_version', 3)
); // <--- to load the correct joomla target
$query->order(
$this->db->quoteName('a.from_line') . ' ASC'
); // <--- insure we always add code from top of file

View File

@ -196,9 +196,7 @@ class Dispenser implements DispenserInterface
$script .= $note;
}
// load the actual script
$script .= $prefix . str_replace(
array_keys($this->placeholder->active),
array_values($this->placeholder->active),
$script .= $prefix . $this->placeholder->update_(
(string) $this->hub[$first][$second]
) . $suffix;
// clear some memory

View File

@ -60,45 +60,38 @@ class External implements ExternalInterface
/**
* Database object to query local DB
*
* @var \JDatabaseDriver
* @since 3.2.0
**/
protected \JDatabaseDriver $db;
protected $db;
/**
* User object
*
* @var User
* @since 3.2.0
**/
protected User $user;
protected $user;
/**
* Database object to query local DB
*
* @var CMSApplication
* @since 3.2.0
**/
protected CMSApplication $app;
protected $app;
/**
* Constructor.
*
* @param Placeholder|null $placeholder The compiler placeholder object.
* @param \JDatabaseDriver|null $db The Database Driver object.
* @param User|null $user The User object.
* @param CMSApplication|null $app The CMS Application object.
*
* @throws \Exception
* @since 3.2.0
*/
public function __construct(?Placeholder $placeholder = null,
?\JDatabaseDriver $db = null, ?User $user = null, ?CMSApplication $app = null)
public function __construct(?Placeholder $placeholder = null)
{
$this->placeholder = $placeholder ?: Compiler::_('Placeholder');
$this->db = $db ?: Factory::getDbo();
$this->user = $user ?: Factory::getUser();
$this->app = $app ?: Factory::getApplication();
$this->db = Factory::getDbo();
$this->user = Factory::getUser();
$this->app = Factory::getApplication();
}
/**

View File

@ -16,7 +16,8 @@ use Joomla\CMS\Factory;
use Joomla\CMS\User\User;
use Joomla\CMS\Filesystem\Folder;
use Joomla\CMS\Application\CMSApplication;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Version;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler;
@ -83,6 +84,14 @@ class Extractor implements ExtractorInterface
4 => 'INSERTED<>$$$$]'
];
/**
* Current Joomla Version We are IN
*
* @var int
* @since 3.2.0
**/
protected int $currentVersion;
/**
* The custom code in local files that already exist in system
*
@ -190,26 +199,23 @@ class Extractor implements ExtractorInterface
/**
* Current User Object
*
* @var User
* @since 3.2.0
**/
protected User $user;
protected $user;
/**
* Database object to query local DB
*
* @var \JDatabaseDriver
* @since 3.2.0
**/
protected \JDatabaseDriver $db;
protected $db;
/**
* Database object to query local DB
*
* @var CMSApplication
* @since 3.2.0
**/
protected CMSApplication $app;
protected $app;
/**
* Constructor.
@ -220,16 +226,12 @@ class Extractor implements ExtractorInterface
* @param Reverse|null $reverse The compiler placeholder reverse object.
* @param Placeholder|null $placeholder The compiler component placeholder object.
* @param Pathfix|null $pathfix The compiler path fixing object.
* @param User|null $user The current User object.
* @param \JDatabaseDriver|null $db The Database Driver object.
* @param CMSApplication|null $app The CMS Application object.
*
* @throws \Exception
* @since 3.2.0
*/
public function __construct(?Config $config = null, ?Gui $gui = null, ?Paths $paths = null,
?Reverse $reverse = null, ?Placeholder $placeholder = null, ?Pathfix $pathfix = null,
?User $user = null, ?\JDatabaseDriver $db = null, ?CMSApplication $app = null)
?Reverse $reverse = null, ?Placeholder $placeholder = null, ?Pathfix $pathfix = null)
{
$this->config = $config ?: Compiler::_('Config');
$this->gui = $gui ?: Compiler::_('Customcode.Gui');
@ -237,9 +239,9 @@ class Extractor implements ExtractorInterface
$this->reverse = $reverse ?: Compiler::_('Placeholder.Reverse');
$this->componentPlaceholder = $placeholder ?: Compiler::_('Component.Placeholder');
$this->pathfix = $pathfix ?: Compiler::_('Utilities.Pathfix');
$this->user = $user ?: Factory::getUser();
$this->db = $db ?: Factory::getDbo();
$this->app = $app ?: Factory::getApplication();
$this->user = Factory::getUser();
$this->db = Factory::getDbo();
$this->app = Factory::getApplication();
// set today's date
$this->today = Factory::getDate()->toSql();
@ -261,6 +263,9 @@ class Extractor implements ExtractorInterface
// set the local placeholders
$this->placeholders = array_reverse($placeholders, true);
// set the current version
$this->currentVersion = (int) Version::MAJOR_VERSION;
}
/**
@ -613,6 +618,11 @@ class Extractor implements ExtractorInterface
1
); // 'target'
$this->new[$pointer[$targetKey]][]
= $this->db->quote(
$this->currentVersion
); // 'joomla_version'
$this->new[$pointer[$targetKey]][]
= $this->db->quote(
$commentType
@ -766,7 +776,7 @@ class Extractor implements ExtractorInterface
$query = $this->db->getQuery(true);
$continue = false;
// Insert columns.
$columns = array('path', 'type', 'target', 'comment_type',
$columns = array('path', 'type', 'target', 'joomla_version', 'comment_type',
'component', 'published', 'created', 'created_by',
'version', 'access', 'hashtarget', 'from_line',
'to_line', 'code', 'hashendtarget');

View File

@ -84,10 +84,9 @@ class Paths
/**
* Database object to query local DB
*
* @var \JDatabaseDriver
* @since 3.2.0
**/
protected \JDatabaseDriver $db;
protected $db;
/**
* Constructor.
@ -97,14 +96,13 @@ class Paths
* @param ComponentPlaceholder|null $componentPlaceholder The compiler component placeholder object.
* @param Customcode|null $customcode The compiler customcode object.
* @param Extractor|null $extractor The compiler language extractor object.
* @param \JDatabaseDriver|null $db The Database Driver object.
*
* @throws \Exception
* @since 3.2.0
*/
public function __construct(?Config $config = null, ?Placeholder $placeholder = null,
?ComponentPlaceholder $componentPlaceholder = null, ?Customcode $customcode = null,
?Extractor $extractor = null, ?\JDatabaseDriver $db = null)
?Extractor $extractor = null)
{
$this->config = $config ?: Compiler::_('Config');
$this->placeholder = $placeholder ?: Compiler::_('Placeholder');
@ -112,7 +110,7 @@ class Paths
$componentPlaceholder = $componentPlaceholder ?: Compiler::_('Component.Placeholder');
$this->customcode = $customcode ?: Compiler::_('Customcode');
$this->extractor = $extractor ?: Compiler::_('Language.Extractor');
$this->db = $db ?: Factory::getDbo();
$this->db = Factory::getDbo();
// load the placeholders to local array
$this->componentPlaceholder = $componentPlaceholder->get();

View File

@ -61,18 +61,16 @@ class Gui implements GuiInterface
/**
* Database object to query local DB
*
* @var \JDatabaseDriver
* @since 3.2.0
**/
protected \JDatabaseDriver $db;
protected $db;
/**
* Database object to query local DB
*
* @var CMSApplication
* @since 3.2.0
**/
protected CMSApplication $app;
protected $app;
/**
* Constructor.
@ -80,20 +78,17 @@ class Gui implements GuiInterface
* @param Config|null $config The compiler config object.
* @param Reverse|null $reverse The compiler placeholder reverse object.
* @param Parser|null $parser The powers parser object.
* @param \JDatabaseDriver|null $db The Database Driver object.
* @param CMSApplication|null $app The CMS Application object.
*
* @throws \Exception
* @since 3.2.0
*/
public function __construct(?Config $config = null, ?Reverse $reverse = null, ?Parser $parser = null,
?\JDatabaseDriver $db = null, ?CMSApplication $app = null)
public function __construct(?Config $config = null, ?Reverse $reverse = null, ?Parser $parser = null)
{
$this->config = $config ?: Compiler::_('Config');
$this->reverse = $reverse ?: Compiler::_('Placeholder.Reverse');
$this->parser = $parser ?: Compiler::_('Power.Parser');
$this->db = $db ?: Factory::getDbo();
$this->app = $app ?: Factory::getApplication();
$this->db = Factory::getDbo();
$this->app = Factory::getApplication();
}
/**

View File

@ -155,10 +155,9 @@ class Data
/**
* Database object to query local DB
*
* @var \JDatabaseDriver
* @since 3.2.0
**/
protected \JDatabaseDriver $db;
protected $db;
/**
* Constructor
@ -176,7 +175,6 @@ class Data
* @param Phpcustomview|null $php The modelling php admin view object.
* @param Ajaxcustomview|null $ajax The modelling ajax object.
* @param Custombuttons|null $custombuttons The modelling custombuttons object.
* @param \JDatabaseDriver|null $db The database object.
*
* @since 3.2.0
*/
@ -184,7 +182,7 @@ class Data
?Customcode $customcode = null, ?Gui $gui = null, ?Libraries $libraries = null,
?Templatelayout $templateLayout = null, ?Dynamicget $dynamic = null, ?Loader $loader = null,
?Javascriptcustomview $javascript = null, ?Csscustomview $css = null, ?Phpcustomview $php = null,
?Ajaxcustomview $ajax = null, ?Custombuttons $custombuttons = null, ?\JDatabaseDriver $db = null)
?Ajaxcustomview $ajax = null, ?Custombuttons $custombuttons = null)
{
$this->config = $config ?: Compiler::_('Config');
$this->event = $event ?: Compiler::_('Event');
@ -199,7 +197,7 @@ class Data
$this->php = $php ?: Compiler::_('Model.Phpcustomview');
$this->ajax = $ajax ?: Compiler::_('Model.Ajaxcustomview');
$this->custombuttons = $custombuttons ?: Compiler::_('Model.Custombuttons');
$this->db = $db ?: Factory::getDbo();
$this->db = Factory::getDbo();
}
/**
@ -222,13 +220,9 @@ class Data
$query->from('#__componentbuilder_' . $table . ' AS a');
$query->where($this->db->quoteName('a.id') . ' = ' . (int) $id);
// for plugin event TODO change event api signatures
$component_context = $this->config->component_context;
// Trigger Event: jcb_ce_onBeforeQueryCustomViewData
$this->event->trigger(
'jcb_ce_onBeforeQueryCustomViewData',
array(&$component_context, &$id, &$table, &$query, &$this->db)
'jcb_ce_onBeforeQueryCustomViewData', [&$id, &$table, &$query, &$this->db]
);
// Reset the query using our newly populated query object.
@ -246,8 +240,7 @@ class Data
// Trigger Event: jcb_ce_onBeforeModelCustomViewData
$this->event->trigger(
'jcb_ce_onBeforeModelCustomViewData',
array(&$component_context, &$item, &$id, &$table)
'jcb_ce_onBeforeModelCustomViewData', [&$item, &$id, &$table]
);
// set GUI mapper
@ -325,8 +318,7 @@ class Data
// Trigger Event: jcb_ce_onAfterModelCustomViewData
$this->event->trigger(
'jcb_ce_onAfterModelCustomViewData',
array(&$component_context, &$item)
'jcb_ce_onAfterModelCustomViewData', [&$item]
);
// set the found data

View File

@ -104,10 +104,9 @@ class Data
/**
* Database object to query local DB
*
* @var \JDatabaseDriver
* @since 3.2.0
**/
protected \JDatabaseDriver $db;
protected $db;
/**
* Constructor
@ -119,14 +118,13 @@ class Data
* @param Dispenser|null $dispenser The compiler customcode dispenser object.
* @param Gui|null $gui The compiler customcode gui.
* @param Dynamicget|null $dynamic The compiler dynamicget modeller object.
* @param \JDatabaseDriver|null $db The database object.
*
* @since 3.2.0
*/
public function __construct(?Config $config = null, ?Registry $registry = null,
?EventInterface $event = null, ?Customcode $customcode = null,
?Dispenser $dispenser = null, ?Gui $gui = null,
?Dynamicget $dynamic = null, ?\JDatabaseDriver $db = null)
?Dynamicget $dynamic = null)
{
$this->config = $config ?: Compiler::_('Config');
$this->registry = $registry ?: Compiler::_('Registry');
@ -135,7 +133,7 @@ class Data
$this->dispenser = $dispenser ?: Compiler::_('Customcode.Dispenser');
$this->gui = $gui ?: Compiler::_('Customcode.Gui');
$this->dynamic = $dynamic ?: Compiler::_('Model.Dynamicget');
$this->db = $db ?: Factory::getDbo();
$this->db = Factory::getDbo();
}
/**
@ -157,9 +155,6 @@ class Data
$ids = implode(',', $ids);
// for plugin event TODO change event api signatures
$component_context = $this->config->component_context;
// Create a new query object.
$query = $this->db->getQuery(true);
$query->select('a.*');
@ -176,8 +171,7 @@ class Data
{
// Trigger Event: jcb_ce_onBeforeModelDynamicGetData
$this->event->trigger(
'jcb_ce_onBeforeModelDynamicGetData',
array(&$component_context, &$result, &$result->id, &$view_code, &$context)
'jcb_ce_onBeforeModelDynamicGetData', [&$result, &$result->id, &$view_code, &$context]
);
// set GUI mapper id
@ -310,8 +304,7 @@ class Data
// Trigger Event: jcb_ce_onAfterModelDynamicGetData
$this->event->trigger(
'jcb_ce_onAfterModelDynamicGetData',
array(&$component_context, &$result, &$result->id, &$view_code, &$context)
'jcb_ce_onAfterModelDynamicGetData', [&$result, &$result->id, &$view_code, &$context]
);
}

View File

@ -65,10 +65,9 @@ class Selection
/**
* Database object to query local DB
*
* @var \JDatabaseDriver
* @since 3.2.0
**/
protected \JDatabaseDriver $db;
protected $db;
/**
* Constructor.
@ -76,17 +75,15 @@ class Selection
* @param Config $config The Config Class.
* @param GetAsLookup $getaslookup The GetAsLookup Class.
* @param SiteFields $sitefields The SiteFields Class.
* @param \JDatabaseDriver|null $db The database object.
*
* @since 3.2.0
*/
public function __construct(Config $config, GetAsLookup $getaslookup, SiteFields $sitefields,
?\JDatabaseDriver $db = null)
public function __construct(Config $config, GetAsLookup $getaslookup, SiteFields $sitefields)
{
$this->config = $config;
$this->getaslookup = $getaslookup;
$this->sitefields = $sitefields;
$this->db = $db ?: Factory::getDbo();
$this->db = Factory::getDbo();
}
/**
@ -251,6 +248,7 @@ class Selection
return [
'select' => $querySelect,
'from' => $queryFrom,
'view' => $viewCode,
'name' => $queryName,
'table' => $table,
'type' => $type,

View File

@ -0,0 +1,374 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Compiler\Extension\JoomlaFive;
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Extension\InstallInterface;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Line;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent;
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\GetScriptInterface;
/**
* Loading the Extension Installation Script Class
*
* @since 3.2.0
*/
final class InstallScript implements GetScriptInterface
{
/**
* The extension
*
* @var InstallInterface|Object
* @since 3.2.0
*/
protected object $extension;
/**
* The methods
*
* @var array
* @since 3.2.0
*/
protected array $methods = ['php_script', 'php_preflight', 'php_postflight', 'php_method'];
/**
* The types
*
* @var array
* @since 3.2.0
*/
protected array $types = ['construct', 'install', 'update', 'uninstall', 'discover_install'];
/**
* The construct bucket
*
* @var array
* @since 3.2.0
*/
protected array $construct = [];
/**
* The install bucket
*
* @var array
* @since 3.2.0
*/
protected array $install = [];
/**
* The update bucket
*
* @var array
* @since 3.2.0
*/
protected array $update = [];
/**
* The uninstall bucket
*
* @var array
* @since 3.2.0
*/
protected array $uninstall = [];
/**
* The preflight switch
*
* @var bool
* @since 3.2.0
*/
protected bool $preflightActive = false;
/**
* The preflight bucket
*
* @var array
* @since 3.2.0
*/
protected array $preflightBucket = ['install' => [], 'uninstall' => [], 'discover_install' => [], 'update' => []];
/**
* The postflight switch
*
* @var bool
* @since 3.2.0
*/
protected bool $postflightActive = false;
/**
* The postflight bucket
*
* @var array
* @since 3.2.0
*/
protected array $postflightBucket = ['install' => [], 'uninstall' => [], 'discover_install' => [], 'update' => []];
/**
* get install script
*
* @param Object $extension The extension object
*
* @return string
* @since 3.2.0
*/
public function get(object $extension): string
{
// loop over methods and types
foreach ($this->methods as $method)
{
foreach ($this->types as $type)
{
if (isset($extension->{'add_' . $method . '_' . $type})
&& $extension->{'add_' . $method . '_' . $type} == 1
&& StringHelper::check(
$extension->{$method . '_' . $type}
))
{
// add to the main methods
if ('php_method' === $method || 'php_script' === $method)
{
$this->{$type}[] = $extension->{$method . '_' . $type};
}
else
{
// get the flight key
$flight = str_replace('php_', '', (string) $method);
// load the script to our bucket
$this->{$flight . 'Bucket'}[$type][] = $extension->{$method . '_' . $type};
// show that the method is active
$this->{$flight . 'Active'} = true;
}
}
}
}
$this->extension = $extension;
// return the class
return $this->build();
}
/**
* build the install class
*
* @return string
* @since 3.2.0
*/
protected function build(): string
{
// start build
$script = $this->head();
// load constructor if set
$script .= $this->construct();
// load install method if set
$script .= $this->main('install');
// load update method if set
$script .= $this->main('update');
// load uninstall method if set
$script .= $this->main('uninstall');
// load preflight method if set
$script .= $this->flight('preflight');
// load postflight method if set
$script .= $this->flight('postflight');
// close the class
$script .= PHP_EOL . '}' . PHP_EOL;
return $script;
}
/**
* get install script head
*
* @return string
* @since 3.2.0
*/
protected function head(): string
{
// get the extension
$extension = $this->extension;
// start build
$script = PHP_EOL . 'use Joomla\CMS\Factory;';
$script .= PHP_EOL . 'use Joomla\CMS\Language\Text;';
$script .= PHP_EOL . 'use Joomla\CMS\Filesystem\File;';
$script .= PHP_EOL . 'use Joomla\CMS\Filesystem\Folder;' . PHP_EOL;
$script .= PHP_EOL . '/**';
$script .= PHP_EOL . ' * ' . $extension->official_name
. ' script file.';
$script .= PHP_EOL . ' *';
$script .= PHP_EOL . ' * @package ' . $extension->class_name;
$script .= PHP_EOL . ' */';
$script .= PHP_EOL . 'class ' . $extension->installer_class_name;
$script .= PHP_EOL . '{';
return $script;
}
/**
* get constructor
*
* @return string
* @since 3.2.0
*/
protected function construct(): string
{
// return empty string if not set
if (!ArrayHelper::check($this->construct))
{
return '';
}
// the __construct script
$script = PHP_EOL . PHP_EOL . Indent::_(1) . '/**';
$script .= PHP_EOL . Indent::_(1) . ' * Constructor';
$script .= PHP_EOL . Indent::_(1) . ' *';
$script .= PHP_EOL . Indent::_(1)
. ' * @param Joomla\CMS\Installer\InstallerAdapter $adapter The object responsible for running this script';
$script .= PHP_EOL . Indent::_(1) . ' */';
$script .= PHP_EOL . Indent::_(1)
. 'public function __construct($adapter)';
$script .= PHP_EOL . Indent::_(1) . '{';
$script .= PHP_EOL . implode(PHP_EOL . PHP_EOL, $this->construct);
// close the function
$script .= PHP_EOL . Indent::_(1) . '}';
return $script;
}
/**
* build main methods
*
* @param string $name the method being called
*
* @return string
* @since 3.2.0
*/
protected function main(string $name): string
{
// return empty string if not set
if (!ArrayHelper::check($this->{$name}))
{
return '';
}
// load the install method
$script = PHP_EOL . PHP_EOL . Indent::_(1) . '/**';
$script .= PHP_EOL . Indent::_(1) . " * Called on $name";
$script .= PHP_EOL . Indent::_(1) . ' *';
$script .= PHP_EOL . Indent::_(1)
. ' * @param Joomla\CMS\Installer\InstallerAdapter $adapter The object responsible for running this script';
$script .= PHP_EOL . Indent::_(1) . ' *';
$script .= PHP_EOL . Indent::_(1)
. ' * @return boolean True on success';
$script .= PHP_EOL . Indent::_(1) . ' */';
$script .= PHP_EOL . Indent::_(1) . 'public function '
. $name . '($adapter)';
$script .= PHP_EOL . Indent::_(1) . '{';
$script .= PHP_EOL . implode(PHP_EOL . PHP_EOL, $this->{$name});
// return true
if ('uninstall' !== $name)
{
$script .= PHP_EOL . Indent::_(2) . 'return true;';
}
// close the function
$script .= PHP_EOL . Indent::_(1) . '}';
return $script;
}
/**
* build flight methods
*
* @param string $name the method being called
*
* @return string
* @since 3.2.0
*/
protected function flight(string $name): string
{
// return empty string if not set
if (empty($this->{$name . 'Active'}))
{
return '';
}
// the pre/post function types
$script = PHP_EOL . PHP_EOL . Indent::_(1) . '/**';
$script .= PHP_EOL . Indent::_(1)
. ' * Called before any type of action';
$script .= PHP_EOL . Indent::_(1) . ' *';
$script .= PHP_EOL . Indent::_(1)
. ' * @param string $route Which action is happening (install|uninstall|discover_install|update)';
$script .= PHP_EOL . Indent::_(1)
. ' * @param Joomla\CMS\Installer\InstallerAdapter $adapter The object responsible for running this script';
$script .= PHP_EOL . Indent::_(1) . ' *';
$script .= PHP_EOL . Indent::_(1)
. ' * @return boolean True on success';
$script .= PHP_EOL . Indent::_(1) . ' */';
$script .= PHP_EOL . Indent::_(1) . 'public function '
. $name . '($route, $adapter)';
$script .= PHP_EOL . Indent::_(1) . '{';
$script .= PHP_EOL . Indent::_(2) . '//' . Line::_(__Line__, __Class__)
. ' get application';
$script .= PHP_EOL . Indent::_(2)
. '$app = Factory::getApplication();' . PHP_EOL;
// add the default version check (TODO) must make this dynamic
if ('preflight' === $name)
{
$script .= PHP_EOL . Indent::_(2) . '//' . Line::_(__Line__, __Class__)
.' the default for both install and update';
$script .= PHP_EOL . Indent::_(2)
. '$jversion = new JVersion();';
$script .= PHP_EOL . Indent::_(2)
. "if (!\$jversion->isCompatible('3.8.0'))";
$script .= PHP_EOL . Indent::_(2) . '{';
$script .= PHP_EOL . Indent::_(3)
. "\$app->enqueueMessage('Please upgrade to at least Joomla! 3.8.0 before continuing!', 'error');";
$script .= PHP_EOL . Indent::_(3) . 'return false;';
$script .= PHP_EOL . Indent::_(2) . '}' . PHP_EOL;
}
// now add the scripts
foreach ($this->{$name . 'Bucket'} as $route => $_script)
{
if (ArrayHelper::check($_script))
{
// set the if and script
$script .= PHP_EOL . Indent::_(2) . "if ('" . $route
. "' === \$route)";
$script .= PHP_EOL . Indent::_(2) . '{';
$script .= PHP_EOL . implode(
PHP_EOL . PHP_EOL, $_script
);
$script .= PHP_EOL . Indent::_(2) . '}' . PHP_EOL;
}
}
// return true
$script .= PHP_EOL . Indent::_(2) . 'return true;';
// close the function
$script .= PHP_EOL . Indent::_(1) . '}';
return $script;
}
}

View File

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

View File

@ -0,0 +1,374 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Compiler\Extension\JoomlaFour;
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Extension\InstallInterface;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Line;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent;
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\GetScriptInterface;
/**
* Loading the Extension Installation Script Class
*
* @since 3.2.0
*/
final class InstallScript implements GetScriptInterface
{
/**
* The extension
*
* @var InstallInterface|Object
* @since 3.2.0
*/
protected object $extension;
/**
* The methods
*
* @var array
* @since 3.2.0
*/
protected array $methods = ['php_script', 'php_preflight', 'php_postflight', 'php_method'];
/**
* The types
*
* @var array
* @since 3.2.0
*/
protected array $types = ['construct', 'install', 'update', 'uninstall', 'discover_install'];
/**
* The construct bucket
*
* @var array
* @since 3.2.0
*/
protected array $construct = [];
/**
* The install bucket
*
* @var array
* @since 3.2.0
*/
protected array $install = [];
/**
* The update bucket
*
* @var array
* @since 3.2.0
*/
protected array $update = [];
/**
* The uninstall bucket
*
* @var array
* @since 3.2.0
*/
protected array $uninstall = [];
/**
* The preflight switch
*
* @var bool
* @since 3.2.0
*/
protected bool $preflightActive = false;
/**
* The preflight bucket
*
* @var array
* @since 3.2.0
*/
protected array $preflightBucket = ['install' => [], 'uninstall' => [], 'discover_install' => [], 'update' => []];
/**
* The postflight switch
*
* @var bool
* @since 3.2.0
*/
protected bool $postflightActive = false;
/**
* The postflight bucket
*
* @var array
* @since 3.2.0
*/
protected array $postflightBucket = ['install' => [], 'uninstall' => [], 'discover_install' => [], 'update' => []];
/**
* get install script
*
* @param Object $extension The extension object
*
* @return string
* @since 3.2.0
*/
public function get(object $extension): string
{
// loop over methods and types
foreach ($this->methods as $method)
{
foreach ($this->types as $type)
{
if (isset($extension->{'add_' . $method . '_' . $type})
&& $extension->{'add_' . $method . '_' . $type} == 1
&& StringHelper::check(
$extension->{$method . '_' . $type}
))
{
// add to the main methods
if ('php_method' === $method || 'php_script' === $method)
{
$this->{$type}[] = $extension->{$method . '_' . $type};
}
else
{
// get the flight key
$flight = str_replace('php_', '', (string) $method);
// load the script to our bucket
$this->{$flight . 'Bucket'}[$type][] = $extension->{$method . '_' . $type};
// show that the method is active
$this->{$flight . 'Active'} = true;
}
}
}
}
$this->extension = $extension;
// return the class
return $this->build();
}
/**
* build the install class
*
* @return string
* @since 3.2.0
*/
protected function build(): string
{
// start build
$script = $this->head();
// load constructor if set
$script .= $this->construct();
// load install method if set
$script .= $this->main('install');
// load update method if set
$script .= $this->main('update');
// load uninstall method if set
$script .= $this->main('uninstall');
// load preflight method if set
$script .= $this->flight('preflight');
// load postflight method if set
$script .= $this->flight('postflight');
// close the class
$script .= PHP_EOL . '}' . PHP_EOL;
return $script;
}
/**
* get install script head
*
* @return string
* @since 3.2.0
*/
protected function head(): string
{
// get the extension
$extension = $this->extension;
// start build
$script = PHP_EOL . 'use Joomla\CMS\Factory;';
$script .= PHP_EOL . 'use Joomla\CMS\Language\Text;';
$script .= PHP_EOL . 'use Joomla\CMS\Filesystem\File;';
$script .= PHP_EOL . 'use Joomla\CMS\Filesystem\Folder;' . PHP_EOL;
$script .= PHP_EOL . '/**';
$script .= PHP_EOL . ' * ' . $extension->official_name
. ' script file.';
$script .= PHP_EOL . ' *';
$script .= PHP_EOL . ' * @package ' . $extension->class_name;
$script .= PHP_EOL . ' */';
$script .= PHP_EOL . 'class ' . $extension->installer_class_name;
$script .= PHP_EOL . '{';
return $script;
}
/**
* get constructor
*
* @return string
* @since 3.2.0
*/
protected function construct(): string
{
// return empty string if not set
if (!ArrayHelper::check($this->construct))
{
return '';
}
// the __construct script
$script = PHP_EOL . PHP_EOL . Indent::_(1) . '/**';
$script .= PHP_EOL . Indent::_(1) . ' * Constructor';
$script .= PHP_EOL . Indent::_(1) . ' *';
$script .= PHP_EOL . Indent::_(1)
. ' * @param Joomla\CMS\Installer\InstallerAdapter $adapter The object responsible for running this script';
$script .= PHP_EOL . Indent::_(1) . ' */';
$script .= PHP_EOL . Indent::_(1)
. 'public function __construct($adapter)';
$script .= PHP_EOL . Indent::_(1) . '{';
$script .= PHP_EOL . implode(PHP_EOL . PHP_EOL, $this->construct);
// close the function
$script .= PHP_EOL . Indent::_(1) . '}';
return $script;
}
/**
* build main methods
*
* @param string $name the method being called
*
* @return string
* @since 3.2.0
*/
protected function main(string $name): string
{
// return empty string if not set
if (!ArrayHelper::check($this->{$name}))
{
return '';
}
// load the install method
$script = PHP_EOL . PHP_EOL . Indent::_(1) . '/**';
$script .= PHP_EOL . Indent::_(1) . " * Called on $name";
$script .= PHP_EOL . Indent::_(1) . ' *';
$script .= PHP_EOL . Indent::_(1)
. ' * @param Joomla\CMS\Installer\InstallerAdapter $adapter The object responsible for running this script';
$script .= PHP_EOL . Indent::_(1) . ' *';
$script .= PHP_EOL . Indent::_(1)
. ' * @return boolean True on success';
$script .= PHP_EOL . Indent::_(1) . ' */';
$script .= PHP_EOL . Indent::_(1) . 'public function '
. $name . '($adapter)';
$script .= PHP_EOL . Indent::_(1) . '{';
$script .= PHP_EOL . implode(PHP_EOL . PHP_EOL, $this->{$name});
// return true
if ('uninstall' !== $name)
{
$script .= PHP_EOL . Indent::_(2) . 'return true;';
}
// close the function
$script .= PHP_EOL . Indent::_(1) . '}';
return $script;
}
/**
* build flight methods
*
* @param string $name the method being called
*
* @return string
* @since 3.2.0
*/
protected function flight(string $name): string
{
// return empty string if not set
if (empty($this->{$name . 'Active'}))
{
return '';
}
// the pre/post function types
$script = PHP_EOL . PHP_EOL . Indent::_(1) . '/**';
$script .= PHP_EOL . Indent::_(1)
. ' * Called before any type of action';
$script .= PHP_EOL . Indent::_(1) . ' *';
$script .= PHP_EOL . Indent::_(1)
. ' * @param string $route Which action is happening (install|uninstall|discover_install|update)';
$script .= PHP_EOL . Indent::_(1)
. ' * @param Joomla\CMS\Installer\InstallerAdapter $adapter The object responsible for running this script';
$script .= PHP_EOL . Indent::_(1) . ' *';
$script .= PHP_EOL . Indent::_(1)
. ' * @return boolean True on success';
$script .= PHP_EOL . Indent::_(1) . ' */';
$script .= PHP_EOL . Indent::_(1) . 'public function '
. $name . '($route, $adapter)';
$script .= PHP_EOL . Indent::_(1) . '{';
$script .= PHP_EOL . Indent::_(2) . '//' . Line::_(__Line__, __Class__)
. ' get application';
$script .= PHP_EOL . Indent::_(2)
. '$app = Factory::getApplication();' . PHP_EOL;
// add the default version check (TODO) must make this dynamic
if ('preflight' === $name)
{
$script .= PHP_EOL . Indent::_(2) . '//' . Line::_(__Line__, __Class__)
.' the default for both install and update';
$script .= PHP_EOL . Indent::_(2)
. '$jversion = new JVersion();';
$script .= PHP_EOL . Indent::_(2)
. "if (!\$jversion->isCompatible('3.8.0'))";
$script .= PHP_EOL . Indent::_(2) . '{';
$script .= PHP_EOL . Indent::_(3)
. "\$app->enqueueMessage('Please upgrade to at least Joomla! 3.8.0 before continuing!', 'error');";
$script .= PHP_EOL . Indent::_(3) . 'return false;';
$script .= PHP_EOL . Indent::_(2) . '}' . PHP_EOL;
}
// now add the scripts
foreach ($this->{$name . 'Bucket'} as $route => $_script)
{
if (ArrayHelper::check($_script))
{
// set the if and script
$script .= PHP_EOL . Indent::_(2) . "if ('" . $route
. "' === \$route)";
$script .= PHP_EOL . Indent::_(2) . '{';
$script .= PHP_EOL . implode(
PHP_EOL . PHP_EOL, $_script
);
$script .= PHP_EOL . Indent::_(2) . '}' . PHP_EOL;
}
}
// return true
$script .= PHP_EOL . Indent::_(2) . 'return true;';
// close the function
$script .= PHP_EOL . Indent::_(1) . '}';
return $script;
}
}

View File

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

View File

@ -25,7 +25,7 @@ use VDM\Joomla\Componentbuilder\Compiler\Interfaces\GetScriptInterface;
*
* @since 3.2.0
*/
class InstallScript implements GetScriptInterface
final class InstallScript implements GetScriptInterface
{
/**
* The extension
@ -207,7 +207,11 @@ class InstallScript implements GetScriptInterface
$extension = $this->extension;
// start build
$script = PHP_EOL . '/**';
$script = PHP_EOL . 'use Joomla\CMS\Factory;';
$script .= PHP_EOL . 'use Joomla\CMS\Language\Text;';
$script .= PHP_EOL . 'use Joomla\CMS\Filesystem\File;';
$script .= PHP_EOL . 'use Joomla\CMS\Filesystem\Folder;' . PHP_EOL;
$script .= PHP_EOL . '/**';
$script .= PHP_EOL . ' * ' . $extension->official_name
. ' script file.';
$script .= PHP_EOL . ' *';
@ -325,7 +329,7 @@ class InstallScript implements GetScriptInterface
$script .= PHP_EOL . Indent::_(2) . '//' . Line::_(__Line__, __Class__)
. ' get application';
$script .= PHP_EOL . Indent::_(2)
. '$app = JFactory::getApplication();' . PHP_EOL;
. '$app = Factory::getApplication();' . PHP_EOL;
// add the default version check (TODO) must make this dynamic
if ('preflight' === $name)

View File

@ -19,6 +19,7 @@ use VDM\Joomla\Componentbuilder\Service\Database;
use VDM\Joomla\Componentbuilder\Compiler\Service\Model;
use VDM\Joomla\Componentbuilder\Compiler\Service\Compiler;
use VDM\Joomla\Componentbuilder\Compiler\Service\Event;
use VDM\Joomla\Componentbuilder\Compiler\Service\Header;
use VDM\Joomla\Componentbuilder\Compiler\Service\History;
use VDM\Joomla\Componentbuilder\Compiler\Service\Language;
use VDM\Joomla\Componentbuilder\Compiler\Service\Placeholder;
@ -34,8 +35,11 @@ use VDM\Joomla\Componentbuilder\Compiler\Service\Field;
use VDM\Joomla\Componentbuilder\Compiler\Service\Joomlamodule;
use VDM\Joomla\Componentbuilder\Compiler\Service\Joomlaplugin;
use VDM\Joomla\Componentbuilder\Compiler\Service\Utilities;
use VDM\Joomla\Componentbuilder\Compiler\Service\Builder;
use VDM\Joomla\Componentbuilder\Compiler\Service\BuilderAJ;
use VDM\Joomla\Componentbuilder\Compiler\Service\BuilderLZ;
use VDM\Joomla\Componentbuilder\Compiler\Service\Creator;
use VDM\Joomla\Componentbuilder\Compiler\Service\ArchitectureController;
use VDM\Joomla\Componentbuilder\Compiler\Service\ArchitectureModel;
use VDM\Joomla\Componentbuilder\Service\Gitea;
use VDM\Joomla\Gitea\Service\Utilities as GiteaUtilities;
use VDM\Joomla\Gitea\Service\Settings as GiteaSettings;
@ -146,6 +150,7 @@ abstract class Factory implements FactoryInterface
->registerServiceProvider(new Model())
->registerServiceProvider(new Compiler())
->registerServiceProvider(new Event())
->registerServiceProvider(new Header())
->registerServiceProvider(new History())
->registerServiceProvider(new Language())
->registerServiceProvider(new Placeholder())
@ -161,8 +166,11 @@ abstract class Factory implements FactoryInterface
->registerServiceProvider(new Joomlamodule())
->registerServiceProvider(new Joomlaplugin())
->registerServiceProvider(new Utilities())
->registerServiceProvider(new Builder())
->registerServiceProvider(new BuilderAJ())
->registerServiceProvider(new BuilderLZ())
->registerServiceProvider(new Creator())
->registerServiceProvider(new ArchitectureController())
->registerServiceProvider(new ArchitectureModel())
->registerServiceProvider(new Gitea())
->registerServiceProvider(new GiteaUtilities())
->registerServiceProvider(new GiteaSettings())

View File

@ -13,17 +13,16 @@ namespace VDM\Joomla\Componentbuilder\Compiler\Field;
use Joomla\CMS\Factory;
use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler;
use VDM\Joomla\Utilities\JsonHelper;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Componentbuilder\Compiler\Config;
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\EventInterface;
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\HistoryInterface;
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\EventInterface as Event;
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\HistoryInterface as History;
use VDM\Joomla\Componentbuilder\Compiler\Placeholder;
use VDM\Joomla\Componentbuilder\Compiler\Customcode;
use VDM\Joomla\Componentbuilder\Compiler\Field\Customcode as FieldCustomcode;
use VDM\Joomla\Componentbuilder\Compiler\Field\Validation;
use VDM\Joomla\Componentbuilder\Compiler\Field\Rule;
use VDM\Joomla\Utilities\JsonHelper;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Utilities\StringHelper;
/**
@ -42,95 +41,93 @@ class Data
protected array $fields;
/**
* Compiler Config
* The Config Class.
*
* @var Config
* @var Config
* @since 3.2.0
*/
protected Config $config;
/**
* Compiler Event
* The EventInterface Class.
*
* @var EventInterface
* @var Event
* @since 3.2.0
*/
protected EventInterface $event;
protected Event $event;
/**
* Compiler History
* The HistoryInterface Class.
*
* @var HistoryInterface
* @var History
* @since 3.2.0
*/
protected HistoryInterface $history;
protected History $history;
/**
* Compiler Placeholder
* The Placeholder Class.
*
* @var Placeholder
* @var Placeholder
* @since 3.2.0
*/
protected Placeholder $placeholder;
/**
* Compiler Customcode
* The Customcode Class.
*
* @var Customcode
* @var Customcode
* @since 3.2.0
*/
protected Customcode $customcode;
/**
* Compiler Field Customcode
* The Customcode Class.
*
* @var FieldCustomcode
* @var FieldCustomcode
* @since 3.2.0
*/
protected FieldCustomcode $fieldCustomcode;
protected FieldCustomcode $fieldcustomcode;
/**
* Compiler Field Validation
* The Rule Class.
*
* @var Validation
* @var Rule
* @since 3.2.0
*/
protected Validation $validation;
protected Rule $rule;
/**
* Database object to query local DB
*
* @var \JDatabaseDriver
* @since 3.2.0
**/
protected \JDatabaseDriver $db;
/**
* Constructor
*
* @param Config|null $config The compiler config object.
* @param EventInterface|null $event The compiler event api object.
* @param HistoryInterface|null $history The compiler history object.
* @param Placeholder|null $placeholder The compiler placeholder object.
* @param Customcode|null $customcode The compiler customcode object.
* @param FieldCustomcode|null $fieldCustomcode The field customcode object.
* @param Validation|null $validation The field validation rule object.
* @param \JDatabaseDriver|null $db The database object.
* The database class.
*
* @since 3.2.0
*/
public function __construct(?Config $config = null, ?EventInterface $event = null, ?HistoryInterface $history = null,
?Placeholder $placeholder = null, ?Customcode $customcode = null, ?FieldCustomcode $fieldCustomcode = null,
?Validation $validation = null, ?\JDatabaseDriver $db = null)
protected $db;
/**
* Constructor.
*
* @param Config $config The Config Class.
* @param Event $event The EventInterface Class.
* @param History $history The HistoryInterface Class.
* @param Placeholder $placeholder The Placeholder Class.
* @param Customcode $customcode The Customcode Class.
* @param FieldCustomcode $fieldcustomcode The Customcode Class.
* @param Rule $rule The Rule Class.
*
* @since 3.2.0
*/
public function __construct(Config $config, Event $event, History $history,
Placeholder $placeholder, Customcode $customcode,
FieldCustomcode $fieldcustomcode, Rule $rule)
{
$this->config = $config ?: Compiler::_('Config');
$this->event = $event ?: Compiler::_('Event');
$this->history = $history ?: Compiler::_('History');
$this->placeholder = $placeholder ?: Compiler::_('Placeholder');
$this->customcode = $customcode ?: Compiler::_('Customcode');
$this->fieldCustomcode = $fieldCustomcode ?: Compiler::_('Field.Customcode');
$this->validation = $validation ?: Compiler::_('Field.Validation');
$this->db = $db ?: Factory::getDbo();
$this->config = $config;
$this->event = $event;
$this->history = $history;
$this->placeholder = $placeholder;
$this->customcode = $customcode;
$this->fieldcustomcode = $fieldcustomcode;
$this->rule = $rule;
$this->db = Factory::getDbo();
}
/**
@ -169,13 +166,9 @@ class Data
$this->db->quoteName('a.id') . ' = ' . $this->db->quote($id)
);
// TODO we need to update the event signatures
$context = $this->config->component_context;
// Trigger Event: jcb_ce_onBeforeQueryFieldData
$this->event->trigger(
'jcb_ce_onBeforeQueryFieldData',
array(&$context, &$id, &$query, &$this->db)
'jcb_ce_onBeforeQueryFieldData', [&$id, &$query, &$this->db]
);
// Reset the query using our newly populated query object.
@ -188,8 +181,7 @@ class Data
// Trigger Event: jcb_ce_onBeforeModelFieldData
$this->event->trigger(
'jcb_ce_onBeforeModelFieldData',
array(&$context, &$field)
'jcb_ce_onBeforeModelFieldData', [&$field]
);
// adding a fix for the changed name of type to fieldtype
@ -199,7 +191,7 @@ class Data
$field->xml = $this->customcode->update(json_decode((string) $field->xml));
// check if we have validate (validation rule and set it if found)
$this->validation->set($id, $field->xml);
$this->rule->set($id, $field->xml);
// load the type values form type params
$field->properties = (isset($field->properties)
@ -301,8 +293,7 @@ class Data
// Trigger Event: jcb_ce_onAfterModelFieldData
$this->event->trigger(
'jcb_ce_onAfterModelFieldData',
array(&$context, &$field)
'jcb_ce_onAfterModelFieldData', [&$field]
);
$this->fields[$id] = $field;
@ -316,14 +307,13 @@ class Data
if ($id > 0 && isset($this->fields[$id]))
{
// update the customcode of the field
$this->fieldCustomcode->update($id, $this->fields[$id], $singleViewName, $listViewName);
$this->fieldcustomcode->update($id, $this->fields[$id], $singleViewName, $listViewName);
// return the field
return $this->fields[$id];
}
return null;
}
}
}

View File

@ -71,21 +71,18 @@ final class Groups
/**
* Database object to query local DB
*
* @var \JDatabaseDriver
* @since 3.2.0
*/
protected \JDatabaseDriver $db;
protected $db;
/**
* Constructor
*
* @param \JDatabaseDriver|null $db The Database Driver object.
*
* @since 3.2.0
*/
public function __construct(?\JDatabaseDriver $db = null)
public function __construct()
{
$this->db = $db ?: Factory::getDbo();
$this->db = Factory::getDbo();
}
/**

View File

@ -0,0 +1,129 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Compiler\Field\JoomlaFive;
use Joomla\CMS\Filesystem\Folder;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Field\CoreFieldInterface;
/**
* Core Joomla Fields
*
* @since 3.2.0
*/
final class CoreField implements CoreFieldInterface
{
/**
* Local Core Joomla Fields
*
* @var array|null
* @since 3.2.0
**/
protected array $fields = [];
/**
* Local Core Joomla Fields Path
*
* @var array
* @since 3.2.0
**/
protected array $paths = [];
/**
* Constructor
*
* @since 3.2.0
*/
public function __construct()
{
// set the path to the form validation fields
$this->paths[] = JPATH_LIBRARIES . '/src/Form/Field';
}
/**
* Get the Array of Existing Validation Field Names
*
* @param bool $lowercase Switch to set fields lowercase
*
* @return array
* @since 3.2.0
*/
public function get(bool $lowercase = false): array
{
if ($this->fields === [])
{
// check if the path exist
foreach ($this->paths as $path)
{
$this->set($path);
}
}
// return fields if found
if ($this->fields !== [])
{
// check if the names should be all lowercase
if ($lowercase)
{
return array_map(
fn($item): string => strtolower((string) $item),
$this->fields
);
}
return $this->fields;
}
// return empty array
return [];
}
/**
* Set the fields found in a path
*
* @param string $path The path to load fields from
* @return void
* @since 3.2.0
*/
private function set(string $path): void
{
// Check if the path exists
if (!Folder::exists($path))
{
return;
}
// Load all PHP files in this path
$fields = Folder::files($path, '\.php$', true, true);
// Process the files to extract field names
$processedFields = array_map(function ($name) {
$fileName = basename($name);
// Remove 'Field.php' if it exists or just '.php' otherwise
if (substr($fileName, -9) === 'Field.php')
{
return str_replace('Field.php', '', $fileName);
}
else
{
return str_replace('.php', '', $fileName);
}
}, $fields);
// Merge with existing fields and remove duplicates
$this->fields = array_unique(array_merge($processedFields, $this->fields));
}
}

View File

@ -0,0 +1,125 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Compiler\Field\JoomlaFive;
use Joomla\CMS\Filesystem\Folder;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Field\CoreRuleInterface;
/**
* Core Joomla Field Rules
*
* @since 3.2.0
*/
final class CoreRule implements CoreRuleInterface
{
/**
* Local Core Joomla Rules
*
* @var array
* @since 3.2.0
**/
protected array $rules = [];
/**
* Local Core Joomla Rules Path
*
* @var string
* @since 3.2.0
**/
protected string $path;
/**
* Constructor
*
* @since 3.2.0
*/
public function __construct()
{
// set the path to the form validation rules
$this->path = JPATH_LIBRARIES . '/src/Form/Rule';
}
/**
* Get the Array of Existing Validation Rule Names
*
* @param bool $lowercase Switch to set rules lowercase
*
* @return array
* @since 3.2.0
*/
public function get(bool $lowercase = false): array
{
if ($this->rules === [])
{
$this->set($this->path);
}
// return rules if found
if ($this->rules !== [])
{
// check if the names should be all lowercase
if ($lowercase)
{
return array_map(
fn($item): string => strtolower((string) $item),
$this->rules
);
}
return $this->rules;
}
// return empty array
return [];
}
/**
* Set the rules found in a path
*
* @param string $path The path to load rules from
* @return void
* @since 3.2.0
*/
private function set(string $path): void
{
// Check if the path exists
if (!Folder::exists($path))
{
return;
}
// Load all PHP files in this path
$rules = Folder::files($path, '\.php$', true, true);
// Process the files to extract rule names
$processedRules = array_map(function ($name) {
$fileName = basename($name);
// Remove 'Rule.php' if it exists or just '.php' otherwise
if (substr($fileName, -8) === 'Rule.php')
{
return str_replace('Rule.php', '', $fileName);
}
else
{
return str_replace('.php', '', $fileName);
}
}, $rules);
// Merge with existing rules and remove duplicates
$this->rules = array_unique(array_merge($processedRules, $this->rules));
}
}

View File

@ -0,0 +1,345 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Compiler\Field\JoomlaFive;
use VDM\Joomla\Componentbuilder\Compiler\Config;
use VDM\Joomla\Componentbuilder\Compiler\Placeholder;
use VDM\Joomla\Componentbuilder\Compiler\Creator\Permission;
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Placefix;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Line;
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Field\InputButtonInterface;
/**
* Compiler Field Input Button
*
* @since 3.2.0
*/
final class InputButton implements InputButtonInterface
{
/**
* The Config Class.
*
* @var Config
* @since 3.2.0
*/
protected Config $config;
/**
* The Placeholder Class.
*
* @var Placeholder
* @since 3.2.0
*/
protected Placeholder $placeholder;
/**
* The Permission Class.
*
* @var Permission
* @since 3.2.0
*/
protected Permission $permission;
/**
* Constructor.
*
* @param Config $config The Config Class.
* @param Placeholder $placeholder The Placeholder Class.
* @param Permission $permission The Permission Class.
*
* @since 3.2.0
*/
public function __construct(Config $config, Placeholder $placeholder,
Permission $permission)
{
$this->config = $config;
$this->placeholder = $placeholder;
$this->permission = $permission;
}
/**
* get Add Button To List Field Input (getInput tweak)
*
* @param array $fieldData The field custom data
*
* @return string of getInput class on success empty string otherwise
* @since 3.2.0
*/
public function get(array $fieldData): string
{
// make sure hte view values are set
if (isset($fieldData['add_button'])
&& ($fieldData['add_button'] === 'true'
|| 1 == $fieldData['add_button'])
&& isset($fieldData['view'])
&& isset($fieldData['views'])
&& StringHelper::check($fieldData['view'])
&& StringHelper::check($fieldData['views']))
{
// set local component
$local_component = "com_" . $this->config->component_code_name;
// check that the component value is set
if (!isset($fieldData['component'])
|| !StringHelper::check(
$fieldData['component']
))
{
$fieldData['component'] = $local_component;
}
// check that the component has the com_ value in it
if (strpos((string) $fieldData['component'], 'com_') === false
|| strpos((string) $fieldData['component'], '=') !== false)
{
$fieldData['component'] = "com_" . $fieldData['component'];
}
// make sure the component is update if # # # or [ [ [ component placeholder is used
if (strpos((string) $fieldData['component'], (string) Placefix::h()) !== false
|| strpos((string) $fieldData['component'], (string) Placefix::b()) !== false) // should not be needed... but
{
$fieldData['component'] = $this->placeholder->update_(
$fieldData['component']
);
}
// get core permissions
$coreLoad = false;
// add ref tags
$refLoad = true;
// fall back on the field component
$component = $fieldData['component'];
// check if we should add ref tags (since it only works well on local views)
if ($local_component !== $component)
{
// do not add ref tags
$refLoad = false;
}
// start building the add buttons/s
$addButton = array();
$addButton[] = PHP_EOL . PHP_EOL . Indent::_(1) . "/**";
$addButton[] = Indent::_(1) . " * Override to add new button";
$addButton[] = Indent::_(1) . " *";
$addButton[] = Indent::_(1)
. " * @return string The field input markup.";
$addButton[] = Indent::_(1) . " *";
$addButton[] = Indent::_(1) . " * @since 3.2";
$addButton[] = Indent::_(1) . " */";
$addButton[] = Indent::_(1) . "protected function getInput()";
$addButton[] = Indent::_(1) . "{";
$addButton[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
. " see if we should add buttons";
$addButton[] = Indent::_(2)
. "\$set_button = \$this->getAttribute('button');";
$addButton[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
. " get html";
$addButton[] = Indent::_(2) . "\$html = parent::getInput();";
$addButton[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
. " if true set button";
$addButton[] = Indent::_(2) . "if (\$set_button === 'true')";
$addButton[] = Indent::_(2) . "{";
$addButton[] = Indent::_(3) . "\$button = array();";
$addButton[] = Indent::_(3) . "\$script = array();";
$addButton[] = Indent::_(3)
. "\$button_code_name = \$this->getAttribute('name');";
$addButton[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__)
. " get the input from url";
$addButton[] = Indent::_(3) . "\$app = Factory::getApplication();";
$addButton[] = Indent::_(3) . "\$jinput = \$app->input;";
$addButton[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__)
. " get the view name & id";
$addButton[] = Indent::_(3)
. "\$values = \$jinput->getArray(array(";
$addButton[] = Indent::_(4) . "'id' => 'int',";
$addButton[] = Indent::_(4) . "'view' => 'word'";
$addButton[] = Indent::_(3) . "));";
$addButton[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__)
. " check if new item";
$addButton[] = Indent::_(3) . "\$ref = '';";
$addButton[] = Indent::_(3) . "\$refJ = '';";
if ($refLoad)
{
$addButton[] = Indent::_(3)
. "if (!is_null(\$values['id']) && strlen(\$values['view']))";
$addButton[] = Indent::_(3) . "{";
$addButton[] = Indent::_(4) . "//" . Line::_(__Line__, __Class__)
. " only load referral if not new item.";
$addButton[] = Indent::_(4)
. "\$ref = '&amp;ref=' . \$values['view'] . '&amp;refid=' . \$values['id'];";
$addButton[] = Indent::_(4)
. "\$refJ = '&ref=' . \$values['view'] . '&refid=' . \$values['id'];";
$addButton[] = Indent::_(4) . "//" . Line::_(__Line__, __Class__)
. " get the return value.";
$addButton[] = Indent::_(4)
. "\$_uri = (string) \Joomla\CMS\Uri\Uri::getInstance();";
$addButton[] = Indent::_(4)
. "\$_return = urlencode(base64_encode(\$_uri));";
$addButton[] = Indent::_(4) . "//" . Line::_(__Line__, __Class__)
. " load return value.";
$addButton[] = Indent::_(4)
. "\$ref .= '&amp;return=' . \$_return;";
$addButton[] = Indent::_(4)
. "\$refJ .= '&return=' . \$_return;";
$addButton[] = Indent::_(3) . "}";
}
else
{
$addButton[] = Indent::_(3)
. "if (!is_null(\$values['id']) && strlen(\$values['view']))";
$addButton[] = Indent::_(3) . "{";
$addButton[] = Indent::_(4) . "//" . Line::_(__Line__, __Class__)
. " only load field details if not new item.";
$addButton[] = Indent::_(4)
. "\$ref = '&amp;field=' . \$values['view'] . '&amp;field_id=' . \$values['id'];";
$addButton[] = Indent::_(4)
. "\$refJ = '&field=' . \$values['view'] . '&field_id=' . \$values['id'];";
$addButton[] = Indent::_(4) . "//" . Line::_(__Line__, __Class__)
. " get the return value.";
$addButton[] = Indent::_(4)
. "\$_uri = (string) \Joomla\CMS\Uri\Uri::getInstance();";
$addButton[] = Indent::_(4)
. "\$_return = urlencode(base64_encode(\$_uri));";
$addButton[] = Indent::_(4) . "//" . Line::_(__Line__, __Class__)
. " load return value.";
$addButton[] = Indent::_(4)
. "\$ref = '&amp;return=' . \$_return;";
$addButton[] = Indent::_(4)
. "\$refJ = '&return=' . \$_return;";
$addButton[] = Indent::_(3) . "}";
}
$addButton[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__)
. " get button label";
$addButton[] = Indent::_(3)
. "\$button_label = trim(\$button_code_name);";
$addButton[] = Indent::_(3)
. "\$button_label = preg_replace('/_+/', ' ', \$button_label);";
$addButton[] = Indent::_(3)
. "\$button_label = preg_replace('/\s+/', ' ', \$button_label);";
$addButton[] = Indent::_(3)
. "\$button_label = preg_replace(\"/[^A-Za-z ]/\", '', \$button_label);";
$addButton[] = Indent::_(3)
. "\$button_label = ucfirst(strtolower(\$button_label));";
$addButton[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__)
. " get user object";
$addButton[] = Indent::_(3) . "\$user = Factory::getApplication()->getIdentity();";
$addButton[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__)
. " only add if user allowed to create " . $fieldData['view'];
// check if the item has permissions.
$addButton[] = Indent::_(3) . "if (\$user->authorise('"
. $this->permission->getGlobal($fieldData['view'], 'core.create')
. "', '" . $component . "') && \$app->isClient('administrator')) // TODO for now only in admin area.";
$addButton[] = Indent::_(3) . "{";
$addButton[] = Indent::_(4) . "//" . Line::_(__Line__, __Class__)
. " build Create button";
$addButton[] = Indent::_(4)
. "\$button[] = '<a id=\"'.\$button_code_name.'Create\" class=\"btn btn-small btn-success hasTooltip\" title=\"'.Text:"
. ":sprintf('" . $this->config->lang_prefix
. "_CREATE_NEW_S', \$button_label).'\" style=\"border-radius: 0px 4px 4px 0px;\"";
$addButton[] = Indent::_(5) . "href=\"index.php?option="
. $fieldData['component'] . "&amp;view=" . $fieldData['view']
. "&amp;layout=edit'.\$ref.'\" >";
$addButton[] = Indent::_(5)
. "<span class=\"icon-new icon-white\"></span></a>';";
$addButton[] = Indent::_(3) . "}";
$addButton[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__)
. " only add if user allowed to edit " . $fieldData['view'];
// check if the item has permissions.
$addButton[] = Indent::_(3) . "if (\$user->authorise('"
. $this->permission->getGlobal($fieldData['view'], 'core.edit')
. "', '" . $component . "') && \$app->isClient('administrator')) // TODO for now only in admin area.";
$addButton[] = Indent::_(3) . "{";
$addButton[] = Indent::_(4) . "//" . Line::_(__Line__, __Class__)
. " build edit button";
$addButton[] = Indent::_(4)
. "\$button[] = '<a id=\"'.\$button_code_name.'Edit\" class=\"btn btn-small hasTooltip\" title=\"'.Text:"
. ":sprintf('" . $this->config->lang_prefix
. "_EDIT_S', \$button_label).'\" style=\"display: none; border-radius: 0px 4px 4px 0px;\" href=\"#\" >";
$addButton[] = Indent::_(5)
. "<span class=\"icon-edit\"></span></a>';";
$addButton[] = Indent::_(4) . "//" . Line::_(__Line__, __Class__)
. " build script";
$addButton[] = Indent::_(4) . "\$script[] = \"";
$addButton[] = Indent::_(5) . "document.addEventListener('DOMContentLoaded', function() {";
$addButton[] = Indent::_(6)
. "document.getElementById('jform_\".\$button_code_name.\"').addEventListener('change', function(e) {";
$addButton[] = Indent::_(7) . "e.preventDefault();";
$addButton[] = Indent::_(7)
. "let \".\$button_code_name.\"Value = this.value;";
$addButton[] = Indent::_(7)
. "\".\$button_code_name.\"Button(\".\$button_code_name.\"Value);";
$addButton[] = Indent::_(6) . "});";
$addButton[] = Indent::_(6)
. "let \".\$button_code_name.\"Value = document.getElementById('jform_\".\$button_code_name.\"').value;";
$addButton[] = Indent::_(6)
. "\".\$button_code_name.\"Button(\".\$button_code_name.\"Value);";
$addButton[] = Indent::_(5) . "});";
$addButton[] = Indent::_(5)
. "function \".\$button_code_name.\"Button(value) {";
$addButton[] = Indent::_(6)
. "var createButton = document.getElementById('\".\$button_code_name.\"Create');";
$addButton[] = Indent::_(6)
. "var editButton = document.getElementById('\".\$button_code_name.\"Edit');";
$addButton[] = Indent::_(6)
. "if (value > 0) {"; // TODO not ideal since value may not be an (int)
$addButton[] = Indent::_(7) . "// hide the create button";
$addButton[] = Indent::_(7)
. "createButton.style.display = 'none';";
$addButton[] = Indent::_(7) . "// show edit button";
$addButton[] = Indent::_(7)
. "editButton.style.display = 'block';";
$addButton[] = Indent::_(7) . "let url = 'index.php?option="
. $fieldData['component'] . "&view=" . $fieldData['views']
. "&task=" . $fieldData['view']
. ".edit&id='+value+'\".\$refJ.\"';"; // TODO this value may not be the ID
$addButton[] = Indent::_(7)
. "editButton.setAttribute('href', url);";
$addButton[] = Indent::_(6) . "} else {";
$addButton[] = Indent::_(7) . "// show the create button";
$addButton[] = Indent::_(7)
. "createButton.style.display = 'block';";
$addButton[] = Indent::_(7) . "// hide edit button";
$addButton[] = Indent::_(7)
. "editButton.style.display = 'none';";
$addButton[] = Indent::_(6) . "}";
$addButton[] = Indent::_(5) . "}\";";
$addButton[] = Indent::_(3) . "}";
$addButton[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__)
. " check if button was created for " . $fieldData['view']
. " field.";
$addButton[] = Indent::_(3)
. "if (is_array(\$button) && count(\$button) > 0)";
$addButton[] = Indent::_(3) . "{";
$addButton[] = Indent::_(4) . "//" . Line::_(__Line__, __Class__)
. " Load the needed script.";
$addButton[] = Indent::_(4)
. "\$document = Factory::getApplication()->getDocument();";
$addButton[] = Indent::_(4)
. "\$document->addScriptDeclaration(implode(' ',\$script));";
$addButton[] = Indent::_(4) . "//" . Line::_(__Line__, __Class__)
. " return the button attached to input field.";
$addButton[] = Indent::_(4)
. "return '<div class=\"input-group\">' .\$html . implode('',\$button).'</div>';";
$addButton[] = Indent::_(3) . "}";
$addButton[] = Indent::_(2) . "}";
$addButton[] = Indent::_(2) . "return \$html;";
$addButton[] = Indent::_(1) . "}";
return implode(PHP_EOL, $addButton);
}
return '';
}
}

View File

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

View File

@ -0,0 +1,129 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Compiler\Field\JoomlaFour;
use Joomla\CMS\Filesystem\Folder;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Field\CoreFieldInterface;
/**
* Core Joomla Fields
*
* @since 3.2.0
*/
final class CoreField implements CoreFieldInterface
{
/**
* Local Core Joomla Fields
*
* @var array|null
* @since 3.2.0
**/
protected array $fields = [];
/**
* Local Core Joomla Fields Path
*
* @var array
* @since 3.2.0
**/
protected array $paths = [];
/**
* Constructor
*
* @since 3.2.0
*/
public function __construct()
{
// set the path to the form validation fields
$this->paths[] = JPATH_LIBRARIES . '/src/Form/Field';
}
/**
* Get the Array of Existing Validation Field Names
*
* @param bool $lowercase Switch to set fields lowercase
*
* @return array
* @since 3.2.0
*/
public function get(bool $lowercase = false): array
{
if ($this->fields === [])
{
// check if the path exist
foreach ($this->paths as $path)
{
$this->set($path);
}
}
// return fields if found
if ($this->fields !== [])
{
// check if the names should be all lowercase
if ($lowercase)
{
return array_map(
fn($item): string => strtolower((string) $item),
$this->fields
);
}
return $this->fields;
}
// return empty array
return [];
}
/**
* Set the fields found in a path
*
* @param string $path The path to load fields from
* @return void
* @since 3.2.0
*/
private function set(string $path): void
{
// Check if the path exists
if (!Folder::exists($path))
{
return;
}
// Load all PHP files in this path
$fields = Folder::files($path, '\.php$', true, true);
// Process the files to extract field names
$processedFields = array_map(function ($name) {
$fileName = basename($name);
// Remove 'Field.php' if it exists or just '.php' otherwise
if (substr($fileName, -9) === 'Field.php')
{
return str_replace('Field.php', '', $fileName);
}
else
{
return str_replace('.php', '', $fileName);
}
}, $fields);
// Merge with existing fields and remove duplicates
$this->fields = array_unique(array_merge($processedFields, $this->fields));
}
}

View File

@ -0,0 +1,125 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Compiler\Field\JoomlaFour;
use Joomla\CMS\Filesystem\Folder;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Field\CoreRuleInterface;
/**
* Core Joomla Field Rules
*
* @since 3.2.0
*/
final class CoreRule implements CoreRuleInterface
{
/**
* Local Core Joomla Rules
*
* @var array
* @since 3.2.0
**/
protected array $rules = [];
/**
* Local Core Joomla Rules Path
*
* @var string
* @since 3.2.0
**/
protected string $path;
/**
* Constructor
*
* @since 3.2.0
*/
public function __construct()
{
// set the path to the form validation rules
$this->path = JPATH_LIBRARIES . '/src/Form/Rule';
}
/**
* Get the Array of Existing Validation Rule Names
*
* @param bool $lowercase Switch to set rules lowercase
*
* @return array
* @since 3.2.0
*/
public function get(bool $lowercase = false): array
{
if ($this->rules === [])
{
$this->set($this->path);
}
// return rules if found
if ($this->rules !== [])
{
// check if the names should be all lowercase
if ($lowercase)
{
return array_map(
fn($item): string => strtolower((string) $item),
$this->rules
);
}
return $this->rules;
}
// return empty array
return [];
}
/**
* Set the rules found in a path
*
* @param string $path The path to load rules from
* @return void
* @since 3.2.0
*/
private function set(string $path): void
{
// Check if the path exists
if (!Folder::exists($path))
{
return;
}
// Load all PHP files in this path
$rules = Folder::files($path, '\.php$', true, true);
// Process the files to extract rule names
$processedRules = array_map(function ($name) {
$fileName = basename($name);
// Remove 'Rule.php' if it exists or just '.php' otherwise
if (substr($fileName, -8) === 'Rule.php')
{
return str_replace('Rule.php', '', $fileName);
}
else
{
return str_replace('.php', '', $fileName);
}
}, $rules);
// Merge with existing rules and remove duplicates
$this->rules = array_unique(array_merge($processedRules, $this->rules));
}
}

View File

@ -0,0 +1,345 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Compiler\Field\JoomlaFour;
use VDM\Joomla\Componentbuilder\Compiler\Config;
use VDM\Joomla\Componentbuilder\Compiler\Placeholder;
use VDM\Joomla\Componentbuilder\Compiler\Creator\Permission;
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Placefix;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Line;
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Field\InputButtonInterface;
/**
* Compiler Field Input Button
*
* @since 3.2.0
*/
final class InputButton implements InputButtonInterface
{
/**
* The Config Class.
*
* @var Config
* @since 3.2.0
*/
protected Config $config;
/**
* The Placeholder Class.
*
* @var Placeholder
* @since 3.2.0
*/
protected Placeholder $placeholder;
/**
* The Permission Class.
*
* @var Permission
* @since 3.2.0
*/
protected Permission $permission;
/**
* Constructor.
*
* @param Config $config The Config Class.
* @param Placeholder $placeholder The Placeholder Class.
* @param Permission $permission The Permission Class.
*
* @since 3.2.0
*/
public function __construct(Config $config, Placeholder $placeholder,
Permission $permission)
{
$this->config = $config;
$this->placeholder = $placeholder;
$this->permission = $permission;
}
/**
* get Add Button To List Field Input (getInput tweak)
*
* @param array $fieldData The field custom data
*
* @return string of getInput class on success empty string otherwise
* @since 3.2.0
*/
public function get(array $fieldData): string
{
// make sure hte view values are set
if (isset($fieldData['add_button'])
&& ($fieldData['add_button'] === 'true'
|| 1 == $fieldData['add_button'])
&& isset($fieldData['view'])
&& isset($fieldData['views'])
&& StringHelper::check($fieldData['view'])
&& StringHelper::check($fieldData['views']))
{
// set local component
$local_component = "com_" . $this->config->component_code_name;
// check that the component value is set
if (!isset($fieldData['component'])
|| !StringHelper::check(
$fieldData['component']
))
{
$fieldData['component'] = $local_component;
}
// check that the component has the com_ value in it
if (strpos((string) $fieldData['component'], 'com_') === false
|| strpos((string) $fieldData['component'], '=') !== false)
{
$fieldData['component'] = "com_" . $fieldData['component'];
}
// make sure the component is update if # # # or [ [ [ component placeholder is used
if (strpos((string) $fieldData['component'], (string) Placefix::h()) !== false
|| strpos((string) $fieldData['component'], (string) Placefix::b()) !== false) // should not be needed... but
{
$fieldData['component'] = $this->placeholder->update_(
$fieldData['component']
);
}
// get core permissions
$coreLoad = false;
// add ref tags
$refLoad = true;
// fall back on the field component
$component = $fieldData['component'];
// check if we should add ref tags (since it only works well on local views)
if ($local_component !== $component)
{
// do not add ref tags
$refLoad = false;
}
// start building the add buttons/s
$addButton = array();
$addButton[] = PHP_EOL . PHP_EOL . Indent::_(1) . "/**";
$addButton[] = Indent::_(1) . " * Override to add new button";
$addButton[] = Indent::_(1) . " *";
$addButton[] = Indent::_(1)
. " * @return string The field input markup.";
$addButton[] = Indent::_(1) . " *";
$addButton[] = Indent::_(1) . " * @since 3.2";
$addButton[] = Indent::_(1) . " */";
$addButton[] = Indent::_(1) . "protected function getInput()";
$addButton[] = Indent::_(1) . "{";
$addButton[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
. " see if we should add buttons";
$addButton[] = Indent::_(2)
. "\$set_button = \$this->getAttribute('button');";
$addButton[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
. " get html";
$addButton[] = Indent::_(2) . "\$html = parent::getInput();";
$addButton[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
. " if true set button";
$addButton[] = Indent::_(2) . "if (\$set_button === 'true')";
$addButton[] = Indent::_(2) . "{";
$addButton[] = Indent::_(3) . "\$button = array();";
$addButton[] = Indent::_(3) . "\$script = array();";
$addButton[] = Indent::_(3)
. "\$button_code_name = \$this->getAttribute('name');";
$addButton[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__)
. " get the input from url";
$addButton[] = Indent::_(3) . "\$app = Factory::getApplication();";
$addButton[] = Indent::_(3) . "\$jinput = \$app->input;";
$addButton[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__)
. " get the view name & id";
$addButton[] = Indent::_(3)
. "\$values = \$jinput->getArray(array(";
$addButton[] = Indent::_(4) . "'id' => 'int',";
$addButton[] = Indent::_(4) . "'view' => 'word'";
$addButton[] = Indent::_(3) . "));";
$addButton[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__)
. " check if new item";
$addButton[] = Indent::_(3) . "\$ref = '';";
$addButton[] = Indent::_(3) . "\$refJ = '';";
if ($refLoad)
{
$addButton[] = Indent::_(3)
. "if (!is_null(\$values['id']) && strlen(\$values['view']))";
$addButton[] = Indent::_(3) . "{";
$addButton[] = Indent::_(4) . "//" . Line::_(__Line__, __Class__)
. " only load referral if not new item.";
$addButton[] = Indent::_(4)
. "\$ref = '&amp;ref=' . \$values['view'] . '&amp;refid=' . \$values['id'];";
$addButton[] = Indent::_(4)
. "\$refJ = '&ref=' . \$values['view'] . '&refid=' . \$values['id'];";
$addButton[] = Indent::_(4) . "//" . Line::_(__Line__, __Class__)
. " get the return value.";
$addButton[] = Indent::_(4)
. "\$_uri = (string) \Joomla\CMS\Uri\Uri::getInstance();";
$addButton[] = Indent::_(4)
. "\$_return = urlencode(base64_encode(\$_uri));";
$addButton[] = Indent::_(4) . "//" . Line::_(__Line__, __Class__)
. " load return value.";
$addButton[] = Indent::_(4)
. "\$ref .= '&amp;return=' . \$_return;";
$addButton[] = Indent::_(4)
. "\$refJ .= '&return=' . \$_return;";
$addButton[] = Indent::_(3) . "}";
}
else
{
$addButton[] = Indent::_(3)
. "if (!is_null(\$values['id']) && strlen(\$values['view']))";
$addButton[] = Indent::_(3) . "{";
$addButton[] = Indent::_(4) . "//" . Line::_(__Line__, __Class__)
. " only load field details if not new item.";
$addButton[] = Indent::_(4)
. "\$ref = '&amp;field=' . \$values['view'] . '&amp;field_id=' . \$values['id'];";
$addButton[] = Indent::_(4)
. "\$refJ = '&field=' . \$values['view'] . '&field_id=' . \$values['id'];";
$addButton[] = Indent::_(4) . "//" . Line::_(__Line__, __Class__)
. " get the return value.";
$addButton[] = Indent::_(4)
. "\$_uri = (string) \Joomla\CMS\Uri\Uri::getInstance();";
$addButton[] = Indent::_(4)
. "\$_return = urlencode(base64_encode(\$_uri));";
$addButton[] = Indent::_(4) . "//" . Line::_(__Line__, __Class__)
. " load return value.";
$addButton[] = Indent::_(4)
. "\$ref = '&amp;return=' . \$_return;";
$addButton[] = Indent::_(4)
. "\$refJ = '&return=' . \$_return;";
$addButton[] = Indent::_(3) . "}";
}
$addButton[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__)
. " get button label";
$addButton[] = Indent::_(3)
. "\$button_label = trim(\$button_code_name);";
$addButton[] = Indent::_(3)
. "\$button_label = preg_replace('/_+/', ' ', \$button_label);";
$addButton[] = Indent::_(3)
. "\$button_label = preg_replace('/\s+/', ' ', \$button_label);";
$addButton[] = Indent::_(3)
. "\$button_label = preg_replace(\"/[^A-Za-z ]/\", '', \$button_label);";
$addButton[] = Indent::_(3)
. "\$button_label = ucfirst(strtolower(\$button_label));";
$addButton[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__)
. " get user object";
$addButton[] = Indent::_(3) . "\$user = Factory::getApplication()->getIdentity();";
$addButton[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__)
. " only add if user allowed to create " . $fieldData['view'];
// check if the item has permissions.
$addButton[] = Indent::_(3) . "if (\$user->authorise('"
. $this->permission->getGlobal($fieldData['view'], 'core.create')
. "', '" . $component . "') && \$app->isClient('administrator')) // TODO for now only in admin area.";
$addButton[] = Indent::_(3) . "{";
$addButton[] = Indent::_(4) . "//" . Line::_(__Line__, __Class__)
. " build Create button";
$addButton[] = Indent::_(4)
. "\$button[] = '<a id=\"'.\$button_code_name.'Create\" class=\"btn btn-small btn-success hasTooltip\" title=\"'.Text:"
. ":sprintf('" . $this->config->lang_prefix
. "_CREATE_NEW_S', \$button_label).'\" style=\"border-radius: 0px 4px 4px 0px;\"";
$addButton[] = Indent::_(5) . "href=\"index.php?option="
. $fieldData['component'] . "&amp;view=" . $fieldData['view']
. "&amp;layout=edit'.\$ref.'\" >";
$addButton[] = Indent::_(5)
. "<span class=\"icon-new icon-white\"></span></a>';";
$addButton[] = Indent::_(3) . "}";
$addButton[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__)
. " only add if user allowed to edit " . $fieldData['view'];
// check if the item has permissions.
$addButton[] = Indent::_(3) . "if (\$user->authorise('"
. $this->permission->getGlobal($fieldData['view'], 'core.edit')
. "', '" . $component . "') && \$app->isClient('administrator')) // TODO for now only in admin area.";
$addButton[] = Indent::_(3) . "{";
$addButton[] = Indent::_(4) . "//" . Line::_(__Line__, __Class__)
. " build edit button";
$addButton[] = Indent::_(4)
. "\$button[] = '<a id=\"'.\$button_code_name.'Edit\" class=\"btn btn-small hasTooltip\" title=\"'.Text:"
. ":sprintf('" . $this->config->lang_prefix
. "_EDIT_S', \$button_label).'\" style=\"display: none; border-radius: 0px 4px 4px 0px;\" href=\"#\" >";
$addButton[] = Indent::_(5)
. "<span class=\"icon-edit\"></span></a>';";
$addButton[] = Indent::_(4) . "//" . Line::_(__Line__, __Class__)
. " build script";
$addButton[] = Indent::_(4) . "\$script[] = \"";
$addButton[] = Indent::_(5) . "document.addEventListener('DOMContentLoaded', function() {";
$addButton[] = Indent::_(6)
. "document.getElementById('jform_\".\$button_code_name.\"').addEventListener('change', function(e) {";
$addButton[] = Indent::_(7) . "e.preventDefault();";
$addButton[] = Indent::_(7)
. "let \".\$button_code_name.\"Value = this.value;";
$addButton[] = Indent::_(7)
. "\".\$button_code_name.\"Button(\".\$button_code_name.\"Value);";
$addButton[] = Indent::_(6) . "});";
$addButton[] = Indent::_(6)
. "let \".\$button_code_name.\"Value = document.getElementById('jform_\".\$button_code_name.\"').value;";
$addButton[] = Indent::_(6)
. "\".\$button_code_name.\"Button(\".\$button_code_name.\"Value);";
$addButton[] = Indent::_(5) . "});";
$addButton[] = Indent::_(5)
. "function \".\$button_code_name.\"Button(value) {";
$addButton[] = Indent::_(6)
. "var createButton = document.getElementById('\".\$button_code_name.\"Create');";
$addButton[] = Indent::_(6)
. "var editButton = document.getElementById('\".\$button_code_name.\"Edit');";
$addButton[] = Indent::_(6)
. "if (value > 0) {"; // TODO not ideal since value may not be an (int)
$addButton[] = Indent::_(7) . "// hide the create button";
$addButton[] = Indent::_(7)
. "createButton.style.display = 'none';";
$addButton[] = Indent::_(7) . "// show edit button";
$addButton[] = Indent::_(7)
. "editButton.style.display = 'block';";
$addButton[] = Indent::_(7) . "let url = 'index.php?option="
. $fieldData['component'] . "&view=" . $fieldData['views']
. "&task=" . $fieldData['view']
. ".edit&id='+value+'\".\$refJ.\"';"; // TODO this value may not be the ID
$addButton[] = Indent::_(7)
. "editButton.setAttribute('href', url);";
$addButton[] = Indent::_(6) . "} else {";
$addButton[] = Indent::_(7) . "// show the create button";
$addButton[] = Indent::_(7)
. "createButton.style.display = 'block';";
$addButton[] = Indent::_(7) . "// hide edit button";
$addButton[] = Indent::_(7)
. "editButton.style.display = 'none';";
$addButton[] = Indent::_(6) . "}";
$addButton[] = Indent::_(5) . "}\";";
$addButton[] = Indent::_(3) . "}";
$addButton[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__)
. " check if button was created for " . $fieldData['view']
. " field.";
$addButton[] = Indent::_(3)
. "if (is_array(\$button) && count(\$button) > 0)";
$addButton[] = Indent::_(3) . "{";
$addButton[] = Indent::_(4) . "//" . Line::_(__Line__, __Class__)
. " Load the needed script.";
$addButton[] = Indent::_(4)
. "\$document = Factory::getApplication()->getDocument();";
$addButton[] = Indent::_(4)
. "\$document->addScriptDeclaration(implode(' ',\$script));";
$addButton[] = Indent::_(4) . "//" . Line::_(__Line__, __Class__)
. " return the button attached to input field.";
$addButton[] = Indent::_(4)
. "return '<div class=\"input-group\">' .\$html . implode('',\$button).'</div>';";
$addButton[] = Indent::_(3) . "}";
$addButton[] = Indent::_(2) . "}";
$addButton[] = Indent::_(2) . "return \$html;";
$addButton[] = Indent::_(1) . "}";
return implode(PHP_EOL, $addButton);
}
return '';
}
}

Some files were not shown because too many files have changed in this diff Show More